@moku-labs/worker 0.7.2 → 0.8.0

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.
@@ -739,7 +739,8 @@ const createQueuesApi = (ctx) => {
739
739
  kind: "queue",
740
740
  name: instance.name,
741
741
  binding: instance.binding,
742
- ...instance.onMessage ? { consumer: true } : {}
742
+ ...instance.onMessage ? { consumer: true } : {},
743
+ ...instance.maxBatchTimeout === void 0 ? {} : { maxBatchTimeout: instance.maxBatchTimeout }
743
744
  }))
744
745
  };
745
746
  };
@@ -2185,6 +2186,57 @@ const renderProvisionResult = (ui, result) => {
2185
2186
  }
2186
2187
  }
2187
2188
  };
2189
+ /**
2190
+ * Format an elapsed duration compactly: sub-second as `820ms`, otherwise one-decimal seconds (`4.2s`),
2191
+ * and minutes once it crosses 60s (`1m04s`) so a long deploy stays readable.
2192
+ *
2193
+ * @param ms - The elapsed milliseconds.
2194
+ * @returns The compact duration string.
2195
+ * @example
2196
+ * ```ts
2197
+ * formatDuration(4234); // "4.2s"
2198
+ * ```
2199
+ */
2200
+ const formatDuration = (ms) => {
2201
+ if (ms < 1e3) return `${String(ms)}ms`;
2202
+ const seconds = ms / 1e3;
2203
+ if (seconds < 60) return `${seconds.toFixed(1)}s`;
2204
+ const whole = Math.floor(seconds);
2205
+ return `${String(Math.floor(whole / 60))}m${String(whole % 60).padStart(2, "0")}s`;
2206
+ };
2207
+ /**
2208
+ * Render the terminal deploy summary as a branded panel — the headline the user actually wants. The
2209
+ * live URL leads on its own line (pink, so it is the first thing the eye lands on), then a dim
2210
+ * key/value block: the target stage, the resource tally (with a red `failed` count when non-zero),
2211
+ * and the wall-clock time the whole deploy took. Replaces the prior single `deployed → url` line.
2212
+ *
2213
+ * @param ui - The branded console to render through.
2214
+ * @param summary - The deploy summary fields.
2215
+ * @param summary.url - The live deployed URL (the panel headline).
2216
+ * @param summary.stage - The target stage the worker deployed to.
2217
+ * @param summary.created - How many resources were created this run.
2218
+ * @param summary.exists - How many resources already existed (skipped).
2219
+ * @param summary.failed - How many resources failed to provision.
2220
+ * @param summary.elapsedMs - The wall-clock deploy duration in milliseconds.
2221
+ * @example
2222
+ * ```ts
2223
+ * renderDeploySummary(ui, { url, stage: "production", created: 0, exists: 5, failed: 0, elapsedMs: 4234 });
2224
+ * ```
2225
+ */
2226
+ const renderDeploySummary = (ui, summary) => {
2227
+ const { palette } = ui;
2228
+ const tally = `${String(summary.exists)} exist · ${String(summary.created)} created`;
2229
+ const failedLabel = palette.red(`${String(summary.failed)} failed`);
2230
+ const resources = summary.failed > 0 ? `${tally} · ${failedLabel}` : tally;
2231
+ ui.heading("Deployed");
2232
+ ui.box([
2233
+ palette.pink(summary.url),
2234
+ "",
2235
+ `${palette.dim("stage".padEnd(10))}${summary.stage}`,
2236
+ `${palette.dim("resources".padEnd(10))}${resources}`,
2237
+ `${palette.dim("took".padEnd(10))}${formatDuration(summary.elapsedMs)}`
2238
+ ]);
2239
+ };
2188
2240
  //#endregion
2189
2241
  //#region src/plugins/deploy/naming.ts
