@rebasepro/types 0.13.0 → 0.13.1-canary.gcd6689e
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.
|
@@ -539,10 +539,15 @@ export type RebaseData<DB = unknown> = {
|
|
|
539
539
|
* Dynamic collection accessor.
|
|
540
540
|
* Access any collection by its slug as a property.
|
|
541
541
|
*
|
|
542
|
+
* The index signature is `CollectionAccessor` alone, for the reason
|
|
543
|
+
* spelled out on {@link RebaseSdkData}: unioning in the `collection`
|
|
544
|
+
* method's own signature is unnecessary across an intersection, and it
|
|
545
|
+
* costs `data.products.find()` — the access this `@example` documents.
|
|
546
|
+
*
|
|
542
547
|
* @example
|
|
543
548
|
* data.products.find({ where: { status: ["==", "published"] } })
|
|
544
549
|
*/
|
|
545
|
-
[collectionSlug: string]: CollectionAccessor
|
|
550
|
+
[collectionSlug: string]: CollectionAccessor;
|
|
546
551
|
});
|
|
547
552
|
/**
|
|
548
553
|
* The unified data access object for the **SDK** — flat rows, no Entity wrapper.
|
|
@@ -595,6 +600,26 @@ export type InsertOf<T> = T extends {
|
|
|
595
600
|
export type UpdateOf<T> = T extends {
|
|
596
601
|
Update: infer U extends Record<string, unknown>;
|
|
597
602
|
} ? U : Partial<RowOf<T>>;
|
|
603
|
+
/**
|
|
604
|
+
* Note on the untyped branch below: its index signature is
|
|
605
|
+
* `SDKCollectionClient`, NOT `SDKCollectionClient | ((slug: string) => …)`.
|
|
606
|
+
*
|
|
607
|
+
* The union looks like it is needed so `collection` — a method on this same
|
|
608
|
+
* object — satisfies the index signature. It is not, because `collection` is
|
|
609
|
+
* declared in a *separate* member of the intersection, and TypeScript only
|
|
610
|
+
* requires named properties to be assignable to an index signature declared
|
|
611
|
+
* alongside them. Including the function arm cost the documented accessor:
|
|
612
|
+
*
|
|
613
|
+
* rebase.dataAsAdmin.projects.find()
|
|
614
|
+
* // ^ Property 'find' does not exist on type
|
|
615
|
+
* // 'SDKCollectionClient | ((slug: string) => …)'
|
|
616
|
+
*
|
|
617
|
+
* Every project without a generated `Database` type lands on this branch, so
|
|
618
|
+
* property-style access — the form used by the `@example` below, by the
|
|
619
|
+
* scaffolded function template, and by the 0.13 migration note — did not
|
|
620
|
+
* compile for any of them. Do not restore the arm; use `collection(slug)` if a
|
|
621
|
+
* caller genuinely needs the by-slug function.
|
|
622
|
+
*/
|
|
598
623
|
export type RebaseSdkData<DB = unknown> = {
|
|
599
624
|
/**
|
|
600
625
|
* Get a flat collection accessor by slug.
|
|
@@ -614,5 +639,5 @@ export type RebaseSdkData<DB = unknown> = {
|
|
|
614
639
|
* @example
|
|
615
640
|
* data.products.find({ where: { status: ["==", "published"] } })
|
|
616
641
|
*/
|
|
617
|
-
[collectionSlug: string]: SDKCollectionClient
|
|
642
|
+
[collectionSlug: string]: SDKCollectionClient;
|
|
618
643
|
});
|