busa-sdk 0.9.5 → 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 +125 -3
- package/dist/index.js +130 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,7 @@ type CreatableNodeType = Extract<BuiltinDefinition, {
|
|
|
239
239
|
creatable: true;
|
|
240
240
|
};
|
|
241
241
|
}>["type"];
|
|
242
|
+
declare const CREATABLE_NODE_TYPES: [CreatableNodeType, ...CreatableNodeType[]];
|
|
242
243
|
type GenericOperationKind = (typeof GENERIC_NODE_OPERATIONS)[number]["kind"];
|
|
243
244
|
type RegisteredOperationKind = BuiltinDefinition["operations"][number]["kind"];
|
|
244
245
|
type OperationKind = GenericOperationKind | RegisteredOperationKind;
|
|
@@ -261,6 +262,17 @@ interface NodeOutput {
|
|
|
261
262
|
updatedAt: string;
|
|
262
263
|
baseId: string | null;
|
|
263
264
|
children: NodeOutput[];
|
|
265
|
+
/**
|
|
266
|
+
* Whether this node has children beyond what `children` carries. Always
|
|
267
|
+
* accurate when the full subtree was loaded (equals `children.length > 0`).
|
|
268
|
+
* The one case it differs: a node sitting exactly at a `nodes.list` `depth`
|
|
269
|
+
* boundary — `children` is `[]` (not fetched) but `hasChildren` is `true`,
|
|
270
|
+
* telling the sidebar to render an expand affordance and lazy-fetch on
|
|
271
|
+
* click instead of rendering it as a leaf. Optional or missing means the
|
|
272
|
+
* caller can safely treat it as `children.length > 0` (which is exactly
|
|
273
|
+
* what it equals whenever it's omitted).
|
|
274
|
+
*/
|
|
275
|
+
hasChildren?: boolean;
|
|
264
276
|
}
|
|
265
277
|
|
|
266
278
|
declare const cloudContract: {
|
|
@@ -387,6 +399,15 @@ declare const cloudContract: {
|
|
|
387
399
|
query: z.ZodDefault<z.ZodString>;
|
|
388
400
|
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
389
401
|
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
402
|
+
sources: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodEnum<{
|
|
403
|
+
records: "records";
|
|
404
|
+
files: "files";
|
|
405
|
+
names: "names";
|
|
406
|
+
}>>, z.ZodEnum<{
|
|
407
|
+
records: "records";
|
|
408
|
+
files: "files";
|
|
409
|
+
names: "names";
|
|
410
|
+
}>]>, z.ZodTransform<("records" | "files" | "names")[], "records" | "files" | "names" | ("records" | "files" | "names")[]>>>;
|
|
390
411
|
}, z.core.$strip>, z.ZodObject<{
|
|
391
412
|
query: z.ZodString;
|
|
392
413
|
limit: z.ZodNumber;
|
|
@@ -411,9 +432,9 @@ declare const cloudContract: {
|
|
|
411
432
|
pattern: z.ZodString;
|
|
412
433
|
flags: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
413
434
|
sources: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
435
|
+
records: "records";
|
|
414
436
|
files: "files";
|
|
415
437
|
docs: "docs";
|
|
416
|
-
records: "records";
|
|
417
438
|
}>>>;
|
|
418
439
|
scope: z.ZodOptional<z.ZodObject<{
|
|
419
440
|
files: z.ZodOptional<z.ZodObject<{
|
|
@@ -487,7 +508,16 @@ declare const cloudContract: {
|
|
|
487
508
|
truncated: z.ZodBoolean;
|
|
488
509
|
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
489
510
|
nodes: {
|
|
490
|
-
list: _orpc_contract.ContractProcedure<
|
|
511
|
+
list: _orpc_contract.ContractProcedure<z.ZodOptional<z.ZodObject<{
|
|
512
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
513
|
+
depth: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
514
|
+
}, z.core.$strip>>, z.ZodArray<z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
515
|
+
isDescendant: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
516
|
+
nodeId: z.ZodString;
|
|
517
|
+
potentialAncestorId: z.ZodString;
|
|
518
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
519
|
+
isDescendant: z.ZodBoolean;
|
|
520
|
+
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
491
521
|
listArchived: _orpc_contract.ContractProcedure<_orpc_contract.Schema<unknown, unknown>, z.ZodArray<z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
492
522
|
createChangeRequest: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
493
523
|
message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -4185,6 +4215,7 @@ declare const cloudContract: {
|
|
|
4185
4215
|
targetBaseSlug: z.ZodOptional<z.ZodString>;
|
|
4186
4216
|
}, z.core.$strip>>;
|
|
4187
4217
|
}, z.core.$strip>>;
|
|
4218
|
+
materialized: z.ZodLiteral<true>;
|
|
4188
4219
|
}, z.core.$strip>, z.ZodObject<{
|
|
4189
4220
|
id: z.ZodString;
|
|
4190
4221
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -4562,11 +4593,13 @@ declare const cloudContract: {
|
|
|
4562
4593
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
4563
4594
|
createdAt: z.ZodString;
|
|
4564
4595
|
}, z.core.$strip>>;
|
|
4596
|
+
materialized: z.ZodLiteral<false>;
|
|
4565
4597
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
4566
4598
|
createChangeRequest: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
4567
4599
|
fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
4568
4600
|
message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4569
4601
|
submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4602
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
4570
4603
|
baseId: z.ZodString;
|
|
4571
4604
|
}, z.core.$strip>, z.ZodObject<{
|
|
4572
4605
|
id: z.ZodString;
|
|
@@ -4950,6 +4983,7 @@ declare const cloudContract: {
|
|
|
4950
4983
|
records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4951
4984
|
message: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4952
4985
|
submittedBy: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4986
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
4953
4987
|
baseId: z.ZodString;
|
|
4954
4988
|
}, z.core.$strip>, z.ZodObject<{
|
|
4955
4989
|
id: z.ZodString;
|
|
@@ -9210,6 +9244,7 @@ declare const cloudContract: {
|
|
|
9210
9244
|
assetId: z.ZodString;
|
|
9211
9245
|
displayName: z.ZodNullable<z.ZodString>;
|
|
9212
9246
|
}, z.core.$strip>>;
|
|
9247
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
9213
9248
|
}, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
9214
9249
|
create: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
9215
9250
|
parentNodeId: z.ZodOptional<z.ZodString>;
|
|
@@ -9255,6 +9290,8 @@ declare const cloudContract: {
|
|
|
9255
9290
|
assetId: z.ZodString;
|
|
9256
9291
|
displayName: z.ZodNullable<z.ZodString>;
|
|
9257
9292
|
}, z.core.$strip>>;
|
|
9293
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
9294
|
+
materialized: z.ZodLiteral<true>;
|
|
9258
9295
|
}, z.core.$strip>, z.ZodObject<{
|
|
9259
9296
|
id: z.ZodString;
|
|
9260
9297
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -9632,6 +9669,7 @@ declare const cloudContract: {
|
|
|
9632
9669
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
9633
9670
|
createdAt: z.ZodString;
|
|
9634
9671
|
}, z.core.$strip>>;
|
|
9672
|
+
materialized: z.ZodLiteral<false>;
|
|
9635
9673
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
9636
9674
|
get: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
9637
9675
|
nodeId: z.ZodString;
|
|
@@ -9653,6 +9691,7 @@ declare const cloudContract: {
|
|
|
9653
9691
|
assetId: z.ZodString;
|
|
9654
9692
|
displayName: z.ZodNullable<z.ZodString>;
|
|
9655
9693
|
}, z.core.$strip>>;
|
|
9694
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
9656
9695
|
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
9657
9696
|
listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
9658
9697
|
nodeId: z.ZodString;
|
|
@@ -10119,6 +10158,7 @@ declare const cloudContract: {
|
|
|
10119
10158
|
assetId: z.ZodString;
|
|
10120
10159
|
displayName: z.ZodNullable<z.ZodString>;
|
|
10121
10160
|
}, z.core.$strip>>;
|
|
10161
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
10122
10162
|
}, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
10123
10163
|
create: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
10124
10164
|
parentNodeId: z.ZodOptional<z.ZodString>;
|
|
@@ -10164,6 +10204,8 @@ declare const cloudContract: {
|
|
|
10164
10204
|
assetId: z.ZodString;
|
|
10165
10205
|
displayName: z.ZodNullable<z.ZodString>;
|
|
10166
10206
|
}, z.core.$strip>>;
|
|
10207
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
10208
|
+
materialized: z.ZodLiteral<true>;
|
|
10167
10209
|
}, z.core.$strip>, z.ZodObject<{
|
|
10168
10210
|
id: z.ZodString;
|
|
10169
10211
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -10541,6 +10583,7 @@ declare const cloudContract: {
|
|
|
10541
10583
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
10542
10584
|
createdAt: z.ZodString;
|
|
10543
10585
|
}, z.core.$strip>>;
|
|
10586
|
+
materialized: z.ZodLiteral<false>;
|
|
10544
10587
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
10545
10588
|
get: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
10546
10589
|
nodeId: z.ZodString;
|
|
@@ -10562,6 +10605,7 @@ declare const cloudContract: {
|
|
|
10562
10605
|
assetId: z.ZodString;
|
|
10563
10606
|
displayName: z.ZodNullable<z.ZodString>;
|
|
10564
10607
|
}, z.core.$strip>>;
|
|
10608
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
10565
10609
|
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
10566
10610
|
listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
10567
10611
|
nodeId: z.ZodString;
|
|
@@ -11010,6 +11054,38 @@ declare const cloudContract: {
|
|
|
11010
11054
|
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
11011
11055
|
};
|
|
11012
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>>;
|
|
11013
11089
|
list: _orpc_contract.ContractProcedure<_orpc_contract.Schema<unknown, unknown>, z.ZodArray<z.ZodObject<{
|
|
11014
11090
|
node: z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>;
|
|
11015
11091
|
entryFile: z.ZodString;
|
|
@@ -11028,6 +11104,7 @@ declare const cloudContract: {
|
|
|
11028
11104
|
assetId: z.ZodString;
|
|
11029
11105
|
displayName: z.ZodNullable<z.ZodString>;
|
|
11030
11106
|
}, z.core.$strip>>;
|
|
11107
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
11031
11108
|
}, z.core.$strip>>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
11032
11109
|
create: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
11033
11110
|
parentNodeId: z.ZodOptional<z.ZodString>;
|
|
@@ -11073,6 +11150,8 @@ declare const cloudContract: {
|
|
|
11073
11150
|
assetId: z.ZodString;
|
|
11074
11151
|
displayName: z.ZodNullable<z.ZodString>;
|
|
11075
11152
|
}, z.core.$strip>>;
|
|
11153
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
11154
|
+
materialized: z.ZodLiteral<true>;
|
|
11076
11155
|
}, z.core.$strip>, z.ZodObject<{
|
|
11077
11156
|
id: z.ZodString;
|
|
11078
11157
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -11450,6 +11529,7 @@ declare const cloudContract: {
|
|
|
11450
11529
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
11451
11530
|
createdAt: z.ZodString;
|
|
11452
11531
|
}, z.core.$strip>>;
|
|
11532
|
+
materialized: z.ZodLiteral<false>;
|
|
11453
11533
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
11454
11534
|
get: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
11455
11535
|
nodeId: z.ZodString;
|
|
@@ -11471,6 +11551,7 @@ declare const cloudContract: {
|
|
|
11471
11551
|
assetId: z.ZodString;
|
|
11472
11552
|
displayName: z.ZodNullable<z.ZodString>;
|
|
11473
11553
|
}, z.core.$strip>>;
|
|
11554
|
+
skippedGitignorePaths: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
11474
11555
|
}, z.core.$strip>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
11475
11556
|
listFiles: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
11476
11557
|
nodeId: z.ZodString;
|
|
@@ -11977,6 +12058,7 @@ declare const cloudContract: {
|
|
|
11977
12058
|
}>;
|
|
11978
12059
|
createdAt: z.ZodString;
|
|
11979
12060
|
}, z.core.$strip>;
|
|
12061
|
+
materialized: z.ZodLiteral<true>;
|
|
11980
12062
|
}, z.core.$strip>, z.ZodObject<{
|
|
11981
12063
|
id: z.ZodString;
|
|
11982
12064
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -12354,6 +12436,7 @@ declare const cloudContract: {
|
|
|
12354
12436
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
12355
12437
|
createdAt: z.ZodString;
|
|
12356
12438
|
}, z.core.$strip>>;
|
|
12439
|
+
materialized: z.ZodLiteral<false>;
|
|
12357
12440
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
12358
12441
|
get: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
12359
12442
|
nodeId: z.ZodString;
|
|
@@ -12401,6 +12484,7 @@ declare const cloudContract: {
|
|
|
12401
12484
|
node: z.ZodType<NodeOutput, unknown, z.core.$ZodTypeInternals<NodeOutput, unknown>>;
|
|
12402
12485
|
storagePrefix: z.ZodString;
|
|
12403
12486
|
body: z.ZodString;
|
|
12487
|
+
materialized: z.ZodLiteral<true>;
|
|
12404
12488
|
}, z.core.$strip>, z.ZodObject<{
|
|
12405
12489
|
id: z.ZodString;
|
|
12406
12490
|
baseId: z.ZodNullable<z.ZodString>;
|
|
@@ -12778,6 +12862,7 @@ declare const cloudContract: {
|
|
|
12778
12862
|
visibleOperationHeads: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
12779
12863
|
createdAt: z.ZodString;
|
|
12780
12864
|
}, z.core.$strip>>;
|
|
12865
|
+
materialized: z.ZodLiteral<false>;
|
|
12781
12866
|
}, z.core.$strip>]>, _orpc_contract.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
12782
12867
|
get: _orpc_contract.ContractProcedure<z.ZodObject<{
|
|
12783
12868
|
nodeId: z.ZodString;
|
|
@@ -20835,6 +20920,35 @@ declare function resolveConfig(config?: BusabaseConfig): ResolvedConfig;
|
|
|
20835
20920
|
* ```
|
|
20836
20921
|
*/
|
|
20837
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;
|
|
20838
20952
|
|
|
20839
20953
|
/**
|
|
20840
20954
|
* Attachments — DTO/VO Zod schemas + inferred types (the contract's type source
|
|
@@ -22181,6 +22295,7 @@ interface FileTreeNodeVO {
|
|
|
22181
22295
|
visibility: "private" | "workspace" | "public";
|
|
22182
22296
|
version: string;
|
|
22183
22297
|
files: FileTreeFileVO[];
|
|
22298
|
+
skippedGitignorePaths?: string[];
|
|
22184
22299
|
}
|
|
22185
22300
|
interface FileTreeReadFileVO {
|
|
22186
22301
|
nodeId: string;
|
|
@@ -22543,6 +22658,13 @@ interface NodeVO {
|
|
|
22543
22658
|
updatedAt: string;
|
|
22544
22659
|
baseId: string | null;
|
|
22545
22660
|
children: NodeVO[];
|
|
22661
|
+
/**
|
|
22662
|
+
* Whether this node has children beyond what `children` carries — see the
|
|
22663
|
+
* matching field on the contract's `NodeOutput` (contract/schemas.ts) for
|
|
22664
|
+
* the full depth-boundary explanation. Optional/omitted is safe to treat
|
|
22665
|
+
* as `children.length > 0`.
|
|
22666
|
+
*/
|
|
22667
|
+
hasChildren?: boolean;
|
|
22546
22668
|
}
|
|
22547
22669
|
|
|
22548
22670
|
interface CommitVO {
|
|
@@ -22844,4 +22966,4 @@ declare class Busabase {
|
|
|
22844
22966
|
}>>>>;
|
|
22845
22967
|
}
|
|
22846
22968
|
|
|
22847
|
-
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 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(""),
|
|
@@ -429,9 +432,23 @@ var nodeSchema = z.lazy(
|
|
|
429
432
|
createdAt: z.string(),
|
|
430
433
|
updatedAt: z.string(),
|
|
431
434
|
baseId: z.string().nullable(),
|
|
432
|
-
children: z.array(nodeSchema)
|
|
435
|
+
children: z.array(nodeSchema),
|
|
436
|
+
hasChildren: z.boolean().optional()
|
|
433
437
|
})
|
|
434
438
|
);
|
|
439
|
+
var listNodesInputSchema = z.object({
|
|
440
|
+
parentId: z.string().nullable().optional().describe("Node to start from. Omit or null to start from the space root."),
|
|
441
|
+
depth: z.coerce.number().int().min(1).max(5).optional().describe(
|
|
442
|
+
"How many levels beneath the start point to eagerly include (default 2 once either field is set). Capped at 5."
|
|
443
|
+
)
|
|
444
|
+
}).optional();
|
|
445
|
+
var isDescendantInputSchema = z.object({
|
|
446
|
+
nodeId: z.string(),
|
|
447
|
+
potentialAncestorId: z.string()
|
|
448
|
+
});
|
|
449
|
+
var isDescendantOutputSchema = z.object({
|
|
450
|
+
isDescendant: z.boolean()
|
|
451
|
+
});
|
|
435
452
|
var userRefSchema = z.object({
|
|
436
453
|
id: z.string(),
|
|
437
454
|
name: z.string().nullable(),
|
|
@@ -754,10 +771,21 @@ var changeRequestCountsSchema = z.object({
|
|
|
754
771
|
merged: z.number().int().nonnegative(),
|
|
755
772
|
rejected: z.number().int().nonnegative()
|
|
756
773
|
});
|
|
774
|
+
var SEARCH_SOURCES = ["records", "files", "names"];
|
|
757
775
|
var searchInputSchema = z.object({
|
|
758
776
|
query: z.string().default(""),
|
|
759
777
|
limit: z.coerce.number().int().min(1).max(100).optional().default(20),
|
|
760
|
-
offset: z.coerce.number().int().min(0).optional().default(0)
|
|
778
|
+
offset: z.coerce.number().int().min(0).optional().default(0),
|
|
779
|
+
/**
|
|
780
|
+
* Restrict which content this call searches. Omitted means all three
|
|
781
|
+
* (unchanged behavior for every caller before this parameter existed).
|
|
782
|
+
*
|
|
783
|
+
* A GET query param that occurs exactly once (`?sources=records`) arrives
|
|
784
|
+
* as a bare string, not a 1-element array — only a REPEATED occurrence
|
|
785
|
+
* (`?sources=records&sources=files`) becomes an array. Accept both shapes
|
|
786
|
+
* and normalize to an array.
|
|
787
|
+
*/
|
|
788
|
+
sources: z.union([z.array(z.enum(SEARCH_SOURCES)), z.enum(SEARCH_SOURCES)]).transform((value) => Array.isArray(value) ? value : [value]).optional()
|
|
761
789
|
});
|
|
762
790
|
var authSpaceSchema = z.object({
|
|
763
791
|
id: z.string(),
|
|
@@ -830,10 +858,17 @@ var fileTreeNodeSchema = z.object({
|
|
|
830
858
|
entryFile: z.string(),
|
|
831
859
|
visibility: z.enum(["private", "workspace", "public"]),
|
|
832
860
|
version: z.string(),
|
|
833
|
-
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([])
|
|
834
867
|
});
|
|
835
868
|
var createFileTreeInputSchema = z.object({
|
|
836
|
-
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
|
+
),
|
|
837
872
|
slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
|
|
838
873
|
name: z.string().min(1),
|
|
839
874
|
description: z.string().optional().default(""),
|
|
@@ -895,8 +930,13 @@ var makeFileTreeContract = (routeBase, tag) => {
|
|
|
895
930
|
path: basePath,
|
|
896
931
|
tags: [tag],
|
|
897
932
|
summary: `Create ${label} node`,
|
|
898
|
-
successDescription: `Review-first by default: a pending ChangeRequest proposing the ${label} node. Returns the materialized ${label} node instead when \`autoMerge: true\` is passed.`
|
|
899
|
-
}).input(createFileTreeInputSchema).output(
|
|
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
|
+
),
|
|
900
940
|
get: oc.route({
|
|
901
941
|
method: "GET",
|
|
902
942
|
path: `${basePath}/{nodeId}`,
|
|
@@ -942,6 +982,22 @@ var makeFileTreeContract = (routeBase, tag) => {
|
|
|
942
982
|
|
|
943
983
|
// ../../packages/busabase-contract/src/domains/airapp/contract.ts
|
|
944
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
|
+
};
|
|
945
1001
|
var AttachmentMetadataSchema = z.record(z.string(), z.unknown());
|
|
946
1002
|
z.object({
|
|
947
1003
|
id: z.string(),
|
|
@@ -1384,7 +1440,10 @@ var createChangeRequestInputSchema = z.object({
|
|
|
1384
1440
|
message: z.string().optional().default("Initial change request").describe(
|
|
1385
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".'
|
|
1386
1442
|
),
|
|
1387
|
-
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
|
+
)
|
|
1388
1447
|
});
|
|
1389
1448
|
var createBulkChangeRequestInputSchema = z.object({
|
|
1390
1449
|
records: z.array(z.record(z.string(), z.unknown())).min(1).max(1e3).describe(
|
|
@@ -1393,7 +1452,10 @@ var createBulkChangeRequestInputSchema = z.object({
|
|
|
1393
1452
|
message: z.string().optional().default("Bulk create records").describe(
|
|
1394
1453
|
'Explanation shown to the human reviewer for the whole batch \u2014 e.g. "Import 240 June webinar leads".'
|
|
1395
1454
|
),
|
|
1396
|
-
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
|
+
)
|
|
1397
1459
|
});
|
|
1398
1460
|
var recordFieldFilterInputSchema = z.object({
|
|
1399
1461
|
baseId: z.string().optional(),
|
|
@@ -1480,8 +1542,13 @@ var baseContract = {
|
|
|
1480
1542
|
path: "/bases",
|
|
1481
1543
|
tags: ["Bases"],
|
|
1482
1544
|
summary: "Create Base",
|
|
1483
|
-
successDescription: "Review-first by default: a pending ChangeRequest proposing the Base. Returns the materialized Base instead when `autoMerge: true` is passed."
|
|
1484
|
-
}).input(createBaseInputSchema).output(
|
|
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
|
+
),
|
|
1485
1552
|
createChangeRequest: oc.route({
|
|
1486
1553
|
method: "POST",
|
|
1487
1554
|
path: "/bases/{baseId}/change-requests",
|
|
@@ -1682,7 +1749,9 @@ var docSchema = z.object({
|
|
|
1682
1749
|
body: z.string()
|
|
1683
1750
|
});
|
|
1684
1751
|
var createDocInputSchema = z.object({
|
|
1685
|
-
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
|
+
),
|
|
1686
1755
|
slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
|
|
1687
1756
|
name: z.string().min(1),
|
|
1688
1757
|
description: z.string().optional().default(""),
|
|
@@ -1716,8 +1785,13 @@ var docContract = {
|
|
|
1716
1785
|
path: "/docs",
|
|
1717
1786
|
tags: ["Docs"],
|
|
1718
1787
|
summary: "Create Doc node",
|
|
1719
|
-
successDescription: "Review-first by default: a pending ChangeRequest proposing the Doc. Returns the materialized Doc node instead when `autoMerge: true` is passed."
|
|
1720
|
-
}).input(createDocInputSchema).output(
|
|
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
|
+
),
|
|
1721
1795
|
get: oc.route({
|
|
1722
1796
|
method: "GET",
|
|
1723
1797
|
path: "/docs/{nodeId}",
|
|
@@ -1851,7 +1925,9 @@ var FileNodeVOSchema = z.object({
|
|
|
1851
1925
|
|
|
1852
1926
|
// ../../packages/busabase-contract/src/domains/file-node/contract.ts
|
|
1853
1927
|
var createFileNodeInputSchema = z.object({
|
|
1854
|
-
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
|
+
),
|
|
1855
1931
|
slug: z.string().min(1).regex(/^[a-z0-9-]+$/),
|
|
1856
1932
|
name: z.string().min(1),
|
|
1857
1933
|
description: z.string().optional().default(""),
|
|
@@ -1875,8 +1951,13 @@ var fileContract = {
|
|
|
1875
1951
|
path: "/files",
|
|
1876
1952
|
tags: ["Files"],
|
|
1877
1953
|
summary: "Create File node",
|
|
1878
|
-
successDescription: "Review-first by default: a pending ChangeRequest proposing the File node. Returns the materialized File node instead when `autoMerge: true` is passed."
|
|
1879
|
-
}).input(createFileNodeInputSchema).output(
|
|
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
|
+
),
|
|
1880
1961
|
get: oc.route({
|
|
1881
1962
|
method: "GET",
|
|
1882
1963
|
path: "/files/{nodeId}",
|
|
@@ -2328,8 +2409,15 @@ var busabaseContractRoutes = {
|
|
|
2328
2409
|
path: "/nodes",
|
|
2329
2410
|
tags: ["Nodes"],
|
|
2330
2411
|
summary: "List node tree",
|
|
2331
|
-
successDescription: "Workspace node tree including folders, Bases, files, and agents."
|
|
2332
|
-
}).output(z.array(nodeSchema)),
|
|
2412
|
+
successDescription: "Workspace node tree including folders, Bases, files, and agents. With no `parentId`/`depth`, returns the FULL tree (legacy behavior, still what every non-sidebar caller gets). Passing `parentId` and/or `depth` switches to a depth-bounded fetch: `parentId` omitted/null starts from the space root and returns it wrapped exactly like the legacy call (just depth-limited); an explicit `parentId` returns that node's children directly, ready to merge into its `NodeVO.children` for a sidebar's lazy per-folder expand. See `NodeVO.hasChildren` for how a depth boundary is surfaced."
|
|
2413
|
+
}).input(listNodesInputSchema).output(z.array(nodeSchema)),
|
|
2414
|
+
isDescendant: oc.route({
|
|
2415
|
+
method: "GET",
|
|
2416
|
+
path: "/nodes/{nodeId}/is-descendant",
|
|
2417
|
+
tags: ["Nodes"],
|
|
2418
|
+
summary: "Check whether a node is a descendant of another",
|
|
2419
|
+
successDescription: "Server-authoritative parentId-chain walk from nodeId up to potentialAncestorId. Used to gate cross-branch drag-and-drop drops in the sidebar, since the full tree is no longer guaranteed to be loaded client-side (depth-bounded lazy load) \u2014 a purely local walk could wrongly allow dropping a folder into its own unloaded descendant."
|
|
2420
|
+
}).input(isDescendantInputSchema).output(isDescendantOutputSchema),
|
|
2333
2421
|
listArchived: oc.route({
|
|
2334
2422
|
method: "GET",
|
|
2335
2423
|
path: "/nodes/archived",
|
|
@@ -2417,7 +2505,7 @@ var busabaseContractRoutes = {
|
|
|
2417
2505
|
bases: baseContract,
|
|
2418
2506
|
skills: skillContract,
|
|
2419
2507
|
drives: driveContract,
|
|
2420
|
-
airapps: airappContract,
|
|
2508
|
+
airapps: { ...airappContract, ...airappRuntimeContract },
|
|
2421
2509
|
files: fileContract,
|
|
2422
2510
|
docs: docContract,
|
|
2423
2511
|
folders: folderContract,
|
|
@@ -2690,6 +2778,26 @@ function createBusabaseClient(config = {}) {
|
|
|
2690
2778
|
});
|
|
2691
2779
|
return createORPCClient(link);
|
|
2692
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
|
+
}
|
|
2693
2801
|
|
|
2694
2802
|
// src/index.ts
|
|
2695
2803
|
var Busabase = class {
|
|
@@ -2816,4 +2924,4 @@ var Busabase = class {
|
|
|
2816
2924
|
}
|
|
2817
2925
|
};
|
|
2818
2926
|
|
|
2819
|
-
export { Busabase, 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": "busa-sdk",
|
|
3
|
-
"version": "0.9.
|
|
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). Short-name alias for busabase-sdk.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/busabase/busabase/tree/main/apps/busabase-sdk",
|