js-bao-wss-client 2.0.4 → 2.0.6

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.
Files changed (60) hide show
  1. package/README.md +242 -39
  2. package/dist/JsBaoClient.d.ts +293 -41
  3. package/dist/JsBaoClient.d.ts.map +1 -1
  4. package/dist/JsBaoClient.js +241 -5
  5. package/dist/JsBaoClient.js.map +1 -1
  6. package/dist/api/blobBucketsApi.d.ts +29 -1
  7. package/dist/api/blobBucketsApi.d.ts.map +1 -1
  8. package/dist/api/blobBucketsApi.js +5 -3
  9. package/dist/api/blobBucketsApi.js.map +1 -1
  10. package/dist/api/collectionsApi.d.ts +9 -1
  11. package/dist/api/collectionsApi.d.ts.map +1 -1
  12. package/dist/api/collectionsApi.js.map +1 -1
  13. package/dist/api/cronTriggersApi.d.ts +19 -6
  14. package/dist/api/cronTriggersApi.d.ts.map +1 -1
  15. package/dist/api/cronTriggersApi.js.map +1 -1
  16. package/dist/api/databaseTypeConfigsApi.d.ts +6 -4
  17. package/dist/api/databaseTypeConfigsApi.d.ts.map +1 -1
  18. package/dist/api/databaseTypeConfigsApi.js.map +1 -1
  19. package/dist/api/databasesApi.d.ts +83 -69
  20. package/dist/api/databasesApi.d.ts.map +1 -1
  21. package/dist/api/databasesApi.js +10 -0
  22. package/dist/api/databasesApi.js.map +1 -1
  23. package/dist/api/documentsApi.d.ts +71 -12
  24. package/dist/api/documentsApi.d.ts.map +1 -1
  25. package/dist/api/documentsApi.js +56 -20
  26. package/dist/api/documentsApi.js.map +1 -1
  27. package/dist/api/geminiApi.d.ts.map +1 -1
  28. package/dist/api/geminiApi.js +11 -14
  29. package/dist/api/geminiApi.js.map +1 -1
  30. package/dist/api/groupsApi.d.ts +20 -4
  31. package/dist/api/groupsApi.d.ts.map +1 -1
  32. package/dist/api/groupsApi.js +9 -1
  33. package/dist/api/groupsApi.js.map +1 -1
  34. package/dist/api/notificationsApi.d.ts +134 -0
  35. package/dist/api/notificationsApi.d.ts.map +1 -0
  36. package/dist/api/notificationsApi.js +52 -0
  37. package/dist/api/notificationsApi.js.map +1 -0
  38. package/dist/api/operationDefinition.d.ts +279 -0
  39. package/dist/api/operationDefinition.d.ts.map +1 -0
  40. package/dist/api/operationDefinition.js +47 -0
  41. package/dist/api/operationDefinition.js.map +1 -0
  42. package/dist/api/resourceMetadataApi.d.ts +182 -0
  43. package/dist/api/resourceMetadataApi.d.ts.map +1 -0
  44. package/dist/api/resourceMetadataApi.js +56 -0
  45. package/dist/api/resourceMetadataApi.js.map +1 -0
  46. package/dist/browser.umd.js +554 -59
  47. package/dist/browser.umd.js.map +1 -1
  48. package/dist/errors.d.ts +34 -1
  49. package/dist/errors.d.ts.map +1 -1
  50. package/dist/errors.js +56 -0
  51. package/dist/errors.js.map +1 -1
  52. package/dist/internal/authController.d.ts +10 -0
  53. package/dist/internal/authController.d.ts.map +1 -1
  54. package/dist/internal/authController.js +14 -2
  55. package/dist/internal/authController.js.map +1 -1
  56. package/dist/internal/httpClient.d.ts +8 -0
  57. package/dist/internal/httpClient.d.ts.map +1 -1
  58. package/dist/internal/httpClient.js +34 -5
  59. package/dist/internal/httpClient.js.map +1 -1
  60. package/package.json +6 -2
