@lunora/runtime 1.0.0-alpha.4 → 1.0.0-alpha.6
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
|
@@ -1499,6 +1499,12 @@ interface ScheduledControllerLike {
|
|
|
1499
1499
|
*/
|
|
1500
1500
|
type CronHandler = (controller: ScheduledControllerLike, env: unknown, context: ExecutionContextLike) => Promise<void> | void;
|
|
1501
1501
|
/**
|
|
1502
|
+
* A Cloudflare Queues push-consumer handler — the worker's `queue()` entry
|
|
1503
|
+
* forwards each delivered `MessageBatch` (typed `unknown` here to keep the
|
|
1504
|
+
* runtime decoupled from `@lunora/queue`'s structural batch type).
|
|
1505
|
+
*/
|
|
1506
|
+
type QueueConsumerHandler = (batch: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1507
|
+
/**
|
|
1502
1508
|
* A single code-defined cron job, shaped like an entry of the generated
|
|
1503
1509
|
* `LUNORA_CRONS` map. `functionPath` is the `"namespace:fn"` to run, `args` its
|
|
1504
1510
|
* bound arguments, and `name` the human label from the `cronJobs()` builder.
|
|
@@ -1844,6 +1850,14 @@ interface WorkerOptions {
|
|
|
1844
1850
|
*/
|
|
1845
1851
|
queryCoordinator?: QueryCoordinator;
|
|
1846
1852
|
/**
|
|
1853
|
+
* Cloudflare Queues push-consumer handler — the worker's `queue(batch, …)`
|
|
1854
|
+
* entry forwards every delivered `MessageBatch` here. Built by codegen from
|
|
1855
|
+
* `lunora/queues.ts` (via `@lunora/queue`'s `dispatchQueueBatch`, which routes
|
|
1856
|
+
* by `batch.queue` to the matching `defineQueue` handler), so the runtime
|
|
1857
|
+
* stays decoupled from the queue package. Omitted when no push queues exist.
|
|
1858
|
+
*/
|
|
1859
|
+
queue?: QueueConsumerHandler;
|
|
1860
|
+
/**
|
|
1847
1861
|
* Resolve the calling identity from the inbound RPC request. Called once
|
|
1848
1862
|
* per RPC (and per fan-out) before the request is forwarded to the
|
|
1849
1863
|
* shard. The returned `userId` becomes `ctx.auth.userId` on the shard
|
|
@@ -1966,6 +1980,12 @@ interface RpcContext {
|
|
|
1966
1980
|
*/
|
|
1967
1981
|
interface LunoraWorker {
|
|
1968
1982
|
fetch: (request: Request, env: unknown, context: ExecutionContextLike) => Promise<Response>;
|
|
1983
|
+
/**
|
|
1984
|
+
* Cloudflare Queues consumer entry — present only when the app declares push
|
|
1985
|
+
* queues. Forwards each delivered `MessageBatch` to the configured
|
|
1986
|
+
* {@link WorkerOptions.queue} handler; a no-op when none is set.
|
|
1987
|
+
*/
|
|
1988
|
+
queue?: (batch: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1969
1989
|
scheduled: (controller: ScheduledControllerLike, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1970
1990
|
/**
|
|
1971
1991
|
* In-process query/mutation dispatch for SSR loaders co-located in this
|
|
@@ -2067,6 +2087,61 @@ type FrameworkWorkerOptionsInput = ((env: unknown) => FrameworkWorkerOptions) |
|
|
|
2067
2087
|
* @param optionsInput Lunora options minus `httpRouter`, or an `(env) => options` factory.
|
|
2068
2088
|
*/
|
|
2069
2089
|
declare const withFrameworkWorker: (host: FrameworkHostHandler, optionsInput: FrameworkWorkerOptionsInput) => LunoraWorker;
|
|
2090
|
+
/**
|
|
2091
|
+
* Options for {@link createLunoraHandler}. Either an `(env) => options` factory
|
|
2092
|
+
* (full control — for bindings that only exist at request time), or a partial
|
|
2093
|
+
* {@link FrameworkWorkerOptions} object whose `shardDO` defaults to the
|
|
2094
|
+
* conventional `env.SHARD` binding. Pass nothing for the common case.
|
|
2095
|
+
*/
|
|
2096
|
+
type LunoraHandlerOptions = ((env: unknown) => FrameworkWorkerOptions) | Partial<FrameworkWorkerOptions>;
|
|
2097
|
+
/**
|
|
2098
|
+
* No-op `ExecutionContext` used when the host runtime didn't supply one (a
|
|
2099
|
+
* non-Cloudflare preview, or a unit test), so the worker's `fetch` always
|
|
2100
|
+
* receives a valid third argument.
|
|
2101
|
+
*/
|
|
2102
|
+
declare const NOOP_EXECUTION_CONTEXT: ExecutionContextLike;
|
|
2103
|
+
/**
|
|
2104
|
+
* Resolve per-request Lunora worker options. A factory is called with the
|
|
2105
|
+
* request `env`; a partial object has its `shardDO` defaulted to `env.SHARD` so
|
|
2106
|
+
* the common case needs no configuration. Throws a clear error when no shard
|
|
2107
|
+
* namespace can be found — a wiring mistake, not a runtime condition to swallow.
|
|
2108
|
+
*/
|
|
2109
|
+
declare const resolveLunoraOptions: (options: LunoraHandlerOptions, env: unknown) => FrameworkWorkerOptions;
|
|
2110
|
+
/**
|
|
2111
|
+
* Build a framework-neutral request handler for Lunora's realtime plane
|
|
2112
|
+
* (`/_lunora/rpc`, `/_lunora/ws`, `/_lunora/admin/*`). This is the **one shared
|
|
2113
|
+
* seam** every web-standard framework integration mounts — Hono, Nitro/h3,
|
|
2114
|
+
* Elysia, or any WinterCG host running on Cloudflare Workers — so each is a
|
|
2115
|
+
* 1–2 line bridge (`(request, env, ctx) => Response`) rather than a bespoke
|
|
2116
|
+
* adapter package.
|
|
2117
|
+
*
|
|
2118
|
+
* Mount it under `/_lunora/*` (or whatever path you reserve) inside your app's
|
|
2119
|
+
* router; everything else stays your framework's. The host supplies, per
|
|
2120
|
+
* request: a Web `Request`, the Cloudflare `env` (carrying the `SHARD` Durable
|
|
2121
|
+
* Object namespace), and — when available — the `ExecutionContext`. The
|
|
2122
|
+
* `101 Switching Protocols` WebSocket-upgrade `Response` (with its `webSocket`)
|
|
2123
|
+
* is returned verbatim, so the framework streams the socket through unchanged.
|
|
2124
|
+
*
|
|
2125
|
+
* ```ts
|
|
2126
|
+
* // Hono
|
|
2127
|
+
* const lunora = createLunoraHandler();
|
|
2128
|
+
* app.use("/_lunora/*", (c) => lunora(c.req.raw, c.env, c.executionCtx));
|
|
2129
|
+
*
|
|
2130
|
+
* // Nitro / h3
|
|
2131
|
+
* const lunora = createLunoraHandler();
|
|
2132
|
+
* export default defineEventHandler((event) => {
|
|
2133
|
+
* const { ctx, env } = event.context.cloudflare;
|
|
2134
|
+
* return lunora(toWebRequest(event), env, ctx);
|
|
2135
|
+
* });
|
|
2136
|
+
* ```
|
|
2137
|
+
*
|
|
2138
|
+
* `shardDO` defaults to `env.SHARD`; pass `options` (or an `(env) => options`
|
|
2139
|
+
* factory) to add `auth`, `crons`, a `security` posture, or a custom namespace.
|
|
2140
|
+
* A new worker is composed per request because the options (and the `SHARD`
|
|
2141
|
+
* binding they default from) are only known once `env` arrives.
|
|
2142
|
+
* @param options Partial worker options (default `shardDO: env.SHARD`), or an `(env) => options` factory.
|
|
2143
|
+
*/
|
|
2144
|
+
declare const createLunoraHandler: (options?: LunoraHandlerOptions) => ((request: Request, env: unknown, context?: ExecutionContextLike) => Promise<Response>);
|
|
2070
2145
|
/** Re-exported helper so callers can roundtrip envelopes in tests. */
|
|
2071
2146
|
declare const defineRpcEnvelope: (envelope: RpcEnvelope) => RpcEnvelope;
|
|
2072
2147
|
/**
|
|
@@ -2310,4 +2385,4 @@ declare const analyticsEngineSink: (options: AnalyticsEngineSinkOptions) => Obse
|
|
|
2310
2385
|
*/
|
|
2311
2386
|
declare const combineSinks: (...sinks: ObservabilitySink[]) => ObservabilitySink;
|
|
2312
2387
|
declare const VERSION: string;
|
|
2313
|
-
export { type AdminTableResolver, type AirbyteMessage, type AnalyticsEngineDataPointLike, type AnalyticsEngineDatasetLike, type AnalyticsEngineSinkOptions, type AuthAdmin, type AuthCapabilities, type AuthImpersonation, type AuthIntrospector, type AuthPage, type AuthSession, type AuthUser, type BackupManifest, type BackupStore, type ConnectorChange, type ConnectorSyncPage, type CorsOptions, type CronHandler, type CronJobDispatch, type CronJobInfo, type CrossShardCounter, type CrossShardReader, type CrossShardRelationCapabilities, type CrossShardRelationOptions, type CsrfOptions, DEFAULT_REGISTRY_CACHE_TTL_MS, type DurableObjectJurisdiction, type DynamicShardRegistry, type DynamicShardRegistryOptions, type ExecutionContextLike, type ExportFanOutRequest, type ExportFanOutResult, type FanOutRequest, type FanOutResult, type FanOutSpec, type FivetranResponse, type FrameworkHostHandler, type FrameworkWorkerOptions, type FrameworkWorkerOptionsInput, type FunctionDescriptor, type FunctionRegistryEntry, type FunctionRegistryLike, type GlobalExportFunction as GlobalExportFn, type GlobalImportFunction as GlobalImportFn, type GlobalIntrospector, type GlobalTableInfo as GlobalTableInfoMeta, type GlobalTablePage as GlobalTablePageMeta, type HttpActionContext, type HttpActionLike, type HttpRouterLike, type ImportFanOutRequest, type ImportFanOutResult, type ListAuthUsersOptions, type LogEvent, type LogLevel, LunoraError, type LunoraErrorBody, type LunoraWorker, type MergeStrategy, type MigrationFanOutRequest, type MigrationFanOutResult, type ObservabilityEvent, type ObservabilitySink, type ObservabilitySinkContext, type QueryCoordinator, type QueryCoordinatorOptions, type RankFanOutRequest, type RankFanOutResult, type RankPageFanOutRequest, type RankPageFanOutResult, type ResolvedSecurity, type ResolvedShard, type Route, type RpcContext, type RpcEnvelope, SHARD_REGISTRY_DO_NAME, type ScheduledControllerLike, type SecurityHeadersOptions, type SecurityOptions, type SentrySinkOptions, type ShardError, type ShardExportOutcome, type ShardImportOutcome, type ShardMigrationOutcome, type ShardNamespaceLike, type ShardRankOutcome, type ShardRankPageOutcome, type ShardRegistry, type ShardTrafficEntry, type ShardTrafficFanOutRequest, type ShardTrafficFanOutResult, type ShardingInfo, type StorageListFunction as StorageListFn, type StorageObject, VERSION, type VectorIndexSummary, type VectorIntrospector, type VectorQueryMatch, type WebhookSinkOptions, type WorkerOptions, analyticsEngineSink, applyJurisdiction, combineSinks, composeWorker, consoleSink, createCrossShardRelationCapabilities, createDynamicShardRegistry, createQueryCoordinator, createStaticShardRegistry, createWorker, decorateResponse, defineRpcEnvelope, emitLogEvent, emitRpcEvent, enforceOrigin, handleCorsPreflight, mergeStrategyForAggregate, resolveSecurity, resolveShard, sentrySink, toAirbyteMessages, toErrorResponse, toFivetranResponse, webhookSink, withFrameworkWorker };
|
|
2388
|
+
export { type AdminTableResolver, type AirbyteMessage, type AnalyticsEngineDataPointLike, type AnalyticsEngineDatasetLike, type AnalyticsEngineSinkOptions, type AuthAdmin, type AuthCapabilities, type AuthImpersonation, type AuthIntrospector, type AuthPage, type AuthSession, type AuthUser, type BackupManifest, type BackupStore, type ConnectorChange, type ConnectorSyncPage, type CorsOptions, type CronHandler, type CronJobDispatch, type CronJobInfo, type CrossShardCounter, type CrossShardReader, type CrossShardRelationCapabilities, type CrossShardRelationOptions, type CsrfOptions, DEFAULT_REGISTRY_CACHE_TTL_MS, type DurableObjectJurisdiction, type DynamicShardRegistry, type DynamicShardRegistryOptions, type ExecutionContextLike, type ExportFanOutRequest, type ExportFanOutResult, type FanOutRequest, type FanOutResult, type FanOutSpec, type FivetranResponse, type FrameworkHostHandler, type FrameworkWorkerOptions, type FrameworkWorkerOptionsInput, type FunctionDescriptor, type FunctionRegistryEntry, type FunctionRegistryLike, type GlobalExportFunction as GlobalExportFn, type GlobalImportFunction as GlobalImportFn, type GlobalIntrospector, type GlobalTableInfo as GlobalTableInfoMeta, type GlobalTablePage as GlobalTablePageMeta, type HttpActionContext, type HttpActionLike, type HttpRouterLike, type ImportFanOutRequest, type ImportFanOutResult, type ListAuthUsersOptions, type LogEvent, type LogLevel, LunoraError, type LunoraErrorBody, type LunoraHandlerOptions, type LunoraWorker, type MergeStrategy, type MigrationFanOutRequest, type MigrationFanOutResult, NOOP_EXECUTION_CONTEXT, type ObservabilityEvent, type ObservabilitySink, type ObservabilitySinkContext, type QueryCoordinator, type QueryCoordinatorOptions, type RankFanOutRequest, type RankFanOutResult, type RankPageFanOutRequest, type RankPageFanOutResult, type ResolvedSecurity, type ResolvedShard, type Route, type RpcContext, type RpcEnvelope, SHARD_REGISTRY_DO_NAME, type ScheduledControllerLike, type SecurityHeadersOptions, type SecurityOptions, type SentrySinkOptions, type ShardError, type ShardExportOutcome, type ShardImportOutcome, type ShardMigrationOutcome, type ShardNamespaceLike, type ShardRankOutcome, type ShardRankPageOutcome, type ShardRegistry, type ShardTrafficEntry, type ShardTrafficFanOutRequest, type ShardTrafficFanOutResult, type ShardingInfo, type StorageListFunction as StorageListFn, type StorageObject, VERSION, type VectorIndexSummary, type VectorIntrospector, type VectorQueryMatch, type WebhookSinkOptions, type WorkerOptions, analyticsEngineSink, applyJurisdiction, combineSinks, composeWorker, consoleSink, createCrossShardRelationCapabilities, createDynamicShardRegistry, createLunoraHandler, createQueryCoordinator, createStaticShardRegistry, createWorker, decorateResponse, defineRpcEnvelope, emitLogEvent, emitRpcEvent, enforceOrigin, handleCorsPreflight, mergeStrategyForAggregate, resolveLunoraOptions, resolveSecurity, resolveShard, sentrySink, toAirbyteMessages, toErrorResponse, toFivetranResponse, webhookSink, withFrameworkWorker };
|
package/dist/index.d.ts
CHANGED
|
@@ -1499,6 +1499,12 @@ interface ScheduledControllerLike {
|
|
|
1499
1499
|
*/
|
|
1500
1500
|
type CronHandler = (controller: ScheduledControllerLike, env: unknown, context: ExecutionContextLike) => Promise<void> | void;
|
|
1501
1501
|
/**
|
|
1502
|
+
* A Cloudflare Queues push-consumer handler — the worker's `queue()` entry
|
|
1503
|
+
* forwards each delivered `MessageBatch` (typed `unknown` here to keep the
|
|
1504
|
+
* runtime decoupled from `@lunora/queue`'s structural batch type).
|
|
1505
|
+
*/
|
|
1506
|
+
type QueueConsumerHandler = (batch: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1507
|
+
/**
|
|
1502
1508
|
* A single code-defined cron job, shaped like an entry of the generated
|
|
1503
1509
|
* `LUNORA_CRONS` map. `functionPath` is the `"namespace:fn"` to run, `args` its
|
|
1504
1510
|
* bound arguments, and `name` the human label from the `cronJobs()` builder.
|
|
@@ -1844,6 +1850,14 @@ interface WorkerOptions {
|
|
|
1844
1850
|
*/
|
|
1845
1851
|
queryCoordinator?: QueryCoordinator;
|
|
1846
1852
|
/**
|
|
1853
|
+
* Cloudflare Queues push-consumer handler — the worker's `queue(batch, …)`
|
|
1854
|
+
* entry forwards every delivered `MessageBatch` here. Built by codegen from
|
|
1855
|
+
* `lunora/queues.ts` (via `@lunora/queue`'s `dispatchQueueBatch`, which routes
|
|
1856
|
+
* by `batch.queue` to the matching `defineQueue` handler), so the runtime
|
|
1857
|
+
* stays decoupled from the queue package. Omitted when no push queues exist.
|
|
1858
|
+
*/
|
|
1859
|
+
queue?: QueueConsumerHandler;
|
|
1860
|
+
/**
|
|
1847
1861
|
* Resolve the calling identity from the inbound RPC request. Called once
|
|
1848
1862
|
* per RPC (and per fan-out) before the request is forwarded to the
|
|
1849
1863
|
* shard. The returned `userId` becomes `ctx.auth.userId` on the shard
|
|
@@ -1966,6 +1980,12 @@ interface RpcContext {
|
|
|
1966
1980
|
*/
|
|
1967
1981
|
interface LunoraWorker {
|
|
1968
1982
|
fetch: (request: Request, env: unknown, context: ExecutionContextLike) => Promise<Response>;
|
|
1983
|
+
/**
|
|
1984
|
+
* Cloudflare Queues consumer entry — present only when the app declares push
|
|
1985
|
+
* queues. Forwards each delivered `MessageBatch` to the configured
|
|
1986
|
+
* {@link WorkerOptions.queue} handler; a no-op when none is set.
|
|
1987
|
+
*/
|
|
1988
|
+
queue?: (batch: unknown, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1969
1989
|
scheduled: (controller: ScheduledControllerLike, env: unknown, context: ExecutionContextLike) => Promise<void>;
|
|
1970
1990
|
/**
|
|
1971
1991
|
* In-process query/mutation dispatch for SSR loaders co-located in this
|
|
@@ -2067,6 +2087,61 @@ type FrameworkWorkerOptionsInput = ((env: unknown) => FrameworkWorkerOptions) |
|
|
|
2067
2087
|
* @param optionsInput Lunora options minus `httpRouter`, or an `(env) => options` factory.
|
|
2068
2088
|
*/
|
|
2069
2089
|
declare const withFrameworkWorker: (host: FrameworkHostHandler, optionsInput: FrameworkWorkerOptionsInput) => LunoraWorker;
|
|
2090
|
+
/**
|
|
2091
|
+
* Options for {@link createLunoraHandler}. Either an `(env) => options` factory
|
|
2092
|
+
* (full control — for bindings that only exist at request time), or a partial
|
|
2093
|
+
* {@link FrameworkWorkerOptions} object whose `shardDO` defaults to the
|
|
2094
|
+
* conventional `env.SHARD` binding. Pass nothing for the common case.
|
|
2095
|
+
*/
|
|
2096
|
+
type LunoraHandlerOptions = ((env: unknown) => FrameworkWorkerOptions) | Partial<FrameworkWorkerOptions>;
|
|
2097
|
+
/**
|
|
2098
|
+
* No-op `ExecutionContext` used when the host runtime didn't supply one (a
|
|
2099
|
+
* non-Cloudflare preview, or a unit test), so the worker's `fetch` always
|
|
2100
|
+
* receives a valid third argument.
|
|
2101
|
+
*/
|
|
2102
|
+
declare const NOOP_EXECUTION_CONTEXT: ExecutionContextLike;
|
|
2103
|
+
/**
|
|
2104
|
+
* Resolve per-request Lunora worker options. A factory is called with the
|
|
2105
|
+
* request `env`; a partial object has its `shardDO` defaulted to `env.SHARD` so
|
|
2106
|
+
* the common case needs no configuration. Throws a clear error when no shard
|
|
2107
|
+
* namespace can be found — a wiring mistake, not a runtime condition to swallow.
|
|
2108
|
+
*/
|
|
2109
|
+
declare const resolveLunoraOptions: (options: LunoraHandlerOptions, env: unknown) => FrameworkWorkerOptions;
|
|
2110
|
+
/**
|
|
2111
|
+
* Build a framework-neutral request handler for Lunora's realtime plane
|
|
2112
|
+
* (`/_lunora/rpc`, `/_lunora/ws`, `/_lunora/admin/*`). This is the **one shared
|
|
2113
|
+
* seam** every web-standard framework integration mounts — Hono, Nitro/h3,
|
|
2114
|
+
* Elysia, or any WinterCG host running on Cloudflare Workers — so each is a
|
|
2115
|
+
* 1–2 line bridge (`(request, env, ctx) => Response`) rather than a bespoke
|
|
2116
|
+
* adapter package.
|
|
2117
|
+
*
|
|
2118
|
+
* Mount it under `/_lunora/*` (or whatever path you reserve) inside your app's
|
|
2119
|
+
* router; everything else stays your framework's. The host supplies, per
|
|
2120
|
+
* request: a Web `Request`, the Cloudflare `env` (carrying the `SHARD` Durable
|
|
2121
|
+
* Object namespace), and — when available — the `ExecutionContext`. The
|
|
2122
|
+
* `101 Switching Protocols` WebSocket-upgrade `Response` (with its `webSocket`)
|
|
2123
|
+
* is returned verbatim, so the framework streams the socket through unchanged.
|
|
2124
|
+
*
|
|
2125
|
+
* ```ts
|
|
2126
|
+
* // Hono
|
|
2127
|
+
* const lunora = createLunoraHandler();
|
|
2128
|
+
* app.use("/_lunora/*", (c) => lunora(c.req.raw, c.env, c.executionCtx));
|
|
2129
|
+
*
|
|
2130
|
+
* // Nitro / h3
|
|
2131
|
+
* const lunora = createLunoraHandler();
|
|
2132
|
+
* export default defineEventHandler((event) => {
|
|
2133
|
+
* const { ctx, env } = event.context.cloudflare;
|
|
2134
|
+
* return lunora(toWebRequest(event), env, ctx);
|
|
2135
|
+
* });
|
|
2136
|
+
* ```
|
|
2137
|
+
*
|
|
2138
|
+
* `shardDO` defaults to `env.SHARD`; pass `options` (or an `(env) => options`
|
|
2139
|
+
* factory) to add `auth`, `crons`, a `security` posture, or a custom namespace.
|
|
2140
|
+
* A new worker is composed per request because the options (and the `SHARD`
|
|
2141
|
+
* binding they default from) are only known once `env` arrives.
|
|
2142
|
+
* @param options Partial worker options (default `shardDO: env.SHARD`), or an `(env) => options` factory.
|
|
2143
|
+
*/
|
|
2144
|
+
declare const createLunoraHandler: (options?: LunoraHandlerOptions) => ((request: Request, env: unknown, context?: ExecutionContextLike) => Promise<Response>);
|
|
2070
2145
|
/** Re-exported helper so callers can roundtrip envelopes in tests. */
|
|
2071
2146
|
declare const defineRpcEnvelope: (envelope: RpcEnvelope) => RpcEnvelope;
|
|
2072
2147
|
/**
|
|
@@ -2310,4 +2385,4 @@ declare const analyticsEngineSink: (options: AnalyticsEngineSinkOptions) => Obse
|
|
|
2310
2385
|
*/
|
|
2311
2386
|
declare const combineSinks: (...sinks: ObservabilitySink[]) => ObservabilitySink;
|
|
2312
2387
|
declare const VERSION: string;
|
|
2313
|
-
export { type AdminTableResolver, type AirbyteMessage, type AnalyticsEngineDataPointLike, type AnalyticsEngineDatasetLike, type AnalyticsEngineSinkOptions, type AuthAdmin, type AuthCapabilities, type AuthImpersonation, type AuthIntrospector, type AuthPage, type AuthSession, type AuthUser, type BackupManifest, type BackupStore, type ConnectorChange, type ConnectorSyncPage, type CorsOptions, type CronHandler, type CronJobDispatch, type CronJobInfo, type CrossShardCounter, type CrossShardReader, type CrossShardRelationCapabilities, type CrossShardRelationOptions, type CsrfOptions, DEFAULT_REGISTRY_CACHE_TTL_MS, type DurableObjectJurisdiction, type DynamicShardRegistry, type DynamicShardRegistryOptions, type ExecutionContextLike, type ExportFanOutRequest, type ExportFanOutResult, type FanOutRequest, type FanOutResult, type FanOutSpec, type FivetranResponse, type FrameworkHostHandler, type FrameworkWorkerOptions, type FrameworkWorkerOptionsInput, type FunctionDescriptor, type FunctionRegistryEntry, type FunctionRegistryLike, type GlobalExportFunction as GlobalExportFn, type GlobalImportFunction as GlobalImportFn, type GlobalIntrospector, type GlobalTableInfo as GlobalTableInfoMeta, type GlobalTablePage as GlobalTablePageMeta, type HttpActionContext, type HttpActionLike, type HttpRouterLike, type ImportFanOutRequest, type ImportFanOutResult, type ListAuthUsersOptions, type LogEvent, type LogLevel, LunoraError, type LunoraErrorBody, type LunoraWorker, type MergeStrategy, type MigrationFanOutRequest, type MigrationFanOutResult, type ObservabilityEvent, type ObservabilitySink, type ObservabilitySinkContext, type QueryCoordinator, type QueryCoordinatorOptions, type RankFanOutRequest, type RankFanOutResult, type RankPageFanOutRequest, type RankPageFanOutResult, type ResolvedSecurity, type ResolvedShard, type Route, type RpcContext, type RpcEnvelope, SHARD_REGISTRY_DO_NAME, type ScheduledControllerLike, type SecurityHeadersOptions, type SecurityOptions, type SentrySinkOptions, type ShardError, type ShardExportOutcome, type ShardImportOutcome, type ShardMigrationOutcome, type ShardNamespaceLike, type ShardRankOutcome, type ShardRankPageOutcome, type ShardRegistry, type ShardTrafficEntry, type ShardTrafficFanOutRequest, type ShardTrafficFanOutResult, type ShardingInfo, type StorageListFunction as StorageListFn, type StorageObject, VERSION, type VectorIndexSummary, type VectorIntrospector, type VectorQueryMatch, type WebhookSinkOptions, type WorkerOptions, analyticsEngineSink, applyJurisdiction, combineSinks, composeWorker, consoleSink, createCrossShardRelationCapabilities, createDynamicShardRegistry, createQueryCoordinator, createStaticShardRegistry, createWorker, decorateResponse, defineRpcEnvelope, emitLogEvent, emitRpcEvent, enforceOrigin, handleCorsPreflight, mergeStrategyForAggregate, resolveSecurity, resolveShard, sentrySink, toAirbyteMessages, toErrorResponse, toFivetranResponse, webhookSink, withFrameworkWorker };
|
|
2388
|
+
export { type AdminTableResolver, type AirbyteMessage, type AnalyticsEngineDataPointLike, type AnalyticsEngineDatasetLike, type AnalyticsEngineSinkOptions, type AuthAdmin, type AuthCapabilities, type AuthImpersonation, type AuthIntrospector, type AuthPage, type AuthSession, type AuthUser, type BackupManifest, type BackupStore, type ConnectorChange, type ConnectorSyncPage, type CorsOptions, type CronHandler, type CronJobDispatch, type CronJobInfo, type CrossShardCounter, type CrossShardReader, type CrossShardRelationCapabilities, type CrossShardRelationOptions, type CsrfOptions, DEFAULT_REGISTRY_CACHE_TTL_MS, type DurableObjectJurisdiction, type DynamicShardRegistry, type DynamicShardRegistryOptions, type ExecutionContextLike, type ExportFanOutRequest, type ExportFanOutResult, type FanOutRequest, type FanOutResult, type FanOutSpec, type FivetranResponse, type FrameworkHostHandler, type FrameworkWorkerOptions, type FrameworkWorkerOptionsInput, type FunctionDescriptor, type FunctionRegistryEntry, type FunctionRegistryLike, type GlobalExportFunction as GlobalExportFn, type GlobalImportFunction as GlobalImportFn, type GlobalIntrospector, type GlobalTableInfo as GlobalTableInfoMeta, type GlobalTablePage as GlobalTablePageMeta, type HttpActionContext, type HttpActionLike, type HttpRouterLike, type ImportFanOutRequest, type ImportFanOutResult, type ListAuthUsersOptions, type LogEvent, type LogLevel, LunoraError, type LunoraErrorBody, type LunoraHandlerOptions, type LunoraWorker, type MergeStrategy, type MigrationFanOutRequest, type MigrationFanOutResult, NOOP_EXECUTION_CONTEXT, type ObservabilityEvent, type ObservabilitySink, type ObservabilitySinkContext, type QueryCoordinator, type QueryCoordinatorOptions, type RankFanOutRequest, type RankFanOutResult, type RankPageFanOutRequest, type RankPageFanOutResult, type ResolvedSecurity, type ResolvedShard, type Route, type RpcContext, type RpcEnvelope, SHARD_REGISTRY_DO_NAME, type ScheduledControllerLike, type SecurityHeadersOptions, type SecurityOptions, type SentrySinkOptions, type ShardError, type ShardExportOutcome, type ShardImportOutcome, type ShardMigrationOutcome, type ShardNamespaceLike, type ShardRankOutcome, type ShardRankPageOutcome, type ShardRegistry, type ShardTrafficEntry, type ShardTrafficFanOutRequest, type ShardTrafficFanOutResult, type ShardingInfo, type StorageListFunction as StorageListFn, type StorageObject, VERSION, type VectorIndexSummary, type VectorIntrospector, type VectorQueryMatch, type WebhookSinkOptions, type WorkerOptions, analyticsEngineSink, applyJurisdiction, combineSinks, composeWorker, consoleSink, createCrossShardRelationCapabilities, createDynamicShardRegistry, createLunoraHandler, createQueryCoordinator, createStaticShardRegistry, createWorker, decorateResponse, defineRpcEnvelope, emitLogEvent, emitRpcEvent, enforceOrigin, handleCorsPreflight, mergeStrategyForAggregate, resolveLunoraOptions, resolveSecurity, resolveShard, sentrySink, toAirbyteMessages, toErrorResponse, toFivetranResponse, webhookSink, withFrameworkWorker };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { toAirbyteMessages, toFivetranResponse } from './packem_shared/toAirbyteMessages-DrHdplb4.mjs';
|
|
2
|
-
export { composeWorker, createWorker, defineRpcEnvelope, withFrameworkWorker } from './packem_shared/
|
|
2
|
+
export { NOOP_EXECUTION_CONTEXT, composeWorker, createLunoraHandler, createWorker, defineRpcEnvelope, resolveLunoraOptions, withFrameworkWorker } from './packem_shared/NOOP_EXECUTION_CONTEXT-Rns-X7RV.mjs';
|
|
3
3
|
export { createCrossShardRelationCapabilities } from './packem_shared/createCrossShardRelationCapabilities-C0KOf7er.mjs';
|
|
4
4
|
export { DEFAULT_REGISTRY_CACHE_TTL_MS, SHARD_REGISTRY_DO_NAME, createDynamicShardRegistry } from './packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-ocax8v0n.mjs';
|
|
5
5
|
export { LunoraError, toErrorResponse } from './packem_shared/LunoraError-CL0aOtpo.mjs';
|
package/dist/packem_shared/{composeWorker-Dxt4Mo0R.mjs → NOOP_EXECUTION_CONTEXT-Rns-X7RV.mjs}
RENAMED
|
@@ -2467,6 +2467,9 @@ const createWorker = (options) => {
|
|
|
2467
2467
|
return decorateResponse(toErrorResponse(error), request, resolvedSecurity);
|
|
2468
2468
|
}
|
|
2469
2469
|
},
|
|
2470
|
+
async queue(batch, env, context) {
|
|
2471
|
+
await options.queue?.(batch, env, context);
|
|
2472
|
+
},
|
|
2470
2473
|
async scheduled(controller, env, context) {
|
|
2471
2474
|
await handleScheduled(controller, env, context);
|
|
2472
2475
|
},
|
|
@@ -2497,10 +2500,30 @@ const withFrameworkWorker = (host, optionsInput) => {
|
|
|
2497
2500
|
const optionsFactory = optionsInput;
|
|
2498
2501
|
return {
|
|
2499
2502
|
fetch: (request, env, context) => build(optionsFactory(env)).fetch(request, env, context),
|
|
2503
|
+
queue: (batch, env, context) => build(optionsFactory(env)).queue?.(batch, env, context) ?? Promise.resolve(),
|
|
2500
2504
|
scheduled: (controller, env, context) => build(optionsFactory(env)).scheduled(controller, env, context),
|
|
2501
2505
|
serverQuery: (request, env, reference, args, options) => build(optionsFactory(env)).serverQuery(request, env, reference, args, options)
|
|
2502
2506
|
};
|
|
2503
2507
|
};
|
|
2508
|
+
const NOOP_EXECUTION_CONTEXT = {
|
|
2509
|
+
passThroughOnException: () => {
|
|
2510
|
+
},
|
|
2511
|
+
waitUntil: () => {
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
const resolveLunoraOptions = (options, env) => {
|
|
2515
|
+
if (typeof options === "function") {
|
|
2516
|
+
return options(env);
|
|
2517
|
+
}
|
|
2518
|
+
const shardDO = options.shardDO ?? env?.SHARD;
|
|
2519
|
+
if (!shardDO) {
|
|
2520
|
+
throw new Error(
|
|
2521
|
+
"@lunora/runtime: no shard Durable Object namespace found. Bind `SHARD` in wrangler.jsonc, or pass `createLunoraHandler({ shardDO: env.MY_SHARD })`."
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
return { ...options, shardDO };
|
|
2525
|
+
};
|
|
2526
|
+
const createLunoraHandler = (options = {}) => (request, env, context) => createWorker(resolveLunoraOptions(options, env)).fetch(request, env, context ?? NOOP_EXECUTION_CONTEXT);
|
|
2504
2527
|
const defineRpcEnvelope = (envelope) => envelope;
|
|
2505
2528
|
|
|
2506
|
-
export { composeWorker, createWorker, defineRpcEnvelope, withFrameworkWorker };
|
|
2529
|
+
export { NOOP_EXECUTION_CONTEXT, composeWorker, createLunoraHandler, createWorker, defineRpcEnvelope, resolveLunoraOptions, withFrameworkWorker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "Lunora Worker runtime: the RPC router, shard resolver, and query coordinator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/runtime"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
28
|
+
"./dist",
|
|
29
29
|
"README.md",
|
|
30
30
|
"LICENSE.md",
|
|
31
31
|
"__assets__"
|