@palbase/backend 10.3.0 → 12.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/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, 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-92kVepng.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 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 TooManyRequests, b2 as TxClient, b3 as Unauthorized, b4 as VerifiedDevice, b5 as defineMiddleware } from './endpoint-92kVepng.cjs';
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-Ck4hER_7.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, S as PalbaseClearAllOverridesResult, T as PalbaseClearOverrideResult, V as PalbaseCohortQueryInput, W as PalbaseCohortResult, X as PalbaseCollectionRef, Y as PalbaseCountQueryInput, Z as PalbaseCountResult, _ as PalbaseCreateLinkParams, $ as PalbaseDeviceInfo, a0 as PalbaseDeviceTokenView, a1 as PalbaseDocumentRef, a2 as PalbaseDocumentSnapshot, a3 as PalbaseEmailClient, a4 as PalbaseEmailSendParams, a5 as PalbaseEmailSendResponse, a6 as PalbaseEventNamesResult, a7 as PalbaseEventsQueryInput, a8 as PalbaseEventsResult, a9 as PalbaseFileObject, aa as PalbaseFlag, ab as PalbaseFlagContext, ac as PalbaseFlagSource, ad as PalbaseFlagValue, ae as PalbaseFlagVariant, af as PalbaseFlagsServiceClient, ag as PalbaseFunctionsClient, ah as PalbaseFunnelQueryInput, ai as PalbaseFunnelResult, aj as PalbaseIdentifyTraits, ak as PalbaseInboxClient, al as PalbaseInboxListOptions, am as PalbaseInboxListResult, an as PalbaseInboxMessage, ao as PalbaseInboxSendParams, ap as PalbaseInboxSendResponse, aq as PalbaseInitialLink, ar as PalbaseInvokeOptions, as as PalbaseLink, at as PalbaseLinkAnalytics, au as PalbaseLinkDetails, av as PalbaseLinksClient, aw as PalbaseListLinksOptions, ax as PalbaseListLinksResult, ay as PalbaseListOptions, az as PalbaseMatchParams, aA as PalbaseMultiChannelResponse, aB as PalbaseOverviewResult, aC as PalbasePreferences, aD as PalbasePreferencesClient, aE as PalbasePublicUrlResponse, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, aK as PalbaseRegisterDeviceParams, aL as PalbaseResult, aM as PalbaseRetentionQueryInput, aN as PalbaseRetentionResult, aO as PalbaseSession, aP as PalbaseSetOverrideResult, aQ as PalbaseSetOverridesResult, aR as PalbaseSignedUrlResponse, aS as PalbaseSmsClient, aT as PalbaseSmsSendParams, aU as PalbaseSmsSendResponse, aV as PalbaseTransformOptions, aW as PalbaseUpdateLinkParams, aX as PalbaseUploadOptions, aY as PalbaseUser, aZ as PalbaseUserDetailResult, a_ as PalbaseUsersQueryInput, a$ as PalbaseUsersResult, b0 as PalbaseVerifyRequestSignatureParams, b1 as PalbaseWhereOperator, b2 as Ref, b3 as TooManyRequests, b4 as TxColumnExpr, b5 as TxInsertShape, b6 as TxInsertValue, b7 as TxNow, b8 as TxPlanBody, b9 as TxPlanError, ba as TxPlanHandle, bb as TxPlanOpResult, bc as TxPlanRejection, bd as TxPlanResponse, be as TxRefError, bf as TxRow, bg as TxRows, bh as TxSelectOptions, bi as TxSetShape, bj as TxSetValue, bk as TxTable, bl as TxWhere, bm as TxWireExpr, bn as TxWireGuard, bo as TxWireOp, bp as TxWireRef, bq as TxWireValue, br as Unauthorized, bs as VerifiedDevice, bt as dec, bu as defineMiddleware, bv as inc, bw as now } from './endpoint-Ck4hER_7.cjs';
3
3
  import { AsyncLocalStorage } from 'node:async_hooks';
