@porulle/jobs-trigger 0.64.0 → 0.65.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/index.js +11 -17
- package/package.json +12 -8
- package/src/index.ts +11 -21
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { task as createTriggerTask, tasks as triggerTasks, } from "@trigger.dev/sdk";
|
|
2
|
+
import { prepareEnqueue } from "@porulle/core/jobs";
|
|
2
3
|
export class TriggerExecutionEngine {
|
|
3
4
|
execution = { mode: "push" };
|
|
4
5
|
tasks = [];
|
|
@@ -17,32 +18,25 @@ export class TriggerExecutionEngine {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
async enqueue(taskSlug, input, options) {
|
|
20
|
-
const
|
|
21
|
-
if (!definition)
|
|
22
|
-
throw new Error(`Unknown task slug: ${taskSlug}`);
|
|
23
|
-
const organizationId = options.organizationId.trim();
|
|
24
|
-
if (!organizationId)
|
|
25
|
-
throw new Error("Jobs enqueue requires a non-empty organizationId.");
|
|
26
|
-
const concurrencyKey = options.concurrencyKey ?? definition.concurrency?.key(input);
|
|
27
|
-
const exclusive = Boolean(definition.concurrency && definition.concurrency.exclusive !== false);
|
|
28
|
-
const supersedes = options.supersedes ?? definition.concurrency?.supersedes;
|
|
29
|
-
const maxAttempts = options.maxAttempts ?? definition.retries?.attempts ?? 1;
|
|
21
|
+
const prepared = prepareEnqueue(this.requireSetup().tasks, taskSlug, input, options);
|
|
30
22
|
const payload = {
|
|
31
23
|
input,
|
|
32
|
-
organizationId,
|
|
33
|
-
maxAttempts,
|
|
34
|
-
...(concurrencyKey ? { concurrencyKey } : {}),
|
|
24
|
+
organizationId: prepared.organizationId,
|
|
25
|
+
maxAttempts: prepared.maxAttempts,
|
|
26
|
+
...(prepared.concurrencyKey ? { concurrencyKey: prepared.concurrencyKey } : {}),
|
|
35
27
|
};
|
|
36
28
|
const handle = await triggerTasks.trigger(taskSlug, payload, {
|
|
37
|
-
maxAttempts,
|
|
38
|
-
...(exclusive && concurrencyKey
|
|
29
|
+
maxAttempts: prepared.maxAttempts,
|
|
30
|
+
...(prepared.exclusive && prepared.concurrencyKey
|
|
31
|
+
? { concurrencyKey: prepared.concurrencyKey }
|
|
32
|
+
: {}),
|
|
39
33
|
...(options.delayMs !== undefined
|
|
40
34
|
? { delay: new Date(Date.now() + options.delayMs) }
|
|
41
35
|
: {}),
|
|
42
|
-
...(supersedes && concurrencyKey
|
|
36
|
+
...(prepared.supersedes && prepared.concurrencyKey
|
|
43
37
|
? {
|
|
44
38
|
debounce: {
|
|
45
|
-
key: concurrencyKey,
|
|
39
|
+
key: prepared.concurrencyKey,
|
|
46
40
|
delay: this.supersedesDebounce,
|
|
47
41
|
mode: "trailing",
|
|
48
42
|
},
|
package/package.json
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@porulle/jobs-trigger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
}
|
|
8
|
+
"@porulle/source": "./src/index.ts",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20.19.0"
|
|
12
16
|
},
|
|
13
17
|
"dependencies": {
|
|
14
18
|
"@trigger.dev/sdk": "^4.5.4",
|
|
15
|
-
"@porulle/core": "0.
|
|
19
|
+
"@porulle/core": "0.65.1"
|
|
16
20
|
},
|
|
17
21
|
"devDependencies": {
|
|
18
22
|
"@types/node": "^24.5.2",
|
|
19
23
|
"eslint": "^9.39.1",
|
|
20
24
|
"typescript": "5.9.2",
|
|
21
25
|
"vitest": "^3.2.4",
|
|
22
|
-
"@porulle/
|
|
23
|
-
"@porulle/
|
|
26
|
+
"@porulle/typescript-config": "0.1.0",
|
|
27
|
+
"@porulle/eslint-config": "0.1.0"
|
|
24
28
|
},
|
|
25
29
|
"publishConfig": {
|
|
26
30
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
task as createTriggerTask,
|
|
3
3
|
tasks as triggerTasks,
|
|
4
4
|
} from "@trigger.dev/sdk";
|
|
5
|
+
import { prepareEnqueue } from "@porulle/core/jobs";
|
|
5
6
|
import type { AnyTask } from "@trigger.dev/sdk";
|
|
6
7
|
import type {
|
|
7
8
|
EnqueueOptions,
|
|
@@ -50,36 +51,25 @@ export class TriggerExecutionEngine implements ExecutionEngine {
|
|
|
50
51
|
input: Record<string, unknown>,
|
|
51
52
|
options: EnqueueOptions,
|
|
52
53
|
): Promise<string> {
|
|
53
|
-
const
|
|
54
|
-
if (!definition) throw new Error(`Unknown task slug: ${taskSlug}`);
|
|
55
|
-
const organizationId = options.organizationId.trim();
|
|
56
|
-
if (!organizationId)
|
|
57
|
-
throw new Error("Jobs enqueue requires a non-empty organizationId.");
|
|
58
|
-
|
|
59
|
-
const concurrencyKey =
|
|
60
|
-
options.concurrencyKey ?? definition.concurrency?.key(input);
|
|
61
|
-
const exclusive = Boolean(
|
|
62
|
-
definition.concurrency && definition.concurrency.exclusive !== false,
|
|
63
|
-
);
|
|
64
|
-
const supersedes = options.supersedes ?? definition.concurrency?.supersedes;
|
|
65
|
-
const maxAttempts =
|
|
66
|
-
options.maxAttempts ?? definition.retries?.attempts ?? 1;
|
|
54
|
+
const prepared = prepareEnqueue(this.requireSetup().tasks, taskSlug, input, options);
|
|
67
55
|
const payload: TriggerJobPayload = {
|
|
68
56
|
input,
|
|
69
|
-
organizationId,
|
|
70
|
-
maxAttempts,
|
|
71
|
-
...(concurrencyKey ? { concurrencyKey } : {}),
|
|
57
|
+
organizationId: prepared.organizationId,
|
|
58
|
+
maxAttempts: prepared.maxAttempts,
|
|
59
|
+
...(prepared.concurrencyKey ? { concurrencyKey: prepared.concurrencyKey } : {}),
|
|
72
60
|
};
|
|
73
61
|
const handle = await triggerTasks.trigger(taskSlug, payload, {
|
|
74
|
-
maxAttempts,
|
|
75
|
-
...(exclusive && concurrencyKey
|
|
62
|
+
maxAttempts: prepared.maxAttempts,
|
|
63
|
+
...(prepared.exclusive && prepared.concurrencyKey
|
|
64
|
+
? { concurrencyKey: prepared.concurrencyKey }
|
|
65
|
+
: {}),
|
|
76
66
|
...(options.delayMs !== undefined
|
|
77
67
|
? { delay: new Date(Date.now() + options.delayMs) }
|
|
78
68
|
: {}),
|
|
79
|
-
...(supersedes && concurrencyKey
|
|
69
|
+
...(prepared.supersedes && prepared.concurrencyKey
|
|
80
70
|
? {
|
|
81
71
|
debounce: {
|
|
82
|
-
key: concurrencyKey,
|
|
72
|
+
key: prepared.concurrencyKey,
|
|
83
73
|
delay: this.supersedesDebounce,
|
|
84
74
|
mode: "trailing" as const,
|
|
85
75
|
},
|