@trigger.dev/sdk 3.3.8 → 3.3.10
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/v3/metadata.d.ts +73 -22
- package/dist/commonjs/v3/metadata.js +45 -13
- package/dist/commonjs/v3/metadata.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +19 -2
- package/dist/commonjs/v3/runs.js +14 -2
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/metadata.d.ts +73 -22
- package/dist/esm/v3/metadata.js +45 -13
- package/dist/esm/v3/metadata.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +19 -2
- package/dist/esm/v3/runs.js +14 -2
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { DeserializedJson } from "@trigger.dev/core";
|
|
2
|
-
import { ApiRequestOptions } from "@trigger.dev/core/v3";
|
|
3
|
-
/**
|
|
4
|
-
* Provides access to run metadata operations.
|
|
5
|
-
* @namespace
|
|
6
|
-
* @property {Function} current - Get the current run's metadata.
|
|
7
|
-
* @property {Function} get - Get a specific key from the current run's metadata.
|
|
8
|
-
* @property {Function} set - Set a key in the current run's metadata.
|
|
9
|
-
* @property {Function} del - Delete a key from the current run's metadata.
|
|
10
|
-
* @property {Function} save - Update the entire metadata object for the current run.
|
|
11
|
-
*/
|
|
2
|
+
import { ApiRequestOptions, type RunMetadataUpdater, type AsyncIterableStream } from "@trigger.dev/core/v3";
|
|
12
3
|
export declare const metadata: {
|
|
13
|
-
current: typeof currentMetadata;
|
|
14
|
-
get: typeof getMetadataKey;
|
|
15
4
|
set: typeof setMetadataKey;
|
|
16
5
|
del: typeof deleteMetadataKey;
|
|
17
|
-
save: typeof saveMetadata;
|
|
18
|
-
replace: typeof replaceMetadata;
|
|
19
|
-
flush: typeof flushMetadata;
|
|
20
|
-
stream: typeof stream;
|
|
21
6
|
append: typeof appendMetadataKey;
|
|
22
7
|
remove: typeof removeMetadataKey;
|
|
23
8
|
increment: typeof incrementMetadataKey;
|
|
24
9
|
decrement: typeof decrementMetadataKey;
|
|
10
|
+
flush: typeof flushMetadata;
|
|
11
|
+
current: typeof currentMetadata;
|
|
12
|
+
get: typeof getMetadataKey;
|
|
13
|
+
save: typeof saveMetadata;
|
|
14
|
+
replace: typeof replaceMetadata;
|
|
15
|
+
stream: typeof stream;
|
|
16
|
+
fetchStream: typeof fetchStream;
|
|
17
|
+
parent: RunMetadataUpdater;
|
|
18
|
+
root: RunMetadataUpdater;
|
|
19
|
+
refresh: typeof refreshMetadata;
|
|
25
20
|
};
|
|
26
21
|
export type RunMetadata = Record<string, DeserializedJson>;
|
|
27
22
|
/**
|
|
@@ -57,7 +52,15 @@ declare function getMetadataKey(key: string): DeserializedJson | undefined;
|
|
|
57
52
|
* @example
|
|
58
53
|
* metadata.set("progress", 0.5);
|
|
59
54
|
*/
|
|
60
|
-
declare function setMetadataKey(key: string, value: DeserializedJson):
|
|
55
|
+
declare function setMetadataKey(key: string, value: DeserializedJson): {
|
|
56
|
+
set: typeof setMetadataKey;
|
|
57
|
+
del: typeof deleteMetadataKey;
|
|
58
|
+
append: typeof appendMetadataKey;
|
|
59
|
+
remove: typeof removeMetadataKey;
|
|
60
|
+
increment: typeof incrementMetadataKey;
|
|
61
|
+
decrement: typeof decrementMetadataKey;
|
|
62
|
+
flush: typeof flushMetadata;
|
|
63
|
+
};
|
|
61
64
|
/**
|
|
62
65
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
63
66
|
*
|
|
@@ -66,7 +69,15 @@ declare function setMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
66
69
|
* @example
|
|
67
70
|
* metadata.del("progress");
|
|
68
71
|
*/
|
|
69
|
-
declare function deleteMetadataKey(key: string):
|
|
72
|
+
declare function deleteMetadataKey(key: string): {
|
|
73
|
+
set: typeof setMetadataKey;
|
|
74
|
+
del: typeof deleteMetadataKey;
|
|
75
|
+
append: typeof appendMetadataKey;
|
|
76
|
+
remove: typeof removeMetadataKey;
|
|
77
|
+
increment: typeof incrementMetadataKey;
|
|
78
|
+
decrement: typeof decrementMetadataKey;
|
|
79
|
+
flush: typeof flushMetadata;
|
|
80
|
+
};
|
|
70
81
|
/**
|
|
71
82
|
* Update the entire metadata object for the current run if inside a task run.
|
|
72
83
|
* This function allows you to replace the entire metadata object with a new one.
|
|
@@ -93,7 +104,15 @@ declare function saveMetadata(metadata: RunMetadata): void;
|
|
|
93
104
|
* metadata.increment("counter", 1); // Increments counter by 1
|
|
94
105
|
* metadata.increment("score", 10); // Increments score by 10
|
|
95
106
|
*/
|
|
96
|
-
declare function incrementMetadataKey(key: string, value?: number):
|
|
107
|
+
declare function incrementMetadataKey(key: string, value?: number): {
|
|
108
|
+
set: typeof setMetadataKey;
|
|
109
|
+
del: typeof deleteMetadataKey;
|
|
110
|
+
append: typeof appendMetadataKey;
|
|
111
|
+
remove: typeof removeMetadataKey;
|
|
112
|
+
increment: typeof incrementMetadataKey;
|
|
113
|
+
decrement: typeof decrementMetadataKey;
|
|
114
|
+
flush: typeof flushMetadata;
|
|
115
|
+
};
|
|
97
116
|
/**
|
|
98
117
|
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
99
118
|
* This function allows you to atomically decrement a numeric metadata value.
|
|
@@ -105,7 +124,15 @@ declare function incrementMetadataKey(key: string, value?: number): void;
|
|
|
105
124
|
* metadata.decrement("counter", 1); // Decrements counter by 1
|
|
106
125
|
* metadata.decrement("score", 5); // Decrements score by 5
|
|
107
126
|
*/
|
|
108
|
-
declare function decrementMetadataKey(key: string, value?: number):
|
|
127
|
+
declare function decrementMetadataKey(key: string, value?: number): {
|
|
128
|
+
set: typeof setMetadataKey;
|
|
129
|
+
del: typeof deleteMetadataKey;
|
|
130
|
+
append: typeof appendMetadataKey;
|
|
131
|
+
remove: typeof removeMetadataKey;
|
|
132
|
+
increment: typeof incrementMetadataKey;
|
|
133
|
+
decrement: typeof decrementMetadataKey;
|
|
134
|
+
flush: typeof flushMetadata;
|
|
135
|
+
};
|
|
109
136
|
/**
|
|
110
137
|
* Appends a value to an array in the metadata of the current run.
|
|
111
138
|
* If the key doesn't exist, it creates a new array with the value.
|
|
@@ -118,7 +145,15 @@ declare function decrementMetadataKey(key: string, value?: number): void;
|
|
|
118
145
|
* metadata.append("logs", "User logged in");
|
|
119
146
|
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
120
147
|
*/
|
|
121
|
-
declare function appendMetadataKey(key: string, value: DeserializedJson):
|
|
148
|
+
declare function appendMetadataKey(key: string, value: DeserializedJson): {
|
|
149
|
+
set: typeof setMetadataKey;
|
|
150
|
+
del: typeof deleteMetadataKey;
|
|
151
|
+
append: typeof appendMetadataKey;
|
|
152
|
+
remove: typeof removeMetadataKey;
|
|
153
|
+
increment: typeof incrementMetadataKey;
|
|
154
|
+
decrement: typeof decrementMetadataKey;
|
|
155
|
+
flush: typeof flushMetadata;
|
|
156
|
+
};
|
|
122
157
|
/**
|
|
123
158
|
* Removes a value from an array in the metadata of the current run.
|
|
124
159
|
*
|
|
@@ -130,7 +165,15 @@ declare function appendMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
130
165
|
* metadata.remove("logs", "User logged in");
|
|
131
166
|
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
132
167
|
*/
|
|
133
|
-
declare function removeMetadataKey(key: string, value: DeserializedJson):
|
|
168
|
+
declare function removeMetadataKey(key: string, value: DeserializedJson): {
|
|
169
|
+
set: typeof setMetadataKey;
|
|
170
|
+
del: typeof deleteMetadataKey;
|
|
171
|
+
append: typeof appendMetadataKey;
|
|
172
|
+
remove: typeof removeMetadataKey;
|
|
173
|
+
increment: typeof incrementMetadataKey;
|
|
174
|
+
decrement: typeof decrementMetadataKey;
|
|
175
|
+
flush: typeof flushMetadata;
|
|
176
|
+
};
|
|
134
177
|
/**
|
|
135
178
|
* Flushes metadata to the Trigger.dev instance
|
|
136
179
|
*
|
|
@@ -138,5 +181,13 @@ declare function removeMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
138
181
|
* @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
|
|
139
182
|
*/
|
|
140
183
|
declare function flushMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Refreshes metadata from the Trigger.dev instance
|
|
186
|
+
*
|
|
187
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
188
|
+
* @returns {Promise<void>} A promise that resolves when the metadata refresh operation is complete.
|
|
189
|
+
*/
|
|
190
|
+
declare function refreshMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
141
191
|
declare function stream<T>(key: string, value: AsyncIterable<T> | ReadableStream<T>, signal?: AbortSignal): Promise<AsyncIterable<T>>;
|
|
192
|
+
declare function fetchStream<T>(key: string, signal?: AbortSignal): Promise<AsyncIterableStream<T>>;
|
|
142
193
|
export {};
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.metadata = void 0;
|
|
4
4
|
const v3_1 = require("@trigger.dev/core/v3");
|
|
5
5
|
const tracer_js_1 = require("./tracer.js");
|
|
6
|
+
const parentMetadataUpdater = v3_1.runMetadata.parent;
|
|
7
|
+
const rootMetadataUpdater = v3_1.runMetadata.root;
|
|
6
8
|
/**
|
|
7
9
|
* Provides access to run metadata operations.
|
|
8
10
|
* @namespace
|
|
@@ -12,19 +14,26 @@ const tracer_js_1 = require("./tracer.js");
|
|
|
12
14
|
* @property {Function} del - Delete a key from the current run's metadata.
|
|
13
15
|
* @property {Function} save - Update the entire metadata object for the current run.
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
current: currentMetadata,
|
|
17
|
-
get: getMetadataKey,
|
|
17
|
+
const metadataUpdater = {
|
|
18
18
|
set: setMetadataKey,
|
|
19
19
|
del: deleteMetadataKey,
|
|
20
|
-
save: saveMetadata,
|
|
21
|
-
replace: replaceMetadata,
|
|
22
|
-
flush: flushMetadata,
|
|
23
|
-
stream: stream,
|
|
24
20
|
append: appendMetadataKey,
|
|
25
21
|
remove: removeMetadataKey,
|
|
26
22
|
increment: incrementMetadataKey,
|
|
27
23
|
decrement: decrementMetadataKey,
|
|
24
|
+
flush: flushMetadata,
|
|
25
|
+
};
|
|
26
|
+
exports.metadata = {
|
|
27
|
+
current: currentMetadata,
|
|
28
|
+
get: getMetadataKey,
|
|
29
|
+
save: saveMetadata,
|
|
30
|
+
replace: replaceMetadata,
|
|
31
|
+
stream: stream,
|
|
32
|
+
fetchStream: fetchStream,
|
|
33
|
+
parent: parentMetadataUpdater,
|
|
34
|
+
root: rootMetadataUpdater,
|
|
35
|
+
refresh: refreshMetadata,
|
|
36
|
+
...metadataUpdater,
|
|
28
37
|
};
|
|
29
38
|
/**
|
|
30
39
|
* Returns the metadata of the current run if inside a task run.
|
|
@@ -64,7 +73,8 @@ function getMetadataKey(key) {
|
|
|
64
73
|
* metadata.set("progress", 0.5);
|
|
65
74
|
*/
|
|
66
75
|
function setMetadataKey(key, value) {
|
|
67
|
-
v3_1.runMetadata.
|
|
76
|
+
v3_1.runMetadata.set(key, value);
|
|
77
|
+
return metadataUpdater;
|
|
68
78
|
}
|
|
69
79
|
/**
|
|
70
80
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
@@ -75,7 +85,8 @@ function setMetadataKey(key, value) {
|
|
|
75
85
|
* metadata.del("progress");
|
|
76
86
|
*/
|
|
77
87
|
function deleteMetadataKey(key) {
|
|
78
|
-
v3_1.runMetadata.
|
|
88
|
+
v3_1.runMetadata.del(key);
|
|
89
|
+
return metadataUpdater;
|
|
79
90
|
}
|
|
80
91
|
/**
|
|
81
92
|
* Update the entire metadata object for the current run if inside a task run.
|
|
@@ -108,7 +119,8 @@ function saveMetadata(metadata) {
|
|
|
108
119
|
* metadata.increment("score", 10); // Increments score by 10
|
|
109
120
|
*/
|
|
110
121
|
function incrementMetadataKey(key, value = 1) {
|
|
111
|
-
v3_1.runMetadata.
|
|
122
|
+
v3_1.runMetadata.increment(key, value);
|
|
123
|
+
return metadataUpdater;
|
|
112
124
|
}
|
|
113
125
|
/**
|
|
114
126
|
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
@@ -122,7 +134,8 @@ function incrementMetadataKey(key, value = 1) {
|
|
|
122
134
|
* metadata.decrement("score", 5); // Decrements score by 5
|
|
123
135
|
*/
|
|
124
136
|
function decrementMetadataKey(key, value = 1) {
|
|
125
|
-
v3_1.runMetadata.
|
|
137
|
+
v3_1.runMetadata.decrement(key, value);
|
|
138
|
+
return metadataUpdater;
|
|
126
139
|
}
|
|
127
140
|
/**
|
|
128
141
|
* Appends a value to an array in the metadata of the current run.
|
|
@@ -137,7 +150,8 @@ function decrementMetadataKey(key, value = 1) {
|
|
|
137
150
|
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
138
151
|
*/
|
|
139
152
|
function appendMetadataKey(key, value) {
|
|
140
|
-
v3_1.runMetadata.
|
|
153
|
+
v3_1.runMetadata.append(key, value);
|
|
154
|
+
return metadataUpdater;
|
|
141
155
|
}
|
|
142
156
|
/**
|
|
143
157
|
* Removes a value from an array in the metadata of the current run.
|
|
@@ -151,7 +165,8 @@ function appendMetadataKey(key, value) {
|
|
|
151
165
|
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
152
166
|
*/
|
|
153
167
|
function removeMetadataKey(key, value) {
|
|
154
|
-
v3_1.runMetadata.
|
|
168
|
+
v3_1.runMetadata.remove(key, value);
|
|
169
|
+
return metadataUpdater;
|
|
155
170
|
}
|
|
156
171
|
/**
|
|
157
172
|
* Flushes metadata to the Trigger.dev instance
|
|
@@ -167,7 +182,24 @@ async function flushMetadata(requestOptions) {
|
|
|
167
182
|
}, requestOptions);
|
|
168
183
|
await v3_1.runMetadata.flush($requestOptions);
|
|
169
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Refreshes metadata from the Trigger.dev instance
|
|
187
|
+
*
|
|
188
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
189
|
+
* @returns {Promise<void>} A promise that resolves when the metadata refresh operation is complete.
|
|
190
|
+
*/
|
|
191
|
+
async function refreshMetadata(requestOptions) {
|
|
192
|
+
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
193
|
+
tracer: tracer_js_1.tracer,
|
|
194
|
+
name: "metadata.refresh()",
|
|
195
|
+
icon: "code-plus",
|
|
196
|
+
}, requestOptions);
|
|
197
|
+
await v3_1.runMetadata.refresh($requestOptions);
|
|
198
|
+
}
|
|
170
199
|
async function stream(key, value, signal) {
|
|
171
200
|
return v3_1.runMetadata.stream(key, value, signal);
|
|
172
201
|
}
|
|
202
|
+
async function fetchStream(key, signal) {
|
|
203
|
+
return v3_1.runMetadata.fetchStream(key, signal);
|
|
204
|
+
}
|
|
173
205
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":";;;AACA,6CAM8B;AAC9B,2CAAqC;AAErC,MAAM,qBAAqB,GAAuB,gBAAW,CAAC,MAAM,CAAC;AACrE,MAAM,mBAAmB,GAAuB,gBAAW,CAAC,IAAI,CAAC;AAEjE;;;;;;;;GAQG;AAEH,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,iBAAiB;IACtB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,oBAAoB;IAC/B,SAAS,EAAE,oBAAoB;IAC/B,KAAK,EAAE,aAAa;CACrB,CAAC;AAEW,QAAA,QAAQ,GAAG;IACtB,OAAO,EAAE,eAAe;IACxB,GAAG,EAA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|
1
|
-
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle, AsyncIterableStream } 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
4
|
export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, AnyRealtimeRun, };
|
|
@@ -12,6 +12,7 @@ export declare const runs: {
|
|
|
12
12
|
subscribeToRun: typeof subscribeToRun;
|
|
13
13
|
subscribeToRunsWithTag: typeof subscribeToRunsWithTag;
|
|
14
14
|
subscribeToBatch: typeof subscribeToRunsInBatch;
|
|
15
|
+
fetchStream: typeof fetchStream;
|
|
15
16
|
};
|
|
16
17
|
export type ListRunsItem = ListRunResponseItem;
|
|
17
18
|
declare function listRuns(projectRef: string, params?: ListProjectRunsQueryParams, requestOptions?: ApiRequestOptions): CursorPagePromise<typeof ListRunResponseItem>;
|
|
@@ -177,6 +178,16 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
177
178
|
output?: InferRunTypes<TRunId>["output"] | undefined;
|
|
178
179
|
payload?: InferRunTypes<TRunId>["payload"] | undefined;
|
|
179
180
|
}>;
|
|
181
|
+
export type SubscribeToRunOptions = {
|
|
182
|
+
/**
|
|
183
|
+
* Whether to close the subscription when the run completes
|
|
184
|
+
*
|
|
185
|
+
* @default true
|
|
186
|
+
*
|
|
187
|
+
* Set this to false if you are making updates to the run metadata after completion through child runs
|
|
188
|
+
*/
|
|
189
|
+
stopOnCompletion?: boolean;
|
|
190
|
+
};
|
|
180
191
|
/**
|
|
181
192
|
* Subscribes to real-time updates for a specific run.
|
|
182
193
|
*
|
|
@@ -187,6 +198,8 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
187
198
|
*
|
|
188
199
|
* @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
|
|
189
200
|
* @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
|
|
201
|
+
* @param {SubscribeToRunOptions} [options] - Optional configuration for the subscription
|
|
202
|
+
* @param {boolean} [options.stopOnCompletion=true] - Whether to close the subscription when the run completes
|
|
190
203
|
* @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
|
|
191
204
|
*
|
|
192
205
|
* @example
|
|
@@ -206,7 +219,7 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
206
219
|
* }
|
|
207
220
|
* ```
|
|
208
221
|
*/
|
|
209
|
-
declare function subscribeToRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId
|
|
222
|
+
declare function subscribeToRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId>, options?: SubscribeToRunOptions): RunSubscription<InferRunTypes<TRunId>>;
|
|
210
223
|
/**
|
|
211
224
|
* Subscribes to real-time updates for all runs that have specific tags.
|
|
212
225
|
*
|
|
@@ -268,3 +281,7 @@ declare function subscribeToRunsWithTag<TTasks extends AnyTask>(tag: string | st
|
|
|
268
281
|
* createdAt, updatedAt, tags, and more. See the Run object documentation for full details.
|
|
269
282
|
*/
|
|
270
283
|
declare function subscribeToRunsInBatch<TTasks extends AnyTask>(batchId: string): RunSubscription<InferRunTypes<TTasks>>;
|
|
284
|
+
/**
|
|
285
|
+
* Fetches a stream of data from a run's stream key.
|
|
286
|
+
*/
|
|
287
|
+
declare function fetchStream<T>(runId: string, streamKey: string): Promise<AsyncIterableStream<T>>;
|
package/dist/commonjs/v3/runs.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.runs = {
|
|
|
14
14
|
subscribeToRun,
|
|
15
15
|
subscribeToRunsWithTag,
|
|
16
16
|
subscribeToBatch: subscribeToRunsInBatch,
|
|
17
|
+
fetchStream,
|
|
17
18
|
};
|
|
18
19
|
function listRuns(paramsOrProjectRef, paramsOrOptions, requestOptions) {
|
|
19
20
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
@@ -206,6 +207,8 @@ async function poll(runId, options, requestOptions) {
|
|
|
206
207
|
*
|
|
207
208
|
* @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
|
|
208
209
|
* @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
|
|
210
|
+
* @param {SubscribeToRunOptions} [options] - Optional configuration for the subscription
|
|
211
|
+
* @param {boolean} [options.stopOnCompletion=true] - Whether to close the subscription when the run completes
|
|
209
212
|
* @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
|
|
210
213
|
*
|
|
211
214
|
* @example
|
|
@@ -225,10 +228,12 @@ async function poll(runId, options, requestOptions) {
|
|
|
225
228
|
* }
|
|
226
229
|
* ```
|
|
227
230
|
*/
|
|
228
|
-
function subscribeToRun(runId) {
|
|
231
|
+
function subscribeToRun(runId, options) {
|
|
229
232
|
const $runId = typeof runId === "string" ? runId : runId.id;
|
|
230
233
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
231
|
-
return apiClient.subscribeToRun($runId
|
|
234
|
+
return apiClient.subscribeToRun($runId, {
|
|
235
|
+
closeOnComplete: typeof options?.stopOnCompletion === "boolean" ? options.stopOnCompletion : true,
|
|
236
|
+
});
|
|
232
237
|
}
|
|
233
238
|
/**
|
|
234
239
|
* Subscribes to real-time updates for all runs that have specific tags.
|
|
@@ -297,4 +302,11 @@ function subscribeToRunsInBatch(batchId) {
|
|
|
297
302
|
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
298
303
|
return apiClient.subscribeToBatch(batchId);
|
|
299
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Fetches a stream of data from a run's stream key.
|
|
307
|
+
*/
|
|
308
|
+
async function fetchStream(runId, streamKey) {
|
|
309
|
+
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
310
|
+
return await apiClient.fetchStream(runId, streamKey);
|
|
311
|
+
}
|
|
300
312
|
//# sourceMappingURL=runs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":";;;AAiBA,6CAY8B;AAC9B,gFAAuF;AAEvF,2CAAqC;AAYxB,QAAA,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;IACtB,gBAAgB,EAAE,sBAAsB;IACxC,WAAW;CACZ,CAAC;AAaF,SAAS,QAAQ,CACf,kBAAiD,EACjD,eAAsF,EACtF,cAAkC;IAElC,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,sBAAsB,CAC5C,kBAAkB,EAClB,eAAe,EACf,cAAc,CACf,CAAC;IAEF,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,IAAA,qBAAgB,EAAC,eAAe,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC,eAAe,CAAC,kBAAkB,EA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AAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAS,sBAAsB,CAC7B,OAAe;IAEf,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,gBAAgB,CAAwB,OAAO,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,WAAW,CAAI,KAAa,EAAE,SAAiB;IAC5D,MAAM,SAAS,GAAG,qBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { DeserializedJson } from "@trigger.dev/core";
|
|
2
|
-
import { ApiRequestOptions } from "@trigger.dev/core/v3";
|
|
3
|
-
/**
|
|
4
|
-
* Provides access to run metadata operations.
|
|
5
|
-
* @namespace
|
|
6
|
-
* @property {Function} current - Get the current run's metadata.
|
|
7
|
-
* @property {Function} get - Get a specific key from the current run's metadata.
|
|
8
|
-
* @property {Function} set - Set a key in the current run's metadata.
|
|
9
|
-
* @property {Function} del - Delete a key from the current run's metadata.
|
|
10
|
-
* @property {Function} save - Update the entire metadata object for the current run.
|
|
11
|
-
*/
|
|
2
|
+
import { ApiRequestOptions, type RunMetadataUpdater, type AsyncIterableStream } from "@trigger.dev/core/v3";
|
|
12
3
|
export declare const metadata: {
|
|
13
|
-
current: typeof currentMetadata;
|
|
14
|
-
get: typeof getMetadataKey;
|
|
15
4
|
set: typeof setMetadataKey;
|
|
16
5
|
del: typeof deleteMetadataKey;
|
|
17
|
-
save: typeof saveMetadata;
|
|
18
|
-
replace: typeof replaceMetadata;
|
|
19
|
-
flush: typeof flushMetadata;
|
|
20
|
-
stream: typeof stream;
|
|
21
6
|
append: typeof appendMetadataKey;
|
|
22
7
|
remove: typeof removeMetadataKey;
|
|
23
8
|
increment: typeof incrementMetadataKey;
|
|
24
9
|
decrement: typeof decrementMetadataKey;
|
|
10
|
+
flush: typeof flushMetadata;
|
|
11
|
+
current: typeof currentMetadata;
|
|
12
|
+
get: typeof getMetadataKey;
|
|
13
|
+
save: typeof saveMetadata;
|
|
14
|
+
replace: typeof replaceMetadata;
|
|
15
|
+
stream: typeof stream;
|
|
16
|
+
fetchStream: typeof fetchStream;
|
|
17
|
+
parent: RunMetadataUpdater;
|
|
18
|
+
root: RunMetadataUpdater;
|
|
19
|
+
refresh: typeof refreshMetadata;
|
|
25
20
|
};
|
|
26
21
|
export type RunMetadata = Record<string, DeserializedJson>;
|
|
27
22
|
/**
|
|
@@ -57,7 +52,15 @@ declare function getMetadataKey(key: string): DeserializedJson | undefined;
|
|
|
57
52
|
* @example
|
|
58
53
|
* metadata.set("progress", 0.5);
|
|
59
54
|
*/
|
|
60
|
-
declare function setMetadataKey(key: string, value: DeserializedJson):
|
|
55
|
+
declare function setMetadataKey(key: string, value: DeserializedJson): {
|
|
56
|
+
set: typeof setMetadataKey;
|
|
57
|
+
del: typeof deleteMetadataKey;
|
|
58
|
+
append: typeof appendMetadataKey;
|
|
59
|
+
remove: typeof removeMetadataKey;
|
|
60
|
+
increment: typeof incrementMetadataKey;
|
|
61
|
+
decrement: typeof decrementMetadataKey;
|
|
62
|
+
flush: typeof flushMetadata;
|
|
63
|
+
};
|
|
61
64
|
/**
|
|
62
65
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
63
66
|
*
|
|
@@ -66,7 +69,15 @@ declare function setMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
66
69
|
* @example
|
|
67
70
|
* metadata.del("progress");
|
|
68
71
|
*/
|
|
69
|
-
declare function deleteMetadataKey(key: string):
|
|
72
|
+
declare function deleteMetadataKey(key: string): {
|
|
73
|
+
set: typeof setMetadataKey;
|
|
74
|
+
del: typeof deleteMetadataKey;
|
|
75
|
+
append: typeof appendMetadataKey;
|
|
76
|
+
remove: typeof removeMetadataKey;
|
|
77
|
+
increment: typeof incrementMetadataKey;
|
|
78
|
+
decrement: typeof decrementMetadataKey;
|
|
79
|
+
flush: typeof flushMetadata;
|
|
80
|
+
};
|
|
70
81
|
/**
|
|
71
82
|
* Update the entire metadata object for the current run if inside a task run.
|
|
72
83
|
* This function allows you to replace the entire metadata object with a new one.
|
|
@@ -93,7 +104,15 @@ declare function saveMetadata(metadata: RunMetadata): void;
|
|
|
93
104
|
* metadata.increment("counter", 1); // Increments counter by 1
|
|
94
105
|
* metadata.increment("score", 10); // Increments score by 10
|
|
95
106
|
*/
|
|
96
|
-
declare function incrementMetadataKey(key: string, value?: number):
|
|
107
|
+
declare function incrementMetadataKey(key: string, value?: number): {
|
|
108
|
+
set: typeof setMetadataKey;
|
|
109
|
+
del: typeof deleteMetadataKey;
|
|
110
|
+
append: typeof appendMetadataKey;
|
|
111
|
+
remove: typeof removeMetadataKey;
|
|
112
|
+
increment: typeof incrementMetadataKey;
|
|
113
|
+
decrement: typeof decrementMetadataKey;
|
|
114
|
+
flush: typeof flushMetadata;
|
|
115
|
+
};
|
|
97
116
|
/**
|
|
98
117
|
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
99
118
|
* This function allows you to atomically decrement a numeric metadata value.
|
|
@@ -105,7 +124,15 @@ declare function incrementMetadataKey(key: string, value?: number): void;
|
|
|
105
124
|
* metadata.decrement("counter", 1); // Decrements counter by 1
|
|
106
125
|
* metadata.decrement("score", 5); // Decrements score by 5
|
|
107
126
|
*/
|
|
108
|
-
declare function decrementMetadataKey(key: string, value?: number):
|
|
127
|
+
declare function decrementMetadataKey(key: string, value?: number): {
|
|
128
|
+
set: typeof setMetadataKey;
|
|
129
|
+
del: typeof deleteMetadataKey;
|
|
130
|
+
append: typeof appendMetadataKey;
|
|
131
|
+
remove: typeof removeMetadataKey;
|
|
132
|
+
increment: typeof incrementMetadataKey;
|
|
133
|
+
decrement: typeof decrementMetadataKey;
|
|
134
|
+
flush: typeof flushMetadata;
|
|
135
|
+
};
|
|
109
136
|
/**
|
|
110
137
|
* Appends a value to an array in the metadata of the current run.
|
|
111
138
|
* If the key doesn't exist, it creates a new array with the value.
|
|
@@ -118,7 +145,15 @@ declare function decrementMetadataKey(key: string, value?: number): void;
|
|
|
118
145
|
* metadata.append("logs", "User logged in");
|
|
119
146
|
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
120
147
|
*/
|
|
121
|
-
declare function appendMetadataKey(key: string, value: DeserializedJson):
|
|
148
|
+
declare function appendMetadataKey(key: string, value: DeserializedJson): {
|
|
149
|
+
set: typeof setMetadataKey;
|
|
150
|
+
del: typeof deleteMetadataKey;
|
|
151
|
+
append: typeof appendMetadataKey;
|
|
152
|
+
remove: typeof removeMetadataKey;
|
|
153
|
+
increment: typeof incrementMetadataKey;
|
|
154
|
+
decrement: typeof decrementMetadataKey;
|
|
155
|
+
flush: typeof flushMetadata;
|
|
156
|
+
};
|
|
122
157
|
/**
|
|
123
158
|
* Removes a value from an array in the metadata of the current run.
|
|
124
159
|
*
|
|
@@ -130,7 +165,15 @@ declare function appendMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
130
165
|
* metadata.remove("logs", "User logged in");
|
|
131
166
|
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
132
167
|
*/
|
|
133
|
-
declare function removeMetadataKey(key: string, value: DeserializedJson):
|
|
168
|
+
declare function removeMetadataKey(key: string, value: DeserializedJson): {
|
|
169
|
+
set: typeof setMetadataKey;
|
|
170
|
+
del: typeof deleteMetadataKey;
|
|
171
|
+
append: typeof appendMetadataKey;
|
|
172
|
+
remove: typeof removeMetadataKey;
|
|
173
|
+
increment: typeof incrementMetadataKey;
|
|
174
|
+
decrement: typeof decrementMetadataKey;
|
|
175
|
+
flush: typeof flushMetadata;
|
|
176
|
+
};
|
|
134
177
|
/**
|
|
135
178
|
* Flushes metadata to the Trigger.dev instance
|
|
136
179
|
*
|
|
@@ -138,5 +181,13 @@ declare function removeMetadataKey(key: string, value: DeserializedJson): void;
|
|
|
138
181
|
* @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
|
|
139
182
|
*/
|
|
140
183
|
declare function flushMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Refreshes metadata from the Trigger.dev instance
|
|
186
|
+
*
|
|
187
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
188
|
+
* @returns {Promise<void>} A promise that resolves when the metadata refresh operation is complete.
|
|
189
|
+
*/
|
|
190
|
+
declare function refreshMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
141
191
|
declare function stream<T>(key: string, value: AsyncIterable<T> | ReadableStream<T>, signal?: AbortSignal): Promise<AsyncIterable<T>>;
|
|
192
|
+
declare function fetchStream<T>(key: string, signal?: AbortSignal): Promise<AsyncIterableStream<T>>;
|
|
142
193
|
export {};
|
package/dist/esm/v3/metadata.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { mergeRequestOptions, runMetadata, } from "@trigger.dev/core/v3";
|
|
2
2
|
import { tracer } from "./tracer.js";
|
|
3
|
+
const parentMetadataUpdater = runMetadata.parent;
|
|
4
|
+
const rootMetadataUpdater = runMetadata.root;
|
|
3
5
|
/**
|
|
4
6
|
* Provides access to run metadata operations.
|
|
5
7
|
* @namespace
|
|
@@ -9,19 +11,26 @@ import { tracer } from "./tracer.js";
|
|
|
9
11
|
* @property {Function} del - Delete a key from the current run's metadata.
|
|
10
12
|
* @property {Function} save - Update the entire metadata object for the current run.
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
|
-
current: currentMetadata,
|
|
14
|
-
get: getMetadataKey,
|
|
14
|
+
const metadataUpdater = {
|
|
15
15
|
set: setMetadataKey,
|
|
16
16
|
del: deleteMetadataKey,
|
|
17
|
-
save: saveMetadata,
|
|
18
|
-
replace: replaceMetadata,
|
|
19
|
-
flush: flushMetadata,
|
|
20
|
-
stream: stream,
|
|
21
17
|
append: appendMetadataKey,
|
|
22
18
|
remove: removeMetadataKey,
|
|
23
19
|
increment: incrementMetadataKey,
|
|
24
20
|
decrement: decrementMetadataKey,
|
|
21
|
+
flush: flushMetadata,
|
|
22
|
+
};
|
|
23
|
+
export const metadata = {
|
|
24
|
+
current: currentMetadata,
|
|
25
|
+
get: getMetadataKey,
|
|
26
|
+
save: saveMetadata,
|
|
27
|
+
replace: replaceMetadata,
|
|
28
|
+
stream: stream,
|
|
29
|
+
fetchStream: fetchStream,
|
|
30
|
+
parent: parentMetadataUpdater,
|
|
31
|
+
root: rootMetadataUpdater,
|
|
32
|
+
refresh: refreshMetadata,
|
|
33
|
+
...metadataUpdater,
|
|
25
34
|
};
|
|
26
35
|
/**
|
|
27
36
|
* Returns the metadata of the current run if inside a task run.
|
|
@@ -61,7 +70,8 @@ function getMetadataKey(key) {
|
|
|
61
70
|
* metadata.set("progress", 0.5);
|
|
62
71
|
*/
|
|
63
72
|
function setMetadataKey(key, value) {
|
|
64
|
-
runMetadata.
|
|
73
|
+
runMetadata.set(key, value);
|
|
74
|
+
return metadataUpdater;
|
|
65
75
|
}
|
|
66
76
|
/**
|
|
67
77
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
@@ -72,7 +82,8 @@ function setMetadataKey(key, value) {
|
|
|
72
82
|
* metadata.del("progress");
|
|
73
83
|
*/
|
|
74
84
|
function deleteMetadataKey(key) {
|
|
75
|
-
runMetadata.
|
|
85
|
+
runMetadata.del(key);
|
|
86
|
+
return metadataUpdater;
|
|
76
87
|
}
|
|
77
88
|
/**
|
|
78
89
|
* Update the entire metadata object for the current run if inside a task run.
|
|
@@ -105,7 +116,8 @@ function saveMetadata(metadata) {
|
|
|
105
116
|
* metadata.increment("score", 10); // Increments score by 10
|
|
106
117
|
*/
|
|
107
118
|
function incrementMetadataKey(key, value = 1) {
|
|
108
|
-
runMetadata.
|
|
119
|
+
runMetadata.increment(key, value);
|
|
120
|
+
return metadataUpdater;
|
|
109
121
|
}
|
|
110
122
|
/**
|
|
111
123
|
* Decrements a numeric value in the metadata of the current run by the specified amount.
|
|
@@ -119,7 +131,8 @@ function incrementMetadataKey(key, value = 1) {
|
|
|
119
131
|
* metadata.decrement("score", 5); // Decrements score by 5
|
|
120
132
|
*/
|
|
121
133
|
function decrementMetadataKey(key, value = 1) {
|
|
122
|
-
runMetadata.
|
|
134
|
+
runMetadata.decrement(key, value);
|
|
135
|
+
return metadataUpdater;
|
|
123
136
|
}
|
|
124
137
|
/**
|
|
125
138
|
* Appends a value to an array in the metadata of the current run.
|
|
@@ -134,7 +147,8 @@ function decrementMetadataKey(key, value = 1) {
|
|
|
134
147
|
* metadata.append("events", { type: "click", timestamp: Date.now() });
|
|
135
148
|
*/
|
|
136
149
|
function appendMetadataKey(key, value) {
|
|
137
|
-
runMetadata.
|
|
150
|
+
runMetadata.append(key, value);
|
|
151
|
+
return metadataUpdater;
|
|
138
152
|
}
|
|
139
153
|
/**
|
|
140
154
|
* Removes a value from an array in the metadata of the current run.
|
|
@@ -148,7 +162,8 @@ function appendMetadataKey(key, value) {
|
|
|
148
162
|
* metadata.remove("events", { type: "click", timestamp: Date.now() });
|
|
149
163
|
*/
|
|
150
164
|
function removeMetadataKey(key, value) {
|
|
151
|
-
runMetadata.
|
|
165
|
+
runMetadata.remove(key, value);
|
|
166
|
+
return metadataUpdater;
|
|
152
167
|
}
|
|
153
168
|
/**
|
|
154
169
|
* Flushes metadata to the Trigger.dev instance
|
|
@@ -164,7 +179,24 @@ async function flushMetadata(requestOptions) {
|
|
|
164
179
|
}, requestOptions);
|
|
165
180
|
await runMetadata.flush($requestOptions);
|
|
166
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Refreshes metadata from the Trigger.dev instance
|
|
184
|
+
*
|
|
185
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
186
|
+
* @returns {Promise<void>} A promise that resolves when the metadata refresh operation is complete.
|
|
187
|
+
*/
|
|
188
|
+
async function refreshMetadata(requestOptions) {
|
|
189
|
+
const $requestOptions = mergeRequestOptions({
|
|
190
|
+
tracer,
|
|
191
|
+
name: "metadata.refresh()",
|
|
192
|
+
icon: "code-plus",
|
|
193
|
+
}, requestOptions);
|
|
194
|
+
await runMetadata.refresh($requestOptions);
|
|
195
|
+
}
|
|
167
196
|
async function stream(key, value, signal) {
|
|
168
197
|
return runMetadata.stream(key, value, signal);
|
|
169
198
|
}
|
|
199
|
+
async function fetchStream(key, signal) {
|
|
200
|
+
return runMetadata.fetchStream(key, signal);
|
|
201
|
+
}
|
|
170
202
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EACnB,WAAW,GAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,qBAAqB,GAAuB,WAAW,CAAC,MAAM,CAAC;AACrE,MAAM,mBAAmB,GAAuB,WAAW,CAAC,IAAI,CAAC;AAEjE;;;;;;;;GAQG;AAEH,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,iBAAiB;IACtB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,oBAAoB;IAC/B,SAAS,EAAE,oBAAoB;IAC/B,KAAK,EAAE,aAAa;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,eAAe;IACxB,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,qBAAqB;IAC7B,IAAI,EAAE,mBAAmB;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AAC,CAAC;IAC/B,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,iBAAiB,CAAC,GAAW,EAAE,KAAuB;IAC7D,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,eAAe,CAAC;AACzB,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;;;;;GAKG;AACH,KAAK,UAAU,eAAe,CAAC,cAAkC;IAC/D,MAAM,eAAe,GAAG,mBAAmB,CACzC;QACE,MAAM;QACN,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,WAAW;KAClB,EACD,cAAc,CACf,CAAC;IAEF,MAAM,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7C,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;AAED,KAAK,UAAU,WAAW,CAAI,GAAW,EAAE,MAAoB;IAC7D,OAAO,WAAW,CAAC,WAAW,CAAI,GAAG,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/esm/v3/runs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle } from "@trigger.dev/core/v3";
|
|
1
|
+
import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle, AsyncIterableStream } 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
4
|
export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, AnyRealtimeRun, };
|
|
@@ -12,6 +12,7 @@ export declare const runs: {
|
|
|
12
12
|
subscribeToRun: typeof subscribeToRun;
|
|
13
13
|
subscribeToRunsWithTag: typeof subscribeToRunsWithTag;
|
|
14
14
|
subscribeToBatch: typeof subscribeToRunsInBatch;
|
|
15
|
+
fetchStream: typeof fetchStream;
|
|
15
16
|
};
|
|
16
17
|
export type ListRunsItem = ListRunResponseItem;
|
|
17
18
|
declare function listRuns(projectRef: string, params?: ListProjectRunsQueryParams, requestOptions?: ApiRequestOptions): CursorPagePromise<typeof ListRunResponseItem>;
|
|
@@ -177,6 +178,16 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
177
178
|
output?: InferRunTypes<TRunId>["output"] | undefined;
|
|
178
179
|
payload?: InferRunTypes<TRunId>["payload"] | undefined;
|
|
179
180
|
}>;
|
|
181
|
+
export type SubscribeToRunOptions = {
|
|
182
|
+
/**
|
|
183
|
+
* Whether to close the subscription when the run completes
|
|
184
|
+
*
|
|
185
|
+
* @default true
|
|
186
|
+
*
|
|
187
|
+
* Set this to false if you are making updates to the run metadata after completion through child runs
|
|
188
|
+
*/
|
|
189
|
+
stopOnCompletion?: boolean;
|
|
190
|
+
};
|
|
180
191
|
/**
|
|
181
192
|
* Subscribes to real-time updates for a specific run.
|
|
182
193
|
*
|
|
@@ -187,6 +198,8 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
187
198
|
*
|
|
188
199
|
* @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
|
|
189
200
|
* @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
|
|
201
|
+
* @param {SubscribeToRunOptions} [options] - Optional configuration for the subscription
|
|
202
|
+
* @param {boolean} [options.stopOnCompletion=true] - Whether to close the subscription when the run completes
|
|
190
203
|
* @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
|
|
191
204
|
*
|
|
192
205
|
* @example
|
|
@@ -206,7 +219,7 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
|
|
|
206
219
|
* }
|
|
207
220
|
* ```
|
|
208
221
|
*/
|
|
209
|
-
declare function subscribeToRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId
|
|
222
|
+
declare function subscribeToRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId>, options?: SubscribeToRunOptions): RunSubscription<InferRunTypes<TRunId>>;
|
|
210
223
|
/**
|
|
211
224
|
* Subscribes to real-time updates for all runs that have specific tags.
|
|
212
225
|
*
|
|
@@ -268,3 +281,7 @@ declare function subscribeToRunsWithTag<TTasks extends AnyTask>(tag: string | st
|
|
|
268
281
|
* createdAt, updatedAt, tags, and more. See the Run object documentation for full details.
|
|
269
282
|
*/
|
|
270
283
|
declare function subscribeToRunsInBatch<TTasks extends AnyTask>(batchId: string): RunSubscription<InferRunTypes<TTasks>>;
|
|
284
|
+
/**
|
|
285
|
+
* Fetches a stream of data from a run's stream key.
|
|
286
|
+
*/
|
|
287
|
+
declare function fetchStream<T>(runId: string, streamKey: string): Promise<AsyncIterableStream<T>>;
|
package/dist/esm/v3/runs.js
CHANGED
|
@@ -11,6 +11,7 @@ export const runs = {
|
|
|
11
11
|
subscribeToRun,
|
|
12
12
|
subscribeToRunsWithTag,
|
|
13
13
|
subscribeToBatch: subscribeToRunsInBatch,
|
|
14
|
+
fetchStream,
|
|
14
15
|
};
|
|
15
16
|
function listRuns(paramsOrProjectRef, paramsOrOptions, requestOptions) {
|
|
16
17
|
const apiClient = apiClientManager.clientOrThrow();
|
|
@@ -203,6 +204,8 @@ async function poll(runId, options, requestOptions) {
|
|
|
203
204
|
*
|
|
204
205
|
* @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
|
|
205
206
|
* @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
|
|
207
|
+
* @param {SubscribeToRunOptions} [options] - Optional configuration for the subscription
|
|
208
|
+
* @param {boolean} [options.stopOnCompletion=true] - Whether to close the subscription when the run completes
|
|
206
209
|
* @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
|
|
207
210
|
*
|
|
208
211
|
* @example
|
|
@@ -222,10 +225,12 @@ async function poll(runId, options, requestOptions) {
|
|
|
222
225
|
* }
|
|
223
226
|
* ```
|
|
224
227
|
*/
|
|
225
|
-
function subscribeToRun(runId) {
|
|
228
|
+
function subscribeToRun(runId, options) {
|
|
226
229
|
const $runId = typeof runId === "string" ? runId : runId.id;
|
|
227
230
|
const apiClient = apiClientManager.clientOrThrow();
|
|
228
|
-
return apiClient.subscribeToRun($runId
|
|
231
|
+
return apiClient.subscribeToRun($runId, {
|
|
232
|
+
closeOnComplete: typeof options?.stopOnCompletion === "boolean" ? options.stopOnCompletion : true,
|
|
233
|
+
});
|
|
229
234
|
}
|
|
230
235
|
/**
|
|
231
236
|
* Subscribes to real-time updates for all runs that have specific tags.
|
|
@@ -294,4 +299,11 @@ function subscribeToRunsInBatch(batchId) {
|
|
|
294
299
|
const apiClient = apiClientManager.clientOrThrow();
|
|
295
300
|
return apiClient.subscribeToBatch(batchId);
|
|
296
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Fetches a stream of data from a run's stream key.
|
|
304
|
+
*/
|
|
305
|
+
async function fetchStream(runId, streamKey) {
|
|
306
|
+
const apiClient = apiClientManager.clientOrThrow();
|
|
307
|
+
return await apiClient.fetchStream(runId, streamKey);
|
|
308
|
+
}
|
|
297
309
|
//# sourceMappingURL=runs.js.map
|
package/dist/esm/v3/runs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":"AAiBA,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;AAYrC,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;IACtB,gBAAgB,EAAE,sBAAsB;IACxC,WAAW;CACZ,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,kBAAkB,EAClB,eAAe,EACf,cAAc,CACf,CAAC;IAEF,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC,eAAe,CAAC,kBAAkB,EAAE,EAAE,EA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U,WAAW,CAAI,KAAa,EAAE,SAAiB;IAC5D,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.3.
|
|
1
|
+
export const VERSION = "3.3.10";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.10",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@opentelemetry/api": "1.9.0",
|
|
41
41
|
"@opentelemetry/api-logs": "0.52.1",
|
|
42
42
|
"@opentelemetry/semantic-conventions": "1.25.1",
|
|
43
|
-
"@trigger.dev/core": "3.3.
|
|
43
|
+
"@trigger.dev/core": "3.3.10",
|
|
44
44
|
"chalk": "^5.2.0",
|
|
45
45
|
"cronstrue": "^2.21.0",
|
|
46
46
|
"debug": "^4.3.4",
|