@lunora/server 1.0.0-alpha.215 → 1.0.0-alpha.217

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.mts CHANGED
@@ -1966,9 +1966,10 @@ interface LivePublishOptions {
1966
1966
  stream: string;
1967
1967
  }
1968
1968
  /**
1969
- * `ctx.live` — publish an arbitrary event to a named topic. The event fans out
1970
- * to the SSE subscribers of `options.stream` on the shard. WebSocket whisper
1971
- * members never receive it (see the live-stream docblock).
1969
+ * `ctx.live` — publish an arbitrary event to a named topic. The event reaches
1970
+ * the SSE subscribers of `options.stream` that followed the topic, and the
1971
+ * WebSocket whisper members that hold a live grant for that stream and topic
1972
+ * (see the live-stream docblock).
1972
1973
  *
1973
1974
  * Reachable from an HTTP-action ctx; an action (a scheduled job) publishes
1974
1975
  * through the same surface in-process (see the live-stream docblock).
@@ -1976,9 +1977,11 @@ interface LivePublishOptions {
1976
1977
  interface LivePublisher {
1977
1978
  /**
1978
1979
  * Publish `payload` to `topic` on `options.stream`. Best-effort — a topic
1979
- * with no subscribers is a no-op. Rejects when the shard refuses the publish
1980
- * (an oversized payload, or a room or route topic), so a silent drop is not
1981
- * possible.
1980
+ * with no subscribers is a no-op. Rejects when the shard refuses the publish:
1981
+ * a `room:` topic (403), a topic over the control-key bound (400), or a
1982
+ * payload over the publish cap (413), so a refused publish is not silently
1983
+ * dropped. On a target that does not serve live streams it rejects with
1984
+ * `LIVE_STREAMS_UNSUPPORTED`.
1982
1985
  */
1983
1986
  publish: (topic: string, payload: unknown, options: LivePublishOptions) => Promise<void>;
1984
1987
  }
@@ -4088,6 +4091,81 @@ interface RegisteredShape<Args extends ValidatorMap = ValidatorMap, Context = Qu
4088
4091
  }
4089
4092
  /** Declare a replication shape. See the module docs for runtime semantics. */
4090
4093
  declare const defineShape: <Args extends ValidatorMap = ValidatorMap, Context = QueryCtx>(definition: ShapeDefinition<Args, Context>) => RegisteredShape<Args, Context>;
