busabase-sdk 0.9.17 → 0.10.0
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 +25 -32
- package/dist/index.js +22 -24
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -586,6 +586,10 @@ declare const cloudContract: {
|
|
|
586
586
|
name: z.ZodString;
|
|
587
587
|
slug: z.ZodNullable<z.ZodString>;
|
|
588
588
|
plan: z.ZodNullable<z.ZodString>;
|
|
589
|
+
nodeVisibilityMode: z.ZodOptional<z.ZodEnum<{
|
|
590
|
+
open: "open";
|
|
591
|
+
restricted: "restricted";
|
|
592
|
+
}>>;
|
|
589
593
|
}, z.core.$strip>;
|
|
590
594
|
user: z.ZodObject<{
|
|
591
595
|
id: z.ZodString;
|
|
@@ -603,6 +607,10 @@ declare const cloudContract: {
|
|
|
603
607
|
name: z.ZodString;
|
|
604
608
|
slug: z.ZodNullable<z.ZodString>;
|
|
605
609
|
plan: z.ZodNullable<z.ZodString>;
|
|
610
|
+
nodeVisibilityMode: z.ZodOptional<z.ZodEnum<{
|
|
611
|
+
open: "open";
|
|
612
|
+
restricted: "restricted";
|
|
613
|
+
}>>;
|
|
606
614
|
}, z.core.$strip>>;
|
|
607
615
|
createdSpace: z.ZodOptional<z.ZodBoolean>;
|
|
608
616
|
bootstrapRequired: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -23445,8 +23453,11 @@ interface BusabaseConfig {
|
|
|
23445
23453
|
*/
|
|
23446
23454
|
baseUrl?: string;
|
|
23447
23455
|
/**
|
|
23448
|
-
* Bearer token.
|
|
23449
|
-
*
|
|
23456
|
+
* Bearer token. Falls back to `BUSABASE_API_KEY`. Omit it in the two cases
|
|
23457
|
+
* where the server authenticates you some other way: a local OSS server
|
|
23458
|
+
* (`apps/busabase`) is open, and a *same-origin browser* call (e.g. from an
|
|
23459
|
+
* AirApp running inside Busabase) authenticates as the logged-in user via
|
|
23460
|
+
* the ambient session cookie.
|
|
23450
23461
|
*/
|
|
23451
23462
|
apiKey?: string;
|
|
23452
23463
|
/**
|
|
@@ -23484,43 +23495,25 @@ declare function resolveConfig(config?: BusabaseConfig): ResolvedConfig;
|
|
|
23484
23495
|
* Config fields default from `BUSABASE_BASE_URL` / `BUSABASE_API_KEY` /
|
|
23485
23496
|
* `BUSABASE_SPACE_ID` when omitted.
|
|
23486
23497
|
*
|
|
23498
|
+
* This is the *only* client the SDK ships. Browser code (an AirApp) and
|
|
23499
|
+
* server/CLI code use the same one — they differ only in where `baseUrl` and
|
|
23500
|
+
* the credential come from: an AirApp running inside Busabase passes
|
|
23501
|
+
* `baseUrl: window.location.origin` and no key (the ambient session cookie
|
|
23502
|
+
* authenticates it), while the same app run locally against a dev server
|
|
23503
|
+
* passes that server's URL and, for Busabase Cloud, an API key.
|
|
23504
|
+
*
|
|
23487
23505
|
* @example
|
|
23488
23506
|
* ```ts
|
|
23507
|
+
* // Server / CLI, against Busabase Cloud:
|
|
23489
23508
|
* const client = createBusabaseClient({ apiKey: process.env.BUSABASE_API_KEY });
|
|
23490
23509
|
* const bases = await client.bases.list();
|
|
23491
23510
|
* const record = await client.records.get({ recordId });
|
|
23511
|
+
*
|
|
23512
|
+
* // Browser (AirApp), same-origin — no key, the session cookie authenticates:
|
|
23513
|
+
* const client = createBusabaseClient({ baseUrl: window.location.origin });
|
|
23492
23514
|
* ```
|
|
23493
23515
|
*/
|
|
23494
23516
|
declare function createBusabaseClient(config?: BusabaseConfig): BusabaseClient;
|
|
23495
|
-
/** Options for {@link createBusabaseRpcClient}. No `apiKey`/`spaceId` — this
|
|
23496
|
-
* transport authenticates purely via the browser's ambient session cookie. */
|
|
23497
|
-
interface BusabaseRpcConfig {
|
|
23498
|
-
/**
|
|
23499
|
-
* Path to the internal RPC endpoint: either a full URL, or a path resolved
|
|
23500
|
-
* against `window.location.origin` (browser only — there is no ambient
|
|
23501
|
-
* session outside one).
|
|
23502
|
-
*
|
|
23503
|
-
* **The default (`/api/rpc`) only matches `apps/busabase` (the OSS app)**,
|
|
23504
|
-
* which mounts busabase's procedures unnamespaced. `apps/busabase-cloud`
|
|
23505
|
-
* mounts the *same* procedures under a `core` prefix instead — pass
|
|
23506
|
-
* `apiBasePath: "/api/rpc/core"` there, or this client will 404 on every
|
|
23507
|
-
* call. There is no single default that works for both; which one you're
|
|
23508
|
-
* targeting is something the caller has to know (this SDK doesn't probe
|
|
23509
|
-
* for it).
|
|
23510
|
-
*
|
|
23511
|
-
* From inside an AirApp running via Nodepod, prepend
|
|
23512
|
-
* `/__busabase_api__` to whichever of the above applies, to route through
|
|
23513
|
-
* the service-worker bridge instead of the sandboxed virtual server — e.g.
|
|
23514
|
-
* `/__busabase_api__/api/rpc/core` for busabase-cloud. See
|
|
23515
|
-
* apps/busabase/docs/node-types.md.
|
|
23516
|
-
*/
|
|
23517
|
-
apiBasePath?: string;
|
|
23518
|
-
/** Extra headers merged into every request. Static object or a (possibly async) factory. */
|
|
23519
|
-
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
23520
|
-
/** Custom `fetch` implementation (e.g. a proxy-aware or instrumented fetch). */
|
|
23521
|
-
fetch?: typeof fetch;
|
|
23522
|
-
}
|
|
23523
|
-
declare function createBusabaseRpcClient(config?: BusabaseRpcConfig): BusabaseClient;
|
|
23524
23517
|
|
|
23525
23518
|
/**
|
|
23526
23519
|
* Attachments — DTO/VO Zod schemas + inferred types (the contract's type source
|
|
@@ -25834,4 +25827,4 @@ declare class Busabase {
|
|
|
25834
25827
|
}>>>>;
|
|
25835
25828
|
}
|
|
25836
25829
|
|
|
25837
|
-
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,
|
|
25830
|
+
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, type CreateFormDTO, 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 FormFieldBindingVO, type FormPageSourceVO, type FormShareVO, type FormSubmitResultVO, type FormThemeVO, type FormVO, type GalleryCardSize, type GalleryCoverFit, type GanttScale, type LookupRollup, type NodeSearchResultVO, 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 SubmitFormDTO, type UpdateFormDTO, type UpdateVaultSettingsDTO, type UserRefVO, VIEW_FIELD_MAX_WIDTH, VIEW_FIELD_MIN_WIDTH, 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 ViewType, type ViewVO, cloudContract, createBusabaseClient, normalizeBaseUrl, resolveConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createORPCClient, ORPCError } from '@orpc/client';
|
|
2
|
-
import { RPCLink } from '@orpc/client/fetch';
|
|
3
|
-
import { oc, eventIterator, inferRPCMethodFromContractRouter } from '@orpc/contract';
|
|
4
2
|
import { OpenAPILink } from '@orpc/openapi-client/fetch';
|
|
3
|
+
import { oc, eventIterator } from '@orpc/contract';
|
|
5
4
|
import { z } from 'zod';
|
|
6
5
|
|
|
7
6
|
// src/client.ts
|
|
@@ -890,7 +889,23 @@ var authSpaceSchema = z.object({
|
|
|
890
889
|
id: z.string(),
|
|
891
890
|
name: z.string(),
|
|
892
891
|
slug: z.string().nullable(),
|
|
893
|
-
plan: z.string().nullable()
|
|
892
|
+
plan: z.string().nullable(),
|
|
893
|
+
/**
|
|
894
|
+
* The space's DEFAULT content visibility for its members — the same
|
|
895
|
+
* `spaces.nodeVisibilityMode` the cloud dashboard reads. `"open"` = a node
|
|
896
|
+
* with no explicit visibility anywhere in its ancestor chain is visible to
|
|
897
|
+
* every member; `"restricted"` = such a node is hidden from non-managers
|
|
898
|
+
* until it is explicitly opened (per-node visibility or a grant).
|
|
899
|
+
*
|
|
900
|
+
* Clients need it to describe a node's EFFECTIVE access truthfully ("everyone
|
|
901
|
+
* in this space can see this" is a lie in a restricted space) and to decide
|
|
902
|
+
* whether per-node grants are meaningful to show at all.
|
|
903
|
+
*
|
|
904
|
+
* OPTIONAL on purpose: it was added after this VO shipped, so an older server
|
|
905
|
+
* (or a host that doesn't model a space default at all) simply omits it.
|
|
906
|
+
* Treat an absent value as `"open"` — the historical behaviour.
|
|
907
|
+
*/
|
|
908
|
+
nodeVisibilityMode: z.enum(["open", "restricted"]).optional()
|
|
894
909
|
});
|
|
895
910
|
var authUserSchema = z.object({
|
|
896
911
|
id: z.string(),
|
|
@@ -3062,6 +3077,9 @@ var busabaseContractRoutes = {
|
|
|
3062
3077
|
live: {
|
|
3063
3078
|
// RPC-only by design: no `.route(...)`, so OpenAPI generation and MCP tool
|
|
3064
3079
|
// discovery skip this long-lived Event Iterator while `/api/rpc` stays typed.
|
|
3080
|
+
// (MCP discovery only skips it because `discoverOpenApiTools` now requires a
|
|
3081
|
+
// route with a method or path — omitting `.route()` still leaves `route: {}`,
|
|
3082
|
+
// which is truthy, and that used to publish this as a callable REST tool.)
|
|
3065
3083
|
subscribe: oc.output(eventIterator(liveEventSchema))
|
|
3066
3084
|
},
|
|
3067
3085
|
bases: baseContract,
|
|
@@ -3481,26 +3499,6 @@ function createBusabaseClient(config = {}) {
|
|
|
3481
3499
|
});
|
|
3482
3500
|
return createORPCClient(link);
|
|
3483
3501
|
}
|
|
3484
|
-
var getBrowserWindow = () => globalThis.window;
|
|
3485
|
-
function createBusabaseRpcClient(config = {}) {
|
|
3486
|
-
const apiBasePath = config.apiBasePath ?? "/api/rpc";
|
|
3487
|
-
const isAbsolute = /^https?:\/\//.test(apiBasePath);
|
|
3488
|
-
if (!isAbsolute && typeof getBrowserWindow() === "undefined") {
|
|
3489
|
-
throw new Error(
|
|
3490
|
-
"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."
|
|
3491
|
-
);
|
|
3492
|
-
}
|
|
3493
|
-
const link = new RPCLink({
|
|
3494
|
-
method: inferRPCMethodFromContractRouter(cloudContract),
|
|
3495
|
-
url: () => isAbsolute ? apiBasePath : `${getBrowserWindow()?.location.origin}${apiBasePath}`,
|
|
3496
|
-
fetch: config.fetch,
|
|
3497
|
-
headers: async () => {
|
|
3498
|
-
const extra = typeof config.headers === "function" ? await config.headers() : config.headers;
|
|
3499
|
-
return { ...extra };
|
|
3500
|
-
}
|
|
3501
|
-
});
|
|
3502
|
-
return createORPCClient(link);
|
|
3503
|
-
}
|
|
3504
3502
|
|
|
3505
3503
|
// src/index.ts
|
|
3506
3504
|
var Busabase = class {
|
|
@@ -3630,4 +3628,4 @@ var Busabase = class {
|
|
|
3630
3628
|
}
|
|
3631
3629
|
};
|
|
3632
3630
|
|
|
3633
|
-
export { Busabase, CREATABLE_NODE_TYPES, DEFAULT_BASE_URL, cloudContract, createBusabaseClient,
|
|
3631
|
+
export { Busabase, CREATABLE_NODE_TYPES, DEFAULT_BASE_URL, cloudContract, createBusabaseClient, normalizeBaseUrl, resolveConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "busabase-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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,8 +41,8 @@
|
|
|
41
41
|
"tsx": "^4.20.5",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vitest": "^2.1.8",
|
|
44
|
-
"busabase-contract": "0.9.17",
|
|
45
44
|
"openlib": "0.1.1",
|
|
45
|
+
"busabase-contract": "0.10.0",
|
|
46
46
|
"open-domains": "0.0.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|