@trigger.dev/core 0.0.0-v3-prerelease-20241105122139 → 0.0.0-v3-prerelease-20241203112040
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/schemas/api.d.ts +1340 -1134
- package/dist/commonjs/schemas/eventFilter.d.ts +4 -4
- package/dist/commonjs/schemas/fetch.d.ts +66 -33
- package/dist/commonjs/schemas/notifications.d.ts +24 -16
- package/dist/commonjs/schemas/requestFilter.d.ts +52 -4
- package/dist/commonjs/schemas/runs.d.ts +29 -13
- package/dist/commonjs/schemas/schedules.d.ts +8 -8
- package/dist/commonjs/schemas/statuses.d.ts +9 -8
- package/dist/commonjs/schemas/tasks.d.ts +32 -31
- package/dist/commonjs/schemas/triggers.d.ts +36 -36
- package/dist/commonjs/v3/apiClient/index.d.ts +159 -135
- package/dist/commonjs/v3/apiClient/index.js +48 -15
- package/dist/commonjs/v3/apiClient/index.js.map +1 -1
- package/dist/commonjs/v3/apiClient/runStream.d.ts +54 -4
- package/dist/commonjs/v3/apiClient/runStream.js +129 -13
- package/dist/commonjs/v3/apiClient/runStream.js.map +1 -1
- package/dist/commonjs/v3/apiClient/stream.js +24 -10
- package/dist/commonjs/v3/apiClient/stream.js.map +1 -1
- package/dist/commonjs/v3/apiClient/types.d.ts +1 -0
- package/dist/commonjs/v3/apiClientManager/index.d.ts +1 -1
- package/dist/commonjs/v3/build/extensions.d.ts +1 -0
- package/dist/commonjs/v3/idempotencyKeys.d.ts +41 -0
- package/dist/commonjs/v3/idempotencyKeys.js +83 -0
- package/dist/commonjs/v3/idempotencyKeys.js.map +1 -0
- package/dist/commonjs/v3/index.d.ts +2 -0
- package/dist/commonjs/v3/index.js +2 -0
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/jwt.d.ts +10 -1
- package/dist/commonjs/v3/jwt.js +17 -4
- package/dist/commonjs/v3/jwt.js.map +1 -1
- package/dist/commonjs/v3/runMetadata/index.d.ts +5 -0
- package/dist/commonjs/v3/runMetadata/index.js +15 -0
- package/dist/commonjs/v3/runMetadata/index.js.map +1 -1
- package/dist/commonjs/v3/runMetadata/manager.d.ts +13 -0
- package/dist/commonjs/v3/runMetadata/manager.js +174 -12
- package/dist/commonjs/v3/runMetadata/manager.js.map +1 -1
- package/dist/commonjs/v3/runMetadata/metadataStream.d.ts +21 -0
- package/dist/commonjs/v3/runMetadata/metadataStream.js +71 -0
- package/dist/commonjs/v3/runMetadata/metadataStream.js.map +1 -0
- package/dist/commonjs/v3/runMetadata/noopManager.d.ts +5 -0
- package/dist/commonjs/v3/runMetadata/noopManager.js +15 -0
- package/dist/commonjs/v3/runMetadata/noopManager.js.map +1 -1
- package/dist/commonjs/v3/runMetadata/types.d.ts +5 -0
- package/dist/commonjs/v3/runtime/devRuntimeManager.js.map +1 -1
- package/dist/commonjs/v3/schemas/api.d.ts +954 -1628
- package/dist/commonjs/v3/schemas/api.js +51 -2
- package/dist/commonjs/v3/schemas/api.js.map +1 -1
- package/dist/commonjs/v3/schemas/build.d.ts +308 -1040
- package/dist/commonjs/v3/schemas/common.d.ts +145 -123
- package/dist/commonjs/v3/schemas/common.js +4 -0
- package/dist/commonjs/v3/schemas/common.js.map +1 -1
- package/dist/commonjs/v3/schemas/eventFilter.d.ts +2 -2
- package/dist/commonjs/v3/schemas/fetch.d.ts +53 -41
- package/dist/commonjs/v3/schemas/messages.d.ts +2705 -4152
- package/dist/commonjs/v3/schemas/openTelemetry.d.ts +22 -22
- package/dist/commonjs/v3/schemas/resources.d.ts +86 -626
- package/dist/commonjs/v3/schemas/resources.js +1 -0
- package/dist/commonjs/v3/schemas/resources.js.map +1 -1
- package/dist/commonjs/v3/schemas/schemas.d.ts +406 -1074
- package/dist/commonjs/v3/schemas/schemas.js +1 -2
- package/dist/commonjs/v3/schemas/schemas.js.map +1 -1
- package/dist/commonjs/v3/schemas/style.d.ts +2 -2
- package/dist/commonjs/v3/types/index.d.ts +1 -0
- package/dist/commonjs/v3/types/index.js +1 -0
- package/dist/commonjs/v3/types/index.js.map +1 -1
- package/dist/commonjs/v3/types/tasks.d.ts +113 -23
- package/dist/commonjs/v3/types/tasks.js.map +1 -1
- package/dist/commonjs/v3/types/tools.d.ts +6 -0
- package/dist/commonjs/v3/types/tools.js +22 -0
- package/dist/commonjs/v3/types/tools.js.map +1 -0
- package/dist/commonjs/v3/utils/getEnv.d.ts +1 -1
- package/dist/commonjs/v3/utils/getEnv.js +3 -3
- package/dist/commonjs/v3/utils/getEnv.js.map +1 -1
- package/dist/commonjs/v3/utils/globals.d.ts +2 -0
- package/dist/commonjs/v3/utils/globals.js.map +1 -1
- package/dist/commonjs/v3/utils/ioSerialization.d.ts +8 -3
- package/dist/commonjs/v3/utils/ioSerialization.js +43 -36
- package/dist/commonjs/v3/utils/ioSerialization.js.map +1 -1
- package/dist/commonjs/v3/wait-until-api.d.ts +2 -0
- package/dist/commonjs/v3/wait-until-api.js +8 -0
- package/dist/commonjs/v3/wait-until-api.js.map +1 -0
- package/dist/commonjs/v3/waitUntil/index.d.ts +11 -0
- package/dist/commonjs/v3/waitUntil/index.js +44 -0
- package/dist/commonjs/v3/waitUntil/index.js.map +1 -0
- package/dist/commonjs/v3/waitUntil/manager.d.ts +8 -0
- package/dist/commonjs/v3/waitUntil/manager.js +28 -0
- package/dist/commonjs/v3/waitUntil/manager.js.map +1 -0
- package/dist/commonjs/v3/waitUntil/types.d.ts +9 -0
- package/dist/commonjs/v3/waitUntil/types.js +3 -0
- package/dist/commonjs/v3/waitUntil/types.js.map +1 -0
- package/dist/commonjs/v3/workers/index.d.ts +1 -0
- package/dist/commonjs/v3/workers/index.js +3 -1
- package/dist/commonjs/v3/workers/index.js.map +1 -1
- package/dist/commonjs/v3/workers/taskExecutor.js +13 -0
- package/dist/commonjs/v3/workers/taskExecutor.js.map +1 -1
- package/dist/commonjs/v3/zodMessageHandler.d.ts +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/schemas/api.d.ts +1340 -1134
- package/dist/esm/schemas/eventFilter.d.ts +4 -4
- package/dist/esm/schemas/fetch.d.ts +66 -33
- package/dist/esm/schemas/notifications.d.ts +24 -16
- package/dist/esm/schemas/requestFilter.d.ts +52 -4
- package/dist/esm/schemas/runs.d.ts +29 -13
- package/dist/esm/schemas/schedules.d.ts +8 -8
- package/dist/esm/schemas/statuses.d.ts +9 -8
- package/dist/esm/schemas/tasks.d.ts +32 -31
- package/dist/esm/schemas/triggers.d.ts +36 -36
- package/dist/esm/v3/apiClient/index.d.ts +159 -135
- package/dist/esm/v3/apiClient/index.js +49 -16
- package/dist/esm/v3/apiClient/index.js.map +1 -1
- package/dist/esm/v3/apiClient/runStream.d.ts +54 -4
- package/dist/esm/v3/apiClient/runStream.js +126 -12
- package/dist/esm/v3/apiClient/runStream.js.map +1 -1
- package/dist/esm/v3/apiClient/stream.js +24 -10
- package/dist/esm/v3/apiClient/stream.js.map +1 -1
- package/dist/esm/v3/apiClient/types.d.ts +1 -0
- package/dist/esm/v3/apiClientManager/index.d.ts +1 -1
- package/dist/esm/v3/build/extensions.d.ts +1 -0
- package/dist/esm/v3/idempotencyKeys.d.ts +41 -0
- package/dist/esm/v3/idempotencyKeys.js +78 -0
- package/dist/esm/v3/idempotencyKeys.js.map +1 -0
- package/dist/esm/v3/index.d.ts +2 -0
- package/dist/esm/v3/index.js +2 -0
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/jwt.d.ts +10 -1
- package/dist/esm/v3/jwt.js +17 -4
- package/dist/esm/v3/jwt.js.map +1 -1
- package/dist/esm/v3/runMetadata/index.d.ts +5 -0
- package/dist/esm/v3/runMetadata/index.js +15 -0
- package/dist/esm/v3/runMetadata/index.js.map +1 -1
- package/dist/esm/v3/runMetadata/manager.d.ts +13 -0
- package/dist/esm/v3/runMetadata/manager.js +174 -12
- package/dist/esm/v3/runMetadata/manager.js.map +1 -1
- package/dist/esm/v3/runMetadata/metadataStream.d.ts +21 -0
- package/dist/esm/v3/runMetadata/metadataStream.js +67 -0
- package/dist/esm/v3/runMetadata/metadataStream.js.map +1 -0
- package/dist/esm/v3/runMetadata/noopManager.d.ts +5 -0
- package/dist/esm/v3/runMetadata/noopManager.js +15 -0
- package/dist/esm/v3/runMetadata/noopManager.js.map +1 -1
- package/dist/esm/v3/runMetadata/types.d.ts +5 -0
- package/dist/esm/v3/runtime/devRuntimeManager.js.map +1 -1
- package/dist/esm/v3/schemas/api.d.ts +954 -1628
- package/dist/esm/v3/schemas/api.js +49 -0
- package/dist/esm/v3/schemas/api.js.map +1 -1
- package/dist/esm/v3/schemas/build.d.ts +308 -1040
- package/dist/esm/v3/schemas/common.d.ts +145 -123
- package/dist/esm/v3/schemas/common.js +4 -0
- package/dist/esm/v3/schemas/common.js.map +1 -1
- package/dist/esm/v3/schemas/eventFilter.d.ts +2 -2
- package/dist/esm/v3/schemas/fetch.d.ts +53 -41
- package/dist/esm/v3/schemas/messages.d.ts +2705 -4152
- package/dist/esm/v3/schemas/openTelemetry.d.ts +22 -22
- package/dist/esm/v3/schemas/resources.d.ts +86 -626
- package/dist/esm/v3/schemas/resources.js +1 -0
- package/dist/esm/v3/schemas/resources.js.map +1 -1
- package/dist/esm/v3/schemas/schemas.d.ts +406 -1074
- package/dist/esm/v3/schemas/schemas.js +1 -2
- package/dist/esm/v3/schemas/schemas.js.map +1 -1
- package/dist/esm/v3/schemas/style.d.ts +2 -2
- package/dist/esm/v3/types/index.d.ts +1 -0
- package/dist/esm/v3/types/index.js +1 -0
- package/dist/esm/v3/types/index.js.map +1 -1
- package/dist/esm/v3/types/tasks.d.ts +113 -23
- package/dist/esm/v3/types/tasks.js.map +1 -1
- package/dist/esm/v3/types/tools.d.ts +6 -0
- package/dist/esm/v3/types/tools.js +19 -0
- package/dist/esm/v3/types/tools.js.map +1 -0
- package/dist/esm/v3/utils/getEnv.d.ts +1 -1
- package/dist/esm/v3/utils/getEnv.js +3 -3
- package/dist/esm/v3/utils/getEnv.js.map +1 -1
- package/dist/esm/v3/utils/globals.d.ts +2 -0
- package/dist/esm/v3/utils/globals.js.map +1 -1
- package/dist/esm/v3/utils/ioSerialization.d.ts +8 -3
- package/dist/esm/v3/utils/ioSerialization.js +43 -36
- package/dist/esm/v3/utils/ioSerialization.js.map +1 -1
- package/dist/esm/v3/wait-until-api.d.ts +2 -0
- package/dist/esm/v3/wait-until-api.js +5 -0
- package/dist/esm/v3/wait-until-api.js.map +1 -0
- package/dist/esm/v3/waitUntil/index.d.ts +11 -0
- package/dist/esm/v3/waitUntil/index.js +40 -0
- package/dist/esm/v3/waitUntil/index.js.map +1 -0
- package/dist/esm/v3/waitUntil/manager.d.ts +8 -0
- package/dist/esm/v3/waitUntil/manager.js +24 -0
- package/dist/esm/v3/waitUntil/manager.js.map +1 -0
- package/dist/esm/v3/waitUntil/types.d.ts +9 -0
- package/dist/esm/v3/waitUntil/types.js +2 -0
- package/dist/esm/v3/waitUntil/types.js.map +1 -0
- package/dist/esm/v3/workers/index.d.ts +1 -0
- package/dist/esm/v3/workers/index.js +1 -0
- package/dist/esm/v3/workers/index.js.map +1 -1
- package/dist/esm/v3/workers/taskExecutor.js +14 -1
- package/dist/esm/v3/workers/taskExecutor.js.map +1 -1
- package/dist/esm/v3/zodMessageHandler.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +7 -3
|
@@ -118,8 +118,6 @@ exports.QueueOptions = zod_1.z.object({
|
|
|
118
118
|
*
|
|
119
119
|
* If this property is omitted, the task can potentially use up the full concurrency of an environment. */
|
|
120
120
|
concurrencyLimit: zod_1.z.number().int().min(0).max(1000).optional(),
|
|
121
|
-
/** @deprecated This feature is coming soon */
|
|
122
|
-
rateLimit: exports.RateLimitOptions.optional(),
|
|
123
121
|
});
|
|
124
122
|
exports.ScheduleMetadata = zod_1.z.object({
|
|
125
123
|
cron: zod_1.z.string(),
|
|
@@ -127,6 +125,7 @@ exports.ScheduleMetadata = zod_1.z.object({
|
|
|
127
125
|
});
|
|
128
126
|
const taskMetadata = {
|
|
129
127
|
id: zod_1.z.string(),
|
|
128
|
+
description: zod_1.z.string().optional(),
|
|
130
129
|
queue: exports.QueueOptions.optional(),
|
|
131
130
|
retry: exports.RetryOptions.optional(),
|
|
132
131
|
machine: common_js_1.MachineConfig.optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../src/v3/schemas/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,2CAA6E;AAE7E;;EAEE;AACW,QAAA,eAAe,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;AAG9E,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,4BAAgB;IAC3B,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;IACnC,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAIH,uMAAuM;AACvM,uDAAuD;AACvD,gCAAgC;AAChC,iDAAiD;AACpC,QAAA,oBAAoB,GAAG,4BAAgB,CAAC,MAAM,CAAC;IAC1D,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;QACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC;IACF,OAAO,EAAE,yBAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;CACvF,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAClD,SAAS,EAAE,4BAAoB;IAC/B,YA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,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IAC9C,oBAAoB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5E,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,oBAAoB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5C,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAQU,QAAA,UAAU,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAI9E,QAAA,kCAAkC,GAAG,OAAC,CAAC,MAAM,CAAC;IACzD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;IACnB,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;IACnC,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC"}
|
|
@@ -67,8 +67,8 @@ export declare const TaskEventStyle: z.ZodDefault<z.ZodObject<{
|
|
|
67
67
|
style?: "codepath" | undefined;
|
|
68
68
|
}>>;
|
|
69
69
|
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
icon?: string | undefined;
|
|
71
70
|
variant?: "primary" | undefined;
|
|
71
|
+
icon?: string | undefined;
|
|
72
72
|
accessory?: {
|
|
73
73
|
items: {
|
|
74
74
|
text: string;
|
|
@@ -78,8 +78,8 @@ export declare const TaskEventStyle: z.ZodDefault<z.ZodObject<{
|
|
|
78
78
|
style?: "codepath" | undefined;
|
|
79
79
|
} | undefined;
|
|
80
80
|
}, {
|
|
81
|
-
icon?: string | undefined;
|
|
82
81
|
variant?: "primary" | undefined;
|
|
82
|
+
icon?: string | undefined;
|
|
83
83
|
accessory?: {
|
|
84
84
|
items: {
|
|
85
85
|
text: string;
|
|
@@ -4,6 +4,7 @@ import { Prettify } from "./utils.js";
|
|
|
4
4
|
export * from "./utils.js";
|
|
5
5
|
export * from "./tasks.js";
|
|
6
6
|
export * from "./idempotencyKeys.js";
|
|
7
|
+
export * from "./tools.js";
|
|
7
8
|
type ResolveEnvironmentVariablesOptions = {
|
|
8
9
|
variables: Record<string, string> | Array<{
|
|
9
10
|
name: string;
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./utils.js"), exports);
|
|
18
18
|
__exportStar(require("./tasks.js"), exports);
|
|
19
19
|
__exportStar(require("./idempotencyKeys.js"), exports);
|
|
20
|
+
__exportStar(require("./tools.js"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v3/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,6CAA2B;AAC3B,6CAA2B;AAC3B,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v3/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,6CAA2B;AAC3B,6CAA2B;AAC3B,uDAAqC;AACrC,6CAA2B"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SerializableJson } from "../../schemas/json.js";
|
|
2
|
+
import { TriggerApiRequestOptions } from "../apiClient/index.js";
|
|
2
3
|
import { RunTags } from "../schemas/api.js";
|
|
4
|
+
import { MachineCpu, MachineMemory, RetryOptions, TaskMetadata, TaskRunContext } from "../schemas/index.js";
|
|
3
5
|
import { QueueOptions } from "../schemas/schemas.js";
|
|
4
6
|
import { IdempotencyKey } from "./idempotencyKeys.js";
|
|
5
|
-
import {
|
|
7
|
+
import { AnySchemaParseFn, inferSchemaIn, inferSchemaOut, Schema } from "./schemas.js";
|
|
6
8
|
import { Prettify } from "./utils.js";
|
|
7
|
-
import {
|
|
8
|
-
import { TriggerApiRequestOptions } from "../apiClient/index.js";
|
|
9
|
+
import { inferToolParameters, ToolTaskParameters } from "./tools.js";
|
|
9
10
|
type RequireOne<T, K extends keyof T> = {
|
|
10
11
|
[X in Exclude<keyof T, K>]?: T[X];
|
|
11
12
|
} & {
|
|
@@ -21,10 +22,10 @@ export declare class SubtaskUnwrapError extends Error {
|
|
|
21
22
|
readonly cause?: unknown;
|
|
22
23
|
constructor(taskId: string, runId: string, subtaskError: unknown);
|
|
23
24
|
}
|
|
24
|
-
export declare class TaskRunPromise<
|
|
25
|
+
export declare class TaskRunPromise<TIdentifier extends string, TOutput> extends Promise<TaskRunResult<TIdentifier, TOutput>> {
|
|
25
26
|
private readonly taskId;
|
|
26
|
-
constructor(executor: (resolve: (value: TaskRunResult<
|
|
27
|
-
unwrap(): Promise<
|
|
27
|
+
constructor(executor: (resolve: (value: TaskRunResult<TIdentifier, TOutput> | PromiseLike<TaskRunResult<TIdentifier, TOutput>>) => void, reject: (reason?: any) => void) => void, taskId: TIdentifier);
|
|
28
|
+
unwrap(): Promise<TOutput>;
|
|
28
29
|
}
|
|
29
30
|
export type InitOutput = Record<string, any> | void | undefined;
|
|
30
31
|
export type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
@@ -80,6 +81,7 @@ export type HandleErrorFunction = (payload: any, error: unknown, params: HandleE
|
|
|
80
81
|
type CommonTaskOptions<TIdentifier extends string, TPayload = void, TOutput = unknown, TInitOutput extends InitOutput = any> = {
|
|
81
82
|
/** An id for your task. This must be unique inside your project and not change between versions. */
|
|
82
83
|
id: TIdentifier;
|
|
84
|
+
description?: string;
|
|
83
85
|
/** The retry settings when an uncaught error is thrown.
|
|
84
86
|
*
|
|
85
87
|
* If omitted it will use the values in your `trigger.config.ts` file.
|
|
@@ -224,6 +226,9 @@ export type TaskOptions<TIdentifier extends string, TPayload = void, TOutput = u
|
|
|
224
226
|
export type TaskWithSchemaOptions<TIdentifier extends string, TSchema extends TaskSchema | undefined = undefined, TOutput = unknown, TInitOutput extends InitOutput = any> = CommonTaskOptions<TIdentifier, inferSchemaOut<TSchema>, TOutput, TInitOutput> & {
|
|
225
227
|
schema?: TSchema;
|
|
226
228
|
};
|
|
229
|
+
export type TaskWithToolOptions<TIdentifier extends string, TParameters extends ToolTaskParameters, TOutput = unknown, TInitOutput extends InitOutput = any> = CommonTaskOptions<TIdentifier, inferToolParameters<TParameters>, TOutput, TInitOutput> & {
|
|
230
|
+
parameters: TParameters;
|
|
231
|
+
};
|
|
227
232
|
declare const __output: unique symbol;
|
|
228
233
|
declare const __payload: unique symbol;
|
|
229
234
|
type BrandRun<P, O> = {
|
|
@@ -240,43 +245,91 @@ export type RunHandle<TTaskIdentifier extends string, TPayload, TOutput> = Brand
|
|
|
240
245
|
taskIdentifier: TTaskIdentifier;
|
|
241
246
|
}, TPayload, TOutput>;
|
|
242
247
|
export type AnyRunHandle = RunHandle<string, any, any>;
|
|
248
|
+
export type BatchedRunHandle<TTaskIdentifier extends string, TPayload, TOutput> = BrandedRun<{
|
|
249
|
+
id: string;
|
|
250
|
+
taskIdentifier: TTaskIdentifier;
|
|
251
|
+
isCached: boolean;
|
|
252
|
+
idempotencyKey?: string;
|
|
253
|
+
}, TPayload, TOutput>;
|
|
254
|
+
export type AnyBatchedRunHandle = BatchedRunHandle<string, any, any>;
|
|
243
255
|
/**
|
|
244
256
|
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
245
257
|
*/
|
|
246
258
|
export type BatchRunHandle<TTaskIdentifier extends string, TPayload, TOutput> = BrandedRun<{
|
|
247
259
|
batchId: string;
|
|
248
|
-
|
|
260
|
+
isCached: boolean;
|
|
261
|
+
idempotencyKey?: string;
|
|
262
|
+
runs: Array<BatchedRunHandle<TTaskIdentifier, TPayload, TOutput>>;
|
|
249
263
|
publicAccessToken: string;
|
|
250
|
-
taskIdentifier: TTaskIdentifier;
|
|
251
264
|
}, TOutput, TPayload>;
|
|
252
265
|
export type RunHandleOutput<TRunHandle> = TRunHandle extends RunHandle<string, any, infer TOutput> ? TOutput : never;
|
|
253
266
|
export type RunHandlePayload<TRunHandle> = TRunHandle extends RunHandle<string, infer TPayload, any> ? TPayload : never;
|
|
254
267
|
export type RunHandleTaskIdentifier<TRunHandle> = TRunHandle extends RunHandle<infer TTaskIdentifier, any, any> ? TTaskIdentifier : never;
|
|
255
|
-
export type TaskRunResult<TOutput = any> = {
|
|
268
|
+
export type TaskRunResult<TIdentifier extends string, TOutput = any> = {
|
|
256
269
|
ok: true;
|
|
257
270
|
id: string;
|
|
271
|
+
taskIdentifier: TIdentifier;
|
|
258
272
|
output: TOutput;
|
|
259
273
|
} | {
|
|
260
274
|
ok: false;
|
|
261
275
|
id: string;
|
|
276
|
+
taskIdentifier: TIdentifier;
|
|
262
277
|
error: unknown;
|
|
263
278
|
};
|
|
264
|
-
export type
|
|
279
|
+
export type AnyTaskRunResult = TaskRunResult<string, any>;
|
|
280
|
+
export type TaskRunResultFromTask<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, any, infer TOutput> ? TaskRunResult<TIdentifier, TOutput> : never;
|
|
281
|
+
export type BatchResult<TIdentifier extends string, TOutput = any> = {
|
|
282
|
+
id: string;
|
|
283
|
+
runs: TaskRunResult<TIdentifier, TOutput>[];
|
|
284
|
+
};
|
|
285
|
+
export type BatchByIdResult<TTask extends AnyTask> = {
|
|
286
|
+
id: string;
|
|
287
|
+
runs: Array<TaskRunResultFromTask<TTask>>;
|
|
288
|
+
};
|
|
289
|
+
export type BatchByTaskResult<TTasks extends readonly AnyTask[]> = {
|
|
265
290
|
id: string;
|
|
266
|
-
runs:
|
|
291
|
+
runs: {
|
|
292
|
+
[K in keyof TTasks]: TaskRunResultFromTask<TTasks[K]>;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
297
|
+
*/
|
|
298
|
+
export type BatchTasksResult<TTasks extends readonly AnyTask[]> = BatchTasksRunHandle<TTasks>;
|
|
299
|
+
export type BatchItem<TInput> = {
|
|
300
|
+
payload: TInput;
|
|
301
|
+
options?: TriggerOptions;
|
|
267
302
|
};
|
|
268
|
-
export type
|
|
269
|
-
payload?: TInput;
|
|
270
|
-
options?: TaskRunOptions;
|
|
271
|
-
} : {
|
|
303
|
+
export type BatchTriggerAndWaitItem<TInput> = {
|
|
272
304
|
payload: TInput;
|
|
273
|
-
options?:
|
|
305
|
+
options?: TriggerAndWaitOptions;
|
|
306
|
+
};
|
|
307
|
+
export type BatchByIdItem<TRunTypes extends AnyRunTypes> = {
|
|
308
|
+
id: TRunTypes["taskIdentifier"];
|
|
309
|
+
payload: TRunTypes["payload"];
|
|
310
|
+
options?: TriggerOptions;
|
|
311
|
+
};
|
|
312
|
+
export type BatchByIdAndWaitItem<TRunTypes extends AnyRunTypes> = {
|
|
313
|
+
id: TRunTypes["taskIdentifier"];
|
|
314
|
+
payload: TRunTypes["payload"];
|
|
315
|
+
options?: TriggerAndWaitOptions;
|
|
316
|
+
};
|
|
317
|
+
export type BatchByTaskItem<TTask extends AnyTask> = {
|
|
318
|
+
task: TTask;
|
|
319
|
+
payload: TaskPayload<TTask>;
|
|
320
|
+
options?: TriggerOptions;
|
|
321
|
+
};
|
|
322
|
+
export type BatchByTaskAndWaitItem<TTask extends AnyTask> = {
|
|
323
|
+
task: TTask;
|
|
324
|
+
payload: TaskPayload<TTask>;
|
|
325
|
+
options?: TriggerAndWaitOptions;
|
|
274
326
|
};
|
|
275
327
|
export interface Task<TIdentifier extends string, TInput = void, TOutput = any> {
|
|
276
328
|
/**
|
|
277
329
|
* The id of the task.
|
|
278
330
|
*/
|
|
279
331
|
id: TIdentifier;
|
|
332
|
+
description?: string;
|
|
280
333
|
/**
|
|
281
334
|
* Trigger a task with the given payload, and continue without waiting for the result. If you want to wait for the result, use `triggerAndWait`. Returns the id of the triggered task run.
|
|
282
335
|
* @param payload
|
|
@@ -284,7 +337,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
284
337
|
* @returns RunHandle
|
|
285
338
|
* - `id` - The id of the triggered task run.
|
|
286
339
|
*/
|
|
287
|
-
trigger: (payload: TInput, options?:
|
|
340
|
+
trigger: (payload: TInput, options?: TriggerOptions, requestOptions?: TriggerApiRequestOptions) => Promise<RunHandle<TIdentifier, TInput, TOutput>>;
|
|
288
341
|
/**
|
|
289
342
|
* Batch trigger multiple task runs with the given payloads, and continue without waiting for the results. If you want to wait for the results, use `batchTriggerAndWait`. Returns the id of the triggered batch.
|
|
290
343
|
* @param items
|
|
@@ -292,7 +345,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
292
345
|
* - `batchId` - The id of the triggered batch.
|
|
293
346
|
* - `runs` - The ids of the triggered task runs.
|
|
294
347
|
*/
|
|
295
|
-
batchTrigger: (items: Array<BatchItem<TInput>>, requestOptions?: TriggerApiRequestOptions) => Promise<BatchRunHandle<TIdentifier, TInput, TOutput>>;
|
|
348
|
+
batchTrigger: (items: Array<BatchItem<TInput>>, options?: BatchTriggerOptions, requestOptions?: TriggerApiRequestOptions) => Promise<BatchRunHandle<TIdentifier, TInput, TOutput>>;
|
|
296
349
|
/**
|
|
297
350
|
* Trigger a task with the given payload, and wait for the result. Returns the result of the task run
|
|
298
351
|
* @param payload
|
|
@@ -309,7 +362,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
309
362
|
* }
|
|
310
363
|
* ```
|
|
311
364
|
*/
|
|
312
|
-
triggerAndWait: (payload: TInput, options?:
|
|
365
|
+
triggerAndWait: (payload: TInput, options?: TriggerAndWaitOptions) => TaskRunPromise<TIdentifier, TOutput>;
|
|
313
366
|
/**
|
|
314
367
|
* Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
|
|
315
368
|
* @param items
|
|
@@ -330,7 +383,17 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
330
383
|
* }
|
|
331
384
|
* ```
|
|
332
385
|
*/
|
|
333
|
-
batchTriggerAndWait: (items: Array<
|
|
386
|
+
batchTriggerAndWait: (items: Array<BatchTriggerAndWaitItem<TInput>>) => Promise<BatchResult<TIdentifier, TOutput>>;
|
|
387
|
+
}
|
|
388
|
+
export interface TaskWithSchema<TIdentifier extends string, TSchema extends TaskSchema | undefined = undefined, TOutput = any> extends Task<TIdentifier, inferSchemaIn<TSchema>, TOutput> {
|
|
389
|
+
schema?: TSchema;
|
|
390
|
+
}
|
|
391
|
+
export interface ToolTask<TIdentifier extends string, TParameters extends ToolTaskParameters, TOutput = any> extends Task<TIdentifier, inferToolParameters<TParameters>, TOutput> {
|
|
392
|
+
tool: {
|
|
393
|
+
parameters: TParameters;
|
|
394
|
+
description?: string;
|
|
395
|
+
execute: (args: inferToolParameters<TParameters>) => Promise<TOutput>;
|
|
396
|
+
};
|
|
334
397
|
}
|
|
335
398
|
export type AnyTask = Task<string, any, any>;
|
|
336
399
|
export type TaskPayload<TTask extends AnyTask> = TTask extends Task<string, infer TInput, any> ? TInput : never;
|
|
@@ -338,6 +401,9 @@ export type TaskOutput<TTask extends AnyTask> = TTask extends Task<string, any,
|
|
|
338
401
|
export type TaskOutputHandle<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, infer TInput, infer TOutput> ? RunHandle<TIdentifier, TOutput, TInput> : never;
|
|
339
402
|
export type TaskBatchOutputHandle<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, infer TInput, infer TOutput> ? BatchRunHandle<TIdentifier, TOutput, TInput> : never;
|
|
340
403
|
export type TaskIdentifier<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, any, any> ? TIdentifier : never;
|
|
404
|
+
export type TaskFromIdentifier<TTask extends AnyTask, TIdentifier extends TTask["id"]> = TTask extends {
|
|
405
|
+
id: TIdentifier;
|
|
406
|
+
} ? TTask : never;
|
|
341
407
|
export type TriggerJwtOptions = {
|
|
342
408
|
/**
|
|
343
409
|
* The expiration time of the JWT. This can be a string like "1h" or a Date object.
|
|
@@ -346,7 +412,7 @@ export type TriggerJwtOptions = {
|
|
|
346
412
|
*/
|
|
347
413
|
expirationTime?: number | Date | string;
|
|
348
414
|
};
|
|
349
|
-
export type
|
|
415
|
+
export type TriggerOptions = {
|
|
350
416
|
/**
|
|
351
417
|
* A unique key that can be used to ensure that a task is only triggered once per key.
|
|
352
418
|
*
|
|
@@ -393,6 +459,12 @@ export type TaskRunOptions = {
|
|
|
393
459
|
*
|
|
394
460
|
*/
|
|
395
461
|
idempotencyKey?: IdempotencyKey | string | string[];
|
|
462
|
+
/**
|
|
463
|
+
* The time-to-live for the idempotency key. Once the TTL has passed, the key can be used again.
|
|
464
|
+
*
|
|
465
|
+
* Specify a duration string like "1h", "10s", "30m", etc.
|
|
466
|
+
*/
|
|
467
|
+
idempotencyKeyTTL?: string;
|
|
396
468
|
maxAttempts?: number;
|
|
397
469
|
queue?: TaskRunConcurrencyOptions;
|
|
398
470
|
concurrencyKey?: string;
|
|
@@ -450,6 +522,11 @@ export type TaskRunOptions = {
|
|
|
450
522
|
*/
|
|
451
523
|
maxDuration?: number;
|
|
452
524
|
};
|
|
525
|
+
export type TriggerAndWaitOptions = Omit<TriggerOptions, "idempotencyKey" | "idempotencyKeyTTL">;
|
|
526
|
+
export type BatchTriggerOptions = {
|
|
527
|
+
idempotencyKey?: IdempotencyKey | string | string[];
|
|
528
|
+
idempotencyKeyTTL?: string;
|
|
529
|
+
};
|
|
453
530
|
export type TaskMetadataWithFunctions = TaskMetadata & {
|
|
454
531
|
fns: {
|
|
455
532
|
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
@@ -469,6 +546,19 @@ export type RunTypes<TTaskIdentifier extends string, TPayload, TOutput> = {
|
|
|
469
546
|
taskIdentifier: TTaskIdentifier;
|
|
470
547
|
};
|
|
471
548
|
export type AnyRunTypes = RunTypes<string, any, any>;
|
|
472
|
-
export type InferRunTypes<T> = T extends RunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends Task<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : AnyRunTypes;
|
|
549
|
+
export type InferRunTypes<T> = T extends RunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends BatchedRunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends Task<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : AnyRunTypes;
|
|
473
550
|
export type RunHandleFromTypes<TRunTypes extends AnyRunTypes> = RunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]>;
|
|
474
|
-
export type BatchRunHandleFromTypes<TRunTypes extends AnyRunTypes> = BatchRunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]
|
|
551
|
+
export type BatchRunHandleFromTypes<TRunTypes extends AnyRunTypes> = TRunTypes extends AnyRunTypes ? BatchRunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]> : never;
|
|
552
|
+
/**
|
|
553
|
+
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
554
|
+
*/
|
|
555
|
+
export type BatchTasksRunHandle<TTasks extends readonly AnyTask[]> = BrandedRun<{
|
|
556
|
+
batchId: string;
|
|
557
|
+
isCached: boolean;
|
|
558
|
+
idempotencyKey?: string;
|
|
559
|
+
runs: {
|
|
560
|
+
[K in keyof TTasks]: BatchedRunHandle<TaskIdentifier<TTasks[K]>, TaskPayload<TTasks[K]>, TaskOutput<TTasks[K]>>;
|
|
561
|
+
};
|
|
562
|
+
publicAccessToken: string;
|
|
563
|
+
}, any, any>;
|
|
564
|
+
export type BatchTasksRunHandleFromTypes<TTasks extends readonly AnyTask[]> = BatchTasksRunHandle<TTasks>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../../src/v3/types/tasks.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../../src/v3/types/tasks.ts"],"names":[],"mappings":";;;AA8BA,MAAa,kBAAmB,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,KAAK,CAAS;IACd,KAAK,CAAW;IAEhC,YAAY,MAAc,EAAE,KAAa,EAAE,YAAqB;QAC9D,IAAI,YAAY,YAAY,KAAK,EAAE,CAAC;YAClC,KAAK,CAAC,YAAY,MAAM,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC;YAC1B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;YACjC,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAnBD,gDAmBC;AAED,MAAa,cAAoD,SAAQ,OAExE;IAUoB;IATnB,YACE,QAOS,EACQ,MAAmB;QAEpC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAFC,WAAM,GAAN,MAAM,CAAa;IAGtC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;gBACd,OAAO,MAAM,CAAC,MAAM,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACrE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,wCA0BC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Schema as AISchema } from "ai";
|
|
3
|
+
import { Schema } from "./schemas.js";
|
|
4
|
+
export type ToolTaskParameters = z.ZodTypeAny | AISchema<any>;
|
|
5
|
+
export type inferToolParameters<PARAMETERS extends ToolTaskParameters> = PARAMETERS extends AISchema<any> ? PARAMETERS["_type"] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
|
|
6
|
+
export declare function convertToolParametersToSchema<TToolParameters extends ToolTaskParameters>(toolParameters: TToolParameters): Schema;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToolParametersToSchema = convertToolParametersToSchema;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function convertToolParametersToSchema(toolParameters) {
|
|
6
|
+
return toolParameters instanceof zod_1.z.ZodSchema
|
|
7
|
+
? toolParameters
|
|
8
|
+
: convertAISchemaToTaskSchema(toolParameters);
|
|
9
|
+
}
|
|
10
|
+
function convertAISchemaToTaskSchema(schema) {
|
|
11
|
+
return (payload) => {
|
|
12
|
+
const result = schema.validate?.(payload);
|
|
13
|
+
if (!result) {
|
|
14
|
+
throw new Error("Invalid payload");
|
|
15
|
+
}
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
throw result.error;
|
|
18
|
+
}
|
|
19
|
+
return result.value;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../src/v3/types/tools.ts"],"names":[],"mappings":";;AAaA,sEAMC;AAnBD,6BAAwB;AAaxB,SAAgB,6BAA6B,CAC3C,cAA+B;IAE/B,OAAO,cAAc,YAAY,OAAC,CAAC,SAAS;QAC1C,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,2BAA2B,CAAC,MAAqB;IACxD,OAAO,CAAC,OAAgB,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,CAAC,KAAK,CAAC;QACrB,CAAC;QAED,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getEnvVar(name: string): string | undefined;
|
|
1
|
+
export declare function getEnvVar(name: string, defaultValue?: string): string | undefined;
|
|
2
2
|
export declare function getNumberEnvVar(name: string, defaultValue?: number): number | undefined;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEnvVar = getEnvVar;
|
|
4
4
|
exports.getNumberEnvVar = getNumberEnvVar;
|
|
5
|
-
function getEnvVar(name) {
|
|
5
|
+
function getEnvVar(name, defaultValue) {
|
|
6
6
|
// This could run in a non-Node.js environment (Bun, Deno, CF Worker, etc.), so don't just assume process.env is a thing
|
|
7
7
|
if (typeof process !== "undefined" && typeof process.env === "object" && process.env !== null) {
|
|
8
|
-
return process.env[name];
|
|
8
|
+
return process.env[name] ?? defaultValue;
|
|
9
9
|
}
|
|
10
|
-
return;
|
|
10
|
+
return defaultValue;
|
|
11
11
|
}
|
|
12
12
|
function getNumberEnvVar(name, defaultValue) {
|
|
13
13
|
const value = getEnvVar(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnv.js","sourceRoot":"","sources":["../../../../src/v3/utils/getEnv.ts"],"names":[],"mappings":";;AAAA,8BAOC;AAED,0CAcC;AAvBD,SAAgB,SAAS,CAAC,IAAY;
|
|
1
|
+
{"version":3,"file":"getEnv.js","sourceRoot":"","sources":["../../../../src/v3/utils/getEnv.ts"],"names":[],"mappings":";;AAAA,8BAOC;AAED,0CAcC;AAvBD,SAAgB,SAAS,CAAC,IAAY,EAAE,YAAqB;IAC3D,wHAAwH;IACxH,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9F,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC;IAC3C,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,YAAqB;IACjE,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { TaskCatalog } from "../task-catalog/catalog.js";
|
|
|
6
6
|
import { TaskContext } from "../taskContext/types.js";
|
|
7
7
|
import { TimeoutManager } from "../timeout/types.js";
|
|
8
8
|
import { UsageManager } from "../usage/types.js";
|
|
9
|
+
import { WaitUntilManager } from "../waitUntil/types.js";
|
|
9
10
|
export declare function registerGlobal<Type extends keyof TriggerDotDevGlobalAPI>(type: Type, instance: TriggerDotDevGlobalAPI[Type], allowOverride?: boolean): boolean;
|
|
10
11
|
export declare function getGlobal<Type extends keyof TriggerDotDevGlobalAPI>(type: Type): TriggerDotDevGlobalAPI[Type] | undefined;
|
|
11
12
|
export declare function unregisterGlobal(type: keyof TriggerDotDevGlobalAPI): void;
|
|
@@ -19,5 +20,6 @@ type TriggerDotDevGlobalAPI = {
|
|
|
19
20
|
["api-client"]?: ApiClientConfiguration;
|
|
20
21
|
["run-metadata"]?: RunMetadataManager;
|
|
21
22
|
["timeout"]?: TimeoutManager;
|
|
23
|
+
["wait-until"]?: WaitUntilManager;
|
|
22
24
|
};
|
|
23
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../../../src/v3/utils/globals.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../../../src/v3/utils/globals.ts"],"names":[],"mappings":";;AAgBA,wCAgBC;AAED,8BAIC;AAED,4CAMC;AApCD,+CAA4C;AAE5C,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEpE,MAAM,OAAO,GAAG,yBAAkC,CAAC;AAEnD,SAAgB,cAAc,CAC5B,IAAU,EACV,QAAsC,EACtC,aAAa,GAAG,KAAK;IAErB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9F,IAAI,CAAC,aAAa,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,yCAAyC;QACzC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,yDAAyD,IAAI,EAAE,CAAC,CAAC;QACvF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IAErB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,SAAS,CACvB,IAAU;IAEV,OAAO,OAAO,CAAC,0BAA0B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAkC;IACjE,MAAM,GAAG,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEhD,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Attributes } from "@opentelemetry/api";
|
|
2
2
|
import { TriggerTracer } from "../tracer.js";
|
|
3
|
+
import { ApiClient } from "../apiClient/index.js";
|
|
3
4
|
export type IOPacket = {
|
|
4
5
|
data?: string | undefined;
|
|
5
6
|
dataType: string;
|
|
6
7
|
};
|
|
7
8
|
export declare function parsePacket(value: IOPacket): Promise<any>;
|
|
8
|
-
export declare function conditionallyImportAndParsePacket(value: IOPacket): Promise<any>;
|
|
9
|
+
export declare function conditionallyImportAndParsePacket(value: IOPacket, client?: ApiClient): Promise<any>;
|
|
9
10
|
export declare function stringifyIO(value: any): Promise<IOPacket>;
|
|
10
11
|
export declare function conditionallyExportPacket(packet: IOPacket, pathPrefix: string, tracer?: TriggerTracer): Promise<IOPacket>;
|
|
11
12
|
export declare function packetRequiresOffloading(packet: IOPacket, lengthLimit?: number): {
|
|
12
13
|
needsOffloading: boolean;
|
|
13
14
|
size: number;
|
|
14
15
|
};
|
|
15
|
-
export declare function conditionallyImportPacket(packet: IOPacket, tracer?: TriggerTracer): Promise<IOPacket>;
|
|
16
|
+
export declare function conditionallyImportPacket(packet: IOPacket, tracer?: TriggerTracer, client?: ApiClient): Promise<IOPacket>;
|
|
16
17
|
export declare function resolvePresignedPacketUrl(url: string, tracer?: TriggerTracer): Promise<any | undefined>;
|
|
17
18
|
export declare function createPacketAttributes(packet: IOPacket, dataKey: string, dataTypeKey: string): Promise<Attributes | undefined>;
|
|
18
19
|
export declare function createPacketAttributesAsJson(data: any, dataType: string): Promise<Attributes>;
|
|
19
|
-
export declare function prettyPrintPacket(rawData: any, dataType?: string): Promise<string>;
|
|
20
|
+
export declare function prettyPrintPacket(rawData: any, dataType?: string, options?: ReplacerOptions): Promise<string>;
|
|
21
|
+
interface ReplacerOptions {
|
|
22
|
+
filteredKeys?: string[];
|
|
23
|
+
}
|
|
20
24
|
export declare function replaceSuperJsonPayload(original: string, newPayload: string): Promise<unknown>;
|
|
25
|
+
export {};
|
|
@@ -35,8 +35,8 @@ async function parsePacket(value) {
|
|
|
35
35
|
return value.data;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
async function conditionallyImportAndParsePacket(value) {
|
|
39
|
-
const importedPacket = await conditionallyImportPacket(value);
|
|
38
|
+
async function conditionallyImportAndParsePacket(value, client) {
|
|
39
|
+
const importedPacket = await conditionallyImportPacket(value, undefined, client);
|
|
40
40
|
return await parsePacket(importedPacket);
|
|
41
41
|
}
|
|
42
42
|
async function stringifyIO(value) {
|
|
@@ -118,16 +118,16 @@ async function exportPacket(packet, pathPrefix) {
|
|
|
118
118
|
dataType: "application/store",
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
async function conditionallyImportPacket(packet, tracer) {
|
|
121
|
+
async function conditionallyImportPacket(packet, tracer, client) {
|
|
122
122
|
if (packet.dataType !== "application/store") {
|
|
123
123
|
return packet;
|
|
124
124
|
}
|
|
125
125
|
if (!tracer) {
|
|
126
|
-
return await importPacket(packet);
|
|
126
|
+
return await importPacket(packet, undefined, client);
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
129
|
const result = await tracer.startActiveSpan("store.downloadPayload", async (span) => {
|
|
130
|
-
return await importPacket(packet, span);
|
|
130
|
+
return await importPacket(packet, span, client);
|
|
131
131
|
}, {
|
|
132
132
|
attributes: {
|
|
133
133
|
[semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "cloud-download",
|
|
@@ -154,14 +154,15 @@ async function resolvePresignedPacketUrl(url, tracer) {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
async function importPacket(packet, span) {
|
|
157
|
+
async function importPacket(packet, span, client) {
|
|
158
158
|
if (!packet.data) {
|
|
159
159
|
return packet;
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
const $client = client ?? apiClientManager_api_js_1.apiClientManager.client;
|
|
162
|
+
if (!$client) {
|
|
162
163
|
return packet;
|
|
163
164
|
}
|
|
164
|
-
const presignedResponse = await
|
|
165
|
+
const presignedResponse = await $client.getPayloadUrl(packet.data);
|
|
165
166
|
const response = await (0, zodfetch_js_1.zodfetch)(zod_1.z.any(), presignedResponse.presignedUrl, undefined, {
|
|
166
167
|
retry: ioRetryOptions,
|
|
167
168
|
}).asResponse();
|
|
@@ -192,7 +193,7 @@ async function createPacketAttributes(packet, dataKey, dataTypeKey) {
|
|
|
192
193
|
}
|
|
193
194
|
try {
|
|
194
195
|
const parsed = parse(packet.data);
|
|
195
|
-
const jsonified = JSON.parse(JSON.stringify(parsed,
|
|
196
|
+
const jsonified = JSON.parse(JSON.stringify(parsed, makeSafeReplacer()));
|
|
196
197
|
const result = {
|
|
197
198
|
...(0, flattenAttributes_js_1.flattenAttributes)(jsonified, dataKey),
|
|
198
199
|
[dataTypeKey]: "application/json",
|
|
@@ -230,7 +231,7 @@ async function createPacketAttributesAsJson(data, dataType) {
|
|
|
230
231
|
case "application/super+json":
|
|
231
232
|
const { deserialize } = await loadSuperJSON();
|
|
232
233
|
const deserialized = deserialize(data);
|
|
233
|
-
const jsonify = safeJsonParse(JSON.stringify(deserialized,
|
|
234
|
+
const jsonify = safeJsonParse(JSON.stringify(deserialized, makeSafeReplacer()));
|
|
234
235
|
return (0, limits_js_1.imposeAttributeLimits)((0, flattenAttributes_js_1.flattenAttributes)(jsonify, undefined));
|
|
235
236
|
case "application/store":
|
|
236
237
|
return data;
|
|
@@ -238,7 +239,7 @@ async function createPacketAttributesAsJson(data, dataType) {
|
|
|
238
239
|
return {};
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
async function prettyPrintPacket(rawData, dataType) {
|
|
242
|
+
async function prettyPrintPacket(rawData, dataType, options) {
|
|
242
243
|
if (rawData === undefined) {
|
|
243
244
|
return "";
|
|
244
245
|
}
|
|
@@ -253,35 +254,41 @@ async function prettyPrintPacket(rawData, dataType) {
|
|
|
253
254
|
if (typeof rawData === "string") {
|
|
254
255
|
rawData = safeJsonParse(rawData);
|
|
255
256
|
}
|
|
256
|
-
return JSON.stringify(rawData,
|
|
257
|
+
return JSON.stringify(rawData, makeSafeReplacer(options), 2);
|
|
257
258
|
}
|
|
258
259
|
if (typeof rawData === "string") {
|
|
259
260
|
return rawData;
|
|
260
261
|
}
|
|
261
|
-
return JSON.stringify(rawData,
|
|
262
|
+
return JSON.stringify(rawData, makeSafeReplacer(options), 2);
|
|
262
263
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
264
|
+
function makeSafeReplacer(options) {
|
|
265
|
+
return function replacer(key, value) {
|
|
266
|
+
// Check if the key should be filtered out
|
|
267
|
+
if (options?.filteredKeys?.includes(key)) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
// If it is a BigInt
|
|
271
|
+
if (typeof value === "bigint") {
|
|
272
|
+
return value.toString();
|
|
273
|
+
}
|
|
274
|
+
// if it is a Regex
|
|
275
|
+
if (value instanceof RegExp) {
|
|
276
|
+
return value.toString();
|
|
277
|
+
}
|
|
278
|
+
// if it is a Set
|
|
279
|
+
if (value instanceof Set) {
|
|
280
|
+
return Array.from(value);
|
|
281
|
+
}
|
|
282
|
+
// if it is a Map, convert it to an object
|
|
283
|
+
if (value instanceof Map) {
|
|
284
|
+
const obj = {};
|
|
285
|
+
value.forEach((v, k) => {
|
|
286
|
+
obj[k] = v;
|
|
287
|
+
});
|
|
288
|
+
return obj;
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
};
|
|
285
292
|
}
|
|
286
293
|
function getPacketExtension(outputType) {
|
|
287
294
|
switch (outputType) {
|
|
@@ -298,7 +305,7 @@ function getPacketExtension(outputType) {
|
|
|
298
305
|
async function loadSuperJSON() {
|
|
299
306
|
const superjson = await import("superjson");
|
|
300
307
|
superjson.registerCustom({
|
|
301
|
-
isApplicable: (v) =>
|
|
308
|
+
isApplicable: (v) => typeof Buffer === "function" && Buffer.isBuffer(v),
|
|
302
309
|
serialize: (v) => [...v],
|
|
303
310
|
deserialize: (v) => Buffer.from(v),
|
|
304
311
|
}, "buffer");
|