4094
+ /**
4095
+ * The per-socket handle a `defineWebSocket` handler receives. Mirrors the
4096
+ * identity fields of a connection-lifecycle event and adds the route's own send
4097
+ * and broadcast helpers.
4098
+ */
4099
+ interface WebSocketHandle {
4100
+ /**
4101
+ * Broadcast a typed `message` to EVERY socket on this route — the sender
4102
+ * included, since the server handler is authoritative and its payload (not
4103
+ * the client's raw frame) is what members should see. The value is
4104
+ * wire-encoded before it leaves the DO, so `bigint` / bytes survive.
4105
+ *
4106
+ * Synchronous and best-effort: local delivery happens inline and the
4107
+ * cross-DO relay hop is fire-and-forget, matching `broadcastWhisper`.
4108
+ */
4109
+ broadcast: (message: unknown) => void;
4110
+ /** Stable per-socket id, the same one `onConnect` saw. */
4111
+ readonly connectionId: string;
4112
+ /** The declared route path this socket was opened on. */
4113
+ readonly path: string;
4114
+ /**
4115
+ * Send a typed `message` to THIS socket only. Wire-encoded like
4116
+ * {@link WebSocketHandle.broadcast}.
4117
+ */
4118
+ send: (message: unknown) => void;
4119
+ /** The shard this socket is bound to. */
4120
+ readonly shardKey: string;
4121
+ /** Verified user id resolved at upgrade, or `null` for an anonymous socket. */
4122
+ readonly userId: null | string;
4123
+ }
4124
+ /** Handler fired once per socket, right after a successful upgrade. */
4125
+ type WebSocketOpenHandler = (context: MutationCtx, socket: WebSocketHandle) => Promise<void> | void;
4126
+ /** Handler fired once per socket, when it closes. */
4127
+ type WebSocketCloseHandler = (context: MutationCtx, socket: WebSocketHandle) => Promise<void> | void;
4128
+ /** Handler for one typed message on a route; `message` is validated against the route's validator. */
4129
+ type WebSocketMessageHandler<Message> = (context: MutationCtx, message: Message, socket: WebSocketHandle) => Promise<void> | void;
4130
+ /** Options for {@link defineWebSocket}. */
4131
+ interface DefineWebSocketOptions<Message extends Validator> {
4132
+ /**
4133
+ * Require a verified session to open the socket. When `true` the shard
4134
+ * refuses an anonymous upgrade; the default (`false`) allows anonymous
4135
+ * sockets, exactly like every other socket surface.
4136
+ */
4137
+ auth?: boolean;
4138
+ /** The route's message validator. Every inbound frame is parsed against it before `onMessage`. */
4139
+ message: Message;
4140
+ /** Fired when a socket closes, with the identity it opened under. */
4141
+ onClose?: WebSocketCloseHandler;
4142
+ /** Fired for each inbound frame, with the message parsed against `message`. */
4143
+ onMessage: WebSocketMessageHandler<Infer<Message>>;
4144
+ /** Fired once after a socket's upgrade is accepted and recorded. */
4145
+ onOpen?: WebSocketOpenHandler;
4146
+ /** The URL path the route serves, e.g. `"/chat"`. Must be non-empty and start with `/`. */
4147
+ path: string;
4148
+ }
4149
+ /**
4150
+ * A registered WebSocket route — an internal mutation tagged `lifecycle:
4151
+ * "socket"` with its `socketPath` and `auth` requirement, so codegen derives the
4152
+ * generated `LUNORA_SOCKETS` path→registration map the shard resolves an
4153
+ * upgraded socket through.
4154
+ */
4155
+ type RegisteredWebSocket = RegisteredFunction<Record<string, never>, void, "mutation"> & {
4156
+ /** `true` when the route refuses anonymous upgrades. */
4157
+ readonly auth: boolean;
4158
+ readonly lifecycle: "socket";
4159
+ readonly socketPath: string;
4160
+ };
4161
+ /**
4162
+ * Declare a typed WebSocket endpoint. See the module docblock for the transport
4163
+ * it rides, the dispatch model, and the authorization path.
4164
+ * @throws {TypeError} when `path` is empty or does not start with `/` — an
4165
+ * empty or relative path would be unroutable and could shadow an app route — or
4166
+ * when it sits under the reserved `/_lunora` prefix.
4167
+ */
4168
+ declare const defineWebSocket: <Message extends Validator>(options: DefineWebSocketOptions<Message>) => RegisteredWebSocket;
4091
4169
  /**
4092
4170
  * Operations a storage rule can gate. `read` covers `download` / `getMetadata` /
4093
4171
  * `head` / `getSignedUrl` / `getUrl`; `write` covers `store` / `upload` /
@@ -4210,7 +4288,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
4210
4288
  */
4211
4289
  declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
4212
4290
  declare const VERSION = "0.0.0";
