@trigger.dev/sdk 0.0.0-prerelease-20240920143613 → 0.0.0-prerelease-20240926084729
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/envvars.js +6 -25
- package/dist/commonjs/v3/envvars.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +1 -0
- package/dist/commonjs/v3/index.js +1 -0
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/metadata.d.ts +79 -0
- package/dist/commonjs/v3/metadata.js +133 -0
- package/dist/commonjs/v3/metadata.js.map +1 -0
- package/dist/commonjs/v3/runs.d.ts +144 -120
- package/dist/commonjs/v3/runs.js +5 -21
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/schedules/index.js +7 -31
- package/dist/commonjs/v3/schedules/index.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +5 -1
- package/dist/commonjs/v3/shared.js +8 -31
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/tags.js +1 -5
- package/dist/commonjs/v3/tags.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/envvars.js +6 -25
- package/dist/esm/v3/envvars.js.map +1 -1
- package/dist/esm/v3/index.d.ts +1 -0
- package/dist/esm/v3/index.js +1 -0
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/metadata.d.ts +79 -0
- package/dist/esm/v3/metadata.js +130 -0
- package/dist/esm/v3/metadata.js.map +1 -0
- package/dist/esm/v3/runs.d.ts +216 -192
- package/dist/esm/v3/runs.js +5 -21
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/schedules/index.js +8 -32
- package/dist/esm/v3/schedules/index.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +5 -1
- package/dist/esm/v3/shared.js +8 -30
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/tags.js +1 -5
- package/dist/esm/v3/tags.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
*/
|
|
12
|
+
export declare const metadata: {
|
|
13
|
+
current: typeof currentMetadata;
|
|
14
|
+
get: typeof getMetadataKey;
|
|
15
|
+
set: typeof setMetadataKey;
|
|
16
|
+
del: typeof deleteMetadataKey;
|
|
17
|
+
save: typeof saveMetadata;
|
|
18
|
+
};
|
|
19
|
+
export type RunMetadata = Record<string, DeserializedJson>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the metadata of the current run if inside a task run.
|
|
22
|
+
* This function allows you to access the entire metadata object for the current run.
|
|
23
|
+
*
|
|
24
|
+
* @returns {RunMetadata | undefined} The current run's metadata or undefined if not in a run context.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const currentMetadata = metadata.current();
|
|
28
|
+
* console.log(currentMetadata);
|
|
29
|
+
*/
|
|
30
|
+
declare function currentMetadata(): RunMetadata | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get a specific key from the metadata of the current run if inside a task run.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} key - The key to retrieve from the metadata.
|
|
35
|
+
* @returns {DeserializedJson | undefined} The value associated with the key, or undefined if not found or not in a run context.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const user = metadata.get("user");
|
|
39
|
+
* console.log(user.name); // "Eric"
|
|
40
|
+
* console.log(user.id); // "user_1234"
|
|
41
|
+
*/
|
|
42
|
+
declare function getMetadataKey(key: string): DeserializedJson | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Set a key in the metadata of the current run if inside a task run.
|
|
45
|
+
* This function allows you to update or add a new key-value pair to the run's metadata.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} key - The key to set in the metadata.
|
|
48
|
+
* @param {DeserializedJson} value - The value to associate with the key.
|
|
49
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
50
|
+
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* await metadata.set("progress", 0.5);
|
|
54
|
+
*/
|
|
55
|
+
declare function setMetadataKey(key: string, value: DeserializedJson, requestOptions?: ApiRequestOptions): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Delete a key from the metadata of the current run if inside a task run.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} key - The key to delete from the metadata.
|
|
60
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
61
|
+
* @returns {Promise<void>} A promise that resolves when the key is deleted from the metadata.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* await metadata.del("progress");
|
|
65
|
+
*/
|
|
66
|
+
declare function deleteMetadataKey(key: string, requestOptions?: ApiRequestOptions): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Update the entire metadata object for the current run if inside a task run.
|
|
69
|
+
* This function allows you to replace the entire metadata object with a new one.
|
|
70
|
+
*
|
|
71
|
+
* @param {RunMetadata} metadata - The new metadata object to set for the run.
|
|
72
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* await metadata.save({ progress: 0.6, user: { name: "Alice", id: "user_5678" } });
|
|
77
|
+
*/
|
|
78
|
+
declare function saveMetadata(metadata: RunMetadata, requestOptions?: ApiRequestOptions): Promise<void>;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { accessoryAttributes, flattenAttributes, mergeRequestOptions, runMetadata, } from "@trigger.dev/core/v3";
|
|
2
|
+
import { tracer } from "./tracer.js";
|
|
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
|
+
*/
|
|
12
|
+
export const metadata = {
|
|
13
|
+
current: currentMetadata,
|
|
14
|
+
get: getMetadataKey,
|
|
15
|
+
set: setMetadataKey,
|
|
16
|
+
del: deleteMetadataKey,
|
|
17
|
+
save: saveMetadata,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Returns the metadata of the current run if inside a task run.
|
|
21
|
+
* This function allows you to access the entire metadata object for the current run.
|
|
22
|
+
*
|
|
23
|
+
* @returns {RunMetadata | undefined} The current run's metadata or undefined if not in a run context.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const currentMetadata = metadata.current();
|
|
27
|
+
* console.log(currentMetadata);
|
|
28
|
+
*/
|
|
29
|
+
function currentMetadata() {
|
|
30
|
+
return runMetadata.current();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get a specific key from the metadata of the current run if inside a task run.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} key - The key to retrieve from the metadata.
|
|
36
|
+
* @returns {DeserializedJson | undefined} The value associated with the key, or undefined if not found or not in a run context.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const user = metadata.get("user");
|
|
40
|
+
* console.log(user.name); // "Eric"
|
|
41
|
+
* console.log(user.id); // "user_1234"
|
|
42
|
+
*/
|
|
43
|
+
function getMetadataKey(key) {
|
|
44
|
+
return runMetadata.getKey(key);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set a key in the metadata of the current run if inside a task run.
|
|
48
|
+
* This function allows you to update or add a new key-value pair to the run's metadata.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} key - The key to set in the metadata.
|
|
51
|
+
* @param {DeserializedJson} value - The value to associate with the key.
|
|
52
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
53
|
+
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* await metadata.set("progress", 0.5);
|
|
57
|
+
*/
|
|
58
|
+
async function setMetadataKey(key, value, requestOptions) {
|
|
59
|
+
const $requestOptions = mergeRequestOptions({
|
|
60
|
+
tracer,
|
|
61
|
+
name: "metadata.set()",
|
|
62
|
+
icon: "code-plus",
|
|
63
|
+
attributes: {
|
|
64
|
+
...accessoryAttributes({
|
|
65
|
+
items: [
|
|
66
|
+
{
|
|
67
|
+
text: key,
|
|
68
|
+
variant: "normal",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
style: "codepath",
|
|
72
|
+
}),
|
|
73
|
+
...flattenAttributes(value, key),
|
|
74
|
+
},
|
|
75
|
+
}, requestOptions);
|
|
76
|
+
await runMetadata.setKey(key, value, $requestOptions);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Delete a key from the metadata of the current run if inside a task run.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} key - The key to delete from the metadata.
|
|
82
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
83
|
+
* @returns {Promise<void>} A promise that resolves when the key is deleted from the metadata.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* await metadata.del("progress");
|
|
87
|
+
*/
|
|
88
|
+
async function deleteMetadataKey(key, requestOptions) {
|
|
89
|
+
const $requestOptions = mergeRequestOptions({
|
|
90
|
+
tracer,
|
|
91
|
+
name: "metadata.del()",
|
|
92
|
+
icon: "code-minus",
|
|
93
|
+
attributes: {
|
|
94
|
+
...accessoryAttributes({
|
|
95
|
+
items: [
|
|
96
|
+
{
|
|
97
|
+
text: key,
|
|
98
|
+
variant: "normal",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
style: "codepath",
|
|
102
|
+
}),
|
|
103
|
+
key,
|
|
104
|
+
},
|
|
105
|
+
}, requestOptions);
|
|
106
|
+
await runMetadata.deleteKey(key, $requestOptions);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Update the entire metadata object for the current run if inside a task run.
|
|
110
|
+
* This function allows you to replace the entire metadata object with a new one.
|
|
111
|
+
*
|
|
112
|
+
* @param {RunMetadata} metadata - The new metadata object to set for the run.
|
|
113
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
114
|
+
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* await metadata.save({ progress: 0.6, user: { name: "Alice", id: "user_5678" } });
|
|
118
|
+
*/
|
|
119
|
+
async function saveMetadata(metadata, requestOptions) {
|
|
120
|
+
const $requestOptions = mergeRequestOptions({
|
|
121
|
+
tracer,
|
|
122
|
+
name: "metadata.save()",
|
|
123
|
+
icon: "code-plus",
|
|
124
|
+
attributes: {
|
|
125
|
+
...flattenAttributes(metadata),
|
|
126
|
+
},
|
|
127
|
+
}, requestOptions);
|
|
128
|
+
await runMetadata.update(metadata, $requestOptions);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/v3/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,GACZ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