@palbase/backend 13.0.0 → 14.1.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.
@@ -97,7 +97,6 @@ var Database = Object.assign(makeTypedSurface(rawDatabase), {
97
97
  var Documents = makeServiceProxy("Documents");
98
98
  var Storage = makeServiceProxy("Storage");
99
99
  var Cache = makeServiceProxy("Cache");
100
- var Queue = makeServiceProxy("Queue");
101
100
  var Log = makeServiceProxy("Log");
102
101
  var Notifications = makeServiceProxy("Notifications");
103
102
  var Purchases = makeServiceProxy("Purchases");
@@ -140,11 +139,10 @@ export {
140
139
  Documents,
141
140
  Storage,
142
141
  Cache,
143
- Queue,
144
142
  Log,
145
143
  Notifications,
146
144
  Purchases,
147
145
  Flags,
148
146
  Realtime
149
147
  };
150
- //# sourceMappingURL=chunk-XATG7BRC.js.map
148
+ //# sourceMappingURL=chunk-I72YYSEI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["/**\n * runtime.ts — request-scoped service singletons.\n *\n * The backend SDK no longer threads a `ctx` god-object through every handler.\n * Instead, controller methods import PascalCase service singletons directly:\n *\n * import { Controller, Post, Body, Database } from \"@palbase/backend\";\n *\n * \\@Controller(\"/todos\")\n * export default class TodosController {\n * \\@Post(\"\") create(\\@Body(CreateTodoBody) body: CreateTodoBody): unknown {\n * return Database.insert(\"todos\", { title: body.title });\n * }\n * }\n *\n * The singletons are thin Proxies. Every property access forwards to the live\n * client for the CURRENT request scope, resolved through {@link __getRuntime}.\n *\n * # Request-scope resolution (persistent app-server)\n *\n * The runtime is a long-running Node process that serves many concurrent\n * requests on one event loop (NOT a fresh subprocess per request). A single\n * module-global slot would let one in-flight request's services bleed into\n * another's. So the services are carried in an {@link AsyncLocalStorage} store\n * ({@link __requestALS}) that the runtime sets per request with\n * {@link __runWithRuntime}; every async continuation of that request reads its\n * own store. `__getRuntime` reads the ALS store first; the module-global slot\n * (set by {@link __setRuntime}) is only a fallback for callers that run OUTSIDE\n * an ALS scope (dev-server, unit tests, the legacy single-shot path). Because\n * each `br-<ref>` pod is single-tenant, there is no cross-tenant leakage; the\n * ALS store is what prevents cross-REQUEST leakage within the shared process.\n *\n * The seam that makes `import { Database } from \"@palbase/backend\"` resolve to\n * the runtime-injected client: `@palbase/backend` is marked esbuild-EXTERNAL\n * when the tenant bundle is built, and the package is installed globally in the\n * pod (NODE_PATH=/usr/local/lib/node_modules). So worker.js's\n * `require('@palbase/backend')` and the bundle's `import` resolve to ONE shared\n * module instance — the ALS store and `__setRuntime` slot on that instance are\n * visible to the singletons the bundle imported.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport type {\n DBClient,\n DBOps,\n CacheClient,\n Logger,\n PalbaseDocsClient,\n} from \"./endpoint.js\";\nimport type {\n PalbaseStorageClient,\n PalbaseNotificationsClient,\n PalbaseFlagsClient,\n PalbaseFlagsServiceClient,\n PalbaseFlagContext,\n PalbaseFlagVariant,\n PalbaseFlag,\n PalbaseFlagValue,\n PalbaseSetOverrideResult,\n PalbaseRealtimeClient,\n} from \"./clients.js\";\nimport type { PalbaseResult } from \"./endpoint.js\";\nimport type {\n EnvTypedDatabase,\n EnvServiceDatabase,\n EnvTables,\n TxPlan,\n TxTables,\n} from \"./db/typed-db.js\";\nimport type { Materialized } from \"./db/tx-plan.js\";\nimport { TxPlanBuilder, runTxPlan } from \"./db/tx-plan.js\";\nimport type { PurchasesService } from \"./purchases/service.js\";\n\n/** The set of live clients the runtime injects per request scope.\n *\n * Realtime is BROADCAST-ONLY here (a stateless handler can push an event but\n * cannot hold a subscription socket — `subscribe()` lives on the client SDK).\n *\n * EXCLUDED on purpose: Functions, Links, Analytics, Auth. They are not\n * exposed as backend handler singletons (auth lives on the client SDK; the rest\n * are out of scope for backend endpoints). */\nexport interface RuntimeServices {\n Database: DBClient;\n Documents: PalbaseDocsClient;\n Storage: PalbaseStorageClient;\n Cache: CacheClient;\n Log: Logger;\n Notifications: PalbaseNotificationsClient;\n Flags: PalbaseFlagsClient;\n Realtime: PalbaseRealtimeClient;\n Purchases: PurchasesService;\n}\n\n/**\n * The per-request ALS box.\n *\n * `runtime` is the service bundle. `userId` is the request's authenticated user\n * id, written by the runtime immediately after it assembles the request object\n * (worker.js: `requestALS.getStore().userId = pbReq.user?.id || null`) and\n * `null` on an anonymous request. It was already being written there for the\n * Flags client's auto-bind; declaring it here makes the existing contract typed\n * instead of implicit, which is what lets `currentSubjectId()` read a\n * server-owned identity rather than trusting anything the caller sent.\n */\nexport interface RequestStore {\n runtime: RuntimeServices;\n userId?: string | null;\n /** This request's id (`req_…`), written by the runtime. Used as the spend\n * idempotency scope when the caller supplied no `Idempotency-Key`. */\n requestId?: string;\n /** The caller's `Idempotency-Key` header, or `null` when absent. What makes a\n * client's retry replay its first result instead of charging twice. */\n idempotencyKey?: string | null;\n}\n\n/**\n * Per-request store. The persistent runtime runs each request inside\n * {@link __runWithRuntime}, so every async continuation of that request reads\n * its OWN `runtime` (and any other request-scoped fields the runtime adds).\n *\n * Exported with a `__` prefix so the runtime (worker.js) shares the SAME ALS\n * instance across the one module instance — two ALS instances would silently\n * not see each other's stores. NOT part of the public author-facing API.\n */\nexport const __requestALS = new AsyncLocalStorage<RequestStore>();\n\n/** Process-global fallback slot. Used only OUTSIDE an ALS scope (dev-server,\n * unit tests, legacy single-shot worker). Inside the persistent server every\n * request runs in {@link __requestALS}, which takes precedence. */\nlet runtime: RuntimeServices | null = null;\n\n/** Install the live clients in the process-global fallback slot.\n *\n * Persistent-server requests should use {@link __runWithRuntime} instead; this\n * remains for dev-server / tests / the legacy single-shot path that run without\n * an ALS scope. NOT part of the public author-facing API. */\nexport function __setRuntime(services: RuntimeServices): void {\n runtime = services;\n}\n\n/** Run `fn` with `services` bound as the request-scoped runtime.\n *\n * The persistent worker calls this once per request so concurrent requests\n * never share a services slot. NOT part of the public author-facing API. */\nexport function __runWithRuntime<T>(services: RuntimeServices, fn: () => T): T {\n return __requestALS.run({ runtime: services }, fn);\n}\n\n/** Read the live clients, throwing if accessed outside a request scope.\n *\n * Resolves the ALS store first (persistent server, per-request), then the\n * process-global fallback (dev-server / tests). NOT part of the public\n * author-facing API — used by the runtime and the singleton Proxies. */\nexport function __getRuntime(): RuntimeServices {\n const scoped = __requestALS.getStore();\n if (scoped) return scoped.runtime;\n if (runtime === null) {\n throw new Error(\n \"Palbase services accessed outside a request scope. The Database/Documents/… \" +\n \"singletons are only available inside an endpoint handler (or after the \" +\n \"runtime has called __runWithRuntime / __setRuntime).\",\n );\n }\n return runtime;\n}\n\n/**\n * Build a Proxy singleton that forwards every property access to the live\n * client named `key` on the current runtime.\n *\n * The single `as RuntimeServices[K]` is the only contained cast in the surface:\n * `Reflect.get` on a typed object returns `unknown` for a `string | symbol`\n * key, but `prop` is constrained to keys of the client interface at the call\n * sites (the exported singletons are typed below), so the forward is sound.\n */\nfunction makeServiceProxy<K extends keyof RuntimeServices>(key: K): RuntimeServices[K] {\n const handler: ProxyHandler<RuntimeServices[K]> = {\n get(_target, prop, receiver) {\n const client = __getRuntime()[key];\n const value = Reflect.get(client as object, prop, receiver) as unknown;\n // Bind methods to their owning client so `this` stays correct when the\n // author destructures or calls `Database.query(...)`.\n return typeof value === \"function\" ? value.bind(client) : value;\n },\n };\n // The Proxy target is irrelevant (all access goes through `get`); the cast\n // names the surface type the singleton presents to authors.\n return new Proxy({} as RuntimeServices[K], handler);\n}\n\n/**\n * Build the `.tables` accessor for the top-level `Database`. Each\n * `tables.<name>` access returns a small object that forwards the five CRUD ops\n * to the underlying client using `name` as the string table identifier. The\n * shapes are typed against the generated `palbase-env.d.ts` (`EnvTables`); at\n * runtime they are plain string-keyed calls, so no schema value is needed here.\n *\n * Returns `EnvTables` — TS cannot infer the mapped type through the Proxy, so\n * a single structural narrowing names the surface (the proxy returns a\n * correctly-shaped accessor for whatever string member is read).\n */\nfunction makeTablesAccessor(ops: () => DBOps): EnvTables {\n const tablesProxy = new Proxy(\n {},\n {\n get(_t, prop: string | symbol) {\n if (typeof prop !== \"string\") return undefined;\n const name = prop;\n return {\n insert: (data: Record<string, unknown>) => ops().insert(name, data),\n update: (id: string, data: Record<string, unknown>) => ops().update(name, id, data),\n delete: (id: string) => ops().delete(name, id),\n findById: (id: string) => ops().findById(name, id),\n findMany: (query?: Record<string, unknown>) => ops().findMany(name, query),\n };\n },\n },\n );\n return tablesProxy as EnvTables;\n}\n\n/** The raw string-keyed `DBClient` for the current request scope. */\nconst rawDatabase: DBClient = makeServiceProxy(\"Database\");\n\n/**\n * Wrap a raw `DBClient` into the typed `{ ...ops, tables, transaction }`\n * surface. The five string ops forward straight through; `tables` is the\n * env-typed accessor; `transaction` yields typed tables. Reused for both the\n * default (RLS-enforced) `Database` and the `asService()` sibling — each is\n * fed its own raw client (the default proxy vs `rawDatabase.asService()`).\n *\n * The `satisfies` pins the op surface so a missing/renamed op is a compile\n * error; the assembled object carries `tables`/`transaction` alongside.\n */\nfunction makeTypedSurface(raw: Omit<DBClient, \"asService\">): EnvServiceDatabase {\n const ops = {\n query: (sql: string, params?: unknown[]) => raw.query(sql, params),\n insert: (table: string, data: Record<string, unknown>) => raw.insert(table, data),\n update: (table: string, id: string, data: Record<string, unknown>) =>\n raw.update(table, id, data),\n delete: (table: string, id: string) => raw.delete(table, id),\n findById: (table: string, id: string) => raw.findById(table, id),\n findMany: (table: string, query?: Record<string, unknown>) => raw.findMany(table, query),\n } satisfies DBOps;\n return Object.assign(ops, {\n tables: makeTablesAccessor(() => raw),\n transaction<T>(\n fn: (tx: TxPlan) => T extends Promise<unknown> ? never : T,\n ): Promise<Materialized<T>> {\n // A FRESH builder per call: it holds this transaction's ops and its error\n // slot table, and the runtime serves concurrent requests on one event loop.\n // A shared builder would splice one request's writes into another's plan.\n const builder = new TxPlanBuilder();\n return runTxPlan(raw, makeTxTablesAccessor(builder), builder, fn) as Promise<\n Materialized<T>\n >;\n },\n });\n}\n\n/**\n * The transaction twin of {@link makeTablesAccessor}: `tables.<name>` yields the\n * table's PLAN operations, recorded into `builder` instead of sent one by one.\n *\n * Same Proxy shape and same reason for the single narrowing — TS cannot infer a\n * mapped type through a Proxy, so the cast names what the trap returns.\n */\nfunction makeTxTablesAccessor(builder: TxPlanBuilder): TxTables {\n const tablesProxy = new Proxy(\n {},\n {\n get(_t, prop: string | symbol) {\n if (typeof prop !== \"string\") return undefined;\n return builder.table(prop);\n },\n },\n );\n return tablesProxy as TxTables;\n}\n\n/**\n * The project's own Postgres (pgx, schema `env_<envId>`).\n *\n * Typed by default: `Database.tables.<name>.insert({...})` is typed against\n * the project's generated `palbase-env.d.ts` with NO import and NO generic.\n * The raw string ops (`query`/`insert`/`update`/`delete`/`findById`/`findMany`)\n * are also available for dynamic table names and read-only SQL.\n *\n * RLS is enforced by default (the runtime runs each op as `authenticated` with\n * the verified user's claims). To bypass RLS, call `Database.asService()` —\n * explicit and greppable — which runs as the `service_role` (BYPASSRLS).\n *\n * @example\n * import { Database } from \"@palbase/backend\";\n *\n * const todo = await Database.tables.todos.insert({ title: req.input.title });\n * todo.id; // string ✓\n * const rows = await Database.query(\"SELECT id FROM todos WHERE done = $1\", [false]);\n * const all = await Database.asService().tables.todos.findMany({}); // RLS bypass\n */\nexport const Database: EnvTypedDatabase = Object.assign(makeTypedSurface(rawDatabase), {\n /**\n * Lazily resolve the runtime's service-role sibling on each call. We do NOT\n * cache it: `rawDatabase.asService()` reads the CURRENT request scope through\n * the runtime proxy, and the per-request runtime injects a service client\n * bound to that request's identity headers — caching would leak one request's\n * sibling into another concurrent request.\n */\n asService(): EnvServiceDatabase {\n return makeTypedSurface(rawDatabase.asService());\n },\n});\n\n/** Firestore-like document client (PalDocs). */\nexport const Documents: PalbaseDocsClient = makeServiceProxy(\"Documents\");\n\n/** Object storage client (buckets, signed URLs). */\nexport const Storage: PalbaseStorageClient = makeServiceProxy(\"Storage\");\n\n/** JSON-typed cache (get/set/incr/getOrSet). */\nexport const Cache: CacheClient = makeServiceProxy(\"Cache\");\n\n\n/** Structured logger. */\nexport const Log: Logger = makeServiceProxy(\"Log\");\n\n/** Push / email / SMS / in-app notifications. */\nexport const Notifications: PalbaseNotificationsClient = makeServiceProxy(\"Notifications\");\n\n/**\n * Palstore purchases (entitlements + quota/credit spend).\n *\n * Reached by handlers through the `@RequireEntitlement` / `@Spend` decorators\n * rather than called directly in the common case; exposed as a singleton for\n * the cases the decorators deliberately do not cover (a dynamic spend count,\n * which must run BEFORE the billable side-effect).\n */\nexport const Purchases: PurchasesService = makeServiceProxy(\"Purchases\");\n\n/**\n * The raw runtime Flags client for the current request scope. Carries the\n * default-surface reads + `setOverride` AND the runtime's `asService()` sibling\n * (the br-pod's `buildFlagsClient` returns both). The default `Flags` singleton\n * below forwards reads + `setOverride` through here; `Flags.asService()`\n * forwards to this client's own `asService()`.\n */\nconst rawFlags: PalbaseFlagsClient = makeServiceProxy(\"Flags\");\n\n/**\n * Feature flags.\n *\n * Mirrors the `Database` / `Database.asService()` model. The default surface is\n * RLS-equivalent for flags: reads resolve against the CURRENT request user and\n * `Flags.setOverride(key, value)` writes an override for that same signed-in\n * user (no userId argument, no admin power). Cross-user admin writes\n * (`setOverrideForUser`, …) live behind `Flags.asService()` — explicit and\n * greppable, just like `Database.asService()`.\n *\n * @example\n * import { Flags } from \"@palbase/backend\";\n *\n * if (await Flags.isEnabled(\"new_checkout\")) { ... } // current user\n * await Flags.setOverride(\"new_checkout\", true); // current user\n * await Flags.asService().setOverrideForUser(\"u_9\", \"x\", true); // cross-user\n */\nexport const Flags: PalbaseFlagsClient = Object.assign(\n {\n isEnabled(\n flagName: string,\n context?: PalbaseFlagContext,\n ): Promise<PalbaseResult<boolean>> {\n return rawFlags.isEnabled(flagName, context);\n },\n getVariant(\n flagName: string,\n context?: PalbaseFlagContext,\n ): Promise<PalbaseResult<PalbaseFlagVariant>> {\n return rawFlags.getVariant(flagName, context);\n },\n getAll(context?: PalbaseFlagContext): Promise<PalbaseResult<PalbaseFlag[]>> {\n return rawFlags.getAll(context);\n },\n setOverride(\n key: string,\n value: PalbaseFlagValue,\n ): Promise<PalbaseResult<PalbaseSetOverrideResult>> {\n return rawFlags.setOverride(key, value);\n },\n },\n {\n /**\n * Lazily resolve the runtime's cross-user sibling on each call. We do NOT\n * cache it: `rawFlags.asService()` reads the CURRENT request scope through\n * the runtime proxy, so caching would leak one request's sibling into\n * another concurrent request. Mirrors `Database.asService()`.\n */\n asService(): PalbaseFlagsServiceClient {\n return rawFlags.asService();\n },\n },\n);\n\n/**\n * The Realtime broadcast singleton for the current request scope. Backend-side\n * Realtime is BROADCAST-ONLY (a stateless handler can push but not subscribe —\n * `subscribe()` lives on the client SDK's `pb.realtime`). Fire-and-forget:\n * `broadcast` resolves once accepted (or with an `error`), never blocking the\n * handler on subscribers.\n *\n * @example\n * import { Realtime } from \"@palbase/backend\";\n *\n * await Realtime.broadcast(\"room:42\", \"message\", { text, from: user.id });\n */\nexport const Realtime: PalbaseRealtimeClient = makeServiceProxy(\"Realtime\");\n"],"mappings":"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","names":[]}
@@ -1,4 +1,4 @@
1
- export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, S as SchemaDef, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, F as policy, G as raw, H as text, J as timestamp, K as uuid } from '../index-BJAf1uPC.cjs';
2
- export { M as Materialized, b2 as Ref, b4 as TxColumnExpr, b5 as TxInsertShape, b7 as TxNow, b8 as TxPlanBody, b9 as TxPlanError, ba as TxPlanHandle, bb as TxPlanOpResult, bc as TxPlanRejection, bd as TxPlanResponse, be as TxRefError, bf as TxRow, bg as TxRows, bh as TxSelectOptions, bi as TxSetShape, bk as TxTable, bl as TxWhere, bt as dec, bv as inc, bw as now } from '../endpoint-Ck4hER_7.cjs';
1
+ export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, S as SchemaDef, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, F as policy, G as raw, H as text, J as timestamp, K as uuid } from '../index-BcA7wqur.cjs';
2
+ export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, b7 as TxPlanBody, b8 as TxPlanError, b9 as TxPlanHandle, ba as TxPlanOpResult, bb as TxPlanRejection, bc as TxPlanResponse, bd as TxRefError, be as TxRow, bf as TxRows, bg as TxSelectOptions, bh as TxSetShape, bj as TxTable, bk as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-D2yR2RD1.cjs';
3
3
  import './env.cjs';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, S as SchemaDef, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, F as policy, G as raw, H as text, J as timestamp, K as uuid } from '../index-l7DhBDtn.js';
