@rebasepro/types 0.30.0 → 0.31.0-canary.g902a0ce

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 (57) hide show
  1. package/README.md +16 -18
  2. package/dist/call_context.d.ts +3 -3
  3. package/dist/controllers/client.d.ts +29 -0
  4. package/dist/controllers/data.d.ts +85 -332
  5. package/dist/controllers/data_driver.d.ts +47 -57
  6. package/dist/controllers/index.d.ts +0 -3
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.es.js +2567 -1151
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/schema/column_options.d.ts +336 -0
  11. package/dist/schema/column_type.d.ts +116 -0
  12. package/dist/schema/columns.d.ts +646 -0
  13. package/dist/schema/compiled.d.ts +114 -0
  14. package/dist/schema/descriptor.d.ts +349 -0
  15. package/dist/schema/hooks.d.ts +164 -0
  16. package/dist/schema/index.d.ts +13 -0
  17. package/dist/schema/infer.d.ts +340 -0
  18. package/dist/schema/json.d.ts +237 -0
  19. package/dist/schema/relations.d.ts +205 -0
  20. package/dist/schema/table.d.ts +304 -0
  21. package/dist/schema/table_options.d.ts +103 -0
  22. package/dist/schema/table_patch.d.ts +338 -0
  23. package/dist/types/auth_adapter.d.ts +12 -6
  24. package/dist/types/auth_hooks.d.ts +65 -0
  25. package/dist/types/backend.d.ts +85 -96
  26. package/dist/types/data_source.d.ts +4 -9
  27. package/dist/types/database_adapter.d.ts +30 -31
  28. package/dist/types/entities.d.ts +0 -162
  29. package/dist/types/filter-operators.d.ts +2 -26
  30. package/dist/types/history.d.ts +6 -9
  31. package/dist/types/index.d.ts +3 -9
  32. package/dist/types/mcp_app_modules.d.ts +0 -2
  33. package/dist/types/policy.d.ts +85 -10
  34. package/dist/types/project_manifest.d.ts +113 -46
  35. package/dist/types/read_query.d.ts +98 -0
  36. package/dist/types/register.d.ts +35 -5
  37. package/dist/types/relations.d.ts +0 -430
  38. package/dist/types/schema_editing.d.ts +54 -2
  39. package/dist/types/schema_version.d.ts +24 -4
  40. package/dist/types/security_rules.d.ts +225 -15
  41. package/dist/types/storage_authorize.d.ts +2 -2
  42. package/dist/types/tenancy.d.ts +3 -3
  43. package/dist/types/ui_preferences.d.ts +228 -0
  44. package/package.json +3 -2
  45. package/dist/controllers/auth_state.d.ts +0 -23
  46. package/dist/controllers/collection_registry.d.ts +0 -67
  47. package/dist/controllers/effective_role.d.ts +0 -4
  48. package/dist/types/admin_block.d.ts +0 -96
  49. package/dist/types/chips.d.ts +0 -16
  50. package/dist/types/collection_contract.d.ts +0 -43
  51. package/dist/types/collection_patch.d.ts +0 -74
  52. package/dist/types/collections.d.ts +0 -783
  53. package/dist/types/component_ref.d.ts +0 -81
  54. package/dist/types/conditions-contract.types.d.ts +0 -14
  55. package/dist/types/entity_callbacks.d.ts +0 -393
  56. package/dist/types/indexes.d.ts +0 -179
  57. package/dist/types/properties.d.ts +0 -1640
@@ -1,6 +1,5 @@
1
1
  import type { VectorSearchParams } from "./data_driver.js";
2
2
  import type { ComputedSortField, SearchMatch } from "../types/search.js";
3
- import { Entity, EntityValues } from "../types/entities.js";
4
3
  import { WhereFilterOp, FieldPath, NonColumnFieldPath, FilterValues, NullsPlacement, OrderBySpec, OrderByTuple, RelationAggregateSort } from "../types/filter-operators.js";
5
4
  /**
6
5
  * The element type of an array column, and the column's own type otherwise.
@@ -130,8 +129,8 @@ export type FilterConditionFor<M extends Record<string, unknown>> = ColumnCondit
130
129
  *
131
130
  * A key-remapped mapped type rather than a conditional over `keyof M`, for the
132
131
  * reason {@link NumericKeyOf} gives: tsc measures the conditional form as
133
- * invariant in `M`, and a typed `SDKCollectionClient<Post>` stopped widening to
134
- * the wide `SDKCollectionClient`.
132
+ * invariant in `M`, and a typed `SDKTableClient<Post>` stopped widening to
133
+ * the wide `SDKTableClient`.
135
134
  */
