feat: build, cli, devtools, sdk, docs...
* feat: nocobase build * chore: update build scripts * chore: update build scripts * chore(versions): 😊 publish v0.7.0-alpha.33 * chore: independent version * chore: nocobase build * chore(versions): 😊 publish v0.7.0-alpha.34 * feat: nocobase-cli * feat: nocobase-cli * chore: update dependencies * feat: improve code * refactor: create-nocobase-app * chore(versions): 😊 publish v0.7.0-alpha.35 * feat: @nocobase/devtools * chore(versions): 😊 publish v0.7.0-alpha.36 * chore: update dependencies * chore(versions): 😊 publish v0.7.0-alpha.37 * feat: improve code * chore(versions): 😊 publish v0.7.0-alpha.38 * feat: improve code * chore(versions): 😊 publish v0.7.0-alpha.39 * feat: update deps * chore(versions): 😊 publish v0.7.0-alpha.40 * chore: update devDependencies * chore(versions): 😊 publish v0.7.0-alpha.41 * fix: postinstall * chore(versions): 😊 publish v0.7.0-alpha.42 * chore: improve code * chore(versions): 😊 publish v0.7.0-alpha.43 * chore: execa * chore(versions): 😊 publish v0.7.0-alpha.44 * chore(cli): allow unknown option * chore(versions): 😊 publish v0.7.0-alpha.45 * fix: default envs * chore(versions): 😊 publish v0.7.0-alpha.45 * fix: package argument for build command * chore(versions): 😊 publish v0.7.0-alpha.46 * fix: improve code * chore(versions): 😊 publish v0.7.0-alpha.48 * feat: clean & doc * chore(versions): 😊 publish v0.7.0-alpha.49 * feat: compilation tips * feat: upgrade command * chore(versions): 😊 publish v0.7.0-alpha.50 * fix: unexpected token ] in JSON * chore(versions): 😊 publish v0.7.0-alpha.51 * fix: upgrade command * chore(versions): 😊 publish v0.7.0-alpha.52 * fix: remove export action from available action * fix: db sync after upgrade * chore(versions): 😊 publish v0.7.0-alpha.53 * feat: upgrade log * chore(versions): 😊 publish v0.7.0-alpha.54 * docs: updates * feat: updates * docs(cli): update usage description * feat: updates * docs: updates * docs: updates * docs: toc * feat: sdk * docs: updates * docs: updates * docs: updates * Update index.md * docs: updates * Update release-notes.md * Update roadmap.md * Update index.md * Update contributing.md * Update contributing.md * Update index.md * Update index.md * Update nocobase-cli.md * Update nocobase-cli.md * fix: user plugin initialization data * Update env.md * Update env.md * Update directory-structure.md * Update index.md * Update action-api.md * Update filter-operators.md * docs: update thanks.md * Update index.md * Update javascript-sdk.md * Update rest-api.md * Update installation.md * Update installation.md * Update upgrading.md * Update upgrading.md * Update upgrading.md * Update installation.md * Update installation.md * Create release-notes.md * Update release-notes.md * feat: updates * feat: update docs * feat: update release-notes.md * feat: switch language * feat: updates * Add files via upload * Add files via upload * Update important-features.md * Update thanks.md * feat: nocobase postinstall * Update index.md * Create why-different.md * Update why-different.md * Create who-is-for.md * Rename who-is-for.md to who.md * feat: update docs * Rename why-different.md to why.md * Update why.md * Update menus.ts * Update why-nocobase.md * Create who.md * Create why.md * feat: updates * chore(versions): 😊 publish v0.7.0-alpha.55 * feat: tips * Update who.md * Update who.md * feat: update docs * feat: update doc menus * fix: plugin client dist * docs: update contributing.md * docs: update readme.md * docs: update readme.md * docs: update readme.md * Update functional-zoning.md * fix: br Co-authored-by: Zhou <zhou.working@gmail.com>
12
.buildrc.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export default {
|
||||||
|
target: 'node',
|
||||||
|
cjs: { type: 'babel', lazy: true },
|
||||||
|
excludePkgs: [
|
||||||
|
'core/build',
|
||||||
|
'core/cli',
|
||||||
|
'core/create-nocobase-app',
|
||||||
|
'core/devtools',
|
||||||
|
'core/dumi-theme-nocobase',
|
||||||
|
'app/client',
|
||||||
|
],
|
||||||
|
};
|
22
.env.example
@ -7,17 +7,14 @@ VERDACCIO_PORT=10104
|
|||||||
|
|
||||||
################# NOCOBASE APPLICATION #################
|
################# NOCOBASE APPLICATION #################
|
||||||
|
|
||||||
NOCOBASE_ENV=development
|
APP_ENV=development
|
||||||
|
APP_PORT=13000
|
||||||
|
APP_KEY=test-key
|
||||||
|
|
||||||
SERVER_PORT=3000
|
API_BASE_PATH=/api/
|
||||||
|
API_BASE_URL=
|
||||||
|
|
||||||
# api base path endpoint for app(web)
|
PROXY_TARGET_URL=
|
||||||
SERVER_BASE_PATH=/api/
|
|
||||||
|
|
||||||
# api server access point for app(web when build)
|
|
||||||
SERVER_BASE_URL=
|
|
||||||
|
|
||||||
JWT_SECRET=09f26e402586e2faa8da4c98a35f1b20d6b033c60
|
|
||||||
|
|
||||||
################# DATABASE #################
|
################# DATABASE #################
|
||||||
|
|
||||||
@ -28,15 +25,18 @@ DB_STORAGE=storage/db/nocobase.sqlite
|
|||||||
# DB_DATABASE=postgres
|
# DB_DATABASE=postgres
|
||||||
# DB_USER=nocobase
|
# DB_USER=nocobase
|
||||||
# DB_PASSWORD=nocobase
|
# DB_PASSWORD=nocobase
|
||||||
# DB_LOG_SQL=on
|
# DB_LOGGING=on
|
||||||
|
|
||||||
################# STORAGE (Initialization only) #################
|
################# STORAGE (Initialization only) #################
|
||||||
|
|
||||||
|
INIT_ROOT_EMAIL=admin@nocobase.com
|
||||||
|
INIT_ROOT_PASSWORD=admin123
|
||||||
|
INIT_ROOT_NICKNAME=Super Admin
|
||||||
|
|
||||||
# local or ali-oss
|
# local or ali-oss
|
||||||
DEFAULT_STORAGE_TYPE=local
|
DEFAULT_STORAGE_TYPE=local
|
||||||
|
|
||||||
# LOCAL STORAGE
|
# LOCAL STORAGE
|
||||||
LOCAL_STORAGE_USE_STATIC_SERVER=true
|
|
||||||
LOCAL_STORAGE_BASE_URL=
|
LOCAL_STORAGE_BASE_URL=
|
||||||
LOCAL_STORAGE_DEST=storage/uploads
|
LOCAL_STORAGE_DEST=storage/uploads
|
||||||
|
|
||||||
|
7
.github/workflows/node-ci.yml
vendored
@ -40,10 +40,9 @@ jobs:
|
|||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
- run: yarn bootstrap
|
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Test with postgres
|
- name: Test with postgres
|
||||||
run: yarn test -i
|
run: yarn test
|
||||||
env:
|
env:
|
||||||
DB_DIALECT: postgres
|
DB_DIALECT: postgres
|
||||||
DB_HOST: postgres
|
DB_HOST: postgres
|
||||||
@ -52,12 +51,12 @@ jobs:
|
|||||||
DB_PASSWORD: password
|
DB_PASSWORD: password
|
||||||
DB_DATABASE: nocobase
|
DB_DATABASE: nocobase
|
||||||
- name: Test with Sqlite
|
- name: Test with Sqlite
|
||||||
run: yarn test -i
|
run: yarn test
|
||||||
env:
|
env:
|
||||||
DB_DIALECT: sqlite
|
DB_DIALECT: sqlite
|
||||||
DB_STORAGE: /tmp/db.sqlite
|
DB_STORAGE: /tmp/db.sqlite
|
||||||
- name: Test with MySQL
|
- name: Test with MySQL
|
||||||
run: yarn test -i
|
run: yarn test
|
||||||
env:
|
env:
|
||||||
DB_DIALECT: mysql
|
DB_DIALECT: mysql
|
||||||
DB_HOST: mysql
|
DB_HOST: mysql
|
||||||
|
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
lib/
|
lib/
|
||||||
!packages/core/create-nocobase-app/lib
|
|
||||||
esm/
|
esm/
|
||||||
|
es/
|
||||||
.env
|
.env
|
||||||
.DS_Store
|
.DS_Store
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
99
.umirc.ts
@ -1,14 +1,103 @@
|
|||||||
|
import transformer from '@umijs/preset-dumi/lib/transformer';
|
||||||
import { defineConfig } from 'dumi';
|
import { defineConfig } from 'dumi';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import menus from './docs/menus';
|
||||||
|
|
||||||
|
const lang = process.env.DOC_LANG || 'en-US';
|
||||||
|
|
||||||
|
console.log('process.env.DOC_LANG', process.env.DOC_LANG);
|
||||||
|
|
||||||
|
const findFilePath = (filename, lang) => {
|
||||||
|
const filePath = path.resolve(__dirname, `docs/${lang}/${filename}`);
|
||||||
|
if (fs.existsSync(`${filePath}.md`)) {
|
||||||
|
return `${filePath}.md`;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const markdown = (filename, lang) => {
|
||||||
|
const filePath = findFilePath(filename, lang);
|
||||||
|
if (!filePath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return transformer.markdown(fs.readFileSync(filePath, 'utf8').toString(), filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPath = (value: string) => {
|
||||||
|
if (!value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const keys = value.split('/');
|
||||||
|
if (keys.pop() === 'index') {
|
||||||
|
return keys.join('/') || '/';
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTitle = (item, lang) => {
|
||||||
|
if (lang) {
|
||||||
|
return item[`title.${lang}`] || item.title;
|
||||||
|
}
|
||||||
|
return item.title;
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseMenuItems = (items, lang = null) => {
|
||||||
|
const menuItems = [];
|
||||||
|
for (const item of items) {
|
||||||
|
if (typeof item === 'string') {
|
||||||
|
const result = markdown(item, lang);
|
||||||
|
if (result) {
|
||||||
|
menuItems.push({
|
||||||
|
title: result.meta.title,
|
||||||
|
disabled: result.meta.disabled,
|
||||||
|
path: getPath(item),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (item.children) {
|
||||||
|
menuItems.push({
|
||||||
|
...item,
|
||||||
|
title: getTitle(item, lang),
|
||||||
|
children: parseMenuItems(item.children, lang),
|
||||||
|
});
|
||||||
|
} else if (item.path) {
|
||||||
|
menuItems.push({
|
||||||
|
...item,
|
||||||
|
title: getTitle(item, lang),
|
||||||
|
path: getPath(item.path),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
menuItems.push({
|
||||||
|
title: getTitle(item, lang),
|
||||||
|
...item,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuItems;
|
||||||
|
};
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
title: 'NocoBase',
|
title: 'NocoBase',
|
||||||
favicon: 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
|
outputPath: `./docs/dist/${lang}`,
|
||||||
logo: 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
|
|
||||||
outputPath: 'docs-dist',
|
|
||||||
mode: 'site',
|
mode: 'site',
|
||||||
resolve: {
|
resolve: {
|
||||||
includes: ['docs', 'packages/client'],
|
includes: [`./docs/${lang}`],
|
||||||
},
|
},
|
||||||
|
locales: [[lang, lang]],
|
||||||
hash: true,
|
hash: true,
|
||||||
// more config: https://d.umijs.org/config
|
logo: 'https://www.nocobase.com/images/logo.png',
|
||||||
|
navs: [
|
||||||
|
{
|
||||||
|
title: 'Docs',
|
||||||
|
path: '/',
|
||||||
|
hidden: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'GitHub',
|
||||||
|
path: 'https://github.com/nocobase/nocobase',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
menus: {
|
||||||
|
'/': parseMenuItems(menus, lang),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
170
README.md
@ -64,172 +64,16 @@ NocoBase is designed for you if you have the following needs.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
NocoBase supports both Docker and CLI installation methods. Docker is recommended if you are new to NocoBase.
|
NocoBase supports three installation methods:
|
||||||
|
|
||||||
### Docker (👍Recommended)
|
- <a target="_blank" href="https://docs.nocobase.com/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
||||||
|
|
||||||
#### 0. Before start
|
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
||||||
|
|
||||||
⚡⚡ Please make sure you have installed [Docker](https://docs.docker.com/get-docker/)
|
- <a target="_blank" href="https://docs.nocobase.com/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
||||||
|
|
||||||
#### 1. Download NocoBase
|
The business code of the project is completely independent and supports low-code development.
|
||||||
|
|
||||||
Download with Git (or Download Zip,and extract it to the nocobase directory)
|
- <a target="_blank" href="https://docs.nocobase.com/getting-started/installation/git-clone">Installing from Git source code</a>
|
||||||
|
|
||||||
```bash
|
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
||||||
git clone https://github.com/nocobase/nocobase.git nocobase
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. Select database (choose one)
|
|
||||||
|
|
||||||
Supports SQLite, MySQL, PostgreSQL
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# SQLite
|
|
||||||
cd nocobase/docker/app-sqlite
|
|
||||||
# MySQL
|
|
||||||
cd nocobase/docker/app-mysql
|
|
||||||
# PostgreSQL
|
|
||||||
cd nocobase/docker/app-postgres
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3. Install and start NocoBase
|
|
||||||
|
|
||||||
It may take dozens of seconds
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# run in the background
|
|
||||||
$ docker-compose up -d
|
|
||||||
# view app logs
|
|
||||||
$ docker-compose logs app
|
|
||||||
|
|
||||||
app-sqlite-app-1 | nginx started
|
|
||||||
app-sqlite-app-1 | yarn run v1.22.15
|
|
||||||
app-sqlite-app-1 | $ cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js install -s
|
|
||||||
app-sqlite-app-1 | Done in 2.72s.
|
|
||||||
app-sqlite-app-1 | yarn run v1.22.15
|
|
||||||
app-sqlite-app-1 | $ pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: Launching in no daemon mode
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] starting in -fork mode-
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] online
|
|
||||||
app-sqlite-app-1 | 🚀 NocoBase server running at: http://localhost:13000/
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. Log in to NocoBase
|
|
||||||
|
|
||||||
Open [http://localhost:13000](http://localhost:13000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
|
|
||||||
|
|
||||||
|
|
||||||
### CLI
|
|
||||||
|
|
||||||
#### 0. Before start
|
|
||||||
|
|
||||||
Please make sure you have Node.js 12.x or above installed. You can download and install the latest LTS version from the official website. It is recommended to use nvm (or nvm-windows for Win systems) to manage Node.js versions if you plan to work with Node.js for a long time.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ node -v
|
|
||||||
|
|
||||||
v16.13.2
|
|
||||||
```
|
|
||||||
|
|
||||||
yarn package manager is recommend.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm install --global yarn
|
|
||||||
$ yarn -v
|
|
||||||
|
|
||||||
1.22.10
|
|
||||||
```
|
|
||||||
|
|
||||||
Also, make sure you have configured and started the required database, which supports SQLite, MySQL, PostgreSQL.
|
|
||||||
|
|
||||||
#### 1. Create a NocoBase project
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# SQLite
|
|
||||||
yarn create nocobase-app my-nocobase-app -d sqlite
|
|
||||||
# MySQL
|
|
||||||
yarn create nocobase-app my-nocobase-app -d mysql \
|
|
||||||
-e DB_HOST=localhost \
|
|
||||||
-e DB_PORT=3356 \
|
|
||||||
-e DB_DATABASE=nocobase \
|
|
||||||
-e DB_USER=nocobase \
|
|
||||||
-e DB_PASSWORD=nocobase
|
|
||||||
# PostgreSQL
|
|
||||||
yarn create nocobase-app my-nocobase-app -d postgres \
|
|
||||||
-e DB_HOST=localhost \
|
|
||||||
-e DB_PORT=5432 \
|
|
||||||
-e DB_DATABASE=nocobase \
|
|
||||||
-e DB_USER=nocobase \
|
|
||||||
-e DB_PASSWORD=nocobase
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. Switch to the project directory
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd my-nocobase-app
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3. Install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn install
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. Install & Start NocoBase
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn nocobase install --lang=en-US
|
|
||||||
yarn start
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 5. Log in to NocoBase
|
|
||||||
|
|
||||||
Open [http://localhost:8000](http://localhost:8000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
- Fork the source code to your own repository
|
|
||||||
- Modify source code
|
|
||||||
- Submit pull request
|
|
||||||
|
|
||||||
### Download
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Replace the following git address with your own repo
|
|
||||||
git clone https://github.com/nocobase/nocobase.git
|
|
||||||
cd nocobase
|
|
||||||
cp .env.example .env
|
|
||||||
yarn install
|
|
||||||
```
|
|
||||||
|
|
||||||
### Development and Testing
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Install NocoBase
|
|
||||||
yarn nocobase install --lang=en-US
|
|
||||||
# Start NocoBase
|
|
||||||
yarn start
|
|
||||||
# Run all tests
|
|
||||||
yarn test
|
|
||||||
# Run all test files in the folder
|
|
||||||
yarn test <dir>
|
|
||||||
# Run a single test file
|
|
||||||
yarn test <file>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Documentation preview
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Start documentation
|
|
||||||
yarn doc --lang=zh-CN
|
|
||||||
yarn doc --lang=en-US
|
|
||||||
```
|
|
||||||
|
|
||||||
The documentation is in the docs directory and follows Markdown syntax
|
|
||||||
|
|
||||||
```bash
|
|
||||||
|- /docs/
|
|
||||||
|- en-US
|
|
||||||
|- zh-CN
|
|
||||||
```
|
|
||||||
|
196
README.zh-CN.md
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
![](https://www.nocobase.com/images/demo/11.png)
|
![](https://www.nocobase.com/images/demo/11.png)
|
||||||
|
|
||||||
NocoBase 是什么
|
## NocoBase 是什么
|
||||||
----------
|
|
||||||
NocoBase 是一个极易扩展的开源无代码开发平台。
|
NocoBase 是一个极易扩展的开源无代码开发平台。
|
||||||
无需编程,使用 NocoBase 搭建自己的协作平台、管理系统,只需要几分钟时间。
|
无需编程,使用 NocoBase 搭建自己的协作平台、管理系统,只需要几分钟时间。
|
||||||
|
|
||||||
@ -13,6 +13,9 @@ https://cn.nocobase.com/
|
|||||||
在线体验:
|
在线体验:
|
||||||
https://demo-cn.nocobase.com/new
|
https://demo-cn.nocobase.com/new
|
||||||
|
|
||||||
|
文档:
|
||||||
|
https://docs-cn.nocobase.com/
|
||||||
|
|
||||||
## 适用场景
|
## 适用场景
|
||||||
|
|
||||||
如果你有以下需求,NocoBase 就是为你设计的:
|
如果你有以下需求,NocoBase 就是为你设计的:
|
||||||
@ -24,8 +27,8 @@ https://demo-cn.nocobase.com/new
|
|||||||
- 私有部署,掌控全部代码和数据
|
- 私有部署,掌控全部代码和数据
|
||||||
- 可免费使用,也可以付费获得更多技术支持
|
- 可免费使用,也可以付费获得更多技术支持
|
||||||
|
|
||||||
为什么选择 NocoBase
|
## 为什么选择 NocoBase
|
||||||
----------
|
|
||||||
- **开源免费**
|
- **开源免费**
|
||||||
- 采用 Apache-2.0 许可协议,不限制商业使用
|
- 采用 Apache-2.0 许可协议,不限制商业使用
|
||||||
- 拥有全部代码,私有化部署,保障数据私有和安全
|
- 拥有全部代码,私有化部署,保障数据私有和安全
|
||||||
@ -50,14 +53,13 @@ https://demo-cn.nocobase.com/new
|
|||||||
- 渐进式开发,上手难度低,对新人友好
|
- 渐进式开发,上手难度低,对新人友好
|
||||||
- 不绑架、不强依赖,可任意组合使用或扩展,可用于现有项目中
|
- 不绑架、不强依赖,可任意组合使用或扩展,可用于现有项目中
|
||||||
|
|
||||||
NocoBase 架构
|
## NocoBase 架构
|
||||||
----------
|
|
||||||
![](https://www.nocobase.com/images/NocoBaseMindMapLite.png)
|
![](https://www.nocobase.com/images/NocoBaseMindMapLite.png)
|
||||||
|
|
||||||
[点此查看完整图片](https://www.nocobase.com/images/NocoBaseMindMap.png)
|
[点此查看完整图片](https://www.nocobase.com/images/NocoBaseMindMap.png)
|
||||||
|
|
||||||
联系
|
## 联系
|
||||||
----------
|
|
||||||
|
|
||||||
如果你希望加入我们一起开发 NocoBase,或者需要提供商业服务,欢迎通过邮件联系我们:hello@nocobase.com
|
如果你希望加入我们一起开发 NocoBase,或者需要提供商业服务,欢迎通过邮件联系我们:hello@nocobase.com
|
||||||
|
|
||||||
@ -67,180 +69,16 @@ NocoBase 架构
|
|||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
NocoBase 支持 Docker 和 CLI 两种安装方法,如果你是新人推荐使用 Docker 安装。
|
NocoBase 支持三种安装方式:
|
||||||
|
|
||||||
### Docker (👍Recommended)
|
- <a target="_blank" href="https://docs-cn.nocobase.com/getting-started/installation/docker-compose">Docker 安装(推荐)</a>
|
||||||
|
|
||||||
#### 0. 先决条件
|
适合无代码场景,不需要写代码。升级时,下载最新镜像并重启即可。
|
||||||
|
|
||||||
⚡⚡ 请确保你已经安装了 [Docker](https://docs.docker.com/get-docker/)
|
- <a target="_blank" href="https://docs-cn.nocobase.com/getting-started/installation/create-nocobase-app">create-nocobase-app 安装</a>
|
||||||
|
|
||||||
#### 1. 将 NocoBase 下载到本地
|
项目的业务代码完全独立,支持低代码开发。
|
||||||
|
|
||||||
使用 Git 下载(或直接[下载 Zip 包](https://github.com/nocobase/nocobase/archive/refs/heads/main.zip),并解压到 nocobase 目录下)
|
- <a target="_blank" href="https://docs-cn.nocobase.com/getting-started/installation/git-clone">Git 源码安装</a>
|
||||||
|
|
||||||
```bash
|
如果你想体验最新未发布版本,或者想参与贡献,需要在源码上进行修改、调试,建议选择这种安装方式,对开发技术水平要求较高,如果代码有更新,可以走 git 流程拉取最新代码。
|
||||||
git clone https://github.com/nocobase/nocobase.git nocobase
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. 选择数据库(任选其一)
|
|
||||||
|
|
||||||
支持 SQLite、MySQL、PostgreSQL 数据库
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# SQLite
|
|
||||||
cd nocobase/docker/app-sqlite
|
|
||||||
# MySQL
|
|
||||||
cd nocobase/docker/app-mysql
|
|
||||||
# PostgreSQL
|
|
||||||
cd nocobase/docker/app-postgres
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3. 安装并启动 NocoBase
|
|
||||||
|
|
||||||
安装过程可能需要等待几十秒钟
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 在后台运行
|
|
||||||
$ docker-compose up -d
|
|
||||||
# 查看 app 进程的情况
|
|
||||||
$ docker-compose logs app
|
|
||||||
|
|
||||||
app-sqlite-app-1 | nginx started
|
|
||||||
app-sqlite-app-1 | yarn run v1.22.15
|
|
||||||
app-sqlite-app-1 | $ cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js install -s
|
|
||||||
app-sqlite-app-1 | Done in 2.72s.
|
|
||||||
app-sqlite-app-1 | yarn run v1.22.15
|
|
||||||
app-sqlite-app-1 | $ pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: Launching in no daemon mode
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] starting in -fork mode-
|
|
||||||
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] online
|
|
||||||
app-sqlite-app-1 | 🚀 NocoBase server running at: http://localhost:13000/
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. 登录 NocoBase
|
|
||||||
|
|
||||||
使用浏览器打开 http://localhost:13000/ 初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。
|
|
||||||
|
|
||||||
### CLI
|
|
||||||
|
|
||||||
#### 0. 先决条件
|
|
||||||
|
|
||||||
请确保你已经安装了 Node.js 12.x 或以上版本,如果你没有安装 Node.js 可以从官网下载并安装最新的 LTS 版本。如果你打算长期与 Node.js 打交道,推荐使用 nvm(Win 系统可以使用 nvm-windows )来管理 Node.js 版本。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ node -v
|
|
||||||
|
|
||||||
v16.13.2
|
|
||||||
```
|
|
||||||
|
|
||||||
推荐使用 yarn 包管理器。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm install --global yarn
|
|
||||||
$ yarn -v
|
|
||||||
|
|
||||||
1.22.10
|
|
||||||
```
|
|
||||||
|
|
||||||
由于国内网络环境的原因,强烈建议你更换国内镜像。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ yarn config set registry https://registry.npmmirror.com/
|
|
||||||
$ yarn config set sqlite3_binary_host_mirror https://npmmirror.com/mirrors/sqlite3/
|
|
||||||
```
|
|
||||||
|
|
||||||
最后,请确保你已经配置并启动所需数据库,数据库支持 SQLite(无需安装启动)、MySQL、PostgreSQL。
|
|
||||||
|
|
||||||
#### 1. 创建 NocoBase 项目
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# SQLite
|
|
||||||
yarn create nocobase-app my-nocobase-app -d sqlite
|
|
||||||
# MySQL
|
|
||||||
yarn create nocobase-app my-nocobase-app -d mysql \
|
|
||||||
-e DB_HOST=localhost \
|
|
||||||
-e DB_PORT=3356 \
|
|
||||||
-e DB_DATABASE=nocobase \
|
|
||||||
-e DB_USER=nocobase \
|
|
||||||
-e DB_PASSWORD=nocobase
|
|
||||||
# PostgreSQL
|
|
||||||
yarn create nocobase-app my-nocobase-app -d postgres \
|
|
||||||
-e DB_HOST=localhost \
|
|
||||||
-e DB_PORT=5432 \
|
|
||||||
-e DB_DATABASE=nocobase \
|
|
||||||
-e DB_USER=nocobase \
|
|
||||||
-e DB_PASSWORD=nocobase
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. 切换目录
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd my-nocobase-app
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3. 安装依赖
|
|
||||||
|
|
||||||
📢 由于网络环境、系统配置等因素影响,接下来这一步骤可能需要十几分钟时间。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn install
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. 安装并启动 NocoBase
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn nocobase install --lang=zh-CN
|
|
||||||
yarn start
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 5. 登录 NocoBase
|
|
||||||
|
|
||||||
使用浏览器打开 http://localhost:13000/ 初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。
|
|
||||||
|
|
||||||
## 贡献
|
|
||||||
|
|
||||||
- Fork 源代码到自己的仓库
|
|
||||||
- 修改源代码
|
|
||||||
- 提交 Pull Request
|
|
||||||
|
|
||||||
### 下载项目
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 替换为自己的仓库地址
|
|
||||||
git clone https://github.com/nocobase/nocobase.git
|
|
||||||
cd nocobase
|
|
||||||
cp .env.example .env
|
|
||||||
yarn install
|
|
||||||
```
|
|
||||||
|
|
||||||
### 应用开发与测试
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 安装
|
|
||||||
yarn nocobase install --lang=zh-CN
|
|
||||||
# 启动应用
|
|
||||||
yarn start
|
|
||||||
# 运行所有测试
|
|
||||||
yarn test
|
|
||||||
# 运行文件夹下所有测试文件
|
|
||||||
yarn test <dir>
|
|
||||||
# 运行单个测试文件
|
|
||||||
yarn test <file>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 文档预览
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 启动文档
|
|
||||||
yarn doc --lang=zh-CN
|
|
||||||
yarn doc --lang=en-US
|
|
||||||
```
|
|
||||||
|
|
||||||
文档在 docs 目录下,遵循 Markdown 语法
|
|
||||||
|
|
||||||
```bash
|
|
||||||
|- /docs/
|
|
||||||
|- en-US
|
|
||||||
|- zh-CN
|
|
||||||
```
|
|
||||||
|
@ -57,6 +57,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
expose:
|
expose:
|
||||||
- ${SERVER_PORT}
|
- ${APP_PORT}
|
||||||
ports:
|
ports:
|
||||||
- "${SERVER_PORT}:${SERVER_PORT}"
|
- "${APP_PORT}:${APP_PORT}"
|
47
docs/en-US/contributing.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
- Fork the source code to your own repository
|
||||||
|
- Modify source code
|
||||||
|
- Submit pull request
|
||||||
|
|
||||||
|
## Download
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Replace the following git address with your own repo
|
||||||
|
git clone https://github.com/nocobase/nocobase.git
|
||||||
|
cd nocobase
|
||||||
|
yarn install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development and Testing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install and start the application
|
||||||
|
yarn dev
|
||||||
|
# Run all tests
|
||||||
|
yarn test
|
||||||
|
# Run all test files in the folder
|
||||||
|
yarn test <dir>
|
||||||
|
# Run a single test file
|
||||||
|
yarn test <file>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation preview
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start documentation
|
||||||
|
yarn doc --lang=zh-CN
|
||||||
|
yarn doc --lang=en-US
|
||||||
|
```
|
||||||
|
|
||||||
|
The documentation is in the docs directory and follows Markdown syntax
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|- /docs/
|
||||||
|
|- en-US
|
||||||
|
|- zh-CN
|
||||||
|
```
|
||||||
|
|
||||||
|
## Others
|
||||||
|
|
||||||
|
For more CLI instructions, please [refer to the NocoBase CLI chapter](./development/nocobase-cli.md)
|
89
docs/en-US/development/directory-structure.md
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
# Directory structure
|
||||||
|
|
||||||
|
## Application scaffolding
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn create nocobase-app my-nocobase-app
|
||||||
|
```
|
||||||
|
|
||||||
|
The directory structure of the application scaffold created by `create-nocobase-app` is as follows
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── my-nocobase-app
|
||||||
|
├── packages # Use the Monorepo approach to manage code, dividing different modules into packages
|
||||||
|
├── app
|
||||||
|
├── client # Client-side modules
|
||||||
|
├── server # Server-side modules
|
||||||
|
├── plugins # Plugins directory
|
||||||
|
├── storages # For database files, attachments, cache, etc.
|
||||||
|
├── db
|
||||||
|
├── .env # Environment variables
|
||||||
|
├── .buildrc.ts # Packaging configuration for packages, supports cjs, esm and umd packaging.
|
||||||
|
├── jest.config.js
|
||||||
|
├── jest.setup.ts
|
||||||
|
├── lerna.json
|
||||||
|
├── package.json
|
||||||
|
├── tsconfig.jest.json
|
||||||
|
├── tsconfig.json
|
||||||
|
├── tsconfig.server.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### packages directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── packages
|
||||||
|
├── app
|
||||||
|
├── client
|
||||||
|
├── public
|
||||||
|
├── src
|
||||||
|
├── pages
|
||||||
|
├── index.tsx
|
||||||
|
├── .umirc.ts
|
||||||
|
├── package.json
|
||||||
|
├── server
|
||||||
|
├── src
|
||||||
|
├── config
|
||||||
|
├── index.ts
|
||||||
|
├── package.json
|
||||||
|
├── /plugins
|
||||||
|
├── my-plugin
|
||||||
|
├── src
|
||||||
|
├── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
NocoBase uses the Monorepo approach to manage the code, dividing the different modules into different packages.
|
||||||
|
|
||||||
|
- `app/client` is the client-side module of the application, built on [umi](https://umijs.org).
|
||||||
|
- `app/server` is the server-side module of the application.
|
||||||
|
- `plugins/*` directory can hold various plugins.
|
||||||
|
|
||||||
|
### storages directory
|
||||||
|
|
||||||
|
Used to store database files, attachments, cache, etc.
|
||||||
|
|
||||||
|
### .env file
|
||||||
|
|
||||||
|
Environment variables
|
||||||
|
|
||||||
|
### .buildrc.ts file
|
||||||
|
|
||||||
|
Packaging configuration for packages, supports cjs, esm and umd packaging.
|
||||||
|
|
||||||
|
## Plugins scaffolding
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase create-plugin my-plugin
|
||||||
|
```
|
||||||
|
|
||||||
|
The plugin scaffolding directory initialized by `nocobase create-plugin` is as follows
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── my-nocobase-app
|
||||||
|
├── packages
|
||||||
|
├── plugins
|
||||||
|
├── my-plugin
|
||||||
|
├── src
|
||||||
|
├── client
|
||||||
|
├── server
|
||||||
|
├── package.json
|
||||||
|
```
|
207
docs/en-US/development/env.md
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
# Environment variables
|
||||||
|
|
||||||
|
## Global environment variables
|
||||||
|
|
||||||
|
Saved in the `.env` file
|
||||||
|
|
||||||
|
### APP_ENV
|
||||||
|
|
||||||
|
Application environment, default value `development`, options include
|
||||||
|
|
||||||
|
- `production` production environment
|
||||||
|
- `development` development environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_ENV=production
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_HOST
|
||||||
|
|
||||||
|
Application host, default value `0.0.0.0`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_HOST=192.168.3.154
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_PORT
|
||||||
|
|
||||||
|
Application port, default value `13000`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_PORT=13000
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_KEY
|
||||||
|
|
||||||
|
Secret key for scenarios such as jwt
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_KEY=app-key-test
|
||||||
|
```
|
||||||
|
|
||||||
|
### API_BASE_PATH
|
||||||
|
|
||||||
|
NocoBase API address prefix, default value `/api/`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
API_BASE_PATH=/api/
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_DIALECT
|
||||||
|
|
||||||
|
Database type, default value `sqlite`,options include
|
||||||
|
|
||||||
|
- `sqlite`
|
||||||
|
- `mysql`
|
||||||
|
- `postgres`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_DIALECT=mysql
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_STORAGE
|
||||||
|
|
||||||
|
Database file path (configured when using SQLite)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Relative path
|
||||||
|
DB_HOST=storage/db/nocobase.db
|
||||||
|
# Absolute path
|
||||||
|
DB_HOST=/your/path/nocobase.db
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_HOST
|
||||||
|
|
||||||
|
Database host (required when using MySQL or PostgreSQL)
|
||||||
|
|
||||||
|
Default value `localhost`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_HOST=localhost
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_PORT
|
||||||
|
|
||||||
|
Database port (required when using MySQL or PostgreSQL)
|
||||||
|
|
||||||
|
- MySQL default port 3356
|
||||||
|
- PostgreSQL default port 5432
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_PORT=3356
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_DATABASE
|
||||||
|
|
||||||
|
Database name (required when using MySQL or PostgreSQL)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_DATABASE=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_USER
|
||||||
|
|
||||||
|
Database user (required when using MySQL or PostgreSQL)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_USER=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_PASSWORD
|
||||||
|
|
||||||
|
Database password (required when using MySQL or PostgreSQL)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_PASSWORD=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_TABLE_PREFIX
|
||||||
|
|
||||||
|
Data Table Prefix
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_TABLE_PREFIX=nocobase_
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_LOGGING
|
||||||
|
|
||||||
|
Switching of logs, default value `off`, options include:
|
||||||
|
|
||||||
|
- `on` On
|
||||||
|
- `off` Off
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_LOGGING=on
|
||||||
|
```
|
||||||
|
|
||||||
|
## Temporary environment variables
|
||||||
|
|
||||||
|
When installing NocoBase, you can assist in the installation by setting temporary environment variables, such as
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=en-US \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
INIT_ROOT_NICKNAME="Super Admin" \
|
||||||
|
nocobase install
|
||||||
|
|
||||||
|
# Equivalent to
|
||||||
|
yarn nocobase install \
|
||||||
|
--lang=en-US \
|
||||||
|
--root-email=demo@nocobase.com \
|
||||||
|
--root-password=admin123 \
|
||||||
|
--root-nickname="Super Admin"
|
||||||
|
|
||||||
|
# Equivalent to
|
||||||
|
yarn nocobase install -l en-US -e demo@nocobase.com -p admin123 -n "Super Admin"
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_APP_LANG
|
||||||
|
|
||||||
|
Language at installation, default value `en-US`, options include
|
||||||
|
|
||||||
|
- `en-US`
|
||||||
|
- `zh-CN`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=en-US \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_EMAIL
|
||||||
|
|
||||||
|
Root user's email
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=en-US \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_PASSWORD
|
||||||
|
|
||||||
|
Root user's password
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=en-US \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_NICKNAME
|
||||||
|
|
||||||
|
Root user's name
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=en-US \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
INIT_ROOT_NICKNAME="Super Admin" \
|
||||||
|
nocobase install
|
||||||
|
```
|
146
docs/en-US/development/http-api/action-api.md
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# Action API
|
||||||
|
|
||||||
|
## Common
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Collection and Association resources are common.
|
||||||
|
|
||||||
|
### `create`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create?whitelist=a,b&blacklist=c,d
|
||||||
|
|
||||||
|
{} # Request Body
|
||||||
|
```
|
||||||
|
|
||||||
|
- Parameters
|
||||||
|
- whitelist White list
|
||||||
|
- blacklist Black list
|
||||||
|
- Request body: JSON data to be inserted
|
||||||
|
- Response body data: Created data JSON
|
||||||
|
|
||||||
|
#### Add a User
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"email": "demo@nocobase.com",
|
||||||
|
"name": "Admin"
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Add a user's article
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users/1/posts:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post"
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Association in Request Body
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"user": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"id": 1,
|
||||||
|
"title": "My first post",
|
||||||
|
"userId": 1,
|
||||||
|
"user": {
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `update`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create?filterByTk=1&whitelist=a,b&blacklist=c,d
|
||||||
|
|
||||||
|
{} # Request Body
|
||||||
|
```
|
||||||
|
|
||||||
|
- Parameters
|
||||||
|
- whitelist White list
|
||||||
|
- blacklist Black list
|
||||||
|
- filterByTk Filter by tk field, by default tk is the primary key of the data table
|
||||||
|
- filter Filter,support json string
|
||||||
|
- Request body: JSON data to be updated
|
||||||
|
|
||||||
|
#### Association in Request Body
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:update/1
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post 2",
|
||||||
|
"user": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"title": "My first post 2",
|
||||||
|
"userId": 2,
|
||||||
|
"user": {
|
||||||
|
"id": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `list`
|
||||||
|
|
||||||
|
### `get`
|
||||||
|
|
||||||
|
### `destroy`
|
||||||
|
|
||||||
|
### `move`
|
||||||
|
|
||||||
|
## Association
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `add`
|
||||||
|
|
||||||
|
### `set`
|
||||||
|
|
||||||
|
### `remove`
|
||||||
|
|
||||||
|
### `toggle`
|
||||||
|
|
||||||
|
|
||||||
|
|
59
docs/en-US/development/http-api/filter-operators.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# Filter operators
|
||||||
|
|
||||||
|
## Common
|
||||||
|
|
||||||
|
- $eq
|
||||||
|
- $ne
|
||||||
|
- $gte
|
||||||
|
- $gt
|
||||||
|
- $lte
|
||||||
|
- $lt
|
||||||
|
- $not
|
||||||
|
- $is
|
||||||
|
- $in
|
||||||
|
- $notIn
|
||||||
|
- $like
|
||||||
|
- $notLike
|
||||||
|
- $iLike
|
||||||
|
- $notILike
|
||||||
|
- $and
|
||||||
|
- $or
|
||||||
|
- $empty
|
||||||
|
- $notEmpty
|
||||||
|
|
||||||
|
## array
|
||||||
|
|
||||||
|
- $match
|
||||||
|
- $notMatch
|
||||||
|
- $anyOf
|
||||||
|
- $noneOf
|
||||||
|
- $arrayEmpty
|
||||||
|
- $arrayNotEmpty
|
||||||
|
|
||||||
|
## association
|
||||||
|
|
||||||
|
- $exists
|
||||||
|
- $notExists
|
||||||
|
|
||||||
|
## boolean
|
||||||
|
|
||||||
|
- $truthy
|
||||||
|
- $falsy
|
||||||
|
|
||||||
|
## date
|
||||||
|
|
||||||
|
- $dateOn
|
||||||
|
- $dateNotOn
|
||||||
|
- $dateBefore
|
||||||
|
- $dateNotBefore
|
||||||
|
- $dateAfter
|
||||||
|
- $dateNotAfter
|
||||||
|
|
||||||
|
## string
|
||||||
|
|
||||||
|
- $includes
|
||||||
|
- $notIncludes
|
||||||
|
- $startsWith
|
||||||
|
- $notStartsWith
|
||||||
|
- $endWith
|
||||||
|
- $notEndWith
|
307
docs/en-US/development/http-api/index.md
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
# Overview
|
||||||
|
|
||||||
|
NocoBase HTTP API is designed based on Resource & Action, it is a superset of REST API. The operation is not limited to add, delete, change, and check, Resource Action can be extended arbitrarily in NocoBase.
|
||||||
|
|
||||||
|
## Resource
|
||||||
|
|
||||||
|
Resource has two expressions in NocoBase.
|
||||||
|
|
||||||
|
- `<collection>`
|
||||||
|
- `<collection>.<association>`
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
- collection is the set of all abstract data
|
||||||
|
- association is the association data for the collection
|
||||||
|
- resource includes both collection and collection.association
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
- `posts` Post
|
||||||
|
- `posts.user` Post user
|
||||||
|
- `posts.tags` Post tags
|
||||||
|
|
||||||
|
## Action
|
||||||
|
|
||||||
|
Representing resource operations as `:<action>`
|
||||||
|
|
||||||
|
- `<collection>:<action>`
|
||||||
|
- `<collection>.<association>:<action>`
|
||||||
|
|
||||||
|
Built-in global operations for collection or association
|
||||||
|
|
||||||
|
- `create`
|
||||||
|
- `get`
|
||||||
|
- `list`
|
||||||
|
- `update`
|
||||||
|
- `destroy`
|
||||||
|
- `move`
|
||||||
|
|
||||||
|
Built-in association operation for association only
|
||||||
|
|
||||||
|
- `set`
|
||||||
|
- `add`
|
||||||
|
- `remove`
|
||||||
|
- `toggle`
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
- `posts:create` Create posts
|
||||||
|
- `posts.user:get` View posts user
|
||||||
|
- `posts.tags:add` Attach post tags (associate existing tags with post)
|
||||||
|
|
||||||
|
## Request URL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
<GET|POST> /api/<collection>:<action>
|
||||||
|
<GET|POST> /api/<collection>:<action>/<collectionIndex>
|
||||||
|
<GET|POST> /api/<collection>/<collectionIndex>/<association>:<action>
|
||||||
|
<GET|POST> /api/<collection>/<collectionIndex>/<association>:<action>/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
posts resource
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
GET /api/posts:list
|
||||||
|
GET /api/posts:get/1
|
||||||
|
POST /api/posts:update/1
|
||||||
|
POST /api/posts:destroy/1
|
||||||
|
```
|
||||||
|
|
||||||
|
posts.comments resource
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts/1/comments:create
|
||||||
|
GET /api/posts/1/comments:list
|
||||||
|
GET /api/posts/1/comments:get/1
|
||||||
|
POST /api/posts/1/comments:update/1
|
||||||
|
POST /api/posts/1/comments:destroy/1
|
||||||
|
```
|
||||||
|
|
||||||
|
posts.tags resource
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts/1/tags:create
|
||||||
|
GET /api/posts/1/tags:get
|
||||||
|
GET /api/posts/1/tags:list
|
||||||
|
POST /api/posts/1/tags:update
|
||||||
|
POST /api/posts/1/tags:destroy
|
||||||
|
POST /api/posts/1/tags:add
|
||||||
|
GET /api/posts/1/tags:remove
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resource location
|
||||||
|
|
||||||
|
- collection resource, locates the data to be processed by `collectionIndex`, `collectionIndex` must be unique
|
||||||
|
- association resource, locates the data to be processed by `collectionIndex` and `associationIndex` jointly, `associationIndex` may not be unique, but `collectionIndex` and `associationIndex`'s association indexes must be unique
|
||||||
|
|
||||||
|
When viewing association resource details, the requested URL needs to provide both `<collectionIndex>` and `<associationIndex>`, `<collectionIndex>` is not redundant because `<associationIndex>` may not be unique.
|
||||||
|
|
||||||
|
For example, `tables.fields` indicates the fields of a data table
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/tables/table1/fields/title
|
||||||
|
GET /api/tables/table2/fields/title
|
||||||
|
```
|
||||||
|
|
||||||
|
Both table1 and table2 have a title field. The title is unique in table1, but other tables may also have a title field
|
||||||
|
|
||||||
|
## Request parameters
|
||||||
|
|
||||||
|
Request parameters can be placed in the request's headers, parameters (query string), and body (GET requests do not have a body).
|
||||||
|
|
||||||
|
A few special request parameters
|
||||||
|
|
||||||
|
- `filter` Data filtering, used in query-related operations.
|
||||||
|
- `filterByTk` filter by tk field, used in operations that specify details of the data.
|
||||||
|
- `sort` Sorting, used in query-related operations.
|
||||||
|
- `fields` which data to output, for use in query-related operations.
|
||||||
|
- `appends` additional relationship fields for use in query-related operations.
|
||||||
|
- `except` which fields to exclude (no output), used in query-related operations.
|
||||||
|
- `whitelist` fields whitelist, used in data creation and update related operations.
|
||||||
|
- `blacklist` fields blacklist, used in data creation and update related operations.
|
||||||
|
|
||||||
|
### filter
|
||||||
|
|
||||||
|
Data filter
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# simple
|
||||||
|
GET /api/posts?filter[status]=publish
|
||||||
|
# Recommend using the json string format, which requires encodeURIComponent encoding
|
||||||
|
GET /api/posts?filter={"status":"published"}
|
||||||
|
|
||||||
|
# filter operators
|
||||||
|
GET /api/posts?filter[status.$eq]=publish
|
||||||
|
GET /api/posts?filter={"status.$eq":"published"}
|
||||||
|
|
||||||
|
# $and
|
||||||
|
GET /api/posts?filter={"$and": [{"status.$eq":"published"}, {"title.$includes":"a"}]}
|
||||||
|
# $or
|
||||||
|
GET /api/posts?filter={"$or": [{"status.$eq":"pending"}, {"status.$eq":"draft"}]}
|
||||||
|
|
||||||
|
# association field
|
||||||
|
GET /api/posts?filter[user.email.$includes]=gmail
|
||||||
|
GET /api/posts?filter={"user.email.$includes":"gmail"}
|
||||||
|
```
|
||||||
|
|
||||||
|
[Click here for more infomation about filter operators](http-api/filter-operators)
|
||||||
|
|
||||||
|
### filterByTk
|
||||||
|
|
||||||
|
Filter by tk field. By default
|
||||||
|
|
||||||
|
- collection resource, tk is the primary key of the data table.
|
||||||
|
- association resource, tk is the targetKey field of the association.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:get?filterByTk=1&fields=name,title&appends=tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### sort
|
||||||
|
|
||||||
|
Sorting. When sorting in descending order, the fields are preceded by the minus sign `-`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# createAt field in ascending order
|
||||||
|
GET /api/posts:get?sort=createdAt
|
||||||
|
# createAt field descending
|
||||||
|
GET /api/posts:get?sort=-createdAt
|
||||||
|
# Multiple fields sorted jointly, createAt field descending, title A-Z ascending
|
||||||
|
GET /api/posts:get?sort=-createdAt,title
|
||||||
|
```
|
||||||
|
|
||||||
|
### fields
|
||||||
|
|
||||||
|
Which fields to output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:list?fields=name,title
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"title": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### appends
|
||||||
|
|
||||||
|
Appends a relationship field
|
||||||
|
|
||||||
|
### except
|
||||||
|
|
||||||
|
Which fields to exclude (not output) for use in query-related operations.
|
||||||
|
|
||||||
|
### whitelist
|
||||||
|
|
||||||
|
Whitelist
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create?whitelist=title
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"date": "2022-05-19" # The date field will be filtered out and will not be written to the database
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### blacklist
|
||||||
|
|
||||||
|
Blacklist
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create?blacklist=date
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"date": "2022-05-19" # The date field will be filtered out and will not be written to the database
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Request Response
|
||||||
|
|
||||||
|
Format of the response
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type ResponseResult = {
|
||||||
|
data?: any; // Master data
|
||||||
|
meta?: any; // Additional Data
|
||||||
|
errors?: ResponseError[]; // Errors
|
||||||
|
};
|
||||||
|
|
||||||
|
type ResponseError = {
|
||||||
|
code?: string;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
View list
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:list
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
count: 1
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
totalPage: 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
View details
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:get/1
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
id: 1
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
count: 1
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
totalPage: 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Error
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
|
||||||
|
Response 400 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
message: 'name must be required',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
```
|
229
docs/en-US/development/http-api/javascript-sdk.md
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
# JavaScript SDK
|
||||||
|
|
||||||
|
## APIClient
|
||||||
|
|
||||||
|
```ts
|
||||||
|
class APIClient {
|
||||||
|
// axios instance
|
||||||
|
axios: AxiosInstance;
|
||||||
|
// constructors
|
||||||
|
constructor(instance?: AxiosInstance | AxiosRequestConfig);
|
||||||
|
// Client-side requests, support for AxiosRequestConfig and ResourceActionOptions
|
||||||
|
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D> | ResourceActionOptions): Promise<R>;
|
||||||
|
// Get Resources
|
||||||
|
resource<R = IResource>(name: string, of?: any): R;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Initialize instance
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import axios from 'axios';
|
||||||
|
import { APIClient } from '@nocobase/sdk';
|
||||||
|
|
||||||
|
// Provide AxiosRequestConfig configuration parameters
|
||||||
|
const api = new APIClient({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provide AxiosInstance
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
const api = new APIClient(instance);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Mock
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { APIClient } from '@nocobase/sdk';
|
||||||
|
import MockAdapter from 'axios-mock-adapter';
|
||||||
|
|
||||||
|
const api = new APIClient({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
|
||||||
|
const mock = new MockAdapter(api.axios);
|
||||||
|
|
||||||
|
mock.onGet('users:get').reply(200, {
|
||||||
|
data: { id: 1, name: 'John Smith' },
|
||||||
|
});
|
||||||
|
|
||||||
|
await api.request({ url: 'users:get' });
|
||||||
|
```
|
||||||
|
|
||||||
|
## Auth
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Pass token directly
|
||||||
|
api.auth.token = '123';
|
||||||
|
// Or sign in via signIn
|
||||||
|
api.auth.signIn();
|
||||||
|
// Log out and delete the token cache
|
||||||
|
api.auth.signOut();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Request
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// url
|
||||||
|
await api.request({
|
||||||
|
url: 'users:list',
|
||||||
|
// request params
|
||||||
|
params: {
|
||||||
|
filter: {
|
||||||
|
'email.$includes': 'noco',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// request body
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
|
||||||
|
// resource & action
|
||||||
|
await api.request({
|
||||||
|
resource: 'users',
|
||||||
|
action: 'list',
|
||||||
|
// action params
|
||||||
|
params: {
|
||||||
|
filter: {
|
||||||
|
'email.$includes': 'noco',
|
||||||
|
},
|
||||||
|
page: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resource action
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await api.resource('collection')[action]();
|
||||||
|
await api.resource('collection.association', collectionId)[action]();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Action API
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await api.resource('collection').create();
|
||||||
|
await api.resource('collection').get();
|
||||||
|
await api.resource('collection').list();
|
||||||
|
await api.resource('collection').update();
|
||||||
|
await api.resource('collection').destroy();
|
||||||
|
await api.resource('collection.association', collectionId).create();
|
||||||
|
await api.resource('collection.association', collectionId).get();
|
||||||
|
await api.resource('collection.association', collectionId).list();
|
||||||
|
await api.resource('collection.association', collectionId).update();
|
||||||
|
await api.resource('collection.association', collectionId).destroy();
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
get: (options?: GetActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
fields?: string || string[];
|
||||||
|
appends?: string || string[];
|
||||||
|
expect?: string || string[];
|
||||||
|
sort?: string[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `list`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
list: (options?: ListActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ListActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
fields?: string || string[];
|
||||||
|
appends?: string || string[];
|
||||||
|
expect?: string || string[];
|
||||||
|
sort?: string[];
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
paginate?: boolean;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `create`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
create: (options?: CreateActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CreateActionOptions {
|
||||||
|
whitelist?: string[];
|
||||||
|
blacklist?: string[];
|
||||||
|
values?: {[key: sting]: any};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `update`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
update: (options?: UpdateActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UpdateActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
whitelist?: string[];
|
||||||
|
blacklist?: string[];
|
||||||
|
values?: {[key: sting]: any};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `destroy`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
destroy: (options?: DestroyActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DestroyActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `move`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
move: (options?: MoveActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MoveActionOptions {
|
||||||
|
sourceId: any;
|
||||||
|
targetId?: any;
|
||||||
|
/** @default 'sort' */
|
||||||
|
sortField?: any;
|
||||||
|
targetScope?: {[key: string]: any};
|
||||||
|
sticky?: boolean;
|
||||||
|
method?: 'insertAfter' | 'prepend';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `<custom>`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface AttachmentResource {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UploadActionOptions {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
api.resource<AttachmentResource>('attachments').upload();
|
||||||
|
api.resource('attachments').upload<UploadActionOptions>();
|
||||||
|
```
|
184
docs/en-US/development/http-api/rest-api.md
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
# REST API
|
||||||
|
|
||||||
|
NocoBase's HTTP API is a superset of the REST API, and the standard CRUD API also supports the RESTful style.
|
||||||
|
|
||||||
|
## Collection rescources
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Create collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:create
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### List collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>:list
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>
|
||||||
|
```
|
||||||
|
|
||||||
|
### View collection details
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>:get?filterByTk=<collectionIndex>
|
||||||
|
GET /api/<collection>:get/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:update?filterByTk=<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
|
||||||
|
# Or
|
||||||
|
POST /api/<collection>:update/<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PUT /api/<collection>/<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### Delete collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:destroy?filterByTk=<collectionIndex>
|
||||||
|
# Or
|
||||||
|
POST /api/<collection>:destroy/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DELETE /api/<collection>/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Association resources
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Create Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:create
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### List Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:list
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>
|
||||||
|
```
|
||||||
|
|
||||||
|
### View Association details
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get?filterByTk=<associationIndex>
|
||||||
|
# Or
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:update?filterByTk=<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
|
||||||
|
# Or
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PUT /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON
|
||||||
|
```
|
||||||
|
|
||||||
|
### Delete Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:destroy?filterByTk=<associationIndex>
|
||||||
|
# Or
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:destroy/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DELETE /api/<collection>/<collectionIndex>/<association>/<associationIndex>
|
||||||
|
```
|
310
docs/en-US/development/nocobase-cli.md
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
---
|
||||||
|
order: 2
|
||||||
|
---
|
||||||
|
|
||||||
|
# NocoBase CLI
|
||||||
|
|
||||||
|
NocoBase CLI is designed to help you develop, build, and deploy NocoBase applications.
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
NocoBase CLI supports both ts-node and node modes
|
||||||
|
|
||||||
|
- ts-node mode (default): used for development environment, supports real-time compilation, but slow response
|
||||||
|
- node mode: for production environment, fast response, but need to execute `yarn nocobase build` to compile all source code first
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase -h
|
||||||
|
|
||||||
|
Usage: nocobase [command] [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
create-plugin Create plugin scaffolding
|
||||||
|
console
|
||||||
|
db:auth Verify that the database connection is successful
|
||||||
|
db:sync Generate relevant data tables and fields from collections configuration
|
||||||
|
install Install
|
||||||
|
start Start the application in the production environment
|
||||||
|
build Compile and package
|
||||||
|
clean Delete the compiled files
|
||||||
|
dev Start the application for the development environment and supports live compilation
|
||||||
|
doc Documentation development
|
||||||
|
test Test
|
||||||
|
umi
|
||||||
|
upgrade Upgrade
|
||||||
|
help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use in scaffolding
|
||||||
|
|
||||||
|
The `scripts` in the application scaffolding `package.json` are as follows
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"dev": "nocobase dev",
|
||||||
|
"start": "nocobase start",
|
||||||
|
"clean": "nocobase clean",
|
||||||
|
"build": "nocobase build",
|
||||||
|
"test": "nocobase test",
|
||||||
|
"postinstall": "nocobase umi generate tmp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Extensions
|
||||||
|
|
||||||
|
NocoBase CLI is built on [commander](https://github.com/tj/commander.js), you can freely extend the command, the extended command can be written in `app/server/index.ts`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const app = new Application(config);
|
||||||
|
|
||||||
|
app.command('hello').action(() => {});
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, write in the plugin.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
class MyPlugin extends Plugin {
|
||||||
|
beforeLoad() {
|
||||||
|
this.app.command('hello').action(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Terminal runs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## Built-in command line
|
||||||
|
|
||||||
|
Sort by frequency of use
|
||||||
|
|
||||||
|
### `dev`
|
||||||
|
|
||||||
|
Start the application in the development environment and the code is compiled in real time.
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
NocoBase will be installed automatically if it is not installed (refer to the install command)
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Usage: nocobase dev [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --port [port]
|
||||||
|
--client
|
||||||
|
--server
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start application for development environment, live compile
|
||||||
|
yarn nocobase dev
|
||||||
|
# Start only the server side
|
||||||
|
yarn nocobase dev --server
|
||||||
|
# Start only the client side
|
||||||
|
yarn nocobase dev --client
|
||||||
|
```
|
||||||
|
|
||||||
|
### `start`
|
||||||
|
|
||||||
|
Start the application in a production environment, the code needs to be yarn build.
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
- NocoBase will be installed automatically if it is not installed (refer to the install command)
|
||||||
|
- If the source code has been modified, it needs to be repackaged (refer to the build command)
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase start -h
|
||||||
|
|
||||||
|
Usage: nocobase start [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --port
|
||||||
|
-s, --silent
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start the application in a production environment
|
||||||
|
yarn nocobase start
|
||||||
|
```
|
||||||
|
|
||||||
|
### `install`
|
||||||
|
|
||||||
|
Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase install -h
|
||||||
|
|
||||||
|
Usage: nocobase install [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --force
|
||||||
|
-c, --clean
|
||||||
|
-s, --silent
|
||||||
|
-l, --lang [lang]
|
||||||
|
-e, --root-email <rootEmail>
|
||||||
|
-p, --root-password <rootPassword>
|
||||||
|
-n, --root-nickname [rootNickname]
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Initial Installation
|
||||||
|
yarn nocobase install -l en-US -e admin@nocobase.com -p admin123
|
||||||
|
# Delete all data tables of NocoBase and reinstall
|
||||||
|
yarn nocobase install -f -l en-US -e admin@nocobase.com -p admin123
|
||||||
|
# Empty the database and reinstall
|
||||||
|
yarn nocobase install -c -l en-US -e admin@nocobase.com -p admin123
|
||||||
|
```
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
Difference between `-f/--force` and `-c/--clean`
|
||||||
|
- `-f/--force` Delete all data tables of NocoBase
|
||||||
|
- `-c/--clean` Delete all data tables of the database
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
### `upgrade`
|
||||||
|
|
||||||
|
Upgrade
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn nocobase upgrade
|
||||||
|
```
|
||||||
|
|
||||||
|
### `test`
|
||||||
|
|
||||||
|
jest tests, supports all [jest-cli](https://jestjs.io/docs/cli) options, and extends `-c, --db-clean` support in addition.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase test -h
|
||||||
|
|
||||||
|
Usage: nocobase test [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-c, --db-clean Empty the database before running all tests
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all test files
|
||||||
|
yarn nocobase test
|
||||||
|
# Run all test files in the specified folder
|
||||||
|
yarn nocobase test packages/core/server
|
||||||
|
# Run all tests in the specified file
|
||||||
|
yarn nocobase test packages/core/database/src/__tests__/database.test.ts
|
||||||
|
|
||||||
|
# Empty the database before running tests
|
||||||
|
yarn nocobase test -c
|
||||||
|
yarn nocobase test packages/core/server -c
|
||||||
|
```
|
||||||
|
|
||||||
|
### `build`
|
||||||
|
|
||||||
|
Before deployed to the production environment, the source code needs to be compiled and packaged. It needs to be rebuilt if there are changes to the code.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# All packages
|
||||||
|
yarn nocobase build
|
||||||
|
# Specified package
|
||||||
|
yarn nocobase build app/server app/client
|
||||||
|
```
|
||||||
|
|
||||||
|
### `clean`
|
||||||
|
|
||||||
|
Delete the compiled file
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
# Equivalent to
|
||||||
|
yarn rimraf -rf packages/*/*/{lib,esm,es,dist}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `doc`
|
||||||
|
|
||||||
|
Documentation development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start documentation
|
||||||
|
yarn doc --lang=en-US # Equivalent to yarn doc dev
|
||||||
|
# Build the documentation and output it to . /docs/dist/ directory by default
|
||||||
|
yarn doc build
|
||||||
|
# View the final result of the document output by dist
|
||||||
|
yarn doc serve --lang=en-US
|
||||||
|
```
|
||||||
|
|
||||||
|
### `db:auth`
|
||||||
|
|
||||||
|
Verify that the database is successfully connected
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase db:auth -h
|
||||||
|
|
||||||
|
Usage: nocobase db:auth [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-r, --repeat [repeat] Number of reconnections
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
### `db:sync`
|
||||||
|
|
||||||
|
Generate data tables and fields via collections configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase db:sync -h
|
||||||
|
|
||||||
|
Usage: nocobase db:sync [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --force
|
||||||
|
-h, --help display help for command
|
||||||
|
```
|
||||||
|
|
||||||
|
### `umi`
|
||||||
|
|
||||||
|
`app/client` is built based on [umi](https://umijs.org/) and can be used to execute other related commands via `nocobase umi`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generate the .umi cache required by the development environment
|
||||||
|
yarn nocobase umi generate tmp
|
||||||
|
```
|
||||||
|
|
||||||
|
### `help`
|
||||||
|
|
||||||
|
The help command, also available with the option parameter, `-h` and `--help`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# View all cli
|
||||||
|
yarn nocobase help
|
||||||
|
# You can also use -h
|
||||||
|
yarn nocobase -h
|
||||||
|
# or --help
|
||||||
|
yarn nocobase --help
|
||||||
|
# Option to view the db:sync command
|
||||||
|
yarn nocobase db:sync -h
|
||||||
|
```
|
@ -0,0 +1 @@
|
|||||||
|
# Overview
|
@ -0,0 +1 @@
|
|||||||
|
# APIClient
|
@ -0,0 +1 @@
|
|||||||
|
# ACL
|
@ -0,0 +1 @@
|
|||||||
|
# Ant Design
|
@ -0,0 +1 @@
|
|||||||
|
# ChianRegion
|
@ -0,0 +1 @@
|
|||||||
|
# CollectionManager
|
@ -0,0 +1 @@
|
|||||||
|
# I18n
|
@ -0,0 +1 @@
|
|||||||
|
# RouteSwitch
|
@ -0,0 +1 @@
|
|||||||
|
# SchemaComponent
|
@ -0,0 +1 @@
|
|||||||
|
# SchemaInitializer
|
1
docs/en-US/development/plugin-development/index.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Quick Start
|
1
docs/en-US/development/plugin-development/server/acl.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ACL
|
@ -0,0 +1 @@
|
|||||||
|
# AppManager
|
1
docs/en-US/development/plugin-development/server/cli.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# CLI
|
@ -0,0 +1 @@
|
|||||||
|
# Database
|
@ -0,0 +1 @@
|
|||||||
|
# Event
|
1
docs/en-US/development/plugin-development/server/i18n.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# I18n
|
@ -0,0 +1 @@
|
|||||||
|
# Middleware
|
@ -0,0 +1 @@
|
|||||||
|
# Overview
|
@ -0,0 +1 @@
|
|||||||
|
# PluginManager
|
@ -0,0 +1 @@
|
|||||||
|
# Resource & Action
|
2
docs/en-US/faq.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# FAQ
|
||||||
|
|
@ -0,0 +1,86 @@
|
|||||||
|
# `create-nocobase-app`
|
||||||
|
|
||||||
|
## 0. Prerequisites
|
||||||
|
|
||||||
|
Make sure you have:
|
||||||
|
|
||||||
|
- Node.js 14+, Yarn 1.22.x installed
|
||||||
|
- Configured and started the required database SQLite 3.x, MySQL 8.x, PostgreSQL 10.x choose one
|
||||||
|
|
||||||
|
Please make sure you have Node.js 14.x or above installed. You can download and install the latest LTS version from the official website. It is recommended to use nvm (or nvm-windows for Win systems) to manage Node.js versions if you plan to work with Node.js for a long time.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ node -v
|
||||||
|
|
||||||
|
v16.13.2
|
||||||
|
```
|
||||||
|
|
||||||
|
Install yarn package manager
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install --global yarn
|
||||||
|
$ yarn -v
|
||||||
|
|
||||||
|
1.22.10
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1. Create a NocoBase project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# SQLite
|
||||||
|
yarn create nocobase-app my-nocobase-app -d sqlite
|
||||||
|
# MySQL
|
||||||
|
yarn create nocobase-app my-nocobase-app -d mysql \
|
||||||
|
-e DB_HOST=localhost \
|
||||||
|
-e DB_PORT=3356 \
|
||||||
|
-e DB_DATABASE=nocobase \
|
||||||
|
-e DB_USER=nocobase \
|
||||||
|
-e DB_PASSWORD=nocobase
|
||||||
|
# PostgreSQL
|
||||||
|
yarn create nocobase-app my-nocobase-app -d postgres \
|
||||||
|
-e DB_HOST=localhost \
|
||||||
|
-e DB_PORT=5432 \
|
||||||
|
-e DB_DATABASE=nocobase \
|
||||||
|
-e DB_USER=nocobase \
|
||||||
|
-e DB_PASSWORD=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Switch to the project directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd my-nocobase-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Install dependencies
|
||||||
|
|
||||||
|
📢 This next step may take more than ten minutes due to network environment, system configuration, and other factors.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Install NocoBase
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn nocobase install --lang=zh-CN
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Start NocoBase
|
||||||
|
|
||||||
|
Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Production
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn start
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: For production, if the code has been modified, you need to execute `yarn build` and restart NocoBase.
|
||||||
|
|
||||||
|
## 6. Log in to NocoBase
|
||||||
|
|
||||||
|
Open [http://localhost:13000](http://localhost:13000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
|
52
docs/en-US/getting-started/installation/docker-compose.md
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Docker (👍 Recommended)
|
||||||
|
|
||||||
|
## 0. Prerequisites
|
||||||
|
|
||||||
|
⚡⚡ Please make sure you have installed [Docker](https://docs.docker.com/get-docker/)
|
||||||
|
|
||||||
|
## 1. Download NocoBase
|
||||||
|
|
||||||
|
Download with Git (or Download Zip,and extract it to the nocobase directory)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/nocobase/nocobase.git nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Select database (choose one)
|
||||||
|
|
||||||
|
Supports SQLite, MySQL, PostgreSQL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# SQLite
|
||||||
|
cd nocobase/docker/app-sqlite
|
||||||
|
# MySQL
|
||||||
|
cd nocobase/docker/app-mysql
|
||||||
|
# PostgreSQL
|
||||||
|
cd nocobase/docker/app-postgres
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Install and start NocoBase
|
||||||
|
|
||||||
|
It may take dozens of seconds
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# run in the background
|
||||||
|
$ docker-compose up -d
|
||||||
|
# view app logs
|
||||||
|
$ docker-compose logs app
|
||||||
|
|
||||||
|
app-sqlite-app-1 | nginx started
|
||||||
|
app-sqlite-app-1 | yarn run v1.22.15
|
||||||
|
app-sqlite-app-1 | $ cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js install -s
|
||||||
|
app-sqlite-app-1 | Done in 2.72s.
|
||||||
|
app-sqlite-app-1 | yarn run v1.22.15
|
||||||
|
app-sqlite-app-1 | $ pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start
|
||||||
|
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: Launching in no daemon mode
|
||||||
|
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] starting in -fork mode-
|
||||||
|
app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] online
|
||||||
|
app-sqlite-app-1 | 🚀 NocoBase server running at: http://localhost:13000/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Log in to NocoBase
|
||||||
|
|
||||||
|
Open [http://localhost:13000](http://localhost:13000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
|
64
docs/en-US/getting-started/installation/git-clone.md
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# Git source code
|
||||||
|
|
||||||
|
## 0. Prerequisites
|
||||||
|
|
||||||
|
Make sure you have:
|
||||||
|
|
||||||
|
- Git, Node.js 14+, Yarn 1.22.x installed
|
||||||
|
- Configured and started the required database SQLite 3.x, MySQL 8.x, PostgreSQL 10.x choose one
|
||||||
|
|
||||||
|
## 1. Download with Git
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/nocobase/nocobase.git my-nocobase-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Switch to the project directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd my-nocobase-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Set environment variables
|
||||||
|
|
||||||
|
The environment variables required by NocoBase are stored in the root `.env` file, modify the environment variables according to the actual situation, if you don't know how to change them, [click here for environment variables description](./development/env.md), or you can leave it as default.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using sqlite database
|
||||||
|
DB_DIALECT=sqlite
|
||||||
|
# sqlite file path
|
||||||
|
DB_STORAGE=storage/db/nocobase.sqlite
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Install NocoBase
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn nocobase install --lang=zh-CN
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. Start NocoBase
|
||||||
|
|
||||||
|
Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Production
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Compile
|
||||||
|
yarn build
|
||||||
|
# Start
|
||||||
|
yarn start
|
||||||
|
```
|
||||||
|
|
||||||
|
## 7. Log in to NocoBase
|
||||||
|
|
||||||
|
Open [http://localhost:13000](http://localhost:13000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
|
23
docs/en-US/getting-started/installation/overview.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Overview
|
||||||
|
|
||||||
|
## Installation Methods
|
||||||
|
|
||||||
|
NocoBase supports three installation methods.
|
||||||
|
|
||||||
|
- [Docker (recommended)](./docker-compose.md)
|
||||||
|
- [create-nocobase-app](./create-nocobase-app.md)
|
||||||
|
- [Git source code](./git-clone.md)
|
||||||
|
|
||||||
|
## How to choose
|
||||||
|
|
||||||
|
**Docker (recommended)**:
|
||||||
|
|
||||||
|
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
||||||
|
|
||||||
|
**create-nocobase-app**:
|
||||||
|
|
||||||
|
The business code of the project is completely independent and supports low-code development.
|
||||||
|
|
||||||
|
**Git source code**:
|
||||||
|
|
||||||
|
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
55
docs/en-US/getting-started/upgrading.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# Upgrading
|
||||||
|
|
||||||
|
Make sure to back up your database before upgrading
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
Switch to the project directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# SQLite
|
||||||
|
cd nocobase/docker/app-sqlite
|
||||||
|
# MySQL
|
||||||
|
cd nocobase/docker/app-mysql
|
||||||
|
# PostgreSQL
|
||||||
|
cd nocobase/docker/app-postgres
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `docker-compose` to stop, delete the application, and download the latest image
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Stop the app
|
||||||
|
docker-compose stop app
|
||||||
|
# Delete the app
|
||||||
|
docker-compose rm app
|
||||||
|
# Download the latest image and start it
|
||||||
|
docker-compose up -d app
|
||||||
|
# Check the status of the app process
|
||||||
|
docker-compose logs app
|
||||||
|
```
|
||||||
|
|
||||||
|
## create-nocobase-app
|
||||||
|
|
||||||
|
Execute the `nocobase upgrad` command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Switch to the project directory
|
||||||
|
cd my-nocobase-app
|
||||||
|
# Execute the update command
|
||||||
|
yarn nocobase upgrade
|
||||||
|
# Start
|
||||||
|
yarn start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Git source code
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Switch to the project directory
|
||||||
|
cd my-nocobase-app
|
||||||
|
# Pull latest source code
|
||||||
|
git pull
|
||||||
|
# Execute the update command
|
||||||
|
yarn nocobase upgrade
|
||||||
|
# Start
|
||||||
|
yarn start
|
||||||
|
```
|
48
docs/en-US/index.md
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Introduction
|
||||||
|
|
||||||
|
![](https://nocobase.oss-cn-beijing.aliyuncs.com/bbcedd403d31cd1ccc4e9709581f5c2f.png)
|
||||||
|
|
||||||
|
## What is NocoBase
|
||||||
|
|
||||||
|
NocoBase is a scalability-first, open-source no-code development platform. No programming required, build your own collaboration platform, management system with NocoBase in minutes.
|
||||||
|
|
||||||
|
Homepage:
|
||||||
|
https://www.nocobase.com/
|
||||||
|
|
||||||
|
Online Demo:
|
||||||
|
https://demo.nocobase.com/new
|
||||||
|
|
||||||
|
Contact Us:
|
||||||
|
hello@nocobase.com
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Open source and free**
|
||||||
|
- Unrestricted commercial use under the Apache-2.0 license
|
||||||
|
- Full code ownership, private deployment, private and secure data
|
||||||
|
- Free to expand and develop for actual needs
|
||||||
|
- Good ecological support
|
||||||
|
- **Strong no-code capability**
|
||||||
|
- Data Model
|
||||||
|
- Create independent data models using dozens of field types such as text, date, number, attachment, option, icon, etc., and various association relationships such as one-to-one, one-to-many, many-to-many, etc.
|
||||||
|
- Block
|
||||||
|
- Display and manipulate data within a page using a free combination of block types such as tables, forms, kanban, calendars, details, etc.
|
||||||
|
- ACL
|
||||||
|
- Role-based control of user's system configuration rights, data action rights and menu access rights.
|
||||||
|
- Workflow
|
||||||
|
- Repetitive tasks are replaced by automation to increase efficiency. Manual approval is required for important matters.
|
||||||
|
- Menu
|
||||||
|
- You can group menus, support adding pages and links, and support unlimited submenus.
|
||||||
|
- Action
|
||||||
|
- Support filtering, exporting, adding, deleting, modifying, viewing and other operations to process data, which can be extended to more types.
|
||||||
|
- **Built for extended development**
|
||||||
|
- Microkernel architecture, flexible and easy to extend, with a robust plug-in system
|
||||||
|
- Node.js-based, with popular frameworks and technologies, including Koa, Sequelize, React, Formily, Ant Design, etc.
|
||||||
|
- Progressive development, easy for getting-started, friendly to newcomers
|
||||||
|
- No binding, no strong dependencies, can be used in any combination or extensions, can be used in existing projects
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
![](https://www.nocobase.com/images/NocoBaseMindMapLite.png)
|
||||||
|
|
||||||
|
[Click here to view the full image](https://www.nocobase.com/images/NocoBaseMindMap.png)
|
71
docs/en-US/release-notes.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# Release Notes
|
||||||
|
|
||||||
|
## Ready for release
|
||||||
|
|
||||||
|
### New features
|
||||||
|
- Packaging tool `@nocobase/build`
|
||||||
|
- CLI `@nocobase/cli`
|
||||||
|
- devtools `@nocobase/devtools`
|
||||||
|
- JavaScript SDK `@nocobase/sdk`
|
||||||
|
- Documents(v0.7)
|
||||||
|
|
||||||
|
### Bug fixes & improvements
|
||||||
|
- `@nocobase/preset-nocobase`
|
||||||
|
- create scaffolding `create-nocobase-app`
|
||||||
|
- Documents theme `dumi-theme-nocobase`
|
||||||
|
|
||||||
|
## 2022/05/14 ~ v0.7.0-alpha.34
|
||||||
|
|
||||||
|
- feat: add plugins:getPinned action api
|
||||||
|
- fix(plugin workflow): cannot get job result properties (#382)
|
||||||
|
- feat: exist on server start throw error (#374)
|
||||||
|
- chore: application options (#375)
|
||||||
|
- fix: not in operator with null value record (#377)
|
||||||
|
|
||||||
|
## 2022/05/13 ~ v0.7.0-alpha.33
|
||||||
|
|
||||||
|
- fix: link-to field data scope error (#1337)
|
||||||
|
- feat(plugin workflow): revisions (#379)
|
||||||
|
- fix(database): fix option-parser include list index (#371)
|
||||||
|
- fix(plugin-worklfow): fix duplicated description in fields values (#368)
|
||||||
|
- fix(database): fix type and transaction in repository (#366)
|
||||||
|
- fix(plugin workflow): fix transaction of execution (#364)
|
||||||
|
|
||||||
|
## 2022/05/05 ~ v0.7.0-alpha.30
|
||||||
|
|
||||||
|
- fix(client): upgrade formily packages
|
||||||
|
- fix(client): setFormValueChanged must be defined
|
||||||
|
|
||||||
|
## 2022/05/01 ~ v0.7.0-alpha.27
|
||||||
|
|
||||||
|
- fix: use wrapper when greater than one column
|
||||||
|
- fix: props for CreateFormBlockInitializers
|
||||||
|
- fix: add schema initializer icon
|
||||||
|
- fix: plugin workflow (#349)
|
||||||
|
- fix: db:sync not working (#348)
|
||||||
|
- fix(plugin-workflow): fix trigger bind logic to avoid duplication (#347)
|
||||||
|
- fix(plugin workflow) (#346)
|
||||||
|
- fix: action open mode
|
||||||
|
- fix: menu url style (#344)
|
||||||
|
- feat: action loading
|
||||||
|
- fix: compile the label field
|
||||||
|
- fix: invalid drag and drop sort
|
||||||
|
|
||||||
|
## 2022/04/25 ~ v0.7.0-alpha.16
|
||||||
|
|
||||||
|
- fix: cannot find module mkdirp (#330)
|
||||||
|
- fix(plugin workflow): UX issues (#329)
|
||||||
|
- fix(plugin-file-manager): test failed
|
||||||
|
- fix(app-server): dist options
|
||||||
|
|
||||||
|
## 2022/04/25 ~ v0.7.0-alpha.0
|
||||||
|
|
||||||
|
- Alpha Version
|
||||||
|
|
||||||
|
## 2021/10/07 ~ v0.5.0
|
||||||
|
|
||||||
|
- The second preview version
|
||||||
|
|
||||||
|
## 2021/04/07 ~ v0.4.0
|
||||||
|
|
||||||
|
- The first preview version
|
31
docs/en-US/roadmap.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Roadmap
|
||||||
|
|
||||||
|
## Iterating
|
||||||
|
|
||||||
|
- `core` Roles & Permissions
|
||||||
|
- `core` Upgrading
|
||||||
|
- `core` Relationships
|
||||||
|
- `plugin` Workflow
|
||||||
|
- `doc` Development Doc
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
- `core` Custom actions
|
||||||
|
- `plugin` Action logs
|
||||||
|
- `plugin` Database connection
|
||||||
|
|
||||||
|
## Planning
|
||||||
|
|
||||||
|
- `ui` Mobile version
|
||||||
|
- `plugin` Export
|
||||||
|
- `plugin` Open API
|
||||||
|
- `core` Plugins manager
|
||||||
|
|
||||||
|
## Future
|
||||||
|
|
||||||
|
- `plugin` Approval
|
||||||
|
- `plugin` Full-text search
|
||||||
|
- `plugin` Shared pages
|
||||||
|
- `plugin` Reference and copy data from other tables
|
||||||
|
- `plugin` Formula
|
||||||
|
- `plugin` Data visualization
|
12
docs/en-US/thanks.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Acknowledgements
|
||||||
|
|
||||||
|
NocoBase uses excellent and proven open source products, to whom we express our sincere gratitude.
|
||||||
|
|
||||||
|
- [Ant Design](https://ant.design/)
|
||||||
|
- [Dnd Kit](https://dndkit.com/)
|
||||||
|
- [Formily](https://github.com/alibaba/formily)
|
||||||
|
- [I18next](https://www.i18next.com/)
|
||||||
|
- [Koa](https://koajs.com/)
|
||||||
|
- [React](https://reactjs.org/)
|
||||||
|
- [Sequelize](https://sequelize.org/)
|
||||||
|
- [UmiJS](https://umijs.org/)
|
3
docs/en-US/user-manual/advanced-guide/actions.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Actions
|
||||||
|
|
||||||
|
TO DO
|
63
docs/en-US/user-manual/advanced-guide/blocks.md
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Blocks
|
||||||
|
|
||||||
|
Blocks are views that are used to display and manipulate data. Blocks can be placed in pages and popups. A block consists of three parts.
|
||||||
|
|
||||||
|
1. content area: the body of the block
|
||||||
|
2. action area: various action buttons can be placed to manipulate the block data
|
||||||
|
3. configuration area: buttons for operating the block configuration
|
||||||
|
|
||||||
|
![6.block.jpg](./blocks/6.block.jpg)
|
||||||
|
|
||||||
|
## Add block
|
||||||
|
|
||||||
|
Enter the UI Editor mode and click the Add block button on the page and in the pop-up window to add the block. The options are divided into 4 steps.
|
||||||
|
|
||||||
|
1. Select block type: Currently available block types include Table, Form, Details, Calendar, Kanban, Markdown
|
||||||
|
2. Select Collection: All collections will be listed here
|
||||||
|
3. Choose the creation method: create a blank block, or duplicate a block template , or reference a block template
|
||||||
|
4. Select Template: If you selected Create from Template in step 3, select the template in step 4
|
||||||
|
|
||||||
|
![6.block-add.jpg](./blocks/6.block-add.jpg)
|
||||||
|
|
||||||
|
## Configure Blocks
|
||||||
|
|
||||||
|
The configuration of blocks consists of three elements.
|
||||||
|
|
||||||
|
- Configure block content
|
||||||
|
- Configure block actions
|
||||||
|
- Configure block properties
|
||||||
|
|
||||||
|
### Configure block content
|
||||||
|
|
||||||
|
Take the table block as an example, the content of the block is the columns to be displayed in the table. Click Configure columns to configure the columns to be displayed.
|
||||||
|
|
||||||
|
![6.block-content.gif](./blocks/6.block-content.gif)
|
||||||
|
|
||||||
|
### Configure block actions
|
||||||
|
|
||||||
|
Take table block as an example, there are filter, add, delete, view, edit, customize and other actions available. Click the Configure actions button to configure the actions. Each of the action buttons can be configured for their own properties.
|
||||||
|
|
||||||
|
![6.block-content.gif](./blocks/6.block-content%201.gif)
|
||||||
|
|
||||||
|
### Configure block properties
|
||||||
|
|
||||||
|
Move the cursor to the upper right corner of the block and you will see the block configuration button. Using the table block as an example, the following properties can be configured.
|
||||||
|
|
||||||
|
- Drag & drop sorting
|
||||||
|
- Set the data scope
|
||||||
|
- Set default sorting rules
|
||||||
|
- Records per page
|
||||||
|
|
||||||
|
![6.collection-setting.gif](./blocks/6.collection-setting.gif)
|
||||||
|
|
||||||
|
## Block Types
|
||||||
|
|
||||||
|
Currently NocoBase supports the following types of blocks.
|
||||||
|
|
||||||
|
- Table
|
||||||
|
- Form
|
||||||
|
- Details
|
||||||
|
- Kanban
|
||||||
|
- Calendar
|
||||||
|
- Related Data
|
||||||
|
- Markdown
|
BIN
docs/en-US/user-manual/advanced-guide/blocks/6.block-add.jpg
Executable file
After Width: | Height: | Size: 333 KiB |
BIN
docs/en-US/user-manual/advanced-guide/blocks/6.block-content 1.gif
Executable file
After Width: | Height: | Size: 567 KiB |
BIN
docs/en-US/user-manual/advanced-guide/blocks/6.block-content.gif
Executable file
After Width: | Height: | Size: 567 KiB |
BIN
docs/en-US/user-manual/advanced-guide/blocks/6.block.jpg
Executable file
After Width: | Height: | Size: 234 KiB |
BIN
docs/en-US/user-manual/advanced-guide/blocks/6.collection-setting.gif
Executable file
After Width: | Height: | Size: 1.3 MiB |
42
docs/en-US/user-manual/advanced-guide/collections.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Collections
|
||||||
|
|
||||||
|
Before developing a system, we usually have to abstract the business and build a data model. In NocoBase, the concept of a data collection is similar to that of a table in a relational database.
|
||||||
|
|
||||||
|
Click the "Collections & Fields" button to enter the configuration interface. Here, you can add, edit and delete data collections.
|
||||||
|
|
||||||
|
![4.collections.gif](./collections/4.collections.gif)
|
||||||
|
|
||||||
|
## Field Types
|
||||||
|
|
||||||
|
- Basic
|
||||||
|
- Single line text
|
||||||
|
- Long text
|
||||||
|
- Phone
|
||||||
|
- Email
|
||||||
|
- Number
|
||||||
|
- Percent
|
||||||
|
- Password
|
||||||
|
- Icon
|
||||||
|
- Choices
|
||||||
|
- Checkbox
|
||||||
|
- Single select
|
||||||
|
- Multiple select
|
||||||
|
- Radio group
|
||||||
|
- Checkbox group
|
||||||
|
- China region
|
||||||
|
- Media
|
||||||
|
- Attachment
|
||||||
|
- Markdown
|
||||||
|
- Rich Text
|
||||||
|
- Date & Time
|
||||||
|
- Date
|
||||||
|
- Time
|
||||||
|
- Relationship Type
|
||||||
|
- Link to
|
||||||
|
- Sub-table
|
||||||
|
- System Info
|
||||||
|
- ID
|
||||||
|
- Created at
|
||||||
|
- Last updated at
|
||||||
|
- Created by
|
||||||
|
- Last updated by
|
BIN
docs/en-US/user-manual/advanced-guide/collections/4.collections.gif
Executable file
After Width: | Height: | Size: 642 KiB |
11
docs/en-US/user-manual/advanced-guide/file-storages.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# File Storages
|
||||||
|
|
||||||
|
NocoBase file storage currently supports the following three methods
|
||||||
|
|
||||||
|
- Local storage
|
||||||
|
- Aliyun OSS
|
||||||
|
- Amazon S3
|
||||||
|
|
||||||
|
Click File storage to enter the configuration interface and add the appropriate information.
|
||||||
|
|
||||||
|
![8.storage.gif](./file-storages/8.storage.gif)
|
BIN
docs/en-US/user-manual/advanced-guide/file-storages/8.storage.gif
Executable file
After Width: | Height: | Size: 1016 KiB |
@ -0,0 +1,9 @@
|
|||||||
|
# Functional zoning
|
||||||
|
|
||||||
|
NocoBase has a built-in layout template by default, and the interface of this layout template is divided into three main areas.
|
||||||
|
|
||||||
|
1. Configuration entry area. Users with permissions can see the UI Editor, Collections & Fields, Roles and Permissions, block templates, Workflows, and other extended configuration options here.
|
||||||
|
2. Menu area. At the top is the first level menu, and on the left side are the menus for the second level and lower tiers. Each menu item can be configured as a menu group, page, or link.
|
||||||
|
3. Block container. This is the block container for the page, in which various blocks can be placed.
|
||||||
|
|
||||||
|
![3.zone.jpg](./functional-zoning/3.zone.jpg)
|
BIN
docs/en-US/user-manual/advanced-guide/functional-zoning/3.zone.jpg
Executable file
After Width: | Height: | Size: 304 KiB |
32
docs/en-US/user-manual/advanced-guide/menus.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Menus
|
||||||
|
|
||||||
|
The default menu location for NocoBase is at the top and on the left. The top is the first level menu and the left side is the menu for the second level and lower levels.
|
||||||
|
|
||||||
|
Three types of menu items are supported.
|
||||||
|
|
||||||
|
- Menu groups
|
||||||
|
- Pages
|
||||||
|
- Links
|
||||||
|
|
||||||
|
Once you enter the UI Editor mode, you can add and edit menus, as well as sort menu items.
|
||||||
|
|
||||||
|
## Add Menu Item
|
||||||
|
|
||||||
|
![5.menu-add.jpg](./menus/5.menu-add.jpg)
|
||||||
|
|
||||||
|
Click Add menu item to select the type to add. Support infinite level submenu.
|
||||||
|
|
||||||
|
## Configure and Sort
|
||||||
|
|
||||||
|
Move the cursor over the menu item and the Sort and Configure buttons will appear in the upper right corner. Press and hold the Sort button to drag and drop the sorting.
|
||||||
|
|
||||||
|
Configurations that are operable on menu items:
|
||||||
|
|
||||||
|
- Edit
|
||||||
|
- Move to
|
||||||
|
- Insert before
|
||||||
|
- Insert after
|
||||||
|
- Insert Inner
|
||||||
|
- Delete
|
||||||
|
|
||||||
|
![5.menu-edit.jpg](./menus/5.menu-edit.jpg)
|
BIN
docs/en-US/user-manual/advanced-guide/menus/5.menu-add.jpg
Executable file
After Width: | Height: | Size: 182 KiB |
BIN
docs/en-US/user-manual/advanced-guide/menus/5.menu-edit.jpg
Executable file
After Width: | Height: | Size: 197 KiB |
1
docs/en-US/user-manual/advanced-guide/plugins.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Plugins
|
@ -0,0 +1,3 @@
|
|||||||
|
# Workflow
|
||||||
|
|
||||||
|
TO DO
|
@ -0,0 +1,3 @@
|
|||||||
|
# Roles & Permissions
|
||||||
|
|
||||||
|
TO DO
|
10
docs/en-US/user-manual/advanced-guide/system-settings.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# System Settings
|
||||||
|
|
||||||
|
Click System settings, the properties that can be configured include:
|
||||||
|
|
||||||
|
- System title
|
||||||
|
- Logo
|
||||||
|
- Language
|
||||||
|
- Allow sign up
|
||||||
|
|
||||||
|
![9.system.gif](./system-settings/9.system.gif)
|
BIN
docs/en-US/user-manual/advanced-guide/system-settings/9.system.gif
Executable file
After Width: | Height: | Size: 460 KiB |
9
docs/en-US/user-manual/advanced-guide/tabs.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Tabs
|
||||||
|
|
||||||
|
In a single record page or popup, you can add multiple tabs and add different blocks to each tab to display different content and actions. For example, in a customer information popup, add 3 tabs to display customer's personal information, order history, customer reviews.
|
||||||
|
|
||||||
|
![7.tabs.gif](./tabs/7.tabs.gif)
|
||||||
|
|
||||||
|
Or, in an order record to be shipped, place a form block in the first tab for quick shipping, a block of associated data in the second tab to display the order items for the current order, and an order details block in the third tab.
|
||||||
|
|
||||||
|
![7.tabs-2.gif](./tabs/7.tabs-2.gif)
|
BIN
docs/en-US/user-manual/advanced-guide/tabs/7.tabs-2.gif
Executable file
After Width: | Height: | Size: 590 KiB |
BIN
docs/en-US/user-manual/advanced-guide/tabs/7.tabs.gif
Executable file
After Width: | Height: | Size: 1.5 MiB |
@ -0,0 +1,91 @@
|
|||||||
|
# 5 minutes to get started
|
||||||
|
|
||||||
|
Let's take 5 minutes to build an order management system using NocoBase.
|
||||||
|
|
||||||
|
## 1. Create data collections and fields
|
||||||
|
|
||||||
|
In this order management system, we need to have the information of `Customers`,`Products`,`Orders` which are interrelated with each other. We need to create 4 data tables and their fields as follows:
|
||||||
|
|
||||||
|
- Customers
|
||||||
|
- Name
|
||||||
|
- Birthday
|
||||||
|
- Gender
|
||||||
|
- Phone
|
||||||
|
- Orders (All orders purchased, data from `Orders`, each customer data contains multiple order data)
|
||||||
|
- Products
|
||||||
|
- Product name
|
||||||
|
- Description
|
||||||
|
- Images
|
||||||
|
- Price
|
||||||
|
- Order Details (In which orders the product was purchased, data from `Order Details`, each product data belongs to multiple order details data)
|
||||||
|
- Orders
|
||||||
|
- Serial number
|
||||||
|
- Total
|
||||||
|
- Note
|
||||||
|
- Address
|
||||||
|
- Customer (Customers who own the order, data from `Customers`, each order data belongs to a customer data)
|
||||||
|
- Order details (The products in the order, data from `Order Details`, each order data contains multiple order details data)
|
||||||
|
- Order Details
|
||||||
|
- Order (The order to which the detail belongs, data from `Orders`, each order detail data belongs to an order data)
|
||||||
|
- Product (The products contained in this detail, data from `Products`, each order detail data contains a product data)
|
||||||
|
- Quantity
|
||||||
|
|
||||||
|
Where the fields with underscores are relational fields, associated to other data tables.
|
||||||
|
|
||||||
|
Next, click the "Collections & Fields" button to enter the Configuration screen and create the first Collection `Customers`.
|
||||||
|
|
||||||
|
![1.customers.gif](./5-minutes-to-get-started/1.customers.gif)
|
||||||
|
|
||||||
|
Then click on "Configure fields" to add a name field for `Customers`, which is a Single line text type.
|
||||||
|
|
||||||
|
![2.field.gif](./5-minutes-to-get-started/2.field.gif)
|
||||||
|
|
||||||
|
In the same way, add Birthday, Gender, and Phone for `Customers`, which are the Datetime type, Radio group type, and Phone type respectively.
|
||||||
|
|
||||||
|
![1.fields.jpg](./5-minutes-to-get-started/1.fields.jpg)
|
||||||
|
|
||||||
|
In the same way, create Collections `Products`, `Orders`, `Order Details` and their fields.
|
||||||
|
|
||||||
|
![1.collections.jpg](./5-minutes-to-get-started/1.collections.jpg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
In this case, for the relationship fields, we have to select the Link to type, thus creating an association between the data collections. In this example, we associate `Products` with `Orders` and use `Order Details` as an junction collection.
|
||||||
|
|
||||||
|
![1.relation.jpg](./5-minutes-to-get-started/1.relation.jpg)
|
||||||
|
|
||||||
|
Once the data collections and fields are created, we start making the interface.
|
||||||
|
|
||||||
|
## 2. Configure menus and pages
|
||||||
|
|
||||||
|
We need three pages for customers, orders, and products to display and manage our data.
|
||||||
|
|
||||||
|
Click the UI Editor button to enter the interface configuration mode. In this mode, we can add menu items, add pages, and arrange blocks within the pages.
|
||||||
|
|
||||||
|
![1.editor.gif](./5-minutes-to-get-started/1.editor.gif)
|
||||||
|
|
||||||
|
Click Add menu item, add menu groups "Customers" and "Orders & Products", then add submenu pages "All Orders" and "Products".
|
||||||
|
|
||||||
|
![1.menu.gif](./5-minutes-to-get-started/1.menu.gif)
|
||||||
|
|
||||||
|
After adding menus and pages, we can add and configure blocks within the pages.
|
||||||
|
|
||||||
|
## 3. Adding and Configuring Blocks
|
||||||
|
|
||||||
|
NocoBase currently supports table, kanban, calendar, form, details, and other types of blocks that present data from a data collection and allow manipulation of the data. Obviously, customers, orders, and products are suitable for displaying and manipulating in a table block.
|
||||||
|
|
||||||
|
We add a table block to the "All Orders" page, select Collection `Orders` as the data source, and configure the columns to be displayed for this table block.
|
||||||
|
|
||||||
|
![1.block.gif](./5-minutes-to-get-started/1.block.gif)
|
||||||
|
|
||||||
|
Configure actions for this table block, including filter, add, delete, view, and edit.
|
||||||
|
|
||||||
|
![1.action.gif](./5-minutes-to-get-started/1.action.gif)
|
||||||
|
|
||||||
|
Configure form and detail blocks for add, edit, view actions.
|
||||||
|
|
||||||
|
![1.action-block.gif](./5-minutes-to-get-started/1.action-block.gif)
|
||||||
|
|
||||||
|
Then, lay out the form blocks on the Products and Customers pages with the same method. When you are done, exit the UI Editor mode and enter the usage mode, and a simple order management system is completed.
|
||||||
|
|
||||||
|
![1.finished.gif](./5-minutes-to-get-started/1.finished.gif)
|
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.action-block.gif
Executable file
After Width: | Height: | Size: 2.5 MiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.action.gif
Executable file
After Width: | Height: | Size: 715 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.block.gif
Executable file
After Width: | Height: | Size: 1.7 MiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.collections.jpg
Executable file
After Width: | Height: | Size: 220 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.customers.gif
Executable file
After Width: | Height: | Size: 842 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.editor.gif
Executable file
After Width: | Height: | Size: 44 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.fields.jpg
Executable file
After Width: | Height: | Size: 249 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.finished.gif
Executable file
After Width: | Height: | Size: 990 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.menu.gif
Executable file
After Width: | Height: | Size: 2.0 MiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/1.relation.jpg
Executable file
After Width: | Height: | Size: 225 KiB |
BIN
docs/en-US/user-manual/introduction/5-minutes-to-get-started/2.field.gif
Executable file
After Width: | Height: | Size: 1.3 MiB |
19
docs/en-US/user-manual/introduction/important-features.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Important Features
|
||||||
|
|
||||||
|
## 1. Separate "data structure" and "user interface"
|
||||||
|
|
||||||
|
Most form-, table-, or process-driven codeless products create data structures directly in the user interface, such as Airtable, where adding a new column to a table is adding a new field. This has the advantage of simplicity of use, but the disadvantage of limited functionality and flexibility to meet the needs of more complex scenarios.
|
||||||
|
|
||||||
|
NocoBase adopts the design idea of separating the data structure from the user interface, allowing you to create any number of blocks (data views) for the data collections, with different type, styles, content, and actions in each block. This takes into account the simplicity of codeless operation, but also the flexibility of native development.
|
||||||
|
|
||||||
|
![2.collection-block.png](./important-features/2.collection-block.png)
|
||||||
|
|
||||||
|
## 2. Separate "system configuration" and "system usage"
|
||||||
|
|
||||||
|
NocoBase is used to develop relatively complex business systems. In these scenarios, we want the system developers and the system users to be different roles. The user sees a mature, well-designed system, like a product developed natively, rather than a rigid, drag-and-drop free system that can be modified at any time; while the developer can quickly develop the system using a WYSIWYG approach.
|
||||||
|
|
||||||
|
![2.user-root.gif](./important-features/2.user-root.gif)
|
||||||
|
|
||||||
|
## 3. Everything is plugins
|
||||||
|
|
||||||
|
NocoBase adopts plugin architecture, all new features can be implemented by developing and installing plugins. In the future, we will build a plug-in marketplace where extending functionality is as easy as installing an APP on your phone.
|
BIN
docs/en-US/user-manual/introduction/important-features/2.collection-block.png
Executable file
After Width: | Height: | Size: 213 KiB |
BIN
docs/en-US/user-manual/introduction/important-features/2.user-root.gif
Executable file
After Width: | Height: | Size: 3.8 MiB |
9
docs/en-US/user-manual/introduction/why-nocobase.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Why NocoBase
|
||||||
|
|
||||||
|
NocoBase is designed for you if you have the following needs.
|
||||||
|
|
||||||
|
- Develop an internal management system
|
||||||
|
- Meet most of your business needs with codeless development
|
||||||
|
- Extremely easy to extend to meet your individual needs
|
||||||
|
- Private deployment with full control of code and data
|
||||||
|
- Free to use or you can pay for more technical support
|
10
docs/en-US/who.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Who is NocoBase for
|
||||||
|
|
||||||
|
NocoBase is designed for you if you have the following needs.
|
||||||
|
|
||||||
|
- Develop an internal management system
|
||||||
|
- Meet most of your business needs with no-code development
|
||||||
|
- Meet particular needs with regular development
|
||||||
|
- The system requires frequent changes
|
||||||
|
- Private deployment with full control of code and data
|
||||||
|
- Free to use or pay for more technical support
|
21
docs/en-US/why.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Why NocoBase is different
|
||||||
|
|
||||||
|
## 1. Separate "data structure" and "user interface"
|
||||||
|
|
||||||
|
Most form-, table-, or process-driven codeless products create data structures directly in the user interface, such as Airtable, where adding a new column to a table is adding a new field. This has the advantage of simplicity of use, but the disadvantage of limited functionality and flexibility to meet the needs of more complex scenarios.
|
||||||
|
|
||||||
|
NocoBase adopts the design idea of separating the data structure from the user interface, allowing you to create any number of blocks (data views) for the data collections, with different type, styles, content, and actions in each block. This takes into account the simplicity of codeless operation, but also the flexibility like native development.
|
||||||
|
|
||||||
|
![2.collection-block.png](./user-manual/introduction/important-features/2.collection-block.png)
|
||||||
|
|
||||||
|
## 2. Separate "system configuration" and "system usage"
|
||||||
|
|
||||||
|
NocoBase is used to develop relatively complex business systems. In these scenarios, we want the system developers and the system users to be different roles. The user sees a mature, well-designed system, like a product developed natively, rather than a rigid, drag-and-drop free system that can be modified at any time; while the developer can quickly develop the system using a WYSIWYG approach.
|
||||||
|
|
||||||
|
![2.user-root.gif](./user-manual/introduction/important-features/2.user-root.gif)
|
||||||
|
|
||||||
|
## 3. Everything is plugins
|
||||||
|
|
||||||
|
NocoBase adopts plugin architecture, all new features can be implemented by developing and installing plugins. In the future, we will build a plug-in marketplace where extending functionality is as easy as installing an APP on your phone.
|
||||||
|
|
||||||
|
![](https://www.nocobase.com/images/NocoBaseMindMapLite.png)
|
139
docs/menus.ts
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
export default [
|
||||||
|
{
|
||||||
|
title: 'Welcome',
|
||||||
|
'title.zh-CN': '欢迎',
|
||||||
|
type: 'group',
|
||||||
|
children: [
|
||||||
|
'/index',
|
||||||
|
'/why',
|
||||||
|
'/who',
|
||||||
|
'/roadmap',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Getting started',
|
||||||
|
'title.zh-CN': '快速开始',
|
||||||
|
type: 'group',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
title: 'Installation',
|
||||||
|
'title.zh-CN': '安装',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/getting-started/installation/overview',
|
||||||
|
'/getting-started/installation/docker-compose',
|
||||||
|
'/getting-started/installation/create-nocobase-app',
|
||||||
|
'/getting-started/installation/git-clone',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'/getting-started/upgrading',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'User manual',
|
||||||
|
'title.zh-CN': '用户手册',
|
||||||
|
type: 'group',
|
||||||
|
children: [
|
||||||
|
'/user-manual/introduction/5-minutes-to-get-started',
|
||||||
|
{
|
||||||
|
title: 'Advanced guide',
|
||||||
|
'title.zh-CN': '深入 NocoBase',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/user-manual/advanced-guide/functional-zoning',
|
||||||
|
'/user-manual/advanced-guide/collections',
|
||||||
|
'/user-manual/advanced-guide/menus',
|
||||||
|
'/user-manual/advanced-guide/blocks',
|
||||||
|
'/user-manual/advanced-guide/actions',
|
||||||
|
'/user-manual/advanced-guide/roles-permissions',
|
||||||
|
'/user-manual/advanced-guide/tabs',
|
||||||
|
'/user-manual/advanced-guide/file-storages',
|
||||||
|
'/user-manual/advanced-guide/system-settings',
|
||||||
|
'/user-manual/advanced-guide/plugins',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Development',
|
||||||
|
'title.zh-CN': '开发指南',
|
||||||
|
type: 'group',
|
||||||
|
children: [
|
||||||
|
'/development/directory-structure',
|
||||||
|
'/development/env',
|
||||||
|
'/development/nocobase-cli',
|
||||||
|
{
|
||||||
|
title: 'HTTP API',
|
||||||
|
'title.zh-CN': 'HTTP API',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/development/http-api/index',
|
||||||
|
'/development/http-api/rest-api',
|
||||||
|
'/development/http-api/action-api',
|
||||||
|
'/development/http-api/javascript-sdk',
|
||||||
|
'/development/http-api/filter-operators',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'/development/javascript-sdk',
|
||||||
|
{
|
||||||
|
title: 'Plugin development',
|
||||||
|
'title.zh-CN': '插件开发',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/development/plugin-development/index',
|
||||||
|
{
|
||||||
|
title: 'Server',
|
||||||
|
'title.zh-CN': 'Server',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/development/plugin-development/server/overview',
|
||||||
|
'/development/plugin-development/server/database',
|
||||||
|
'/development/plugin-development/server/resourcer',
|
||||||
|
'/development/plugin-development/server/middleware',
|
||||||
|
'/development/plugin-development/server/acl',
|
||||||
|
'/development/plugin-development/server/events',
|
||||||
|
'/development/plugin-development/server/i18n',
|
||||||
|
'/development/plugin-development/server/cli',
|
||||||
|
'/development/plugin-development/server/app-manager',
|
||||||
|
'/development/plugin-development/server/plugin-manager',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Client',
|
||||||
|
'title.zh-CN': 'Client',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/development/plugin-development/client/overview',
|
||||||
|
{
|
||||||
|
title: 'Providers',
|
||||||
|
'title.zh-CN': 'Providers',
|
||||||
|
type: 'subMenu',
|
||||||
|
children: [
|
||||||
|
'/development/plugin-development/client/providers/acl',
|
||||||
|
'/development/plugin-development/client/providers/antd',
|
||||||
|
'/development/plugin-development/client/providers/api-client',
|
||||||
|
'/development/plugin-development/client/providers/collection-manager',
|
||||||
|
'/development/plugin-development/client/providers/i18n',
|
||||||
|
'/development/plugin-development/client/providers/route-switch',
|
||||||
|
'/development/plugin-development/client/providers/schema-component',
|
||||||
|
'/development/plugin-development/client/providers/schema-initializer',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Community',
|
||||||
|
'title.zh-CN': '社区',
|
||||||
|
type: 'group',
|
||||||
|
children: [
|
||||||
|
'/contributing',
|
||||||
|
'/release-notes',
|
||||||
|
'/faq',
|
||||||
|
'/thanks',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
];
|
47
docs/zh-CN/contributing.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 贡献
|
||||||
|
|
||||||
|
- Fork 源代码到自己的仓库
|
||||||
|
- 修改源代码
|
||||||
|
- 提交 Pull Request
|
||||||
|
|
||||||
|
## 下载项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 替换为自己的仓库地址
|
||||||
|
git clone https://github.com/nocobase/nocobase.git
|
||||||
|
cd nocobase
|
||||||
|
yarn install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 应用开发与测试
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装并启动应用
|
||||||
|
yarn dev
|
||||||
|
# 运行所有测试
|
||||||
|
yarn test
|
||||||
|
# 运行文件夹下所有测试文件
|
||||||
|
yarn test <dir>
|
||||||
|
# 运行单个测试文件
|
||||||
|
yarn test <file>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 文档预览
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动文档
|
||||||
|
yarn doc --lang=zh-CN
|
||||||
|
yarn doc --lang=en-US
|
||||||
|
```
|
||||||
|
|
||||||
|
文档在 docs 目录下,遵循 Markdown 语法
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|- /docs/
|
||||||
|
|- en-US
|
||||||
|
|- zh-CN
|
||||||
|
```
|
||||||
|
|
||||||
|
## 其他
|
||||||
|
|
||||||
|
更多 Commands 使用说明 [参考 NocoBase CLI 章节](./development/nocobase-cli.md)
|
89
docs/zh-CN/development/directory-structure.md
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
# 目录结构
|
||||||
|
|
||||||
|
## 应用脚手架
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn create nocobase-app my-nocobase-app
|
||||||
|
```
|
||||||
|
|
||||||
|
通过 `create-nocobase-app` 创建的应用脚手架目录结构如下:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── my-nocobase-app
|
||||||
|
├── packages # 采用 Monorepo 的方式管理代码,将不同模块划分到不同包里
|
||||||
|
├── app
|
||||||
|
├── client # 客户端模块
|
||||||
|
├── server # 服务端模块
|
||||||
|
├── plugins # 插件目录
|
||||||
|
├── storages # 用于存放数据库文件、附件、缓存等
|
||||||
|
├── db
|
||||||
|
├── .env # 环境变量
|
||||||
|
├── .buildrc.ts # packages 的打包配置,支持 cjs、esm 和 umd 三种格式的打包。
|
||||||
|
├── jest.config.js
|
||||||
|
├── jest.setup.ts
|
||||||
|
├── lerna.json
|
||||||
|
├── package.json
|
||||||
|
├── tsconfig.jest.json
|
||||||
|
├── tsconfig.json
|
||||||
|
├── tsconfig.server.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### packages 目录
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── packages
|
||||||
|
├── app
|
||||||
|
├── client
|
||||||
|
├── public
|
||||||
|
├── src
|
||||||
|
├── pages
|
||||||
|
├── index.tsx
|
||||||
|
├── .umirc.ts
|
||||||
|
├── package.json
|
||||||
|
├── server
|
||||||
|
├── src
|
||||||
|
├── config
|
||||||
|
├── index.ts
|
||||||
|
├── package.json
|
||||||
|
├── /plugins
|
||||||
|
├── my-plugin
|
||||||
|
├── src
|
||||||
|
├── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
NocoBase 采用 Monorepo 的方式管理代码,将不同模块划分到不同包里。
|
||||||
|
|
||||||
|
- `app/client` 为应用的客户端模块,基于 [umi](https://umijs.org/zh-CN) 构建;
|
||||||
|
- `app/server` 为应用的服务端模块;
|
||||||
|
- `plugins/*` 目录里可以放各种插件。
|
||||||
|
|
||||||
|
### storages 目录
|
||||||
|
|
||||||
|
用于存放数据库文件、附件、缓存等。
|
||||||
|
|
||||||
|
### .env 文件
|
||||||
|
|
||||||
|
环境变量。
|
||||||
|
|
||||||
|
### .buildrc.ts 文件
|
||||||
|
|
||||||
|
packages 的打包配置,支持 cjs、esm 和 umd 三种格式的打包。
|
||||||
|
|
||||||
|
## 插件脚手架
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase create-plugin my-plugin
|
||||||
|
```
|
||||||
|
|
||||||
|
通过 `nocobase create-plugin` 初始化的插件脚手架目录如下:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
├── my-nocobase-app
|
||||||
|
├── packages
|
||||||
|
├── plugins
|
||||||
|
├── my-plugin
|
||||||
|
├── src
|
||||||
|
├── client
|
||||||
|
├── server
|
||||||
|
├── package.json
|
||||||
|
```
|
207
docs/zh-CN/development/env.md
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
# 环境变量
|
||||||
|
|
||||||
|
## 全局环境变量
|
||||||
|
|
||||||
|
保存在 `.env` 文件里
|
||||||
|
|
||||||
|
### APP_ENV
|
||||||
|
|
||||||
|
应用环境,默认值 `development`,可选项包括:
|
||||||
|
|
||||||
|
- `production` 生产环境
|
||||||
|
- `development` 开发环境
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_ENV=production
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_HOST
|
||||||
|
|
||||||
|
应用主机,默认值 `0.0.0.0`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_HOST=192.168.3.154
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_PORT
|
||||||
|
|
||||||
|
应用端口,默认值 `13000`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_PORT=13000
|
||||||
|
```
|
||||||
|
|
||||||
|
### APP_KEY
|
||||||
|
|
||||||
|
秘钥,用于 jwt 等场景
|
||||||
|
|
||||||
|
```bash
|
||||||
|
APP_KEY=app-key-test
|
||||||
|
```
|
||||||
|
|
||||||
|
### API_BASE_PATH
|
||||||
|
|
||||||
|
NocoBase API 地址前缀,默认值 `/api/`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
API_BASE_PATH=/api/
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_DIALECT
|
||||||
|
|
||||||
|
数据库类型,默认值 `sqlite`,可选项包括:
|
||||||
|
|
||||||
|
- `sqlite`
|
||||||
|
- `mysql`
|
||||||
|
- `postgres`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_DIALECT=mysql
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_STORAGE
|
||||||
|
|
||||||
|
数据库文件路径(使用 SQLite 数据库时配置)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 相对路径
|
||||||
|
DB_HOST=storage/db/nocobase.db
|
||||||
|
# 绝对路径
|
||||||
|
DB_HOST=/your/path/nocobase.db
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_HOST
|
||||||
|
|
||||||
|
数据库主机(使用 mysql 或 postgres 数据库时需要配置)
|
||||||
|
|
||||||
|
默认值 `localhost`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_HOST=localhost
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_PORT
|
||||||
|
|
||||||
|
数据库端口(使用 mysql 或 postgres 数据库时需要配置)
|
||||||
|
|
||||||
|
- MySQL 默认端口 3356
|
||||||
|
- PostgreSQL 默认端口 5432
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_PORT=3356
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_DATABASE
|
||||||
|
|
||||||
|
数据库名(使用 mysql 或 postgres 数据库时需要配置)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_DATABASE=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_USER
|
||||||
|
|
||||||
|
数据库用户(使用 mysql 或 postgres 数据库时需要配置)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_USER=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_PASSWORD
|
||||||
|
|
||||||
|
数据库密码(使用 mysql 或 postgres 数据库时需要配置)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_PASSWORD=nocobase
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_TABLE_PREFIX
|
||||||
|
|
||||||
|
数据表前缀
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_TABLE_PREFIX=nocobase_
|
||||||
|
```
|
||||||
|
|
||||||
|
### DB_LOGGING
|
||||||
|
|
||||||
|
数据库日志开关,默认值 `off`,可选项包括:
|
||||||
|
|
||||||
|
- `on` 打开
|
||||||
|
- `off` 关闭
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DB_LOGGING=on
|
||||||
|
```
|
||||||
|
|
||||||
|
## 临时环境变量
|
||||||
|
|
||||||
|
安装 NocoBase 时,可以通过设置临时的环境变量来辅助安装,如:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=zh-CN \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
INIT_ROOT_NICKNAME="Super Admin" \
|
||||||
|
nocobase install
|
||||||
|
|
||||||
|
# 等同于
|
||||||
|
yarn nocobase install \
|
||||||
|
--lang=zh-CN \
|
||||||
|
--root-email=demo@nocobase.com \
|
||||||
|
--root-password=admin123 \
|
||||||
|
--root-nickname="Super Admin"
|
||||||
|
|
||||||
|
# 等同于
|
||||||
|
yarn nocobase install -l zh-CN -e demo@nocobase.com -p admin123 -n "Super Admin"
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_APP_LANG
|
||||||
|
|
||||||
|
安装时的语言,默认值 `en-US`,可选项包括:
|
||||||
|
|
||||||
|
- `en-US`
|
||||||
|
- `zh-CN`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=zh-CN \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_EMAIL
|
||||||
|
|
||||||
|
Root 用户邮箱
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=zh-CN \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_PASSWORD
|
||||||
|
|
||||||
|
Root 用户密码
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=zh-CN \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
nocobase install
|
||||||
|
```
|
||||||
|
|
||||||
|
### INIT_ROOT_NICKNAME
|
||||||
|
|
||||||
|
Root 用户昵称
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn cross-env \
|
||||||
|
INIT_APP_LANG=zh-CN \
|
||||||
|
INIT_ROOT_EMAIL=demo@nocobase.com \
|
||||||
|
INIT_ROOT_PASSWORD=admin123 \
|
||||||
|
INIT_ROOT_NICKNAME="Super Admin" \
|
||||||
|
nocobase install
|
||||||
|
```
|
146
docs/zh-CN/development/http-api/action-api.md
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# Action API
|
||||||
|
|
||||||
|
## Common
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Collection 和 Association 资源通用。
|
||||||
|
|
||||||
|
### `create`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create?whitelist=a,b&blacklist=c,d
|
||||||
|
|
||||||
|
{} # Request Body
|
||||||
|
```
|
||||||
|
|
||||||
|
- Parameters
|
||||||
|
- whitelist 白名单
|
||||||
|
- blacklist 黑名单
|
||||||
|
- Request body: 待插入的 JSON 数据
|
||||||
|
- Response body data: 已创建的数据 JSON
|
||||||
|
|
||||||
|
#### 新增用户
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"email": "demo@nocobase.com",
|
||||||
|
"name": "Admin"
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 新增用户文章
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users/1/posts:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post"
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Request Body 里的 association
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"user": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"id": 1,
|
||||||
|
"title": "My first post",
|
||||||
|
"userId": 1,
|
||||||
|
"user": {
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `update`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/users:create?filterByTk=1&whitelist=a,b&blacklist=c,d
|
||||||
|
|
||||||
|
{} # Request Body
|
||||||
|
```
|
||||||
|
|
||||||
|
- Parameters
|
||||||
|
- whitelist 白名单
|
||||||
|
- blacklist 黑名单
|
||||||
|
- filterByTk 根据 tk 字段过滤,默认情况 tk 为数据表的主键
|
||||||
|
- filter 过滤,支持 json string
|
||||||
|
- Request body: 待更新的 JSON 数据
|
||||||
|
|
||||||
|
#### Request Body 里的 association
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:update/1
|
||||||
|
|
||||||
|
Request Body
|
||||||
|
{
|
||||||
|
"title": "My first post 2",
|
||||||
|
"user": 2
|
||||||
|
}
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"title": "My first post 2",
|
||||||
|
"userId": 2,
|
||||||
|
"user": {
|
||||||
|
"id": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `list`
|
||||||
|
|
||||||
|
### `get`
|
||||||
|
|
||||||
|
### `destroy`
|
||||||
|
|
||||||
|
### `move`
|
||||||
|
|
||||||
|
## Association
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `add`
|
||||||
|
|
||||||
|
### `set`
|
||||||
|
|
||||||
|
### `remove`
|
||||||
|
|
||||||
|
### `toggle`
|
||||||
|
|
||||||
|
|
||||||
|
|
59
docs/zh-CN/development/http-api/filter-operators.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# Filter operators
|
||||||
|
|
||||||
|
## 通用
|
||||||
|
|
||||||
|
- $eq
|
||||||
|
- $ne
|
||||||
|
- $gte
|
||||||
|
- $gt
|
||||||
|
- $lte
|
||||||
|
- $lt
|
||||||
|
- $not
|
||||||
|
- $is
|
||||||
|
- $in
|
||||||
|
- $notIn
|
||||||
|
- $like
|
||||||
|
- $notLike
|
||||||
|
- $iLike
|
||||||
|
- $notILike
|
||||||
|
- $and
|
||||||
|
- $or
|
||||||
|
- $empty
|
||||||
|
- $notEmpty
|
||||||
|
|
||||||
|
## array
|
||||||
|
|
||||||
|
- $match
|
||||||
|
- $notMatch
|
||||||
|
- $anyOf
|
||||||
|
- $noneOf
|
||||||
|
- $arrayEmpty
|
||||||
|
- $arrayNotEmpty
|
||||||
|
|
||||||
|
## association
|
||||||
|
|
||||||
|
- $exists
|
||||||
|
- $notExists
|
||||||
|
|
||||||
|
## boolean
|
||||||
|
|
||||||
|
- $truthy
|
||||||
|
- $falsy
|
||||||
|
|
||||||
|
## date
|
||||||
|
|
||||||
|
- $dateOn
|
||||||
|
- $dateNotOn
|
||||||
|
- $dateBefore
|
||||||
|
- $dateNotBefore
|
||||||
|
- $dateAfter
|
||||||
|
- $dateNotAfter
|
||||||
|
|
||||||
|
## string
|
||||||
|
|
||||||
|
- $includes
|
||||||
|
- $notIncludes
|
||||||
|
- $startsWith
|
||||||
|
- $notStartsWith
|
||||||
|
- $endWith
|
||||||
|
- $notEndWith
|
307
docs/zh-CN/development/http-api/index.md
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
# 概述
|
||||||
|
|
||||||
|
NocoBase 的 HTTP API 基于 Resource & Action 设计,是 REST API 的超集,操作不局限于增删改查,在 NocoBase 里,Resource Action 可以任意的扩展。
|
||||||
|
|
||||||
|
## 资源 Resource
|
||||||
|
|
||||||
|
在 NocoBase 里,资源(resource)有两种表达方式:
|
||||||
|
|
||||||
|
- `<collection>`
|
||||||
|
- `<collection>.<association>`
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
- collection 是所有抽象数据的集合
|
||||||
|
- association 为 collection 的关联数据
|
||||||
|
- resource 包括 collection 和 collection.association 两类
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
|
||||||
|
- `posts` 文章
|
||||||
|
- `posts.user` 文章用户
|
||||||
|
- `posts.tags` 文章标签
|
||||||
|
|
||||||
|
## 操作 Action
|
||||||
|
|
||||||
|
以 `:<action>` 的方式表示资源操作
|
||||||
|
|
||||||
|
- `<collection>:<action>`
|
||||||
|
- `<collection>.<association>:<action>`
|
||||||
|
|
||||||
|
内置的全局操作,可用于 collection 或 association
|
||||||
|
|
||||||
|
- `create`
|
||||||
|
- `get`
|
||||||
|
- `list`
|
||||||
|
- `update`
|
||||||
|
- `destroy`
|
||||||
|
- `move`
|
||||||
|
|
||||||
|
内置的关联操作,仅用于 association
|
||||||
|
|
||||||
|
- `set`
|
||||||
|
- `add`
|
||||||
|
- `remove`
|
||||||
|
- `toggle`
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
|
||||||
|
- `posts:create` 创建文章
|
||||||
|
- `posts.user:get` 查看文章用户
|
||||||
|
- `posts.tags:add` 附加文章标签(将现有的标签与文章关联)
|
||||||
|
|
||||||
|
## 请求 URL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
<GET|POST> /api/<collection>:<action>
|
||||||
|
<GET|POST> /api/<collection>:<action>/<collectionIndex>
|
||||||
|
<GET|POST> /api/<collection>/<collectionIndex>/<association>:<action>
|
||||||
|
<GET|POST> /api/<collection>/<collectionIndex>/<association>:<action>/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
|
||||||
|
posts 资源
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
GET /api/posts:list
|
||||||
|
GET /api/posts:get/1
|
||||||
|
POST /api/posts:update/1
|
||||||
|
POST /api/posts:destroy/1
|
||||||
|
```
|
||||||
|
|
||||||
|
posts.comments 资源
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts/1/comments:create
|
||||||
|
GET /api/posts/1/comments:list
|
||||||
|
GET /api/posts/1/comments:get/1
|
||||||
|
POST /api/posts/1/comments:update/1
|
||||||
|
POST /api/posts/1/comments:destroy/1
|
||||||
|
```
|
||||||
|
|
||||||
|
posts.tags 资源
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts/1/tags:create
|
||||||
|
GET /api/posts/1/tags:get
|
||||||
|
GET /api/posts/1/tags:list
|
||||||
|
POST /api/posts/1/tags:update
|
||||||
|
POST /api/posts/1/tags:destroy
|
||||||
|
POST /api/posts/1/tags:add
|
||||||
|
GET /api/posts/1/tags:remove
|
||||||
|
```
|
||||||
|
|
||||||
|
## 资源定位
|
||||||
|
|
||||||
|
- collection 资源,通过 `collectionIndex` 定位到待处理的数据,`collectionIndex` 必须唯一
|
||||||
|
- association 资源,通过 `collectionIndex` 和 `associationIndex` 联合定位待处理的数据,`associationIndex` 可能不是唯一的,但是 `collectionIndex` 和 `associationIndex` 的联合索引必须唯一
|
||||||
|
|
||||||
|
查看 association 资源详情时,请求的 URL 需要同时提供 `<collectionIndex>` 和 `<associationIndex>`,`<collectionIndex>` 并不多余,因为 `<associationIndex>` 可能不是唯一的。
|
||||||
|
|
||||||
|
例如 `tables.fields` 表示数据表的字段
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/tables/table1/fields/title
|
||||||
|
GET /api/tables/table2/fields/title
|
||||||
|
```
|
||||||
|
|
||||||
|
table1 和 table2 都有 title 字段,title 在 table1 里是唯一的,但是其他表也可能有 title 字段
|
||||||
|
|
||||||
|
## 请求参数
|
||||||
|
|
||||||
|
请求的参数可以放在 Request 的 headers、parameters(query string)、body(GET 请求没有 body) 里。
|
||||||
|
|
||||||
|
几个特殊的 Parameters 请求参数
|
||||||
|
|
||||||
|
- `filter` 数据过滤,用于查询相关操作里;
|
||||||
|
- `filterByTk` 根据 tk 字段字过滤,用于指定详情数据的操作里;
|
||||||
|
- `sort` 排序,用于查询相关操作里。
|
||||||
|
- `fields` 输出哪些数据,用于查询相关操作里;
|
||||||
|
- `appends` 附加关系字段,用于查询相关操作里;
|
||||||
|
- `except` 排除哪些字段(不输出),用于查询相关操作里;
|
||||||
|
- `whitelist` 字段白名单,用于数据的创建和更新相关操作里;
|
||||||
|
- `blacklist` 字段黑名单,用于数据的创建和更新相关操作里;
|
||||||
|
|
||||||
|
### filter
|
||||||
|
|
||||||
|
数据过滤
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# simple
|
||||||
|
GET /api/posts?filter[status]=publish
|
||||||
|
# 推荐使用 json string 的格式,需要 encodeURIComponent 编码
|
||||||
|
GET /api/posts?filter={"status":"published"}
|
||||||
|
|
||||||
|
# filter operators
|
||||||
|
GET /api/posts?filter[status.$eq]=publish
|
||||||
|
GET /api/posts?filter={"status.$eq":"published"}
|
||||||
|
|
||||||
|
# $and
|
||||||
|
GET /api/posts?filter={"$and": [{"status.$eq":"published"}, {"title.$includes":"a"}]}
|
||||||
|
# $or
|
||||||
|
GET /api/posts?filter={"$or": [{"status.$eq":"pending"}, {"status.$eq":"draft"}]}
|
||||||
|
|
||||||
|
# association field
|
||||||
|
GET /api/posts?filter[user.email.$includes]=gmail
|
||||||
|
GET /api/posts?filter={"user.email.$includes":"gmail"}
|
||||||
|
```
|
||||||
|
|
||||||
|
[点此查看更多关于 filter operators 的内容](http-api/filter-operators)
|
||||||
|
|
||||||
|
### filterByTk
|
||||||
|
|
||||||
|
根据 tk 字段过滤,默认情况:
|
||||||
|
|
||||||
|
- collection 资源,tk 为数据表的主键;
|
||||||
|
- association 资源,tk 为 association 的 targetKey 字段。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:get?filterByTk=1&fields=name,title&appends=tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### sort
|
||||||
|
|
||||||
|
排序。降序时,字段前面加上减号 `-`。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# createAt 字段升序
|
||||||
|
GET /api/posts:get?sort=createdAt
|
||||||
|
# createAt 字段降序
|
||||||
|
GET /api/posts:get?sort=-createdAt
|
||||||
|
# 多个字段联合排序,createAt 字段降序、title A-Z 升序
|
||||||
|
GET /api/posts:get?sort=-createdAt,title
|
||||||
|
```
|
||||||
|
|
||||||
|
### fields
|
||||||
|
|
||||||
|
输出哪些数据
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:list?fields=name,title
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"title": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### appends
|
||||||
|
|
||||||
|
附加关系字段
|
||||||
|
|
||||||
|
### except
|
||||||
|
|
||||||
|
排除哪些字段(不输出),用于查询相关操作里;
|
||||||
|
|
||||||
|
### whitelist
|
||||||
|
|
||||||
|
白名单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create?whitelist=title
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"date": "2022-05-19" # date 字段会被过滤掉,不会写入数据库
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### blacklist
|
||||||
|
|
||||||
|
黑名单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create?blacklist=date
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "My first post",
|
||||||
|
"date": "2022-05-19" # date 字段会被过滤掉,不会写入数据库
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 请求响应
|
||||||
|
|
||||||
|
响应的格式
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type ResponseResult = {
|
||||||
|
data?: any; // 主体数据
|
||||||
|
meta?: any; // 附加数据
|
||||||
|
errors?: ResponseError[]; // 报错
|
||||||
|
};
|
||||||
|
|
||||||
|
type ResponseError = {
|
||||||
|
code?: string;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
|
||||||
|
查看列表
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:list
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
count: 1
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
totalPage: 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
查看详情
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/posts:get/1
|
||||||
|
|
||||||
|
Response 200 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
id: 1
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
count: 1
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
totalPage: 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
报错
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/posts:create
|
||||||
|
|
||||||
|
Response 400 (application/json)
|
||||||
|
|
||||||
|
{
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
message: 'name must be required',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
```
|
229
docs/zh-CN/development/http-api/javascript-sdk.md
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
# JavaScript SDK
|
||||||
|
|
||||||
|
## APIClient
|
||||||
|
|
||||||
|
```ts
|
||||||
|
class APIClient {
|
||||||
|
// axios 实例
|
||||||
|
axios: AxiosInstance;
|
||||||
|
// 构造器
|
||||||
|
constructor(instance?: AxiosInstance | AxiosRequestConfig);
|
||||||
|
// 客户端请求,支持 AxiosRequestConfig 和 ResourceActionOptions
|
||||||
|
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D> | ResourceActionOptions): Promise<R>;
|
||||||
|
// 获取资源
|
||||||
|
resource<R = IResource>(name: string, of?: any): R;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
初始化实例
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import axios from 'axios';
|
||||||
|
import { APIClient } from '@nocobase/sdk';
|
||||||
|
|
||||||
|
// 提供 AxiosRequestConfig 配置参数
|
||||||
|
const api = new APIClient({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 提供 AxiosInstance
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
const api = new APIClient(instance);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Mock
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { APIClient } from '@nocobase/sdk';
|
||||||
|
import MockAdapter from 'axios-mock-adapter';
|
||||||
|
|
||||||
|
const api = new APIClient({
|
||||||
|
baseURL: 'https://localhost:8000/api',
|
||||||
|
});
|
||||||
|
|
||||||
|
const mock = new MockAdapter(api.axios);
|
||||||
|
|
||||||
|
mock.onGet('users:get').reply(200, {
|
||||||
|
data: { id: 1, name: 'John Smith' },
|
||||||
|
});
|
||||||
|
|
||||||
|
await api.request({ url: 'users:get' });
|
||||||
|
```
|
||||||
|
|
||||||
|
## Auth
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// 直接传 token
|
||||||
|
api.auth.token = '123';
|
||||||
|
// 或者通过 signIn 登录
|
||||||
|
api.auth.signIn();
|
||||||
|
// 注销并删除 token 缓存
|
||||||
|
api.auth.signOut();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Request
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// url
|
||||||
|
await api.request({
|
||||||
|
url: 'users:list',
|
||||||
|
// request params
|
||||||
|
params: {
|
||||||
|
filter: {
|
||||||
|
'email.$includes': 'noco',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// request body
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
|
||||||
|
// resource & action
|
||||||
|
await api.request({
|
||||||
|
resource: 'users',
|
||||||
|
action: 'list',
|
||||||
|
// action params
|
||||||
|
params: {
|
||||||
|
filter: {
|
||||||
|
'email.$includes': 'noco',
|
||||||
|
},
|
||||||
|
page: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resource action
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await api.resource('collection')[action]();
|
||||||
|
await api.resource('collection.association', collectionId)[action]();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Action API
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await api.resource('collection').create();
|
||||||
|
await api.resource('collection').get();
|
||||||
|
await api.resource('collection').list();
|
||||||
|
await api.resource('collection').update();
|
||||||
|
await api.resource('collection').destroy();
|
||||||
|
await api.resource('collection.association', collectionId).create();
|
||||||
|
await api.resource('collection.association', collectionId).get();
|
||||||
|
await api.resource('collection.association', collectionId).list();
|
||||||
|
await api.resource('collection.association', collectionId).update();
|
||||||
|
await api.resource('collection.association', collectionId).destroy();
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
get: (options?: GetActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
fields?: string || string[];
|
||||||
|
appends?: string || string[];
|
||||||
|
expect?: string || string[];
|
||||||
|
sort?: string[];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `list`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
list: (options?: ListActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ListActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
fields?: string || string[];
|
||||||
|
appends?: string || string[];
|
||||||
|
expect?: string || string[];
|
||||||
|
sort?: string[];
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
paginate?: boolean;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `create`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
create: (options?: CreateActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CreateActionOptions {
|
||||||
|
whitelist?: string[];
|
||||||
|
blacklist?: string[];
|
||||||
|
values?: {[key: sting]: any};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `update`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
update: (options?: UpdateActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UpdateActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
whitelist?: string[];
|
||||||
|
blacklist?: string[];
|
||||||
|
values?: {[key: sting]: any};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `destroy`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
destroy: (options?: DestroyActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DestroyActionOptions {
|
||||||
|
filter?: any;
|
||||||
|
filterByTk?: any;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `move`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface Resource {
|
||||||
|
move: (options?: MoveActionOptions) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MoveActionOptions {
|
||||||
|
sourceId: any;
|
||||||
|
targetId?: any;
|
||||||
|
/** @default 'sort' */
|
||||||
|
sortField?: any;
|
||||||
|
targetScope?: {[key: string]: any};
|
||||||
|
sticky?: boolean;
|
||||||
|
method?: 'insertAfter' | 'prepend';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `<custom>`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
interface AttachmentResource {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UploadActionOptions {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
api.resource<AttachmentResource>('attachments').upload();
|
||||||
|
api.resource('attachments').upload<UploadActionOptions>();
|
||||||
|
```
|
184
docs/zh-CN/development/http-api/rest-api.md
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
# REST API
|
||||||
|
|
||||||
|
NocoBase 的 HTTP API 是 REST API 的超集,标准的 CRUD API 也支持 RESTful 风格。
|
||||||
|
|
||||||
|
## Collection 资源
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 创建 collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:create
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### 查看 collection 列表
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>:list
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 查看 collection 详情
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>:get?filterByTk=<collectionIndex>
|
||||||
|
GET /api/<collection>:get/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 更新 collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:update?filterByTk=<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
|
||||||
|
# 或者
|
||||||
|
POST /api/<collection>:update/<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PUT /api/<collection>/<collectionIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### 删除 collection
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>:destroy?filterByTk=<collectionIndex>
|
||||||
|
# 或者
|
||||||
|
POST /api/<collection>:destroy/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DELETE /api/<collection>/<collectionIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Association 资源
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 创建 Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:create
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
### 查看 Association 列表
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:list
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 查看 Association 详情
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get?filterByTk=<associationIndex>
|
||||||
|
# 或者
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 更新 Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:update?filterByTk=<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
|
||||||
|
# 或者
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON body
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PUT /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
||||||
|
|
||||||
|
{} # JSON 数据
|
||||||
|
```
|
||||||
|
|
||||||
|
### 删除 Association
|
||||||
|
|
||||||
|
HTTP API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:destroy?filterByTk=<associationIndex>
|
||||||
|
# 或者
|
||||||
|
POST /api/<collection>/<collectionIndex>/<association>:destroy/<associationIndex>
|
||||||
|
```
|
||||||
|
|
||||||
|
REST API
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DELETE /api/<collection>/<collectionIndex>/<association>/<associationIndex>
|
||||||
|
```
|
310
docs/zh-CN/development/nocobase-cli.md
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
---
|
||||||
|
order: 2
|
||||||
|
---
|
||||||
|
|
||||||
|
# NocoBase CLI
|
||||||
|
|
||||||
|
NocoBase CLI 旨在帮助你开发、构建和部署 NocoBase 应用。
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
NocoBase CLI 支持 ts-node 和 node 两种运行模式
|
||||||
|
|
||||||
|
- ts-node 模式(默认):用于开发环境,支持实时编译,但是响应较慢
|
||||||
|
- node 模式:用于生产环境,响应迅速,但需要先执行 `yarn nocobase build` 将全部源码进行编译
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
## 使用说明
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase -h
|
||||||
|
|
||||||
|
Usage: nocobase [command] [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
create-plugin 创建插件脚手架
|
||||||
|
console
|
||||||
|
db:auth 校验数据库是否连接成功
|
||||||
|
db:sync 通过 collections 配置生成相关数据表和字段
|
||||||
|
install 安装
|
||||||
|
start 生产环境启动应用
|
||||||
|
build 编译打包
|
||||||
|
clean 删除编译之后的文件
|
||||||
|
dev 启动应用,用于开发环境,支持实时编译
|
||||||
|
doc 文档开发
|
||||||
|
test 测试
|
||||||
|
umi
|
||||||
|
upgrade 升级
|
||||||
|
help
|
||||||
|
```
|
||||||
|
|
||||||
|
## 在脚手架里应用
|
||||||
|
|
||||||
|
应用脚手架 `package.json` 里的 `scripts` 如下:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"dev": "nocobase dev",
|
||||||
|
"start": "nocobase start",
|
||||||
|
"clean": "nocobase clean",
|
||||||
|
"build": "nocobase build",
|
||||||
|
"test": "nocobase test",
|
||||||
|
"postinstall": "nocobase umi generate tmp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 命令行扩展
|
||||||
|
|
||||||
|
NocoBase CLI 基于 [commander](https://github.com/tj/commander.js) 构建,你可以自由扩展命令,扩展的 command 可以写在 `app/server/index.ts` 里:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const app = new Application(config);
|
||||||
|
|
||||||
|
app.command('hello').action(() => {});
|
||||||
|
```
|
||||||
|
|
||||||
|
或者,写在插件里:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
class MyPlugin extends Plugin {
|
||||||
|
beforeLoad() {
|
||||||
|
this.app.command('hello').action(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
终端运行
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## 内置命令行
|
||||||
|
|
||||||
|
按使用频率排序
|
||||||
|
|
||||||
|
### `dev`
|
||||||
|
|
||||||
|
开发环境下,启动应用,代码实时编译。
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
NocoBase 未安装时,会自动安装(参考 install 命令)
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Usage: nocobase dev [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --port [port]
|
||||||
|
--client
|
||||||
|
--server
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动应用,用于开发环境,实时编译
|
||||||
|
yarn nocobase dev
|
||||||
|
# 只启动服务端
|
||||||
|
yarn nocobase dev --server
|
||||||
|
# 只启动客户端
|
||||||
|
yarn nocobase dev --client
|
||||||
|
```
|
||||||
|
|
||||||
|
### `start`
|
||||||
|
|
||||||
|
生产环境下,启动应用,代码需要 yarn build。
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
- NocoBase 未安装时,会自动安装(参考 install 命令)
|
||||||
|
- 源码有修改时,需要重新打包(参考 build 命令)
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase start -h
|
||||||
|
|
||||||
|
Usage: nocobase start [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --port
|
||||||
|
-s, --silent
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动应用,用于生产环境,
|
||||||
|
yarn nocobase start
|
||||||
|
```
|
||||||
|
|
||||||
|
### `install`
|
||||||
|
|
||||||
|
安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase install -h
|
||||||
|
|
||||||
|
Usage: nocobase install [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --force
|
||||||
|
-c, --clean
|
||||||
|
-s, --silent
|
||||||
|
-l, --lang [lang]
|
||||||
|
-e, --root-email <rootEmail>
|
||||||
|
-p, --root-password <rootPassword>
|
||||||
|
-n, --root-nickname [rootNickname]
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 初始安装
|
||||||
|
yarn nocobase install -l zh-CN -e admin@nocobase.com -p admin123
|
||||||
|
# 删除 NocoBase 的所有数据表,并重新安装
|
||||||
|
yarn nocobase install -f -l zh-CN -e admin@nocobase.com -p admin123
|
||||||
|
# 清空数据库,并重新安装
|
||||||
|
yarn nocobase install -c -l zh-CN -e admin@nocobase.com -p admin123
|
||||||
|
```
|
||||||
|
|
||||||
|
<Alert>
|
||||||
|
|
||||||
|
`-f/--force` 和 `-c/--clean` 的区别
|
||||||
|
- `-f/--force` 删除 NocoBase 的数据表
|
||||||
|
- `-c/--clean` 清空数据库,所有数据表都会被删除
|
||||||
|
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
### `upgrade`
|
||||||
|
|
||||||
|
升级
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn nocobase upgrade
|
||||||
|
```
|
||||||
|
|
||||||
|
### `test`
|
||||||
|
|
||||||
|
jest 测试,支持所有 [jest-cli](https://jestjs.io/docs/cli) 的 options,除此之外还扩展了 `-c, --db-clean` 的支持。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase test -h
|
||||||
|
|
||||||
|
Usage: nocobase test [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-c, --db-clean 运行所有测试前清空数据库
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 运行所有测试文件
|
||||||
|
yarn nocobase test
|
||||||
|
# 运行指定文件夹下所有测试文件
|
||||||
|
yarn nocobase test packages/core/server
|
||||||
|
# 运行指定文件里的所有测试
|
||||||
|
yarn nocobase test packages/core/database/src/__tests__/database.test.ts
|
||||||
|
|
||||||
|
# 运行测试前,清空数据库
|
||||||
|
yarn nocobase test -c
|
||||||
|
yarn nocobase test packages/core/server -c
|
||||||
|
```
|
||||||
|
|
||||||
|
### `build`
|
||||||
|
|
||||||
|
代码部署到生产环境前,需要将源码编译打包,如果代码有修改,也需要重新构建。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 所有包
|
||||||
|
yarn nocobase build
|
||||||
|
# 指定包
|
||||||
|
yarn nocobase build app/server app/client
|
||||||
|
```
|
||||||
|
|
||||||
|
### `clean`
|
||||||
|
|
||||||
|
删除编译之后的文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
# 等同于
|
||||||
|
yarn rimraf -rf packages/*/*/{lib,esm,es,dist}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `doc`
|
||||||
|
|
||||||
|
文档开发
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动文档
|
||||||
|
yarn doc --lang=zh-CN # 等同于 yarn doc dev
|
||||||
|
# 构建文档,默认输出到 ./docs/dist/ 目录下
|
||||||
|
yarn doc build
|
||||||
|
# 查看 dist 输出的文档最终效果
|
||||||
|
yarn doc serve --lang=zh-CN
|
||||||
|
```
|
||||||
|
|
||||||
|
### `db:auth`
|
||||||
|
|
||||||
|
校验数据库是否连接成功
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase db:auth -h
|
||||||
|
|
||||||
|
Usage: nocobase db:auth [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-r, --repeat [repeat] 重连次数
|
||||||
|
-h, --help
|
||||||
|
```
|
||||||
|
|
||||||
|
### `db:sync`
|
||||||
|
|
||||||
|
通过 collections 配置生成数据表和字段
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn nocobase db:sync -h
|
||||||
|
|
||||||
|
Usage: nocobase db:sync [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --force
|
||||||
|
-h, --help display help for command
|
||||||
|
```
|
||||||
|
|
||||||
|
### `umi`
|
||||||
|
|
||||||
|
`app/client` 基于 [umi](https://umijs.org/) 构建,可以通过 `nocobase umi` 来执行其他相关命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 生成开发环境所需的 .umi 缓存
|
||||||
|
yarn nocobase umi generate tmp
|
||||||
|
```
|
||||||
|
|
||||||
|
### `help`
|
||||||
|
|
||||||
|
帮助命令,也可以用 option 参数,`-h` 和 `--help`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 查看所有 cli
|
||||||
|
yarn nocobase help
|
||||||
|
# 也可以用 -h
|
||||||
|
yarn nocobase -h
|
||||||
|
# 或者 --help
|
||||||
|
yarn nocobase --help
|
||||||
|
# 查看 db:sync 命令的 option
|
||||||
|
yarn nocobase db:sync -h
|
||||||
|
```
|