2190
2242
  /**
@@ -2560,13 +2612,14 @@ const buildD1Databases = (resources, ids) => resources.filter((resource) => reso
2560
2612
  * Every queue is a `producer`; a queue flagged `consumer: true` (it declares an `onMessage` handler)
2561
2613
  * is ALSO registered as a `consumer` so wrangler delivers its messages to this Worker's queue()
2562
2614
  * handler — both locally under `wrangler dev` and in production. Without the consumer entry the
2563
- * handler never runs (the bug that silently drops a queue-driven activity feed).
2615
+ * handler never runs (the bug that silently drops a queue-driven activity feed). A consumer that
2616
+ * sets `maxBatchTimeout` carries it through as wrangler's `max_batch_timeout` (lower delivery latency).
2564
2617
  *
2565
2618
  * @param resources - All resource descriptors from the manifest.
2566
2619
  * @returns The queues section (producers, plus consumers when any), or undefined when there are none.
2567
2620
  * @example
2568
2621
  * ```ts
2569
- * const q = buildQueues([{ kind: "queue", name: "tracker-activity", binding: "ACTIVITY", consumer: true }]);
2622
+ * const q = buildQueues([{ kind: "queue", name: "tracker-activity", binding: "ACTIVITY", consumer: true, maxBatchTimeout: 1 }]);
2570
2623
  * ```
2571
2624
  */
2572
2625
  const buildQueues = (resources) => {
@@ -2576,7 +2629,11 @@ const buildQueues = (resources) => {
2576
2629
  queue: resource.name,
2577
2630
  binding: resource.binding
2578
2631
  }));
