@moku-labs/worker 0.8.1 → 0.9.1

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/cli.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-l-AOWzhR.cjs");
2
+ const require_cli = require("./cli-imQGo0tc.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-BDkgen4r.cjs";
1
+ import { a as ResourceManifest, i as ExternalManifest, n as cliPlugin, t as deployPlugin } from "./index-CWxQr2Q3.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-BDkgen4r.mjs";
1
+ import { a as ResourceManifest, i as ExternalManifest, n as cliPlugin, t as deployPlugin } from "./index-CWxQr2Q3.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-DNW8_355.mjs";
1
+ import { n as deployPlugin, t as cliPlugin } from "./cli--EPl98vG.mjs";
2
2
  export { cliPlugin, deployPlugin };
@@ -36,6 +36,7 @@ type WorkerEvents = {
36
36
  "provision:plan": {
37
37
  exists: number;
38
38
  missing: number;
39
+ ships: number;
39
40
  account: string;
40
41
  };
41
42
  "provision:skip": {
@@ -119,6 +120,25 @@ type WebBuild = () => Promise<unknown>;
119
120
  * ```
120
121
  */
121
122
  type OnChange = (changes: readonly string[]) => Promise<unknown>;
123
+ /**
124
+ * The remote seed wired into `deploy({ seed: true })`: which SQL file to load into the REMOTE D1
125
+ * AFTER a successful deploy (+ migration), and which cached KV keys to clear afterwards so the app
126
+ * rebuilds them from the freshly-seeded rows. Declarative — the deploy plugin runs no app code, so
127
+ * the app-specific seed lives in `pluginConfigs.deploy.seed` (config) rather than a deploy hook.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * deploy: { seed: { file: "db/seed.sql", resetKv: [{ binding: "BOARDS_KV", key: "boards:index" }] } }
132
+ * ```
133
+ */
134
+ type SeedConfig = {
135
+ /** SQL file executed against the remote D1 (e.g. "db/seed.sql"). */file: string; /** The d1 binding to target when more than one database is configured (e.g. "DB"); the sole one otherwise. */
136
+ binding?: string; /** Cached KV keys to delete after seeding so reads rebuild from the freshly-seeded DB. */
137
+ resetKv?: {
138
+ binding: string;
139
+ key: string;
140
+ }[];
141
+ };
122
142
  /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
123
143
  type Config$1 = {
124
144
  /**
@@ -169,6 +189,12 @@ type Config$1 = {
169
189
  buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
170
190
  migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
171
191
  debounceMs: number;
192
+ /**
193
+ * The remote seed `deploy({ seed: true })` loads AFTER a successful deploy (+ migration): the SQL
194
+ * file and the cached KV keys to reset. Omit it and `deploy({ seed: true })` reports a clear
195
+ * "no seed configured" error instead of silently doing nothing.
196
+ */
197
+ seed?: SeedConfig;
172
198
  };
173
199
  /**
174
200
  * Discriminated union of per-INSTANCE resource descriptors. Each resource plugin's `deployManifest()`
@@ -221,13 +247,18 @@ type ProvisionedRef = {
221
247
  };
222
248
  /**
223
249
  * Read-only infra preflight result: which declared resources already exist in the Cloudflare
224
- * account versus which are still missing and must be created. Produced by `checkInfra()`.
250
+ * account, which are still missing and must be created, and which ship with the Worker. Produced by
251
+ * `checkInfra()`. Durable Objects are neither "exists" nor "missing" — the planner never queries the
252
+ * account for them and never API-provisions them; they are created by `wrangler deploy` (the
253
+ * auto-derived DO migration), so they get their own `ships` bucket instead of masquerading as
254
+ * already-existing.
225
255
  */
226
256
  type InfraPlan = {
227
257
  /** Resolved account display name (or id when the name is unknown). */account: string; /** Resolved Cloudflare account id used for the existence checks. */
228
- accountId: string; /** Declared resources that already exist (with their captured ids where applicable). */
258
+ accountId: string; /** Declared resources the account listing confirmed already exist (with captured ids where applicable). */
229
259
  exists: ProvisionedRef[]; /** Declared resources that do not yet exist and must be created. */
230
- missing: ResourceManifest[];
260
+ missing: ResourceManifest[]; /** Durable Objects that ship with the Worker — created by `wrangler deploy`, never API-provisioned. */
261
+ ships: ResourceManifest[];
231
262
  };
232
263
  /**
233
264
  * A resource that failed to provision, with the (branded) error message captured so the guided flow
@@ -239,16 +270,45 @@ type ProvisionFailure = {
239
270
  };
240
271
  /**
241
272
  * Outcome of acting on an {@link InfraPlan}: the resources just created, those skipped because they
242
- * already existed, those that FAILED to create, and the merged id map (binding Cloudflare id) for
243
- * the config writer. Provisioning is resilient a single resource failure is captured here, not
244
- * thrown, so the guided flow can report a clear per-resource result.
273
+ * already existed, those that ship with the Worker (Durable Objects not created here), those that
274
+ * FAILED to create, and the merged id map (binding Cloudflare id) for the config writer.
275
+ * Provisioning is resilient a single resource failure is captured here, not thrown, so the guided
276
+ * flow can report a clear per-resource result.
245
277
  */
246
278
  type ProvisionResult = {
247
279
  /** Resources created during this run. */created: ProvisionedRef[]; /** Resources skipped because they already existed. */
248
- skipped: ProvisionedRef[]; /** Resources that failed to create (captured, not thrown). */
280
+ skipped: ProvisionedRef[]; /** Durable Objects that ship with the Worker not created at the provision step (`wrangler deploy` does). */
281
+ bundled: ResourceManifest[]; /** Resources that failed to create (captured, not thrown). */
249
282
  failed: ProvisionFailure[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
250
283
  ids: Record<string, string>;
251
284
  };
285
+ /**
286
+ * Structured outcome of a deploy run (the value `run()` / `cli.deploy()` now resolve to, replacing
287
+ * the old `void`) so a script can branch on the result instead of guessing from a thrown error. It
288
+ * is also WHY the post-deploy migration + seed live inside `run()`: the report's `status` is the
289
+ * single source of truth for whether the worker actually went live, so those remote-DB steps run
290
+ * only on a successful deploy and never on an aborted one.
291
+ *
292
+ * `ok` is true only when the worker is live AND every requested post-step (migration, seed) also
293
+ * succeeded. `status` is the coarse outcome: `"deployed"` (live, all post-steps ok), `"aborted"`
294
+ * (a gate was declined or auth was never set up — nothing shipped), `"failed"` (a step errored).
295
+ */
296
+ type DeployReport = {
297
+ /** True only when the worker is live and every requested post-step (migration, seed) succeeded. */ok: boolean; /** Coarse outcome: "deployed" (live + post-steps ok), "aborted" (a gate declined / auth not set up), "failed" (a step errored). */
298
+ status: "deployed" | "aborted" | "failed"; /** The resolved deploy stage (resource-name suffix; "production" is bare). */
299
+ stage: string; /** The live worker URL once `wrangler deploy` succeeded — set even if a later migration/seed failed. */
300
+ url?: string; /** Provisioning tally: resources created, already-existing, shipped-with-the-Worker (DOs), and failed to create. */
301
+ resources?: {
302
+ created: number;
303
+ exists: number;
304
+ bundled: number;
305
+ failed: number;
306
+ }; /** Remote D1 migration outcome — "skipped" (not requested), "applied", or "failed". */
307
+ migration: "skipped" | "applied" | "failed"; /** Remote seed outcome — "skipped" (not requested), "applied", or "failed". */
308
+ seed: "skipped" | "applied" | "failed"; /** Wall-clock duration of the whole run (ms). */
309
+ elapsedMs: number; /** Branded failure message(s) — empty when `ok`; one per failed step otherwise. */
310
+ errors: string[];
311
+ };
252
312
  /** Result of verifying the `.env` Cloudflare API token and resolving its account. */
253
313
  type AuthStatus = {
254
314
  /** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
@@ -294,10 +354,12 @@ type Api = {
294
354
  * per-change rebuild when `onChange` is omitted.
295
355
  * @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
296
356
  * so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
357
+ * @param opts.seed - Load the configured seed (`pluginConfigs.deploy.seed`) into the LOCAL D1 and
358
+ * reset its cached KV keys before serving — the local analogue of `deploy({ seed: true })`.
297
359
  * @returns Resolves when the dev session ends.
298
360
  * @example
299
361
  * ```ts
300
- * await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
362
+ * await app.cli.dev({ stage: "dev", port: 7878, seed: true, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
301
363
  * ```
302
364
  */
303
365
  dev(opts?: {
@@ -305,30 +367,38 @@ type Api = {
305
367
  stage?: string;
306
368
  webBuild?: WebBuild;
307
369
  onChange?: OnChange;
370
+ seed?: boolean;
308
371
  }): Promise<void>;
309
372
  /**
310
- * One-command Cloudflare deploy (delegates to deploy.run). Guided/interactive by default; pass
311
- * `{ ci: true }` for the automated/non-interactive path (CI). A failure renders a branded `✗`
312
- * line and sets a non-zero exit code rather than throwing a raw stack trace.
373
+ * One-command Cloudflare deploy (delegates to deploy.run), then only on a successful deploy —
374
+ * the requested post-deploy remote steps (migration, seed). Guided/interactive by default; pass
375
+ * `{ ci: true }` for the automated/non-interactive path (CI). Unlike the other verbs this RETURNS
376
+ * the structured {@link DeployReport} (so a script can branch on the outcome) AND, on a failure,
377
+ * renders a branded `✗` line + sets a non-zero exit code rather than throwing a raw stack trace.
313
378
  *
314
- * @param opts - Optional ci flag, stage, and a web build hook.
379
+ * @param opts - Optional ci flag, stage, a web build hook, and the post-deploy migration/seed flags.
315
380
  * @param opts.ci - Automated mode: never prompts, auto-confirms. Omit/false → guided on a TTY.
316
381
  * @param opts.stage - Stage for the generated wrangler config's resource names (e.g. "production",
317
382
  * "staging"). Falls back to the `--stage` CLI flag, then the app's configured stage. Pass it
318
383
  * explicitly from a script for a self-documenting `deploy({ stage })` instead of the hidden flag.
319
384
  * @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
320
- * @returns Resolves once the deploy completes (or after a failure is rendered).
385
+ * @param opts.migration - Apply pending remote D1 migrations after a successful deploy (skipped on abort).
386
+ * @param opts.seed - Load the configured remote seed (`pluginConfigs.deploy.seed`) after a
387
+ * successful deploy (+ migration); skipped on an aborted deploy.
388
+ * @returns The deploy report (status, url, resource tally, migration/seed outcome, errors).
321
389
  * @example
322
390
  * ```ts
323
- * await app.cli.deploy({ stage: "production", webBuild: () => web.cli.build() }); // guided
324
- * await app.cli.deploy({ ci: true, webBuild: () => web.cli.build() }); // CI
391
+ * const report = await app.cli.deploy({ webBuild: () => web.cli.build(), migration: true, seed: true });
392
+ * if (report.status === "aborted") return; // creds not set up yet — nothing shipped
325
393
  * ```
326
394
  */
327
395
  deploy(opts?: {
328
396
  ci?: boolean;
329
397
  stage?: string;
330
398
  webBuild?: WebBuild;
331
- }): Promise<void>;
399
+ migration?: boolean;
400
+ seed?: boolean;
401
+ }): Promise<DeployReport>;
332
402
  /**
333
403
  * Seed a configured D1 database from a SQL file (delegates to deploy.seed). Local by default
334
404
  * (applies the database's migrations first so its tables exist, then executes the file);
@@ -431,12 +501,15 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
431
501
  stage?: string;
432
502
  webBuild?: WebBuild;
433
503
  manifest?: ExternalManifest;
434
- }): Promise<void>;
504
+ migration?: boolean;
505
+ seed?: boolean;
506
+ }): Promise<DeployReport>;
435
507
  dev(opts?: {
436
508
  port?: number;
437
509
  stage?: string;
438
510
  webBuild?: WebBuild;
439
511
  onChange?: OnChange;
512
+ seed?: boolean;
440
513
  }): Promise<void>;
441
514
  seed(sqlFile: string, opts?: {
442
515
  stage?: string;
@@ -455,4 +528,4 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
455
528
  wrangler: (args: string[]) => Promise<void>;
456
529
  }, {}> & Record<never, never>;
457
530
  //#endregion
458
- export { WorkerConfig as a, WorkerPluginCtx as c, ResourceManifest as i, cliPlugin as n, WorkerEnv as o, ExternalManifest as r, WorkerEvents as s, deployPlugin as t };
531
+ export { ResourceManifest as a, WorkerEnv as c, ExternalManifest as i, WorkerEvents as l, cliPlugin as n, SeedConfig as o, DeployReport as r, WorkerConfig as s, deployPlugin as t, WorkerPluginCtx as u };
@@ -36,6 +36,7 @@ type WorkerEvents = {
36
36
  "provision:plan": {
37
37
  exists: number;
38
38
  missing: number;
39
+ ships: number;
39
40
  account: string;
40
41
  };
41
42
  "provision:skip": {
@@ -119,6 +120,25 @@ type WebBuild = () => Promise<unknown>;
119
120
  * ```
120
121
  */
121
122
  type OnChange = (changes: readonly string[]) => Promise<unknown>;
123
+ /**
124
+ * The remote seed wired into `deploy({ seed: true })`: which SQL file to load into the REMOTE D1
125
+ * AFTER a successful deploy (+ migration), and which cached KV keys to clear afterwards so the app
126
+ * rebuilds them from the freshly-seeded rows. Declarative — the deploy plugin runs no app code, so
127
+ * the app-specific seed lives in `pluginConfigs.deploy.seed` (config) rather than a deploy hook.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * deploy: { seed: { file: "db/seed.sql", resetKv: [{ binding: "BOARDS_KV", key: "boards:index" }] } }
132
+ * ```
133
+ */
134
+ type SeedConfig = {
135
+ /** SQL file executed against the remote D1 (e.g. "db/seed.sql"). */file: string; /** The d1 binding to target when more than one database is configured (e.g. "DB"); the sole one otherwise. */
136
+ binding?: string; /** Cached KV keys to delete after seeding so reads rebuild from the freshly-seeded DB. */
137
+ resetKv?: {
138
+ binding: string;
139
+ key: string;
140
+ }[];
141
+ };
122
142
  /** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
123
143
  type Config$1 = {
124
144
  /**
@@ -169,6 +189,12 @@ type Config$1 = {
169
189
  buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
170
190
  migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
171
191
  debounceMs: number;
192
+ /**
193
+ * The remote seed `deploy({ seed: true })` loads AFTER a successful deploy (+ migration): the SQL
194
+ * file and the cached KV keys to reset. Omit it and `deploy({ seed: true })` reports a clear
195
+ * "no seed configured" error instead of silently doing nothing.
196
+ */
197
+ seed?: SeedConfig;
172
198
  };
173
199
  /**
174
200
  * Discriminated union of per-INSTANCE resource descriptors. Each resource plugin's `deployManifest()`
@@ -221,13 +247,18 @@ type ProvisionedRef = {
221
247
  };
222
248
  /**
223
249
  * Read-only infra preflight result: which declared resources already exist in the Cloudflare
224
- * account versus which are still missing and must be created. Produced by `checkInfra()`.
250
+ * account, which are still missing and must be created, and which ship with the Worker. Produced by
251
+ * `checkInfra()`. Durable Objects are neither "exists" nor "missing" — the planner never queries the
252
+ * account for them and never API-provisions them; they are created by `wrangler deploy` (the
253
+ * auto-derived DO migration), so they get their own `ships` bucket instead of masquerading as
254
+ * already-existing.
225
255
  */
226
256
  type InfraPlan = {
227
257
  /** Resolved account display name (or id when the name is unknown). */account: string; /** Resolved Cloudflare account id used for the existence checks. */
228
- accountId: string; /** Declared resources that already exist (with their captured ids where applicable). */
258
+ accountId: string; /** Declared resources the account listing confirmed already exist (with captured ids where applicable). */
229
259
  exists: ProvisionedRef[]; /** Declared resources that do not yet exist and must be created. */
230
- missing: ResourceManifest[];
260
+ missing: ResourceManifest[]; /** Durable Objects that ship with the Worker — created by `wrangler deploy`, never API-provisioned. */
261
+ ships: ResourceManifest[];
231
262
  };
232
263
  /**
233
264
  * A resource that failed to provision, with the (branded) error message captured so the guided flow
@@ -239,16 +270,45 @@ type ProvisionFailure = {
239
270
  };
240
271
  /**
241
272
  * Outcome of acting on an {@link InfraPlan}: the resources just created, those skipped because they
242
- * already existed, those that FAILED to create, and the merged id map (binding Cloudflare id) for
243
- * the config writer. Provisioning is resilient a single resource failure is captured here, not
244
- * thrown, so the guided flow can report a clear per-resource result.
273
+ * already existed, those that ship with the Worker (Durable Objects not created here), those that
274
+ * FAILED to create, and the merged id map (binding Cloudflare id) for the config writer.
275
+ * Provisioning is resilient a single resource failure is captured here, not thrown, so the guided
276
+ * flow can report a clear per-resource result.
245
277
  */
246
278
  type ProvisionResult = {
247
279
  /** Resources created during this run. */created: ProvisionedRef[]; /** Resources skipped because they already existed. */
248
- skipped: ProvisionedRef[]; /** Resources that failed to create (captured, not thrown). */
280
+ skipped: ProvisionedRef[]; /** Durable Objects that ship with the Worker not created at the provision step (`wrangler deploy` does). */
281
+ bundled: ResourceManifest[]; /** Resources that failed to create (captured, not thrown). */
249
282
  failed: ProvisionFailure[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
250
283
  ids: Record<string, string>;
251
284
  };
285
+ /**
286
+ * Structured outcome of a deploy run (the value `run()` / `cli.deploy()` now resolve to, replacing
287
+ * the old `void`) so a script can branch on the result instead of guessing from a thrown error. It
288
+ * is also WHY the post-deploy migration + seed live inside `run()`: the report's `status` is the
289
+ * single source of truth for whether the worker actually went live, so those remote-DB steps run
290
+ * only on a successful deploy and never on an aborted one.
291
+ *
292
+ * `ok` is true only when the worker is live AND every requested post-step (migration, seed) also
293
+ * succeeded. `status` is the coarse outcome: `"deployed"` (live, all post-steps ok), `"aborted"`
294
+ * (a gate was declined or auth was never set up — nothing shipped), `"failed"` (a step errored).
295
+ */
296
+ type DeployReport = {
297
+ /** True only when the worker is live and every requested post-step (migration, seed) succeeded. */ok: boolean; /** Coarse outcome: "deployed" (live + post-steps ok), "aborted" (a gate declined / auth not set up), "failed" (a step errored). */
298
+ status: "deployed" | "aborted" | "failed"; /** The resolved deploy stage (resource-name suffix; "production" is bare). */
299
+ stage: string; /** The live worker URL once `wrangler deploy` succeeded — set even if a later migration/seed failed. */
300
+ url?: string; /** Provisioning tally: resources created, already-existing, shipped-with-the-Worker (DOs), and failed to create. */
301
+ resources?: {
302
+ created: number;
303
+ exists: number;
304
+ bundled: number;
305
+ failed: number;
306
+ }; /** Remote D1 migration outcome — "skipped" (not requested), "applied", or "failed". */
307
+ migration: "skipped" | "applied" | "failed"; /** Remote seed outcome — "skipped" (not requested), "applied", or "failed". */
308
+ seed: "skipped" | "applied" | "failed"; /** Wall-clock duration of the whole run (ms). */
309
+ elapsedMs: number; /** Branded failure message(s) — empty when `ok`; one per failed step otherwise. */
310
+ errors: string[];
311
+ };
252
312
  /** Result of verifying the `.env` Cloudflare API token and resolving its account. */
253
313
  type AuthStatus = {
254
314
  /** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
@@ -294,10 +354,12 @@ type Api = {
294
354
  * per-change rebuild when `onChange` is omitted.
295
355
  * @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
296
356
  * so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
357
+ * @param opts.seed - Load the configured seed (`pluginConfigs.deploy.seed`) into the LOCAL D1 and
358
+ * reset its cached KV keys before serving — the local analogue of `deploy({ seed: true })`.
297
359
  * @returns Resolves when the dev session ends.
298
360
  * @example
299
361
  * ```ts
300
- * await app.cli.dev({ stage: "dev", port: 7878, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
362
+ * await app.cli.dev({ stage: "dev", port: 7878, seed: true, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
301
363
  * ```
302
364
  */
303
365
  dev(opts?: {
@@ -305,30 +367,38 @@ type Api = {
305
367
  stage?: string;
306
368
  webBuild?: WebBuild;
307
369
  onChange?: OnChange;
370
+ seed?: boolean;
308
371
  }): Promise<void>;
309
372
  /**
310
- * One-command Cloudflare deploy (delegates to deploy.run). Guided/interactive by default; pass
311
- * `{ ci: true }` for the automated/non-interactive path (CI). A failure renders a branded `✗`
312
- * line and sets a non-zero exit code rather than throwing a raw stack trace.
373
+ * One-command Cloudflare deploy (delegates to deploy.run), then only on a successful deploy —
374
+ * the requested post-deploy remote steps (migration, seed). Guided/interactive by default; pass
375
+ * `{ ci: true }` for the automated/non-interactive path (CI). Unlike the other verbs this RETURNS
376
+ * the structured {@link DeployReport} (so a script can branch on the outcome) AND, on a failure,
377
+ * renders a branded `✗` line + sets a non-zero exit code rather than throwing a raw stack trace.
313
378
  *
314
- * @param opts - Optional ci flag, stage, and a web build hook.
379
+ * @param opts - Optional ci flag, stage, a web build hook, and the post-deploy migration/seed flags.
315
380
  * @param opts.ci - Automated mode: never prompts, auto-confirms. Omit/false → guided on a TTY.
316
381
  * @param opts.stage - Stage for the generated wrangler config's resource names (e.g. "production",
317
382
  * "staging"). Falls back to the `--stage` CLI flag, then the app's configured stage. Pass it
318
383
  * explicitly from a script for a self-documenting `deploy({ stage })` instead of the hidden flag.
319
384
  * @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
320
- * @returns Resolves once the deploy completes (or after a failure is rendered).
385
+ * @param opts.migration - Apply pending remote D1 migrations after a successful deploy (skipped on abort).
386
+ * @param opts.seed - Load the configured remote seed (`pluginConfigs.deploy.seed`) after a
387
+ * successful deploy (+ migration); skipped on an aborted deploy.
388
+ * @returns The deploy report (status, url, resource tally, migration/seed outcome, errors).
321
389
  * @example
322
390
  * ```ts
323
- * await app.cli.deploy({ stage: "production", webBuild: () => web.cli.build() }); // guided
324
- * await app.cli.deploy({ ci: true, webBuild: () => web.cli.build() }); // CI
391
+ * const report = await app.cli.deploy({ webBuild: () => web.cli.build(), migration: true, seed: true });
392
+ * if (report.status === "aborted") return; // creds not set up yet — nothing shipped
325
393
  * ```
326
394
  */
327
395
  deploy(opts?: {
328
396
  ci?: boolean;
329
397
  stage?: string;
330
398
  webBuild?: WebBuild;
331
- }): Promise<void>;
399
+ migration?: boolean;
400
+ seed?: boolean;
401
+ }): Promise<DeployReport>;
332
402
  /**
333
403
  * Seed a configured D1 database from a SQL file (delegates to deploy.seed). Local by default
334
404
  * (applies the database's migrations first so its tables exist, then executes the file);
@@ -431,12 +501,15 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
431
501
  stage?: string;
432
502
  webBuild?: WebBuild;
433
503
  manifest?: ExternalManifest;
434
- }): Promise<void>;
504
+ migration?: boolean;
505
+ seed?: boolean;
506
+ }): Promise<DeployReport>;
435
507
  dev(opts?: {
436
508
  port?: number;
437
509
  stage?: string;
438
510
  webBuild?: WebBuild;
439
511
  onChange?: OnChange;
512
+ seed?: boolean;
440
513
  }): Promise<void>;
441
514
  seed(sqlFile: string, opts?: {
442
515
  stage?: string;
@@ -455,4 +528,4 @@ declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", C
455
528
  wrangler: (args: string[]) => Promise<void>;
456
529
  }, {}> & Record<never, never>;
457
530
  //#endregion
458
- export { WorkerConfig as a, WorkerPluginCtx as c, ResourceManifest as i, cliPlugin as n, WorkerEnv as o, ExternalManifest as r, WorkerEvents as s, deployPlugin as t };
531
+ export { ResourceManifest as a, WorkerEnv as c, ExternalManifest as i, WorkerEvents as l, cliPlugin as n, SeedConfig as o, DeployReport as r, WorkerConfig as s, deployPlugin as t, WorkerPluginCtx as u };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-l-AOWzhR.cjs");
2
+ const require_cli = require("./cli-imQGo0tc.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-BDkgen4r.cjs";
1
+ import { a as ResourceManifest, c as WorkerEnv, i as ExternalManifest, l as WorkerEvents, n as cliPlugin, o as SeedConfig, r as DeployReport, s as WorkerConfig, t as deployPlugin, u as WorkerPluginCtx } from "./index-CWxQr2Q3.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
 
@@ -1237,4 +1237,4 @@ declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku
1237
1237
  */
1238
1238
  declare const createApp: typeof boundCreateApp;
1239
1239
  //#endregion
1240
- export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
1240
+ export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type DeployReport, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type SeedConfig, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
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-BDkgen4r.mjs";
1
+ import { a as ResourceManifest, c as WorkerEnv, i as ExternalManifest, l as WorkerEvents, n as cliPlugin, o as SeedConfig, r as DeployReport, s as WorkerConfig, t as deployPlugin, u as WorkerPluginCtx } from "./index-CWxQr2Q3.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
 
@@ -1237,4 +1237,4 @@ declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku
1237
1237
  */
1238
1238
  declare const createApp: typeof boundCreateApp;
1239
1239
  //#endregion
1240
- export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
1240
+ export { type types_d_exports as Bindings, type types_d_exports$1 as D1, type DeployReport, type types_d_exports$2 as DurableObjects, type ExternalManifest, type PluginCtx, type types_d_exports$3 as Queues, type ResourceManifest, type SeedConfig, type types_d_exports$4 as Server, type StageApi, type types_d_exports$5 as Storage, type WorkerConfig, type WorkerEnv, type WorkerEvents, type WorkerPluginCtx, bindingsPlugin, cliPlugin, createApp, createPlugin, d1Plugin, defineDurableObject, deployPlugin, durableObjectsPlugin, endpoint, envPlugin, kvPlugin, logPlugin, queuesPlugin, serverPlugin, stagePlugin, storagePlugin };
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-DNW8_355.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--EPl98vG.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.8.1",
3
+ "version": "0.9.1",
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",