@palbase/backend 23.0.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/bin/palbase-backend.cjs +695 -61
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -5
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-FSGSB42K.js → chunk-7Z6MGMXQ.js} +64 -4
  6. package/dist/chunk-7Z6MGMXQ.js.map +1 -0
  7. package/dist/{chunk-OMRTHM4X.js → chunk-H3JAISUY.js} +136 -1
  8. package/dist/chunk-H3JAISUY.js.map +1 -0
  9. package/dist/{chunk-REZU6UKT.js → chunk-NXDH6VQJ.js} +549 -42
  10. package/dist/chunk-NXDH6VQJ.js.map +1 -0
  11. package/dist/{chunk-W5ODXPY3.js → chunk-P2Q27SGP.js} +32 -3
  12. package/dist/chunk-P2Q27SGP.js.map +1 -0
  13. package/dist/{chunk-ZC6Q2BRD.js → chunk-T5IOSOE5.js} +7 -2
  14. package/dist/chunk-T5IOSOE5.js.map +1 -0
  15. package/dist/{chunk-HAF67F2H.js → chunk-ZUGY7RGS.js} +86 -3
  16. package/dist/chunk-ZUGY7RGS.js.map +1 -0
  17. package/dist/db/index.cjs +115 -3
  18. package/dist/db/index.cjs.map +1 -1
  19. package/dist/db/index.d.cts +2 -2
  20. package/dist/db/index.d.ts +2 -2
  21. package/dist/db/index.js +2 -2
  22. package/dist/{endpoint-BavvbW4P.d.ts → endpoint-0_DGBajf.d.ts} +168 -9
  23. package/dist/{endpoint-i8TTCohk.d.cts → endpoint-CcQ1a36a.d.cts} +168 -9
  24. package/dist/engine/index.cjs +684 -48
  25. package/dist/engine/index.cjs.map +1 -1
  26. package/dist/engine/index.d.cts +4 -4
  27. package/dist/engine/index.d.ts +4 -4
  28. package/dist/engine/index.js +4 -4
  29. package/dist/{index-B3jmmItD.d.ts → index-CJiJU9ux.d.ts} +209 -36
  30. package/dist/{index-Bmvx1EvJ.d.cts → index-D-4-PNuQ.d.cts} +209 -36
  31. package/dist/{index-B7YBEG5w.d.ts → index-D17r-MKb.d.ts} +177 -7
  32. package/dist/{index-E7OscPJT.d.cts → index-DRFxf07H.d.cts} +177 -7
  33. package/dist/index.cjs +269 -7
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +54 -12
  36. package/dist/index.d.ts +54 -12
  37. package/dist/index.js +54 -11
  38. package/dist/index.js.map +1 -1
  39. package/dist/openapi/index.cjs +45 -5
  40. package/dist/openapi/index.cjs.map +1 -1
  41. package/dist/openapi/index.d.cts +9 -4
  42. package/dist/openapi/index.d.ts +9 -4
  43. package/dist/openapi/index.js +35 -11
  44. package/dist/openapi/index.js.map +1 -1
  45. package/dist/{registry-C3H2uPeZ.d.cts → registry-1X-skBNu.d.cts} +101 -7
  46. package/dist/{registry-DY3d9l1k.d.ts → registry-CEod_5sz.d.ts} +101 -7
  47. package/dist/test/index.cjs +509 -9
  48. package/dist/test/index.cjs.map +1 -1
  49. package/dist/test/index.d.cts +35 -3
  50. package/dist/test/index.d.ts +35 -3
  51. package/dist/test/index.js +507 -8
  52. package/dist/test/index.js.map +1 -1
  53. package/docs/README.md +4 -4
  54. package/docs/database.md +115 -11
  55. package/docs/getting-started.md +5 -4
  56. package/docs/llms-full.txt +385 -89
  57. package/docs/migrations.md +81 -59
  58. package/docs/schema.md +82 -2
  59. package/docs/services.md +98 -9
  60. package/package.json +3 -2
  61. package/stager/return_types.js +23 -0
  62. package/template/AGENTS.md +121 -41
  63. package/template/controllers/notes.controller.ts +64 -0
  64. package/template/package.json +1 -1
  65. package/template/services/note.service.ts +74 -0
  66. package/template/tsconfig.json +11 -1
  67. package/dist/chunk-FSGSB42K.js.map +0 -1
  68. package/dist/chunk-HAF67F2H.js.map +0 -1
  69. package/dist/chunk-OMRTHM4X.js.map +0 -1
  70. package/dist/chunk-REZU6UKT.js.map +0 -1
  71. package/dist/chunk-W5ODXPY3.js.map +0 -1
  72. package/dist/chunk-Y5HXVUMP.js +0 -90
  73. package/dist/chunk-Y5HXVUMP.js.map +0 -1
  74. package/dist/chunk-ZC6Q2BRD.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,13 +1,13 @@
