@carthooks/arcubase-cli 0.1.9 → 0.1.12
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 +1407 -345
- package/bundle/arcubase.mjs +1407 -345
- package/dist/generated/command_registry.generated.d.ts +36 -35
- package/dist/generated/command_registry.generated.d.ts.map +1 -1
- package/dist/generated/command_registry.generated.js +37 -36
- package/dist/generated/type_index.generated.d.ts +23 -23
- package/dist/generated/type_index.generated.js +23 -23
- package/dist/runtime/entity_save_schema.d.ts.map +1 -1
- package/dist/runtime/entity_save_schema.js +30 -0
- package/dist/runtime/env.d.ts +2 -1
- package/dist/runtime/env.d.ts.map +1 -1
- package/dist/runtime/env.js +10 -1
- package/dist/runtime/errors.d.ts +4 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/execute.d.ts +4 -2
- package/dist/runtime/execute.d.ts.map +1 -1
- package/dist/runtime/execute.js +1025 -106
- package/dist/runtime/paths.d.ts +1 -1
- package/dist/runtime/paths.d.ts.map +1 -1
- package/dist/runtime/paths.js +9 -2
- package/dist/runtime/upload.d.ts +1 -11
- package/dist/runtime/upload.d.ts.map +1 -1
- package/dist/runtime/upload.js +19 -133
- package/dist/runtime/zod_registry.d.ts +5 -3
- package/dist/runtime/zod_registry.d.ts.map +1 -1
- package/dist/runtime/zod_registry.js +108 -48
- package/dist/tests/bootstrap.test.js +12 -0
- package/dist/tests/command_registry.test.js +8 -0
- package/dist/tests/docs_readability.test.d.ts +2 -0
- package/dist/tests/docs_readability.test.d.ts.map +1 -0
- package/dist/tests/docs_readability.test.js +87 -0
- package/dist/tests/entity_save_schema.test.js +22 -0
- package/dist/tests/execute_validation.test.js +446 -32
- package/dist/tests/help.test.js +56 -4
- package/dist/tests/upload.test.js +30 -77
- package/package.json +1 -1
- package/sdk-dist/docs/runtime-reference/README.md +43 -29
- package/sdk-dist/docs/runtime-reference/access-rule.md +109 -0
- package/sdk-dist/docs/runtime-reference/condition.md +182 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/README.md +6 -5
- package/sdk-dist/docs/runtime-reference/entity-schema/checkbox.md +1 -1
- package/sdk-dist/docs/runtime-reference/entity-schema/file.md +2 -2
- package/sdk-dist/docs/runtime-reference/entity-schema/image.md +2 -2
- package/sdk-dist/docs/runtime-reference/entity-schema/linkto.md +3 -3
- package/sdk-dist/docs/runtime-reference/entity-schema/number.md +1 -1
- package/sdk-dist/docs/runtime-reference/entity-schema/query.md +3 -3
- package/sdk-dist/docs/runtime-reference/entity-schema/relation.md +3 -3
- package/sdk-dist/docs/runtime-reference/entity-schema/relationfield.md +3 -3
- package/sdk-dist/docs/runtime-reference/entity-schema/status.md +1 -1
- package/sdk-dist/docs/runtime-reference/entity-schema/text.md +1 -1
- package/sdk-dist/docs/runtime-reference/entity-schema.md +28 -21
- package/sdk-dist/docs/runtime-reference/examples/README.md +1 -1
- package/sdk-dist/docs/runtime-reference/examples/crm-01/README.md +30 -11
- package/sdk-dist/docs/runtime-reference/examples/crm-01/contact.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/contact.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/create-app.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/customer.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/customer.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/follow-up.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/follow-up.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.bulk-update.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.query.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.row.insert.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/crm-01/lead.selection.condition.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/oms-01/README.md +26 -26
- package/sdk-dist/docs/runtime-reference/examples/oms-01/sales-order.row.insert.json +1 -1
- package/sdk-dist/docs/runtime-reference/examples/wms-01/README.md +26 -10
- package/sdk-dist/docs/runtime-reference/examples/wms-01/create-app.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/goods-receipt.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/goods-receipt.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/inventory-snapshot.bulk-update.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/inventory-snapshot.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/inventory-snapshot.query.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/inventory-snapshot.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/inventory-snapshot.selection.condition.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/item-master.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/item-master.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/stock-issue.create-entity.json +1 -0
- package/sdk-dist/docs/runtime-reference/examples/wms-01/stock-issue.schema.json +1 -0
- package/sdk-dist/docs/runtime-reference/row-crud.md +35 -8
- package/sdk-dist/docs/runtime-reference/search-and-bulk-actions.md +31 -95
- package/sdk-dist/docs/runtime-reference/selection.md +128 -0
- package/sdk-dist/docs/runtime-reference/table-lifecycle.md +113 -30
- package/sdk-dist/docs/runtime-reference/uploads.md +30 -59
- package/sdk-dist/docs/runtime-reference/workflow/README.md +129 -13
- package/sdk-dist/generated/command_registry.generated.ts +37 -36
- package/sdk-dist/generated/type_index.generated.ts +23 -23
- package/src/generated/command_registry.generated.ts +37 -36
- package/src/generated/type_index.generated.ts +23 -23
- package/src/runtime/entity_save_schema.ts +30 -0
- package/src/runtime/env.ts +14 -2
- package/src/runtime/errors.ts +4 -0
- package/src/runtime/execute.ts +1249 -129
- package/src/runtime/paths.ts +11 -2
- package/src/runtime/upload.ts +19 -178
- package/src/runtime/zod_registry.ts +113 -48
- package/src/tests/bootstrap.test.ts +16 -0
- package/src/tests/command_registry.test.ts +9 -0
- package/src/tests/docs_readability.test.ts +96 -0
- package/src/tests/entity_save_schema.test.ts +22 -0
- package/src/tests/execute_validation.test.ts +564 -45
- package/src/tests/help.test.ts +51 -7
- package/src/tests/upload.test.ts +34 -91
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
|
|
6
|
+
const root = path.resolve('docs/runtime-reference')
|
|
7
|
+
|
|
8
|
+
test('runtime docs keep full FieldVO template', () => {
|
|
9
|
+
const text = fs.readFileSync(path.join(root, 'entity-schema.md'), 'utf8')
|
|
10
|
+
for (const token of [
|
|
11
|
+
'"label"',
|
|
12
|
+
'"required"',
|
|
13
|
+
'"children": null',
|
|
14
|
+
'"options"',
|
|
15
|
+
'"key"',
|
|
16
|
+
'"default_value_mode"',
|
|
17
|
+
'"depends"',
|
|
18
|
+
'"transfers"',
|
|
19
|
+
]) {
|
|
20
|
+
assert.match(text, new RegExp(token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')))
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('runtime docs keep updated equivalents for retired sections', () => {
|
|
25
|
+
const text = fs.readFileSync(path.join(root, 'search-and-bulk-actions.md'), 'utf8')
|
|
26
|
+
assert.match(text, /## Selection tags/)
|
|
27
|
+
assert.match(text, /Current reset surface has no tag-specific CLI command/)
|
|
28
|
+
assert.match(text, /arcubase row selection-action/)
|
|
29
|
+
assert.match(text, /arcubase row bulk-update/)
|
|
30
|
+
assert.doesNotMatch(text, /entity-tags/)
|
|
31
|
+
assert.doesNotMatch(text, /policy_id/)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('runtime docs do not expose retired tenant env input', () => {
|
|
35
|
+
const text = fs.readFileSync(path.join(root, 'README.md'), 'utf8')
|
|
36
|
+
assert.doesNotMatch(text, /ARCUBASE_TENANT_ID/)
|
|
37
|
+
assert.doesNotMatch(text, /ARCUBASE_ADMIN_TENANT_ID/)
|
|
38
|
+
assert.doesNotMatch(text, /ARCUBASE_USER_TENANT_ID/)
|
|
39
|
+
assert.match(text, /Tenant identity comes from the JWT access token/)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test('runtime docs split selection condition from condition set', () => {
|
|
43
|
+
const selection = fs.readFileSync(path.join(root, 'selection.md'), 'utf8')
|
|
44
|
+
assert.match(selection, /EntitySelectionVO/)
|
|
45
|
+
assert.match(selection, /selection\.condition/)
|
|
46
|
+
assert.match(selection, /route-query search state/)
|
|
47
|
+
assert.match(selection, /Action Matrix/)
|
|
48
|
+
assert.match(selection, /do not put `\{mode, conditions\}` here/)
|
|
49
|
+
|
|
50
|
+
const condition = fs.readFileSync(path.join(root, 'condition.md'), 'utf8')
|
|
51
|
+
assert.match(condition, /Selection Condition/)
|
|
52
|
+
assert.match(condition, /FilterCond/)
|
|
53
|
+
assert.match(condition, /ConditionSet/)
|
|
54
|
+
assert.match(condition, /Do not mix them/)
|
|
55
|
+
assert.match(condition, /not valid inside `selection\.condition`/)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('runtime docs do not use retired table create and row probe names', () => {
|
|
59
|
+
for (const file of [
|
|
60
|
+
path.join(root, 'table-lifecycle.md'),
|
|
61
|
+
path.join(root, 'examples', 'oms-01', 'README.md'),
|
|
62
|
+
]) {
|
|
63
|
+
const text = fs.readFileSync(file, 'utf8')
|
|
64
|
+
assert.doesNotMatch(text, /--id <app_id>/)
|
|
65
|
+
assert.doesNotMatch(text, /query-entity/)
|
|
66
|
+
assert.match(text, /--app-id <app_id>/)
|
|
67
|
+
assert.match(text, /row query/)
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('scenario examples exist and are readable', () => {
|
|
72
|
+
for (const dir of ['oms-01', 'wms-01', 'crm-01']) {
|
|
73
|
+
const readme = path.join(root, 'examples', dir, 'README.md')
|
|
74
|
+
assert.ok(fs.existsSync(readme), `${readme} must exist`)
|
|
75
|
+
assert.ok(fs.readFileSync(readme, 'utf8').trim().length > 40)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('scenario json examples parse and schema examples use full FieldVO', () => {
|
|
80
|
+
for (const dir of ['oms-01', 'wms-01', 'crm-01']) {
|
|
81
|
+
const full = path.join(root, 'examples', dir)
|
|
82
|
+
for (const file of fs.readdirSync(full).filter((item) => item.endsWith('.json'))) {
|
|
83
|
+
const body = JSON.parse(fs.readFileSync(path.join(full, file), 'utf8'))
|
|
84
|
+
assert.ok(body && typeof body === 'object', file)
|
|
85
|
+
if (file.endsWith('.schema.json')) {
|
|
86
|
+
assert.ok(Array.isArray(body.fields), file)
|
|
87
|
+
assert.ok(body.fields.length > 0, file)
|
|
88
|
+
for (const field of body.fields) {
|
|
89
|
+
for (const key of ['id', 'label', 'type', 'required', 'options', 'children', 'key']) {
|
|
90
|
+
assert.ok(key in field, `${dir}/${file} missing ${key}`)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
@@ -43,6 +43,28 @@ test('EntitySaveReqVO accepts fields as array', () => {
|
|
|
43
43
|
assert.equal(parsed.success, true)
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
+
test('EntitySaveReqVO normalizes mechanical FieldVO defaults', () => {
|
|
47
|
+
assert.ok(schema)
|
|
48
|
+
const parsed = schema!.safeParse({
|
|
49
|
+
name: '订单',
|
|
50
|
+
field_id_seq: 1002,
|
|
51
|
+
layout: [[1001]],
|
|
52
|
+
fields: [{
|
|
53
|
+
id: 1001,
|
|
54
|
+
label: '标题',
|
|
55
|
+
type: 'text',
|
|
56
|
+
required: true,
|
|
57
|
+
key: 'title',
|
|
58
|
+
options: { type: 'text', placeholder: '', lengthLimit: false, lengthMin: 0, lengthMax: 255 },
|
|
59
|
+
}],
|
|
60
|
+
})
|
|
61
|
+
assert.equal(parsed.success, true)
|
|
62
|
+
if (!parsed.success) return
|
|
63
|
+
assert.equal(parsed.data.fields[0].children, null)
|
|
64
|
+
assert.equal(parsed.data.fields[0].transfers, null)
|
|
65
|
+
assert.deepEqual(parsed.data.fields[0].depends, [])
|
|
66
|
+
})
|
|
67
|
+
|
|
46
68
|
test('EntitySaveReqVO rejects fields as object', () => {
|
|
47
69
|
assert.ok(schema)
|
|
48
70
|
const parsed = schema!.safeParse({
|