2579
- const consumers = queueResources.filter((resource) => resource.consumer === true).map((resource) => ({ queue: resource.name }));
2632
+ const consumers = queueResources.filter((resource) => resource.consumer === true).map((resource) => {
2633
+ const entry = { queue: resource.name };
2634
+ if (resource.maxBatchTimeout !== void 0) entry.max_batch_timeout = resource.maxBatchTimeout;
2635
+ return entry;
2636
+ });
2580
2637
  return consumers.length > 0 ? {
2581
2638
  producers,
2582
2639
  consumers
@@ -3065,29 +3122,31 @@ const guidedUpload = async (ctx, manifest, deps) => {
3065
3122
  };
3066
3123
  /**
3067
3124
  * The final deploy step: confirm the target (guided only), run `wrangler deploy` with interactive
3068
- * retry, then emit deploy:complete. Resolves false when the target gate or a deploy retry is declined.
3125
+ * retry, then emit deploy:complete. Returns the deployed URL, or undefined when the target gate or a
3126
+ * deploy retry is declined (so the caller renders the summary panel only on a real success).
3069
3127
  *
3070
3128
  * @param ctx - The deploy plugin context.
3071
3129
  * @param manifest - The assembled (or caller-supplied) deploy manifest.
3072
3130
  * @param stage - The resolved deploy stage (for the confirm prompt).
3073
3131
  * @param deps - Interactivity + the confirm prompt.
3074
- * @returns True once deployed; false when the user declined the gate or a retry (abort).
3132
+ * @returns The deployed URL once live; undefined when the user declined the gate or a retry (abort).
3075
3133
  * @example
3076
3134
  * ```ts
3077
- * if (!(await guidedDeployStep(ctx, manifest, stage, deps))) return emitAborted(ctx);
3135
+ * const url = await guidedDeployStep(ctx, manifest, stage, deps);
3136
+ * if (url === undefined) return emitAborted(ctx);
3078
3137
  * ```
3079
3138
  */
3080
3139
  const guidedDeployStep = async (ctx, manifest, stage, deps) => {
3081
- if (!await deps.confirm(`Deploy "${manifest.name}" to ${stage}?`)) return false;
3140
+ if (!await deps.confirm(`Deploy "${manifest.name}" to ${stage}?`)) return void 0;
3082
3141
  ctx.emit("deploy:phase", { phase: "deploy" });
3083
3142
  const url = await guidedStep(() => runWrangler([
3084
3143
  "deploy",
3085
3144
  "--config",
3086
3145
  ctx.config.configFile
3087
3146
  ]), HINTS.deploy, deps);
3088
- if (url === ABORTED) return false;
3147
+ if (url === ABORTED) return void 0;
3089
3148
  ctx.emit("deploy:complete", { url });
3090
- return true;
3149
+ return url;
3091
3150
  };
3092
3151
  /**
3093
3152
  * Create the deploy api. Assembles the manifest from each resource plugin's own deployManifest(),
@@ -3135,6 +3194,7 @@ const createDeployApi = (ctx) => ({
3135
3194
  interactive,
3136
3195
  confirm: interactive ? createBrandPrompts().confirm : async (_question) => true
3137
3196
  };
3197
+ const startedAt = Date.now();
3138
3198
  ctx.emit("deploy:phase", { phase: "auth" });
3139
3199
  if (!await guidedAuth(ctx, deps)) return emitAborted(ctx);
3140
3200
  if (!await guidedWebBuild(ctx, opts?.webBuild ?? ctx.config.webBuild, deps)) return emitAborted(ctx);
@@ -3146,7 +3206,16 @@ const createDeployApi = (ctx) => ({
3146
3206
  ctx.emit("deploy:phase", { phase: "wrangler-config" });
3147
3207
  await writeWranglerConfig(ctx.config.configFile, manifest, provisioned.ids, wranglerExtra(ctx.config));
3148
3208
  if (!await guidedUpload(ctx, manifest, deps)) return emitAborted(ctx);
3149
- if (!await guidedDeployStep(ctx, manifest, stage, deps)) return emitAborted(ctx);
3209
+ const url = await guidedDeployStep(ctx, manifest, stage, deps);
3210
+ if (url === void 0) return emitAborted(ctx);
3211
+ renderDeploySummary(createBrandConsole(), {
3212
+ url,
3213
+ stage,
3214
+ created: provisioned.created.length,
3215
+ exists: provisioned.skipped.length,
3216
+ failed: provisioned.failed.length,
3217
+ elapsedMs: Date.now() - startedAt
3218
+ });
3150
3219
  },
3151
3220
  /**
3152
3221
  * Start a long-lived local dev session: cold-build the Moku site, spawn `wrangler dev
@@ -3631,7 +3700,7 @@ const SPINNER_CLEAR = `\r${" ".repeat(72)}\r`;
3631
3700
  * const hooks = createCliHooks(ctx);
3632
3701
  * hooks["deploy:phase"]({ phase: "detect" }); // logs "detect" → renders " › detect"
3633
3702
  * hooks["dev:phase"]({ phase: "serve", detail: "http://localhost:8787" }); // "serve · …"
3634
- * hooks["deploy:complete"]({ url: "https://x.workers.dev" }); // "deployed https://x.workers.dev"
3703
+ * hooks["deploy:complete"](); // settles the deploy spinner; the "Deployed" panel renders separately
3635
3704
  * ```
3636
3705
  */
3637
3706
  const createCliHooks = (ctx) => {
@@ -3718,17 +3787,16 @@ const createCliHooks = (ctx) => {
3718
3787
  ctx.log.warn(p.message);
3719
3788
  },
3720
3789
  /**
3721
- * Log the terminal success line with the deployed URL.
3790
+ * Settle the final deploy spinner. The deployed URL + summary now render as a branded panel (the
3791
+ * deploy plugin's renderDeploySummary), so the cli no longer logs a duplicate `deployed → url`.
3722
3792
  *
3723
- * @param p - The deploy:complete event payload.
3724
3793
  * @example
3725
3794
  * ```ts
3726
- * handler({ url: "https://my-worker.workers.dev" }); // "deployed https://my-worker.workers.dev"
3795
+ * handler(); // clears the `deploy` spinner; the "Deployed" panel follows from the deploy plugin
3727
3796
  * ```
3728
3797
  */
3729
- "deploy:complete"(p) {
3798
+ "deploy:complete"() {
3730
3799
  stopSpinner();
3731
- ctx.log.info(`deployed → ${p.url}`);
3732
3800
  }
3733
3801
  };
3734
3802
  };
@@ -762,7 +762,8 @@ const createQueuesApi = (ctx) => {
762
762
  kind: "queue",
763
763
  name: instance.name,
764
764
  binding: instance.binding,
765
- ...instance.onMessage ? { consumer: true } : {}
765
+ ...instance.onMessage ? { consumer: true } : {},
766
+ ...instance.maxBatchTimeout === void 0 ? {} : { maxBatchTimeout: instance.maxBatchTimeout }
766
767
  }))
767
768
  };
768
769
  };
@@ -2208,6 +2209,57 @@ const renderProvisionResult = (ui, result) => {
2208
2209
  }
2209
2210
  }
2210
2211
  };
