@palbase/backend 28.0.0 → 30.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/bin/palbase-backend.cjs +166 -12
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +3 -3
  4. package/dist/{chunk-RVP6BTEZ.js → chunk-5J5W75A6.js} +15 -4
  5. package/dist/chunk-5J5W75A6.js.map +1 -0
  6. package/dist/{chunk-IVZERLTM.js → chunk-ENZ2RFFJ.js} +2 -2
  7. package/dist/{chunk-SNDXY565.js → chunk-SG4UTNOP.js} +5 -2
  8. package/dist/chunk-SG4UTNOP.js.map +1 -0
  9. package/dist/{chunk-75YROPRZ.js → chunk-VN7NMDUH.js} +166 -15
  10. package/dist/chunk-VN7NMDUH.js.map +1 -0
  11. package/dist/db/index.cjs +4 -1
  12. package/dist/db/index.cjs.map +1 -1
  13. package/dist/db/index.d.cts +1 -1
  14. package/dist/db/index.d.ts +1 -1
  15. package/dist/db/index.js +2 -2
  16. package/dist/engine/index.cjs +166 -12
  17. package/dist/engine/index.cjs.map +1 -1
  18. package/dist/engine/index.d.cts +3 -3
  19. package/dist/engine/index.d.ts +3 -3
  20. package/dist/engine/index.js +3 -3
  21. package/dist/{index-dTTLlHIn.d.ts → index-8qy3kIuA.d.ts} +228 -12
  22. package/dist/{index-DtISj9QX.d.cts → index-DtCgaZAg.d.cts} +228 -12
  23. package/dist/{index-9C3JHxg-.d.cts → index-Zi7MptvP.d.cts} +30 -8
  24. package/dist/{index-BbvOoZFr.d.ts → index-b-Q3l7W5.d.ts} +30 -8
  25. package/dist/index.cjs +66 -3
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +51 -11
  28. package/dist/index.d.ts +51 -11
  29. package/dist/index.js +52 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/openapi/index.d.cts +2 -2
  32. package/dist/openapi/index.d.ts +2 -2
  33. package/dist/{registry-JQNIX-eA.d.ts → registry-BGJ-Al6F.d.ts} +1 -1
  34. package/dist/{registry-qIPM5BQe.d.cts → registry-CEYLH-Iz.d.cts} +1 -1
  35. package/dist/test/index.cjs +56 -0
  36. package/dist/test/index.cjs.map +1 -1
  37. package/dist/test/index.d.cts +1 -1
  38. package/dist/test/index.d.ts +1 -1
  39. package/dist/test/index.js +56 -0
  40. package/dist/test/index.js.map +1 -1
  41. package/docs/README.md +1 -1
  42. package/docs/database.md +49 -0
  43. package/docs/llms-full.txt +50 -1
  44. package/package.json +1 -1
  45. package/template/package.json +1 -1
  46. package/dist/chunk-75YROPRZ.js.map +0 -1
  47. package/dist/chunk-RVP6BTEZ.js.map +0 -1
  48. package/dist/chunk-SNDXY565.js.map +0 -1
  49. /package/dist/{chunk-IVZERLTM.js.map → chunk-ENZ2RFFJ.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { P as PalbaseResult, e as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-DtISj9QX.cjs';
2
- export { f as AnyColumn, g as AuthConfig, B as BadRequest, h as Cache, C as CacheClient, i as ClientInfo, j as ColRef, k as ColumnBuilder, l as ColumnDef, m as ColumnMap, n as ColumnType, o as Conflict, D as DBClient, a as DBOps, p as Database, q as DeadlockDetected, r as Documents, E as EXTENSION_DEPENDENCIES, s as EmbeddingModelRef, t as EnvSchemas, u as EnvServiceDatabase, v as EnvTables, w as EnvTypedDatabase, x as EnvTypedTable, y as ErrorDef, z as ErrorMap, F as ErrorThrowers, G as FileContext, I as Flags, J as Forbidden, K as HttpMethod, L as IndexBuilder, M as IndexDef, N as InsertShape, O as LifecycleHook, Q as Log, U as Logger, V as Materialized, W as Middleware, X as MiddlewareContext, Y as MiddlewareHandler, Z as NotFound, $ as Notifications, a0 as OnDeleteAction, a1 as PALBASE_EXTENSIONS, a2 as PBRequest, a3 as PalError, a4 as PalbaseAnalyticsClient, a5 as PalbaseAnalyticsManagementNamespace, a6 as PalbaseAnalyticsProperties, a7 as PalbaseAnalyticsQueryNamespace, a8 as PalbaseAttestAndroidParams, a9 as PalbaseAttestAndroidResult, aa as PalbaseAttestiOSParams, ab as PalbaseAttestiOSResult, ac as PalbaseAuthClient, ad as PalbaseBatchOverrideOperation, ae as PalbaseBatchSetOverridesResult, af as PalbaseBindDeviceParams, ag as PalbaseBucketClient, ah as PalbaseClearAllOverridesResult, ai as PalbaseClearOverrideResult, aj as PalbaseCohortQueryInput, ak as PalbaseCohortResult, al as PalbaseCollectionRef, am as PalbaseCountQueryInput, an as PalbaseCountResult, ao as PalbaseCreateLinkParams, ap as PalbaseDeviceInfo, aq as PalbaseDeviceTokenView, ar as PalbaseDocsClient, as as PalbaseDocumentRef, at as PalbaseDocumentSnapshot, au as PalbaseEmailClient, av as PalbaseEmailSendParams, aw as PalbaseEmailSendResponse, ax as PalbaseEventNamesResult, ay as PalbaseEventsQueryInput, az as PalbaseEventsResult, aA as PalbaseExtension, aB as PalbaseFileObject, aC as PalbaseFlag, aD as PalbaseFlagContext, aE as PalbaseFlagSource, aF as PalbaseFlagValue, aG as PalbaseFlagVariant, aH as PalbaseFlagsClient, aI as PalbaseFlagsServiceClient, aJ as PalbaseFunctionsClient, aK as PalbaseFunnelQueryInput, aL as PalbaseFunnelResult, aM as PalbaseIdentifyTraits, aN as PalbaseInboxClient, aO as PalbaseInboxListOptions, aP as PalbaseInboxListResult, aQ as PalbaseInboxMessage, aR as PalbaseInboxSendParams, aS as PalbaseInboxSendResponse, aT as PalbaseInitialLink, aU as PalbaseInvokeOptions, aV as PalbaseLink, aW as PalbaseLinkAnalytics, aX as PalbaseLinkDetails, aY as PalbaseLinksClient, aZ as PalbaseListLinksOptions, a_ as PalbaseListLinksResult, a$ as PalbaseListOptions, b0 as PalbaseMatchParams, b1 as PalbaseMultiChannelResponse, b2 as PalbaseNotificationsClient, b3 as PalbaseOverviewResult, b4 as PalbasePreferences, b5 as PalbasePreferencesClient, b6 as PalbasePushClient, b7 as PalbasePushSendParams, b8 as PalbasePushSendResponse, b9 as PalbaseQrCodeOptions, ba as PalbaseQuerySnapshot, bb as PalbaseRealtimeClient, bc as PalbaseRegisterDeviceParams, bd as PalbaseRetentionQueryInput, be as PalbaseRetentionResult, bf as PalbaseSession, bg as PalbaseSetOverrideResult, bh as PalbaseSetOverridesResult, bi as PalbaseSignedUrlResponse, bj as PalbaseSmsClient, bk as PalbaseSmsSendParams, bl as PalbaseSmsSendResponse, bm as PalbaseStorageClient, bn as PalbaseTransformOptions, bo as PalbaseUpdateLinkParams, bp as PalbaseUploadOptions, bq as PalbaseUser, br as PalbaseUserDetailResult, bs as PalbaseUsersQueryInput, bt as PalbaseUsersResult, bu as PalbaseVerifyRequestSignatureParams, bv as PalbaseWhereOperator, bw as PolicyBinOp, bx as PolicyBuilder, by as PolicyCommand, bz as PolicyDef, bA as PolicyExprCtx, bB as PolicyExprRef, bC as PolicyMode, bD as PolicyOperand, R as RateLimitConfig, bE as RawConstraintDef, bF as Realtime, bG as Ref, bH as RequestStore, bI as RowShape, c as RuntimeServices, bJ as Secrets, bK as SecretsService, bL as SerializationFailure, bM as SetShape, bN as SetValue, bO as ShutdownRunner, bP as SqlFragment, bQ as Storage, bR as TABLE_META, bS as TableDef, bT as TableHandle, bU as TableInput, bV as TooManyRequests, bW as TxColumnExpr, bX as TxInsertShape, bY as TxInsertValue, bZ as TxNow, b_ as TxPlan, T as TxPlanBody, b$ as TxPlanError, c0 as TxPlanHandle, c1 as TxPlanOpResult, c2 as TxPlanRejection, b as TxPlanResponse, c3 as TxRefError, c4 as TxRow, c5 as TxRows, c6 as TxSelectOptions, c7 as TxSetShape, c8 as TxSetValue, c9 as TxTable, ca as TxTables, cb as TxWhere, cc as TxWireExpr, cd as TxWireGuard, ce as TxWireOp, cf as TxWireRef, cg as TxWireValue, ch as TypedDB, ci as TypedTable, cj as TypedTx, ck as Unauthorized, cl as UniqueViolation, cm as UserT, cn as VerifiedDevice, co as __getRuntime, d as __requestALS, cp as __resetLifecycleHooks, cq as __runStartHooks, _ as __runWithRuntime, cr as __setRuntime, cs as bigint, ct as boolean, cu as col, cv as dec, cw as decrement, cx as defineMiddleware, cy as defineSchema, cz as defineTable, cA as enumType, cB as exprCtx, cC as inc, cD as increment, cE as index, cF as installationRef, cG as integer, cH as isPalbaseExtension, cI as isRetryable, cJ as jsonb, cK as makeTypedDB, cL as now, cM as numeric, cN as onShutdown, cO as onStart, cP as openai, cQ as ownedByUser, cR as policy, cS as raw, cT as sqlFragment, cU as text, cV as timestamp, cW as userRef, cX as uuid, cY as vector, cZ as withRetry } from './index-DtISj9QX.cjs';
3
- import { M as ModuleClients, C as Container } from './index-9C3JHxg-.cjs';
4
- export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-9C3JHxg-.cjs';
1
+ import { P as PalbaseResult, e as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-DtCgaZAg.cjs';
2
+ export { f as AnyColumn, g as Auth, h as AuthConfig, B as BadRequest, i as Cache, C as CacheClient, j as ClientInfo, k as ColRef, l as ColumnBuilder, m as ColumnDef, n as ColumnMap, o as ColumnType, p as Conflict, D as DBClient, a as DBOps, q as Database, r as DeadlockDetected, s as Documents, E as EXTENSION_DEPENDENCIES, t as EmbeddingModelRef, u as EnvSchemas, v as EnvServiceDatabase, w as EnvTables, x as EnvTypedDatabase, y as EnvTypedTable, z as ErrorDef, F as ErrorMap, G as ErrorThrowers, I as FileContext, J as Flags, K as Forbidden, L as HttpMethod, M as IndexBuilder, N as IndexDef, O as InsertShape, Q as LifecycleHook, U as Log, V as Logger, W as Materialized, X as Middleware, Y as MiddlewareContext, Z as MiddlewareHandler, $ as NotFound, a0 as Notifications, a1 as OnDeleteAction, a2 as PALBASE_EXTENSIONS, a3 as PBRequest, a4 as PalError, a5 as PalbaseAnalyticsClient, a6 as PalbaseAnalyticsManagementNamespace, a7 as PalbaseAnalyticsProperties, a8 as PalbaseAnalyticsQueryNamespace, a9 as PalbaseAttestAndroidParams, aa as PalbaseAttestAndroidResult, ab as PalbaseAttestiOSParams, ac as PalbaseAttestiOSResult, ad as PalbaseAuthAdminClient, ae as PalbaseAuthClient, af as PalbaseBatchOverrideOperation, ag as PalbaseBatchSetOverridesResult, ah as PalbaseBindDeviceParams, ai as PalbaseBucketClient, aj as PalbaseClearAllOverridesResult, ak as PalbaseClearOverrideResult, al as PalbaseCohortQueryInput, am as PalbaseCohortResult, an as PalbaseCollectionRef, ao as PalbaseCountQueryInput, ap as PalbaseCountResult, aq as PalbaseCreateLinkParams, ar as PalbaseDeviceInfo, as as PalbaseDeviceTokenView, at as PalbaseDocsClient, au as PalbaseDocumentRef, av as PalbaseDocumentSnapshot, aw as PalbaseEmailClient, ax as PalbaseEmailSendParams, ay as PalbaseEmailSendResponse, az as PalbaseEventNamesResult, aA as PalbaseEventsQueryInput, aB as PalbaseEventsResult, aC as PalbaseExtension, aD as PalbaseFileObject, aE as PalbaseFlag, aF as PalbaseFlagContext, aG as PalbaseFlagSource, aH as PalbaseFlagValue, aI as PalbaseFlagVariant, aJ as PalbaseFlagsClient, aK as PalbaseFlagsServiceClient, aL as PalbaseFunctionsClient, aM as PalbaseFunnelQueryInput, aN as PalbaseFunnelResult, aO as PalbaseIdentifyTraits, aP as PalbaseInboxClient, aQ as PalbaseInboxListOptions, aR as PalbaseInboxListResult, aS as PalbaseInboxMessage, aT as PalbaseInboxSendParams, aU as PalbaseInboxSendResponse, aV as PalbaseInitialLink, aW as PalbaseInvokeOptions, aX as PalbaseLink, aY as PalbaseLinkAnalytics, aZ as PalbaseLinkDetails, a_ as PalbaseLinksClient, a$ as PalbaseListLinksOptions, b0 as PalbaseListLinksResult, b1 as PalbaseListOptions, b2 as PalbaseMatchParams, b3 as PalbaseMultiChannelResponse, b4 as PalbaseNotificationsClient, b5 as PalbaseOverviewResult, b6 as PalbasePreferences, b7 as PalbasePreferencesClient, b8 as PalbasePushClient, b9 as PalbasePushSendParams, ba as PalbasePushSendResponse, bb as PalbaseQrCodeOptions, bc as PalbaseQuerySnapshot, bd as PalbaseRealtimeClient, be as PalbaseRegisterDeviceParams, bf as PalbaseRetentionQueryInput, bg as PalbaseRetentionResult, bh as PalbaseSession, bi as PalbaseSetOverrideResult, bj as PalbaseSetOverridesResult, bk as PalbaseSignedUrlResponse, bl as PalbaseSmsClient, bm as PalbaseSmsSendParams, bn as PalbaseSmsSendResponse, bo as PalbaseStorageClient, bp as PalbaseTransformOptions, bq as PalbaseUpdateLinkParams, br as PalbaseUploadOptions, bs as PalbaseUser, bt as PalbaseUserDetailResult, bu as PalbaseUsersQueryInput, bv as PalbaseUsersResult, bw as PalbaseVerifyRequestSignatureParams, bx as PalbaseWhereOperator, by as PolicyBinOp, bz as PolicyBuilder, bA as PolicyCommand, bB as PolicyDef, bC as PolicyExprCtx, bD as PolicyExprRef, bE as PolicyMode, bF as PolicyOperand, R as RateLimitConfig, bG as RawConstraintDef, bH as Realtime, bI as Ref, bJ as RequestStore, bK as RowShape, c as RuntimeServices, bL as Secrets, bM as SecretsService, bN as SerializationFailure, bO as SetShape, bP as SetValue, bQ as ShutdownRunner, bR as SqlFragment, bS as Storage, bT as TABLE_META, bU as TableDef, bV as TableHandle, bW as TableInput, bX as TooManyRequests, bY as TxColumnExpr, bZ as TxInsertShape, b_ as TxInsertValue, b$ as TxNow, c0 as TxPlan, T as TxPlanBody, c1 as TxPlanError, c2 as TxPlanHandle, c3 as TxPlanOpResult, c4 as TxPlanRejection, b as TxPlanResponse, c5 as TxRefError, c6 as TxRow, c7 as TxRows, c8 as TxSelectOptions, c9 as TxSetShape, ca as TxSetValue, cb as TxTable, cc as TxTables, cd as TxWhere, ce as TxWireExpr, cf as TxWireGuard, cg as TxWireOp, ch as TxWireRef, ci as TxWireValue, cj as TypedDB, ck as TypedTable, cl as TypedTx, cm as Unauthorized, cn as UniqueViolation, co as UserT, cp as VerifiedDevice, cq as __getRuntime, d as __requestALS, cr as __resetLifecycleHooks, cs as __runStartHooks, _ as __runWithRuntime, ct as __setRuntime, cu as bigint, cv as boolean, cw as col, cx as dec, cy as decrement, cz as defineMiddleware, cA as defineSchema, cB as defineTable, cC as enumType, cD as exprCtx, cE as inc, cF as increment, cG as index, cH as installationRef, cI as integer, cJ as isPalbaseExtension, cK as isRetryable, cL as jsonb, cM as makeTypedDB, cN as now, cO as numeric, cP as onShutdown, cQ as onStart, cR as openai, cS as ownedByUser, cT as policy, cU as raw, cV as sqlFragment, cW as text, cX as timestamp, cY as userRef, cZ as uuid, c_ as vector, c$ as withRetry } from './index-DtCgaZAg.cjs';
3
+ import { M as ModuleClients, C as Container } from './index-Zi7MptvP.cjs';
4
+ export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-Zi7MptvP.cjs';
5
5
  export { TableTypes, Tables } from './db/env.cjs';
6
6
  export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.cjs';
7
- import { a as RouteOptions } from './registry-qIPM5BQe.cjs';
8
- export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-qIPM5BQe.cjs';
7
+ import { a as RouteOptions } from './registry-CEYLH-Iz.cjs';
8
+ export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-CEYLH-Iz.cjs';
9
9
  import { ZodTypeAny, z } from 'zod';
10
10
  export { z } from 'zod';
11
11
  import { T as Token } from './module-Dl1KFVtc.cjs';
@@ -20,10 +20,12 @@ import 'node:async_hooks';
20
20
  *
21
21
  * WHAT IS NOT BUILT HERE, and why each one is absent rather than forgotten:
22
22
  *
23
- * - `auth`, `functions`, `analytics`, `links` — the SDK exports no singleton
24
- * for any of them (`runtime.ts` exports ten, and these four are not among
25
- * them), so no handler could reach them. They were constructed on every
26
- * boot and thrown away.
23
+ * - `functions`, `analytics`, `links` — the SDK exports no singleton for any
24
+ * of them, so no handler could reach them. They were constructed on every
25
+ * boot and thrown away. `auth` was in this list until roles arrived: the
26
+ * sign-in half still belongs to the client SDK, but the ASSIGNMENT half is
27
+ * an operator verb a handler has to be able to call, so `Auth` is built
28
+ * above — as `PalbaseAuthAdminClient`, three methods and no more.
27
29
  * - `Purchases` — its client talked to palstore, and v2 contains no palstore
28
30
  * at all. The surface was unbacked before it was untyped. Dropped from v2
29
31
  * by the user's decision on 2026-08-15, with the SDK's `src/purchases/`
@@ -128,6 +130,44 @@ declare class PalbaseModuleError extends Error {
128
130
  }
129
131
  declare function makeHttpClient(cfg: TransportConfig): ModuleTransport;
130
132
 
133
+ /**
134
+ * auth.ts — the role-assignment half of auth, as a backend handler reaches it.
135
+ *
136
+ * WHAT THIS IS NOT. It is not the client SDK's `auth` (sign-up, sign-in, MFA,
137
+ * device attestation): those are a person acting on their OWN account, they run
138
+ * in the app, and a server has no business holding them. This is the operator
139
+ * verb — "make this user an agent" — and it exists because the product itself is
140
+ * often where the promotion happens: a supervisor taps a button in the tenant's
141
+ * own app, and the tenant's handler has to be able to write the assignment.
142
+ *
143
+ * THE CREDENTIAL IS THE POINT. `/admin/users/{uid}/roles/{role}` answers 403 to
144
+ * anon and to `authenticated` alike (FR-013), so these calls ride the transport
145
+ * built with the SERVICE-ROLE key. A backend is the only place that key exists;
146
+ * putting this surface anywhere a client SDK could reach it would let an end
147
+ * user grant themselves the permission the rest of the feature is about.
148
+ *
149
+ * IT THROWS, and the rest of this package envelopes. That is a deliberate split
150
+ * and it comes from the SHAPE OF THE ANSWER: `assignRole` returns nothing, so a
151
+ * failure it did not throw for would be indistinguishable from a write that
152
+ * happened. The named `RoleNotDefined` is the one refusal a caller can act on —
153
+ * the role names live in git, so a miss is a typo, not a runtime condition —
154
+ * and every other refusal arrives as the transport's own `PalbaseModuleError`
155
+ * with the platform's code on it.
156
+ */
157
+
158
+ /**
159
+ * The named refusal: this stack declares no role by that name.
160
+ *
161
+ * A role's DEFINITION is committed (`palbase roles`, lowered into the generated
162
+ * client as an enum), so a name that misses is a typo in code rather than a
163
+ * state a retry could fix. It carries the name it was asked for, because the
164
+ * message alone would make a handler parse text to log which one failed.
165
+ */
166
+ declare class RoleNotDefined extends Error {
167
+ readonly role: string;
168
+ constructor(role: string, message?: string);
169
+ }
170
+
131
171
  /** One column, flattened. Mirrors Go's `schema.ColumnJSON`. */
132
172
  interface ColumnJSON {
133
173
  type: string;
@@ -1051,4 +1091,4 @@ declare function getJobManifest(ctor: object): JobManifest;
1051
1091
  */
1052
1092
  declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
1053
1093
 
1054
- export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
1094
+ export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { P as PalbaseResult, e as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-dTTLlHIn.js';
2
- export { f as AnyColumn, g as AuthConfig, B as BadRequest, h as Cache, C as CacheClient, i as ClientInfo, j as ColRef, k as ColumnBuilder, l as ColumnDef, m as ColumnMap, n as ColumnType, o as Conflict, D as DBClient, a as DBOps, p as Database, q as DeadlockDetected, r as Documents, E as EXTENSION_DEPENDENCIES, s as EmbeddingModelRef, t as EnvSchemas, u as EnvServiceDatabase, v as EnvTables, w as EnvTypedDatabase, x as EnvTypedTable, y as ErrorDef, z as ErrorMap, F as ErrorThrowers, G as FileContext, I as Flags, J as Forbidden, K as HttpMethod, L as IndexBuilder, M as IndexDef, N as InsertShape, O as LifecycleHook, Q as Log, U as Logger, V as Materialized, W as Middleware, X as MiddlewareContext, Y as MiddlewareHandler, Z as NotFound, $ as Notifications, a0 as OnDeleteAction, a1 as PALBASE_EXTENSIONS, a2 as PBRequest, a3 as PalError, a4 as PalbaseAnalyticsClient, a5 as PalbaseAnalyticsManagementNamespace, a6 as PalbaseAnalyticsProperties, a7 as PalbaseAnalyticsQueryNamespace, a8 as PalbaseAttestAndroidParams, a9 as PalbaseAttestAndroidResult, aa as PalbaseAttestiOSParams, ab as PalbaseAttestiOSResult, ac as PalbaseAuthClient, ad as PalbaseBatchOverrideOperation, ae as PalbaseBatchSetOverridesResult, af as PalbaseBindDeviceParams, ag as PalbaseBucketClient, ah as PalbaseClearAllOverridesResult, ai as PalbaseClearOverrideResult, aj as PalbaseCohortQueryInput, ak as PalbaseCohortResult, al as PalbaseCollectionRef, am as PalbaseCountQueryInput, an as PalbaseCountResult, ao as PalbaseCreateLinkParams, ap as PalbaseDeviceInfo, aq as PalbaseDeviceTokenView, ar as PalbaseDocsClient, as as PalbaseDocumentRef, at as PalbaseDocumentSnapshot, au as PalbaseEmailClient, av as PalbaseEmailSendParams, aw as PalbaseEmailSendResponse, ax as PalbaseEventNamesResult, ay as PalbaseEventsQueryInput, az as PalbaseEventsResult, aA as PalbaseExtension, aB as PalbaseFileObject, aC as PalbaseFlag, aD as PalbaseFlagContext, aE as PalbaseFlagSource, aF as PalbaseFlagValue, aG as PalbaseFlagVariant, aH as PalbaseFlagsClient, aI as PalbaseFlagsServiceClient, aJ as PalbaseFunctionsClient, aK as PalbaseFunnelQueryInput, aL as PalbaseFunnelResult, aM as PalbaseIdentifyTraits, aN as PalbaseInboxClient, aO as PalbaseInboxListOptions, aP as PalbaseInboxListResult, aQ as PalbaseInboxMessage, aR as PalbaseInboxSendParams, aS as PalbaseInboxSendResponse, aT as PalbaseInitialLink, aU as PalbaseInvokeOptions, aV as PalbaseLink, aW as PalbaseLinkAnalytics, aX as PalbaseLinkDetails, aY as PalbaseLinksClient, aZ as PalbaseListLinksOptions, a_ as PalbaseListLinksResult, a$ as PalbaseListOptions, b0 as PalbaseMatchParams, b1 as PalbaseMultiChannelResponse, b2 as PalbaseNotificationsClient, b3 as PalbaseOverviewResult, b4 as PalbasePreferences, b5 as PalbasePreferencesClient, b6 as PalbasePushClient, b7 as PalbasePushSendParams, b8 as PalbasePushSendResponse, b9 as PalbaseQrCodeOptions, ba as PalbaseQuerySnapshot, bb as PalbaseRealtimeClient, bc as PalbaseRegisterDeviceParams, bd as PalbaseRetentionQueryInput, be as PalbaseRetentionResult, bf as PalbaseSession, bg as PalbaseSetOverrideResult, bh as PalbaseSetOverridesResult, bi as PalbaseSignedUrlResponse, bj as PalbaseSmsClient, bk as PalbaseSmsSendParams, bl as PalbaseSmsSendResponse, bm as PalbaseStorageClient, bn as PalbaseTransformOptions, bo as PalbaseUpdateLinkParams, bp as PalbaseUploadOptions, bq as PalbaseUser, br as PalbaseUserDetailResult, bs as PalbaseUsersQueryInput, bt as PalbaseUsersResult, bu as PalbaseVerifyRequestSignatureParams, bv as PalbaseWhereOperator, bw as PolicyBinOp, bx as PolicyBuilder, by as PolicyCommand, bz as PolicyDef, bA as PolicyExprCtx, bB as PolicyExprRef, bC as PolicyMode, bD as PolicyOperand, R as RateLimitConfig, bE as RawConstraintDef, bF as Realtime, bG as Ref, bH as RequestStore, bI as RowShape, c as RuntimeServices, bJ as Secrets, bK as SecretsService, bL as SerializationFailure, bM as SetShape, bN as SetValue, bO as ShutdownRunner, bP as SqlFragment, bQ as Storage, bR as TABLE_META, bS as TableDef, bT as TableHandle, bU as TableInput, bV as TooManyRequests, bW as TxColumnExpr, bX as TxInsertShape, bY as TxInsertValue, bZ as TxNow, b_ as TxPlan, T as TxPlanBody, b$ as TxPlanError, c0 as TxPlanHandle, c1 as TxPlanOpResult, c2 as TxPlanRejection, b as TxPlanResponse, c3 as TxRefError, c4 as TxRow, c5 as TxRows, c6 as TxSelectOptions, c7 as TxSetShape, c8 as TxSetValue, c9 as TxTable, ca as TxTables, cb as TxWhere, cc as TxWireExpr, cd as TxWireGuard, ce as TxWireOp, cf as TxWireRef, cg as TxWireValue, ch as TypedDB, ci as TypedTable, cj as TypedTx, ck as Unauthorized, cl as UniqueViolation, cm as UserT, cn as VerifiedDevice, co as __getRuntime, d as __requestALS, cp as __resetLifecycleHooks, cq as __runStartHooks, _ as __runWithRuntime, cr as __setRuntime, cs as bigint, ct as boolean, cu as col, cv as dec, cw as decrement, cx as defineMiddleware, cy as defineSchema, cz as defineTable, cA as enumType, cB as exprCtx, cC as inc, cD as increment, cE as index, cF as installationRef, cG as integer, cH as isPalbaseExtension, cI as isRetryable, cJ as jsonb, cK as makeTypedDB, cL as now, cM as numeric, cN as onShutdown, cO as onStart, cP as openai, cQ as ownedByUser, cR as policy, cS as raw, cT as sqlFragment, cU as text, cV as timestamp, cW as userRef, cX as uuid, cY as vector, cZ as withRetry } from './index-dTTLlHIn.js';
3
- import { M as ModuleClients, C as Container } from './index-BbvOoZFr.js';
4
- export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-BbvOoZFr.js';
1
+ import { P as PalbaseResult, e as PolicyExpr, S as SchemaDef, A as AuthSpec, H as HttpError } from './index-8qy3kIuA.js';
2
+ export { f as AnyColumn, g as Auth, h as AuthConfig, B as BadRequest, i as Cache, C as CacheClient, j as ClientInfo, k as ColRef, l as ColumnBuilder, m as ColumnDef, n as ColumnMap, o as ColumnType, p as Conflict, D as DBClient, a as DBOps, q as Database, r as DeadlockDetected, s as Documents, E as EXTENSION_DEPENDENCIES, t as EmbeddingModelRef, u as EnvSchemas, v as EnvServiceDatabase, w as EnvTables, x as EnvTypedDatabase, y as EnvTypedTable, z as ErrorDef, F as ErrorMap, G as ErrorThrowers, I as FileContext, J as Flags, K as Forbidden, L as HttpMethod, M as IndexBuilder, N as IndexDef, O as InsertShape, Q as LifecycleHook, U as Log, V as Logger, W as Materialized, X as Middleware, Y as MiddlewareContext, Z as MiddlewareHandler, $ as NotFound, a0 as Notifications, a1 as OnDeleteAction, a2 as PALBASE_EXTENSIONS, a3 as PBRequest, a4 as PalError, a5 as PalbaseAnalyticsClient, a6 as PalbaseAnalyticsManagementNamespace, a7 as PalbaseAnalyticsProperties, a8 as PalbaseAnalyticsQueryNamespace, a9 as PalbaseAttestAndroidParams, aa as PalbaseAttestAndroidResult, ab as PalbaseAttestiOSParams, ac as PalbaseAttestiOSResult, ad as PalbaseAuthAdminClient, ae as PalbaseAuthClient, af as PalbaseBatchOverrideOperation, ag as PalbaseBatchSetOverridesResult, ah as PalbaseBindDeviceParams, ai as PalbaseBucketClient, aj as PalbaseClearAllOverridesResult, ak as PalbaseClearOverrideResult, al as PalbaseCohortQueryInput, am as PalbaseCohortResult, an as PalbaseCollectionRef, ao as PalbaseCountQueryInput, ap as PalbaseCountResult, aq as PalbaseCreateLinkParams, ar as PalbaseDeviceInfo, as as PalbaseDeviceTokenView, at as PalbaseDocsClient, au as PalbaseDocumentRef, av as PalbaseDocumentSnapshot, aw as PalbaseEmailClient, ax as PalbaseEmailSendParams, ay as PalbaseEmailSendResponse, az as PalbaseEventNamesResult, aA as PalbaseEventsQueryInput, aB as PalbaseEventsResult, aC as PalbaseExtension, aD as PalbaseFileObject, aE as PalbaseFlag, aF as PalbaseFlagContext, aG as PalbaseFlagSource, aH as PalbaseFlagValue, aI as PalbaseFlagVariant, aJ as PalbaseFlagsClient, aK as PalbaseFlagsServiceClient, aL as PalbaseFunctionsClient, aM as PalbaseFunnelQueryInput, aN as PalbaseFunnelResult, aO as PalbaseIdentifyTraits, aP as PalbaseInboxClient, aQ as PalbaseInboxListOptions, aR as PalbaseInboxListResult, aS as PalbaseInboxMessage, aT as PalbaseInboxSendParams, aU as PalbaseInboxSendResponse, aV as PalbaseInitialLink, aW as PalbaseInvokeOptions, aX as PalbaseLink, aY as PalbaseLinkAnalytics, aZ as PalbaseLinkDetails, a_ as PalbaseLinksClient, a$ as PalbaseListLinksOptions, b0 as PalbaseListLinksResult, b1 as PalbaseListOptions, b2 as PalbaseMatchParams, b3 as PalbaseMultiChannelResponse, b4 as PalbaseNotificationsClient, b5 as PalbaseOverviewResult, b6 as PalbasePreferences, b7 as PalbasePreferencesClient, b8 as PalbasePushClient, b9 as PalbasePushSendParams, ba as PalbasePushSendResponse, bb as PalbaseQrCodeOptions, bc as PalbaseQuerySnapshot, bd as PalbaseRealtimeClient, be as PalbaseRegisterDeviceParams, bf as PalbaseRetentionQueryInput, bg as PalbaseRetentionResult, bh as PalbaseSession, bi as PalbaseSetOverrideResult, bj as PalbaseSetOverridesResult, bk as PalbaseSignedUrlResponse, bl as PalbaseSmsClient, bm as PalbaseSmsSendParams, bn as PalbaseSmsSendResponse, bo as PalbaseStorageClient, bp as PalbaseTransformOptions, bq as PalbaseUpdateLinkParams, br as PalbaseUploadOptions, bs as PalbaseUser, bt as PalbaseUserDetailResult, bu as PalbaseUsersQueryInput, bv as PalbaseUsersResult, bw as PalbaseVerifyRequestSignatureParams, bx as PalbaseWhereOperator, by as PolicyBinOp, bz as PolicyBuilder, bA as PolicyCommand, bB as PolicyDef, bC as PolicyExprCtx, bD as PolicyExprRef, bE as PolicyMode, bF as PolicyOperand, R as RateLimitConfig, bG as RawConstraintDef, bH as Realtime, bI as Ref, bJ as RequestStore, bK as RowShape, c as RuntimeServices, bL as Secrets, bM as SecretsService, bN as SerializationFailure, bO as SetShape, bP as SetValue, bQ as ShutdownRunner, bR as SqlFragment, bS as Storage, bT as TABLE_META, bU as TableDef, bV as TableHandle, bW as TableInput, bX as TooManyRequests, bY as TxColumnExpr, bZ as TxInsertShape, b_ as TxInsertValue, b$ as TxNow, c0 as TxPlan, T as TxPlanBody, c1 as TxPlanError, c2 as TxPlanHandle, c3 as TxPlanOpResult, c4 as TxPlanRejection, b as TxPlanResponse, c5 as TxRefError, c6 as TxRow, c7 as TxRows, c8 as TxSelectOptions, c9 as TxSetShape, ca as TxSetValue, cb as TxTable, cc as TxTables, cd as TxWhere, ce as TxWireExpr, cf as TxWireGuard, cg as TxWireOp, ch as TxWireRef, ci as TxWireValue, cj as TypedDB, ck as TypedTable, cl as TypedTx, cm as Unauthorized, cn as UniqueViolation, co as UserT, cp as VerifiedDevice, cq as __getRuntime, d as __requestALS, cr as __resetLifecycleHooks, cs as __runStartHooks, _ as __runWithRuntime, ct as __setRuntime, cu as bigint, cv as boolean, cw as col, cx as dec, cy as decrement, cz as defineMiddleware, cA as defineSchema, cB as defineTable, cC as enumType, cD as exprCtx, cE as inc, cF as increment, cG as index, cH as installationRef, cI as integer, cJ as isPalbaseExtension, cK as isRetryable, cL as jsonb, cM as makeTypedDB, cN as now, cO as numeric, cP as onShutdown, cQ as onStart, cR as openai, cS as ownedByUser, cT as policy, cU as raw, cV as sqlFragment, cW as text, cX as timestamp, cY as userRef, cZ as uuid, c_ as vector, c$ as withRetry } from './index-8qy3kIuA.js';
3
+ import { M as ModuleClients, C as Container } from './index-b-Q3l7W5.js';
4
+ export { D as DECLARATION_REFUSAL, a as DeclarationRefused, b as DiError, c as DiKind, d as ModulePressure, e as assertNoOrphanEntryPoints, f as buildContainer, i as isDeclarationRefused } from './index-b-Q3l7W5.js';
5
5
  export { TableTypes, Tables } from './db/env.js';
6
6
  export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.js';
7
- import { a as RouteOptions } from './registry-JQNIX-eA.js';
8
- export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-JQNIX-eA.js';
7
+ import { a as RouteOptions } from './registry-BGJ-Al6F.js';
8
+ export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-BGJ-Al6F.js';
9
9
  import { ZodTypeAny, z } from 'zod';
10
10
  export { z } from 'zod';
11
11
  import { T as Token } from './module-Dl1KFVtc.js';
@@ -20,10 +20,12 @@ import 'node:async_hooks';
20
20
  *
21
21
  * WHAT IS NOT BUILT HERE, and why each one is absent rather than forgotten:
22
22
  *
23
- * - `auth`, `functions`, `analytics`, `links` — the SDK exports no singleton
24
- * for any of them (`runtime.ts` exports ten, and these four are not among
25
- * them), so no handler could reach them. They were constructed on every
26
- * boot and thrown away.
23
+ * - `functions`, `analytics`, `links` — the SDK exports no singleton for any
24
+ * of them, so no handler could reach them. They were constructed on every
25
+ * boot and thrown away. `auth` was in this list until roles arrived: the
26
+ * sign-in half still belongs to the client SDK, but the ASSIGNMENT half is
27
+ * an operator verb a handler has to be able to call, so `Auth` is built
28
+ * above — as `PalbaseAuthAdminClient`, three methods and no more.
27
29
  * - `Purchases` — its client talked to palstore, and v2 contains no palstore
28
30
  * at all. The surface was unbacked before it was untyped. Dropped from v2
29
31
  * by the user's decision on 2026-08-15, with the SDK's `src/purchases/`
@@ -128,6 +130,44 @@ declare class PalbaseModuleError extends Error {
128
130
  }
129
131
  declare function makeHttpClient(cfg: TransportConfig): ModuleTransport;
130
132
 
133
+ /**
134
+ * auth.ts — the role-assignment half of auth, as a backend handler reaches it.
135
+ *
136
+ * WHAT THIS IS NOT. It is not the client SDK's `auth` (sign-up, sign-in, MFA,
137
+ * device attestation): those are a person acting on their OWN account, they run
138
+ * in the app, and a server has no business holding them. This is the operator
139
+ * verb — "make this user an agent" — and it exists because the product itself is
140
+ * often where the promotion happens: a supervisor taps a button in the tenant's
141
+ * own app, and the tenant's handler has to be able to write the assignment.
142
+ *
143
+ * THE CREDENTIAL IS THE POINT. `/admin/users/{uid}/roles/{role}` answers 403 to
144
+ * anon and to `authenticated` alike (FR-013), so these calls ride the transport
145
+ * built with the SERVICE-ROLE key. A backend is the only place that key exists;
146
+ * putting this surface anywhere a client SDK could reach it would let an end
147
+ * user grant themselves the permission the rest of the feature is about.
148
+ *
149
+ * IT THROWS, and the rest of this package envelopes. That is a deliberate split
150
+ * and it comes from the SHAPE OF THE ANSWER: `assignRole` returns nothing, so a
151
+ * failure it did not throw for would be indistinguishable from a write that
152
+ * happened. The named `RoleNotDefined` is the one refusal a caller can act on —
153
+ * the role names live in git, so a miss is a typo, not a runtime condition —
154
+ * and every other refusal arrives as the transport's own `PalbaseModuleError`
155
+ * with the platform's code on it.
156
+ */
157
+
158
+ /**
159
+ * The named refusal: this stack declares no role by that name.
160
+ *
161
+ * A role's DEFINITION is committed (`palbase roles`, lowered into the generated
162
+ * client as an enum), so a name that misses is a typo in code rather than a
163
+ * state a retry could fix. It carries the name it was asked for, because the
164
+ * message alone would make a handler parse text to log which one failed.
165
+ */
166
+ declare class RoleNotDefined extends Error {
167
+ readonly role: string;
168
+ constructor(role: string, message?: string);
169
+ }
170
+
131
171
  /** One column, flattened. Mirrors Go's `schema.ColumnJSON`. */
132
172
  interface ColumnJSON {
133
173
  type: string;
@@ -1051,4 +1091,4 @@ declare function getJobManifest(ctor: object): JobManifest;
1051
1091
  */
1052
1092
  declare function getJobConfig(ctor: object, container: Container): ResolvedJob;
1053
1093
 
1054
- export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
1094
+ export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Container, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Injectable, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OnAuthorize, OnEmpty, OnFirst, OnJoin, OnLeave, OnMessage, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, PolicyExpr, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RoleNotDefined, Room, type RoomOptions, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, Token, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __claimInjectables, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, controllersOf, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getHookManifest, getJobConfig, getJobManifest, getRegisteredControllers, getWebhookConfig, getWebhookManifest, hooksOf, jobsOf, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, resolveEffectiveAuth, roomsOf, toSchemaJSON, webhooksOf };
package/dist/index.js CHANGED
@@ -26,12 +26,13 @@ import {
26
26
  userRef,
27
27
  uuid,
28
28
  vector
29
- } from "./chunk-IVZERLTM.js";
29
+ } from "./chunk-ENZ2RFFJ.js";
30
30
  import {
31
31
  defineError,
32
32
  getErrorRegistry
33
33
  } from "./chunk-TWX6JTGJ.js";
34
34
  import {
35
+ Auth,
35
36
  Cache,
36
37
  DECLARATION_REFUSAL,
37
38
  Database,
@@ -65,14 +66,14 @@ import {
65
66
  onStart,
66
67
  roomsOf,
67
68
  webhooksOf
68
- } from "./chunk-RVP6BTEZ.js";
69
+ } from "./chunk-5J5W75A6.js";
69
70
  import {
70
71
  col,
71
72
  makeTypedDB,
72
73
  sqlFragment,
73
74
  toSchemaJSON,
74
75
  withRetry
75
- } from "./chunk-SNDXY565.js";
76
+ } from "./chunk-SG4UTNOP.js";
76
77
  import {
77
78
  TxPlanError,
78
79
  TxRefError,
@@ -201,6 +202,48 @@ function makeHttpClient(cfg) {
201
202
  }
202
203
  __name(makeHttpClient, "makeHttpClient");
203
204
 
205
+ // src/clients/auth.ts
206
+ var RoleNotDefined = class extends Error {
207
+ static {
208
+ __name(this, "RoleNotDefined");
209
+ }
210
+ role;
211
+ constructor(role, message) {
212
+ super(message ?? `No role named "${role}" is defined for this stack`);
213
+ this.name = "RoleNotDefined";
214
+ this.role = role;
215
+ }
216
+ };
217
+ function refuse(error, role) {
218
+ if (error.code === "role_not_defined") throw new RoleNotDefined(role, error.message);
219
+ if (error instanceof PalbaseModuleError) throw error;
220
+ throw new PalbaseModuleError(error.code ?? "unknown_error", error.message ?? "request failed", 0);
221
+ }
222
+ __name(refuse, "refuse");
223
+ function rolesPath(userId, role) {
224
+ const base = `/admin/users/${encodeURIComponent(userId)}/roles`;
225
+ return role === void 0 ? base : `${base}/${encodeURIComponent(role)}`;
226
+ }
227
+ __name(rolesPath, "rolesPath");
228
+ function buildAuthClient(http) {
229
+ return {
230
+ async assignRole(userId, role) {
231
+ const { error } = await http.request("PUT", rolesPath(userId, role));
232
+ if (error) refuse(error, role);
233
+ },
234
+ async revokeRole(userId, role) {
235
+ const { error } = await http.request("DELETE", rolesPath(userId, role));
236
+ if (error) refuse(error, role);
237
+ },
238
+ async rolesOf(userId) {
239
+ const { data, error } = await http.request("GET", rolesPath(userId));
240
+ if (error) refuse(error, "");
241
+ return data?.roles ?? [];
242
+ }
243
+ };
244
+ }
245
+ __name(buildAuthClient, "buildAuthClient");
246
+
204
247
  // src/clients/documents.ts
205
248
  var SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
206
249
  function validateSegment(segment, label) {
@@ -1185,6 +1228,10 @@ function buildModuleClients(cfg) {
1185
1228
  fetchImpl: cfg.fetchImpl
1186
1229
  });
1187
1230
  return {
1231
+ // The ROLE half of auth only (`clients/auth.ts` says why the rest is not
1232
+ // here). It rides the same service-role transport, which is exactly the
1233
+ // credential the assignment routes demand.
1234
+ Auth: buildAuthClient(http),
1188
1235
  Documents: buildDocumentsClient(http),
1189
1236
  Storage: buildStorageClient(http, cfg.publicOrigin),
1190
1237
  Notifications: buildNotificationsClient(http),
@@ -1938,6 +1985,7 @@ __name(getJobConfig, "getJobConfig");
1938
1985
  // src/index.ts
1939
1986
  import { z } from "zod";
1940
1987
  export {
1988
+ Auth,
1941
1989
  BadRequest,
1942
1990
  Body,
1943
1991
  Cache,
@@ -1988,6 +2036,7 @@ export {
1988
2036
  Realtime,
1989
2037
  Req,
1990
2038
  RequestId,
2039
+ RoleNotDefined,
1991
2040
  Room,
1992
2041
  Secrets,
1993
2042
  SerializationFailure,