@palbase/backend 29.0.0 → 30.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/bin/palbase-backend.cjs +22 -7
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +2 -2
  4. package/dist/{chunk-DHJ3SYAE.js → chunk-RADVOY7Y.js} +23 -9
  5. package/dist/{chunk-DHJ3SYAE.js.map → chunk-RADVOY7Y.js.map} +1 -1
  6. package/dist/{chunk-ESSQ3YML.js → chunk-YRVIWHJC.js} +7 -3
  7. package/dist/{chunk-ESSQ3YML.js.map → chunk-YRVIWHJC.js.map} +1 -1
  8. package/dist/db/index.d.cts +1 -1
  9. package/dist/db/index.d.ts +1 -1
  10. package/dist/engine/index.cjs +22 -7
  11. package/dist/engine/index.cjs.map +1 -1
  12. package/dist/engine/index.d.cts +3 -3
  13. package/dist/engine/index.d.ts +3 -3
  14. package/dist/engine/index.js +2 -2
  15. package/dist/{index-BOe82fsK.d.ts → index-8qy3kIuA.d.ts} +66 -4
  16. package/dist/{index-ChvoVczS.d.cts → index-DtCgaZAg.d.cts} +66 -4
  17. package/dist/{index-BZfmdRmh.d.cts → index-Zi7MptvP.d.cts} +3 -3
  18. package/dist/{index-BYDUKexK.d.ts → index-b-Q3l7W5.d.ts} +3 -3
  19. package/dist/index.cjs +55 -2
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +51 -11
  22. package/dist/index.d.ts +51 -11
  23. package/dist/index.js +50 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/openapi/index.d.cts +2 -2
  26. package/dist/openapi/index.d.ts +2 -2
  27. package/dist/{registry-DaqHsOq8.d.ts → registry-BGJ-Al6F.d.ts} +1 -1
  28. package/dist/{registry-B2KfKWv1.d.cts → registry-CEYLH-Iz.d.cts} +1 -1
  29. package/dist/test/index.d.cts +1 -1
  30. package/dist/test/index.d.ts +1 -1
  31. package/docs/README.md +1 -1
  32. package/docs/llms-full.txt +1 -1
  33. package/package.json +1 -1
  34. package/template/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import '../index-ChvoVczS.cjs';
2
- export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-BZfmdRmh.cjs';
1
+ import '../index-DtCgaZAg.cjs';
2
+ export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-Zi7MptvP.cjs';
3
3
  import '../db/env.cjs';
4
4
  import '../stack.cjs';
5
5
  import 'zod';
6
6
  import 'node:async_hooks';
7
7
  import '../module-Dl1KFVtc.cjs';
8
- import '../registry-B2KfKWv1.cjs';
8
+ import '../registry-CEYLH-Iz.cjs';
@@ -1,8 +1,8 @@
1
- import '../index-BOe82fsK.js';
2
- export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-BYDUKexK.js';
1
+ import '../index-8qy3kIuA.js';
2
+ export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-b-Q3l7W5.js';
3
3
  import '../db/env.js';
4
4
  import '../stack.js';
5
5
  import 'zod';
6
6
  import 'node:async_hooks';
7
7
  import '../module-Dl1KFVtc.js';
8
- import '../registry-DaqHsOq8.js';
8
+ import '../registry-BGJ-Al6F.js';
@@ -16,12 +16,12 @@ import {
16
16
  quoteIdent,
17
17
  scrubSecrets,
18
18
  withTables
19
- } from "../chunk-DHJ3SYAE.js";
19
+ } from "../chunk-RADVOY7Y.js";
20
20
  import {
21
21
  DECLARATION_REFUSAL,
22
22
  DeclarationRefused,
23
23
  isDeclarationRefused
24
- } from "../chunk-ESSQ3YML.js";
24
+ } from "../chunk-YRVIWHJC.js";
25
25
  import "../chunk-SG4UTNOP.js";
26
26
  import "../chunk-3TUJWHC2.js";
27
27
  import "../chunk-VVMJEVQP.js";
