@hatchet-dev/typescript-sdk 0.5.7 → 0.6.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/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 +8 -0
- package/protoc/workflows/workflows.js +62 -1
- package/step.d.ts +1 -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.1",
|
|
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
|
};
|
|
@@ -14,6 +14,10 @@ export declare enum RateLimitDuration {
|
|
|
14
14
|
SECOND = 0,
|
|
15
15
|
MINUTE = 1,
|
|
16
16
|
HOUR = 2,
|
|
17
|
+
DAY = 3,
|
|
18
|
+
WEEK = 4,
|
|
19
|
+
MONTH = 5,
|
|
20
|
+
YEAR = 6,
|
|
17
21
|
UNRECOGNIZED = -1
|
|
18
22
|
}
|
|
19
23
|
export declare function rateLimitDurationFromJSON(object: any): RateLimitDuration;
|
|
@@ -43,6 +47,8 @@ export interface CreateWorkflowVersionOpts {
|
|
|
43
47
|
scheduleTimeout?: string | undefined;
|
|
44
48
|
/** (optional) the input for the cron trigger */
|
|
45
49
|
cronInput?: string | undefined;
|
|
50
|
+
/** (optional) the job to run on failure */
|
|
51
|
+
onFailureJob?: CreateWorkflowJobOpts | undefined;
|
|
46
52
|
}
|
|
47
53
|
export interface WorkflowConcurrencyOpts {
|
|
48
54
|
/** (required) the action id for getting the concurrency group */
|
|
@@ -148,6 +154,8 @@ export interface TriggerWorkflowRequest {
|
|
|
148
154
|
* child index/key match an existing workflow run.
|
|
149
155
|
*/
|
|
150
156
|
childKey?: string | undefined;
|
|
157
|
+
/** (optional) additional metadata for the workflow */
|
|
158
|
+
additionalMetadata?: string | undefined;
|
|
151
159
|
}
|
|
152
160
|
export interface TriggerWorkflowResponse {
|
|
153
161
|
workflowRunId: string;
|
|
@@ -77,6 +77,10 @@ var RateLimitDuration;
|
|
|
77
77
|
RateLimitDuration[RateLimitDuration["SECOND"] = 0] = "SECOND";
|
|
78
78
|
RateLimitDuration[RateLimitDuration["MINUTE"] = 1] = "MINUTE";
|
|
79
79
|
RateLimitDuration[RateLimitDuration["HOUR"] = 2] = "HOUR";
|
|
80
|
+
RateLimitDuration[RateLimitDuration["DAY"] = 3] = "DAY";
|
|
81
|
+
RateLimitDuration[RateLimitDuration["WEEK"] = 4] = "WEEK";
|
|
82
|
+
RateLimitDuration[RateLimitDuration["MONTH"] = 5] = "MONTH";
|
|
83
|
+
RateLimitDuration[RateLimitDuration["YEAR"] = 6] = "YEAR";
|
|
80
84
|
RateLimitDuration[RateLimitDuration["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
81
85
|
})(RateLimitDuration || (exports.RateLimitDuration = RateLimitDuration = {}));
|
|
82
86
|
function rateLimitDurationFromJSON(object) {
|
|
@@ -90,6 +94,18 @@ function rateLimitDurationFromJSON(object) {
|
|
|
90
94
|
case 2:
|
|
91
95
|
case 'HOUR':
|
|
92
96
|
return RateLimitDuration.HOUR;
|
|
97
|
+
case 3:
|
|
98
|
+
case 'DAY':
|
|
99
|
+
return RateLimitDuration.DAY;
|
|
100
|
+
case 4:
|
|
101
|
+
case 'WEEK':
|
|
102
|
+
return RateLimitDuration.WEEK;
|
|
103
|
+
case 5:
|
|
104
|
+
case 'MONTH':
|
|
105
|
+
return RateLimitDuration.MONTH;
|
|
106
|
+
case 6:
|
|
107
|
+
case 'YEAR':
|
|
108
|
+
return RateLimitDuration.YEAR;
|
|
93
109
|
case -1:
|
|
94
110
|
case 'UNRECOGNIZED':
|
|
95
111
|
default:
|
|
@@ -105,6 +121,14 @@ function rateLimitDurationToJSON(object) {
|
|
|
105
121
|
return 'MINUTE';
|
|
106
122
|
case RateLimitDuration.HOUR:
|
|
107
123
|
return 'HOUR';
|
|
124
|
+
case RateLimitDuration.DAY:
|
|
125
|
+
return 'DAY';
|
|
126
|
+
case RateLimitDuration.WEEK:
|
|
127
|
+
return 'WEEK';
|
|
128
|
+
case RateLimitDuration.MONTH:
|
|
129
|
+
return 'MONTH';
|
|
130
|
+
case RateLimitDuration.YEAR:
|
|
131
|
+
return 'YEAR';
|
|
108
132
|
case RateLimitDuration.UNRECOGNIZED:
|
|
109
133
|
default:
|
|
110
134
|
return 'UNRECOGNIZED';
|
|
@@ -178,6 +202,7 @@ function createBaseCreateWorkflowVersionOpts() {
|
|
|
178
202
|
concurrency: undefined,
|
|
179
203
|
scheduleTimeout: undefined,
|
|
180
204
|
cronInput: undefined,
|
|
205
|
+
onFailureJob: undefined,
|
|
181
206
|
};
|
|
182
207
|
}
|
|
183
208
|
exports.CreateWorkflowVersionOpts = {
|
|
@@ -212,6 +237,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
212
237
|
if (message.cronInput !== undefined) {
|
|
213
238
|
writer.uint32(82).string(message.cronInput);
|
|
214
239
|
}
|
|
240
|
+
if (message.onFailureJob !== undefined) {
|
|
241
|
+
exports.CreateWorkflowJobOpts.encode(message.onFailureJob, writer.uint32(90).fork()).ldelim();
|
|
242
|
+
}
|
|
215
243
|
return writer;
|
|
216
244
|
},
|
|
217
245
|
decode(input, length) {
|
|
@@ -281,6 +309,12 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
281
309
|
}
|
|
282
310
|
message.cronInput = reader.string();
|
|
283
311
|
continue;
|
|
312
|
+
case 11:
|
|
313
|
+
if (tag !== 90) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
message.onFailureJob = exports.CreateWorkflowJobOpts.decode(reader, reader.uint32());
|
|
317
|
+
continue;
|
|
284
318
|
}
|
|
285
319
|
if ((tag & 7) === 4 || tag === 0) {
|
|
286
320
|
break;
|
|
@@ -313,6 +347,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
313
347
|
? globalThis.String(object.scheduleTimeout)
|
|
314
348
|
: undefined,
|
|
315
349
|
cronInput: isSet(object.cronInput) ? globalThis.String(object.cronInput) : undefined,
|
|
350
|
+
onFailureJob: isSet(object.onFailureJob)
|
|
351
|
+
? exports.CreateWorkflowJobOpts.fromJSON(object.onFailureJob)
|
|
352
|
+
: undefined,
|
|
316
353
|
};
|
|
317
354
|
},
|
|
318
355
|
toJSON(message) {
|
|
@@ -348,6 +385,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
348
385
|
if (message.cronInput !== undefined) {
|
|
349
386
|
obj.cronInput = message.cronInput;
|
|
350
387
|
}
|
|
388
|
+
if (message.onFailureJob !== undefined) {
|
|
389
|
+
obj.onFailureJob = exports.CreateWorkflowJobOpts.toJSON(message.onFailureJob);
|
|
390
|
+
}
|
|
351
391
|
return obj;
|
|
352
392
|
},
|
|
353
393
|
create(base) {
|
|
@@ -369,6 +409,10 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
369
409
|
: undefined;
|
|
370
410
|
message.scheduleTimeout = (_h = object.scheduleTimeout) !== null && _h !== void 0 ? _h : undefined;
|
|
371
411
|
message.cronInput = (_j = object.cronInput) !== null && _j !== void 0 ? _j : undefined;
|
|
412
|
+
message.onFailureJob =
|
|
413
|
+
object.onFailureJob !== undefined && object.onFailureJob !== null
|
|
414
|
+
? exports.CreateWorkflowJobOpts.fromPartial(object.onFailureJob)
|
|
415
|
+
: undefined;
|
|
372
416
|
return message;
|
|
373
417
|
},
|
|
374
418
|
};
|
|
@@ -1230,6 +1274,7 @@ function createBaseTriggerWorkflowRequest() {
|
|
|
1230
1274
|
parentStepRunId: undefined,
|
|
1231
1275
|
childIndex: undefined,
|
|
1232
1276
|
childKey: undefined,
|
|
1277
|
+
additionalMetadata: undefined,
|
|
1233
1278
|
};
|
|
1234
1279
|
}
|
|
1235
1280
|
exports.TriggerWorkflowRequest = {
|
|
@@ -1252,6 +1297,9 @@ exports.TriggerWorkflowRequest = {
|
|
|
1252
1297
|
if (message.childKey !== undefined) {
|
|
1253
1298
|
writer.uint32(50).string(message.childKey);
|
|
1254
1299
|
}
|
|
1300
|
+
if (message.additionalMetadata !== undefined) {
|
|
1301
|
+
writer.uint32(58).string(message.additionalMetadata);
|
|
1302
|
+
}
|
|
1255
1303
|
return writer;
|
|
1256
1304
|
},
|
|
1257
1305
|
decode(input, length) {
|
|
@@ -1297,6 +1345,12 @@ exports.TriggerWorkflowRequest = {
|
|
|
1297
1345
|
}
|
|
1298
1346
|
message.childKey = reader.string();
|
|
1299
1347
|
continue;
|
|
1348
|
+
case 7:
|
|
1349
|
+
if (tag !== 58) {
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
message.additionalMetadata = reader.string();
|
|
1353
|
+
continue;
|
|
1300
1354
|
}
|
|
1301
1355
|
if ((tag & 7) === 4 || tag === 0) {
|
|
1302
1356
|
break;
|
|
@@ -1315,6 +1369,9 @@ exports.TriggerWorkflowRequest = {
|
|
|
1315
1369
|
: undefined,
|
|
1316
1370
|
childIndex: isSet(object.childIndex) ? globalThis.Number(object.childIndex) : undefined,
|
|
1317
1371
|
childKey: isSet(object.childKey) ? globalThis.String(object.childKey) : undefined,
|
|
1372
|
+
additionalMetadata: isSet(object.additionalMetadata)
|
|
1373
|
+
? globalThis.String(object.additionalMetadata)
|
|
1374
|
+
: undefined,
|
|
1318
1375
|
};
|
|
1319
1376
|
},
|
|
1320
1377
|
toJSON(message) {
|
|
@@ -1337,13 +1394,16 @@ exports.TriggerWorkflowRequest = {
|
|
|
1337
1394
|
if (message.childKey !== undefined) {
|
|
1338
1395
|
obj.childKey = message.childKey;
|
|
1339
1396
|
}
|
|
1397
|
+
if (message.additionalMetadata !== undefined) {
|
|
1398
|
+
obj.additionalMetadata = message.additionalMetadata;
|
|
1399
|
+
}
|
|
1340
1400
|
return obj;
|
|
1341
1401
|
},
|
|
1342
1402
|
create(base) {
|
|
1343
1403
|
return exports.TriggerWorkflowRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1344
1404
|
},
|
|
1345
1405
|
fromPartial(object) {
|
|
1346
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1406
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1347
1407
|
const message = createBaseTriggerWorkflowRequest();
|
|
1348
1408
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
1349
1409
|
message.input = (_b = object.input) !== null && _b !== void 0 ? _b : '';
|
|
@@ -1351,6 +1411,7 @@ exports.TriggerWorkflowRequest = {
|
|
|
1351
1411
|
message.parentStepRunId = (_d = object.parentStepRunId) !== null && _d !== void 0 ? _d : undefined;
|
|
1352
1412
|
message.childIndex = (_e = object.childIndex) !== null && _e !== void 0 ? _e : undefined;
|
|
1353
1413
|
message.childKey = (_f = object.childKey) !== null && _f !== void 0 ? _f : undefined;
|
|
1414
|
+
message.additionalMetadata = (_g = object.additionalMetadata) !== null && _g !== void 0 ? _g : undefined;
|
|
1354
1415
|
return message;
|
|
1355
1416
|
},
|
|
1356
1417
|
};
|
package/step.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export declare class Context<T, K> {
|
|
|
87
87
|
playground(name: string, defaultValue?: string): string;
|
|
88
88
|
log(message: string, level?: LogLevel): void;
|
|
89
89
|
putStream(data: string | Uint8Array): Promise<void>;
|
|
90
|
-
spawnWorkflow<P = unknown>(workflowName: string, input:
|
|
90
|
+
spawnWorkflow<P = unknown, Q = unknown>(workflowName: string, input: Q, key?: string): ChildWorkflowRef<P>;
|
|
91
91
|
}
|
|
92
92
|
export type StepRunFunction<T, K> = (ctx: Context<T, K>) => Promise<NextStep> | NextStep | void;
|
|
93
93
|
export interface CreateStep<T, K> extends z.infer<typeof CreateStepSchema> {
|
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
|
});
|