@rebasepro/types 0.9.1-canary.f0ac103 → 0.9.1-canary.fd3754b
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/controllers/data.d.ts +2 -44
- package/dist/controllers/data_driver.d.ts +3 -45
- package/dist/index.es.js +1 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +591 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/collections.d.ts +0 -11
- package/dist/types/entity_callbacks.d.ts +3 -3
- package/dist/types/policy.d.ts +2 -48
- package/dist/types/websockets.d.ts +0 -27
- package/package.json +6 -5
- package/src/controllers/data.ts +2 -42
- package/src/controllers/data_driver.ts +3 -47
- package/src/types/collections.ts +0 -12
- package/src/types/entity_callbacks.ts +3 -3
- package/src/types/policy.ts +1 -50
- package/src/types/websockets.ts +0 -24
|
@@ -149,15 +149,6 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
149
149
|
* @returns The created entity
|
|
150
150
|
*/
|
|
151
151
|
create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
|
|
152
|
-
/**
|
|
153
|
-
* Create many records in a single transaction.
|
|
154
|
-
*
|
|
155
|
-
* See {@link SDKCollectionClient.createMany}. Optional: not every driver can
|
|
156
|
-
* write in bulk, and callers should fall back to `create` per record.
|
|
157
|
-
*/
|
|
158
|
-
createMany?(data: Partial<EntityValues<M>>[], options?: {
|
|
159
|
-
upsert?: boolean;
|
|
160
|
-
}): Promise<Entity<M>[]>;
|
|
161
152
|
/**
|
|
162
153
|
* Update an existing record by ID.
|
|
163
154
|
* @returns The updated entity
|
|
@@ -271,43 +262,10 @@ export interface SDKCollectionClient<M extends Record<string, unknown> = Record<
|
|
|
271
262
|
/**
|
|
272
263
|
* Create a new record.
|
|
273
264
|
* @param data The record data to create (the collection's `Insert` shape).
|
|
274
|
-
* @param id Optional specific
|
|
275
|
-
* whose key *is* `id`: the value goes in as that column. For a table keyed
|
|
276
|
-
* on anything else (a `sku`, a composite key), there is no `id` column to
|
|
277
|
-
* receive it — put the key in `data` instead, where it belongs among the
|
|
278
|
-
* columns.
|
|
265
|
+
* @param id Optional specific ID to use for the new record.
|
|
279
266
|
* @returns The created row
|
|
280
267
|
*/
|
|
281
268
|
create(data: I, id?: string | number): Promise<M>;
|
|
282
|
-
/**
|
|
283
|
-
* Write many records in a single request and a single transaction.
|
|
284
|
-
*
|
|
285
|
-
* Built for imports and ETL, where one call per row means one HTTP round
|
|
286
|
-
* trip and one transaction per row. Every record still runs the normal
|
|
287
|
-
* pipeline — callbacks, relations, row-level security — and the batch is
|
|
288
|
-
* all-or-nothing: if any record is rejected, none of them land and the
|
|
289
|
-
* error names the offending index.
|
|
290
|
-
*
|
|
291
|
-
* A record carrying its primary key updates that row; one without inserts.
|
|
292
|
-
* With `{ upsert: true }` each record is written as INSERT ... ON CONFLICT
|
|
293
|
-
* DO UPDATE on the primary key instead, which is what makes a re-runnable
|
|
294
|
-
* import idempotent.
|
|
295
|
-
*
|
|
296
|
-
* Batches are capped server-side (1000 rows by default) because one batch
|
|
297
|
-
* holds its locks for the whole transaction — chunk larger jobs.
|
|
298
|
-
*
|
|
299
|
-
* @returns The written rows, in the order given.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```ts
|
|
303
|
-
* for (const chunk of chunks(rows, 1000)) {
|
|
304
|
-
* await client.data.products.createMany(chunk, { upsert: true });
|
|
305
|
-
* }
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
createMany(data: I[], options?: {
|
|
309
|
-
upsert?: boolean;
|
|
310
|
-
}): Promise<M[]>;
|
|
311
269
|
/**
|
|
312
270
|
* Update an existing record by ID.
|
|
313
271
|
* @param data The fields to update (the collection's `Update` shape).
|
|
@@ -387,7 +345,7 @@ export type RebaseData<DB = unknown> = {
|
|
|
387
345
|
* - The frontend SDK client (`client.data.products.find()`)
|
|
388
346
|
* - Backend framework callbacks & scripts (`context.data.products.find()`)
|
|
389
347
|
*
|
|
390
|
-
* Every accessor returns flat rows (
|
|
348
|
+
* Every accessor returns flat rows (`{ id, ...columns }`) via
|
|
391
349
|
* {@link SDKCollectionClient} — access fields directly (`row.title`), never
|
|
392
350
|
* `row.values.title`. The admin CMS uses {@link RebaseData} (Entity) instead.
|
|
393
351
|
*
|
|
@@ -65,30 +65,6 @@ export interface SaveProps<M extends Record<string, unknown> = Record<string, un
|
|
|
65
65
|
previousValues?: Partial<EntityValues<M>>;
|
|
66
66
|
collection?: CollectionConfig<M>;
|
|
67
67
|
status: EntityStatus;
|
|
68
|
-
/**
|
|
69
|
-
* Write the row with INSERT ... ON CONFLICT DO UPDATE on the primary key
|
|
70
|
-
* instead of choosing between insert and update up front.
|
|
71
|
-
*
|
|
72
|
-
* One statement, so it does not lose the race a read-then-write can, and it
|
|
73
|
-
* succeeds whether or not the row is already there — what a re-runnable
|
|
74
|
-
* import needs. Requires every primary key column to be present; without
|
|
75
|
-
* them there is no conflict target and the row is inserted normally.
|
|
76
|
-
*/
|
|
77
|
-
upsert?: boolean;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
export interface SaveManyProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
83
|
-
path: string;
|
|
84
|
-
/**
|
|
85
|
-
* The rows to write. A row carrying its primary key updates (or, with
|
|
86
|
-
* `upsert`, inserts-or-updates) that row; one without inserts.
|
|
87
|
-
*/
|
|
88
|
-
rows: Partial<EntityValues<M>>[];
|
|
89
|
-
collection?: CollectionConfig<M>;
|
|
90
|
-
/** Apply every row as INSERT ... ON CONFLICT DO UPDATE. See {@link SaveProps.upsert}. */
|
|
91
|
-
upsert?: boolean;
|
|
92
68
|
}
|
|
93
69
|
/**
|
|
94
70
|
* @internal
|
|
@@ -159,19 +135,6 @@ export interface DataDriver {
|
|
|
159
135
|
* @param props
|
|
160
136
|
*/
|
|
161
137
|
save<M extends Record<string, unknown> = Record<string, unknown>>(props: SaveProps<M>): Promise<Record<string, unknown>>;
|
|
162
|
-
/**
|
|
163
|
-
* Save many rows as one unit of work.
|
|
164
|
-
*
|
|
165
|
-
* Every row runs the same pipeline as {@link save} — callbacks, relations
|
|
166
|
-
* and row-level security all still apply — but they share a single
|
|
167
|
-
* transaction, so the batch either lands whole or not at all. That, and the
|
|
168
|
-
* single round trip, is what makes importing tens of thousands of rows
|
|
169
|
-
* viable without dropping to raw SQL.
|
|
170
|
-
*
|
|
171
|
-
* Optional: drivers that cannot do this leave it undefined and callers fall
|
|
172
|
-
* back to `save` per row.
|
|
173
|
-
*/
|
|
174
|
-
saveMany?<M extends Record<string, unknown> = Record<string, unknown>>(props: SaveManyProps<M>): Promise<Record<string, unknown>[]>;
|
|
175
138
|
/**
|
|
176
139
|
* Delete a entity
|
|
177
140
|
* @param props
|
|
@@ -240,14 +203,9 @@ export interface DataDriver {
|
|
|
240
203
|
* REST-optimised fetch service exposed by drivers that support
|
|
241
204
|
* eager-loading of relations via `include`.
|
|
242
205
|
*
|
|
243
|
-
* The methods return flattened rows
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* through the REST API / SDK client.
|
|
247
|
-
*
|
|
248
|
-
* No synthesized `id`: identity is a primary key, which may be named anything
|
|
249
|
-
* and span several columns, so an address is derived by whoever needs one (see
|
|
250
|
-
* `buildCompositeId`) rather than written into the row on top of the data.
|
|
206
|
+
* The methods return flattened rows (`{ id, ...columns }`) with
|
|
207
|
+
* included relations inlined as plain nested rows — the shape served
|
|
208
|
+
* to app developers through the REST API / SDK client.
|
|
251
209
|
*
|
|
252
210
|
* @group DataDriver
|
|
253
211
|
*/
|
package/dist/index.es.js
CHANGED
|
@@ -312,23 +312,6 @@ function getDeclaredSubcollections(collection) {
|
|
|
312
312
|
}
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region src/types/policy.ts
|
|
315
|
-
/**
|
|
316
|
-
* The id a request without a logged-in user reports as `auth.uid()`.
|
|
317
|
-
*
|
|
318
|
-
* A user-context request always sets `app.user_id`: blank would read back as
|
|
319
|
-
* `NULL`, and `NULL` is how the trusted server context is recognised, so an
|
|
320
|
-
* anonymous visitor would be promoted to server privileges. The driver
|
|
321
|
-
* therefore substitutes this sentinel at the single chokepoint where the GUC
|
|
322
|
-
* is set.
|
|
323
|
-
*
|
|
324
|
-
* The consequence for policy authors is that **`auth.uid() IS NOT NULL` is a
|
|
325
|
-
* tautology on the user path** — it is true for anonymous visitors too. Use
|
|
326
|
-
* {@link policy.authenticated} (or `auth.uid() <> 'anonymous'`) to mean "signed
|
|
327
|
-
* in", and {@link policy.serverContext} to mean "the trusted server context".
|
|
328
|
-
*
|
|
329
|
-
* @group Models
|
|
330
|
-
*/
|
|
331
|
-
var ANONYMOUS_USER_ID = "anonymous";
|
|
332
315
|
/** @group Models */
|
|
333
316
|
var policy = {
|
|
334
317
|
true: () => ({ kind: "true" }),
|
|
@@ -360,7 +343,6 @@ var policy = {
|
|
|
360
343
|
roles
|
|
361
344
|
}),
|
|
362
345
|
authenticated: () => ({ kind: "authenticated" }),
|
|
363
|
-
serverContext: () => ({ kind: "serverContext" }),
|
|
364
346
|
existsIn: (args) => ({
|
|
365
347
|
kind: "existsIn",
|
|
366
348
|
collection: args.collection,
|
|
@@ -568,6 +550,6 @@ function isPublicStoragePath(path) {
|
|
|
568
550
|
return p.startsWith("public/") || p.startsWith(`default/public/`);
|
|
569
551
|
}
|
|
570
552
|
//#endregion
|
|
571
|
-
export { ALL_WHERE_FILTER_OPS,
|
|
553
|
+
export { ALL_WHERE_FILTER_OPS, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_DATA_SOURCE_KEY, DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REST_TO_CANONICAL, RebaseApiError, RebaseClientError, Vector, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, isBranchAdmin, isDocumentAdmin, isFirebaseCollectionConfig, isLazyComponentRef, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isSQLAdmin, isSchemaAdmin, policy, registerDataSourceCapabilities, toCanonicalOp };
|
|
572
554
|
|
|
573
555
|
//# sourceMappingURL=index.es.js.map
|