2212
+ /**
2213
+ * Format an elapsed duration compactly: sub-second as `820ms`, otherwise one-decimal seconds (`4.2s`),
2214
+ * and minutes once it crosses 60s (`1m04s`) so a long deploy stays readable.
2215
+ *
2216
+ * @param ms - The elapsed milliseconds.
2217
+ * @returns The compact duration string.
2218
+ * @example
2219
+ * ```ts
2220
+ * formatDuration(4234); // "4.2s"
2221
+ * ```
2222
+ */
2223
+ const formatDuration = (ms) => {
2224
+ if (ms < 1e3) return `${String(ms)}ms`;
2225
+ const seconds = ms / 1e3;
2226
+ if (seconds < 60) return `${seconds.toFixed(1)}s`;
2227
+ const whole = Math.floor(seconds);
2228
+ return `${String(Math.floor(whole / 60))}m${String(whole % 60).padStart(2, "0")}s`;
2229
+ };
2230
+ /**
2231
+ * Render the terminal deploy summary as a branded panel — the headline the user actually wants. The
2232
+ * live URL leads on its own line (pink, so it is the first thing the eye lands on), then a dim
2233
+ * key/value block: the target stage, the resource tally (with a red `failed` count when non-zero),
2234
+ * and the wall-clock time the whole deploy took. Replaces the prior single `deployed → url` line.
2235
+ *
2236
+ * @param ui - The branded console to render through.
2237
+ * @param summary - The deploy summary fields.
2238
+ * @param summary.url - The live deployed URL (the panel headline).
2239
+ * @param summary.stage - The target stage the worker deployed to.
2240
+ * @param summary.created - How many resources were created this run.
2241
+ * @param summary.exists - How many resources already existed (skipped).
2242
+ * @param summary.failed - How many resources failed to provision.
2243
+ * @param summary.elapsedMs - The wall-clock deploy duration in milliseconds.
2244
+ * @example
2245
+ * ```ts
2246
+ * renderDeploySummary(ui, { url, stage: "production", created: 0, exists: 5, failed: 0, elapsedMs: 4234 });
2247
+ * ```
2248
+ */
2249
+ const renderDeploySummary = (ui, summary) => {
2250
+ const { palette } = ui;
2251
+ const tally = `${String(summary.exists)} exist · ${String(summary.created)} created`;
2252
+ const failedLabel = palette.red(`${String(summary.failed)} failed`);
2253
+ const resources = summary.failed > 0 ? `${tally} · ${failedLabel}` : tally;
2254
+ ui.heading("Deployed");
2255
+ ui.box([
2256
+ palette.pink(summary.url),
2257
+ "",
2258
+ `${palette.dim("stage".padEnd(10))}${summary.stage}`,
2259
+ `${palette.dim("resources".padEnd(10))}${resources}`,
2260
+ `${palette.dim("took".padEnd(10))}${formatDuration(summary.elapsedMs)}`
2261
+ ]);
2262
+ };
2211
2263
  //#endregion
2212
2264
  //#region src/plugins/deploy/naming.ts
2213
2265
  /**
@@ -2583,13 +2635,14 @@ const buildD1Databases = (resources, ids) => resources.filter((resource) => reso
2583
2635
  * Every queue is a `producer`; a queue flagged `consumer: true` (it declares an `onMessage` handler)
2584
2636
  * is ALSO registered as a `consumer` so wrangler delivers its messages to this Worker's queue()
2585
2637
  * handler — both locally under `wrangler dev` and in production. Without the consumer entry the
2586
- * handler never runs (the bug that silently drops a queue-driven activity feed).
2638
+ * handler never runs (the bug that silently drops a queue-driven activity feed). A consumer that
2639
+ * sets `maxBatchTimeout` carries it through as wrangler's `max_batch_timeout` (lower delivery latency).
2587
2640
  *
2588
2641
  * @param resources - All resource descriptors from the manifest.
2589
2642
  * @returns The queues section (producers, plus consumers when any), or undefined when there are none.
2590
2643
  * @example
2591
2644
  * ```ts
2592
- * const q = buildQueues([{ kind: "queue", name: "tracker-activity", binding: "ACTIVITY", consumer: true }]);
2645
+ * const q = buildQueues([{ kind: "queue", name: "tracker-activity", binding: "ACTIVITY", consumer: true, maxBatchTimeout: 1 }]);
2593
2646
  * ```
2594
2647
  */
2595
2648
  const buildQueues = (resources) => {
@@ -2599,7 +2652,11 @@ const buildQueues = (resources) => {
2599
2652
  queue: resource.name,
2600
2653
  binding: resource.binding
2601
2654
  }));