2
- export { M as Materialized, b2 as Ref, b4 as TxColumnExpr, b5 as TxInsertShape, b7 as TxNow, b8 as TxPlanBody, b9 as TxPlanError, ba as TxPlanHandle, bb as TxPlanOpResult, bc as TxPlanRejection, bd as TxPlanResponse, be as TxRefError, bf as TxRow, bg as TxRows, bh as TxSelectOptions, bi as TxSetShape, bk as TxTable, bl as TxWhere, bt as dec, bv as inc, bw as now } from '../endpoint-Ck4hER_7.js';
1
+ export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, E as EnvTypedDatabase, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, S as SchemaDef, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, F as policy, G as raw, H as text, J as timestamp, K as uuid } from '../index-CB8TARW4.js';
2
+ export { M as Materialized, b1 as Ref, b3 as TxColumnExpr, b4 as TxInsertShape, b6 as TxNow, b7 as TxPlanBody, b8 as TxPlanError, b9 as TxPlanHandle, ba as TxPlanOpResult, bb as TxPlanRejection, bc as TxPlanResponse, bd as TxRefError, be as TxRow, bf as TxRows, bg as TxSelectOptions, bh as TxSetShape, bj as TxTable, bk as TxWhere, bs as dec, bu as inc, bv as now } from '../endpoint-D2yR2RD1.js';
3
3
  import './env.js';
