@palbase/backend 35.0.1 → 36.0.0

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 (70) hide show
  1. package/dist/bin/palbase-backend.cjs +556 -487
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +6 -6
  4. package/dist/{chunk-L4R7WXLH.js → chunk-7WAGQ3VR.js} +4 -171
  5. package/dist/chunk-7WAGQ3VR.js.map +1 -0
  6. package/dist/{chunk-UMESJJRS.js → chunk-CS6NQ6PO.js} +2 -1
  7. package/dist/chunk-CS6NQ6PO.js.map +1 -0
  8. package/dist/{chunk-BOD3DT6D.js → chunk-EHKEMHB4.js} +560 -430
  9. package/dist/chunk-EHKEMHB4.js.map +1 -0
  10. package/dist/{chunk-PRH45NZU.js → chunk-FFO36MQQ.js} +2 -45
  11. package/dist/chunk-FFO36MQQ.js.map +1 -0
  12. package/dist/{chunk-P7MGSAFT.js → chunk-LFUNRWUE.js} +1 -40
  13. package/dist/chunk-LFUNRWUE.js.map +1 -0
  14. package/dist/{chunk-RZLY4BOY.js → chunk-PDD55QWN.js} +2 -2
  15. package/dist/{chunk-YO5GYM73.js → chunk-X7UR3VXA.js} +5 -6
  16. package/dist/chunk-X7UR3VXA.js.map +1 -0
  17. package/dist/{chunk-6FEHCEB7.js → chunk-YANGWAIM.js} +3 -3
  18. package/dist/db/index.cjs +1 -232
  19. package/dist/db/index.cjs.map +1 -1
  20. package/dist/db/index.d.cts +3 -46
  21. package/dist/db/index.d.ts +3 -46
  22. package/dist/db/index.js +4 -12
  23. package/dist/engine/index.cjs +556 -487
  24. package/dist/engine/index.cjs.map +1 -1
  25. package/dist/engine/index.d.cts +4 -4
  26. package/dist/engine/index.d.ts +4 -4
  27. package/dist/engine/index.js +6 -6
  28. package/dist/{index-DllNjpTl.d.cts → index-CI7S0Wqv.d.cts} +61 -8
  29. package/dist/{endpoint-BI0yGuEL.d.ts → index-CUy50OLU.d.ts} +6 -82
  30. package/dist/{endpoint-DaGnjt42.d.cts → index-DRx880KY.d.cts} +6 -82
  31. package/dist/{index-E8Sd6NFy.d.ts → index-Ogi30dbt.d.ts} +61 -8
  32. package/dist/index.cjs +5 -237
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +6 -7
  35. package/dist/index.d.ts +6 -7
  36. package/dist/index.js +7 -15
  37. package/dist/index.js.map +1 -1
  38. package/dist/openapi/index.cjs +1 -0
  39. package/dist/openapi/index.cjs.map +1 -1
  40. package/dist/openapi/index.d.cts +3 -3
  41. package/dist/openapi/index.d.ts +3 -3
  42. package/dist/openapi/index.js +2 -2
  43. package/dist/{registry-BnKvIyve.d.cts → registry-C7UCkQf0.d.cts} +1 -1
  44. package/dist/{registry-zDCj0eOU.d.ts → registry-DJcvbomD.d.ts} +1 -1
  45. package/dist/test/index.cjs +3 -11
  46. package/dist/test/index.cjs.map +1 -1
  47. package/dist/test/index.d.cts +2 -2
  48. package/dist/test/index.d.ts +2 -2
  49. package/dist/test/index.js +2 -9
  50. package/dist/test/index.js.map +1 -1
  51. package/docs/README.md +1 -1
  52. package/docs/database.md +2 -60
  53. package/docs/examples/database-dx.ts +12 -17
  54. package/docs/llms-full.txt +3 -61
  55. package/package.json +1 -1
  56. package/stager/inferred_returns.js +153 -0
  57. package/stager/return_types.js +9 -4
  58. package/stager/stage.js +3 -1
  59. package/template/AGENTS.md +5 -5
  60. package/template/package.json +2 -2
  61. package/dist/chunk-BOD3DT6D.js.map +0 -1
  62. package/dist/chunk-L4R7WXLH.js.map +0 -1
  63. package/dist/chunk-P7MGSAFT.js.map +0 -1
  64. package/dist/chunk-PRH45NZU.js.map +0 -1
  65. package/dist/chunk-UMESJJRS.js.map +0 -1
  66. package/dist/chunk-YO5GYM73.js.map +0 -1
  67. package/docs/examples/check-query-contracts.ts +0 -5
  68. package/docs/examples/database-dx.contract.json +0 -65
  69. /package/dist/{chunk-RZLY4BOY.js.map → chunk-PDD55QWN.js.map} +0 -0
  70. /package/dist/{chunk-6FEHCEB7.js.map → chunk-YANGWAIM.js.map} +0 -0
@@ -1,8 +1,8 @@
1
- import '../endpoint-DaGnjt42.cjs';
2
- export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-DllNjpTl.cjs';
1
+ import '../index-DRx880KY.cjs';
2
+ export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-CI7S0Wqv.cjs';
3
3
  import 'zod';
4
- import '../stack.cjs';
5
4
  import '../db/env.cjs';
5
+ import '../stack.cjs';
6
6
  import 'node:async_hooks';
7
7
  import '../module-Dl1KFVtc.cjs';
8
- import '../registry-BnKvIyve.cjs';
8
+ import '../registry-C7UCkQf0.cjs';
@@ -1,8 +1,8 @@
1
- import '../endpoint-BI0yGuEL.js';
2
- export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-E8Sd6NFy.js';
1
+ import '../index-CUy50OLU.js';
2
+ export { A as App, g as AuthVerifier, B as BootRefused, h as COMMAND_EXECUTOR_DDL, j as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, k as EngineConfig, M as ModuleClients, R as RateLimiter, l as RequestDatabase, m as RouteEntry, n as RuntimeHooks, S as ScrubResult, o as SqlDriver, p as SqlTx, q as buildRouteTable, r as createApp, s as createLazyTransaction, t as createOps, u as createRequestDatabase, v as effectiveAuth, w as hostAllowed, x as installCommandExecutor, y as installEgressFence, i as isDeclarationRefused, z as loadConfig, F as makeMemoryCache, G as matchRoute, H as quoteIdent, I as scrubSecrets, J as setCursorKey, K as withQueryCancellation, L as withTables } from '../index-Ogi30dbt.js';
3
3
  import 'zod';
4
- import '../stack.js';
5
4
  import '../db/env.js';
5
+ import '../stack.js';
6
6
  import 'node:async_hooks';
7
7
  import '../module-Dl1KFVtc.js';
8
- import '../registry-zDCj0eOU.js';
8
+ import '../registry-DJcvbomD.js';
@@ -20,18 +20,18 @@ import {
20
20
  setCursorKey,
21
21
  withQueryCancellation,
22
22
  withTables
23
- } from "../chunk-BOD3DT6D.js";
23
+ } from "../chunk-EHKEMHB4.js";
24
24
  import {
25
25
  DECLARATION_REFUSAL,
26
26
  DeclarationRefused,
27
27
  isDeclarationRefused
28
- } from "../chunk-6FEHCEB7.js";
28
+ } from "../chunk-YANGWAIM.js";
29
29
  import "../chunk-GHNC2UHS.js";
30
- import "../chunk-YO5GYM73.js";
31
- import "../chunk-PRH45NZU.js";
32
- import "../chunk-P7MGSAFT.js";
30
+ import "../chunk-X7UR3VXA.js";
31
+ import "../chunk-FFO36MQQ.js";
32
+ import "../chunk-LFUNRWUE.js";
33
33
  import "../chunk-JJW3L62T.js";
34
- import "../chunk-UMESJJRS.js";
34
+ import "../chunk-CS6NQ6PO.js";
35
35
  import "../chunk-VXPNPVAG.js";
