@lunora/runtime 1.0.0-alpha.4 → 1.0.0-alpha.5

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
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
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/composeWorker-Dxt4Mo0R.mjs';
2
+ export { composeWorker, createWorker, defineRpcEnvelope, withFrameworkWorker } from './packem_shared/composeWorker-49Hxp9Ho.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';
@@ -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,6 +2500,7 @@ 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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/runtime",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
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__"