4
- import { E as EnvTypedDatabase, S as SchemaDef } from './index-BaHs33jr.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 RawConstraintDef, n as RowShape, o as SchemaInput, T as TableDef, p as TableInput, q as TypedDB, r as TypedTable, s as TypedTx, t as bigint, u as boolean, v as defineSchema, w as enumType, x as integer, y as isPalbaseExtension, z as jsonb, A as makeTypedDB, B as numeric, D as policy, F as raw, G as text, H as timestamp, J as uuid } from './index-BaHs33jr.cjs';
4
+ import { E as EnvTypedDatabase, S as SchemaDef } from './index-BJAf1uPC.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-BJAf1uPC.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';
@@ -1459,43 +1459,6 @@ interface JobMeta {
1459
1459
  /** The globally unique Environment runtime identifier. */
1460
1460
  environmentId: string;
1461
1461
  }
1462
- /** Configuration for defining a scheduled job. */
1463
- interface JobConfig {
1464
- /** Unique job name — alphanumeric, underscore, hyphen only. */
1465
- name: string;
1466
- /** Cron expression (e.g., "0 3 * * *"). */
1467
- schedule: string;
1468
- /** Execution timeout in seconds. Defaults to 30. */
1469
- timeout?: number;
1470
- /** Job handler function. */
1471
- handler: (meta: JobMeta) => Promise<void>;
1472
- }
1473
- /** Resolved job configuration with defaults applied. */
1474
- interface ResolvedJobConfig {
1475
- name: string;
1476
- schedule: string;
1477
- timeout: number;
1478
- handler: (meta: JobMeta) => Promise<void>;
1479
- }
1480
- /**
1481
- * Define a scheduled cron job.
1482
- *
1483
- * Jobs are placed in the `jobs/` directory and auto-discovered at deploy time.
1484
- *
1485
- * @example
1486
- * ```ts
1487
- * export default defineJob({
1488
- * name: "cleanup-expired",
1489
- * schedule: "0 3 * * *", // every day at 3 AM
1490
- * timeout: 60,
1491
- * handler: async (meta) => {
1492
- * await Database.delete("sessions", "expired < NOW()");
1493
- * Log.info("Cleaned up expired sessions");
1494
- * },
1495
- * });
1496
- * ```
1497
- */
1498
- declare function defineJob(config: JobConfig): ResolvedJobConfig;
1499
1462
 
1500
1463
  /** Supported webhook provider types. */
1501
1464
  type WebhookProvider = "stripe" | "github" | "twilio" | "sendgrid" | "slack" | "discord" | "livekit";
@@ -1509,135 +1472,70 @@ interface WebhookMeta {
1509
1472
  /** The globally unique Environment runtime identifier. */
1510
1473
  environmentId: string;
1511
1474
  }
