@trigger.dev/sdk 3.2.0 → 3.2.2
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/commonjs/apiClient.d.ts +53 -63
- package/dist/commonjs/io.d.ts +7 -19
- package/dist/commonjs/status.d.ts +1 -1
- package/dist/commonjs/triggerClient.d.ts +11 -21
- package/dist/commonjs/triggers/scheduled.d.ts +2 -2
- package/dist/commonjs/types.d.ts +2 -2
- package/dist/commonjs/v3/auth.d.ts +1 -1
- package/dist/commonjs/v3/auth.js +3 -0
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/idempotencyKeys.d.ts +1 -40
- package/dist/commonjs/v3/idempotencyKeys.js +1 -69
- package/dist/commonjs/v3/idempotencyKeys.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +3 -1
- package/dist/commonjs/v3/index.js +2 -0
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/metadata.d.ts +55 -0
- package/dist/commonjs/v3/metadata.js +65 -0
- package/dist/commonjs/v3/metadata.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +11 -11
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +3 -2
- package/dist/commonjs/v3/shared.js +26 -14
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/tasks.d.ts +2 -1
- package/dist/commonjs/v3/tasks.js +2 -1
- package/dist/commonjs/v3/tasks.js.map +1 -1
- package/dist/commonjs/v3/waitUntil.d.ts +9 -0
- package/dist/commonjs/v3/waitUntil.js +16 -0
- package/dist/commonjs/v3/waitUntil.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/apiClient.d.ts +53 -63
- package/dist/esm/io.d.ts +7 -19
- package/dist/esm/status.d.ts +1 -1
- package/dist/esm/triggerClient.d.ts +9 -21
- package/dist/esm/triggers/invokeTrigger.d.ts +1 -1
- package/dist/esm/triggers/scheduled.d.ts +2 -2
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/v3/auth.d.ts +1 -1
- package/dist/esm/v3/auth.js +3 -0
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/idempotencyKeys.d.ts +1 -40
- package/dist/esm/v3/idempotencyKeys.js +1 -68
- package/dist/esm/v3/idempotencyKeys.js.map +1 -1
- package/dist/esm/v3/index.d.ts +3 -1
- package/dist/esm/v3/index.js +2 -0
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/metadata.d.ts +55 -0
- package/dist/esm/v3/metadata.js +65 -0
- package/dist/esm/v3/metadata.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +14 -14
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +3 -2
- package/dist/esm/v3/shared.js +26 -15
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/tasks.d.ts +2 -1
- package/dist/esm/v3/tasks.js +2 -1
- package/dist/esm/v3/tasks.js.map +1 -1
- package/dist/esm/v3/waitUntil.d.ts +9 -0
- package/dist/esm/v3/waitUntil.js +13 -0
- package/dist/esm/v3/waitUntil.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/package.json +9 -5
package/dist/esm/v3/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/v3/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CAAC,OAA+B;IACvD,gBAAgB,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,SAAS;IACT,iBAAiB;IACjB,QAAQ;CACT,CA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AED,OAAO,oBAAoB,CAAC;AAC9B,CAAC"}
|
|
@@ -1,44 +1,5 @@
|
|
|
1
|
-
import { type IdempotencyKey } from "@trigger.dev/core/v3";
|
|
1
|
+
import { createIdempotencyKey, type IdempotencyKey } from "@trigger.dev/core/v3";
|
|
2
2
|
export declare const idempotencyKeys: {
|
|
3
3
|
create: typeof createIdempotencyKey;
|
|
4
4
|
};
|
|
5
5
|
export type { IdempotencyKey };
|
|
6
|
-
export declare function isIdempotencyKey(value: string | string[] | IdempotencyKey): value is IdempotencyKey;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a deterministic idempotency key based on the provided key material.
|
|
9
|
-
*
|
|
10
|
-
* If running inside a task, the task run ID is automatically included in the key material, giving you a unique key per task run.
|
|
11
|
-
* This ensures that a given child task is only triggered once per task run, even if the parent task is retried.
|
|
12
|
-
*
|
|
13
|
-
* @param {string | string[]} key The key material to create the idempotency key from.
|
|
14
|
-
* @param {object} [options] Additional options.
|
|
15
|
-
* @param {"run" | "attempt" | "global"} [options.scope="run"] The scope of the idempotency key.
|
|
16
|
-
*
|
|
17
|
-
* @returns {Promise<IdempotencyKey>} The idempotency key as a branded string.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { idempotencyKeys, task } from "@trigger.dev/sdk/v3";
|
|
23
|
-
*
|
|
24
|
-
* export const myTask = task({
|
|
25
|
-
* id: "my-task",
|
|
26
|
-
* run: async (payload: any) => {
|
|
27
|
-
* const idempotencyKey = await idempotencyKeys.create("my-task-key");
|
|
28
|
-
*
|
|
29
|
-
* // Use the idempotency key when triggering child tasks
|
|
30
|
-
* await childTask.triggerAndWait(payload, { idempotencyKey });
|
|
31
|
-
* }
|
|
32
|
-
* });
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* You can also use the `scope` parameter to create a key that is unique per task run, task run attempts (retries of the same run), or globally:
|
|
36
|
-
*
|
|
37
|
-
* ```typescript
|
|
38
|
-
* await idempotencyKeys.create("my-task-key", { scope: "attempt" }); // Creates a key that is unique per task run attempt
|
|
39
|
-
* await idempotencyKeys.create("my-task-key", { scope: "global" }); // Skips including the task run ID
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare function createIdempotencyKey(key: string | string[], options?: {
|
|
43
|
-
scope?: "run" | "attempt" | "global";
|
|
44
|
-
}): Promise<IdempotencyKey>;
|
|
@@ -1,72 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createIdempotencyKey } from "@trigger.dev/core/v3";
|
|
2
2
|
export const idempotencyKeys = {
|
|
3
3
|
create: createIdempotencyKey,
|
|
4
4
|
};
|
|
5
|
-
export function isIdempotencyKey(value) {
|
|
6
|
-
// Cannot check the brand at runtime because it doesn't exist (it's a TypeScript-only construct)
|
|
7
|
-
return typeof value === "string" && value.length === 64;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Creates a deterministic idempotency key based on the provided key material.
|
|
11
|
-
*
|
|
12
|
-
* If running inside a task, the task run ID is automatically included in the key material, giving you a unique key per task run.
|
|
13
|
-
* This ensures that a given child task is only triggered once per task run, even if the parent task is retried.
|
|
14
|
-
*
|
|
15
|
-
* @param {string | string[]} key The key material to create the idempotency key from.
|
|
16
|
-
* @param {object} [options] Additional options.
|
|
17
|
-
* @param {"run" | "attempt" | "global"} [options.scope="run"] The scope of the idempotency key.
|
|
18
|
-
*
|
|
19
|
-
* @returns {Promise<IdempotencyKey>} The idempotency key as a branded string.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* ```typescript
|
|
24
|
-
* import { idempotencyKeys, task } from "@trigger.dev/sdk/v3";
|
|
25
|
-
*
|
|
26
|
-
* export const myTask = task({
|
|
27
|
-
* id: "my-task",
|
|
28
|
-
* run: async (payload: any) => {
|
|
29
|
-
* const idempotencyKey = await idempotencyKeys.create("my-task-key");
|
|
30
|
-
*
|
|
31
|
-
* // Use the idempotency key when triggering child tasks
|
|
32
|
-
* await childTask.triggerAndWait(payload, { idempotencyKey });
|
|
33
|
-
* }
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* You can also use the `scope` parameter to create a key that is unique per task run, task run attempts (retries of the same run), or globally:
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
40
|
-
* await idempotencyKeys.create("my-task-key", { scope: "attempt" }); // Creates a key that is unique per task run attempt
|
|
41
|
-
* await idempotencyKeys.create("my-task-key", { scope: "global" }); // Skips including the task run ID
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
async function createIdempotencyKey(key, options) {
|
|
45
|
-
const idempotencyKey = await generateIdempotencyKey([...(Array.isArray(key) ? key : [key])].concat(injectScope(options?.scope ?? "run")));
|
|
46
|
-
return idempotencyKey;
|
|
47
|
-
}
|
|
48
|
-
function injectScope(scope) {
|
|
49
|
-
switch (scope) {
|
|
50
|
-
case "run": {
|
|
51
|
-
if (taskContext?.ctx) {
|
|
52
|
-
return [taskContext.ctx.run.id];
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
case "attempt": {
|
|
57
|
-
if (taskContext?.ctx) {
|
|
58
|
-
return [taskContext.ctx.attempt.id];
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
async function generateIdempotencyKey(keyMaterial) {
|
|
66
|
-
const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(keyMaterial.join("-")));
|
|
67
|
-
// Return a hex string, using cross-runtime compatible methods
|
|
68
|
-
return Array.from(new Uint8Array(hash))
|
|
69
|
-
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
70
|
-
.join("");
|
|
71
|
-
}
|
|
72
5
|
//# sourceMappingURL=idempotencyKeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idempotencyKeys.js","sourceRoot":"","sources":["../../../src/v3/idempotencyKeys.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"idempotencyKeys.js","sourceRoot":"","sources":["../../../src/v3/idempotencyKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;AAEjF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,oBAAoB;CAC7B,CAAC"}
|
package/dist/esm/v3/index.d.ts
CHANGED
|
@@ -4,17 +4,19 @@ export { retry, type RetryOptions } from "./retry.js";
|
|
|
4
4
|
export { queue } from "./shared.js";
|
|
5
5
|
export * from "./tasks.js";
|
|
6
6
|
export * from "./wait.js";
|
|
7
|
+
export * from "./waitUntil.js";
|
|
7
8
|
export * from "./usage.js";
|
|
8
9
|
export * from "./idempotencyKeys.js";
|
|
9
10
|
export * from "./tags.js";
|
|
10
11
|
export * from "./metadata.js";
|
|
11
12
|
export * from "./timeout.js";
|
|
13
|
+
export * from "./waitUntil.js";
|
|
12
14
|
export type { Context };
|
|
13
15
|
import type { Context } from "./shared.js";
|
|
14
16
|
import type { ApiClientConfiguration } from "@trigger.dev/core/v3";
|
|
15
17
|
export type { ApiClientConfiguration };
|
|
16
18
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, logger, type LogLevel, } from "@trigger.dev/core/v3";
|
|
17
|
-
export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RetrieveRunResult, type AnyRetrieveRunResult, } from "./runs.js";
|
|
19
|
+
export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RealtimeRun, type RetrieveRunResult, type AnyRetrieveRunResult, } from "./runs.js";
|
|
18
20
|
export * as schedules from "./schedules/index.js";
|
|
19
21
|
export * as envvars from "./envvars.js";
|
|
20
22
|
export type { ImportEnvironmentVariablesParams } from "./envvars.js";
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -4,11 +4,13 @@ export { retry } from "./retry.js";
|
|
|
4
4
|
export { queue } from "./shared.js";
|
|
5
5
|
export * from "./tasks.js";
|
|
6
6
|
export * from "./wait.js";
|
|
7
|
+
export * from "./waitUntil.js";
|
|
7
8
|
export * from "./usage.js";
|
|
8
9
|
export * from "./idempotencyKeys.js";
|
|
9
10
|
export * from "./tags.js";
|
|
10
11
|
export * from "./metadata.js";
|
|
11
12
|
export * from "./timeout.js";
|
|
13
|
+
export * from "./waitUntil.js";
|
|
12
14
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, logger, } from "@trigger.dev/core/v3";
|
|
13
15
|
export { runs, } from "./runs.js";
|
|
14
16
|
export * as schedules from "./schedules/index.js";
|
package/dist/esm/v3/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAS/B,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,GAEP,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,IAAI,GAOL,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -17,6 +17,11 @@ export declare const metadata: {
|
|
|
17
17
|
save: typeof saveMetadata;
|
|
18
18
|
replace: typeof replaceMetadata;
|
|
19
19
|
flush: typeof flushMetadata;
|
|
20
|
+
stream: typeof stream;
|
|
21
|
+
append: typeof appendMetadataKey;
|
|
22
|
+
remove: typeof removeMetadataKey;
|
|
23
|
+
increment: typeof incrementMetadataKey;
|
|
24
|
+
decrement: typeof decrementMetadataKey;
|
|
20
25
|
};
|
|
21
26
|
export type RunMetadata = Record<string, DeserializedJson>;
|
|
22
27
|
/**
|
|
@@ -77,6 +82,55 @@ declare function replaceMetadata(metadata: RunMetadata): void;
|
|
|
77
82
|
* @deprecated Use `metadata.replace()` instead.
|
|
78
83
|
*/
|
|
79
84
|
declare function saveMetadata(metadata: RunMetadata): void;
|
|
85
|
+
/**
|
|
86
|
+
* Increments a numeric value in the metadata of the current run by the specified amount.
|
|
87
|
+
* This function allows you to atomically increment a numeric metadata value.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} key - The key of the numeric value to increment.
|
|
90
|
+
* @param {number} value - The amount to increment the value by.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* metadata.increment("counter", 1); // Increments counter by 1
|
|
94
|
+
* metadata.increment("score", 10); // Increments score by 10
|
|
95
|
+
*/
|
|
96
|
+
declare function incrementMetadataKey(key: string, value?: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
99
|
+
* This function allows you to atomically decrement a numeric metadata value.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} key - The key of the numeric value to decrement.
|
|
102
|
+
* @param {number} value - The amount to decrement the value by.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* metadata.decrement("counter", 1); // Decrements counter by 1
|
|
106
|
+
* metadata.decrement("score", 5); // Decrements score by 5
|
|
107
|
+
*/
|
|
108
|
+
declare function decrementMetadataKey(key: string, value?: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Appends a value to an array in the metadata of the current run.
|
|
111
|
+
* If the key doesn't exist, it creates a new array with the value.
|
|
112
|
+
* If the key exists but isn't an array, it converts the existing value to an array.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} key - The key of the array in metadata.
|
|
115
|
+
* @param {DeserializedJson} value - The value to append to the array.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* metadata.append("logs", "User logged in");
|
|
119
|
+
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
120
|
+
*/
|
|
121
|
+
declare function appendMetadataKey(key: string, value: DeserializedJson): void;
|
|
122
|
+
/**
|
|
123
|
+
* Removes a value from an array in the metadata of the current run.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} key - The key of the array in metadata.
|
|
126
|
+
* @param {DeserializedJson} value - The value to remove from the array.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
*
|
|
130
|
+
* metadata.remove("logs", "User logged in");
|
|
131
|
+
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
132
|
+
*/
|
|
133
|
+
declare function removeMetadataKey(key: string, value: DeserializedJson): void;
|
|
80
134
|
/**
|
|
81
135
|
* Flushes metadata to the Trigger.dev instance
|
|
82
136
|
*
|
|
@@ -84,4 +138,5 @@ declare function saveMetadata(metadata: RunMetadata): void;
|
|
|
84
138
|
* @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
|
|
85
139
|
*/
|
|
86
140
|
declare function flushMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
141
|
+
declare function stream<T>(key: string, value: AsyncIterable<T> | ReadableStream<T>, signal?: AbortSignal): Promise<AsyncIterable<T>>;
|
|
87
142
|
export {};
|
package/dist/esm/v3/metadata.js
CHANGED
|
@@ -17,6 +17,11 @@ export const metadata = {
|
|
|
17
17
|
save: saveMetadata,
|
|
18
18
|
replace: replaceMetadata,
|
|
19
19
|
flush: flushMetadata,
|
|
20
|
+
stream: stream,
|
|
21
|
+
append: appendMetadataKey,
|
|
22
|
+
remove: removeMetadataKey,
|
|
23
|
+
increment: incrementMetadataKey,
|
|
24
|
+
decrement: decrementMetadataKey,
|
|
20
25
|
};
|
|
21
26
|
/**
|
|
22
27
|
* Returns the metadata of the current run if inside a task run.
|
|
@@ -88,6 +93,63 @@ function replaceMetadata(metadata) {
|
|
|
88
93
|
function saveMetadata(metadata) {
|
|
89
94
|
runMetadata.update(metadata);
|
|
90
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Increments a numeric value in the metadata of the current run by the specified amount.
|
|
98
|
+
* This function allows you to atomically increment a numeric metadata value.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} key - The key of the numeric value to increment.
|
|
101
|
+
* @param {number} value - The amount to increment the value by.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* metadata.increment("counter", 1); // Increments counter by 1
|
|
105
|
+
* metadata.increment("score", 10); // Increments score by 10
|
|
106
|
+
*/
|
|
107
|
+
function incrementMetadataKey(key, value = 1) {
|
|
108
|
+
runMetadata.incrementKey(key, value);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
112
|
+
* This function allows you to atomically decrement a numeric metadata value.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} key - The key of the numeric value to decrement.
|
|
115
|
+
* @param {number} value - The amount to decrement the value by.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* metadata.decrement("counter", 1); // Decrements counter by 1
|
|
119
|
+
* metadata.decrement("score", 5); // Decrements score by 5
|
|
120
|
+
*/
|
|
121
|
+
function decrementMetadataKey(key, value = 1) {
|
|
122
|
+
runMetadata.decrementKey(key, value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Appends a value to an array in the metadata of the current run.
|
|
126
|
+
* If the key doesn't exist, it creates a new array with the value.
|
|
127
|
+
* If the key exists but isn't an array, it converts the existing value to an array.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} key - The key of the array in metadata.
|
|
130
|
+
* @param {DeserializedJson} value - The value to append to the array.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* metadata.append("logs", "User logged in");
|
|
134
|
+
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
135
|
+
*/
|
|
136
|
+
function appendMetadataKey(key, value) {
|
|
137
|
+
runMetadata.appendKey(key, value);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Removes a value from an array in the metadata of the current run.
|
|
141
|
+
*
|
|
142
|
+
* @param {string} key - The key of the array in metadata.
|
|
143
|
+
* @param {DeserializedJson} value - The value to remove from the array.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
*
|
|
147
|
+
* metadata.remove("logs", "User logged in");
|
|
148
|
+
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
149
|
+
*/
|
|
150
|
+
function removeMetadataKey(key, value) {
|
|
151
|
+
runMetadata.removeFromKey(key, value);
|
|
152
|
+
}
|
|
91
153
|
/**
|
|
92
154
|
* Flushes metadata to the Trigger.dev instance
|
|
93
155
|
*
|
|
@@ -102,4 +164,7 @@ async function flushMetadata(requestOptions) {
|
|
|
102
164
|
}, requestOptions);
|
|
103
165
|
await runMetadata.flush($requestOptions);
|
|
104
166
|
}
|
|
167
|
+
async function stream(key, value, signal) {
|
|
168
|
+
return runMetadata.stream(key, value, signal);
|
|
169
|
+
}
|
|
105
170
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACnB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,eAAe;IACxB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,eAAe;IACxB,KAAK,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACnB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,eAAe;IACxB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,eAAe;IACxB,KAAK,EAAE,aAAa;IACpB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,oBAAoB;IA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,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,aAAa,CAAC,cAAkC;IAC7D,MAAM,eAAe,GAAG,mBAAmB,CACzC;QACE,MAAM;QACN,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,WAAW;KAClB,EACD,cAAc,CACf,CAAC;IAEF,MAAM,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,MAAM,CACnB,GAAW,EACX,KAA2C,EAC3C,MAAoB;IAEpB,OAAO,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/esm/v3/runs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RunSubscription, TaskRunShape } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, RunSubscription, TaskRunShape } from "@trigger.dev/core/v3";
|
|
2
2
|
import { ApiPromise, CanceledRunResponse, CursorPagePromise, ListRunResponseItem, ReplayRunResponse, RetrieveRunResponse } from "@trigger.dev/core/v3";
|
|
3
3
|
import { AnyRunHandle, AnyTask } from "./shared.js";
|
|
4
|
-
export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape };
|
|
4
|
+
export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, };
|
|
5
5
|
export declare const runs: {
|
|
6
6
|
replay: typeof replayRun;
|
|
7
7
|
cancel: typeof cancelRun;
|
|
@@ -28,14 +28,14 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
28
28
|
}, requestOptions?: ApiRequestOptions): Promise<{
|
|
29
29
|
version?: string | undefined;
|
|
30
30
|
status: "COMPLETED" | "CANCELED" | "QUEUED" | "TIMED_OUT" | "EXECUTING" | "WAITING_FOR_DEPLOY" | "REATTEMPTING" | "FROZEN" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
|
|
31
|
+
id: string;
|
|
32
|
+
metadata?: Record<string, any> | undefined;
|
|
33
|
+
startedAt?: Date | undefined;
|
|
31
34
|
error?: {
|
|
32
35
|
message: string;
|
|
33
36
|
name?: string | undefined;
|
|
34
37
|
stackTrace?: string | undefined;
|
|
35
38
|
} | undefined;
|
|
36
|
-
id: string;
|
|
37
|
-
metadata?: Record<string, any> | undefined;
|
|
38
|
-
startedAt?: Date | undefined;
|
|
39
39
|
idempotencyKey?: string | undefined;
|
|
40
40
|
attempts: ({
|
|
41
41
|
status: "PENDING" | "COMPLETED" | "CANCELED" | "EXECUTING" | "FAILED" | "PAUSED";
|
|
@@ -90,15 +90,15 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
90
90
|
isSuccess: boolean;
|
|
91
91
|
isFailed: boolean;
|
|
92
92
|
isCancelled: boolean;
|
|
93
|
-
batchId?: string | undefined;
|
|
94
|
-
idempotencyKey?: string | undefined;
|
|
95
93
|
version?: string | undefined;
|
|
94
|
+
metadata?: Record<string, any> | undefined;
|
|
96
95
|
startedAt?: Date | undefined;
|
|
96
|
+
idempotencyKey?: string | undefined;
|
|
97
|
+
batchId?: string | undefined;
|
|
97
98
|
finishedAt?: Date | undefined;
|
|
98
99
|
delayedUntil?: Date | undefined;
|
|
99
100
|
ttl?: string | undefined;
|
|
100
101
|
expiredAt?: Date | undefined;
|
|
101
|
-
metadata?: Record<string, any> | undefined;
|
|
102
102
|
} | undefined;
|
|
103
103
|
parent?: {
|
|
104
104
|
status: "COMPLETED" | "CANCELED" | "QUEUED" | "TIMED_OUT" | "EXECUTING" | "WAITING_FOR_DEPLOY" | "REATTEMPTING" | "FROZEN" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
|
|
@@ -119,15 +119,15 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
119
119
|
isSuccess: boolean;
|
|
120
120
|
isFailed: boolean;
|
|
121
121
|
isCancelled: boolean;
|
|
122
|
-
batchId?: string | undefined;
|
|
123
|
-
idempotencyKey?: string | undefined;
|
|
124
122
|
version?: string | undefined;
|
|
123
|
+
metadata?: Record<string, any> | undefined;
|
|
125
124
|
startedAt?: Date | undefined;
|
|
125
|
+
idempotencyKey?: string | undefined;
|
|
126
|
+
batchId?: string | undefined;
|
|
126
127
|
finishedAt?: Date | undefined;
|
|
127
128
|
delayedUntil?: Date | undefined;
|
|
128
129
|
ttl?: string | undefined;
|
|
129
130
|
expiredAt?: Date | undefined;
|
|
130
|
-
metadata?: Record<string, any> | undefined;
|
|
131
131
|
} | undefined;
|
|
132
132
|
children?: {
|
|
133
133
|
status: "COMPLETED" | "CANCELED" | "QUEUED" | "TIMED_OUT" | "EXECUTING" | "WAITING_FOR_DEPLOY" | "REATTEMPTING" | "FROZEN" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
|
|
@@ -148,15 +148,15 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
148
148
|
isSuccess: boolean;
|
|
149
149
|
isFailed: boolean;
|
|
150
150
|
isCancelled: boolean;
|
|
151
|
-
batchId?: string | undefined;
|
|
152
|
-
idempotencyKey?: string | undefined;
|
|
153
151
|
version?: string | undefined;
|
|
152
|
+
metadata?: Record<string, any> | undefined;
|
|
154
153
|
startedAt?: Date | undefined;
|
|
154
|
+
idempotencyKey?: string | undefined;
|
|
155
|
+
batchId?: string | undefined;
|
|
155
156
|
finishedAt?: Date | undefined;
|
|
156
157
|
delayedUntil?: Date | undefined;
|
|
157
158
|
ttl?: string | undefined;
|
|
158
159
|
expiredAt?: Date | undefined;
|
|
159
|
-
metadata?: Record<string, any> | undefined;
|
|
160
160
|
}[] | undefined;
|
|
161
161
|
};
|
|
162
162
|
depth: number;
|
package/dist/esm/v3/runs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":"AAcA,OAAO,EAOL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":"AAcA,OAAO,EAOL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAWrC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,aAAa;IACzB,IAAI;IACJ,cAAc;IACd,sBAAsB;CACvB,CAAC;AAaF,SAAS,QAAQ,CACf,kBAAiD,EACjD,eAAsF,EACtF,cAAkC;IAElC,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,sBAAsB,CAC5C,kB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,CAAC;IAEjB,OAAO,QAAQ,EAAE,GAAG,iBAAiB,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAEvD,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,IAAI,KAAK,CACb,OACE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAC5C,2BAA2B,iBAAiB,WAAW,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,KAAoB;IAEpB,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;IAE5D,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,sBAAsB,CAC7B,GAAsB;IAEtB,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,sBAAsB,CAAwB,GAAG,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/esm/v3/shared.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SerializableJson } from "@trigger.dev/core";
|
|
2
2
|
import { ApiRequestOptions, InitOutput, Queue, QueueOptions, SubtaskUnwrapError, TaskRunContext, TaskRunPromise } from "@trigger.dev/core/v3";
|
|
3
3
|
import { PollOptions } from "./runs.js";
|
|
4
|
-
import type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, BatchRunHandleFromTypes, InferRunTypes,
|
|
4
|
+
import type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, BatchRunHandleFromTypes, InferRunTypes, RetrieveRunResult, RunHandle, RunHandleFromTypes, RunHandleOutput, RunHandlePayload, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunOptions, TaskRunResult, TaskSchema, TaskWithSchema, TaskWithSchemaOptions, TaskWithToolOptions, ToolTask, ToolTaskParameters, TriggerApiRequestOptions } from "@trigger.dev/core/v3";
|
|
5
5
|
export type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, Queue, RunHandle, RunHandleOutput, RunHandlePayload, SerializableJson, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunOptions, TaskRunResult, };
|
|
6
6
|
export { SubtaskUnwrapError, TaskRunPromise };
|
|
7
7
|
export type Context = TaskRunContext;
|
|
@@ -9,7 +9,8 @@ export declare function queue(options: {
|
|
|
9
9
|
name: string;
|
|
10
10
|
} & QueueOptions): Queue;
|
|
11
11
|
export declare function createTask<TIdentifier extends string, TInput = void, TOutput = unknown, TInitOutput extends InitOutput = any>(params: TaskOptions<TIdentifier, TInput, TOutput, TInitOutput>): Task<TIdentifier, TInput, TOutput>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function createToolTask<TIdentifier extends string, TParameters extends ToolTaskParameters, TOutput = unknown, TInitOutput extends InitOutput = any>(params: TaskWithToolOptions<TIdentifier, TParameters, TOutput, TInitOutput>): ToolTask<TIdentifier, TParameters, TOutput>;
|
|
13
|
+
export declare function createSchemaTask<TIdentifier extends string, TSchema extends TaskSchema | undefined = undefined, TOutput = unknown, TInitOutput extends InitOutput = any>(params: TaskWithSchemaOptions<TIdentifier, TSchema, TOutput, TInitOutput>): TaskWithSchema<TIdentifier, TSchema, TOutput>;
|
|
13
14
|
/**
|
|
14
15
|
* Trigger a task by its identifier with the given payload. Returns a typesafe `RunHandle`.
|
|
15
16
|
*
|
package/dist/esm/v3/shared.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SpanKind } from "@opentelemetry/api";
|
|
2
2
|
import { SEMATTRS_MESSAGING_DESTINATION, SEMATTRS_MESSAGING_OPERATION, SEMATTRS_MESSAGING_SYSTEM, } from "@opentelemetry/semantic-conventions";
|
|
3
|
-
import { accessoryAttributes, apiClientManager, conditionallyImportPacket, createErrorTaskError, defaultRetryOptions, getSchemaParseFn, logger, parsePacket, runtime, SemanticInternalAttributes, stringifyIO, SubtaskUnwrapError, taskCatalog, taskContext, TaskRunPromise, } from "@trigger.dev/core/v3";
|
|
4
|
-
import { idempotencyKeys, isIdempotencyKey } from "./idempotencyKeys.js";
|
|
3
|
+
import { accessoryAttributes, apiClientManager, conditionallyImportPacket, convertToolParametersToSchema, createErrorTaskError, defaultRetryOptions, getSchemaParseFn, logger, makeIdempotencyKey, parsePacket, runtime, SemanticInternalAttributes, stringifyIO, SubtaskUnwrapError, taskCatalog, taskContext, TaskRunPromise, } from "@trigger.dev/core/v3";
|
|
5
4
|
import { runs } from "./runs.js";
|
|
6
5
|
import { tracer } from "./tracer.js";
|
|
7
6
|
export { SubtaskUnwrapError, TaskRunPromise };
|
|
@@ -17,6 +16,7 @@ export function createTask(params) {
|
|
|
17
16
|
: undefined;
|
|
18
17
|
const task = {
|
|
19
18
|
id: params.id,
|
|
19
|
+
description: params.description,
|
|
20
20
|
trigger: async (payload, options) => {
|
|
21
21
|
const taskMetadata = taskCatalog.getTaskManifest(params.id);
|
|
22
22
|
return await trigger_internal(taskMetadata && taskMetadata.exportName
|
|
@@ -58,6 +58,7 @@ export function createTask(params) {
|
|
|
58
58
|
};
|
|
59
59
|
taskCatalog.registerTaskMetadata({
|
|
60
60
|
id: params.id,
|
|
61
|
+
description: params.description,
|
|
61
62
|
queue: params.queue,
|
|
62
63
|
retry: params.retry ? { ...defaultRetryOptions, ...params.retry } : undefined,
|
|
63
64
|
machine: params.machine,
|
|
@@ -77,6 +78,22 @@ export function createTask(params) {
|
|
|
77
78
|
task[Symbol.for("trigger.dev/task")] = true;
|
|
78
79
|
return task;
|
|
79
80
|
}
|
|
81
|
+
export function createToolTask(params) {
|
|
82
|
+
const task = createSchemaTask({
|
|
83
|
+
...params,
|
|
84
|
+
schema: convertToolParametersToSchema(params.parameters),
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
...task,
|
|
88
|
+
tool: {
|
|
89
|
+
parameters: params.parameters,
|
|
90
|
+
description: params.description,
|
|
91
|
+
execute: async (args) => {
|
|
92
|
+
return task.triggerAndWait(args).unwrap();
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
80
97
|
export function createSchemaTask(params) {
|
|
81
98
|
const customQueue = params.queue
|
|
82
99
|
? queue({
|
|
@@ -89,6 +106,8 @@ export function createSchemaTask(params) {
|
|
|
89
106
|
: undefined;
|
|
90
107
|
const task = {
|
|
91
108
|
id: params.id,
|
|
109
|
+
description: params.description,
|
|
110
|
+
schema: params.schema,
|
|
92
111
|
trigger: async (payload, options, requestOptions) => {
|
|
93
112
|
const taskMetadata = taskCatalog.getTaskManifest(params.id);
|
|
94
113
|
return await trigger_internal(taskMetadata && taskMetadata.exportName
|
|
@@ -130,6 +149,7 @@ export function createSchemaTask(params) {
|
|
|
130
149
|
};
|
|
131
150
|
taskCatalog.registerTaskMetadata({
|
|
132
151
|
id: params.id,
|
|
152
|
+
description: params.description,
|
|
133
153
|
queue: params.queue,
|
|
134
154
|
retry: params.retry ? { ...defaultRetryOptions, ...params.retry } : undefined,
|
|
135
155
|
machine: params.machine,
|
|
@@ -258,7 +278,7 @@ async function trigger_internal(name, id, payload, parsePayload, options, reques
|
|
|
258
278
|
concurrencyKey: options?.concurrencyKey,
|
|
259
279
|
test: taskContext.ctx?.run.isTest,
|
|
260
280
|
payloadType: payloadPacket.dataType,
|
|
261
|
-
idempotencyKey: await
|
|
281
|
+
idempotencyKey: await makeIdempotencyKey(options?.idempotencyKey),
|
|
262
282
|
delay: options?.delay,
|
|
263
283
|
ttl: options?.ttl,
|
|
264
284
|
tags: options?.tags,
|
|
@@ -303,7 +323,7 @@ async function batchTrigger_internal(name, id, items, parsePayload, requestOptio
|
|
|
303
323
|
concurrencyKey: item.options?.concurrencyKey,
|
|
304
324
|
test: taskContext.ctx?.run.isTest,
|
|
305
325
|
payloadType: payloadPacket.dataType,
|
|
306
|
-
idempotencyKey: await
|
|
326
|
+
idempotencyKey: await makeIdempotencyKey(item.options?.idempotencyKey),
|
|
307
327
|
delay: item.options?.delay,
|
|
308
328
|
ttl: item.options?.ttl,
|
|
309
329
|
tags: item.options?.tags,
|
|
@@ -350,7 +370,7 @@ async function triggerAndWait_internal(name, id, payload, parsePayload, options,
|
|
|
350
370
|
concurrencyKey: options?.concurrencyKey,
|
|
351
371
|
test: taskContext.ctx?.run.isTest,
|
|
352
372
|
payloadType: payloadPacket.dataType,
|
|
353
|
-
idempotencyKey: await
|
|
373
|
+
idempotencyKey: await makeIdempotencyKey(options?.idempotencyKey),
|
|
354
374
|
delay: options?.delay,
|
|
355
375
|
ttl: options?.ttl,
|
|
356
376
|
tags: options?.tags,
|
|
@@ -415,7 +435,7 @@ async function batchTriggerAndWait_internal(name, id, items, parsePayload, reque
|
|
|
415
435
|
concurrencyKey: item.options?.concurrencyKey,
|
|
416
436
|
test: taskContext.ctx?.run.isTest,
|
|
417
437
|
payloadType: payloadPacket.dataType,
|
|
418
|
-
idempotencyKey: await
|
|
438
|
+
idempotencyKey: await makeIdempotencyKey(item.options?.idempotencyKey),
|
|
419
439
|
delay: item.options?.delay,
|
|
420
440
|
ttl: item.options?.ttl,
|
|
421
441
|
tags: item.options?.tags,
|
|
@@ -534,13 +554,4 @@ async function handleTaskRunExecutionResult(execution) {
|
|
|
534
554
|
};
|
|
535
555
|
}
|
|
536
556
|
}
|
|
537
|
-
async function makeKey(idempotencyKey) {
|
|
538
|
-
if (!idempotencyKey) {
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
if (isIdempotencyKey(idempotencyKey)) {
|
|
542
|
-
return idempotencyKey;
|
|
543
|
-
}
|
|
544
|
-
return await idempotencyKeys.create(idempotencyKey, { scope: "global" });
|
|
545
|
-
}
|
|
546
557
|
//# sourceMappingURL=shared.js.map
|