@carthooks/arcubase-cli 0.1.3 → 0.1.5

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.
Files changed (64) hide show
  1. package/bundle/arcubase-admin.mjs +546 -243
  2. package/bundle/arcubase.mjs +546 -243
  3. package/dist/bin/arcubase-admin.js +0 -0
  4. package/dist/bin/arcubase.js +0 -0
  5. package/dist/generated/command_registry.generated.d.ts +36 -112
  6. package/dist/generated/command_registry.generated.d.ts.map +1 -1
  7. package/dist/generated/command_registry.generated.js +40 -163
  8. package/dist/generated/type_index.generated.d.ts +0 -12
  9. package/dist/generated/type_index.generated.d.ts.map +1 -1
  10. package/dist/generated/type_index.generated.js +0 -12
  11. package/dist/generated/zod_registry.generated.d.ts +1 -19
  12. package/dist/generated/zod_registry.generated.d.ts.map +1 -1
  13. package/dist/generated/zod_registry.generated.js +0 -21
  14. package/dist/runtime/command_registry.d.ts +19 -1
  15. package/dist/runtime/command_registry.d.ts.map +1 -1
  16. package/dist/runtime/command_registry.js +19 -1
  17. package/dist/runtime/errors.d.ts +1 -0
  18. package/dist/runtime/errors.d.ts.map +1 -1
  19. package/dist/runtime/execute.d.ts.map +1 -1
  20. package/dist/runtime/execute.js +321 -8
  21. package/dist/runtime/upload.d.ts +13 -0
  22. package/dist/runtime/upload.d.ts.map +1 -0
  23. package/dist/runtime/upload.js +148 -0
  24. package/dist/runtime/zod_registry.d.ts.map +1 -1
  25. package/dist/runtime/zod_registry.js +50 -30
  26. package/dist/tests/command_registry.test.js +11 -4
  27. package/dist/tests/execute_validation.test.js +221 -13
  28. package/dist/tests/help.test.js +29 -6
  29. package/dist/tests/upload.test.d.ts +2 -0
  30. package/dist/tests/upload.test.d.ts.map +1 -0
  31. package/dist/tests/upload.test.js +107 -0
  32. package/package.json +1 -1
  33. package/sdk-dist/api/admin/app.ts +8 -1
  34. package/sdk-dist/docs/runtime-reference/README.md +33 -15
  35. package/sdk-dist/docs/runtime-reference/app-discovery.md +68 -0
  36. package/sdk-dist/docs/runtime-reference/entity-schema/README.md +2 -2
  37. package/sdk-dist/docs/runtime-reference/entity-schema/file.md +9 -0
  38. package/sdk-dist/docs/runtime-reference/entity-schema/image.md +9 -0
  39. package/sdk-dist/docs/runtime-reference/entity-schema/subform.md +2 -2
  40. package/sdk-dist/docs/runtime-reference/entity-schema.md +2 -2
  41. package/sdk-dist/docs/runtime-reference/examples/README.md +1 -1
  42. package/sdk-dist/docs/runtime-reference/examples/oms-01/README.md +23 -4
  43. package/sdk-dist/docs/runtime-reference/examples/oms-01/app-overview.md +1 -1
  44. package/sdk-dist/docs/runtime-reference/row-crud.md +8 -6
  45. package/sdk-dist/docs/runtime-reference/search-and-bulk-actions.md +5 -5
  46. package/sdk-dist/docs/runtime-reference/table-lifecycle.md +34 -6
  47. package/sdk-dist/docs/runtime-reference/uploads.md +106 -0
  48. package/sdk-dist/generated/command_registry.generated.ts +40 -163
  49. package/sdk-dist/generated/type_index.generated.ts +0 -12
  50. package/sdk-dist/generated/zod_registry.generated.ts +0 -36
  51. package/sdk-dist/types/app.ts +7 -0
  52. package/src/generated/command_registry.generated.ts +40 -163
  53. package/src/generated/type_index.generated.ts +0 -12
  54. package/src/generated/zod_registry.generated.ts +0 -36
  55. package/src/runtime/command_registry.ts +38 -2
  56. package/src/runtime/errors.ts +1 -0
  57. package/src/runtime/execute.ts +368 -8
  58. package/src/runtime/upload.ts +196 -0
  59. package/src/runtime/zod_registry.ts +50 -30
  60. package/src/tests/command_registry.test.ts +13 -4
  61. package/src/tests/execute_validation.test.ts +257 -13
  62. package/src/tests/help.test.ts +35 -6
  63. package/src/tests/upload.test.ts +133 -0
  64. package/sdk-dist/docs/runtime-reference/workflow/README.md +0 -19