1
- import { g as PalbaseResult, A as AuthSpec, H as HttpError } from './endpoint-i8TTCohk.cjs';
2
- export { h as AuthConfig, B as BadRequest, C as CacheClient, i as ClientInfo, j as Conflict, D as DBClient, k as DBOps, E as ErrorDef, l as ErrorMap, m as ErrorThrowers, F as FileContext, n as Forbidden, o as HttpMethod, L as Logger, M as Materialized, p as Middleware, q as MiddlewareContext, r as MiddlewareHandler, N as NotFound, s as PBRequest, t as PalError, u as PalbaseAnalyticsClient, v as PalbaseAnalyticsManagementNamespace, w as PalbaseAnalyticsProperties, x as PalbaseAnalyticsQueryNamespace, y as PalbaseAttestAndroidParams, z as PalbaseAttestAndroidResult, G as PalbaseAttestiOSParams, I as PalbaseAttestiOSResult, J as PalbaseAuthClient, K as PalbaseBatchOverrideOperation, O as PalbaseBatchSetOverridesResult, Q as PalbaseBindDeviceParams, e as PalbaseBucketClient, U as PalbaseClearAllOverridesResult, V as PalbaseClearOverrideResult, W as PalbaseCohortQueryInput, X as PalbaseCohortResult, Y as PalbaseCollectionRef, Z as PalbaseCountQueryInput, _ as PalbaseCountResult, $ as PalbaseCreateLinkParams, a0 as PalbaseDeviceInfo, a1 as PalbaseDeviceTokenView, P as PalbaseDocsClient, a2 as PalbaseDocumentRef, a3 as PalbaseDocumentSnapshot, a4 as PalbaseEmailClient, a5 as PalbaseEmailSendParams, a6 as PalbaseEmailSendResponse, a7 as PalbaseEventNamesResult, a8 as PalbaseEventsQueryInput, a9 as PalbaseEventsResult, aa as PalbaseFileObject, ab as PalbaseFlag, ac as PalbaseFlagContext, ad as PalbaseFlagSource, ae as PalbaseFlagValue, af as PalbaseFlagVariant, a as PalbaseFlagsClient, ag as PalbaseFlagsServiceClient, ah as PalbaseFunctionsClient, ai as PalbaseFunnelQueryInput, aj as PalbaseFunnelResult, ak as PalbaseIdentifyTraits, al as PalbaseInboxClient, am as PalbaseInboxListOptions, an as PalbaseInboxListResult, ao as PalbaseInboxMessage, ap as PalbaseInboxSendParams, aq as PalbaseInboxSendResponse, ar as PalbaseInitialLink, as as PalbaseInvokeOptions, at as PalbaseLink, au as PalbaseLinkAnalytics, av as PalbaseLinkDetails, aw as PalbaseLinksClient, ax as PalbaseListLinksOptions, ay as PalbaseListLinksResult, az as PalbaseListOptions, aA as PalbaseMatchParams, aB as PalbaseMultiChannelResponse, b as PalbaseNotificationsClient, aC as PalbaseOverviewResult, aD as PalbasePreferences, aE as PalbasePreferencesClient, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, c as PalbaseRealtimeClient, aK as PalbaseRegisterDeviceParams, 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, d as PalbaseStorageClient, 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, R as RateLimitConfig, b1 as Ref, S as SecretsService, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, f as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bg as TxSetValue, bh as TxTable, bi as TxWhere, bj as TxWireExpr, bk as TxWireGuard, bl as TxWireOp, bm as TxWireRef, bn as TxWireValue, bo as Unauthorized, bp as UserT, bq as VerifiedDevice, br as dec, bs as defineMiddleware, bt as inc, bu as now } from './endpoint-i8TTCohk.cjs';
3
- import { M as ModuleClients } from './index-E7OscPJT.cjs';
4
- export { C as Cache, D as Database, a as Documents, F as Flags, L as Log, N as Notifications, R as Realtime, b as RequestStore, c as RuntimeServices, S as Secrets, d as Storage, _ as __getRuntime, e as __requestALS, f as __runWithRuntime, g as __setRuntime } from './index-E7OscPJT.cjs';
5
- import { S as SchemaDef } from './index-Bmvx1EvJ.cjs';
6
- export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, f as EnvServiceDatabase, g as EnvTables, E as EnvTypedDatabase, h as EnvTypedTable, 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 TxPlan, r as TxTables, s as TypedDB, t as TypedTable, u as TypedTx, v as bigint, w as boolean, x as defineSchema, y as enumType, z as integer, A as isPalbaseExtension, B as jsonb, D as makeTypedDB, F as numeric, G as openai, H as policy, J as raw, K as text, L as timestamp, M as uuid, N as vector } from './index-Bmvx1EvJ.cjs';
1
+ import { h as PalbaseResult, A as AuthSpec, H as HttpError } from './endpoint-CcQ1a36a.cjs';
2
+ export { i as AuthConfig, B as BadRequest, C as CacheClient, j as ClientInfo, k as Conflict, D as DBClient, f as DBOps, E as ErrorDef, l as ErrorMap, m as ErrorThrowers, F as FileContext, n as Forbidden, o as HttpMethod, L as Logger, M as Materialized, p as Middleware, q as MiddlewareContext, r as MiddlewareHandler, N as NotFound, s as PBRequest, t as PalError, u as PalbaseAnalyticsClient, v as PalbaseAnalyticsManagementNamespace, w as PalbaseAnalyticsProperties, x as PalbaseAnalyticsQueryNamespace, y as PalbaseAttestAndroidParams, z as PalbaseAttestAndroidResult, G as PalbaseAttestiOSParams, I as PalbaseAttestiOSResult, J as PalbaseAuthClient, K as PalbaseBatchOverrideOperation, O as PalbaseBatchSetOverridesResult, Q as PalbaseBindDeviceParams, e as PalbaseBucketClient, U as PalbaseClearAllOverridesResult, V as PalbaseClearOverrideResult, W as PalbaseCohortQueryInput, X as PalbaseCohortResult, Y as PalbaseCollectionRef, Z as PalbaseCountQueryInput, _ as PalbaseCountResult, $ as PalbaseCreateLinkParams, a0 as PalbaseDeviceInfo, a1 as PalbaseDeviceTokenView, P as PalbaseDocsClient, a2 as PalbaseDocumentRef, a3 as PalbaseDocumentSnapshot, a4 as PalbaseEmailClient, a5 as PalbaseEmailSendParams, a6 as PalbaseEmailSendResponse, a7 as PalbaseEventNamesResult, a8 as PalbaseEventsQueryInput, a9 as PalbaseEventsResult, aa as PalbaseFileObject, ab as PalbaseFlag, ac as PalbaseFlagContext, ad as PalbaseFlagSource, ae as PalbaseFlagValue, af as PalbaseFlagVariant, a as PalbaseFlagsClient, ag as PalbaseFlagsServiceClient, ah as PalbaseFunctionsClient, ai as PalbaseFunnelQueryInput, aj as PalbaseFunnelResult, ak as PalbaseIdentifyTraits, al as PalbaseInboxClient, am as PalbaseInboxListOptions, an as PalbaseInboxListResult, ao as PalbaseInboxMessage, ap as PalbaseInboxSendParams, aq as PalbaseInboxSendResponse, ar as PalbaseInitialLink, as as PalbaseInvokeOptions, at as PalbaseLink, au as PalbaseLinkAnalytics, av as PalbaseLinkDetails, aw as PalbaseLinksClient, ax as PalbaseListLinksOptions, ay as PalbaseListLinksResult, az as PalbaseListOptions, aA as PalbaseMatchParams, aB as PalbaseMultiChannelResponse, b as PalbaseNotificationsClient, aC as PalbaseOverviewResult, aD as PalbasePreferences, aE as PalbasePreferencesClient, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, c as PalbaseRealtimeClient, aK as PalbaseRegisterDeviceParams, 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, d as PalbaseStorageClient, 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, R as RateLimitConfig, b1 as Ref, S as SecretsService, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bg as TxSetValue, bh as TxTable, bi as TxWhere, bj as TxWireExpr, bk as TxWireGuard, bl as TxWireOp, bm as TxWireRef, bn as TxWireValue, bo as Unauthorized, bp as UniqueViolation, bq as UserT, br as VerifiedDevice, bs as dec, bt as defineMiddleware, bu as inc, bv as now } from './endpoint-CcQ1a36a.cjs';
3
+ import { M as ModuleClients } from './index-DRFxf07H.cjs';
4
+ export { C as Cache, D as Database, a as Documents, F as Flags, L as LifecycleHook, b as Log, N as Notifications, R as Realtime, c as RequestStore, d as RuntimeServices, S as Secrets, e as ShutdownRunner, f as Storage, _ as __getRuntime, g as __requestALS, h as __resetLifecycleHooks, i as __runStartHooks, j as __runWithRuntime, k as __setRuntime, o as onShutdown, l as onStart } from './index-DRFxf07H.cjs';
5
+ import { S as SchemaDef } from './index-D-4-PNuQ.cjs';
6
+ export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, f as EnvServiceDatabase, g as EnvTables, E as EnvTypedDatabase, h as EnvTypedTable, 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 TxPlan, r as TxTables, s as TypedDB, t as TypedTable, u as TypedTx, v as bigint, w as boolean, x as defineSchema, y as enumType, z as integer, A as isPalbaseExtension, B as jsonb, D as makeTypedDB, F as numeric, G as openai, H as policy, J as raw, K as text, L as timestamp, M as uuid, N as vector } from './index-D-4-PNuQ.cjs';
7
7
  export { TableTypes, Tables } from './db/env.cjs';