4213
- export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveStream, type LiveStreamConfig, type LiveSubscribeHandler, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
4291
+ export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DefineWebSocketOptions, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveStream, type LiveStreamConfig, type LiveSubscribeHandler, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWebSocket, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WebSocketCloseHandler, type WebSocketHandle, type WebSocketMessageHandler, type WebSocketOpenHandler, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, defineWebSocket, deny, documentHistoryExtension, flushDeferredDeletes,
4214
4292
  /**
4215
4293
  * True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
4216
4294
  * NUL. Guards against response-header injection / `Headers`-construction throws
package/dist/index.d.ts CHANGED
@@ -1966,9 +1966,10 @@ interface LivePublishOptions {
1966
1966
  stream: string;
1967
1967
  }
1968
1968
  /**
1969
- * `ctx.live` — publish an arbitrary event to a named topic. The event fans out
1970
- * to the SSE subscribers of `options.stream` on the shard. WebSocket whisper
1971
- * members never receive it (see the live-stream docblock).
1969
+ * `ctx.live` — publish an arbitrary event to a named topic. The event reaches
1970
+ * the SSE subscribers of `options.stream` that followed the topic, and the
1971
+ * WebSocket whisper members that hold a live grant for that stream and topic
1972
+ * (see the live-stream docblock).
1972
1973
  *
1973
1974
  * Reachable from an HTTP-action ctx; an action (a scheduled job) publishes
1974
1975
  * through the same surface in-process (see the live-stream docblock).
@@ -1976,9 +1977,11 @@ interface LivePublishOptions {
1976
1977
  interface LivePublisher {
1977
1978
  /**
1978
1979
  * Publish `payload` to `topic` on `options.stream`. Best-effort — a topic
1979
- * with no subscribers is a no-op. Rejects when the shard refuses the publish
1980
- * (an oversized payload, or a room or route topic), so a silent drop is not
1981
- * possible.
1980
+ * with no subscribers is a no-op. Rejects when the shard refuses the publish:
1981
+ * a `room:` topic (403), a topic over the control-key bound (400), or a
1982
+ * payload over the publish cap (413), so a refused publish is not silently
1983
+ * dropped. On a target that does not serve live streams it rejects with
1984
+ * `LIVE_STREAMS_UNSUPPORTED`.
1982
1985
  */
1983
1986
  publish: (topic: string, payload: unknown, options: LivePublishOptions) => Promise<void>;
1984
1987
  }
@@ -4088,6 +4091,81 @@ interface RegisteredShape<Args extends ValidatorMap = ValidatorMap, Context = Qu
4088
4091
  }
4089
4092
  /** Declare a replication shape. See the module docs for runtime semantics. */
4090
4093
  declare const defineShape: <Args extends ValidatorMap = ValidatorMap, Context = QueryCtx>(definition: ShapeDefinition<Args, Context>) => RegisteredShape<Args, Context>;
