@hatchet-dev/typescript-sdk 0.5.7 → 0.6.0
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/clients/admin/admin-client.d.ts +1 -0
- package/clients/admin/admin-client.js +3 -1
- package/clients/event/event-client.d.ts +4 -1
- package/clients/event/event-client.js +4 -1
- package/clients/worker/worker.js +27 -3
- package/package.json +2 -1
- package/protoc/events/events.d.ts +4 -0
- package/protoc/events/events.js +43 -4
- package/protoc/workflows/workflows.d.ts +4 -0
- package/protoc/workflows/workflows.js +38 -1
- package/workflow.d.ts +58 -0
- package/workflow.js +4 -0
|
@@ -52,6 +52,7 @@ export declare class AdminClient {
|
|
|
52
52
|
parentStepRunId?: string | undefined;
|
|
53
53
|
childIndex?: number | undefined;
|
|
54
54
|
childKey?: string | undefined;
|
|
55
|
+
additionalMetadata?: Record<string, string> | undefined;
|
|
55
56
|
}): Promise<string>;
|
|
56
57
|
/**
|
|
57
58
|
* List workflows in the tenant associated with the API token.
|
|
@@ -83,7 +83,9 @@ class AdminClient {
|
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
84
|
try {
|
|
85
85
|
const inputStr = JSON.stringify(input);
|
|
86
|
-
const resp = yield this.client.triggerWorkflow(Object.assign({ name: workflowName, input: inputStr }, options))
|
|
86
|
+
const resp = yield this.client.triggerWorkflow(Object.assign(Object.assign({ name: workflowName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
87
|
+
? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
88
|
+
: undefined }));
|
|
87
89
|
return resp.workflowRunId;
|
|
88
90
|
}
|
|
89
91
|
catch (e) {
|
|
@@ -8,12 +8,15 @@ export declare enum LogLevel {
|
|
|
8
8
|
ERROR = "ERROR",
|
|
9
9
|
DEBUG = "DEBUG"
|
|
10
10
|
}
|
|
11
|
+
export interface PushEventOptions {
|
|
12
|
+
additionalMetadata?: Record<string, string>;
|
|
13
|
+
}
|
|
11
14
|
export declare class EventClient {
|
|
12
15
|
config: ClientConfig;
|
|
13
16
|
client: EventsServiceClient;
|
|
14
17
|
logger: Logger;
|
|
15
18
|
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
|
|
16
|
-
push<T>(type: string, input: T): Promise<import("../../protoc/events/events").Event>;
|
|
19
|
+
push<T>(type: string, input: T, options?: PushEventOptions): Promise<import("../../protoc/events/events").Event>;
|
|
17
20
|
putLog(stepRunId: string, log: string, level?: LogLevel): void;
|
|
18
21
|
putStream(stepRunId: string, data: string | Uint8Array): void;
|
|
19
22
|
}
|
|
@@ -31,13 +31,16 @@ class EventClient {
|
|
|
31
31
|
this.client = factory.create(events_1.EventsServiceDefinition, channel);
|
|
32
32
|
this.logger = new logger_1.Logger(`Dispatcher`, config.log_level);
|
|
33
33
|
}
|
|
34
|
-
push(type, input) {
|
|
34
|
+
push(type, input, options = {}) {
|
|
35
35
|
var _a;
|
|
36
36
|
const namespacedType = `${(_a = this.config.namespace) !== null && _a !== void 0 ? _a : ''}${type}`;
|
|
37
37
|
const req = {
|
|
38
38
|
key: namespacedType,
|
|
39
39
|
payload: JSON.stringify(input),
|
|
40
40
|
eventTimestamp: new Date(),
|
|
41
|
+
additionalMetadata: options.additionalMetadata
|
|
42
|
+
? JSON.stringify(options.additionalMetadata)
|
|
43
|
+
: undefined,
|
|
41
44
|
};
|
|
42
45
|
try {
|
|
43
46
|
const e = this.client.push(req);
|
package/clients/worker/worker.js
CHANGED
|
@@ -49,7 +49,7 @@ class Worker {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
register_workflow(initWorkflow) {
|
|
52
|
-
var _a, _b;
|
|
52
|
+
var _a, _b, _c;
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: this.client.config.namespace + initWorkflow.id });
|
|
55
55
|
try {
|
|
@@ -60,6 +60,24 @@ class Worker {
|
|
|
60
60
|
limitStrategy: workflow.concurrency.limitStrategy || workflows_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
|
|
61
61
|
}
|
|
62
62
|
: undefined;
|
|
63
|
+
const onFailureJob = workflow.onFailure
|
|
64
|
+
? {
|
|
65
|
+
name: `${workflow.id}-on-failure`,
|
|
66
|
+
description: workflow.description,
|
|
67
|
+
steps: [
|
|
68
|
+
{
|
|
69
|
+
readableId: workflow.onFailure.name,
|
|
70
|
+
action: `${workflow.id}-on-failure:${workflow.onFailure.name}`,
|
|
71
|
+
timeout: workflow.onFailure.timeout || '60s',
|
|
72
|
+
inputs: '{}',
|
|
73
|
+
parents: [],
|
|
74
|
+
userData: '{}',
|
|
75
|
+
retries: workflow.onFailure.retries || 0,
|
|
76
|
+
rateLimits: (_b = workflow.onFailure.rate_limits) !== null && _b !== void 0 ? _b : [],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
: undefined;
|
|
63
81
|
const registeredWorkflow = this.client.admin.put_workflow({
|
|
64
82
|
name: workflow.id,
|
|
65
83
|
description: workflow.description,
|
|
@@ -69,6 +87,7 @@ class Worker {
|
|
|
69
87
|
scheduledTriggers: [],
|
|
70
88
|
concurrency,
|
|
71
89
|
scheduleTimeout: workflow.scheduleTimeout,
|
|
90
|
+
onFailureJob,
|
|
72
91
|
jobs: [
|
|
73
92
|
{
|
|
74
93
|
name: workflow.id,
|
|
@@ -99,8 +118,13 @@ class Worker {
|
|
|
99
118
|
acc[`${workflow.id}:${step.name}`] = step.run;
|
|
100
119
|
return acc;
|
|
101
120
|
}, {});
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
const onFailureAction = workflow.onFailure
|
|
122
|
+
? {
|
|
123
|
+
[`${workflow.id}-on-failure:${workflow.onFailure.name}`]: workflow.onFailure.run,
|
|
124
|
+
}
|
|
125
|
+
: {};
|
|
126
|
+
this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
|
|
127
|
+
this.action_registry = ((_c = workflow.concurrency) === null || _c === void 0 ? void 0 : _c.name)
|
|
104
128
|
? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
|
|
105
129
|
});
|
|
106
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"example:rate": "npm run exec -- ./examples/rate-limit/events.ts",
|
|
39
39
|
"worker:fanout": "npm run exec -- ./examples/fanout-worker.ts",
|
|
40
40
|
"worker:simple": "npm run exec -- ./examples/simple-worker.ts",
|
|
41
|
+
"worker:on-failure": "npm run exec -- ./examples/on-failure.ts",
|
|
41
42
|
"manual:trigger": "npm run exec -- ./examples/manual-trigger.ts",
|
|
42
43
|
"worker:dag": "npm run exec -- ./examples/dag-worker.ts",
|
|
43
44
|
"worker:concurrency": "npm run exec -- ./examples/concurrency/cancel-in-progress/concurrency-worker.ts",
|
|
@@ -12,6 +12,8 @@ export interface Event {
|
|
|
12
12
|
payload: string;
|
|
13
13
|
/** when the event was generated */
|
|
14
14
|
eventTimestamp: Date | undefined;
|
|
15
|
+
/** the payload for the event */
|
|
16
|
+
additionalMetadata?: string | undefined;
|
|
15
17
|
}
|
|
16
18
|
export interface PutLogRequest {
|
|
17
19
|
/** the step run id for the request */
|
|
@@ -46,6 +48,8 @@ export interface PushEventRequest {
|
|
|
46
48
|
payload: string;
|
|
47
49
|
/** when the event was generated */
|
|
48
50
|
eventTimestamp: Date | undefined;
|
|
51
|
+
/** metadata for the event */
|
|
52
|
+
additionalMetadata?: string | undefined;
|
|
49
53
|
}
|
|
50
54
|
export interface ReplayEventRequest {
|
|
51
55
|
/** the event id to replay */
|
package/protoc/events/events.js
CHANGED
|
@@ -28,7 +28,14 @@ const _m0 = __importStar(require("protobufjs/minimal"));
|
|
|
28
28
|
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
29
29
|
exports.protobufPackage = '';
|
|
30
30
|
function createBaseEvent() {
|
|
31
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
tenantId: '',
|
|
33
|
+
eventId: '',
|
|
34
|
+
key: '',
|
|
35
|
+
payload: '',
|
|
36
|
+
eventTimestamp: undefined,
|
|
37
|
+
additionalMetadata: undefined,
|
|
38
|
+
};
|
|
32
39
|
}
|
|
33
40
|
exports.Event = {
|
|
34
41
|
encode(message, writer = _m0.Writer.create()) {
|
|
@@ -47,6 +54,9 @@ exports.Event = {
|
|
|
47
54
|
if (message.eventTimestamp !== undefined) {
|
|
48
55
|
timestamp_1.Timestamp.encode(toTimestamp(message.eventTimestamp), writer.uint32(42).fork()).ldelim();
|
|
49
56
|
}
|
|
57
|
+
if (message.additionalMetadata !== undefined) {
|
|
58
|
+
writer.uint32(50).string(message.additionalMetadata);
|
|
59
|
+
}
|
|
50
60
|
return writer;
|
|
51
61
|
},
|
|
52
62
|
decode(input, length) {
|
|
@@ -86,6 +96,12 @@ exports.Event = {
|
|
|
86
96
|
}
|
|
87
97
|
message.eventTimestamp = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
88
98
|
continue;
|
|
99
|
+
case 6:
|
|
100
|
+
if (tag !== 50) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
message.additionalMetadata = reader.string();
|
|
104
|
+
continue;
|
|
89
105
|
}
|
|
90
106
|
if ((tag & 7) === 4 || tag === 0) {
|
|
91
107
|
break;
|
|
@@ -103,6 +119,9 @@ exports.Event = {
|
|
|
103
119
|
eventTimestamp: isSet(object.eventTimestamp)
|
|
104
120
|
? fromJsonTimestamp(object.eventTimestamp)
|
|
105
121
|
: undefined,
|
|
122
|
+
additionalMetadata: isSet(object.additionalMetadata)
|
|
123
|
+
? globalThis.String(object.additionalMetadata)
|
|
124
|
+
: undefined,
|
|
106
125
|
};
|
|
107
126
|
},
|
|
108
127
|
toJSON(message) {
|
|
@@ -122,19 +141,23 @@ exports.Event = {
|
|
|
122
141
|
if (message.eventTimestamp !== undefined) {
|
|
123
142
|
obj.eventTimestamp = message.eventTimestamp.toISOString();
|
|
124
143
|
}
|
|
144
|
+
if (message.additionalMetadata !== undefined) {
|
|
145
|
+
obj.additionalMetadata = message.additionalMetadata;
|
|
146
|
+
}
|
|
125
147
|
return obj;
|
|
126
148
|
},
|
|
127
149
|
create(base) {
|
|
128
150
|
return exports.Event.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
129
151
|
},
|
|
130
152
|
fromPartial(object) {
|
|
131
|
-
var _a, _b, _c, _d, _e;
|
|
153
|
+
var _a, _b, _c, _d, _e, _f;
|
|
132
154
|
const message = createBaseEvent();
|
|
133
155
|
message.tenantId = (_a = object.tenantId) !== null && _a !== void 0 ? _a : '';
|
|
134
156
|
message.eventId = (_b = object.eventId) !== null && _b !== void 0 ? _b : '';
|
|
135
157
|
message.key = (_c = object.key) !== null && _c !== void 0 ? _c : '';
|
|
136
158
|
message.payload = (_d = object.payload) !== null && _d !== void 0 ? _d : '';
|
|
137
159
|
message.eventTimestamp = (_e = object.eventTimestamp) !== null && _e !== void 0 ? _e : undefined;
|
|
160
|
+
message.additionalMetadata = (_f = object.additionalMetadata) !== null && _f !== void 0 ? _f : undefined;
|
|
138
161
|
return message;
|
|
139
162
|
},
|
|
140
163
|
};
|
|
@@ -417,7 +440,7 @@ exports.PutStreamEventResponse = {
|
|
|
417
440
|
},
|
|
418
441
|
};
|
|
419
442
|
function createBasePushEventRequest() {
|
|
420
|
-
return { key: '', payload: '', eventTimestamp: undefined };
|
|
443
|
+
return { key: '', payload: '', eventTimestamp: undefined, additionalMetadata: undefined };
|
|
421
444
|
}
|
|
422
445
|
exports.PushEventRequest = {
|
|
423
446
|
encode(message, writer = _m0.Writer.create()) {
|
|
@@ -430,6 +453,9 @@ exports.PushEventRequest = {
|
|
|
430
453
|
if (message.eventTimestamp !== undefined) {
|
|
431
454
|
timestamp_1.Timestamp.encode(toTimestamp(message.eventTimestamp), writer.uint32(26).fork()).ldelim();
|
|
432
455
|
}
|
|
456
|
+
if (message.additionalMetadata !== undefined) {
|
|
457
|
+
writer.uint32(34).string(message.additionalMetadata);
|
|
458
|
+
}
|
|
433
459
|
return writer;
|
|
434
460
|
},
|
|
435
461
|
decode(input, length) {
|
|
@@ -457,6 +483,12 @@ exports.PushEventRequest = {
|
|
|
457
483
|
}
|
|
458
484
|
message.eventTimestamp = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
459
485
|
continue;
|
|
486
|
+
case 4:
|
|
487
|
+
if (tag !== 34) {
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
message.additionalMetadata = reader.string();
|
|
491
|
+
continue;
|
|
460
492
|
}
|
|
461
493
|
if ((tag & 7) === 4 || tag === 0) {
|
|
462
494
|
break;
|
|
@@ -472,6 +504,9 @@ exports.PushEventRequest = {
|
|
|
472
504
|
eventTimestamp: isSet(object.eventTimestamp)
|
|
473
505
|
? fromJsonTimestamp(object.eventTimestamp)
|
|
474
506
|
: undefined,
|
|
507
|
+
additionalMetadata: isSet(object.additionalMetadata)
|
|
508
|
+
? globalThis.String(object.additionalMetadata)
|
|
509
|
+
: undefined,
|
|
475
510
|
};
|
|
476
511
|
},
|
|
477
512
|
toJSON(message) {
|
|
@@ -485,17 +520,21 @@ exports.PushEventRequest = {
|
|
|
485
520
|
if (message.eventTimestamp !== undefined) {
|
|
486
521
|
obj.eventTimestamp = message.eventTimestamp.toISOString();
|
|
487
522
|
}
|
|
523
|
+
if (message.additionalMetadata !== undefined) {
|
|
524
|
+
obj.additionalMetadata = message.additionalMetadata;
|
|
525
|
+
}
|
|
488
526
|
return obj;
|
|
489
527
|
},
|
|
490
528
|
create(base) {
|
|
491
529
|
return exports.PushEventRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
492
530
|
},
|
|
493
531
|
fromPartial(object) {
|
|
494
|
-
var _a, _b, _c;
|
|
532
|
+
var _a, _b, _c, _d;
|
|
495
533
|
const message = createBasePushEventRequest();
|
|
496
534
|
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
|
|
497
535
|
message.payload = (_b = object.payload) !== null && _b !== void 0 ? _b : '';
|
|
498
536
|
message.eventTimestamp = (_c = object.eventTimestamp) !== null && _c !== void 0 ? _c : undefined;
|
|
537
|
+
message.additionalMetadata = (_d = object.additionalMetadata) !== null && _d !== void 0 ? _d : undefined;
|
|
499
538
|
return message;
|
|
500
539
|
},
|
|
501
540
|
};
|
|
@@ -43,6 +43,8 @@ export interface CreateWorkflowVersionOpts {
|
|
|
43
43
|
scheduleTimeout?: string | undefined;
|
|
44
44
|
/** (optional) the input for the cron trigger */
|
|
45
45
|
cronInput?: string | undefined;
|
|
46
|
+
/** (optional) the job to run on failure */
|
|
47
|
+
onFailureJob?: CreateWorkflowJobOpts | undefined;
|
|
46
48
|
}
|
|
47
49
|
export interface WorkflowConcurrencyOpts {
|
|
48
50
|
/** (required) the action id for getting the concurrency group */
|
|
@@ -148,6 +150,8 @@ export interface TriggerWorkflowRequest {
|
|
|
148
150
|
* child index/key match an existing workflow run.
|
|
149
151
|
*/
|
|
150
152
|
childKey?: string | undefined;
|
|
153
|
+
/** (optional) additional metadata for the workflow */
|
|
154
|
+
additionalMetadata?: string | undefined;
|
|
151
155
|
}
|
|
152
156
|
export interface TriggerWorkflowResponse {
|
|
153
157
|
workflowRunId: string;
|
|
@@ -178,6 +178,7 @@ function createBaseCreateWorkflowVersionOpts() {
|
|
|
178
178
|
concurrency: undefined,
|
|
179
179
|
scheduleTimeout: undefined,
|
|
180
180
|
cronInput: undefined,
|
|
181
|
+
onFailureJob: undefined,
|
|
181
182
|
};
|
|
182
183
|
}
|
|
183
184
|
exports.CreateWorkflowVersionOpts = {
|
|
@@ -212,6 +213,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
212
213
|
if (message.cronInput !== undefined) {
|
|
213
214
|
writer.uint32(82).string(message.cronInput);
|
|
214
215
|
}
|
|
216
|
+
if (message.onFailureJob !== undefined) {
|
|
217
|
+
exports.CreateWorkflowJobOpts.encode(message.onFailureJob, writer.uint32(90).fork()).ldelim();
|
|
218
|
+
}
|
|
215
219
|
return writer;
|
|
216
220
|
},
|
|
217
221
|
decode(input, length) {
|
|
@@ -281,6 +285,12 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
281
285
|
}
|
|
282
286
|
message.cronInput = reader.string();
|
|
283
287
|
continue;
|
|
288
|
+
case 11:
|
|
289
|
+
if (tag !== 90) {
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
message.onFailureJob = exports.CreateWorkflowJobOpts.decode(reader, reader.uint32());
|
|
293
|
+
continue;
|
|
284
294
|
}
|
|
285
295
|
if ((tag & 7) === 4 || tag === 0) {
|
|
286
296
|
break;
|
|
@@ -313,6 +323,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
313
323
|
? globalThis.String(object.scheduleTimeout)
|
|
314
324
|
: undefined,
|
|
315
325
|
cronInput: isSet(object.cronInput) ? globalThis.String(object.cronInput) : undefined,
|
|
326
|
+
onFailureJob: isSet(object.onFailureJob)
|
|
327
|
+
? exports.CreateWorkflowJobOpts.fromJSON(object.onFailureJob)
|
|
328
|
+
: undefined,
|
|
316
329
|
};
|
|
317
330
|
},
|
|
318
331
|
toJSON(message) {
|
|
@@ -348,6 +361,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
348
361
|
if (message.cronInput !== undefined) {
|
|
349
362
|
obj.cronInput = message.cronInput;
|
|
350
363
|
}
|
|
364
|
+
if (message.onFailureJob !== undefined) {
|
|
365
|
+
obj.onFailureJob = exports.CreateWorkflowJobOpts.toJSON(message.onFailureJob);
|
|
366
|
+
}
|
|
351
367
|
return obj;
|
|
352
368
|
},
|
|
353
369
|
create(base) {
|
|
@@ -369,6 +385,10 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
369
385
|
: undefined;
|
|
370
386
|
message.scheduleTimeout = (_h = object.scheduleTimeout) !== null && _h !== void 0 ? _h : undefined;
|
|
371
387
|
message.cronInput = (_j = object.cronInput) !== null && _j !== void 0 ? _j : undefined;
|
|
388
|
+
message.onFailureJob =
|
|
389
|
+
object.onFailureJob !== undefined && object.onFailureJob !== null
|
|
390
|
+
? exports.CreateWorkflowJobOpts.fromPartial(object.onFailureJob)
|
|
391
|
+
: undefined;
|
|
372
392
|
return message;
|
|
373
393
|
},
|
|
374
394
|
};
|
|
@@ -1230,6 +1250,7 @@ function createBaseTriggerWorkflowRequest() {
|
|
|
1230
1250
|
parentStepRunId: undefined,
|
|
1231
1251
|
childIndex: undefined,
|
|
1232
1252
|
childKey: undefined,
|
|
1253
|
+
additionalMetadata: undefined,
|
|
1233
1254
|
};
|
|
1234
1255
|
}
|
|
1235
1256
|
exports.TriggerWorkflowRequest = {
|
|
@@ -1252,6 +1273,9 @@ exports.TriggerWorkflowRequest = {
|
|
|
1252
1273
|
if (message.childKey !== undefined) {
|
|
1253
1274
|
writer.uint32(50).string(message.childKey);
|
|
1254
1275
|
}
|
|
1276
|
+
if (message.additionalMetadata !== undefined) {
|
|
1277
|
+
writer.uint32(58).string(message.additionalMetadata);
|
|
1278
|
+
}
|
|
1255
1279
|
return writer;
|
|
1256
1280
|
},
|
|
1257
1281
|
decode(input, length) {
|
|
@@ -1297,6 +1321,12 @@ exports.TriggerWorkflowRequest = {
|
|
|
1297
1321
|
}
|
|
1298
1322
|
message.childKey = reader.string();
|
|
1299
1323
|
continue;
|
|
1324
|
+
case 7:
|
|
1325
|
+
if (tag !== 58) {
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1328
|
+
message.additionalMetadata = reader.string();
|
|
1329
|
+
continue;
|
|
1300
1330
|
}
|
|
1301
1331
|
if ((tag & 7) === 4 || tag === 0) {
|
|
1302
1332
|
break;
|
|
@@ -1315,6 +1345,9 @@ exports.TriggerWorkflowRequest = {
|
|
|
1315
1345
|
: undefined,
|
|
1316
1346
|
childIndex: isSet(object.childIndex) ? globalThis.Number(object.childIndex) : undefined,
|
|
1317
1347
|
childKey: isSet(object.childKey) ? globalThis.String(object.childKey) : undefined,
|
|
1348
|
+
additionalMetadata: isSet(object.additionalMetadata)
|
|
1349
|
+
? globalThis.String(object.additionalMetadata)
|
|
1350
|
+
: undefined,
|
|
1318
1351
|
};
|
|
1319
1352
|
},
|
|
1320
1353
|
toJSON(message) {
|
|
@@ -1337,13 +1370,16 @@ exports.TriggerWorkflowRequest = {
|
|
|
1337
1370
|
if (message.childKey !== undefined) {
|
|
1338
1371
|
obj.childKey = message.childKey;
|
|
1339
1372
|
}
|
|
1373
|
+
if (message.additionalMetadata !== undefined) {
|
|
1374
|
+
obj.additionalMetadata = message.additionalMetadata;
|
|
1375
|
+
}
|
|
1340
1376
|
return obj;
|
|
1341
1377
|
},
|
|
1342
1378
|
create(base) {
|
|
1343
1379
|
return exports.TriggerWorkflowRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1344
1380
|
},
|
|
1345
1381
|
fromPartial(object) {
|
|
1346
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1382
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1347
1383
|
const message = createBaseTriggerWorkflowRequest();
|
|
1348
1384
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
1349
1385
|
message.input = (_b = object.input) !== null && _b !== void 0 ? _b : '';
|
|
@@ -1351,6 +1387,7 @@ exports.TriggerWorkflowRequest = {
|
|
|
1351
1387
|
message.parentStepRunId = (_d = object.parentStepRunId) !== null && _d !== void 0 ? _d : undefined;
|
|
1352
1388
|
message.childIndex = (_e = object.childIndex) !== null && _e !== void 0 ? _e : undefined;
|
|
1353
1389
|
message.childKey = (_f = object.childKey) !== null && _f !== void 0 ? _f : undefined;
|
|
1390
|
+
message.additionalMetadata = (_g = object.additionalMetadata) !== null && _g !== void 0 ? _g : undefined;
|
|
1354
1391
|
return message;
|
|
1355
1392
|
},
|
|
1356
1393
|
};
|
package/workflow.d.ts
CHANGED
|
@@ -56,6 +56,9 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
56
56
|
description: z.ZodString;
|
|
57
57
|
version: z.ZodOptional<z.ZodString>;
|
|
58
58
|
scheduleTimeout: z.ZodOptional<z.ZodString>;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Workflow timeout is deprecated. Use step timeouts instead.
|
|
61
|
+
*/
|
|
59
62
|
timeout: z.ZodOptional<z.ZodString>;
|
|
60
63
|
on: z.ZodUnion<[z.ZodObject<{
|
|
61
64
|
cron: z.ZodString;
|
|
@@ -110,6 +113,40 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
110
113
|
units: number;
|
|
111
114
|
}[] | undefined;
|
|
112
115
|
}>, "many">;
|
|
116
|
+
onFailure: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
119
|
+
timeout: z.ZodOptional<z.ZodString>;
|
|
120
|
+
retries: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
rate_limits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
122
|
+
key: z.ZodString;
|
|
123
|
+
units: z.ZodNumber;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
key: string;
|
|
126
|
+
units: number;
|
|
127
|
+
}, {
|
|
128
|
+
key: string;
|
|
129
|
+
units: number;
|
|
130
|
+
}>, "many">>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
name: string;
|
|
133
|
+
parents?: string[] | undefined;
|
|
134
|
+
timeout?: string | undefined;
|
|
135
|
+
retries?: number | undefined;
|
|
136
|
+
rate_limits?: {
|
|
137
|
+
key: string;
|
|
138
|
+
units: number;
|
|
139
|
+
}[] | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
name: string;
|
|
142
|
+
parents?: string[] | undefined;
|
|
143
|
+
timeout?: string | undefined;
|
|
144
|
+
retries?: number | undefined;
|
|
145
|
+
rate_limits?: {
|
|
146
|
+
key: string;
|
|
147
|
+
units: number;
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
}>>;
|
|
113
150
|
}, "strip", z.ZodTypeAny, {
|
|
114
151
|
description: string;
|
|
115
152
|
steps: {
|
|
@@ -133,6 +170,16 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
133
170
|
version?: string | undefined;
|
|
134
171
|
scheduleTimeout?: string | undefined;
|
|
135
172
|
timeout?: string | undefined;
|
|
173
|
+
onFailure?: {
|
|
174
|
+
name: string;
|
|
175
|
+
parents?: string[] | undefined;
|
|
176
|
+
timeout?: string | undefined;
|
|
177
|
+
retries?: number | undefined;
|
|
178
|
+
rate_limits?: {
|
|
179
|
+
key: string;
|
|
180
|
+
units: number;
|
|
181
|
+
}[] | undefined;
|
|
182
|
+
} | undefined;
|
|
136
183
|
}, {
|
|
137
184
|
description: string;
|
|
138
185
|
steps: {
|
|
@@ -156,11 +203,22 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
156
203
|
version?: string | undefined;
|
|
157
204
|
scheduleTimeout?: string | undefined;
|
|
158
205
|
timeout?: string | undefined;
|
|
206
|
+
onFailure?: {
|
|
207
|
+
name: string;
|
|
208
|
+
parents?: string[] | undefined;
|
|
209
|
+
timeout?: string | undefined;
|
|
210
|
+
retries?: number | undefined;
|
|
211
|
+
rate_limits?: {
|
|
212
|
+
key: string;
|
|
213
|
+
units: number;
|
|
214
|
+
}[] | undefined;
|
|
215
|
+
} | undefined;
|
|
159
216
|
}>;
|
|
160
217
|
export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
|
|
161
218
|
concurrency?: z.infer<typeof WorkflowConcurrency> & {
|
|
162
219
|
key: (ctx: any) => string;
|
|
163
220
|
};
|
|
164
221
|
steps: CreateStep<any, any>[];
|
|
222
|
+
onFailure?: CreateStep<any, any>;
|
|
165
223
|
}
|
|
166
224
|
export {};
|
package/workflow.js
CHANGED
|
@@ -49,7 +49,11 @@ exports.CreateWorkflowSchema = z.object({
|
|
|
49
49
|
description: z.string(),
|
|
50
50
|
version: z.string().optional(),
|
|
51
51
|
scheduleTimeout: z.string().optional(),
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Workflow timeout is deprecated. Use step timeouts instead.
|
|
54
|
+
*/
|
|
52
55
|
timeout: exports.HatchetTimeoutSchema.optional(),
|
|
53
56
|
on: OnConfigSchema,
|
|
54
57
|
steps: StepsSchema,
|
|
58
|
+
onFailure: step_1.CreateStepSchema === null || step_1.CreateStepSchema === void 0 ? void 0 : step_1.CreateStepSchema.optional(),
|
|
55
59
|
});
|