@palbase/backend 16.0.0 → 17.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.
@@ -1,3 +1,4 @@
1
+ import { Tables, TableTypes } from './db/env.cjs';
1
2
  import { ZodSchema, z } from 'zod';
2
3
 
3
4
  /** Supported HTTP methods for endpoints. */
@@ -2001,4 +2002,656 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
2001
2002
  */
2002
2003
  type AuthSpec = boolean | Partial<AuthConfig>;
2003
2004
 
2004
- 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 PalbaseWhereOperator 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 PalbasePushClient as aD, type PalbasePushSendParams as aE, type PalbasePushSendResponse as aF, type PalbaseQrCodeOptions as aG, type PalbaseQuerySnapshot as aH, type PalbaseRegisterDeviceParams as aI, type PalbaseResult as aJ, type PalbaseRetentionQueryInput as aK, type PalbaseRetentionResult as aL, type PalbaseSession as aM, type PalbaseSetOverrideResult as aN, type PalbaseSetOverridesResult as aO, type PalbaseSignedUrlResponse as aP, type PalbaseSmsClient as aQ, type PalbaseSmsSendParams as aR, type PalbaseSmsSendResponse as aS, type PalbaseTransformOptions as aT, type PalbaseUpdateLinkParams as aU, type PalbaseUploadOptions as aV, type PalbaseUser as aW, type PalbaseUserDetailResult as aX, type PalbaseUsersQueryInput as aY, type PalbaseUsersResult as aZ, type PalbaseVerifyRequestSignatureParams 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 Ref as b0, TooManyRequests as b1, type TxColumnExpr as b2, type TxInsertShape as b3, type TxInsertValue as b4, type TxNow as b5, type TxPlanBody as b6, TxPlanError as b7, type TxPlanHandle as b8, type TxPlanOpResult as b9, type TxPlanRejection as ba, type TxPlanResponse as bb, TxRefError as bc, type TxRow as bd, type TxRows as be, type TxSelectOptions as bf, type TxSetShape as bg, type TxSetValue as bh, type TxTable as bi, type TxWhere as bj, type TxWireExpr as bk, type TxWireGuard as bl, type TxWireOp as bm, type TxWireRef as bn, type TxWireValue as bo, Unauthorized as bp, type VerifiedDevice as bq, dec as br, defineMiddleware as bs, inc as bt, now as bu, 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 };
2005
+ /** On delete action for foreign key references. */
2006
+ type OnDeleteAction = 'cascade' | 'set null' | 'restrict' | 'no action';
2007
+ /**
2008
+ * The ON DELETE actions permitted on a foreign key to the built-in auth users
2009
+ * (`auth.users`). Both let a user's rows be removed (`cascade`) or detached
2010
+ * (`set null`) when the account is erased; `restrict` / `no action` would BLOCK
2011
+ * erasure and are therefore excluded. This is the CLIENT-SIDE mirror of the
2012
+ * server's auth-FK deletion policy — the server (validateAuthUserFK) is the real
2013
+ * boundary, this narrows the type so the common mistake is caught at compile time.
2014
+ */
2015
+ type AuthUserOnDelete = Extract<OnDeleteAction, 'cascade' | 'set null'>;
2016
+ /** Column type identifiers. */
2017
+ type ColumnType = 'uuid' | 'text' | 'integer' | 'bigint' | 'numeric' | 'boolean' | 'timestamp' | 'jsonb' | 'enum';
2018
+ /** Base column definition shared by all column types. */
2019
+ interface ColumnDef {
2020
+ type: ColumnType;
2021
+ nullable: boolean;
2022
+ primaryKey: boolean;
2023
+ defaultValue?: unknown;
2024
+ defaultRandom?: boolean;
2025
+ defaultNow?: boolean;
2026
+ references?: {
2027
+ table: string;
2028
+ column: string;
2029
+ };
2030
+ onDeleteAction?: OnDeleteAction;
2031
+ enumName?: string;
2032
+ enumValues?: string[];
2033
+ unique?: boolean;
2034
+ }
2035
+ declare const __colKind: unique symbol;
2036
+ declare const __colNullable: unique symbol;
2037
+ declare const __colHasDefault: unique symbol;
2038
+ declare const __colEnumValues: unique symbol;
2039
+ declare const __colPayload: unique symbol;
2040
+ /**
2041
+ * Fluent column builder with phantom type params:
2042
+ * K — ColumnType literal (e.g. "text", "integer")
2043
+ * N — boolean: true when nullable() has been called last (false = NOT NULL)
2044
+ * D — boolean: true when a default has been set
2045
+ * E — enum value union (never for non-enum columns)
2046
+ * P — jsonb payload shape (unknown unless jsonb<T>() supplied one)
2047
+ *
2048
+ * All five params have defaults so bare `ColumnBuilder` (no args) still
2049
+ * satisfies `Record<string, ColumnBuilder>` in schema.ts without modification.
2050
+ *
2051
+ * The five `declare readonly` brand fields carry the phantom types into the
2052
+ * structural shape so that conditional types like ColValue<C> can discriminate
2053
+ * on K without requiring runtime values on those fields.
2054
+ */
2055
+ declare class ColumnBuilder<K extends ColumnType = ColumnType, N extends boolean = boolean, D extends boolean = boolean, E = unknown, P = unknown> {
2056
+ readonly [__colKind]: K;
2057
+ readonly [__colNullable]: N;
2058
+ readonly [__colHasDefault]: D;
2059
+ readonly [__colEnumValues]: E;
2060
+ readonly [__colPayload]: P;
2061
+ readonly _def: ColumnDef;
2062
+ constructor(type: K, existingDef?: ColumnDef);
2063
+ /** Mark this column as the primary key. */
2064
+ primaryKey(): ColumnBuilder<K, N, D, E, P>;
2065
+ /** Mark this column as NOT NULL (default). */
2066
+ notNull(): ColumnBuilder<K, false, D, E, P>;
2067
+ /** Allow NULL values. */
2068
+ nullable(): ColumnBuilder<K, true, D, E, P>;
2069
+ /** Set a default value. */
2070
+ default(value: unknown): ColumnBuilder<K, N, true, E, P>;
2071
+ /** UUID: generate a random default (gen_random_uuid()). */
2072
+ defaultRandom(): ColumnBuilder<K, N, true, E, P>;
2073
+ /** Timestamp: default to now(). */
2074
+ defaultNow(): ColumnBuilder<K, N, true, E, P>;
2075
+ /** Add a foreign key reference. */
2076
+ references(table: string, column: string): ColumnBuilder<K, N, D, E, P>;
2077
+ /**
2078
+ * Add a real DB-level foreign key to the built-in auth users
2079
+ * (`REFERENCES auth.users(id)`), so a column like `user_id` gets true
2080
+ * database cascade/integrity instead of app-layer-only. Sugar for
2081
+ * `.references("auth.users", "id")`.
2082
+ *
2083
+ * `auth.users` lives in the SAME tenant database (palauth-owned), so this is
2084
+ * a genuine cross-schema integrity constraint scoped to THIS tenant's users.
2085
+ * The referenced `auth.users.id` is `text` (palauth ids are `usr_<uuid>`), so
2086
+ * the referencing column must be `text()` too.
2087
+ *
2088
+ * ON DELETE is REQUIRED here and may only be `cascade` or `set null`: an
2089
+ * account-erasure request must never be blocked by a lingering FK, so
2090
+ * `restrict` / `no action` are not accepted (they don't type-check). Example:
2091
+ * `text().notNull().referencesAuthUser("cascade")`, or
2092
+ * `text().nullable().referencesAuthUser("set null")`. The server
2093
+ * (validateAuthUserFK) enforces this — and the remaining rules the type can't
2094
+ * express (referencing column is text, `set null` needs a nullable column) —
2095
+ * as the real boundary; this signature is the compile-time DX mirror.
2096
+ */
2097
+ referencesAuthUser(onDelete: AuthUserOnDelete): ColumnBuilder<K, N, D, E, P>;
2098
+ /**
2099
+ * Add a real DB-level foreign key to the canonical, server-minted installation
2100
+ * anchor (`REFERENCES auth.installations(id)`) — the app-scoped verified-device
2101
+ * root (`ins_...`). Sugar for `.references("auth.installations", "id")`.
2102
+ *
2103
+ * An installation is an APP INSTALL, not a user: this FK is NOT user ownership.
2104
+ * A user-owned row STILL needs its own `.referencesAuthUser(...)` FK so account
2105
+ * erasure removes it — an installation reference alone does not tie a row to a
2106
+ * user's deletion. Use this only for install-scoped state (device prefs, push
2107
+ * routing, …), alongside a separate auth-user FK where the row is user-owned.
2108
+ *
2109
+ * `auth.installations` lives in the SAME tenant DB (palauth-owned); its `id` is
2110
+ * `text` (`ins_<uuid>`), so the referencing column must be `text()` too. ON
2111
+ * DELETE is REQUIRED and may only be `cascade` or `set null` (same allowed set
2112
+ * as an auth-user FK): an installation revoke / orphan cleanup must never be
2113
+ * blocked by a lingering FK. The server (validateAuthAnchorFK) is the real
2114
+ * boundary; this signature is the compile-time DX mirror.
2115
+ */
2116
+ referencesInstallation(onDelete: AuthUserOnDelete): ColumnBuilder<K, N, D, E, P>;
2117
+ /** Set the ON DELETE action for a foreign key reference. */
2118
+ onDelete(action: OnDeleteAction): ColumnBuilder<K, N, D, E, P>;
2119
+ /** Add a single-column UNIQUE constraint. */
2120
+ unique(): ColumnBuilder<K, N, D, E, P>;
2121
+ }
2122
+ /**
2123
+ * Extracts the TypeScript value type for a column, respecting nullability.
2124
+ * - "uuid" | "text" | "timestamp" | "bigint" | "numeric" → string (or string | null when N = true)
2125
+ * Note: bigint/numeric surface as string — JS number loses precision past 2^53,
2126
+ * and pgx/PostgREST serialize int8/numeric as strings. App code uses
2127
+ * BigInt(row.amount) for bigint, or a decimal lib for numeric.
2128
+ * - "integer" → number
2129
+ * - "boolean" → boolean
2130
+ * - "jsonb" → P (the dev-supplied payload shape from jsonb<T>(), else unknown)
2131
+ * - "enum" → E (the union of literal values)
2132
+ */
2133
+ type ColValue<C> = C extends ColumnBuilder<'uuid' | 'text' | 'timestamp' | 'bigint' | 'numeric', infer N, infer _D, infer _E, infer _P> ? N extends true ? string | null : string : C extends ColumnBuilder<'integer', infer N, infer _D, infer _E, infer _P> ? N extends true ? number | null : number : C extends ColumnBuilder<'boolean', infer N, infer _D, infer _E, infer _P> ? N extends true ? boolean | null : boolean : C extends ColumnBuilder<'jsonb', infer N, infer _D, infer _E, infer P> ? N extends true ? P | null : P : C extends ColumnBuilder<'enum', infer N, infer _D, infer E, infer _P> ? N extends true ? E | null : E : never;
2134
+ /**
2135
+ * True when a column is optional on INSERT:
2136
+ * - nullable columns (N = true) — the DB allows NULL so the field may be omitted
2137
+ * - columns with a default (D = true) — the DB fills in the value when absent
2138
+ */
2139
+ type ColIsOptionalOnInsert<C> = C extends ColumnBuilder<infer _K, true, infer _D, infer _E> ? true : C extends ColumnBuilder<infer _K, infer _N, true, infer _E> ? true : false;
2140
+ /** Create a UUID column. */
2141
+ declare function uuid(): ColumnBuilder<'uuid', false, false, never>;
2142
+ /** Create a TEXT column. */
2143
+ declare function text(): ColumnBuilder<'text', false, false, never>;
2144
+ /** Create an INTEGER column. Emits int4 (max ~2.1B). */
2145
+ declare function integer(): ColumnBuilder<'integer', false, false, never>;
2146
+ /**
2147
+ * Create a BIGINT column (Postgres int8, max ~9.2×10^18).
2148
+ * Surfaces as `string` in row/insert types — JS number loses precision past 2^53
2149
+ * and pgx/PostgREST serialize int8 as a JSON string. Use BigInt(row.column) in app code.
2150
+ */
2151
+ declare function bigint(): ColumnBuilder<'bigint', false, false, never>;
2152
+ /**
2153
+ * Create a NUMERIC column (Postgres `numeric`/`decimal`, arbitrary precision).
2154
+ * For exact fractional values (money with cents as a decimal, rates, weights)
2155
+ * where int4/int8 don't fit. Surfaces as `string` in row/insert types — JS
2156
+ * number can't hold arbitrary-precision decimals without rounding, and
2157
+ * pgx/PostgREST serialize numeric as a JSON string. Parse with a decimal lib
2158
+ * (or BigInt for scaled integers) in app code.
2159
+ */
2160
+ declare function numeric(): ColumnBuilder<'numeric', false, false, never>;
2161
+ /** Create a BOOLEAN column. */
2162
+ declare function boolean(): ColumnBuilder<'boolean', false, false, never>;
2163
+ /** Create a TIMESTAMP column. */
2164
+ declare function timestamp(): ColumnBuilder<'timestamp', false, false, never>;
2165
+ /**
2166
+ * Create a JSONB column. Pass a payload type to make the generated row/insert
2167
+ * type concrete instead of `unknown`:
2168
+ *
2169
+ * tags: jsonb<string[]>() // row.tags: string[]
2170
+ * meta: jsonb<{ tier: string }>() // row.meta: { tier: string }
2171
+ * raw: jsonb() // row.raw: unknown (back-compat)
2172
+ *
2173
+ * The runtime accepts a plain JS object/array directly (no JSON.stringify); the
2174
+ * generic only refines the TYPE the env codegen emits.
2175
+ */
2176
+ declare function jsonb<T = unknown>(): ColumnBuilder<'jsonb', false, false, never, T>;
2177
+ /**
2178
+ * Create an ENUM column.
2179
+ * @param name The PostgreSQL enum type name (used in DDL).
2180
+ * @param values A readonly tuple of valid string values — kept `const` so the
2181
+ * union `V[number]` is as narrow as possible.
2182
+ */
2183
+ declare function enumType<const V extends readonly string[]>(name: string, values: V): ColumnBuilder<'enum', false, false, V[number]>;
2184
+
2185
+ /**
2186
+ * policy.ts — the RLS policy authoring DSL.
2187
+ *
2188
+ * `policy(name)` returns a fluent builder that mirrors the `ColumnBuilder`
2189
+ * style in columns.ts: each chainable method mutates the underlying
2190
+ * definition and returns the builder so calls compose. The terminal value is
2191
+ * a plain {@link PolicyDef} — the exact JSON shape the runtime's
2192
+ * `schema_extract.js` reads off the bundled module and the Go side parses into
2193
+ * `PolicyJSON` (CONTRACT-POLICY).
2194
+ *
2195
+ * @example
2196
+ * import { policy } from "@palbase/backend";
2197
+ *
2198
+ * policy("owner_select")
2199
+ * .for("select")
2200
+ * .to("authenticated")
2201
+ * .using("owner = (select auth.uid())");
2202
+ */
2203
+ /** The SQL command a policy applies to. `"all"` covers SELECT/INSERT/UPDATE/DELETE. */
2204
+ type PolicyCommand = "all" | "select" | "insert" | "update" | "delete";
2205
+ /** Whether a policy is permissive (OR-combined, the default) or restrictive
2206
+ * (AND-combined). Mirrors Postgres `CREATE POLICY ... AS PERMISSIVE|RESTRICTIVE`. */
2207
+ type PolicyMode = "permissive" | "restrictive";
2208
+ /**
2209
+ * The compiled, serializable policy definition — the EXACT shape consumed by
2210
+ * `schema_extract.js` → Go `PolicyJSON` (CONTRACT-POLICY).
2211
+ *
2212
+ * - `roles`: the DB roles this policy applies to (`TO` clause). An empty array
2213
+ * means the policy applies to PUBLIC (all roles) — the Postgres default.
2214
+ * - `using`: the `USING (...)` row-visibility expression, or `null` when none.
2215
+ * - `withCheck`: the `WITH CHECK (...)` write-validation expression, or `null`.
2216
+ * - `permissive`: `true` for `AS PERMISSIVE` (default), `false` for restrictive.
2217
+ */
2218
+ interface PolicyDef {
2219
+ name: string;
2220
+ command: PolicyCommand;
2221
+ roles: string[];
2222
+ using: string | null;
2223
+ withCheck: string | null;
2224
+ permissive: boolean;
2225
+ }
2226
+ /**
2227
+ * Fluent RLS policy builder.
2228
+ *
2229
+ * Defaults (documented, applied at construction):
2230
+ * - `command`: `"all"` — applies to every SQL command unless `.for(...)` narrows it.
2231
+ * - `roles`: `["authenticated"]` — the common case is "rule applies to signed-in
2232
+ * users". Call `.to(...)` to override; pass `.to()` with no roles (or never
2233
+ * call it after a reset) to target PUBLIC.
2234
+ * - `using` / `withCheck`: `null` — no row filter / write check until set.
2235
+ * - `permissive`: `true` — `AS PERMISSIVE` (policies OR together).
2236
+ *
2237
+ * Each method mutates `_def` in place and returns `this`, so the chain is a
2238
+ * single builder instance (no per-call allocation, like a tagged-template
2239
+ * compile target). The terminal `PolicyDef` is read directly off `_def` by
2240
+ * `schema_extract.js`.
2241
+ */
2242
+ declare class PolicyBuilder {
2243
+ readonly _def: PolicyDef;
2244
+ constructor(name: string);
2245
+ /** Restrict the policy to a single SQL command (default `"all"`). */
2246
+ for(command: PolicyCommand): this;
2247
+ /**
2248
+ * Set the DB roles the policy applies to (the `TO` clause), replacing any
2249
+ * previously-set roles. Call with no arguments to target PUBLIC (all roles).
2250
+ *
2251
+ * @example
2252
+ * policy("p").to("authenticated")
2253
+ * policy("p").to("authenticated", "service_role")
2254
+ * policy("p").to() // PUBLIC
2255
+ */
2256
+ to(...roles: string[]): this;
2257
+ /** Set the `USING (...)` row-visibility expression (raw SQL). */
2258
+ using(sqlExpr: string): this;
2259
+ /** Set the `WITH CHECK (...)` write-validation expression (raw SQL). */
2260
+ withCheck(sqlExpr: string): this;
2261
+ /** Set the policy mode: `"permissive"` (default, OR-combined) or
2262
+ * `"restrictive"` (AND-combined). */
2263
+ as(mode: PolicyMode): this;
2264
+ }
2265
+ /**
2266
+ * Start authoring an RLS policy. Returns a {@link PolicyBuilder}; the resulting
2267
+ * `PolicyBuilder` is accepted directly in a table's `policies: [...]` array
2268
+ * (its `_def` is read at schema-extract time).
2269
+ *
2270
+ * @param name The policy name. Palbase reconciliation keys policies by
2271
+ * `(table, name)`, so names must be unique per table.
2272
+ */
2273
+ declare function policy(name: string): PolicyBuilder;
2274
+
2275
+ /**
2276
+ * Postgres extensions a Palbase project can enable from its schema.
2277
+ *
2278
+ * Extensions are config-as-code: declare them in `defineSchema({ extensions })`
2279
+ * and the deploy installs them (CREATE EXTENSION … SCHEMA extensions) using the
2280
+ * deploy path's privileged connection. They are NOT toggled live from Studio —
2281
+ * CREATE EXTENSION requires a superuser role that only the deploy path holds.
2282
+ *
2283
+ * The list is an allowlist (a string-literal union) so editors autocomplete the
2284
+ * supported names and a typo fails typecheck. It is intentionally extensible:
2285
+ * add a name here (+ confirm the base image ships it) to support more.
2286
+ */
2287
+ declare const PALBASE_EXTENSIONS: readonly ["vector", "pg_trgm", "unaccent", "citext", "postgis", "cube", "earthdistance", "hstore", "ltree", "btree_gist", "pg_cron", "pgcrypto", "uuid-ossp"];
2288
+ /** A Postgres extension supported by Palbase (allowlist union). */
2289
+ type PalbaseExtension = (typeof PALBASE_EXTENSIONS)[number];
2290
+ /**
2291
+ * Extensions that depend on another extension. The deploy installs
2292
+ * dependencies first; declaring `earthdistance` without `cube` still works
2293
+ * because the deploy resolves the order, but listing both is clearer.
2294
+ */
2295
+ declare const EXTENSION_DEPENDENCIES: Partial<Record<PalbaseExtension, PalbaseExtension[]>>;
2296
+ /** Runtime guard: is `name` a supported Palbase extension? */
2297
+ declare function isPalbaseExtension(name: string): name is PalbaseExtension;
2298
+
2299
+ /**
2300
+ * A named raw-SQL DDL object declared in db/schema.ts for anything the typed DSL
2301
+ * cannot express (EXCLUDE, CHECK, partial/expression indexes, triggers, views).
2302
+ * The deploy emits `up` verbatim on the privileged DDL connection — same trust
2303
+ * posture as policy().using(). Tracked by NAME (not by diffing the body), so a
2304
+ * changed body needs a new name or an explicit drop+add.
2305
+ */
2306
+ interface RawConstraintDef {
2307
+ name: string;
2308
+ up: string;
2309
+ down?: string;
2310
+ }
2311
+ declare function raw(name: string, up: string, opts?: {
2312
+ down?: string;
2313
+ }): RawConstraintDef;
2314
+
2315
+ /**
2316
+ * A map of column builders keyed by column name — the value you write under
2317
+ * the `columns` key of `defineSchema({ tables: { <name>: { columns } } })`.
2318
+ *
2319
+ * The default `Record<string, ColumnBuilder>` keeps bare references compiling
2320
+ * without a type argument.
2321
+ */
2322
+ type ColumnMap = Record<string, ColumnBuilder>;
2323
+ /**
2324
+ * The author-facing value written under each table key:
2325
+ * `{ columns, rls?, policies? }`.
2326
+ *
2327
+ * - `columns`: the column map (required).
2328
+ * - `rls`: enable + FORCE row-level security on this table. **Defaults to
2329
+ * `true`**, and is forced on when `policies` is non-empty. A table with RLS
2330
+ * and no policies is deny-all, which is the starting state: nothing reads it
2331
+ * until a policy says who may. Set `rls: false` only for a genuinely public
2332
+ * table — it is an explicit opt-out that a reviewer can grep for, not
2333
+ * something you get by forgetting.
2334
+ * - `policies`: the RLS policies for this table, authored with `policy(name)`.
2335
+ * Each entry may be a {@link PolicyBuilder} (the normal `policy(...)` chain)
2336
+ * or a raw {@link PolicyDef} object.
2337
+ *
2338
+ * The `C` type parameter preserves the precise per-column phantom types so the
2339
+ * typed `Database.tables.*` surface keeps inferring insert/row shapes.
2340
+ */
2341
+ interface TableInput<C extends ColumnMap = ColumnMap> {
2342
+ columns: C;
2343
+ rls?: boolean;
2344
+ policies?: (PolicyBuilder | PolicyDef)[];
2345
+ /** Composite/named primary key (ordered column names). Omit for single-column inline .primaryKey(). */
2346
+ primaryKey?: string[];
2347
+ /** Named multi-column UNIQUE constraints. */
2348
+ unique?: {
2349
+ name: string;
2350
+ columns: string[];
2351
+ }[];
2352
+ /** Named raw-SQL DDL objects (EXCLUDE, triggers, views) that the typed DSL cannot express. */
2353
+ raw?: RawConstraintDef[];
2354
+ /**
2355
+ * Named first-class CHECK constraints. Diffed by NAME with a BODY compare:
2356
+ * a changed `expr` (after pg normalization) recreates the constraint
2357
+ * (DROP + ADD). `expr` is trusted SQL emitted verbatim (like policy USING),
2358
+ * `name` is identifier-validated.
2359
+ */
2360
+ checks?: {
2361
+ name: string;
2362
+ expr: string;
2363
+ }[];
2364
+ /**
2365
+ * Plain (non-unique) btree indexes over an ordered column list, emitted as
2366
+ * standalone `CREATE INDEX [IF NOT EXISTS] name ON table (col1, col2)`
2367
+ * statements (NOT a table clause — a separate migration statement category).
2368
+ * Structural compare by NAME (no expression normalization). `name` and each
2369
+ * column are identifier-validated by the Go differ.
2370
+ *
2371
+ * Scope: columns-only plain btree. Partial (`where`) and expression indexes
2372
+ * are a deliberate follow-up — modelling them needs the same raw-SQL
2373
+ * normalization round-trip CHECK uses (Task 10), so they are NOT in this
2374
+ * type yet to avoid a half-working partial-index path.
2375
+ */
2376
+ indexes?: {
2377
+ name: string;
2378
+ columns: string[];
2379
+ }[];
2380
+ }
2381
+ /**
2382
+ * A table definition — the runtime value the Go runtime's `schema_extract.js`
2383
+ * reads. It keys tables by `tableDef.name`, reads `tableDef.columns` for the
2384
+ * column DDL, and `tableDef.rls` + `tableDef.policies` for RLS.
2385
+ *
2386
+ * `defineSchema` derives `name` from the object key, so authors never repeat
2387
+ * the table name. `rls`/`policies` are always present after normalization
2388
+ * (defaulted to `true`/`[]`).
2389
+ *
2390
+ * The `C` type parameter preserves the precise per-column phantom types so that
2391
+ * downstream mapped types (InsertShape, RowShape) can discriminate on them.
2392
+ */
2393
+ interface TableDef<C extends ColumnMap = ColumnMap> {
2394
+ name: string;
2395
+ columns: C;
2396
+ rls: boolean;
2397
+ policies: PolicyDef[];
2398
+ primaryKey?: string[];
2399
+ unique?: {
2400
+ name: string;
2401
+ columns: string[];
2402
+ }[];
2403
+ /** Named raw-SQL DDL objects emitted verbatim on deploy. Tracked by name. */
2404
+ raw?: RawConstraintDef[];
2405
+ /** Named first-class CHECK constraints. Diffed by name + (normalized) body. */
2406
+ checks?: {
2407
+ name: string;
2408
+ expr: string;
2409
+ }[];
2410
+ /** Plain btree indexes (columns-only), emitted as standalone CREATE INDEX. Diffed by name. */
2411
+ indexes?: {
2412
+ name: string;
2413
+ columns: string[];
2414
+ }[];
2415
+ }
2416
+ /**
2417
+ * A schema definition containing multiple tables, keyed by table name.
2418
+ *
2419
+ * The `T` type parameter preserves the exact `TableDef<...>` type for each
2420
+ * table so that `SchemaDef["tables"]["rooms"]` resolves to the precise
2421
+ * `TableDef<{ id: ColumnBuilder<'uuid', false, true, never>; ... }>`.
2422
+ */
2423
+ interface SchemaDef<T extends Record<string, TableDef> = Record<string, TableDef>> {
2424
+ tables: T;
2425
+ /** Postgres extensions to install on deploy. Normalized to `[]` when absent. */
2426
+ extensions: PalbaseExtension[];
2427
+ }
2428
+ /** The author-facing input to `defineSchema` — a `tables` map whose keys are
2429
+ * the table names and whose values are `{ columns, rls?, policies? }`, plus an
2430
+ * optional `extensions` allowlist. */
2431
+ interface SchemaInput<T extends Record<string, TableInput> = Record<string, TableInput>> {
2432
+ tables: T;
2433
+ /**
2434
+ * Postgres extensions to enable for this project, e.g. `["vector"]`.
2435
+ * Config-as-code: installed by the deploy (CREATE EXTENSION … SCHEMA
2436
+ * extensions) with the privileged deploy connection. The type is an
2437
+ * allowlist union, so unsupported names fail typecheck.
2438
+ */
2439
+ extensions?: PalbaseExtension[];
2440
+ }
2441
+ /** Map the author's `{ tables: { <name>: { columns } } }` input to the
2442
+ * `{ tables: { <name>: TableDef<columns> } }` runtime/type shape, threading the
2443
+ * per-table column map `T[K]["columns"]` so column-level inference survives. */
2444
+ type TablesFromInput<T extends Record<string, TableInput>> = {
2445
+ [K in keyof T]: TableDef<T[K]["columns"]>;
2446
+ };
2447
+ /**
2448
+ * Define a schema. The table NAME comes from the object key. Each table value
2449
+ * is `{ columns, rls?, policies? }`:
2450
+ *
2451
+ * export default defineSchema({
2452
+ * tables: {
2453
+ * todos: {
2454
+ * columns: {
2455
+ * id: uuid().primaryKey().defaultRandom(),
2456
+ * owner: text().notNull(),
2457
+ * title: text().notNull(),
2458
+ * },
2459
+ * rls: true,
2460
+ * policies: [
2461
+ * policy("owner_all").for("all").to("authenticated")
2462
+ * .using("owner = (select auth.uid())")
2463
+ * .withCheck("owner = (select auth.uid())"),
2464
+ * ],
2465
+ * },
2466
+ * },
2467
+ * });
2468
+ *
2469
+ * The returned value is
2470
+ * `{ tables: { todos: { name, columns, rls, policies } } }` — the exact shape
2471
+ * the runtime schema extractor parses. Per-column phantom types are preserved
2472
+ * so `Database.tables.todos.insert({...})` stays typed.
2473
+ *
2474
+ * RLS normalization: `rls` defaults to **`true`**, `policies` to `[]`. A table
2475
+ * that declares neither is therefore deny-all — nothing reads it until a policy
2476
+ * says who may, which is the safe starting point rather than a bug. Declare
2477
+ * `rls: false` for a genuinely public table; that is an explicit, greppable
2478
+ * statement of intent instead of an omission. When `policies` is non-empty,
2479
+ * `rls` is forced on (ENABLE + FORCE) regardless of the declared flag — a table
2480
+ * with policies must have RLS enabled or the policies would be inert.
2481
+ */
2482
+ declare function defineSchema<T extends Record<string, TableInput>>(input: SchemaInput<T>): SchemaDef<TablesFromInput<T>>;
2483
+
2484
+ /**
2485
+ * typed-db.ts — Task 2: TypedDB schema-derived insert/row shapes.
2486
+ *
2487
+ * Derives INSERT and full-row TypeScript types from a `defineSchema()` result
2488
+ * and wraps the untyped runtime `DBClient` with a typed facade.
2489
+ *
2490
+ * No value-any. No `as unknown as X`. The two narrow `as` casts in
2491
+ * `makeTypedTable` are safe because:
2492
+ * - `data as Record<string, unknown>`: InsertShape<T> maps string keys to
2493
+ * typed values; all value types are subsets of `unknown`, so the cast is
2494
+ * structurally sound.
2495
+ * - `result as RowShape<T>`: The runtime DBClient returns `Record<string,
2496
+ * unknown>` which is the erased form of the typed row; we're narrowing back
2497
+ * to the precise shape that the schema declared.
2498
+ * Both casts are narrowing only (not widening) and correctness is guaranteed
2499
+ * by the schema the caller provides.
2500
+ */
2501
+
2502
+ /** Keys of C whose columns are required on INSERT (not nullable, no default). */
2503
+ type RequiredKeys<C> = {
2504
+ [K in keyof C]: ColIsOptionalOnInsert<C[K]> extends true ? never : K;
2505
+ }[keyof C];
2506
+ /** Keys of C whose columns are optional on INSERT (nullable or has a default). */
2507
+ type OptionalKeys<C> = {
2508
+ [K in keyof C]: ColIsOptionalOnInsert<C[K]> extends true ? K : never;
2509
+ }[keyof C];
2510
+ /**
2511
+ * The TypeScript type for an INSERT payload for table `T`.
2512
+ * - Required: columns that are NOT NULL and have no DB-level default.
2513
+ * - Optional: columns that are nullable or carry a default.
2514
+ *
2515
+ * When all columns are optional, `RequiredKeys<C>` resolves to `never` and
2516
+ * the first part becomes `{}`, which is a neutral element for `&`.
2517
+ */
2518
+ type InsertShape<T extends TableDef> = {
2519
+ [K in RequiredKeys<T["columns"]>]: ColValue<T["columns"][K]>;
2520
+ } & {
2521
+ [K in OptionalKeys<T["columns"]>]?: ColValue<T["columns"][K]>;
2522
+ };
2523
+ /**
2524
+ * The TypeScript type for a full row returned by the DB for table `T`.
2525
+ * Every column is present; nullable columns resolve to `T | null`.
2526
+ */
2527
+ type RowShape<T extends TableDef> = {
2528
+ [K in keyof T["columns"]]: ColValue<T["columns"][K]>;
2529
+ };
2530
+ /** A typed table accessor that mirrors the runtime DBClient surface. */
2531
+ interface TypedTable<T extends TableDef> {
2532
+ insert(data: InsertShape<T>): Promise<RowShape<T>>;
2533
+ /** Update the row by id; resolves to the updated row, or `null` if no row
2534
+ * matched (absent or RLS-hidden) — an idempotent outcome, mirroring
2535
+ * `findById`. The runtime returns a null row rather than throwing. */
2536
+ update(id: string, data: Partial<InsertShape<T>>): Promise<RowShape<T> | null>;
2537
+ delete(id: string): Promise<void>;
2538
+ findById(id: string): Promise<RowShape<T> | null>;
2539
+ findMany(query?: Partial<RowShape<T>>): Promise<RowShape<T>[]>;
2540
+ }
2541
+ /** A typed DB facade covering all tables declared in schema `S`. */
2542
+ interface TypedDB<S extends SchemaDef> {
2543
+ tables: {
2544
+ [K in keyof S["tables"]]: TypedTable<S["tables"][K]>;
2545
+ };
2546
+ /** Run a transaction plan. See {@link EnvTypedDatabase.transaction}. */
2547
+ transaction<T>(fn: (tx: TypedTx<S>) => T extends Promise<unknown> ? never : T): Promise<Materialized<T>>;
2548
+ }
2549
+ /** The plan-building handle a `TypedDB<S>` transaction callback receives: the
2550
+ * schema's tables, expressed as plan operations rather than awaited calls. */
2551
+ type TypedTx<S extends SchemaDef> = TxPlanHandle<{
2552
+ [K in keyof S["tables"]]: TxTable<RowShape<S["tables"][K]>, InsertShape<S["tables"][K]>>;
2553
+ }>;
2554
+ /**
2555
+ * Wraps a raw `DBClient` with the type-safe `TypedDB<S>` facade derived from
2556
+ * the provided schema. No behavior change for the direct ops — all calls
2557
+ * delegate to `raw` with the table name as a plain string.
2558
+ *
2559
+ * `transaction` does NOT delegate to a per-op client: the callback describes a
2560
+ * plan against a fresh {@link TxPlanBuilder}, and the whole plan travels in one
2561
+ * `raw.txPlan` call. The schema is used only for its table NAMES; the values
2562
+ * are typed by `S` at compile time and are plain strings at run time.
2563
+ *
2564
+ * The `as` casts are single structural narrowings from a dynamically-built
2565
+ * object to the precise mapped type (TS cannot infer the mapped-type result
2566
+ * through `Object.keys` iteration) — see the module-level doc comment.
2567
+ */
2568
+ declare function makeTypedDB<S extends SchemaDef>(schema: S, raw: DBClient): TypedDB<S>;
2569
+ /** A typed table accessor derived from one env `Tables` entry's flat shapes. */
2570
+ interface EnvTypedTable<T extends TableTypes> {
2571
+ insert(data: T["insert"]): Promise<T["row"]>;
2572
+ /** Update the row by id; resolves to the updated row, or `null` if no row
2573
+ * matched (absent or RLS-hidden) — an idempotent outcome, mirroring
2574
+ * `findById`. The runtime returns a null row rather than throwing. */
2575
+ update(id: string, data: Partial<T["insert"]>): Promise<T["row"] | null>;
2576
+ delete(id: string): Promise<void>;
2577
+ findById(id: string): Promise<T["row"] | null>;
2578
+ findMany(query?: Partial<T["row"]>): Promise<T["row"][]>;
2579
+ }
2580
+ /** The `tables` map exposed on `Database`/`tx`, keyed by the env `Tables`
2581
+ * interface. When no schema is declared `Tables` is empty, so `tables` is an
2582
+ * empty object — accessing `.tables.foo` is then a compile error (no member). */
2583
+ type EnvTables = {
2584
+ [K in keyof Tables]: EnvTypedTable<Tables[K]>;
2585
+ };
2586
+ /** The project's tables as PLAN operations, keyed by the env `Tables`
2587
+ * interface. The transaction twin of {@link EnvTables}. */
2588
+ type TxTables = {
2589
+ [K in keyof Tables]: TxTable<Tables[K]["row"], Tables[K]["insert"]>;
2590
+ };
2591
+ /**
2592
+ * The handle a `Database.transaction(…)` callback receives.
2593
+ *
2594
+ * Tables only — no `query`, no `findById`, no `asService`. A read whose value
2595
+ * the plan does not write belongs outside the transaction, where it costs one
2596
+ * round trip and is an ordinary value you can branch on.
2597
+ */
2598
+ type TxPlan = TxPlanHandle<TxTables>;
2599
+ /**
2600
+ * The RLS-bypass sibling returned by `Database.asService()`. Same typed surface
2601
+ * as {@link EnvTypedDatabase} — `tables`, the raw string ops, and a typed
2602
+ * `transaction` — but it does NOT re-expose `asService` (no double-bypass).
2603
+ * Every op it performs runs as the `service_role` (BYPASSRLS).
2604
+ */
2605
+ interface EnvServiceDatabase extends Omit<DBClient, "txPlan" | "asService"> {
2606
+ tables: EnvTables;
2607
+ transaction<T>(fn: (tx: TxPlan) => T extends Promise<unknown> ? never : T): Promise<Materialized<T>>;
2608
+ }
2609
+ /**
2610
+ * The typed-by-default Database surface: the raw string-keyed `DBClient` ops
2611
+ * PLUS a `tables` map typed against the project's generated `palbase-env.d.ts`,
2612
+ * a `transaction` that runs a whole plan in one request, and `asService()` for
2613
+ * the explicit RLS-bypass sibling.
2614
+ *
2615
+ * The low-level `txPlan` op is deliberately NOT re-exposed here: `transaction`
2616
+ * is the surface, and a hand-built plan would bypass the ref/guard machinery
2617
+ * that makes one safe to write.
2618
+ */
2619
+ interface EnvTypedDatabase extends Omit<DBClient, "txPlan" | "asService"> {
2620
+ tables: EnvTables;
2621
+ /**
2622
+ * Run a transaction. The callback DESCRIBES the operations; the whole
2623
+ * description travels in one request and the broker runs it inside a single
2624
+ * transaction — committing when it finishes, rolling back on any failure.
2625
+ *
2626
+ * The callback is SYNCHRONOUS: nothing has run when it returns, so there is
2627
+ * nothing to await. `async` on it and `await` inside it are compile errors.
2628
+ * Values a later operation needs are {@link Ref}s, written straight into the
2629
+ * next operation; values the CALLER needs are returned and substituted before
2630
+ * this promise resolves.
2631
+ *
2632
+ * @example
2633
+ * const { statementId } = await Database.transaction((tx) => {
2634
+ * const st = tx.tables.statements
2635
+ * .insert({ household_id: hid, file_sha256: sha, status: "reviewing" })
2636
+ * .expectOne(new Internal("statement insert failed"));
2637
+ *
2638
+ * tx.tables.statement_lines.insertMany(
2639
+ * lines.map((l) => ({ statement_id: st.id, category: resolveCategory(l) })),
2640
+ * );
2641
+ *
2642
+ * return { statementId: st.id };
2643
+ * });
2644
+ */
2645
+ transaction<T>(fn: (tx: TxPlan) => T extends Promise<unknown> ? never : T): Promise<Materialized<T>>;
2646
+ /**
2647
+ * Return a sibling that bypasses RLS by running as the `service_role`. Use
2648
+ * sparingly and explicitly — the default `Database.*` path is RLS-enforced.
2649
+ *
2650
+ * @example
2651
+ * const all = await Database.asService().tables.todos.findMany({});
2652
+ * const rows = await Database.asService().query("SELECT * FROM todos");
2653
+ */
2654
+ asService(): EnvServiceDatabase;
2655
+ }
2656
+
2657
+ export { type PalbaseBindDeviceParams as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, type EnvTypedDatabase as E, type FileContext as F, PalError as G, HttpError as H, type InsertShape as I, type PalbaseAnalyticsClient as J, type PalbaseAnalyticsManagementNamespace as K, type Logger as L, type Materialized as M, NotFound as N, type OnDeleteAction as O, type PalbaseDocsClient as P, type PalbaseAnalyticsProperties as Q, type RateLimitConfig as R, type SchemaDef as S, type PalbaseAnalyticsQueryNamespace as T, type PalbaseAttestAndroidParams as U, type PalbaseAttestAndroidResult as V, type PalbaseAttestiOSParams as W, type PalbaseAttestiOSResult as X, type PalbaseAuthClient as Y, type PalbaseBatchOverrideOperation as Z, type PalbaseBatchSetOverridesResult as _, type PalbaseFlagsClient as a, type PalbaseSignedUrlResponse as a$, type PalbaseBucketClient as a0, type PalbaseClearAllOverridesResult as a1, type PalbaseClearOverrideResult as a2, type PalbaseCohortQueryInput as a3, type PalbaseCohortResult as a4, type PalbaseCollectionRef as a5, type PalbaseCountQueryInput as a6, type PalbaseCountResult as a7, type PalbaseCreateLinkParams as a8, type PalbaseDeviceInfo as a9, type PalbaseInboxSendResponse as aA, type PalbaseInitialLink as aB, type PalbaseInvokeOptions as aC, type PalbaseLink as aD, type PalbaseLinkAnalytics as aE, type PalbaseLinkDetails as aF, type PalbaseLinksClient as aG, type PalbaseListLinksOptions as aH, type PalbaseListLinksResult as aI, type PalbaseListOptions as aJ, type PalbaseMatchParams as aK, type PalbaseMultiChannelResponse as aL, type PalbaseOverviewResult as aM, type PalbasePreferences as aN, type PalbasePreferencesClient as aO, type PalbasePushClient as aP, type PalbasePushSendParams as aQ, type PalbasePushSendResponse as aR, type PalbaseQrCodeOptions as aS, type PalbaseQuerySnapshot as aT, type PalbaseRegisterDeviceParams as aU, type PalbaseResult as aV, type PalbaseRetentionQueryInput as aW, type PalbaseRetentionResult as aX, type PalbaseSession as aY, type PalbaseSetOverrideResult as aZ, type PalbaseSetOverridesResult as a_, type PalbaseDeviceTokenView as aa, type PalbaseDocumentRef as ab, type PalbaseDocumentSnapshot as ac, type PalbaseEmailClient as ad, type PalbaseEmailSendParams as ae, type PalbaseEmailSendResponse as af, type PalbaseEventNamesResult as ag, type PalbaseEventsQueryInput as ah, type PalbaseEventsResult as ai, type PalbaseExtension as aj, type PalbaseFileObject as ak, type PalbaseFlag as al, type PalbaseFlagContext as am, type PalbaseFlagSource as an, type PalbaseFlagValue as ao, type PalbaseFlagVariant as ap, type PalbaseFlagsServiceClient as aq, type PalbaseFunctionsClient as ar, type PalbaseFunnelQueryInput as as, type PalbaseFunnelResult as at, type PalbaseIdentifyTraits as au, type PalbaseInboxClient as av, type PalbaseInboxListOptions as aw, type PalbaseInboxListResult as ax, type PalbaseInboxMessage as ay, type PalbaseInboxSendParams as az, type PalbaseNotificationsClient as b, jsonb as b$, type PalbaseSmsClient as b0, type PalbaseSmsSendParams as b1, type PalbaseSmsSendResponse as b2, type PalbaseTransformOptions as b3, type PalbaseUpdateLinkParams as b4, type PalbaseUploadOptions as b5, type PalbaseUser as b6, type PalbaseUserDetailResult as b7, type PalbaseUsersQueryInput as b8, type PalbaseUsersResult as b9, type TxRows as bA, type TxSelectOptions as bB, type TxSetShape as bC, type TxSetValue as bD, type TxTable as bE, type TxTables as bF, type TxWhere as bG, type TxWireExpr as bH, type TxWireGuard as bI, type TxWireOp as bJ, type TxWireRef as bK, type TxWireValue as bL, type TypedDB as bM, type TypedTable as bN, type TypedTx as bO, Unauthorized as bP, type User as bQ, type VerifiedDevice as bR, bigint as bS, boolean as bT, dec as bU, defineMiddleware as bV, defineSchema as bW, enumType as bX, inc as bY, integer as bZ, isPalbaseExtension as b_, type PalbaseVerifyRequestSignatureParams as ba, type PalbaseWhereOperator as bb, PolicyBuilder as bc, type PolicyCommand as bd, type PolicyDef as be, type PolicyMode as bf, type RawConstraintDef as bg, type Ref as bh, type RowShape as bi, type SchemaInput as bj, type TableDef as bk, type TableInput as bl, TooManyRequests as bm, type TxColumnExpr as bn, type TxInsertShape as bo, type TxInsertValue as bp, type TxNow as bq, type TxPlan as br, type TxPlanBody as bs, TxPlanError as bt, type TxPlanHandle as bu, type TxPlanOpResult as bv, type TxPlanRejection as bw, type TxPlanResponse as bx, TxRefError as by, type TxRow as bz, type PalbaseRealtimeClient as c, makeTypedDB as c0, now as c1, numeric as c2, policy as c3, raw as c4, text as c5, timestamp as c6, uuid as c7, type PalbaseStorageClient as d, type AuthConfig as e, type ClientInfo as f, ColumnBuilder as g, type ColumnDef as h, type ColumnMap as i, type ColumnType as j, Conflict as k, type DBOps as l, EXTENSION_DEPENDENCIES as m, type EnvServiceDatabase as n, type EnvTables as o, type EnvTypedTable as p, type ErrorDef as q, type ErrorMap as r, type ErrorThrowers as s, Forbidden as t, type HttpMethod as u, type Middleware as v, type MiddlewareContext as w, type MiddlewareHandler as x, PALBASE_EXTENSIONS as y, type PBRequest as z };