4094
+ /**
4095
+ * The per-socket handle a `defineWebSocket` handler receives. Mirrors the
4096
+ * identity fields of a connection-lifecycle event and adds the route's own send
4097
+ * and broadcast helpers.
4098
+ */
4099
+ interface WebSocketHandle {
4100
+ /**
4101
+ * Broadcast a typed `message` to EVERY socket on this route — the sender
4102
+ * included, since the server handler is authoritative and its payload (not
4103
+ * the client's raw frame) is what members should see. The value is
4104
+ * wire-encoded before it leaves the DO, so `bigint` / bytes survive.
4105
+ *
4106
+ * Synchronous and best-effort: local delivery happens inline and the
4107
+ * cross-DO relay hop is fire-and-forget, matching `broadcastWhisper`.
4108
+ */
4109
+ broadcast: (message: unknown) => void;
4110
+ /** Stable per-socket id, the same one `onConnect` saw. */
4111
+ readonly connectionId: string;
4112
+ /** The declared route path this socket was opened on. */
4113
+ readonly path: string;
4114
+ /**
4115
+ * Send a typed `message` to THIS socket only. Wire-encoded like
4116
+ * {@link WebSocketHandle.broadcast}.
4117
+ */
4118
+ send: (message: unknown) => void;
4119
+ /** The shard this socket is bound to. */
4120
+ readonly shardKey: string;
4121
+ /** Verified user id resolved at upgrade, or `null` for an anonymous socket. */
4122
+ readonly userId: null | string;
4123
+ }
4124
+ /** Handler fired once per socket, right after a successful upgrade. */
4125
+ type WebSocketOpenHandler = (context: MutationCtx, socket: WebSocketHandle) => Promise<void> | void;
4126
+ /** Handler fired once per socket, when it closes. */
4127
+ type WebSocketCloseHandler = (context: MutationCtx, socket: WebSocketHandle) => Promise<void> | void;
4128
+ /** Handler for one typed message on a route; `message` is validated against the route's validator. */
4129
+ type WebSocketMessageHandler<Message> = (context: MutationCtx, message: Message, socket: WebSocketHandle) => Promise<void> | void;
4130
+ /** Options for {@link defineWebSocket}. */
4131
+ interface DefineWebSocketOptions<Message extends Validator> {
4132
+ /**
4133
+ * Require a verified session to open the socket. When `true` the shard
4134
+ * refuses an anonymous upgrade; the default (`false`) allows anonymous
4135
+ * sockets, exactly like every other socket surface.
4136
+ */
4137
+ auth?: boolean;
4138
+ /** The route's message validator. Every inbound frame is parsed against it before `onMessage`. */
4139
+ message: Message;
4140
+ /** Fired when a socket closes, with the identity it opened under. */
4141
+ onClose?: WebSocketCloseHandler;
4142
+ /** Fired for each inbound frame, with the message parsed against `message`. */
4143
+ onMessage: WebSocketMessageHandler<Infer<Message>>;
4144
+ /** Fired once after a socket's upgrade is accepted and recorded. */
4145
+ onOpen?: WebSocketOpenHandler;
4146
+ /** The URL path the route serves, e.g. `"/chat"`. Must be non-empty and start with `/`. */
4147
+ path: string;
4148
+ }
4149
+ /**
4150
+ * A registered WebSocket route — an internal mutation tagged `lifecycle:
4151
+ * "socket"` with its `socketPath` and `auth` requirement, so codegen derives the
4152
+ * generated `LUNORA_SOCKETS` path→registration map the shard resolves an
4153
+ * upgraded socket through.
4154
+ */
4155
+ type RegisteredWebSocket = RegisteredFunction<Record<string, never>, void, "mutation"> & {
4156
+ /** `true` when the route refuses anonymous upgrades. */
4157
+ readonly auth: boolean;
4158
+ readonly lifecycle: "socket";
4159
+ readonly socketPath: string;
4160
+ };
4161
+ /**
4162
+ * Declare a typed WebSocket endpoint. See the module docblock for the transport
4163
+ * it rides, the dispatch model, and the authorization path.
4164
+ * @throws {TypeError} when `path` is empty or does not start with `/` — an
4165
+ * empty or relative path would be unroutable and could shadow an app route — or
4166
+ * when it sits under the reserved `/_lunora` prefix.
4167
+ */
4168
+ declare const defineWebSocket: <Message extends Validator>(options: DefineWebSocketOptions<Message>) => RegisteredWebSocket;
4091
4169
  /**
4092
4170
  * Operations a storage rule can gate. `read` covers `download` / `getMetadata` /
4093
4171
  * `head` / `getSignedUrl` / `getUrl`; `write` covers `store` / `upload` /
@@ -4210,7 +4288,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
4210
4288
  */
4211
4289
  declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
4212
4290
  declare const VERSION = "0.0.0";