@@ -39,6 +39,20 @@ interface User {
39
39
  */
40
40
  emailVerified: boolean;
41
41
  role: string;
42
+ /**
43
+ * The caller's APPLICATION roles, as assigned in `auth.user_roles`.
44
+ *
45
+ * Not to be confused with {@link User.role}, which is the DATABASE role RLS
46
+ * reads and is the literal string "authenticated" for every signed-in user.
47
+ * These are the names a stack declares (`palbase roles`) and an operator
48
+ * assigns; `auth: { role }` gates on the same set.
49
+ *
50
+ * Resolved per request from the table, in the transaction the handler is
51
+ * about to use — never from a token claim, so a role revoked a second ago is
52
+ * already gone here. An empty array for a caller who holds none, never null:
53
+ * `user.roles.includes("agent")` needs no guard.
54
+ */
55
+ roles: string[];
42
56
  metadata: Record<string, unknown>;
43
57
  /**
44
58
  * Reserved, server-owned verified device claim. `null` on an authenticated
@@ -2080,6 +2094,37 @@ interface PalbaseAuthClient {
2080
2094
  dispose(): void;
2081
2095
  };
2082
2096
  }
2097
+ /**
2098
+ * The `Auth` singleton a backend handler reaches — the ROLE-ASSIGNMENT surface,
2099
+ * and nothing else.
2100
+ *
2101
+ * Deliberately not {@link PalbaseAuthClient}: that one is a person acting on
2102
+ * their own account (sign-in, MFA, device attestation) and it belongs to the
2103
+ * client SDK. What a server needs is the operator verb — "make this user an
2104
+ * agent" — because the promotion usually happens inside the tenant's own
2105
+ * product, in a handler a supervisor triggers.
2106
+ *
2107
+ * These calls carry the SERVICE-ROLE credential: the routes behind them refuse
2108
+ * anon and `authenticated` alike (FR-013), which is what stops an end user from
2109
+ * granting themselves the permission the rest of the feature gates on.
2110
+ *
2111
+ * Unlike the other clients here these THROW rather than envelope, because two
2112
+ * of the three answer `void` — a refusal that came back as a value would be
2113
+ * indistinguishable from a write that happened. See `clients/auth.ts`.
2114
+ */
2115
+ interface PalbaseAuthAdminClient {
2116
+ /**
2117
+ * Give a user a role. Idempotent: assigning one they already hold is not an
2118
+ * error and leaves one row. Throws `RoleNotDefined` when the stack declares
2119
+ * no role by that name.
2120
+ */
2121
+ assignRole(userId: string, role: string): Promise<void>;
2122
+ /** Take a role away. Revoking one they do not hold is not an error. */
2123
+ revokeRole(userId: string, role: string): Promise<void>;
2124
+ /** What that user holds right now. `[]` for a user with no roles — a FAILED
2125
+ * read throws rather than answering the same thing. */
2126
+ rolesOf(userId: string): Promise<string[]>;
2127
+ }
2083
2128
  /**
2084
2129
  * Bucket-level file operations available via `ctx.storage.bucket(name)`.
2085
2130
  * `getPublicUrl` is synchronous (no network call — constructs URL locally).
@@ -2539,11 +2584,14 @@ interface PalbaseLinksClient {
2539
2584
  * Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
2540
2585
  * cannot hold a subscription socket — `subscribe()` lives on the client SDK).
2541
2586
  *
2542
- * EXCLUDED on purpose: Functions, Links, Analytics, Auth. They are not
2543
- * exposed as backend handler singletons (auth lives on the client SDK; the rest
2544
- * are out of scope for backend endpoints). */
2587
+ * EXCLUDED on purpose: Functions, Links, Analytics. They are not exposed as
2588
+ * backend handler singletons out of scope for backend endpoints. `Auth` is
2589
+ * here in its ROLE-ASSIGNMENT shape only: signing in is the client SDK's job,
2590
+ * but granting a role is an operator verb the tenant's own handler needs
2591
+ * (FR-009). */
2545
2592
  interface RuntimeServices {
2546
2593
  Database: DBClient;
2594
+ Auth: PalbaseAuthAdminClient;
2547
2595
  Secrets: SecretsService;
2548
2596
  Documents: PalbaseDocsClient;
2549
2597
  Storage: PalbaseStorageClient;
@@ -2753,6 +2801,20 @@ declare const Cache: CacheClient;
2753
2801
  * the STACK holds, because no route returns a platform secret's value at all.
2754
2802
  */
2755
2803
  declare const Secrets: SecretsService;
2804
+ /**
2805
+ * Role assignment, as an operator — `Auth.assignRole(userId, "agent")`.
2806
+ *
2807
+ * The half of auth a SERVER owns. Signing in, MFA and device attestation are a
2808
+ * person acting on their own account and live on the client SDK; granting a
2809
+ * role is the tenant's product doing something to somebody else, which is
2810
+ * exactly what a handler is for. It writes with the service-role credential,
2811
+ * because an end user who could write their own assignment would make every
2812
+ * permission underneath it meaningless.
2813
+ *
2814
+ * The write is visible to the very next request: authority is read from the
2815
+ * table on each call, never carried on a token.
2816
+ */
2817
+ declare const Auth: PalbaseAuthAdminClient;
2756
2818
  /** Structured logger. */
2757
2819
  declare const Log: Logger;
2758
2820
  /** Push / email / SMS / in-app notifications. */
@@ -5098,4 +5160,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
5098
5160
  */
5099
5161
  type AuthSpec = boolean | Partial<AuthConfig>;
5100
5162
 
5101
- export { Notifications as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorThrowers as F, type FileContext as G, HttpError as H, Flags as I, Forbidden as J, type HttpMethod as K, IndexBuilder as L, type IndexDef as M, type InsertShape as N, type LifecycleHook as O, type PalbaseResult as P, Log as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, type Logger as U, type Materialized as V, type Middleware as W, type MiddlewareContext as X, type MiddlewareHandler as Y, NotFound as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListOptions as a$, type OnDeleteAction as a0, PALBASE_EXTENSIONS as a1, type PBRequest as a2, PalError as a3, type PalbaseAnalyticsClient as a4, type PalbaseAnalyticsManagementNamespace as a5, type PalbaseAnalyticsProperties as a6, type PalbaseAnalyticsQueryNamespace as a7, type PalbaseAttestAndroidParams as a8, type PalbaseAttestAndroidResult as a9, type PalbaseExtension as aA, type PalbaseFileObject as aB, type PalbaseFlag as aC, type PalbaseFlagContext as aD, type PalbaseFlagSource as aE, type PalbaseFlagValue as aF, type PalbaseFlagVariant as aG, type PalbaseFlagsClient as aH, type PalbaseFlagsServiceClient as aI, type PalbaseFunctionsClient as aJ, type PalbaseFunnelQueryInput as aK, type PalbaseFunnelResult as aL, type PalbaseIdentifyTraits as aM, type PalbaseInboxClient as aN, type PalbaseInboxListOptions as aO, type PalbaseInboxListResult as aP, type PalbaseInboxMessage as aQ, type PalbaseInboxSendParams as aR, type PalbaseInboxSendResponse as aS, type PalbaseInitialLink as aT, type PalbaseInvokeOptions as aU, type PalbaseLink as aV, type PalbaseLinkAnalytics as aW, type PalbaseLinkDetails as aX, type PalbaseLinksClient as aY, type PalbaseListLinksOptions as aZ, type PalbaseListLinksResult as a_, type PalbaseAttestiOSParams as aa, type PalbaseAttestiOSResult as ab, type PalbaseAuthClient as ac, type PalbaseBatchOverrideOperation as ad, type PalbaseBatchSetOverridesResult as ae, type PalbaseBindDeviceParams as af, type PalbaseBucketClient as ag, type PalbaseClearAllOverridesResult as ah, type PalbaseClearOverrideResult as ai, type PalbaseCohortQueryInput as aj, type PalbaseCohortResult as ak, type PalbaseCollectionRef as al, type PalbaseCountQueryInput as am, type PalbaseCountResult as an, type PalbaseCreateLinkParams as ao, type PalbaseDeviceInfo as ap, type PalbaseDeviceTokenView as aq, type PalbaseDocsClient as ar, type PalbaseDocumentRef as as, type PalbaseDocumentSnapshot as at, type PalbaseEmailClient as au, type PalbaseEmailSendParams as av, type PalbaseEmailSendResponse as aw, type PalbaseEventNamesResult as ax, type PalbaseEventsQueryInput as ay, type PalbaseEventsResult as az, type TxPlanResponse as b, TxPlanError as b$, type PalbaseMatchParams as b0, type PalbaseMultiChannelResponse as b1, type PalbaseNotificationsClient as b2, type PalbaseOverviewResult as b3, type PalbasePreferences as b4, type PalbasePreferencesClient as b5, type PalbasePushClient as b6, type PalbasePushSendParams as b7, type PalbasePushSendResponse as b8, type PalbaseQrCodeOptions as b9, type PolicyExprCtx as bA, PolicyExprRef as bB, type PolicyMode as bC, type PolicyOperand as bD, type RawConstraintDef as bE, Realtime as bF, type Ref as bG, type RequestStore as bH, type RowShape as bI, Secrets as bJ, type SecretsService as bK, SerializationFailure as bL, type SetShape as bM, type SetValue as bN, type ShutdownRunner as bO, type SqlFragment as bP, Storage as bQ, TABLE_META as bR, type TableDef as bS, type TableHandle as bT, type TableInput as bU, TooManyRequests as bV, type TxColumnExpr as bW, type TxInsertShape as bX, type TxInsertValue as bY, type TxNow as bZ, type TxPlan as b_, type PalbaseQuerySnapshot as ba, type PalbaseRealtimeClient as bb, type PalbaseRegisterDeviceParams as bc, type PalbaseRetentionQueryInput as bd, type PalbaseRetentionResult as be, type PalbaseSession as bf, type PalbaseSetOverrideResult as bg, type PalbaseSetOverridesResult as bh, type PalbaseSignedUrlResponse as bi, type PalbaseSmsClient as bj, type PalbaseSmsSendParams as bk, type PalbaseSmsSendResponse as bl, type PalbaseStorageClient as bm, type PalbaseTransformOptions as bn, type PalbaseUpdateLinkParams as bo, type PalbaseUploadOptions as bp, type PalbaseUser as bq, type PalbaseUserDetailResult as br, type PalbaseUsersQueryInput as bs, type PalbaseUsersResult as bt, type PalbaseVerifyRequestSignatureParams as bu, type PalbaseWhereOperator as bv, type PolicyBinOp as bw, PolicyBuilder as bx, type PolicyCommand as by, type PolicyDef as bz, type RuntimeServices as c, type TxPlanHandle as c0, type TxPlanOpResult as c1, type TxPlanRejection as c2, TxRefError as c3, type TxRow as c4, type TxRows as c5, type TxSelectOptions as c6, type TxSetShape as c7, type TxSetValue as c8, type TxTable as c9, enumType as cA, exprCtx as cB, inc as cC, increment as cD, index as cE, installationRef as cF, integer as cG, isPalbaseExtension as cH, isRetryable as cI, jsonb as cJ, makeTypedDB as cK, now as cL, numeric as cM, onShutdown as cN, onStart as cO, openai as cP, ownedByUser as cQ, policy as cR, raw as cS, sqlFragment as cT, text as cU, timestamp as cV, userRef as cW, uuid as cX, vector as cY, withRetry as cZ, type TxTables as ca, type TxWhere as cb, type TxWireExpr as cc, type TxWireGuard as cd, type TxWireOp as ce, type TxWireRef as cf, type TxWireValue as cg, type TypedDB as ch, type TypedTable as ci, type TypedTx as cj, Unauthorized as ck, UniqueViolation as cl, type User as cm, type VerifiedDevice as cn, __getRuntime as co, __resetLifecycleHooks as cp, __runStartHooks as cq, __setRuntime as cr, bigint as cs, boolean as ct, col as cu, dec as cv, decrement as cw, defineMiddleware as cx, defineSchema as cy, defineTable as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, type AuthConfig as g, Cache as h, type ClientInfo as i, type ColRef as j, ColumnBuilder as k, type ColumnDef as l, type ColumnMap as m, type ColumnType as n, Conflict as o, Database as p, DeadlockDetected as q, Documents as r, type EmbeddingModelRef as s, type EnvSchemas as t, type EnvServiceDatabase as u, type EnvTables as v, type EnvTypedDatabase as w, type EnvTypedTable as x, type ErrorDef as y, type ErrorMap as z };
5163
+ export { NotFound as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorMap as F, type ErrorThrowers as G, HttpError as H, type FileContext as I, Flags as J, Forbidden as K, type HttpMethod as L, IndexBuilder as M, type IndexDef as N, type InsertShape as O, type PalbaseResult as P, type LifecycleHook as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, Log as U, type Logger as V, type Materialized as W, type Middleware as X, type MiddlewareContext as Y, type MiddlewareHandler as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListLinksOptions as a$, Notifications as a0, type OnDeleteAction as a1, PALBASE_EXTENSIONS as a2, type PBRequest as a3, PalError as a4, type PalbaseAnalyticsClient as a5, type PalbaseAnalyticsManagementNamespace as a6, type PalbaseAnalyticsProperties as a7, type PalbaseAnalyticsQueryNamespace as a8, type PalbaseAttestAndroidParams as a9, type PalbaseEventsQueryInput as aA, type PalbaseEventsResult as aB, type PalbaseExtension as aC, type PalbaseFileObject as aD, type PalbaseFlag as aE, type PalbaseFlagContext as aF, type PalbaseFlagSource as aG, type PalbaseFlagValue as aH, type PalbaseFlagVariant as aI, type PalbaseFlagsClient as aJ, type PalbaseFlagsServiceClient as aK, type PalbaseFunctionsClient as aL, type PalbaseFunnelQueryInput as aM, type PalbaseFunnelResult as aN, type PalbaseIdentifyTraits as aO, type PalbaseInboxClient as aP, type PalbaseInboxListOptions as aQ, type PalbaseInboxListResult as aR, type PalbaseInboxMessage as aS, type PalbaseInboxSendParams as aT, type PalbaseInboxSendResponse as aU, type PalbaseInitialLink as aV, type PalbaseInvokeOptions as aW, type PalbaseLink as aX, type PalbaseLinkAnalytics as aY, type PalbaseLinkDetails as aZ, type PalbaseLinksClient as a_, type PalbaseAttestAndroidResult as aa, type PalbaseAttestiOSParams as ab, type PalbaseAttestiOSResult as ac, type PalbaseAuthAdminClient as ad, type PalbaseAuthClient as ae, type PalbaseBatchOverrideOperation as af, type PalbaseBatchSetOverridesResult as ag, type PalbaseBindDeviceParams as ah, type PalbaseBucketClient as ai, type PalbaseClearAllOverridesResult as aj, type PalbaseClearOverrideResult as ak, type PalbaseCohortQueryInput as al, type PalbaseCohortResult as am, type PalbaseCollectionRef as an, type PalbaseCountQueryInput as ao, type PalbaseCountResult as ap, type PalbaseCreateLinkParams as aq, type PalbaseDeviceInfo as ar, type PalbaseDeviceTokenView as as, type PalbaseDocsClient as at, type PalbaseDocumentRef as au, type PalbaseDocumentSnapshot as av, type PalbaseEmailClient as aw, type PalbaseEmailSendParams as ax, type PalbaseEmailSendResponse as ay, type PalbaseEventNamesResult as az, type TxPlanResponse as b, type TxNow as b$, type PalbaseListLinksResult as b0, type PalbaseListOptions as b1, type PalbaseMatchParams as b2, type PalbaseMultiChannelResponse as b3, type PalbaseNotificationsClient as b4, type PalbaseOverviewResult as b5, type PalbasePreferences as b6, type PalbasePreferencesClient as b7, type PalbasePushClient as b8, type PalbasePushSendParams as b9, type PolicyCommand as bA, type PolicyDef as bB, type PolicyExprCtx as bC, PolicyExprRef as bD, type PolicyMode as bE, type PolicyOperand as bF, type RawConstraintDef as bG, Realtime as bH, type Ref as bI, type RequestStore as bJ, type RowShape as bK, Secrets as bL, type SecretsService as bM, SerializationFailure as bN, type SetShape as bO, type SetValue as bP, type ShutdownRunner as bQ, type SqlFragment as bR, Storage as bS, TABLE_META as bT, type TableDef as bU, type TableHandle as bV, type TableInput as bW, TooManyRequests as bX, type TxColumnExpr as bY, type TxInsertShape as bZ, type TxInsertValue as b_, type PalbasePushSendResponse as ba, type PalbaseQrCodeOptions as bb, type PalbaseQuerySnapshot as bc, type PalbaseRealtimeClient as bd, type PalbaseRegisterDeviceParams as be, type PalbaseRetentionQueryInput as bf, type PalbaseRetentionResult as bg, type PalbaseSession as bh, type PalbaseSetOverrideResult as bi, type PalbaseSetOverridesResult as bj, type PalbaseSignedUrlResponse as bk, type PalbaseSmsClient as bl, type PalbaseSmsSendParams as bm, type PalbaseSmsSendResponse as bn, type PalbaseStorageClient as bo, type PalbaseTransformOptions as bp, type PalbaseUpdateLinkParams as bq, type PalbaseUploadOptions as br, type PalbaseUser as bs, type PalbaseUserDetailResult as bt, type PalbaseUsersQueryInput as bu, type PalbaseUsersResult as bv, type PalbaseVerifyRequestSignatureParams as bw, type PalbaseWhereOperator as bx, type PolicyBinOp as by, PolicyBuilder as bz, type RuntimeServices as c, withRetry as c$, type TxPlan as c0, TxPlanError as c1, type TxPlanHandle as c2, type TxPlanOpResult as c3, type TxPlanRejection as c4, TxRefError as c5, type TxRow as c6, type TxRows as c7, type TxSelectOptions as c8, type TxSetShape as c9, defineSchema as cA, defineTable as cB, enumType as cC, exprCtx as cD, inc as cE, increment as cF, index as cG, installationRef as cH, integer as cI, isPalbaseExtension as cJ, isRetryable as cK, jsonb as cL, makeTypedDB as cM, now as cN, numeric as cO, onShutdown as cP, onStart as cQ, openai as cR, ownedByUser as cS, policy as cT, raw as cU, sqlFragment as cV, text as cW, timestamp as cX, userRef as cY, uuid as cZ, vector as c_, type TxSetValue as ca, type TxTable as cb, type TxTables as cc, type TxWhere as cd, type TxWireExpr as ce, type TxWireGuard as cf, type TxWireOp as cg, type TxWireRef as ch, type TxWireValue as ci, type TypedDB as cj, type TypedTable as ck, type TypedTx as cl, Unauthorized as cm, UniqueViolation as cn, type User as co, type VerifiedDevice as cp, __getRuntime as cq, __resetLifecycleHooks as cr, __runStartHooks as cs, __setRuntime as ct, bigint as cu, boolean as cv, col as cw, dec as cx, decrement as cy, defineMiddleware as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, Auth as g, type AuthConfig as h, Cache as i, type ClientInfo as j, type ColRef as k, ColumnBuilder as l, type ColumnDef as m, type ColumnMap as n, type ColumnType as o, Conflict as p, Database as q, DeadlockDetected as r, Documents as s, type EmbeddingModelRef as t, type EnvSchemas as u, type EnvServiceDatabase as v, type EnvTables as w, type EnvTypedDatabase as x, type EnvTypedTable as y, type ErrorDef as z };
@@ -39,6 +39,20 @@ interface User {
39
39
  */
40
40
  emailVerified: boolean;
41
41
  role: string;
42
+ /**
43
+ * The caller's APPLICATION roles, as assigned in `auth.user_roles`.
44
+ *
45
+ * Not to be confused with {@link User.role}, which is the DATABASE role RLS
46
+ * reads and is the literal string "authenticated" for every signed-in user.
47
+ * These are the names a stack declares (`palbase roles`) and an operator
48
+ * assigns; `auth: { role }` gates on the same set.
49
+ *
50
+ * Resolved per request from the table, in the transaction the handler is
51
+ * about to use — never from a token claim, so a role revoked a second ago is
52
+ * already gone here. An empty array for a caller who holds none, never null:
53
+ * `user.roles.includes("agent")` needs no guard.
54
+ */
55
+ roles: string[];
42
56
  metadata: Record<string, unknown>;
43
57
  /**
44
58
  * Reserved, server-owned verified device claim. `null` on an authenticated
@@ -2080,6 +2094,37 @@ interface PalbaseAuthClient {
2080
2094
  dispose(): void;
2081
2095
  };
2082
2096
  }
2097
+ /**
2098
+ * The `Auth` singleton a backend handler reaches — the ROLE-ASSIGNMENT surface,
2099
+ * and nothing else.
2100
+ *
2101
+ * Deliberately not {@link PalbaseAuthClient}: that one is a person acting on
2102
+ * their own account (sign-in, MFA, device attestation) and it belongs to the
2103
+ * client SDK. What a server needs is the operator verb — "make this user an
2104
+ * agent" — because the promotion usually happens inside the tenant's own
2105
+ * product, in a handler a supervisor triggers.
2106
+ *
2107
+ * These calls carry the SERVICE-ROLE credential: the routes behind them refuse
2108
+ * anon and `authenticated` alike (FR-013), which is what stops an end user from
2109
+ * granting themselves the permission the rest of the feature gates on.
2110
+ *
2111
+ * Unlike the other clients here these THROW rather than envelope, because two
2112
+ * of the three answer `void` — a refusal that came back as a value would be
2113
+ * indistinguishable from a write that happened. See `clients/auth.ts`.
2114
+ */
2115
+ interface PalbaseAuthAdminClient {
2116
+ /**
2117
+ * Give a user a role. Idempotent: assigning one they already hold is not an
2118
+ * error and leaves one row. Throws `RoleNotDefined` when the stack declares
2119
+ * no role by that name.
2120
+ */
2121
+ assignRole(userId: string, role: string): Promise<void>;
2122
+ /** Take a role away. Revoking one they do not hold is not an error. */
2123
+ revokeRole(userId: string, role: string): Promise<void>;
2124
+ /** What that user holds right now. `[]` for a user with no roles — a FAILED
2125
+ * read throws rather than answering the same thing. */
2126
+ rolesOf(userId: string): Promise<string[]>;
2127
+ }
2083
2128
  /**
2084
2129
  * Bucket-level file operations available via `ctx.storage.bucket(name)`.
2085
2130
  * `getPublicUrl` is synchronous (no network call — constructs URL locally).
@@ -2539,11 +2584,14 @@ interface PalbaseLinksClient {
2539
2584
  * Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
2540
2585
  * cannot hold a subscription socket — `subscribe()` lives on the client SDK).
2541
2586
  *
2542
- * EXCLUDED on purpose: Functions, Links, Analytics, Auth. They are not
2543
- * exposed as backend handler singletons (auth lives on the client SDK; the rest
2544
- * are out of scope for backend endpoints). */
2587
+ * EXCLUDED on purpose: Functions, Links, Analytics. They are not exposed as
2588
+ * backend handler singletons out of scope for backend endpoints. `Auth` is
2589
+ * here in its ROLE-ASSIGNMENT shape only: signing in is the client SDK's job,
2590
+ * but granting a role is an operator verb the tenant's own handler needs
2591
+ * (FR-009). */
2545
2592
  interface RuntimeServices {
2546
2593
  Database: DBClient;
2594
+ Auth: PalbaseAuthAdminClient;
2547
2595
  Secrets: SecretsService;
2548
2596
  Documents: PalbaseDocsClient;
2549
2597
  Storage: PalbaseStorageClient;
@@ -2753,6 +2801,20 @@ declare const Cache: CacheClient;
2753
2801
  * the STACK holds, because no route returns a platform secret's value at all.
2754
2802
  */
2755
2803
  declare const Secrets: SecretsService;
2804
+ /**
2805
+ * Role assignment, as an operator — `Auth.assignRole(userId, "agent")`.
2806
+ *
2807
+ * The half of auth a SERVER owns. Signing in, MFA and device attestation are a
2808
+ * person acting on their own account and live on the client SDK; granting a
2809
+ * role is the tenant's product doing something to somebody else, which is
2810
+ * exactly what a handler is for. It writes with the service-role credential,
2811
+ * because an end user who could write their own assignment would make every
2812
+ * permission underneath it meaningless.
2813
+ *
2814
+ * The write is visible to the very next request: authority is read from the
2815
+ * table on each call, never carried on a token.
2816
+ */
2817
+ declare const Auth: PalbaseAuthAdminClient;
2756
2818
  /** Structured logger. */
2757
2819
  declare const Log: Logger;
2758
2820
  /** Push / email / SMS / in-app notifications. */
@@ -5098,4 +5160,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
5098
5160
  */
5099
5161
  type AuthSpec = boolean | Partial<AuthConfig>;
5100
5162
 
5101
- export { Notifications as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorThrowers as F, type FileContext as G, HttpError as H, Flags as I, Forbidden as J, type HttpMethod as K, IndexBuilder as L, type IndexDef as M, type InsertShape as N, type LifecycleHook as O, type PalbaseResult as P, Log as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, type Logger as U, type Materialized as V, type Middleware as W, type MiddlewareContext as X, type MiddlewareHandler as Y, NotFound as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListOptions as a$, type OnDeleteAction as a0, PALBASE_EXTENSIONS as a1, type PBRequest as a2, PalError as a3, type PalbaseAnalyticsClient as a4, type PalbaseAnalyticsManagementNamespace as a5, type PalbaseAnalyticsProperties as a6, type PalbaseAnalyticsQueryNamespace as a7, type PalbaseAttestAndroidParams as a8, type PalbaseAttestAndroidResult as a9, type PalbaseExtension as aA, type PalbaseFileObject as aB, type PalbaseFlag as aC, type PalbaseFlagContext as aD, type PalbaseFlagSource as aE, type PalbaseFlagValue as aF, type PalbaseFlagVariant as aG, type PalbaseFlagsClient as aH, type PalbaseFlagsServiceClient as aI, type PalbaseFunctionsClient as aJ, type PalbaseFunnelQueryInput as aK, type PalbaseFunnelResult as aL, type PalbaseIdentifyTraits as aM, type PalbaseInboxClient as aN, type PalbaseInboxListOptions as aO, type PalbaseInboxListResult as aP, type PalbaseInboxMessage as aQ, type PalbaseInboxSendParams as aR, type PalbaseInboxSendResponse as aS, type PalbaseInitialLink as aT, type PalbaseInvokeOptions as aU, type PalbaseLink as aV, type PalbaseLinkAnalytics as aW, type PalbaseLinkDetails as aX, type PalbaseLinksClient as aY, type PalbaseListLinksOptions as aZ, type PalbaseListLinksResult as a_, type PalbaseAttestiOSParams as aa, type PalbaseAttestiOSResult as ab, type PalbaseAuthClient as ac, type PalbaseBatchOverrideOperation as ad, type PalbaseBatchSetOverridesResult as ae, type PalbaseBindDeviceParams as af, type PalbaseBucketClient as ag, type PalbaseClearAllOverridesResult as ah, type PalbaseClearOverrideResult as ai, type PalbaseCohortQueryInput as aj, type PalbaseCohortResult as ak, type PalbaseCollectionRef as al, type PalbaseCountQueryInput as am, type PalbaseCountResult as an, type PalbaseCreateLinkParams as ao, type PalbaseDeviceInfo as ap, type PalbaseDeviceTokenView as aq, type PalbaseDocsClient as ar, type PalbaseDocumentRef as as, type PalbaseDocumentSnapshot as at, type PalbaseEmailClient as au, type PalbaseEmailSendParams as av, type PalbaseEmailSendResponse as aw, type PalbaseEventNamesResult as ax, type PalbaseEventsQueryInput as ay, type PalbaseEventsResult as az, type TxPlanResponse as b, TxPlanError as b$, type PalbaseMatchParams as b0, type PalbaseMultiChannelResponse as b1, type PalbaseNotificationsClient as b2, type PalbaseOverviewResult as b3, type PalbasePreferences as b4, type PalbasePreferencesClient as b5, type PalbasePushClient as b6, type PalbasePushSendParams as b7, type PalbasePushSendResponse as b8, type PalbaseQrCodeOptions as b9, type PolicyExprCtx as bA, PolicyExprRef as bB, type PolicyMode as bC, type PolicyOperand as bD, type RawConstraintDef as bE, Realtime as bF, type Ref as bG, type RequestStore as bH, type RowShape as bI, Secrets as bJ, type SecretsService as bK, SerializationFailure as bL, type SetShape as bM, type SetValue as bN, type ShutdownRunner as bO, type SqlFragment as bP, Storage as bQ, TABLE_META as bR, type TableDef as bS, type TableHandle as bT, type TableInput as bU, TooManyRequests as bV, type TxColumnExpr as bW, type TxInsertShape as bX, type TxInsertValue as bY, type TxNow as bZ, type TxPlan as b_, type PalbaseQuerySnapshot as ba, type PalbaseRealtimeClient as bb, type PalbaseRegisterDeviceParams as bc, type PalbaseRetentionQueryInput as bd, type PalbaseRetentionResult as be, type PalbaseSession as bf, type PalbaseSetOverrideResult as bg, type PalbaseSetOverridesResult as bh, type PalbaseSignedUrlResponse as bi, type PalbaseSmsClient as bj, type PalbaseSmsSendParams as bk, type PalbaseSmsSendResponse as bl, type PalbaseStorageClient as bm, type PalbaseTransformOptions as bn, type PalbaseUpdateLinkParams as bo, type PalbaseUploadOptions as bp, type PalbaseUser as bq, type PalbaseUserDetailResult as br, type PalbaseUsersQueryInput as bs, type PalbaseUsersResult as bt, type PalbaseVerifyRequestSignatureParams as bu, type PalbaseWhereOperator as bv, type PolicyBinOp as bw, PolicyBuilder as bx, type PolicyCommand as by, type PolicyDef as bz, type RuntimeServices as c, type TxPlanHandle as c0, type TxPlanOpResult as c1, type TxPlanRejection as c2, TxRefError as c3, type TxRow as c4, type TxRows as c5, type TxSelectOptions as c6, type TxSetShape as c7, type TxSetValue as c8, type TxTable as c9, enumType as cA, exprCtx as cB, inc as cC, increment as cD, index as cE, installationRef as cF, integer as cG, isPalbaseExtension as cH, isRetryable as cI, jsonb as cJ, makeTypedDB as cK, now as cL, numeric as cM, onShutdown as cN, onStart as cO, openai as cP, ownedByUser as cQ, policy as cR, raw as cS, sqlFragment as cT, text as cU, timestamp as cV, userRef as cW, uuid as cX, vector as cY, withRetry as cZ, type TxTables as ca, type TxWhere as cb, type TxWireExpr as cc, type TxWireGuard as cd, type TxWireOp as ce, type TxWireRef as cf, type TxWireValue as cg, type TypedDB as ch, type TypedTable as ci, type TypedTx as cj, Unauthorized as ck, UniqueViolation as cl, type User as cm, type VerifiedDevice as cn, __getRuntime as co, __resetLifecycleHooks as cp, __runStartHooks as cq, __setRuntime as cr, bigint as cs, boolean as ct, col as cu, dec as cv, decrement as cw, defineMiddleware as cx, defineSchema as cy, defineTable as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, type AuthConfig as g, Cache as h, type ClientInfo as i, type ColRef as j, ColumnBuilder as k, type ColumnDef as l, type ColumnMap as m, type ColumnType as n, Conflict as o, Database as p, DeadlockDetected as q, Documents as r, type EmbeddingModelRef as s, type EnvSchemas as t, type EnvServiceDatabase as u, type EnvTables as v, type EnvTypedDatabase as w, type EnvTypedTable as x, type ErrorDef as y, type ErrorMap as z };
5163
+ export { NotFound as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorMap as F, type ErrorThrowers as G, HttpError as H, type FileContext as I, Flags as J, Forbidden as K, type HttpMethod as L, IndexBuilder as M, type IndexDef as N, type InsertShape as O, type PalbaseResult as P, type LifecycleHook as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, Log as U, type Logger as V, type Materialized as W, type Middleware as X, type MiddlewareContext as Y, type MiddlewareHandler as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListLinksOptions as a$, Notifications as a0, type OnDeleteAction as a1, PALBASE_EXTENSIONS as a2, type PBRequest as a3, PalError as a4, type PalbaseAnalyticsClient as a5, type PalbaseAnalyticsManagementNamespace as a6, type PalbaseAnalyticsProperties as a7, type PalbaseAnalyticsQueryNamespace as a8, type PalbaseAttestAndroidParams as a9, type PalbaseEventsQueryInput as aA, type PalbaseEventsResult as aB, type PalbaseExtension as aC, type PalbaseFileObject as aD, type PalbaseFlag as aE, type PalbaseFlagContext as aF, type PalbaseFlagSource as aG, type PalbaseFlagValue as aH, type PalbaseFlagVariant as aI, type PalbaseFlagsClient as aJ, type PalbaseFlagsServiceClient as aK, type PalbaseFunctionsClient as aL, type PalbaseFunnelQueryInput as aM, type PalbaseFunnelResult as aN, type PalbaseIdentifyTraits as aO, type PalbaseInboxClient as aP, type PalbaseInboxListOptions as aQ, type PalbaseInboxListResult as aR, type PalbaseInboxMessage as aS, type PalbaseInboxSendParams as aT, type PalbaseInboxSendResponse as aU, type PalbaseInitialLink as aV, type PalbaseInvokeOptions as aW, type PalbaseLink as aX, type PalbaseLinkAnalytics as aY, type PalbaseLinkDetails as aZ, type PalbaseLinksClient as a_, type PalbaseAttestAndroidResult as aa, type PalbaseAttestiOSParams as ab, type PalbaseAttestiOSResult as ac, type PalbaseAuthAdminClient as ad, type PalbaseAuthClient as ae, type PalbaseBatchOverrideOperation as af, type PalbaseBatchSetOverridesResult as ag, type PalbaseBindDeviceParams as ah, type PalbaseBucketClient as ai, type PalbaseClearAllOverridesResult as aj, type PalbaseClearOverrideResult as ak, type PalbaseCohortQueryInput as al, type PalbaseCohortResult as am, type PalbaseCollectionRef as an, type PalbaseCountQueryInput as ao, type PalbaseCountResult as ap, type PalbaseCreateLinkParams as aq, type PalbaseDeviceInfo as ar, type PalbaseDeviceTokenView as as, type PalbaseDocsClient as at, type PalbaseDocumentRef as au, type PalbaseDocumentSnapshot as av, type PalbaseEmailClient as aw, type PalbaseEmailSendParams as ax, type PalbaseEmailSendResponse as ay, type PalbaseEventNamesResult as az, type TxPlanResponse as b, type TxNow as b$, type PalbaseListLinksResult as b0, type PalbaseListOptions as b1, type PalbaseMatchParams as b2, type PalbaseMultiChannelResponse as b3, type PalbaseNotificationsClient as b4, type PalbaseOverviewResult as b5, type PalbasePreferences as b6, type PalbasePreferencesClient as b7, type PalbasePushClient as b8, type PalbasePushSendParams as b9, type PolicyCommand as bA, type PolicyDef as bB, type PolicyExprCtx as bC, PolicyExprRef as bD, type PolicyMode as bE, type PolicyOperand as bF, type RawConstraintDef as bG, Realtime as bH, type Ref as bI, type RequestStore as bJ, type RowShape as bK, Secrets as bL, type SecretsService as bM, SerializationFailure as bN, type SetShape as bO, type SetValue as bP, type ShutdownRunner as bQ, type SqlFragment as bR, Storage as bS, TABLE_META as bT, type TableDef as bU, type TableHandle as bV, type TableInput as bW, TooManyRequests as bX, type TxColumnExpr as bY, type TxInsertShape as bZ, type TxInsertValue as b_, type PalbasePushSendResponse as ba, type PalbaseQrCodeOptions as bb, type PalbaseQuerySnapshot as bc, type PalbaseRealtimeClient as bd, type PalbaseRegisterDeviceParams as be, type PalbaseRetentionQueryInput as bf, type PalbaseRetentionResult as bg, type PalbaseSession as bh, type PalbaseSetOverrideResult as bi, type PalbaseSetOverridesResult as bj, type PalbaseSignedUrlResponse as bk, type PalbaseSmsClient as bl, type PalbaseSmsSendParams as bm, type PalbaseSmsSendResponse as bn, type PalbaseStorageClient as bo, type PalbaseTransformOptions as bp, type PalbaseUpdateLinkParams as bq, type PalbaseUploadOptions as br, type PalbaseUser as bs, type PalbaseUserDetailResult as bt, type PalbaseUsersQueryInput as bu, type PalbaseUsersResult as bv, type PalbaseVerifyRequestSignatureParams as bw, type PalbaseWhereOperator as bx, type PolicyBinOp as by, PolicyBuilder as bz, type RuntimeServices as c, withRetry as c$, type TxPlan as c0, TxPlanError as c1, type TxPlanHandle as c2, type TxPlanOpResult as c3, type TxPlanRejection as c4, TxRefError as c5, type TxRow as c6, type TxRows as c7, type TxSelectOptions as c8, type TxSetShape as c9, defineSchema as cA, defineTable as cB, enumType as cC, exprCtx as cD, inc as cE, increment as cF, index as cG, installationRef as cH, integer as cI, isPalbaseExtension as cJ, isRetryable as cK, jsonb as cL, makeTypedDB as cM, now as cN, numeric as cO, onShutdown as cP, onStart as cQ, openai as cR, ownedByUser as cS, policy as cT, raw as cU, sqlFragment as cV, text as cW, timestamp as cX, userRef as cY, uuid as cZ, vector as c_, type TxSetValue as ca, type TxTable as cb, type TxTables as cc, type TxWhere as cd, type TxWireExpr as ce, type TxWireGuard as cf, type TxWireOp as cg, type TxWireRef as ch, type TxWireValue as ci, type TypedDB as cj, type TypedTable as ck, type TypedTx as cl, Unauthorized as cm, UniqueViolation as cn, type User as co, type VerifiedDevice as cp, __getRuntime as cq, __resetLifecycleHooks as cr, __runStartHooks as cs, __setRuntime as ct, bigint as cu, boolean as cv, col as cw, dec as cx, decrement as cy, defineMiddleware as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, Auth as g, type AuthConfig as h, Cache as i, type ClientInfo as j, type ColRef as k, ColumnBuilder as l, type ColumnDef as m, type ColumnMap as n, type ColumnType as o, Conflict as p, Database as q, DeadlockDetected as r, Documents as s, type EmbeddingModelRef as t, type EnvSchemas as u, type EnvServiceDatabase as v, type EnvTables as w, type EnvTypedDatabase as x, type EnvTypedTable as y, type ErrorDef as z };
@@ -1,6 +1,6 @@
1
- import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-ChvoVczS.cjs';
1
+ import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-DtCgaZAg.cjs';
2
2
  import { T as Token } from './module-Dl1KFVtc.cjs';
3
- import { R as RouteMeta } from './registry-B2KfKWv1.cjs';
3
+ import { R as RouteMeta } from './registry-CEYLH-Iz.cjs';
4
4
 
5
5
  /**
6
6
  * engine/config.ts — settings from the environment, and the gate that refuses
@@ -998,7 +998,7 @@ interface RuntimeHooks {
998
998
  __requestALS: typeof __requestALS;
999
999
  }
1000
1000
  /** The module singletons the engine injects, minus the two it owns itself. */
1001
- type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
1001
+ type ModuleClients = Partial<Pick<RuntimeServices, "Auth" | "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
1002
1002
  interface CreateAppOptions {
1003
1003
  /**
1004
1004
  * Vault'tan TEK secret okuma (FR-025): sorgu-anı embedding'in anahtarı
@@ -1,6 +1,6 @@
1
- import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-BOe82fsK.js';
1
+ import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-8qy3kIuA.js';
2
2
  import { T as Token } from './module-Dl1KFVtc.js';
3
- import { R as RouteMeta } from './registry-DaqHsOq8.js';
3
+ import { R as RouteMeta } from './registry-BGJ-Al6F.js';
4
4
 
5
5
  /**
6
6
  * engine/config.ts — settings from the environment, and the gate that refuses
@@ -998,7 +998,7 @@ interface RuntimeHooks {
998
998
  __requestALS: typeof __requestALS;
999
999
  }
1000
1000
  /** The module singletons the engine injects, minus the two it owns itself. */
1001
- type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
1001
+ type ModuleClients = Partial<Pick<RuntimeServices, "Auth" | "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
1002
1002
  interface CreateAppOptions {
1003
1003
  /**
1004
1004
  * Vault'tan TEK secret okuma (FR-025): sorgu-anı embedding'in anahtarı
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
+ Auth: () => Auth,
24
25
  BadRequest: () => BadRequest,
25
26
  Body: () => Body,
26
27
  Cache: () => Cache,
@@ -71,6 +72,7 @@ __export(src_exports, {
71
72
  Realtime: () => Realtime,
72
73
  Req: () => Req,
73
74
  RequestId: () => RequestId,
75
+ RoleNotDefined: () => RoleNotDefined,
74
76
  Room: () => Room,
75
77
  Secrets: () => Secrets,
76
78
  SerializationFailure: () => SerializationFailure,
@@ -1520,6 +1522,7 @@ var Storage = Object.assign({
1520
1522
  });
1521
1523
  var Cache = makeServiceProxy("Cache");
1522
1524
  var Secrets = makeServiceProxy("Secrets");
1525
+ var Auth = makeServiceProxy("Auth");
1523
1526
  var Log = makeServiceProxy("Log");
1524
1527
  var Notifications = makeServiceProxy("Notifications");
1525
1528
  var rawFlags = makeServiceProxy("Flags");
@@ -1647,6 +1650,48 @@ function makeHttpClient(cfg) {
1647
1650
  }
1648
1651
  __name(makeHttpClient, "makeHttpClient");
1649
1652
 
1653
+ // src/clients/auth.ts
1654
+ var RoleNotDefined = class extends Error {
1655
+ static {
1656
+ __name(this, "RoleNotDefined");
1657
+ }
1658
+ role;
1659
+ constructor(role, message) {
1660
+ super(message ?? `No role named "${role}" is defined for this stack`);
1661
+ this.name = "RoleNotDefined";
1662
+ this.role = role;
1663
+ }
1664
+ };
1665
+ function refuse(error, role) {
1666
+ if (error.code === "role_not_defined") throw new RoleNotDefined(role, error.message);
1667
+ if (error instanceof PalbaseModuleError) throw error;
1668
+ throw new PalbaseModuleError(error.code ?? "unknown_error", error.message ?? "request failed", 0);
1669
+ }
1670
+ __name(refuse, "refuse");
1671
+ function rolesPath(userId, role) {
1672
+ const base = `/admin/users/${encodeURIComponent(userId)}/roles`;
1673
+ return role === void 0 ? base : `${base}/${encodeURIComponent(role)}`;
1674
+ }
1675
+ __name(rolesPath, "rolesPath");
1676
+ function buildAuthClient(http) {
1677
+ return {
1678
+ async assignRole(userId, role) {
1679
+ const { error } = await http.request("PUT", rolesPath(userId, role));
1680
+ if (error) refuse(error, role);
1681
+ },
1682
+ async revokeRole(userId, role) {
1683
+ const { error } = await http.request("DELETE", rolesPath(userId, role));
1684
+ if (error) refuse(error, role);
1685
+ },
1686
+ async rolesOf(userId) {
1687
+ const { data, error } = await http.request("GET", rolesPath(userId));
1688
+ if (error) refuse(error, "");
1689
+ return data?.roles ?? [];
1690
+ }
1691
+ };
1692
+ }
1693
+ __name(buildAuthClient, "buildAuthClient");
1694
+
1650
1695
  // src/clients/documents.ts
1651
1696
  var SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
1652
1697
  function validateSegment(segment, label) {
@@ -2631,6 +2676,10 @@ function buildModuleClients(cfg) {
2631
2676
  fetchImpl: cfg.fetchImpl
2632
2677
  });
2633
2678
  return {
2679
+ // The ROLE half of auth only (`clients/auth.ts` says why the rest is not
2680
+ // here). It rides the same service-role transport, which is exactly the
2681
+ // credential the assignment routes demand.
2682
+ Auth: buildAuthClient(http),
2634
2683
  Documents: buildDocumentsClient(http),
2635
2684
  Storage: buildStorageClient(http, cfg.publicOrigin),
2636
2685
  Notifications: buildNotificationsClient(http),
@@ -3623,8 +3672,10 @@ function baseTsType(def) {
3623
3672
  if (values.length === 0) return "string";
3624
3673
  return values.map((v) => JSON.stringify(v)).join(" | ");
3625
3674
  }
3626
- default:
3627
- return "unknown";
3675
+ default: {
3676
+ const unhandled = def.type;
3677
+ throw new Error(`env-gen: "${String(unhandled)}" kolon tipinin TypeScript kar\u015F\u0131l\u0131\u011F\u0131 bildirilmemi\u015F. baseTsType'a bir case ekleyin \u2014 sessizce \`unknown\` d\xF6nmek o kolonu her kural\u0131n d\u0131\u015F\u0131na \xE7\u0131kar\u0131r.`);
3678
+ }
3628
3679
  }
3629
3680
  }
3630
3681
  __name(baseTsType, "baseTsType");
@@ -5280,6 +5331,7 @@ __name(getJobConfig, "getJobConfig");
5280
5331
  var import_zod2 = require("zod");
5281
5332
  // Annotate the CommonJS export names for ESM import in node:
5282
5333
  0 && (module.exports = {
5334
+ Auth,
5283
5335
  BadRequest,
5284
5336
  Body,
5285
5337
  Cache,
@@ -5330,6 +5382,7 @@ var import_zod2 = require("zod");
5330
5382
  Realtime,
5331
5383
  Req,
5332
5384
  RequestId,
5385
+ RoleNotDefined,
5333
5386
  Room,
5334
5387
  Secrets,
5335
5388
  SerializationFailure,