@carthooks/arcubase-cli 0.1.21 → 0.1.22

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 (56) hide show
  1. package/bundle/arcubase-admin.mjs +1297 -79
  2. package/bundle/arcubase.mjs +1297 -79
  3. package/dist/generated/command_registry.generated.d.ts +285 -0
  4. package/dist/generated/command_registry.generated.d.ts.map +1 -1
  5. package/dist/generated/command_registry.generated.js +395 -0
  6. package/dist/generated/help_examples.generated.d.ts +77 -0
  7. package/dist/generated/help_examples.generated.d.ts.map +1 -1
  8. package/dist/generated/help_examples.generated.js +122 -0
  9. package/dist/generated/type_index.generated.d.ts +40 -1
  10. package/dist/generated/type_index.generated.d.ts.map +1 -1
  11. package/dist/generated/type_index.generated.js +42 -1
  12. package/dist/generated/zod_registry.generated.d.ts +29 -1
  13. package/dist/generated/zod_registry.generated.d.ts.map +1 -1
  14. package/dist/generated/zod_registry.generated.js +37 -0
  15. package/dist/runtime/dev_sdk_gen.d.ts +9 -0
  16. package/dist/runtime/dev_sdk_gen.d.ts.map +1 -0
  17. package/dist/runtime/dev_sdk_gen.js +319 -0
  18. package/dist/runtime/execute.d.ts.map +1 -1
  19. package/dist/runtime/execute.js +280 -1
  20. package/dist/runtime/zod_registry.d.ts.map +1 -1
  21. package/dist/runtime/zod_registry.js +58 -0
  22. package/package.json +1 -1
  23. package/sdk-dist/api/admin/index.ts +1 -0
  24. package/sdk-dist/api/admin/public-link.ts +48 -0
  25. package/sdk-dist/api/shared-link/form.ts +42 -1
  26. package/sdk-dist/api/user/index.ts +0 -1
  27. package/sdk-dist/docs/runtime-reference/dashboard.md +15 -0
  28. package/sdk-dist/docs/runtime-reference/dev-sdk-gen.md +41 -0
  29. package/sdk-dist/docs/runtime-reference/help-examples/admin/dashboard/update-layout.json +16 -0
  30. package/sdk-dist/docs/runtime-reference/help-examples/admin/widget/create.json +33 -0
  31. package/sdk-dist/docs/runtime-reference/help-examples/admin/widget/preview-data.json +42 -0
  32. package/sdk-dist/docs/runtime-reference/widgets.md +40 -0
  33. package/sdk-dist/generated/command_registry.generated.ts +395 -0
  34. package/sdk-dist/generated/help_examples.generated.ts +122 -0
  35. package/sdk-dist/generated/type_index.generated.ts +42 -1
  36. package/sdk-dist/generated/zod_registry.generated.ts +56 -0
  37. package/sdk-dist/types/app.ts +37 -1
  38. package/sdk-dist/types/common.ts +77 -35
  39. package/sdk-dist/types/index.ts +1 -1
  40. package/sdk-dist/types/public-link.ts +10 -0
  41. package/sdk-dist/types/shared-link.ts +16 -1
  42. package/sdk-dist/types/user-action.ts +1 -43
  43. package/src/generated/command_registry.generated.ts +395 -0
  44. package/src/generated/help_examples.generated.ts +122 -0
  45. package/src/generated/type_index.generated.ts +42 -1
  46. package/src/generated/zod_registry.generated.ts +56 -0
  47. package/src/runtime/dev_sdk_gen.ts +360 -0
  48. package/src/runtime/execute.ts +325 -1
  49. package/src/runtime/zod_registry.ts +58 -0
  50. package/src/tests/command_registry.test.ts +20 -2
  51. package/src/tests/dev_sdk_gen.test.ts +226 -0
  52. package/src/tests/docs_readability.test.ts +15 -0
  53. package/src/tests/execute_validation.test.ts +129 -0
  54. package/src/tests/help.test.ts +70 -0
  55. package/sdk-dist/api/user/copilot.ts +0 -20
  56. package/sdk-dist/types/copilot.ts +0 -34