@@ -0,0 +1,133 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import fs from 'fs'
4
+ import os from 'os'
5
+ import path from 'path'
6
+ import { executeCLI } from '../runtime/execute.js'
7
+
8
+ const env = {
9
+ ARCUBASE_BASE_URL: 'https://arcubase.example.com',
10
+ ARCUBASE_TENANT_ID: 'tenant_1',
11
+ ARCUBASE_ACCESS_TOKEN: 'tok',
12
+ ARCUBASE_TRACE_ID: '',
13
+ ARCUBASE_SUBJECT_TYPE: '',
14
+ ARCUBASE_SUBJECT_ID: '',
15
+ ARCUBASE_TOKEN_EXPIRES_AT: '',
16
+ }
17
+
18
+ test('upload help works without runtime env', async () => {
19
+ const out = await executeCLI('user', ['upload', '--help'], undefined, async () => new Response('{}'))
20
+ assert.equal(out.kind, 'help')
21
+ assert.match(out.text, /arcubase upload <local-file>/)
22
+ assert.match(out.text, /uploads\.md/)
23
+ })
24
+
25
+ test('upload returns file field value array for row payloads', async () => {
26
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'arcubase-upload-'))
27
+ const sourceFile = path.join(tempDir, 'contract.pdf')
28
+ fs.writeFileSync(sourceFile, 'fake pdf bytes')
29
+
30
+ const calls: Array<{ url: string; method?: string }> = []
31
+
32
+ const result = await executeCLI(
33
+ 'user',
34
+ ['upload', sourceFile],
35
+ env as any,
36
+ async (input, init) => {
37
+ const url = String(input)
38
+ calls.push({ url, method: init?.method })
39
+ if (url === 'https://arcubase.example.com/upload/token') {
40
+ return new Response(
41
+ JSON.stringify({
42
+ data: {
43
+ id: 123456,
44
+ mode: 'aliyun-oss',
45
+ token_data: {
46
+ dir: 'upload/123456/',
47
+ policy: 'policy',
48
+ accessid: 'accessid',
49
+ signature: 'signature',
50
+ host: 'https://uploads.example.com',
51
+ },
52
+ },
53
+ }),
54
+ { status: 200, headers: { 'Content-Type': 'application/json' } },
55
+ )
56
+ }
57
+ if (url === 'https://uploads.example.com') {
58
+ return new Response('', { status: 200 })
59
+ }
60
+ throw new Error(`unexpected fetch url: ${url}`)
61
+ },
62
+ )
63
+
64
+ assert.equal(result.kind, 'result')
65
+ assert.deepEqual(calls, [
66
+ { url: 'https://arcubase.example.com/upload/token', method: 'POST' },
67
+ { url: 'https://uploads.example.com', method: 'POST' },
68
+ ])
69
+ assert.deepEqual(result.data, [
70
+ {
71
+ upload_id: 123456,
72
+ file: 'contract.pdf',
73
+ file_name: 'contract.pdf',
74
+ meta: {},
75
+ },
76
+ ])
77
+ })
78
+
79
+ test('upload supports s3-post-policy tokens', async () => {
80
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'arcubase-upload-s3-'))
81
+ const sourceFile = path.join(tempDir, 'contract.pdf')
82
+ fs.writeFileSync(sourceFile, 'fake pdf bytes')
83
+
84
+ const calls: Array<{ url: string; method?: string }> = []
85
+
86
+ const result = await executeCLI(
87
+ 'user',
88
+ ['upload', sourceFile],
89
+ env as any,
90
+ async (input, init) => {
91
+ const url = String(input)
92
+ calls.push({ url, method: init?.method })
93
+ if (url === 'https://arcubase.example.com/upload/token') {
94
+ return new Response(
95
+ JSON.stringify({
96
+ data: {
97
+ id: 654321,
98
+ mode: 's3-post-policy',
99
+ token_data: {
100
+ dir: 'upload/654321/',
101
+ policy: 'policy',
102
+ host: 'https://uploads.example.com/private-bucket',
103
+ x_amz_algorithm: 'AWS4-HMAC-SHA256',
104
+ x_amz_credential: 'test/20260504/us-east-1/s3/aws4_request',
105
+ x_amz_date: '20260504T010203Z',
106
+ x_amz_signature: 'abc123',
107
+ },
108
+ },
109
+ }),
110
+ { status: 200, headers: { 'Content-Type': 'application/json' } },
111
+ )
112
+ }
113
+ if (url === 'https://uploads.example.com/private-bucket') {
114
+ return new Response('', { status: 200 })
115
+ }
116
+ throw new Error(`unexpected fetch url: ${url}`)
117
+ },
118
+ )
119
+
120
+ assert.equal(result.kind, 'result')
121
+ assert.deepEqual(calls, [
122
+ { url: 'https://arcubase.example.com/upload/token', method: 'POST' },
123
+ { url: 'https://uploads.example.com/private-bucket', method: 'POST' },
124
+ ])
125
+ assert.deepEqual(result.data, [
126
+ {
127
+ upload_id: 654321,
128
+ file: 'contract.pdf',
129
+ file_name: 'contract.pdf',
130
+ meta: {},
131
+ },
132
+ ])
133
+ })
@@ -1,19 +0,0 @@
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