@rebasepro/types 0.13.0 → 0.13.1-canary.g3660bd5
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.
|
@@ -34,13 +34,19 @@ export interface FilterCondition {
|
|
|
34
34
|
*
|
|
35
35
|
* `limit`/`offset` and `page` describe the same window two ways. If **both
|
|
36
36
|
* `offset` and `page` are provided, `page` wins** — the backend computes
|
|
37
|
-
* `offset = (page - 1) * (limit ??
|
|
38
|
-
* Pick one style per query.
|
|
37
|
+
* `offset = (page - 1) * (limit ?? DEFAULT_LIST_LIMIT)` and ignores the
|
|
38
|
+
* explicit `offset`. Pick one style per query.
|
|
39
39
|
*
|
|
40
40
|
* @group Data
|
|
41
41
|
*/
|
|
42
42
|
export interface FindParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of items to return.
|
|
45
|
+
*
|
|
46
|
+
* Defaults to {@link DEFAULT_LIST_LIMIT}, and is clamped to
|
|
47
|
+
* {@link MAX_LIST_LIMIT}. Both bounds are applied by the backend, so a
|
|
48
|
+
* read is never unbounded whether or not a limit was asked for.
|
|
49
|
+
*/
|
|
44
50
|
limit?: number;
|
|
45
51
|
/**
|
|
46
52
|
* Number of items to skip. Ignored when {@link FindParams.page} is also
|
|
@@ -49,7 +55,7 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
|
|
|
49
55
|
offset?: number;
|
|
50
56
|
/**
|
|
51
57
|
* Page number (1-indexed), alternative to {@link FindParams.offset}.
|
|
52
|
-
* When set, overrides `offset` as `(page - 1) * (limit ??
|
|
58
|
+
* When set, overrides `offset` as `(page - 1) * (limit ?? DEFAULT_LIST_LIMIT)`.
|
|
53
59
|
*/
|
|
54
60
|
page?: number;
|
|
55
61
|
/**
|
|
@@ -539,10 +545,15 @@ export type RebaseData<DB = unknown> = {
|
|
|
539
545
|
* Dynamic collection accessor.
|
|
540
546
|
* Access any collection by its slug as a property.
|
|
541
547
|
*
|
|
548
|
+
* The index signature is `CollectionAccessor` alone, for the reason
|
|
549
|
+
* spelled out on {@link RebaseSdkData}: unioning in the `collection`
|
|
550
|
+
* method's own signature is unnecessary across an intersection, and it
|
|
551
|
+
* costs `data.products.find()` — the access this `@example` documents.
|
|
552
|
+
*
|
|
542
553
|
* @example
|
|
543
554
|
* data.products.find({ where: { status: ["==", "published"] } })
|
|
544
555
|
*/
|
|
545
|
-
[collectionSlug: string]: CollectionAccessor
|
|
556
|
+
[collectionSlug: string]: CollectionAccessor;
|
|
546
557
|
});
|
|
547
558
|
/**
|
|
548
559
|
* The unified data access object for the **SDK** — flat rows, no Entity wrapper.
|
|
@@ -595,6 +606,26 @@ export type InsertOf<T> = T extends {
|
|
|
595
606
|
export type UpdateOf<T> = T extends {
|
|
596
607
|
Update: infer U extends Record<string, unknown>;
|
|
597
608
|
} ? U : Partial<RowOf<T>>;
|
|
609
|
+
/**
|
|
610
|
+
* Note on the untyped branch below: its index signature is
|
|
611
|
+
* `SDKCollectionClient`, NOT `SDKCollectionClient | ((slug: string) => …)`.
|
|
612
|
+
*
|
|
613
|
+
* The union looks like it is needed so `collection` — a method on this same
|
|
614
|
+
* object — satisfies the index signature. It is not, because `collection` is
|
|
615
|
+
* declared in a *separate* member of the intersection, and TypeScript only
|
|
616
|
+
* requires named properties to be assignable to an index signature declared
|
|
617
|
+
* alongside them. Including the function arm cost the documented accessor:
|
|
618
|
+
*
|
|
619
|
+
* rebase.dataAsAdmin.projects.find()
|
|
620
|
+
* // ^ Property 'find' does not exist on type
|
|
621
|
+
* // 'SDKCollectionClient | ((slug: string) => …)'
|
|
622
|
+
*
|
|
623
|
+
* Every project without a generated `Database` type lands on this branch, so
|
|
624
|
+
* property-style access — the form used by the `@example` below, by the
|
|
625
|
+
* scaffolded function template, and by the 0.13 migration note — did not
|
|
626
|
+
* compile for any of them. Do not restore the arm; use `collection(slug)` if a
|
|
627
|
+
* caller genuinely needs the by-slug function.
|
|
628
|
+
*/
|
|
598
629
|
export type RebaseSdkData<DB = unknown> = {
|
|
599
630
|
/**
|
|
600
631
|
* Get a flat collection accessor by slug.
|
|
@@ -614,5 +645,5 @@ export type RebaseSdkData<DB = unknown> = {
|
|
|
614
645
|
* @example
|
|
615
646
|
* data.products.find({ where: { status: ["==", "published"] } })
|
|
616
647
|
*/
|
|
617
|
-
[collectionSlug: string]: SDKCollectionClient
|
|
648
|
+
[collectionSlug: string]: SDKCollectionClient;
|
|
618
649
|
});
|