@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.
- package/dist/bin/palbase-backend.cjs +22 -7
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +2 -2
- package/dist/{chunk-DHJ3SYAE.js → chunk-RADVOY7Y.js} +23 -9
- package/dist/{chunk-DHJ3SYAE.js.map → chunk-RADVOY7Y.js.map} +1 -1
- package/dist/{chunk-ESSQ3YML.js → chunk-YRVIWHJC.js} +7 -3
- package/dist/{chunk-ESSQ3YML.js.map → chunk-YRVIWHJC.js.map} +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/engine/index.cjs +22 -7
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +3 -3
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.js +2 -2
- package/dist/{index-BOe82fsK.d.ts → index-8qy3kIuA.d.ts} +66 -4
- package/dist/{index-ChvoVczS.d.cts → index-DtCgaZAg.d.cts} +66 -4
- package/dist/{index-BZfmdRmh.d.cts → index-Zi7MptvP.d.cts} +3 -3
- package/dist/{index-BYDUKexK.d.ts → index-b-Q3l7W5.d.ts} +3 -3
- package/dist/index.cjs +55 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -11
- package/dist/index.d.ts +51 -11
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/{registry-DaqHsOq8.d.ts → registry-BGJ-Al6F.d.ts} +1 -1
- package/dist/{registry-B2KfKWv1.d.cts → registry-CEYLH-Iz.d.cts} +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/docs/README.md +1 -1
- package/docs/llms-full.txt +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
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-
|
|
2
|
-
export { f as AnyColumn, g as AuthConfig, B as BadRequest,
|
|
3
|
-
import { M as ModuleClients, C as Container } from './index-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
-
* - `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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-
|
|
2
|
-
export { f as AnyColumn, g as AuthConfig, B as BadRequest,
|
|
3
|
-
import { M as ModuleClients, C as Container } from './index-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
-
* - `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
@@ -32,6 +32,7 @@ import {
|
|
|
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,7 +66,7 @@ import {
|
|
|
65
66
|
onStart,
|
|
66
67
|
roomsOf,
|
|
67
68
|
webhooksOf
|
|
68
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-YRVIWHJC.js";
|
|
69
70
|
import {
|
|
70
71
|
col,
|
|
71
72
|
makeTypedDB,
|
|
@@ -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,
|