busa-cli 0.10.0 → 0.10.2
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/dist/{chunk-GUIGCDNE.js → chunk-DGRADZF2.js} +195 -65
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -234,11 +234,11 @@ var baseFieldChangeTask = {
|
|
|
234
234
|
...input.message ? { message: input.message } : {},
|
|
235
235
|
...input.submittedBy ? { submittedBy: input.submittedBy } : {}
|
|
236
236
|
};
|
|
237
|
-
const bases = client.bases;
|
|
238
237
|
switch (input.operation) {
|
|
239
238
|
case "add":
|
|
240
|
-
return bases.
|
|
239
|
+
return client.bases.fieldChangeRequest({
|
|
241
240
|
...common,
|
|
241
|
+
operation: "create",
|
|
242
242
|
slug: input.slug,
|
|
243
243
|
name: input.name,
|
|
244
244
|
...input.fieldType ? { type: input.fieldType } : {},
|
|
@@ -246,31 +246,36 @@ var baseFieldChangeTask = {
|
|
|
246
246
|
...input.options ? { options: input.options } : {}
|
|
247
247
|
});
|
|
248
248
|
case "update":
|
|
249
|
-
return bases.
|
|
249
|
+
return client.bases.fieldChangeRequest({
|
|
250
250
|
...common,
|
|
251
|
+
operation: "update",
|
|
251
252
|
fieldId: input.fieldId,
|
|
252
253
|
patch: input.patch
|
|
253
254
|
});
|
|
254
255
|
case "delete":
|
|
255
|
-
return bases.
|
|
256
|
+
return client.bases.fieldChangeRequest({
|
|
256
257
|
...common,
|
|
258
|
+
operation: "delete",
|
|
257
259
|
fieldId: input.fieldId
|
|
258
260
|
});
|
|
259
261
|
case "convert":
|
|
260
|
-
return bases.
|
|
262
|
+
return client.bases.fieldChangeRequest({
|
|
261
263
|
...common,
|
|
264
|
+
operation: "convert",
|
|
262
265
|
fieldId: input.fieldId,
|
|
263
266
|
newType: input.newType,
|
|
264
267
|
...input.selectChoiceMode ? { selectChoiceMode: input.selectChoiceMode } : {}
|
|
265
268
|
});
|
|
266
269
|
case "reorder":
|
|
267
|
-
return bases.
|
|
270
|
+
return client.bases.fieldChangeRequest({
|
|
268
271
|
...common,
|
|
272
|
+
operation: "reorder",
|
|
269
273
|
fieldIds: input.fieldIds
|
|
270
274
|
});
|
|
271
275
|
default:
|
|
272
|
-
return bases.
|
|
276
|
+
return client.bases.fieldChangeRequest({
|
|
273
277
|
...common,
|
|
278
|
+
operation: "restore",
|
|
274
279
|
fieldId: input.fieldId
|
|
275
280
|
});
|
|
276
281
|
}
|
|
@@ -313,7 +318,7 @@ var changeRequestQueryTask = {
|
|
|
313
318
|
],
|
|
314
319
|
execute: async (client, input) => {
|
|
315
320
|
if (input.countsOnly) return client.changeRequests.counts();
|
|
316
|
-
return client.changeRequests.
|
|
321
|
+
return client.changeRequests.list({
|
|
317
322
|
...input.status ? { status: input.status } : {},
|
|
318
323
|
...input.mine !== void 0 ? { mine: input.mine } : {},
|
|
319
324
|
...input.limit !== void 0 ? { limit: input.limit } : {},
|
|
@@ -403,11 +408,6 @@ var changeRequestMergeTask = {
|
|
|
403
408
|
|
|
404
409
|
// ../../packages/busabase-contract/src/tasks/file-tree.ts
|
|
405
410
|
var FILE_TREE_KINDS = ["skill", "drive", "airapp"];
|
|
406
|
-
var NAMESPACE = {
|
|
407
|
-
skill: "skills",
|
|
408
|
-
drive: "drives",
|
|
409
|
-
airapp: "airapps"
|
|
410
|
-
};
|
|
411
411
|
var kindParam = {
|
|
412
412
|
name: "kind",
|
|
413
413
|
kind: "enum",
|
|
@@ -452,7 +452,7 @@ var nodeListTask = {
|
|
|
452
452
|
annotations: { readOnly: true, destructive: false },
|
|
453
453
|
params: [kindParam],
|
|
454
454
|
examples: ["busabase-cli nodes list-file-trees --kind skill"],
|
|
455
|
-
execute: async (client, input) => client
|
|
455
|
+
execute: async (client, input) => client.fileTrees.list({ type: resolveKind(input.kind) })
|
|
456
456
|
};
|
|
457
457
|
var nodeGetTask = {
|
|
458
458
|
name: "node_get_file_tree",
|
|
@@ -478,7 +478,7 @@ var nodeGetTask = {
|
|
|
478
478
|
annotations: { readOnly: true, destructive: false },
|
|
479
479
|
params: [kindParam, nodeIdParam],
|
|
480
480
|
examples: ["busabase-cli nodes get-file-tree --kind airapp --node-id nod_123"],
|
|
481
|
-
execute: async (client, input) => client
|
|
481
|
+
execute: async (client, input) => client.fileTrees.get({ nodeId: input.nodeId, type: resolveKind(input.kind) })
|
|
482
482
|
};
|
|
483
483
|
var nodeListFilesTask = {
|
|
484
484
|
name: "node_files_list",
|
|
@@ -504,7 +504,7 @@ var nodeListFilesTask = {
|
|
|
504
504
|
annotations: { readOnly: true, destructive: false },
|
|
505
505
|
params: [kindParam, nodeIdParam],
|
|
506
506
|
examples: ["busabase-cli nodes files --kind drive --node-id nod_123"],
|
|
507
|
-
execute: async (client, input) => client
|
|
507
|
+
execute: async (client, input) => client.fileTrees.listFiles({ nodeId: input.nodeId, type: resolveKind(input.kind) })
|
|
508
508
|
};
|
|
509
509
|
var nodeReadFileTask = {
|
|
510
510
|
name: "node_file_read",
|
|
@@ -540,9 +540,10 @@ var nodeReadFileTask = {
|
|
|
540
540
|
}
|
|
541
541
|
],
|
|
542
542
|
examples: ["busabase-cli nodes read-file --kind skill --node-id nod_123 --file-path SKILL.md"],
|
|
543
|
-
execute: async (client, input) => client
|
|
543
|
+
execute: async (client, input) => client.fileTrees.readFile({
|
|
544
544
|
nodeId: input.nodeId,
|
|
545
|
-
filePath: input.filePath
|
|
545
|
+
filePath: input.filePath,
|
|
546
|
+
type: resolveKind(input.kind)
|
|
546
547
|
})
|
|
547
548
|
};
|
|
548
549
|
var nodeFilesChangeRequestTask = {
|
|
@@ -593,11 +594,12 @@ var nodeFilesChangeRequestTask = {
|
|
|
593
594
|
}
|
|
594
595
|
const payload = {
|
|
595
596
|
nodeId: input.nodeId,
|
|
597
|
+
type: resolveKind(input.kind),
|
|
596
598
|
operations: input.operations,
|
|
597
599
|
...input.message ? { message: input.message } : {},
|
|
598
600
|
...input.submittedBy ? { submittedBy: input.submittedBy } : {}
|
|
599
601
|
};
|
|
600
|
-
return client
|
|
602
|
+
return client.fileTrees.createChangeRequest(payload);
|
|
601
603
|
}
|
|
602
604
|
};
|
|
603
605
|
|
|
@@ -655,15 +657,18 @@ var listArchivedTask = {
|
|
|
655
657
|
"busabase-cli archived list --scope records --base-id bas_1 --limit 100"
|
|
656
658
|
],
|
|
657
659
|
execute: async (client, input) => {
|
|
658
|
-
if (input.scope === "nodes") return client.nodes.
|
|
659
|
-
if (input.scope === "bases") return client.bases.
|
|
660
|
+
if (input.scope === "nodes") return client.nodes.list({ status: "archived" });
|
|
661
|
+
if (input.scope === "bases") return client.bases.list({ status: "archived" });
|
|
660
662
|
if (!input.baseId) {
|
|
661
663
|
throw new Error(`scope "${input.scope}" requires baseId.`);
|
|
662
664
|
}
|
|
663
665
|
if (input.scope === "fields") return client.bases.listDeletedFields({ baseId: input.baseId });
|
|
664
|
-
if (input.scope === "views")
|
|
665
|
-
|
|
666
|
+
if (input.scope === "views") {
|
|
667
|
+
return client.bases.listViews({ baseId: input.baseId, status: "archived" });
|
|
668
|
+
}
|
|
669
|
+
return client.records.list({
|
|
666
670
|
baseId: input.baseId,
|
|
671
|
+
status: "archived",
|
|
667
672
|
...input.limit !== void 0 ? { limit: input.limit } : {},
|
|
668
673
|
...input.cursor ? { cursor: input.cursor } : {}
|
|
669
674
|
});
|
|
@@ -1237,14 +1242,15 @@ var nodeCreateTask = {
|
|
|
1237
1242
|
if (FILE_TREE_TYPES.has(type)) {
|
|
1238
1243
|
const payload = {
|
|
1239
1244
|
...common,
|
|
1245
|
+
// `type` is the contract's discriminator, so the narrowing has to be
|
|
1246
|
+
// explicit — `FILE_TREE_TYPES.has` doesn't narrow a plain string.
|
|
1247
|
+
type,
|
|
1240
1248
|
...Array.isArray(input.files) ? { files: input.files } : {},
|
|
1241
1249
|
...input.mergeMode ? { mergeMode: input.mergeMode } : {},
|
|
1242
1250
|
...input.visibility ? { visibility: input.visibility } : {},
|
|
1243
1251
|
...input.version ? { version: input.version } : {}
|
|
1244
1252
|
};
|
|
1245
|
-
|
|
1246
|
-
if (type === "drive") return client.drives.create(payload);
|
|
1247
|
-
return client.airapps.create(payload);
|
|
1253
|
+
return client.fileTrees.create(payload);
|
|
1248
1254
|
}
|
|
1249
1255
|
if (type === "doc") {
|
|
1250
1256
|
const payload = { ...common, body: input.body ?? "" };
|
|
@@ -1321,20 +1327,20 @@ var recordChangeTask = {
|
|
|
1321
1327
|
if (!input.fields || typeof input.fields !== "object") {
|
|
1322
1328
|
throw new Error('operation "update" requires `fields` (an object keyed by field slug).');
|
|
1323
1329
|
}
|
|
1324
|
-
return client.records.
|
|
1330
|
+
return client.records.changeRequest({
|
|
1325
1331
|
...common,
|
|
1332
|
+
operation: "update",
|
|
1326
1333
|
fields: input.fields
|
|
1327
1334
|
});
|
|
1328
1335
|
}
|
|
1329
1336
|
if (input.operation === "delete") {
|
|
1330
|
-
return client.records.
|
|
1337
|
+
return client.records.changeRequest({
|
|
1331
1338
|
...common,
|
|
1339
|
+
operation: "delete",
|
|
1332
1340
|
deleteMode: "archive"
|
|
1333
1341
|
});
|
|
1334
1342
|
}
|
|
1335
|
-
return client.records.
|
|
1336
|
-
common
|
|
1337
|
-
);
|
|
1343
|
+
return client.records.changeRequest({ ...common, operation: "restore" });
|
|
1338
1344
|
}
|
|
1339
1345
|
};
|
|
1340
1346
|
|
|
@@ -1415,7 +1421,7 @@ var recordQueryTask = {
|
|
|
1415
1421
|
input.baseId ? { baseId: input.baseId } : {}
|
|
1416
1422
|
);
|
|
1417
1423
|
}
|
|
1418
|
-
return client.records.
|
|
1424
|
+
return client.records.list({
|
|
1419
1425
|
...input.limit !== void 0 ? { limit: input.limit } : {},
|
|
1420
1426
|
...input.baseId ? { baseId: input.baseId } : {},
|
|
1421
1427
|
...input.cursor ? { cursor: input.cursor } : {},
|
|
@@ -1493,7 +1499,8 @@ var viewChangeTask = {
|
|
|
1493
1499
|
if (!input.baseId || !input.name) {
|
|
1494
1500
|
throw new Error('action "create" requires baseId and name.');
|
|
1495
1501
|
}
|
|
1496
|
-
return client.
|
|
1502
|
+
return client.views.changeRequest({
|
|
1503
|
+
operation: "create",
|
|
1497
1504
|
baseId: input.baseId,
|
|
1498
1505
|
name: input.name,
|
|
1499
1506
|
...input.type ? { type: input.type } : {},
|
|
@@ -1505,19 +1512,16 @@ var viewChangeTask = {
|
|
|
1505
1512
|
const target = { viewId: input.viewId, ...meta };
|
|
1506
1513
|
if (input.action === "update") {
|
|
1507
1514
|
if (!input.patch) throw new Error('action "update" requires patch.');
|
|
1508
|
-
return client.views.
|
|
1515
|
+
return client.views.changeRequest({
|
|
1516
|
+
operation: "update",
|
|
1509
1517
|
...target,
|
|
1510
1518
|
...input.patch
|
|
1511
1519
|
});
|
|
1512
1520
|
}
|
|
1513
1521
|
if (input.action === "delete") {
|
|
1514
|
-
return client.views.
|
|
1515
|
-
target
|
|
1516
|
-
);
|
|
1522
|
+
return client.views.changeRequest({ operation: "delete", ...target });
|
|
1517
1523
|
}
|
|
1518
|
-
return client.views.
|
|
1519
|
-
target
|
|
1520
|
-
);
|
|
1524
|
+
return client.views.changeRequest({ operation: "restore", ...target });
|
|
1521
1525
|
}
|
|
1522
1526
|
};
|
|
1523
1527
|
|
|
@@ -3393,6 +3397,15 @@ var restoreFieldChangeRequestInputSchema = z6.object({
|
|
|
3393
3397
|
message: z6.string().optional(),
|
|
3394
3398
|
submittedBy: z6.string().optional().default("local-editor")
|
|
3395
3399
|
});
|
|
3400
|
+
var withBaseId = { baseId: z6.string().min(1) };
|
|
3401
|
+
var fieldChangeRequestInputSchema = z6.discriminatedUnion("operation", [
|
|
3402
|
+
createFieldChangeRequestInputSchema.extend({ operation: z6.literal("create"), ...withBaseId }),
|
|
3403
|
+
updateFieldChangeRequestInputSchema.extend({ operation: z6.literal("update"), ...withBaseId }),
|
|
3404
|
+
deleteFieldChangeRequestInputSchema.extend({ operation: z6.literal("delete"), ...withBaseId }),
|
|
3405
|
+
convertFieldChangeRequestInputSchema.extend({ operation: z6.literal("convert"), ...withBaseId }),
|
|
3406
|
+
reorderFieldsChangeRequestInputSchema.extend({ operation: z6.literal("reorder"), ...withBaseId }),
|
|
3407
|
+
restoreFieldChangeRequestInputSchema.extend({ operation: z6.literal("restore"), ...withBaseId })
|
|
3408
|
+
]);
|
|
3396
3409
|
|
|
3397
3410
|
// ../../packages/busabase-contract/src/domains/base/contract/view-schemas.ts
|
|
3398
3411
|
import { z as z8 } from "zod";
|
|
@@ -3444,7 +3457,13 @@ var listNodesInputSchema = z7.object({
|
|
|
3444
3457
|
parentId: z7.string().nullable().optional().describe("Node to start from. Omit or null to start from the space root."),
|
|
3445
3458
|
depth: z7.coerce.number().int().min(1).max(5).optional().describe(
|
|
3446
3459
|
"How many levels beneath the start point to eagerly include (default 2 once either field is set). Capped at 5."
|
|
3447
|
-
)
|
|
3460
|
+
),
|
|
3461
|
+
/**
|
|
3462
|
+
* `active` (default) walks the live tree. `archived` returns the flat set of
|
|
3463
|
+
* soft-archived nodes for the Trash view — no `parentId`/`depth` walk, since
|
|
3464
|
+
* archived nodes are shown as a list, not a tree.
|
|
3465
|
+
*/
|
|
3466
|
+
status: z7.enum(["active", "archived"]).optional().default("active")
|
|
3448
3467
|
}).optional();
|
|
3449
3468
|
var isDescendantInputSchema = z7.object({
|
|
3450
3469
|
nodeId: z7.string(),
|
|
@@ -3773,6 +3792,9 @@ var createCommentInputSchema = commentSubjectInputSchema.extend({
|
|
|
3773
3792
|
var listInputSchema = z7.object({
|
|
3774
3793
|
limit: z7.coerce.number().int().min(1).max(100).optional().default(50)
|
|
3775
3794
|
}).optional().default({ limit: 50 });
|
|
3795
|
+
var listByStatusInputSchema = z7.object({
|
|
3796
|
+
status: z7.enum(["active", "archived"]).optional().default("active")
|
|
3797
|
+
});
|
|
3776
3798
|
var listChangeRequestsPagedInputSchema = z7.object({
|
|
3777
3799
|
limit: z7.coerce.number().int().min(1).max(100).optional().default(50),
|
|
3778
3800
|
/** Opaque base64 cursor (`createdAt|id`) for keyset pagination. */
|
|
@@ -3949,6 +3971,24 @@ var restoreViewInputSchema = z8.object({
|
|
|
3949
3971
|
message: z8.string().optional().default("Restore view"),
|
|
3950
3972
|
submittedBy: z8.string().optional().default("local-producer")
|
|
3951
3973
|
});
|
|
3974
|
+
var viewChangeRequestInputSchema = z8.discriminatedUnion("operation", [
|
|
3975
|
+
createViewInputSchema.extend({
|
|
3976
|
+
operation: z8.literal("create"),
|
|
3977
|
+
baseId: z8.string().min(1).describe("Base the new view belongs to.")
|
|
3978
|
+
}),
|
|
3979
|
+
updateViewInputSchema.extend({
|
|
3980
|
+
operation: z8.literal("update"),
|
|
3981
|
+
viewId: z8.string().min(1)
|
|
3982
|
+
}),
|
|
3983
|
+
deleteViewInputSchema.extend({
|
|
3984
|
+
operation: z8.literal("delete"),
|
|
3985
|
+
viewId: z8.string().min(1)
|
|
3986
|
+
}),
|
|
3987
|
+
restoreViewInputSchema.extend({
|
|
3988
|
+
operation: z8.literal("restore"),
|
|
3989
|
+
viewId: z8.string().min(1)
|
|
3990
|
+
})
|
|
3991
|
+
]);
|
|
3952
3992
|
|
|
3953
3993
|
// ../../packages/busabase-contract/src/domains/package/types.ts
|
|
3954
3994
|
var PACKAGE_FORMAT = "busabase-package@1";
|
|
@@ -4292,7 +4332,8 @@ var applyInstall = async (client, plan, options) => {
|
|
|
4292
4332
|
}
|
|
4293
4333
|
const patched = resolveFieldIdOptions(field, base.node.slug, fieldIds, state.warnings);
|
|
4294
4334
|
if (!patched) continue;
|
|
4295
|
-
const changeRequest = await client.bases.
|
|
4335
|
+
const changeRequest = await client.bases.fieldChangeRequest({
|
|
4336
|
+
operation: "update",
|
|
4296
4337
|
baseId: base.baseId,
|
|
4297
4338
|
fieldId,
|
|
4298
4339
|
patch: { options: patched },
|
|
@@ -4443,7 +4484,8 @@ var createBase = async (client, node, parentNodeId, options, state, bases, field
|
|
|
4443
4484
|
bases.push({ node, baseId: result.id });
|
|
4444
4485
|
indexFields(fieldIds, node.slug, result.fields);
|
|
4445
4486
|
for (const view of node.base.views) {
|
|
4446
|
-
const changeRequest = await client.
|
|
4487
|
+
const changeRequest = await client.views.changeRequest({
|
|
4488
|
+
operation: "create",
|
|
4447
4489
|
baseId: result.id,
|
|
4448
4490
|
slug: view.slug,
|
|
4449
4491
|
name: view.name,
|
|
@@ -4477,8 +4519,8 @@ var createFileTreeNode = async (client, node, parentNodeId, options, state) => {
|
|
|
4477
4519
|
})
|
|
4478
4520
|
);
|
|
4479
4521
|
const files = uploaded.filter((entry) => entry !== void 0);
|
|
4480
|
-
const
|
|
4481
|
-
|
|
4522
|
+
const result = await client.fileTrees.create({
|
|
4523
|
+
type: node.type,
|
|
4482
4524
|
parentNodeId,
|
|
4483
4525
|
slug: node.slug,
|
|
4484
4526
|
name: node.name,
|
|
@@ -4653,12 +4695,17 @@ var linkRelations = async (client, base, relationFieldSlugs, recordIdsByKey, opt
|
|
|
4653
4695
|
if (!hasRelation) continue;
|
|
4654
4696
|
const recordId = recordIdsByKey.get(record.key);
|
|
4655
4697
|
if (!recordId) continue;
|
|
4656
|
-
const changeRequest = await client.records.
|
|
4698
|
+
const changeRequest = await client.records.changeRequest({
|
|
4699
|
+
operation: "update",
|
|
4657
4700
|
recordId,
|
|
4658
4701
|
fields: { ...toCreatableFields(base.node, record.fields), ...relationValues },
|
|
4659
4702
|
message: `Link relations for ${base.node.slug}`,
|
|
4660
|
-
author: options.submittedBy
|
|
4703
|
+
author: options.submittedBy,
|
|
4704
|
+
autoMerge: false
|
|
4661
4705
|
});
|
|
4706
|
+
if (changeRequest.materialized) {
|
|
4707
|
+
throw new Error("Relation update unexpectedly bypassed the install review flow");
|
|
4708
|
+
}
|
|
4662
4709
|
await approveAndMerge(client, changeRequest.id);
|
|
4663
4710
|
}
|
|
4664
4711
|
};
|
|
@@ -4725,7 +4772,7 @@ var collectNode = async (client, source, options) => {
|
|
|
4725
4772
|
case "skill":
|
|
4726
4773
|
case "airapp":
|
|
4727
4774
|
case "drive":
|
|
4728
|
-
return collectFileTree(client, source, common, options);
|
|
4775
|
+
return collectFileTree(client, source, source.type, common, options);
|
|
4729
4776
|
case "file":
|
|
4730
4777
|
return collectFile(client, source, common, options);
|
|
4731
4778
|
default:
|
|
@@ -4767,7 +4814,7 @@ var collectBase = async (client, source, common, options) => {
|
|
|
4767
4814
|
};
|
|
4768
4815
|
};
|
|
4769
4816
|
var buildIndexes = async (client) => {
|
|
4770
|
-
const bases = await client.bases.list();
|
|
4817
|
+
const bases = await client.bases.list({});
|
|
4771
4818
|
const baseSlugById = /* @__PURE__ */ new Map();
|
|
4772
4819
|
const fieldSlugById = /* @__PURE__ */ new Map();
|
|
4773
4820
|
for (const base of bases) {
|
|
@@ -4854,7 +4901,7 @@ var collectRecords = async (client, baseId, fields, options) => {
|
|
|
4854
4901
|
let droppedAttachments = 0;
|
|
4855
4902
|
let cursor;
|
|
4856
4903
|
do {
|
|
4857
|
-
const page = await client.records.
|
|
4904
|
+
const page = await client.records.list({ baseId, limit: 100, cursor });
|
|
4858
4905
|
for (const record of page.records) {
|
|
4859
4906
|
if (record.status !== "active") continue;
|
|
4860
4907
|
const values = {};
|
|
@@ -4880,12 +4927,15 @@ var collectRecords = async (client, baseId, fields, options) => {
|
|
|
4880
4927
|
}
|
|
4881
4928
|
return records.sort((a, b) => a.key.localeCompare(b.key, "en"));
|
|
4882
4929
|
};
|
|
4883
|
-
var collectFileTree = async (client, source, common, options) => {
|
|
4884
|
-
const
|
|
4885
|
-
const listed = await api.listFiles({ nodeId: source.id });
|
|
4930
|
+
var collectFileTree = async (client, source, type, common, options) => {
|
|
4931
|
+
const listed = await client.fileTrees.listFiles({ nodeId: source.id, type });
|
|
4886
4932
|
const files = [];
|
|
4887
4933
|
for (const file of listed) {
|
|
4888
|
-
const read = await
|
|
4934
|
+
const read = await client.fileTrees.readFile({
|
|
4935
|
+
nodeId: source.id,
|
|
4936
|
+
filePath: file.path,
|
|
4937
|
+
type
|
|
4938
|
+
});
|
|
4889
4939
|
files.push({
|
|
4890
4940
|
path: file.path,
|
|
4891
4941
|
bytes: read.encoding === "url" ? await downloadBytes(read.content, file.path, options) : Buffer.from(read.content, "utf8")
|
|
@@ -5584,7 +5634,7 @@ var findTargetFolder = (nodes, slug) => {
|
|
|
5584
5634
|
return roots.find((node) => node.slug === slug && node.type === "folder");
|
|
5585
5635
|
};
|
|
5586
5636
|
var resolveTargetState = async (client, targetFolderSlug) => {
|
|
5587
|
-
const [nodes, bases] = await Promise.all([client.nodes.list(), client.bases.list()]);
|
|
5637
|
+
const [nodes, bases] = await Promise.all([client.nodes.list({}), client.bases.list({})]);
|
|
5588
5638
|
return {
|
|
5589
5639
|
targetFolder: findTargetFolder(nodes, targetFolderSlug),
|
|
5590
5640
|
existingBaseSlugs: new Set(bases.map((base) => base.slug))
|
|
@@ -6377,10 +6427,17 @@ function classifyKind(inner) {
|
|
|
6377
6427
|
function inputFields(inputSchema) {
|
|
6378
6428
|
if (inputSchema === void 0) return [];
|
|
6379
6429
|
const { inner } = unwrapSchema(inputSchema);
|
|
6380
|
-
const shape =
|
|
6381
|
-
if (!shape
|
|
6430
|
+
const shape = objectShape(inner);
|
|
6431
|
+
if (!shape) {
|
|
6382
6432
|
return [{ key: "input", kind: "json", required: true, root: true }];
|
|
6383
6433
|
}
|
|
6434
|
+
return fieldsFromShape(shape);
|
|
6435
|
+
}
|
|
6436
|
+
function objectShape(inner) {
|
|
6437
|
+
const shape = inner?.shape ?? (inner?.def?.type === "object" ? inner.def.shape : void 0);
|
|
6438
|
+
return shape && typeof shape === "object" ? shape : void 0;
|
|
6439
|
+
}
|
|
6440
|
+
function fieldsFromShape(shape) {
|
|
6384
6441
|
const fields = [];
|
|
6385
6442
|
for (const [key, sub] of Object.entries(shape)) {
|
|
6386
6443
|
const { inner: unwrapped, optional } = unwrapSchema(sub);
|
|
@@ -6389,6 +6446,34 @@ function inputFields(inputSchema) {
|
|
|
6389
6446
|
}
|
|
6390
6447
|
return fields;
|
|
6391
6448
|
}
|
|
6449
|
+
function unionVariants(inputSchema, discriminator = "operation") {
|
|
6450
|
+
if (inputSchema === void 0) return null;
|
|
6451
|
+
const { inner } = unwrapSchema(inputSchema);
|
|
6452
|
+
let unionNode = inner;
|
|
6453
|
+
let extraShape = {};
|
|
6454
|
+
if (inner?.def?.type === "intersection") {
|
|
6455
|
+
for (const side of [inner.def.left, inner.def.right]) {
|
|
6456
|
+
const { inner: sideInner } = unwrapSchema(side);
|
|
6457
|
+
const shape = objectShape(sideInner);
|
|
6458
|
+
if (shape) extraShape = { ...extraShape, ...shape };
|
|
6459
|
+
else unionNode = sideInner;
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
const options = unionNode?.def?.options ?? unionNode?.options;
|
|
6463
|
+
if (!Array.isArray(options) || options.length === 0) return null;
|
|
6464
|
+
const variants = [];
|
|
6465
|
+
for (const option of options) {
|
|
6466
|
+
const { inner: optionInner } = unwrapSchema(option);
|
|
6467
|
+
const shape = objectShape(optionInner);
|
|
6468
|
+
if (!shape) return null;
|
|
6469
|
+
const { inner: discInner } = unwrapSchema(shape[discriminator]);
|
|
6470
|
+
const value = discInner?.def?.values?.[0] ?? discInner?.def?.value;
|
|
6471
|
+
if (typeof value !== "string") return null;
|
|
6472
|
+
const { [discriminator]: _pinned, ...rest } = shape;
|
|
6473
|
+
variants.push({ value, fields: fieldsFromShape({ ...rest, ...extraShape }) });
|
|
6474
|
+
}
|
|
6475
|
+
return variants;
|
|
6476
|
+
}
|
|
6392
6477
|
var GENERATED_SKIP = /* @__PURE__ */ new Set([
|
|
6393
6478
|
"search",
|
|
6394
6479
|
// top-level `search`
|
|
@@ -6398,18 +6483,48 @@ var GENERATED_SKIP = /* @__PURE__ */ new Set([
|
|
|
6398
6483
|
// `records by-field-text`
|
|
6399
6484
|
"records.listChangeRequests",
|
|
6400
6485
|
// `records change-requests`
|
|
6401
|
-
|
|
6402
|
-
// `
|
|
6486
|
+
// The `/file-trees` group is exposed by the task layer as `nodes
|
|
6487
|
+
// list-file-trees` / `get-file-tree` / `files` / `read-file` /
|
|
6488
|
+
// `files-change-request`, each taking `--kind` (see tasks/file-tree.ts).
|
|
6489
|
+
"fileTrees.list",
|
|
6490
|
+
"fileTrees.create",
|
|
6491
|
+
"fileTrees.get",
|
|
6492
|
+
"fileTrees.listFiles",
|
|
6493
|
+
"fileTrees.readFile",
|
|
6494
|
+
"fileTrees.createChangeRequest"
|
|
6403
6495
|
]);
|
|
6404
6496
|
function registerGeneratedCommands(program, state) {
|
|
6405
6497
|
const getGroup = (displayName, tag) => program.commands.find((c2) => c2.name() === displayName) ?? program.command(displayName).description(tag ?? `${displayName} endpoints`);
|
|
6406
6498
|
const addLeaf = (parent, navPath, procKey, proc) => {
|
|
6407
6499
|
const { route, inputSchema } = proc["~orpc"];
|
|
6408
|
-
const
|
|
6500
|
+
const baseName = [...navPath.slice(1), procKey].map(kebab).join("-");
|
|
6501
|
+
const variants = unionVariants(inputSchema);
|
|
6502
|
+
if (variants) {
|
|
6503
|
+
for (const variant of variants) {
|
|
6504
|
+
addOneLeaf(
|
|
6505
|
+
parent,
|
|
6506
|
+
navPath,
|
|
6507
|
+
procKey,
|
|
6508
|
+
proc,
|
|
6509
|
+
`${kebab(variant.value)}-${baseName}`,
|
|
6510
|
+
[
|
|
6511
|
+
{ key: "operation", kind: "string", required: true, pinned: variant.value },
|
|
6512
|
+
...variant.fields
|
|
6513
|
+
],
|
|
6514
|
+
// The shared summary describes the merged endpoint; say which branch this is.
|
|
6515
|
+
`${route.summary ?? baseName} \u2014 operation "${variant.value}"`
|
|
6516
|
+
);
|
|
6517
|
+
}
|
|
6518
|
+
return;
|
|
6519
|
+
}
|
|
6520
|
+
addOneLeaf(parent, navPath, procKey, proc, baseName, inputFields(inputSchema));
|
|
6521
|
+
};
|
|
6522
|
+
const addOneLeaf = (parent, navPath, procKey, proc, name, fields, description) => {
|
|
6523
|
+
const { route } = proc["~orpc"];
|
|
6409
6524
|
if (parent.commands.some((c2) => c2.name() === name || c2.aliases().includes(name))) return;
|
|
6410
|
-
const
|
|
6411
|
-
const leaf = parent.command(name).description(route.summary ?? `${route.method} ${route.path}`);
|
|
6525
|
+
const leaf = parent.command(name).description(description ?? route.summary ?? `${route.method} ${route.path}`);
|
|
6412
6526
|
for (const f of fields) {
|
|
6527
|
+
if (f.pinned !== void 0) continue;
|
|
6413
6528
|
const flag = `--${kebab(f.key)}`;
|
|
6414
6529
|
if (GLOBAL_LONG_FLAGS.has(flag)) continue;
|
|
6415
6530
|
if (f.kind === "boolean") {
|
|
@@ -6442,6 +6557,10 @@ OpenAPI: ${route.method} ${route.path}`);
|
|
|
6442
6557
|
runAction(state, (client, opts) => {
|
|
6443
6558
|
let input = {};
|
|
6444
6559
|
for (const f of fields) {
|
|
6560
|
+
if (f.pinned !== void 0) {
|
|
6561
|
+
input[f.key] = f.pinned;
|
|
6562
|
+
continue;
|
|
6563
|
+
}
|
|
6445
6564
|
if (GLOBAL_LONG_FLAGS.has(`--${kebab(f.key)}`)) continue;
|
|
6446
6565
|
const optKey = f.kind === "json" ? `${f.key}Json` : f.key;
|
|
6447
6566
|
const value = opts[optKey];
|
|
@@ -6673,11 +6792,21 @@ Examples:
|
|
|
6673
6792
|
)
|
|
6674
6793
|
);
|
|
6675
6794
|
const bases = program.command("bases").description("Bases (structured tables)");
|
|
6676
|
-
addGlobalFlags(bases.command("list")).description("List Bases in the active space").
|
|
6795
|
+
addGlobalFlags(bases.command("list")).description("List Bases in the active space").addOption(
|
|
6796
|
+
new Option2("--status <active|archived>", "live Bases (default) or archived ones").choices([
|
|
6797
|
+
"active",
|
|
6798
|
+
"archived"
|
|
6799
|
+
])
|
|
6800
|
+
).action(
|
|
6801
|
+
runAction(
|
|
6802
|
+
state,
|
|
6803
|
+
(client, opts) => client.bases.list({ status: opts.status ?? "active" })
|
|
6804
|
+
)
|
|
6805
|
+
);
|
|
6677
6806
|
addGlobalFlags(bases.command("get")).description("Get one Base by slug").requiredOption("--slug <slug>", "Base slug").action(
|
|
6678
6807
|
runAction(state, async (client, opts) => {
|
|
6679
6808
|
const slug = opts.slug;
|
|
6680
|
-
const found = (await client.bases.list()).find((base) => base.slug === slug);
|
|
6809
|
+
const found = (await client.bases.list({})).find((base) => base.slug === slug);
|
|
6681
6810
|
if (!found) throw new Error(`no Base with slug "${slug}"`);
|
|
6682
6811
|
return found;
|
|
6683
6812
|
})
|
|
@@ -6724,7 +6853,8 @@ Examples:
|
|
|
6724
6853
|
"No field patch supplied. Pass --name, --required, --options-json, or attachment option flags."
|
|
6725
6854
|
);
|
|
6726
6855
|
}
|
|
6727
|
-
return client.bases.
|
|
6856
|
+
return client.bases.fieldChangeRequest({
|
|
6857
|
+
operation: "update",
|
|
6728
6858
|
baseId: opts.baseId,
|
|
6729
6859
|
fieldId: opts.fieldId,
|
|
6730
6860
|
patch,
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "busa-cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Command-line client for the Busabase OpenAPI REST API. Talks to a local or remote `busabase server`. Short-name alias for busabase-cli.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/busabase/busabase/tree/main/apps/busabase-cli",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@zip.js/zip.js": "^2.8.20",
|
|
35
35
|
"busabase-package": "workspace:*",
|
|
36
|
-
"busabase-sdk": "0.10.
|
|
36
|
+
"busabase-sdk": "0.10.2",
|
|
37
37
|
"commander": "^14.0.0",
|
|
38
38
|
"tar-stream": "^3.1.7",
|
|
39
39
|
"yaml": "^2.9.0",
|