busa-sdk 0.11.2 → 0.11.4

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/index.d.ts CHANGED
@@ -7967,6 +7967,7 @@ declare const cloudContract: {
7967
7967
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
7968
7968
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
7969
7969
  idempotencyKey: z.ZodOptional<z.ZodString>;
7970
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
7970
7971
  baseId: z.ZodString;
7971
7972
  }, z.core.$strip>, z.ZodObject<{
7972
7973
  id: z.ZodString;
@@ -8706,6 +8707,7 @@ declare const cloudContract: {
8706
8707
  }, z.core.$strip>>>>;
8707
8708
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8708
8709
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8710
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
8709
8711
  baseId: z.ZodString;
8710
8712
  operation: z.ZodLiteral<"create">;
8711
8713
  }, z.core.$strip>, z.ZodObject<{
@@ -8788,12 +8790,14 @@ declare const cloudContract: {
8788
8790
  }, z.core.$strip>;
8789
8791
  message: z.ZodOptional<z.ZodString>;
8790
8792
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8793
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
8791
8794
  baseId: z.ZodString;
8792
8795
  operation: z.ZodLiteral<"update">;
8793
8796
  }, z.core.$strip>, z.ZodObject<{
8794
8797
  fieldId: z.ZodString;
8795
8798
  message: z.ZodOptional<z.ZodString>;
8796
8799
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8800
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
8797
8801
  baseId: z.ZodString;
8798
8802
  operation: z.ZodLiteral<"delete">;
8799
8803
  }, z.core.$strip>, z.ZodObject<{
@@ -8834,18 +8838,21 @@ declare const cloudContract: {
8834
8838
  }>>;
8835
8839
  message: z.ZodOptional<z.ZodString>;
8836
8840
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8841
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
8837
8842
  baseId: z.ZodString;
8838
8843
  operation: z.ZodLiteral<"convert">;
8839
8844
  }, z.core.$strip>, z.ZodObject<{
8840
8845
  fieldIds: z.ZodArray<z.ZodString>;
8841
8846
  message: z.ZodOptional<z.ZodString>;
8842
8847
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8848
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
8843
8849
  baseId: z.ZodString;
8844
8850
  operation: z.ZodLiteral<"reorder">;
8845
8851
  }, z.core.$strip>, z.ZodObject<{
8846
8852
  fieldId: z.ZodString;
8847
8853
  message: z.ZodOptional<z.ZodString>;
8848
8854
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8855
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
8849
8856
  baseId: z.ZodString;
8850
8857
  operation: z.ZodLiteral<"restore">;
8851
8858
  }, z.core.$strip>], "operation">, z.ZodObject<{
@@ -9294,11 +9301,13 @@ declare const cloudContract: {
9294
9301
  lifecycleChangeRequest: _orpc_contract.ContractProcedure<z.ZodDiscriminatedUnion<[z.ZodObject<{
9295
9302
  message: z.ZodOptional<z.ZodString>;
9296
9303
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
9304
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
9297
9305
  baseId: z.ZodString;
9298
9306
  operation: z.ZodLiteral<"archive">;
9299
9307
  }, z.core.$strip>, z.ZodObject<{
9300
9308
  message: z.ZodOptional<z.ZodString>;
9301
9309
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
9310
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
9302
9311
  baseId: z.ZodString;
9303
9312
  operation: z.ZodLiteral<"restore">;
9304
9313
  }, z.core.$strip>], "operation">, z.ZodObject<{
@@ -10233,6 +10242,7 @@ declare const cloudContract: {
10233
10242
  version: z.ZodOptional<z.ZodString>;
10234
10243
  }, z.core.$strip>>;
10235
10244
  }, z.core.$strict>]>>;
10245
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
10236
10246
  nodeId: z.ZodString;
10237
10247
  type: z.ZodOptional<z.ZodEnum<{
10238
10248
  skill: "skill";
@@ -11554,6 +11564,7 @@ declare const cloudContract: {
11554
11564
  body: z.ZodString;
11555
11565
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
11556
11566
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
11567
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
11557
11568
  nodeId: z.ZodString;
11558
11569
  }, z.core.$strip>, z.ZodObject<{
11559
11570
  id: z.ZodString;
@@ -12351,6 +12362,7 @@ declare const cloudContract: {
12351
12362
  }, z.core.$strict>>;
12352
12363
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12353
12364
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12365
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
12354
12366
  }, z.core.$strip>, z.ZodObject<{
12355
12367
  id: z.ZodString;
12356
12368
  baseId: z.ZodNullable<z.ZodString>;
@@ -16993,6 +17005,20 @@ declare const cloudContract: {
16993
17005
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
16994
17006
  count: _orpc_contract.ContractProcedure<z.ZodDefault<z.ZodOptional<z.ZodObject<{
16995
17007
  baseId: z.ZodOptional<z.ZodString>;
17008
+ viewId: z.ZodOptional<z.ZodString>;
17009
+ filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
17010
+ fieldSlug: z.ZodString;
17011
+ fieldType: z.ZodOptional<z.ZodString>;
17012
+ operator: z.ZodEnum<{
17013
+ contains: "contains";
17014
+ equals: "equals";
17015
+ not_empty: "not_empty";
17016
+ is_empty: "is_empty";
17017
+ is_true: "is_true";
17018
+ is_false: "is_false";
17019
+ }>;
17020
+ value: z.ZodOptional<z.ZodUnknown>;
17021
+ }, z.core.$strip>>>;
16996
17022
  }, z.core.$strip>>>, z.ZodObject<{
16997
17023
  total: z.ZodNumber;
16998
17024
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
@@ -17420,11 +17446,13 @@ declare const cloudContract: {
17420
17446
  deleteMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
17421
17447
  archive: "archive";
17422
17448
  }>>>;
17449
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
17423
17450
  recordId: z.ZodString;
17424
17451
  operation: z.ZodLiteral<"delete">;
17425
17452
  }, z.core.$strip>, z.ZodObject<{
17426
17453
  message: z.ZodOptional<z.ZodString>;
17427
17454
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17455
+ autoMerge: z.ZodOptional<z.ZodLiteral<false>>;
17428
17456
  recordId: z.ZodString;
17429
17457
  operation: z.ZodLiteral<"restore">;
17430
17458
  }, z.core.$strip>], "operation">, z.ZodUnion<readonly [z.ZodObject<{
package/dist/index.js CHANGED
@@ -36,6 +36,9 @@ var LocaleSchema = z.enum(i18n.locales);
36
36
  // ../../packages/openlib/i18n/i-string.ts
37
37
  var iStringRecordSchema = z.partialRecord(LocaleSchema, z.string());
38
38
  z.union([z.string(), iStringRecordSchema]).describe("i18n string");
39
+ var autoMergeNotAccepted = (reason) => z.literal(false, { error: `\`autoMerge: true\` is not accepted here: ${reason}` }).optional().describe(`Only \`false\` (or omitted) is accepted. ${reason}`);
40
+
41
+ // ../../packages/busabase-contract/src/domains/base/contract/base-schemas.ts
39
42
  var fieldNameSchema = z.union([
40
43
  z.string().min(1),
41
44
  iStringRecordSchema.refine(
@@ -191,14 +194,21 @@ var createBaseFieldInputSchema = z.object({
191
194
  required: z.boolean().optional().default(false),
192
195
  options: fieldOptionsSchema.optional().default({})
193
196
  });
197
+ var fieldAutoMergeSchema = z.boolean().optional().describe(
198
+ "Whether to approve and merge this field change immediately. Omitted defaults to merging immediately if the actor has write access on the Base's node, otherwise falling back to a pending Change Request; pass explicit false to force review even with write access. Not accepted by the delete and convert operations, which always require review."
199
+ );
194
200
  var createFieldChangeRequestInputSchema = createBaseFieldInputSchema.extend({
195
201
  message: z.string().optional().default("Add field"),
196
- submittedBy: z.string().optional().default("local-editor")
202
+ submittedBy: z.string().optional().default("local-editor"),
203
+ autoMerge: fieldAutoMergeSchema
197
204
  });
198
205
  var deleteFieldChangeRequestInputSchema = z.object({
199
206
  fieldId: z.string().min(1),
200
207
  message: z.string().optional(),
201
- submittedBy: z.string().optional().default("local-editor")
208
+ submittedBy: z.string().optional().default("local-editor"),
209
+ autoMerge: autoMergeNotAccepted(
210
+ "deleting a field soft-deletes its stored values with it, so it always requires review. Omit the flag."
211
+ )
202
212
  });
203
213
  var updateFieldChangeRequestInputSchema = z.object({
204
214
  fieldId: z.string().min(1),
@@ -208,7 +218,8 @@ var updateFieldChangeRequestInputSchema = z.object({
208
218
  options: fieldOptionsSchema.optional()
209
219
  }),
210
220
  message: z.string().optional(),
211
- submittedBy: z.string().optional().default("local-editor")
221
+ submittedBy: z.string().optional().default("local-editor"),
222
+ autoMerge: fieldAutoMergeSchema
212
223
  });
213
224
  var previewFieldConversionInputSchema = z.object({
214
225
  fieldId: z.string().min(1),
@@ -225,25 +236,39 @@ var convertFieldChangeRequestInputSchema = z.object({
225
236
  newType: fieldTypeSchema,
226
237
  selectChoiceMode: z.enum(["auto_create", "null_on_missing"]).default("null_on_missing"),
227
238
  message: z.string().optional(),
228
- submittedBy: z.string().optional().default("local-editor")
239
+ submittedBy: z.string().optional().default("local-editor"),
240
+ autoMerge: autoMergeNotAccepted(
241
+ "converting a field's type can drop values, so it always requires review. Run previewFieldConversion first to see what would change, then omit the flag."
242
+ )
229
243
  });
230
244
  var reorderFieldsChangeRequestInputSchema = z.object({
231
245
  fieldIds: z.array(z.string()).min(1),
232
246
  message: z.string().optional(),
233
- submittedBy: z.string().optional().default("local-editor")
247
+ submittedBy: z.string().optional().default("local-editor"),
248
+ autoMerge: fieldAutoMergeSchema
234
249
  });
235
250
  var archiveBaseInputSchema = z.object({
236
251
  message: z.string().optional(),
237
- submittedBy: z.string().optional().default("local-editor")
252
+ submittedBy: z.string().optional().default("local-editor"),
253
+ autoMerge: autoMergeNotAccepted(
254
+ "archiving a Base removes it and every record in it from every listing at once, so it always requires review. Omit the flag."
255
+ )
238
256
  });
239
257
  var restoreBaseInputSchema = z.object({
240
258
  message: z.string().optional(),
241
- submittedBy: z.string().optional().default("local-editor")
259
+ submittedBy: z.string().optional().default("local-editor"),
260
+ // Restoring an archived Base is the undo of a destructive act — nothing is at
261
+ // risk, so it takes the same permission-aware default as everything else.
262
+ // `archiveBaseInputSchema` above deliberately has no `autoMerge`: archiving
263
+ // takes a whole Base and every record in it out of every listing at once,
264
+ // which is strictly larger than the record `delete` that is already review-only.
265
+ autoMerge: z.boolean().optional()
242
266
  });
243
267
  var restoreFieldChangeRequestInputSchema = z.object({
244
268
  fieldId: z.string().min(1),
245
269
  message: z.string().optional(),
246
- submittedBy: z.string().optional().default("local-editor")
270
+ submittedBy: z.string().optional().default("local-editor"),
271
+ autoMerge: fieldAutoMergeSchema
247
272
  });
248
273
  var withBaseId = { baseId: z.string().min(1) };
249
274
  var fieldChangeRequestInputSchema = z.discriminatedUnion("operation", [
@@ -900,7 +925,10 @@ var createDeleteChangeRequestInputSchema = z.object({
900
925
  submittedBy: z.string().optional().default("local-producer"),
901
926
  // Only "archive" is supported — hard delete after retention was never
902
927
  // implemented, so the API no longer accepts it (breaking change).
903
- deleteMode: z.enum(["archive"]).optional().default("archive")
928
+ deleteMode: z.enum(["archive"]).optional().default("archive"),
929
+ autoMerge: autoMergeNotAccepted(
930
+ "archiving a record removes user content from every listing, so it always requires review. Omit the flag."
931
+ )
904
932
  });
905
933
  var reviseOperationInputSchema = z.object({
906
934
  fields: z.record(z.string(), z.unknown()).describe(
@@ -1124,7 +1152,16 @@ var createFileTreeChangeRequestInputSchema = z.object({
1124
1152
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Rewrite README.md quickstart for the new auth flow".'
1125
1153
  ),
1126
1154
  submittedBy: z.string().optional().default("local-producer"),
1127
- operations: z.array(fileTreeFileOperationInputSchema).min(1)
1155
+ operations: z.array(fileTreeFileOperationInputSchema).min(1),
1156
+ // Honoured only when EVERY operation in the batch is non-destructive
1157
+ // (create / update / metadata_update). A batch containing a `delete` stays
1158
+ // review-first no matter what this says, because deleting a mounted file
1159
+ // destroys content — the same line that keeps record `delete` review-only.
1160
+ // Server-side enforcement lives in the filetree handler, not here: the check
1161
+ // is over the operations array, which a per-field schema cannot express.
1162
+ autoMerge: z.boolean().optional().describe(
1163
+ "Whether to approve and merge these file changes immediately. Omitted defaults to merging immediately if the actor has write access on the node, otherwise falling back to a pending Change Request; pass explicit false to force review even with write access. IGNORED when any operation is a delete \u2014 those batches always require review."
1164
+ )
1128
1165
  });
1129
1166
  var FILE_TREE_NODE_TYPES = ["skill", "drive", "airapp"];
1130
1167
  var fileTreeNodeTypeSchema = z.enum(FILE_TREE_NODE_TYPES);
@@ -1408,7 +1445,10 @@ var EditAssetContentInputSchema = z.object({
1408
1445
  message: z.string().optional().default("Edit file content").describe(
1409
1446
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Fix typo in setup instructions".'
1410
1447
  ),
1411
- submittedBy: z.string().optional().default("agent")
1448
+ submittedBy: z.string().optional().default("agent"),
1449
+ autoMerge: autoMergeNotAccepted(
1450
+ "editContent rewrites the real mounted file bytes, so it always requires review. Omit the flag."
1451
+ )
1412
1452
  });
1413
1453
  var AssetDownloadInputSchema = z.object({ assetId: z.string() });
1414
1454
  var AssetDownloadVOSchema = z.object({
@@ -1691,9 +1731,42 @@ var listRecordsPageResponseSchema = z.object({
1691
1731
  page: z.number().int().min(1),
1692
1732
  pageSize: z.number().int().min(1).max(100)
1693
1733
  });
1694
- var countRecordsInputSchema = z.object({
1695
- baseId: z.string().optional()
1696
- }).optional().default({});
1734
+ var countRecordsShapeSchema = z.object({
1735
+ baseId: z.string().optional(),
1736
+ /**
1737
+ * Count only the rows a saved View would display (the View's filters
1738
+ * applied; its sort is ignored — a count doesn't need an order). A View
1739
+ * belongs to exactly one Base, so this requires `baseId`.
1740
+ */
1741
+ viewId: z.string().optional(),
1742
+ /**
1743
+ * Ad-hoc filter conditions — same shape `records.list`'s `filters` uses —
1744
+ * for composing a condition set without a saved View (e.g. an AirApp
1745
+ * summary tile like "main-branch PRs"). Combined with the View's own
1746
+ * filters (AND) when `viewId` is also given. Requires `baseId`: a field
1747
+ * slug is only unambiguous within one Base, and proving a filter exact
1748
+ * (see `countRecords`) requires that Base's real field definitions —
1749
+ * never the caller-supplied `fieldType` hint, which elsewhere is only a
1750
+ * pushdown hint and isn't trustworthy enough for an exact count.
1751
+ */
1752
+ filters: z.array(listRecordsFilterSchema).optional()
1753
+ }).superRefine((value, ctx) => {
1754
+ if (value.viewId && !value.baseId) {
1755
+ ctx.addIssue({
1756
+ code: "custom",
1757
+ path: ["baseId"],
1758
+ message: "baseId is required when viewId is given"
1759
+ });
1760
+ }
1761
+ if (value.filters?.length && !value.baseId) {
1762
+ ctx.addIssue({
1763
+ code: "custom",
1764
+ path: ["baseId"],
1765
+ message: "baseId is required when filters is given"
1766
+ });
1767
+ }
1768
+ });
1769
+ var countRecordsInputSchema = countRecordsShapeSchema.optional().default({});
1697
1770
  var countRecordsResponseSchema = z.object({
1698
1771
  /** Total active records in the space (optionally scoped to a base). */
1699
1772
  total: z.number().int().nonnegative()
@@ -1728,7 +1801,13 @@ var createBulkChangeRequestInputSchema = z.object({
1728
1801
  submittedBy: z.string().optional().default("local-producer"),
1729
1802
  idempotencyKey: z.string().optional().describe(
1730
1803
  "Optional client-supplied key that dedupes retries. Scoped per base + submitter: calling this endpoint again with the SAME idempotencyKey returns the bulk change request created by the first call instead of creating a duplicate. Omit for normal one-shot calls; only set it when you might retry."
1731
- )
1804
+ ),
1805
+ // Same permission-aware tri-state as the single-record endpoint above. N record
1806
+ // CREATES are purely additive, so there is nothing here the review gate is
1807
+ // protecting — and until now the published skill doc told agents to send N
1808
+ // separate single-record calls precisely because this one could not merge,
1809
+ // which is slower and produces N change requests instead of one.
1810
+ autoMerge: z.boolean().optional()
1732
1811
  });
1733
1812
  var recordFieldFilterInputSchema = z.object({
1734
1813
  baseId: z.string().optional(),
@@ -1749,7 +1828,10 @@ var recordGetInputSchema = z.union([
1749
1828
  ]);
1750
1829
  var restoreRecordInputSchema = z.object({
1751
1830
  message: z.string().optional(),
1752
- submittedBy: z.string().optional().default("local-editor")
1831
+ submittedBy: z.string().optional().default("local-editor"),
1832
+ autoMerge: autoMergeNotAccepted(
1833
+ "restoring a record brings archived content back into every listing, so it always requires review. Omit the flag."
1834
+ )
1753
1835
  });
1754
1836
  var withRecordId = { recordId: z.string().min(1) };
1755
1837
  var recordChangeRequestInputSchema = z.discriminatedUnion("operation", [
@@ -1887,7 +1969,8 @@ var recordContract = {
1887
1969
  path: "/records/count",
1888
1970
  tags: ["Records"],
1889
1971
  summary: "Count records",
1890
- successDescription: "Total active records in the space, optionally scoped to a base."
1972
+ description: "A real SQL COUNT \u2014 always the exact total, never a partial or capped number, so it's safe to render as a canonical figure (e.g. a dashboard summary tile). Plain `baseId` scoping is always cheap. Adding `viewId` and/or `filters` is exact too \u2014 provably-exact conditions (e.g. text equals/contains, not_empty/is_empty, checkbox is_true/is_false) stay a cheap SQL COUNT; everything else falls back to evaluating every matching row server-side, which is exact but not free on a large Base. Both `viewId` and `filters` require `baseId`.",
1973
+ successDescription: "Total active records matching the scope: the whole space, one Base, a saved View, an ad-hoc filter set, or a combination."
1891
1974
  }).input(countRecordsInputSchema).output(countRecordsResponseSchema),
1892
1975
  get: oc.route({
1893
1976
  method: "GET",
@@ -1982,7 +2065,12 @@ var createDocChangeRequestInputSchema = z.object({
1982
2065
  message: z.string().optional().default("Update doc").describe(
1983
2066
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Add rollback steps to the deploy runbook".'
1984
2067
  ),
1985
- submittedBy: z.string().optional().default("local-producer")
2068
+ submittedBy: z.string().optional().default("local-producer"),
2069
+ // A Doc body update is the Doc-domain twin of a record `update`, which has taken
2070
+ // the permission-aware default since #5712 — and this node type already has a
2071
+ // direct-write bypass (`PUT /docs/{nodeId}/body`), so review-first here was never
2072
+ // an actual guarantee, just a slower path to the same place.
2073
+ autoMerge: z.boolean().optional()
1986
2074
  });
1987
2075
  var docContract = {
1988
2076
  create: oc.route({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busa-sdk",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "Typed TypeScript/JavaScript SDK for the Busabase OpenAPI REST API. Talks to a local or remote `busabase server` (or Busabase Cloud). Short-name alias for busabase-sdk.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/busabase/busabase/tree/main/apps/busabase-sdk",