4213
- export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveStream, type LiveStreamConfig, type LiveSubscribeHandler, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
4291
+ export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineRoomOptions, type DefineStorageRuleInput, type DefineWebSocketOptions, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpRunners, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LivePublishOptions, type LivePublisher, type LiveStream, type LiveStreamConfig, type LiveSubscribeHandler, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type ModuleConfig, type ModuleDefinition, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type PlatformAdminCheck, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredRoom, type RegisteredShape, type RegisteredStream, type RegisteredWebSocket, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type RoomJoinHandler, type RoomLeaveHandler, type RoomMessageHandler, type RoomMessageOf, type RoomSocket, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, type ShardFetch, type ShardFetchInit, type ShardInitEvent, type ShardInitHandler, type SseEvent, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type StorageServeAuthorizer, type StorageServeAuthzContext, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WebSocketCloseHandler, type WebSocketHandle, type WebSocketMessageHandler, type WebSocketOpenHandler, type WhereInput, type WhisperAuthorizeHandler, type WhisperEvent, actionCacheExtension, allowAll, asBucketStorage, assertShapesDeclareReadPolicies, beginDeferredDeletes, beginDeferredSchedules, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, createServices, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineIdentityGuard, defineListArgs, defineLiveStream, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, defineWebSocket, deny, documentHistoryExtension, flushDeferredDeletes,
4214
4292
  /**
4215
4293
  * True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
4216
4294
  * NUL. Guards against response-header injection / `Headers`-construction throws
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as n,actionCacheExtension as i,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-mmP-6BcT.mjs";import{initLunora as d}from"./packem_shared/initLunora-B-7Xs3Qq.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as u,flushDeferredDeletes as S,withDeferredDeletes as h}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as g}from"./packem_shared/beginDeferredSchedules-C7QLYr6C.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as A,DOCUMENT_HISTORY_TABLE as I,defineDocumentHistory as L,documentHistoryExtension as _}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-B5Zp-7SI.mjs";import{LunoraEnvError as M,defineEnv as P,redactSecrets as b}from"./packem_shared/LunoraEnvError-bkdMu_-N.mjs";import{bindOrm as F,bindTableFacade as O}from"./packem_shared/bindOrm-9fbLRbOb.mjs";import{httpAction as H,httpRoute as N,httpRouter as w,isSafeHeaderValue as U,lastEventId as k,sseEvent as B}from"./packem_shared/httpAction-D2S7bQzl.mjs";import{serveStorageObject as W}from"./packem_shared/serveStorageObject-aqBFrLyo.mjs";import{defineIdentity as Y}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as J}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as Q,onDisconnect as X,onShardInit as q}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as Z,DEFAULT_MAX_LIMIT as $,clampLimit as ee,defineListArgs as re}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as te}from"./packem_shared/defineLiveStream-BKomK5uG.mjs";import{defineMigration as ie}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ae}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as de}from"./packem_shared/defineMutator-B4ipDtDR.mjs";import{platformAdmin as pe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as ce,d as le,a as Ee,b as ue,e as Se,f as he,g as De,h as Te,i as ge,j as Re,k as Ae,m as Ie}from"./packem_shared/plugin-Bm9wIpiI.mjs";import{PRESENCE_DEFAULT_TTL_MS as _e,PRESENCE_TABLE as Ce,definePresence as Me,presenceExtension as Pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-DFpy5J8G.mjs";import{protectPublic as ye}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as Oe}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as He}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as we}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as ke}from"./packem_shared/defineShape-CwKm5KLp.mjs";import{onWhisper as Ve}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as je}from"@lunora/errors";import{cronJobs as Ge}from"@lunora/scheduler";import{ValidationError as Ke,v as Qe}from"@lunora/values";import{allowAll as qe,deny as ze,isDeny as Ze,toWhereInput as $e}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as rr}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as tr,buildRlsReadRegistry as nr,composeShapeReadWhere as ir}from"./packem_shared/assertShapesDeclareReadPolicies-Bg4Ter7Q.mjs";import{buildMaskRegistry as ar}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as dr,definePermission as mr,definePolicies as pr,definePolicy as xr,defineRole as cr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Er,defineStorageRules as ur}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{mask as hr}from"./packem_shared/mask-D-jRCAhy.mjs";import{r as Tr}from"./packem_shared/middleware-3ySZVrpt.mjs";import{storageRules as Rr}from"./packem_shared/storageRules-CBLioxF7.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,n as ACTION_CACHE_TABLE,Z as DEFAULT_LIMIT,$ as DEFAULT_MAX_LIMIT,A as DOCUMENT_HISTORY_REDACTED_FIELDS,I as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,je as LunoraError,_e as PRESENCE_DEFAULT_TTL_MS,Ce as PRESENCE_TABLE,e as VERSION,Ke as ValidationError,i as actionCacheExtension,qe as allowAll,rr as asBucketStorage,tr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,F as bindOrm,O as bindTableFacade,ar as buildMaskRegistry,nr as buildRlsReadRegistry,f as cacheKeyFor,ee as clampLimit,ce as composePluginMiddleware,ir as composeShapeReadWhere,dr as createPolicyDsl,l as createSecrets,we as createServices,Ge as cronJobs,a as defineActionCache,le as defineAggregateIndex,Ee as defineComponent,L as defineDocumentHistory,P as defineEnv,Y as defineIdentity,J as defineIdentityGuard,re as defineListArgs,te as defineLiveStream,ie as defineMigration,ae as defineModule,de as defineMutator,mr as definePermission,ue as definePlugin,pr as definePolicies,xr as definePolicy,Me as definePresence,Se as defineRankIndex,cr as defineRole,He as defineRoom,he as defineSchema,De as defineSchemaExtension,ke as defineShape,Er as defineStorageRule,ur as defineStorageRules,Te as defineTable,ge as defineVectorIndex,ze as deny,_ as documentHistoryExtension,S as flushDeferredDeletes,H as httpAction,N as httpRoute,w as httpRouter,Re as indexFieldsFromSchema,d as initLunora,Ae as installPlugins,Ze as isDeny,p as isPerDispatchMiddleware,U as isSafeHeaderValue,k as lastEventId,hr as mask,Ie as mergeSchemaExtension,Q as onConnect,X as onDisconnect,Oe as onQueryChange,q as onShardInit,Ve as onWhisper,pe as platformAdmin,Pe as presenceExtension,ye as protectPublic,b as redactSecrets,Tr as rls,W as serveStorageObject,B as sseEvent,Rr as storageRules,x as tagPerDispatchMiddleware,$e as toWhereInput,Qe as v,h as withDeferredDeletes,g as withDeferredSchedules};
1
+ import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as n,actionCacheExtension as i,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-mmP-6BcT.mjs";import{initLunora as d}from"./packem_shared/initLunora-B-7Xs3Qq.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as S,flushDeferredDeletes as u,withDeferredDeletes as h}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as g}from"./packem_shared/beginDeferredSchedules-C7QLYr6C.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as A,DOCUMENT_HISTORY_TABLE as I,defineDocumentHistory as L,documentHistoryExtension as _}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-B5Zp-7SI.mjs";import{LunoraEnvError as M,defineEnv as P,redactSecrets as b}from"./packem_shared/LunoraEnvError-bkdMu_-N.mjs";import{bindOrm as F,bindTableFacade as O}from"./packem_shared/bindOrm-9fbLRbOb.mjs";import{httpAction as H,httpRoute as N,httpRouter as k,isSafeHeaderValue as w,lastEventId as U,sseEvent as B}from"./packem_shared/httpAction-D2S7bQzl.mjs";import{serveStorageObject as W}from"./packem_shared/serveStorageObject-aqBFrLyo.mjs";import{defineIdentity as Y}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as J}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as Q,onDisconnect as X,onShardInit as q}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as Z,DEFAULT_MAX_LIMIT as $,clampLimit as ee,defineListArgs as re}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as te}from"./packem_shared/defineLiveStream-BKomK5uG.mjs";import{defineMigration as ie}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ae}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as de}from"./packem_shared/defineMutator-B4ipDtDR.mjs";import{platformAdmin as pe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as ce,d as le,a as Ee,b as Se,e as ue,f as he,g as De,h as Te,i as ge,j as Re,k as Ae,m as Ie}from"./packem_shared/plugin-Bm9wIpiI.mjs";import{PRESENCE_DEFAULT_TTL_MS as _e,PRESENCE_TABLE as Ce,definePresence as Me,presenceExtension as Pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-DFpy5J8G.mjs";import{protectPublic as ye}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as Oe}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as He}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as ke}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as Ue}from"./packem_shared/defineShape-CwKm5KLp.mjs";import{defineWebSocket as Ve}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as je}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Ge}from"@lunora/errors";import{cronJobs as Ke}from"@lunora/scheduler";import{ValidationError as Xe,v as qe}from"@lunora/values";import{allowAll as Ze,deny as $e,isDeny as er,toWhereInput as rr}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as tr}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as ir,buildRlsReadRegistry as fr,composeShapeReadWhere as ar}from"./packem_shared/assertShapesDeclareReadPolicies-Bg4Ter7Q.mjs";import{buildMaskRegistry as dr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as pr,definePermission as xr,definePolicies as cr,definePolicy as lr,defineRole as Er}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as ur,defineStorageRules as hr}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{mask as Tr}from"./packem_shared/mask-D-jRCAhy.mjs";import{r as Rr}from"./packem_shared/middleware-3ySZVrpt.mjs";import{storageRules as Ir}from"./packem_shared/storageRules-CBLioxF7.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,n as ACTION_CACHE_TABLE,Z as DEFAULT_LIMIT,$ as DEFAULT_MAX_LIMIT,A as DOCUMENT_HISTORY_REDACTED_FIELDS,I as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,Ge as LunoraError,_e as PRESENCE_DEFAULT_TTL_MS,Ce as PRESENCE_TABLE,e as VERSION,Xe as ValidationError,i as actionCacheExtension,Ze as allowAll,tr as asBucketStorage,ir as assertShapesDeclareReadPolicies,S as beginDeferredDeletes,T as beginDeferredSchedules,F as bindOrm,O as bindTableFacade,dr as buildMaskRegistry,fr as buildRlsReadRegistry,f as cacheKeyFor,ee as clampLimit,ce as composePluginMiddleware,ar as composeShapeReadWhere,pr as createPolicyDsl,l as createSecrets,ke as createServices,Ke as cronJobs,a as defineActionCache,le as defineAggregateIndex,Ee as defineComponent,L as defineDocumentHistory,P as defineEnv,Y as defineIdentity,J as defineIdentityGuard,re as defineListArgs,te as defineLiveStream,ie as defineMigration,ae as defineModule,de as defineMutator,xr as definePermission,Se as definePlugin,cr as definePolicies,lr as definePolicy,Me as definePresence,ue as defineRankIndex,Er as defineRole,He as defineRoom,he as defineSchema,De as defineSchemaExtension,Ue as defineShape,ur as defineStorageRule,hr as defineStorageRules,Te as defineTable,ge as defineVectorIndex,Ve as defineWebSocket,$e as deny,_ as documentHistoryExtension,u as flushDeferredDeletes,H as httpAction,N as httpRoute,k as httpRouter,Re as indexFieldsFromSchema,d as initLunora,Ae as installPlugins,er as isDeny,p as isPerDispatchMiddleware,w as isSafeHeaderValue,U as lastEventId,Tr as mask,Ie as mergeSchemaExtension,Q as onConnect,X as onDisconnect,Oe as onQueryChange,q as onShardInit,je as onWhisper,pe as platformAdmin,Pe as presenceExtension,ye as protectPublic,b as redactSecrets,Rr as rls,W as serveStorageObject,B as sseEvent,Ir as storageRules,x as tagPerDispatchMiddleware,rr as toWhereInput,qe as v,h as withDeferredDeletes,g as withDeferredSchedules};
@@ -0,0 +1 @@
1
+ import{parseValidatorMap as u}from"@lunora/values";const m=s=>{const{auth:n=!1,message:o,onClose:i,onMessage:p,onOpen:h,path:e}=s;if(typeof e!="string"||!e.startsWith("/")||new URL(e,"https://lunora.invalid").pathname!==e)throw new TypeError("defineWebSocket: `path` must be a plain URL path starting with `/` (no `?`, `#`, `..` or unencoded characters)");if(e==="/_lunora"||e.startsWith("/_lunora/"))throw new TypeError("defineWebSocket: `path` must not be under the reserved `/_lunora` prefix");return{args:{},auth:n,handler:async(t,c)=>{const{kind:r,message:l,socket:a}=c;if(r==="open"){await h?.(t,a);return}if(r==="close"){await i?.(t,a);return}const{message:d}=u({message:o},{message:l},"message");await p(t,d,a)},kind:"mutation",lifecycle:"socket",socketPath:e,visibility:"internal"}};export{m as defineWebSocket};
package/dist/types.d.mts CHANGED
@@ -1071,11 +1071,11 @@ interface RunAction {
1071
1071
  * a watched read's result changed — see `onQueryChange`. `whisper` is per-TOPIC
1072
1072
  * and decides whether a socket may join or broadcast to one — see `onWhisper`
1073
1073
  * and {@link WhisperEvent}; unlike the other four it is a query, and its return
1074
- * value is the verdict. `room` is per-ROOM-MESSAGE and is a mutation: a
1075
- * `defineRoom` registration dispatched when a socket joins, leaves, or sends a
1076
- * typed message to the room's whisper topic.
1074
+ * value is the verdict. `socket` is per-ROUTE-FRAME and is
1075
+ * a mutation: a `defineWebSocket` registration dispatched when a socket opens,
1076
+ * sends a typed frame, or closes on the route's path.
1077
1077
  */
