@trigger.dev/sdk 3.0.13 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/v3/auth.d.ts +104 -0
- package/dist/commonjs/v3/auth.js +99 -0
- package/dist/commonjs/v3/auth.js.map +1 -0
- package/dist/commonjs/v3/idempotencyKeys.d.ts +2 -7
- package/dist/commonjs/v3/idempotencyKeys.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +2 -19
- package/dist/commonjs/v3/index.js +16 -35
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/metadata.d.ts +20 -12
- package/dist/commonjs/v3/metadata.js +28 -53
- package/dist/commonjs/v3/metadata.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +36 -759
- package/dist/commonjs/v3/runs.js +12 -1
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +9 -380
- package/dist/commonjs/v3/shared.js +99 -54
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/tasks.d.ts +5 -5
- package/dist/commonjs/v3/tasks.js +3 -5
- package/dist/commonjs/v3/tasks.js.map +1 -1
- package/dist/commonjs/v3/tracer.d.ts +1 -1
- package/dist/commonjs/v3/tracer.js +2 -2
- package/dist/commonjs/v3/tracer.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/auth.d.ts +104 -0
- package/dist/esm/v3/auth.js +95 -0
- package/dist/esm/v3/auth.js.map +1 -0
- package/dist/esm/v3/idempotencyKeys.d.ts +2 -7
- package/dist/esm/v3/idempotencyKeys.js.map +1 -1
- package/dist/esm/v3/index-browser.d.mts +2 -0
- package/dist/esm/v3/index-browser.mjs +3 -0
- package/dist/esm/v3/index-browser.mjs.map +1 -0
- package/dist/esm/v3/index.d.ts +2 -19
- package/dist/esm/v3/index.js +2 -22
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/metadata.d.ts +20 -12
- package/dist/esm/v3/metadata.js +29 -54
- package/dist/esm/v3/metadata.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +34 -757
- package/dist/esm/v3/runs.js +12 -1
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +9 -380
- package/dist/esm/v3/shared.js +96 -51
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/tasks.d.ts +5 -5
- package/dist/esm/v3/tasks.js +3 -4
- package/dist/esm/v3/tasks.js.map +1 -1
- package/dist/esm/v3/tracer.d.ts +1 -1
- package/dist/esm/v3/tracer.js +1 -1
- package/dist/esm/v3/tracer.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type ApiClientConfiguration } from "@trigger.dev/core/v3";
|
|
2
|
+
/**
|
|
3
|
+
* Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
|
|
4
|
+
* @param options The API client configuration.
|
|
5
|
+
* @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
|
|
6
|
+
* @param options.accessToken The accessToken to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { configure } from "@trigger.dev/sdk/v3";
|
|
12
|
+
*
|
|
13
|
+
* configure({
|
|
14
|
+
* baseURL: "https://api.trigger.dev",
|
|
15
|
+
* accessToken: "tr_dev_1234567890"
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function configure(options: ApiClientConfiguration): void;
|
|
20
|
+
export declare const auth: {
|
|
21
|
+
configure: typeof configure;
|
|
22
|
+
createPublicToken: typeof createPublicToken;
|
|
23
|
+
withAuth: typeof withAuth;
|
|
24
|
+
};
|
|
25
|
+
type PublicTokenPermissionAction = "read";
|
|
26
|
+
type PublicTokenPermissionProperties = {
|
|
27
|
+
/**
|
|
28
|
+
* Grant access to specific tasks
|
|
29
|
+
*/
|
|
30
|
+
tasks?: string | string[];
|
|
31
|
+
/**
|
|
32
|
+
* Grant access to specific run tags
|
|
33
|
+
*/
|
|
34
|
+
tags?: string | string[];
|
|
35
|
+
/**
|
|
36
|
+
* Grant access to specific runs
|
|
37
|
+
*/
|
|
38
|
+
runs?: string | string[] | true;
|
|
39
|
+
/**
|
|
40
|
+
* Grant access to specific batch runs
|
|
41
|
+
*/
|
|
42
|
+
batch?: string | string[];
|
|
43
|
+
};
|
|
44
|
+
export type PublicTokenPermissions = {
|
|
45
|
+
[key in PublicTokenPermissionAction]?: PublicTokenPermissionProperties;
|
|
46
|
+
};
|
|
47
|
+
export type CreatePublicTokenOptions = {
|
|
48
|
+
/**
|
|
49
|
+
* A collection of permission scopes to be granted to the token.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
*
|
|
53
|
+
* ```typescript
|
|
54
|
+
* scopes: {
|
|
55
|
+
* read: {
|
|
56
|
+
* tags: ["file:1234"]
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
scopes?: PublicTokenPermissions;
|
|
62
|
+
/**
|
|
63
|
+
* The expiration time for the token. This can be a number representing the time in milliseconds, a `Date` object, or a string.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
*
|
|
67
|
+
* ```typescript
|
|
68
|
+
* expirationTime: "1h"
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
expirationTime?: number | Date | string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Creates a public token using the provided options.
|
|
75
|
+
*
|
|
76
|
+
* @param options - Optional parameters for creating the public token.
|
|
77
|
+
* @param options.scopes - An array of permission scopes to be included in the token.
|
|
78
|
+
* @param options.expirationTime - The expiration time for the token.
|
|
79
|
+
* @returns A promise that resolves to a string representing the generated public token.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { auth } from "@trigger.dev/sdk/v3";
|
|
85
|
+
*
|
|
86
|
+
* const publicToken = await auth.createPublicToken({
|
|
87
|
+
* scopes: {
|
|
88
|
+
* read: {
|
|
89
|
+
* tags: ["file:1234"]
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
declare function createPublicToken(options?: CreatePublicTokenOptions): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Executes a provided asynchronous function with a specified API client configuration.
|
|
97
|
+
*
|
|
98
|
+
* @template R - The type of the asynchronous function to be executed.
|
|
99
|
+
* @param {ApiClientConfiguration} config - The configuration for the API client.
|
|
100
|
+
* @param {R} fn - The asynchronous function to be executed.
|
|
101
|
+
* @returns {Promise<ReturnType<R>>} A promise that resolves to the return type of the provided function.
|
|
102
|
+
*/
|
|
103
|
+
declare function withAuth<R extends (...args: any[]) => Promise<any>>(config: ApiClientConfiguration, fn: R): Promise<ReturnType<R>>;
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.auth = void 0;
|
|
4
|
+
exports.configure = configure;
|
|
5
|
+
const v3_1 = require("@trigger.dev/core/v3");
|
|
6
|
+
const v3_2 = require("@trigger.dev/core/v3");
|
|
7
|
+
/**
|
|
8
|
+
* Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
|
|
9
|
+
* @param options The API client configuration.
|
|
10
|
+
* @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
|
|
11
|
+
* @param options.accessToken The accessToken to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { configure } from "@trigger.dev/sdk/v3";
|
|
17
|
+
*
|
|
18
|
+
* configure({
|
|
19
|
+
* baseURL: "https://api.trigger.dev",
|
|
20
|
+
* accessToken: "tr_dev_1234567890"
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function configure(options) {
|
|
25
|
+
v3_1.apiClientManager.setGlobalAPIClientConfiguration(options);
|
|
26
|
+
}
|
|
27
|
+
exports.auth = {
|
|
28
|
+
configure,
|
|
29
|
+
createPublicToken,
|
|
30
|
+
withAuth,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates a public token using the provided options.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Optional parameters for creating the public token.
|
|
36
|
+
* @param options.scopes - An array of permission scopes to be included in the token.
|
|
37
|
+
* @param options.expirationTime - The expiration time for the token.
|
|
38
|
+
* @returns A promise that resolves to a string representing the generated public token.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
*
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { auth } from "@trigger.dev/sdk/v3";
|
|
44
|
+
*
|
|
45
|
+
* const publicToken = await auth.createPublicToken({
|
|
46
|
+
* scopes: {
|
|
47
|
+
* read: {
|
|
48
|
+
* tags: ["file:1234"]
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async function createPublicToken(options) {
|
|
54
|
+
const apiClient = v3_1.apiClientManager.clientOrThrow();
|
|
55
|
+
const claims = await apiClient.generateJWTClaims();
|
|
56
|
+
return await (0, v3_2.generateJWT)({
|
|
57
|
+
secretKey: apiClient.accessToken,
|
|
58
|
+
payload: {
|
|
59
|
+
...claims,
|
|
60
|
+
scopes: options?.scopes ? flattenScopes(options.scopes) : undefined,
|
|
61
|
+
},
|
|
62
|
+
expirationTime: options?.expirationTime,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Executes a provided asynchronous function with a specified API client configuration.
|
|
67
|
+
*
|
|
68
|
+
* @template R - The type of the asynchronous function to be executed.
|
|
69
|
+
* @param {ApiClientConfiguration} config - The configuration for the API client.
|
|
70
|
+
* @param {R} fn - The asynchronous function to be executed.
|
|
71
|
+
* @returns {Promise<ReturnType<R>>} A promise that resolves to the return type of the provided function.
|
|
72
|
+
*/
|
|
73
|
+
async function withAuth(config, fn) {
|
|
74
|
+
return v3_1.apiClientManager.runWithConfig(config, fn);
|
|
75
|
+
}
|
|
76
|
+
function flattenScopes(permissions) {
|
|
77
|
+
const flattenedPermissions = [];
|
|
78
|
+
for (const [action, properties] of Object.entries(permissions)) {
|
|
79
|
+
if (properties) {
|
|
80
|
+
if (typeof properties === "boolean" && properties) {
|
|
81
|
+
flattenedPermissions.push(action);
|
|
82
|
+
}
|
|
83
|
+
else if (typeof properties === "object") {
|
|
84
|
+
for (const [property, value] of Object.entries(properties)) {
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
for (const item of value) {
|
|
87
|
+
flattenedPermissions.push(`${action}:${property}:${item}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (typeof value === "string") {
|
|
91
|
+
flattenedPermissions.push(`${action}:${property}:${value}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return flattenedPermissions;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/v3/auth.ts"],"names":[],"mappings":";;;AAoBA,8BAEC;AAtBD,6CAAqF;AACrF,6CAA2E;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,SAAS,CAAC,OAA+B;IACvD,qBAAgB,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C,EAAE,CAAC;oBAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;wBACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;4BACzB,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;wBAC7D,CAAC;oBACH,CAAC;yBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBACrC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { type IdempotencyKey } from "@trigger.dev/core/v3";
|
|
1
2
|
export declare const idempotencyKeys: {
|
|
2
3
|
create: typeof createIdempotencyKey;
|
|
3
4
|
};
|
|
4
|
-
|
|
5
|
-
type Brand<B> = {
|
|
6
|
-
[__brand]: B;
|
|
7
|
-
};
|
|
8
|
-
type Branded<T, B> = T & Brand<B>;
|
|
9
|
-
export type IdempotencyKey = Branded<string, "IdempotencyKey">;
|
|
5
|
+
export type { IdempotencyKey };
|
|
10
6
|
export declare function isIdempotencyKey(value: string | string[] | IdempotencyKey): value is IdempotencyKey;
|
|
11
7
|
/**
|
|
12
8
|
* Creates a deterministic idempotency key based on the provided key material.
|
|
@@ -46,4 +42,3 @@ export declare function isIdempotencyKey(value: string | string[] | IdempotencyK
|
|
|
46
42
|
declare function createIdempotencyKey(key: string | string[], options?: {
|
|
47
43
|
scope?: "run" | "attempt" | "global";
|
|
48
44
|
}): Promise<IdempotencyKey>;
|
|
49
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idempotencyKeys.js","sourceRoot":"","sources":["../../../src/v3/idempotencyKeys.ts"],"names":[],"mappings":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AsB,CAAC,WAAqB;IACzD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CACrC,SAAS,EACT,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAChD,CAAC;IAEF,8DAA8D;IAC9D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;SACpC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -14,25 +14,8 @@ import type { Context } from "./shared.js";
|
|
|
14
14
|
import type { ApiClientConfiguration } from "@trigger.dev/core/v3";
|
|
15
15
|
export type { ApiClientConfiguration };
|
|
16
16
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, logger, type LogLevel, } from "@trigger.dev/core/v3";
|
|
17
|
-
export { runs } from "./runs.js";
|
|
17
|
+
export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RetrieveRunResult, type AnyRetrieveRunResult, } from "./runs.js";
|
|
18
18
|
export * as schedules from "./schedules/index.js";
|
|
19
19
|
export * as envvars from "./envvars.js";
|
|
20
20
|
export type { ImportEnvironmentVariablesParams } from "./envvars.js";
|
|
21
|
-
|
|
22
|
-
* Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
|
|
23
|
-
* @param options The API client configuration.
|
|
24
|
-
* @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
|
|
25
|
-
* @param options.secretKey The secret key to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
*
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { configure } from "@trigger.dev/sdk/v3";
|
|
31
|
-
*
|
|
32
|
-
* configure({
|
|
33
|
-
* baseURL: "https://api.trigger.dev",
|
|
34
|
-
* secretKey: "tr_dev_1234567890"
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function configure(options: ApiClientConfiguration): void;
|
|
21
|
+
export { configure, auth } from "./auth.js";
|
|
@@ -26,8 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.envvars = exports.schedules = exports.runs = exports.logger = exports.AbortTaskRunError = exports.UnprocessableEntityError = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.InternalServerError = exports.ConflictError = exports.BadRequestError = exports.AuthenticationError = exports.ApiError = exports.queue = exports.retry = void 0;
|
|
30
|
-
exports.configure = configure;
|
|
29
|
+
exports.auth = exports.configure = exports.envvars = exports.schedules = exports.runs = exports.logger = exports.AbortTaskRunError = exports.UnprocessableEntityError = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.InternalServerError = exports.ConflictError = exports.BadRequestError = exports.AuthenticationError = exports.ApiError = exports.queue = exports.retry = void 0;
|
|
31
30
|
__exportStar(require("./cache.js"), exports);
|
|
32
31
|
__exportStar(require("./config.js"), exports);
|
|
33
32
|
var retry_js_1 = require("./retry.js");
|
|
@@ -41,41 +40,23 @@ __exportStar(require("./idempotencyKeys.js"), exports);
|
|
|
41
40
|
__exportStar(require("./tags.js"), exports);
|
|
42
41
|
__exportStar(require("./metadata.js"), exports);
|
|
43
42
|
__exportStar(require("./timeout.js"), exports);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Object.defineProperty(exports, "
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
Object.defineProperty(exports, "
|
|
49
|
-
Object.defineProperty(exports, "
|
|
50
|
-
Object.defineProperty(exports, "
|
|
51
|
-
Object.defineProperty(exports, "
|
|
52
|
-
Object.defineProperty(exports, "
|
|
53
|
-
Object.defineProperty(exports, "
|
|
54
|
-
Object.defineProperty(exports, "
|
|
55
|
-
Object.defineProperty(exports, "
|
|
56
|
-
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return v3_2.logger; } });
|
|
43
|
+
var v3_1 = require("@trigger.dev/core/v3");
|
|
44
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return v3_1.ApiError; } });
|
|
45
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return v3_1.AuthenticationError; } });
|
|
46
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return v3_1.BadRequestError; } });
|
|
47
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return v3_1.ConflictError; } });
|
|
48
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return v3_1.InternalServerError; } });
|
|
49
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return v3_1.NotFoundError; } });
|
|
50
|
+
Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return v3_1.PermissionDeniedError; } });
|
|
51
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return v3_1.RateLimitError; } });
|
|
52
|
+
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return v3_1.UnprocessableEntityError; } });
|
|
53
|
+
Object.defineProperty(exports, "AbortTaskRunError", { enumerable: true, get: function () { return v3_1.AbortTaskRunError; } });
|
|
54
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return v3_1.logger; } });
|
|
57
55
|
var runs_js_1 = require("./runs.js");
|
|
58
56
|
Object.defineProperty(exports, "runs", { enumerable: true, get: function () { return runs_js_1.runs; } });
|
|
59
57
|
exports.schedules = __importStar(require("./schedules/index.js"));
|
|
60
58
|
exports.envvars = __importStar(require("./envvars.js"));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
|
|
65
|
-
* @param options.secretKey The secret key to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
*
|
|
69
|
-
* ```typescript
|
|
70
|
-
* import { configure } from "@trigger.dev/sdk/v3";
|
|
71
|
-
*
|
|
72
|
-
* configure({
|
|
73
|
-
* baseURL: "https://api.trigger.dev",
|
|
74
|
-
* secretKey: "tr_dev_1234567890"
|
|
75
|
-
* });
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
function configure(options) {
|
|
79
|
-
v3_1.apiClientManager.setGlobalAPIClientConfiguration(options);
|
|
80
|
-
}
|
|
59
|
+
var auth_js_1 = require("./auth.js");
|
|
60
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return auth_js_1.configure; } });
|
|
61
|
+
Object.defineProperty(exports, "auth", { enumerable: true, get: function () { return auth_js_1.auth; } });
|
|
81
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,uCAAsD;AAA7C,iGAAA,KAAK,OAAA;AACd,yCAAoC;AAA3B,kGAAA,KAAK,OAAA;AACd,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,uDAAqC;AACrC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAS7B,2CAa8B;AAZ5B,8FAAA,QAAQ,OAAA;AACR,yGAAA,mBAAmB,OAAA;AACnB,qGAAA,eAAe,OAAA;AACf,mGAAA,aAAa,OAAA;AACb,yGAAA,mBAAmB,OAAA;AACnB,mGAAA,aAAa,OAAA;AACb,2GAAA,qBAAqB,OAAA;AACrB,oGAAA,cAAc,OAAA;AACd,8GAAA,wBAAwB,OAAA;AACxB,uGAAA,iBAAiB,OAAA;AACjB,4FAAA,MAAM,OAAA;AAIR,qCAOmB;AANjB,+FAAA,IAAI,OAAA;AAON,kEAAkD;AAClD,wDAAwC;AAGxC,qCAA4C;AAAnC,oGAAA,SAAS,OAAA;AAAE,+FAAA,IAAI,OAAA"}
|
|
@@ -15,6 +15,8 @@ export declare const metadata: {
|
|
|
15
15
|
set: typeof setMetadataKey;
|
|
16
16
|
del: typeof deleteMetadataKey;
|
|
17
17
|
save: typeof saveMetadata;
|
|
18
|
+
replace: typeof replaceMetadata;
|
|
19
|
+
flush: typeof flushMetadata;
|
|
18
20
|
};
|
|
19
21
|
export type RunMetadata = Record<string, DeserializedJson>;
|
|
20
22
|
/**
|
|
@@ -46,34 +48,40 @@ declare function getMetadataKey(key: string): DeserializedJson | undefined;
|
|
|
46
48
|
*
|
|
47
49
|
* @param {string} key - The key to set in the metadata.
|
|
48
50
|
* @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
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
*
|
|
53
|
+
* metadata.set("progress", 0.5);
|
|
54
54
|
*/
|
|
55
|
-
declare function setMetadataKey(key: string, value: DeserializedJson
|
|
55
|
+
declare function setMetadataKey(key: string, value: DeserializedJson): void;
|
|
56
56
|
/**
|
|
57
57
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
58
58
|
*
|
|
59
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
60
|
*
|
|
63
61
|
* @example
|
|
64
|
-
*
|
|
62
|
+
* metadata.del("progress");
|
|
65
63
|
*/
|
|
66
|
-
declare function deleteMetadataKey(key: string
|
|
64
|
+
declare function deleteMetadataKey(key: string): void;
|
|
67
65
|
/**
|
|
68
66
|
* Update the entire metadata object for the current run if inside a task run.
|
|
69
67
|
* This function allows you to replace the entire metadata object with a new one.
|
|
70
68
|
*
|
|
71
69
|
* @param {RunMetadata} metadata - The new metadata object to set for the run.
|
|
72
|
-
* @
|
|
73
|
-
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
70
|
+
* @returns {void}
|
|
74
71
|
*
|
|
75
72
|
* @example
|
|
76
|
-
*
|
|
73
|
+
* metadata.replace({ progress: 0.6, user: { name: "Alice", id: "user_5678" } });
|
|
77
74
|
*/
|
|
78
|
-
declare function
|
|
75
|
+
declare function replaceMetadata(metadata: RunMetadata): void;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use `metadata.replace()` instead.
|
|
78
|
+
*/
|
|
79
|
+
declare function saveMetadata(metadata: RunMetadata): void;
|
|
80
|
+
/**
|
|
81
|
+
* Flushes metadata to the Trigger.dev instance
|
|
82
|
+
*
|
|
83
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
84
|
+
* @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
|
|
85
|
+
*/
|
|
86
|
+
declare function flushMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
|
|
79
87
|
export {};
|
|
@@ -18,6 +18,8 @@ exports.metadata = {
|
|
|
18
18
|
set: setMetadataKey,
|
|
19
19
|
del: deleteMetadataKey,
|
|
20
20
|
save: saveMetadata,
|
|
21
|
+
replace: replaceMetadata,
|
|
22
|
+
flush: flushMetadata,
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
25
|
* Returns the metadata of the current run if inside a task run.
|
|
@@ -52,82 +54,55 @@ function getMetadataKey(key) {
|
|
|
52
54
|
*
|
|
53
55
|
* @param {string} key - The key to set in the metadata.
|
|
54
56
|
* @param {DeserializedJson} value - The value to associate with the key.
|
|
55
|
-
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
56
|
-
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
59
|
-
*
|
|
59
|
+
* metadata.set("progress", 0.5);
|
|
60
60
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
tracer: tracer_js_1.tracer,
|
|
64
|
-
name: "metadata.set()",
|
|
65
|
-
icon: "code-plus",
|
|
66
|
-
attributes: {
|
|
67
|
-
...(0, v3_1.accessoryAttributes)({
|
|
68
|
-
items: [
|
|
69
|
-
{
|
|
70
|
-
text: key,
|
|
71
|
-
variant: "normal",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
style: "codepath",
|
|
75
|
-
}),
|
|
76
|
-
...(0, v3_1.flattenAttributes)(value, key),
|
|
77
|
-
},
|
|
78
|
-
}, requestOptions);
|
|
79
|
-
await v3_1.runMetadata.setKey(key, value, $requestOptions);
|
|
61
|
+
function setMetadataKey(key, value) {
|
|
62
|
+
v3_1.runMetadata.setKey(key, value);
|
|
80
63
|
}
|
|
81
64
|
/**
|
|
82
65
|
* Delete a key from the metadata of the current run if inside a task run.
|
|
83
66
|
*
|
|
84
67
|
* @param {string} key - The key to delete from the metadata.
|
|
85
|
-
* @param {ApiRequestOptions} [requestOptions] - Optional API request options.
|
|
86
|
-
* @returns {Promise<void>} A promise that resolves when the key is deleted from the metadata.
|
|
87
68
|
*
|
|
88
69
|
* @example
|
|
89
|
-
*
|
|
70
|
+
* metadata.del("progress");
|
|
90
71
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
tracer: tracer_js_1.tracer,
|
|
94
|
-
name: "metadata.del()",
|
|
95
|
-
icon: "code-minus",
|
|
96
|
-
attributes: {
|
|
97
|
-
...(0, v3_1.accessoryAttributes)({
|
|
98
|
-
items: [
|
|
99
|
-
{
|
|
100
|
-
text: key,
|
|
101
|
-
variant: "normal",
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
style: "codepath",
|
|
105
|
-
}),
|
|
106
|
-
key,
|
|
107
|
-
},
|
|
108
|
-
}, requestOptions);
|
|
109
|
-
await v3_1.runMetadata.deleteKey(key, $requestOptions);
|
|
72
|
+
function deleteMetadataKey(key) {
|
|
73
|
+
v3_1.runMetadata.deleteKey(key);
|
|
110
74
|
}
|
|
111
75
|
/**
|
|
112
76
|
* Update the entire metadata object for the current run if inside a task run.
|
|
113
77
|
* This function allows you to replace the entire metadata object with a new one.
|
|
114
78
|
*
|
|
115
79
|
* @param {RunMetadata} metadata - The new metadata object to set for the run.
|
|
116
|
-
* @
|
|
117
|
-
* @returns {Promise<void>} A promise that resolves when the metadata is updated.
|
|
80
|
+
* @returns {void}
|
|
118
81
|
*
|
|
119
82
|
* @example
|
|
120
|
-
*
|
|
83
|
+
* metadata.replace({ progress: 0.6, user: { name: "Alice", id: "user_5678" } });
|
|
84
|
+
*/
|
|
85
|
+
function replaceMetadata(metadata) {
|
|
86
|
+
v3_1.runMetadata.update(metadata);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use `metadata.replace()` instead.
|
|
90
|
+
*/
|
|
91
|
+
function saveMetadata(metadata) {
|
|
92
|
+
v3_1.runMetadata.update(metadata);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Flushes metadata to the Trigger.dev instance
|
|
96
|
+
*
|
|
97
|
+
* @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
|
|
98
|
+
* @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
|
|
121
99
|
*/
|
|
122
|
-
async function
|
|
100
|
+
async function flushMetadata(requestOptions) {
|
|
123
101
|
const $requestOptions = (0, v3_1.mergeRequestOptions)({
|
|
124
102
|
tracer: tracer_js_1.tracer,
|
|
125
|
-
name: "metadata.
|
|
103
|
+
name: "metadata.flush()",
|
|
126
104
|
icon: "code-plus",
|
|
127
|
-
attributes: {
|
|
128
|
-
...(0, v3_1.flattenAttributes)(metadata),
|
|
129
|
-
},
|
|
130
105
|
}, requestOptions);
|
|
131
|
-
await v3_1.runMetadata.
|
|
106
|
+
await v3_1.runMetadata.flush($requestOptions);
|
|
132
107
|
}
|
|
133
108
|
//# 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,6CAK8B;AAC9B,2CAAqC;AAErC;;;;;;;;GAQG;AAEU,QAAA,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;CACrB,CAAC;AAIF;;;;;;;;;GASG;AACH,SAAS,eAAe;IACtB,OAAO,gBAAW,CAAC,OAAO,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,gBAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,cAAc,CAAC,GAAW,EAAE,KAAuB;IAC1D,gBAAW,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,gBAAW,CAAC,S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