136
135
  type ColumnConditions<M extends Record<string, unknown>> = {
137
136
  [K in keyof M as K extends string ? K : never]: string extends K ? FilterCondition : {
@@ -221,15 +220,15 @@ export interface IncludeOptions {
221
220
  * - `["author", "comments.author"]` — a dotted path is the same thing as the
222
221
  * nested object form, spelled flat. It is what the REST `?include=` parameter
223
222
  * carries, and the two forms compile to the same request.
224
- * - `["*"]` — every relation the collection declares, one hop deep, those
223
+ * - `["*"]` — every relation the table declares, one hop deep, those
225
224
  * declared only for a record's tabs included — so on a list it can embed
226
225
  * every row of a to-many relation no column shows. Name the relations the
227
226
  * view renders instead; the admin panel does, and sends `*` only when it
228
- * cannot resolve a collection's relations in the browser.
227
+ * cannot resolve a table's relations in the browser.
229
228
  * - `{ comments: { limit: 5, include: { author: true } } }` — the parametrised
230
229
  * form.
231
230
  *
232
- * A name that is not a relation of the collection is a **400
231
+ * A name that is not a relation of the table is a **400
233
232
  * `UNKNOWN_RELATION`**, not a silent omission: a read that quietly drops an
234
233
  * `include` answers 200 with the field missing, which is indistinguishable from
235
234
  * a row that genuinely has no related row.
@@ -252,7 +251,7 @@ export interface ByIdReadOptions<Inc = IncludeSpec> {
252
251
  include?: Inc;
253
252
  }
254
253
  /**
255
- * An include checked against one generated collection's relations: `R` is its
254
+ * An include checked against one generated table's relations: `R` is its
256
255
  * `Relations` map (relation name → the accessor it reaches) and `DB` the
257
256
  * generated `Database`, so a nested `include` is checked against the *target's*
258
257
  * relations in turn.
@@ -267,7 +266,7 @@ export type IncludeSpecFor<DB, R> = readonly (Extract<keyof R, string> | "*" | `
267
266
  [K in Extract<keyof R, string>]?: true | IncludeOptionsFor<DB, R[K]>;
268
267
  };
269
268
  /**
270
- * {@link IncludeOptions} for a relation that reaches the generated collection
269
+ * {@link IncludeOptions} for a relation that reaches the generated table
271
270
  * `T`: its nested `include` is checked against `T`'s relations.
272
271
  *
273
272
  * @group Data
@@ -299,7 +298,7 @@ export type IncludeArgOf<Inc> = Inc extends readonly (infer E)[] ? E | Inc : Inc
299
298
  */
300
299
  export declare const MAX_INCLUDE_DEPTH = 3;
301
300
  /**
302
- * Parameters for querying a collection.
301
+ * Parameters for querying a table.
303
302
  *
304
303
  * ## How the filter parameters combine
305
304
  *
@@ -338,8 +337,8 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
338
337
  * {@link MAX_LIST_LIMIT}: the backend **rejects** anything else with a 400
339
338
  * rather than trimming it to fit, because a page quietly smaller than the
340
339
  * one you asked for is indistinguishable from having reached the end of the
341
- * collection. To read past the ceiling, page with `offset` — or let
342
- * {@link SDKCollectionClient.iterate} / {@link SDKCollectionClient.findAll}
340
+ * table. To read past the ceiling, page with `offset` — or let
341
+ * {@link SDKTableClient.iterate} / {@link SDKTableClient.findAll}
343
342
  * do it for you.
344
343
  */
345
344
  limit?: number;
@@ -385,10 +384,10 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
385
384
  /**
386
385
  * Relations to load into the response — see {@link IncludeSpec}.
387
386
  *
388
- * Not checked against `M` here: a relation name comes from the collection's
387
+ * Not checked against `M` here: a relation name comes from the table's
389
388
  * `relations`, not from its columns, so nothing in a *hand-written* row type
390
389
  * can validate one. A **generated** `Database` narrows this to the
391
- * collection's actual relation keys, recursively — see
390
+ * table's actual relation keys, recursively — see
392
391
  * {@link IncludeSpecFor}. The row a read returns still types each relation
393
392
  * as optional; the generated `RowWith<A, I>` names the row with the
394
393
  * included ones required.
@@ -445,13 +444,13 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
445
444
  * Text search string, AND-ed with `where`/`logical`. This is the value
446
445
  * behind the query builder's `.search()` method.
447
446
  *
448
- * What it compiles to depends on the collection. By default — matching
449
- * every collection that has not said otherwise — it is a case-insensitive
450
- * substring match OR-ed across the collection's top-level `string`
447
+ * What it compiles to depends on the table. By default — matching
448
+ * every table that has not said otherwise — it is a case-insensitive
449
+ * substring match OR-ed across the table's top-level `string`
451
450
  * properties: it does not reach inside `map` or `array` properties, it does
452
451
  * not stem or rank, and it cannot use an index.
453
452
  *
454
- * A Postgres collection that declares a `search` block instead gets a
453
+ * A Postgres table that declares a `search` block instead gets a
455
454
  * ranked full-text match over exactly the fields it named, and rows come
456
455
  * back with a {@link FindParams.orderBy}-able `_score`.
457
456
  */
@@ -459,7 +458,7 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
459
458
  /**
460
459
  * Nearest-neighbour search over a `vector` property.
461
460
  *
462
- * Postgres only, and only for a collection that declares a property of
461
+ * Postgres only, and only for a table that declares a column of
463
462
  * type `vector`. Rows come back ordered by distance, closest first, each
464
463
  * carrying a `_distance`. Combines with `where` and `logical`, which are
465
464
  * applied as filters before the ordering — so this is "the nearest rows
@@ -477,7 +476,7 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
477
476
  * field per returned row, and `ts_headline` re-parses the document rather
478
477
  * than reading the index. Fine for a page of results, not for an export.
479
478
  *
480
- * Ignored unless the collection declares a `search` block and the query
479
+ * Ignored unless the table declares a `search` block and the query
481
480
  * carries a `searchString`; there is nothing to explain otherwise.
482
481
  */
483
482
  searchExplain?: boolean;
@@ -500,197 +499,7 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
500
499
  count?: "exact" | "none";
501
500
  }
502
501
  /**
503
- * Paginated response from a collection query.
504
- * @group Data
505
- */
506
- export interface FindResponse<M extends Record<string, unknown> = Record<string, unknown>> {
507
- /** Array of entities matching the query */
508
- data: Entity<M>[];
509
- /** Pagination metadata */
510
- meta: {
511
- total: number;
512
- limit: number;
513
- offset: number;
514
- hasMore: boolean;
515
- };
516
- }
517
- /**
518
- * Fluent query builder for the **admin panel** — resolves to `FindResponse<M>`
519
- * (Snapshot-wrapped rows).
520
- *
521
- * @internal App developers should use {@link SDKQueryBuilderInterface}
522
- * (flat rows, returned by `client.data.*` / `context.data.*`). This
523
- * Snapshot-flavored variant backs the admin panel internals only.
524
- *
525
- * @group Data
526
- */
527
- export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
528
- where<K extends keyof M & string, Op extends WhereFilterOp>(column: K, operator: Op, value: WhereValueFor<Op, M[K]>): this;
529
- where(logicalCondition: LogicalConditionFor<M>): this;
530
- orderBy(column: (keyof M & string) | ComputedSortField, direction?: "asc" | "desc"): this;
531
- limit(count: number): this;
532
- offset(count: number): this;
533
- search(searchString: string, options?: {
534
- explain?: boolean;
535
- }): this;
536
- /**
537
- * Order rows by nearest-neighbour distance to `vector`, closest first.
538
- *
539
- * Postgres only, over a property declared as `type: "vector"`. Each row
540
- * comes back with a `_distance`. Any `where` on the same query filters
541
- * before the ordering; distance decides the order.
542
- *
543
- * The query embedding is the caller's to produce.
544
- */
545
- vectorSearch(property: string, vector: number[], options?: {
546
- distance?: "cosine" | "l2" | "inner_product";
547
- threshold?: number;
548
- }): this;
549
- include(...relations: string[]): this;
550
- find(): Promise<FindResponse<M>>;
551
- listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
552
- }
553
- /**
554
- * A single collection's CRUD accessor for the **admin panel** — every method
555
- * resolves to `Snapshot`-wrapped rows (`FindResponse<M>` / `Snapshot<M>`).
556
- *
557
- * @internal App developers do **not** use this. The public, symmetric surface
558
- * is {@link SDKCollectionClient} (flat rows), exposed as `client.data.products`
559
- * in the SDK and `context.data.products` in framework callbacks. This
560
- * Snapshot-flavored accessor backs the admin panel view-model only.
561
- *
562
- * @group Data
563
- */
564
- export interface CollectionAccessor<M extends Record<string, unknown> = Record<string, unknown>> {
565
- /**
566
- * Find multiple records with optional filtering, pagination, and sorting.
567
- */
568
- find(params?: FindParams<M>): Promise<FindResponse<M>>;
569
- /**
570
- * Find a single record by its ID.
571
- */
572
- findById(id: string | number, options?: ByIdReadOptions): Promise<Entity<M> | undefined>;
573
- /**
574
- * Create a new record.
575
- * @param data The entity data to create.
576
- * @param id Optional specific ID to use for the new record.
577
- * @returns The created entity
578
- */
579
- create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
580
- /**
581
- * Create many records in a single transaction.
582
- *
583
- * See {@link SDKCollectionClient.createMany}. Optional: not every driver can
584
- * write in bulk, and callers should fall back to `create` per record.
585
- */
586
- createMany?(data: Partial<EntityValues<M>>[], options?: {
587
- upsert?: boolean;
588
- onConflict?: readonly string[];
589
- where?: WhereFor<M>;
590
- ignoreDuplicates?: boolean;
591
- }): Promise<Entity<M>[]>;
592
- /**
593
- * Update an existing record by ID.
594
- *
595
- * `options.ifMatch` is the version the edit was made against
596
- * ({@link Entity.etag}): the write is refused with `412
597
- * PRECONDITION_FAILED` when the row has changed since. A data source that
598
- * cannot check one ignores it, and the write is unconditional.
599
- * @returns The updated entity
600
- */
601
- update(id: string | number, data: Partial<EntityValues<M>>, options?: {
602
- ifMatch?: string;
603
- }): Promise<Entity<M>>;
604
- /**
605
- * Update many records in a single transaction.
606
- *
607
- * See {@link SDKCollectionClient.updateMany}. Optional, as `createMany` is.
608
- */
609
- updateMany?(updates: {
610
- id: string | number;
611
- data: Partial<EntityValues<M>>;
612
- }[]): Promise<Entity<M>[]>;
613
- /**
614
- * Delete many records in a single transaction.
615
- *
616
- * See {@link SDKCollectionClient.deleteMany}. Optional, as `createMany` is.
617
- */
618
- deleteMany?(ids: (string | number)[]): Promise<void>;
619
- /** See {@link SDKCollectionClient.updateWhere}. Optional, as `createMany` is. */
620
- updateWhere?(query: FilteredWriteParams<M>, data: Partial<EntityValues<M>>): Promise<Entity<M>[]>;
621
- /** See {@link SDKCollectionClient.deleteWhere}. Optional, as `createMany` is. */
622
- deleteWhere?(query: FilteredWriteParams<M>): Promise<number>;
623
- /**
624
- * Delete a record by ID.
625
- */
626
- delete(id: string | number): Promise<void>;
627
- /**
628
- * Subscribe to a collection for real-time updates.
629
- * Optional method, may not be supported by all implementations (like stateless HTTP clients).
630
- */
631
- listen?(params: FindParams<M> | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
632
- /**
633
- * Subscribe to a single record for real-time updates: every frame is the
634
- * record as `findById(id, options)` reads it.
635
- * Optional method.
636
- */
637
- listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void, options?: ByIdReadOptions): () => void;
638
- /**
639
- * {@link SDKCollectionClient.listenCount}: the matching rows' count, live.
640
- * Optional method; absent where the data source cannot subscribe.
641
- */
642
- listenCount?(params: FindParams<M> | undefined, onCount: (total: number) => void, onError?: (error: Error) => void): () => void;
643
- /**
644
- * The rows a soft delete stamped, and the delete that removes a row for
645
- * good: what {@link SDKCollectionClient.trash} is built from. A restore is
646
- * an ordinary {@link update}. Optional; absent where the data source
647
- * cannot read a collection's trash.
648
- */
649
- trash?: CollectionTrashAccessor<M>;
650
- /**
651
- * Count the number of records matching the given filter.
652
- *
653
- * Optional on this contract because a data source need not support it, and
654
- * required on `CollectionClient` — the HTTP implementation always has it.
655
- * So `client.data.posts.count()` compiles in the browser while the same
656
- * call through a `context.data` accessor needs `count?.()`, which is the
657
- * one place the two halves of this API are not interchangeable.
658
- */
659
- count?(params?: FindParams<M>): Promise<number>;
660
- /**
661
- * {@link SDKCollectionClient.aggregate}. Optional here for the same reason
662
- * `count` is: not every data source can compute one, and the SDK wraps an
663
- * absent implementation in a stub that says so rather than returning a
664
- * number nothing counted.
665
- */
666
- aggregate?(params: AggregateParams<M>): Promise<AggregateResult>;
667
- /** {@link SDKCollectionClient.refresh}. Optional, as `aggregate` is. */
668
- refresh?(options?: RefreshOptions): Promise<void>;
669
- where<K extends keyof M & string, Op extends WhereFilterOp>(column: K, operator: Op, value: WhereValueFor<Op, M[K]>): QueryBuilderInterface<M>;
670
- where(logicalCondition: LogicalConditionFor<M>): QueryBuilderInterface<M>;
671
- orderBy(column: (keyof M & string) | ComputedSortField, direction?: "asc" | "desc"): QueryBuilderInterface<M>;
672
- limit(count: number): QueryBuilderInterface<M>;
673
- offset(count: number): QueryBuilderInterface<M>;
674
- search(searchString: string, options?: {
675
- explain?: boolean;
676
- }): QueryBuilderInterface<M>;
677
- /**
678
- * Order rows by nearest-neighbour distance to `vector`, closest first.
679
- *
680
- * Postgres only, over a property declared as `type: "vector"`. Each row
681
- * comes back with a `_distance`. Any `where` on the same query filters
682
- * before the ordering; distance decides the order.
683
- *
684
- * The query embedding is the caller's to produce.
685
- */
686
- vectorSearch(property: string, vector: number[], options?: {
687
- distance?: "cosine" | "l2" | "inner_product";
688
- threshold?: number;
689
- }): QueryBuilderInterface<M>;
690
- include(...relations: string[]): QueryBuilderInterface<M>;
691
- }
692
- /**
693
- * Pagination metadata returned with collection queries.
502
+ * Pagination metadata returned with table queries.
694
503
  * @group Data
695
504
  */
696
505
  export interface PaginationMeta {
@@ -719,7 +528,7 @@ export interface PaginationMeta {
719
528
  nextCursor?: string;
720
529
  }
721
530
  /**
722
- * Paginated response from a collection query (SDK-facing).
531
+ * Paginated response from a table query (SDK-facing).
723
532
  * Returns flat rows instead of Entity-wrapped objects.
724
533
  *
725
534
  * @example
@@ -759,7 +568,7 @@ export interface FindResult<M extends Record<string, unknown> = Record<string, u
759
568
  */
760
569
  export type QueryComputedFields = {
761
570
  /**
762
- * Relevance, when the collection declares a {@link SearchConfig} and the
571
+ * Relevance, when the table declares a {@link SearchConfig} and the
763
572
  * query carried a search string. Higher is better; the scale is not
764
573
  * comparable between two different search strings.
765
574
  */
@@ -868,8 +677,8 @@ export type AggregateGroupTransform = "lower" | "upper" | "unnest" | "year" | "m
868
677
  *
869
678
  * Written as the keys of a key-remapped mapped type, not as a conditional over
870
679
  * `keyof M`: tsc measures the conditional form as invariant in `M`, which made
871
- * a typed `SDKCollectionClient<Post>` unassignable to the wide
872
- * `SDKCollectionClient` that helpers taking any collection accept. A mapped
680
+ * a typed `SDKTableClient<Post>` unassignable to the wide
681
+ * `SDKTableClient` that helpers taking any table accept. A mapped
873
682
  * type is related structurally, so a typed client still widens.
874
683
  */
875
684
  export type NumericKeyOf<M extends Record<string, unknown>> = Extract<keyof {
@@ -887,7 +696,7 @@ export type NumericKeyOf<M extends Record<string, unknown>> = Extract<keyof {
887
696
  */
888
697
  export type AggregateRow = Record<string, unknown>;
889
698
  /**
890
- * What {@link SDKCollectionClient.aggregate} takes: the same narrowing a
699
+ * What {@link SDKTableClient.aggregate} takes: the same narrowing a
891
700
  * `find()` takes, minus the parts of it that describe a *page* of rows.
892
701
  *
893
702
  * `limit` and `offset` page through the **groups**, as they page a listing's
@@ -972,7 +781,7 @@ export interface AggregateMeta {
972
781
  hasMore: boolean;
973
782
  }
974
783
  /**
975
- * What {@link SDKCollectionClient.aggregate} resolves to: the rows, as an
784
+ * What {@link SDKTableClient.aggregate} resolves to: the rows, as an
976
785
  * array, carrying the page they are as `meta`.
977
786
  *
978
787
  * `meta` is present on a grouped aggregate that was cut at a `limit` — which,
@@ -1001,8 +810,8 @@ export type CursorSpec<M extends Record<string, unknown> = Record<string, unknow
1001
810
  direction?: "asc" | "desc";
1002
811
  };
1003
812
  /**
1004
- * How {@link SDKCollectionClient.iterate} / {@link SDKCollectionClient.findAll}
1005
- * walk a collection, layered on top of the normal `find()` parameters.
813
+ * How {@link SDKTableClient.iterate} / {@link SDKTableClient.findAll}
814
+ * walk a table, layered on top of the normal `find()` parameters.
1006
815
  *
1007
816
  * @group Data
1008
817
  */
@@ -1044,7 +853,7 @@ export interface PageWalkOptions<M extends Record<string, unknown> = Record<stri
1044
853
  maxPages?: number;
1045
854
  }
1046
855
  /**
1047
- * Parameters accepted by {@link SDKCollectionClient.iterate} — everything
856
+ * Parameters accepted by {@link SDKTableClient.iterate} — everything
1048
857
  * `find()` takes except the window itself (`limit`, `offset`, `page`), which
1049
858
  * the iterator owns, plus the walk options.
1050
859
  *
@@ -1055,8 +864,8 @@ export interface PageWalkOptions<M extends Record<string, unknown> = Record<stri
1055
864
  */
1056
865
  export type IterateParams<M extends Record<string, unknown> = Record<string, unknown>, Inc = IncludeSpec> = Omit<FindParams<M, Inc>, "limit" | "offset" | "page"> & PageWalkOptions<M>;
1057
866
  /**
1058
- * Parameters accepted by {@link SDKCollectionClient.findAll}: the iteration
1059
- * parameters plus the ceiling that keeps a whole collection from being pulled
867
+ * Parameters accepted by {@link SDKTableClient.findAll}: the iteration
868
+ * parameters plus the ceiling that keeps a whole table from being pulled
1060
869
  * into memory unnoticed.
1061
870
  *
1062
871
  * @group Data
@@ -1072,7 +881,7 @@ export type FindAllParams<M extends Record<string, unknown> = Record<string, unk
1072
881
  };
1073
882
  /**
1074
883
  * Fluent Query Builder Interface for the SDK client.
1075
- * Returns `FindResult<M>` (flat rows) instead of `FindResponse<M>` (Entity-wrapped).
884
+ * Resolves to `FindResult<M>` (flat rows).
1076
885
  *
1077
886
  * @group Data
1078
887
  */
@@ -1144,7 +953,7 @@ export interface SDKQueryBuilderInterface<M extends Record<string, unknown> = Re
1144
953
  /**
1145
954
  * Page through everything this query matches, one row at a time.
1146
955
  *
1147
- * The same walker {@link SDKCollectionClient.iterate} uses, so the ceiling
956
+ * The same walker {@link SDKTableClient.iterate} uses, so the ceiling
1148
957
  * on `limit` is not a ceiling on what a query can read. `.limit()` set on
1149
958
  * the builder becomes the **page size** here, not a total.
1150
959
  */
@@ -1152,7 +961,7 @@ export interface SDKQueryBuilderInterface<M extends Record<string, unknown> = Re
1152
961
  /**
1153
962
  * Collect everything this query matches into one array.
1154
963
  *
1155
- * {@link SDKCollectionClient.findAll}'s `maxRows` guard applies: an
964
+ * {@link SDKTableClient.findAll}'s `maxRows` guard applies: an
1156
965
  * unbounded collect is a memory hazard, so it stops and says so rather than
1157
966
  * growing until the process dies.
1158
967
  */
@@ -1163,10 +972,10 @@ export interface SDKQueryBuilderInterface<M extends Record<string, unknown> = Re
1163
972
  listen(onUpdate: (data: FindResult<M>) => void, onError?: (error: Error) => void): () => void;
1164
973
  }
1165
974
  /**
1166
- * SDK collection client — returns flat rows, no Entity wrapper.
975
+ * SDK table client — returns flat rows, no Entity wrapper.
1167
976
  *
1168
977
  * This is the public API surface for app developers using
1169
- * `createRebaseClient()`. admin internals use `CollectionAccessor` instead.
978
+ * `createRebaseClient()`.
1170
979
  *
1171
980
  * Type parameters:
1172
981
  * - `M` — the **Row** shape returned by reads (`find`, `findById`, `listen`).
@@ -1232,7 +1041,7 @@ export declare const BATCH_REF_KEY = "$ref";
1232
1041
  *
1233
1042
  * Except on a `map` (pass `propertyType`): a map's value is a JSON document,
1234
1043
  * and one may legitimately carry `$` keys — a JSON Schema's `$schema`, a
1235
- * MongoDB-style export. There, only a single-key object whose key is one of
1044
+ * document exported from another database. There, only a single-key object whose key is one of
1236
1045
  * {@link FIELD_OPERATORS} is an operation, and anything else is data. A caller
1237
1046
  * that does not know the property type gets the strict reading.
1238
1047
  *
@@ -1264,7 +1073,7 @@ export type FieldOperation =
1264
1073
  $merge: Record<string, unknown>;
1265
1074
  };
1266
1075
  /**
1267
- * The payload {@link SDKCollectionClient.update} accepts: plain values, field
1076
+ * The payload {@link SDKTableClient.update} accepts: plain values, field
1268
1077
  * operations, or both in one body.
1269
1078
  *
1270
1079
  * @group Data
@@ -1326,8 +1135,8 @@ export interface UpsertOptions<M extends Record<string, unknown> = Record<string
1326
1135
  ignoreDuplicates?: boolean;
1327
1136
  }
1328
1137
  /**
1329
- * The rows a filtered write ({@link SDKCollectionClient.updateWhere},
1330
- * {@link SDKCollectionClient.deleteWhere}) addresses: the same `where` and
1138
+ * The rows a filtered write ({@link SDKTableClient.updateWhere},
1139
+ * {@link SDKTableClient.deleteWhere}) addresses: the same `where` and
1331
1140
  * `logical` a `find()` takes, AND-ed.
1332
1141
  *
1333
1142
  * At least one condition. A filtered write with none would address every row,
@@ -1349,7 +1158,7 @@ export interface FilteredWriteParams<M extends Record<string, unknown> = Record<
1349
1158
  *
1350
1159
  * `{ "$ref": "order.id" }` reads the field `id` off the result of the operation
1351
1160
  * that named itself `ref: "order"`. Without it a batch cannot express the one
1352
- * thing a cross-collection batch exists for — writing a parent and its children
1161
+ * thing a cross-table batch exists for — writing a parent and its children
1353
1162
  * together — because the child's foreign key is not knowable until the parent
1354
1163
  * has been inserted, and splitting the two into separate requests is exactly
1355
1164
  * the non-atomic sequence the batch replaces.
@@ -1364,7 +1173,7 @@ export interface BatchRef {
1364
1173
  $ref: string;
1365
1174
  }
1366
1175
  /**
1367
- * A row's values in a batch: the collection's own columns, each of which may
1176
+ * A row's values in a batch: the table's own columns, each of which may
1368
1177
  * instead be a {@link BatchRef} to a value an earlier operation produces.
1369
1178
  *
1370
1179
  * Homomorphic over the row type, so a column the row type requires is required
@@ -1378,10 +1187,10 @@ type BatchValues<T> = {
1378
1187
  /**
1379
1188
  * One entry of a batch request.
1380
1189
  *
1381
- * `collection` is the collection's **accessor** on a typed client — the name
1190
+ * `table` is the table's **accessor** on a typed client — the name
1382
1191
  * `client.data.<accessor>` takes, and the key of the generated `Database`
1383
1192
  * (`orderItems`). The client resolves it to the slug the route knows
1384
- * (`order_items`) through its `collections` dictionary; a slug that is not an
1193
+ * (`order_items`) through its `tables` dictionary; a slug that is not an
1385
1194
  * accessor is sent as written.
1386
1195
  *
1387
1196
  * @group Data
@@ -1389,20 +1198,20 @@ type BatchValues<T> = {
1389
1198
  export type BatchOperation<DB = Record<string, unknown>> = {
1390
1199
  [K in Extract<keyof DB, string>]: {
1391
1200
  op: "create";
1392
- collection: K;
1201
+ table: K;
1393
1202
  values: BatchValues<InsertOf<DB[K]>>;
1394
1203
  /** Name this row so a later operation can reference its columns. */
1395
1204
  ref?: string;
1396
1205
  } | {
1397
1206
  op: "upsert";
1398
- collection: K;
1207
+ table: K;
1399
1208
  values: BatchValues<InsertOf<DB[K]>>;
1400
1209
  /** See {@link UpsertOptions.onConflict}. Defaults to the primary key. */
1401
1210
  onConflict?: readonly string[];
1402
1211
  ref?: string;
1403
1212
  } | {
1404
1213
  op: "update";
1405
- collection: K;
1214
+ table: K;
1406
1215
  id: string | number | BatchRef;
1407
1216
  values: {
1408
1217
  [F in keyof UpdateOf<DB[K]>]?: UpdateOf<DB[K]>[F] | FieldOperationFor<UpdateOf<DB[K]>[F]> | BatchRef;
@@ -1410,7 +1219,7 @@ export type BatchOperation<DB = Record<string, unknown>> = {
1410
1219
  ref?: string;
1411
1220
  } | {
1412
1221
  op: "delete";
1413
- collection: K;
1222
+ table: K;
1414
1223
  id: string | number | BatchRef;
1415
1224
  ref?: string;
1416
1225
  };
@@ -1500,27 +1309,14 @@ export interface WriteOptions {
1500
1309
  */
1501
1310
  ifMatch?: string;
1502
1311
  }
1503
- /**
1504
- * The entity-shaped half of {@link TrashClient}, on a {@link CollectionAccessor}.
1505
- */
1506
- export interface CollectionTrashAccessor<M extends Record<string, unknown> = Record<string, unknown>> {
1507
- /** The trashed rows matching `params`. */
1508
- find(params?: FindParams<M>): Promise<FindResponse<M>>;
1509
- /** How many trashed rows match `params`. */
1510
- count(params?: FindParams<M>): Promise<number>;
1511
- /** Delete a row for good, trashed or live. */
1512
- purge(id: string | number): Promise<void>;
1513
- /** {@link purge} for several rows, as one transaction, where the data source can. */
1514
- purgeMany?(ids: (string | number)[]): Promise<void>;
1515
- }
1516
1312
  /**
1517
1313
  * Options for {@link TrashClient.restore} and {@link TrashClient.restoreMany}.
1518
1314
  */
1519
1315
  export interface RestoreOptions<M extends Record<string, unknown> = Record<string, unknown>> extends WriteOptions {
1520
1316
  /**
1521
- * The collection's soft-delete field, as declared in `softDelete`.
1317
+ * The table's soft-delete field, as declared in `softDelete`.
1522
1318
  * Defaults to `deletedAt`, the field `softDelete: true` uses; pass the
1523
- * name a `softDelete: { field: "archivedAt" }` collection declares.
1319
+ * name a `softDelete: { field: "archivedAt" }` table declares.
1524
1320
  *
1525
1321
  * A restore is an ordinary update setting this field to `null`, which is
1526
1322
  * the one update the server lets reach a trashed row.
@@ -1528,13 +1324,13 @@ export interface RestoreOptions<M extends Record<string, unknown> = Record<strin
1528
1324
  field?: keyof M & string;
1529
1325
  }
1530
1326
  /**
1531
- * The trash of a collection that declares `softDelete`: the rows a delete
1327
+ * The trash of a table that declares `softDelete`: the rows a delete
1532
1328
  * stamped rather than removed. `client.data.<slug>.trash` in the browser,
1533
1329
  * `context.data.<slug>.trash` and `rebase.data.<slug>.trash` on the server.
1534
1330
  *
1535
- * For a collection that declares `softDelete`. On one that does not, `find`
1331
+ * For a table that declares `softDelete`. On one that does not, `find`
1536
1332
  * and `count` answer for the live rows, `restore` is refused for a field the
1537
- * collection does not have, and `purge` is an ordinary delete.
1333
+ * table does not have, and `purge` is an ordinary delete.
1538
1334
  *
1539
1335
  * Where the data source cannot read a trash, every method is a stub that
1540
1336
  * throws when called.
@@ -1560,8 +1356,8 @@ export interface TrashClient<M extends Record<string, unknown> = Record<string,
1560
1356
  /** {@link TrashClient.purge} for several rows, as one transaction (`POST /data/<slug>/bulk/delete?hard=true`). */
1561
1357
  purgeMany(ids: (string | number)[], options?: WriteOptions): Promise<void>;
1562
1358
  }
1563
- export interface SDKCollectionClient<M extends Record<string, unknown> = Record<string, unknown>, I = Partial<M>, U = Partial<M>,
1564
- /** The include this collection takes; {@link IncludeOf} for a generated `Database`. */
1359
+ export interface SDKTableClient<M extends Record<string, unknown> = Record<string, unknown>, I = Partial<M>, U = Partial<M>,
1360
+ /** The include this table takes; {@link IncludeOf} for a generated `Database`. */
1565
1361
  Inc = IncludeSpec> {
1566
1362
  /**
1567
1363
  * Find multiple records with optional filtering, pagination, and sorting.
@@ -1686,7 +1482,7 @@ Inc = IncludeSpec> {
1686
1482
  get(id: string | number): Promise<M>;
1687
1483
  /**
1688
1484
  * Create a new record.
1689
- * @param data The record data to create (the collection's `Insert` shape).
1485
+ * @param data The record data to create (the table's `Insert` shape).
1690
1486
  * @param id Optional specific id, sent as an `id` column. This is for tables
1691
1487
  * whose key *is* `id`: the value goes in as that column. For a table keyed
1692
1488
  * on anything else (a `sku`, a composite key), there is no `id` column to
@@ -1742,7 +1538,7 @@ Inc = IncludeSpec> {
1742
1538
  } & WriteOptions): Promise<M[]>;
1743
1539
  /**
1744
1540
  * Update an existing record by ID.
1745
- * @param data The fields to update (the collection's `Update` shape).
1541
+ * @param data The fields to update (the table's `Update` shape).
1746
1542
  * @param options Per-request write options — notably `idempotencyKey`.
1747
1543
  * @returns The updated row.
1748
1544
  * @throws {RebaseApiError} with status 404 when the record does not exist.
@@ -1774,7 +1570,7 @@ Inc = IncludeSpec> {
1774
1570
  * `unique` index. Anything else is a 400 rather than a Postgres error
1775
1571
  * raised half-way through a transaction.
1776
1572
  *
1777
- * Refused (400 `INVALID_CONFLICT_TARGET`) on the auth collection, whose
1573
+ * Refused (400 `INVALID_CONFLICT_TARGET`) on the auth table, whose
1778
1574
  * rows are the users: a create and an update of a user follow different
1779
1575
  * rules, and an upsert only learns which it is inside the write.
1780
1576
  *
@@ -1864,7 +1660,7 @@ Inc = IncludeSpec> {
1864
1660
  * ```
1865
1661
  *
1866
1662
  * Matching nothing is not an error: the answer is `[]`. Row-level
1867
- * security applies as to any write. On a collection whose writes run
1663
+ * security applies as to any write. On a table whose writes run
1868
1664
  * per-row work — a save hook, history, tenancy, a `beforeQuery`, a trash,
1869
1665
  * per-field access — the matching rows are read under the caller's scope
1870
1666
  * and updated one by one through the full pipeline, in one transaction.
@@ -1964,7 +1760,7 @@ Inc = IncludeSpec> {
1964
1760
  */
1965
1761
  listenCount(params: FindParams<M, Inc> | undefined, onCount: (total: number) => void, onError?: (error: Error) => void): () => void;
1966
1762
  /**
1967
- * The collection's trash: list, count, restore and purge the rows a soft
1763
+ * The table's trash: list, count, restore and purge the rows a soft
1968
1764
  * delete stamped. See {@link TrashClient}.
1969
1765
  */
1970
1766
  trash: TrashClient<M, Inc>;
@@ -1977,7 +1773,7 @@ Inc = IncludeSpec> {
1977
1773
  count(params?: FindParams<M, Inc>): Promise<number>;
1978
1774
  /**
1979
1775
  * `count`/`sum`/`avg`/`min`/`max` over the matching rows, optionally
1980
- * grouped — the SDK half of `GET /<collection>/aggregate`.
1776
+ * grouped — the SDK half of `GET /<table>/aggregate`.
1981
1777
  *
1982
1778
  * The whole point is not to fetch rows in order to reduce them: "revenue by
1983
1779
  * status" over a million orders is one query and one row per status here,
@@ -2005,7 +1801,7 @@ Inc = IncludeSpec> {
2005
1801
  * { materialized: true }`), as `REFRESH MATERIALIZED VIEW` does.
2006
1802
  *
2007
1803
  * For a caller holding one of the view's `roles` (`dataAsAdmin` does);
2008
- * refused for anyone else and for a collection that is not a materialized
1804
+ * refused for anyone else and for a table that is not a materialized
2009
1805
  * view. With `concurrently`, reads go on being served the old rows while
2010
1806
  * the new ones are computed — slower, and never a blocked read.
2011
1807
  *
@@ -2041,50 +1837,6 @@ Inc = IncludeSpec> {
2041
1837
  /** {@link SDKQueryBuilderInterface.after} */
2042
1838
  after(cursor: string): SDKQueryBuilderInterface<M, Inc>;
2043
1839
  }
2044
- /**
2045
- * The unified data access object for the **admin panel** (Entity-shaped).
2046
- *
2047
- * Access collections as dynamic properties: `data.products.find(...)`. Each
2048
- * accessor returns `Entity`-wrapped records (`{ id, path, values }`) — the
2049
- * view-model the admin renders. This is what `useData()` / the admin
2050
- * `RebaseContext.data` are backed by.
2051
- *
2052
- * @internal App developers do **not** use this — they use
2053
- * {@link RebaseSdkData} (flat rows), which is what the SDK client and backend
2054
- * `context.data` expose. This Entity-shaped map backs the admin panel only.
2055
- *
2056
- * @group Data
2057
- */
2058
- export type RebaseData<DB = unknown> = {
2059
- /**
2060
- * Get a collection accessor by slug.
2061
- * Alternative to dynamic property access for cases where
2062
- * the collection name is a variable.
2063
- *
2064
- * @example
2065
- * const accessor = data.collection("products");
2066
- * await accessor.find({ limit: 10 });
2067
- */
2068
- collection<M extends Record<string, unknown> = Record<string, unknown>>(slug: string): CollectionAccessor<M>;
2069
- } & (DB extends Record<string, unknown> ? {
2070
- [K in keyof DB]: CollectionAccessor<DB[K] extends {
2071
- Row: infer R extends Record<string, unknown>;
2072
- } ? R : Record<string, unknown>>;
2073
- } : {
2074
- /**
2075
- * Dynamic collection accessor.
2076
- * Access any collection by its slug as a property.
2077
- *
2078
- * The index signature is `CollectionAccessor` alone, for the reason
2079
- * spelled out on {@link RebaseSdkData}: unioning in the `collection`
2080
- * method's own signature is unnecessary across an intersection, and it
2081
- * costs `data.products.find()` — the access this `@example` documents.
2082
- *
2083
- * @example
2084
- * data.products.find({ where: { status: ["==", "published"] } })
2085
- */
2086
- [collectionSlug: string]: CollectionAccessor;
2087
- });
2088
1840
  /**
2089
1841
  * The unified data access object for the **SDK** — flat rows, no Entity wrapper.
2090
1842
  *
@@ -2094,8 +1846,9 @@ export type RebaseData<DB = unknown> = {
2094
1846
  * - Backend framework callbacks & scripts (`context.data.products.find()`)
2095
1847
  *
2096
1848
  * Every accessor returns flat rows (the table's columns) via
2097
- * {@link SDKCollectionClient} — access fields directly (`row.title`), never
2098
- * `row.values.title`. The admin uses {@link RebaseData} (Entity) instead.
1849
+ * {@link SDKTableClient} — access fields directly (`row.title`), never
1850
+ * `row.values.title`. (The admin panel's `Entity` view model is built from
1851
+ * these rows in `@rebasepro/cms-types`.)
2099
1852
  *
2100
1853
  * @example
2101
1854
  * // Frontend SDK
@@ -2153,63 +1906,63 @@ type EntryOfSlug<DB, S extends string> = DB[{
2153
1906
  } ? K : never;
2154
1907
  }[keyof DB]];
2155
1908
  /**
2156
- * `collection(slug)` for a slug the registered `Database` declares: the same
2157
- * typed client as the slug's accessor (`collection("my-notes")` is
1909
+ * `table(slug)` for a slug the registered `Database` declares: the same
1910
+ * typed client as the slug's accessor (`table("my-notes")` is
2158
1911
  * `myNotes`). A slug it does not declare, or one computed at runtime, is
2159
1912
  * served by the untyped overload.
2160
1913
  */
2161
- type TypedSlugCollection<DB> = {
2162
- collection<S extends SlugOf<DB>>(slug: S): SDKCollectionClient<RowOf<EntryOfSlug<DB, S>>, InsertOf<EntryOfSlug<DB, S>>, UpdateOf<EntryOfSlug<DB, S>>, IncludeOf<EntryOfSlug<DB, S>, DB>>;
1914
+ type TypedSlugTable<DB> = {
1915
+ table<S extends SlugOf<DB>>(slug: S): SDKTableClient<RowOf<EntryOfSlug<DB, S>>, InsertOf<EntryOfSlug<DB, S>>, UpdateOf<EntryOfSlug<DB, S>>, IncludeOf<EntryOfSlug<DB, S>, DB>>;
2163
1916
  };
2164
1917
  /**
2165
1918
  * Note on the untyped branch below: its index signature is
2166
- * `SDKCollectionClient`, NOT `SDKCollectionClient | ((slug: string) => …)`.
1919
+ * `SDKTableClient`, NOT `SDKTableClient | ((slug: string) => …)`.
2167
1920
  *
2168
- * The union looks like it is needed so `collection` — a method on this same
2169
- * object — satisfies the index signature. It is not, because `collection` is
1921
+ * The union looks like it is needed so `table` — a method on this same
1922
+ * object — satisfies the index signature. It is not, because `table` is
2170
1923
  * declared in a *separate* member of the intersection, and TypeScript only
2171
1924
  * requires named properties to be assignable to an index signature declared
2172
1925
  * alongside them. Including the function arm cost the documented accessor:
2173
1926
  *
2174
1927
  * rebase.dataAsAdmin.projects.find()
2175
1928
  * // ^ Property 'find' does not exist on type
2176
- * // 'SDKCollectionClient | ((slug: string) => …)'
1929
+ * // 'SDKTableClient | ((slug: string) => …)'
2177
1930
  *
2178
1931
  * Every project without a generated `Database` type lands on this branch, so
2179
1932
  * property-style access — the form used by the `@example` below, by the
2180
1933
  * scaffolded function template, and by the 0.13 migration note — did not
2181
- * compile for any of them. Do not restore the arm; use `collection(slug)` if a
1934
+ * compile for any of them. Do not restore the arm; use `table(slug)` if a
2182
1935
  * caller genuinely needs the by-slug function.
2183
1936
  */
2184
- export type RebaseSdkData<DB = unknown> = (unknown extends DB ? unknown : TypedSlugCollection<DB>) & {
1937
+ export type RebaseSdkData<DB = unknown> = (unknown extends DB ? unknown : TypedSlugTable<DB>) & {
2185
1938
  /**
2186
- * Get a flat collection accessor by slug.
1939
+ * Get a flat table accessor by slug.
2187
1940
  *
2188
1941
  * @example
2189
- * const accessor = data.collection("products");
1942
+ * const accessor = data.table("products");
2190
1943
  * await accessor.find({ limit: 10 });
2191
1944
  */
2192
- collection<M extends Record<string, unknown> = Record<string, unknown>>(slug: string): SDKCollectionClient<M>;
1945
+ table<M extends Record<string, unknown> = Record<string, unknown>>(slug: string): SDKTableClient<M>;
2193
1946
  /**
2194
- * A mixed list of writes across collections, as one transaction: the
1947
+ * A mixed list of writes across tables, as one transaction: the
2195
1948
  * in-process form of the HTTP client's `client.batch()`, with the same
2196
- * operations, `$ref`s and answer. `collection` is the accessor, as
1949
+ * operations, `$ref`s and answer. `table` is the accessor, as
2197
1950
  * everywhere on this object.
2198
1951
  *
2199
- * Reserved, as `collection` is: a collection whose accessor is `batch` is
2200
- * reached with `data.collection("batch")`.
1952
+ * Reserved, as `table` is: a table whose accessor is `batch` is
1953
+ * reached with `data.table("batch")`.
2201
1954
  */
2202
1955
  batch(operations: BatchOperation<unknown extends DB ? Record<string, unknown> : DB>[]): Promise<BatchResult>;
2203
1956
  } & (unknown extends DB ? {
2204
1957
  /**
2205
- * Dynamic flat collection accessor.
2206
- * Access any collection by its slug as a property.
1958
+ * Dynamic flat table accessor.
1959
+ * Access any table by its slug as a property.
2207
1960
  *
2208
1961
  * @example
2209
1962
  * data.products.find({ where: { status: ["==", "published"] } })
2210
1963
  */
2211
- [collectionSlug: string]: SDKCollectionClient;
1964
+ [tableSlug: string]: SDKTableClient;
2212
1965
  } : {
2213
- [K in keyof DB]: SDKCollectionClient<RowOf<DB[K]>, InsertOf<DB[K]>, UpdateOf<DB[K]>, IncludeOf<DB[K], DB>>;
1966
+ [K in keyof DB]: SDKTableClient<RowOf<DB[K]>, InsertOf<DB[K]>, UpdateOf<DB[K]>, IncludeOf<DB[K], DB>>;
2214
1967
  });
2215
1968
  export {};