nuxt-cf-jobs 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -73,13 +73,13 @@ jobsIgnore: ['**/_*.ts', '**/*.d.ts', '**/*.test.ts', '**/*.spec.ts']
73
73
  The generated registry is available as `#cf-jobs/app` by default.
74
74
 
75
75
  ```ts
76
+ import type { JobName, JobPayload } from '#cf-jobs/app'
76
77
  import {
77
78
  buildJobPayload,
78
79
  getJobDefinition,
79
80
  getQueue,
80
- prepareJob,
81
- type JobName,
82
- type JobPayload,
81
+
82
+ prepareJob
83
83
  } from '#cf-jobs/app'
84
84
 
85
85
  const name: JobName = 'sync/table'
@@ -201,8 +201,7 @@ export default defineEventHandler(async (event) => {
201
201
  await repository.migrate()
202
202
 
203
203
  const publisher = createQueuePublisher(env, queue =>
204
- queue === 'default' ? 'QUEUE_DEFAULT' : undefined,
205
- )
204
+ queue === 'default' ? 'QUEUE_DEFAULT' : undefined,)
206
205
 
207
206
  const record = await prepareJob({
208
207
  name: 'sync/table',
@@ -220,8 +219,8 @@ export default defineEventHandler(async (event) => {
220
219
  Consume durable queue messages with `runDurableJobMessage()` and the D1 repository:
221
220
 
222
221
  ```ts
223
- import { runDurableJobMessage } from 'nuxt-cf-jobs/durable'
224
222
  import { createD1DurableJobRepository } from 'nuxt-cf-jobs/d1'
223
+ import { runDurableJobMessage } from 'nuxt-cf-jobs/durable'
225
224
  import { jobRegistry } from '#cf-jobs/app'
226
225
 
227
226
  export default defineNitroPlugin((nitroApp) => {
@@ -276,6 +275,34 @@ export default defineNitroPlugin((nitroApp) => {
276
275
  - `releaseStaleReservedJobs()`
277
276
  - `toDispatchableJob()`
278
277
 
278
+ ## CLI
279
+
280
+ The package ships a `cf-jobs` binary, an `artisan queue:*`-style tool for inspecting and managing the durable D1 job tables. It queries D1 through `wrangler d1 execute`, so it works against both the local miniflare database (default) and production (`--remote`), auto-detecting the D1 binding from your wrangler config.
281
+
282
+ ```bash
283
+ # backpressure overview: per-queue ready/reserved/delayed, ready-lag, failures, stuck reservations
284
+ pnpm cf-jobs # alias for `cf-jobs status`
285
+ pnpm cf-jobs status --remote
286
+
287
+ # inspect jobs
288
+ pnpm cf-jobs jobs --queue billing --state ready --limit 20
289
+ pnpm cf-jobs failed # artisan queue:failed
290
+ pnpm cf-jobs schedule # artisan schedule:list (cron + next run)
291
+ pnpm cf-jobs tasks # every discovered task
292
+
293
+ # manage (prompt for confirmation; pass --yes to skip, required when non-interactive)
294
+ pnpm cf-jobs retry <id> # artisan queue:retry — re-queue a failed job
295
+ pnpm cf-jobs retry --queue billing # re-queue a whole queue's failures
296
+ pnpm cf-jobs forget <id> # artisan queue:forget
297
+ pnpm cf-jobs flush # artisan queue:flush — delete all failed jobs
298
+ pnpm cf-jobs clear --state reserved # artisan queue:clear — drop active jobs (e.g. stuck reservations)
299
+ pnpm cf-jobs migrate # create the job tables/indexes in D1
300
+ ```
301
+
302
+ Every command accepts `--config <wrangler path>`, `--db <binding>`, `--remote`, `--json`, and `--jobs-table` / `--failed-table` overrides. `status` flags queues whose oldest ready job is lagging and reservations stuck for more than five minutes (a crashed or timed-out consumer). Run `cf-jobs <command> --help` for the full argument list.
303
+
304
+ `cf-jobs` shells out to `wrangler`; it resolves the binary from `node_modules/.bin`, falling back to `wrangler` on `PATH` (override with `CF_JOBS_WRANGLER_BIN`).
305
+
279
306
  ## Runtime Validation
280
307
 
281
308
  The generated registry validates jobs at startup. It fails loudly for:
@@ -298,9 +325,9 @@ assertQueueBindings()
298
325
  Use the narrow subpaths when you can:
299
326
 
300
327
  ```ts
301
- import { defineJob } from 'nuxt-cf-jobs/server'
302
- import { runDurableJobMessage } from 'nuxt-cf-jobs/durable'
303
328
  import { createD1DurableJobRepository } from 'nuxt-cf-jobs/d1'
329
+ import { runDurableJobMessage } from 'nuxt-cf-jobs/durable'
330
+ import { defineJob } from 'nuxt-cf-jobs/server'
304
331
  import { createFakeQueue } from 'nuxt-cf-jobs/testing'
305
332
  ```
306
333
 
@@ -0,0 +1 @@
1
+