@@ -0,0 +1,226 @@
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
+
7
+ import { generateArcubaseProjectSDK } from '../runtime/dev_sdk_gen.js'
8
+ import { executeCLI } from '../runtime/execute.js'
9
+ import { CLIError } from '../runtime/errors.js'
10
+
11
+ const env = {
12
+ ARCUBASE_BASE_URL: 'https://arcubase.example.com',
13
+ ARCUBASE_ACCESS_TOKEN: 'tok',
14
+ ARCUBASE_SDK_ROOT: '/runtime/arcubase-sdk',
15
+ ARCUBASE_TRACE_ID: '',
16
+ ARCUBASE_SUBJECT_TYPE: '',
17
+ ARCUBASE_SUBJECT_ID: '',
18
+ ARCUBASE_TOKEN_EXPIRES_AT: '',
19
+ }
20
+
21
+ function appDetail() {
22
+ return {
23
+ id: 3882856425,
24
+ name: '故事应用',
25
+ entities: {},
26
+ }
27
+ }
28
+
29
+ function entityList() {
30
+ return [
31
+ {
32
+ id: 3883547182,
33
+ name: '编故事',
34
+ },
35
+ ]
36
+ }
37
+
38
+ function appDetailWithEntityList() {
39
+ return {
40
+ id: 3882856425,
41
+ name: '故事应用',
42
+ entities: [
43
+ {
44
+ id: 3883547182,
45
+ name: '编故事',
46
+ },
47
+ ],
48
+ }
49
+ }
50
+
51
+ function entityDetail() {
52
+ return {
53
+ id: 3883547182,
54
+ app_id: 3882856425,
55
+ name: '编故事',
56
+ key: 'story',
57
+ fields: [
58
+ { id: 1006, label: '时代', key: 'era', type: 'select', required: false, options: { options: { items: [{ key: 1, value: '现代' }] } } },
59
+ { id: 1013, label: '你刚刚', key: 'recentEvent', type: 'text', required: false, options: {} },
60
+ { id: 1011, label: '故事', key: 'story', type: 'textarea', required: true, options: {} },
61
+ ],
62
+ }
63
+ }
64
+
65
+ function entityDetailWithoutFieldKeys() {
66
+ const detail = entityDetail()
67
+ detail.fields = detail.fields.map((field) => ({ ...field, key: '' }))
68
+ return detail
69
+ }
70
+
71
+ function sdkSchemaPayload() {
72
+ return {
73
+ ...appDetailWithEntityList(),
74
+ entities: [
75
+ {
76
+ ...entityDetail(),
77
+ key: 'story',
78
+ },
79
+ ],
80
+ }
81
+ }
82
+
83
+ test('generateArcubaseProjectSDK emits typed key based entity sdk', () => {
84
+ const result = generateArcubaseProjectSDK(sdkSchemaPayload())
85
+
86
+ assert.deepEqual(result.files.map((file) => file.path).sort(), [
87
+ 'client.ts',
88
+ 'entities/story.ts',
89
+ 'index.ts',
90
+ 'runtime.ts',
91
+ 'schema.ts',
92
+ ])
93
+
94
+ const client = result.files.find((file) => file.path === 'client.ts')?.contents ?? ''
95
+ assert.match(client, /createArcubaseSdk/)
96
+ assert.match(client, /story: createStorySDK\(runtime\)/)
97
+
98
+ const runtime = result.files.find((file) => file.path === 'runtime.ts')?.contents ?? ''
99
+ assert.match(runtime, /accessToken/)
100
+ assert.match(runtime, /refreshToken/)
101
+
102
+ const story = result.files.find((file) => file.path === 'entities/story.ts')?.contents ?? ''
103
+ assert.match(story, /export type StoryFields =/)
104
+ assert.match(story, /era\?: number \| string/)
105
+ assert.match(story, /recentEvent\?: string/)
106
+ assert.match(story, /story: string/)
107
+ assert.match(story, /create\(fields: StoryCreateInput\)/)
108
+ assert.match(story, /update\(rowId: string \| number, fields: StoryUpdateInput\)/)
109
+ assert.match(story, /toArcubaseFields\(fields\)/)
110
+ assert.match(story, /changed_fields: Object.keys\(data\)\.map\(\(fieldId\) => Number\(fieldId\)\)/)
111
+ assert.match(story, /\/entity\/3882856425\/\$\{entityId\}\/insert/)
112
+
113
+ const schema = result.files.find((file) => file.path === 'schema.ts')?.contents ?? ''
114
+ assert.match(schema, /"story"/)
115
+ assert.match(schema, /"fieldId": 1011/)
116
+ assert.match(schema, /"entityId": 3883547182/)
117
+ })
118
+
119
+ test('generateArcubaseProjectSDK rejects missing field keys', () => {
120
+ const payload = sdkSchemaPayload()
121
+ payload.entities[0].fields[1].key = ''
122
+
123
+ assert.throws(() => generateArcubaseProjectSDK(payload), (error: unknown) => {
124
+ assert.ok(error instanceof CLIError)
125
+ assert.equal(error.code, 'SDK_GEN_FIELD_KEY_REQUIRED')
126
+ assert.match(error.message, /你刚刚/)
127
+ return true
128
+ })
129
+ })
130
+
131
+ test('generateArcubaseProjectSDK rejects duplicate field keys within an entity', () => {
132
+ const payload = sdkSchemaPayload()
133
+ payload.entities[0].fields[1].key = 'story'
134
+
135
+ assert.throws(() => generateArcubaseProjectSDK(payload), (error: unknown) => {
136
+ assert.ok(error instanceof CLIError)
137
+ assert.equal(error.code, 'SDK_GEN_DUPLICATE_FIELD_KEY')
138
+ assert.match(error.message, /story/)
139
+ return true
140
+ })
141
+ })
142
+
143
+ test('arcubase-admin dev sdk-gen fetches app schema and writes typed sdk files', async () => {
144
+ const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'arcubase-sdk-gen-'))
145
+ const calls: Array<{ url: string; method?: string }> = []
146
+
147
+ const result = await executeCLI(
148
+ 'admin',
149
+ ['dev', 'sdk-gen', '--app-id', '3882856425', '--out', outDir],
150
+ env as any,
151
+ async (url, init) => {
152
+ calls.push({ url: String(url), method: init?.method })
153
+ if (String(url).endsWith('/api/apps/3882856425')) {
154
+ return new Response(JSON.stringify({ data: appDetail() }), { status: 200 })
155
+ }
156
+ if (String(url).endsWith('/api/apps/3882856425/entities')) {
157
+ return new Response(JSON.stringify({ data: entityList() }), { status: 200 })
158
+ }
159
+ if (String(url).endsWith('/api/apps/3882856425/entity/3883547182')) {
160
+ return new Response(JSON.stringify({ data: entityDetail() }), { status: 200 })
161
+ }
162
+ return new Response(JSON.stringify({ error: { message: `unexpected url ${url}` } }), { status: 404 })
163
+ },
164
+ )
165
+
166
+ assert.equal(result.kind, 'result')
167
+ assert.deepEqual(result.commandPath, ['dev', 'sdk-gen'])
168
+ assert.equal(calls[0].method, 'GET')
169
+ assert.match(calls[0].url, /\/api\/apps\/3882856425$/)
170
+ assert.equal(calls[1].method, 'GET')
171
+ assert.match(calls[1].url, /\/api\/apps\/3882856425\/entities$/)
172
+ assert.equal(calls[2].method, 'GET')
173
+ assert.match(calls[2].url, /\/api\/apps\/3882856425\/entity\/3883547182$/)
174
+ assert.ok(fs.existsSync(path.join(outDir, 'index.ts')))
175
+ assert.ok(fs.existsSync(path.join(outDir, 'client.ts')))
176
+ assert.ok(fs.existsSync(path.join(outDir, 'entities/story.ts')))
177
+ assert.match(fs.readFileSync(path.join(outDir, 'client.ts'), 'utf8'), /createArcubaseSdk/)
178
+ })
179
+
180
+ test('arcubase-admin dev sdk-gen initializes missing field keys through admin auth before generation', async () => {
181
+ const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'arcubase-sdk-gen-'))
182
+ const calls: Array<{ url: string; method?: string; authorization?: string; body?: any }> = []
183
+
184
+ const result = await executeCLI(
185
+ 'admin',
186
+ ['dev', 'sdk-gen', '--app-id', '3882856425', '--out', outDir],
187
+ env as any,
188
+ async (url, init) => {
189
+ const bodyText = typeof init?.body === 'string' ? init.body : undefined
190
+ calls.push({
191
+ url: String(url),
192
+ method: init?.method,
193
+ authorization: init?.headers instanceof Headers
194
+ ? init.headers.get('Authorization') ?? undefined
195
+ : (init?.headers as Record<string, string> | undefined)?.Authorization,
196
+ body: bodyText ? JSON.parse(bodyText) : undefined,
197
+ })
198
+ if (String(url).endsWith('/api/apps/3882856425')) {
199
+ return new Response(JSON.stringify({ data: appDetail() }), { status: 200 })
200
+ }
201
+ if (String(url).endsWith('/api/apps/3882856425/entities')) {
202
+ return new Response(JSON.stringify({ data: entityList() }), { status: 200 })
203
+ }
204
+ if (String(url).endsWith('/api/apps/3882856425/entity/3883547182')) {
205
+ return new Response(JSON.stringify({ data: entityDetailWithoutFieldKeys() }), { status: 200 })
206
+ }
207
+ if (String(url).endsWith('/api/apps/3882856425/entity/3883547182/custom-keys')) {
208
+ return new Response(JSON.stringify({ data: entityDetail() }), { status: 200 })
209
+ }
210
+ return new Response(JSON.stringify({ error: { message: `unexpected url ${url}` } }), { status: 404 })
211
+ },
212
+ )
213
+
214
+ assert.equal(result.kind, 'result')
215
+ const customKeysCall = calls.find((call) => call.url.endsWith('/api/apps/3882856425/entity/3883547182/custom-keys'))
216
+ assert.ok(customKeysCall)
217
+ assert.equal(customKeysCall.method, 'PUT')
218
+ assert.equal(customKeysCall.authorization, 'Bearer tok')
219
+ assert.deepEqual(customKeysCall.body, [
220
+ { id: 1006, key: 'field1006' },
221
+ { id: 1013, key: 'field1013' },
222
+ { id: 1011, key: 'field1011' },
223
+ ])
224
+ assert.match(fs.readFileSync(path.join(outDir, 'entities/story.ts'), 'utf8'), /field1011: string/)
225
+ assert.deepEqual(result.data.initializedFieldKeys, [{ entityId: 3883547182, fields: ['field1006', 'field1013', 'field1011'] }])
226
+ })
@@ -68,6 +68,21 @@ test('runtime docs do not use retired table create and row probe names', () => {
68
68
  }
69
69
  })
