busabase-sdk 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +1088 -3
  2. package/dist/index.js +222 -77
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -170,6 +170,7 @@ var fieldTypeSchema = z.enum([
170
170
  "select",
171
171
  "multiselect",
172
172
  "url",
173
+ "embed",
173
174
  "email",
174
175
  "phone",
175
176
  "created_time",
@@ -207,6 +208,11 @@ var fieldOptionsSchema = z.object({
207
208
  code: z.object({
208
209
  language: z.string().optional()
209
210
  }).optional(),
211
+ embed: z.object({
212
+ aspectRatio: z.enum(["16:9", "4:3", "1:1"]).optional(),
213
+ height: z.number().int().positive().max(1200).optional(),
214
+ providers: z.array(z.string()).optional()
215
+ }).optional(),
210
216
  inverseFieldId: z.string().optional(),
211
217
  multiple: z.boolean().optional(),
212
218
  // Display formatting for `number` columns (Notion-style: one number type,
@@ -629,20 +635,21 @@ var commentSchema = z.object({
629
635
  createdAt: z.string(),
630
636
  updatedAt: z.string()
631
637
  });
638
+ var changeRequestStatusSchema = z.enum([
639
+ "in_review",
640
+ "changes_requested",
641
+ "approved",
642
+ "rejected",
643
+ "merged",
644
+ "abandoned",
645
+ "conflict"
646
+ ]);
632
647
  var changeRequestSchema = z.object({
633
648
  id: z.string(),
634
649
  baseId: z.string().nullable(),
635
650
  targetType: z.enum(["base", "node"]),
636
651
  nodeId: z.string().nullable(),
637
- status: z.enum([
638
- "in_review",
639
- "changes_requested",
640
- "approved",
641
- "rejected",
642
- "merged",
643
- "abandoned",
644
- "conflict"
645
- ]),
652
+ status: changeRequestStatusSchema,
646
653
  submittedBy: z.string(),
647
654
  submittedByUser: userRefSchema.nullable().optional().default(null),
648
655
  sourceMeta: z.record(z.string(), z.unknown()),
@@ -838,6 +845,25 @@ var createCommentInputSchema = commentSubjectInputSchema.extend({
838
845
  var listInputSchema = z.object({
839
846
  limit: z.coerce.number().int().min(1).max(100).optional().default(50)
840
847
  }).optional().default({ limit: 50 });
848
+ var listChangeRequestsPagedInputSchema = z.object({
849
+ limit: z.coerce.number().int().min(1).max(100).optional().default(50),
850
+ /** Opaque base64 cursor (`createdAt|id`) for keyset pagination. */
851
+ cursor: z.string().optional(),
852
+ status: z.array(changeRequestStatusSchema).optional(),
853
+ mine: z.boolean().optional()
854
+ }).optional().default({ limit: 50 });
855
+ var listChangeRequestsResponseSchema = z.object({
856
+ changeRequests: z.array(changeRequestSchema),
857
+ nextCursor: z.string().nullable()
858
+ });
859
+ var changeRequestCountsSchema = z.object({
860
+ review: z.number().int().nonnegative(),
861
+ changes: z.number().int().nonnegative(),
862
+ created: z.number().int().nonnegative(),
863
+ approved: z.number().int().nonnegative(),
864
+ merged: z.number().int().nonnegative(),
865
+ rejected: z.number().int().nonnegative()
866
+ });
841
867
  var searchInputSchema = z.object({
842
868
  query: z.string().default(""),
843
869
  limit: z.coerce.number().int().min(1).max(100).optional().default(20),
@@ -872,6 +898,69 @@ var authInfoSchema = z.object({
872
898
  */
873
899
  spaces: z.array(authSpaceSchema)
874
900
  });
901
+ var viewFilterOperatorSchema = z.enum([
902
+ "contains",
903
+ "equals",
904
+ "not_empty",
905
+ "is_empty",
906
+ "is_true",
907
+ "is_false"
908
+ ]);
909
+ var viewFilterSchema = z.object({
910
+ fieldSlug: z.string(),
911
+ // Stable field identity — survives slug reuse; populated on merge.
912
+ fieldId: z.string().optional(),
913
+ operator: viewFilterOperatorSchema,
914
+ value: z.unknown().optional()
915
+ });
916
+ var viewSortSchema = z.object({
917
+ direction: z.enum(["asc", "desc"]),
918
+ fieldSlug: z.string(),
919
+ fieldId: z.string().optional()
920
+ });
921
+ var viewConfigSchema = z.object({
922
+ filters: z.array(viewFilterSchema).default([]),
923
+ sorts: z.array(viewSortSchema).default([]),
924
+ visibleFieldSlugs: z.array(z.string()).nullable().optional()
925
+ });
926
+ var viewSchema = z.object({
927
+ id: z.string(),
928
+ baseId: z.string(),
929
+ slug: z.string(),
930
+ name: z.string(),
931
+ description: z.string(),
932
+ type: z.literal("table"),
933
+ config: viewConfigSchema,
934
+ status: z.enum(["active", "archived"]),
935
+ createdBy: z.string(),
936
+ createdByUser: userRefSchema.nullable().optional().default(null),
937
+ archivedAt: z.string().nullable(),
938
+ createdAt: z.string(),
939
+ updatedAt: z.string()
940
+ });
941
+ var createViewInputSchema = z.object({
942
+ config: viewConfigSchema.optional().default({ filters: [], sorts: [] }),
943
+ description: z.string().optional().default(""),
944
+ message: z.string().optional().default("Create view"),
945
+ name: z.string().min(1),
946
+ slug: z.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
947
+ submittedBy: z.string().optional().default("local-producer")
948
+ });
949
+ var updateViewInputSchema = z.object({
950
+ config: viewConfigSchema.optional(),
951
+ description: z.string().optional(),
952
+ message: z.string().optional().default("Update view"),
953
+ name: z.string().min(1).optional(),
954
+ submittedBy: z.string().optional().default("local-producer")
955
+ });
956
+ var deleteViewInputSchema = z.object({
957
+ message: z.string().optional().default("Delete view"),
958
+ submittedBy: z.string().optional().default("local-producer")
959
+ });
960
+ var restoreViewInputSchema = z.object({
961
+ message: z.string().optional().default("Restore view"),
962
+ submittedBy: z.string().optional().default("local-producer")
963
+ });
875
964
 
876
965
  // ../../packages/busabase-contract/src/domains/base/contract/record-schemas.ts
877
966
  var recordSchema = z.object({
@@ -889,16 +978,38 @@ var recordSchema = z.object({
889
978
  base: baseSchema,
890
979
  headCommit: commitSchema
891
980
  });
981
+ var listRecordsFilterSchema = z.object({
982
+ fieldSlug: z.string(),
983
+ fieldType: z.string().optional(),
984
+ operator: viewFilterOperatorSchema,
985
+ value: z.unknown().optional()
986
+ });
987
+ var listRecordsSortSchema = z.object({
988
+ fieldSlug: z.string(),
989
+ fieldType: z.string().optional(),
990
+ direction: z.enum(["asc", "desc"]).optional().default("asc")
991
+ });
892
992
  var listRecordsInputSchema = z.object({
893
993
  limit: z.coerce.number().int().min(1).max(100).optional().default(50),
894
994
  baseId: z.string().optional(),
895
- /** Opaque base64 cursor (`createdAt:id`) for keyset pagination. */
896
- cursor: z.string().optional()
995
+ /** Opaque base64 cursor for keyset pagination (createdAt-keyed, or sort-keyed when `sort` is set). */
996
+ cursor: z.string().optional(),
997
+ /** View filters for server-side push-down (superset; client still narrows). */
998
+ filters: z.array(listRecordsFilterSchema).optional(),
999
+ /** View sort for server-side push-down (number/date fields only). */
1000
+ sort: listRecordsSortSchema.optional()
897
1001
  }).optional().default({ limit: 50 });
898
1002
  var listRecordsResponseSchema = z.object({
899
1003
  records: z.array(recordSchema),
900
1004
  nextCursor: z.string().nullable()
901
1005
  });
1006
+ var countRecordsInputSchema = z.object({
1007
+ baseId: z.string().optional()
1008
+ }).optional().default({});
1009
+ var countRecordsResponseSchema = z.object({
1010
+ /** Total active records in the space (optionally scoped to a base). */
1011
+ total: z.number().int().nonnegative()
1012
+ });
902
1013
  var createChangeRequestInputSchema = z.object({
903
1014
  fields: z.record(z.string(), z.unknown()).describe(
904
1015
  "Record field values keyed by field slug. The base's PRIMARY field (its first field) becomes the record's display name and the change request title everywhere \u2014 always give it a short, human-readable value, never an id or placeholder."
@@ -940,71 +1051,6 @@ var recordLinkSchema = z.object({
940
1051
  createdAt: z.string(),
941
1052
  updatedAt: z.string()
942
1053
  });
943
- var viewFilterOperatorSchema = z.enum([
944
- "contains",
945
- "equals",
946
- "not_empty",
947
- "is_empty",
948
- "is_true",
949
- "is_false"
950
- ]);
951
- var viewFilterSchema = z.object({
952
- fieldSlug: z.string(),
953
- // Stable field identity — survives slug reuse; populated on merge.
954
- fieldId: z.string().optional(),
955
- operator: viewFilterOperatorSchema,
956
- value: z.unknown().optional()
957
- });
958
- var viewSortSchema = z.object({
959
- direction: z.enum(["asc", "desc"]),
960
- fieldSlug: z.string(),
961
- fieldId: z.string().optional()
962
- });
963
- var viewConfigSchema = z.object({
964
- filters: z.array(viewFilterSchema).default([]),
965
- sorts: z.array(viewSortSchema).default([]),
966
- visibleFieldSlugs: z.array(z.string()).nullable().optional()
967
- });
968
- var viewSchema = z.object({
969
- id: z.string(),
970
- baseId: z.string(),
971
- slug: z.string(),
972
- name: z.string(),
973
- description: z.string(),
974
- type: z.literal("table"),
975
- config: viewConfigSchema,
976
- status: z.enum(["active", "archived"]),
977
- createdBy: z.string(),
978
- createdByUser: userRefSchema.nullable().optional().default(null),
979
- archivedAt: z.string().nullable(),
980
- createdAt: z.string(),
981
- updatedAt: z.string()
982
- });
983
- var createViewInputSchema = z.object({
984
- config: viewConfigSchema.optional().default({ filters: [], sorts: [] }),
985
- description: z.string().optional().default(""),
986
- message: z.string().optional().default("Create view"),
987
- name: z.string().min(1),
988
- slug: z.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
989
- submittedBy: z.string().optional().default("local-producer")
990
- });
991
- var updateViewInputSchema = z.object({
992
- config: viewConfigSchema.optional(),
993
- description: z.string().optional(),
994
- message: z.string().optional().default("Update view"),
995
- name: z.string().min(1).optional(),
996
- submittedBy: z.string().optional().default("local-producer")
997
- });
998
- var deleteViewInputSchema = z.object({
999
- message: z.string().optional().default("Delete view"),
1000
- submittedBy: z.string().optional().default("local-producer")
1001
- });
1002
- var restoreViewInputSchema = z.object({
1003
- message: z.string().optional().default("Restore view"),
1004
- submittedBy: z.string().optional().default("local-producer")
1005
- });
1006
-
1007
- // ../../packages/busabase-contract/src/domains/base/contract/routes.ts
1008
1054
  var baseContract = {
1009
1055
  list: oc.route({
1010
1056
  method: "GET",
@@ -1169,6 +1215,13 @@ var recordContract = {
1169
1215
  summary: "List records with keyset pagination",
1170
1216
  successDescription: "A page of canonical records plus an opaque nextCursor (null at the end)."
1171
1217
  }).input(listRecordsInputSchema).output(listRecordsResponseSchema),
1218
+ count: oc.route({
1219
+ method: "GET",
1220
+ path: "/records/count",
1221
+ tags: ["Records"],
1222
+ summary: "Count records",
1223
+ successDescription: "Total active records in the space, optionally scoped to a base."
1224
+ }).input(countRecordsInputSchema).output(countRecordsResponseSchema),
1172
1225
  get: oc.route({
1173
1226
  method: "GET",
1174
1227
  path: "/records/{recordId}",
@@ -1501,6 +1554,82 @@ var folderContract = {
1501
1554
 
1502
1555
  // ../../packages/busabase-contract/src/domains/skill/contract.ts
1503
1556
  var skillContract = makeFileTreeContract("skills", "Skills");
1557
+ var VaultItemKeySchema = z.string().trim().min(1).max(128).regex(/^[A-Z_][A-Z0-9_]*$/, "Use uppercase letters, numbers, and underscores");
1558
+ var VaultItemValueSchema = z.string().max(8192);
1559
+ var VaultItemKindSchema = z.enum(["secret", "variable"]);
1560
+ var VaultScopeTypeSchema = z.enum([
1561
+ "personal",
1562
+ "workspace",
1563
+ "base",
1564
+ "agent",
1565
+ "tool",
1566
+ "api_key"
1567
+ ]);
1568
+ var VaultEnvironmentSchema = z.enum(["local", "development", "staging", "production"]);
1569
+ var VaultAccessPolicySchema = z.object({
1570
+ runtime: z.boolean().default(true),
1571
+ reveal: z.boolean().default(true),
1572
+ edit: z.boolean().default(true),
1573
+ share: z.boolean().default(false)
1574
+ });
1575
+ var VaultItemInputSchema = z.object({
1576
+ id: z.string().optional(),
1577
+ kind: VaultItemKindSchema,
1578
+ key: VaultItemKeySchema,
1579
+ value: VaultItemValueSchema,
1580
+ scopeType: VaultScopeTypeSchema.default("personal"),
1581
+ scopeId: z.string().trim().nullable().optional(),
1582
+ environment: VaultEnvironmentSchema.default("local"),
1583
+ description: z.string().trim().max(512).default(""),
1584
+ access: VaultAccessPolicySchema.default({
1585
+ runtime: true,
1586
+ reveal: true,
1587
+ edit: true,
1588
+ share: false
1589
+ })
1590
+ });
1591
+ var UpdateVaultSettingsInputSchema = z.object({
1592
+ items: z.array(VaultItemInputSchema).max(200)
1593
+ });
1594
+ var VaultItemVOSchema = VaultItemInputSchema.extend({
1595
+ id: z.string(),
1596
+ scopeId: z.string().nullable(),
1597
+ updatedAt: z.string(),
1598
+ createdAt: z.string(),
1599
+ lastUsedAt: z.string().nullable()
1600
+ });
1601
+ var VaultSettingsVOSchema = z.object({
1602
+ ownerId: z.string().nullable(),
1603
+ items: z.array(VaultItemVOSchema),
1604
+ updatedAt: z.string().nullable()
1605
+ });
1606
+ z.record(VaultItemKeySchema, VaultItemValueSchema).default({});
1607
+ var VaultSuccessSchema = z.object({ success: z.boolean() });
1608
+
1609
+ // ../../packages/busabase-contract/src/domains/vault/contract.ts
1610
+ var vaultContract = {
1611
+ get: oc.route({
1612
+ method: "GET",
1613
+ path: "/vault",
1614
+ tags: ["Vault"],
1615
+ summary: "Get local Vault settings",
1616
+ successDescription: "Local Vault secrets and variables for this Busabase instance."
1617
+ }).output(VaultSettingsVOSchema),
1618
+ update: oc.route({
1619
+ method: "PUT",
1620
+ path: "/vault",
1621
+ tags: ["Vault"],
1622
+ summary: "Replace local Vault settings",
1623
+ successDescription: "Updated local Vault secrets and variables."
1624
+ }).input(UpdateVaultSettingsInputSchema).output(VaultSettingsVOSchema),
1625
+ clear: oc.route({
1626
+ method: "DELETE",
1627
+ path: "/vault",
1628
+ tags: ["Vault"],
1629
+ summary: "Clear local Vault settings",
1630
+ successDescription: "Removed local Vault secrets and variables."
1631
+ }).output(VaultSuccessSchema)
1632
+ };
1504
1633
 
1505
1634
  // ../../packages/busabase-contract/src/contract/busabase.ts
1506
1635
  var changeRequestBatchResultSchema = z.object({
@@ -1613,6 +1742,7 @@ var busabaseContractRoutes = {
1613
1742
  docs: docContract,
1614
1743
  folders: folderContract,
1615
1744
  assets: assetsContract,
1745
+ vault: vaultContract,
1616
1746
  changeRequests: {
1617
1747
  list: oc.route({
1618
1748
  method: "GET",
@@ -1621,6 +1751,20 @@ var busabaseContractRoutes = {
1621
1751
  summary: "List change requests",
1622
1752
  successDescription: "Change requests waiting for review or ready to merge."
1623
1753
  }).input(listInputSchema).output(z.array(changeRequestSchema)),
1754
+ listPaged: oc.route({
1755
+ method: "GET",
1756
+ path: "/change-requests/paged",
1757
+ tags: ["Change Requests"],
1758
+ summary: "List change requests with keyset pagination",
1759
+ successDescription: "A page of change requests plus an opaque nextCursor (null at the end). Filter with `status` and/or `mine`."
1760
+ }).input(listChangeRequestsPagedInputSchema).output(listChangeRequestsResponseSchema),
1761
+ counts: oc.route({
1762
+ method: "GET",
1763
+ path: "/change-requests/counts",
1764
+ tags: ["Change Requests"],
1765
+ summary: "Count change requests by inbox tab",
1766
+ successDescription: "Whole-space change request counts per inbox tab (review / changes / created / approved / merged / rejected)."
1767
+ }).output(changeRequestCountsSchema),
1624
1768
  get: oc.route({
1625
1769
  method: "GET",
1626
1770
  path: "/change-requests/{changeRequestId}",
@@ -1742,6 +1886,7 @@ var notFoundErrors = {
1742
1886
  data: ErrorResponseSchema
1743
1887
  }
1744
1888
  };
1889
+ var { vault: _localVault, ...cloudWorkbenchRoutes } = busabaseContractRoutes;
1745
1890
  var cloudExtraRoutes = {
1746
1891
  system: {
1747
1892
  health: oc.route({
@@ -1822,7 +1967,7 @@ var cloudExtraRoutes = {
1822
1967
  }
1823
1968
  };
1824
1969
  var cloudContract = oc.prefix("/api/v1").router({
1825
- ...busabaseContractRoutes,
1970
+ ...cloudWorkbenchRoutes,
1826
1971
  ...cloudExtraRoutes
1827
1972
  });
1828
1973
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busabase-sdk",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Typed TypeScript/JavaScript SDK for the Busabase OpenAPI REST API. Talks to a local or remote `busabase server` (or Busabase Cloud).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/busabase/busabase/tree/main/apps/busabase-sdk",
@@ -41,9 +41,9 @@
41
41
  "tsx": "^4.20.5",
42
42
  "typescript": "^5.9.3",
43
43
  "vitest": "^2.1.8",
44
+ "busabase-contract": "0.9.3",
44
45
  "open-domains": "0.0.1",
45
- "openlib": "0.1.0",
46
- "busabase-contract": "0.9.2"
46
+ "openlib": "0.1.0"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=24.18.0"