@carthooks/arcubase-cli 0.1.2 → 0.1.3
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 +907 -10
- package/bundle/arcubase.mjs +907 -10
- 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 +10 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/execute.d.ts.map +1 -1
- package/dist/runtime/execute.js +89 -10
- 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 +133 -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 +450 -0
- package/dist/tests/help.test.js +33 -0
- package/package.json +1 -1
- package/sdk-dist/docs/runtime-reference/README.md +177 -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 +44 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/formula.md +44 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/image.md +43 -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 +164 -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 +186 -0
- package/sdk-dist/docs/runtime-reference/search-and-bulk-actions.md +494 -0
- package/sdk-dist/docs/runtime-reference/table-lifecycle.md +123 -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 +11 -0
- package/src/runtime/execute.ts +123 -10
- package/src/runtime/zod_registry.ts +154 -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 +598 -0
- package/src/tests/help.test.ts +39 -0
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
## Step 1: create the app
|
|
21
|
+
|
|
22
|
+
Command:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
arcubase-admin app create-app-by-tenants --body-file create-app.json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Minimal `create-app.json`:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"name": "bt053"
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Rules:
|
|
37
|
+
|
|
38
|
+
- `name` is required
|
|
39
|
+
- keep `name` at `20` characters or fewer
|
|
40
|
+
|
|
41
|
+
## Step 2: create the entity shell
|
|
42
|
+
|
|
43
|
+
Command:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
arcubase-admin app create-entity \
|
|
47
|
+
--id <app_id> \
|
|
48
|
+
--body-file create-entity.json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Minimal `create-entity.json`:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"name": "simple"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Rules:
|
|
60
|
+
|
|
61
|
+
- this only creates the shell
|
|
62
|
+
- this does not mean row CRUD is ready
|
|
63
|
+
|
|
64
|
+
## Step 3: fetch the current shell
|
|
65
|
+
|
|
66
|
+
Command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
arcubase-admin entity admin-get-entity-info \
|
|
70
|
+
--app-id <app_id> \
|
|
71
|
+
--entity-id <entity_id>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Use the returned shell as the base for `save-entity.json`.
|
|
75
|
+
|
|
76
|
+
Rules:
|
|
77
|
+
|
|
78
|
+
- do not invent `schema_version`
|
|
79
|
+
- do not invent top-level `options`
|
|
80
|
+
- keep `id`, `app_id`, `name`, and `workflow_enabled` from the shell
|
|
81
|
+
- normalize shell placeholder `null` values before save
|
|
82
|
+
|
|
83
|
+
## Step 4: save the full schema
|
|
84
|
+
|
|
85
|
+
Command:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
arcubase-admin entity admin-save-entity \
|
|
89
|
+
--app-id <app_id> \
|
|
90
|
+
--entity-id <entity_id> \
|
|
91
|
+
--body-file save-entity.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Read before writing `save-entity.json`:
|
|
95
|
+
|
|
96
|
+
1. `entity-schema.md`
|
|
97
|
+
2. `entity-schema/README.md`
|
|
98
|
+
3. the exact field-type pages you need
|
|
99
|
+
|
|
100
|
+
## Step 5: probe readiness
|
|
101
|
+
|
|
102
|
+
Command:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
arcubase workflow query-entity \
|
|
106
|
+
--app-id <app_id> \
|
|
107
|
+
--entity-id <entity_id> \
|
|
108
|
+
--body-file query.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Minimal `query.json`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"limit": 20,
|
|
116
|
+
"offset": 0
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Rules:
|
|
121
|
+
|
|
122
|
+
- only call the table ready after this command succeeds
|
|
123
|
+
- if shell creation succeeded but `query-entity` still fails, the table is not ready
|
|
@@ -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
|
+
}
|