1078
- type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "whisper";
1078
+ type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "socket" | "whisper";
1079
1079
  /**
1080
1080
  * The event a whisper authorizer (`onWhisper`) receives as its second argument.
1081
1081
  *
package/dist/types.d.ts CHANGED
@@ -1071,11 +1071,11 @@ interface RunAction {
1071
1071
  * a watched read's result changed — see `onQueryChange`. `whisper` is per-TOPIC
1072
1072
  * and decides whether a socket may join or broadcast to one — see `onWhisper`
1073
1073
  * and {@link WhisperEvent}; unlike the other four it is a query, and its return
1074
- * value is the verdict. `room` is per-ROOM-MESSAGE and is a mutation: a
1075
- * `defineRoom` registration dispatched when a socket joins, leaves, or sends a
1076
- * typed message to the room's whisper topic.
1074
+ * value is the verdict. `socket` is per-ROUTE-FRAME and is
1075
+ * a mutation: a `defineWebSocket` registration dispatched when a socket opens,
1076
+ * sends a typed frame, or closes on the route's path.
1077
1077
  */
1078
- type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "whisper";
1078
+ type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "socket" | "whisper";
1079
1079
  /**
1080
1080
  * The event a whisper authorizer (`onWhisper`) receives as its second argument.
1081
1081
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/server",
3
- "version": "1.0.0-alpha.215",
3
+ "version": "1.0.0-alpha.217",
4
4
  "description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
5
5
  "keywords": [
6
6
  "backend",
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
74
- "@lunora/scheduler": "1.0.0-alpha.135",
75
- "@lunora/shard-engine": "1.0.0-alpha.138",
76
- "@lunora/values": "1.0.0-alpha.70",
74
+ "@lunora/scheduler": "1.0.0-alpha.137",
75
+ "@lunora/shard-engine": "1.0.0-alpha.140",
76
+ "@lunora/values": "1.0.0-alpha.72",
77
77
  "@lunora/wire": "1.0.0-alpha.1",
78
78
  "drizzle-orm": "^0.45.3",
79
79
  "hono": "^4.13.13"