@trigger.dev/sdk 2.0.0-next.13 → 2.0.0-next.15
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/index.d.ts +45 -7
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,19 @@ declare const ServerTaskSchema: z.ZodObject<{
|
|
|
64
64
|
text: string;
|
|
65
65
|
url?: string | undefined;
|
|
66
66
|
}>, "many">>>;
|
|
67
|
+
outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
68
|
+
label: z.ZodString;
|
|
69
|
+
text: z.ZodString;
|
|
70
|
+
url: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
label: string;
|
|
73
|
+
text: string;
|
|
74
|
+
url?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
label: string;
|
|
77
|
+
text: string;
|
|
78
|
+
url?: string | undefined;
|
|
79
|
+
}>, "many">>>;
|
|
67
80
|
output: z.ZodNullable<z.ZodOptional<z.ZodType<DeserializedJson, z.ZodTypeDef, DeserializedJson>>>;
|
|
68
81
|
error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
69
82
|
parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -98,6 +111,11 @@ declare const ServerTaskSchema: z.ZodObject<{
|
|
|
98
111
|
text: string;
|
|
99
112
|
url?: string | undefined;
|
|
100
113
|
}[] | null | undefined;
|
|
114
|
+
outputProperties?: {
|
|
115
|
+
label: string;
|
|
116
|
+
text: string;
|
|
117
|
+
url?: string | undefined;
|
|
118
|
+
}[] | null | undefined;
|
|
101
119
|
output?: DeserializedJson | undefined;
|
|
102
120
|
error?: string | null | undefined;
|
|
103
121
|
parentId?: string | null | undefined;
|
|
@@ -124,6 +142,11 @@ declare const ServerTaskSchema: z.ZodObject<{
|
|
|
124
142
|
text: string;
|
|
125
143
|
url?: string | undefined;
|
|
126
144
|
}[] | null | undefined;
|
|
145
|
+
outputProperties?: {
|
|
146
|
+
label: string;
|
|
147
|
+
text: string;
|
|
148
|
+
url?: string | undefined;
|
|
149
|
+
}[] | null | undefined;
|
|
127
150
|
output?: DeserializedJson | undefined;
|
|
128
151
|
error?: string | null | undefined;
|
|
129
152
|
parentId?: string | null | undefined;
|
|
@@ -157,6 +180,10 @@ declare const CachedTaskSchema: z.ZodObject<{
|
|
|
157
180
|
parentId?: string | null | undefined;
|
|
158
181
|
}>;
|
|
159
182
|
|
|
183
|
+
type Prettify<T> = {
|
|
184
|
+
[K in keyof T]: T[K];
|
|
185
|
+
} & {};
|
|
186
|
+
|
|
160
187
|
declare const UpdateTriggerSourceBodySchema: z.ZodObject<{
|
|
161
188
|
registeredEvents: z.ZodArray<z.ZodString, "many">;
|
|
162
189
|
secret: z.ZodOptional<z.ZodString>;
|
|
@@ -2227,7 +2254,7 @@ declare const CompleteTaskBodyInputSchema: z.ZodObject<{
|
|
|
2227
2254
|
}[] | undefined;
|
|
2228
2255
|
output?: SerializableJson;
|
|
2229
2256
|
}>;
|
|
2230
|
-
type CompleteTaskBodyInput = z.input<typeof CompleteTaskBodyInputSchema
|
|
2257
|
+
type CompleteTaskBodyInput = Prettify<z.input<typeof CompleteTaskBodyInputSchema>>;
|
|
2231
2258
|
declare const FailTaskBodyInputSchema: z.ZodObject<{
|
|
2232
2259
|
error: z.ZodObject<{
|
|
2233
2260
|
message: z.ZodString;
|
|
@@ -3111,10 +3138,6 @@ declare const FetchRetryOptionsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminat
|
|
|
3111
3138
|
*/
|
|
3112
3139
|
type FetchRetryOptions = z.infer<typeof FetchRetryOptionsSchema>;
|
|
3113
3140
|
|
|
3114
|
-
type Prettify<T> = {
|
|
3115
|
-
[K in keyof T]: T[K];
|
|
3116
|
-
} & {};
|
|
3117
|
-
|
|
3118
3141
|
type ApiClientOptions = {
|
|
3119
3142
|
apiKey?: string;
|
|
3120
3143
|
apiUrl?: string;
|
|
@@ -3159,6 +3182,11 @@ declare class ApiClient {
|
|
|
3159
3182
|
text: string;
|
|
3160
3183
|
url?: string | undefined;
|
|
3161
3184
|
}[] | null | undefined;
|
|
3185
|
+
outputProperties?: {
|
|
3186
|
+
label: string;
|
|
3187
|
+
text: string;
|
|
3188
|
+
url?: string | undefined;
|
|
3189
|
+
}[] | null | undefined;
|
|
3162
3190
|
output?: DeserializedJson | undefined;
|
|
3163
3191
|
error?: string | null | undefined;
|
|
3164
3192
|
parentId?: string | null | undefined;
|
|
@@ -3186,6 +3214,11 @@ declare class ApiClient {
|
|
|
3186
3214
|
text: string;
|
|
3187
3215
|
url?: string | undefined;
|
|
3188
3216
|
}[] | null | undefined;
|
|
3217
|
+
outputProperties?: {
|
|
3218
|
+
label: string;
|
|
3219
|
+
text: string;
|
|
3220
|
+
url?: string | undefined;
|
|
3221
|
+
}[] | null | undefined;
|
|
3189
3222
|
output?: DeserializedJson | undefined;
|
|
3190
3223
|
error?: string | null | undefined;
|
|
3191
3224
|
parentId?: string | null | undefined;
|
|
@@ -3213,6 +3246,11 @@ declare class ApiClient {
|
|
|
3213
3246
|
text: string;
|
|
3214
3247
|
url?: string | undefined;
|
|
3215
3248
|
}[] | null | undefined;
|
|
3249
|
+
outputProperties?: {
|
|
3250
|
+
label: string;
|
|
3251
|
+
text: string;
|
|
3252
|
+
url?: string | undefined;
|
|
3253
|
+
}[] | null | undefined;
|
|
3216
3254
|
output?: DeserializedJson | undefined;
|
|
3217
3255
|
error?: string | null | undefined;
|
|
3218
3256
|
parentId?: string | null | undefined;
|
|
@@ -3936,7 +3974,7 @@ declare class IO {
|
|
|
3936
3974
|
retryAt: Date;
|
|
3937
3975
|
error?: Error;
|
|
3938
3976
|
jitter?: number;
|
|
3939
|
-
} | undefined | void): Promise<TResult>;
|
|
3977
|
+
} | Error | undefined | void): Promise<TResult>;
|
|
3940
3978
|
/** `io.try()` allows you to run Tasks and catch any errors that are thrown, it's similar to a normal `try/catch` block but works with [io.runTask()](/sdk/io/runtask).
|
|
3941
3979
|
* A regular `try/catch` block on its own won't work as expected with Tasks. Internally `runTask()` throws some special errors to control flow execution. This is necessary to deal with resumability, serverless timeouts, and retrying Tasks.
|
|
3942
3980
|
* @param tryCallback The code you wish to run
|
|
@@ -3983,7 +4021,7 @@ type AuthenticatedTask<TClient, TParams, TResult, TAuth = ConnectionAuth> = {
|
|
|
3983
4021
|
onError?: (error: unknown, task: ServerTask) => {
|
|
3984
4022
|
retryAt: Date;
|
|
3985
4023
|
error?: Error;
|
|
3986
|
-
} | undefined | void;
|
|
4024
|
+
} | Error | undefined | void;
|
|
3987
4025
|
};
|
|
3988
4026
|
declare function authenticatedTask<TClient, TParams, TResult>(options: {
|
|
3989
4027
|
run: (params: TParams, client: TClient, task: ServerTask, io: IO) => Promise<TResult>;
|
package/dist/index.js
CHANGED
|
@@ -430,6 +430,7 @@ var TaskSchema = import_zod7.z.object({
|
|
|
430
430
|
status: TaskStatusSchema,
|
|
431
431
|
description: import_zod7.z.string().optional().nullable(),
|
|
432
432
|
properties: import_zod7.z.array(DisplayPropertySchema).optional().nullable(),
|
|
433
|
+
outputProperties: import_zod7.z.array(DisplayPropertySchema).optional().nullable(),
|
|
433
434
|
params: DeserializedJsonSchema.optional().nullable(),
|
|
434
435
|
output: DeserializedJsonSchema.optional().nullable(),
|
|
435
436
|
error: import_zod7.z.string().optional().nullable(),
|
|
@@ -1028,6 +1029,7 @@ var currentDate = {
|
|
|
1028
1029
|
|
|
1029
1030
|
// src/apiClient.ts
|
|
1030
1031
|
var import_zod12 = require("zod");
|
|
1032
|
+
var import_node_fetch = __toESM(require("node-fetch"));
|
|
1031
1033
|
var _apiUrl, _options, _logger, _apiKey, apiKey_fn;
|
|
1032
1034
|
var ApiClient = class {
|
|
1033
1035
|
constructor(options) {
|
|
@@ -1045,7 +1047,7 @@ var ApiClient = class {
|
|
|
1045
1047
|
url: options.url,
|
|
1046
1048
|
name: options.name
|
|
1047
1049
|
});
|
|
1048
|
-
const response = await
|
|
1050
|
+
const response = await (0, import_node_fetch.default)(`${__privateGet(this, _apiUrl)}/api/v1/endpoints`, {
|
|
1049
1051
|
method: "POST",
|
|
1050
1052
|
headers: {
|
|
1051
1053
|
"Content-Type": "application/json",
|
|
@@ -1259,7 +1261,7 @@ function getApiKey(key) {
|
|
|
1259
1261
|
}
|
|
1260
1262
|
__name(getApiKey, "getApiKey");
|
|
1261
1263
|
async function zodfetch(schema, url, requestInit, options) {
|
|
1262
|
-
const response = await
|
|
1264
|
+
const response = await (0, import_node_fetch.default)(url, requestInit);
|
|
1263
1265
|
if ((!requestInit || requestInit.method === "GET") && response.status === 404 && options?.optional) {
|
|
1264
1266
|
return;
|
|
1265
1267
|
}
|
|
@@ -1708,7 +1710,8 @@ var IO = class {
|
|
|
1708
1710
|
task
|
|
1709
1711
|
});
|
|
1710
1712
|
await this._apiClient.completeTask(this._id, task.id, {
|
|
1711
|
-
output: result ?? void 0
|
|
1713
|
+
output: result ?? void 0,
|
|
1714
|
+
properties: task.outputProperties ?? void 0
|
|
1712
1715
|
});
|
|
1713
1716
|
return result;
|
|
1714
1717
|
} catch (error) {
|
|
@@ -1718,10 +1721,14 @@ var IO = class {
|
|
|
1718
1721
|
if (onError) {
|
|
1719
1722
|
const onErrorResult = onError(error, task, this);
|
|
1720
1723
|
if (onErrorResult) {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1724
|
+
if (onErrorResult instanceof Error) {
|
|
1725
|
+
error = onErrorResult;
|
|
1726
|
+
} else {
|
|
1727
|
+
const parsedError2 = ErrorWithStackSchema.safeParse(onErrorResult.error);
|
|
1728
|
+
throw new RetryWithTaskError(parsedError2.success ? parsedError2.data : {
|
|
1729
|
+
message: "Unknown error"
|
|
1730
|
+
}, task, onErrorResult.retryAt);
|
|
1731
|
+
}
|
|
1725
1732
|
}
|
|
1726
1733
|
}
|
|
1727
1734
|
const parsedError = ErrorWithStackSchema.safeParse(error);
|