@rebasepro/types 0.30.1 → 0.31.0-canary.g59cd6fd
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/README.md +16 -18
- package/dist/call_context.d.ts +3 -3
- package/dist/controllers/client.d.ts +29 -0
- package/dist/controllers/data.d.ts +85 -332
- package/dist/controllers/data_driver.d.ts +47 -57
- package/dist/controllers/index.d.ts +0 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2567 -1151
- package/dist/index.es.js.map +1 -1
- package/dist/schema/column_options.d.ts +336 -0
- package/dist/schema/column_type.d.ts +116 -0
- package/dist/schema/columns.d.ts +646 -0
- package/dist/schema/compiled.d.ts +114 -0
- package/dist/schema/descriptor.d.ts +349 -0
- package/dist/schema/hooks.d.ts +164 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/infer.d.ts +340 -0
- package/dist/schema/json.d.ts +237 -0
- package/dist/schema/relations.d.ts +205 -0
- package/dist/schema/table.d.ts +304 -0
- package/dist/schema/table_options.d.ts +103 -0
- package/dist/schema/table_patch.d.ts +338 -0
- package/dist/types/auth_adapter.d.ts +5 -5
- package/dist/types/auth_hooks.d.ts +65 -0
- package/dist/types/backend.d.ts +85 -96
- package/dist/types/data_source.d.ts +4 -9
- package/dist/types/database_adapter.d.ts +30 -31
- package/dist/types/entities.d.ts +0 -162
- package/dist/types/filter-operators.d.ts +2 -26
- package/dist/types/history.d.ts +6 -9
- package/dist/types/index.d.ts +3 -9
- package/dist/types/mcp_app_modules.d.ts +0 -2
- package/dist/types/policy.d.ts +85 -10
- package/dist/types/project_manifest.d.ts +113 -46
- package/dist/types/read_query.d.ts +98 -0
- package/dist/types/register.d.ts +35 -5
- package/dist/types/relations.d.ts +0 -430
- package/dist/types/schema_editing.d.ts +54 -2
- package/dist/types/schema_version.d.ts +24 -4
- package/dist/types/security_rules.d.ts +225 -15
- package/dist/types/storage_authorize.d.ts +2 -2
- package/dist/types/tenancy.d.ts +3 -3
- package/dist/types/ui_preferences.d.ts +228 -0
- package/package.json +3 -2
- package/dist/controllers/auth_state.d.ts +0 -23
- package/dist/controllers/collection_registry.d.ts +0 -67
- package/dist/controllers/effective_role.d.ts +0 -4
- package/dist/types/admin_block.d.ts +0 -96
- package/dist/types/chips.d.ts +0 -16
- package/dist/types/collection_contract.d.ts +0 -43
- package/dist/types/collection_patch.d.ts +0 -74
- package/dist/types/collections.d.ts +0 -783
- package/dist/types/component_ref.d.ts +0 -81
- package/dist/types/conditions-contract.types.d.ts +0 -14
- package/dist/types/entity_callbacks.d.ts +0 -393
- package/dist/types/indexes.d.ts +0 -179
- package/dist/types/properties.d.ts +0 -1640
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { RebaseApiError } from "../errors.js";
|
|
2
|
-
import type { EntityStatus
|
|
3
|
-
import type {
|
|
2
|
+
import type { EntityStatus } from "../types/entities.js";
|
|
3
|
+
import type { FilterValues } from "../types/filter-operators.js";
|
|
4
4
|
import type { OrderByTuple } from "../types/filter-operators.js";
|
|
5
|
-
import type { RebaseCallContext } from "../call_context.js";
|
|
6
5
|
import type { AggregateGroupTransform, IncludeSpec, LogicalCondition } from "./data.js";
|
|
7
6
|
import type { CollectionUpdateMeta } from "../types/websockets.js";
|
|
8
7
|
/**
|
|
@@ -12,7 +11,6 @@ export interface FetchOneProps<M extends Record<string, unknown> = Record<string
|
|
|
12
11
|
path: string;
|
|
13
12
|
id: string | number;
|
|
14
13
|
databaseId?: string;
|
|
15
|
-
collection?: CollectionConfig<M>;
|
|
16
14
|
/**
|
|
17
15
|
* See {@link FetchCollectionProps.withDeleted}. A soft-deleted row is a 404
|
|
18
16
|
* here by default, so `findById` and `find` agree about which rows exist —
|
|
@@ -20,26 +18,21 @@ export interface FetchOneProps<M extends Record<string, unknown> = Record<string
|
|
|
20
18
|
* of inconsistency that makes a feature untrustworthy.
|
|
21
19
|
*/
|
|
22
20
|
withDeleted?: boolean | "only";
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* What a row listener subscribes to: the row, and the relations each frame
|
|
26
|
-
* loads into it.
|
|
27
|
-
*
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export type ListenOneTarget<M extends Record<string, unknown> = Record<string, unknown>> = FetchOneProps<M> & {
|
|
31
21
|
/**
|
|
32
|
-
* Relations to load into every frame, as
|
|
33
|
-
* loads them into each row of a list
|
|
34
|
-
*
|
|
35
|
-
*
|
|
22
|
+
* Relations to load into the row (or into every frame of a listener), as
|
|
23
|
+
* {@link FetchCollectionProps.include} loads them into each row of a list:
|
|
24
|
+
* the target's own row under the relation's name. Absent means none — a
|
|
25
|
+
* row carries its foreign keys and no relation. Without it on a listener a
|
|
26
|
+
* to-many relation was absent from each frame, and the admin's record
|
|
27
|
+
* form, opened by URL, showed it empty — so a save from it unlinked every
|
|
28
|
+
* related row.
|
|
36
29
|
*/
|
|
37
30
|
include?: IncludeSpec;
|
|
38
|
-
}
|
|
31
|
+
}
|
|
39
32
|
/**
|
|
40
33
|
* @internal
|
|
41
34
|
*/
|
|
42
|
-
export type ListenOneProps<M extends Record<string, unknown> = Record<string, unknown>> =
|
|
35
|
+
export type ListenOneProps<M extends Record<string, unknown> = Record<string, unknown>> = FetchOneProps<M> & {
|
|
43
36
|
onUpdate: (row: Record<string, unknown> | null) => void;
|
|
44
37
|
onError?: (error: Error) => void;
|
|
45
38
|
};
|
|
@@ -109,7 +102,6 @@ export declare function resolveClientListLimit(rawLimit: number | string | null
|
|
|
109
102
|
*/
|
|
110
103
|
export interface FetchCollectionProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
111
104
|
path: string;
|
|
112
|
-
collection?: CollectionConfig<M>;
|
|
113
105
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
114
106
|
/**
|
|
115
107
|
* An `or(...)`/`and(...)` group, applied alongside `filter`.
|
|
@@ -154,8 +146,7 @@ export interface FetchCollectionProps<M extends Record<string, unknown> = Record
|
|
|
154
146
|
* not expressible as a filter, because the field is not part of the
|
|
155
147
|
* caller's vocabulary.
|
|
156
148
|
*
|
|
157
|
-
* Ignored by
|
|
158
|
-
* PostgresCollectionConfig.softDelete}: there is no stamp to look at, and
|
|
149
|
+
* Ignored by tables that declare no `softDelete`: there is no stamp to look at, and
|
|
159
150
|
* silently returning nothing for `"only"` on such a collection would be a
|
|
160
151
|
* worse answer than ignoring it.
|
|
161
152
|
*/
|
|
@@ -202,10 +193,9 @@ export type ListenCollectionProps<M extends Record<string, unknown> = Record<str
|
|
|
202
193
|
*/
|
|
203
194
|
export interface SaveProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
204
195
|
path: string;
|
|
205
|
-
values: Partial<
|
|
196
|
+
values: Partial<M>;
|
|
206
197
|
id?: string | number;
|
|
207
|
-
previousValues?: Partial<
|
|
208
|
-
collection?: CollectionConfig<M>;
|
|
198
|
+
previousValues?: Partial<M>;
|
|
209
199
|
status: EntityStatus;
|
|
210
200
|
/**
|
|
211
201
|
* Write the row with INSERT ... ON CONFLICT DO UPDATE on the primary key
|
|
@@ -276,8 +266,7 @@ export interface SaveManyProps<M extends Record<string, unknown> = Record<string
|
|
|
276
266
|
* The rows to write. A row carrying its primary key updates (or, with
|
|
277
267
|
* `upsert`, inserts-or-updates) that row; one without inserts.
|
|
278
268
|
*/
|
|
279
|
-
rows: Partial<
|
|
280
|
-
collection?: CollectionConfig<M>;
|
|
269
|
+
rows: Partial<M>[];
|
|
281
270
|
/** Apply every row as INSERT ... ON CONFLICT DO UPDATE. See {@link SaveProps.upsert}. */
|
|
282
271
|
upsert?: boolean;
|
|
283
272
|
/** The conflict target for those upserts. See {@link SaveProps.onConflict}. */
|
|
@@ -308,14 +297,13 @@ export interface WriteFilterProps<M extends Record<string, unknown> = Record<str
|
|
|
308
297
|
path: string;
|
|
309
298
|
filter?: FilterValues<string>;
|
|
310
299
|
logical?: LogicalCondition;
|
|
311
|
-
collection?: CollectionConfig<M>;
|
|
312
300
|
}
|
|
313
301
|
/**
|
|
314
302
|
* @internal
|
|
315
303
|
*/
|
|
316
304
|
export interface UpdateWhereProps<M extends Record<string, unknown> = Record<string, unknown>> extends WriteFilterProps<M> {
|
|
317
305
|
/** What to set on every row the filter matches; field operations (`$inc`, …) included. */
|
|
318
|
-
values: Partial<
|
|
306
|
+
values: Partial<M>;
|
|
319
307
|
}
|
|
320
308
|
/**
|
|
321
309
|
* @internal
|
|
@@ -339,9 +327,8 @@ export interface UpdateManyProps<M extends Record<string, unknown> = Record<stri
|
|
|
339
327
|
*/
|
|
340
328
|
updates: {
|
|
341
329
|
id: string | number;
|
|
342
|
-
values: Partial<
|
|
330
|
+
values: Partial<M>;
|
|
343
331
|
}[];
|
|
344
|
-
collection?: CollectionConfig<M>;
|
|
345
332
|
}
|
|
346
333
|
/**
|
|
347
334
|
* @internal
|
|
@@ -361,10 +348,8 @@ export interface DeleteProps<M extends Record<string, unknown> = Record<string,
|
|
|
361
348
|
id: string | number;
|
|
362
349
|
path: string;
|
|
363
350
|
};
|
|
364
|
-
collection?: CollectionConfig<M>;
|
|
365
351
|
/**
|
|
366
|
-
* Issue a real `DELETE` on a
|
|
367
|
-
* {@link PostgresCollectionConfig.softDelete}.
|
|
352
|
+
* Issue a real `DELETE` on a table that declares `softDelete`.
|
|
368
353
|
*
|
|
369
354
|
* The row and every cascade behind it go. It needs the same permission an
|
|
370
355
|
* ordinary delete does and nothing more: it is the same verb, and a second
|
|
@@ -386,7 +371,6 @@ export interface DeleteProps<M extends Record<string, unknown> = Record<string,
|
|
|
386
371
|
export interface DeleteManyProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
387
372
|
path: string;
|
|
388
373
|
ids: (string | number)[];
|
|
389
|
-
collection?: CollectionConfig<M>;
|
|
390
374
|
/** See {@link DeleteProps.hard}. */
|
|
391
375
|
hard?: boolean;
|
|
392
376
|
}
|
|
@@ -422,8 +406,7 @@ export interface BatchWriteOperation<M extends Record<string, unknown> = Record<
|
|
|
422
406
|
path: string;
|
|
423
407
|
/** Required for `update` and `delete`. May be a `$ref` marker; see `batchWrite`. */
|
|
424
408
|
id?: unknown;
|
|
425
|
-
values?: Partial<
|
|
426
|
-
collection?: CollectionConfig<M>;
|
|
409
|
+
values?: Partial<M>;
|
|
427
410
|
/** See {@link SaveProps.onConflict}. `upsert` only. */
|
|
428
411
|
onConflict?: readonly string[];
|
|
429
412
|
/** Names this operation's result, for a later `$ref`. */
|
|
@@ -438,7 +421,6 @@ export interface BatchWriteProps<M extends Record<string, unknown> = Record<stri
|
|
|
438
421
|
export type FilterCombinationValidProps = {
|
|
439
422
|
path: string;
|
|
440
423
|
databaseId?: string;
|
|
441
|
-
collection: CollectionConfig;
|
|
442
424
|
filterValues: FilterValues<string>;
|
|
443
425
|
sortBy?: [string, "asc" | "desc"];
|
|
444
426
|
};
|
|
@@ -457,10 +439,10 @@ export interface CallerSqlOptions {
|
|
|
457
439
|
*
|
|
458
440
|
* Implement this interface to connect a custom backend (or use a built-in
|
|
459
441
|
* driver such as the Firestore one) and register it on
|
|
460
|
-
* `<Rebase dataSources>`.
|
|
461
|
-
*
|
|
442
|
+
* `<Rebase dataSources>`. The SDK reads a driver through `buildSdkData`
|
|
443
|
+
* (`@rebasepro/common`), and tables are routed to it by their `dataSource` key.
|
|
462
444
|
*
|
|
463
|
-
* For *consuming* data in application code, use `
|
|
445
|
+
* For *consuming* data in application code, use `client.data` /
|
|
464
446
|
* `context.data` instead — this interface is only for providing it.
|
|
465
447
|
*
|
|
466
448
|
* @group Datasource
|
|
@@ -569,7 +551,7 @@ export interface DataDriver {
|
|
|
569
551
|
deleteWhere?<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteWhereProps<M>): Promise<number>;
|
|
570
552
|
/**
|
|
571
553
|
* Recompute the rows of a collection that serves a materialized view —
|
|
572
|
-
* see `
|
|
554
|
+
* see `SDKTableClient.refresh`. Optional: only a driver with views
|
|
573
555
|
* has one.
|
|
574
556
|
*/
|
|
575
557
|
refreshView?(path: string, options?: {
|
|
@@ -584,7 +566,7 @@ export interface DataDriver {
|
|
|
584
566
|
*
|
|
585
567
|
* The rule is here rather than in each driver because the two
|
|
586
568
|
* implementations answered differently and each had a test pinning its own
|
|
587
|
-
* habit:
|
|
569
|
+
* habit: one threw, the other logged a warning and resolved. Three things
|
|
588
570
|
* decide it in favour of rejecting.
|
|
589
571
|
*
|
|
590
572
|
* The REST layer already says 404 — `DELETE /api/data/<c>/<id>` reads the
|
|
@@ -669,10 +651,9 @@ export interface DataDriver {
|
|
|
669
651
|
* @param name of the property
|
|
670
652
|
* @param value
|
|
671
653
|
* @param id
|
|
672
|
-
* @param collection
|
|
673
654
|
* @return `true` if there are no other fields besides the given entity
|
|
674
655
|
*/
|
|
675
|
-
checkUniqueField(path: string, name: string, value: unknown, id?: string | number
|
|
656
|
+
checkUniqueField(path: string, name: string, value: unknown, id?: string | number): Promise<boolean>;
|
|
676
657
|
/**
|
|
677
658
|
* Count the number of entities in a collection
|
|
678
659
|
*/
|
|
@@ -730,31 +711,41 @@ export interface DataDriver {
|
|
|
730
711
|
*/
|
|
731
712
|
scanStoredRows?(props: {
|
|
732
713
|
path: string;
|
|
733
|
-
collection: CollectionConfig;
|
|
734
714
|
/** Rows per page. */
|
|
735
715
|
pageSize?: number;
|
|
736
716
|
}): AsyncIterable<Record<string, unknown>[]>;
|
|
717
|
+
/**
|
|
718
|
+
* Rows of a table this caller did not read through the driver, served as a
|
|
719
|
+
* read of that table serves them: the columns the caller may not read
|
|
720
|
+
* (`.private()`, `.access({ read })`, a withheld relation and its foreign
|
|
721
|
+
* key) taken out, then the table's `afterRead` chain — global, the
|
|
722
|
+
* table's, its columns' `.transform({ afterRead })` — run once, with this
|
|
723
|
+
* driver's caller as `context`.
|
|
724
|
+
*
|
|
725
|
+
* For stored copies of rows served back to a caller: a history entry's
|
|
726
|
+
* snapshots are the row as it was written, before any hook, and without
|
|
727
|
+
* this they would hand a caller what every other read of the table masks.
|
|
728
|
+
* The rows are the table's REST shape (column keys); a key the table has
|
|
729
|
+
* no column for is the caller's to remove first — this takes out what the
|
|
730
|
+
* table restricts, and cannot know what a dropped column held.
|
|
731
|
+
*
|
|
732
|
+
* A hook that throws fails the call: nothing is served unmasked.
|
|
733
|
+
*
|
|
734
|
+
* Optional. A server door that serves stored rows refuses to serve them
|
|
735
|
+
* through a driver without it, rather than serve them unmasked.
|
|
736
|
+
*/
|
|
737
|
+
serveStoredRows?(path: string, rows: Record<string, unknown>[]): Promise<Record<string, unknown>[]>;
|
|
737
738
|
/**
|
|
738
739
|
* Check if the given filter combination is valid
|
|
739
740
|
* @param props
|
|
740
741
|
*/
|
|
741
|
-
isFilterCombinationValid?(props:
|
|
742
|
-
databaseId?: string;
|
|
743
|
-
}): boolean;
|
|
742
|
+
isFilterCombinationValid?(props: FilterCombinationValidProps): boolean;
|
|
744
743
|
/**
|
|
745
744
|
* Get the object to generate the current time in the driver
|
|
746
745
|
*/
|
|
747
746
|
currentTime?: () => unknown;
|
|
748
747
|
delegateToCMSModel?: (data: unknown) => unknown;
|
|
749
748
|
cmsToDelegateModel?: (data: unknown) => unknown;
|
|
750
|
-
initTextSearch?: (props: {
|
|
751
|
-
context: RebaseCallContext;
|
|
752
|
-
path: string;
|
|
753
|
-
databaseId?: string;
|
|
754
|
-
collection: CollectionConfig;
|
|
755
|
-
parentCollectionSlugs?: string[];
|
|
756
|
-
parentEntityIds?: string[];
|
|
757
|
-
}) => Promise<boolean>;
|
|
758
749
|
/**
|
|
759
750
|
* Flag to indicate if the driver has requested the initialization of the text search index
|
|
760
751
|
*/
|
|
@@ -776,7 +767,6 @@ export interface DataDriver {
|
|
|
776
767
|
/**
|
|
777
768
|
* Return the admin capabilities of this driver.
|
|
778
769
|
* @see SQLAdmin
|
|
779
|
-
* @see DocumentAdmin
|
|
780
770
|
* @see SchemaAdmin
|
|
781
771
|
*/
|
|
782
772
|
admin?: import("../types/backend.js").DatabaseAdmin;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export * from "./collection_registry.js";
|
|
2
|
-
export * from "./auth_state.js";
|
|
3
1
|
export * from "./data.js";
|
|
4
2
|
export * from "./data_driver.js";
|
|
5
|
-
export * from "./effective_role.js";
|
|
6
3
|
export * from "./storage.js";
|
|
7
4
|
export * from "./storage-references.js";
|
|
8
5
|
export * from "./email.js";
|
package/dist/index.d.ts
CHANGED