@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.
- package/bundle/arcubase-admin.mjs +546 -243
- package/bundle/arcubase.mjs +546 -243
- package/dist/bin/arcubase-admin.js +0 -0
- package/dist/bin/arcubase.js +0 -0
- package/dist/generated/command_registry.generated.d.ts +36 -112
- package/dist/generated/command_registry.generated.d.ts.map +1 -1
- package/dist/generated/command_registry.generated.js +40 -163
- package/dist/generated/type_index.generated.d.ts +0 -12
- package/dist/generated/type_index.generated.d.ts.map +1 -1
- package/dist/generated/type_index.generated.js +0 -12
- package/dist/generated/zod_registry.generated.d.ts +1 -19
- package/dist/generated/zod_registry.generated.d.ts.map +1 -1
- package/dist/generated/zod_registry.generated.js +0 -21
- package/dist/runtime/command_registry.d.ts +19 -1
- package/dist/runtime/command_registry.d.ts.map +1 -1
- package/dist/runtime/command_registry.js +19 -1
- package/dist/runtime/errors.d.ts +1 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/execute.d.ts.map +1 -1
- package/dist/runtime/execute.js +321 -8
- 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.map +1 -1
- package/dist/runtime/zod_registry.js +50 -30
- package/dist/tests/command_registry.test.js +11 -4
- package/dist/tests/execute_validation.test.js +221 -13
- package/dist/tests/help.test.js +29 -6
- 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/api/admin/app.ts +8 -1
- package/sdk-dist/docs/runtime-reference/README.md +33 -15
- package/sdk-dist/docs/runtime-reference/app-discovery.md +68 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/README.md +2 -2
- package/sdk-dist/docs/runtime-reference/entity-schema/file.md +9 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/image.md +9 -0
- package/sdk-dist/docs/runtime-reference/entity-schema/subform.md +2 -2
- package/sdk-dist/docs/runtime-reference/entity-schema.md +2 -2
- package/sdk-dist/docs/runtime-reference/examples/README.md +1 -1
- package/sdk-dist/docs/runtime-reference/examples/oms-01/README.md +23 -4
- package/sdk-dist/docs/runtime-reference/examples/oms-01/app-overview.md +1 -1
- package/sdk-dist/docs/runtime-reference/row-crud.md +8 -6
- package/sdk-dist/docs/runtime-reference/search-and-bulk-actions.md +5 -5
- package/sdk-dist/docs/runtime-reference/table-lifecycle.md +34 -6
- package/sdk-dist/docs/runtime-reference/uploads.md +106 -0
- package/sdk-dist/generated/command_registry.generated.ts +40 -163
- package/sdk-dist/generated/type_index.generated.ts +0 -12
- package/sdk-dist/generated/zod_registry.generated.ts +0 -36
- package/sdk-dist/types/app.ts +7 -0
- package/src/generated/command_registry.generated.ts +40 -163
- package/src/generated/type_index.generated.ts +0 -12
- package/src/generated/zod_registry.generated.ts +0 -36
- package/src/runtime/command_registry.ts +38 -2
- package/src/runtime/errors.ts +1 -0
- package/src/runtime/execute.ts +368 -8
- package/src/runtime/upload.ts +196 -0
- package/src/runtime/zod_registry.ts +50 -30
- package/src/tests/command_registry.test.ts +13 -4
- package/src/tests/execute_validation.test.ts +257 -13
- package/src/tests/help.test.ts +35 -6
- package/src/tests/upload.test.ts +133 -0
- package/sdk-dist/docs/runtime-reference/workflow/README.md +0 -19
package/bundle/arcubase.mjs
CHANGED
|
@@ -227,6 +227,22 @@ var adminCommands = [
|
|
|
227
227
|
"scalarParams": [],
|
|
228
228
|
"responseType": "AppCreateByTenantsRespVO"
|
|
229
229
|
},
|
|
230
|
+
{
|
|
231
|
+
"scope": "admin",
|
|
232
|
+
"module": "app",
|
|
233
|
+
"functionName": "listApps",
|
|
234
|
+
"commandPath": [
|
|
235
|
+
"app",
|
|
236
|
+
"list-apps"
|
|
237
|
+
],
|
|
238
|
+
"method": "GET",
|
|
239
|
+
"endpoint": "/apps",
|
|
240
|
+
"endpointParams": [],
|
|
241
|
+
"controller": "App.ListApps",
|
|
242
|
+
"requestType": null,
|
|
243
|
+
"scalarParams": [],
|
|
244
|
+
"responseType": "AppListRespVO"
|
|
245
|
+
},
|
|
230
246
|
{
|
|
231
247
|
"scope": "admin",
|
|
232
248
|
"module": "app",
|
|
@@ -3232,88 +3248,6 @@ var adminCommands = [
|
|
|
3232
3248
|
}
|
|
3233
3249
|
],
|
|
3234
3250
|
"responseType": "TenantUsageDailyRespVO"
|
|
3235
|
-
},
|
|
3236
|
-
{
|
|
3237
|
-
"scope": "admin",
|
|
3238
|
-
"module": "workflow",
|
|
3239
|
-
"functionName": "deployEntityWorkflow",
|
|
3240
|
-
"commandPath": [
|
|
3241
|
-
"workflow",
|
|
3242
|
-
"deploy-entity-workflow"
|
|
3243
|
-
],
|
|
3244
|
-
"method": "POST",
|
|
3245
|
-
"endpoint": "/apps/:app_id/entity/:entity_id/workflow/deploy",
|
|
3246
|
-
"endpointParams": [
|
|
3247
|
-
"app_id",
|
|
3248
|
-
"entity_id"
|
|
3249
|
-
],
|
|
3250
|
-
"controller": "Entity.WorkflowDeploy",
|
|
3251
|
-
"requestType": "EntityWorkflowDeployReqVO",
|
|
3252
|
-
"scalarParams": [],
|
|
3253
|
-
"responseType": "EntityWorkflowDeployRespVO"
|
|
3254
|
-
},
|
|
3255
|
-
{
|
|
3256
|
-
"scope": "admin",
|
|
3257
|
-
"module": "workflow",
|
|
3258
|
-
"functionName": "getEntityWorkflow",
|
|
3259
|
-
"commandPath": [
|
|
3260
|
-
"workflow",
|
|
3261
|
-
"get-entity-workflow"
|
|
3262
|
-
],
|
|
3263
|
-
"method": "GET",
|
|
3264
|
-
"endpoint": "/apps/:app_id/entity/:entity_id/workflow",
|
|
3265
|
-
"endpointParams": [
|
|
3266
|
-
"app_id",
|
|
3267
|
-
"entity_id"
|
|
3268
|
-
],
|
|
3269
|
-
"controller": "Entity.WorkflowGet",
|
|
3270
|
-
"requestType": null,
|
|
3271
|
-
"scalarParams": [
|
|
3272
|
-
{
|
|
3273
|
-
"name": "workingId",
|
|
3274
|
-
"type": "string",
|
|
3275
|
-
"hasDefault": true
|
|
3276
|
-
}
|
|
3277
|
-
],
|
|
3278
|
-
"responseType": "EntityWorkflowGetRespVO"
|
|
3279
|
-
},
|
|
3280
|
-
{
|
|
3281
|
-
"scope": "admin",
|
|
3282
|
-
"module": "workflow",
|
|
3283
|
-
"functionName": "createEntityWorkflowVersion",
|
|
3284
|
-
"commandPath": [
|
|
3285
|
-
"workflow",
|
|
3286
|
-
"create-entity-workflow-version"
|
|
3287
|
-
],
|
|
3288
|
-
"method": "POST",
|
|
3289
|
-
"endpoint": "/apps/:app_id/entity/:entity_id/workflow/new",
|
|
3290
|
-
"endpointParams": [
|
|
3291
|
-
"app_id",
|
|
3292
|
-
"entity_id"
|
|
3293
|
-
],
|
|
3294
|
-
"controller": "Entity.WorkflowNewVersion",
|
|
3295
|
-
"requestType": null,
|
|
3296
|
-
"scalarParams": [],
|
|
3297
|
-
"responseType": "EntityWorkflowNewVersionRespVO"
|
|
3298
|
-
},
|
|
3299
|
-
{
|
|
3300
|
-
"scope": "admin",
|
|
3301
|
-
"module": "workflow",
|
|
3302
|
-
"functionName": "updateEntityWorkflow",
|
|
3303
|
-
"commandPath": [
|
|
3304
|
-
"workflow",
|
|
3305
|
-
"update-entity-workflow"
|
|
3306
|
-
],
|
|
3307
|
-
"method": "POST",
|
|
3308
|
-
"endpoint": "/apps/:app_id/entity/:entity_id/workflow",
|
|
3309
|
-
"endpointParams": [
|
|
3310
|
-
"app_id",
|
|
3311
|
-
"entity_id"
|
|
3312
|
-
],
|
|
3313
|
-
"controller": "Entity.WorkflowUpdate",
|
|
3314
|
-
"requestType": "EntityWorkflowUpdateReqVO",
|
|
3315
|
-
"scalarParams": [],
|
|
3316
|
-
"responseType": "EntityWorkflowUpdateRespVO"
|
|
3317
3251
|
}
|
|
3318
3252
|
];
|
|
3319
3253
|
var userCommands = [
|
|
@@ -4430,10 +4364,10 @@ var userCommands = [
|
|
|
4430
4364
|
},
|
|
4431
4365
|
{
|
|
4432
4366
|
"scope": "user",
|
|
4433
|
-
"module": "
|
|
4367
|
+
"module": "rows",
|
|
4434
4368
|
"functionName": "putEntityQueryKeeper",
|
|
4435
4369
|
"commandPath": [
|
|
4436
|
-
"
|
|
4370
|
+
"rows",
|
|
4437
4371
|
"put-entity-query-keeper"
|
|
4438
4372
|
],
|
|
4439
4373
|
"method": "POST",
|
|
@@ -4449,10 +4383,10 @@ var userCommands = [
|
|
|
4449
4383
|
},
|
|
4450
4384
|
{
|
|
4451
4385
|
"scope": "user",
|
|
4452
|
-
"module": "
|
|
4386
|
+
"module": "rows",
|
|
4453
4387
|
"functionName": "queryEntity",
|
|
4454
4388
|
"commandPath": [
|
|
4455
|
-
"
|
|
4389
|
+
"rows",
|
|
4456
4390
|
"query-entity"
|
|
4457
4391
|
],
|
|
4458
4392
|
"method": "POST",
|
|
@@ -4468,10 +4402,10 @@ var userCommands = [
|
|
|
4468
4402
|
},
|
|
4469
4403
|
{
|
|
4470
4404
|
"scope": "user",
|
|
4471
|
-
"module": "
|
|
4405
|
+
"module": "rows",
|
|
4472
4406
|
"functionName": "filterEntityQuery",
|
|
4473
4407
|
"commandPath": [
|
|
4474
|
-
"
|
|
4408
|
+
"rows",
|
|
4475
4409
|
"filter-entity-query"
|
|
4476
4410
|
],
|
|
4477
4411
|
"method": "POST",
|
|
@@ -4487,10 +4421,10 @@ var userCommands = [
|
|
|
4487
4421
|
},
|
|
4488
4422
|
{
|
|
4489
4423
|
"scope": "user",
|
|
4490
|
-
"module": "
|
|
4424
|
+
"module": "rows",
|
|
4491
4425
|
"functionName": "queryEntitySelection",
|
|
4492
4426
|
"commandPath": [
|
|
4493
|
-
"
|
|
4427
|
+
"rows",
|
|
4494
4428
|
"query-entity-selection"
|
|
4495
4429
|
],
|
|
4496
4430
|
"method": "POST",
|
|
@@ -4507,29 +4441,10 @@ var userCommands = [
|
|
|
4507
4441
|
},
|
|
4508
4442
|
{
|
|
4509
4443
|
"scope": "user",
|
|
4510
|
-
"module": "
|
|
4511
|
-
"functionName": "resolveEntityWorkflow",
|
|
4512
|
-
"commandPath": [
|
|
4513
|
-
"workflow",
|
|
4514
|
-
"resolve-entity-workflow"
|
|
4515
|
-
],
|
|
4516
|
-
"method": "POST",
|
|
4517
|
-
"endpoint": "/entity/:app_id/:entity_id/resolve-workflow",
|
|
4518
|
-
"endpointParams": [
|
|
4519
|
-
"app_id",
|
|
4520
|
-
"entity_id"
|
|
4521
|
-
],
|
|
4522
|
-
"controller": "UserAction.EntityResolveWorkflow",
|
|
4523
|
-
"requestType": "EntityResolveWorkflowReqVO",
|
|
4524
|
-
"scalarParams": [],
|
|
4525
|
-
"responseType": "EntityResolveWorkflowRespVO"
|
|
4526
|
-
},
|
|
4527
|
-
{
|
|
4528
|
-
"scope": "user",
|
|
4529
|
-
"module": "workflow",
|
|
4444
|
+
"module": "rows",
|
|
4530
4445
|
"functionName": "getEntityRow",
|
|
4531
4446
|
"commandPath": [
|
|
4532
|
-
"
|
|
4447
|
+
"rows",
|
|
4533
4448
|
"get-entity-row"
|
|
4534
4449
|
],
|
|
4535
4450
|
"method": "GET",
|
|
@@ -4552,10 +4467,10 @@ var userCommands = [
|
|
|
4552
4467
|
},
|
|
4553
4468
|
{
|
|
4554
4469
|
"scope": "user",
|
|
4555
|
-
"module": "
|
|
4470
|
+
"module": "rows",
|
|
4556
4471
|
"functionName": "deleteEntityRow",
|
|
4557
4472
|
"commandPath": [
|
|
4558
|
-
"
|
|
4473
|
+
"rows",
|
|
4559
4474
|
"delete-entity-row"
|
|
4560
4475
|
],
|
|
4561
4476
|
"method": "POST",
|
|
@@ -4571,10 +4486,10 @@ var userCommands = [
|
|
|
4571
4486
|
},
|
|
4572
4487
|
{
|
|
4573
4488
|
"scope": "user",
|
|
4574
|
-
"module": "
|
|
4489
|
+
"module": "rows",
|
|
4575
4490
|
"functionName": "restoreEntityRow",
|
|
4576
4491
|
"commandPath": [
|
|
4577
|
-
"
|
|
4492
|
+
"rows",
|
|
4578
4493
|
"restore-entity-row"
|
|
4579
4494
|
],
|
|
4580
4495
|
"method": "POST",
|
|
@@ -4590,10 +4505,10 @@ var userCommands = [
|
|
|
4590
4505
|
},
|
|
4591
4506
|
{
|
|
4592
4507
|
"scope": "user",
|
|
4593
|
-
"module": "
|
|
4508
|
+
"module": "rows",
|
|
4594
4509
|
"functionName": "updateEntityRow",
|
|
4595
4510
|
"commandPath": [
|
|
4596
|
-
"
|
|
4511
|
+
"rows",
|
|
4597
4512
|
"update-entity-row"
|
|
4598
4513
|
],
|
|
4599
4514
|
"method": "PUT",
|
|
@@ -4610,10 +4525,10 @@ var userCommands = [
|
|
|
4610
4525
|
},
|
|
4611
4526
|
{
|
|
4612
4527
|
"scope": "user",
|
|
4613
|
-
"module": "
|
|
4528
|
+
"module": "rows",
|
|
4614
4529
|
"functionName": "validateEntityUniq",
|
|
4615
4530
|
"commandPath": [
|
|
4616
|
-
"
|
|
4531
|
+
"rows",
|
|
4617
4532
|
"validate-entity-uniq"
|
|
4618
4533
|
],
|
|
4619
4534
|
"method": "POST",
|
|
@@ -4629,10 +4544,10 @@ var userCommands = [
|
|
|
4629
4544
|
},
|
|
4630
4545
|
{
|
|
4631
4546
|
"scope": "user",
|
|
4632
|
-
"module": "
|
|
4547
|
+
"module": "rows",
|
|
4633
4548
|
"functionName": "insertEntity",
|
|
4634
4549
|
"commandPath": [
|
|
4635
|
-
"
|
|
4550
|
+
"rows",
|
|
4636
4551
|
"insert-entity"
|
|
4637
4552
|
],
|
|
4638
4553
|
"method": "POST",
|
|
@@ -4648,10 +4563,10 @@ var userCommands = [
|
|
|
4648
4563
|
},
|
|
4649
4564
|
{
|
|
4650
4565
|
"scope": "user",
|
|
4651
|
-
"module": "
|
|
4566
|
+
"module": "rows",
|
|
4652
4567
|
"functionName": "prepareEntityInsert",
|
|
4653
4568
|
"commandPath": [
|
|
4654
|
-
"
|
|
4569
|
+
"rows",
|
|
4655
4570
|
"prepare-entity-insert"
|
|
4656
4571
|
],
|
|
4657
4572
|
"method": "POST",
|
|
@@ -4667,48 +4582,10 @@ var userCommands = [
|
|
|
4667
4582
|
},
|
|
4668
4583
|
{
|
|
4669
4584
|
"scope": "user",
|
|
4670
|
-
"module": "
|
|
4671
|
-
"functionName": "queryEntityWorkflowApproveUsers",
|
|
4672
|
-
"commandPath": [
|
|
4673
|
-
"workflow",
|
|
4674
|
-
"query-entity-workflow-approve-users"
|
|
4675
|
-
],
|
|
4676
|
-
"method": "POST",
|
|
4677
|
-
"endpoint": "/entity/:app_id/:entity_id/query-approve-users",
|
|
4678
|
-
"endpointParams": [
|
|
4679
|
-
"app_id",
|
|
4680
|
-
"entity_id"
|
|
4681
|
-
],
|
|
4682
|
-
"controller": "UserAction.EntityWorkflowApproveUsers",
|
|
4683
|
-
"requestType": null,
|
|
4684
|
-
"scalarParams": [],
|
|
4685
|
-
"responseType": "EntityWorkflowApproveUsersRespVO"
|
|
4686
|
-
},
|
|
4687
|
-
{
|
|
4688
|
-
"scope": "user",
|
|
4689
|
-
"module": "workflow",
|
|
4690
|
-
"functionName": "queryEntityWorkflowNodes",
|
|
4691
|
-
"commandPath": [
|
|
4692
|
-
"workflow",
|
|
4693
|
-
"query-entity-workflow-nodes"
|
|
4694
|
-
],
|
|
4695
|
-
"method": "POST",
|
|
4696
|
-
"endpoint": "/entity/:app_id/:entity_id/query-workflow-nodes",
|
|
4697
|
-
"endpointParams": [
|
|
4698
|
-
"app_id",
|
|
4699
|
-
"entity_id"
|
|
4700
|
-
],
|
|
4701
|
-
"controller": "UserAction.EntityWorkflowNodes",
|
|
4702
|
-
"requestType": null,
|
|
4703
|
-
"scalarParams": [],
|
|
4704
|
-
"responseType": "EntityWorkflowNodesRespVO"
|
|
4705
|
-
},
|
|
4706
|
-
{
|
|
4707
|
-
"scope": "user",
|
|
4708
|
-
"module": "workflow",
|
|
4585
|
+
"module": "rows",
|
|
4709
4586
|
"functionName": "getEntitySubformItems",
|
|
4710
4587
|
"commandPath": [
|
|
4711
|
-
"
|
|
4588
|
+
"rows",
|
|
4712
4589
|
"get-entity-subform-items"
|
|
4713
4590
|
],
|
|
4714
4591
|
"method": "POST",
|
|
@@ -4726,8 +4603,24 @@ var userCommands = [
|
|
|
4726
4603
|
];
|
|
4727
4604
|
|
|
4728
4605
|
// src/runtime/command_registry.ts
|
|
4606
|
+
var customAdminCommands = [
|
|
4607
|
+
{
|
|
4608
|
+
scope: "admin",
|
|
4609
|
+
module: "app",
|
|
4610
|
+
functionName: "inventory",
|
|
4611
|
+
commandPath: ["app", "inventory"],
|
|
4612
|
+
method: "GET",
|
|
4613
|
+
endpoint: "/apps",
|
|
4614
|
+
endpointParams: [],
|
|
4615
|
+
controller: "Runtime.AppInventory",
|
|
4616
|
+
requestType: null,
|
|
4617
|
+
scalarParams: [],
|
|
4618
|
+
responseType: "AppInventoryRespVO"
|
|
4619
|
+
}
|
|
4620
|
+
];
|
|
4621
|
+
var customUserCommands = [];
|
|
4729
4622
|
function listCommands(scope) {
|
|
4730
|
-
return scope === "admin" ? adminCommands : userCommands;
|
|
4623
|
+
return scope === "admin" ? [...adminCommands, ...customAdminCommands] : [...userCommands, ...customUserCommands];
|
|
4731
4624
|
}
|
|
4732
4625
|
function findCommand(scope, moduleName, commandName) {
|
|
4733
4626
|
return listCommands(scope).find((item) => item.commandPath[0] === moduleName && item.commandPath[1] === commandName) ?? null;
|
|
@@ -5276,8 +5169,8 @@ function getErrorMap() {
|
|
|
5276
5169
|
|
|
5277
5170
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
5278
5171
|
var makeIssue = (params) => {
|
|
5279
|
-
const { data, path, errorMaps, issueData } = params;
|
|
5280
|
-
const fullPath = [...
|
|
5172
|
+
const { data, path: path2, errorMaps, issueData } = params;
|
|
5173
|
+
const fullPath = [...path2, ...issueData.path || []];
|
|
5281
5174
|
const fullIssue = {
|
|
5282
5175
|
...issueData,
|
|
5283
5176
|
path: fullPath
|
|
@@ -5393,11 +5286,11 @@ var errorUtil;
|
|
|
5393
5286
|
|
|
5394
5287
|
// node_modules/zod/v3/types.js
|
|
5395
5288
|
var ParseInputLazyPath = class {
|
|
5396
|
-
constructor(parent, value,
|
|
5289
|
+
constructor(parent, value, path2, key) {
|
|
5397
5290
|
this._cachedPath = [];
|
|
5398
5291
|
this.parent = parent;
|
|
5399
5292
|
this.data = value;
|
|
5400
|
-
this._path =
|
|
5293
|
+
this._path = path2;
|
|
5401
5294
|
this._key = key;
|
|
5402
5295
|
}
|
|
5403
5296
|
get path() {
|
|
@@ -8973,7 +8866,6 @@ var EntityQueryLinkToValuesReqVOSchema = external_exports.lazy(() => external_ex
|
|
|
8973
8866
|
var EntityQueryRelationReqVOSchema = external_exports.lazy(() => external_exports.object({ "addition": external_exports.boolean().optional(), "data": external_exports.record(external_exports.string(), external_exports.any()).optional(), "entity": external_exports.boolean().optional(), "field_id": external_exports.number().optional(), "input": external_exports.string().optional(), "limit": external_exports.number().optional(), "offset": external_exports.number().optional(), "policies": external_exports.boolean().optional(), "query": external_exports.string().optional(), "total": external_exports.boolean().optional() }).strict());
|
|
8974
8867
|
var EntityQueryOrderVOSchema = external_exports.lazy(() => external_exports.object({ "column": external_exports.string().optional(), "order": external_exports.string().optional() }).strict());
|
|
8975
8868
|
var EntityQueryReqVOSchema = external_exports.lazy(() => external_exports.object({ "limit": external_exports.number().optional(), "offset": external_exports.number().optional(), "policy_id": external_exports.string().optional(), "search": external_exports.record(external_exports.string(), external_exports.any()).optional(), "sorts": external_exports.array(EntityQueryOrderVOSchema).optional(), "view_mode": external_exports.string().optional(), "withSubForm": external_exports.boolean().optional() }).strict());
|
|
8976
|
-
var EntityResolveWorkflowReqVOSchema = external_exports.lazy(() => external_exports.object({ "approve_users": external_exports.array(external_exports.number()).optional(), "closeCurrentTasks": external_exports.boolean().optional(), "node_id": external_exports.number().optional(), "policy_id": external_exports.string().optional(), "record_id": external_exports.number().optional(), "version_id": external_exports.number().optional() }).strict());
|
|
8977
8869
|
var EntitySaveCustomKeysFieldVOSchema = external_exports.lazy(() => external_exports.object({ "id": external_exports.number().optional(), "key": external_exports.string().optional() }).strict());
|
|
8978
8870
|
var EntitySaveCustomKeysReqVOSchema = external_exports.lazy(() => external_exports.array(EntitySaveCustomKeysFieldVOSchema));
|
|
8979
8871
|
var EntitySaveNameReqVOSchema = external_exports.lazy(() => external_exports.object({ "name": external_exports.string().optional() }).strict());
|
|
@@ -8996,20 +8888,6 @@ var EntityUpdateReqVOSchema = external_exports.lazy(() => external_exports.objec
|
|
|
8996
8888
|
var EntityUpdateSuccessScreenReqVOSchema = external_exports.lazy(() => external_exports.object({ "EnableDraft": external_exports.boolean().optional(), "EnableOffline": external_exports.boolean().optional(), "EnableSuccessScreen": external_exports.boolean().optional(), "SuccessScreen": external_exports.string().optional() }).strict());
|
|
8997
8889
|
var EntityValidateUniqFieldVOSchema = external_exports.lazy(() => external_exports.object({ "field_id": external_exports.number().optional(), "value": external_exports.string().optional() }).strict());
|
|
8998
8890
|
var EntityValidateUniqReqVOSchema = external_exports.lazy(() => external_exports.object({ "fields": external_exports.array(EntityValidateUniqFieldVOSchema).optional(), "record_id": external_exports.number().optional() }).strict());
|
|
8999
|
-
var ActionBulkUpdateActionSchema = external_exports.lazy(() => external_exports.object({ "number_add": external_exports.number().optional(), "number_mul": external_exports.number().optional(), "number_sub": external_exports.number().optional(), "text_append": external_exports.string().optional(), "text_prepend": external_exports.string().optional(), "text_replace": external_exports.string().optional(), "text_search": external_exports.string().optional(), "type": external_exports.string().optional(), "value": external_exports.any().optional() }).strict());
|
|
9000
|
-
var ActionBulkUpdateSchema = external_exports.lazy(() => external_exports.object({ "action": ActionBulkUpdateActionSchema.optional(), "id": external_exports.number().optional() }).strict());
|
|
9001
|
-
var WorkflowActionConfigSchema = external_exports.lazy(() => external_exports.object({ "enabled": external_exports.boolean().optional(), "options": external_exports.object({ "comment_required": external_exports.boolean().optional(), "desc": external_exports.string().optional(), "modifiers": external_exports.array(ActionBulkUpdateSchema).optional() }).strict().optional() }).strict());
|
|
9002
|
-
var WorkflowVoteTypeSchema = external_exports.lazy(() => external_exports.union([external_exports.literal(0), external_exports.literal(1)]));
|
|
9003
|
-
var NotificationWebhookConfigSchema = external_exports.lazy(() => external_exports.object({ "mode": NotificationPayloadModeSchema.optional(), "template": external_exports.string().optional(), "url": external_exports.string().optional(), "version": external_exports.string().optional() }).strict());
|
|
9004
|
-
var WorkflowConfigNodeSchema = external_exports.lazy(() => external_exports.object({ "data": external_exports.object({ "actions": external_exports.record(external_exports.string(), WorkflowActionConfigSchema).optional(), "approver_actions": external_exports.array(external_exports.number()).optional(), "approvers": external_exports.array(PermitUserScopeSchema).optional(), "auto_forward": external_exports.boolean().optional(), "cc": external_exports.array(PermitUserScopeSchema).optional(), "fields": external_exports.array(external_exports.number()).optional(), "notify_email": external_exports.boolean().optional(), "notify_email_tmpl": external_exports.object({ "body": external_exports.string().optional(), "subject": external_exports.string().optional() }).strict().optional(), "submit_condition": external_exports.array(external_exports.number()).optional(), "use_cc": external_exports.boolean().optional(), "vote_type": WorkflowVoteTypeSchema.optional(), "webhooks": external_exports.array(NotificationWebhookConfigSchema).optional() }).strict().optional(), "events": external_exports.array(external_exports.number()).optional(), "id": external_exports.string().optional(), "label": external_exports.string().optional(), "mode": external_exports.string().optional(), "position": external_exports.array(external_exports.number()).optional(), "type": external_exports.string().optional() }).strict());
|
|
9005
|
-
var WorkflowConfigDiagramSchema = external_exports.lazy(() => external_exports.object({ "edges": external_exports.array(external_exports.number()).optional(), "id_seq": external_exports.number().optional(), "nodes": external_exports.array(WorkflowConfigNodeSchema).optional(), "viewport": external_exports.array(external_exports.number()).optional() }).strict());
|
|
9006
|
-
var WorkflowAutoApproveRuleSchema = external_exports.lazy(() => external_exports.union([external_exports.literal(1), external_exports.literal(2), external_exports.literal(3)]));
|
|
9007
|
-
var WorkflowRetractRuleSchema = external_exports.lazy(() => external_exports.union([external_exports.literal(1), external_exports.literal(2), external_exports.literal(3)]));
|
|
9008
|
-
var WorkflowSLATriggerSchema = external_exports.lazy(() => external_exports.object({ "hasUpdateField": external_exports.boolean().optional(), "hasWebhook": external_exports.boolean().optional(), "modifiers": external_exports.array(ActionBulkUpdateSchema).optional(), "time_point": external_exports.number().optional(), "webhook": NotificationWebhookConfigSchema.optional() }).strict());
|
|
9009
|
-
var WorkflowSLAConfigSchema = external_exports.lazy(() => external_exports.object({ "ddl": external_exports.number().optional(), "enabled": external_exports.boolean().optional(), "id": external_exports.string().optional(), "name": external_exports.string().optional(), "nodes": external_exports.array(external_exports.string()).optional(), "triggers": external_exports.array(WorkflowSLATriggerSchema).optional() }).strict());
|
|
9010
|
-
var WorkflowOptionsSchema = external_exports.lazy(() => external_exports.object({ "allow_urge": external_exports.boolean().optional(), "allow_view_diagram": external_exports.boolean().optional(), "auto_approve_rule": WorkflowAutoApproveRuleSchema.optional(), "retract_rule": WorkflowRetractRuleSchema.optional(), "sla": external_exports.array(WorkflowSLAConfigSchema).optional() }).strict());
|
|
9011
|
-
var EntityWorkflowDeployReqVOSchema = external_exports.lazy(() => external_exports.object({ "diagram": WorkflowConfigDiagramSchema.optional(), "id": external_exports.number().optional(), "options": WorkflowOptionsSchema.optional() }).strict());
|
|
9012
|
-
var EntityWorkflowUpdateReqVOSchema = external_exports.lazy(() => external_exports.object({ "diagram": WorkflowConfigDiagramSchema.optional(), "id": external_exports.number().optional(), "options": WorkflowOptionsSchema.optional() }).strict());
|
|
9013
8891
|
var EntityUtilsQueryOrderSchema = external_exports.lazy(() => external_exports.object({ "column": external_exports.string().optional(), "order": external_exports.string().optional() }).strict());
|
|
9014
8892
|
var FetchWidgetsDataReqVOSchema = external_exports.lazy(() => external_exports.object({ "dashboard_id": external_exports.number().optional(), "ingress_hash_id": external_exports.string().optional(), "ingress_id": external_exports.number().optional(), "querys": external_exports.object({ "search": external_exports.record(external_exports.string(), external_exports.any()).optional(), "sorts": external_exports.array(EntityUtilsQueryOrderSchema).optional() }).strict().optional(), "type": WidgetsTypeCodeSchema.optional() }).strict());
|
|
9015
8893
|
var GetOrganizationTreeReqVOSchema = external_exports.lazy(() => external_exports.object({ "parent_id": external_exports.number().optional() }).strict());
|
|
@@ -9134,7 +9012,6 @@ var bodySchemas = {
|
|
|
9134
9012
|
"EntityQueryLinkToValuesReqVO": EntityQueryLinkToValuesReqVOSchema,
|
|
9135
9013
|
"EntityQueryRelationReqVO": EntityQueryRelationReqVOSchema,
|
|
9136
9014
|
"EntityQueryReqVO": EntityQueryReqVOSchema,
|
|
9137
|
-
"EntityResolveWorkflowReqVO": EntityResolveWorkflowReqVOSchema,
|
|
9138
9015
|
"EntitySaveCustomKeysReqVO": EntitySaveCustomKeysReqVOSchema,
|
|
9139
9016
|
"EntitySaveNameReqVO": EntitySaveNameReqVOSchema,
|
|
9140
9017
|
"EntitySaveReqVO": EntitySaveReqVOSchema,
|
|
@@ -9147,8 +9024,6 @@ var bodySchemas = {
|
|
|
9147
9024
|
"EntityUpdateReqVO": EntityUpdateReqVOSchema,
|
|
9148
9025
|
"EntityUpdateSuccessScreenReqVO": EntityUpdateSuccessScreenReqVOSchema,
|
|
9149
9026
|
"EntityValidateUniqReqVO": EntityValidateUniqReqVOSchema,
|
|
9150
|
-
"EntityWorkflowDeployReqVO": EntityWorkflowDeployReqVOSchema,
|
|
9151
|
-
"EntityWorkflowUpdateReqVO": EntityWorkflowUpdateReqVOSchema,
|
|
9152
9027
|
"FetchWidgetsDataReqVO": FetchWidgetsDataReqVOSchema,
|
|
9153
9028
|
"GetOrganizationTreeReqVO": GetOrganizationTreeReqVOSchema,
|
|
9154
9029
|
"GetOrganizationUsersReqVO": GetOrganizationUsersReqVOSchema,
|
|
@@ -9476,10 +9351,6 @@ var typeIndex = {
|
|
|
9476
9351
|
"file": "/opt/arcubase-sdk/types/user-action.ts",
|
|
9477
9352
|
"dependencies": []
|
|
9478
9353
|
},
|
|
9479
|
-
"EntityResolveWorkflowReqVO": {
|
|
9480
|
-
"file": "/opt/arcubase-sdk/types/user-action.ts",
|
|
9481
|
-
"dependencies": []
|
|
9482
|
-
},
|
|
9483
9354
|
"EntitySaveCustomKeysReqVO": {
|
|
9484
9355
|
"file": "/opt/arcubase-sdk/types/entity.ts",
|
|
9485
9356
|
"dependencies": [
|
|
@@ -9538,14 +9409,6 @@ var typeIndex = {
|
|
|
9538
9409
|
"file": "/opt/arcubase-sdk/types/common.ts",
|
|
9539
9410
|
"dependencies": []
|
|
9540
9411
|
},
|
|
9541
|
-
"EntityWorkflowDeployReqVO": {
|
|
9542
|
-
"file": "/opt/arcubase-sdk/types/workflow.ts",
|
|
9543
|
-
"dependencies": []
|
|
9544
|
-
},
|
|
9545
|
-
"EntityWorkflowUpdateReqVO": {
|
|
9546
|
-
"file": "/opt/arcubase-sdk/types/workflow.ts",
|
|
9547
|
-
"dependencies": []
|
|
9548
|
-
},
|
|
9549
9412
|
"FetchWidgetsDataReqVO": {
|
|
9550
9413
|
"file": "/opt/arcubase-sdk/types/user-action.ts",
|
|
9551
9414
|
"dependencies": []
|
|
@@ -10372,54 +10235,59 @@ var examplesIndexDocHint = {
|
|
|
10372
10235
|
title: "Examples index",
|
|
10373
10236
|
file: "/opt/arcubase-sdk/docs/runtime-reference/examples/README.md"
|
|
10374
10237
|
};
|
|
10375
|
-
var
|
|
10376
|
-
title: "
|
|
10377
|
-
file: "/opt/arcubase-sdk/docs/runtime-reference/
|
|
10238
|
+
var appDiscoveryDocHint = {
|
|
10239
|
+
title: "App discovery",
|
|
10240
|
+
file: "/opt/arcubase-sdk/docs/runtime-reference/app-discovery.md"
|
|
10378
10241
|
};
|
|
10379
10242
|
var docHintIndex = {
|
|
10380
10243
|
AppCreateByTenantsReqVO: [
|
|
10244
|
+
appDiscoveryDocHint,
|
|
10381
10245
|
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10382
|
-
examplesIndexDocHint
|
|
10383
|
-
omsExampleDocHint
|
|
10246
|
+
examplesIndexDocHint
|
|
10384
10247
|
],
|
|
10385
10248
|
AppCreateEntityReqVO: [
|
|
10249
|
+
appDiscoveryDocHint,
|
|
10386
10250
|
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10387
|
-
examplesIndexDocHint
|
|
10388
|
-
omsExampleDocHint
|
|
10251
|
+
examplesIndexDocHint
|
|
10389
10252
|
],
|
|
10390
10253
|
EntitySaveReqVO: [
|
|
10391
10254
|
{ title: "Entity schema", file: "/opt/arcubase-sdk/docs/runtime-reference/entity-schema.md" },
|
|
10392
|
-
|
|
10255
|
+
examplesIndexDocHint
|
|
10393
10256
|
],
|
|
10394
10257
|
EntityQueryReqVO: [
|
|
10395
10258
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10396
10259
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10397
|
-
|
|
10260
|
+
examplesIndexDocHint
|
|
10398
10261
|
],
|
|
10399
10262
|
EntityUpdateReqVO: [
|
|
10400
10263
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10401
|
-
|
|
10264
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10265
|
+
examplesIndexDocHint
|
|
10402
10266
|
],
|
|
10403
10267
|
EntitySelectionActionReqVO: [
|
|
10404
10268
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10405
|
-
|
|
10269
|
+
examplesIndexDocHint
|
|
10406
10270
|
],
|
|
10407
10271
|
InsertReqVO: [
|
|
10408
10272
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10409
|
-
|
|
10273
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10274
|
+
examplesIndexDocHint
|
|
10410
10275
|
],
|
|
10411
10276
|
EntityBulkUpdateReqVO: [
|
|
10412
10277
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10413
|
-
|
|
10278
|
+
examplesIndexDocHint
|
|
10414
10279
|
],
|
|
10415
10280
|
"EntityInvokeBatchOperatorReqVO & InvokeRequestVO": [
|
|
10416
|
-
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" }
|
|
10281
|
+
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10282
|
+
examplesIndexDocHint
|
|
10417
10283
|
],
|
|
10418
10284
|
"{ policy_id: string selection: any }": [
|
|
10419
|
-
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" }
|
|
10285
|
+
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10286
|
+
examplesIndexDocHint
|
|
10420
10287
|
],
|
|
10421
10288
|
"{ policy_id: string selection: any tag_names: string[] }": [
|
|
10422
|
-
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" }
|
|
10289
|
+
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10290
|
+
examplesIndexDocHint
|
|
10423
10291
|
]
|
|
10424
10292
|
};
|
|
10425
10293
|
function getTypeHints(typeName) {
|
|
@@ -10451,53 +10319,68 @@ function getDocHints(typeName) {
|
|
|
10451
10319
|
}
|
|
10452
10320
|
var commandDocHintIndex = {
|
|
10453
10321
|
"admin.app.createAppByTenants": [
|
|
10322
|
+
appDiscoveryDocHint,
|
|
10454
10323
|
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10455
|
-
examplesIndexDocHint
|
|
10456
|
-
|
|
10324
|
+
examplesIndexDocHint
|
|
10325
|
+
],
|
|
10326
|
+
"admin.app.listApps": [
|
|
10327
|
+
appDiscoveryDocHint,
|
|
10328
|
+
examplesIndexDocHint
|
|
10329
|
+
],
|
|
10330
|
+
"admin.app.inventory": [
|
|
10331
|
+
appDiscoveryDocHint,
|
|
10332
|
+
examplesIndexDocHint
|
|
10457
10333
|
],
|
|
10458
10334
|
"admin.app.createEntity": [
|
|
10335
|
+
appDiscoveryDocHint,
|
|
10459
10336
|
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10460
|
-
|
|
10337
|
+
examplesIndexDocHint
|
|
10461
10338
|
],
|
|
10462
10339
|
"admin.entity.adminGetEntityInfo": [
|
|
10340
|
+
appDiscoveryDocHint,
|
|
10463
10341
|
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10464
|
-
|
|
10342
|
+
examplesIndexDocHint
|
|
10465
10343
|
],
|
|
10466
10344
|
"admin.entity.adminSaveEntity": [
|
|
10467
10345
|
{ title: "Entity schema", file: "/opt/arcubase-sdk/docs/runtime-reference/entity-schema.md" },
|
|
10468
|
-
|
|
10346
|
+
{ title: "Table lifecycle", file: "/opt/arcubase-sdk/docs/runtime-reference/table-lifecycle.md" },
|
|
10347
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10348
|
+
examplesIndexDocHint
|
|
10469
10349
|
],
|
|
10470
|
-
"user.
|
|
10350
|
+
"user.rows.insertEntity": [
|
|
10471
10351
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10472
|
-
|
|
10352
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10353
|
+
examplesIndexDocHint
|
|
10473
10354
|
],
|
|
10474
|
-
"user.
|
|
10355
|
+
"user.rows.queryEntity": [
|
|
10475
10356
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10476
|
-
|
|
10357
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10358
|
+
examplesIndexDocHint
|
|
10477
10359
|
],
|
|
10478
|
-
"user.
|
|
10360
|
+
"user.rows.getEntityRow": [
|
|
10479
10361
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10480
|
-
|
|
10362
|
+
examplesIndexDocHint
|
|
10481
10363
|
],
|
|
10482
|
-
"user.
|
|
10364
|
+
"user.rows.updateEntityRow": [
|
|
10483
10365
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10484
|
-
|
|
10366
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10367
|
+
examplesIndexDocHint
|
|
10485
10368
|
],
|
|
10486
|
-
"user.
|
|
10369
|
+
"user.rows.queryEntitySelection": [
|
|
10487
10370
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10488
|
-
|
|
10371
|
+
examplesIndexDocHint
|
|
10489
10372
|
],
|
|
10490
|
-
"user.
|
|
10373
|
+
"user.rows.deleteEntityRow": [
|
|
10491
10374
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10492
|
-
|
|
10375
|
+
examplesIndexDocHint
|
|
10493
10376
|
],
|
|
10494
|
-
"user.
|
|
10377
|
+
"user.rows.restoreEntityRow": [
|
|
10495
10378
|
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" },
|
|
10496
|
-
|
|
10379
|
+
examplesIndexDocHint
|
|
10497
10380
|
],
|
|
10498
10381
|
"user.entity.updateEntityBulk": [
|
|
10499
10382
|
{ title: "Search and bulk actions", file: "/opt/arcubase-sdk/docs/runtime-reference/search-and-bulk-actions.md" },
|
|
10500
|
-
|
|
10383
|
+
examplesIndexDocHint
|
|
10501
10384
|
]
|
|
10502
10385
|
};
|
|
10503
10386
|
function getCommandDocHints(operation) {
|
|
@@ -10506,14 +10389,246 @@ function getCommandDocHints(operation) {
|
|
|
10506
10389
|
return commandDocHintIndex[key] ?? [];
|
|
10507
10390
|
}
|
|
10508
10391
|
|
|
10392
|
+
// src/runtime/upload.ts
|
|
10393
|
+
import fs2 from "fs";
|
|
10394
|
+
import path from "path";
|
|
10395
|
+
function readUploadSource(sourcePath) {
|
|
10396
|
+
const absolutePath = path.resolve(sourcePath);
|
|
10397
|
+
if (!fs2.existsSync(absolutePath)) {
|
|
10398
|
+
throw new CLIError("UPLOAD_SOURCE_NOT_FOUND", `upload source file does not exist: ${sourcePath}`, 2);
|
|
10399
|
+
}
|
|
10400
|
+
const stat = fs2.statSync(absolutePath);
|
|
10401
|
+
if (!stat.isFile()) {
|
|
10402
|
+
throw new CLIError("UPLOAD_SOURCE_INVALID", `upload source path must be a file: ${sourcePath}`, 2);
|
|
10403
|
+
}
|
|
10404
|
+
return {
|
|
10405
|
+
absolutePath,
|
|
10406
|
+
bytes: fs2.readFileSync(absolutePath)
|
|
10407
|
+
};
|
|
10408
|
+
}
|
|
10409
|
+
function parseJSONResponse(raw) {
|
|
10410
|
+
try {
|
|
10411
|
+
return raw ? JSON.parse(raw) : null;
|
|
10412
|
+
} catch {
|
|
10413
|
+
return raw;
|
|
10414
|
+
}
|
|
10415
|
+
}
|
|
10416
|
+
function requireTokenPayload(payload) {
|
|
10417
|
+
if (payload && typeof payload === "object" && payload.error) {
|
|
10418
|
+
const upstreamError = payload.error;
|
|
10419
|
+
const message = typeof upstreamError === "object" && upstreamError && "message" in upstreamError && typeof upstreamError.message === "string" ? upstreamError.message : typeof upstreamError === "string" ? upstreamError : JSON.stringify(upstreamError);
|
|
10420
|
+
throw new CLIError("UPSTREAM_BODY_ERROR", message, 1, {
|
|
10421
|
+
endpoint: "/upload/token",
|
|
10422
|
+
method: "POST",
|
|
10423
|
+
traceId: typeof payload.trace_id === "string" ? payload.trace_id : void 0,
|
|
10424
|
+
upstreamError
|
|
10425
|
+
});
|
|
10426
|
+
}
|
|
10427
|
+
if (!payload?.data || typeof payload.data !== "object") {
|
|
10428
|
+
throw new CLIError("UPLOAD_TOKEN_INVALID", "upload token response did not include data", 1);
|
|
10429
|
+
}
|
|
10430
|
+
return payload.data;
|
|
10431
|
+
}
|
|
10432
|
+
function renderUploadHelp() {
|
|
10433
|
+
return [
|
|
10434
|
+
"arcubase upload <local-file> [flags]",
|
|
10435
|
+
"",
|
|
10436
|
+
"purpose:",
|
|
10437
|
+
" - upload one local file through Arcubase",
|
|
10438
|
+
" - return a field value that can be used directly in file or image row payloads",
|
|
10439
|
+
"",
|
|
10440
|
+
"flags:",
|
|
10441
|
+
" --filename <name> override the uploaded filename stored in Arcubase",
|
|
10442
|
+
" --global request a global upload token instead of a tenant-scoped token",
|
|
10443
|
+
"",
|
|
10444
|
+
"result shape:",
|
|
10445
|
+
" - data is a JSON array",
|
|
10446
|
+
" - use that array directly as the value of a file or image field in insert/update payloads",
|
|
10447
|
+
"",
|
|
10448
|
+
"example:",
|
|
10449
|
+
" arcubase upload ./contract.pdf",
|
|
10450
|
+
" arcubase upload ./photo.jpg --filename lead-photo.jpg",
|
|
10451
|
+
"",
|
|
10452
|
+
"docs:",
|
|
10453
|
+
" - Uploads: /opt/arcubase-sdk/docs/runtime-reference/uploads.md",
|
|
10454
|
+
" - Row CRUD: /opt/arcubase-sdk/docs/runtime-reference/row-crud.md",
|
|
10455
|
+
" - File field: /opt/arcubase-sdk/docs/runtime-reference/entity-schema/file.md",
|
|
10456
|
+
" - Image field: /opt/arcubase-sdk/docs/runtime-reference/entity-schema/image.md"
|
|
10457
|
+
].join("\n");
|
|
10458
|
+
}
|
|
10459
|
+
async function uploadLocalFile(env, sourcePath, options, fetchImpl = fetch) {
|
|
10460
|
+
const { absolutePath, bytes } = readUploadSource(sourcePath);
|
|
10461
|
+
const filename = options.filename && options.filename.trim() || path.basename(absolutePath);
|
|
10462
|
+
const tokenResponse = await fetchImpl(buildURL(env.ARCUBASE_BASE_URL, "/upload/token"), {
|
|
10463
|
+
method: "POST",
|
|
10464
|
+
headers: {
|
|
10465
|
+
...buildRequestHeaders(env),
|
|
10466
|
+
"Content-Type": "application/json"
|
|
10467
|
+
},
|
|
10468
|
+
body: JSON.stringify({
|
|
10469
|
+
global: Boolean(options.global)
|
|
10470
|
+
})
|
|
10471
|
+
});
|
|
10472
|
+
const tokenRaw = await tokenResponse.text();
|
|
10473
|
+
const tokenParsed = parseJSONResponse(tokenRaw);
|
|
10474
|
+
if (!tokenResponse.ok) {
|
|
10475
|
+
throw new CLIError("UPLOAD_TOKEN_REQUEST_FAILED", typeof tokenParsed === "string" ? tokenParsed : JSON.stringify(tokenParsed), 1, {
|
|
10476
|
+
endpoint: "/upload/token",
|
|
10477
|
+
method: "POST"
|
|
10478
|
+
});
|
|
10479
|
+
}
|
|
10480
|
+
const tokenData = requireTokenPayload(tokenParsed);
|
|
10481
|
+
if (tokenData.mode !== "aliyun-oss" && tokenData.mode !== "s3-post-policy") {
|
|
10482
|
+
throw new CLIError("UPLOAD_MODE_UNSUPPORTED", `unsupported upload mode: ${String(tokenData.mode || "")}`, 1);
|
|
10483
|
+
}
|
|
10484
|
+
if (!tokenData.token_data?.dir || !tokenData.token_data.policy || !tokenData.token_data.host) {
|
|
10485
|
+
throw new CLIError("UPLOAD_TOKEN_INVALID", "upload token response is missing required token_data fields", 1);
|
|
10486
|
+
}
|
|
10487
|
+
if (tokenData.id === void 0 || tokenData.id === null || tokenData.id === "") {
|
|
10488
|
+
throw new CLIError("UPLOAD_TOKEN_INVALID", "upload token response is missing id", 1);
|
|
10489
|
+
}
|
|
10490
|
+
const form = new FormData();
|
|
10491
|
+
form.append("key", `${tokenData.token_data.dir}${filename}`);
|
|
10492
|
+
form.append("policy", tokenData.token_data.policy);
|
|
10493
|
+
if (tokenData.mode === "aliyun-oss") {
|
|
10494
|
+
if (!tokenData.token_data.accessid || !tokenData.token_data.signature) {
|
|
10495
|
+
throw new CLIError("UPLOAD_TOKEN_INVALID", "upload token response is missing required token_data fields", 1);
|
|
10496
|
+
}
|
|
10497
|
+
form.append("OSSAccessKeyId", tokenData.token_data.accessid);
|
|
10498
|
+
form.append("success_action_status", "200");
|
|
10499
|
+
form.append("signature", tokenData.token_data.signature);
|
|
10500
|
+
} else {
|
|
10501
|
+
if (!tokenData.token_data.x_amz_algorithm || !tokenData.token_data.x_amz_credential || !tokenData.token_data.x_amz_date || !tokenData.token_data.x_amz_signature) {
|
|
10502
|
+
throw new CLIError("UPLOAD_TOKEN_INVALID", "upload token response is missing required s3 token_data fields", 1);
|
|
10503
|
+
}
|
|
10504
|
+
form.append("x-amz-algorithm", tokenData.token_data.x_amz_algorithm);
|
|
10505
|
+
form.append("x-amz-credential", tokenData.token_data.x_amz_credential);
|
|
10506
|
+
form.append("x-amz-date", tokenData.token_data.x_amz_date);
|
|
10507
|
+
form.append("x-amz-signature", tokenData.token_data.x_amz_signature);
|
|
10508
|
+
}
|
|
10509
|
+
form.append("file", new Blob([new Uint8Array(bytes)]), filename);
|
|
10510
|
+
const uploadResponse = await fetchImpl(tokenData.token_data.host, {
|
|
10511
|
+
method: "POST",
|
|
10512
|
+
body: form
|
|
10513
|
+
});
|
|
10514
|
+
const uploadRaw = await uploadResponse.text();
|
|
10515
|
+
if (!uploadResponse.ok) {
|
|
10516
|
+
throw new CLIError("UPLOAD_TRANSFER_FAILED", uploadRaw || `upload failed with status ${uploadResponse.status}`, 1, {
|
|
10517
|
+
endpoint: tokenData.token_data.host,
|
|
10518
|
+
method: "POST"
|
|
10519
|
+
});
|
|
10520
|
+
}
|
|
10521
|
+
return [
|
|
10522
|
+
{
|
|
10523
|
+
upload_id: tokenData.id,
|
|
10524
|
+
file: filename,
|
|
10525
|
+
file_name: filename,
|
|
10526
|
+
meta: {}
|
|
10527
|
+
}
|
|
10528
|
+
];
|
|
10529
|
+
}
|
|
10530
|
+
|
|
10509
10531
|
// src/runtime/execute.ts
|
|
10532
|
+
function parseJSONResponse2(raw) {
|
|
10533
|
+
if (!raw) return null;
|
|
10534
|
+
try {
|
|
10535
|
+
return JSON.parse(raw);
|
|
10536
|
+
} catch {
|
|
10537
|
+
return raw;
|
|
10538
|
+
}
|
|
10539
|
+
}
|
|
10540
|
+
function unwrapResponseData(payload) {
|
|
10541
|
+
return isRecord2(payload) && "data" in payload ? payload.data : payload;
|
|
10542
|
+
}
|
|
10543
|
+
function formatUpstreamError(payload) {
|
|
10544
|
+
if (typeof payload === "string") {
|
|
10545
|
+
return payload;
|
|
10546
|
+
}
|
|
10547
|
+
if (isRecord2(payload) && isRecord2(payload.error) && typeof payload.error.message === "string") {
|
|
10548
|
+
return payload.error.message;
|
|
10549
|
+
}
|
|
10550
|
+
return JSON.stringify(payload);
|
|
10551
|
+
}
|
|
10552
|
+
function extractApps(payload) {
|
|
10553
|
+
const data = unwrapResponseData(payload);
|
|
10554
|
+
if (!Array.isArray(data)) return [];
|
|
10555
|
+
return data.filter((item) => isRecord2(item)).filter((item) => item.id !== void 0 && typeof item.name === "string").map((item) => ({
|
|
10556
|
+
id: String(item.id),
|
|
10557
|
+
name: item.name
|
|
10558
|
+
}));
|
|
10559
|
+
}
|
|
10560
|
+
function extractEntities(payload) {
|
|
10561
|
+
const data = unwrapResponseData(payload);
|
|
10562
|
+
if (!Array.isArray(data)) return [];
|
|
10563
|
+
return data.filter((item) => isRecord2(item)).filter((item) => item.id !== void 0 && typeof item.name === "string").map((item) => ({
|
|
10564
|
+
id: String(item.id),
|
|
10565
|
+
name: item.name
|
|
10566
|
+
}));
|
|
10567
|
+
}
|
|
10568
|
+
async function executeAppInventory(runtimeEnv, fetchImpl) {
|
|
10569
|
+
const appsResponse = await fetchImpl(buildURL(runtimeEnv.ARCUBASE_BASE_URL, "/apps"), {
|
|
10570
|
+
method: "GET",
|
|
10571
|
+
headers: buildRequestHeaders(runtimeEnv)
|
|
10572
|
+
});
|
|
10573
|
+
const appsRaw = await appsResponse.text();
|
|
10574
|
+
const appsPayload = parseJSONResponse2(appsRaw);
|
|
10575
|
+
if (!appsResponse.ok) {
|
|
10576
|
+
throw new CLIError("UPSTREAM_REQUEST_FAILED", formatUpstreamError(appsPayload), 1);
|
|
10577
|
+
}
|
|
10578
|
+
if (isRecord2(appsPayload) && appsPayload.error) {
|
|
10579
|
+
throw new CLIError("UPSTREAM_BODY_ERROR", formatUpstreamError(appsPayload), 1, {
|
|
10580
|
+
endpoint: "/apps",
|
|
10581
|
+
method: "GET",
|
|
10582
|
+
upstreamError: appsPayload.error
|
|
10583
|
+
});
|
|
10584
|
+
}
|
|
10585
|
+
const apps = extractApps(appsPayload);
|
|
10586
|
+
const items = [];
|
|
10587
|
+
for (const app of apps) {
|
|
10588
|
+
const entitiesResponse = await fetchImpl(buildURL(runtimeEnv.ARCUBASE_BASE_URL, `/apps/${encodeURIComponent(app.id)}/entities`), {
|
|
10589
|
+
method: "POST",
|
|
10590
|
+
headers: {
|
|
10591
|
+
...buildRequestHeaders(runtimeEnv),
|
|
10592
|
+
"Content-Type": "application/json"
|
|
10593
|
+
},
|
|
10594
|
+
body: JSON.stringify({})
|
|
10595
|
+
});
|
|
10596
|
+
const entitiesRaw = await entitiesResponse.text();
|
|
10597
|
+
const entitiesPayload = parseJSONResponse2(entitiesRaw);
|
|
10598
|
+
if (!entitiesResponse.ok) {
|
|
10599
|
+
throw new CLIError("UPSTREAM_REQUEST_FAILED", formatUpstreamError(entitiesPayload), 1);
|
|
10600
|
+
}
|
|
10601
|
+
if (isRecord2(entitiesPayload) && entitiesPayload.error) {
|
|
10602
|
+
throw new CLIError("UPSTREAM_BODY_ERROR", formatUpstreamError(entitiesPayload), 1, {
|
|
10603
|
+
endpoint: `/apps/${app.id}/entities`,
|
|
10604
|
+
method: "POST",
|
|
10605
|
+
upstreamError: entitiesPayload.error
|
|
10606
|
+
});
|
|
10607
|
+
}
|
|
10608
|
+
items.push({
|
|
10609
|
+
...app,
|
|
10610
|
+
entities: extractEntities(entitiesPayload)
|
|
10611
|
+
});
|
|
10612
|
+
}
|
|
10613
|
+
return {
|
|
10614
|
+
kind: "result",
|
|
10615
|
+
commandPath: ["app", "inventory"],
|
|
10616
|
+
status: 200,
|
|
10617
|
+
data: {
|
|
10618
|
+
apps: items
|
|
10619
|
+
}
|
|
10620
|
+
};
|
|
10621
|
+
}
|
|
10510
10622
|
function renderRootHelp(scope) {
|
|
10511
10623
|
const binary = scope === "admin" ? "arcubase-admin" : "arcubase";
|
|
10624
|
+
const items = listModules(scope).map((item) => ` - ${item}`);
|
|
10512
10625
|
return [
|
|
10513
10626
|
`${binary} <module> <command> [flags]`,
|
|
10514
10627
|
"",
|
|
10628
|
+
...scope === "admin" ? ["use arcubase-admin for app, entity shell, and schema management", ""] : ["use arcubase for rows, search, selection actions, and bulk actions", ""],
|
|
10515
10629
|
"modules:",
|
|
10516
|
-
...
|
|
10630
|
+
...items,
|
|
10631
|
+
...scope === "user" ? ["", "special commands:", " - upload <local-file>"] : []
|
|
10517
10632
|
].join("\n");
|
|
10518
10633
|
}
|
|
10519
10634
|
function renderModuleHelp(scope, moduleName) {
|
|
@@ -10525,15 +10640,26 @@ function renderModuleHelp(scope, moduleName) {
|
|
|
10525
10640
|
return [
|
|
10526
10641
|
`${scope === "admin" ? "arcubase-admin" : "arcubase"} ${moduleName} <command> [flags]`,
|
|
10527
10642
|
"",
|
|
10643
|
+
...scope === "admin" ? ["use arcubase-admin for app, entity shell, and schema management", ""] : ["use arcubase for rows, search, selection actions, and bulk actions", ""],
|
|
10528
10644
|
"commands:",
|
|
10529
10645
|
...items.map((item) => ` - ${item.commandPath[1]}`)
|
|
10530
10646
|
].join("\n");
|
|
10531
10647
|
}
|
|
10648
|
+
function buildUnknownCommandDetails(scope, moduleName, commandName) {
|
|
10649
|
+
const suggestions = findCommandSuggestions(moduleName, commandName).map((item) => `${item.binary} ${item.moduleName} ${item.commandName}`);
|
|
10650
|
+
if (scope === "admin" && moduleName === "workflow" && suggestions.some((item) => item.startsWith("arcubase rows "))) {
|
|
10651
|
+
return {
|
|
10652
|
+
suggestions,
|
|
10653
|
+
reason: `${moduleName} ${commandName} is not a valid command group; use arcubase rows for row operations`,
|
|
10654
|
+
hint: `use: arcubase rows ${commandName}`
|
|
10655
|
+
};
|
|
10656
|
+
}
|
|
10657
|
+
return suggestions.length > 0 ? { suggestions } : void 0;
|
|
10658
|
+
}
|
|
10532
10659
|
function renderCommandHelp(scope, moduleName, commandName) {
|
|
10533
10660
|
const command = findCommand(scope, moduleName, commandName);
|
|
10534
10661
|
if (!command) {
|
|
10535
|
-
|
|
10536
|
-
throw new CLIError("UNKNOWN_COMMAND", `unknown command: ${moduleName} ${commandName}`, 2, suggestions.length > 0 ? { suggestions } : void 0);
|
|
10662
|
+
throw new CLIError("UNKNOWN_COMMAND", `unknown command: ${moduleName} ${commandName}`, 2, buildUnknownCommandDetails(scope, moduleName, commandName));
|
|
10537
10663
|
}
|
|
10538
10664
|
const docHints = [
|
|
10539
10665
|
...getCommandDocHints(`${scope}.${command.module}.${command.functionName}`),
|
|
@@ -10547,6 +10673,17 @@ function renderCommandHelp(scope, moduleName, commandName) {
|
|
|
10547
10673
|
"query flags: --query-file",
|
|
10548
10674
|
command.endpointParams.length ? `path flags: ${command.endpointParams.map((item) => `--${item.replace(/_/g, "-")}`).join(", ")}` : "path flags: none",
|
|
10549
10675
|
command.scalarParams.length ? `scalar flags: ${command.scalarParams.map((item) => `--${item.name.replace(/([A-Z])/g, "-$1").toLowerCase()}`).join(", ")}` : "scalar flags: none",
|
|
10676
|
+
...scope === "admin" && moduleName === "entity" && commandName === "admin-save-entity" ? [
|
|
10677
|
+
"next step:",
|
|
10678
|
+
" - switch to arcubase for row operations",
|
|
10679
|
+
" - row insert: arcubase rows insert-entity --app-id <app_id> --entity-id <entity_id> --body-file insert.json",
|
|
10680
|
+
" - row query: arcubase rows query-entity --app-id <app_id> --entity-id <entity_id> --body-file query.json"
|
|
10681
|
+
] : [],
|
|
10682
|
+
...scope === "admin" && moduleName === "app" && commandName === "inventory" ? [
|
|
10683
|
+
"purpose:",
|
|
10684
|
+
" - list all accessible apps and each app entity list in one call sequence",
|
|
10685
|
+
" - use this before asking the user for app_id"
|
|
10686
|
+
] : [],
|
|
10550
10687
|
...docHints.length > 0 ? ["docs:", ...docHints.map((item) => ` - ${item.title}: ${item.file}`)] : []
|
|
10551
10688
|
].join("\n");
|
|
10552
10689
|
}
|
|
@@ -10594,13 +10731,139 @@ function buildScalarQuery(command, flags) {
|
|
|
10594
10731
|
function isRecord2(value) {
|
|
10595
10732
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10596
10733
|
}
|
|
10597
|
-
function
|
|
10734
|
+
function extractEntityFields(payload) {
|
|
10735
|
+
const candidate = isRecord2(payload) && isRecord2(payload.data) ? payload.data : payload;
|
|
10736
|
+
if (!isRecord2(candidate) || !Array.isArray(candidate.fields)) {
|
|
10737
|
+
return [];
|
|
10738
|
+
}
|
|
10739
|
+
return candidate.fields.filter((item) => isRecord2(item)).filter((item) => typeof item.id === "number" && typeof item.type === "string").map((item) => ({
|
|
10740
|
+
id: item.id,
|
|
10741
|
+
type: item.type,
|
|
10742
|
+
label: typeof item.label === "string" ? item.label : void 0
|
|
10743
|
+
}));
|
|
10744
|
+
}
|
|
10745
|
+
async function fetchEntityFields(runtimeEnv, appId, entityId, fetchImpl) {
|
|
10746
|
+
const response = await fetchImpl(buildURL(runtimeEnv.ARCUBASE_BASE_URL, `/entity/${encodeURIComponent(appId)}/${encodeURIComponent(entityId)}`), {
|
|
10747
|
+
method: "GET",
|
|
10748
|
+
headers: buildRequestHeaders(runtimeEnv)
|
|
10749
|
+
});
|
|
10750
|
+
const raw = await response.text();
|
|
10751
|
+
let parsedResponse = raw;
|
|
10752
|
+
try {
|
|
10753
|
+
parsedResponse = raw ? JSON.parse(raw) : null;
|
|
10754
|
+
} catch {
|
|
10755
|
+
parsedResponse = raw;
|
|
10756
|
+
}
|
|
10757
|
+
if (!response.ok) {
|
|
10758
|
+
throw new CLIError("UPSTREAM_REQUEST_FAILED", typeof parsedResponse === "string" ? parsedResponse : JSON.stringify(parsedResponse), 1);
|
|
10759
|
+
}
|
|
10760
|
+
if (isRecord2(parsedResponse) && parsedResponse.error) {
|
|
10761
|
+
const upstreamError = parsedResponse.error;
|
|
10762
|
+
const upstreamMessage = isRecord2(upstreamError) && typeof upstreamError.message === "string" ? upstreamError.message : typeof upstreamError === "string" ? upstreamError : JSON.stringify(upstreamError);
|
|
10763
|
+
throw new CLIError("UPSTREAM_BODY_ERROR", upstreamMessage, 1, {
|
|
10764
|
+
endpoint: `/entity/${appId}/${entityId}`,
|
|
10765
|
+
method: "GET",
|
|
10766
|
+
upstreamError
|
|
10767
|
+
});
|
|
10768
|
+
}
|
|
10769
|
+
const fields = extractEntityFields(parsedResponse);
|
|
10770
|
+
return new Map(fields.map((field) => [field.id, field]));
|
|
10771
|
+
}
|
|
10772
|
+
function looksLikeLocalFilePath(value) {
|
|
10773
|
+
return value.startsWith("./") || value.startsWith("../") || value.startsWith("/") || value.startsWith("~/") || /\.(pdf|png|jpe?g|gif|webp|bmp|svg|heic|txt|csv|xlsx?|docx?|pptx?|zip)$/i.test(value);
|
|
10774
|
+
}
|
|
10775
|
+
function isValidUploadEntry(value) {
|
|
10776
|
+
if (!isRecord2(value)) {
|
|
10777
|
+
return false;
|
|
10778
|
+
}
|
|
10779
|
+
const hasUploadId = typeof value.upload_id === "number" || typeof value.upload_id === "string";
|
|
10780
|
+
const hasAssetsId = typeof value.assets_id === "number" || typeof value.assets_id === "string";
|
|
10781
|
+
return (hasUploadId || hasAssetsId) && typeof value.file === "string" && typeof value.file_name === "string";
|
|
10782
|
+
}
|
|
10783
|
+
async function validateFileFieldPayloads(scope, command, runtimeEnv, flags, body, fetchImpl) {
|
|
10784
|
+
if (!isRecord2(body)) {
|
|
10785
|
+
return;
|
|
10786
|
+
}
|
|
10787
|
+
const container = command.functionName === "updateEntityRow" ? body.data : body.fields;
|
|
10788
|
+
if (!isRecord2(container)) {
|
|
10789
|
+
return;
|
|
10790
|
+
}
|
|
10791
|
+
const appId = flagValue(flags, "app-id");
|
|
10792
|
+
const entityId = flagValue(flags, "entity-id");
|
|
10793
|
+
if (!appId || !entityId) {
|
|
10794
|
+
return;
|
|
10795
|
+
}
|
|
10796
|
+
const fieldsById = await fetchEntityFields(runtimeEnv, appId, entityId, fetchImpl);
|
|
10797
|
+
for (const [fieldIdText, value] of Object.entries(container)) {
|
|
10798
|
+
if (!/^\d+$/.test(fieldIdText)) {
|
|
10799
|
+
continue;
|
|
10800
|
+
}
|
|
10801
|
+
const fieldId = Number(fieldIdText);
|
|
10802
|
+
const field = fieldsById.get(fieldId);
|
|
10803
|
+
if (!field || field.type !== "file" && field.type !== "image") {
|
|
10804
|
+
continue;
|
|
10805
|
+
}
|
|
10806
|
+
const fieldPath = command.functionName === "updateEntityRow" ? `body.data.${fieldId}` : `body.fields.${fieldId}`;
|
|
10807
|
+
const fieldName = field.label ? `${field.label} (${field.type})` : `${field.type} field ${fieldId}`;
|
|
10808
|
+
if (typeof value === "string") {
|
|
10809
|
+
const guidance = looksLikeLocalFilePath(value) ? `do not put a local file path directly into ${fieldName}; run "arcubase upload ${value}" first and use the returned data array as the field value` : `${fieldName} must be an array returned by "arcubase upload <local-file>", not a string`;
|
|
10810
|
+
throw new CLIError("BODY_VALIDATION_FAILED", guidance, 2, {
|
|
10811
|
+
operation: `${scope}.${command.module}.${command.functionName}`,
|
|
10812
|
+
requestType: command.requestType ?? void 0,
|
|
10813
|
+
issues: [{ path: fieldPath, message: guidance }],
|
|
10814
|
+
docHints: [
|
|
10815
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10816
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" }
|
|
10817
|
+
]
|
|
10818
|
+
});
|
|
10819
|
+
}
|
|
10820
|
+
if (isRecord2(value)) {
|
|
10821
|
+
const guidance = `${fieldName} must be an array. Run "arcubase upload <local-file>" and use the returned data array directly as the field value`;
|
|
10822
|
+
throw new CLIError("BODY_VALIDATION_FAILED", guidance, 2, {
|
|
10823
|
+
operation: `${scope}.${command.module}.${command.functionName}`,
|
|
10824
|
+
requestType: command.requestType ?? void 0,
|
|
10825
|
+
issues: [{ path: fieldPath, message: guidance }],
|
|
10826
|
+
docHints: [
|
|
10827
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10828
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" }
|
|
10829
|
+
]
|
|
10830
|
+
});
|
|
10831
|
+
}
|
|
10832
|
+
if (!Array.isArray(value)) {
|
|
10833
|
+
const guidance = `${fieldName} must be an array returned by "arcubase upload <local-file>"`;
|
|
10834
|
+
throw new CLIError("BODY_VALIDATION_FAILED", guidance, 2, {
|
|
10835
|
+
operation: `${scope}.${command.module}.${command.functionName}`,
|
|
10836
|
+
requestType: command.requestType ?? void 0,
|
|
10837
|
+
issues: [{ path: fieldPath, message: guidance }],
|
|
10838
|
+
docHints: [
|
|
10839
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10840
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" }
|
|
10841
|
+
]
|
|
10842
|
+
});
|
|
10843
|
+
}
|
|
10844
|
+
for (const [index, item] of value.entries()) {
|
|
10845
|
+
if (!isValidUploadEntry(item)) {
|
|
10846
|
+
const guidance = `${fieldName} entries must include upload_id or assets_id plus file and file_name. Use "arcubase upload <local-file>" and copy the returned array item as-is`;
|
|
10847
|
+
throw new CLIError("BODY_VALIDATION_FAILED", guidance, 2, {
|
|
10848
|
+
operation: `${scope}.${command.module}.${command.functionName}`,
|
|
10849
|
+
requestType: command.requestType ?? void 0,
|
|
10850
|
+
issues: [{ path: `${fieldPath}.${index}`, message: guidance }],
|
|
10851
|
+
docHints: [
|
|
10852
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
10853
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" }
|
|
10854
|
+
]
|
|
10855
|
+
});
|
|
10856
|
+
}
|
|
10857
|
+
}
|
|
10858
|
+
}
|
|
10859
|
+
}
|
|
10860
|
+
function throwBodyValidationFailure(message, requestType, path2, scope, command) {
|
|
10598
10861
|
throw new CLIError("BODY_VALIDATION_FAILED", message, 2, {
|
|
10599
10862
|
operation: `${scope}.${command.module}.${command.functionName}`,
|
|
10600
10863
|
requestType,
|
|
10601
10864
|
issues: [
|
|
10602
10865
|
{
|
|
10603
|
-
path,
|
|
10866
|
+
path: path2,
|
|
10604
10867
|
message
|
|
10605
10868
|
}
|
|
10606
10869
|
],
|
|
@@ -10612,7 +10875,7 @@ function validateActionSpecificBody(scope, command, flags, body) {
|
|
|
10612
10875
|
if (!isRecord2(body) || !command.requestType) {
|
|
10613
10876
|
return;
|
|
10614
10877
|
}
|
|
10615
|
-
if (command.module === "
|
|
10878
|
+
if (command.module === "rows" && command.functionName === "queryEntitySelection") {
|
|
10616
10879
|
const action = flagValue(flags, "action");
|
|
10617
10880
|
const selection = body.selection;
|
|
10618
10881
|
if (!isRecord2(selection) || typeof selection.type !== "string") {
|
|
@@ -10624,7 +10887,7 @@ function validateActionSpecificBody(scope, command, flags, body) {
|
|
|
10624
10887
|
if (action === "query") {
|
|
10625
10888
|
if (type === "condition") {
|
|
10626
10889
|
throwBodyValidationFailure(
|
|
10627
|
-
"selection.type=condition is not supported for action=query; use selection.type=ids or selection.type=all, or use
|
|
10890
|
+
"selection.type=condition is not supported for action=query; use selection.type=ids or selection.type=all, or use rows query-entity for search conditions",
|
|
10628
10891
|
command.requestType,
|
|
10629
10892
|
"body.selection.type",
|
|
10630
10893
|
scope,
|
|
@@ -10655,6 +10918,31 @@ function validateActionSpecificBody(scope, command, flags, body) {
|
|
|
10655
10918
|
}
|
|
10656
10919
|
async function executeCLI(scope, argv, env, fetchImpl = fetch) {
|
|
10657
10920
|
const parsed = parseCLIArgs(argv);
|
|
10921
|
+
if (scope === "user" && parsed.commandTokens[0] === "upload") {
|
|
10922
|
+
if (hasFlag(parsed.flags, "help") || parsed.commandTokens.length === 1) {
|
|
10923
|
+
return { kind: "help", text: renderUploadHelp() };
|
|
10924
|
+
}
|
|
10925
|
+
const sourcePath = parsed.commandTokens[1];
|
|
10926
|
+
if (!sourcePath) {
|
|
10927
|
+
throw new CLIError("UPLOAD_SOURCE_REQUIRED", "upload requires a local file path", 2);
|
|
10928
|
+
}
|
|
10929
|
+
const runtimeEnv2 = env ?? loadRuntimeEnv(scope);
|
|
10930
|
+
const data = await uploadLocalFile(
|
|
10931
|
+
runtimeEnv2,
|
|
10932
|
+
sourcePath,
|
|
10933
|
+
{
|
|
10934
|
+
filename: flagValue(parsed.flags, "filename"),
|
|
10935
|
+
global: hasFlag(parsed.flags, "global")
|
|
10936
|
+
},
|
|
10937
|
+
fetchImpl
|
|
10938
|
+
);
|
|
10939
|
+
return {
|
|
10940
|
+
kind: "result",
|
|
10941
|
+
commandPath: ["upload", sourcePath],
|
|
10942
|
+
status: 200,
|
|
10943
|
+
data
|
|
10944
|
+
};
|
|
10945
|
+
}
|
|
10658
10946
|
if (parsed.commandTokens.length === 0) {
|
|
10659
10947
|
return { kind: "help", text: renderRootHelp(scope) };
|
|
10660
10948
|
}
|
|
@@ -10671,7 +10959,10 @@ async function executeCLI(scope, argv, env, fetchImpl = fetch) {
|
|
|
10671
10959
|
const runtimeEnv = env ?? loadRuntimeEnv(scope);
|
|
10672
10960
|
const command = findCommand(scope, moduleName, commandName);
|
|
10673
10961
|
if (!command) {
|
|
10674
|
-
throw new CLIError("UNKNOWN_COMMAND", `unknown command: ${moduleName} ${commandName}`, 2);
|
|
10962
|
+
throw new CLIError("UNKNOWN_COMMAND", `unknown command: ${moduleName} ${commandName}`, 2, buildUnknownCommandDetails(scope, moduleName, commandName));
|
|
10963
|
+
}
|
|
10964
|
+
if (scope === "admin" && moduleName === "app" && commandName === "inventory") {
|
|
10965
|
+
return executeAppInventory(runtimeEnv, fetchImpl);
|
|
10675
10966
|
}
|
|
10676
10967
|
const endpoint = normalizeExternalEndpoint(resolveEndpoint(command.endpoint, parsed.flags));
|
|
10677
10968
|
const scalarQuery = buildScalarQuery(command, parsed.flags);
|
|
@@ -10718,6 +11009,9 @@ async function executeCLI(scope, argv, env, fetchImpl = fetch) {
|
|
|
10718
11009
|
}
|
|
10719
11010
|
}
|
|
10720
11011
|
}
|
|
11012
|
+
if (scope === "user" && (command.functionName === "insertEntity" || command.functionName === "updateEntityRow")) {
|
|
11013
|
+
await validateFileFieldPayloads(scope, command, runtimeEnv, parsed.flags, validatedBody, fetchImpl);
|
|
11014
|
+
}
|
|
10721
11015
|
const response = await fetchImpl(buildURL(runtimeEnv.ARCUBASE_BASE_URL, endpoint, Object.keys(query).length > 0 ? query : void 0), {
|
|
10722
11016
|
method: command.method,
|
|
10723
11017
|
headers: {
|
|
@@ -10739,11 +11033,20 @@ async function executeCLI(scope, argv, env, fetchImpl = fetch) {
|
|
|
10739
11033
|
const upstreamError = parsedResponse.error;
|
|
10740
11034
|
const upstreamMessage = typeof upstreamError === "object" && upstreamError && "message" in upstreamError && typeof upstreamError.message === "string" ? upstreamError.message : typeof upstreamError === "string" ? upstreamError : JSON.stringify(upstreamError);
|
|
10741
11035
|
const traceId = typeof parsedResponse.trace_id === "string" ? parsedResponse.trace_id : typeof parsedResponse.request_id === "string" ? parsedResponse.request_id : void 0;
|
|
11036
|
+
const uploadBindFailure = upstreamMessage.includes("failed to bind upload to assets");
|
|
10742
11037
|
throw new CLIError("UPSTREAM_BODY_ERROR", upstreamMessage, 1, {
|
|
10743
11038
|
endpoint,
|
|
10744
11039
|
method: command.method,
|
|
10745
11040
|
traceId,
|
|
10746
|
-
upstreamError
|
|
11041
|
+
upstreamError,
|
|
11042
|
+
...uploadBindFailure ? {
|
|
11043
|
+
reason: "the row payload used a file/image upload entry, but Arcubase could not bind that upload into an asset record",
|
|
11044
|
+
hint: "verify the upload storage host is reachable from the Arcubase server, then rerun arcubase upload and retry the row insert/update",
|
|
11045
|
+
docHints: [
|
|
11046
|
+
{ title: "Uploads", file: "/opt/arcubase-sdk/docs/runtime-reference/uploads.md" },
|
|
11047
|
+
{ title: "Row CRUD", file: "/opt/arcubase-sdk/docs/runtime-reference/row-crud.md" }
|
|
11048
|
+
]
|
|
11049
|
+
} : {}
|
|
10747
11050
|
});
|
|
10748
11051
|
}
|
|
10749
11052
|
return {
|