@carthooks/arcubase-cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/arcubase-admin.mjs +1238 -16
- package/bundle/arcubase.mjs +1238 -16
- package/dist/bin/arcubase-admin.js +0 -0
- package/dist/bin/arcubase.js +0 -0
- package/dist/runtime/command_registry.d.ts +8 -0
- package/dist/runtime/command_registry.d.ts.map +1 -1
- package/dist/runtime/command_registry.js +35 -0
- package/dist/runtime/entity_save_schema.d.ts +15 -0
- package/dist/runtime/entity_save_schema.d.ts.map +1 -0
- package/dist/runtime/entity_save_schema.js +641 -0
- package/dist/runtime/errors.d.ts +11 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/execute.d.ts.map +1 -1
- package/dist/runtime/execute.js +294 -12
- package/dist/runtime/upload.d.ts +13 -0
- package/dist/runtime/upload.d.ts.map +1 -0
- package/dist/runtime/upload.js +148 -0
- package/dist/runtime/zod_registry.d.ts +6 -0
- package/dist/runtime/zod_registry.d.ts.map +1 -1
- package/dist/runtime/zod_registry.js +136 -0
- package/dist/tests/command_registry.test.js +5 -0
- package/dist/tests/entity_save_schema.test.d.ts +2 -0
- package/dist/tests/entity_save_schema.test.d.ts.map +1 -0
- package/dist/tests/entity_save_schema.test.js +221 -0
- package/dist/tests/execute_validation.test.js +603 -0
- package/dist/tests/help.test.js +49 -0
- package/dist/tests/upload.test.d.ts +2 -0
- package/dist/tests/upload.test.d.ts.map +1 -0
- package/dist/tests/upload.test.js +107 -0
- package/package.json +1 -1
- package/sdk-dist/docs/runtime-reference/README.md +187 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/README.md +120 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/address.md +34 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/boolean.md +37 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/button.md +47 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/checkbox.md +61 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/datasets.md +35 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/datetime.md +40 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/department.md +33 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/departments.md +34 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/divider.md +39 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/file.md +53 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/formula.md +44 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/image.md +52 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/linkto.md +67 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/location.md +32 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/lookup.md +41 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/member.md +37 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/members.md +31 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/number.md +70 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/query.md +50 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/radio.md +53 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/relation.md +55 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/relationfield.md +38 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/rollup.md +54 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/select.md +63 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/selects.md +51 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/serialnumber.md +48 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/signature.md +31 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/status.md +70 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/subform.md +74 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/tags.md +19 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/text.md +76 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/textarea.md +47 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/workflow_status.md +17 -0
- package/sdk-dist/docs/runtime-reference/entity-schema.md +197 -0
- package/sdk-dist/docs/runtime-reference/examples/README.md +51 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/README.md +20 -0
- package/sdk-dist/docs/runtime-reference/examples/mes-01/README.md +21 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/README.md +183 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/app-overview.md +79 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/create-app.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/goods-receipt.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/goods-receipt.schema.json +159 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/item-master.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/item-master.schema.json +179 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/picking-list.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/picking-list.schema.json +168 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/purchase-order.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/purchase-order.schema.json +417 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.bulk-update.json +22 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.query.json +10 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.row.insert.json +28 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.schema.json +398 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.selection.condition.json +13 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.selection.ids.json +7 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/stock-issue.create-entity.json +3 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/stock-issue.schema.json +137 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/README.md +21 -0
- package/sdk-dist/docs/runtime-reference/row-crud.md +188 -0
- package/sdk-dist/docs/runtime-reference/search-and-bulk-actions.md +494 -0
- package/sdk-dist/docs/runtime-reference/table-lifecycle.md +135 -0
- package/sdk-dist/docs/runtime-reference/uploads.md +106 -0
- package/sdk-dist/docs/runtime-reference/workflow/README.md +19 -0
- package/src/runtime/command_registry.ts +47 -0
- package/src/runtime/entity_save_schema.ts +708 -0
- package/src/runtime/errors.ts +12 -0
- package/src/runtime/execute.ts +367 -12
- package/src/runtime/upload.ts +196 -0
- package/src/runtime/zod_registry.ts +156 -0
- package/src/tests/command_registry.test.ts +6 -0
- package/src/tests/entity_save_schema.test.ts +236 -0
- package/src/tests/execute_validation.test.ts +781 -0
- package/src/tests/help.test.ts +60 -0
- package/src/tests/upload.test.ts +133 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Table Lifecycle
|
|
2
|
+
|
|
3
|
+
Use this page when the goal is:
|
|
4
|
+
|
|
5
|
+
- create an app
|
|
6
|
+
- create a table
|
|
7
|
+
- save the schema
|
|
8
|
+
- confirm the table is really ready
|
|
9
|
+
|
|
10
|
+
The successful path is command-first:
|
|
11
|
+
|
|
12
|
+
1. create the app
|
|
13
|
+
2. create the entity shell
|
|
14
|
+
3. fetch the current shell
|
|
15
|
+
4. save the full schema
|
|
16
|
+
5. probe rows with `query-entity`
|
|
17
|
+
|
|
18
|
+
Do not stop at shell creation.
|
|
19
|
+
|
|
20
|
+
CLI phase split:
|
|
21
|
+
|
|
22
|
+
- schema phase uses `arcubase-admin`
|
|
23
|
+
- row phase uses `arcubase`
|
|
24
|
+
- the switch happens immediately after `admin-save-entity`
|
|
25
|
+
- do not use `arcubase-admin` for row insert or row query
|
|
26
|
+
|
|
27
|
+
## Step 1: create the app
|
|
28
|
+
|
|
29
|
+
Command:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
arcubase-admin app create-app-by-tenants --body-file create-app.json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Minimal `create-app.json`:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"name": "bt053"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Rules:
|
|
44
|
+
|
|
45
|
+
- `name` is required
|
|
46
|
+
- keep `name` at `20` characters or fewer
|
|
47
|
+
|
|
48
|
+
## Step 2: create the entity shell
|
|
49
|
+
|
|
50
|
+
Command:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
arcubase-admin app create-entity \
|
|
54
|
+
--id <app_id> \
|
|
55
|
+
--body-file create-entity.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Minimal `create-entity.json`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"name": "simple"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Rules:
|
|
67
|
+
|
|
68
|
+
- this only creates the shell
|
|
69
|
+
- this does not mean row CRUD is ready
|
|
70
|
+
|
|
71
|
+
## Step 3: fetch the current shell
|
|
72
|
+
|
|
73
|
+
Command:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
arcubase-admin entity admin-get-entity-info \
|
|
77
|
+
--app-id <app_id> \
|
|
78
|
+
--entity-id <entity_id>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use the returned shell as the base for `save-entity.json`.
|
|
82
|
+
|
|
83
|
+
Rules:
|
|
84
|
+
|
|
85
|
+
- do not invent `schema_version`
|
|
86
|
+
- do not invent top-level `options`
|
|
87
|
+
- keep `id`, `app_id`, `name`, and `workflow_enabled` from the shell
|
|
88
|
+
- normalize shell placeholder `null` values before save
|
|
89
|
+
|
|
90
|
+
## Step 4: save the full schema
|
|
91
|
+
|
|
92
|
+
Command:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
arcubase-admin entity admin-save-entity \
|
|
96
|
+
--app-id <app_id> \
|
|
97
|
+
--entity-id <entity_id> \
|
|
98
|
+
--body-file save-entity.json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Read before writing `save-entity.json`:
|
|
102
|
+
|
|
103
|
+
1. `entity-schema.md`
|
|
104
|
+
2. `entity-schema/README.md`
|
|
105
|
+
3. the exact field-type pages you need
|
|
106
|
+
|
|
107
|
+
After `admin-save-entity`, switch binaries:
|
|
108
|
+
|
|
109
|
+
- use `arcubase workflow insert-entity` for row insertion
|
|
110
|
+
- use `arcubase workflow query-entity` for readiness and row reads
|
|
111
|
+
|
|
112
|
+
## Step 5: probe readiness
|
|
113
|
+
|
|
114
|
+
Command:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
arcubase workflow query-entity \
|
|
118
|
+
--app-id <app_id> \
|
|
119
|
+
--entity-id <entity_id> \
|
|
120
|
+
--body-file query.json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Minimal `query.json`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"limit": 20,
|
|
128
|
+
"offset": 0
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Rules:
|
|
133
|
+
|
|
134
|
+
- only call the table ready after this command succeeds
|
|
135
|
+
- if shell creation succeeded but `query-entity` still fails, the table is not ready
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Uploads
|
|
2
|
+
|
|
3
|
+
Use this page when a row contains a `file` or `image` field.
|
|
4
|
+
|
|
5
|
+
The successful path is:
|
|
6
|
+
|
|
7
|
+
1. run `arcubase upload <local-file>`
|
|
8
|
+
2. use the returned JSON array directly as the field value
|
|
9
|
+
3. insert or update the row with `arcubase workflow insert-entity` or `arcubase workflow update-entity-row`
|
|
10
|
+
|
|
11
|
+
Do not construct `upload_id`, `assets_id`, or OSS form fields by hand.
|
|
12
|
+
|
|
13
|
+
## Upload one local file
|
|
14
|
+
|
|
15
|
+
Command:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
arcubase upload ./contract.pdf
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Optional flags:
|
|
22
|
+
|
|
23
|
+
- `--filename <name>`
|
|
24
|
+
- `--global`
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
arcubase upload ./lead-photo.jpg --filename lead-photo.jpg
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Upload result shape
|
|
33
|
+
|
|
34
|
+
The command returns a JSON array.
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"data": [
|
|
41
|
+
{
|
|
42
|
+
"upload_id": 123456,
|
|
43
|
+
"file": "contract.pdf",
|
|
44
|
+
"file_name": "contract.pdf",
|
|
45
|
+
"meta": {}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use the `data` array directly as the field value for a `file` or `image` field.
|
|
52
|
+
|
|
53
|
+
## Insert a row with a file field
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"fields": {
|
|
58
|
+
"1001": "Lead A",
|
|
59
|
+
"1007": [
|
|
60
|
+
{
|
|
61
|
+
"upload_id": 123456,
|
|
62
|
+
"file": "contract.pdf",
|
|
63
|
+
"file_name": "contract.pdf",
|
|
64
|
+
"meta": {}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Update a row with an image field
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"data": {
|
|
76
|
+
"1008": [
|
|
77
|
+
{
|
|
78
|
+
"upload_id": 123457,
|
|
79
|
+
"file": "lead-photo.jpg",
|
|
80
|
+
"file_name": "lead-photo.jpg",
|
|
81
|
+
"meta": {}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"changed_fields": [1008]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Preview an uploaded file
|
|
90
|
+
|
|
91
|
+
Command:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
arcubase common upload-preview --body-file preview.json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Example `preview.json`:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"upload_id": 123456,
|
|
102
|
+
"fname": "contract.pdf"
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This returns a preview URL for the upload token entry. It does not insert or update a row.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Workflow Runtime Reference
|
|
2
|
+
|
|
3
|
+
This directory is reserved for future workflow runtime docs.
|
|
4
|
+
|
|
5
|
+
It will follow the same single-path distribution model as entity schema docs:
|
|
6
|
+
|
|
7
|
+
- Development source of truth:
|
|
8
|
+
- `misc/packages/@carthooks/arcubase-cli/docs/runtime-reference/workflow/`
|
|
9
|
+
- Runtime location:
|
|
10
|
+
- `/opt/arcubase-sdk/docs/runtime-reference/workflow/`
|
|
11
|
+
- Distribution path:
|
|
12
|
+
- `sdk-dist/docs/runtime-reference/workflow/`
|
|
13
|
+
|
|
14
|
+
Expected coverage later:
|
|
15
|
+
|
|
16
|
+
- workflow configuration lifecycle
|
|
17
|
+
- real writable structure for nodes, edges, actions, and conditions
|
|
18
|
+
- integration points between workflow and entity schema
|
|
19
|
+
- common failure cases and debugging guidance
|
|
@@ -20,3 +20,50 @@ export function listModules(scope: CommandScope): string[] {
|
|
|
20
20
|
export function listModuleCommands(scope: CommandScope, moduleName: string): readonly CommandDef[] {
|
|
21
21
|
return listCommands(scope).filter((item) => item.commandPath[0] === moduleName)
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
function levenshtein(a: string, b: string): number {
|
|
25
|
+
const dp = Array.from({ length: a.length + 1 }, () => new Array<number>(b.length + 1).fill(0))
|
|
26
|
+
for (let i = 0; i <= a.length; i += 1) dp[i][0] = i
|
|
27
|
+
for (let j = 0; j <= b.length; j += 1) dp[0][j] = j
|
|
28
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
29
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
30
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1
|
|
31
|
+
dp[i][j] = Math.min(
|
|
32
|
+
dp[i - 1][j] + 1,
|
|
33
|
+
dp[i][j - 1] + 1,
|
|
34
|
+
dp[i - 1][j - 1] + cost,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return dp[a.length][b.length]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type CommandSuggestion = {
|
|
42
|
+
scope: CommandScope
|
|
43
|
+
moduleName: string
|
|
44
|
+
commandName: string
|
|
45
|
+
binary: 'arcubase-admin' | 'arcubase'
|
|
46
|
+
score: number
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function findCommandSuggestions(moduleName: string, commandName: string, limit = 3): CommandSuggestion[] {
|
|
50
|
+
const suggestions: CommandSuggestion[] = []
|
|
51
|
+
for (const scope of ['admin', 'user'] as const) {
|
|
52
|
+
for (const command of listCommands(scope)) {
|
|
53
|
+
const [candidateModule, candidateCommand] = command.commandPath
|
|
54
|
+
const moduleScore = candidateModule === moduleName ? 0 : levenshtein(candidateModule, moduleName || '')
|
|
55
|
+
const commandScore = candidateCommand === commandName ? 0 : levenshtein(candidateCommand, commandName || '')
|
|
56
|
+
const score = commandScore * 3 + moduleScore
|
|
57
|
+
suggestions.push({
|
|
58
|
+
scope,
|
|
59
|
+
moduleName: candidateModule,
|
|
60
|
+
commandName: candidateCommand,
|
|
61
|
+
binary: scope === 'admin' ? 'arcubase-admin' : 'arcubase',
|
|
62
|
+
score,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return suggestions
|
|
67
|
+
.sort((a, b) => a.score - b.score || a.binary.localeCompare(b.binary) || a.moduleName.localeCompare(b.moduleName) || a.commandName.localeCompare(b.commandName))
|
|
68
|
+
.slice(0, limit)
|
|
69
|
+
}
|