@palbase/backend 13.0.0 → 14.1.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-XATG7BRC.js → chunk-I72YYSEI.js} +1 -3
- package/dist/chunk-I72YYSEI.js.map +1 -0
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/{endpoint-Ck4hER_7.d.cts → endpoint-D2yR2RD1.d.cts} +23 -9
- package/dist/{endpoint-Ck4hER_7.d.ts → endpoint-D2yR2RD1.d.ts} +23 -9
- package/dist/{index-BJAf1uPC.d.cts → index-BcA7wqur.d.cts} +1 -1
- package/dist/{index-l7DhBDtn.d.ts → index-CB8TARW4.d.ts} +1 -1
- package/dist/index.cjs +22 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -71
- package/dist/index.d.ts +40 -71
- package/dist/index.js +20 -39
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +0 -6
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +1 -2
- package/dist/test/index.d.ts +1 -2
- package/dist/test/index.js +1 -6
- package/dist/test/index.js.map +1 -1
- package/docs/README.md +2 -4
- package/docs/auth.md +136 -0
- package/docs/background.md +15 -39
- package/docs/config.md +51 -10
- package/docs/database.md +11 -3
- package/docs/events.md +1 -1
- package/docs/llms-full.txt +383 -59
- package/docs/llms.txt +3 -1
- package/docs/migrations.md +30 -0
- package/docs/schema.md +31 -3
- package/docs/services.md +0 -9
- package/package.json +4 -2
- package/dist/chunk-XATG7BRC.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient,
|
|
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 Materialized, o as Middleware, p as MiddlewareContext, q as MiddlewareHandler, N as NotFound, P as PBRequest, r as PalError, s as PalbaseAnalyticsClient, t as PalbaseAnalyticsManagementNamespace, u as PalbaseAnalyticsProperties, v as PalbaseAnalyticsQueryNamespace, w as PalbaseAttestAndroidParams, x as PalbaseAttestAndroidResult, y as PalbaseAttestiOSParams, z as PalbaseAttestiOSResult, G as PalbaseAuthClient, I as PalbaseBatchOverrideOperation, J as PalbaseBatchSetOverridesResult, K as PalbaseBindDeviceParams, O as PalbaseBucketClient,
|
|
1
|
+
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, e as PalbaseRealtimeClient, D as DBClient, f as PalbaseStorageClient, A as AuthSpec, R as RateLimitConfig, H as HttpError } from './endpoint-D2yR2RD1.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 Materialized, o as Middleware, p as MiddlewareContext, q as MiddlewareHandler, N as NotFound, P as PBRequest, r as PalError, s as PalbaseAnalyticsClient, t as PalbaseAnalyticsManagementNamespace, u as PalbaseAnalyticsProperties, v as PalbaseAnalyticsQueryNamespace, w as PalbaseAttestAndroidParams, x as PalbaseAttestAndroidResult, y as PalbaseAttestiOSParams, z as PalbaseAttestiOSResult, G as PalbaseAuthClient, I as PalbaseBatchOverrideOperation, J as PalbaseBatchSetOverridesResult, K as PalbaseBindDeviceParams, O as PalbaseBucketClient, Q as PalbaseClearAllOverridesResult, S as PalbaseClearOverrideResult, T as PalbaseCohortQueryInput, V as PalbaseCohortResult, W as PalbaseCollectionRef, X as PalbaseCountQueryInput, Y as PalbaseCountResult, Z as PalbaseCreateLinkParams, _ as PalbaseDeviceInfo, $ as PalbaseDeviceTokenView, a0 as PalbaseDocumentRef, a1 as PalbaseDocumentSnapshot, a2 as PalbaseEmailClient, a3 as PalbaseEmailSendParams, a4 as PalbaseEmailSendResponse, a5 as PalbaseEventNamesResult, a6 as PalbaseEventsQueryInput, a7 as PalbaseEventsResult, a8 as PalbaseFileObject, a9 as PalbaseFlag, aa as PalbaseFlagContext, ab as PalbaseFlagSource, ac as PalbaseFlagValue, ad as PalbaseFlagVariant, ae as PalbaseFlagsServiceClient, af as PalbaseFunctionsClient, ag as PalbaseFunnelQueryInput, ah as PalbaseFunnelResult, ai as PalbaseIdentifyTraits, aj as PalbaseInboxClient, ak as PalbaseInboxListOptions, al as PalbaseInboxListResult, am as PalbaseInboxMessage, an as PalbaseInboxSendParams, ao as PalbaseInboxSendResponse, ap as PalbaseInitialLink, aq as PalbaseInvokeOptions, ar as PalbaseLink, as as PalbaseLinkAnalytics, at as PalbaseLinkDetails, au as PalbaseLinksClient, av as PalbaseListLinksOptions, aw as PalbaseListLinksResult, ax as PalbaseListOptions, ay as PalbaseMatchParams, az as PalbaseMultiChannelResponse, aA as PalbaseOverviewResult, aB as PalbasePreferences, aC as PalbasePreferencesClient, aD as PalbasePublicUrlResponse, aE as PalbasePushClient, aF as PalbasePushSendParams, aG as PalbasePushSendResponse, aH as PalbaseQrCodeOptions, aI as PalbaseQuerySnapshot, aJ as PalbaseRegisterDeviceParams, aK as PalbaseResult, aL as PalbaseRetentionQueryInput, aM as PalbaseRetentionResult, aN as PalbaseSession, aO as PalbaseSetOverrideResult, aP as PalbaseSetOverridesResult, aQ as PalbaseSignedUrlResponse, aR as PalbaseSmsClient, aS as PalbaseSmsSendParams, aT as PalbaseSmsSendResponse, aU as PalbaseTransformOptions, aV as PalbaseUpdateLinkParams, aW as PalbaseUploadOptions, aX as PalbaseUser, aY as PalbaseUserDetailResult, aZ as PalbaseUsersQueryInput, a_ as PalbaseUsersResult, a$ as PalbaseVerifyRequestSignatureParams, b0 as PalbaseWhereOperator, b1 as Ref, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, b7 as TxPlanBody, b8 as TxPlanError, b9 as TxPlanHandle, ba as TxPlanOpResult, bb as TxPlanRejection, bc as TxPlanResponse, bd as TxRefError, be as TxRow, bf as TxRows, bg as TxSelectOptions, bh as TxSetShape, bi as TxSetValue, bj as TxTable, bk as TxWhere, bl as TxWireExpr, bm as TxWireGuard, bn as TxWireOp, bo as TxWireRef, bp as TxWireValue, bq as Unauthorized, U as UserT, br as VerifiedDevice, bs as dec, bt as defineMiddleware, bu as inc, bv as now } from './endpoint-D2yR2RD1.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, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, D as numeric, F as policy, G as raw, H as text, J as timestamp, K as uuid } from './index-
|
|
4
|
+
import { E as EnvTypedDatabase, S as SchemaDef } from './index-BcA7wqur.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, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, D as numeric, F as policy, G as raw, H as text, J as timestamp, K as uuid } from './index-BcA7wqur.cjs';
|
|
6
6
|
import { EntitlementKey, LimitKey } from './purchases/keys.cjs';
|
|
7
7
|
import { TableTypes, Tables } from './db/env.cjs';
|
|
8
8
|
import { ZodTypeAny, z } from 'zod';
|
|
@@ -117,7 +117,6 @@ interface RuntimeServices {
|
|
|
117
117
|
Documents: PalbaseDocsClient;
|
|
118
118
|
Storage: PalbaseStorageClient;
|
|
119
119
|
Cache: CacheClient;
|
|
120
|
-
Queue: QueueClient;
|
|
121
120
|
Log: Logger;
|
|
122
121
|
Notifications: PalbaseNotificationsClient;
|
|
123
122
|
Flags: PalbaseFlagsClient;
|
|
@@ -199,8 +198,6 @@ declare const Documents: PalbaseDocsClient;
|
|
|
199
198
|
declare const Storage: PalbaseStorageClient;
|
|
200
199
|
/** JSON-typed cache (get/set/incr/getOrSet). */
|
|
201
200
|
declare const Cache: CacheClient;
|
|
202
|
-
/** Background job queue. */
|
|
203
|
-
declare const Queue: QueueClient;
|
|
204
201
|
/** Structured logger. */
|
|
205
202
|
declare const Log: Logger;
|
|
206
203
|
/** Push / email / SMS / in-app notifications. */
|
|
@@ -504,18 +501,20 @@ declare function defineStorage(input: StorageInput): StorageConfig;
|
|
|
504
501
|
/**
|
|
505
502
|
* egress.ts — the tenant outbound-HTTP allowlist config-as-code DSL.
|
|
506
503
|
*
|
|
507
|
-
* `defineEgress({ hosts })` declares the external hosts a backend may
|
|
508
|
-
* config/egress.ts default-exports
|
|
509
|
-
* (SchemaExtractor.EvaluateConfigFile →
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
504
|
+
* `defineEgress({ hosts, timeoutMs })` declares the external hosts a backend may
|
|
505
|
+
* fetch(), and how long a single call may take. config/egress.ts default-exports
|
|
506
|
+
* it; the deploy evals it to JSON (SchemaExtractor.EvaluateConfigFile →
|
|
507
|
+
* config_extract.js) and bakes both into the artifact manifest → the isolate
|
|
508
|
+
* loader → Tenant.egressAllow / Tenant.egressTimeoutMs. The tenantFetch
|
|
509
|
+
* capability rejects any host NOT on the list. NO config/egress.ts (or an empty
|
|
510
|
+
* list) ⇒ the backend has NO outbound network — fail-closed.
|
|
513
511
|
*
|
|
514
512
|
* @example
|
|
515
513
|
* // config/egress.ts
|
|
516
514
|
* import { defineEgress } from "@palbase/backend";
|
|
517
515
|
* export default defineEgress({
|
|
518
|
-
* hosts: ["api.
|
|
516
|
+
* hosts: ["api.openai.com"],
|
|
517
|
+
* timeoutMs: 90_000, // a slow LLM call; default 30_000
|
|
519
518
|
* });
|
|
520
519
|
*
|
|
521
520
|
* Each host is a bare hostname (no scheme/port/path/wildcard). A leading dot,
|
|
@@ -523,18 +522,43 @@ declare function defineStorage(input: StorageInput): StorageConfig;
|
|
|
523
522
|
* https-only on :443; the deploy REJECTS a malformed / IP-literal / internal host
|
|
524
523
|
* (fail-closed — a security allowlist is never best-effort).
|
|
525
524
|
*
|
|
526
|
-
*
|
|
525
|
+
* `timeoutMs` is a CEILING, not a grant: the call still ends when the INVOCATION
|
|
526
|
+
* ends. A job may run up to its own `@Job({ timeout })` (max 300s), while a
|
|
527
|
+
* request is additionally bounded by the gateway. Setting 300_000 on a route
|
|
528
|
+
* whose request dies earlier buys nothing — size it to the caller.
|
|
529
|
+
*
|
|
530
|
+
* Response bodies are BUFFERED whole (5 MB cap) before your fetch() resolves, so
|
|
531
|
+
* a streaming/SSE upstream gives you no partial output and no earlier
|
|
532
|
+
* first-byte: the entire stream must complete inside `timeoutMs`.
|
|
533
|
+
*
|
|
534
|
+
* Emits: { __config: "egress", hosts: [...], timeoutMs?: number }
|
|
527
535
|
*/
|
|
528
536
|
/** The discriminant written under `__config` so the deploy eval knows the kind. */
|
|
529
537
|
declare const EGRESS_CONFIG_KIND: "egress";
|
|
538
|
+
/**
|
|
539
|
+
* Bounds on `timeoutMs`, duplicated (deliberately) in the deploy's
|
|
540
|
+
* ParseEgressConfig. This copy shapes the authoring error; that one is
|
|
541
|
+
* authoritative and fail-closed. They must agree — a value this accepts and the
|
|
542
|
+
* deploy rejects is a broken deploy the author cannot see coming.
|
|
543
|
+
*/
|
|
544
|
+
declare const EGRESS_TIMEOUT_MIN_MS = 1000;
|
|
545
|
+
declare const EGRESS_TIMEOUT_MAX_MS = 300000;
|
|
546
|
+
/** Applied when `timeoutMs` is omitted. Also spelled in the isolate capability. */
|
|
547
|
+
declare const EGRESS_TIMEOUT_DEFAULT_MS = 30000;
|
|
530
548
|
/** The author-facing input to defineEgress. */
|
|
531
549
|
interface EgressInput {
|
|
532
550
|
hosts: string[];
|
|
551
|
+
/**
|
|
552
|
+
* Per-call ceiling for an outbound fetch, in milliseconds.
|
|
553
|
+
* 1_000..300_000; omitted ⇒ 30_000.
|
|
554
|
+
*/
|
|
555
|
+
timeoutMs?: number;
|
|
533
556
|
}
|
|
534
557
|
/** The evaluated config/egress.ts default export (what the deploy reads). */
|
|
535
558
|
interface EgressConfig {
|
|
536
559
|
__config: typeof EGRESS_CONFIG_KIND;
|
|
537
560
|
hosts: string[];
|
|
561
|
+
timeoutMs?: number;
|
|
538
562
|
}
|
|
539
563
|
/**
|
|
540
564
|
* Declare the backend's outbound-HTTP allowlist. Client-side this only shapes +
|
|
@@ -1396,61 +1420,6 @@ interface DefinedError {
|
|
|
1396
1420
|
declare function defineError<S extends ZodTypeAny>(code: string, status: number, dataSchema: S): DefinedErrorWithData<S>;
|
|
1397
1421
|
declare function defineError(code: string, status: number): DefinedError;
|
|
1398
1422
|
|
|
1399
|
-
/** Non-service, per-invocation data for background worker handlers.
|
|
1400
|
-
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
1401
|
-
interface WorkerMeta {
|
|
1402
|
-
/** Environment-scoped env vars. */
|
|
1403
|
-
env: Record<string, string>;
|
|
1404
|
-
/** The user that enqueued the job, if any (background jobs are usually system-initiated). */
|
|
1405
|
-
user: User$1 | null;
|
|
1406
|
-
/** Per-invocation id for correlation. */
|
|
1407
|
-
requestId: string;
|
|
1408
|
-
/** The globally unique Environment runtime identifier. */
|
|
1409
|
-
environmentId: string;
|
|
1410
|
-
}
|
|
1411
|
-
/** Backoff strategy for worker retries. */
|
|
1412
|
-
type BackoffStrategy = "exponential" | "linear" | "fixed";
|
|
1413
|
-
/** Configuration for a background worker. */
|
|
1414
|
-
interface WorkerConfig<TPayload = unknown> {
|
|
1415
|
-
/** Worker name — must be unique across the project. */
|
|
1416
|
-
name: string;
|
|
1417
|
-
/** Maximum number of retries before sending to dead letter queue. Defaults to 3. */
|
|
1418
|
-
retry?: number;
|
|
1419
|
-
/** Execution timeout in seconds. Defaults to 30. */
|
|
1420
|
-
timeout?: number;
|
|
1421
|
-
/** Backoff strategy between retries. Defaults to "exponential". */
|
|
1422
|
-
backoff?: BackoffStrategy;
|
|
1423
|
-
/** Handler function that processes the job payload. */
|
|
1424
|
-
handler: (payload: TPayload, meta: WorkerMeta) => Promise<void>;
|
|
1425
|
-
}
|
|
1426
|
-
/** Resolved worker configuration with defaults applied. */
|
|
1427
|
-
interface ResolvedWorkerConfig<TPayload = unknown> {
|
|
1428
|
-
name: string;
|
|
1429
|
-
retry: number;
|
|
1430
|
-
timeout: number;
|
|
1431
|
-
backoff: BackoffStrategy;
|
|
1432
|
-
handler: (payload: TPayload, meta: WorkerMeta) => Promise<void>;
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Define a background worker that processes jobs from the queue.
|
|
1436
|
-
*
|
|
1437
|
-
* Workers are placed in the `workers/` directory and auto-discovered at deploy time.
|
|
1438
|
-
*
|
|
1439
|
-
* @example
|
|
1440
|
-
* ```ts
|
|
1441
|
-
* export default defineWorker({
|
|
1442
|
-
* name: "send-email",
|
|
1443
|
-
* retry: 5,
|
|
1444
|
-
* timeout: 60,
|
|
1445
|
-
* backoff: "exponential",
|
|
1446
|
-
* handler: async (payload: { to: string; subject: string }, meta) => {
|
|
1447
|
-
* await sendEmail(payload.to, payload.subject);
|
|
1448
|
-
* },
|
|
1449
|
-
* });
|
|
1450
|
-
* ```
|
|
1451
|
-
*/
|
|
1452
|
-
declare function defineWorker<TPayload = unknown>(config: WorkerConfig<TPayload>): ResolvedWorkerConfig<TPayload>;
|
|
1453
|
-
|
|
1454
1423
|
/** Non-service, per-invocation data for job handlers.
|
|
1455
1424
|
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
1456
1425
|
interface JobMeta {
|
|
@@ -1746,4 +1715,4 @@ declare const documents: {
|
|
|
1746
1715
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1747
1716
|
};
|
|
1748
1717
|
|
|
1749
|
-
export { type AcsOptions, type ApnsOptions,
|
|
1718
|
+
export { type AcsOptions, type ApnsOptions, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, EGRESS_TIMEOUT_DEFAULT_MS, EGRESS_TIMEOUT_MAX_MS, EGRESS_TIMEOUT_MIN_MS, type EgressConfig, type EgressInput, EntitlementKey, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, Job, type JobMeta, type JobOptions, LimitKey, type LimitState, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, On, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderName, type ProviderOptions, Purchases, type PurchasesManifest, type PurchasesService, Put, Query, QueryParams, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedHook, type ResolvedJob, type ResolvedWebhook, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SignatureSpec, type SmtpOptions, Spend, type SpendMeta, type SpendOptions, Storage, type StorageConfig, type StorageInput, type StoreEnv, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineStorage, defineTestUsers, documents, entitlementFor, flag, getErrorRegistry, getJobConfig, getRoutes, getWebhookConfig, makeEnvDts, makePurchasesDts, parseFileSizeLimit, recordThrows, reservedSecretKey, spendFor, storage, testUser, validateUploadAgainstStorage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient,
|
|
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 Materialized, o as Middleware, p as MiddlewareContext, q as MiddlewareHandler, N as NotFound, P as PBRequest, r as PalError, s as PalbaseAnalyticsClient, t as PalbaseAnalyticsManagementNamespace, u as PalbaseAnalyticsProperties, v as PalbaseAnalyticsQueryNamespace, w as PalbaseAttestAndroidParams, x as PalbaseAttestAndroidResult, y as PalbaseAttestiOSParams, z as PalbaseAttestiOSResult, G as PalbaseAuthClient, I as PalbaseBatchOverrideOperation, J as PalbaseBatchSetOverridesResult, K as PalbaseBindDeviceParams, O as PalbaseBucketClient,
|
|
1
|
+
import { C as CacheClient, b as PalbaseDocsClient, c as PalbaseFlagsClient, L as Logger, d as PalbaseNotificationsClient, e as PalbaseRealtimeClient, D as DBClient, f as PalbaseStorageClient, A as AuthSpec, R as RateLimitConfig, H as HttpError } from './endpoint-D2yR2RD1.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 Materialized, o as Middleware, p as MiddlewareContext, q as MiddlewareHandler, N as NotFound, P as PBRequest, r as PalError, s as PalbaseAnalyticsClient, t as PalbaseAnalyticsManagementNamespace, u as PalbaseAnalyticsProperties, v as PalbaseAnalyticsQueryNamespace, w as PalbaseAttestAndroidParams, x as PalbaseAttestAndroidResult, y as PalbaseAttestiOSParams, z as PalbaseAttestiOSResult, G as PalbaseAuthClient, I as PalbaseBatchOverrideOperation, J as PalbaseBatchSetOverridesResult, K as PalbaseBindDeviceParams, O as PalbaseBucketClient, Q as PalbaseClearAllOverridesResult, S as PalbaseClearOverrideResult, T as PalbaseCohortQueryInput, V as PalbaseCohortResult, W as PalbaseCollectionRef, X as PalbaseCountQueryInput, Y as PalbaseCountResult, Z as PalbaseCreateLinkParams, _ as PalbaseDeviceInfo, $ as PalbaseDeviceTokenView, a0 as PalbaseDocumentRef, a1 as PalbaseDocumentSnapshot, a2 as PalbaseEmailClient, a3 as PalbaseEmailSendParams, a4 as PalbaseEmailSendResponse, a5 as PalbaseEventNamesResult, a6 as PalbaseEventsQueryInput, a7 as PalbaseEventsResult, a8 as PalbaseFileObject, a9 as PalbaseFlag, aa as PalbaseFlagContext, ab as PalbaseFlagSource, ac as PalbaseFlagValue, ad as PalbaseFlagVariant, ae as PalbaseFlagsServiceClient, af as PalbaseFunctionsClient, ag as PalbaseFunnelQueryInput, ah as PalbaseFunnelResult, ai as PalbaseIdentifyTraits, aj as PalbaseInboxClient, ak as PalbaseInboxListOptions, al as PalbaseInboxListResult, am as PalbaseInboxMessage, an as PalbaseInboxSendParams, ao as PalbaseInboxSendResponse, ap as PalbaseInitialLink, aq as PalbaseInvokeOptions, ar as PalbaseLink, as as PalbaseLinkAnalytics, at as PalbaseLinkDetails, au as PalbaseLinksClient, av as PalbaseListLinksOptions, aw as PalbaseListLinksResult, ax as PalbaseListOptions, ay as PalbaseMatchParams, az as PalbaseMultiChannelResponse, aA as PalbaseOverviewResult, aB as PalbasePreferences, aC as PalbasePreferencesClient, aD as PalbasePublicUrlResponse, aE as PalbasePushClient, aF as PalbasePushSendParams, aG as PalbasePushSendResponse, aH as PalbaseQrCodeOptions, aI as PalbaseQuerySnapshot, aJ as PalbaseRegisterDeviceParams, aK as PalbaseResult, aL as PalbaseRetentionQueryInput, aM as PalbaseRetentionResult, aN as PalbaseSession, aO as PalbaseSetOverrideResult, aP as PalbaseSetOverridesResult, aQ as PalbaseSignedUrlResponse, aR as PalbaseSmsClient, aS as PalbaseSmsSendParams, aT as PalbaseSmsSendResponse, aU as PalbaseTransformOptions, aV as PalbaseUpdateLinkParams, aW as PalbaseUploadOptions, aX as PalbaseUser, aY as PalbaseUserDetailResult, aZ as PalbaseUsersQueryInput, a_ as PalbaseUsersResult, a$ as PalbaseVerifyRequestSignatureParams, b0 as PalbaseWhereOperator, b1 as Ref, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, b7 as TxPlanBody, b8 as TxPlanError, b9 as TxPlanHandle, ba as TxPlanOpResult, bb as TxPlanRejection, bc as TxPlanResponse, bd as TxRefError, be as TxRow, bf as TxRows, bg as TxSelectOptions, bh as TxSetShape, bi as TxSetValue, bj as TxTable, bk as TxWhere, bl as TxWireExpr, bm as TxWireGuard, bn as TxWireOp, bo as TxWireRef, bp as TxWireValue, bq as Unauthorized, U as UserT, br as VerifiedDevice, bs as dec, bt as defineMiddleware, bu as inc, bv as now } from './endpoint-D2yR2RD1.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, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, D as numeric, F as policy, G as raw, H as text, J as timestamp, K as uuid } from './index-
|
|
4
|
+
import { E as EnvTypedDatabase, S as SchemaDef } from './index-CB8TARW4.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, I as InsertShape, O as OnDeleteAction, P as PALBASE_EXTENSIONS, h as PalbaseExtension, i as PolicyBuilder, j as PolicyCommand, k as PolicyDef, l as PolicyMode, R as RawConstraintDef, m as RowShape, n as SchemaInput, T as TableDef, o as TableInput, p as TxPlan, q as TxTables, r as TypedDB, s as TypedTable, t as TypedTx, u as bigint, v as boolean, w as defineSchema, x as enumType, y as integer, z as isPalbaseExtension, A as jsonb, B as makeTypedDB, D as numeric, F as policy, G as raw, H as text, J as timestamp, K as uuid } from './index-CB8TARW4.js';
|
|
6
6
|
import { EntitlementKey, LimitKey } from './purchases/keys.js';
|
|
7
7
|
import { TableTypes, Tables } from './db/env.js';
|
|
8
8
|
import { ZodTypeAny, z } from 'zod';
|
|
@@ -117,7 +117,6 @@ interface RuntimeServices {
|
|
|
117
117
|
Documents: PalbaseDocsClient;
|
|
118
118
|
Storage: PalbaseStorageClient;
|
|
119
119
|
Cache: CacheClient;
|
|
120
|
-
Queue: QueueClient;
|
|
121
120
|
Log: Logger;
|
|
122
121
|
Notifications: PalbaseNotificationsClient;
|
|
123
122
|
Flags: PalbaseFlagsClient;
|
|
@@ -199,8 +198,6 @@ declare const Documents: PalbaseDocsClient;
|
|
|
199
198
|
declare const Storage: PalbaseStorageClient;
|
|
200
199
|
/** JSON-typed cache (get/set/incr/getOrSet). */
|
|
201
200
|
declare const Cache: CacheClient;
|
|
202
|
-
/** Background job queue. */
|
|
203
|
-
declare const Queue: QueueClient;
|
|
204
201
|
/** Structured logger. */
|
|
205
202
|
declare const Log: Logger;
|
|
206
203
|
/** Push / email / SMS / in-app notifications. */
|
|
@@ -504,18 +501,20 @@ declare function defineStorage(input: StorageInput): StorageConfig;
|
|
|
504
501
|
/**
|
|
505
502
|
* egress.ts — the tenant outbound-HTTP allowlist config-as-code DSL.
|
|
506
503
|
*
|
|
507
|
-
* `defineEgress({ hosts })` declares the external hosts a backend may
|
|
508
|
-
* config/egress.ts default-exports
|
|
509
|
-
* (SchemaExtractor.EvaluateConfigFile →
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
504
|
+
* `defineEgress({ hosts, timeoutMs })` declares the external hosts a backend may
|
|
505
|
+
* fetch(), and how long a single call may take. config/egress.ts default-exports
|
|
506
|
+
* it; the deploy evals it to JSON (SchemaExtractor.EvaluateConfigFile →
|
|
507
|
+
* config_extract.js) and bakes both into the artifact manifest → the isolate
|
|
508
|
+
* loader → Tenant.egressAllow / Tenant.egressTimeoutMs. The tenantFetch
|
|
509
|
+
* capability rejects any host NOT on the list. NO config/egress.ts (or an empty
|
|
510
|
+
* list) ⇒ the backend has NO outbound network — fail-closed.
|
|
513
511
|
*
|
|
514
512
|
* @example
|
|
515
513
|
* // config/egress.ts
|
|
516
514
|
* import { defineEgress } from "@palbase/backend";
|
|
517
515
|
* export default defineEgress({
|
|
518
|
-
* hosts: ["api.
|
|
516
|
+
* hosts: ["api.openai.com"],
|
|
517
|
+
* timeoutMs: 90_000, // a slow LLM call; default 30_000
|
|
519
518
|
* });
|
|
520
519
|
*
|
|
521
520
|
* Each host is a bare hostname (no scheme/port/path/wildcard). A leading dot,
|
|
@@ -523,18 +522,43 @@ declare function defineStorage(input: StorageInput): StorageConfig;
|
|
|
523
522
|
* https-only on :443; the deploy REJECTS a malformed / IP-literal / internal host
|
|
524
523
|
* (fail-closed — a security allowlist is never best-effort).
|
|
525
524
|
*
|
|
526
|
-
*
|
|
525
|
+
* `timeoutMs` is a CEILING, not a grant: the call still ends when the INVOCATION
|
|
526
|
+
* ends. A job may run up to its own `@Job({ timeout })` (max 300s), while a
|
|
527
|
+
* request is additionally bounded by the gateway. Setting 300_000 on a route
|
|
528
|
+
* whose request dies earlier buys nothing — size it to the caller.
|
|
529
|
+
*
|
|
530
|
+
* Response bodies are BUFFERED whole (5 MB cap) before your fetch() resolves, so
|
|
531
|
+
* a streaming/SSE upstream gives you no partial output and no earlier
|
|
532
|
+
* first-byte: the entire stream must complete inside `timeoutMs`.
|
|
533
|
+
*
|
|
534
|
+
* Emits: { __config: "egress", hosts: [...], timeoutMs?: number }
|
|
527
535
|
*/
|
|
528
536
|
/** The discriminant written under `__config` so the deploy eval knows the kind. */
|
|
529
537
|
declare const EGRESS_CONFIG_KIND: "egress";
|
|
538
|
+
/**
|
|
539
|
+
* Bounds on `timeoutMs`, duplicated (deliberately) in the deploy's
|
|
540
|
+
* ParseEgressConfig. This copy shapes the authoring error; that one is
|
|
541
|
+
* authoritative and fail-closed. They must agree — a value this accepts and the
|
|
542
|
+
* deploy rejects is a broken deploy the author cannot see coming.
|
|
543
|
+
*/
|
|
544
|
+
declare const EGRESS_TIMEOUT_MIN_MS = 1000;
|
|
545
|
+
declare const EGRESS_TIMEOUT_MAX_MS = 300000;
|
|
546
|
+
/** Applied when `timeoutMs` is omitted. Also spelled in the isolate capability. */
|
|
547
|
+
declare const EGRESS_TIMEOUT_DEFAULT_MS = 30000;
|
|
530
548
|
/** The author-facing input to defineEgress. */
|
|
531
549
|
interface EgressInput {
|
|
532
550
|
hosts: string[];
|
|
551
|
+
/**
|
|
552
|
+
* Per-call ceiling for an outbound fetch, in milliseconds.
|
|
553
|
+
* 1_000..300_000; omitted ⇒ 30_000.
|
|
554
|
+
*/
|
|
555
|
+
timeoutMs?: number;
|
|
533
556
|
}
|
|
534
557
|
/** The evaluated config/egress.ts default export (what the deploy reads). */
|
|
535
558
|
interface EgressConfig {
|
|
536
559
|
__config: typeof EGRESS_CONFIG_KIND;
|
|
537
560
|
hosts: string[];
|
|
561
|
+
timeoutMs?: number;
|
|
538
562
|
}
|
|
539
563
|
/**
|
|
540
564
|
* Declare the backend's outbound-HTTP allowlist. Client-side this only shapes +
|
|
@@ -1396,61 +1420,6 @@ interface DefinedError {
|
|
|
1396
1420
|
declare function defineError<S extends ZodTypeAny>(code: string, status: number, dataSchema: S): DefinedErrorWithData<S>;
|
|
1397
1421
|
declare function defineError(code: string, status: number): DefinedError;
|
|
1398
1422
|
|
|
1399
|
-
/** Non-service, per-invocation data for background worker handlers.
|
|
1400
|
-
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
1401
|
-
interface WorkerMeta {
|
|
1402
|
-
/** Environment-scoped env vars. */
|
|
1403
|
-
env: Record<string, string>;
|
|
1404
|
-
/** The user that enqueued the job, if any (background jobs are usually system-initiated). */
|
|
1405
|
-
user: User$1 | null;
|
|
1406
|
-
/** Per-invocation id for correlation. */
|
|
1407
|
-
requestId: string;
|
|
1408
|
-
/** The globally unique Environment runtime identifier. */
|
|
1409
|
-
environmentId: string;
|
|
1410
|
-
}
|
|
1411
|
-
/** Backoff strategy for worker retries. */
|
|
1412
|
-
type BackoffStrategy = "exponential" | "linear" | "fixed";
|
|
1413
|
-
/** Configuration for a background worker. */
|
|
1414
|
-
interface WorkerConfig<TPayload = unknown> {
|
|
1415
|
-
/** Worker name — must be unique across the project. */
|
|
1416
|
-
name: string;
|
|
1417
|
-
/** Maximum number of retries before sending to dead letter queue. Defaults to 3. */
|
|
1418
|
-
retry?: number;
|
|
1419
|
-
/** Execution timeout in seconds. Defaults to 30. */
|
|
1420
|
-
timeout?: number;
|
|
1421
|
-
/** Backoff strategy between retries. Defaults to "exponential". */
|
|
1422
|
-
backoff?: BackoffStrategy;
|
|
1423
|
-
/** Handler function that processes the job payload. */
|
|
1424
|
-
handler: (payload: TPayload, meta: WorkerMeta) => Promise<void>;
|
|
1425
|
-
}
|
|
1426
|
-
/** Resolved worker configuration with defaults applied. */
|
|
1427
|
-
interface ResolvedWorkerConfig<TPayload = unknown> {
|
|
1428
|
-
name: string;
|
|
1429
|
-
retry: number;
|
|
1430
|
-
timeout: number;
|
|
1431
|
-
backoff: BackoffStrategy;
|
|
1432
|
-
handler: (payload: TPayload, meta: WorkerMeta) => Promise<void>;
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Define a background worker that processes jobs from the queue.
|
|
1436
|
-
*
|
|
1437
|
-
* Workers are placed in the `workers/` directory and auto-discovered at deploy time.
|
|
1438
|
-
*
|
|
1439
|
-
* @example
|
|
1440
|
-
* ```ts
|
|
1441
|
-
* export default defineWorker({
|
|
1442
|
-
* name: "send-email",
|
|
1443
|
-
* retry: 5,
|
|
1444
|
-
* timeout: 60,
|
|
1445
|
-
* backoff: "exponential",
|
|
1446
|
-
* handler: async (payload: { to: string; subject: string }, meta) => {
|
|
1447
|
-
* await sendEmail(payload.to, payload.subject);
|
|
1448
|
-
* },
|
|
1449
|
-
* });
|
|
1450
|
-
* ```
|
|
1451
|
-
*/
|
|
1452
|
-
declare function defineWorker<TPayload = unknown>(config: WorkerConfig<TPayload>): ResolvedWorkerConfig<TPayload>;
|
|
1453
|
-
|
|
1454
1423
|
/** Non-service, per-invocation data for job handlers.
|
|
1455
1424
|
* Services (Database, Log, …) are imported as singletons, not passed here. */
|
|
1456
1425
|
interface JobMeta {
|
|
@@ -1746,4 +1715,4 @@ declare const documents: {
|
|
|
1746
1715
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1747
1716
|
};
|
|
1748
1717
|
|
|
1749
|
-
export { type AcsOptions, type ApnsOptions,
|
|
1718
|
+
export { type AcsOptions, type ApnsOptions, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, EGRESS_TIMEOUT_DEFAULT_MS, EGRESS_TIMEOUT_MAX_MS, EGRESS_TIMEOUT_MIN_MS, type EgressConfig, type EgressInput, EntitlementKey, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, Job, type JobMeta, type JobOptions, LimitKey, type LimitState, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, On, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderName, type ProviderOptions, Purchases, type PurchasesManifest, type PurchasesService, Put, Query, QueryParams, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedHook, type ResolvedJob, type ResolvedWebhook, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SignatureSpec, type SmtpOptions, Spend, type SpendMeta, type SpendOptions, Storage, type StorageConfig, type StorageInput, type StoreEnv, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineStorage, defineTestUsers, documents, entitlementFor, flag, getErrorRegistry, getJobConfig, getRoutes, getWebhookConfig, makeEnvDts, makePurchasesDts, parseFileSizeLimit, recordThrows, reservedSecretKey, spendFor, storage, testUser, validateUploadAgainstStorage };
|
package/dist/index.js
CHANGED
|
@@ -6,14 +6,13 @@ import {
|
|
|
6
6
|
Log,
|
|
7
7
|
Notifications,
|
|
8
8
|
Purchases,
|
|
9
|
-
Queue,
|
|
10
9
|
Realtime,
|
|
11
10
|
Storage,
|
|
12
11
|
__getRuntime,
|
|
13
12
|
__requestALS,
|
|
14
13
|
__runWithRuntime,
|
|
15
14
|
__setRuntime
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-I72YYSEI.js";
|
|
17
16
|
import {
|
|
18
17
|
EXTENSION_DEPENDENCIES,
|
|
19
18
|
PALBASE_EXTENSIONS,
|
|
@@ -518,6 +517,9 @@ function defineStorage(input) {
|
|
|
518
517
|
|
|
519
518
|
// src/config/egress.ts
|
|
520
519
|
var EGRESS_CONFIG_KIND = "egress";
|
|
520
|
+
var EGRESS_TIMEOUT_MIN_MS = 1e3;
|
|
521
|
+
var EGRESS_TIMEOUT_MAX_MS = 3e5;
|
|
522
|
+
var EGRESS_TIMEOUT_DEFAULT_MS = 3e4;
|
|
521
523
|
function defineEgress(input) {
|
|
522
524
|
if (input === null || typeof input !== "object" || !Array.isArray(input.hosts)) {
|
|
523
525
|
throw new Error("defineEgress expects { hosts: string[] }");
|
|
@@ -529,7 +531,19 @@ function defineEgress(input) {
|
|
|
529
531
|
}
|
|
530
532
|
hosts.push(h.trim().toLowerCase());
|
|
531
533
|
}
|
|
532
|
-
|
|
534
|
+
if (input.timeoutMs === void 0) {
|
|
535
|
+
return { __config: EGRESS_CONFIG_KIND, hosts };
|
|
536
|
+
}
|
|
537
|
+
const timeoutMs = input.timeoutMs;
|
|
538
|
+
if (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs)) {
|
|
539
|
+
throw new Error("defineEgress: timeoutMs must be an integer number of milliseconds");
|
|
540
|
+
}
|
|
541
|
+
if (timeoutMs < EGRESS_TIMEOUT_MIN_MS || timeoutMs > EGRESS_TIMEOUT_MAX_MS) {
|
|
542
|
+
throw new Error(
|
|
543
|
+
`defineEgress: timeoutMs must be between ${EGRESS_TIMEOUT_MIN_MS} and ${EGRESS_TIMEOUT_MAX_MS} (got ${timeoutMs})`
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
return { __config: EGRESS_CONFIG_KIND, hosts, timeoutMs };
|
|
533
547
|
}
|
|
534
548
|
|
|
535
549
|
// src/config/notifications.ts
|
|
@@ -1222,40 +1236,6 @@ function humanize(code) {
|
|
|
1222
1236
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
1223
1237
|
}
|
|
1224
1238
|
|
|
1225
|
-
// src/worker.ts
|
|
1226
|
-
var VALID_WORKER_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
1227
|
-
var WORKER_DEFAULTS = {
|
|
1228
|
-
retry: 3,
|
|
1229
|
-
timeout: 30,
|
|
1230
|
-
backoff: "exponential"
|
|
1231
|
-
};
|
|
1232
|
-
function defineWorker(config) {
|
|
1233
|
-
if (!config.name || config.name.trim() === "") {
|
|
1234
|
-
throw new Error("Worker name is required");
|
|
1235
|
-
}
|
|
1236
|
-
if (!VALID_WORKER_NAME.test(config.name)) {
|
|
1237
|
-
throw new Error(
|
|
1238
|
-
`Invalid worker name "${config.name}": must match [a-zA-Z0-9_-]+`
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
if (config.retry !== void 0 && (config.retry < 0 || !Number.isInteger(config.retry))) {
|
|
1242
|
-
throw new Error("Worker retry must be a non-negative integer");
|
|
1243
|
-
}
|
|
1244
|
-
if (config.timeout !== void 0 && config.timeout <= 0) {
|
|
1245
|
-
throw new Error("Worker timeout must be a positive number");
|
|
1246
|
-
}
|
|
1247
|
-
if (config.backoff !== void 0 && !["exponential", "linear", "fixed"].includes(config.backoff)) {
|
|
1248
|
-
throw new Error(`Invalid backoff strategy: ${config.backoff}`);
|
|
1249
|
-
}
|
|
1250
|
-
return {
|
|
1251
|
-
name: config.name,
|
|
1252
|
-
retry: config.retry ?? WORKER_DEFAULTS.retry,
|
|
1253
|
-
timeout: config.timeout ?? WORKER_DEFAULTS.timeout,
|
|
1254
|
-
backoff: config.backoff ?? WORKER_DEFAULTS.backoff,
|
|
1255
|
-
handler: config.handler
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
1239
|
// src/decorators/webhook.ts
|
|
1260
1240
|
var WEBHOOK_META = /* @__PURE__ */ Symbol.for("palbase.backend.webhookMeta");
|
|
1261
1241
|
var WEBHOOK_EVENTS = /* @__PURE__ */ Symbol.for("palbase.backend.webhookEvents");
|
|
@@ -1565,6 +1545,9 @@ export {
|
|
|
1565
1545
|
Delete,
|
|
1566
1546
|
Documents,
|
|
1567
1547
|
EGRESS_CONFIG_KIND,
|
|
1548
|
+
EGRESS_TIMEOUT_DEFAULT_MS,
|
|
1549
|
+
EGRESS_TIMEOUT_MAX_MS,
|
|
1550
|
+
EGRESS_TIMEOUT_MIN_MS,
|
|
1568
1551
|
EXTENSION_DEPENDENCIES,
|
|
1569
1552
|
FLAGS_CONFIG_KIND,
|
|
1570
1553
|
Flags,
|
|
@@ -1590,7 +1573,6 @@ export {
|
|
|
1590
1573
|
Put,
|
|
1591
1574
|
Query,
|
|
1592
1575
|
QueryParams,
|
|
1593
|
-
Queue,
|
|
1594
1576
|
RESERVED_SECRET_PREFIX,
|
|
1595
1577
|
Realtime,
|
|
1596
1578
|
Req,
|
|
@@ -1631,7 +1613,6 @@ export {
|
|
|
1631
1613
|
defineSchema,
|
|
1632
1614
|
defineStorage,
|
|
1633
1615
|
defineTestUsers,
|
|
1634
|
-
defineWorker,
|
|
1635
1616
|
documents,
|
|
1636
1617
|
entitlementFor,
|
|
1637
1618
|
enumType,
|