@@ -0,0 +1,52 @@
1
+ // ── API ──
2
+ /**
3
+ * Sub-API for the notification inbox (`client.notifications.*`).
4
+ *
5
+ * Inbox reads/writes act on the signed-in user's own notifications. `send()`
6
+ * requires app admin permission. Live updates arrive as the `notification`
7
+ * client event (`client.on("notification", ...)`).
8
+ */
9
+ export class NotificationsAPI {
10
+ constructor(client) {
11
+ this.client = client;
12
+ }
13
+ /** List the caller's notifications, newest first. */
14
+ async list(options) {
15
+ const params = new URLSearchParams();
16
+ if (options?.limit !== undefined)
17
+ params.set("limit", String(options.limit));
18
+ if (options?.cursor)
19
+ params.set("cursor", options.cursor);
20
+ const query = params.toString() ? `?${params.toString()}` : "";
21
+ return this.client.makeRequest("GET", `/notifications${query}`);
22
+ }
23
+ /** Count the caller's unread notifications. */
24
+ async unreadCount() {
25
+ return this.client.makeRequest("GET", "/notifications/unread-count");
26
+ }
27
+ /** Mark one of the caller's notifications as read. */
28
+ async markRead(notificationId) {
29
+ return this.client.makeRequest("PATCH", `/notifications/${encodeURIComponent(notificationId)}/read`, {});
30
+ }
31
+ /** Mark all of the caller's notifications as read. */
32
+ async markAllRead() {
33
+ return this.client.makeRequest("POST", "/notifications/read-all", {});
34
+ }
35
+ /** Send a notification to an app user (requires app admin permission). */
36
+ async send(params) {
37
+ return this.client.makeRequest("POST", "/notifications/send", params);
38
+ }
39
+ /** Register (upsert) the calling user's device push token. */
40
+ async registerDevice(params) {
41
+ return this.client.makeRequest("POST", "/me/push-tokens", params);
42
+ }
43
+ /** List the calling user's registered push devices. */
44
+ async listDevices() {
45
+ return this.client.makeRequest("GET", "/me/push-tokens");
46
+ }
47
+ /** Unregister one of the calling user's device push tokens (e.g. on logout). */
48
+ async unregisterDevice(token) {
49
+ return this.client.makeRequest("DELETE", `/me/push-tokens/${encodeURIComponent(token)}`);
50
+ }
51
+ }
52
+ //# sourceMappingURL=notificationsApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationsApi.js","sourceRoot":"","sources":["../../api/notificationsApi.ts"],"names":[],"mappings":"AAuGA,YAAY;AAEZ;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD,qDAAqD;IACrD,KAAK,CAAC,IAAI,CACR,OAAiC;QAEjC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,EAAE,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CA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MAAM,CAAC,WAAW,CAC5B,QAAQ,EACR,mBAAmB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CACd,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Typed database operation definitions (issue #1544).
3
+ *
4
+ * These types replace the previous `definition: Record<string, any>` on
5
+ * `createOperation` / `updateOperation` / `DatabaseOperationInfo`. They are
6
+ * hand-authored to mirror the server validator
7
+ * (`validateDefinition` in `database-type-operations-controller.ts`), whose
8
+ * declarative allow-lists live in the dependency-free descriptor
9
+ * `src/app-api/controllers/operation-definition-descriptor.ts`. A key-parity
10
+ * test (`cli/tests/unit/operation-def-client-types.test.ts`) asserts that each
11
+ * member below carries exactly the keys the descriptor allows, and a byte-copy
12
+ * drift guard keeps the vendored descriptor in step with the server — so these
13
+ * types can never silently diverge from what the server enforces.
14
+ *
15
+ * The discriminated union lives at the PARAMS level, not on `definition` alone:
16
+ * the op `type` is a sibling of `definition`, so `CreateOperationParams` and
17
+ * `DatabaseOperationInfo` are unions keyed on `type` that bind the matching
18
+ * definition shape. `updateOperation` takes the plain `OperationDefinition`
19
+ * union (a partial update can change `type` and definition independently, so it
20
+ * makes no per-type narrowing claim).
21
+ *
22
+ * The leaf value shapes (filter objects, CEL expression strings, `$params`
23
+ * references) stay permissive on purpose — the server is the authoritative
24
+ * runtime boundary for those; these types describe the STRUCTURE (which op
25
+ * types exist and which keys each definition allows) that the audit found
26
+ * untyped, without over-promising the contents of a filter or a CEL string.
27
+ *
28
+ * This module is deliberately dependency-free (only `import type` for the
29
+ * runtime-key self-check helper is inlined below) so it can be imported by the
30
+ * codegen key-parity test without dragging in the full client graph.
31
+ */
32
+ /** The operation kinds accepted by `createOperation` / `updateOperation`. */
33
+ export type OperationType = "query" | "mutation" | "count" | "aggregate" | "pipeline" | "applyToQuery";
34
+ /**
35
+ * A filter is a structured query object or a `$params.<name>` reference string
36
+ * resolved at execution time. The server validates its contents; the client
37
+ * keeps it permissive.
38
+ */
39
+ export type OperationFilter = Record<string, any> | string;
40
+ /** An object literal or a `$params.<name>` reference string. */
41
+ export type ObjectOrParamsRef = Record<string, any> | string;
42
+ /** A `query` operation definition. Keys: filter, sort, limit, projection, include, cache. */
43
+ export interface QueryDefinition {
44
+ /** Structured filter object, or a `$params` reference. Required. */
45
+ filter: OperationFilter;
46
+ /** Field → sort direction (`1` ascending, `-1` descending). */
47
+ sort?: Record<string, 1 | -1>;
48
+ /** Maximum records to return (server caps at 1000). */
49
+ limit?: number;
50
+ /**
51
+ * Field projection: an include map (`{ field: 1 }`) or an exclude map
52
+ * (`{ field: 0 }`). The server's `validateProjectionAndSort` accepts only a
53
+ * plain object whose values are exactly `0` or `1` — arrays and boolean
54
+ * values are rejected with a 400.
55
+ */
56
+ projection?: Record<string, 0 | 1>;
57
+ /** Related records to include in the result. */
58
+ include?: Record<string, any>;
59
+ /** Opt-in result-cache configuration (#1247); query definitions only. */
60
+ cache?: Record<string, any>;
61
+ }
62
+ /** A single write inside a `mutation` definition's `operations` array. */
63
+ export interface MutationOperation {
64
+ op: "save" | "patch" | "delete" | "increment" | "addToSet" | "removeFromSet";
65
+ /** Target record id (required for patch/delete/increment/addToSet/removeFromSet). */
66
+ id?: string;
67
+ /** Record data for save/patch (object or `$params` reference). */
68
+ data?: ObjectOrParamsRef;
69
+ /** Field → increment amount for `increment` (object or `$params` reference). */
70
+ fields?: ObjectOrParamsRef;
71
+ /** Field → string-set members for addToSet/removeFromSet (object or `$params`). */
72
+ stringSets?: ObjectOrParamsRef;
73
+ /** `save` only: skip when the record already exists. */
74
+ ifNotExists?: boolean;
75
+ /** `save` only: a CEL condition (or `$params` reference) gating the write. */
76
+ condition?: string;
77
+ /** `save` only: field name (or `$params` reference) to upsert on. */
78
+ upsertOn?: string;
79
+ }
80
+ /** A `mutation` operation definition. Keys: operations. */
81
+ export interface MutationDefinition {
82
+ operations: MutationOperation[];
83
+ }
84
+ /** A `count` operation definition. Keys: filter. */
85
+ export interface CountDefinition {
86
+ filter: OperationFilter;
87
+ }
88
+ /** A single aggregation inside an `aggregate` definition's `operations` array. */
89
+ export interface AggregateOperation {
90
+ type: "count" | "sum" | "avg" | "min" | "max";
91
+ /** Field to aggregate. Required for every op except `count`. */
92
+ field?: string;
93
+ }
94
+ /** A `groupBy` entry: a field name or a StringSet-membership descriptor. */
95
+ export type AggregateGroupByEntry = string | {
96
+ field: string;
97
+ contains: string;
98
+ };
99
+ /** An `aggregate` operation definition. Keys: groupBy, operations, filter, limit, sort. */
100
+ export interface AggregateDefinition {
101
+ groupBy: AggregateGroupByEntry[] | string;
102
+ operations: AggregateOperation[] | string;
103
+ filter?: OperationFilter;
104
+ limit?: number;
105
+ sort?: {
106
+ field: string;
107
+ direction: 1 | -1;
108
+ };
109
+ }
110
+ /**
111
+ * A `query` step inside a `pipeline` definition's `steps` array. Keys:
112
+ * name, type, modelName, filter, sort, limit, projection, include.
113
+ */
114
+ export interface PipelineQueryStep {
115
+ /** Unique step name (referenced by later steps as `$steps.<name>`). */
116
+ name: string;
117
+ type: "query";
118
+ modelName: string;
119
+ /** Structured filter object, or a `$params`/`$steps` reference. Required. */
120
+ filter: OperationFilter;
121
+ /** Field → sort direction (`1` ascending, `-1` descending). */
122
+ sort?: Record<string, 1 | -1>;
123
+ limit?: number;
124
+ /** Field projection: an include (`1`) or exclude (`0`) map. Object only. */
125
+ projection?: Record<string, 0 | 1>;
126
+ include?: Record<string, any>;
127
+ }
128
+ /**
129
+ * A `count` step inside a `pipeline` definition's `steps` array. Keys:
130
+ * name, type, modelName, filter. A count step takes no sort/limit/projection.
131
+ */
132
+ export interface PipelineCountStep {
133
+ /** Unique step name (referenced by later steps as `$steps.<name>`). */
134
+ name: string;
135
+ type: "count";
136
+ modelName: string;
137
+ /** Structured filter object, or a `$params`/`$steps` reference. Required. */
138
+ filter: OperationFilter;
139
+ }
140
+ /**
141
+ * An `aggregate` step inside a `pipeline` definition's `steps` array. Keys:
142
+ * name, type, modelName, groupBy, operations, filter, limit, sort. The step's
143
+ * `sort` is the aggregate `{ field, direction }` shape, not the query
144
+ * field→direction map.
145
+ */
146
+ export interface PipelineAggregateStep {
147
+ /** Unique step name (referenced by later steps as `$steps.<name>`). */
148
+ name: string;
149
+ type: "aggregate";
150
+ modelName: string;
151
+ groupBy: AggregateGroupByEntry[] | string;
152
+ operations: AggregateOperation[] | string;
153
+ filter?: OperationFilter;
154
+ limit?: number;
155
+ sort?: {
156
+ field: string;
157
+ direction: 1 | -1;
158
+ };
159
+ }
160
+ /**
161
+ * A single step inside a `pipeline` definition's `steps` array, discriminated
162
+ * on `type` so only the keys the server accepts for that step type compile
163
+ * (e.g. a `count` step carrying `projection`, or an `aggregate` step carrying a
164
+ * query-shaped `sort: { name: 1 }`, is a compile error — both are 400s at
165
+ * runtime). The per-type key sets mirror `PIPELINE_*_STEP_KEYS` in the server
166
+ * descriptor.
167
+ */
168
+ export type PipelineStep = PipelineQueryStep | PipelineCountStep | PipelineAggregateStep;
169
+ /** A `pipeline` operation definition. Keys: steps, return. */
170
+ export interface PipelineDefinition {
171
+ steps: PipelineStep[];
172
+ /** `"all"` or the name of a step whose result to return. */
173
+ return?: string;
174
+ }
175
+ /** The `source` (query) block of an `applyToQuery` definition. Keys: filter, sort, limit. */
176
+ export interface ApplyToQuerySource {
177
+ filter: OperationFilter;
178
+ sort?: Record<string, 1 | -1>;
179
+ limit?: number;
180
+ }
181
+ /** The `action` (mutation) block of an `applyToQuery` definition. Keys: op, data, fields, stringSets. */
182
+ export interface ApplyToQueryAction {
183
+ op: "delete" | "patch" | "increment" | "addToSet" | "removeFromSet";
184
+ data?: ObjectOrParamsRef;
185
+ fields?: ObjectOrParamsRef;
186
+ stringSets?: ObjectOrParamsRef;
187
+ }
188
+ /** An `applyToQuery` operation definition. Keys: source, action. */
189
+ export interface ApplyToQueryDefinition {
190
+ source: ApplyToQuerySource;
191
+ action: ApplyToQueryAction;
192
+ }
193
+ /**
194
+ * The plain union of every operation-definition shape. Used by `updateOperation`
195
+ * (a partial update makes no per-type narrowing claim) and as the building block
196
+ * of the discriminated params/info unions below.
197
+ */
198
+ export type OperationDefinition = QueryDefinition | MutationDefinition | CountDefinition | AggregateDefinition | PipelineDefinition | ApplyToQueryDefinition;
199
+ /** Maps each op `type` to its definition shape (for the discriminated unions). */
200
+ export interface OperationDefinitionByType {
201
+ query: QueryDefinition;
202
+ mutation: MutationDefinition;
203
+ count: CountDefinition;
204
+ aggregate: AggregateDefinition;
205
+ pipeline: PipelineDefinition;
206
+ applyToQuery: ApplyToQueryDefinition;
207
+ }
208
+ /** One member of the {@link CreateOperationParams} discriminated union. */
209
+ export interface CreateOperationParamsOf<T extends OperationType> {
210
+ /** Unique name used to reference this operation. */
211
+ name: string;
212
+ /** The operation kind — discriminates the `definition` shape. */
213
+ type: T;
214
+ /** The model (table) this operation acts on. */
215
+ modelName: string;
216
+ /** Who can execute this operation (e.g. "public", "owner", "authenticated"). */
217
+ access: string;
218
+ /** The operation logic, typed to the `type` above. */
219
+ definition: OperationDefinitionByType[T];
220
+ /** Schema describing the runtime parameters this operation accepts. */
221
+ params?: Record<string, any>;
222
+ }
223
+ /**
224
+ * Parameters for `createOperation`, discriminated on `type` so `definition` is
225
+ * bound to the matching shape (a `type: "query"` requires a {@link QueryDefinition},
226
+ * and an unknown `type` or a stray definition key is a compile error).
227
+ */
228
+ export type CreateOperationParams = CreateOperationParamsOf<"query"> | CreateOperationParamsOf<"mutation"> | CreateOperationParamsOf<"count"> | CreateOperationParamsOf<"aggregate"> | CreateOperationParamsOf<"pipeline"> | CreateOperationParamsOf<"applyToQuery">;
229
+ /**
230
+ * Parameters for `updateOperation`. `definition` is the plain
231
+ * {@link OperationDefinition} union — a partial update can change `type` and
232
+ * `definition` independently, so no per-type correlation is claimed.
233
+ */
234
+ export interface UpdateOperationParams {
235
+ /** Change the model this operation acts on. */
236
+ modelName?: string;
237
+ /** Change who can execute this operation. */
238
+ access?: string;
239
+ /** Replace the operation's query/mutation logic. */
240
+ definition?: OperationDefinition;
241
+ /** Replace the runtime parameter schema, or null to remove it. */
242
+ params?: Record<string, any> | null;
243
+ }
244
+ /** One member of the {@link DatabaseOperationInfo} discriminated union. */
245
+ export interface DatabaseOperationInfoOf<T extends OperationType> {
246
+ databaseId: string;
247
+ name: string;
248
+ /** The operation kind — discriminates the `definition` shape. */
249
+ type: T;
250
+ modelName: string;
251
+ access: string;
252
+ /** The stored operation logic, typed to the `type` above. */
253
+ definition: OperationDefinitionByType[T];
254
+ params: Record<string, any> | null;
255
+ createdBy: string;
256
+ createdAt: string;
257
+ modifiedAt: string;
258
+ }
259
+ /**
260
+ * A stored operation, as returned by the `databases/:id/operations` endpoints.
261
+ * Discriminated on `type` so `definition` narrows to the matching shape.
262
+ */
263
+ export type DatabaseOperationInfo = DatabaseOperationInfoOf<"query"> | DatabaseOperationInfoOf<"mutation"> | DatabaseOperationInfoOf<"count"> | DatabaseOperationInfoOf<"aggregate"> | DatabaseOperationInfoOf<"pipeline"> | DatabaseOperationInfoOf<"applyToQuery">;
264
+ /**
265
+ * The allowed top-level keys of each definition shape, as a runtime constant.
266
+ * The codegen key-parity test compares this against the vendored server
267
+ * descriptor's per-type allow-lists, and the type-level self-checks below assert
268
+ * each array equals `keyof <Definition>` — so the runtime constant, the authored
269
+ * types, and the server descriptor stay in lockstep.
270
+ */
271
+ export declare const OPERATION_DEFINITION_KEY_SETS: {
272
+ readonly query: readonly ["filter", "sort", "limit", "projection", "include", "cache"];
273
+ readonly mutation: readonly ["operations"];
274
+ readonly count: readonly ["filter"];
275
+ readonly aggregate: readonly ["groupBy", "operations", "filter", "limit", "sort"];
276
+ readonly pipeline: readonly ["steps", "return"];
277
+ readonly applyToQuery: readonly ["source", "action"];
278
+ };
279
+ //# sourceMappingURL=operationDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationDefinition.d.ts","sourceRoot":"","sources":["../../api/operationDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG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
+ *
4
+ * These types replace the previous `definition: Record<string, any>` on
5
+ * `createOperation` / `updateOperation` / `DatabaseOperationInfo`. They are
6
+ * hand-authored to mirror the server validator
7
+ * (`validateDefinition` in `database-type-operations-controller.ts`), whose
8
+ * declarative allow-lists live in the dependency-free descriptor
9
+ * `src/app-api/controllers/operation-definition-descriptor.ts`. A key-parity
10
+ * test (`cli/tests/unit/operation-def-client-types.test.ts`) asserts that each
11
+ * member below carries exactly the keys the descriptor allows, and a byte-copy
12
+ * drift guard keeps the vendored descriptor in step with the server — so these
13
+ * types can never silently diverge from what the server enforces.
14
+ *
15
+ * The discriminated union lives at the PARAMS level, not on `definition` alone:
16
+ * the op `type` is a sibling of `definition`, so `CreateOperationParams` and
17
+ * `DatabaseOperationInfo` are unions keyed on `type` that bind the matching
18
+ * definition shape. `updateOperation` takes the plain `OperationDefinition`
19
+ * union (a partial update can change `type` and definition independently, so it
20
+ * makes no per-type narrowing claim).
21
+ *
22
+ * The leaf value shapes (filter objects, CEL expression strings, `$params`
23
+ * references) stay permissive on purpose — the server is the authoritative
24
+ * runtime boundary for those; these types describe the STRUCTURE (which op
25
+ * types exist and which keys each definition allows) that the audit found
26
+ * untyped, without over-promising the contents of a filter or a CEL string.
27
+ *
28
+ * This module is deliberately dependency-free (only `import type` for the
29
+ * runtime-key self-check helper is inlined below) so it can be imported by the
30
+ * codegen key-parity test without dragging in the full client graph.
31
+ */
32
+ /**
33
+ * The allowed top-level keys of each definition shape, as a runtime constant.
34
+ * The codegen key-parity test compares this against the vendored server
35
+ * descriptor's per-type allow-lists, and the type-level self-checks below assert
36
+ * each array equals `keyof <Definition>` — so the runtime constant, the authored
37
+ * types, and the server descriptor stay in lockstep.
38
+ */
39
+ export const OPERATION_DEFINITION_KEY_SETS = {
40
+ query: ["filter", "sort", "limit", "projection", "include", "cache"],
41
+ mutation: ["operations"],
42
+ count: ["filter"],
43
+ aggregate: ["groupBy", "operations", "filter", "limit", "sort"],
44
+ pipeline: ["steps", "return"],
45
+ applyToQuery: ["source", "action"],
46
+ };
47
+ //# sourceMappingURL=operationDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationDefinition.js","sourceRoot":"","sources":["../../api/operationDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAyRH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC;IACpE,QAAQ,EAAE,CAAC,YAAY,CAAC;IACxB,KAAK,EAAE,CAAC,QAAQ,CAAC;IACjB,SAAS,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;IAC/D,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;CACyB,CAAC"}
@@ -0,0 +1,182 @@
1
+ import type { JsBaoClient } from "../JsBaoClient";
2
+ /**
3
+ * Result of a single-category metadata read (`resourceMetadata.get`). A
4
+ * discriminated union on `exists`: when a row was written the read carries the
5
+ * typed `data` and its `schemaVersion`; when no row exists yet the read still
6
+ * succeeds but `data` is an empty object and `schemaVersion` is `null`. Narrow
7
+ * on `exists` before reading `data` — the empty branch does not carry `T`, so a
8
+ * typed caller cannot access `T`'s fields without checking first.
9
+ */
10
+ export type ResourceMetadataReadResult<T extends object = Record<string, unknown>> = {
11
+ resourceType: string;
12
+ resourceId: string;
13
+ category: string;
14
+ /** The stored metadata object. */
15
+ data: T;
16
+ /** Schema version the stored data was validated against. */
17
+ schemaVersion: number;
18
+ /** A stored row exists for this resource and category. */
19
+ exists: true;
20
+ } | {
21
+ resourceType: string;
22
+ resourceId: string;
23
+ category: string;
24
+ /**
25
+ * No row has been written yet, so this is an empty object. Typed as an
26
+ * object with no keys (not `Record<string, never>`, which declares every
27
+ * key as `never` and lets `data.field` collapse to the true branch's type
28
+ * — defeating the narrowing). A caller must check `exists` before reading
29
+ * `T`'s fields.
30
+ */
31
+ data: Record<never, never>;
32
+ /** No stored row, so there is no schema version. */
33
+ schemaVersion: null;
34
+ /** No stored row exists for this resource and category. */
35
+ exists: false;
36
+ };
37
+ /** Result of a metadata write (`resourceMetadata.set` — a full replace). */
38
+ export interface ResourceMetadataWriteResult<T extends object = Record<string, unknown>> {
39
+ resourceType: string;
40
+ resourceId: string;
41
+ category: string;
42
+ /** The stored metadata object as validated and persisted. */
43
+ data: T;
44
+ /** Schema version the write was validated against. */
45
+ schemaVersion: number;
46
+ /** Stored size of the serialized data, in bytes. */
47
+ size: number;
48
+ }
49
+ /**
50
+ * One item of a batch read request. `categories` is required and must be
51
+ * non-empty — there is no expand-to-all; an item that omits it comes back as a
52
+ * per-item error with `status: 400`.
53
+ */
54
+ export interface ResourceMetadataBatchRequestItem {
55
+ resourceType: string;
56
+ resourceId: string;
57
+ /** Explicit categories to read for this resource. */
58
+ categories: string[];
59
+ }
60
+ /** Parameters for `resourceMetadata.getBatch`. */
61
+ export interface ResourceMetadataBatchParams {
62
+ /**
63
+ * Up to 50 resource entries, and up to 200 expanded resource/category pairs
64
+ * per call. Exceeding either limit fails the whole call with `400
65
+ * BATCH_TOO_LARGE`.
66
+ */
67
+ requests: ResourceMetadataBatchRequestItem[];
68
+ }
69
+ /**
70
+ * Per-category result inside a batch read — a discriminated union on `ok`. A
71
+ * success carries the same fields as the single read (`data`, `schemaVersion`,
72
+ * `exists`); a failure carries `status`/`code`/`message` and never `data`.
73
+ */
74
+ export type ResourceMetadataBatchCategoryResult = {
75
+ ok: true;
76
+ data: Record<string, unknown>;
77
+ schemaVersion: number | null;
78
+ exists: boolean;
79
+ } | {
80
+ ok: false;
81
+ status: number;
82
+ code: string;
83
+ message: string;
84
+ };
85
+ /**
86
+ * Per-resource result inside a batch read. `ok: true` carries a per-category
87
+ * map; `ok: false` is an item-level fault (malformed segment, or missing
88
+ * `categories`) that applies to the whole item.
89
+ */
90
+ export type ResourceMetadataBatchResourceResult = {
91
+ resourceType: string;
92
+ resourceId: string;
93
+ ok: true;
94
+ categories: Record<string, ResourceMetadataBatchCategoryResult>;
95
+ } | {
96
+ resourceType: string;
97
+ resourceId: string;
98
+ ok: false;
99
+ status: number;
100
+ code: string;
101
+ message: string;
102
+ };
103
+ /**
104
+ * Result of `resourceMetadata.getBatch`. The call itself succeeds (HTTP 200)
105
+ * even when individual items fail — check each entry's `ok` discriminant.
106
+ */
107
+ export interface ResourceMetadataBatchResult {
108
+ /** One entry per request item, in request order. */
109
+ results: ResourceMetadataBatchResourceResult[];
110
+ }
111
+ /** One stored category in a resource metadata listing (`resourceMetadata.list`). */
112
+ export interface ResourceMetadataListEntry {
113
+ category: string;
114
+ /** The stored metadata object for this category. */
115
+ data: Record<string, unknown>;
116
+ /** Schema version the stored data was validated against (`null` if unknown). */
117
+ schemaVersion: number | null;
118
+ }
119
+ /**
120
+ * Result of `resourceMetadata.list`. Only categories the caller may read are
121
+ * returned: each is gated by its `readRule` with the app-level owner/admin
122
+ * bypass, so an admin sees every category while a plain member sees only the
123
+ * ones their rule permits. A resource with no metadata returns an empty list.
124
+ */
125
+ export interface ResourceMetadataListResult {
126
+ resourceType: string;
127
+ resourceId: string;
128
+ categories: ResourceMetadataListEntry[];
129
+ }
130
+ /** Result of `resourceMetadata.delete` (idempotent — an absent item is not an error). */
131
+ export interface ResourceMetadataDeleteResult {
132
+ resourceType: string;
133
+ resourceId: string;
134
+ category: string;
135
+ /** `false` when no stored item existed (still a success, not a 404). */
136
+ deleted: boolean;
137
+ }
138
+ /**
139
+ * Sub-API for reading and writing typed resource metadata (values only —
140
+ * category definitions are managed by app admins, not through this client).
141
+ * Reads are gated per category by its `readRule` and writes by its
142
+ * `writeRule`, with an app-level owner/admin bypass; a resource-level
143
+ * permission never bypasses. A denial surfaces as an HTTP 403
144
+ * error on the single calls and as a per-item `ok: false` entry in the batch.
145
+ */
146
+ export declare class ResourceMetadataAPI {
147
+ private client;
148
+ constructor(client: JsBaoClient);
149
+ /**
150
+ * Read one resource's metadata for one category. Succeeds with
151
+ * `exists: false` and empty `data` when nothing has been written yet;
152
+ * fails with 404 when the category is not defined for the resource type,
153
+ * or 403 when the category's `readRule` denies the caller.
154
+ */
155
+ get<T extends object = Record<string, unknown>>(resourceType: string, resourceId: string, category: string): Promise<ResourceMetadataReadResult<T>>;
156
+ /**
157
+ * Write (full replace) one resource's metadata for one category. The data
158
+ * is validated against the category's schema; the category's `writeRule`
159
+ * gates the write (403 on denial).
160
+ */
161
+ set<T extends object = Record<string, unknown>>(resourceType: string, resourceId: string, category: string, data: T): Promise<ResourceMetadataWriteResult<T>>;
162
+ /**
163
+ * Read metadata for many resources in one call (bounded: 50 resources /
164
+ * 200 resource-category pairs). Partial success: per-item 403/404 errors
165
+ * are returned as structured entries and do not fail the call.
166
+ */
167
+ getBatch(params: ResourceMetadataBatchParams): Promise<ResourceMetadataBatchResult>;
168
+ /**
169
+ * List every stored metadata category on one resource. Only categories the
170
+ * caller may read are returned (each gated by its `readRule`, with the
171
+ * app-level owner/admin bypass); a resource with no metadata comes back with
172
+ * an empty `categories` array.
173
+ */
174
+ list(resourceType: string, resourceId: string): Promise<ResourceMetadataListResult>;
175
+ /**
176
+ * Delete one resource's metadata for one category. The category's `writeRule`
177
+ * gates the delete (403 on denial). Idempotent: deleting an item that does
178
+ * not exist succeeds with `deleted: false` rather than failing with 404.
179
+ */
180
+ delete(resourceType: string, resourceId: string, category: string): Promise<ResourceMetadataDeleteResult>;
181
+ }
182
+ //# sourceMappingURL=resourceMetadataApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceMetadataApi.d.ts","sourceRoot":"","sources":["../../api/resourceMetadataApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,0B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,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEvC;;;;;OAKG;IACG,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;IASzC;;;;OAIG;IACG,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;IAU1C;;;;OAIG;IACG,QAAQ,CACZ,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IAQvC;;;;;OAKG;IACG,IAAI,CACR,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,0BAA0B,CAAC;IAStC;;;;OAIG;IACG,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,4BAA4B,CAAC;CAQzC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Sub-API for reading and writing typed resource metadata (values only —
3
+ * category definitions are managed by app admins, not through this client).
4
+ * Reads are gated per category by its `readRule` and writes by its
5
+ * `writeRule`, with an app-level owner/admin bypass; a resource-level
6
+ * permission never bypasses. A denial surfaces as an HTTP 403
7
+ * error on the single calls and as a per-item `ok: false` entry in the batch.
8
+ */
9
+ export class ResourceMetadataAPI {
10
+ constructor(client) {
11
+ this.client = client;
12
+ }
13
+ /**
14
+ * Read one resource's metadata for one category. Succeeds with
15
+ * `exists: false` and empty `data` when nothing has been written yet;
16
+ * fails with 404 when the category is not defined for the resource type,
17
+ * or 403 when the category's `readRule` denies the caller.
18
+ */
19
+ async get(resourceType, resourceId, category) {
20
+ return this.client.makeRequest("GET", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`);
21
+ }
22
+ /**
23
+ * Write (full replace) one resource's metadata for one category. The data
24
+ * is validated against the category's schema; the category's `writeRule`
25
+ * gates the write (403 on denial).
26
+ */
27
+ async set(resourceType, resourceId, category, data) {
28
+ return this.client.makeRequest("PUT", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`, { data });
29
+ }
30
+ /**
31
+ * Read metadata for many resources in one call (bounded: 50 resources /
32
+ * 200 resource-category pairs). Partial success: per-item 403/404 errors
33
+ * are returned as structured entries and do not fail the call.
34
+ */
35
+ async getBatch(params) {
36
+ return this.client.makeRequest("POST", "/resources/metadata/batch", params);
37
+ }
38
+ /**
39
+ * List every stored metadata category on one resource. Only categories the
40
+ * caller may read are returned (each gated by its `readRule`, with the
41
+ * app-level owner/admin bypass); a resource with no metadata comes back with
42
+ * an empty `categories` array.
43
+ */
44
+ async list(resourceType, resourceId) {
45
+ return this.client.makeRequest("GET", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata`);
46
+ }
47
+ /**
48
+ * Delete one resource's metadata for one category. The category's `writeRule`
49
+ * gates the delete (403 on denial). Idempotent: deleting an item that does
50
+ * not exist succeeds with `deleted: false` rather than failing with 404.
51
+ */
52
+ async delete(resourceType, resourceId, category) {
53
+ return this.client.makeRequest("DELETE", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`);
54
+ }
55
+ }
56
+ //# sourceMappingURL=resourceMetadataApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceMetadataApi.js","sourceRoot":"","sources":["../../api/resourceMetadataApi.ts"],"names":[],"mappings":"AAqJA;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAE3C;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,YAAoB,EACpB,UAAkB,EAClB,QAAgB;QAEhB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,UAAU,CACX,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAC7C,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CACP,YAAoB,EACpB,UAAkB,EAClB,QAAgB,EAChB,IAAO;QAEP,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,UAAU,CACX,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAC5C,EAAE,IAAI,EAAE,CACT,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CACZ,MAAmC;QAEnC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,MAAM,EACN,2BAA2B,EAC3B,MAAM,CACP,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CACR,YAAoB,EACpB,UAAkB;QAElB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,UAAU,CACX,WAAW,CACb,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,YAAoB,EACpB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