@rebasepro/types 0.14.1-canary.g7e666eb → 0.14.1

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.
@@ -638,8 +638,14 @@ export interface BackendBootstrapper {
638
638
  * enum types, and never drop, narrow or rewrite anything. This runs
639
639
  * unattended against live customer data with nobody reading a diff, so the
640
640
  * destructive half stays a deliberate migration.
641
+ *
642
+ * `driverResult` is optional: this runs before `initializeDriver`, and only
643
+ * the bundle path has a pre-init stand-in to pass. An adapter built by an
644
+ * application already holds its own connection and MUST use it when this is
645
+ * `undefined` — dereferencing it unconditionally works for managed tenants
646
+ * and breaks every app that builds its own adapter.
641
647
  */
642
- ensureCollectionSchema?(collections: unknown[], driverResult: InitializedDriver, log?: (message: string) => void): Promise<{
648
+ ensureCollectionSchema?(collections: unknown[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
643
649
  applied: number;
644
650
  }>;
645
651
  /**
@@ -658,7 +664,7 @@ export interface BackendBootstrapper {
658
664
  * Runs after auth initialization, because the generated policies call the
659
665
  * `auth.*` helper functions and `CREATE POLICY` validates they exist.
660
666
  */
661
- ensureCollectionPolicies?(collections: unknown[], driverResult: InitializedDriver, log?: (message: string) => void): Promise<{
667
+ ensureCollectionPolicies?(collections: unknown[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
662
668
  applied: number;
663
669
  }>;
664
670
  /**
@@ -84,8 +84,16 @@ export interface DatabaseAdapter {
84
84
  * into a `BackendBootstrapper`: the runtime calls it through the bootstrapper
85
85
  * at boot, and a wrapper that silently omits it leaves a managed tenant
86
86
  * 500ing every data route with no create step ever having run.
87
+ *
88
+ * `driverResult` is optional because this runs BEFORE `initializeDriver`, so
89
+ * there may be no result to pass. The bundle path can supply a pre-init
90
+ * stand-in because the coordinator opened the connection itself; an app that
91
+ * constructed this adapter never handed the framework a connection handle,
92
+ * so it passes `undefined` and the adapter MUST fall back to the connection
93
+ * it was constructed with. An adapter that dereferences `driverResult`
94
+ * unconditionally works for managed tenants and breaks every self-built one.
87
95
  */
88
- ensureCollectionSchema?(collections: unknown[], driverResult: InitializedDriver, log?: (message: string) => void): Promise<{
96
+ ensureCollectionSchema?(collections: unknown[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
89
97
  applied: number;
90
98
  }>;
91
99
  /**
@@ -98,7 +106,7 @@ export interface DatabaseAdapter {
98
106
  * policies, tables exist but every user-context read is denied (a public
99
107
  * collection answers 401).
100
108
  */
101
- ensureCollectionPolicies?(collections: unknown[], driverResult: InitializedDriver, log?: (message: string) => void): Promise<{
109
+ ensureCollectionPolicies?(collections: unknown[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
102
110
  applied: number;
103
111
  }>;
104
112
  /**
@@ -147,4 +155,25 @@ export interface DatabaseAdapterInitConfig {
147
155
  baas?: {
148
156
  unprotectedTables?: "exclude" | "serve";
149
157
  };
158
+ /**
159
+ * What the runtime's boot-time table provisioning did, in this process,
160
+ * before this driver was initialized.
161
+ *
162
+ * A driver that checks for missing tables cannot otherwise tell "the create
163
+ * step ran and this table still is not here" from "no create step ran at
164
+ * all" — and those need opposite advice. The Postgres driver's drift warning
165
+ * assumed the first, told operators to redeploy with REBASE_MIGRATE_ON_BOOT
166
+ * unset, and pointed at driver version skew; for an app whose boot path had
167
+ * no provisioning step, all of that was unactionable and one investigation
168
+ * chased a driver that was perfectly current.
169
+ *
170
+ * Absent when the caller predates this field: treat that as "unknown" and
171
+ * fall back to generic guidance rather than asserting either case.
172
+ */
173
+ schemaProvisioning?: {
174
+ /** Whether the table-creation hook actually ran this boot. */
175
+ attempted: boolean;
176
+ /** Why it did not, when it did not — safe to print verbatim. */
177
+ reason?: string;
178
+ };
150
179
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/types",
3
3
  "type": "module",
4
- "version": "0.14.1-canary.g7e666eb",
4
+ "version": "0.14.1",
5
5
  "description": "Rebase type definitions — shared interfaces and controller types",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -539,6 +539,31 @@ export interface RestFetchService {
539
539
  include?: string[]
540
540
  ): Promise<Record<string, unknown>[]>;
541
541
 
542
+ /**
543
+ * `count`/`sum`/`avg`/`min`/`max` over the rows a filter selects,
544
+ * optionally grouped.
545
+ *
546
+ * Optional, and the REST route answers 501 where a driver does not
547
+ * implement it — an aggregate is not a thing to approximate, and an empty
548
+ * result set would read as "nothing matched".
549
+ *
550
+ * Any implementation **must apply the same row-level authorization as a
551
+ * read**. An aggregate is an efficient way to learn about rows you cannot
552
+ * select, and `count(*)` over a table whose policies would return nothing
553
+ * has to be zero.
554
+ */
555
+ aggregate?(
556
+ collectionPath: string,
557
+ options: {
558
+ aggregates: { fn: "count" | "sum" | "avg" | "min" | "max"; field?: string; alias: string }[];
559
+ groupBy?: string[];
560
+ filter?: FilterValues<string>;
561
+ logical?: LogicalCondition;
562
+ searchString?: string;
563
+ limit?: number;
564
+ }
565
+ ): Promise<Record<string, unknown>[]>;
566
+
542
567
  /**
543
568
  * Fetch a single flattened entity with optional relation includes.
544
569
  */
@@ -822,10 +822,16 @@ export interface BackendBootstrapper {
822
822
  * enum types, and never drop, narrow or rewrite anything. This runs
823
823
  * unattended against live customer data with nobody reading a diff, so the
824
824
  * destructive half stays a deliberate migration.
825
+ *
826
+ * `driverResult` is optional: this runs before `initializeDriver`, and only
827
+ * the bundle path has a pre-init stand-in to pass. An adapter built by an
828
+ * application already holds its own connection and MUST use it when this is
829
+ * `undefined` — dereferencing it unconditionally works for managed tenants
830
+ * and breaks every app that builds its own adapter.
825
831
  */
826
832
  ensureCollectionSchema?(
827
833
  collections: unknown[],
828
- driverResult: InitializedDriver,
834
+ driverResult?: InitializedDriver,
829
835
  log?: (message: string) => void
830
836
  ): Promise<{ applied: number }>;
831
837
 
@@ -847,7 +853,7 @@ export interface BackendBootstrapper {
847
853
  */
848
854
  ensureCollectionPolicies?(
849
855
  collections: unknown[],
850
- driverResult: InitializedDriver,
856
+ driverResult?: InitializedDriver,
851
857
  log?: (message: string) => void
852
858
  ): Promise<{ applied: number }>;
853
859
 
@@ -108,10 +108,18 @@ export interface DatabaseAdapter {
108
108
  * into a `BackendBootstrapper`: the runtime calls it through the bootstrapper
109
109
  * at boot, and a wrapper that silently omits it leaves a managed tenant
110
110
  * 500ing every data route with no create step ever having run.
111
+ *
112
+ * `driverResult` is optional because this runs BEFORE `initializeDriver`, so
113
+ * there may be no result to pass. The bundle path can supply a pre-init
114
+ * stand-in because the coordinator opened the connection itself; an app that
115
+ * constructed this adapter never handed the framework a connection handle,
116
+ * so it passes `undefined` and the adapter MUST fall back to the connection
117
+ * it was constructed with. An adapter that dereferences `driverResult`
118
+ * unconditionally works for managed tenants and breaks every self-built one.
111
119
  */
112
120
  ensureCollectionSchema?(
113
121
  collections: unknown[],
114
- driverResult: InitializedDriver,
122
+ driverResult?: InitializedDriver,
115
123
  log?: (message: string) => void,
116
124
  ): Promise<{ applied: number }>;
117
125
 
@@ -127,7 +135,7 @@ export interface DatabaseAdapter {
127
135
  */
128
136
  ensureCollectionPolicies?(
129
137
  collections: unknown[],
130
- driverResult: InitializedDriver,
138
+ driverResult?: InitializedDriver,
131
139
  log?: (message: string) => void,
132
140
  ): Promise<{ applied: number }>;
133
141
 
@@ -178,4 +186,25 @@ export interface DatabaseAdapterInitConfig {
178
186
  * Drivers that introspect should honour `unprotectedTables`.
179
187
  */
180
188
  baas?: { unprotectedTables?: "exclude" | "serve" };
189
+ /**
190
+ * What the runtime's boot-time table provisioning did, in this process,
191
+ * before this driver was initialized.
192
+ *
193
+ * A driver that checks for missing tables cannot otherwise tell "the create
194
+ * step ran and this table still is not here" from "no create step ran at
195
+ * all" — and those need opposite advice. The Postgres driver's drift warning
196
+ * assumed the first, told operators to redeploy with REBASE_MIGRATE_ON_BOOT
197
+ * unset, and pointed at driver version skew; for an app whose boot path had
198
+ * no provisioning step, all of that was unactionable and one investigation
199
+ * chased a driver that was perfectly current.
200
+ *
201
+ * Absent when the caller predates this field: treat that as "unknown" and
202
+ * fall back to generic guidance rather than asserting either case.
203
+ */
204
+ schemaProvisioning?: {
205
+ /** Whether the table-creation hook actually ran this boot. */
206
+ attempted: boolean;
207
+ /** Why it did not, when it did not — safe to print verbatim. */
208
+ reason?: string;
209
+ };
181
210
  }