@palbase/backend 6.0.0 → 8.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.
- package/dist/{chunk-HAVXYTDJ.js → chunk-SWT2QR5F.js} +4 -2
- package/dist/chunk-SWT2QR5F.js.map +1 -0
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/{endpoint-CfdiQbVC.d.cts → endpoint-cDQyI6jH.d.cts} +69 -44
- package/dist/{endpoint-CfdiQbVC.d.ts → endpoint-cDQyI6jH.d.ts} +69 -44
- package/dist/{index-DvhjkX6F.d.cts → index-B-FNCK84.d.cts} +1 -1
- package/dist/{index-BVnIdFpa.d.ts → index-BfnIO5G-.d.ts} +1 -1
- package/dist/index.cjs +138 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -9
- package/dist/index.d.ts +80 -9
- package/dist/index.js +139 -7
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +4 -4
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +4 -5
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +11 -10
- package/docs/llms-full.txt +73 -19
- package/docs/routing.md +9 -5
- package/docs/services.md +53 -4
- package/package.json +5 -2
- package/dist/chunk-HAVXYTDJ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, Q as QueueClient, D as DBClient,
|
|
2
|
-
export {
|
|
1
|
+
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, Q as QueueClient, e as PalbaseRealtimeClient, D as DBClient, f as PalbaseStorageClient, A as AuthSpec, R as RateLimitConfig, H as HttpError, U as User$1 } from './endpoint-cDQyI6jH.cjs';
|
|
2
|
+
export { g as AuthConfig, B as BadRequest, h as ClientInfo, i as Conflict, j as DBOps, E as ErrorDef, k as ErrorMap, l as ErrorThrowers, F as FileContext, m as Forbidden, n as HttpMethod, M as Middleware, o as MiddlewareContext, p as MiddlewareHandler, N as NotFound, P as PBRequest, q as PalError, r as PalbaseAnalyticsClient, s as PalbaseAnalyticsManagementNamespace, t as PalbaseAnalyticsProperties, u as PalbaseAnalyticsQueryNamespace, v as PalbaseAttestAndroidParams, w as PalbaseAttestAndroidResult, x as PalbaseAttestiOSParams, y as PalbaseAttestiOSResult, z as PalbaseAuthClient, G as PalbaseBatchOverrideOperation, I as PalbaseBatchSetOverridesResult, J as PalbaseBindDeviceParams, K as PalbaseBucketClient, O as PalbaseClearAllOverridesResult, S as PalbaseClearOverrideResult, T as PalbaseCmsClient, V as PalbaseCmsFindOneOptions, W as PalbaseCmsFindOptions, X as PalbaseCohortQueryInput, Y as PalbaseCohortResult, Z as PalbaseCollectionRef, _ as PalbaseCountQueryInput, $ as PalbaseCountResult, a0 as PalbaseCreateLinkParams, a1 as PalbaseDeviceInfo, a2 as PalbaseDeviceTokenView, a3 as PalbaseDocumentRef, a4 as PalbaseDocumentSnapshot, a5 as PalbaseEmailClient, a6 as PalbaseEmailSendParams, a7 as PalbaseEmailSendResponse, a8 as PalbaseEventNamesResult, a9 as PalbaseEventsQueryInput, aa as PalbaseEventsResult, ab as PalbaseFileObject, ac as PalbaseFlag, ad as PalbaseFlagContext, ae as PalbaseFlagSource, af as PalbaseFlagValue, ag as PalbaseFlagVariant, ah as PalbaseFlagsServiceClient, ai as PalbaseFunctionsClient, aj as PalbaseFunnelQueryInput, ak as PalbaseFunnelResult, al as PalbaseIdentifyTraits, am as PalbaseInboxClient, an as PalbaseInboxListOptions, ao as PalbaseInboxListResult, ap as PalbaseInboxMessage, aq as PalbaseInboxSendParams, ar as PalbaseInboxSendResponse, as as PalbaseInitialLink, at as PalbaseInvokeOptions, au as PalbaseLink, av as PalbaseLinkAnalytics, aw as PalbaseLinkDetails, ax as PalbaseLinksClient, ay as PalbaseListLinksOptions, az as PalbaseListLinksResult, aA as PalbaseListOptions, aB as PalbaseMatchParams, aC as PalbaseMultiChannelResponse, aD as PalbaseOverviewResult, aE as PalbasePreferences, aF as PalbasePreferencesClient, aG as PalbasePublicUrlResponse, aH as PalbasePushClient, aI as PalbasePushSendParams, aJ as PalbasePushSendResponse, aK as PalbaseQrCodeOptions, aL as PalbaseQuerySnapshot, aM as PalbaseRegisterDeviceParams, aN as PalbaseResult, aO as PalbaseRetentionQueryInput, aP as PalbaseRetentionResult, aQ as PalbaseSession, aR as PalbaseSetOverrideResult, aS as PalbaseSetOverridesResult, aT as PalbaseSignedUrlResponse, aU as PalbaseSmsClient, aV as PalbaseSmsSendParams, aW as PalbaseSmsSendResponse, aX as PalbaseTransformOptions, aY as PalbaseUpdateLinkParams, aZ as PalbaseUploadOptions, a_ as PalbaseUser, a$ as PalbaseUserDetailResult, b0 as PalbaseUsersQueryInput, b1 as PalbaseUsersResult, b2 as PalbaseVerifyRequestSignatureParams, b3 as PalbaseWhereOperator, b4 as TooManyRequests, b5 as TxClient, b6 as Unauthorized, b7 as defineMiddleware } from './endpoint-cDQyI6jH.cjs';
|
|
3
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
-
import { E as EnvTypedDatabase, S as SchemaDef } from './index-
|
|
5
|
-
export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, f as EnvTables, g as EnvTypedTable, h as EnvTypedTx, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, i as PalbaseExtension, j as PolicyBuilder, k as PolicyCommand, l as PolicyDef, m as PolicyMode, R as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TypedDB, q as TypedTable, r as TypedTx, s as boolean, t as defineSchema, u as enumType, v as integer, w as isPalbaseExtension, x as jsonb, y as makeTypedDB, z as policy, A as text, B as timestamp, D as uuid } from './index-
|
|
4
|
+
import { E as EnvTypedDatabase, S as SchemaDef } from './index-B-FNCK84.cjs';
|
|
5
|
+
export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, f as EnvTables, g as EnvTypedTable, h as EnvTypedTx, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, i as PalbaseExtension, j as PolicyBuilder, k as PolicyCommand, l as PolicyDef, m as PolicyMode, R as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TypedDB, q as TypedTable, r as TypedTx, s as boolean, t as defineSchema, u as enumType, v as integer, w as isPalbaseExtension, x as jsonb, y as makeTypedDB, z as policy, A as text, B as timestamp, D as uuid } from './index-B-FNCK84.cjs';
|
|
6
6
|
export { TableTypes, Tables } from './db/env.cjs';
|
|
7
|
-
import { ZodTypeAny } from 'zod';
|
|
7
|
+
import { ZodTypeAny, z } from 'zod';
|
|
8
8
|
export { z } from 'zod';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -50,9 +50,12 @@ export { z } from 'zod';
|
|
|
50
50
|
|
|
51
51
|
/** The set of live clients the runtime injects per request scope.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
|
|
54
|
+
* cannot hold a subscription socket — `subscribe()` lives on the client SDK).
|
|
55
|
+
*
|
|
56
|
+
* EXCLUDED on purpose: Functions, CMS, Links, Analytics, Auth. They are not
|
|
57
|
+
* exposed as backend handler singletons (auth lives on the client SDK; the rest
|
|
58
|
+
* are out of scope for backend endpoints). */
|
|
56
59
|
interface RuntimeServices {
|
|
57
60
|
Database: DBClient;
|
|
58
61
|
Documents: PalbaseDocsClient;
|
|
@@ -62,6 +65,7 @@ interface RuntimeServices {
|
|
|
62
65
|
Log: Logger;
|
|
63
66
|
Notifications: PalbaseNotificationsClient;
|
|
64
67
|
Flags: PalbaseFlagsClient;
|
|
68
|
+
Realtime: PalbaseRealtimeClient;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Per-request store. The persistent runtime runs each request inside
|
|
@@ -143,6 +147,19 @@ declare const Notifications: PalbaseNotificationsClient;
|
|
|
143
147
|
* await Flags.asService().setOverrideForUser("u_9", "x", true); // cross-user
|
|
144
148
|
*/
|
|
145
149
|
declare const Flags: PalbaseFlagsClient;
|
|
150
|
+
/**
|
|
151
|
+
* The Realtime broadcast singleton for the current request scope. Backend-side
|
|
152
|
+
* Realtime is BROADCAST-ONLY (a stateless handler can push but not subscribe —
|
|
153
|
+
* `subscribe()` lives on the client SDK's `pb.realtime`). Fire-and-forget:
|
|
154
|
+
* `broadcast` resolves once accepted (or with an `error`), never blocking the
|
|
155
|
+
* handler on subscribers.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* import { Realtime } from "@palbase/backend";
|
|
159
|
+
*
|
|
160
|
+
* await Realtime.broadcast("room:42", "message", { text, from: user.id });
|
|
161
|
+
*/
|
|
162
|
+
declare const Realtime: PalbaseRealtimeClient;
|
|
146
163
|
|
|
147
164
|
/**
|
|
148
165
|
* env-gen.ts — generate the `palbase-env.d.ts` text from a `defineSchema()`
|
|
@@ -695,6 +712,20 @@ interface RouteOptions {
|
|
|
695
712
|
/** Per-route rate limit. */
|
|
696
713
|
rateLimit?: RateLimitConfig;
|
|
697
714
|
}
|
|
715
|
+
/** One inferred throw site: the error CLASS name (e.g. "TodoLocked") and its
|
|
716
|
+
* wire code (e.g. "todo_locked"). `status`, `hasData`, and the data JSON schema
|
|
717
|
+
* are NOT carried here — they resolve from the error registry by `code` at
|
|
718
|
+
* extract/openapi time (single source of truth). */
|
|
719
|
+
interface ThrowDescriptor {
|
|
720
|
+
name: string;
|
|
721
|
+
code: string;
|
|
722
|
+
}
|
|
723
|
+
/** Attach the inferred throw descriptors to the route for `fnName` (called by
|
|
724
|
+
* the stager-injected IIFE that carries the throw analysis result — the
|
|
725
|
+
* `recordReturn` twin). If the route does not exist yet, the descriptors are
|
|
726
|
+
* buffered (THROWS_BUFFER) and drained into the route by `recordRoute` when the
|
|
727
|
+
* method decorator runs. */
|
|
728
|
+
declare function recordThrows(target: object, fnName: string, throws: ThrowDescriptor[]): void;
|
|
698
729
|
|
|
699
730
|
/** A legacy method decorator. */
|
|
700
731
|
type MethodDecorator = (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
@@ -737,6 +768,46 @@ declare function TraceId(): ParameterDecorator;
|
|
|
737
768
|
/** `@Req()` — inject the raw request object (escape hatch, `: PBRequest`). */
|
|
738
769
|
declare function Req(): ParameterDecorator;
|
|
739
770
|
|
|
771
|
+
/** One registered error: the wire code, HTTP status, the class name the
|
|
772
|
+
* analyzer sees, the optional data payload schema, and whether it is one of the
|
|
773
|
+
* pre-seeded built-in named classes. */
|
|
774
|
+
interface RegisteredError {
|
|
775
|
+
code: string;
|
|
776
|
+
status: number;
|
|
777
|
+
className: string;
|
|
778
|
+
dataSchema?: ZodTypeAny;
|
|
779
|
+
/** JSON.stringify of the converted JSON schema — equal digest ⇔ the spec
|
|
780
|
+
* twins would emit an identical `data` schema for this error. */
|
|
781
|
+
dataDigest?: string;
|
|
782
|
+
builtin: boolean;
|
|
783
|
+
}
|
|
784
|
+
declare function getErrorRegistry(): Map<string, RegisteredError>;
|
|
785
|
+
/** Class returned for schema-bearing errors: ctor(data, message?). */
|
|
786
|
+
interface DefinedErrorWithData<S extends ZodTypeAny> {
|
|
787
|
+
new (data: z.input<S>, message?: string): HttpError;
|
|
788
|
+
readonly code: string;
|
|
789
|
+
readonly status: number;
|
|
790
|
+
}
|
|
791
|
+
/** Class returned for schema-less errors: ctor(message?). */
|
|
792
|
+
interface DefinedError {
|
|
793
|
+
new (message?: string): HttpError;
|
|
794
|
+
readonly code: string;
|
|
795
|
+
readonly status: number;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Define a project error class. MUST be called with literal args (string
|
|
799
|
+
* literal `code`, numeric literal `status`) at module top level — the deploy
|
|
800
|
+
* stager's static analyzer reads those literals to resolve throw sites.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* // models/todos/errors.ts
|
|
804
|
+
* export const TodoLocked = defineError("todo_locked", 409, z.object({ retryAfter: z.number() }));
|
|
805
|
+
* // services/todo.service.ts
|
|
806
|
+
* throw new TodoLocked({ retryAfter: 30 });
|
|
807
|
+
*/
|
|
808
|
+
declare function defineError<S extends ZodTypeAny>(code: string, status: number, dataSchema: S): DefinedErrorWithData<S>;
|
|
809
|
+
declare function defineError(code: string, status: number): DefinedError;
|
|
810
|
+
|
|
740
811
|
/** Non-service, per-invocation data for background worker handlers.
|
|
741
812
|
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
742
813
|
interface WorkerMeta {
|
|
@@ -1189,4 +1260,4 @@ declare const documents: {
|
|
|
1189
1260
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1190
1261
|
};
|
|
1191
1262
|
|
|
1192
|
-
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseStorageClient, Param, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TraceId, type TwilioOptions, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineFlags, defineJob, defineNotifications, defineStorage, defineWebhook, defineWorker, documents, flag, makeEnvDts, parseFileSizeLimit, reservedSecretKey, storage };
|
|
1263
|
+
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, type ThrowDescriptor, TraceId, type TwilioOptions, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineWebhook, defineWorker, documents, flag, getErrorRegistry, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, Q as QueueClient, D as DBClient,
|
|
2
|
-
export {
|
|
1
|
+
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, Q as QueueClient, e as PalbaseRealtimeClient, D as DBClient, f as PalbaseStorageClient, A as AuthSpec, R as RateLimitConfig, H as HttpError, U as User$1 } from './endpoint-cDQyI6jH.js';
|
|
2
|
+
export { g as AuthConfig, B as BadRequest, h as ClientInfo, i as Conflict, j as DBOps, E as ErrorDef, k as ErrorMap, l as ErrorThrowers, F as FileContext, m as Forbidden, n as HttpMethod, M as Middleware, o as MiddlewareContext, p as MiddlewareHandler, N as NotFound, P as PBRequest, q as PalError, r as PalbaseAnalyticsClient, s as PalbaseAnalyticsManagementNamespace, t as PalbaseAnalyticsProperties, u as PalbaseAnalyticsQueryNamespace, v as PalbaseAttestAndroidParams, w as PalbaseAttestAndroidResult, x as PalbaseAttestiOSParams, y as PalbaseAttestiOSResult, z as PalbaseAuthClient, G as PalbaseBatchOverrideOperation, I as PalbaseBatchSetOverridesResult, J as PalbaseBindDeviceParams, K as PalbaseBucketClient, O as PalbaseClearAllOverridesResult, S as PalbaseClearOverrideResult, T as PalbaseCmsClient, V as PalbaseCmsFindOneOptions, W as PalbaseCmsFindOptions, X as PalbaseCohortQueryInput, Y as PalbaseCohortResult, Z as PalbaseCollectionRef, _ as PalbaseCountQueryInput, $ as PalbaseCountResult, a0 as PalbaseCreateLinkParams, a1 as PalbaseDeviceInfo, a2 as PalbaseDeviceTokenView, a3 as PalbaseDocumentRef, a4 as PalbaseDocumentSnapshot, a5 as PalbaseEmailClient, a6 as PalbaseEmailSendParams, a7 as PalbaseEmailSendResponse, a8 as PalbaseEventNamesResult, a9 as PalbaseEventsQueryInput, aa as PalbaseEventsResult, ab as PalbaseFileObject, ac as PalbaseFlag, ad as PalbaseFlagContext, ae as PalbaseFlagSource, af as PalbaseFlagValue, ag as PalbaseFlagVariant, ah as PalbaseFlagsServiceClient, ai as PalbaseFunctionsClient, aj as PalbaseFunnelQueryInput, ak as PalbaseFunnelResult, al as PalbaseIdentifyTraits, am as PalbaseInboxClient, an as PalbaseInboxListOptions, ao as PalbaseInboxListResult, ap as PalbaseInboxMessage, aq as PalbaseInboxSendParams, ar as PalbaseInboxSendResponse, as as PalbaseInitialLink, at as PalbaseInvokeOptions, au as PalbaseLink, av as PalbaseLinkAnalytics, aw as PalbaseLinkDetails, ax as PalbaseLinksClient, ay as PalbaseListLinksOptions, az as PalbaseListLinksResult, aA as PalbaseListOptions, aB as PalbaseMatchParams, aC as PalbaseMultiChannelResponse, aD as PalbaseOverviewResult, aE as PalbasePreferences, aF as PalbasePreferencesClient, aG as PalbasePublicUrlResponse, aH as PalbasePushClient, aI as PalbasePushSendParams, aJ as PalbasePushSendResponse, aK as PalbaseQrCodeOptions, aL as PalbaseQuerySnapshot, aM as PalbaseRegisterDeviceParams, aN as PalbaseResult, aO as PalbaseRetentionQueryInput, aP as PalbaseRetentionResult, aQ as PalbaseSession, aR as PalbaseSetOverrideResult, aS as PalbaseSetOverridesResult, aT as PalbaseSignedUrlResponse, aU as PalbaseSmsClient, aV as PalbaseSmsSendParams, aW as PalbaseSmsSendResponse, aX as PalbaseTransformOptions, aY as PalbaseUpdateLinkParams, aZ as PalbaseUploadOptions, a_ as PalbaseUser, a$ as PalbaseUserDetailResult, b0 as PalbaseUsersQueryInput, b1 as PalbaseUsersResult, b2 as PalbaseVerifyRequestSignatureParams, b3 as PalbaseWhereOperator, b4 as TooManyRequests, b5 as TxClient, b6 as Unauthorized, b7 as defineMiddleware } from './endpoint-cDQyI6jH.js';
|
|
3
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
-
import { E as EnvTypedDatabase, S as SchemaDef } from './index-
|
|
5
|
-
export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, f as EnvTables, g as EnvTypedTable, h as EnvTypedTx, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, i as PalbaseExtension, j as PolicyBuilder, k as PolicyCommand, l as PolicyDef, m as PolicyMode, R as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TypedDB, q as TypedTable, r as TypedTx, s as boolean, t as defineSchema, u as enumType, v as integer, w as isPalbaseExtension, x as jsonb, y as makeTypedDB, z as policy, A as text, B as timestamp, D as uuid } from './index-
|
|
4
|
+
import { E as EnvTypedDatabase, S as SchemaDef } from './index-BfnIO5G-.js';
|
|
5
|
+
export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EnvServiceDatabase, f as EnvTables, g as EnvTypedTable, h as EnvTypedTx, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, i as PalbaseExtension, j as PolicyBuilder, k as PolicyCommand, l as PolicyDef, m as PolicyMode, R as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TypedDB, q as TypedTable, r as TypedTx, s as boolean, t as defineSchema, u as enumType, v as integer, w as isPalbaseExtension, x as jsonb, y as makeTypedDB, z as policy, A as text, B as timestamp, D as uuid } from './index-BfnIO5G-.js';
|
|
6
6
|
export { TableTypes, Tables } from './db/env.js';
|
|
7
|
-
import { ZodTypeAny } from 'zod';
|
|
7
|
+
import { ZodTypeAny, z } from 'zod';
|
|
8
8
|
export { z } from 'zod';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -50,9 +50,12 @@ export { z } from 'zod';
|
|
|
50
50
|
|
|
51
51
|
/** The set of live clients the runtime injects per request scope.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
|
|
54
|
+
* cannot hold a subscription socket — `subscribe()` lives on the client SDK).
|
|
55
|
+
*
|
|
56
|
+
* EXCLUDED on purpose: Functions, CMS, Links, Analytics, Auth. They are not
|
|
57
|
+
* exposed as backend handler singletons (auth lives on the client SDK; the rest
|
|
58
|
+
* are out of scope for backend endpoints). */
|
|
56
59
|
interface RuntimeServices {
|
|
57
60
|
Database: DBClient;
|
|
58
61
|
Documents: PalbaseDocsClient;
|
|
@@ -62,6 +65,7 @@ interface RuntimeServices {
|
|
|
62
65
|
Log: Logger;
|
|
63
66
|
Notifications: PalbaseNotificationsClient;
|
|
64
67
|
Flags: PalbaseFlagsClient;
|
|
68
|
+
Realtime: PalbaseRealtimeClient;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Per-request store. The persistent runtime runs each request inside
|
|
@@ -143,6 +147,19 @@ declare const Notifications: PalbaseNotificationsClient;
|
|
|
143
147
|
* await Flags.asService().setOverrideForUser("u_9", "x", true); // cross-user
|
|
144
148
|
*/
|
|
145
149
|
declare const Flags: PalbaseFlagsClient;
|
|
150
|
+
/**
|
|
151
|
+
* The Realtime broadcast singleton for the current request scope. Backend-side
|
|
152
|
+
* Realtime is BROADCAST-ONLY (a stateless handler can push but not subscribe —
|
|
153
|
+
* `subscribe()` lives on the client SDK's `pb.realtime`). Fire-and-forget:
|
|
154
|
+
* `broadcast` resolves once accepted (or with an `error`), never blocking the
|
|
155
|
+
* handler on subscribers.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* import { Realtime } from "@palbase/backend";
|
|
159
|
+
*
|
|
160
|
+
* await Realtime.broadcast("room:42", "message", { text, from: user.id });
|
|
161
|
+
*/
|
|
162
|
+
declare const Realtime: PalbaseRealtimeClient;
|
|
146
163
|
|
|
147
164
|
/**
|
|
148
165
|
* env-gen.ts — generate the `palbase-env.d.ts` text from a `defineSchema()`
|
|
@@ -695,6 +712,20 @@ interface RouteOptions {
|
|
|
695
712
|
/** Per-route rate limit. */
|
|
696
713
|
rateLimit?: RateLimitConfig;
|
|
697
714
|
}
|
|
715
|
+
/** One inferred throw site: the error CLASS name (e.g. "TodoLocked") and its
|
|
716
|
+
* wire code (e.g. "todo_locked"). `status`, `hasData`, and the data JSON schema
|
|
717
|
+
* are NOT carried here — they resolve from the error registry by `code` at
|
|
718
|
+
* extract/openapi time (single source of truth). */
|
|
719
|
+
interface ThrowDescriptor {
|
|
720
|
+
name: string;
|
|
721
|
+
code: string;
|
|
722
|
+
}
|
|
723
|
+
/** Attach the inferred throw descriptors to the route for `fnName` (called by
|
|
724
|
+
* the stager-injected IIFE that carries the throw analysis result — the
|
|
725
|
+
* `recordReturn` twin). If the route does not exist yet, the descriptors are
|
|
726
|
+
* buffered (THROWS_BUFFER) and drained into the route by `recordRoute` when the
|
|
727
|
+
* method decorator runs. */
|
|
728
|
+
declare function recordThrows(target: object, fnName: string, throws: ThrowDescriptor[]): void;
|
|
698
729
|
|
|
699
730
|
/** A legacy method decorator. */
|
|
700
731
|
type MethodDecorator = (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
@@ -737,6 +768,46 @@ declare function TraceId(): ParameterDecorator;
|
|
|
737
768
|
/** `@Req()` — inject the raw request object (escape hatch, `: PBRequest`). */
|
|
738
769
|
declare function Req(): ParameterDecorator;
|
|
739
770
|
|
|
771
|
+
/** One registered error: the wire code, HTTP status, the class name the
|
|
772
|
+
* analyzer sees, the optional data payload schema, and whether it is one of the
|
|
773
|
+
* pre-seeded built-in named classes. */
|
|
774
|
+
interface RegisteredError {
|
|
775
|
+
code: string;
|
|
776
|
+
status: number;
|
|
777
|
+
className: string;
|
|
778
|
+
dataSchema?: ZodTypeAny;
|
|
779
|
+
/** JSON.stringify of the converted JSON schema — equal digest ⇔ the spec
|
|
780
|
+
* twins would emit an identical `data` schema for this error. */
|
|
781
|
+
dataDigest?: string;
|
|
782
|
+
builtin: boolean;
|
|
783
|
+
}
|
|
784
|
+
declare function getErrorRegistry(): Map<string, RegisteredError>;
|
|
785
|
+
/** Class returned for schema-bearing errors: ctor(data, message?). */
|
|
786
|
+
interface DefinedErrorWithData<S extends ZodTypeAny> {
|
|
787
|
+
new (data: z.input<S>, message?: string): HttpError;
|
|
788
|
+
readonly code: string;
|
|
789
|
+
readonly status: number;
|
|
790
|
+
}
|
|
791
|
+
/** Class returned for schema-less errors: ctor(message?). */
|
|
792
|
+
interface DefinedError {
|
|
793
|
+
new (message?: string): HttpError;
|
|
794
|
+
readonly code: string;
|
|
795
|
+
readonly status: number;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Define a project error class. MUST be called with literal args (string
|
|
799
|
+
* literal `code`, numeric literal `status`) at module top level — the deploy
|
|
800
|
+
* stager's static analyzer reads those literals to resolve throw sites.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* // models/todos/errors.ts
|
|
804
|
+
* export const TodoLocked = defineError("todo_locked", 409, z.object({ retryAfter: z.number() }));
|
|
805
|
+
* // services/todo.service.ts
|
|
806
|
+
* throw new TodoLocked({ retryAfter: 30 });
|
|
807
|
+
*/
|
|
808
|
+
declare function defineError<S extends ZodTypeAny>(code: string, status: number, dataSchema: S): DefinedErrorWithData<S>;
|
|
809
|
+
declare function defineError(code: string, status: number): DefinedError;
|
|
810
|
+
|
|
740
811
|
/** Non-service, per-invocation data for background worker handlers.
|
|
741
812
|
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
742
813
|
interface WorkerMeta {
|
|
@@ -1189,4 +1260,4 @@ declare const documents: {
|
|
|
1189
1260
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1190
1261
|
};
|
|
1191
1262
|
|
|
1192
|
-
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseStorageClient, Param, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TraceId, type TwilioOptions, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineFlags, defineJob, defineNotifications, defineStorage, defineWebhook, defineWorker, documents, flag, makeEnvDts, parseFileSizeLimit, reservedSecretKey, storage };
|
|
1263
|
+
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, type ThrowDescriptor, TraceId, type TwilioOptions, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineWebhook, defineWorker, documents, flag, getErrorRegistry, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage };
|
package/dist/index.js
CHANGED
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
Log,
|
|
7
7
|
Notifications,
|
|
8
8
|
Queue,
|
|
9
|
+
Realtime,
|
|
9
10
|
Storage,
|
|
10
11
|
__getRuntime,
|
|
11
12
|
__requestALS,
|
|
12
13
|
__runWithRuntime,
|
|
13
14
|
__setRuntime
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SWT2QR5F.js";
|
|
15
16
|
import {
|
|
16
17
|
EXTENSION_DEPENDENCIES,
|
|
17
18
|
PALBASE_EXTENSIONS,
|
|
@@ -399,6 +400,7 @@ function Controller(basePath, options = {}) {
|
|
|
399
400
|
var ROUTES = /* @__PURE__ */ Symbol.for("palbase.backend.routes");
|
|
400
401
|
var PARAM_BUFFER = /* @__PURE__ */ Symbol.for("palbase.backend.paramBuffer");
|
|
401
402
|
var RETURN_BUFFER = /* @__PURE__ */ Symbol.for("palbase.backend.returnBuffer");
|
|
403
|
+
var THROWS_BUFFER = /* @__PURE__ */ Symbol.for("palbase.backend.throwsBuffer");
|
|
402
404
|
function carrierOf(target) {
|
|
403
405
|
const ctor = typeof target === "function" ? target : target.constructor ?? target;
|
|
404
406
|
return ctor;
|
|
@@ -425,6 +427,10 @@ function recordRoute(target, fnName, method, subpath, options) {
|
|
|
425
427
|
if (returnBuffer && returnBuffer[fnName] !== void 0) {
|
|
426
428
|
route.returnSchema = returnBuffer[fnName];
|
|
427
429
|
}
|
|
430
|
+
const throwsBuffer = carrier[THROWS_BUFFER];
|
|
431
|
+
if (throwsBuffer && throwsBuffer[fnName] !== void 0) {
|
|
432
|
+
route.throws = throwsBuffer[fnName];
|
|
433
|
+
}
|
|
428
434
|
routes.push(route);
|
|
429
435
|
}
|
|
430
436
|
function recordParam(target, fnName, meta) {
|
|
@@ -440,6 +446,20 @@ function recordParam(target, fnName, meta) {
|
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
}
|
|
449
|
+
function recordThrows(target, fnName, throws) {
|
|
450
|
+
const carrier = carrierOf(target);
|
|
451
|
+
const routes = carrier[ROUTES];
|
|
452
|
+
const route = routes?.find((r) => r.fnName === fnName);
|
|
453
|
+
if (route) {
|
|
454
|
+
route.throws = throws;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (!Object.prototype.hasOwnProperty.call(carrier, THROWS_BUFFER)) {
|
|
458
|
+
carrier[THROWS_BUFFER] = {};
|
|
459
|
+
}
|
|
460
|
+
const throwsBuffer = carrier[THROWS_BUFFER];
|
|
461
|
+
if (throwsBuffer) throwsBuffer[fnName] = throws;
|
|
462
|
+
}
|
|
443
463
|
|
|
444
464
|
// src/decorators/methods.ts
|
|
445
465
|
function makeMethodDecorator(method) {
|
|
@@ -556,8 +576,8 @@ function defaultMessage(name) {
|
|
|
556
576
|
return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();
|
|
557
577
|
}
|
|
558
578
|
var BadRequest = class extends NamedHttpError {
|
|
559
|
-
constructor(
|
|
560
|
-
super(400, "bad_request", "BadRequest", message,
|
|
579
|
+
constructor(data, message) {
|
|
580
|
+
super(400, "bad_request", "BadRequest", message, void 0, data);
|
|
561
581
|
}
|
|
562
582
|
};
|
|
563
583
|
var Unauthorized = class extends NamedHttpError {
|
|
@@ -581,11 +601,119 @@ var Conflict = class extends NamedHttpError {
|
|
|
581
601
|
}
|
|
582
602
|
};
|
|
583
603
|
var TooManyRequests = class extends NamedHttpError {
|
|
584
|
-
constructor(
|
|
585
|
-
super(429, "too_many_requests", "TooManyRequests", message,
|
|
604
|
+
constructor(data, message) {
|
|
605
|
+
super(429, "too_many_requests", "TooManyRequests", message, void 0, data);
|
|
586
606
|
}
|
|
587
607
|
};
|
|
588
608
|
|
|
609
|
+
// src/error-registry.ts
|
|
610
|
+
import {
|
|
611
|
+
OpenAPIRegistry,
|
|
612
|
+
OpenApiGeneratorV31,
|
|
613
|
+
extendZodWithOpenApi
|
|
614
|
+
} from "@asteasolutions/zod-to-openapi";
|
|
615
|
+
import { z } from "zod";
|
|
616
|
+
extendZodWithOpenApi(z);
|
|
617
|
+
var ERROR_REGISTRY = /* @__PURE__ */ Symbol.for("palbase.backend.errorRegistry");
|
|
618
|
+
var BUILTIN_DATA_SCHEMAS = {
|
|
619
|
+
bad_request: z.object({
|
|
620
|
+
fields: z.array(z.object({ field: z.string(), message: z.string() }))
|
|
621
|
+
}),
|
|
622
|
+
too_many_requests: z.object({ retryAfter: z.number().int() })
|
|
623
|
+
};
|
|
624
|
+
function getErrorRegistry() {
|
|
625
|
+
const g = globalThis;
|
|
626
|
+
if (!g[ERROR_REGISTRY]) {
|
|
627
|
+
const m = /* @__PURE__ */ new Map();
|
|
628
|
+
for (const [code, status, className] of [
|
|
629
|
+
["bad_request", 400, "BadRequest"],
|
|
630
|
+
["unauthorized", 401, "Unauthorized"],
|
|
631
|
+
["forbidden", 403, "Forbidden"],
|
|
632
|
+
["not_found", 404, "NotFound"],
|
|
633
|
+
["conflict", 409, "Conflict"],
|
|
634
|
+
["too_many_requests", 429, "TooManyRequests"]
|
|
635
|
+
]) {
|
|
636
|
+
const dataSchema = BUILTIN_DATA_SCHEMAS[code];
|
|
637
|
+
m.set(code, {
|
|
638
|
+
code,
|
|
639
|
+
status,
|
|
640
|
+
className,
|
|
641
|
+
builtin: true,
|
|
642
|
+
...dataSchema ? { dataSchema, dataDigest: digestOf(code, dataSchema) } : {}
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
g[ERROR_REGISTRY] = m;
|
|
646
|
+
}
|
|
647
|
+
return g[ERROR_REGISTRY];
|
|
648
|
+
}
|
|
649
|
+
function defineError(code, status, dataSchema) {
|
|
650
|
+
if (!Number.isInteger(status) || status < 400 || status > 599) {
|
|
651
|
+
throw new Error(
|
|
652
|
+
`defineError: status for "${code}" must be a 4xx/5xx integer, got ${status} \u2014 error responses must not clobber success responses in the project spec.`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
const registry2 = getErrorRegistry();
|
|
656
|
+
const existing = registry2.get(code);
|
|
657
|
+
const className = defaultClassName(code);
|
|
658
|
+
const dataDigest = dataSchema ? digestOf(code, dataSchema) : void 0;
|
|
659
|
+
if (existing) {
|
|
660
|
+
const sameShape = existing.status === status && !existing.builtin && existing.dataDigest === dataDigest;
|
|
661
|
+
if (!sameShape) {
|
|
662
|
+
throw new Error(
|
|
663
|
+
`defineError: duplicate error code "${code}" with a different shape (existing: status ${existing.status}${existing.builtin ? ", built-in" : ""}${existing.status === status && !existing.builtin ? ", different data schema" : ""}). Error codes are project-unique.`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
const makeWithData = (schema) => class extends HttpError {
|
|
668
|
+
static code = code;
|
|
669
|
+
static status = status;
|
|
670
|
+
constructor(data, message) {
|
|
671
|
+
super(status, code, message ?? humanize(code), schema.parse(data));
|
|
672
|
+
this.name = className;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
const makeWithoutData = () => class extends HttpError {
|
|
676
|
+
static code = code;
|
|
677
|
+
static status = status;
|
|
678
|
+
constructor(message) {
|
|
679
|
+
super(status, code, message ?? humanize(code));
|
|
680
|
+
this.name = className;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const cls = dataSchema ? makeWithData(dataSchema) : makeWithoutData();
|
|
684
|
+
Object.defineProperty(cls, "name", { value: className });
|
|
685
|
+
registry2.set(code, {
|
|
686
|
+
code,
|
|
687
|
+
status,
|
|
688
|
+
className,
|
|
689
|
+
builtin: false,
|
|
690
|
+
...dataSchema ? { dataSchema } : {},
|
|
691
|
+
...dataDigest !== void 0 ? { dataDigest } : {}
|
|
692
|
+
});
|
|
693
|
+
return cls;
|
|
694
|
+
}
|
|
695
|
+
function digestOf(code, dataSchema) {
|
|
696
|
+
const TMP_REF = "__PalbaseErrorDataDigest";
|
|
697
|
+
const tmpRegistry = new OpenAPIRegistry();
|
|
698
|
+
tmpRegistry.register(TMP_REF, z.object({ data: dataSchema }).openapi(TMP_REF));
|
|
699
|
+
const generated = new OpenApiGeneratorV31(tmpRegistry.definitions).generateComponents();
|
|
700
|
+
const out = generated.components?.schemas?.[TMP_REF];
|
|
701
|
+
const digest = JSON.stringify(out ?? null);
|
|
702
|
+
if (digest.includes('"$ref"')) {
|
|
703
|
+
throw new Error(
|
|
704
|
+
`defineError: dataSchema for "${code}" carries .openapi(refId) metadata \u2014 it would emit dangling $ref pointers in the project spec. Use a plain zod schema (z.object({...})) without .openapi(...).`
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
return digest;
|
|
708
|
+
}
|
|
709
|
+
function defaultClassName(code) {
|
|
710
|
+
return code.split("_").map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
711
|
+
}
|
|
712
|
+
function humanize(code) {
|
|
713
|
+
const s = code.replace(/_/g, " ");
|
|
714
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
715
|
+
}
|
|
716
|
+
|
|
589
717
|
// src/worker.ts
|
|
590
718
|
var VALID_WORKER_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
591
719
|
var WORKER_DEFAULTS = {
|
|
@@ -884,7 +1012,7 @@ var documents = {
|
|
|
884
1012
|
};
|
|
885
1013
|
|
|
886
1014
|
// src/index.ts
|
|
887
|
-
import { z } from "zod";
|
|
1015
|
+
import { z as z2 } from "zod";
|
|
888
1016
|
export {
|
|
889
1017
|
BadRequest,
|
|
890
1018
|
Body,
|
|
@@ -918,6 +1046,7 @@ export {
|
|
|
918
1046
|
Query,
|
|
919
1047
|
Queue,
|
|
920
1048
|
RESERVED_SECRET_PREFIX,
|
|
1049
|
+
Realtime,
|
|
921
1050
|
Req,
|
|
922
1051
|
RequestId,
|
|
923
1052
|
Resource,
|
|
@@ -938,6 +1067,7 @@ export {
|
|
|
938
1067
|
boolean,
|
|
939
1068
|
bucket,
|
|
940
1069
|
buildProvider,
|
|
1070
|
+
defineError,
|
|
941
1071
|
defineFlags,
|
|
942
1072
|
defineJob,
|
|
943
1073
|
defineMiddleware,
|
|
@@ -949,6 +1079,7 @@ export {
|
|
|
949
1079
|
documents,
|
|
950
1080
|
enumType,
|
|
951
1081
|
flag,
|
|
1082
|
+
getErrorRegistry,
|
|
952
1083
|
integer,
|
|
953
1084
|
isPalbaseExtension,
|
|
954
1085
|
jsonb,
|
|
@@ -956,11 +1087,12 @@ export {
|
|
|
956
1087
|
makeTypedDB,
|
|
957
1088
|
parseFileSizeLimit,
|
|
958
1089
|
policy,
|
|
1090
|
+
recordThrows,
|
|
959
1091
|
reservedSecretKey,
|
|
960
1092
|
storage,
|
|
961
1093
|
text,
|
|
962
1094
|
timestamp,
|
|
963
1095
|
uuid,
|
|
964
|
-
z
|
|
1096
|
+
z2 as z
|
|
965
1097
|
};
|
|
966
1098
|
//# sourceMappingURL=index.js.map
|