busabase-sdk 0.17.2 → 0.18.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/airapp-gate.d.ts +74 -114
- package/dist/airapp-gate.js +231 -229
- package/dist/airapp-node.d.ts +97 -52
- package/dist/airapp-node.js +422 -444
- package/dist/airapp.d.ts +102 -147
- package/dist/airapp.js +432 -423
- package/dist/client-CbUceGzy.d.ts +20523 -0
- package/dist/index.d.ts +2807 -2739
- package/dist/index.js +4803 -4029
- package/dist/oauth-Dg2Z41RP.js +173 -0
- package/dist/oauth-FfuT0EGC.d.ts +69 -0
- package/dist/oauth-node-DGiWkh_l.d.ts +64 -0
- package/dist/oauth-node.d.ts +2 -64
- package/dist/oauth-node.js +188 -3
- package/dist/oauth.d.ts +2 -67
- package/dist/oauth.js +2 -2
- package/dist/url-B8GMXalA.js +10 -0
- package/package.json +6 -6
- package/dist/chunk-5NYQX65A.js +0 -6
- package/dist/chunk-C23JVY2Y.js +0 -211
- package/dist/chunk-WSHJMHUS.js +0 -215
- package/dist/client-DIlpYL9z.d.ts +0 -17818
package/dist/airapp.d.ts
CHANGED
|
@@ -1,56 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import '@orpc/shared';
|
|
4
|
-
import 'zod';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* AirApp resource provisioning — how an app claims (or creates) the Folder and
|
|
8
|
-
* Bases it declares, exactly once, without ever taking over someone else's.
|
|
9
|
-
*
|
|
10
|
-
* Every App-in-Skill shipped a byte-identical copy of this module (280 lines ×
|
|
11
|
-
* 65 apps, two spellings). That is the wrong place for it: the rules encoded
|
|
12
|
-
* here are not app preferences, they are the safety boundary that keeps an app
|
|
13
|
-
* from adopting a Folder a human created for something else. A third party
|
|
14
|
-
* re-deriving them from scratch gets the happy path right and the conflict
|
|
15
|
-
* cases wrong, and the failure is silent — the app happily writes into data it
|
|
16
|
-
* does not own.
|
|
17
|
-
*
|
|
18
|
-
* The contract, in one line: **an app owns a node only if it stamped it.**
|
|
19
|
-
* Ownership lives in `node.metadata` as `{ appId, resourceKey, schemaVersion }`.
|
|
20
|
-
* Anything else is either a legacy node this app plausibly created before
|
|
21
|
-
* stamping existed (claimable *only* after a full structural fingerprint match)
|
|
22
|
-
* or someone else's (never touched, always a `SETUP_CONFLICT`).
|
|
23
|
-
*
|
|
24
|
-
* This module is isomorphic — browser and Node both — and holds no I/O beyond
|
|
25
|
-
* the passed-in client.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { createBusabaseClient } from "busabase-sdk";
|
|
30
|
-
* import { inspectProvisionedResources, provisionDeclaredResources } from "busabase-sdk/airapp";
|
|
31
|
-
*
|
|
32
|
-
* const client = createBusabaseClient({ baseUrl: window.location.origin });
|
|
33
|
-
* const config = {
|
|
34
|
-
* appId: "kelly-crm",
|
|
35
|
-
* appName: "Kelly CRM",
|
|
36
|
-
* schemaVersion: 1,
|
|
37
|
-
* folder: { slug: "kelly-crm", name: "Kelly CRM", description: "CRM workspace" },
|
|
38
|
-
* bases: [{ key: "contacts", slug: "kelly-crm-contacts-v1", name: "Contacts", fields: [...] }],
|
|
39
|
-
* };
|
|
40
|
-
*
|
|
41
|
-
* let resources = await inspectProvisionedResources(client, config);
|
|
42
|
-
* if (!resources.folder || resources.missing.length) {
|
|
43
|
-
* resources = await provisionDeclaredResources(client, config); // one idempotent ChangeRequest
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
|
|
1
|
+
import { t as BusabaseClient } from "./client-CbUceGzy.js";
|
|
2
|
+
//#region src/airapp.d.ts
|
|
48
3
|
type NodeChangeRequestInput = Parameters<BusabaseClient["nodes"]["createChangeRequest"]>[0];
|
|
49
4
|
type NodeOperationInput = NodeChangeRequestInput["operations"][number];
|
|
50
5
|
type FileTreeChangeRequestInput = Parameters<BusabaseClient["fileTrees"]["createChangeRequest"]>[0];
|
|
51
6
|
type FileTreeOperationInput = FileTreeChangeRequestInput["operations"][number];
|
|
52
7
|
type FileTreeCreateOrUpdateOperation = Extract<FileTreeOperationInput, {
|
|
53
|
-
|
|
8
|
+
kind: "create" | "update";
|
|
54
9
|
}>;
|
|
55
10
|
/**
|
|
56
11
|
* A Base field, as an app declares it.
|
|
@@ -65,35 +20,35 @@ type FileTreeCreateOrUpdateOperation = Extract<FileTreeOperationInput, {
|
|
|
65
20
|
* surface to match how declarations are actually written.
|
|
66
21
|
*/
|
|
67
22
|
interface AirAppFieldDeclaration {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
23
|
+
slug: string;
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
options?: Record<string, unknown>;
|
|
73
28
|
}
|
|
74
29
|
/** The client surface provisioning needs. Both `BusabaseClient` and `Busabase` satisfy it. */
|
|
75
30
|
type AirAppProvisioningClient = Pick<BusabaseClient, "nodes" | "bases">;
|
|
76
31
|
/** One Base the app declares it needs. `key` is the app's stable internal handle. */
|
|
77
32
|
interface AirAppBaseDeclaration {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
33
|
+
/** Stable internal handle, e.g. `"contacts"`. Also the node's `resourceKey`. */
|
|
34
|
+
key: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
fields: AirAppFieldDeclaration[];
|
|
39
|
+
/** Resolved at provision time; ignore when declaring. */
|
|
40
|
+
nodeId?: string;
|
|
41
|
+
/** Resolved at provision time; ignore when declaring. */
|
|
42
|
+
baseId?: string;
|
|
43
|
+
/** Free-form extras an app keeps alongside its declaration (e.g. `readLimit`). */
|
|
44
|
+
[extra: string]: unknown;
|
|
90
45
|
}
|
|
91
46
|
interface AirAppFolderDeclaration {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
47
|
+
slug: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
/** Pin the Folder by id once known; otherwise it is discovered by slug. */
|
|
51
|
+
nodeId?: string;
|
|
97
52
|
}
|
|
98
53
|
/**
|
|
99
54
|
* The app's own AirApp node, when it ships one inside its Folder.
|
|
@@ -109,25 +64,25 @@ interface AirAppFolderDeclaration {
|
|
|
109
64
|
* unattributable stranger, and the legacy claim would be refused.
|
|
110
65
|
*/
|
|
111
66
|
interface AirAppNodeDeclaration {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
67
|
+
slug: string;
|
|
68
|
+
name: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
/** Ownership key written into the node's metadata, e.g. `"airapp"`. */
|
|
71
|
+
resourceKey: string;
|
|
117
72
|
}
|
|
118
73
|
/** Everything an app declares about the workspace shape it needs. */
|
|
119
74
|
interface AirAppResourceConfig {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
75
|
+
appId: string;
|
|
76
|
+
appName: string;
|
|
77
|
+
/**
|
|
78
|
+
* Bump when the declared shape changes. A node stamped with an older version
|
|
79
|
+
* is re-stamped (a "repair"), not recreated — the data survives.
|
|
80
|
+
*/
|
|
81
|
+
schemaVersion: number;
|
|
82
|
+
folder: AirAppFolderDeclaration;
|
|
83
|
+
bases: AirAppBaseDeclaration[];
|
|
84
|
+
/** The app's own AirApp node inside the Folder, when it ships one. */
|
|
85
|
+
airApp?: AirAppNodeDeclaration;
|
|
131
86
|
}
|
|
132
87
|
/**
|
|
133
88
|
* The ownership stamp written into `node.metadata`.
|
|
@@ -137,48 +92,48 @@ interface AirAppResourceConfig {
|
|
|
137
92
|
* being open to declaration merging — is not assignable to an index signature.
|
|
138
93
|
*/
|
|
139
94
|
type AirAppResourceOwnership = {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
95
|
+
appId: string;
|
|
96
|
+
resourceKey: string;
|
|
97
|
+
schemaVersion: number;
|
|
143
98
|
};
|
|
144
99
|
/** A node this app owns but whose ownership stamp needs (re)writing. */
|
|
145
100
|
interface AirAppOwnershipRepair {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
101
|
+
nodeId: string;
|
|
102
|
+
baseId?: string;
|
|
103
|
+
resourceKey: string;
|
|
104
|
+
metadata: AirAppResourceOwnership;
|
|
150
105
|
}
|
|
151
106
|
interface AirAppProvisionedBase extends AirAppBaseDeclaration {
|
|
152
|
-
|
|
153
|
-
|
|
107
|
+
nodeId: string;
|
|
108
|
+
baseId: string;
|
|
154
109
|
}
|
|
155
110
|
interface AirAppResources {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
111
|
+
/** The app's root Folder, or `null` when it does not exist yet. */
|
|
112
|
+
folder: (AirAppFolderDeclaration & {
|
|
113
|
+
nodeId: string;
|
|
114
|
+
}) | null;
|
|
115
|
+
/** Declared Bases that exist and are owned, with their resolved ids. */
|
|
116
|
+
bases: AirAppProvisionedBase[];
|
|
117
|
+
/** Declared Bases that do not exist yet. */
|
|
118
|
+
missing: AirAppBaseDeclaration[];
|
|
119
|
+
/** Owned nodes whose ownership stamp is missing or stale. */
|
|
120
|
+
repairs: AirAppOwnershipRepair[];
|
|
121
|
+
/**
|
|
122
|
+
* The app's own AirApp node (see `AirAppNodeDeclaration`), when `config.airApp`
|
|
123
|
+
* is declared and a matching node exists under the Folder — owned or legacy,
|
|
124
|
+
* stamped or not; a pending stamp repair is reported separately via `repairs`.
|
|
125
|
+
* `null` when not declared, or declared but not found — the latter is what
|
|
126
|
+
* `publishAirApp` treats as "create", not a `missing`-array entry, because
|
|
127
|
+
* unlike a Base it is never auto-created just by finding it absent.
|
|
128
|
+
*/
|
|
129
|
+
airApp: {
|
|
130
|
+
nodeId: string;
|
|
131
|
+
} | null;
|
|
132
|
+
/**
|
|
133
|
+
* Set when the server is too old for `nodes.updateMetadata`, so ownership was
|
|
134
|
+
* established by full structural fingerprint instead of a stamp.
|
|
135
|
+
*/
|
|
136
|
+
compatibilityMode?: "verified-legacy-fingerprint";
|
|
182
137
|
}
|
|
183
138
|
/**
|
|
184
139
|
* Why setup cannot proceed. These are the app's five distinguishable states —
|
|
@@ -199,27 +154,27 @@ type AirAppSetupCode = "SETUP_REQUIRED" | "SETUP_PENDING" | "SETUP_CONFLICT" | "
|
|
|
199
154
|
* this class without touching its rendering code, then move to `error.code`.
|
|
200
155
|
*/
|
|
201
156
|
declare class AirAppSetupError extends Error {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
157
|
+
readonly code: AirAppSetupCode;
|
|
158
|
+
/** The human-readable half, without the `CODE: ` prefix. */
|
|
159
|
+
readonly detail: string;
|
|
160
|
+
constructor(code: AirAppSetupCode, detail: string);
|
|
206
161
|
}
|
|
207
162
|
/** True for a 404 / NOT_FOUND from any of the client's transports. */
|
|
208
163
|
declare const isNotFound: (error: unknown) => boolean;
|
|
209
164
|
/** A node as this module reads it — the fields provisioning actually looks at. */
|
|
210
165
|
interface ReadNode {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
166
|
+
id: string;
|
|
167
|
+
type: string;
|
|
168
|
+
slug: string;
|
|
169
|
+
name: string;
|
|
170
|
+
description: string;
|
|
171
|
+
baseId: string | null;
|
|
172
|
+
metadata: Record<string, unknown>;
|
|
173
|
+
children?: ReadNode[];
|
|
219
174
|
}
|
|
220
175
|
interface ReadFolderDetail {
|
|
221
|
-
|
|
222
|
-
|
|
176
|
+
node: ReadNode;
|
|
177
|
+
children: ReadNode[];
|
|
223
178
|
}
|
|
224
179
|
/**
|
|
225
180
|
* Decide, from one already-read Folder, what exists / is missing / needs
|
|
@@ -237,7 +192,7 @@ declare function resolveProvisionedFolder(folder: ReadFolderDetail | null | unde
|
|
|
237
192
|
* structure lands in a single reviewable change.
|
|
238
193
|
*/
|
|
239
194
|
declare function buildProvisionOperations(config: AirAppResourceConfig, folder: {
|
|
240
|
-
|
|
195
|
+
nodeId: string;
|
|
241
196
|
} | null, missingBases: AirAppBaseDeclaration[]): NodeOperationInput[];
|
|
242
197
|
/** Read the current state of this app's declared resources. Never mutates. */
|
|
243
198
|
declare function inspectProvisionedResources(client: AirAppProvisioningClient, config: AirAppResourceConfig): Promise<AirAppResources>;
|
|
@@ -254,19 +209,19 @@ declare function provisionDeclaredResources(client: AirAppProvisioningClient, co
|
|
|
254
209
|
type AirAppPublishClient = AirAppProvisioningClient & Pick<BusabaseClient, "fileTrees" | "changeRequests">;
|
|
255
210
|
/** One file of the app's built AirApp bundle, as `publishAirApp` receives it. */
|
|
256
211
|
interface AirAppFileInput {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
212
|
+
path: string;
|
|
213
|
+
content: string;
|
|
214
|
+
mimeType?: string;
|
|
260
215
|
}
|
|
261
216
|
type AirAppPublishResult = {
|
|
262
|
-
|
|
263
|
-
|
|
217
|
+
status: "created";
|
|
218
|
+
changeRequestId: string;
|
|
264
219
|
} | {
|
|
265
|
-
|
|
266
|
-
|
|
220
|
+
status: "updated";
|
|
221
|
+
changeRequestId: string;
|
|
267
222
|
} | {
|
|
268
|
-
|
|
269
|
-
|
|
223
|
+
status: "pending";
|
|
224
|
+
changeRequestId: string;
|
|
270
225
|
};
|
|
271
226
|
/**
|
|
272
227
|
* The create-vs-update operation list for one AirApp publish. Pure — no I/O —
|
|
@@ -297,5 +252,5 @@ declare function buildAirAppFileOperations(localFiles: AirAppFileInput[], deploy
|
|
|
297
252
|
* `airApp`; `SETUP_REQUIRED` when the Folder does not exist yet.
|
|
298
253
|
*/
|
|
299
254
|
declare function publishAirApp(client: AirAppPublishClient, config: AirAppResourceConfig, files: AirAppFileInput[]): Promise<AirAppPublishResult>;
|
|
300
|
-
|
|
301
|
-
export {
|
|
255
|
+
//#endregion
|
|
256
|
+
export { AirAppBaseDeclaration, AirAppFieldDeclaration, AirAppFileInput, AirAppFolderDeclaration, AirAppNodeDeclaration, AirAppOwnershipRepair, AirAppProvisionedBase, AirAppProvisioningClient, AirAppPublishClient, AirAppPublishResult, AirAppResourceConfig, AirAppResourceOwnership, AirAppResources, AirAppSetupCode, AirAppSetupError, buildAirAppFileOperations, buildProvisionOperations, inspectProvisionedResources, isNotFound, provisionDeclaredResources, publishAirApp, resolveProvisionedFolder };
|