8
8
  export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.cjs';
9
- import { a as RouteOptions } from './registry-C3H2uPeZ.cjs';
10
- export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, T as ThrowDescriptor, c as Upload, U as UploadConfig, d as UploadedObject, g as getRoutes, r as recordThrows } from './registry-C3H2uPeZ.cjs';
9
+ import { a as RouteOptions } from './registry-1X-skBNu.cjs';
10
+ export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-1X-skBNu.cjs';
11
11
  import { ZodTypeAny, z } from 'zod';
12
12
  export { z } from 'zod';
13
13
  import 'node:async_hooks';
@@ -417,7 +417,9 @@ declare function makeStackDts(names: StackNames): string;
417
417
 
418
418
  /** Options accepted by `@Controller`. */
419
419
  interface ControllerOptions {
420
- /** Default auth for ALL routes in this controller (route-level overrides). */
420
+ /** Default auth for ALL routes in this controller (route-level overrides;
421
+ * omitting it falls through to the application default declared with
422
+ * {@link defineDefaultAuth}). */
421
423
  auth?: AuthSpec;
422
424
  }
423
425
  /**
@@ -431,6 +433,27 @@ interface ControllerOptions {
431
433
  declare function getRegisteredControllers(): readonly unknown[];
432
434
  /** Empty the registry. For tests, which load controllers repeatedly. */
433
435
  declare function __resetRegisteredControllers(): void;