1512
- /** Secret reference — resolves from environment variables at runtime. */
1513
- interface EnvSecretRef {
1514
- env: string;
1515
- }
1516
- /** Provider-specific event maps for type-safe event handlers. */
1517
- interface ProviderEventMap {
1518
- stripe: {
1519
- "checkout.session.completed": Record<string, unknown>;
1520
- "payment_intent.succeeded": Record<string, unknown>;
1521
- "payment_intent.payment_failed": Record<string, unknown>;
1522
- "customer.subscription.created": Record<string, unknown>;
1523
- "customer.subscription.updated": Record<string, unknown>;
1524
- "customer.subscription.deleted": Record<string, unknown>;
1525
- "invoice.paid": Record<string, unknown>;
1526
- "invoice.payment_failed": Record<string, unknown>;
1527
- [key: string]: Record<string, unknown>;
1528
- };
1529
- github: {
1530
- push: Record<string, unknown>;
1531
- pull_request: Record<string, unknown>;
1532
- issues: Record<string, unknown>;
1533
- "pull_request.opened": Record<string, unknown>;
1534
- "pull_request.closed": Record<string, unknown>;
1535
- "pull_request.merged": Record<string, unknown>;
1536
- [key: string]: Record<string, unknown>;
1537
- };
1538
- twilio: {
1539
- "message.received": Record<string, unknown>;
1540
- "message.sent": Record<string, unknown>;
1541
- "call.completed": Record<string, unknown>;
1542
- [key: string]: Record<string, unknown>;
1543
- };
1544
- sendgrid: {
1545
- delivered: Record<string, unknown>;
1546
- bounce: Record<string, unknown>;
1547
- open: Record<string, unknown>;
1548
- click: Record<string, unknown>;
1549
- [key: string]: Record<string, unknown>;
1550
- };
1551
- slack: {
1552
- url_verification: Record<string, unknown>;
1553
- event_callback: Record<string, unknown>;
1554
- [key: string]: Record<string, unknown>;
1555
- };
1556
- discord: {
1557
- PING: Record<string, unknown>;
1558
- MESSAGE_CREATE: Record<string, unknown>;
1559
- INTERACTION_CREATE: Record<string, unknown>;
1560
- [key: string]: Record<string, unknown>;
1561
- };
1562
- livekit: {
1563
- "room.started": Record<string, unknown>;
1564
- "room.finished": Record<string, unknown>;
1565
- "participant.joined": Record<string, unknown>;
1566
- "participant.left": Record<string, unknown>;
1567
- [key: string]: Record<string, unknown>;
1568
- };
1569
- }
1570
- /** Event handler function type. */
1571
- type WebhookEventHandler<TEvent = Record<string, unknown>> = (event: TEvent, meta: WebhookMeta) => Promise<void>;
1572
- /** Provider-based webhook configuration. */
1573
- interface ProviderWebhookConfig<P extends WebhookProvider = WebhookProvider> {
1574
- provider: P;
1575
- secret: EnvSecretRef;
1576
- events: {
1577
- [K in keyof ProviderEventMap[P]]?: WebhookEventHandler<ProviderEventMap[P][K]>;
1578
- };
1579
- }
1580
- /** Incoming request representation for custom verify functions. */
1475
+ /** Raw incoming request representation, read by signature verification. */
1581
1476
  interface WebhookRequest {
1582
1477
  headers: Record<string, string>;
1583
1478
  body: string;
1584
1479
  method: string;
1585
1480
  url: string;
1586
1481
  }