36
36
  export {
37
37
  AuthVerifier,
@@ -1,6 +1,54 @@
1
- import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, P as PreparedRead, C as CompiledRead, f as RawPageOptions, g as Page, h as TxPlanBody, i as CommandOptions, j as TxPlanResponse, A as AuthSpec, k as CacheClient, b as RuntimeServices, _ as __runWithRuntime, l as __requestALS } from './endpoint-DaGnjt42.cjs';
1
+ import { c as DatabaseDiagnosticsOptions, d as DatabaseDiagnostics, a as DBClient, T as TransactionIsolation, e as DBOps, f as RawPageOptions, P as Page, g as TxPlanBody, C as CommandOptions, h as TxPlanResponse, A as AuthSpec, i as CacheClient, b as RuntimeServices, _ as __runWithRuntime, j as __requestALS } from './index-DRx880KY.cjs';
2
2
  import { T as Token } from './module-Dl1KFVtc.cjs';
3
- import { R as RouteMeta } from './registry-BnKvIyve.cjs';
3
+ import { R as RouteMeta } from './registry-C7UCkQf0.cjs';
4
+
5
+ interface AdmissionLease {
6
+ queueMs: number;
7
+ release(): void;
8
+ }
9
+ /** Deployment settings, never a query/workload declaration in application code. */
10
+ interface DatabaseAdmissionOptions {
11
+ concurrency: number;
12
+ queueLimit?: number;
13
+ queueTimeoutMs?: number;
14
+ /** Optional signed, issuer-controlled top-level tenant claim. By default
15
+ * fairness uses verified sub, not the installation-wide tenant_id. */
16
+ tenantClaim?: string;
17
+ onReject?: (event: {
18
+ reason: "full" | "timeout" | "cancelled";
19
+ active: number;
20
+ queued: number;
21
+ }) => void;
22
+ }
23
+ declare class DatabaseAdmission {
24
+ readonly options: DatabaseAdmissionOptions;
25
+ private active;
26
+ private queued;
27
+ private tenants;
28
+ private pending;
29
+ private lastTenant?;
30
+ private accepted;
31
+ private rejected;
32
+ private readonly limit;
33
+ private readonly timeout;
34
+ constructor(options: DatabaseAdmissionOptions);
35
+ get snapshot(): {
36
+ active: number;
37
+ queued: number;
38
+ tenants: number;
39
+ accepted: number;
40
+ rejected: {
41
+ full: number;
42
+ timeout: number;
43
+ cancelled: number;
44
+ };
45
+ };
46
+ private rejection;
47
+ private take;
48
+ private drain;
49
+ acquire(claimsJson: string, signal?: AbortSignal): Promise<AdmissionLease>;
50
+ }
51
+ declare function databaseAdmission(owner: object, options?: DatabaseAdmissionOptions): DatabaseAdmission;
4
52
 
5
53
  /**
6
54
  * engine/config.ts — settings from the environment, and the gate that refuses
@@ -70,6 +118,8 @@ interface EngineConfig {
70
118
  */
71
119
  dbServiceRole: string;
72
120
  poolMax: number;
121
+ /** Internal engine/core deployment policy; application CRUD has no capacity options. */
122
+ databaseAdmission?: Omit<DatabaseAdmissionOptions, "concurrency">;
73
123
  databaseDiagnostics?: DatabaseDiagnosticsOptions;
74
124
  }
75
125
  /**
@@ -121,7 +171,7 @@ declare class TransactionControl {
121
171
  dispose(): void;
122
172
  }
123
173
 
124
- type Timing = "queueMs" | "poolMs" | "setupMs" | "sqlMs" | "commitMs" | "rollbackMs";
174
+ type Timing = "queueMs" | "poolMs" | "setupMs" | "sqlMs" | "commitMs" | "rollbackMs" | "connectionMs";
125
175
  /** Allocated only when diagnostics or a budget is configured. One collector
126
176
  * follows the request's user/service handles and independent atomic attempts. */