2602
- const consumers = queueResources.filter((resource) => resource.consumer === true).map((resource) => ({ queue: resource.name }));
2655
+ const consumers = queueResources.filter((resource) => resource.consumer === true).map((resource) => {
2656
+ const entry = { queue: resource.name };
2657
+ if (resource.maxBatchTimeout !== void 0) entry.max_batch_timeout = resource.maxBatchTimeout;
2658
+ return entry;
2659
+ });
2603
2660
  return consumers.length > 0 ? {
2604
2661
  producers,
2605
2662
  consumers
@@ -3088,29 +3145,31 @@ const guidedUpload = async (ctx, manifest, deps) => {
3088
3145
  };
3089
3146
  /**
3090
3147
  * The final deploy step: confirm the target (guided only), run `wrangler deploy` with interactive
3091
- * retry, then emit deploy:complete. Resolves false when the target gate or a deploy retry is declined.
3148
+ * retry, then emit deploy:complete. Returns the deployed URL, or undefined when the target gate or a
3149
+ * deploy retry is declined (so the caller renders the summary panel only on a real success).
3092
3150
  *
3093
3151
  * @param ctx - The deploy plugin context.
3094
3152
  * @param manifest - The assembled (or caller-supplied) deploy manifest.
3095
3153
  * @param stage - The resolved deploy stage (for the confirm prompt).
3096
3154
  * @param deps - Interactivity + the confirm prompt.
3097
- * @returns True once deployed; false when the user declined the gate or a retry (abort).
3155
+ * @returns The deployed URL once live; undefined when the user declined the gate or a retry (abort).
3098
3156
  * @example
3099
3157
  * ```ts
3100
- * if (!(await guidedDeployStep(ctx, manifest, stage, deps))) return emitAborted(ctx);
3158
+ * const url = await guidedDeployStep(ctx, manifest, stage, deps);
3159
+ * if (url === undefined) return emitAborted(ctx);
3101
3160
  * ```
3102
3161
  */
3103
3162
  const guidedDeployStep = async (ctx, manifest, stage, deps) => {
3104
- if (!await deps.confirm(`Deploy "${manifest.name}" to ${stage}?`)) return false;
3163
+ if (!await deps.confirm(`Deploy "${manifest.name}" to ${stage}?`)) return void 0;
3105
3164
  ctx.emit("deploy:phase", { phase: "deploy" });
3106
3165
  const url = await guidedStep(() => runWrangler([
3107
3166
  "deploy",
3108
3167
  "--config",
3109
3168
  ctx.config.configFile
3110
3169
  ]), HINTS.deploy, deps);
3111
- if (url === ABORTED) return false;
3170
+ if (url === ABORTED) return void 0;
3112
3171
  ctx.emit("deploy:complete", { url });
3113
- return true;
3172
+ return url;
3114
3173
  };
3115
3174
  /**
3116
3175
  * Create the deploy api. Assembles the manifest from each resource plugin's own deployManifest(),
@@ -3158,6 +3217,7 @@ const createDeployApi = (ctx) => ({
3158
3217
  interactive,
3159
3218
  confirm: interactive ? (0, _moku_labs_common_cli.createBrandPrompts)().confirm : async (_question) => true
3160
3219
  };
3220
+ const startedAt = Date.now();
3161
3221
  ctx.emit("deploy:phase", { phase: "auth" });
3162
3222
  if (!await guidedAuth(ctx, deps)) return emitAborted(ctx);
3163
3223
  if (!await guidedWebBuild(ctx, opts?.webBuild ?? ctx.config.webBuild, deps)) return emitAborted(ctx);
@@ -3169,7 +3229,16 @@ const createDeployApi = (ctx) => ({
3169
3229
  ctx.emit("deploy:phase", { phase: "wrangler-config" });
3170
3230
  await writeWranglerConfig(ctx.config.configFile, manifest, provisioned.ids, wranglerExtra(ctx.config));
3171
3231
  if (!await guidedUpload(ctx, manifest, deps)) return emitAborted(ctx);
3172
- if (!await guidedDeployStep(ctx, manifest, stage, deps)) return emitAborted(ctx);
3232
+ const url = await guidedDeployStep(ctx, manifest, stage, deps);
3233
+ if (url === void 0) return emitAborted(ctx);
3234
+ renderDeploySummary((0, _moku_labs_common_cli.createBrandConsole)(), {
3235
+ url,
3236
+ stage,
3237
+ created: provisioned.created.length,
3238
+ exists: provisioned.skipped.length,
3239
+ failed: provisioned.failed.length,
3240
+ elapsedMs: Date.now() - startedAt
3241
+ });
3173
3242
  },
3174
3243
  /**
3175
3244
  * Start a long-lived local dev session: cold-build the Moku site, spawn `wrangler dev
@@ -3654,7 +3723,7 @@ const SPINNER_CLEAR = `\r${" ".repeat(72)}\r`;
3654
3723
  * const hooks = createCliHooks(ctx);
3655
3724
  * hooks["deploy:phase"]({ phase: "detect" }); // logs "detect" → renders " › detect"
3656
3725
  * hooks["dev:phase"]({ phase: "serve", detail: "http://localhost:8787" }); // "serve · …"
3657
- * hooks["deploy:complete"]({ url: "https://x.workers.dev" }); // "deployed https://x.workers.dev"
3726
+ * hooks["deploy:complete"](); // settles the deploy spinner; the "Deployed" panel renders separately
3658
3727
  * ```
3659
3728
  */
3660
3729
  const createCliHooks = (ctx) => {
@@ -3741,17 +3810,16 @@ const createCliHooks = (ctx) => {
3741
3810
  ctx.log.warn(p.message);
3742
3811
  },
3743
3812
  /**
3744
- * Log the terminal success line with the deployed URL.
3813
+ * Settle the final deploy spinner. The deployed URL + summary now render as a branded panel (the
3814
+ * deploy plugin's renderDeploySummary), so the cli no longer logs a duplicate `deployed → url`.
3745
3815
  *
3746
- * @param p - The deploy:complete event payload.
3747
3816
  * @example
3748
3817
  * ```ts
3749
- * handler({ url: "https://my-worker.workers.dev" }); // "deployed https://my-worker.workers.dev"
3818
+ * handler(); // clears the `deploy` spinner; the "Deployed" panel follows from the deploy plugin
3750
3819
  * ```
3751
3820
  */
3752
- "deploy:complete"(p) {
3821
+ "deploy:complete"() {
3753
3822
  stopSpinner();
3754
- ctx.log.info(`deployed → ${p.url}`);
3755
3823
  }
3756
3824
  };
3757
3825
  };
package/dist/cli.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-BPnG_JGR.cjs");
2
+ const require_cli = require("./cli-DkoPBbJC.cjs");
3
3
  exports.cliPlugin = require_cli.cliPlugin;
4
4
  exports.deployPlugin = require_cli.deployPlugin;
package/dist/cli.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-DCweBI9s.cjs";
1
+ import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-BuY9o1u0.cjs";
2
2
  export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
package/dist/cli.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-DCweBI9s.mjs";
1
+ import { i as ResourceManifest, n as cliPlugin, r as ExternalManifest, t as deployPlugin } from "./index-BuY9o1u0.mjs";
2
2
  export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as deployPlugin, t as cliPlugin } from "./cli-D8UmSqh4.mjs";