1587
- /** Custom webhook configuration. */
1588
- interface CustomWebhookConfig {
1589
- path: string;
1590
- verify?: (req: WebhookRequest) => Promise<boolean> | boolean;
1591
- handler: (payload: Record<string, unknown>, meta: WebhookMeta) => Promise<void>;
1592
- }
1593
- /** Resolved provider webhook (internal). */
1594
- interface ResolvedProviderWebhook<P extends WebhookProvider = WebhookProvider> {
1595
- type: "provider";
1596
- provider: P;
1597
- secret: EnvSecretRef;
1482
+
1483
+ /** A signature scheme spelled out, for a service with no preset. The presets
1484
+ * (`provider`) are named configurations of this same shape. */
1485
+ interface SignatureSpec {
1486
+ /** Header carrying the signature. */
1487
+ header: string;
1488
+ /** Stripped before comparison (e.g. `sha256=`). Omit when absent. */
1489
+ prefix?: string;
1490
+ algo: "hmac-sha256" | "hmac-sha1";
1491
+ encoding: "hex" | "base64";
1492
+ /** What the HMAC covers. Exactly two placeholders: `{body}` and `{ts}`.
1493
+ * Everything else is literal. `{ts}` requires `timestampHeader` and brings
1494
+ * the five-minute replay window with it. */
1495
+ signs: string;
1496
+ timestampHeader?: string;
1497
+ }
1498
+ interface WebhookOptions {
1499
+ provider?: WebhookProvider;
1500
+ signature?: SignatureSpec;
1501
+ /** Env-var REFERENCE for the signing secret — the platform never holds it. */
1502
+ secret: {
1503
+ env: string;
1504
+ };
1505
+ }
1506
+ type WebhookEventHandler = (event: unknown, meta: WebhookMeta) => Promise<void>;
1507
+ interface ResolvedWebhook {
1508
+ provider?: WebhookProvider;
1509
+ signature?: SignatureSpec;
1510
+ secret: {
1511
+ env: string;
1512
+ };
1598
1513
  events: Record<string, WebhookEventHandler>;
1599
1514
  }
1600
- /** Resolved custom webhook (internal). */
1601
- interface ResolvedCustomWebhook {
1602
- type: "custom";
1603
- path: string;
1604
- verify?: (req: WebhookRequest) => Promise<boolean> | boolean;
1605
- handler: (payload: Record<string, unknown>, meta: WebhookMeta) => Promise<void>;
1515
+ /** Mark a class as an inbound webhook. The mount name is the FILE name — there
1516
+ * is deliberately no `name` option, because the file name IS the public URL. */
1517
+ declare function Webhook(options: WebhookOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
1518
+ /** Bind a method to one event name. Any string is valid: presets provide
1519
+ * autocomplete, never a constraint, because we do not carry provider catalogs. */
1520
+ declare function On(event: string): (target: object, fnName: string | symbol) => void;
1521
+ /** Read a decorated class back as the resolved config the runtime consumes.
1522
+ * Every misuse throws HERE, at build time, rather than becoming a webhook that
1523
+ * answers 200 and does nothing. */
1524
+ declare function getWebhookConfig(ctor: object): ResolvedWebhook;
1525
+
1526
+ interface JobOptions {
1527
+ /** Cron expression, five fields (e.g. "0 3 * * *"). */
1528
+ schedule: string;
1529
+ /** Execution timeout in seconds. Defaults to 30, ceiling 300 (sandbox limit). */
1530
+ timeout?: number;
1606
1531
  }
1607
- /** Union of resolved webhook types. */
1608
- type ResolvedWebhookConfig = ResolvedProviderWebhook | ResolvedCustomWebhook;
1609
- /**
1610
- * Define a provider-based webhook.
1611
- *
1612
- * @example
1613
- * ```ts
1614
- * export default defineWebhook({
1615
- * provider: "stripe",
1616
- * secret: { env: "STRIPE_WEBHOOK_SECRET" },
1617
- * events: {
1618
- * "checkout.session.completed": async (event, meta) => {
1619
- * await Database.insert("orders", { status: "paid" });
1620
- * },
1621
- * },
1622
- * });
1623
- * ```
1624
- */
1625
- declare function defineWebhook<P extends WebhookProvider>(config: ProviderWebhookConfig<P>): ResolvedProviderWebhook<P>;
1626
- /**
1627
- * Define a custom webhook with optional verification.
1628
- *
1629
- * @example
1630
- * ```ts
1631
- * export default defineWebhook({
1632
- * path: "/webhooks/livekit",
1633
- * verify: async (req) => req.headers["x-api-key"] === "secret",
1634
- * handler: async (payload, meta) => {
1635
- * Log.info("Received webhook", payload);
1636
- * },
1637
- * });
1638
- * ```
1639
- */
1640
- declare function defineWebhook(config: CustomWebhookConfig): ResolvedCustomWebhook;
1532
+ interface ResolvedJob {
1533
+ schedule: string;
1534
+ timeout: number;
1535
+ handler: (meta: JobMeta) => Promise<void>;
1536
+ }
1537
+ declare function Job(options: JobOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
1538
+ declare function getJobConfig(ctor: object): ResolvedJob;
1641
1539
 
1642
1540
  /**
1643
1541
  * resource.ts — external connections as lifecycle-managed classes.
@@ -1848,4 +1746,4 @@ declare const documents: {
1848
1746
  onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
1849
1747
  };
1850
1748
 
1851
- 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, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, EntitlementKey, type EnvSecretRef, 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, type JobConfig, type JobMeta, LimitKey, type LimitState, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Purchases, type PurchasesManifest, type PurchasesService, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, 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 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, 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, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, entitlementFor, flag, getErrorRegistry, getRoutes, makeEnvDts, makePurchasesDts, parseFileSizeLimit, recordThrows, reservedSecretKey, spendFor, storage, testUser, validateUploadAgainstStorage };
1749
+ export { type AcsOptions, type ApnsOptions, type BackoffStrategy, 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, 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, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedHook, type ResolvedJob, type ResolvedWebhook, type ResolvedWorkerConfig, 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, User$1 as UserT, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineStorage, defineTestUsers, defineWorker, 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, 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-92kVepng.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 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 TooManyRequests, b2 as TxClient, b3 as Unauthorized, b4 as VerifiedDevice, b5 as defineMiddleware } from './endpoint-92kVepng.js';
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-Ck4hER_7.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, S as PalbaseClearAllOverridesResult, T as PalbaseClearOverrideResult, V as PalbaseCohortQueryInput, W as PalbaseCohortResult, X as PalbaseCollectionRef, Y as PalbaseCountQueryInput, Z as PalbaseCountResult, _ as PalbaseCreateLinkParams, $ as PalbaseDeviceInfo, a0 as PalbaseDeviceTokenView, a1 as PalbaseDocumentRef, a2 as PalbaseDocumentSnapshot, a3 as PalbaseEmailClient, a4 as PalbaseEmailSendParams, a5 as PalbaseEmailSendResponse, a6 as PalbaseEventNamesResult, a7 as PalbaseEventsQueryInput, a8 as PalbaseEventsResult, a9 as PalbaseFileObject, aa as PalbaseFlag, ab as PalbaseFlagContext, ac as PalbaseFlagSource, ad as PalbaseFlagValue, ae as PalbaseFlagVariant, af as PalbaseFlagsServiceClient, ag as PalbaseFunctionsClient, ah as PalbaseFunnelQueryInput, ai as PalbaseFunnelResult, aj as PalbaseIdentifyTraits, ak as PalbaseInboxClient, al as PalbaseInboxListOptions, am as PalbaseInboxListResult, an as PalbaseInboxMessage, ao as PalbaseInboxSendParams, ap as PalbaseInboxSendResponse, aq as PalbaseInitialLink, ar as PalbaseInvokeOptions, as as PalbaseLink, at as PalbaseLinkAnalytics, au as PalbaseLinkDetails, av as PalbaseLinksClient, aw as PalbaseListLinksOptions, ax as PalbaseListLinksResult, ay as PalbaseListOptions, az as PalbaseMatchParams, aA as PalbaseMultiChannelResponse, aB as PalbaseOverviewResult, aC as PalbasePreferences, aD as PalbasePreferencesClient, aE as PalbasePublicUrlResponse, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, aK as PalbaseRegisterDeviceParams, aL as PalbaseResult, aM as PalbaseRetentionQueryInput, aN as PalbaseRetentionResult, aO as PalbaseSession, aP as PalbaseSetOverrideResult, aQ as PalbaseSetOverridesResult, aR as PalbaseSignedUrlResponse, aS as PalbaseSmsClient, aT as PalbaseSmsSendParams, aU as PalbaseSmsSendResponse, aV as PalbaseTransformOptions, aW as PalbaseUpdateLinkParams, aX as PalbaseUploadOptions, aY as PalbaseUser, aZ as PalbaseUserDetailResult, a_ as PalbaseUsersQueryInput, a$ as PalbaseUsersResult, b0 as PalbaseVerifyRequestSignatureParams, b1 as PalbaseWhereOperator, b2 as Ref, b3 as TooManyRequests, b4 as TxColumnExpr, b5 as TxInsertShape, b6 as TxInsertValue, b7 as TxNow, b8 as TxPlanBody, b9 as TxPlanError, ba as TxPlanHandle, bb as TxPlanOpResult, bc as TxPlanRejection, bd as TxPlanResponse, be as TxRefError, bf as TxRow, bg as TxRows, bh as TxSelectOptions, bi as TxSetShape, bj as TxSetValue, bk as TxTable, bl as TxWhere, bm as TxWireExpr, bn as TxWireGuard, bo as TxWireOp, bp as TxWireRef, bq as TxWireValue, br as Unauthorized, bs as VerifiedDevice, bt as dec, bu as defineMiddleware, bv as inc, bw as now } from './endpoint-Ck4hER_7.js';
3
3
  import { AsyncLocalStorage } from 'node:async_hooks';
4
- import { E as EnvTypedDatabase, S as SchemaDef } from './index-DfryIw9U.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 RawConstraintDef, n as RowShape, o as SchemaInput, T as TableDef, p as TableInput, q as TypedDB, r as TypedTable, s as TypedTx, t as bigint, u as boolean, v as defineSchema, w as enumType, x as integer, y as isPalbaseExtension, z as jsonb, A as makeTypedDB, B as numeric, D as policy, F as raw, G as text, H as timestamp, J as uuid } from './index-DfryIw9U.js';
4
+ import { E as EnvTypedDatabase, S as SchemaDef } from './index-l7DhBDtn.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-l7DhBDtn.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';
@@ -1459,43 +1459,6 @@ interface JobMeta {
1459
1459
  /** The globally unique Environment runtime identifier. */
1460
1460
  environmentId: string;
1461
1461
  }
1462
- /** Configuration for defining a scheduled job. */
1463
- interface JobConfig {
1464
- /** Unique job name — alphanumeric, underscore, hyphen only. */
1465
- name: string;
1466
- /** Cron expression (e.g., "0 3 * * *"). */
1467
- schedule: string;
1468
- /** Execution timeout in seconds. Defaults to 30. */
1469
- timeout?: number;
1470
- /** Job handler function. */
1471
- handler: (meta: JobMeta) => Promise<void>;
1472
- }
1473
- /** Resolved job configuration with defaults applied. */
1474
- interface ResolvedJobConfig {
1475
- name: string;
1476
- schedule: string;
1477
- timeout: number;
1478
- handler: (meta: JobMeta) => Promise<void>;
1479
- }
1480
- /**
1481
- * Define a scheduled cron job.
1482
- *
1483
- * Jobs are placed in the `jobs/` directory and auto-discovered at deploy time.
1484
- *
1485
- * @example
1486
- * ```ts
1487
- * export default defineJob({
1488
- * name: "cleanup-expired",
1489
- * schedule: "0 3 * * *", // every day at 3 AM
1490
- * timeout: 60,
1491
- * handler: async (meta) => {
1492
- * await Database.delete("sessions", "expired < NOW()");
1493
- * Log.info("Cleaned up expired sessions");
1494
- * },
1495
- * });
1496
- * ```
1497
- */
1498
- declare function defineJob(config: JobConfig): ResolvedJobConfig;
1499
1462
 
1500
1463
  /** Supported webhook provider types. */
1501
1464
  type WebhookProvider = "stripe" | "github" | "twilio" | "sendgrid" | "slack" | "discord" | "livekit";
@@ -1509,135 +1472,70 @@ interface WebhookMeta {
1509
1472
  /** The globally unique Environment runtime identifier. */
1510
1473
  environmentId: string;
1511
1474
  }
1512
- /** Secret reference — resolves from environment variables at runtime. */
1513
- interface EnvSecretRef {
1514
- env: string;
1515
- }
1516
- /** Provider-specific event maps for type-safe event handlers. */
1517
- interface ProviderEventMap {
1518
- stripe: {
1519
- "checkout.session.completed": Record<string, unknown>;
1520
- "payment_intent.succeeded": Record<string, unknown>;
1521
- "payment_intent.payment_failed": Record<string, unknown>;
1522
- "customer.subscription.created": Record<string, unknown>;
1523
- "customer.subscription.updated": Record<string, unknown>;
1524
- "customer.subscription.deleted": Record<string, unknown>;
1525
- "invoice.paid": Record<string, unknown>;
1526
- "invoice.payment_failed": Record<string, unknown>;
1527
- [key: string]: Record<string, unknown>;
1528
- };
1529
- github: {
1530
- push: Record<string, unknown>;
1531
- pull_request: Record<string, unknown>;
1532
- issues: Record<string, unknown>;
1533
- "pull_request.opened": Record<string, unknown>;
1534
- "pull_request.closed": Record<string, unknown>;
1535
- "pull_request.merged": Record<string, unknown>;
1536
- [key: string]: Record<string, unknown>;
1537
- };
1538
- twilio: {
1539
- "message.received": Record<string, unknown>;
1540
- "message.sent": Record<string, unknown>;
1541
- "call.completed": Record<string, unknown>;
1542
- [key: string]: Record<string, unknown>;
1543
- };
1544
- sendgrid: {
1545
- delivered: Record<string, unknown>;
1546
- bounce: Record<string, unknown>;
1547
- open: Record<string, unknown>;
1548
- click: Record<string, unknown>;
1549
- [key: string]: Record<string, unknown>;
1550
- };
1551
- slack: {
1552
- url_verification: Record<string, unknown>;
1553
- event_callback: Record<string, unknown>;
1554
- [key: string]: Record<string, unknown>;
1555
- };
1556
- discord: {
1557
- PING: Record<string, unknown>;
1558
- MESSAGE_CREATE: Record<string, unknown>;
1559
- INTERACTION_CREATE: Record<string, unknown>;
1560
- [key: string]: Record<string, unknown>;
1561
- };
1562
- livekit: {
1563
- "room.started": Record<string, unknown>;
1564
- "room.finished": Record<string, unknown>;
1565
- "participant.joined": Record<string, unknown>;
1566
- "participant.left": Record<string, unknown>;
1567
- [key: string]: Record<string, unknown>;
1568
- };
1569
- }
1570
- /** Event handler function type. */
1571
- type WebhookEventHandler<TEvent = Record<string, unknown>> = (event: TEvent, meta: WebhookMeta) => Promise<void>;
1572
- /** Provider-based webhook configuration. */
1573
- interface ProviderWebhookConfig<P extends WebhookProvider = WebhookProvider> {
1574
- provider: P;
1575
- secret: EnvSecretRef;
1576
- events: {
1577
- [K in keyof ProviderEventMap[P]]?: WebhookEventHandler<ProviderEventMap[P][K]>;
1578
- };
1579
- }
1580
- /** Incoming request representation for custom verify functions. */
1475
+ /** Raw incoming request representation, read by signature verification. */
1581
1476
  interface WebhookRequest {
1582
1477
  headers: Record<string, string>;
1583
1478
  body: string;
1584
1479
  method: string;
1585
1480
  url: string;
1586
1481
  }
1587
- /** Custom webhook configuration. */
1588
- interface CustomWebhookConfig {
1589
- path: string;
1590
- verify?: (req: WebhookRequest) => Promise<boolean> | boolean;
1591
- handler: (payload: Record<string, unknown>, meta: WebhookMeta) => Promise<void>;
1592
- }
1593
- /** Resolved provider webhook (internal). */
1594
- interface ResolvedProviderWebhook<P extends WebhookProvider = WebhookProvider> {
1595
- type: "provider";
1596
- provider: P;
1597
- secret: EnvSecretRef;
1482
+
1483
+ /** A signature scheme spelled out, for a service with no preset. The presets
1484
+ * (`provider`) are named configurations of this same shape. */
1485
+ interface SignatureSpec {
1486
+ /** Header carrying the signature. */
1487
+ header: string;
1488
+ /** Stripped before comparison (e.g. `sha256=`). Omit when absent. */
1489
+ prefix?: string;
1490
+ algo: "hmac-sha256" | "hmac-sha1";
1491
+ encoding: "hex" | "base64";
1492
+ /** What the HMAC covers. Exactly two placeholders: `{body}` and `{ts}`.
1493
+ * Everything else is literal. `{ts}` requires `timestampHeader` and brings
1494
+ * the five-minute replay window with it. */
1495
+ signs: string;
1496
+ timestampHeader?: string;
1497
+ }
1498
+ interface WebhookOptions {
1499
+ provider?: WebhookProvider;
1500
+ signature?: SignatureSpec;
1501
+ /** Env-var REFERENCE for the signing secret — the platform never holds it. */
1502
+ secret: {
1503
+ env: string;
1504
+ };
1505
+ }
1506
+ type WebhookEventHandler = (event: unknown, meta: WebhookMeta) => Promise<void>;
1507
+ interface ResolvedWebhook {
1508
+ provider?: WebhookProvider;
1509
+ signature?: SignatureSpec;
1510
+ secret: {
1511
+ env: string;
1512
+ };
1598
1513
  events: Record<string, WebhookEventHandler>;
1599
1514
  }
1600
- /** Resolved custom webhook (internal). */
1601
- interface ResolvedCustomWebhook {
1602
- type: "custom";
1603
- path: string;
1604
- verify?: (req: WebhookRequest) => Promise<boolean> | boolean;
1605
- handler: (payload: Record<string, unknown>, meta: WebhookMeta) => Promise<void>;
1515
+ /** Mark a class as an inbound webhook. The mount name is the FILE name — there
1516
+ * is deliberately no `name` option, because the file name IS the public URL. */
1517
+ declare function Webhook(options: WebhookOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
1518
+ /** Bind a method to one event name. Any string is valid: presets provide
1519
+ * autocomplete, never a constraint, because we do not carry provider catalogs. */
1520
+ declare function On(event: string): (target: object, fnName: string | symbol) => void;
1521
+ /** Read a decorated class back as the resolved config the runtime consumes.
1522
+ * Every misuse throws HERE, at build time, rather than becoming a webhook that
1523
+ * answers 200 and does nothing. */
1524
+ declare function getWebhookConfig(ctor: object): ResolvedWebhook;
1525
+
1526
+ interface JobOptions {
1527
+ /** Cron expression, five fields (e.g. "0 3 * * *"). */
1528
+ schedule: string;
1529
+ /** Execution timeout in seconds. Defaults to 30, ceiling 300 (sandbox limit). */
1530
+ timeout?: number;
1606
1531
  }
1607
- /** Union of resolved webhook types. */
1608
- type ResolvedWebhookConfig = ResolvedProviderWebhook | ResolvedCustomWebhook;
1609
- /**
1610
- * Define a provider-based webhook.
1611
- *
1612
- * @example
1613
- * ```ts
1614
- * export default defineWebhook({
1615
- * provider: "stripe",
1616
- * secret: { env: "STRIPE_WEBHOOK_SECRET" },
1617
- * events: {
1618
- * "checkout.session.completed": async (event, meta) => {
1619
- * await Database.insert("orders", { status: "paid" });
1620
- * },
1621
- * },
1622
- * });
1623
- * ```
1624
- */
1625
- declare function defineWebhook<P extends WebhookProvider>(config: ProviderWebhookConfig<P>): ResolvedProviderWebhook<P>;
1626
- /**
1627
- * Define a custom webhook with optional verification.
1628
- *
1629
- * @example
1630
- * ```ts
1631
- * export default defineWebhook({
1632
- * path: "/webhooks/livekit",
1633
- * verify: async (req) => req.headers["x-api-key"] === "secret",
1634
- * handler: async (payload, meta) => {
1635
- * Log.info("Received webhook", payload);
1636
- * },
1637
- * });
1638
- * ```
1639
- */
1640
- declare function defineWebhook(config: CustomWebhookConfig): ResolvedCustomWebhook;
1532
+ interface ResolvedJob {
1533
+ schedule: string;
1534
+ timeout: number;
1535
+ handler: (meta: JobMeta) => Promise<void>;
1536
+ }
1537
+ declare function Job(options: JobOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
1538
+ declare function getJobConfig(ctor: object): ResolvedJob;
1641
1539
 
1642
1540
  /**
1643
1541
  * resource.ts — external connections as lifecycle-managed classes.
@@ -1848,4 +1746,4 @@ declare const documents: {
1848
1746
  onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
1849
1747
  };
1850
1748
 
1851
- 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, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, EntitlementKey, type EnvSecretRef, 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, type JobConfig, type JobMeta, LimitKey, type LimitState, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Purchases, type PurchasesManifest, type PurchasesService, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, 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 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, 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, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, entitlementFor, flag, getErrorRegistry, getRoutes, makeEnvDts, makePurchasesDts, parseFileSizeLimit, recordThrows, reservedSecretKey, spendFor, storage, testUser, validateUploadAgainstStorage };
1749
+ export { type AcsOptions, type ApnsOptions, type BackoffStrategy, 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, 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, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type RequestStore, RequireEntitlement, type ResolvedHook, type ResolvedJob, type ResolvedWebhook, type ResolvedWorkerConfig, 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, User$1 as UserT, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineStorage, defineTestUsers, defineWorker, documents, entitlementFor, flag, getErrorRegistry, getJobConfig, getRoutes, getWebhookConfig, makeEnvDts, makePurchasesDts, parseFileSizeLimit, recordThrows, reservedSecretKey, spendFor, storage, testUser, validateUploadAgainstStorage };