436
+ /**
437
+ * Declare the default auth for EVERY route in the application — the ring the
438
+ * cascade consults when neither the route nor its controller says anything.
439
+ *
440
+ * The measured problem it removes: `auth: { verifiedEmail: true }` repeated by
441
+ * hand on ten `@Controller`s. A security setting that must be repeated is a
442
+ * security setting that will be forgotten — the eleventh controller opens the
443
+ * door and nothing says so.
444
+ *
445
+ * Call it at MODULE SCOPE in a file the application imports (the controllers'
446
+ * own barrel, or a module a controller imports). The cascade reads this slot
447
+ * when the route table is built and when the spec is emitted — both of which
448
+ * run after module loading — so declaration order does not matter, but being
449
+ * imported at all does.
450
+ *
451
+ * @example
452
+ * defineDefaultAuth({ verifiedEmail: true }); // every route, unless it says otherwise
453
+ */
454
+ declare function defineDefaultAuth(auth: AuthSpec): void;
455
+ /** Clear the application default. For tests, which declare it repeatedly. */
456
+ declare function __resetDefaultAuth(): void;
434
457
  /**
435
458
  * Mark a class as a Palbase backend controller. `basePath` is the mount path
436
459
  * for every route the class declares; `options.auth` sets the controller-level
@@ -443,6 +466,19 @@ declare function __resetRegisteredControllers(): void;
443
466
  * }
444
467
  */
