@lunora/server 1.0.0-alpha.232 → 1.0.0-alpha.233
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
|
@@ -4,7 +4,7 @@ import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeC
|
|
|
4
4
|
export type { B as AuthState, C as CachePurge, H as DatabaseReader, D as DatabaseWriter, J as FunctionVisibility, N as GeoBoundingBox, P as GeoFilterBuilder, U as GeoIndexDefinition, Y as GeoPointInput, Z as IndexDefinition, _ as IndexRangeBuilder, $ as LifecycleEventKind, a0 as LogFields, a1 as LunoraLogMethod, a2 as LunoraLogger, a3 as LunoraMetrics, L as LunoraTracer, a4 as LunoraWideEvent, a5 as MutationStorage, a6 as PaginationOptions, a7 as PaginationResult, a8 as PatchIfResult, a9 as RankSortKey, aa as ReadOnlyStorage, ab as RelatedDirection, ac as RelatedNode, ad as RelatedOptions, ae as RelatedPage, af as RelatedStart, ag as RelatedStartReference, ah as RestCacheConfig, ai as RetryPolicy, aj as RunQueryOptions, ak as ScheduledFunctionDoc, al as ScheduledJob, am as Scheduler, an as SearchFilterBuilder, ao as SearchIndexDefinition, ap as ShardMode, aq as SpanContextIds, ar as SpanEvaluation, a as SpanHandle, as as SpanIdentity, at as SpanKind, au as SpanLink, av as SpanOptions, aw as Storage, ax as StorageListOptions, ay as StorageListResult, az as StorageMetadata, aA as StorageMultipartUpload, aB as StorageMultipartUploadOptions, aC as StorageObjectBody, aD as StorageObjectHead, aE as StorageRange, aF as StorageUploadBody, aG as StorageUploadOptions, aH as StorageUploadResult, aI as StorageUploadedPart, aJ as SystemDatabaseReader, aK as SystemDoc, aL as SystemQuery, aM as SystemTableName, aN as TableReader, aO as TableVectorIndex, aP as TriggerAggregateOptions, aQ as TriggerCtx, aR as TriggerDatabase, aS as TriggerDeleteEvent, aT as TriggerEvent, aU as TriggerGroupByEntry, aV as TriggerGroupByOptions, aW as TriggerHandler, aX as TriggerInsertEvent, aY as TriggerOp, aZ as TriggerQueryArgs, a_ as TriggerQueryPage, a$ as TriggerRankOptions, b0 as TriggerRankPageOptions, b1 as TriggerRankResult, b2 as TriggerRow, b3 as TriggerTiming, b4 as TriggerUpdateEvent, b5 as TtlDefinition, b6 as VectorMatch, b7 as VectorMatches, b8 as VectorQueryInput, b9 as VectorRecord, ba as VectorSearch, bb as VectorSearchReader, bc as VectorUpsertInput, bd as WorkflowCreateOptions, be as WorkflowEventDefinition, bf as WorkflowHandle, bg as WorkflowInstance, bh as WorkflowInstanceEvent, bi as WorkflowInstanceStatus, bj as WorkflowStatusResult, bk as Workflows } from "./packem_shared/types.d-CCjAj93e.mjs";
|
|
5
5
|
import { LunoraError } from '@lunora/errors';
|
|
6
6
|
export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
|
|
7
|
-
import { Context, Hono } from 'hono';
|
|
7
|
+
import { Context, Hono, ExecutionContext } from 'hono';
|
|
8
8
|
import { WhereOperators, QueryArgs as QueryArgs$2, QueryPlan } from "./data-model.mjs";
|
|
9
9
|
import { W as WhereInput, a as Policy, b as RlsOptions, c as Permission, R as Role, T as TypedDefinePolicyInput, D as DefinePolicyInput } from "./packem_shared/types.d-B7FLdYUD.mjs";
|
|
10
10
|
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-B7FLdYUD.mjs";
|
|
@@ -2581,11 +2581,11 @@ interface LiveStreamConfig<Topics extends LiveTopics = LiveTopics> {
|
|
|
2581
2581
|
}
|
|
2582
2582
|
/** The two route handlers {@link defineLiveStream} produces, plus the declaration they enforce. */
|
|
2583
2583
|
interface LiveStream<Topics extends LiveTopics = LiveTopics> {
|
|
2584
|
-
/**
|
|
2584
|
+
/** Served at `connectPath` by the worker's live-stream router. Returns the SSE response. */
|
|
2585
2585
|
connect: LunoraRouteHandler;
|
|
2586
2586
|
/** `GET` path for the SSE connection. */
|
|
2587
2587
|
connectPath: string;
|
|
2588
|
-
/**
|
|
2588
|
+
/** Served at `controlPath` by the worker's live-stream router. Returns a JSON ack. */
|
|
2589
2589
|
control: LunoraRouteHandler;
|
|
2590
2590
|
/** `POST` path for subscribe / unsubscribe control. */
|
|
2591
2591
|
controlPath: string;
|
|
@@ -2613,6 +2613,38 @@ interface LiveStream<Topics extends LiveTopics = LiveTopics> {
|
|
|
2613
2613
|
* route with 501 in that mode.
|
|
2614
2614
|
*/
|
|
2615
2615
|
declare const defineLiveStream: <const Topics extends LiveTopics>(config: LiveStreamConfig<Topics>) => LiveStream<Topics>;
|
|
2616
|
+
/** A declared stream {@link liveStreamRouter} serves. `load` runs on the first request that reaches the stream. */
|
|
2617
|
+
interface LiveStreamMount {
|
|
2618
|
+
/** The stream's `id`, which names its routes: `/live/<id>/connect` and `/live/<id>/control`. */
|
|
2619
|
+
id: string;
|
|
2620
|
+
/** The stream's two handlers, deferred so a worker starts without evaluating every live module. */
|
|
2621
|
+
load: () => Promise<Pick<LiveStream, "connect" | "control">>;
|
|
2622
|
+
}
|
|
2623
|
+
/** Anything with a `fetch` a request can be handed to: `httpRouter()`, or a framework host's router. */
|
|
2624
|
+
interface LiveRouterApp {
|
|
2625
|
+
fetch(request: Request, env?: Record<string, unknown>, context?: ExecutionContext): Promise<Response> | Response;
|
|
2626
|
+
}
|
|
2627
|
+
/** The triggers a framework host may carry beside its `fetch`, which the runtime reads by name. */
|
|
2628
|
+
interface LiveHostTriggers {
|
|
2629
|
+
email?: unknown;
|
|
2630
|
+
queue?: unknown;
|
|
2631
|
+
scheduled?: unknown;
|
|
2632
|
+
}
|
|
2633
|
+
/** The router a live-stream router hands every other request to: an app with a `fetch`, or a bare `fetch` handler. */
|
|
2634
|
+
type LiveRouterFallback = (LiveHostTriggers & LiveRouterApp) | ((request: Request, env?: Record<string, unknown>, context?: ExecutionContext) => Promise<Response> | Response);
|
|
2635
|
+
/**
|
|
2636
|
+
* Serve each declared stream's connect and control routes. Codegen emits this as the worker's `httpRouter`, or wraps
|
|
2637
|
+
* a framework host with it, so a stream needs no `app.get` / `app.post` of its own.
|
|
2638
|
+
*
|
|
2639
|
+
* A Hono `fallback` (the app's `httpRouter()`) gets the stream routes registered on it, so its middleware runs for
|
|
2640
|
+
* them, and it is returned as the router. Any other `fallback` is a framework host: the stream routes are matched
|
|
2641
|
+
* first on a router of their own, and every other request goes to the host. With no `fallback`, the router is the
|
|
2642
|
+
* stream routes alone.
|
|
2643
|
+
*
|
|
2644
|
+
* Only the exact method and path of a stream's two routes are taken. Calling this again with the same Hono app adds
|
|
2645
|
+
* nothing, so the same app can be passed on every build.
|
|
2646
|
+
*/
|
|
2647
|
+
declare const liveStreamRouter: (mounts: ReadonlyArray<LiveStreamMount>, fallback?: LiveRouterFallback) => LiveRouterApp;
|
|
2616
2648
|
/**
|
|
2617
2649
|
* Structural mirrors of `@lunora/shard-engine`'s rank-page-row shapes
|
|
2618
2650
|
* (`RankPageRowKey` / `RankPageRow` / `ShardRankPageResult`) — the return type
|
|
@@ -4316,7 +4348,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
|
|
|
4316
4348
|
*/
|
|
4317
4349
|
declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
|
|
4318
4350
|
declare const VERSION = "0.0.0";
|
|
4319
|
-
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 LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, 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,
|
|
4351
|
+
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 LiveRouterApp, type LiveRouterFallback, type LiveStream, type LiveStreamConfig, type LiveStreamMount, type LiveSubscribeHandler, type LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, 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,
|
|
4320
4352
|
/**
|
|
4321
4353
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4322
4354
|
* NUL. Guards against response-header injection / `Headers`-construction throws
|
|
@@ -4361,7 +4393,7 @@ isSafeHeaderValue,
|
|
|
4361
4393
|
* handler can guard a request-derived header value before writing it — the fix the
|
|
4362
4394
|
* `http_action_response_header_injection` advisor lint points to.
|
|
4363
4395
|
*/
|
|
4364
|
-
lastEventId, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject,
|
|
4396
|
+
lastEventId, liveStreamRouter, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject,
|
|
4365
4397
|
/**
|
|
4366
4398
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4367
4399
|
* NUL. Guards against response-header injection / `Headers`-construction throws
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeC
|
|
|
4
4
|
export type { B as AuthState, C as CachePurge, H as DatabaseReader, D as DatabaseWriter, J as FunctionVisibility, N as GeoBoundingBox, P as GeoFilterBuilder, U as GeoIndexDefinition, Y as GeoPointInput, Z as IndexDefinition, _ as IndexRangeBuilder, $ as LifecycleEventKind, a0 as LogFields, a1 as LunoraLogMethod, a2 as LunoraLogger, a3 as LunoraMetrics, L as LunoraTracer, a4 as LunoraWideEvent, a5 as MutationStorage, a6 as PaginationOptions, a7 as PaginationResult, a8 as PatchIfResult, a9 as RankSortKey, aa as ReadOnlyStorage, ab as RelatedDirection, ac as RelatedNode, ad as RelatedOptions, ae as RelatedPage, af as RelatedStart, ag as RelatedStartReference, ah as RestCacheConfig, ai as RetryPolicy, aj as RunQueryOptions, ak as ScheduledFunctionDoc, al as ScheduledJob, am as Scheduler, an as SearchFilterBuilder, ao as SearchIndexDefinition, ap as ShardMode, aq as SpanContextIds, ar as SpanEvaluation, a as SpanHandle, as as SpanIdentity, at as SpanKind, au as SpanLink, av as SpanOptions, aw as Storage, ax as StorageListOptions, ay as StorageListResult, az as StorageMetadata, aA as StorageMultipartUpload, aB as StorageMultipartUploadOptions, aC as StorageObjectBody, aD as StorageObjectHead, aE as StorageRange, aF as StorageUploadBody, aG as StorageUploadOptions, aH as StorageUploadResult, aI as StorageUploadedPart, aJ as SystemDatabaseReader, aK as SystemDoc, aL as SystemQuery, aM as SystemTableName, aN as TableReader, aO as TableVectorIndex, aP as TriggerAggregateOptions, aQ as TriggerCtx, aR as TriggerDatabase, aS as TriggerDeleteEvent, aT as TriggerEvent, aU as TriggerGroupByEntry, aV as TriggerGroupByOptions, aW as TriggerHandler, aX as TriggerInsertEvent, aY as TriggerOp, aZ as TriggerQueryArgs, a_ as TriggerQueryPage, a$ as TriggerRankOptions, b0 as TriggerRankPageOptions, b1 as TriggerRankResult, b2 as TriggerRow, b3 as TriggerTiming, b4 as TriggerUpdateEvent, b5 as TtlDefinition, b6 as VectorMatch, b7 as VectorMatches, b8 as VectorQueryInput, b9 as VectorRecord, ba as VectorSearch, bb as VectorSearchReader, bc as VectorUpsertInput, bd as WorkflowCreateOptions, be as WorkflowEventDefinition, bf as WorkflowHandle, bg as WorkflowInstance, bh as WorkflowInstanceEvent, bi as WorkflowInstanceStatus, bj as WorkflowStatusResult, bk as Workflows } from "./packem_shared/types.d-CCjAj93e.js";
|
|
5
5
|
import { LunoraError } from '@lunora/errors';
|
|
6
6
|
export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
|
|
7
|
-
import { Context, Hono } from 'hono';
|
|
7
|
+
import { Context, Hono, ExecutionContext } from 'hono';
|
|
8
8
|
import { WhereOperators, QueryArgs as QueryArgs$2, QueryPlan } from "./data-model.js";
|
|
9
9
|
import { W as WhereInput, a as Policy, b as RlsOptions, c as Permission, R as Role, T as TypedDefinePolicyInput, D as DefinePolicyInput } from "./packem_shared/types.d-BCtjbIzl.js";
|
|
10
10
|
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-BCtjbIzl.js";
|
|
@@ -2581,11 +2581,11 @@ interface LiveStreamConfig<Topics extends LiveTopics = LiveTopics> {
|
|
|
2581
2581
|
}
|
|
2582
2582
|
/** The two route handlers {@link defineLiveStream} produces, plus the declaration they enforce. */
|
|
2583
2583
|
interface LiveStream<Topics extends LiveTopics = LiveTopics> {
|
|
2584
|
-
/**
|
|
2584
|
+
/** Served at `connectPath` by the worker's live-stream router. Returns the SSE response. */
|
|
2585
2585
|
connect: LunoraRouteHandler;
|
|
2586
2586
|
/** `GET` path for the SSE connection. */
|
|
2587
2587
|
connectPath: string;
|
|
2588
|
-
/**
|
|
2588
|
+
/** Served at `controlPath` by the worker's live-stream router. Returns a JSON ack. */
|
|
2589
2589
|
control: LunoraRouteHandler;
|
|
2590
2590
|
/** `POST` path for subscribe / unsubscribe control. */
|
|
2591
2591
|
controlPath: string;
|
|
@@ -2613,6 +2613,38 @@ interface LiveStream<Topics extends LiveTopics = LiveTopics> {
|
|
|
2613
2613
|
* route with 501 in that mode.
|
|
2614
2614
|
*/
|
|
2615
2615
|
declare const defineLiveStream: <const Topics extends LiveTopics>(config: LiveStreamConfig<Topics>) => LiveStream<Topics>;
|
|
2616
|
+
/** A declared stream {@link liveStreamRouter} serves. `load` runs on the first request that reaches the stream. */
|
|
2617
|
+
interface LiveStreamMount {
|
|
2618
|
+
/** The stream's `id`, which names its routes: `/live/<id>/connect` and `/live/<id>/control`. */
|
|
2619
|
+
id: string;
|
|
2620
|
+
/** The stream's two handlers, deferred so a worker starts without evaluating every live module. */
|
|
2621
|
+
load: () => Promise<Pick<LiveStream, "connect" | "control">>;
|
|
2622
|
+
}
|
|
2623
|
+
/** Anything with a `fetch` a request can be handed to: `httpRouter()`, or a framework host's router. */
|
|
2624
|
+
interface LiveRouterApp {
|
|
2625
|
+
fetch(request: Request, env?: Record<string, unknown>, context?: ExecutionContext): Promise<Response> | Response;
|
|
2626
|
+
}
|
|
2627
|
+
/** The triggers a framework host may carry beside its `fetch`, which the runtime reads by name. */
|
|
2628
|
+
interface LiveHostTriggers {
|
|
2629
|
+
email?: unknown;
|
|
2630
|
+
queue?: unknown;
|
|
2631
|
+
scheduled?: unknown;
|
|
2632
|
+
}
|
|
2633
|
+
/** The router a live-stream router hands every other request to: an app with a `fetch`, or a bare `fetch` handler. */
|
|
2634
|
+
type LiveRouterFallback = (LiveHostTriggers & LiveRouterApp) | ((request: Request, env?: Record<string, unknown>, context?: ExecutionContext) => Promise<Response> | Response);
|
|
2635
|
+
/**
|
|
2636
|
+
* Serve each declared stream's connect and control routes. Codegen emits this as the worker's `httpRouter`, or wraps
|
|
2637
|
+
* a framework host with it, so a stream needs no `app.get` / `app.post` of its own.
|
|
2638
|
+
*
|
|
2639
|
+
* A Hono `fallback` (the app's `httpRouter()`) gets the stream routes registered on it, so its middleware runs for
|
|
2640
|
+
* them, and it is returned as the router. Any other `fallback` is a framework host: the stream routes are matched
|
|
2641
|
+
* first on a router of their own, and every other request goes to the host. With no `fallback`, the router is the
|
|
2642
|
+
* stream routes alone.
|
|
2643
|
+
*
|
|
2644
|
+
* Only the exact method and path of a stream's two routes are taken. Calling this again with the same Hono app adds
|
|
2645
|
+
* nothing, so the same app can be passed on every build.
|
|
2646
|
+
*/
|
|
2647
|
+
declare const liveStreamRouter: (mounts: ReadonlyArray<LiveStreamMount>, fallback?: LiveRouterFallback) => LiveRouterApp;
|
|
2616
2648
|
/**
|
|
2617
2649
|
* Structural mirrors of `@lunora/shard-engine`'s rank-page-row shapes
|
|
2618
2650
|
* (`RankPageRowKey` / `RankPageRow` / `ShardRankPageResult`) — the return type
|
|
@@ -4316,7 +4348,7 @@ type RegisteredWhisperAuthorizer = RegisteredFunction<Record<string, never>, boo
|
|
|
4316
4348
|
*/
|
|
4317
4349
|
declare const onWhisper: (handler: WhisperAuthorizeHandler) => RegisteredWhisperAuthorizer;
|
|
4318
4350
|
declare const VERSION = "0.0.0";
|
|
4319
|
-
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 LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, 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,
|
|
4351
|
+
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 LiveRouterApp, type LiveRouterFallback, type LiveStream, type LiveStreamConfig, type LiveStreamMount, type LiveSubscribeHandler, type LiveSubscribeOptions, type LiveTopicDeclaration, type LiveTopicKey, type LiveTopicPayload, type LiveTopicRef, type LiveTopics, 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,
|
|
4320
4352
|
/**
|
|
4321
4353
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4322
4354
|
* NUL. Guards against response-header injection / `Headers`-construction throws
|
|
@@ -4361,7 +4393,7 @@ isSafeHeaderValue,
|
|
|
4361
4393
|
* handler can guard a request-derived header value before writing it — the fix the
|
|
4362
4394
|
* `http_action_response_header_injection` advisor lint points to.
|
|
4363
4395
|
*/
|
|
4364
|
-
lastEventId, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject,
|
|
4396
|
+
lastEventId, liveStreamRouter, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, onWhisper, platformAdmin, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject,
|
|
4365
4397
|
/**
|
|
4366
4398
|
* True when `value` is safe to use as an HTTP header field-value: no CR, LF, or
|
|
4367
4399
|
* 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
|
|
1
|
+
import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as i,actionCacheExtension as n,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-9W5_vf8H.mjs";import{initLunora as d}from"./packem_shared/initLunora-DH7k24N0.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-xyn3tFOE.mjs";import{LunoraEnvError as M,defineEnv as P,redactSecrets as b}from"./packem_shared/LunoraEnvError-bkdMu_-N.mjs";import{bindOrm as v,bindTableFacade as F}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-DplHzcUa.mjs";import{serveStorageObject as W}from"./packem_shared/serveStorageObject-B9GbK4qd.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,liveStreamRouter as ie}from"./packem_shared/defineLiveStream-DV3CtmGT.mjs";import{defineMigration as fe}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as se}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as me}from"./packem_shared/defineMutator-DlLFSWbO.mjs";import{platformAdmin as xe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as le,d as Ee,a as Se,b as ue,e as he,f as De,g as Te,h as ge,i as Re,j as Ae,k as Ie,m as Le}from"./packem_shared/plugin-Bm9wIpiI.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ce,PRESENCE_TABLE as Me,definePresence as Pe,presenceExtension as be}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-CKKVL22B.mjs";import{protectPublic as ve}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as Oe}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as Ne}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as we}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as Be}from"./packem_shared/defineShape-CULsDRu5.mjs";import{defineWebSocket as We}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as Ye}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Je}from"@lunora/errors";import{cronJobs as Qe}from"@lunora/scheduler";import{ValidationError as qe,v as ze}from"@lunora/values";import{allowAll as $e,deny as er,isDeny as rr,toWhereInput as or}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as ir}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as fr,buildRlsReadRegistry as ar,composeShapeReadWhere as sr}from"./packem_shared/assertShapesDeclareReadPolicies-Bg4Ter7Q.mjs";import{buildMaskRegistry as mr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as xr,definePermission as cr,definePolicies as lr,definePolicy as Er,defineRole as Sr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as hr,defineStorageRules as Dr}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{mask as gr}from"./packem_shared/mask-D-jRCAhy.mjs";import{r as Ar}from"./packem_shared/middleware-3ySZVrpt.mjs";import{storageRules as Lr}from"./packem_shared/storageRules-CBLioxF7.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,i 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,Ce as PRESENCE_DEFAULT_TTL_MS,Me as PRESENCE_TABLE,e as VERSION,qe as ValidationError,n as actionCacheExtension,$e as allowAll,ir as asBucketStorage,fr as assertShapesDeclareReadPolicies,S as beginDeferredDeletes,T as beginDeferredSchedules,v as bindOrm,F as bindTableFacade,mr as buildMaskRegistry,ar as buildRlsReadRegistry,f as cacheKeyFor,ee as clampLimit,le as composePluginMiddleware,sr as composeShapeReadWhere,xr as createPolicyDsl,l as createSecrets,we as createServices,Qe as cronJobs,a as defineActionCache,Ee as defineAggregateIndex,Se as defineComponent,L as defineDocumentHistory,P as defineEnv,Y as defineIdentity,J as defineIdentityGuard,re as defineListArgs,te as defineLiveStream,fe as defineMigration,se as defineModule,me as defineMutator,cr as definePermission,ue as definePlugin,lr as definePolicies,Er as definePolicy,Pe as definePresence,he as defineRankIndex,Sr as defineRole,Ne as defineRoom,De as defineSchema,Te as defineSchemaExtension,Be as defineShape,hr as defineStorageRule,Dr as defineStorageRules,ge as defineTable,Re as defineVectorIndex,We as defineWebSocket,er as deny,_ as documentHistoryExtension,u as flushDeferredDeletes,H as httpAction,N as httpRoute,k as httpRouter,Ae as indexFieldsFromSchema,d as initLunora,Ie as installPlugins,rr as isDeny,p as isPerDispatchMiddleware,w as isSafeHeaderValue,U as lastEventId,ie as liveStreamRouter,gr as mask,Le as mergeSchemaExtension,Q as onConnect,X as onDisconnect,Oe as onQueryChange,q as onShardInit,Ye as onWhisper,xe as platformAdmin,be as presenceExtension,ve as protectPublic,b as redactSecrets,Ar as rls,W as serveStorageObject,B as sseEvent,Lr as storageRules,x as tagPerDispatchMiddleware,or as toWhereInput,ze as v,h as withDeferredDeletes,g as withDeferredSchedules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as S,isLunoraError as I}from"@lunora/errors";import{isStringValidator as P,parseValidatorMap as w}from"@lunora/values";import{Hono as j}from"hono";import{httpRouter as A,httpAction as E}from"./httpAction-DplHzcUa.mjs";const C="/_lunora/live/connect",g="/_lunora/live/control",N="room:",D="__lunora_socket__:",B=256,v=e=>`/live/${e}/connect`,m=e=>`/live/${e}/control`,K=/^[A-Za-z]\w*$/u,T=e=>K.test(e),U=e=>`${e}:`.startsWith(N)||`${e}:`.startsWith(D),k=(e,t,r)=>[e,...t.map(a=>{const i=r[a];if(typeof i!="string")throw new TypeError(`live topic "${e}" needs a string key.${a}`);return encodeURIComponent(i)})].join(":"),V=(e,t)=>{if(e.length>B)return;const[r,...a]=e.split(":");if(r===void 0||!Object.hasOwn(t,r))return;const i=t[r];if(a.length!==i.length)return;const o={};try{for(const[d,u]of i.entries())o[u]=decodeURIComponent(a[d]);return k(r,i,o)===e?{key:o,name:r}:void 0}catch{return}},F=async e=>{try{const t=await e.json();return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}},_=e=>Response.json({code:"FORBIDDEN_TOPIC",error:`subscribe to "${e}" was denied`},{status:403}),h=e=>Response.json({code:"BAD_REQUEST",error:e},{status:400}),H=(e,t)=>{for(const[r,a]of Object.entries(t)){if(!T(r))throw new TypeError(`defineLiveStream("${e}"): topic name "${r}" must be a plain identifier (letters, digits and "_", starting with a letter)`);if(U(r))throw new TypeError(`defineLiveStream("${e}"): topic name "${r}" would encode into a reserved topic prefix`);for(const[i,o]of Object.entries(a.key??{})){if(!T(i))throw new TypeError(`defineLiveStream("${e}"): key field "${r}.${i}" must be a plain identifier`);if(!P(o))throw new TypeError(`defineLiveStream("${e}"): key field "${r}.${i}" must be a string validator (v.string(), v.id(), v.literal(…))`)}}},z=(e,t)=>new S("BAD_REQUEST",`publish to "${e}" was refused: ${t instanceof Error?t.message:String(t)}`,{status:400}),X=e=>{H(e.id,e.topics);const t=v(e.id),r=m(e.id),a=Object.fromEntries(Object.entries(e.topics).map(([s,c])=>[s,Object.keys(c.key??{})])),i=s=>{const c=V(s,a),n=c===void 0?void 0:e.topics[c.name];if(!(c===void 0||n===void 0))try{return{declaration:n,key:w(n.key??{},c.key,"key"),name:c.name}}catch{return}},o=(s,c)=>{const n=i(s);if(n===void 0)throw new S("BAD_REQUEST",`"${s}" is not a topic declared by live stream "${e.id}"`,{status:400});const{declaration:p}=n;try{return w({payload:p.payload},{payload:c},"topic").payload}catch(y){throw z(s,y)}},d=async(s,c)=>{const n=i(c);if(n===void 0)return!1;if(!e.onSubscribe)return e.allowAnonymousControl===!0&&s.auth.userId===null;try{return await e.onSubscribe({ctx:s,key:n.key,raw:c,topic:n.name})===!0}catch(p){return console.error("[lunora] live subscribe authorization threw; denying:",p),!1}},u=E(async(s,c)=>{const n=new URL(c.url).searchParams.get("shard")??void 0;return s.fetchShard(n,C,{method:"GET"})}),R=E(async(s,c)=>{const n=await F(c);if(!n)return h("Expected a JSON object body");const{action:p}=n,y=typeof n.topic=="string"?n.topic:void 0;if(y===void 0||y.length===0)return h("topic is required");if(p!=="subscribe"&&p!=="unsubscribe")return h("action must be subscribe or unsubscribe");const l=typeof n.shardKey=="string"?n.shardKey:void 0,L=l===void 0?s:{...s,...s.forShard(l)};if(p==="subscribe"&&!await d(L,y))return _(y);const b=s.fetchShard(l,g,{body:JSON.stringify({...n,stream:e.id}),method:"POST"});if(p!=="subscribe")return b;try{return await b}catch(f){if(I(f)&&f.code==="FORBIDDEN_SHARD")return _(y);throw f}});return{connect:u,connectPath:t,control:R,controlPath:r,id:e.id,topics:e.topics,validatePublish:o}},M=e=>typeof e!="object"?{}:{...typeof e.email=="function"?{email:e.email}:{},...typeof e.queue=="function"?{queue:e.queue}:{},...typeof e.scheduled=="function"?{scheduled:e.scheduled}:{}},$=new WeakSet,O=(e,t)=>{for(const r of t){let a;const i=()=>(a??=r.load().catch(o=>{throw a=void 0,o}),a);e.get(v(r.id),async o=>{const{connect:d}=await i();return d(o)}),e.post(m(r.id),async o=>{const{control:d}=await i();return d(o)})}},q=(e,t)=>{if(t instanceof j)return $.has(t)||(O(t,e),$.add(t)),t;const r=A();if(O(r,e),t===void 0)return r;const a=new Set(e.flatMap(o=>[`GET ${v(o.id)}`,`POST ${m(o.id)}`])),i=(o,d,u)=>typeof t=="function"?t(o,d,u):t.fetch(o,d,u);return{...M(t),fetch:(o,d,u)=>a.has(`${o.method} ${new URL(o.url).pathname}`)?r.fetch(o,d,u):i(o,d,u)}};export{X as defineLiveStream,q as liveStreamRouter};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as T,isLunoraError as $}from"@lunora/errors";import{isStringValidator as S,parseValidatorMap as b}from"@lunora/values";import{httpAction as m}from"./httpAction-DplHzcUa.mjs";const L="/_lunora/live/connect",R="/_lunora/live/control",I="room:",P="__lunora_socket__:",k=256,C=e=>`/live/${e}/connect`,j=e=>`/live/${e}/control`,A=/^[A-Za-z]\w*$/u,E=e=>A.test(e),N=e=>`${e}:`.startsWith(I)||`${e}:`.startsWith(P),D=(e,r,n)=>[e,...r.map(a=>{const s=n[a];if(typeof s!="string")throw new TypeError(`live topic "${e}" needs a string key.${a}`);return encodeURIComponent(s)})].join(":"),g=(e,r)=>{if(e.length>k)return;const[n,...a]=e.split(":");if(n===void 0||!Object.hasOwn(r,n))return;const s=r[n];if(a.length!==s.length)return;const d={};try{for(const[l,p]of s.entries())d[p]=decodeURIComponent(a[l]);return D(n,s,d)===e?{key:d,name:n}:void 0}catch{return}},B=async e=>{try{const r=await e.json();return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}catch{return}},w=e=>Response.json({code:"FORBIDDEN_TOPIC",error:`subscribe to "${e}" was denied`},{status:403}),h=e=>Response.json({code:"BAD_REQUEST",error:e},{status:400}),K=(e,r)=>{for(const[n,a]of Object.entries(r)){if(!E(n))throw new TypeError(`defineLiveStream("${e}"): topic name "${n}" must be a plain identifier (letters, digits and "_", starting with a letter)`);if(N(n))throw new TypeError(`defineLiveStream("${e}"): topic name "${n}" would encode into a reserved topic prefix`);for(const[s,d]of Object.entries(a.key??{})){if(!E(s))throw new TypeError(`defineLiveStream("${e}"): key field "${n}.${s}" must be a plain identifier`);if(!S(d))throw new TypeError(`defineLiveStream("${e}"): key field "${n}.${s}" must be a string validator (v.string(), v.id(), v.literal(…))`)}}},U=(e,r)=>new T("BAD_REQUEST",`publish to "${e}" was refused: ${r instanceof Error?r.message:String(r)}`,{status:400}),H=e=>{K(e.id,e.topics);const r=C(e.id),n=j(e.id),a=Object.fromEntries(Object.entries(e.topics).map(([o,i])=>[o,Object.keys(i.key??{})])),s=o=>{const i=g(o,a),t=i===void 0?void 0:e.topics[i.name];if(!(i===void 0||t===void 0))try{return{declaration:t,key:b(t.key??{},i.key,"key"),name:i.name}}catch{return}},d=(o,i)=>{const t=s(o);if(t===void 0)throw new T("BAD_REQUEST",`"${o}" is not a topic declared by live stream "${e.id}"`,{status:400});const{declaration:c}=t;try{return b({payload:c.payload},{payload:i},"topic").payload}catch(u){throw U(o,u)}},l=async(o,i)=>{const t=s(i);if(t===void 0)return!1;if(!e.onSubscribe)return e.allowAnonymousControl===!0&&o.auth.userId===null;try{return await e.onSubscribe({ctx:o,key:t.key,raw:i,topic:t.name})===!0}catch(c){return console.error("[lunora] live subscribe authorization threw; denying:",c),!1}},p=m(async(o,i)=>{const t=new URL(i.url).searchParams.get("shard")??void 0;return o.fetchShard(t,L,{method:"GET"})}),_=m(async(o,i)=>{const t=await B(i);if(!t)return h("Expected a JSON object body");const{action:c}=t,u=typeof t.topic=="string"?t.topic:void 0;if(u===void 0||u.length===0)return h("topic is required");if(c!=="subscribe"&&c!=="unsubscribe")return h("action must be subscribe or unsubscribe");const y=typeof t.shardKey=="string"?t.shardKey:void 0,O=y===void 0?o:{...o,...o.forShard(y)};if(c==="subscribe"&&!await l(O,u))return w(u);const f=o.fetchShard(y,R,{body:JSON.stringify({...t,stream:e.id}),method:"POST"});if(c!=="subscribe")return f;try{return await f}catch(v){if($(v)&&v.code==="FORBIDDEN_SHARD")return w(u);throw v}});return{connect:p,connectPath:r,control:_,controlPath:n,id:e.id,topics:e.topics,validatePublish:d}};export{H as defineLiveStream};
|