@porulle/jobs-cloudflare 0.64.0 → 0.65.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { TaskNonRetryableError, createPassThroughTaskStep, } from "@porulle/core/jobs";
1
+ import { TaskNonRetryableError, createPassThroughTaskStep, prepareEnqueue, } from "@porulle/core/jobs";
2
2
  /** Deterministic JSON with sorted object keys — key order must not change the hash. */
3
3
  function stableStringify(value) {
4
4
  if (value === null || typeof value !== "object")
@@ -114,15 +114,8 @@ export class CloudflareExecutionEngine {
114
114
  * it **starts**; the enqueue payload is identity, not data. A pending instance created before a
115
115
  * later write will still observe that write when it runs. */
116
116
  async enqueue(taskSlug, input, options) {
117
- const task = this.requireSetup().tasks.get(taskSlug);
118
- if (!task)
119
- throw new Error(`Unknown task slug: ${taskSlug}`);
120
- const organizationId = options.organizationId.trim();
121
- if (!organizationId)
122
- throw new Error("Jobs enqueue requires a non-empty organizationId.");
123
- const concurrencyKey = options.concurrencyKey ?? task.concurrency?.key(input);
124
- const exclusive = Boolean(task.concurrency && task.concurrency.exclusive !== false);
125
- const supersedes = Boolean(options.supersedes ?? task.concurrency?.supersedes);
117
+ const prepared = prepareEnqueue(this.requireSetup().tasks, taskSlug, input, options);
118
+ const { organizationId, concurrencyKey, exclusive, supersedes, maxAttempts } = prepared;
126
119
  if ((exclusive || supersedes) &&
127
120
  concurrencyKey &&
128
121
  !this.options.coordinator) {
@@ -134,7 +127,7 @@ export class CloudflareExecutionEngine {
134
127
  taskSlug,
135
128
  input,
136
129
  organizationId,
137
- maxAttempts: options.maxAttempts ?? task.retries?.attempts ?? 1,
130
+ maxAttempts,
138
131
  exclusive,
139
132
  supersedes,
140
133
  ...(options.delayMs !== undefined ? { delayMs: options.delayMs } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/jobs-cloudflare",
3
- "version": "0.64.0",
3
+ "version": "0.65.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,7 +11,7 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@porulle/core": "0.64.0"
14
+ "@porulle/core": "0.65.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^24.5.2",
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  TaskNonRetryableError,
3
3
  createPassThroughTaskStep,
4
+ prepareEnqueue,
4
5
  } from "@porulle/core/jobs";
5
6
  import type {
6
7
  EnqueueOptions,
@@ -253,20 +254,8 @@ export class CloudflareExecutionEngine implements ExecutionEngine {
253
254
  input: Record<string, unknown>,
254
255
  options: EnqueueOptions,
255
256
  ): Promise<string> {
256
- const task = this.requireSetup().tasks.get(taskSlug);
257
- if (!task) throw new Error(`Unknown task slug: ${taskSlug}`);
258
- const organizationId = options.organizationId.trim();
259
- if (!organizationId)
260
- throw new Error("Jobs enqueue requires a non-empty organizationId.");
261
-
262
- const concurrencyKey =
263
- options.concurrencyKey ?? task.concurrency?.key(input);
264
- const exclusive = Boolean(
265
- task.concurrency && task.concurrency.exclusive !== false,
266
- );
267
- const supersedes = Boolean(
268
- options.supersedes ?? task.concurrency?.supersedes,
269
- );
257
+ const prepared = prepareEnqueue(this.requireSetup().tasks, taskSlug, input, options);
258
+ const { organizationId, concurrencyKey, exclusive, supersedes, maxAttempts } = prepared;
270
259
  if (
271
260
  (exclusive || supersedes) &&
272
261
  concurrencyKey &&
@@ -283,7 +272,7 @@ export class CloudflareExecutionEngine implements ExecutionEngine {
283
272
  taskSlug,
284
273
  input,
285
274
  organizationId,
286
- maxAttempts: options.maxAttempts ?? task.retries?.attempts ?? 1,
275
+ maxAttempts,
287
276
  exclusive,
288
277
  supersedes,
289
278
  ...(options.delayMs !== undefined ? { delayMs: options.delayMs } : {}),