445
468
  declare function Controller(basePath: string, options?: ControllerOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
469
+ /**
470
+ * A class the runtime constructs takes NO constructor parameters.
471
+ *
472
+ * ONE writer, four callers (controller, hook, job, webhook) and the build's own
473
+ * check. Four hand-written copies of this message is how the four come to
474
+ * disagree about what is refused — and the disagreement is silent, because a
475
+ * class that slips past one of them still ends up with `undefined` fields.
476
+ *
477
+ * Why it is refused rather than injected: there is no container. The parameter
478
+ * would arrive `undefined`, the code would compile, deploy, and fail at the
479
+ * first request that touches the field — the most expensive place to learn it.
480
+ */
481
+ declare function assertZeroArgConstructor(Ctrl: unknown, kind: string): void;
446
482
 
447
483
  /** A legacy method decorator. */
448
484
  type MethodDecorator = (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
@@ -591,7 +627,10 @@ declare function Hook(event: string): (target: object, fnName: string | symbol)
591
627
  /** Resolves a hook class into the two maps the runtime dispatches from.
592
628
  *
593
629
  * Every misuse throws HERE, at build time, rather than becoming a hook that is
594
- * silently never called — the failure mode this whole change exists to end. */
630
+ * silently never called — the failure mode this whole change exists to end.
631
+ *
632
+ * @throws when the class declares constructor parameters (FR-011) — nothing
633
+ * here supplies them, so the field would be `undefined` on every event. */
595
634
  declare function getHookConfig(ctor: object): ResolvedHookClass;
596
635
 
597
636
  /** A legacy parameter decorator. */
@@ -731,7 +770,10 @@ declare function Webhook(options: WebhookOptions): <T extends abstract new (...a
731
770
  declare function On(event: string): (target: object, fnName: string | symbol) => void;
732
771
  /** Read a decorated class back as the resolved config the runtime consumes.
733
772
  * Every misuse throws HERE, at build time, rather than becoming a webhook that
734
- * answers 200 and does nothing. */
773
+ * answers 200 and does nothing.
774
+ *
775
+ * @throws when the class declares constructor parameters (FR-011) — nothing
776
+ * here supplies them, so the field would be `undefined` on every delivery. */
735
777
  declare function getWebhookConfig(ctor: object): ResolvedWebhook;
736
778
 
737
779
  interface JobOptions {
@@ -759,4 +801,4 @@ interface ResolvedJob {
759
801
  declare function Job(options: JobOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
760
802
  declare function getJobConfig(ctor: object): ResolvedJob;
761
803
 
762
- export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __resetRegisteredControllers, buildModuleClients, defineChannels, defineError, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, toSchemaJSON };
804
+ export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, toSchemaJSON };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { g as PalbaseResult, A as AuthSpec, H as HttpError } from './endpoint-BavvbW4P.js';
2
- export { h as AuthConfig, B as BadRequest, C as CacheClient, i as ClientInfo, j as Conflict, D as DBClient, k as DBOps, E as ErrorDef, l as ErrorMap, m as ErrorThrowers, F as FileContext, n as Forbidden, o as HttpMethod, L as Logger, M as Materialized, p as Middleware, q as MiddlewareContext, r as MiddlewareHandler, N as NotFound, s as PBRequest, t as PalError, u as PalbaseAnalyticsClient, v as PalbaseAnalyticsManagementNamespace, w as PalbaseAnalyticsProperties, x as PalbaseAnalyticsQueryNamespace, y as PalbaseAttestAndroidParams, z as PalbaseAttestAndroidResult, G as PalbaseAttestiOSParams, I as PalbaseAttestiOSResult, J as PalbaseAuthClient, K as PalbaseBatchOverrideOperation, O as PalbaseBatchSetOverridesResult, Q as PalbaseBindDeviceParams, e as PalbaseBucketClient, U as PalbaseClearAllOverridesResult, V as PalbaseClearOverrideResult, W as PalbaseCohortQueryInput, X as PalbaseCohortResult, Y as PalbaseCollectionRef, Z as PalbaseCountQueryInput, _ as PalbaseCountResult, $ as PalbaseCreateLinkParams, a0 as PalbaseDeviceInfo, a1 as PalbaseDeviceTokenView, P as PalbaseDocsClient, a2 as PalbaseDocumentRef, a3 as PalbaseDocumentSnapshot, a4 as PalbaseEmailClient, a5 as PalbaseEmailSendParams, a6 as PalbaseEmailSendResponse, a7 as PalbaseEventNamesResult, a8 as PalbaseEventsQueryInput, a9 as PalbaseEventsResult, aa as PalbaseFileObject, ab as PalbaseFlag, ac as PalbaseFlagContext, ad as PalbaseFlagSource, ae as PalbaseFlagValue, af as PalbaseFlagVariant, a as PalbaseFlagsClient, ag as PalbaseFlagsServiceClient, ah as PalbaseFunctionsClient, ai as PalbaseFunnelQueryInput, aj as PalbaseFunnelResult, ak as PalbaseIdentifyTraits, al as PalbaseInboxClient, am as PalbaseInboxListOptions, an as PalbaseInboxListResult, ao as PalbaseInboxMessage, ap as PalbaseInboxSendParams, aq as PalbaseInboxSendResponse, ar as PalbaseInitialLink, as as PalbaseInvokeOptions, at as PalbaseLink, au as PalbaseLinkAnalytics, av as PalbaseLinkDetails, aw as PalbaseLinksClient, ax as PalbaseListLinksOptions, ay as PalbaseListLinksResult, az as PalbaseListOptions, aA as PalbaseMatchParams, aB as PalbaseMultiChannelResponse, b as PalbaseNotificationsClient, aC as PalbaseOverviewResult, aD as PalbasePreferences, aE as PalbasePreferencesClient, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, c as PalbaseRealtimeClient, aK as PalbaseRegisterDeviceParams, 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, d as PalbaseStorageClient, 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, R as RateLimitConfig, b1 as Ref, S as SecretsService, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, f as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bg as TxSetValue, bh as TxTable, bi as TxWhere, bj as TxWireExpr, bk as TxWireGuard, bl as TxWireOp, bm as TxWireRef, bn as TxWireValue, bo as Unauthorized, bp as UserT, bq as VerifiedDevice, br as dec, bs as defineMiddleware, bt as inc, bu as now } from './endpoint-BavvbW4P.js';
3
- import { M as ModuleClients } from './index-B7YBEG5w.js';
4
- export { C as Cache, D as Database, a as Documents, F as Flags, L as Log, N as Notifications, R as Realtime, b as RequestStore, c as RuntimeServices, S as Secrets, d as Storage, _ as __getRuntime, e as __requestALS, f as __runWithRuntime, g as __setRuntime } from './index-B7YBEG5w.js';
5
- import { S as SchemaDef } from './index-B3jmmItD.js';
6
- export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, f as EnvServiceDatabase, g as EnvTables, E as EnvTypedDatabase, h as EnvTypedTable, 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 TxPlan, r as TxTables, s as TypedDB, t as TypedTable, u as TypedTx, v as bigint, w as boolean, x as defineSchema, y as enumType, z as integer, A as isPalbaseExtension, B as jsonb, D as makeTypedDB, F as numeric, G as openai, H as policy, J as raw, K as text, L as timestamp, M as uuid, N as vector } from './index-B3jmmItD.js';
1
+ import { h as PalbaseResult, A as AuthSpec, H as HttpError } from './endpoint-0_DGBajf.js';
2
+ export { i as AuthConfig, B as BadRequest, C as CacheClient, j as ClientInfo, k as Conflict, D as DBClient, f as DBOps, E as ErrorDef, l as ErrorMap, m as ErrorThrowers, F as FileContext, n as Forbidden, o as HttpMethod, L as Logger, M as Materialized, p as Middleware, q as MiddlewareContext, r as MiddlewareHandler, N as NotFound, s as PBRequest, t as PalError, u as PalbaseAnalyticsClient, v as PalbaseAnalyticsManagementNamespace, w as PalbaseAnalyticsProperties, x as PalbaseAnalyticsQueryNamespace, y as PalbaseAttestAndroidParams, z as PalbaseAttestAndroidResult, G as PalbaseAttestiOSParams, I as PalbaseAttestiOSResult, J as PalbaseAuthClient, K as PalbaseBatchOverrideOperation, O as PalbaseBatchSetOverridesResult, Q as PalbaseBindDeviceParams, e as PalbaseBucketClient, U as PalbaseClearAllOverridesResult, V as PalbaseClearOverrideResult, W as PalbaseCohortQueryInput, X as PalbaseCohortResult, Y as PalbaseCollectionRef, Z as PalbaseCountQueryInput, _ as PalbaseCountResult, $ as PalbaseCreateLinkParams, a0 as PalbaseDeviceInfo, a1 as PalbaseDeviceTokenView, P as PalbaseDocsClient, a2 as PalbaseDocumentRef, a3 as PalbaseDocumentSnapshot, a4 as PalbaseEmailClient, a5 as PalbaseEmailSendParams, a6 as PalbaseEmailSendResponse, a7 as PalbaseEventNamesResult, a8 as PalbaseEventsQueryInput, a9 as PalbaseEventsResult, aa as PalbaseFileObject, ab as PalbaseFlag, ac as PalbaseFlagContext, ad as PalbaseFlagSource, ae as PalbaseFlagValue, af as PalbaseFlagVariant, a as PalbaseFlagsClient, ag as PalbaseFlagsServiceClient, ah as PalbaseFunctionsClient, ai as PalbaseFunnelQueryInput, aj as PalbaseFunnelResult, ak as PalbaseIdentifyTraits, al as PalbaseInboxClient, am as PalbaseInboxListOptions, an as PalbaseInboxListResult, ao as PalbaseInboxMessage, ap as PalbaseInboxSendParams, aq as PalbaseInboxSendResponse, ar as PalbaseInitialLink, as as PalbaseInvokeOptions, at as PalbaseLink, au as PalbaseLinkAnalytics, av as PalbaseLinkDetails, aw as PalbaseLinksClient, ax as PalbaseListLinksOptions, ay as PalbaseListLinksResult, az as PalbaseListOptions, aA as PalbaseMatchParams, aB as PalbaseMultiChannelResponse, b as PalbaseNotificationsClient, aC as PalbaseOverviewResult, aD as PalbasePreferences, aE as PalbasePreferencesClient, aF as PalbasePushClient, aG as PalbasePushSendParams, aH as PalbasePushSendResponse, aI as PalbaseQrCodeOptions, aJ as PalbaseQuerySnapshot, c as PalbaseRealtimeClient, aK as PalbaseRegisterDeviceParams, 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, d as PalbaseStorageClient, 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, R as RateLimitConfig, b1 as Ref, S as SecretsService, b2 as TooManyRequests, b3 as TxColumnExpr, b4 as TxInsertShape, b5 as TxInsertValue, b6 as TxNow, T as TxPlanBody, b7 as TxPlanError, b8 as TxPlanHandle, b9 as TxPlanOpResult, ba as TxPlanRejection, g as TxPlanResponse, bb as TxRefError, bc as TxRow, bd as TxRows, be as TxSelectOptions, bf as TxSetShape, bg as TxSetValue, bh as TxTable, bi as TxWhere, bj as TxWireExpr, bk as TxWireGuard, bl as TxWireOp, bm as TxWireRef, bn as TxWireValue, bo as Unauthorized, bp as UniqueViolation, bq as UserT, br as VerifiedDevice, bs as dec, bt as defineMiddleware, bu as inc, bv as now } from './endpoint-0_DGBajf.js';
3
+ import { M as ModuleClients } from './index-D17r-MKb.js';
4
+ export { C as Cache, D as Database, a as Documents, F as Flags, L as LifecycleHook, b as Log, N as Notifications, R as Realtime, c as RequestStore, d as RuntimeServices, S as Secrets, e as ShutdownRunner, f as Storage, _ as __getRuntime, g as __requestALS, h as __resetLifecycleHooks, i as __runStartHooks, j as __runWithRuntime, k as __setRuntime, o as onShutdown, l as onStart } from './index-D17r-MKb.js';
5
+ import { S as SchemaDef } from './index-CJiJU9ux.js';
6
+ export { C as ColumnBuilder, a as ColumnDef, b as ColumnMap, c as ColumnType, d as EXTENSION_DEPENDENCIES, e as EmbeddingModelRef, f as EnvServiceDatabase, g as EnvTables, E as EnvTypedDatabase, h as EnvTypedTable, 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 TxPlan, r as TxTables, s as TypedDB, t as TypedTable, u as TypedTx, v as bigint, w as boolean, x as defineSchema, y as enumType, z as integer, A as isPalbaseExtension, B as jsonb, D as makeTypedDB, F as numeric, G as openai, H as policy, J as raw, K as text, L as timestamp, M as uuid, N as vector } from './index-CJiJU9ux.js';
7
7
  export { TableTypes, Tables } from './db/env.js';
8
8
  export { PalbaseBucketName, PalbaseFlagKey, PalbaseSecretName } from './stack.js';
9
- import { a as RouteOptions } from './registry-DY3d9l1k.js';
10
- export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, T as ThrowDescriptor, c as Upload, U as UploadConfig, d as UploadedObject, g as getRoutes, r as recordThrows } from './registry-DY3d9l1k.js';
9
+ import { a as RouteOptions } from './registry-CEod_5sz.js';
10
+ export { H as HttpMethodUpper, b as ParamKind, P as ParamMeta, R as RouteMeta, c as Signal, d as Sse, S as SseConfig, e as SseOut, f as SseWriter, T as ThrowDescriptor, g as Upload, U as UploadConfig, h as UploadedObject, i as getRoutes, r as recordThrows } from './registry-CEod_5sz.js';
11
11
  import { ZodTypeAny, z } from 'zod';
12
12
  export { z } from 'zod';
13
13
  import 'node:async_hooks';
@@ -417,7 +417,9 @@ declare function makeStackDts(names: StackNames): string;
417
417
 
418
418
  /** Options accepted by `@Controller`. */
419
419
  interface ControllerOptions {
420
- /** Default auth for ALL routes in this controller (route-level overrides). */
420
+ /** Default auth for ALL routes in this controller (route-level overrides;
421
+ * omitting it falls through to the application default declared with
422
+ * {@link defineDefaultAuth}). */
421
423
  auth?: AuthSpec;
422
424
  }
423
425
  /**
@@ -431,6 +433,27 @@ interface ControllerOptions {
431
433
  declare function getRegisteredControllers(): readonly unknown[];
432
434
  /** Empty the registry. For tests, which load controllers repeatedly. */
433
435
  declare function __resetRegisteredControllers(): void;
436
+ /**
437
+ * Declare the default auth for EVERY route in the application — the ring the
438
+ * cascade consults when neither the route nor its controller says anything.
439
+ *
440
+ * The measured problem it removes: `auth: { verifiedEmail: true }` repeated by
441
+ * hand on ten `@Controller`s. A security setting that must be repeated is a
442
+ * security setting that will be forgotten — the eleventh controller opens the
443
+ * door and nothing says so.
444
+ *
445
+ * Call it at MODULE SCOPE in a file the application imports (the controllers'
446
+ * own barrel, or a module a controller imports). The cascade reads this slot
447
+ * when the route table is built and when the spec is emitted — both of which
448
+ * run after module loading — so declaration order does not matter, but being
449
+ * imported at all does.
450
+ *
451
+ * @example
452
+ * defineDefaultAuth({ verifiedEmail: true }); // every route, unless it says otherwise
453
+ */
454
+ declare function defineDefaultAuth(auth: AuthSpec): void;
455
+ /** Clear the application default. For tests, which declare it repeatedly. */
456
+ declare function __resetDefaultAuth(): void;
434
457
  /**
435
458
  * Mark a class as a Palbase backend controller. `basePath` is the mount path
436
459
  * for every route the class declares; `options.auth` sets the controller-level
@@ -443,6 +466,19 @@ declare function __resetRegisteredControllers(): void;
443
466
  * }
444
467
  */
445
468
  declare function Controller(basePath: string, options?: ControllerOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
469
+ /**
470
+ * A class the runtime constructs takes NO constructor parameters.
471
+ *
472
+ * ONE writer, four callers (controller, hook, job, webhook) and the build's own
473
+ * check. Four hand-written copies of this message is how the four come to
474
+ * disagree about what is refused — and the disagreement is silent, because a
475
+ * class that slips past one of them still ends up with `undefined` fields.
476
+ *
477
+ * Why it is refused rather than injected: there is no container. The parameter
478
+ * would arrive `undefined`, the code would compile, deploy, and fail at the
479
+ * first request that touches the field — the most expensive place to learn it.
480
+ */
481
+ declare function assertZeroArgConstructor(Ctrl: unknown, kind: string): void;
446
482
 
447
483
  /** A legacy method decorator. */
448
484
  type MethodDecorator = (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
@@ -591,7 +627,10 @@ declare function Hook(event: string): (target: object, fnName: string | symbol)
591
627
  /** Resolves a hook class into the two maps the runtime dispatches from.
592
628
  *
593
629
  * Every misuse throws HERE, at build time, rather than becoming a hook that is
594
- * silently never called — the failure mode this whole change exists to end. */
630
+ * silently never called — the failure mode this whole change exists to end.
631
+ *
632
+ * @throws when the class declares constructor parameters (FR-011) — nothing
633
+ * here supplies them, so the field would be `undefined` on every event. */
595
634
  declare function getHookConfig(ctor: object): ResolvedHookClass;
596
635
 
597
636
  /** A legacy parameter decorator. */
@@ -731,7 +770,10 @@ declare function Webhook(options: WebhookOptions): <T extends abstract new (...a
731
770
  declare function On(event: string): (target: object, fnName: string | symbol) => void;
732
771
  /** Read a decorated class back as the resolved config the runtime consumes.
733
772
  * Every misuse throws HERE, at build time, rather than becoming a webhook that
734
- * answers 200 and does nothing. */
773
+ * answers 200 and does nothing.
774
+ *
775
+ * @throws when the class declares constructor parameters (FR-011) — nothing
776
+ * here supplies them, so the field would be `undefined` on every delivery. */
735
777
  declare function getWebhookConfig(ctor: object): ResolvedWebhook;
736
778
 
737
779
  interface JobOptions {
@@ -759,4 +801,4 @@ interface ResolvedJob {
759
801
  declare function Job(options: JobOptions): <T extends abstract new (...args: never[]) => object>(ctor: T) => T;
760
802
  declare function getJobConfig(ctor: object): ResolvedJob;
761
803
 
762
- export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __resetRegisteredControllers, buildModuleClients, defineChannels, defineError, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, toSchemaJSON };
804
+ export { type AuthHookEvent, Body, type ChannelAuthorizeCtx, type ChannelEntry, type ChannelGrant, type ChannelsDef, type ChannelsInput, Client, type ColumnJSON, Controller, type ControllerOptions, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, type FileDeletedEvent, type FileUploadedEvent, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, type ModuleClientsConfig, type ModuleTransport, On, OptionalUser, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, Put, Query, QueryParams, type RegisteredError, Req, RequestId, type RequestOptions, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, RouteOptions, SchemaDef, type SchemaJSON, type SignatureSpec, type StackNames, type TableJSON, TraceId, type TransportConfig, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __resetDefaultAuth, __resetRegisteredControllers, assertZeroArgConstructor, buildModuleClients, defineChannels, defineDefaultAuth, defineError, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makeStackDts, ownerOnly, publicChannel, toSchemaJSON };
package/dist/index.js CHANGED
@@ -18,11 +18,11 @@ import {
18
18
  timestamp,
19
19
  uuid,
20
20
  vector
21
- } from "./chunk-HAF67F2H.js";
21
+ } from "./chunk-ZUGY7RGS.js";
22
22
  import {
23
23
  defineError,
24
24
  getErrorRegistry
25
- } from "./chunk-ZC6Q2BRD.js";
25
+ } from "./chunk-T5IOSOE5.js";
26
26
  import {
27
27
  Cache,
28
28
  Database,
@@ -35,35 +35,41 @@ import {
35
35
  Storage,
36
36
  __getRuntime,
37
37
  __requestALS,
38
+ __resetLifecycleHooks,
39
+ __runStartHooks,
38
40
  __runWithRuntime,
39
- __setRuntime
40
- } from "./chunk-FSGSB42K.js";
41
+ __setRuntime,
42
+ onShutdown,
43
+ onStart
44
+ } from "./chunk-7Z6MGMXQ.js";
41
45
  import {
42
46
  TxPlanError,
43
47
  TxRefError,
44
48
  dec,
45
49
  inc,
46
50
  now
47
- } from "./chunk-W5ODXPY3.js";
48
- import {
49
- Controller,
50
- __resetRegisteredControllers,
51
- getRegisteredControllers
52
- } from "./chunk-Y5HXVUMP.js";
51
+ } from "./chunk-P2Q27SGP.js";
53
52
  import {
54
53
  BadRequest,
55
54
  Conflict,
55
+ Controller,
56
56
  Forbidden,
57
57
  HttpError,
58
58
  NotFound,
59
59
  PalError,
60
60
  TooManyRequests,
61
61
  Unauthorized,
62
+ UniqueViolation,
63
+ __resetDefaultAuth,
64
+ __resetRegisteredControllers,
65
+ assertZeroArgConstructor,
66
+ defineDefaultAuth,
67
+ getRegisteredControllers,
62
68
  getRoutes,
63
69
  recordParam,
64
70
  recordRoute,
65
71
  recordThrows
66
- } from "./chunk-OMRTHM4X.js";
72
+ } from "./chunk-H3JAISUY.js";
67
73
  import "./chunk-7D4SUZUM.js";
68
74
 
69
75
  // src/clients/http.ts
@@ -1442,6 +1448,7 @@ function getWebhookConfig(ctor) {
1442
1448
  if (entries.length === 0) {
1443
1449
  throw new Error("@Webhook requires at least one @On handler");
1444
1450
  }
1451
+ assertZeroArgConstructor(ctor, "webhook class");
1445
1452
  const instance = new ctor();
1446
1453
  const events = /* @__PURE__ */ Object.create(null);
1447
1454
  for (const entry of entries) {
@@ -1503,6 +1510,7 @@ function getHookConfig(ctor) {
1503
1510
  `${ctor.name ?? "a hook class"} carries no handler \u2014 a hook file must declare at least one @Hook (blocking) or @On (listener) method`
1504
1511
  );
1505
1512
  }
1513
+ assertZeroArgConstructor(ctor, "hook class");
1506
1514
  const instance = new ctor();
1507
1515
  return {
1508
1516
  blocking: bind(instance, blockingEntries, "@Hook"),
@@ -1544,6 +1552,29 @@ function validateUploadConfigShape(c) {
1544
1552
  }
1545
1553
  }
1546
1554
 
1555
+ // src/decorators/sse.ts
1556
+ function Sse(subpath = "", config) {
1557
+ const { auth, rateLimit, ...sseConfig } = config;
1558
+ const options = {
1559
+ sseConfig,
1560
+ ...auth !== void 0 ? { auth } : {},
1561
+ ...rateLimit !== void 0 ? { rateLimit } : {}
1562
+ };
1563
+ return function(target, propertyKey) {
1564
+ recordRoute(target, String(propertyKey), "POST", subpath, options);
1565
+ };
1566
+ }
1567
+ function SseOut() {
1568
+ return function(target, propertyKey, parameterIndex) {
1569
+ recordParam(target, String(propertyKey), { index: parameterIndex, kind: "sseOut" });
1570
+ };
1571
+ }
1572
+ function Signal() {
1573
+ return function(target, propertyKey, parameterIndex) {
1574
+ recordParam(target, String(propertyKey), { index: parameterIndex, kind: "signal" });
1575
+ };
1576
+ }
1577
+
1547
1578
  // src/decorators/params.ts
1548
1579
  function makeParamDecorator(kind, extra) {
1549
1580
  return function(target, propertyKey, parameterIndex) {
@@ -1710,6 +1741,7 @@ function getJobConfig(ctor) {
1710
1741
  if (retry > MAX_RETRY) {
1711
1742
  throw new Error(`@Job \`retry\` exceeds the ceiling of ${MAX_RETRY}`);
1712
1743
  }
1744
+ assertZeroArgConstructor(ctor, "job class");
1713
1745
  const instance = new ctor();
1714
1746
  if (typeof instance.run !== "function") {
1715
1747
  throw new Error("@Job class must declare an async run() method");
@@ -1758,26 +1790,35 @@ export {
1758
1790
  Req,
1759
1791
  RequestId,
1760
1792
  Secrets,
1793
+ Signal,
1794
+ Sse,
1795
+ SseOut,
1761
1796
  Storage,
1762
1797
  TooManyRequests,
1763
1798
  TraceId,
1764
1799
  TxPlanError,
1765
1800
  TxRefError,
1766
1801
  Unauthorized,
1802
+ UniqueViolation,
1767
1803
  Upload,
1768
1804
  UploadedObject,
1769
1805
  User,
1770
1806
  Webhook,
1771
1807
  __getRuntime,
1772
1808
  __requestALS,
1809
+ __resetDefaultAuth,
1810
+ __resetLifecycleHooks,
1773
1811
  __resetRegisteredControllers,
1812
+ __runStartHooks,
1774
1813
  __runWithRuntime,
1775
1814
  __setRuntime,
1815
+ assertZeroArgConstructor,
1776
1816
  bigint,
1777
1817
  boolean,
1778
1818
  buildModuleClients,
1779
1819
  dec,
1780
1820
  defineChannels,
1821
+ defineDefaultAuth,
1781
1822
  defineError,
1782
1823
  defineMiddleware,
1783
1824
  defineSchema,
@@ -1798,6 +1839,8 @@ export {
1798
1839
  makeTypedDB,
1799
1840
  now,
1800
1841
  numeric,
1842
+ onShutdown,
1843
+ onStart,
1801
1844
  openai,
1802
1845
  ownerOnly,
1803
1846
  policy,