4
4
  import 'zod';
@@ -22,6 +22,19 @@ interface User {
22
22
  id: string;
23
23
  /** User's email, if they signed up with one (absent for phone-only users). */
24
24
  email?: string;
25
+ /**
26
+ * Whether that email address has been confirmed.
27
+ *
28
+ * Server-resolved from the verified user profile, not read from the JWT: a
29
+ * token claim is only true as of when the token was minted, so a user who
30
+ * verifies mid-session would keep reporting `false` until it expired.
31
+ *
32
+ * `false` for a phone-only user (no address to confirm) and for any user who
33
+ * has not clicked through yet. Before this field existed, answering "is this
34
+ * address confirmed" in a handler cost an extra network round-trip PER
35
+ * REQUEST for one boolean the runtime already had.
36
+ */
37
+ emailVerified: boolean;
25
38
  role: string;
26
39
  metadata: Record<string, unknown>;
27
40
  /**
@@ -35,8 +48,16 @@ interface User {
35
48
  interface AuthConfig {
36
49
  /** Whether authentication is required. Defaults to true. */
37
50
  required: boolean;
38
- /** Required role for access. If undefined, any authenticated user is allowed. */
51
+ /** Required role for access. If undefined, any authenticated user is allowed.
52
+ *
53
+ * Matched against the caller's `metadata.role` — NOT `user.role`, which is the
54
+ * database role RLS reads and is always "authenticated" for a signed-in user.
55
+ * Not signed in → 401; signed in with a different or missing role → 403. */
39
56
  role?: string;
57
+ /** Require a confirmed email address. An unverified caller gets 403
58
+ * `email_not_verified`. Fences a whole controller; for a partial rule read
59
+ * `user.emailVerified` in the handler instead. */
60
+ verifiedEmail?: boolean;
40
61
  }
