@lunora/server 1.0.0-alpha.209 → 1.0.0-alpha.210
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 +84 -4
- package/dist/index.d.ts +84 -4
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/defineRoom-CoGi-xwm.mjs +1 -0
- package/dist/types.d.mts +19 -5
- package/dist/types.d.ts +19 -5
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -2063,13 +2063,23 @@ interface HttpRoute {
|
|
|
2063
2063
|
*/
|
|
2064
2064
|
declare const lastEventId: (request: Request) => string | undefined;
|
|
2065
2065
|
/**
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2066
|
+
* Module-unique brand marking a yielded chunk as an opt-in SSE frame that
|
|
2067
|
+
* carries an event id. `Symbol.for` (not a fresh `Symbol()`) keeps the key
|
|
2068
|
+
* stable even if this package is bundled twice into one worker, and the brand
|
|
2069
|
+
* means a plain user chunk that happens to have `id`/`data` fields is NOT
|
|
2070
|
+
* mistaken for a frame — {@link sseEvent} is the only way to opt in.
|
|
2071
|
+
*/
|
|
2072
|
+
declare const SSE_EVENT_BRAND: unique symbol;
|
|
2073
|
+
/**
|
|
2074
|
+
* The shape {@link sseEvent} returns and a `.stream()` handler yields to attach an
|
|
2075
|
+
* SSE `id:` to one chunk. The brand is REQUIRED: a plain `{ data, id }` object does
|
|
2076
|
+
* not satisfy it, so a yield typed `SseEvent<T>` is always a frame the pump unwraps,
|
|
2077
|
+
* and the chunk type codegen derives from it is the type that reaches the wire.
|
|
2069
2078
|
*/
|
|
2070
2079
|
interface SseEvent<R> {
|
|
2071
2080
|
readonly data: R;
|
|
2072
2081
|
readonly id: string;
|
|
2082
|
+
readonly [SSE_EVENT_BRAND]: true;
|
|
2073
2083
|
}
|
|
2074
2084
|
/**
|
|
2075
2085
|
* Wrap a chunk so the SSE pump emits `id: <id>` immediately before its `data:`
|
|
@@ -3749,6 +3759,76 @@ declare const assertShapesDeclareReadPolicies: (shapes: Readonly<Record<string,
|
|
|
3749
3759
|
* exposes a protected, policy-less table.
|
|
3750
3760
|
*/
|
|
3751
3761
|
declare const composeShapeReadWhere: (registry: RlsReadRegistry, request: ShapeReadWhereRequest) => WhereInput;
|
|
3762
|
+
/**
|
|
3763
|
+
* The per-socket handle a room handler receives. Mirrors the identity fields of
|
|
3764
|
+
* a connection-lifecycle event and adds the room's own broadcast helper.
|
|
3765
|
+
*/
|
|
3766
|
+
interface RoomSocket<Message = unknown> {
|
|
3767
|
+
/**
|
|
3768
|
+
* Broadcast a typed `message` to EVERY socket in the room — the sender
|
|
3769
|
+
* included, since the server handler is authoritative and its payload (not
|
|
3770
|
+
* the client's raw send) is what members should see. A broadcast queued by
|
|
3771
|
+
* `onJoin` goes to the members already in the room, not to the socket that
|
|
3772
|
+
* is joining. The value is
|
|
3773
|
+
* wire-encoded before it leaves the DO, so `bigint` / bytes survive.
|
|
3774
|
+
*
|
|
3775
|
+
* Synchronous and best-effort: local delivery happens inline and the
|
|
3776
|
+
* cross-DO relay hop is fire-and-forget, matching `broadcastWhisper`.
|
|
3777
|
+
*/
|
|
3778
|
+
broadcast: (message: Message) => void;
|
|
3779
|
+
/** Stable per-socket id, the same one `onConnect` saw. */
|
|
3780
|
+
readonly connectionId: string;
|
|
3781
|
+
/** App-supplied connection context from the client `connect` envelope. */
|
|
3782
|
+
readonly context?: Record<string, unknown>;
|
|
3783
|
+
/** The shard this socket is bound to. */
|
|
3784
|
+
readonly shardKey: string;
|
|
3785
|
+
/** Verified user id resolved at upgrade, or `null` for an anonymous socket. */
|
|
3786
|
+
readonly userId: null | string;
|
|
3787
|
+
}
|
|
3788
|
+
/** Handler for a socket joining a room. */
|
|
3789
|
+
type RoomJoinHandler<Message = unknown> = (context: MutationCtx, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3790
|
+
/** Handler for a socket leaving a room. */
|
|
3791
|
+
type RoomLeaveHandler<Message = unknown> = (context: MutationCtx, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3792
|
+
/** Handler for one typed message on a room; `message` is validated against the room's validator. */
|
|
3793
|
+
type RoomMessageHandler<Message> = (context: MutationCtx, message: Message, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3794
|
+
/** Options for {@link defineRoom}. */
|
|
3795
|
+
interface DefineRoomOptions<Message extends Validator> {
|
|
3796
|
+
/** The room's message validator. Every inbound message is parsed against it before `onMessage`. */
|
|
3797
|
+
message: Message;
|
|
3798
|
+
/** Room name; the wire topic is `room:<name>`. Must be non-empty. */
|
|
3799
|
+
name: string;
|
|
3800
|
+
/** Fired after a socket's join to the room topic is authorized and recorded. */
|
|
3801
|
+
onJoin?: RoomJoinHandler<Infer<Message>>;
|
|
3802
|
+
/** Fired when a socket leaves the room topic. Never authorization-gated. */
|
|
3803
|
+
onLeave?: RoomLeaveHandler<Infer<Message>>;
|
|
3804
|
+
/** Fired for each inbound message, with the message parsed against `message`. */
|
|
3805
|
+
onMessage: RoomMessageHandler<Infer<Message>>;
|
|
3806
|
+
}
|
|
3807
|
+
/**
|
|
3808
|
+
* A registered room — an internal mutation tagged with its `channel`, so codegen
|
|
3809
|
+
* emits it into `LUNORA_FUNCTIONS` (path dispatch) and derives the generated
|
|
3810
|
+
* `LUNORA_ROOMS` topic→path map the shard resolves a room topic through.
|
|
3811
|
+
*
|
|
3812
|
+
* `Message` is the room's message type, carried type-only (`__roomMessage` is
|
|
3813
|
+
* never set at runtime). The generated room references read it back through
|
|
3814
|
+
* {@link RoomMessageOf}, so a client's `connectRoom` is typed from the room itself.
|
|
3815
|
+
*/
|
|
3816
|
+
type RegisteredRoom<Message = unknown> = RegisteredFunction<Record<string, never>, void, "mutation"> & {
|
|
3817
|
+
readonly __roomMessage?: Message;
|
|
3818
|
+
readonly channel: {
|
|
3819
|
+
readonly kind: "room";
|
|
3820
|
+
readonly name: string;
|
|
3821
|
+
};
|
|
3822
|
+
};
|
|
3823
|
+
/** The message type a {@link RegisteredRoom} carries. */
|
|
3824
|
+
type RoomMessageOf<Room> = Room extends RegisteredRoom<infer Message> ? Message : never;
|
|
3825
|
+
/**
|
|
3826
|
+
* Declare a typed room. See the module docblock for the transport it rides, the
|
|
3827
|
+
* dispatch model, and the authorization path.
|
|
3828
|
+
* @throws {TypeError} when `name` is empty — an empty override would make the
|
|
3829
|
+
* room topic collidable and the `LUNORA_ROOMS` map ambiguous.
|
|
3830
|
+
*/
|
|
3831
|
+
declare const defineRoom: <Message extends Validator>(options: DefineRoomOptions<Message>) => RegisteredRoom<Infer<Message>>;
|
|
3752
3832
|
/**
|
|
3753
3833
|
* `ctx.services` — typed Cloudflare service bindings to sibling Workers the app
|
|
3754
3834
|
* declares in `lunora.config.*` `services` (plan 457). A service binding is a
|
|
@@ -4016,7 +4096,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
|
|
|
4016
4096
|
*/
|
|
4017
4097
|
declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
|
|
4018
4098
|
declare const VERSION = "0.0.0";
|
|
4019
|
-
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 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 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 RegisteredShape, type RegisteredStream, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, 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, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
|
|
4099
|
+
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 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 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, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
|
|
4020
4100
|
/**
|
|
4021
4101
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4022
4102
|
* NUL. Guards against response-header injection / `Headers`-construction throws
|
package/dist/index.d.ts
CHANGED
|
@@ -2063,13 +2063,23 @@ interface HttpRoute {
|
|
|
2063
2063
|
*/
|
|
2064
2064
|
declare const lastEventId: (request: Request) => string | undefined;
|
|
2065
2065
|
/**
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2066
|
+
* Module-unique brand marking a yielded chunk as an opt-in SSE frame that
|
|
2067
|
+
* carries an event id. `Symbol.for` (not a fresh `Symbol()`) keeps the key
|
|
2068
|
+
* stable even if this package is bundled twice into one worker, and the brand
|
|
2069
|
+
* means a plain user chunk that happens to have `id`/`data` fields is NOT
|
|
2070
|
+
* mistaken for a frame — {@link sseEvent} is the only way to opt in.
|
|
2071
|
+
*/
|
|
2072
|
+
declare const SSE_EVENT_BRAND: unique symbol;
|
|
2073
|
+
/**
|
|
2074
|
+
* The shape {@link sseEvent} returns and a `.stream()` handler yields to attach an
|
|
2075
|
+
* SSE `id:` to one chunk. The brand is REQUIRED: a plain `{ data, id }` object does
|
|
2076
|
+
* not satisfy it, so a yield typed `SseEvent<T>` is always a frame the pump unwraps,
|
|
2077
|
+
* and the chunk type codegen derives from it is the type that reaches the wire.
|
|
2069
2078
|
*/
|
|
2070
2079
|
interface SseEvent<R> {
|
|
2071
2080
|
readonly data: R;
|
|
2072
2081
|
readonly id: string;
|
|
2082
|
+
readonly [SSE_EVENT_BRAND]: true;
|
|
2073
2083
|
}
|
|
2074
2084
|
/**
|
|
2075
2085
|
* Wrap a chunk so the SSE pump emits `id: <id>` immediately before its `data:`
|
|
@@ -3749,6 +3759,76 @@ declare const assertShapesDeclareReadPolicies: (shapes: Readonly<Record<string,
|
|
|
3749
3759
|
* exposes a protected, policy-less table.
|
|
3750
3760
|
*/
|
|
3751
3761
|
declare const composeShapeReadWhere: (registry: RlsReadRegistry, request: ShapeReadWhereRequest) => WhereInput;
|
|
3762
|
+
/**
|
|
3763
|
+
* The per-socket handle a room handler receives. Mirrors the identity fields of
|
|
3764
|
+
* a connection-lifecycle event and adds the room's own broadcast helper.
|
|
3765
|
+
*/
|
|
3766
|
+
interface RoomSocket<Message = unknown> {
|
|
3767
|
+
/**
|
|
3768
|
+
* Broadcast a typed `message` to EVERY socket in the room — the sender
|
|
3769
|
+
* included, since the server handler is authoritative and its payload (not
|
|
3770
|
+
* the client's raw send) is what members should see. A broadcast queued by
|
|
3771
|
+
* `onJoin` goes to the members already in the room, not to the socket that
|
|
3772
|
+
* is joining. The value is
|
|
3773
|
+
* wire-encoded before it leaves the DO, so `bigint` / bytes survive.
|
|
3774
|
+
*
|
|
3775
|
+
* Synchronous and best-effort: local delivery happens inline and the
|
|
3776
|
+
* cross-DO relay hop is fire-and-forget, matching `broadcastWhisper`.
|
|
3777
|
+
*/
|
|
3778
|
+
broadcast: (message: Message) => void;
|
|
3779
|
+
/** Stable per-socket id, the same one `onConnect` saw. */
|
|
3780
|
+
readonly connectionId: string;
|
|
3781
|
+
/** App-supplied connection context from the client `connect` envelope. */
|
|
3782
|
+
readonly context?: Record<string, unknown>;
|
|
3783
|
+
/** The shard this socket is bound to. */
|
|
3784
|
+
readonly shardKey: string;
|
|
3785
|
+
/** Verified user id resolved at upgrade, or `null` for an anonymous socket. */
|
|
3786
|
+
readonly userId: null | string;
|
|
3787
|
+
}
|
|
3788
|
+
/** Handler for a socket joining a room. */
|
|
3789
|
+
type RoomJoinHandler<Message = unknown> = (context: MutationCtx, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3790
|
+
/** Handler for a socket leaving a room. */
|
|
3791
|
+
type RoomLeaveHandler<Message = unknown> = (context: MutationCtx, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3792
|
+
/** Handler for one typed message on a room; `message` is validated against the room's validator. */
|
|
3793
|
+
type RoomMessageHandler<Message> = (context: MutationCtx, message: Message, socket: RoomSocket<Message>) => Promise<void> | void;
|
|
3794
|
+
/** Options for {@link defineRoom}. */
|
|
3795
|
+
interface DefineRoomOptions<Message extends Validator> {
|
|
3796
|
+
/** The room's message validator. Every inbound message is parsed against it before `onMessage`. */
|
|
3797
|
+
message: Message;
|
|
3798
|
+
/** Room name; the wire topic is `room:<name>`. Must be non-empty. */
|
|
3799
|
+
name: string;
|
|
3800
|
+
/** Fired after a socket's join to the room topic is authorized and recorded. */
|
|
3801
|
+
onJoin?: RoomJoinHandler<Infer<Message>>;
|
|
3802
|
+
/** Fired when a socket leaves the room topic. Never authorization-gated. */
|
|
3803
|
+
onLeave?: RoomLeaveHandler<Infer<Message>>;
|
|
3804
|
+
/** Fired for each inbound message, with the message parsed against `message`. */
|
|
3805
|
+
onMessage: RoomMessageHandler<Infer<Message>>;
|
|
3806
|
+
}
|
|
3807
|
+
/**
|
|
3808
|
+
* A registered room — an internal mutation tagged with its `channel`, so codegen
|
|
3809
|
+
* emits it into `LUNORA_FUNCTIONS` (path dispatch) and derives the generated
|
|
3810
|
+
* `LUNORA_ROOMS` topic→path map the shard resolves a room topic through.
|
|
3811
|
+
*
|
|
3812
|
+
* `Message` is the room's message type, carried type-only (`__roomMessage` is
|
|
3813
|
+
* never set at runtime). The generated room references read it back through
|
|
3814
|
+
* {@link RoomMessageOf}, so a client's `connectRoom` is typed from the room itself.
|
|
3815
|
+
*/
|
|
3816
|
+
type RegisteredRoom<Message = unknown> = RegisteredFunction<Record<string, never>, void, "mutation"> & {
|
|
3817
|
+
readonly __roomMessage?: Message;
|
|
3818
|
+
readonly channel: {
|
|
3819
|
+
readonly kind: "room";
|
|
3820
|
+
readonly name: string;
|
|
3821
|
+
};
|
|
3822
|
+
};
|
|
3823
|
+
/** The message type a {@link RegisteredRoom} carries. */
|
|
3824
|
+
type RoomMessageOf<Room> = Room extends RegisteredRoom<infer Message> ? Message : never;
|
|
3825
|
+
/**
|
|
3826
|
+
* Declare a typed room. See the module docblock for the transport it rides, the
|
|
3827
|
+
* dispatch model, and the authorization path.
|
|
3828
|
+
* @throws {TypeError} when `name` is empty — an empty override would make the
|
|
3829
|
+
* room topic collidable and the `LUNORA_ROOMS` map ambiguous.
|
|
3830
|
+
*/
|
|
3831
|
+
declare const defineRoom: <Message extends Validator>(options: DefineRoomOptions<Message>) => RegisteredRoom<Infer<Message>>;
|
|
3752
3832
|
/**
|
|
3753
3833
|
* `ctx.services` — typed Cloudflare service bindings to sibling Workers the app
|
|
3754
3834
|
* declares in `lunora.config.*` `services` (plan 457). A service binding is a
|
|
@@ -4016,7 +4096,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
|
|
|
4016
4096
|
*/
|
|
4017
4097
|
declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
|
|
4018
4098
|
declare const VERSION = "0.0.0";
|
|
4019
|
-
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 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 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 RegisteredShape, type RegisteredStream, type RegisteredWhisperAuthorizer, type RelationBuilder, type RelationDefinition, type RelationThrough, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ServiceBindingSpec, type ServiceFetcher, type ServiceRpc, type ShapeDefinition, type ShapeGuardDeclaration, type ShapeReadWhereRequest, 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, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
|
|
4099
|
+
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 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 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, defineMigration, defineModule, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineRoom, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes,
|
|
4020
4100
|
/**
|
|
4021
4101
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4022
4102
|
* 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
|
|
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 h,withDeferredDeletes as S}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 _,documentHistoryExtension as L}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{defineMigration as te}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ie}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as ae}from"./packem_shared/defineMutator-B4ipDtDR.mjs";import{platformAdmin as de}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as pe,d as xe,a as ce,b as le,e as Ee,f as ue,g as he,h as Se,i as De,j as Te,k as ge,m as Re}from"./packem_shared/plugin-Bm9wIpiI.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ie,PRESENCE_TABLE as _e,definePresence as Le,presenceExtension as Ce}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-DFpy5J8G.mjs";import{protectPublic as Pe}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as ye}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as Oe}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as He}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as we}from"./packem_shared/defineShape-CwKm5KLp.mjs";import{onWhisper as ke}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Ve}from"@lunora/errors";import{cronJobs as je}from"@lunora/scheduler";import{ValidationError as Ge,v as Je}from"@lunora/values";import{allowAll as Qe,deny as Xe,isDeny as qe,toWhereInput as ze}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as $e}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as rr,buildRlsReadRegistry as or,composeShapeReadWhere as tr}from"./packem_shared/assertShapesDeclareReadPolicies-Bg4Ter7Q.mjs";import{buildMaskRegistry as ir}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as ar,definePermission as sr,definePolicies as dr,definePolicy as mr,defineRole as pr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as cr,defineStorageRules as lr}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{mask as ur}from"./packem_shared/mask-D-jRCAhy.mjs";import{r as Sr}from"./packem_shared/middleware-3ySZVrpt.mjs";import{storageRules as Tr}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,Ve as LunoraError,Ie as PRESENCE_DEFAULT_TTL_MS,_e as PRESENCE_TABLE,e as VERSION,Ge as ValidationError,i as actionCacheExtension,Qe as allowAll,$e as asBucketStorage,rr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,F as bindOrm,O as bindTableFacade,ir as buildMaskRegistry,or as buildRlsReadRegistry,f as cacheKeyFor,ee as clampLimit,pe as composePluginMiddleware,tr as composeShapeReadWhere,ar as createPolicyDsl,l as createSecrets,He as createServices,je as cronJobs,a as defineActionCache,xe as defineAggregateIndex,ce as defineComponent,_ as defineDocumentHistory,P as defineEnv,Y as defineIdentity,J as defineIdentityGuard,re as defineListArgs,te as defineMigration,ie as defineModule,ae as defineMutator,sr as definePermission,le as definePlugin,dr as definePolicies,mr as definePolicy,Le as definePresence,Ee as defineRankIndex,pr as defineRole,Oe as defineRoom,ue as defineSchema,he as defineSchemaExtension,we as defineShape,cr as defineStorageRule,lr as defineStorageRules,Se as defineTable,De as defineVectorIndex,Xe as deny,L as documentHistoryExtension,h as flushDeferredDeletes,H as httpAction,N as httpRoute,w as httpRouter,Te as indexFieldsFromSchema,d as initLunora,ge as installPlugins,qe as isDeny,p as isPerDispatchMiddleware,U as isSafeHeaderValue,k as lastEventId,ur as mask,Re as mergeSchemaExtension,Q as onConnect,X as onDisconnect,ye as onQueryChange,q as onShardInit,ke as onWhisper,de as platformAdmin,Ce as presenceExtension,Pe as protectPublic,b as redactSecrets,Sr as rls,W as serveStorageObject,B as sseEvent,Tr as storageRules,x as tagPerDispatchMiddleware,ze as toWhereInput,Je as v,S as withDeferredDeletes,g as withDeferredSchedules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseValidatorMap as f}from"@lunora/values";const w=i=>{const{message:o,name:e,onJoin:r,onLeave:t,onMessage:m}=i;if(typeof e!="string"||e.length===0)throw new TypeError("defineRoom: `name` must be a non-empty string");return{args:{},handler:async(n,g)=>{const{kind:s,message:d,socket:a}=g;if(s==="join"){await r?.(n,a);return}if(s==="leave"){await t?.(n,a);return}const{message:p}=f({message:o},{message:d},"message");await m(n,p,a)},channel:{kind:"room",name:e},kind:"mutation",visibility:"internal"}};export{w as defineRoom};
|
package/dist/types.d.mts
CHANGED
|
@@ -936,6 +936,17 @@ interface ExposeConfig {
|
|
|
936
936
|
}
|
|
937
937
|
interface RegisteredFunction<A extends ArgsValidator, R, Kind extends FunctionKind> {
|
|
938
938
|
readonly args: A;
|
|
939
|
+
/**
|
|
940
|
+
* Set on a channel registration, which a socket reaches by its name rather
|
|
941
|
+
* than a lifecycle moment: a `defineRoom` (`kind: "room"`, with the room's name,
|
|
942
|
+
* WITHOUT the topic prefix). Codegen collects it into the generated
|
|
943
|
+
* `LUNORA_ROOMS` map (topic → function path) the DO resolves a room whisper
|
|
944
|
+
* topic through. Absent on every other registration.
|
|
945
|
+
*/
|
|
946
|
+
readonly channel?: {
|
|
947
|
+
readonly kind: "room";
|
|
948
|
+
readonly name: string;
|
|
949
|
+
};
|
|
939
950
|
/**
|
|
940
951
|
* Set by the `.expose({ rest: true })` builder modifier. Marks the procedure
|
|
941
952
|
* as published on the public REST surface (plan 167). Absent on procedures that
|
|
@@ -945,10 +956,11 @@ interface RegisteredFunction<A extends ArgsValidator, R, Kind extends FunctionKi
|
|
|
945
956
|
readonly handler: (context: unknown, args: InferArgs<A>) => Promise<R> | R;
|
|
946
957
|
readonly kind: Kind;
|
|
947
958
|
/**
|
|
948
|
-
* Set on connection-lifecycle hooks (`onConnect` / `onDisconnect`)
|
|
949
|
-
* Marks the function for the generated
|
|
950
|
-
*
|
|
951
|
-
* Absent on ordinary registrations
|
|
959
|
+
* Set on connection-lifecycle hooks (`onConnect` / `onDisconnect`), and on the
|
|
960
|
+
* other four moments. Marks the function for the generated
|
|
961
|
+
* `LUNORA_LIFECYCLE_HOOKS` manifest so the DO dispatches it from the socket
|
|
962
|
+
* lifecycle rather than via a client RPC. Absent on ordinary registrations
|
|
963
|
+
* and on channel registrations (`channel`).
|
|
952
964
|
*/
|
|
953
965
|
readonly lifecycle?: LifecycleEventKind;
|
|
954
966
|
readonly visibility?: FunctionVisibility;
|
|
@@ -1059,7 +1071,9 @@ interface RunAction {
|
|
|
1059
1071
|
* a watched read's result changed — see `onQueryChange`. `whisper` is per-TOPIC
|
|
1060
1072
|
* and decides whether a socket may join or broadcast to one — see `onWhisper`
|
|
1061
1073
|
* and {@link WhisperEvent}; unlike the other four it is a query, and its return
|
|
1062
|
-
* value is the verdict.
|
|
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.
|
|
1063
1077
|
*/
|
|
1064
1078
|
type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "whisper";
|
|
1065
1079
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -936,6 +936,17 @@ interface ExposeConfig {
|
|
|
936
936
|
}
|
|
937
937
|
interface RegisteredFunction<A extends ArgsValidator, R, Kind extends FunctionKind> {
|
|
938
938
|
readonly args: A;
|
|
939
|
+
/**
|
|
940
|
+
* Set on a channel registration, which a socket reaches by its name rather
|
|
941
|
+
* than a lifecycle moment: a `defineRoom` (`kind: "room"`, with the room's name,
|
|
942
|
+
* WITHOUT the topic prefix). Codegen collects it into the generated
|
|
943
|
+
* `LUNORA_ROOMS` map (topic → function path) the DO resolves a room whisper
|
|
944
|
+
* topic through. Absent on every other registration.
|
|
945
|
+
*/
|
|
946
|
+
readonly channel?: {
|
|
947
|
+
readonly kind: "room";
|
|
948
|
+
readonly name: string;
|
|
949
|
+
};
|
|
939
950
|
/**
|
|
940
951
|
* Set by the `.expose({ rest: true })` builder modifier. Marks the procedure
|
|
941
952
|
* as published on the public REST surface (plan 167). Absent on procedures that
|
|
@@ -945,10 +956,11 @@ interface RegisteredFunction<A extends ArgsValidator, R, Kind extends FunctionKi
|
|
|
945
956
|
readonly handler: (context: unknown, args: InferArgs<A>) => Promise<R> | R;
|
|
946
957
|
readonly kind: Kind;
|
|
947
958
|
/**
|
|
948
|
-
* Set on connection-lifecycle hooks (`onConnect` / `onDisconnect`)
|
|
949
|
-
* Marks the function for the generated
|
|
950
|
-
*
|
|
951
|
-
* Absent on ordinary registrations
|
|
959
|
+
* Set on connection-lifecycle hooks (`onConnect` / `onDisconnect`), and on the
|
|
960
|
+
* other four moments. Marks the function for the generated
|
|
961
|
+
* `LUNORA_LIFECYCLE_HOOKS` manifest so the DO dispatches it from the socket
|
|
962
|
+
* lifecycle rather than via a client RPC. Absent on ordinary registrations
|
|
963
|
+
* and on channel registrations (`channel`).
|
|
952
964
|
*/
|
|
953
965
|
readonly lifecycle?: LifecycleEventKind;
|
|
954
966
|
readonly visibility?: FunctionVisibility;
|
|
@@ -1059,7 +1071,9 @@ interface RunAction {
|
|
|
1059
1071
|
* a watched read's result changed — see `onQueryChange`. `whisper` is per-TOPIC
|
|
1060
1072
|
* and decides whether a socket may join or broadcast to one — see `onWhisper`
|
|
1061
1073
|
* and {@link WhisperEvent}; unlike the other four it is a query, and its return
|
|
1062
|
-
* value is the verdict.
|
|
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.
|
|
1063
1077
|
*/
|
|
1064
1078
|
type LifecycleEventKind = "connect" | "disconnect" | "init" | "reactor" | "whisper";
|
|
1065
1079
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.210",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -71,8 +71,8 @@
|
|
|
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.
|
|
75
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
74
|
+
"@lunora/scheduler": "1.0.0-alpha.131",
|
|
75
|
+
"@lunora/shard-engine": "1.0.0-alpha.133",
|
|
76
76
|
"@lunora/values": "1.0.0-alpha.67",
|
|
77
77
|
"@lunora/wire": "1.0.0-alpha.1",
|
|
78
78
|
"drizzle-orm": "^0.45.3",
|