busabase-sdk 0.9.6 → 0.9.7

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
@@ -4215,6 +4215,7 @@ declare const cloudContract: {
4215
4215
  targetBaseSlug: z.ZodOptional<z.ZodString>;
4216
4216
  }, z.core.$strip>>;
4217
4217
  }, z.core.$strip>>;
4218
+ materialized: z.ZodLiteral<true>;
4218
4219
  }, z.core.$strip>, z.ZodObject<{
4219
4220
  id: z.ZodString;
4220
4221
  baseId: z.ZodNullable<z.ZodString>;
@@ -4592,11 +4593,13 @@ declare const cloudContract: {
4592
4593
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
4593
4594
  createdAt: z.ZodString;
4594
4595
  }, z.core.$strip>>;
4596
+ materialized: z.ZodLiteral<false>;
4595
4597
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
4596
4598
  createChangeRequest: _orpc_contract.ContractProcedure<z.ZodObject<{
4597
4599
  fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4598
4600
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4599
4601
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4602
+ idempotencyKey: z.ZodOptional<z.ZodString>;
4600
4603
  baseId: z.ZodString;
4601
4604
  }, z.core.$strip>, z.ZodObject<{
4602
4605
  id: z.ZodString;
@@ -4980,6 +4983,7 @@ declare const cloudContract: {
4980
4983
  records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4981
4984
  message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4982
4985
  submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4986
+ idempotencyKey: z.ZodOptional<z.ZodString>;
4983
4987
  baseId: z.ZodString;
4984
4988
  }, z.core.$strip>, z.ZodObject<{
4985
4989
  id: z.ZodString;
@@ -9240,6 +9244,7 @@ declare const cloudContract: {
9240
9244
  assetId: z.ZodString;
9241
9245
  displayName: z.ZodNullable<z.ZodString>;
9242
9246
  }, z.core.$strip>>;
9247
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
9243
9248
  }, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
9244
9249
  create: _orpc_contract.ContractProcedure<z.ZodObject<{
9245
9250
  parentNodeId: z.ZodOptional<z.ZodString>;
@@ -9285,6 +9290,8 @@ declare const cloudContract: {
9285
9290
  assetId: z.ZodString;
9286
9291
  displayName: z.ZodNullable<z.ZodString>;
9287
9292
  }, z.core.$strip>>;
9293
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
9294
+ materialized: z.ZodLiteral<true>;
9288
9295
  }, z.core.$strip>, z.ZodObject<{
9289
9296
  id: z.ZodString;
9290
9297
  baseId: z.ZodNullable<z.ZodString>;
@@ -9662,6 +9669,7 @@ declare const cloudContract: {
9662
9669
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
9663
9670
  createdAt: z.ZodString;
9664
9671
  }, z.core.$strip>>;
9672
+ materialized: z.ZodLiteral<false>;
9665
9673
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
9666
9674
  get: _orpc_contract.ContractProcedure<z.ZodObject<{
9667
9675
  nodeId: z.ZodString;
@@ -9683,6 +9691,7 @@ declare const cloudContract: {
9683
9691
  assetId: z.ZodString;
9684
9692
  displayName: z.ZodNullable<z.ZodString>;
9685
9693
  }, z.core.$strip>>;
9694
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
9686
9695
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
9687
9696
  listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
9688
9697
  nodeId: z.ZodString;
@@ -10149,6 +10158,7 @@ declare const cloudContract: {
10149
10158
  assetId: z.ZodString;
10150
10159
  displayName: z.ZodNullable<z.ZodString>;
10151
10160
  }, z.core.$strip>>;
10161
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
10152
10162
  }, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
10153
10163
  create: _orpc_contract.ContractProcedure<z.ZodObject<{
10154
10164
  parentNodeId: z.ZodOptional<z.ZodString>;
@@ -10194,6 +10204,8 @@ declare const cloudContract: {
10194
10204
  assetId: z.ZodString;
10195
10205
  displayName: z.ZodNullable<z.ZodString>;
10196
10206
  }, z.core.$strip>>;
10207
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
10208
+ materialized: z.ZodLiteral<true>;
10197
10209
  }, z.core.$strip>, z.ZodObject<{
10198
10210
  id: z.ZodString;
10199
10211
  baseId: z.ZodNullable<z.ZodString>;
@@ -10571,6 +10583,7 @@ declare const cloudContract: {
10571
10583
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
10572
10584
  createdAt: z.ZodString;
10573
10585
  }, z.core.$strip>>;
10586
+ materialized: z.ZodLiteral<false>;
10574
10587
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
10575
10588
  get: _orpc_contract.ContractProcedure<z.ZodObject<{
10576
10589
  nodeId: z.ZodString;
@@ -10592,6 +10605,7 @@ declare const cloudContract: {
10592
10605
  assetId: z.ZodString;
10593
10606
  displayName: z.ZodNullable<z.ZodString>;
10594
10607
  }, z.core.$strip>>;
10608
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
10595
10609
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
10596
10610
  listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
10597
10611
  nodeId: z.ZodString;
@@ -11040,6 +11054,38 @@ declare const cloudContract: {
11040
11054
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
11041
11055
  };
11042
11056
  airapps: {
11057
+ runLocalNode: _orpc_contract.ContractProcedure<z.ZodObject<{
11058
+ nodeId: z.ZodString;
11059
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
11060
+ }, z.core.$strip>, _orpc_contract.Schema<AsyncIteratorObject<{
11061
+ type: "log";
11062
+ line: string;
11063
+ } | {
11064
+ type: "installed";
11065
+ } | {
11066
+ type: "ready";
11067
+ previewUrl: string;
11068
+ } | {
11069
+ type: "exit";
11070
+ code: number | null;
11071
+ } | {
11072
+ type: "error";
11073
+ message: string;
11074
+ }, unknown, void>, _orpc_shared.AsyncIteratorClass<{
11075
+ type: "log";
11076
+ line: string;
11077
+ } | {
11078
+ type: "installed";
11079
+ } | {
11080
+ type: "ready";
11081
+ previewUrl: string;
11082
+ } | {
11083
+ type: "exit";
11084
+ code: number | null;
11085
+ } | {
11086
+ type: "error";
11087
+ message: string;
11088
+ }, unknown, void>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
11043
11089
  list: _orpc_contract.ContractProcedure<_orpc_contract.Schema<unknown, unknown>, z.ZodArray<z.ZodObject<{
11044
11090
  node: z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>;
11045
11091
  entryFile: z.ZodString;
@@ -11058,6 +11104,7 @@ declare const cloudContract: {
11058
11104
  assetId: z.ZodString;
11059
11105
  displayName: z.ZodNullable<z.ZodString>;
11060
11106
  }, z.core.$strip>>;
11107
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
11061
11108
  }, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
11062
11109
  create: _orpc_contract.ContractProcedure<z.ZodObject<{
11063
11110
  parentNodeId: z.ZodOptional<z.ZodString>;
@@ -11103,6 +11150,8 @@ declare const cloudContract: {
11103
11150
  assetId: z.ZodString;
11104
11151
  displayName: z.ZodNullable<z.ZodString>;
11105
11152
  }, z.core.$strip>>;
11153
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
11154
+ materialized: z.ZodLiteral<true>;
11106
11155
  }, z.core.$strip>, z.ZodObject<{
11107
11156
  id: z.ZodString;
11108
11157
  baseId: z.ZodNullable<z.ZodString>;
@@ -11480,6 +11529,7 @@ declare const cloudContract: {
11480
11529
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
11481
11530
  createdAt: z.ZodString;
11482
11531
  }, z.core.$strip>>;
11532
+ materialized: z.ZodLiteral<false>;
11483
11533
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
11484
11534
  get: _orpc_contract.ContractProcedure<z.ZodObject<{
11485
11535
  nodeId: z.ZodString;
@@ -11501,6 +11551,7 @@ declare const cloudContract: {
11501
11551
  assetId: z.ZodString;
11502
11552
  displayName: z.ZodNullable<z.ZodString>;
11503
11553
  }, z.core.$strip>>;
11554
+ skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
11504
11555
  }, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
11505
11556
  listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
11506
11557
  nodeId: z.ZodString;
@@ -12007,6 +12058,7 @@ declare const cloudContract: {
12007
12058
  }>;
12008
12059
  createdAt: z.ZodString;
12009
12060
  }, z.core.$strip>;
12061
+ materialized: z.ZodLiteral<true>;
12010
12062
  }, z.core.$strip>, z.ZodObject<{
12011
12063
  id: z.ZodString;
12012
12064
  baseId: z.ZodNullable<z.ZodString>;
@@ -12384,6 +12436,7 @@ declare const cloudContract: {
12384
12436
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
12385
12437
  createdAt: z.ZodString;
12386
12438
  }, z.core.$strip>>;
12439
+ materialized: z.ZodLiteral<false>;
12387
12440
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
12388
12441
  get: _orpc_contract.ContractProcedure<z.ZodObject<{
12389
12442
  nodeId: z.ZodString;
@@ -12431,6 +12484,7 @@ declare const cloudContract: {
12431
12484
  node: z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>;
12432
12485
  storagePrefix: z.ZodString;
12433
12486
  body: z.ZodString;
12487
+ materialized: z.ZodLiteral<true>;
12434
12488
  }, z.core.$strip>, z.ZodObject<{
12435
12489
  id: z.ZodString;
12436
12490
  baseId: z.ZodNullable<z.ZodString>;
@@ -12808,6 +12862,7 @@ declare const cloudContract: {
12808
12862
  visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
12809
12863
  createdAt: z.ZodString;
12810
12864
  }, z.core.$strip>>;
12865
+ materialized: z.ZodLiteral<false>;
12811
12866
  }, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
12812
12867
  get: _orpc_contract.ContractProcedure<z.ZodObject<{
12813
12868
  nodeId: z.ZodString;
@@ -20865,6 +20920,35 @@ declare function resolveConfig(config?: BusabaseConfig): ResolvedConfig;
20865
20920
  * ```
20866
20921
  */
20867
20922
  declare function createBusabaseClient(config?: BusabaseConfig): BusabaseClient;
20923
+ /** Options for {@link createBusabaseRpcClient}. No `apiKey`/`spaceId` — this
20924
+ * transport authenticates purely via the browser's ambient session cookie. */
20925
+ interface BusabaseRpcConfig {
20926
+ /**
20927
+ * Path to the internal RPC endpoint: either a full URL, or a path resolved
20928
+ * against `window.location.origin` (browser only — there is no ambient
20929
+ * session outside one).
20930
+ *
20931
+ * **The default (`/api/rpc`) only matches `apps/busabase` (the OSS app)**,
20932
+ * which mounts busabase's procedures unnamespaced. `apps/busabase-cloud`
20933
+ * mounts the *same* procedures under a `core` prefix instead — pass
20934
+ * `apiBasePath: "/api/rpc/core"` there, or this client will 404 on every
20935
+ * call. There is no single default that works for both; which one you're
20936
+ * targeting is something the caller has to know (this SDK doesn't probe
20937
+ * for it).
20938
+ *
20939
+ * From inside an AirApp running via Nodepod, prepend
20940
+ * `/__busabase_api__` to whichever of the above applies, to route through
20941
+ * the service-worker bridge instead of the sandboxed virtual server — e.g.
20942
+ * `/__busabase_api__/api/rpc/core` for busabase-cloud. See
20943
+ * apps/busabase/docs/node-types.md.
20944
+ */
20945
+ apiBasePath?: string;
20946
+ /** Extra headers merged into every request. Static object or a (possibly async) factory. */
20947
+ headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
20948
+ /** Custom `fetch` implementation (e.g. a proxy-aware or instrumented fetch). */
20949
+ fetch?: typeof fetch;
20950
+ }
20951
+ declare function createBusabaseRpcClient(config?: BusabaseRpcConfig): BusabaseClient;
20868
20952
 
20869
20953
  /**
20870
20954
  * Attachments — DTO/VO Zod schemas + inferred types (the contract's type source
@@ -22211,6 +22295,7 @@ interface FileTreeNodeVO {
22211
22295
  visibility: "private" | "workspace" | "public";
22212
22296
  version: string;
22213
22297
  files: FileTreeFileVO[];
22298
+ skippedGitignorePaths?: string[];
22214
22299
  }
22215
22300
  interface FileTreeReadFileVO {
22216
22301
  nodeId: string;
@@ -22881,4 +22966,4 @@ declare class Busabase {
22881
22966
  }>>>>;
22882
22967
  }
22883
22968
 
22884
- export { type ActivityItemVO, type AgentTaskVO, type FileTreeFileVO as AirAppFileVO, type FileTreeReadFileVO as AirAppReadFileVO, type FileTreeNodeVO as AirAppVO, type AssetAttachmentRef, type AssetDetailVO, type AssetTextStatus, type AssetUsageVO, type AssetVO, type AttachmentRef, type AuditAction, type AuditEventVO, type BaseFieldVO, type BaseVO, Busabase, type BusabaseClient, type BusabaseConfig, CREATABLE_NODE_TYPES, type ChangeRequestBatchResultVO, type ChangeRequestCountsVO, type ChangeRequestStatus, type ChangeRequestTargetType, type ChangeRequestVO, type CloudContract, type CommentSubjectType, type CommentVO, type CommitVO, type CreatableNodeType, DEFAULT_BASE_URL, type FileTreeFileVO as DriveFileVO, type FileTreeReadFileVO as DriveReadFileVO, type FileTreeNodeVO as DriveVO, type FieldType, type FileNodeMetadata, type FileNodeVO, type FileTreeFileVO, type FileTreeNodeVO, type FileTreeReadFileVO, type NodeType, type NodeVO, type OperationKind, type OperationStatus, type OperationVO, type RecordLinkVO, type RecordVO, type ResolvedConfig, type ReviewVO, type ReviewVerdict, type SearchResponseVO, type SearchResultKind, type SearchResultVO, type FileTreeFileVO as SkillFileVO, type FileTreeReadFileVO as SkillReadFileVO, type FileTreeNodeVO as SkillVO, type UpdateVaultSettingsDTO, type UserRefVO, type VaultAccessPolicy, type VaultEnvironment, type VaultItemInput, type VaultItemKind, type VaultItemVO, type VaultRuntimeEnv, type VaultScopeType, type VaultSettingsVO, type ViewConfigVO, type ViewFilterOperator, type ViewFilterVO, type ViewSortVO, type ViewVO, cloudContract, createBusabaseClient, normalizeBaseUrl, resolveConfig };
22969
+ export { type ActivityItemVO, type AgentTaskVO, type FileTreeFileVO as AirAppFileVO, type FileTreeReadFileVO as AirAppReadFileVO, type FileTreeNodeVO as AirAppVO, type AssetAttachmentRef, type AssetDetailVO, type AssetTextStatus, type AssetUsageVO, type AssetVO, type AttachmentRef, type AuditAction, type AuditEventVO, type BaseFieldVO, type BaseVO, Busabase, type BusabaseClient, type BusabaseConfig, type BusabaseRpcConfig, CREATABLE_NODE_TYPES, type ChangeRequestBatchResultVO, type ChangeRequestCountsVO, type ChangeRequestStatus, type ChangeRequestTargetType, type ChangeRequestVO, type CloudContract, type CommentSubjectType, type CommentVO, type CommitVO, type CreatableNodeType, DEFAULT_BASE_URL, type FileTreeFileVO as DriveFileVO, type FileTreeReadFileVO as DriveReadFileVO, type FileTreeNodeVO as DriveVO, type FieldType, type FileNodeMetadata, type FileNodeVO, type FileTreeFileVO, type FileTreeNodeVO, type FileTreeReadFileVO, type NodeType, type NodeVO, type OperationKind, type OperationStatus, type OperationVO, type RecordLinkVO, type RecordVO, type ResolvedConfig, type ReviewVO, type ReviewVerdict, type SearchResponseVO, type SearchResultKind, type SearchResultVO, type FileTreeFileVO as SkillFileVO, type FileTreeReadFileVO as SkillReadFileVO, type FileTreeNodeVO as SkillVO, type UpdateVaultSettingsDTO, type UserRefVO, type VaultAccessPolicy, type VaultEnvironment, type VaultItemInput, type VaultItemKind, type VaultItemVO, type VaultRuntimeEnv, type VaultScopeType, type VaultSettingsVO, type ViewConfigVO, type ViewFilterOperator, type ViewFilterVO, type ViewSortVO, type ViewVO, cloudContract, createBusabaseClient, createBusabaseRpcClient, normalizeBaseUrl, resolveConfig };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createORPCClient } from '@orpc/client';
2
+ import { RPCLink } from '@orpc/client/fetch';
3
+ import { oc, eventIterator, inferRPCMethodFromContractRouter } from '@orpc/contract';
2
4
  import { OpenAPILink } from '@orpc/openapi-client/fetch';
3
- import { oc, eventIterator } from '@orpc/contract';
4
5
  import { z } from 'zod';
5
6
 
6
7
  // src/client.ts
@@ -112,7 +113,9 @@ var baseSchema = z.object({
112
113
  fields: z.array(baseFieldSchema)
113
114
  });
114
115
  var createBaseInputSchema = z.object({
115
- parentNodeId: z.string().optional(),
116
+ parentNodeId: z.string().optional().describe(
117
+ "Parent node id. Must be a folder or the space root; container-incapable node types (Base, Doc, AirApp, etc.) cannot hold children."
118
+ ),
116
119
  slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
117
120
  name: z.string().min(1),
118
121
  description: z.string().optional().default(""),
@@ -855,10 +858,17 @@ var fileTreeNodeSchema = z.object({
855
858
  entryFile: z.string(),
856
859
  visibility: z.enum(["private", "workspace", "public"]),
857
860
  version: z.string(),
858
- files: z.array(fileTreeFileSchema)
861
+ files: z.array(fileTreeFileSchema),
862
+ // Paths silently dropped from this create call by an uploaded `.gitignore`
863
+ // (upload-safety layer 1 — see `logic/upload-safety.ts`). Empty on
864
+ // ordinary get/list responses and on creates that didn't include a
865
+ // `.gitignore`.
866
+ skippedGitignorePaths: z.array(z.string()).optional().default([])
859
867
  });
860
868
  var createFileTreeInputSchema = z.object({
861
- parentNodeId: z.string().optional(),
869
+ parentNodeId: z.string().optional().describe(
870
+ "Parent node id. Must be a folder or the space root; container-incapable node types (Base, Doc, AirApp, etc.) cannot hold children."
871
+ ),
862
872
  slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
863
873
  name: z.string().min(1),
864
874
  description: z.string().optional().default(""),
@@ -920,8 +930,13 @@ var makeFileTreeContract = (routeBase, tag) => {
920
930
  path: basePath,
921
931
  tags: [tag],
922
932
  summary: `Create ${label} node`,
923
- successDescription: `Review-first by default: a pending ChangeRequest proposing the ${label} node. Returns the materialized ${label} node instead when \`autoMerge: true\` is passed.`
924
- }).input(createFileTreeInputSchema).output(z.union([fileTreeNodeSchema, changeRequestSchema])),
933
+ successDescription: `Review-first by default: a pending ChangeRequest proposing the ${label} node (\`materialized: false\`). Returns the materialized ${label} node instead (\`materialized: true\`) when \`autoMerge: true\` is passed.`
934
+ }).input(createFileTreeInputSchema).output(
935
+ z.union([
936
+ fileTreeNodeSchema.extend({ materialized: z.literal(true) }),
937
+ changeRequestSchema.extend({ materialized: z.literal(false) })
938
+ ])
939
+ ),
925
940
  get: oc.route({
926
941
  method: "GET",
927
942
  path: `${basePath}/{nodeId}`,
@@ -967,6 +982,22 @@ var makeFileTreeContract = (routeBase, tag) => {
967
982
 
968
983
  // ../../packages/busabase-contract/src/domains/airapp/contract.ts
969
984
  var airappContract = makeFileTreeContract("airapps", "AirApps");
985
+ var airAppRunLocalNodeInputSchema = z.object({
986
+ nodeId: z.string(),
987
+ /** Text files to mount into the sandbox workdir before installing, keyed by
988
+ * path (same shape `RunPanel` already assembles for `NodepodRunner.mount`). */
989
+ files: z.record(z.string(), z.string())
990
+ });
991
+ var airAppRuntimeEventSchema = z.discriminatedUnion("type", [
992
+ z.object({ type: z.literal("log"), line: z.string() }),
993
+ z.object({ type: z.literal("installed") }),
994
+ z.object({ type: z.literal("ready"), previewUrl: z.string() }),
995
+ z.object({ type: z.literal("exit"), code: z.number().nullable() }),
996
+ z.object({ type: z.literal("error"), message: z.string() })
997
+ ]);
998
+ var airappRuntimeContract = {
999
+ runLocalNode: oc.input(airAppRunLocalNodeInputSchema).output(eventIterator(airAppRuntimeEventSchema))
1000
+ };
970
1001
  var AttachmentMetadataSchema = z.record(z.string(), z.unknown());
971
1002
  z.object({
972
1003
  id: z.string(),
@@ -1409,7 +1440,10 @@ var createChangeRequestInputSchema = z.object({
1409
1440
  message: z.string().optional().default("Initial change request").describe(
1410
1441
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Add Acme Corp \u2014 qualified lead from the June webinar".'
1411
1442
  ),
1412
- submittedBy: z.string().optional().default("local-producer")
1443
+ submittedBy: z.string().optional().default("local-producer"),
1444
+ idempotencyKey: z.string().optional().describe(
1445
+ "Optional client-supplied key that dedupes retries. Scoped per base + submitter: calling this endpoint again with the SAME idempotencyKey (e.g. after a timeout or a 5xx where you couldn't tell if the first call succeeded) returns the 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."
1446
+ )
1413
1447
  });
1414
1448
  var createBulkChangeRequestInputSchema = z.object({
1415
1449
  records: z.array(z.record(z.string(), z.unknown())).min(1).max(1e3).describe(
@@ -1418,7 +1452,10 @@ var createBulkChangeRequestInputSchema = z.object({
1418
1452
  message: z.string().optional().default("Bulk create records").describe(
1419
1453
  'Explanation shown to the human reviewer for the whole batch \u2014 e.g. "Import 240 June webinar leads".'
1420
1454
  ),
1421
- submittedBy: z.string().optional().default("local-producer")
1455
+ submittedBy: z.string().optional().default("local-producer"),
1456
+ idempotencyKey: z.string().optional().describe(
1457
+ "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."
1458
+ )
1422
1459
  });
1423
1460
  var recordFieldFilterInputSchema = z.object({
1424
1461
  baseId: z.string().optional(),
@@ -1505,8 +1542,13 @@ var baseContract = {
1505
1542
  path: "/bases",
1506
1543
  tags: ["Bases"],
1507
1544
  summary: "Create Base",
1508
- successDescription: "Review-first by default: a pending ChangeRequest proposing the Base. Returns the materialized Base instead when `autoMerge: true` is passed."
1509
- }).input(createBaseInputSchema).output(z.union([baseSchema, changeRequestSchema])),
1545
+ successDescription: "Review-first by default: a pending ChangeRequest proposing the Base (`materialized: false`). Returns the materialized Base instead (`materialized: true`) when `autoMerge: true` is passed."
1546
+ }).input(createBaseInputSchema).output(
1547
+ z.union([
1548
+ baseSchema.extend({ materialized: z.literal(true) }),
1549
+ changeRequestSchema.extend({ materialized: z.literal(false) })
1550
+ ])
1551
+ ),
1510
1552
  createChangeRequest: oc.route({
1511
1553
  method: "POST",
1512
1554
  path: "/bases/{baseId}/change-requests",
@@ -1707,7 +1749,9 @@ var docSchema = z.object({
1707
1749
  body: z.string()
1708
1750
  });
1709
1751
  var createDocInputSchema = z.object({
1710
- parentNodeId: z.string().optional(),
1752
+ parentNodeId: z.string().optional().describe(
1753
+ "Parent node id. Must be a folder or the space root; container-incapable node types (Base, Doc, AirApp, etc.) cannot hold children."
1754
+ ),
1711
1755
  slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
1712
1756
  name: z.string().min(1),
1713
1757
  description: z.string().optional().default(""),
@@ -1741,8 +1785,13 @@ var docContract = {
1741
1785
  path: "/docs",
1742
1786
  tags: ["Docs"],
1743
1787
  summary: "Create Doc node",
1744
- successDescription: "Review-first by default: a pending ChangeRequest proposing the Doc. Returns the materialized Doc node instead when `autoMerge: true` is passed."
1745
- }).input(createDocInputSchema).output(z.union([docSchema, changeRequestSchema])),
1788
+ successDescription: "Review-first by default: a pending ChangeRequest proposing the Doc (`materialized: false`). Returns the materialized Doc node instead (`materialized: true`) when `autoMerge: true` is passed."
1789
+ }).input(createDocInputSchema).output(
1790
+ z.union([
1791
+ docSchema.extend({ materialized: z.literal(true) }),
1792
+ changeRequestSchema.extend({ materialized: z.literal(false) })
1793
+ ])
1794
+ ),
1746
1795
  get: oc.route({
1747
1796
  method: "GET",
1748
1797
  path: "/docs/{nodeId}",
@@ -1876,7 +1925,9 @@ var FileNodeVOSchema = z.object({
1876
1925
 
1877
1926
  // ../../packages/busabase-contract/src/domains/file-node/contract.ts
1878
1927
  var createFileNodeInputSchema = z.object({
1879
- parentNodeId: z.string().optional(),
1928
+ parentNodeId: z.string().optional().describe(
1929
+ "Parent node id. Must be a folder or the space root; container-incapable node types (Base, Doc, AirApp, etc.) cannot hold children."
1930
+ ),
1880
1931
  slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
1881
1932
  name: z.string().min(1),
1882
1933
  description: z.string().optional().default(""),
@@ -1900,8 +1951,13 @@ var fileContract = {
1900
1951
  path: "/files",
1901
1952
  tags: ["Files"],
1902
1953
  summary: "Create File node",
1903
- successDescription: "Review-first by default: a pending ChangeRequest proposing the File node. Returns the materialized File node instead when `autoMerge: true` is passed."
1904
- }).input(createFileNodeInputSchema).output(z.union([FileNodeVOSchema, changeRequestSchema])),
1954
+ successDescription: "Review-first by default: a pending ChangeRequest proposing the File node (`materialized: false`). Returns the materialized File node instead (`materialized: true`) when `autoMerge: true` is passed."
1955
+ }).input(createFileNodeInputSchema).output(
1956
+ z.union([
1957
+ FileNodeVOSchema.extend({ materialized: z.literal(true) }),
1958
+ changeRequestSchema.extend({ materialized: z.literal(false) })
1959
+ ])
1960
+ ),
1905
1961
  get: oc.route({
1906
1962
  method: "GET",
1907
1963
  path: "/files/{nodeId}",
@@ -2449,7 +2505,7 @@ var busabaseContractRoutes = {
2449
2505
  bases: baseContract,
2450
2506
  skills: skillContract,
2451
2507
  drives: driveContract,
2452
- airapps: airappContract,
2508
+ airapps: { ...airappContract, ...airappRuntimeContract },
2453
2509
  files: fileContract,
2454
2510
  docs: docContract,
2455
2511
  folders: folderContract,
@@ -2722,6 +2778,26 @@ function createBusabaseClient(config = {}) {
2722
2778
  });
2723
2779
  return createORPCClient(link);
2724
2780
  }
2781
+ var getBrowserWindow = () => globalThis.window;
2782
+ function createBusabaseRpcClient(config = {}) {
2783
+ const apiBasePath = config.apiBasePath ?? "/api/rpc";
2784
+ const isAbsolute = /^https?:\/\//.test(apiBasePath);
2785
+ if (!isAbsolute && typeof getBrowserWindow() === "undefined") {
2786
+ throw new Error(
2787
+ "createBusabaseRpcClient: apiBasePath must be an absolute URL (http:// or https://) outside a browser \u2014 this client authenticates via the browser's ambient session cookie, which only exists client-side."
2788
+ );
2789
+ }
2790
+ const link = new RPCLink({
2791
+ method: inferRPCMethodFromContractRouter(cloudContract),
2792
+ url: () => isAbsolute ? apiBasePath : `${getBrowserWindow()?.location.origin}${apiBasePath}`,
2793
+ fetch: config.fetch,
2794
+ headers: async () => {
2795
+ const extra = typeof config.headers === "function" ? await config.headers() : config.headers;
2796
+ return { ...extra };
2797
+ }
2798
+ });
2799
+ return createORPCClient(link);
2800
+ }
2725
2801
 
2726
2802
  // src/index.ts
2727
2803
  var Busabase = class {
@@ -2848,4 +2924,4 @@ var Busabase = class {
2848
2924
  }
2849
2925
  };
2850
2926
 
2851
- export { Busabase, CREATABLE_NODE_TYPES, DEFAULT_BASE_URL, cloudContract, createBusabaseClient, normalizeBaseUrl, resolveConfig };
2927
+ export { Busabase, CREATABLE_NODE_TYPES, DEFAULT_BASE_URL, cloudContract, createBusabaseClient, createBusabaseRpcClient, normalizeBaseUrl, resolveConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busabase-sdk",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
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.6",
45
44
  "open-domains": "0.0.2",
46
- "openlib": "0.1.1"
45
+ "openlib": "0.1.1",
46
+ "busabase-contract": "0.9.6"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=24.18.0"