41
62
 
42
63
  /** Middleware context — subset of EndpointContext without input (not yet validated). */
@@ -1693,13 +1714,6 @@ interface FileContext {
1693
1714
  size: number;
1694
1715
  data: Uint8Array;
1695
1716
  }
1696
- /** Queue client for dispatching background jobs from within a handler. */
1697
- interface QueueClient {
1698
- /** Enqueue a job for the named worker. Returns the new job ID. */
1699
- push(worker: string, payload: unknown): Promise<{
1700
- jobId: string;
1701
- }>;
1702
- }
1703
1717
  /** Rate limit configuration for an endpoint. */
1704
1718
  interface RateLimitConfig {
1705
1719
  /** Maximum number of requests in the window. */
@@ -1984,4 +1998,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
1984
1998
  */
1985
1999
  type AuthSpec = boolean | Partial<AuthConfig>;
1986
2000
 
1987
- export { type PalbaseDeviceInfo as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type ErrorDef as E, type FileContext as F, type PalbaseAuthClient as G, HttpError as H, type PalbaseBatchOverrideOperation as I, type PalbaseBatchSetOverridesResult as J, type PalbaseBindDeviceParams as K, type Logger as L, type Materialized as M, NotFound as N, type PalbaseBucketClient as O, type PBRequest as P, type QueueClient as Q, type RateLimitConfig as R, type PalbaseClearAllOverridesResult as S, type PalbaseClearOverrideResult as T, type User as U, type PalbaseCohortQueryInput as V, type PalbaseCohortResult as W, type PalbaseCollectionRef as X, type PalbaseCountQueryInput as Y, type PalbaseCountResult as Z, type PalbaseCreateLinkParams as _, type PalbaseModuleClients as a, type PalbaseUsersResult as a$, type PalbaseDeviceTokenView as a0, type PalbaseDocumentRef as a1, type PalbaseDocumentSnapshot as a2, type PalbaseEmailClient as a3, type PalbaseEmailSendParams as a4, type PalbaseEmailSendResponse as a5, type PalbaseEventNamesResult as a6, type PalbaseEventsQueryInput as a7, type PalbaseEventsResult as a8, type PalbaseFileObject as a9, type PalbaseMultiChannelResponse as aA, type PalbaseOverviewResult as aB, type PalbasePreferences as aC, type PalbasePreferencesClient as aD, type PalbasePublicUrlResponse as aE, type PalbasePushClient as aF, type PalbasePushSendParams as aG, type PalbasePushSendResponse as aH, type PalbaseQrCodeOptions as aI, type PalbaseQuerySnapshot as aJ, type PalbaseRegisterDeviceParams as aK, type PalbaseResult as aL, type PalbaseRetentionQueryInput as aM, type PalbaseRetentionResult as aN, type PalbaseSession as aO, type PalbaseSetOverrideResult as aP, type PalbaseSetOverridesResult as aQ, type PalbaseSignedUrlResponse as aR, type PalbaseSmsClient as aS, type PalbaseSmsSendParams as aT, type PalbaseSmsSendResponse as aU, type PalbaseTransformOptions as aV, type PalbaseUpdateLinkParams as aW, type PalbaseUploadOptions as aX, type PalbaseUser as aY, type PalbaseUserDetailResult as aZ, type PalbaseUsersQueryInput as a_, type PalbaseFlag as aa, type PalbaseFlagContext as ab, type PalbaseFlagSource as ac, type PalbaseFlagValue as ad, type PalbaseFlagVariant as ae, type PalbaseFlagsServiceClient as af, type PalbaseFunctionsClient as ag, type PalbaseFunnelQueryInput as ah, type PalbaseFunnelResult as ai, type PalbaseIdentifyTraits as aj, type PalbaseInboxClient as ak, type PalbaseInboxListOptions as al, type PalbaseInboxListResult as am, type PalbaseInboxMessage as an, type PalbaseInboxSendParams as ao, type PalbaseInboxSendResponse as ap, type PalbaseInitialLink as aq, type PalbaseInvokeOptions as ar, type PalbaseLink as as, type PalbaseLinkAnalytics as at, type PalbaseLinkDetails as au, type PalbaseLinksClient as av, type PalbaseListLinksOptions as aw, type PalbaseListLinksResult as ax, type PalbaseListOptions as ay, type PalbaseMatchParams as az, type PalbaseDocsClient as b, type PalbaseVerifyRequestSignatureParams as b0, type PalbaseWhereOperator as b1, type Ref as b2, TooManyRequests as b3, type TxColumnExpr as b4, type TxInsertShape as b5, type TxInsertValue as b6, type TxNow as b7, type TxPlanBody as b8, TxPlanError as b9, type TxPlanHandle as ba, type TxPlanOpResult as bb, type TxPlanRejection as bc, type TxPlanResponse as bd, TxRefError as be, type TxRow as bf, type TxRows as bg, type TxSelectOptions as bh, type TxSetShape as bi, type TxSetValue as bj, type TxTable as bk, type TxWhere as bl, type TxWireExpr as bm, type TxWireGuard as bn, type TxWireOp as bo, type TxWireRef as bp, type TxWireValue as bq, Unauthorized as br, type VerifiedDevice as bs, dec as bt, defineMiddleware as bu, inc as bv, now as bw, type PalbaseFlagsClient as c, type PalbaseNotificationsClient as d, type PalbaseRealtimeClient as e, type PalbaseStorageClient as f, type AuthConfig as g, type ClientInfo as h, Conflict as i, type DBOps as j, type ErrorMap as k, type ErrorThrowers as l, Forbidden as m, type HttpMethod as n, type Middleware as o, type MiddlewareContext as p, type MiddlewareHandler as q, PalError as r, type PalbaseAnalyticsClient as s, type PalbaseAnalyticsManagementNamespace as t, type PalbaseAnalyticsProperties as u, type PalbaseAnalyticsQueryNamespace as v, type PalbaseAttestAndroidParams as w, type PalbaseAttestAndroidResult as x, type PalbaseAttestiOSParams as y, type PalbaseAttestiOSResult as z };
2001
+ export { type PalbaseDeviceTokenView as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type ErrorDef as E, type FileContext as F, type PalbaseAuthClient as G, HttpError as H, type PalbaseBatchOverrideOperation as I, type PalbaseBatchSetOverridesResult as J, type PalbaseBindDeviceParams as K, type Logger as L, type Materialized as M, NotFound as N, type PalbaseBucketClient as O, type PBRequest as P, type PalbaseClearAllOverridesResult as Q, type RateLimitConfig as R, type PalbaseClearOverrideResult as S, type PalbaseCohortQueryInput as T, type User as U, type PalbaseCohortResult as V, type PalbaseCollectionRef as W, type PalbaseCountQueryInput as X, type PalbaseCountResult as Y, type PalbaseCreateLinkParams as Z, type PalbaseDeviceInfo as _, type PalbaseModuleClients as a, type PalbaseVerifyRequestSignatureParams as a$, type PalbaseDocumentRef as a0, type PalbaseDocumentSnapshot as a1, type PalbaseEmailClient as a2, type PalbaseEmailSendParams as a3, type PalbaseEmailSendResponse as a4, type PalbaseEventNamesResult as a5, type PalbaseEventsQueryInput as a6, type PalbaseEventsResult as a7, type PalbaseFileObject as a8, type PalbaseFlag as a9, type PalbaseOverviewResult as aA, type PalbasePreferences as aB, type PalbasePreferencesClient as aC, type PalbasePublicUrlResponse as aD, type PalbasePushClient as aE, type PalbasePushSendParams as aF, type PalbasePushSendResponse as aG, type PalbaseQrCodeOptions as aH, type PalbaseQuerySnapshot as aI, type PalbaseRegisterDeviceParams as aJ, type PalbaseResult as aK, type PalbaseRetentionQueryInput as aL, type PalbaseRetentionResult as aM, type PalbaseSession as aN, type PalbaseSetOverrideResult as aO, type PalbaseSetOverridesResult as aP, type PalbaseSignedUrlResponse as aQ, type PalbaseSmsClient as aR, type PalbaseSmsSendParams as aS, type PalbaseSmsSendResponse as aT, type PalbaseTransformOptions as aU, type PalbaseUpdateLinkParams as aV, type PalbaseUploadOptions as aW, type PalbaseUser as aX, type PalbaseUserDetailResult as aY, type PalbaseUsersQueryInput as aZ, type PalbaseUsersResult as a_, type PalbaseFlagContext as aa, type PalbaseFlagSource as ab, type PalbaseFlagValue as ac, type PalbaseFlagVariant as ad, type PalbaseFlagsServiceClient as ae, type PalbaseFunctionsClient as af, type PalbaseFunnelQueryInput as ag, type PalbaseFunnelResult as ah, type PalbaseIdentifyTraits as ai, type PalbaseInboxClient as aj, type PalbaseInboxListOptions as ak, type PalbaseInboxListResult as al, type PalbaseInboxMessage as am, type PalbaseInboxSendParams as an, type PalbaseInboxSendResponse as ao, type PalbaseInitialLink as ap, type PalbaseInvokeOptions as aq, type PalbaseLink as ar, type PalbaseLinkAnalytics as as, type PalbaseLinkDetails as at, type PalbaseLinksClient as au, type PalbaseListLinksOptions as av, type PalbaseListLinksResult as aw, type PalbaseListOptions as ax, type PalbaseMatchParams as ay, type PalbaseMultiChannelResponse as az, type PalbaseDocsClient as b, type PalbaseWhereOperator as b0, type Ref as b1, TooManyRequests as b2, type TxColumnExpr as b3, type TxInsertShape as b4, type TxInsertValue as b5, type TxNow as b6, type TxPlanBody as b7, TxPlanError as b8, type TxPlanHandle as b9, type TxPlanOpResult as ba, type TxPlanRejection as bb, type TxPlanResponse as bc, TxRefError as bd, type TxRow as be, type TxRows as bf, type TxSelectOptions as bg, type TxSetShape as bh, type TxSetValue as bi, type TxTable as bj, type TxWhere as bk, type TxWireExpr as bl, type TxWireGuard as bm, type TxWireOp as bn, type TxWireRef as bo, type TxWireValue as bp, Unauthorized as bq, type VerifiedDevice as br, dec as bs, defineMiddleware as bt, inc as bu, now as bv, type PalbaseFlagsClient as c, type PalbaseNotificationsClient as d, type PalbaseRealtimeClient as e, type PalbaseStorageClient as f, type AuthConfig as g, type ClientInfo as h, Conflict as i, type DBOps as j, type ErrorMap as k, type ErrorThrowers as l, Forbidden as m, type HttpMethod as n, type Middleware as o, type MiddlewareContext as p, type MiddlewareHandler as q, PalError as r, type PalbaseAnalyticsClient as s, type PalbaseAnalyticsManagementNamespace as t, type PalbaseAnalyticsProperties as u, type PalbaseAnalyticsQueryNamespace as v, type PalbaseAttestAndroidParams as w, type PalbaseAttestAndroidResult as x, type PalbaseAttestiOSParams as y, type PalbaseAttestiOSResult as z };
@@ -22,6 +22,19 @@ interface User {
22
22
  id: string;
23
23
  /** User's email, if they signed up with one (absent for phone-only users). */
24
24
  email?: string;
25
+ /**
26
+ * Whether that email address has been confirmed.
27
+ *
28
+ * Server-resolved from the verified user profile, not read from the JWT: a
29
+ * token claim is only true as of when the token was minted, so a user who
30
+ * verifies mid-session would keep reporting `false` until it expired.
31
+ *
32
+ * `false` for a phone-only user (no address to confirm) and for any user who
33
+ * has not clicked through yet. Before this field existed, answering "is this
34
+ * address confirmed" in a handler cost an extra network round-trip PER
35
+ * REQUEST for one boolean the runtime already had.
36
+ */
37
+ emailVerified: boolean;
25
38
  role: string;
26
39
  metadata: Record<string, unknown>;
27
40
  /**
@@ -35,8 +48,16 @@ interface User {
35
48
  interface AuthConfig {
36
49
  /** Whether authentication is required. Defaults to true. */
37
50
  required: boolean;
38
- /** Required role for access. If undefined, any authenticated user is allowed. */
51
+ /** Required role for access. If undefined, any authenticated user is allowed.
52
+ *
53
+ * Matched against the caller's `metadata.role` — NOT `user.role`, which is the
54
+ * database role RLS reads and is always "authenticated" for a signed-in user.
55
+ * Not signed in → 401; signed in with a different or missing role → 403. */
39
56
  role?: string;
57
+ /** Require a confirmed email address. An unverified caller gets 403
58
+ * `email_not_verified`. Fences a whole controller; for a partial rule read
59
+ * `user.emailVerified` in the handler instead. */
60
+ verifiedEmail?: boolean;
40
61
  }
41
62
 
42
63
  /** Middleware context — subset of EndpointContext without input (not yet validated). */
@@ -1693,13 +1714,6 @@ interface FileContext {
1693
1714
  size: number;
1694
1715
  data: Uint8Array;
1695
1716
  }
1696
- /** Queue client for dispatching background jobs from within a handler. */
1697
- interface QueueClient {
1698
- /** Enqueue a job for the named worker. Returns the new job ID. */
1699
- push(worker: string, payload: unknown): Promise<{
1700
- jobId: string;
1701
- }>;
1702
- }
1703
1717
  /** Rate limit configuration for an endpoint. */
1704
1718
  interface RateLimitConfig {
1705
1719
  /** Maximum number of requests in the window. */
@@ -1984,4 +1998,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
1984
1998
  */
1985
1999
  type AuthSpec = boolean | Partial<AuthConfig>;
1986
2000
 
1987
- export { type PalbaseDeviceInfo as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type ErrorDef as E, type FileContext as F, type PalbaseAuthClient as G, HttpError as H, type PalbaseBatchOverrideOperation as I, type PalbaseBatchSetOverridesResult as J, type PalbaseBindDeviceParams as K, type Logger as L, type Materialized as M, NotFound as N, type PalbaseBucketClient as O, type PBRequest as P, type QueueClient as Q, type RateLimitConfig as R, type PalbaseClearAllOverridesResult as S, type PalbaseClearOverrideResult as T, type User as U, type PalbaseCohortQueryInput as V, type PalbaseCohortResult as W, type PalbaseCollectionRef as X, type PalbaseCountQueryInput as Y, type PalbaseCountResult as Z, type PalbaseCreateLinkParams as _, type PalbaseModuleClients as a, type PalbaseUsersResult as a$, type PalbaseDeviceTokenView as a0, type PalbaseDocumentRef as a1, type PalbaseDocumentSnapshot as a2, type PalbaseEmailClient as a3, type PalbaseEmailSendParams as a4, type PalbaseEmailSendResponse as a5, type PalbaseEventNamesResult as a6, type PalbaseEventsQueryInput as a7, type PalbaseEventsResult as a8, type PalbaseFileObject as a9, type PalbaseMultiChannelResponse as aA, type PalbaseOverviewResult as aB, type PalbasePreferences as aC, type PalbasePreferencesClient as aD, type PalbasePublicUrlResponse as aE, type PalbasePushClient as aF, type PalbasePushSendParams as aG, type PalbasePushSendResponse as aH, type PalbaseQrCodeOptions as aI, type PalbaseQuerySnapshot as aJ, type PalbaseRegisterDeviceParams as aK, type PalbaseResult as aL, type PalbaseRetentionQueryInput as aM, type PalbaseRetentionResult as aN, type PalbaseSession as aO, type PalbaseSetOverrideResult as aP, type PalbaseSetOverridesResult as aQ, type PalbaseSignedUrlResponse as aR, type PalbaseSmsClient as aS, type PalbaseSmsSendParams as aT, type PalbaseSmsSendResponse as aU, type PalbaseTransformOptions as aV, type PalbaseUpdateLinkParams as aW, type PalbaseUploadOptions as aX, type PalbaseUser as aY, type PalbaseUserDetailResult as aZ, type PalbaseUsersQueryInput as a_, type PalbaseFlag as aa, type PalbaseFlagContext as ab, type PalbaseFlagSource as ac, type PalbaseFlagValue as ad, type PalbaseFlagVariant as ae, type PalbaseFlagsServiceClient as af, type PalbaseFunctionsClient as ag, type PalbaseFunnelQueryInput as ah, type PalbaseFunnelResult as ai, type PalbaseIdentifyTraits as aj, type PalbaseInboxClient as ak, type PalbaseInboxListOptions as al, type PalbaseInboxListResult as am, type PalbaseInboxMessage as an, type PalbaseInboxSendParams as ao, type PalbaseInboxSendResponse as ap, type PalbaseInitialLink as aq, type PalbaseInvokeOptions as ar, type PalbaseLink as as, type PalbaseLinkAnalytics as at, type PalbaseLinkDetails as au, type PalbaseLinksClient as av, type PalbaseListLinksOptions as aw, type PalbaseListLinksResult as ax, type PalbaseListOptions as ay, type PalbaseMatchParams as az, type PalbaseDocsClient as b, type PalbaseVerifyRequestSignatureParams as b0, type PalbaseWhereOperator as b1, type Ref as b2, TooManyRequests as b3, type TxColumnExpr as b4, type TxInsertShape as b5, type TxInsertValue as b6, type TxNow as b7, type TxPlanBody as b8, TxPlanError as b9, type TxPlanHandle as ba, type TxPlanOpResult as bb, type TxPlanRejection as bc, type TxPlanResponse as bd, TxRefError as be, type TxRow as bf, type TxRows as bg, type TxSelectOptions as bh, type TxSetShape as bi, type TxSetValue as bj, type TxTable as bk, type TxWhere as bl, type TxWireExpr as bm, type TxWireGuard as bn, type TxWireOp as bo, type TxWireRef as bp, type TxWireValue as bq, Unauthorized as br, type VerifiedDevice as bs, dec as bt, defineMiddleware as bu, inc as bv, now as bw, type PalbaseFlagsClient as c, type PalbaseNotificationsClient as d, type PalbaseRealtimeClient as e, type PalbaseStorageClient as f, type AuthConfig as g, type ClientInfo as h, Conflict as i, type DBOps as j, type ErrorMap as k, type ErrorThrowers as l, Forbidden as m, type HttpMethod as n, type Middleware as o, type MiddlewareContext as p, type MiddlewareHandler as q, PalError as r, type PalbaseAnalyticsClient as s, type PalbaseAnalyticsManagementNamespace as t, type PalbaseAnalyticsProperties as u, type PalbaseAnalyticsQueryNamespace as v, type PalbaseAttestAndroidParams as w, type PalbaseAttestAndroidResult as x, type PalbaseAttestiOSParams as y, type PalbaseAttestiOSResult as z };
2001
+ export { type PalbaseDeviceTokenView as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type ErrorDef as E, type FileContext as F, type PalbaseAuthClient as G, HttpError as H, type PalbaseBatchOverrideOperation as I, type PalbaseBatchSetOverridesResult as J, type PalbaseBindDeviceParams as K, type Logger as L, type Materialized as M, NotFound as N, type PalbaseBucketClient as O, type PBRequest as P, type PalbaseClearAllOverridesResult as Q, type RateLimitConfig as R, type PalbaseClearOverrideResult as S, type PalbaseCohortQueryInput as T, type User as U, type PalbaseCohortResult as V, type PalbaseCollectionRef as W, type PalbaseCountQueryInput as X, type PalbaseCountResult as Y, type PalbaseCreateLinkParams as Z, type PalbaseDeviceInfo as _, type PalbaseModuleClients as a, type PalbaseVerifyRequestSignatureParams as a$, type PalbaseDocumentRef as a0, type PalbaseDocumentSnapshot as a1, type PalbaseEmailClient as a2, type PalbaseEmailSendParams as a3, type PalbaseEmailSendResponse as a4, type PalbaseEventNamesResult as a5, type PalbaseEventsQueryInput as a6, type PalbaseEventsResult as a7, type PalbaseFileObject as a8, type PalbaseFlag as a9, type PalbaseOverviewResult as aA, type PalbasePreferences as aB, type PalbasePreferencesClient as aC, type PalbasePublicUrlResponse as aD, type PalbasePushClient as aE, type PalbasePushSendParams as aF, type PalbasePushSendResponse as aG, type PalbaseQrCodeOptions as aH, type PalbaseQuerySnapshot as aI, type PalbaseRegisterDeviceParams as aJ, type PalbaseResult as aK, type PalbaseRetentionQueryInput as aL, type PalbaseRetentionResult as aM, type PalbaseSession as aN, type PalbaseSetOverrideResult as aO, type PalbaseSetOverridesResult as aP, type PalbaseSignedUrlResponse as aQ, type PalbaseSmsClient as aR, type PalbaseSmsSendParams as aS, type PalbaseSmsSendResponse as aT, type PalbaseTransformOptions as aU, type PalbaseUpdateLinkParams as aV, type PalbaseUploadOptions as aW, type PalbaseUser as aX, type PalbaseUserDetailResult as aY, type PalbaseUsersQueryInput as aZ, type PalbaseUsersResult as a_, type PalbaseFlagContext as aa, type PalbaseFlagSource as ab, type PalbaseFlagValue as ac, type PalbaseFlagVariant as ad, type PalbaseFlagsServiceClient as ae, type PalbaseFunctionsClient as af, type PalbaseFunnelQueryInput as ag, type PalbaseFunnelResult as ah, type PalbaseIdentifyTraits as ai, type PalbaseInboxClient as aj, type PalbaseInboxListOptions as ak, type PalbaseInboxListResult as al, type PalbaseInboxMessage as am, type PalbaseInboxSendParams as an, type PalbaseInboxSendResponse as ao, type PalbaseInitialLink as ap, type PalbaseInvokeOptions as aq, type PalbaseLink as ar, type PalbaseLinkAnalytics as as, type PalbaseLinkDetails as at, type PalbaseLinksClient as au, type PalbaseListLinksOptions as av, type PalbaseListLinksResult as aw, type PalbaseListOptions as ax, type PalbaseMatchParams as ay, type PalbaseMultiChannelResponse as az, type PalbaseDocsClient as b, type PalbaseWhereOperator as b0, type Ref as b1, TooManyRequests as b2, type TxColumnExpr as b3, type TxInsertShape as b4, type TxInsertValue as b5, type TxNow as b6, type TxPlanBody as b7, TxPlanError as b8, type TxPlanHandle as b9, type TxPlanOpResult as ba, type TxPlanRejection as bb, type TxPlanResponse as bc, TxRefError as bd, type TxRow as be, type TxRows as bf, type TxSelectOptions as bg, type TxSetShape as bh, type TxSetValue as bi, type TxTable as bj, type TxWhere as bk, type TxWireExpr as bl, type TxWireGuard as bm, type TxWireOp as bn, type TxWireRef as bo, type TxWireValue as bp, Unauthorized as bq, type VerifiedDevice as br, dec as bs, defineMiddleware as bt, inc as bu, now as bv, type PalbaseFlagsClient as c, type PalbaseNotificationsClient as d, type PalbaseRealtimeClient as e, type PalbaseStorageClient as f, type AuthConfig as g, type ClientInfo as h, Conflict as i, type DBOps as j, type ErrorMap as k, type ErrorThrowers as l, Forbidden as m, type HttpMethod as n, type Middleware as o, type MiddlewareContext as p, type MiddlewareHandler as q, PalError as r, type PalbaseAnalyticsClient as s, type PalbaseAnalyticsManagementNamespace as t, type PalbaseAnalyticsProperties as u, type PalbaseAnalyticsQueryNamespace as v, type PalbaseAttestAndroidParams as w, type PalbaseAttestAndroidResult as x, type PalbaseAttestiOSParams as y, type PalbaseAttestiOSResult as z };
@@ -1,5 +1,5 @@
1
1
  import { Tables, TableTypes } from './db/env.cjs';
2
- import { D as DBClient, ba as TxPlanHandle, bk as TxTable, M as Materialized } from './endpoint-Ck4hER_7.cjs';
2
+ import { D as DBClient, b9 as TxPlanHandle, bj as TxTable, M as Materialized } from './endpoint-D2yR2RD1.cjs';
3
3
 
4
4
  /** On delete action for foreign key references. */
5
5
  type OnDeleteAction = 'cascade' | 'set null' | 'restrict' | 'no action';
@@ -1,5 +1,5 @@
1
1
  import { Tables, TableTypes } from './db/env.js';
2
- import { D as DBClient, ba as TxPlanHandle, bk as TxTable, M as Materialized } from './endpoint-Ck4hER_7.js';
2
+ import { D as DBClient, b9 as TxPlanHandle, bj as TxTable, M as Materialized } from './endpoint-D2yR2RD1.js';
3
3
 
4
4
  /** On delete action for foreign key references. */
5
5
  type OnDeleteAction = 'cascade' | 'set null' | 'restrict' | 'no action';
package/dist/index.cjs CHANGED
@@ -30,6 +30,9 @@ __export(src_exports, {
30
30
  Delete: () => Delete,
31
31
  Documents: () => Documents,
32
32
  EGRESS_CONFIG_KIND: () => EGRESS_CONFIG_KIND,
33
+ EGRESS_TIMEOUT_DEFAULT_MS: () => EGRESS_TIMEOUT_DEFAULT_MS,
34
+ EGRESS_TIMEOUT_MAX_MS: () => EGRESS_TIMEOUT_MAX_MS,
35
+ EGRESS_TIMEOUT_MIN_MS: () => EGRESS_TIMEOUT_MIN_MS,
33
36
  EXTENSION_DEPENDENCIES: () => EXTENSION_DEPENDENCIES,
34
37
  FLAGS_CONFIG_KIND: () => FLAGS_CONFIG_KIND,
35
38
  Flags: () => Flags,
@@ -55,7 +58,6 @@ __export(src_exports, {
55
58
  Put: () => Put,
56
59
  Query: () => Query,
57
60
  QueryParams: () => QueryParams,
58
- Queue: () => Queue,
59
61
  RESERVED_SECRET_PREFIX: () => RESERVED_SECRET_PREFIX,
60
62
  Realtime: () => Realtime,
61
63
  Req: () => Req,
@@ -96,7 +98,6 @@ __export(src_exports, {
96
98
  defineSchema: () => defineSchema,
97
99
  defineStorage: () => defineStorage,
98
100
  defineTestUsers: () => defineTestUsers,
99
- defineWorker: () => defineWorker,
100
101
  documents: () => documents,
101
102
  entitlementFor: () => entitlementFor,
102
103
  enumType: () => enumType,
@@ -634,7 +635,6 @@ var Database = Object.assign(makeTypedSurface(rawDatabase), {
634
635
  var Documents = makeServiceProxy("Documents");
635
636
  var Storage = makeServiceProxy("Storage");
636
637
  var Cache = makeServiceProxy("Cache");
637
- var Queue = makeServiceProxy("Queue");
638
638
  var Log = makeServiceProxy("Log");
639
639
  var Notifications = makeServiceProxy("Notifications");
640
640
  var Purchases = makeServiceProxy("Purchases");
@@ -1447,6 +1447,9 @@ function defineStorage(input) {
1447
1447
 
1448
1448
  // src/config/egress.ts
1449
1449
  var EGRESS_CONFIG_KIND = "egress";
1450
+ var EGRESS_TIMEOUT_MIN_MS = 1e3;
1451
+ var EGRESS_TIMEOUT_MAX_MS = 3e5;
1452
+ var EGRESS_TIMEOUT_DEFAULT_MS = 3e4;
1450
1453
  function defineEgress(input) {
1451
1454
  if (input === null || typeof input !== "object" || !Array.isArray(input.hosts)) {
1452
1455
  throw new Error("defineEgress expects { hosts: string[] }");
@@ -1458,7 +1461,19 @@ function defineEgress(input) {
1458
1461
  }
1459
1462
  hosts.push(h.trim().toLowerCase());
1460
1463
  }
1461
- return { __config: EGRESS_CONFIG_KIND, hosts };
1464
+ if (input.timeoutMs === void 0) {
1465
+ return { __config: EGRESS_CONFIG_KIND, hosts };
1466
+ }
1467
+ const timeoutMs = input.timeoutMs;
1468
+ if (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs)) {
1469
+ throw new Error("defineEgress: timeoutMs must be an integer number of milliseconds");
1470
+ }
1471
+ if (timeoutMs < EGRESS_TIMEOUT_MIN_MS || timeoutMs > EGRESS_TIMEOUT_MAX_MS) {
1472
+ throw new Error(
1473
+ `defineEgress: timeoutMs must be between ${EGRESS_TIMEOUT_MIN_MS} and ${EGRESS_TIMEOUT_MAX_MS} (got ${timeoutMs})`
1474
+ );
1475
+ }
1476
+ return { __config: EGRESS_CONFIG_KIND, hosts, timeoutMs };
1462
1477
  }
1463
1478
 
1464
1479
  // src/config/notifications.ts
@@ -2147,40 +2162,6 @@ function humanize(code) {
2147
2162
  return s.charAt(0).toUpperCase() + s.slice(1);
2148
2163
  }
2149
2164
 
2150
- // src/worker.ts
2151
- var VALID_WORKER_NAME = /^[a-zA-Z0-9_-]+$/;
2152
- var WORKER_DEFAULTS = {
2153
- retry: 3,
2154
- timeout: 30,
2155
- backoff: "exponential"
2156
- };
2157
- function defineWorker(config) {
2158
- if (!config.name || config.name.trim() === "") {
2159
- throw new Error("Worker name is required");
2160
- }
2161
- if (!VALID_WORKER_NAME.test(config.name)) {
2162
- throw new Error(
2163
- `Invalid worker name "${config.name}": must match [a-zA-Z0-9_-]+`
2164
- );
2165
- }
2166
- if (config.retry !== void 0 && (config.retry < 0 || !Number.isInteger(config.retry))) {
2167
- throw new Error("Worker retry must be a non-negative integer");
2168
- }
2169
- if (config.timeout !== void 0 && config.timeout <= 0) {
2170
- throw new Error("Worker timeout must be a positive number");
2171
- }
2172
- if (config.backoff !== void 0 && !["exponential", "linear", "fixed"].includes(config.backoff)) {
2173
- throw new Error(`Invalid backoff strategy: ${config.backoff}`);
2174
- }
2175
- return {
2176
- name: config.name,
2177
- retry: config.retry ?? WORKER_DEFAULTS.retry,
2178
- timeout: config.timeout ?? WORKER_DEFAULTS.timeout,
2179
- backoff: config.backoff ?? WORKER_DEFAULTS.backoff,
2180
- handler: config.handler
2181
- };
2182
- }
2183
-
2184
2165
  // src/decorators/webhook.ts
2185
2166
  var WEBHOOK_META = /* @__PURE__ */ Symbol.for("palbase.backend.webhookMeta");
2186
2167
  var WEBHOOK_EVENTS = /* @__PURE__ */ Symbol.for("palbase.backend.webhookEvents");
@@ -2491,6 +2472,9 @@ var import_zod2 = require("zod");
2491
2472
  Delete,
2492
2473
  Documents,
2493
2474
  EGRESS_CONFIG_KIND,
2475
+ EGRESS_TIMEOUT_DEFAULT_MS,
2476
+ EGRESS_TIMEOUT_MAX_MS,
2477
+ EGRESS_TIMEOUT_MIN_MS,
2494
2478
  EXTENSION_DEPENDENCIES,
2495
2479
  FLAGS_CONFIG_KIND,
2496
2480
  Flags,
@@ -2516,7 +2500,6 @@ var import_zod2 = require("zod");
2516
2500
  Put,
2517
2501
  Query,
2518
2502
  QueryParams,
2519
- Queue,
2520
2503
  RESERVED_SECRET_PREFIX,
2521
2504
  Realtime,
2522
2505
  Req,
@@ -2557,7 +2540,6 @@ var import_zod2 = require("zod");
2557
2540
  defineSchema,
2558
2541
  defineStorage,
2559
2542
  defineTestUsers,
2560
- defineWorker,
2561
2543
  documents,
2562
2544
  entitlementFor,
2563
2545
  enumType,