1
+ import { n as deployPlugin, t as cliPlugin } from "./cli-By06KF-9.mjs";
2
2
  export { cliPlugin, deployPlugin };
@@ -179,6 +179,7 @@ type ResourceManifest = {
179
179
  name: string;
180
180
  binding: string;
181
181
  consumer?: boolean;
182
+ maxBatchTimeout?: number;
182
183
  } | {
183
184
  kind: "do";
184
185
  binding: string;
@@ -179,6 +179,7 @@ type ResourceManifest = {
179
179
  name: string;
180
180
  binding: string;
181
181
  consumer?: boolean;
182
+ maxBatchTimeout?: number;
182
183
  } | {
183
184
  kind: "do";
184
185
  binding: string;
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-BPnG_JGR.cjs");
2
+ const require_cli = require("./cli-DkoPBbJC.cjs");
3
3
  let _moku_labs_common = require("@moku-labs/common");
4
4
  //#region src/env-provider.ts
5
5
  /**
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-DCweBI9s.cjs";
1
+ import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-BuY9o1u0.cjs";
2
2
  import { envPlugin, logPlugin } from "@moku-labs/common";
3
3
  import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
4
4
 
@@ -774,7 +774,14 @@ declare namespace types_d_exports$3 {
774
774
  type QueueInstance = {
775
775
  /** Base Cloudflare queue name (stage-suffixed at deploy, e.g. `tracker-activity-dev`). */name: string; /** Producer env binding the Queue resolves off the per-request `env` (e.g. `env.ACTIVITY`). */
776
776
  binding: string; /** Per-instance consumer handler — awaited once per message in `consume()`. Optional → no-op. */
777
- onMessage?: (message: Message, env: WorkerEnv) => Promise<void>; /** Marks this instance the default when more than one is configured. */
777
+ onMessage?: (message: Message, env: WorkerEnv) => Promise<void>;
778
+ /**
779
+ * Max seconds the consumer waits to fill a batch before delivering it (Cloudflare's
780
+ * `max_batch_timeout`, 0–60). Lower means lower delivery latency and smaller batches; omit to use
781
+ * Cloudflare's default (~5s). Written to the generated wrangler `consumers` entry, so it only has
782
+ * an effect on an instance that also declares an `onMessage` handler.
783
+ */
784
+ maxBatchTimeout?: number; /** Marks this instance the default when more than one is configured. */
778
785
  default?: boolean;
779
786
  };
780
787
  /**
@@ -861,6 +868,7 @@ type Api = QueueProducerApi & {
861
868
  name: string;
862
869
  binding: string;
863
870
  consumer?: boolean;
871
+ maxBatchTimeout?: number;
864
872
  }>;
865
873
  };
866
874
  /**
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-DCweBI9s.mjs";
1
+ import { a as WorkerConfig, c as WorkerPluginCtx, i as ResourceManifest, n as cliPlugin, o as WorkerEnv, r as ExternalManifest, s as WorkerEvents, t as deployPlugin } from "./index-BuY9o1u0.mjs";
2
2
  import { envPlugin, logPlugin } from "@moku-labs/common";
3
3
  import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
4
4
 
@@ -774,7 +774,14 @@ declare namespace types_d_exports$3 {
774
774
  type QueueInstance = {
775
775
  /** Base Cloudflare queue name (stage-suffixed at deploy, e.g. `tracker-activity-dev`). */name: string; /** Producer env binding the Queue resolves off the per-request `env` (e.g. `env.ACTIVITY`). */
776
776
  binding: string; /** Per-instance consumer handler — awaited once per message in `consume()`. Optional → no-op. */
777
- onMessage?: (message: Message, env: WorkerEnv) => Promise<void>; /** Marks this instance the default when more than one is configured. */
777
+ onMessage?: (message: Message, env: WorkerEnv) => Promise<void>;
778
+ /**
779
+ * Max seconds the consumer waits to fill a batch before delivering it (Cloudflare's
780
+ * `max_batch_timeout`, 0–60). Lower means lower delivery latency and smaller batches; omit to use
781
+ * Cloudflare's default (~5s). Written to the generated wrangler `consumers` entry, so it only has
782
+ * an effect on an instance that also declares an `onMessage` handler.
783
+ */
784
+ maxBatchTimeout?: number; /** Marks this instance the default when more than one is configured. */
778
785
  default?: boolean;
779
786
  };
780
787
  /**
@@ -861,6 +868,7 @@ type Api = QueueProducerApi & {
861
868
  name: string;
862
869
  binding: string;
863
870
  consumer?: boolean;
871
+ maxBatchTimeout?: number;
864
872
  }>;
865
873
  };
866
874
  /**
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-D8UmSqh4.mjs";
1
+ import { a as kvPlugin, c as d1Plugin, d as createCore, f as createPlugin$1, i as queuesPlugin, l as bindingsPlugin, n as deployPlugin, o as durableObjectsPlugin, p as stagePlugin, r as storagePlugin, s as defineDurableObject, t as cliPlugin, u as coreConfig } from "./cli-By06KF-9.mjs";
2
2
  import { envPlugin, logPlugin } from "@moku-labs/common";
3
3
  //#region src/env-provider.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/worker",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Cloudflare Worker framework for Moku — Durable Objects, Queues, R2, D1, and KV plugins that compose with Moku Web.",
5
5
  "repository": {
6
6
  "type": "git",