70
70
 
71
+ test('runtime docs document dashboard and widget single success paths', () => {
72
+ const dashboard = fs.readFileSync(path.join(root, 'dashboard.md'), 'utf8')
73
+ const widgets = fs.readFileSync(path.join(root, 'widgets.md'), 'utf8')
74
+ assert.match(dashboard, /arcubase dashboard get/)
75
+ assert.match(dashboard, /arcubase-admin dashboard list/)
76
+ assert.match(dashboard, /not exposed/)
77
+ assert.match(widgets, /arcubase-admin widget list/)
78
+ assert.match(widgets, /--widget-id/)
79
+ for (const aggregate of ['sum', 'avg', 'max', 'min', 'count', 'distinct_count']) {
80
+ assert.match(widgets, new RegExp(`\\\`${aggregate}\\\``))
81
+ }
82
+ assert.match(widgets, /unsupported aggregate names are invalid request bodies/)
83
+ assert.doesNotMatch(widgets, /widgets_id/)
84
+ })
85
+
71
86
  test('scenario examples exist and are readable', () => {
72
87
  for (const dir of ['oms-01', 'wms-01', 'crm-01']) {
73
88
  const readme = path.join(root, 'examples', dir, 'README.md')
@@ -1094,6 +1094,135 @@ test('entry fixed app tables query cannot be disabled by query file', async () =
1094
1094
  assert.equal(out.data.url, 'https://arcubase.example.com/api/entry?include_app_tables=true')
1095
1095
  })
1096
1096
 
1097
+ test('dashboard and widget commands map to approved endpoints', async () => {
1098
+ const adminWidgetList = await executeCLI(
1099
+ 'admin',
1100
+ ['widget', 'list', '--app-id', 'app_1', '--type', 'dashboard', '--dashboard-id', '100'],
1101
+ env as any,
1102
+ async (url, init) => new Response(JSON.stringify({ url, method: init?.method }), { status: 200 }),
1103
+ )
1104
+ assert.equal(adminWidgetList.kind, 'result')
1105
+ assert.equal(adminWidgetList.data.url, 'https://arcubase.example.com/api/apps/app_1/widgets?type=dashboard&dashboard_id=100')
1106
+ assert.equal(adminWidgetList.data.method, 'GET')
1107
+
1108
+ const userDashboardWidgets = await executeCLI(
1109
+ 'user',
1110
+ ['dashboard', 'widgets', '--app-id', 'app_1', '--dashboard-id', 'dash_1'],
1111
+ env as any,
1112
+ async (url, init) => new Response(JSON.stringify({ url, method: init?.method }), { status: 200 }),
1113
+ )
1114
+ assert.equal(userDashboardWidgets.kind, 'result')
1115
+ assert.equal(userDashboardWidgets.data.url, 'https://arcubase.example.com/api/dashboard/app_1/dash_1/widgets')
1116
+ assert.equal(userDashboardWidgets.data.method, 'GET')
1117
+
1118
+ const userWidgetData = await executeCLI(
1119
+ 'user',
1120
+ ['widget', 'data', '--app-id', 'app_1', '--body-json', '{"dashboard_id":100,"type":1}'],
1121
+ env as any,
1122
+ async (url, init) => new Response(JSON.stringify({
1123
+ url,
1124
+ method: init?.method,
1125
+ body: init?.body ? JSON.parse(String(init.body)) : null,
1126
+ }), { status: 200 }),
1127
+ )
1128
+ assert.equal(userWidgetData.kind, 'result')
1129
+ assert.equal(userWidgetData.data.url, 'https://arcubase.example.com/api/apps/app_1/widgets-data')
1130
+ assert.equal(userWidgetData.data.method, 'POST')
1131
+ assert.deepEqual(userWidgetData.data.body, { dashboard_id: 100, type: 1 })
1132
+ })
1133
+
1134
+ test('widget preview-data rejects unsupported aggregate before request', async () => {
1135
+ let called = false
1136
+ await assert.rejects(async () => {
1137
+ await executeCLI(
1138
+ 'admin',
1139
+ [
1140
+ 'widget',
1141
+ 'preview-data',
1142
+ '--app-id',
1143
+ 'app_1',
1144
+ '--body-json',
1145
+ '{"dataSource":2188891001,"dataSourceType":"entity","measures":[{"Name":"median_amount","FieldID":1004,"Aggregate":"median"}]}',
1146
+ ],
1147
+ env as any,
1148
+ async () => {
1149
+ called = true
1150
+ return new Response('{}', { status: 200 })
1151
+ },
1152
+ )
1153
+ }, (error: unknown) => {
1154
+ assert.ok(error instanceof CLIError)
1155
+ assert.equal(error.code, 'BODY_VALIDATION_FAILED')
1156
+ assert.equal(error.details?.requestType, 'AppPreviewWidgetsDataReqVO')
1157
+ assert.ok((error.details?.issues ?? []).some((item) => item.path === 'body.measures.0.Aggregate'))
1158
+ assert.ok((error.details?.docHints ?? []).some((item) => item.file === '/runtime/arcubase-sdk/docs/runtime-reference/widgets.md'))
1159
+ return true
1160
+ })
1161
+ assert.equal(called, false)
1162
+ })
1163
+
1164
+ test('widget preview-data rejects field dimensions without IsField true before request', async () => {
1165
+ let called = false
1166
+ await assert.rejects(async () => {
1167
+ await executeCLI(
1168
+ 'admin',
1169
+ [
1170
+ 'widget',
1171
+ 'preview-data',
1172
+ '--app-id',
1173
+ 'app_1',
1174
+ '--body-json',
1175
+ '{"dataSource":2188891001,"dataSourceType":"entity","dimensions":[{"FieldID":1004,"Name":"Source"}],"measures":[{"Name":"Total Amount","FieldID":1005,"Aggregate":"sum"}]}',
1176
+ ],
1177
+ env as any,
1178
+ async () => {
1179
+ called = true
1180
+ return new Response('{}', { status: 200 })
1181
+ },
1182
+ )
1183
+ }, (error: unknown) => {
1184
+ assert.ok(error instanceof CLIError)
1185
+ assert.equal(error.code, 'BODY_VALIDATION_FAILED')
1186
+ assert.equal(error.details?.requestType, 'AppPreviewWidgetsDataReqVO')
1187
+ assert.ok((error.details?.issues ?? []).some((item) => item.path === 'body.dimensions.0.IsField'))
1188
+ assert.ok((error.details?.commonMistakes ?? []).includes('field dimensions with FieldID must set IsField:true'))
1189
+ return true
1190
+ })
1191
+ assert.equal(called, false)
1192
+ })
1193
+
1194
+ test('widget update rejects chart field dimensions without IsField true before request', async () => {
1195
+ let called = false
1196
+ await assert.rejects(async () => {
1197
+ await executeCLI(
1198
+ 'admin',
1199
+ [
1200
+ 'widget',
1201
+ 'update',
1202
+ '--app-id',
1203
+ 'app_1',
1204
+ '--widget-id',
1205
+ 'widget_1',
1206
+ '--body-json',
1207
+ '{"entity_id":2188891001,"options":{"charts":{"entity_id":2188891001,"dimensions":[{"FieldID":1004,"IsField":false,"Name":"Source"}],"measures":[{"Name":"Total Amount","FieldID":1005,"Aggregate":"sum"}]}}}',
1208
+ ],
1209
+ env as any,
1210
+ async () => {
1211
+ called = true
1212
+ return new Response('{}', { status: 200 })
1213
+ },
1214
+ )
1215
+ }, (error: unknown) => {
1216
+ assert.ok(error instanceof CLIError)
1217
+ assert.equal(error.code, 'BODY_VALIDATION_FAILED')
1218
+ assert.equal(error.details?.requestType, 'AppUpdateWidgetsReqVO')
1219
+ assert.ok((error.details?.issues ?? []).some((item) => item.path === 'body.options.charts.dimensions.0.IsField'))
1220
+ assert.ok((error.details?.commonMistakes ?? []).includes('field dimensions with FieldID must set IsField:true'))
1221
+ return true
1222
+ })
1223
+ assert.equal(called, false)
1224
+ })
1225
+
1097
1226
  test('upstream http failures include endpoint status and body details', async () => {
1098
1227
  await assert.rejects(async () => {
1099
1228
  await executeCLI('user', ['entry'], env as any, async () => new Response('', { status: 500 }))
@@ -21,10 +21,25 @@ test('admin root help exposes reset surface nouns only', async () => {
21
21
  assert.match(out.text, /\btable\b/)
22
22
  assert.match(out.text, /\baccess-rule\b/)
23
23
  assert.match(out.text, /\bworkflow\b/)
24
+ assert.match(out.text, /\bdev\b/)
24
25
  assert.doesNotMatch(out.text, /\bentity\b/)
25
26
  assert.doesNotMatch(out.text, /\bingress\b/)
26
27
  })
27
28
 
29
+ test('admin dev sdk-gen help documents typed project sdk generation', async () => {
30
+ const moduleHelp = await executeCLI('admin', ['dev', '--help'], env as any, async () => new Response('{}'))
31
+ assert.equal(moduleHelp.kind, 'help')
32
+ assert.match(moduleHelp.text, /sdk-gen/)
33
+
34
+ const commandHelp = await executeCLI('admin', ['dev', 'sdk-gen', '--help'], env as any, async () => new Response('{}'))
35
+ assert.equal(commandHelp.kind, 'help')
36
+ assert.match(commandHelp.text, /arcubase-admin dev sdk-gen/)
37
+ assert.match(commandHelp.text, /--app-id/)
38
+ assert.match(commandHelp.text, /--out/)
39
+ assert.match(commandHelp.text, /field\.key/)
40
+ assert.match(commandHelp.text, /createArcubaseSdk\(\{ baseURL, accessToken, refreshToken \}\)/)
41
+ })
42
+
28
43
  test('user root help exposes reset surface nouns only', async () => {
29
44
  const out = await executeCLI('user', ['--help'], env as any, async () => new Response('{}'))
30
45
  assert.equal(out.kind, 'help')
@@ -99,6 +114,30 @@ test('admin table create help gives one-call body-json example', async () => {
99
114
  assert.match(out.text, /"type":"textarea"/)
100
115
  })
101
116
 
117
+ test('dashboard and widget help exposes agent-readable body docs and flags', async () => {
118
+ const adminDashboardCreate = await executeCLI('admin', ['dashboard', 'create', '--help'], env as any, async () => new Response('{}'))
119
+ assert.equal(adminDashboardCreate.kind, 'help')
120
+ assert.match(adminDashboardCreate.text, /arcubase-admin dashboard create/)
121
+ assert.match(adminDashboardCreate.text, /endpoint: \/apps\/:app_id\/dashboard/)
122
+ assert.match(adminDashboardCreate.text, /body: DashboardCreateReqVO via --body-json/)
123
+ assert.match(adminDashboardCreate.text, /^types:$/m)
124
+ assert.match(adminDashboardCreate.text, /^docs:$/m)
125
+
126
+ const adminWidgetList = await executeCLI('admin', ['widget', 'list', '--help'], env as any, async () => new Response('{}'))
127
+ assert.equal(adminWidgetList.kind, 'help')
128
+ assert.match(adminWidgetList.text, /arcubase-admin widget list/)
129
+ assert.match(adminWidgetList.text, /endpoint: \/apps\/:app_id\/widgets/)
130
+ assert.match(adminWidgetList.text, /query flags: --type, --dashboard-id, --ingress-id, --query-file/)
131
+ assert.match(adminWidgetList.text, /^docs:$/m)
132
+
133
+ const userWidgetData = await executeCLI('user', ['widget', 'data', '--help'], env as any, async () => new Response('{}'))
134
+ assert.equal(userWidgetData.kind, 'help')
135
+ assert.match(userWidgetData.text, /arcubase widget data/)
136
+ assert.match(userWidgetData.text, /body: FetchWidgetsDataReqVO via --body-json/)
137
+ assert.match(userWidgetData.text, /^types:$/m)
138
+ assert.match(userWidgetData.text, /^docs:$/m)
139
+ })
140
+
102
141
  test('admin access-rule help gives update whitelist and assign-users body-json examples', async () => {
103
142
  const create = await executeCLI('admin', ['access-rule', 'create', '--help'], env as any, async () => new Response('{}'))
104
143
  assert.equal(create.kind, 'help')
@@ -166,6 +205,37 @@ test('admin access-rule bulk-apply help-examples show transactional matrix body'
166
205
  assert.doesNotMatch(out.text, /"type":"member"/)
167
206
  })
168
207
 
208
+ test('admin dashboard update-layout help-examples show top-level layout array', async () => {
209
+ const out = await executeCLI('admin', ['dashboard', 'update-layout', '--help-examples'], env as any, async () => new Response('{}'))
210
+ assert.equal(out.kind, 'help')
211
+ assert.match(out.text, /arcubase-admin dashboard update-layout --help-examples/)
212
+ assert.match(out.text, /--body-json '\[\{"id":2188892001,"x":0,"y":0,"w":12,"h":6\}\]'/)
213
+ assert.match(out.text, /the request body is a top-level array/)
214
+ assert.match(out.text, /do not wrap the array/)
215
+ })
216
+
217
+ test('admin widget preview-data help-examples show chart query body without widget id', async () => {
218
+ const out = await executeCLI('admin', ['widget', 'preview-data', '--help-examples'], env as any, async () => new Response('{}'))
219
+ assert.equal(out.kind, 'help')
220
+ assert.match(out.text, /arcubase-admin widget preview-data --help-examples/)
221
+ assert.match(out.text, /"dataSource":2188891001/)
222
+ assert.match(out.text, /"dataSourceType":"entity"/)
223
+ assert.match(out.text, /"Aggregate":"sum"/)
224
+ assert.match(out.text, /preview-data does not accept --widget-id/)
225
+ assert.match(out.text, /do not send widget_id or id/)
226
+ assert.doesNotMatch(out.text, /--widget-id <widget_id>/)
227
+ })
228
+
229
+ test('admin widget create help-examples avoid manual options type', async () => {
230
+ const out = await executeCLI('admin', ['widget', 'create', '--help-examples'], env as any, async () => new Response('{}'))
231
+ assert.equal(out.kind, 'help')
232
+ assert.match(out.text, /arcubase-admin widget create --help-examples/)
233
+ assert.match(out.text, /"type":"chart","options":\{"dashboard_id":2188892001\}/)
234
+ assert.match(out.text, /do not set options.type by hand/)
235
+ assert.match(out.text, /dashboard_id selects a dashboard widget/)
236
+ assert.doesNotMatch(out.text, /"options":\{"dashboard_id":2188892001,"type":/)
237
+ })
238
+
169
239
  test('user row bulk-update help-examples show ids and condition selection bodies', async () => {
170
240
  const out = await executeCLI('user', ['row', 'bulk-update', '--help-examples'], env as any, async () => new Response('{}'))
171
241
  assert.equal(out.kind, 'help')
@@ -1,20 +0,0 @@
1
- import { getDefaultClient } from '../../factory'
2
- import type {
3
- CopilotInitConversationRespVO,
4
- CopilotSendMessageReqVO,
5
- CopilotSendMessageRespVO
6
- } from '../../types/copilot'
7
-
8
- // @endpoint POST /copilot/init
9
- // @controller CopilotController.InitConversation
10
- export async function initCopilotConversation(): Promise<CopilotInitConversationRespVO> {
11
- return getDefaultClient().post('/copilot/init')
12
- }
13
-
14
- // @endpoint POST /copilot/send-message
15
- // @controller CopilotController.SendMessage
16
- export async function sendCopilotMessage(
17
- data: CopilotSendMessageReqVO
18
- ): Promise<CopilotSendMessageRespVO> {
19
- return getDefaultClient().post('/copilot/send-message', data)
20
- }
@@ -1,34 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- // @ts-nocheck
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
-
13
- import type { ErrorResponse } from './common'
14
-
15
- export interface CopilotMessage {
16
- Content?: string;
17
- Type?: string;
18
- }
19
-
20
- export interface CopilotInitConversationRespVO {
21
- ID?: string;
22
- }
23
-
24
- export interface CopilotSendMessageReqVO {
25
- conversation_id?: string;
26
- current_view?: string;
27
- messages?: CopilotMessage[];
28
- params?: Record<string, string>;
29
- }
30
-
31
- export interface CopilotSendMessageRespVO {
32
- ID?: string;
33
- Request?: string;
34
- }