busa-sdk 0.9.9 → 0.9.10

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
@@ -251,7 +251,7 @@ interface NodeOutput {
251
251
  slug: string;
252
252
  name: string;
253
253
  description: string;
254
- metadata: {
254
+ metadata: Record<string, unknown> & {
255
255
  entryFile?: string;
256
256
  visibility?: "private" | "workspace" | "public";
257
257
  version?: string;
@@ -393,6 +393,8 @@ declare const cloudContract: {
393
393
  slug: z.ZodNullable<z.ZodString>;
394
394
  plan: z.ZodNullable<z.ZodString>;
395
395
  }, z.core.$strip>>;
396
+ createdSpace: z.ZodOptional<z.ZodBoolean>;
397
+ bootstrapRequired: z.ZodOptional<z.ZodBoolean>;
396
398
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
397
399
  };
398
400
  search: _orpc_contract.ContractProcedure<z.ZodObject<{
@@ -1413,6 +1415,10 @@ declare const cloudContract: {
1413
1415
  createdAt: z.ZodString;
1414
1416
  }, z.core.$strip>>;
1415
1417
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
1418
+ updateMetadata: _orpc_contract.ContractProcedure<z.ZodObject<{
1419
+ nodeId: z.ZodString;
1420
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1421
+ }, z.core.$strip>, z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
1416
1422
  purge: _orpc_contract.ContractProcedure<z.ZodObject<{
1417
1423
  nodeId: z.ZodString;
1418
1424
  }, z.core.$strip>, z.ZodObject<{
@@ -1508,6 +1514,7 @@ declare const cloudContract: {
1508
1514
  "asset.metadata_updated": "asset.metadata_updated";
1509
1515
  "asset.text_written": "asset.text_written";
1510
1516
  "asset.text_marked_none": "asset.text_marked_none";
1517
+ "node.metadata_updated": "node.metadata_updated";
1511
1518
  "node.purged": "node.purged";
1512
1519
  }>;
1513
1520
  actorId: z.ZodString;
@@ -1546,6 +1553,7 @@ declare const cloudContract: {
1546
1553
  "asset.metadata_updated": "asset.metadata_updated";
1547
1554
  "asset.text_written": "asset.text_written";
1548
1555
  "asset.text_marked_none": "asset.text_marked_none";
1556
+ "node.metadata_updated": "node.metadata_updated";
1549
1557
  "node.purged": "node.purged";
1550
1558
  }>;
1551
1559
  actorId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -1576,6 +1584,7 @@ declare const cloudContract: {
1576
1584
  "asset.metadata_updated": "asset.metadata_updated";
1577
1585
  "asset.text_written": "asset.text_written";
1578
1586
  "asset.text_marked_none": "asset.text_marked_none";
1587
+ "node.metadata_updated": "node.metadata_updated";
1579
1588
  "node.purged": "node.purged";
1580
1589
  }>;
1581
1590
  actorId: z.ZodString;
@@ -2562,6 +2571,7 @@ declare const cloudContract: {
2562
2571
  "asset.metadata_updated": "asset.metadata_updated";
2563
2572
  "asset.text_written": "asset.text_written";
2564
2573
  "asset.text_marked_none": "asset.text_marked_none";
2574
+ "node.metadata_updated": "node.metadata_updated";
2565
2575
  "node.purged": "node.purged";
2566
2576
  }>;
2567
2577
  actorId: z.ZodString;
@@ -14792,6 +14802,91 @@ declare const cloudContract: {
14792
14802
  ok: z.ZodBoolean;
14793
14803
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
14794
14804
  };
14805
+ install: {
14806
+ planFromGithub: _orpc_contract.ContractProcedure<z.ZodObject<{
14807
+ repoUrl: z.ZodString;
14808
+ intoFolder: z.ZodOptional<z.ZodString>;
14809
+ rename: z.ZodOptional<z.ZodBoolean>;
14810
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
14811
+ }, z.core.$strip>, z.ZodObject<{
14812
+ package: z.ZodObject<{
14813
+ name: z.ZodString;
14814
+ description: z.ZodDefault<z.ZodString>;
14815
+ version: z.ZodOptional<z.ZodString>;
14816
+ author: z.ZodOptional<z.ZodString>;
14817
+ license: z.ZodOptional<z.ZodString>;
14818
+ homepage: z.ZodOptional<z.ZodString>;
14819
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
14820
+ }, z.core.$strip>;
14821
+ source: z.ZodObject<{
14822
+ owner: z.ZodString;
14823
+ repo: z.ZodString;
14824
+ ref: z.ZodOptional<z.ZodString>;
14825
+ subdir: z.ZodOptional<z.ZodString>;
14826
+ }, z.core.$strip>;
14827
+ targetFolderSlug: z.ZodString;
14828
+ nodes: z.ZodDefault<z.ZodArray<z.ZodObject<{
14829
+ path: z.ZodString;
14830
+ slug: z.ZodString;
14831
+ name: z.ZodString;
14832
+ type: z.ZodEnum<{
14833
+ file: "file";
14834
+ base: "base";
14835
+ folder: "folder";
14836
+ skill: "skill";
14837
+ drive: "drive";
14838
+ airapp: "airapp";
14839
+ doc: "doc";
14840
+ }>;
14841
+ depth: z.ZodNumber;
14842
+ fieldCount: z.ZodOptional<z.ZodNumber>;
14843
+ recordCount: z.ZodOptional<z.ZodNumber>;
14844
+ fileCount: z.ZodOptional<z.ZodNumber>;
14845
+ }, z.core.$strip>>>;
14846
+ counts: z.ZodObject<{
14847
+ folders: z.ZodNumber;
14848
+ docs: z.ZodNumber;
14849
+ bases: z.ZodNumber;
14850
+ records: z.ZodNumber;
14851
+ skills: z.ZodNumber;
14852
+ airapps: z.ZodNumber;
14853
+ drives: z.ZodNumber;
14854
+ files: z.ZodNumber;
14855
+ }, z.core.$strip>;
14856
+ collisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
14857
+ kind: z.ZodEnum<{
14858
+ base: "base";
14859
+ node: "node";
14860
+ }>;
14861
+ slug: z.ZodString;
14862
+ path: z.ZodString;
14863
+ renamedTo: z.ZodOptional<z.ZodString>;
14864
+ }, z.core.$strip>>>;
14865
+ warnings: z.ZodDefault<z.ZodArray<z.ZodString>>;
14866
+ requiresAutoMerge: z.ZodBoolean;
14867
+ applicable: z.ZodBoolean;
14868
+ }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
14869
+ fromGithub: _orpc_contract.ContractProcedure<z.ZodObject<{
14870
+ repoUrl: z.ZodString;
14871
+ intoFolder: z.ZodOptional<z.ZodString>;
14872
+ rename: z.ZodOptional<z.ZodBoolean>;
14873
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
14874
+ }, z.core.$strip>, z.ZodObject<{
14875
+ targetFolderSlug: z.ZodString;
14876
+ targetFolderNodeId: z.ZodString;
14877
+ created: z.ZodObject<{
14878
+ folders: z.ZodNumber;
14879
+ docs: z.ZodNumber;
14880
+ bases: z.ZodNumber;
14881
+ views: z.ZodNumber;
14882
+ records: z.ZodNumber;
14883
+ fileTreeNodes: z.ZodNumber;
14884
+ files: z.ZodNumber;
14885
+ }, z.core.$strip>;
14886
+ pendingChangeRequests: z.ZodNumber;
14887
+ warnings: z.ZodDefault<z.ZodArray<z.ZodString>>;
14888
+ }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
14889
+ };
14795
14890
  changeRequests: {
14796
14891
  list: _orpc_contract.ContractProcedure<z.ZodDefault<z.ZodOptional<z.ZodObject<{
14797
14892
  limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
@@ -22494,6 +22589,7 @@ declare const activityItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
22494
22589
  "asset.metadata_updated": "asset.metadata_updated";
22495
22590
  "asset.text_written": "asset.text_written";
22496
22591
  "asset.text_marked_none": "asset.text_marked_none";
22592
+ "node.metadata_updated": "node.metadata_updated";
22497
22593
  "node.purged": "node.purged";
22498
22594
  }>;
22499
22595
  actorId: z.ZodString;
@@ -23039,7 +23135,7 @@ type ChangeRequestTargetType = "base" | "node";
23039
23135
  type ReviewVerdict = "approved" | "rejected";
23040
23136
  type SearchResultKind = "record" | "change_request" | "base" | "file";
23041
23137
  type CommentSubjectType = "record" | "change_request" | "operation" | "commit";
23042
- type AuditAction = "record.viewed" | "change_request.created" | "change_request.updated" | "change_request.deleted" | "change_request.reviewed" | "change_request.merged" | "base.created" | "field.created" | "doc.created" | "doc.updated" | "file.created" | "skill.created" | "drive.created" | "airapp.created" | "asset.deleted" | "asset.metadata_updated" | "asset.text_written" | "asset.text_marked_none" | "node.purged";
23138
+ type AuditAction = "record.viewed" | "change_request.created" | "change_request.updated" | "change_request.deleted" | "change_request.reviewed" | "change_request.merged" | "base.created" | "field.created" | "doc.created" | "doc.updated" | "file.created" | "skill.created" | "drive.created" | "airapp.created" | "asset.deleted" | "asset.metadata_updated" | "asset.text_written" | "asset.text_marked_none" | "node.metadata_updated" | "node.purged";
23043
23139
  interface UserRefVO {
23044
23140
  id: string;
23045
23141
  name: string | null;
@@ -23070,7 +23166,7 @@ interface NodeVO {
23070
23166
  slug: string;
23071
23167
  name: string;
23072
23168
  description: string;
23073
- metadata: {
23169
+ metadata: Record<string, unknown> & {
23074
23170
  entryFile?: string;
23075
23171
  visibility?: "private" | "workspace" | "public";
23076
23172
  version?: string;
package/dist/index.js CHANGED
@@ -427,7 +427,7 @@ var nodeSchema = z.lazy(
427
427
  visibility: z.enum(["private", "workspace", "public"]).optional(),
428
428
  version: z.string().optional(),
429
429
  assetId: z.string().optional()
430
- }).default({}),
430
+ }).catchall(z.unknown()).default({}),
431
431
  position: z.number(),
432
432
  createdAt: z.string(),
433
433
  updatedAt: z.string(),
@@ -459,6 +459,10 @@ var isDescendantInputSchema = z.object({
459
459
  var isDescendantOutputSchema = z.object({
460
460
  isDescendant: z.boolean()
461
461
  });
462
+ var updateNodeMetadataInputSchema = z.object({
463
+ nodeId: z.string(),
464
+ metadata: z.record(z.string(), z.unknown())
465
+ });
462
466
  var searchNodesByNameInputSchema = z.object({
463
467
  query: z.string().min(1),
464
468
  limit: z.number().int().min(1).max(50).optional().default(20)
@@ -647,6 +651,7 @@ var auditActionSchema = z.enum([
647
651
  "asset.metadata_updated",
648
652
  "asset.text_written",
649
653
  "asset.text_marked_none",
654
+ "node.metadata_updated",
650
655
  "node.purged"
651
656
  ]);
652
657
  var auditEventSchema = z.object({
@@ -836,7 +841,11 @@ var authInfoSchema = z.object({
836
841
  * space-scoped — when this has more than one entry, callers should confirm the
837
842
  * intended space and target it explicitly via the `x-busabase-space` header.
838
843
  */
839
- spaces: z.array(authSpaceSchema)
844
+ spaces: z.array(authSpaceSchema),
845
+ /** Cloud only: the server created this user's first Space during this exact request. */
846
+ createdSpace: z.boolean().optional(),
847
+ /** Cloud only: this auto-created Space still needs its idempotent starter initialization. */
848
+ bootstrapRequired: z.boolean().optional()
840
849
  });
841
850
 
842
851
  // ../../packages/busabase-contract/src/domains/filetree/contract.ts
@@ -2081,6 +2090,168 @@ var folderContract = {
2081
2090
  successDescription: "Folder node and its direct children."
2082
2091
  }).input(z.object({ nodeId: z.string() })).output(folderSchema)
2083
2092
  };
2093
+ var InstallPlanNodeTypeSchema = z.enum([
2094
+ "folder",
2095
+ "doc",
2096
+ "base",
2097
+ "skill",
2098
+ "airapp",
2099
+ "drive",
2100
+ "file"
2101
+ ]);
2102
+ var InstallPlanNodeVOSchema = z.object({
2103
+ /** Package-relative path, e.g. `guides/faq`. Unique within a plan. */
2104
+ path: z.string(),
2105
+ slug: z.string(),
2106
+ name: z.string(),
2107
+ type: InstallPlanNodeTypeSchema,
2108
+ /** 0 for a top-level node under the target folder. */
2109
+ depth: z.number().int().min(0),
2110
+ /** Bases only. */
2111
+ fieldCount: z.number().int().min(0).optional(),
2112
+ /** Bases only — the per-base record count §15.4 asks the plan to surface. */
2113
+ recordCount: z.number().int().min(0).optional(),
2114
+ /** skill / airapp / drive only — files carried verbatim inside the node. */
2115
+ fileCount: z.number().int().min(0).optional()
2116
+ });
2117
+ var InstallCollisionVOSchema = z.object({
2118
+ kind: z.enum(["node", "base"]),
2119
+ slug: z.string(),
2120
+ /** Human-readable location, e.g. `my-package/product-catalog`. */
2121
+ path: z.string(),
2122
+ /** Set when `rename` resolved it — the slug that would actually be created. */
2123
+ renamedTo: z.string().optional()
2124
+ });
2125
+ var InstallPlanCountsVOSchema = z.object({
2126
+ folders: z.number().int().min(0),
2127
+ docs: z.number().int().min(0),
2128
+ bases: z.number().int().min(0),
2129
+ records: z.number().int().min(0),
2130
+ skills: z.number().int().min(0),
2131
+ airapps: z.number().int().min(0),
2132
+ drives: z.number().int().min(0),
2133
+ files: z.number().int().min(0)
2134
+ });
2135
+ var InstallPackageInfoVOSchema = z.object({
2136
+ name: z.string(),
2137
+ description: z.string().default(""),
2138
+ version: z.string().optional(),
2139
+ author: z.string().optional(),
2140
+ license: z.string().optional(),
2141
+ homepage: z.string().optional(),
2142
+ tags: z.array(z.string()).default([])
2143
+ });
2144
+ var InstallPlanVOSchema = z.object({
2145
+ package: InstallPackageInfoVOSchema,
2146
+ /** Resolved GitHub source, echoed back so the UI can show what it actually fetched. */
2147
+ source: z.object({
2148
+ owner: z.string(),
2149
+ repo: z.string(),
2150
+ ref: z.string().optional(),
2151
+ subdir: z.string().optional()
2152
+ }),
2153
+ targetFolderSlug: z.string(),
2154
+ nodes: z.array(InstallPlanNodeVOSchema).default([]),
2155
+ counts: InstallPlanCountsVOSchema,
2156
+ collisions: z.array(InstallCollisionVOSchema).default([]),
2157
+ warnings: z.array(z.string()).default([]),
2158
+ /**
2159
+ * True when a record carries a relation VALUE. A relation stores the ids of the
2160
+ * records it points at, and those exist only once the records are merged — so a
2161
+ * review-first install would land every relation empty. `autoMerge` is required
2162
+ * in that case, and the UI must say why.
2163
+ */
2164
+ requiresAutoMerge: z.boolean(),
2165
+ /**
2166
+ * Whether installing with **the options this plan was asked for** would work:
2167
+ * false when a collision is unresolved, or when `requiresAutoMerge` is unmet
2168
+ * for the `autoMerge` the caller passed.
2169
+ *
2170
+ * It is therefore an answer to "what happens if I install like this", not a
2171
+ * property of the package — a package whose records carry relation values
2172
+ * reports `applicable: false` when planned WITHOUT `autoMerge` and true WITH
2173
+ * it. A client that offers an auto-merge toggle must re-plan when it changes
2174
+ * (the same way it re-plans when `rename` or `intoFolder` change), rather than
2175
+ * treating one plan's `applicable` as final.
2176
+ *
2177
+ * There is deliberately no `blockedReason` string here: the reason is already
2178
+ * carried structurally by `collisions[]` (with `renamedTo`) and
2179
+ * `requiresAutoMerge`, and each client words it for its own surface — a CLI
2180
+ * says "re-run with --auto-merge", a dialog points at its own checkbox.
2181
+ */
2182
+ applicable: z.boolean()
2183
+ });
2184
+ var InstallCreatedCountsVOSchema = z.object({
2185
+ folders: z.number().int().min(0),
2186
+ docs: z.number().int().min(0),
2187
+ bases: z.number().int().min(0),
2188
+ views: z.number().int().min(0),
2189
+ records: z.number().int().min(0),
2190
+ fileTreeNodes: z.number().int().min(0),
2191
+ files: z.number().int().min(0)
2192
+ });
2193
+ var InstallResultVOSchema = z.object({
2194
+ targetFolderSlug: z.string(),
2195
+ targetFolderNodeId: z.string(),
2196
+ created: InstallCreatedCountsVOSchema,
2197
+ /**
2198
+ * Change requests left for a human to review. Structure (folders, Bases, their
2199
+ * fields and views) is always created immediately — a pending Base has no id, so
2200
+ * there would be nowhere to attach a view or a record. Content (records, docs,
2201
+ * skills, AirApps) is what lands here for review.
2202
+ */
2203
+ pendingChangeRequests: z.number().int().min(0),
2204
+ warnings: z.array(z.string()).default([])
2205
+ });
2206
+ var repoUrlField = z.string().min(1).describe(
2207
+ "GitHub repo URL: https://github.com/<owner>/<repo>[/tree/<ref>[/<subdir>]]. Only GitHub hosts are accepted."
2208
+ );
2209
+ var intoFolderField = z.string().optional().describe("Slug of the folder to install into. Defaults to the package manifest's name.");
2210
+ var renameField = z.boolean().optional().describe(
2211
+ "Resolve slug collisions by suffixing (-2, -3, \u2026) instead of refusing. Never overwrites anything."
2212
+ );
2213
+ var InstallPlanFromGithubDTOSchema = z.object({
2214
+ repoUrl: repoUrlField,
2215
+ intoFolder: intoFolderField,
2216
+ rename: renameField,
2217
+ /**
2218
+ * Plan as if installing with auto-merge. Only affects the returned
2219
+ * `applicable` (see `InstallPlanVOSchema`) — a dry run never writes either
2220
+ * way. A client with an auto-merge toggle passes the toggle's current value so
2221
+ * the preview answers the question the user is actually about to ask.
2222
+ *
2223
+ * `.optional()` with no `.default()`, matching `rename` above: `z.infer` gives
2224
+ * the OUTPUT type, so a default would make this REQUIRED for every caller.
2225
+ * Omitted means "plan without auto-merge" (applied in the logic layer).
2226
+ */
2227
+ autoMerge: z.boolean().optional()
2228
+ });
2229
+ var InstallFromGithubDTOSchema = z.object({
2230
+ repoUrl: repoUrlField,
2231
+ intoFolder: intoFolderField,
2232
+ rename: renameField,
2233
+ autoMerge: z.boolean().optional().describe(
2234
+ "Merge the content change requests on the spot instead of leaving them for review. This trusts the package author: a package can carry skills and AirApps, i.e. code this space's agents will execute."
2235
+ )
2236
+ });
2237
+
2238
+ // ../../packages/busabase-contract/src/domains/install/contract.ts
2239
+ var installContract = {
2240
+ planFromGithub: oc.route({
2241
+ method: "POST",
2242
+ path: "/install/github/plan",
2243
+ tags: ["Install"],
2244
+ summary: "Dry-run a GitHub package install",
2245
+ successDescription: "What installing this package would create: the node outline, per-base record counts, slug collisions, warnings, and whether autoMerge is required. Creates nothing."
2246
+ }).input(InstallPlanFromGithubDTOSchema).output(InstallPlanVOSchema),
2247
+ fromGithub: oc.route({
2248
+ method: "POST",
2249
+ path: "/install/github",
2250
+ tags: ["Install"],
2251
+ summary: "Install a package from a GitHub repo",
2252
+ successDescription: "Created counts plus the number of change requests left for review. Structure (folders, Bases, fields, views) is created immediately \u2014 a pending Base has no id to attach a view or record to; content (records, docs, skills, AirApps) lands as change requests unless `autoMerge` is set."
2253
+ }).input(InstallFromGithubDTOSchema).output(InstallResultVOSchema)
2254
+ };
2084
2255
 
2085
2256
  // ../../packages/busabase-contract/src/domains/skill/contract.ts
2086
2257
  var skillContract = makeFileTreeContract("skills", "Skills");
@@ -2541,6 +2712,13 @@ var busabaseContractRoutes = {
2541
2712
  summary: "Move or reorder a node",
2542
2713
  successDescription: "Merged change request that repositioned the node under its (optionally new) parent. Applied immediately (auto-merged) since reordering is a low-risk structural tweak, not a review-worthy content change."
2543
2714
  }).input(moveNodeInputSchema).output(changeRequestSchema),
2715
+ updateMetadata: oc.route({
2716
+ method: "PATCH",
2717
+ path: "/nodes/{nodeId}/metadata",
2718
+ tags: ["Nodes"],
2719
+ summary: "Update node metadata",
2720
+ successDescription: "Shallow-merged the supplied top-level keys into the active node's existing metadata. Requires write access on the node."
2721
+ }).input(updateNodeMetadataInputSchema).output(nodeSchema),
2544
2722
  purge: oc.route({
2545
2723
  method: "DELETE",
2546
2724
  path: "/nodes/{nodeId}",
@@ -2677,6 +2855,7 @@ var busabaseContractRoutes = {
2677
2855
  vault: vaultContract,
2678
2856
  webhooks: webhookContract,
2679
2857
  dump: dumpContract,
2858
+ install: installContract,
2680
2859
  changeRequests: {
2681
2860
  list: oc.route({
2682
2861
  method: "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busa-sdk",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
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",