127
177
  declare class DatabaseTrace {
@@ -147,6 +197,8 @@ declare class DatabaseTrace {
147
197
 
148
198
  /** The slice of a SQL driver the engine uses. `Bun.sql` satisfies it. */
149
199
  interface SqlDriver {
200
+ /** Shared by every request and identity using this physical application pool. */
201
+ admission?: DatabaseAdmission;
150
202
  /** Optional reliable cancellation through a separate control connection. */
151
203
  cancelBackend?(pid: number, startedAt: string): Promise<void>;
152
204
  /** Run a parameterised statement. */
@@ -225,7 +277,7 @@ interface OpsContext {
225
277
  readonly commands?: boolean;
226
278
  readonly trace?: DatabaseTrace;
227
279
  }
228
- declare function createOps(tx: TxLike, context?: OpsContext): {
280
+ declare function createOps(tx: TxLike | (() => TxLike | Promise<TxLike>), context?: OpsContext): {
229
281
  diagnostics(): DatabaseDiagnostics | null;
230
282
  query<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;
231
283
  insert(table: string, data: Row): Promise<Row>;
@@ -380,9 +432,6 @@ declare function createOps(tx: TxLike, context?: OpsContext): {
380
432
  with?: Record<string, unknown>;
381
433
  }): Promise<Row | null>;
382
434
  findById(table: string, id: string): Promise<Row | null>;
383
- compileQuery(query: PreparedRead): CompiledRead;
384
- readQuery(query: PreparedRead): Promise<Row[]>;
385
- explainQuery(query: PreparedRead): Promise<unknown[]>;
386
435
  findMany(table: string, query?: Row, opts?: FindManyOptions): Promise<Row[]>;
387
436
  page(table: string, query?: Row, opts?: RawPageOptions): Promise<Page<Row>>;
388
437
  /**
@@ -557,6 +606,8 @@ declare function withTables<T extends ReturnType<typeof createOps>>(ops: T, sche
557
606
  interface RequestDatabase {
558
607
  /** What the engine injects as the request's `Database` singleton. */
559
608
  readonly client: DBClient;
609
+ /** @internal Core has finished its read-only authorization queries. */
610
+ authorizationComplete?(): void;
560
611
  /** Commit whatever was opened. Called once, after the handler returns. */
561
612
  commit(): Promise<void>;
562
613
  /** Roll back whatever was opened. Called once, when the handler throws. */
@@ -619,7 +670,7 @@ declare function createRequestDatabase(sql: SqlDriver, identity: {
619
670
  role: string;
620
671
  serviceRole: string;
621
672
  claimsJson: string;
622
- }, diagnostics?: DatabaseDiagnosticsOptions): RequestDatabase;
673
+ }, diagnostics?: DatabaseDiagnosticsOptions, signal?: AbortSignal): RequestDatabase;
623
674
 
624
675
  /**
625
676
  * The two ways a stack refuses to boot — and they are two because their CURES
@@ -1100,6 +1151,8 @@ interface CreateAppOptions {
1100
1151
  logger?: Pick<Console, "info" | "warn" | "error" | "debug">;
1101
1152
  }
1102
1153
  interface App {
1154
+ /** Core/operator observation of the shared physical pool's admission queue. */
1155
+ readonly databasePressure?: ReturnType<typeof databaseAdmission>["snapshot"];
1103
1156
  handle: (req: Request) => Promise<Response>;
1104
1157
  routes: readonly RouteEntry[];
1105
1158
  config: EngineConfig;
@@ -1,6 +1,6 @@
1
1
  import { z, ZodSchema } from 'zod';
2
- import { PalbaseFlagKey, Buckets, BucketTypes, PalbaseSecretName } from './stack.js';
3
2
  import { Schemas, Tables, TableTypes } from './db/env.js';
3
+ import { PalbaseFlagKey, Buckets, BucketTypes, PalbaseSecretName } from './stack.js';
4
4
  import { AsyncLocalStorage } from 'node:async_hooks';
5
5
 
6
6
  interface CommandOptions {
@@ -84,6 +84,8 @@ interface DatabaseDiagnostics {
84
84
  queueMs: number;
85
85
  /** Time until the driver's transaction callback starts; includes wire BEGIN. */
86
86
  poolMs: number;
87
+ /** From the driver's BEGIN callback through acknowledged COMMIT/ROLLBACK. */
88
+ connectionMs?: number;
87
89
  setupMs: number;
88
90
  /** Driver wait including PostgreSQL execution/locks and network time. */
89
91
  sqlMs: number;
@@ -3162,31 +3164,6 @@ declare const Flags: PalbaseFlagsAmbient;
3162
3164
  */
3163
3165
  declare const Realtime: PalbaseRealtimeClient;
3164
3166
 
3165
- /** Limits apply per engine process. PostgreSQL locks remain the authority when
3166
- * several replicas write the same rows. Size the total budget across replicas. */
3167
- interface WorkloadOptions {
3168
- concurrency: number;
3169
- queueLimit: number;
3170
- tenantConcurrency?: number;
3171
- tenantQueueLimit?: number;
3172
- queueTimeoutMs?: number;
3173
- /** Read from authenticated claims; defaults to tenant_id, then sub, then one
3174
- * shared anonymous bucket. A request body never chooses the tenant budget. */
3175
- tenantClaim?: string;
3176
- }
3177
- interface DatabaseWorkload {
3178
- readonly name: string;
3179
- readonly concurrency: number;
3180
- readonly queueLimit: number;
3181
- readonly tenantConcurrency: number;
3182
- readonly tenantQueueLimit: number;
3183
- readonly queueTimeoutMs: number;
3184
- readonly tenantClaim: string;
3185
- }
3186
- /** Declare once at module scope and reuse on $atomic calls. Keys, queue limits
3187
- * and tenant budgets affect admission, not SQL permissions or isolation. */
3188
- declare function defineWorkload(name: string, options: WorkloadOptions): DatabaseWorkload;
3189
-
3190
3167
  /** A PostgreSQL isolation level supported by the explicit root transaction. */
3191
3168
  type TransactionIsolation = "read committed" | "repeatable read" | "serializable";
3192
3169
  interface AtomicOptions {
@@ -3203,53 +3180,6 @@ interface AtomicOptions {
3203
3180
  * cancelled; rollback settles before release. An in-flight COMMIT is awaited. */
3204
3181
  timeoutMs?: number;
3205
3182
  signal?: AbortSignal;
3206
- workload?: DatabaseWorkload;
3207
- /** Resource names shared within a workload. Include a tenant prefix if the
3208
- * resource ID itself is only unique inside a tenant. Requires workload. */
3209
- conflictKeys?: readonly string[];
3210
- }
3211
-
3212
- /** Storage metadata that affects the declared response; defaults and unrelated
3213
- * columns do not change an explicitly projected query's contract. */
3214
- interface QueryColumnContract {
3215
- type: string;
3216
- nullable: boolean;
3217
- codec?: string;
3218
- enumValues?: readonly string[];
3219
- dimensions?: number;
3220
- }
3221
- interface PreparedRead {
3222
- name: string;
3223
- table: string;
3224
- columns: Record<string, QueryColumnContract>;
3225
- where: Record<string, unknown>;
3226
- options: {
3227
- select: string[];
3228
- orderBy?: {
3229
- column: string;
3230
- direction?: "asc" | "desc";
3231
- nulls?: "first" | "last";
3232
- } | {
3233
- column: string;
3234
- direction?: "asc" | "desc";
3235
- nulls?: "first" | "last";
3236
- }[];
3237
- limit?: number;
3238
- };
3239
- }
3240
- interface CompiledRead {
3241
- sql: string;
3242
- params: unknown[];
3243
- }
3244
- interface QueryDatabase {
3245
- readQuery(query: PreparedRead): Promise<Record<string, unknown>[]>;
3246
- compileQuery(query: PreparedRead): CompiledRead;
3247
- explainQuery(query: PreparedRead): Promise<unknown[]>;
3248
- }
3249
- interface EnvQueryDatabase {
3250
- $readQuery: QueryDatabase["readQuery"];
3251
- $compileQuery: QueryDatabase["compileQuery"];
3252
- $explainQuery: QueryDatabase["explainQuery"];
3253
3183
  }
3254
3184
 
3255
3185
  /** Keys of C whose columns are required on INSERT (not nullable, no default). */
@@ -3364,7 +3294,7 @@ interface TypedTable<T extends TableDef> {
3364
3294
  }): Promise<number>;
3365
3295
  }
3366
3296
  /** A typed DB facade covering all tables declared in schema `S`. */
3367
- interface TypedDB<S extends SchemaDef> extends QueryDatabase {
3297
+ interface TypedDB<S extends SchemaDef> {
3368
3298
  diagnostics: DBOps["diagnostics"];
3369
3299
  command<T>(fn: (tx: TypedTx<S>) => T extends Promise<unknown> ? never : T, options?: CommandOptions): Promise<Materialized<T>>;
3370
3300
  tables: {
@@ -4344,10 +4274,7 @@ type EnvServiceDatabase = EnvSchemaSurface & {
4344
4274
  $delete: DBClient["delete"];
4345
4275
  $findById: DBClient["findById"];
4346
4276
  $findUnique: DBClient["findUnique"];
4347
- $readQuery: DBClient["readQuery"];
4348
4277
  $diagnostics: DBClient["diagnostics"];
4349
- $compileQuery: DBClient["compileQuery"];
4350
- $explainQuery: DBClient["explainQuery"];
4351
4278
  $findMany: DBClient["findMany"];
4352
4279
  $page: DBClient["page"];
4353
4280
  $put: DBClient["put"];
@@ -4418,10 +4345,7 @@ type EnvTypedDatabase = EnvSchemaSurface & {
4418
4345
  $delete: DBClient["delete"];
4419
4346
  $findById: DBClient["findById"];
4420
4347
  $findUnique: DBClient["findUnique"];
4421
- $readQuery: DBClient["readQuery"];
4422
4348
  $diagnostics: DBClient["diagnostics"];
4423
- $compileQuery: DBClient["compileQuery"];
4424
- $explainQuery: DBClient["explainQuery"];
4425
4349
  $findMany: DBClient["findMany"];
4426
4350
  $page: DBClient["page"];
4427
4351
  $put: DBClient["put"];
@@ -5115,7 +5039,7 @@ interface RateLimitConfig {
5115
5039
  }
5116
5040
  /** The six raw string-keyed DB operations shared by `DBClient` and the
5117
5041
  * transaction-scoped client. */
5118
- interface DBOps extends QueryDatabase {
5042
+ interface DBOps {
5119
5043
  /** Null when diagnostics/budgets are disabled. Binding values are never included. */
5120
5044
  diagnostics(): DatabaseDiagnostics | null;
5121
5045
  /** Match exactly one declared primary/unique key; null never denotes a unique value. */
@@ -5690,4 +5614,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
5690
5614
  */
5691
5615
  type AuthSpec = boolean | Partial<AuthConfig>;
5692
5616
 
5693
- export { type ErrorMap as $, type AuthSpec as A, BadRequest as B, type CompiledRead as C, type DatabaseBudget as D, type EnvServiceDatabase as E, type ColumnMap as F, type ColumnType as G, HttpError as H, Conflict as I, Database as J, type DatabaseQueryEvent as K, type DatabaseWorkload as L, DeadlockDetected as M, Documents as N, EXTENSION_DEPENDENCIES as O, type PreparedRead as P, type EmbeddingModelRef as Q, type RateLimitConfig as R, type SchemaDef as S, type TransactionIsolation as T, type EnvQueryDatabase as U, type EnvSchemas as V, type EnvTables as W, type EnvTypedDatabase as X, type EnvTypedTable as Y, type ErrorDef as Z, __runWithRuntime as _, type DBClient as a, type PalbaseFileObject as a$, type ErrorThrowers as a0, type FileContext as a1, type FindManyOpts as a2, Flags as a3, Forbidden as a4, type HttpMethod as a5, IndexBuilder as a6, type IndexDef as a7, type InsertManyOptions as a8, type InsertShape as a9, type PalbaseAttestiOSResult as aA, type PalbaseAuthAdminClient as aB, type PalbaseAuthClient as aC, type PalbaseBatchOverrideOperation as aD, type PalbaseBatchSetOverridesResult as aE, type PalbaseBindDeviceParams as aF, type PalbaseBucketClient as aG, type PalbaseClearAllOverridesResult as aH, type PalbaseClearOverrideResult as aI, type PalbaseCohortQueryInput as aJ, type PalbaseCohortResult as aK, type PalbaseCollectionRef as aL, type PalbaseCountQueryInput as aM, type PalbaseCountResult as aN, type PalbaseCreateLinkParams as aO, type PalbaseDeviceInfo as aP, type PalbaseDeviceTokenView as aQ, type PalbaseDocsClient as aR, type PalbaseDocumentRef as aS, type PalbaseDocumentSnapshot as aT, type PalbaseEmailClient as aU, type PalbaseEmailSendParams as aV, type PalbaseEmailSendResponse as aW, type PalbaseEventNamesResult as aX, type PalbaseEventsQueryInput as aY, type PalbaseEventsResult as aZ, type PalbaseExtension as a_, type InsertValues as aa, type LifecycleHook as ab, Log as ac, type Logger as ad, type Materialized as ae, type Middleware as af, type MiddlewareContext as ag, type MiddlewareHandler as ah, type MutateInput as ai, NotFound as aj, Notifications as ak, type OnDeleteAction as al, type OrderBySpec as am, PALBASE_EXTENSIONS as an, type PBRequest as ao, type PageInfo as ap, type PageInput as aq, type PageNavigation as ar, PalError as as, type PalbaseAnalyticsClient as at, type PalbaseAnalyticsManagementNamespace as au, type PalbaseAnalyticsProperties as av, type PalbaseAnalyticsQueryNamespace as aw, type PalbaseAttestAndroidParams as ax, type PalbaseAttestAndroidResult as ay, type PalbaseAttestiOSParams as az, type RuntimeServices as b, type PalbaseWhereOperator as b$, type PalbaseFlag as b0, type PalbaseFlagContext as b1, type PalbaseFlagSource as b2, type PalbaseFlagValue as b3, type PalbaseFlagVariant as b4, type PalbaseFlagsClient as b5, type PalbaseFlagsServiceClient as b6, type PalbaseFunctionsClient as b7, type PalbaseFunnelQueryInput as b8, type PalbaseFunnelResult as b9, type PalbaseQrCodeOptions as bA, type PalbaseQuerySnapshot as bB, type PalbaseRealtimeClient as bC, type PalbaseRegisterDeviceParams as bD, type PalbaseRetentionQueryInput as bE, type PalbaseRetentionResult as bF, type PalbaseSession as bG, type PalbaseSetOverrideResult as bH, type PalbaseSetOverridesResult as bI, type PalbaseSignedUrlResponse as bJ, type PalbaseSmsClient as bK, type PalbaseSmsSendParams as bL, type PalbaseSmsSendResponse as bM, type PalbaseStorageClient as bN, type PalbaseTransformOptions as bO, type PalbaseUpdateLinkParams as bP, type PalbaseUploadOptions as bQ, type PalbaseUser as bR, type PalbaseUserDetailResult as bS, type PalbaseUsersQueryInput as bT, type PalbaseUsersResult as bU, type PalbaseVerifyRequestSignatureParams as bV, type PalbaseWhatsAppClient as bW, type PalbaseWhatsAppEvent as bX, type PalbaseWhatsAppSendParams as bY, type PalbaseWhatsAppSendResponse as bZ, type PalbaseWhatsAppTemplate as b_, type PalbaseIdentifyTraits as ba, type PalbaseInboxClient as bb, type PalbaseInboxListOptions as bc, type PalbaseInboxListResult as bd, type PalbaseInboxMessage as be, type PalbaseInboxSendParams as bf, type PalbaseInboxSendResponse as bg, type PalbaseInitialLink as bh, type PalbaseInvokeOptions as bi, type PalbaseLink as bj, type PalbaseLinkAnalytics as bk, type PalbaseLinkDetails as bl, type PalbaseLinksClient as bm, type PalbaseListLinksOptions as bn, type PalbaseListLinksResult as bo, type PalbaseListOptions as bp, type PalbaseMatchParams as bq, type PalbaseMultiChannelResponse as br, type PalbaseNotificationChannel as bs, type PalbaseNotificationsClient as bt, type PalbaseOverviewResult as bu, type PalbasePreferences as bv, type PalbasePreferencesClient as bw, type PalbasePushClient as bx, type PalbasePushSendParams as by, type PalbasePushSendResponse as bz, type DatabaseDiagnosticsOptions as c, __getRuntime as c$, type PolicyBinOp as c0, PolicyBuilder as c1, type PolicyCommand as c2, type PolicyDef as c3, type PolicyExprCtx as c4, PolicyExprRef as c5, type PolicyMode as c6, type PolicyOperand as c7, type QueryColumnContract as c8, type QueryDatabase as c9, type TxPlanOpResult as cA, type TxPlanRejection as cB, TxRefError as cC, type TxRow as cD, type TxRows as cE, type TxSelectOptions as cF, type TxSetShape as cG, type TxSetValue as cH, type TxTable as cI, type TxTables as cJ, type TxWhere as cK, type TxWireExpr as cL, type TxWireGuard as cM, type TxWireOp as cN, type TxWireRef as cO, type TxWireValue as cP, type TypedDB as cQ, type TypedTable as cR, type TypedTx as cS, Unauthorized as cT, UniqueViolation as cU, type UniqueWhere as cV, type User as cW, type VerifiedDevice as cX, type WhereFilter as cY, type WhereOp as cZ, type WorkloadOptions as c_, type QueryInput as ca, type RawConstraintDef as cb, Realtime as cc, type Ref as cd, type RequestStore as ce, type RowShape as cf, Secrets as cg, type SecretsService as ch, SerializationFailure as ci, type SetShape as cj, type SetValue as ck, type ShutdownRunner as cl, type SqlFragment as cm, Storage as cn, TABLE_META as co, type TableDef as cp, type TableHandle as cq, type TableInput as cr, TooManyRequests as cs, type TxColumnExpr as ct, type TxInsertShape as cu, type TxInsertValue as cv, type TxNow as cw, type TxPlan as cx, TxPlanError as cy, type TxPlanHandle as cz, type DatabaseDiagnostics as d, __resetLifecycleHooks as d0, __runStartHooks as d1, __setRuntime as d2, bigint as d3, boolean as d4, can as d5, col as d6, dec as d7, decrement as d8, defineMiddleware as d9, userRef as dA, uuid as dB, vector as dC, withRetry as dD, type ColValue as dE, defineSchema as da, defineTable as db, defineWorkload as dc, enumType as dd, exprCtx as de, inc as df, increment as dg, index as dh, installationRef as di, integer as dj, isPalbaseExtension as dk, isRetryable as dl, jsonb as dm, makeTypedDB as dn, now as dp, numeric as dq, onShutdown as dr, onStart as ds, openai as dt, ownedByUser as du, policy as dv, raw as dw, sqlFragment as dx, text as dy, timestamp as dz, type DBOps as e, type RawPageOptions as f, type Page as g, type TxPlanBody as h, type CommandOptions as i, type TxPlanResponse as j, type CacheClient as k, __requestALS as l, type PalbaseResult as m, type PolicyExpr as n, type AggregateInput as o, type AggregateResult as p, type AnyColumn as q, type AtomicDatabase as r, type AtomicOptions as s, Auth as t, type AuthConfig as u, Cache as v, type ClientInfo as w, type ColRef as x, ColumnBuilder as y, type ColumnDef as z };
5617
+ export { Flags as $, type AuthSpec as A, BadRequest as B, type CommandOptions as C, type DatabaseBudget as D, type EnvServiceDatabase as E, Conflict as F, Database as G, HttpError as H, type DatabaseQueryEvent as I, DeadlockDetected as J, Documents as K, EXTENSION_DEPENDENCIES as L, type EmbeddingModelRef as M, type EnvSchemas as N, type EnvTables as O, type Page as P, type EnvTypedDatabase as Q, type RateLimitConfig as R, type SchemaDef as S, type TransactionIsolation as T, type EnvTypedTable as U, type ErrorDef as V, type ErrorMap as W, type ErrorThrowers as X, type FileContext as Y, type FindManyOpts as Z, __runWithRuntime as _, type DBClient as a, type PalbaseFlagValue as a$, Forbidden as a0, type HttpMethod as a1, IndexBuilder as a2, type IndexDef as a3, type InsertManyOptions as a4, type InsertShape as a5, type InsertValues as a6, type LifecycleHook as a7, Log as a8, type Logger as a9, type PalbaseBatchSetOverridesResult as aA, type PalbaseBindDeviceParams as aB, type PalbaseBucketClient as aC, type PalbaseClearAllOverridesResult as aD, type PalbaseClearOverrideResult as aE, type PalbaseCohortQueryInput as aF, type PalbaseCohortResult as aG, type PalbaseCollectionRef as aH, type PalbaseCountQueryInput as aI, type PalbaseCountResult as aJ, type PalbaseCreateLinkParams as aK, type PalbaseDeviceInfo as aL, type PalbaseDeviceTokenView as aM, type PalbaseDocsClient as aN, type PalbaseDocumentRef as aO, type PalbaseDocumentSnapshot as aP, type PalbaseEmailClient as aQ, type PalbaseEmailSendParams as aR, type PalbaseEmailSendResponse as aS, type PalbaseEventNamesResult as aT, type PalbaseEventsQueryInput as aU, type PalbaseEventsResult as aV, type PalbaseExtension as aW, type PalbaseFileObject as aX, type PalbaseFlag as aY, type PalbaseFlagContext as aZ, type PalbaseFlagSource as a_, type Materialized as aa, type Middleware as ab, type MiddlewareContext as ac, type MiddlewareHandler as ad, type MutateInput as ae, NotFound as af, Notifications as ag, type OnDeleteAction as ah, type OrderBySpec as ai, PALBASE_EXTENSIONS as aj, type PBRequest as ak, type PageInfo as al, type PageInput as am, type PageNavigation as an, PalError as ao, type PalbaseAnalyticsClient as ap, type PalbaseAnalyticsManagementNamespace as aq, type PalbaseAnalyticsProperties as ar, type PalbaseAnalyticsQueryNamespace as as, type PalbaseAttestAndroidParams as at, type PalbaseAttestAndroidResult as au, type PalbaseAttestiOSParams as av, type PalbaseAttestiOSResult as aw, type PalbaseAuthAdminClient as ax, type PalbaseAuthClient as ay, type PalbaseBatchOverrideOperation as az, type RuntimeServices as b, type PolicyDef as b$, type PalbaseFlagVariant as b0, type PalbaseFlagsClient as b1, type PalbaseFlagsServiceClient as b2, type PalbaseFunctionsClient as b3, type PalbaseFunnelQueryInput as b4, type PalbaseFunnelResult as b5, type PalbaseIdentifyTraits as b6, type PalbaseInboxClient as b7, type PalbaseInboxListOptions as b8, type PalbaseInboxListResult as b9, type PalbaseRetentionQueryInput as bA, type PalbaseRetentionResult as bB, type PalbaseSession as bC, type PalbaseSetOverrideResult as bD, type PalbaseSetOverridesResult as bE, type PalbaseSignedUrlResponse as bF, type PalbaseSmsClient as bG, type PalbaseSmsSendParams as bH, type PalbaseSmsSendResponse as bI, type PalbaseStorageClient as bJ, type PalbaseTransformOptions as bK, type PalbaseUpdateLinkParams as bL, type PalbaseUploadOptions as bM, type PalbaseUser as bN, type PalbaseUserDetailResult as bO, type PalbaseUsersQueryInput as bP, type PalbaseUsersResult as bQ, type PalbaseVerifyRequestSignatureParams as bR, type PalbaseWhatsAppClient as bS, type PalbaseWhatsAppEvent as bT, type PalbaseWhatsAppSendParams as bU, type PalbaseWhatsAppSendResponse as bV, type PalbaseWhatsAppTemplate as bW, type PalbaseWhereOperator as bX, type PolicyBinOp as bY, PolicyBuilder as bZ, type PolicyCommand as b_, type PalbaseInboxMessage as ba, type PalbaseInboxSendParams as bb, type PalbaseInboxSendResponse as bc, type PalbaseInitialLink as bd, type PalbaseInvokeOptions as be, type PalbaseLink as bf, type PalbaseLinkAnalytics as bg, type PalbaseLinkDetails as bh, type PalbaseLinksClient as bi, type PalbaseListLinksOptions as bj, type PalbaseListLinksResult as bk, type PalbaseListOptions as bl, type PalbaseMatchParams as bm, type PalbaseMultiChannelResponse as bn, type PalbaseNotificationChannel as bo, type PalbaseNotificationsClient as bp, type PalbaseOverviewResult as bq, type PalbasePreferences as br, type PalbasePreferencesClient as bs, type PalbasePushClient as bt, type PalbasePushSendParams as bu, type PalbasePushSendResponse as bv, type PalbaseQrCodeOptions as bw, type PalbaseQuerySnapshot as bx, type PalbaseRealtimeClient as by, type PalbaseRegisterDeviceParams as bz, type DatabaseDiagnosticsOptions as c, col as c$, type PolicyExprCtx as c0, PolicyExprRef as c1, type PolicyMode as c2, type PolicyOperand as c3, type QueryInput as c4, type RawConstraintDef as c5, Realtime as c6, type Ref as c7, type RequestStore as c8, type RowShape as c9, type TxSetShape as cA, type TxSetValue as cB, type TxTable as cC, type TxTables as cD, type TxWhere as cE, type TxWireExpr as cF, type TxWireGuard as cG, type TxWireOp as cH, type TxWireRef as cI, type TxWireValue as cJ, type TypedDB as cK, type TypedTable as cL, type TypedTx as cM, Unauthorized as cN, UniqueViolation as cO, type UniqueWhere as cP, type User as cQ, type VerifiedDevice as cR, type WhereFilter as cS, type WhereOp as cT, __getRuntime as cU, __resetLifecycleHooks as cV, __runStartHooks as cW, __setRuntime as cX, bigint as cY, boolean as cZ, can as c_, Secrets as ca, type SecretsService as cb, SerializationFailure as cc, type SetShape as cd, type SetValue as ce, type ShutdownRunner as cf, type SqlFragment as cg, Storage as ch, TABLE_META as ci, type TableDef as cj, type TableHandle as ck, type TableInput as cl, TooManyRequests as cm, type TxColumnExpr as cn, type TxInsertShape as co, type TxInsertValue as cp, type TxNow as cq, type TxPlan as cr, TxPlanError as cs, type TxPlanHandle as ct, type TxPlanOpResult as cu, type TxPlanRejection as cv, TxRefError as cw, type TxRow as cx, type TxRows as cy, type TxSelectOptions as cz, type DatabaseDiagnostics as d, dec as d0, decrement as d1, defineMiddleware as d2, defineSchema as d3, defineTable as d4, enumType as d5, exprCtx as d6, inc as d7, increment as d8, index as d9, installationRef as da, integer as db, isPalbaseExtension as dc, isRetryable as dd, jsonb as de, makeTypedDB as df, now as dg, numeric as dh, onShutdown as di, onStart as dj, openai as dk, ownedByUser as dl, policy as dm, raw as dn, sqlFragment as dp, text as dq, timestamp as dr, userRef as ds, uuid as dt, vector as du, withRetry as dv, type DBOps as e, type RawPageOptions as f, type TxPlanBody as g, type TxPlanResponse as h, type CacheClient as i, __requestALS as j, type PalbaseResult as k, type PolicyExpr as l, type AggregateInput as m, type AggregateResult as n, type AnyColumn as o, type AtomicDatabase as p, type AtomicOptions as q, Auth as r, type AuthConfig as s, Cache as t, type ClientInfo as u, type ColRef as v, ColumnBuilder as w, type ColumnDef as x, type ColumnMap as y, type ColumnType as z };
@@ -1,6 +1,6 @@
1
1
  import { z, ZodSchema } from 'zod';
2
- import { PalbaseFlagKey, Buckets, BucketTypes, PalbaseSecretName } from './stack.cjs';
3
2
  import { Schemas, Tables, TableTypes } from './db/env.cjs';
3
+ import { PalbaseFlagKey, Buckets, BucketTypes, PalbaseSecretName } from './stack.cjs';
4
4
  import { AsyncLocalStorage } from 'node:async_hooks';
5
5
 
6
6
  interface CommandOptions {
@@ -84,6 +84,8 @@ interface DatabaseDiagnostics {
84
84
  queueMs: number;
85
85
  /** Time until the driver's transaction callback starts; includes wire BEGIN. */
86
86
  poolMs: number;
87
+ /** From the driver's BEGIN callback through acknowledged COMMIT/ROLLBACK. */
88
+ connectionMs?: number;
87
89
  setupMs: number;
88
90
  /** Driver wait including PostgreSQL execution/locks and network time. */
89
91
  sqlMs: number;
@@ -3162,31 +3164,6 @@ declare const Flags: PalbaseFlagsAmbient;
3162
3164
  */
3163
3165
  declare const Realtime: PalbaseRealtimeClient;
3164
3166
 
3165
- /** Limits apply per engine process. PostgreSQL locks remain the authority when
3166
- * several replicas write the same rows. Size the total budget across replicas. */
3167
- interface WorkloadOptions {
3168
- concurrency: number;
3169
- queueLimit: number;
3170
- tenantConcurrency?: number;
3171
- tenantQueueLimit?: number;
3172
- queueTimeoutMs?: number;
3173
- /** Read from authenticated claims; defaults to tenant_id, then sub, then one
3174
- * shared anonymous bucket. A request body never chooses the tenant budget. */
3175
- tenantClaim?: string;
3176
- }
3177
- interface DatabaseWorkload {
3178
- readonly name: string;
3179
- readonly concurrency: number;
3180
- readonly queueLimit: number;
3181
- readonly tenantConcurrency: number;
3182
- readonly tenantQueueLimit: number;
3183
- readonly queueTimeoutMs: number;
3184
- readonly tenantClaim: string;
3185
- }
3186
- /** Declare once at module scope and reuse on $atomic calls. Keys, queue limits
3187
- * and tenant budgets affect admission, not SQL permissions or isolation. */
3188
- declare function defineWorkload(name: string, options: WorkloadOptions): DatabaseWorkload;
3189
-
3190
3167
  /** A PostgreSQL isolation level supported by the explicit root transaction. */
3191
3168
  type TransactionIsolation = "read committed" | "repeatable read" | "serializable";
3192
3169
  interface AtomicOptions {
@@ -3203,53 +3180,6 @@ interface AtomicOptions {
3203
3180
  * cancelled; rollback settles before release. An in-flight COMMIT is awaited. */
3204
3181
  timeoutMs?: number;
3205
3182
  signal?: AbortSignal;
3206
- workload?: DatabaseWorkload;
3207
- /** Resource names shared within a workload. Include a tenant prefix if the
3208
- * resource ID itself is only unique inside a tenant. Requires workload. */
3209
- conflictKeys?: readonly string[];
3210
- }
3211
-
3212
- /** Storage metadata that affects the declared response; defaults and unrelated
3213
- * columns do not change an explicitly projected query's contract. */
3214
- interface QueryColumnContract {
3215
- type: string;
3216
- nullable: boolean;
3217
- codec?: string;
3218
- enumValues?: readonly string[];
3219
- dimensions?: number;
3220
- }
3221
- interface PreparedRead {
3222
- name: string;
3223
- table: string;
3224
- columns: Record<string, QueryColumnContract>;
3225
- where: Record<string, unknown>;
3226
- options: {
3227
- select: string[];
3228
- orderBy?: {
3229
- column: string;
3230
- direction?: "asc" | "desc";
3231
- nulls?: "first" | "last";
3232
- } | {
3233
- column: string;
3234
- direction?: "asc" | "desc";
3235
- nulls?: "first" | "last";
3236
- }[];
3237
- limit?: number;
3238
- };
3239
- }
3240
- interface CompiledRead {
3241
- sql: string;
3242
- params: unknown[];
3243
- }
3244
- interface QueryDatabase {
3245
- readQuery(query: PreparedRead): Promise<Record<string, unknown>[]>;
3246
- compileQuery(query: PreparedRead): CompiledRead;
3247
- explainQuery(query: PreparedRead): Promise<unknown[]>;
3248
- }
3249
- interface EnvQueryDatabase {
3250
- $readQuery: QueryDatabase["readQuery"];
3251
- $compileQuery: QueryDatabase["compileQuery"];
3252
- $explainQuery: QueryDatabase["explainQuery"];
3253
3183
  }
3254
3184
 
3255
3185
  /** Keys of C whose columns are required on INSERT (not nullable, no default). */
@@ -3364,7 +3294,7 @@ interface TypedTable<T extends TableDef> {
3364
3294
  }): Promise<number>;
3365
3295
  }
3366
3296
  /** A typed DB facade covering all tables declared in schema `S`. */
3367
- interface TypedDB<S extends SchemaDef> extends QueryDatabase {
3297
+ interface TypedDB<S extends SchemaDef> {
3368
3298
  diagnostics: DBOps["diagnostics"];
3369
3299
  command<T>(fn: (tx: TypedTx<S>) => T extends Promise<unknown> ? never : T, options?: CommandOptions): Promise<Materialized<T>>;
3370
3300
  tables: {
@@ -4344,10 +4274,7 @@ type EnvServiceDatabase = EnvSchemaSurface & {
4344
4274
  $delete: DBClient["delete"];
4345
4275
  $findById: DBClient["findById"];
4346
4276
  $findUnique: DBClient["findUnique"];
4347
- $readQuery: DBClient["readQuery"];
4348
4277
  $diagnostics: DBClient["diagnostics"];
4349
- $compileQuery: DBClient["compileQuery"];
4350
- $explainQuery: DBClient["explainQuery"];
4351
4278
  $findMany: DBClient["findMany"];
4352
4279
  $page: DBClient["page"];
4353
4280
  $put: DBClient["put"];
@@ -4418,10 +4345,7 @@ type EnvTypedDatabase = EnvSchemaSurface & {
4418
4345
  $delete: DBClient["delete"];
4419
4346
  $findById: DBClient["findById"];
4420
4347
  $findUnique: DBClient["findUnique"];
4421
- $readQuery: DBClient["readQuery"];
4422
4348
  $diagnostics: DBClient["diagnostics"];
4423
- $compileQuery: DBClient["compileQuery"];
4424
- $explainQuery: DBClient["explainQuery"];
4425
4349
  $findMany: DBClient["findMany"];
4426
4350
  $page: DBClient["page"];
4427
4351
  $put: DBClient["put"];
@@ -5115,7 +5039,7 @@ interface RateLimitConfig {
5115
5039
  }
5116
5040
  /** The six raw string-keyed DB operations shared by `DBClient` and the
5117
5041
  * transaction-scoped client. */
5118
- interface DBOps extends QueryDatabase {
5042
+ interface DBOps {
5119
5043
  /** Null when diagnostics/budgets are disabled. Binding values are never included. */
5120
5044
  diagnostics(): DatabaseDiagnostics | null;
5121
5045
  /** Match exactly one declared primary/unique key; null never denotes a unique value. */
@@ -5690,4 +5614,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
5690
5614
  */
5691
5615
  type AuthSpec = boolean | Partial<AuthConfig>;
5692
5616
 
5693
- export { type ErrorMap as $, type AuthSpec as A, BadRequest as B, type CompiledRead as C, type DatabaseBudget as D, type EnvServiceDatabase as E, type ColumnMap as F, type ColumnType as G, HttpError as H, Conflict as I, Database as J, type DatabaseQueryEvent as K, type DatabaseWorkload as L, DeadlockDetected as M, Documents as N, EXTENSION_DEPENDENCIES as O, type PreparedRead as P, type EmbeddingModelRef as Q, type RateLimitConfig as R, type SchemaDef as S, type TransactionIsolation as T, type EnvQueryDatabase as U, type EnvSchemas as V, type EnvTables as W, type EnvTypedDatabase as X, type EnvTypedTable as Y, type ErrorDef as Z, __runWithRuntime as _, type DBClient as a, type PalbaseFileObject as a$, type ErrorThrowers as a0, type FileContext as a1, type FindManyOpts as a2, Flags as a3, Forbidden as a4, type HttpMethod as a5, IndexBuilder as a6, type IndexDef as a7, type InsertManyOptions as a8, type InsertShape as a9, type PalbaseAttestiOSResult as aA, type PalbaseAuthAdminClient as aB, type PalbaseAuthClient as aC, type PalbaseBatchOverrideOperation as aD, type PalbaseBatchSetOverridesResult as aE, type PalbaseBindDeviceParams as aF, type PalbaseBucketClient as aG, type PalbaseClearAllOverridesResult as aH, type PalbaseClearOverrideResult as aI, type PalbaseCohortQueryInput as aJ, type PalbaseCohortResult as aK, type PalbaseCollectionRef as aL, type PalbaseCountQueryInput as aM, type PalbaseCountResult as aN, type PalbaseCreateLinkParams as aO, type PalbaseDeviceInfo as aP, type PalbaseDeviceTokenView as aQ, type PalbaseDocsClient as aR, type PalbaseDocumentRef as aS, type PalbaseDocumentSnapshot as aT, type PalbaseEmailClient as aU, type PalbaseEmailSendParams as aV, type PalbaseEmailSendResponse as aW, type PalbaseEventNamesResult as aX, type PalbaseEventsQueryInput as aY, type PalbaseEventsResult as aZ, type PalbaseExtension as a_, type InsertValues as aa, type LifecycleHook as ab, Log as ac, type Logger as ad, type Materialized as ae, type Middleware as af, type MiddlewareContext as ag, type MiddlewareHandler as ah, type MutateInput as ai, NotFound as aj, Notifications as ak, type OnDeleteAction as al, type OrderBySpec as am, PALBASE_EXTENSIONS as an, type PBRequest as ao, type PageInfo as ap, type PageInput as aq, type PageNavigation as ar, PalError as as, type PalbaseAnalyticsClient as at, type PalbaseAnalyticsManagementNamespace as au, type PalbaseAnalyticsProperties as av, type PalbaseAnalyticsQueryNamespace as aw, type PalbaseAttestAndroidParams as ax, type PalbaseAttestAndroidResult as ay, type PalbaseAttestiOSParams as az, type RuntimeServices as b, type PalbaseWhereOperator as b$, type PalbaseFlag as b0, type PalbaseFlagContext as b1, type PalbaseFlagSource as b2, type PalbaseFlagValue as b3, type PalbaseFlagVariant as b4, type PalbaseFlagsClient as b5, type PalbaseFlagsServiceClient as b6, type PalbaseFunctionsClient as b7, type PalbaseFunnelQueryInput as b8, type PalbaseFunnelResult as b9, type PalbaseQrCodeOptions as bA, type PalbaseQuerySnapshot as bB, type PalbaseRealtimeClient as bC, type PalbaseRegisterDeviceParams as bD, type PalbaseRetentionQueryInput as bE, type PalbaseRetentionResult as bF, type PalbaseSession as bG, type PalbaseSetOverrideResult as bH, type PalbaseSetOverridesResult as bI, type PalbaseSignedUrlResponse as bJ, type PalbaseSmsClient as bK, type PalbaseSmsSendParams as bL, type PalbaseSmsSendResponse as bM, type PalbaseStorageClient as bN, type PalbaseTransformOptions as bO, type PalbaseUpdateLinkParams as bP, type PalbaseUploadOptions as bQ, type PalbaseUser as bR, type PalbaseUserDetailResult as bS, type PalbaseUsersQueryInput as bT, type PalbaseUsersResult as bU, type PalbaseVerifyRequestSignatureParams as bV, type PalbaseWhatsAppClient as bW, type PalbaseWhatsAppEvent as bX, type PalbaseWhatsAppSendParams as bY, type PalbaseWhatsAppSendResponse as bZ, type PalbaseWhatsAppTemplate as b_, type PalbaseIdentifyTraits as ba, type PalbaseInboxClient as bb, type PalbaseInboxListOptions as bc, type PalbaseInboxListResult as bd, type PalbaseInboxMessage as be, type PalbaseInboxSendParams as bf, type PalbaseInboxSendResponse as bg, type PalbaseInitialLink as bh, type PalbaseInvokeOptions as bi, type PalbaseLink as bj, type PalbaseLinkAnalytics as bk, type PalbaseLinkDetails as bl, type PalbaseLinksClient as bm, type PalbaseListLinksOptions as bn, type PalbaseListLinksResult as bo, type PalbaseListOptions as bp, type PalbaseMatchParams as bq, type PalbaseMultiChannelResponse as br, type PalbaseNotificationChannel as bs, type PalbaseNotificationsClient as bt, type PalbaseOverviewResult as bu, type PalbasePreferences as bv, type PalbasePreferencesClient as bw, type PalbasePushClient as bx, type PalbasePushSendParams as by, type PalbasePushSendResponse as bz, type DatabaseDiagnosticsOptions as c, __getRuntime as c$, type PolicyBinOp as c0, PolicyBuilder as c1, type PolicyCommand as c2, type PolicyDef as c3, type PolicyExprCtx as c4, PolicyExprRef as c5, type PolicyMode as c6, type PolicyOperand as c7, type QueryColumnContract as c8, type QueryDatabase as c9, type TxPlanOpResult as cA, type TxPlanRejection as cB, TxRefError as cC, type TxRow as cD, type TxRows as cE, type TxSelectOptions as cF, type TxSetShape as cG, type TxSetValue as cH, type TxTable as cI, type TxTables as cJ, type TxWhere as cK, type TxWireExpr as cL, type TxWireGuard as cM, type TxWireOp as cN, type TxWireRef as cO, type TxWireValue as cP, type TypedDB as cQ, type TypedTable as cR, type TypedTx as cS, Unauthorized as cT, UniqueViolation as cU, type UniqueWhere as cV, type User as cW, type VerifiedDevice as cX, type WhereFilter as cY, type WhereOp as cZ, type WorkloadOptions as c_, type QueryInput as ca, type RawConstraintDef as cb, Realtime as cc, type Ref as cd, type RequestStore as ce, type RowShape as cf, Secrets as cg, type SecretsService as ch, SerializationFailure as ci, type SetShape as cj, type SetValue as ck, type ShutdownRunner as cl, type SqlFragment as cm, Storage as cn, TABLE_META as co, type TableDef as cp, type TableHandle as cq, type TableInput as cr, TooManyRequests as cs, type TxColumnExpr as ct, type TxInsertShape as cu, type TxInsertValue as cv, type TxNow as cw, type TxPlan as cx, TxPlanError as cy, type TxPlanHandle as cz, type DatabaseDiagnostics as d, __resetLifecycleHooks as d0, __runStartHooks as d1, __setRuntime as d2, bigint as d3, boolean as d4, can as d5, col as d6, dec as d7, decrement as d8, defineMiddleware as d9, userRef as dA, uuid as dB, vector as dC, withRetry as dD, type ColValue as dE, defineSchema as da, defineTable as db, defineWorkload as dc, enumType as dd, exprCtx as de, inc as df, increment as dg, index as dh, installationRef as di, integer as dj, isPalbaseExtension as dk, isRetryable as dl, jsonb as dm, makeTypedDB as dn, now as dp, numeric as dq, onShutdown as dr, onStart as ds, openai as dt, ownedByUser as du, policy as dv, raw as dw, sqlFragment as dx, text as dy, timestamp as dz, type DBOps as e, type RawPageOptions as f, type Page as g, type TxPlanBody as h, type CommandOptions as i, type TxPlanResponse as j, type CacheClient as k, __requestALS as l, type PalbaseResult as m, type PolicyExpr as n, type AggregateInput as o, type AggregateResult as p, type AnyColumn as q, type AtomicDatabase as r, type AtomicOptions as s, Auth as t, type AuthConfig as u, Cache as v, type ClientInfo as w, type ColRef as x, ColumnBuilder as y, type ColumnDef as z };
5617
+ export { Flags as $, type AuthSpec as A, BadRequest as B, type CommandOptions as C, type DatabaseBudget as D, type EnvServiceDatabase as E, Conflict as F, Database as G, HttpError as H, type DatabaseQueryEvent as I, DeadlockDetected as J, Documents as K, EXTENSION_DEPENDENCIES as L, type EmbeddingModelRef as M, type EnvSchemas as N, type EnvTables as O, type Page as P, type EnvTypedDatabase as Q, type RateLimitConfig as R, type SchemaDef as S, type TransactionIsolation as T, type EnvTypedTable as U, type ErrorDef as V, type ErrorMap as W, type ErrorThrowers as X, type FileContext as Y, type FindManyOpts as Z, __runWithRuntime as _, type DBClient as a, type PalbaseFlagValue as a$, Forbidden as a0, type HttpMethod as a1, IndexBuilder as a2, type IndexDef as a3, type InsertManyOptions as a4, type InsertShape as a5, type InsertValues as a6, type LifecycleHook as a7, Log as a8, type Logger as a9, type PalbaseBatchSetOverridesResult as aA, type PalbaseBindDeviceParams as aB, type PalbaseBucketClient as aC, type PalbaseClearAllOverridesResult as aD, type PalbaseClearOverrideResult as aE, type PalbaseCohortQueryInput as aF, type PalbaseCohortResult as aG, type PalbaseCollectionRef as aH, type PalbaseCountQueryInput as aI, type PalbaseCountResult as aJ, type PalbaseCreateLinkParams as aK, type PalbaseDeviceInfo as aL, type PalbaseDeviceTokenView as aM, type PalbaseDocsClient as aN, type PalbaseDocumentRef as aO, type PalbaseDocumentSnapshot as aP, type PalbaseEmailClient as aQ, type PalbaseEmailSendParams as aR, type PalbaseEmailSendResponse as aS, type PalbaseEventNamesResult as aT, type PalbaseEventsQueryInput as aU, type PalbaseEventsResult as aV, type PalbaseExtension as aW, type PalbaseFileObject as aX, type PalbaseFlag as aY, type PalbaseFlagContext as aZ, type PalbaseFlagSource as a_, type Materialized as aa, type Middleware as ab, type MiddlewareContext as ac, type MiddlewareHandler as ad, type MutateInput as ae, NotFound as af, Notifications as ag, type OnDeleteAction as ah, type OrderBySpec as ai, PALBASE_EXTENSIONS as aj, type PBRequest as ak, type PageInfo as al, type PageInput as am, type PageNavigation as an, PalError as ao, type PalbaseAnalyticsClient as ap, type PalbaseAnalyticsManagementNamespace as aq, type PalbaseAnalyticsProperties as ar, type PalbaseAnalyticsQueryNamespace as as, type PalbaseAttestAndroidParams as at, type PalbaseAttestAndroidResult as au, type PalbaseAttestiOSParams as av, type PalbaseAttestiOSResult as aw, type PalbaseAuthAdminClient as ax, type PalbaseAuthClient as ay, type PalbaseBatchOverrideOperation as az, type RuntimeServices as b, type PolicyDef as b$, type PalbaseFlagVariant as b0, type PalbaseFlagsClient as b1, type PalbaseFlagsServiceClient as b2, type PalbaseFunctionsClient as b3, type PalbaseFunnelQueryInput as b4, type PalbaseFunnelResult as b5, type PalbaseIdentifyTraits as b6, type PalbaseInboxClient as b7, type PalbaseInboxListOptions as b8, type PalbaseInboxListResult as b9, type PalbaseRetentionQueryInput as bA, type PalbaseRetentionResult as bB, type PalbaseSession as bC, type PalbaseSetOverrideResult as bD, type PalbaseSetOverridesResult as bE, type PalbaseSignedUrlResponse as bF, type PalbaseSmsClient as bG, type PalbaseSmsSendParams as bH, type PalbaseSmsSendResponse as bI, type PalbaseStorageClient as bJ, type PalbaseTransformOptions as bK, type PalbaseUpdateLinkParams as bL, type PalbaseUploadOptions as bM, type PalbaseUser as bN, type PalbaseUserDetailResult as bO, type PalbaseUsersQueryInput as bP, type PalbaseUsersResult as bQ, type PalbaseVerifyRequestSignatureParams as bR, type PalbaseWhatsAppClient as bS, type PalbaseWhatsAppEvent as bT, type PalbaseWhatsAppSendParams as bU, type PalbaseWhatsAppSendResponse as bV, type PalbaseWhatsAppTemplate as bW, type PalbaseWhereOperator as bX, type PolicyBinOp as bY, PolicyBuilder as bZ, type PolicyCommand as b_, type PalbaseInboxMessage as ba, type PalbaseInboxSendParams as bb, type PalbaseInboxSendResponse as bc, type PalbaseInitialLink as bd, type PalbaseInvokeOptions as be, type PalbaseLink as bf, type PalbaseLinkAnalytics as bg, type PalbaseLinkDetails as bh, type PalbaseLinksClient as bi, type PalbaseListLinksOptions as bj, type PalbaseListLinksResult as bk, type PalbaseListOptions as bl, type PalbaseMatchParams as bm, type PalbaseMultiChannelResponse as bn, type PalbaseNotificationChannel as bo, type PalbaseNotificationsClient as bp, type PalbaseOverviewResult as bq, type PalbasePreferences as br, type PalbasePreferencesClient as bs, type PalbasePushClient as bt, type PalbasePushSendParams as bu, type PalbasePushSendResponse as bv, type PalbaseQrCodeOptions as bw, type PalbaseQuerySnapshot as bx, type PalbaseRealtimeClient as by, type PalbaseRegisterDeviceParams as bz, type DatabaseDiagnosticsOptions as c, col as c$, type PolicyExprCtx as c0, PolicyExprRef as c1, type PolicyMode as c2, type PolicyOperand as c3, type QueryInput as c4, type RawConstraintDef as c5, Realtime as c6, type Ref as c7, type RequestStore as c8, type RowShape as c9, type TxSetShape as cA, type TxSetValue as cB, type TxTable as cC, type TxTables as cD, type TxWhere as cE, type TxWireExpr as cF, type TxWireGuard as cG, type TxWireOp as cH, type TxWireRef as cI, type TxWireValue as cJ, type TypedDB as cK, type TypedTable as cL, type TypedTx as cM, Unauthorized as cN, UniqueViolation as cO, type UniqueWhere as cP, type User as cQ, type VerifiedDevice as cR, type WhereFilter as cS, type WhereOp as cT, __getRuntime as cU, __resetLifecycleHooks as cV, __runStartHooks as cW, __setRuntime as cX, bigint as cY, boolean as cZ, can as c_, Secrets as ca, type SecretsService as cb, SerializationFailure as cc, type SetShape as cd, type SetValue as ce, type ShutdownRunner as cf, type SqlFragment as cg, Storage as ch, TABLE_META as ci, type TableDef as cj, type TableHandle as ck, type TableInput as cl, TooManyRequests as cm, type TxColumnExpr as cn, type TxInsertShape as co, type TxInsertValue as cp, type TxNow as cq, type TxPlan as cr, TxPlanError as cs, type TxPlanHandle as ct, type TxPlanOpResult as cu, type TxPlanRejection as cv, TxRefError as cw, type TxRow as cx, type TxRows as cy, type TxSelectOptions as cz, type DatabaseDiagnostics as d, dec as d0, decrement as d1, defineMiddleware as d2, defineSchema as d3, defineTable as d4, enumType as d5, exprCtx as d6, inc as d7, increment as d8, index as d9, installationRef as da, integer as db, isPalbaseExtension as dc, isRetryable as dd, jsonb as de, makeTypedDB as df, now as dg, numeric as dh, onShutdown as di, onStart as dj, openai as dk, ownedByUser as dl, policy as dm, raw as dn, sqlFragment as dp, text as dq, timestamp as dr, userRef as ds, uuid as dt, vector as du, withRetry as dv, type DBOps as e, type RawPageOptions as f, type TxPlanBody as g, type TxPlanResponse as h, type CacheClient as i, __requestALS as j, type PalbaseResult as k, type PolicyExpr as l, type AggregateInput as m, type AggregateResult as n, type AnyColumn as o, type AtomicDatabase as p, type AtomicOptions as q, Auth as r, type AuthConfig as s, Cache as t, type ClientInfo as u, type ColRef as v, ColumnBuilder as w, type ColumnDef as x, type ColumnMap as y, type ColumnType as z };