@hatchet-dev/typescript-sdk 1.11.0 → 1.12.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 +38 -0
- package/clients/admin/admin-client.js +19 -6
- package/clients/dispatcher/action-listener.d.ts +6 -2
- package/clients/dispatcher/action-listener.js +2 -2
- package/clients/dispatcher/dispatcher-client.d.ts +8 -2
- package/clients/dispatcher/dispatcher-client.js +18 -4
- package/clients/event/event-client.d.ts +2 -2
- package/clients/event/event-client.js +4 -4
- package/clients/hatchet-client/hatchet-logger.js +2 -2
- package/clients/rest/generated/data-contracts.d.ts +1 -1
- package/clients/worker/worker.js +11 -11
- package/examples/webhooks.d.ts +1 -0
- package/examples/webhooks.js +45 -0
- package/package.json +1 -1
- package/protoc/dispatcher/dispatcher.d.ts +25 -25
- package/protoc/dispatcher/dispatcher.js +109 -95
- package/protoc/events/events.d.ts +4 -4
- package/protoc/events/events.js +20 -16
- package/protoc/v1/workflows.d.ts +7 -7
- package/protoc/workflows/workflows.d.ts +22 -22
- package/protoc/workflows/workflows.js +18 -18
- package/step.d.ts +1 -1
- package/step.js +19 -19
- package/util/workflow-run-ref.js +1 -1
- package/v1/client/admin.d.ts +30 -0
- package/v1/client/admin.js +21 -6
- package/v1/client/client.d.ts +8 -1
- package/v1/client/client.js +12 -1
- package/v1/client/features/runs.d.ts +9 -1
- package/v1/client/features/runs.js +4 -2
- package/v1/client/features/webhooks.d.ts +28 -0
- package/v1/client/features/webhooks.js +97 -0
- package/v1/client/worker/context.d.ts +1 -1
- package/v1/client/worker/context.js +23 -23
- package/v1/client/worker/worker-internal.d.ts +2 -2
- package/v1/client/worker/worker-internal.js +25 -25
- package/v1/declaration.js +1 -1
- package/v1/parent-run-context-vars.d.ts +4 -1
- package/v1/parent-run-context-vars.js +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/protoc/events/events.js
CHANGED
|
@@ -225,7 +225,7 @@ exports.Events = {
|
|
|
225
225
|
};
|
|
226
226
|
function createBasePutLogRequest() {
|
|
227
227
|
return {
|
|
228
|
-
|
|
228
|
+
taskRunExternalId: '',
|
|
229
229
|
createdAt: undefined,
|
|
230
230
|
message: '',
|
|
231
231
|
level: undefined,
|
|
@@ -235,8 +235,8 @@ function createBasePutLogRequest() {
|
|
|
235
235
|
}
|
|
236
236
|
exports.PutLogRequest = {
|
|
237
237
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
238
|
-
if (message.
|
|
239
|
-
writer.uint32(10).string(message.
|
|
238
|
+
if (message.taskRunExternalId !== '') {
|
|
239
|
+
writer.uint32(10).string(message.taskRunExternalId);
|
|
240
240
|
}
|
|
241
241
|
if (message.createdAt !== undefined) {
|
|
242
242
|
timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(18).fork()).join();
|
|
@@ -266,7 +266,7 @@ exports.PutLogRequest = {
|
|
|
266
266
|
if (tag !== 10) {
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
269
|
-
message.
|
|
269
|
+
message.taskRunExternalId = reader.string();
|
|
270
270
|
continue;
|
|
271
271
|
}
|
|
272
272
|
case 2: {
|
|
@@ -314,7 +314,9 @@ exports.PutLogRequest = {
|
|
|
314
314
|
},
|
|
315
315
|
fromJSON(object) {
|
|
316
316
|
return {
|
|
317
|
-
|
|
317
|
+
taskRunExternalId: isSet(object.taskRunExternalId)
|
|
318
|
+
? globalThis.String(object.taskRunExternalId)
|
|
319
|
+
: '',
|
|
318
320
|
createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
|
|
319
321
|
message: isSet(object.message) ? globalThis.String(object.message) : '',
|
|
320
322
|
level: isSet(object.level) ? globalThis.String(object.level) : undefined,
|
|
@@ -326,8 +328,8 @@ exports.PutLogRequest = {
|
|
|
326
328
|
},
|
|
327
329
|
toJSON(message) {
|
|
328
330
|
const obj = {};
|
|
329
|
-
if (message.
|
|
330
|
-
obj.
|
|
331
|
+
if (message.taskRunExternalId !== '') {
|
|
332
|
+
obj.taskRunExternalId = message.taskRunExternalId;
|
|
331
333
|
}
|
|
332
334
|
if (message.createdAt !== undefined) {
|
|
333
335
|
obj.createdAt = message.createdAt.toISOString();
|
|
@@ -352,7 +354,7 @@ exports.PutLogRequest = {
|
|
|
352
354
|
fromPartial(object) {
|
|
353
355
|
var _a, _b, _c, _d, _e, _f;
|
|
354
356
|
const message = createBasePutLogRequest();
|
|
355
|
-
message.
|
|
357
|
+
message.taskRunExternalId = (_a = object.taskRunExternalId) !== null && _a !== void 0 ? _a : '';
|
|
356
358
|
message.createdAt = (_b = object.createdAt) !== null && _b !== void 0 ? _b : undefined;
|
|
357
359
|
message.message = (_c = object.message) !== null && _c !== void 0 ? _c : '';
|
|
358
360
|
message.level = (_d = object.level) !== null && _d !== void 0 ? _d : undefined;
|
|
@@ -400,7 +402,7 @@ exports.PutLogResponse = {
|
|
|
400
402
|
};
|
|
401
403
|
function createBasePutStreamEventRequest() {
|
|
402
404
|
return {
|
|
403
|
-
|
|
405
|
+
taskRunExternalId: '',
|
|
404
406
|
createdAt: undefined,
|
|
405
407
|
message: new Uint8Array(0),
|
|
406
408
|
metadata: '',
|
|
@@ -409,8 +411,8 @@ function createBasePutStreamEventRequest() {
|
|
|
409
411
|
}
|
|
410
412
|
exports.PutStreamEventRequest = {
|
|
411
413
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
412
|
-
if (message.
|
|
413
|
-
writer.uint32(10).string(message.
|
|
414
|
+
if (message.taskRunExternalId !== '') {
|
|
415
|
+
writer.uint32(10).string(message.taskRunExternalId);
|
|
414
416
|
}
|
|
415
417
|
if (message.createdAt !== undefined) {
|
|
416
418
|
timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(18).fork()).join();
|
|
@@ -437,7 +439,7 @@ exports.PutStreamEventRequest = {
|
|
|
437
439
|
if (tag !== 10) {
|
|
438
440
|
break;
|
|
439
441
|
}
|
|
440
|
-
message.
|
|
442
|
+
message.taskRunExternalId = reader.string();
|
|
441
443
|
continue;
|
|
442
444
|
}
|
|
443
445
|
case 2: {
|
|
@@ -478,7 +480,9 @@ exports.PutStreamEventRequest = {
|
|
|
478
480
|
},
|
|
479
481
|
fromJSON(object) {
|
|
480
482
|
return {
|
|
481
|
-
|
|
483
|
+
taskRunExternalId: isSet(object.taskRunExternalId)
|
|
484
|
+
? globalThis.String(object.taskRunExternalId)
|
|
485
|
+
: '',
|
|
482
486
|
createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
|
|
483
487
|
message: isSet(object.message) ? bytesFromBase64(object.message) : new Uint8Array(0),
|
|
484
488
|
metadata: isSet(object.metadata) ? globalThis.String(object.metadata) : '',
|
|
@@ -487,8 +491,8 @@ exports.PutStreamEventRequest = {
|
|
|
487
491
|
},
|
|
488
492
|
toJSON(message) {
|
|
489
493
|
const obj = {};
|
|
490
|
-
if (message.
|
|
491
|
-
obj.
|
|
494
|
+
if (message.taskRunExternalId !== '') {
|
|
495
|
+
obj.taskRunExternalId = message.taskRunExternalId;
|
|
492
496
|
}
|
|
493
497
|
if (message.createdAt !== undefined) {
|
|
494
498
|
obj.createdAt = message.createdAt.toISOString();
|
|
@@ -510,7 +514,7 @@ exports.PutStreamEventRequest = {
|
|
|
510
514
|
fromPartial(object) {
|
|
511
515
|
var _a, _b, _c, _d, _e;
|
|
512
516
|
const message = createBasePutStreamEventRequest();
|
|
513
|
-
message.
|
|
517
|
+
message.taskRunExternalId = (_a = object.taskRunExternalId) !== null && _a !== void 0 ? _a : '';
|
|
514
518
|
message.createdAt = (_b = object.createdAt) !== null && _b !== void 0 ? _b : undefined;
|
|
515
519
|
message.message = (_c = object.message) !== null && _c !== void 0 ? _c : new Uint8Array(0);
|
|
516
520
|
message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : '';
|
package/protoc/v1/workflows.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ export interface CreateWorkflowVersionRequest {
|
|
|
106
106
|
cronInput?: string | undefined;
|
|
107
107
|
/** (optional) the job to run on failure */
|
|
108
108
|
onFailureTask?: CreateTaskOpts | undefined;
|
|
109
|
-
/** (optional) the sticky strategy for assigning
|
|
109
|
+
/** (optional) the sticky strategy for assigning tasks to workers */
|
|
110
110
|
sticky?: StickyStrategy | undefined;
|
|
111
111
|
/** (optional) the default priority for the workflow */
|
|
112
112
|
defaultPriority?: number | undefined;
|
|
@@ -167,17 +167,17 @@ export interface CreateTaskOpts {
|
|
|
167
167
|
inputs: string;
|
|
168
168
|
/** (optional) the task parents. if none are passed in, this is a root task */
|
|
169
169
|
parents: string[];
|
|
170
|
-
/** (optional) the number of retries for the
|
|
170
|
+
/** (optional) the number of retries for the task, default 0 */
|
|
171
171
|
retries: number;
|
|
172
|
-
/** (optional) the rate limits for the
|
|
172
|
+
/** (optional) the rate limits for the task */
|
|
173
173
|
rateLimits: CreateTaskRateLimit[];
|
|
174
|
-
/** (optional) the desired worker affinity state for the
|
|
174
|
+
/** (optional) the desired worker affinity state for the task */
|
|
175
175
|
workerLabels: {
|
|
176
176
|
[key: string]: DesiredWorkerLabels;
|
|
177
177
|
};
|
|
178
|
-
/** (optional) the retry backoff factor for the
|
|
178
|
+
/** (optional) the retry backoff factor for the task */
|
|
179
179
|
backoffFactor?: number | undefined;
|
|
180
|
-
/** (optional) the maximum backoff time for the
|
|
180
|
+
/** (optional) the maximum backoff time for the task */
|
|
181
181
|
backoffMaxSeconds?: number | undefined;
|
|
182
182
|
/** (optional) the task concurrency options */
|
|
183
183
|
concurrency: Concurrency[];
|
|
@@ -193,7 +193,7 @@ export interface CreateTaskOpts_WorkerLabelsEntry {
|
|
|
193
193
|
export interface CreateTaskRateLimit {
|
|
194
194
|
/** (required) the key for the rate limit */
|
|
195
195
|
key: string;
|
|
196
|
-
/** (optional) the number of units this
|
|
196
|
+
/** (optional) the number of units this task consumes */
|
|
197
197
|
units?: number | undefined;
|
|
198
198
|
/** (optional) a CEL expression for determining the rate limit key */
|
|
199
199
|
keyExpr?: string | undefined;
|
|
@@ -78,7 +78,7 @@ export interface CreateWorkflowVersionOpts {
|
|
|
78
78
|
cronInput?: string | undefined;
|
|
79
79
|
/** (optional) the job to run on failure */
|
|
80
80
|
onFailureJob?: CreateWorkflowJobOpts | undefined;
|
|
81
|
-
/** (optional) the sticky strategy for assigning
|
|
81
|
+
/** (optional) the sticky strategy for assigning tasks to workers */
|
|
82
82
|
sticky?: StickyStrategy | undefined;
|
|
83
83
|
/** (optional) the kind of workflow */
|
|
84
84
|
kind?: WorkflowKind | undefined;
|
|
@@ -101,7 +101,7 @@ export interface CreateWorkflowJobOpts {
|
|
|
101
101
|
name: string;
|
|
102
102
|
/** (optional) the job description */
|
|
103
103
|
description: string;
|
|
104
|
-
/** (required) the job
|
|
104
|
+
/** (required) the job tasks */
|
|
105
105
|
steps: CreateWorkflowStepOpts[];
|
|
106
106
|
}
|
|
107
107
|
export interface DesiredWorkerLabels {
|
|
@@ -126,31 +126,31 @@ export interface DesiredWorkerLabels {
|
|
|
126
126
|
*/
|
|
127
127
|
weight?: number | undefined;
|
|
128
128
|
}
|
|
129
|
-
/** CreateWorkflowStepOpts represents options to create a workflow
|
|
129
|
+
/** CreateWorkflowStepOpts represents options to create a workflow task. */
|
|
130
130
|
export interface CreateWorkflowStepOpts {
|
|
131
|
-
/** (required) the
|
|
131
|
+
/** (required) the task name */
|
|
132
132
|
readableId: string;
|
|
133
|
-
/** (required) the
|
|
133
|
+
/** (required) the task action id */
|
|
134
134
|
action: string;
|
|
135
|
-
/** (optional) the
|
|
135
|
+
/** (optional) the task timeout */
|
|
136
136
|
timeout: string;
|
|
137
|
-
/** (optional) the
|
|
137
|
+
/** (optional) the task inputs, assuming string representation of JSON */
|
|
138
138
|
inputs: string;
|
|
139
|
-
/** (optional) the
|
|
139
|
+
/** (optional) the task parents. if none are passed in, this is a root task */
|
|
140
140
|
parents: string[];
|
|
141
|
-
/** (optional) the custom
|
|
141
|
+
/** (optional) the custom task user data, assuming string representation of JSON */
|
|
142
142
|
userData: string;
|
|
143
|
-
/** (optional) the number of retries for the
|
|
143
|
+
/** (optional) the number of retries for the task, default 0 */
|
|
144
144
|
retries: number;
|
|
145
|
-
/** (optional) the rate limits for the
|
|
145
|
+
/** (optional) the rate limits for the task */
|
|
146
146
|
rateLimits: CreateStepRateLimit[];
|
|
147
|
-
/** (optional) the desired worker affinity state for the
|
|
147
|
+
/** (optional) the desired worker affinity state for the task */
|
|
148
148
|
workerLabels: {
|
|
149
149
|
[key: string]: DesiredWorkerLabels;
|
|
150
150
|
};
|
|
151
|
-
/** (optional) the retry backoff factor for the
|
|
151
|
+
/** (optional) the retry backoff factor for the task */
|
|
152
152
|
backoffFactor?: number | undefined;
|
|
153
|
-
/** (optional) the maximum backoff time for the
|
|
153
|
+
/** (optional) the maximum backoff time for the task */
|
|
154
154
|
backoffMaxSeconds?: number | undefined;
|
|
155
155
|
}
|
|
156
156
|
export interface CreateWorkflowStepOpts_WorkerLabelsEntry {
|
|
@@ -160,7 +160,7 @@ export interface CreateWorkflowStepOpts_WorkerLabelsEntry {
|
|
|
160
160
|
export interface CreateStepRateLimit {
|
|
161
161
|
/** (required) the key for the rate limit */
|
|
162
162
|
key: string;
|
|
163
|
-
/** (optional) the number of units this
|
|
163
|
+
/** (optional) the number of units this task consumes */
|
|
164
164
|
units?: number | undefined;
|
|
165
165
|
/** (optional) a CEL expression for determining the rate limit key */
|
|
166
166
|
keyExpr?: string | undefined;
|
|
@@ -181,8 +181,8 @@ export interface ScheduleWorkflowRequest {
|
|
|
181
181
|
input: string;
|
|
182
182
|
/** (optional) the parent workflow run id */
|
|
183
183
|
parentId?: string | undefined;
|
|
184
|
-
/** (optional) the parent
|
|
185
|
-
|
|
184
|
+
/** (optional) the parent task external run id */
|
|
185
|
+
parentTaskRunExternalId?: string | undefined;
|
|
186
186
|
/**
|
|
187
187
|
* (optional) the index of the child workflow. if this is set, matches on the index or the
|
|
188
188
|
* child key will be a no-op, even if the schedule has changed.
|
|
@@ -235,17 +235,17 @@ export interface TriggerWorkflowRequest {
|
|
|
235
235
|
input: string;
|
|
236
236
|
/** (optional) the parent workflow run id */
|
|
237
237
|
parentId?: string | undefined;
|
|
238
|
-
/** (optional) the parent
|
|
239
|
-
|
|
238
|
+
/** (optional) the parent task external run id */
|
|
239
|
+
parentTaskRunExternalId?: string | undefined;
|
|
240
240
|
/**
|
|
241
241
|
* (optional) the index of the child workflow. if this is set, matches on the index or the
|
|
242
|
-
* child key will return an existing workflow run if the parent id, parent
|
|
242
|
+
* child key will return an existing workflow run if the parent id, parent task run id, and
|
|
243
243
|
* child index/key match an existing workflow run.
|
|
244
244
|
*/
|
|
245
245
|
childIndex?: number | undefined;
|
|
246
246
|
/**
|
|
247
247
|
* (optional) the key for the child. if this is set, matches on the index or the
|
|
248
|
-
* child key will return an existing workflow run if the parent id, parent
|
|
248
|
+
* child key will return an existing workflow run if the parent id, parent task run id, and
|
|
249
249
|
* child index/key match an existing workflow run.
|
|
250
250
|
*/
|
|
251
251
|
childKey?: string | undefined;
|
|
@@ -256,7 +256,7 @@ export interface TriggerWorkflowRequest {
|
|
|
256
256
|
* requires the workflow definition to have a sticky strategy
|
|
257
257
|
*/
|
|
258
258
|
desiredWorkerId?: string | undefined;
|
|
259
|
-
/** (optional) override for the priority of the workflow
|
|
259
|
+
/** (optional) override for the priority of the workflow tasks, will set all tasks to this priority */
|
|
260
260
|
priority?: number | undefined;
|
|
261
261
|
}
|
|
262
262
|
export interface TriggerWorkflowResponse {
|
|
@@ -1405,7 +1405,7 @@ function createBaseScheduleWorkflowRequest() {
|
|
|
1405
1405
|
schedules: [],
|
|
1406
1406
|
input: '',
|
|
1407
1407
|
parentId: undefined,
|
|
1408
|
-
|
|
1408
|
+
parentTaskRunExternalId: undefined,
|
|
1409
1409
|
childIndex: undefined,
|
|
1410
1410
|
childKey: undefined,
|
|
1411
1411
|
additionalMetadata: undefined,
|
|
@@ -1426,8 +1426,8 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1426
1426
|
if (message.parentId !== undefined) {
|
|
1427
1427
|
writer.uint32(34).string(message.parentId);
|
|
1428
1428
|
}
|
|
1429
|
-
if (message.
|
|
1430
|
-
writer.uint32(42).string(message.
|
|
1429
|
+
if (message.parentTaskRunExternalId !== undefined) {
|
|
1430
|
+
writer.uint32(42).string(message.parentTaskRunExternalId);
|
|
1431
1431
|
}
|
|
1432
1432
|
if (message.childIndex !== undefined) {
|
|
1433
1433
|
writer.uint32(48).int32(message.childIndex);
|
|
@@ -1482,7 +1482,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1482
1482
|
if (tag !== 42) {
|
|
1483
1483
|
break;
|
|
1484
1484
|
}
|
|
1485
|
-
message.
|
|
1485
|
+
message.parentTaskRunExternalId = reader.string();
|
|
1486
1486
|
continue;
|
|
1487
1487
|
}
|
|
1488
1488
|
case 6: {
|
|
@@ -1529,8 +1529,8 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1529
1529
|
: [],
|
|
1530
1530
|
input: isSet(object.input) ? globalThis.String(object.input) : '',
|
|
1531
1531
|
parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : undefined,
|
|
1532
|
-
|
|
1533
|
-
? globalThis.String(object.
|
|
1532
|
+
parentTaskRunExternalId: isSet(object.parentTaskRunExternalId)
|
|
1533
|
+
? globalThis.String(object.parentTaskRunExternalId)
|
|
1534
1534
|
: undefined,
|
|
1535
1535
|
childIndex: isSet(object.childIndex) ? globalThis.Number(object.childIndex) : undefined,
|
|
1536
1536
|
childKey: isSet(object.childKey) ? globalThis.String(object.childKey) : undefined,
|
|
@@ -1555,8 +1555,8 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1555
1555
|
if (message.parentId !== undefined) {
|
|
1556
1556
|
obj.parentId = message.parentId;
|
|
1557
1557
|
}
|
|
1558
|
-
if (message.
|
|
1559
|
-
obj.
|
|
1558
|
+
if (message.parentTaskRunExternalId !== undefined) {
|
|
1559
|
+
obj.parentTaskRunExternalId = message.parentTaskRunExternalId;
|
|
1560
1560
|
}
|
|
1561
1561
|
if (message.childIndex !== undefined) {
|
|
1562
1562
|
obj.childIndex = Math.round(message.childIndex);
|
|
@@ -1582,7 +1582,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1582
1582
|
message.schedules = ((_b = object.schedules) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
|
|
1583
1583
|
message.input = (_c = object.input) !== null && _c !== void 0 ? _c : '';
|
|
1584
1584
|
message.parentId = (_d = object.parentId) !== null && _d !== void 0 ? _d : undefined;
|
|
1585
|
-
message.
|
|
1585
|
+
message.parentTaskRunExternalId = (_e = object.parentTaskRunExternalId) !== null && _e !== void 0 ? _e : undefined;
|
|
1586
1586
|
message.childIndex = (_f = object.childIndex) !== null && _f !== void 0 ? _f : undefined;
|
|
1587
1587
|
message.childKey = (_g = object.childKey) !== null && _g !== void 0 ? _g : undefined;
|
|
1588
1588
|
message.additionalMetadata = (_h = object.additionalMetadata) !== null && _h !== void 0 ? _h : undefined;
|
|
@@ -2072,7 +2072,7 @@ function createBaseTriggerWorkflowRequest() {
|
|
|
2072
2072
|
name: '',
|
|
2073
2073
|
input: '',
|
|
2074
2074
|
parentId: undefined,
|
|
2075
|
-
|
|
2075
|
+
parentTaskRunExternalId: undefined,
|
|
2076
2076
|
childIndex: undefined,
|
|
2077
2077
|
childKey: undefined,
|
|
2078
2078
|
additionalMetadata: undefined,
|
|
@@ -2091,8 +2091,8 @@ exports.TriggerWorkflowRequest = {
|
|
|
2091
2091
|
if (message.parentId !== undefined) {
|
|
2092
2092
|
writer.uint32(26).string(message.parentId);
|
|
2093
2093
|
}
|
|
2094
|
-
if (message.
|
|
2095
|
-
writer.uint32(34).string(message.
|
|
2094
|
+
if (message.parentTaskRunExternalId !== undefined) {
|
|
2095
|
+
writer.uint32(34).string(message.parentTaskRunExternalId);
|
|
2096
2096
|
}
|
|
2097
2097
|
if (message.childIndex !== undefined) {
|
|
2098
2098
|
writer.uint32(40).int32(message.childIndex);
|
|
@@ -2143,7 +2143,7 @@ exports.TriggerWorkflowRequest = {
|
|
|
2143
2143
|
if (tag !== 34) {
|
|
2144
2144
|
break;
|
|
2145
2145
|
}
|
|
2146
|
-
message.
|
|
2146
|
+
message.parentTaskRunExternalId = reader.string();
|
|
2147
2147
|
continue;
|
|
2148
2148
|
}
|
|
2149
2149
|
case 5: {
|
|
@@ -2194,8 +2194,8 @@ exports.TriggerWorkflowRequest = {
|
|
|
2194
2194
|
name: isSet(object.name) ? globalThis.String(object.name) : '',
|
|
2195
2195
|
input: isSet(object.input) ? globalThis.String(object.input) : '',
|
|
2196
2196
|
parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : undefined,
|
|
2197
|
-
|
|
2198
|
-
? globalThis.String(object.
|
|
2197
|
+
parentTaskRunExternalId: isSet(object.parentTaskRunExternalId)
|
|
2198
|
+
? globalThis.String(object.parentTaskRunExternalId)
|
|
2199
2199
|
: undefined,
|
|
2200
2200
|
childIndex: isSet(object.childIndex) ? globalThis.Number(object.childIndex) : undefined,
|
|
2201
2201
|
childKey: isSet(object.childKey) ? globalThis.String(object.childKey) : undefined,
|
|
@@ -2219,8 +2219,8 @@ exports.TriggerWorkflowRequest = {
|
|
|
2219
2219
|
if (message.parentId !== undefined) {
|
|
2220
2220
|
obj.parentId = message.parentId;
|
|
2221
2221
|
}
|
|
2222
|
-
if (message.
|
|
2223
|
-
obj.
|
|
2222
|
+
if (message.parentTaskRunExternalId !== undefined) {
|
|
2223
|
+
obj.parentTaskRunExternalId = message.parentTaskRunExternalId;
|
|
2224
2224
|
}
|
|
2225
2225
|
if (message.childIndex !== undefined) {
|
|
2226
2226
|
obj.childIndex = Math.round(message.childIndex);
|
|
@@ -2248,7 +2248,7 @@ exports.TriggerWorkflowRequest = {
|
|
|
2248
2248
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
2249
2249
|
message.input = (_b = object.input) !== null && _b !== void 0 ? _b : '';
|
|
2250
2250
|
message.parentId = (_c = object.parentId) !== null && _c !== void 0 ? _c : undefined;
|
|
2251
|
-
message.
|
|
2251
|
+
message.parentTaskRunExternalId = (_d = object.parentTaskRunExternalId) !== null && _d !== void 0 ? _d : undefined;
|
|
2252
2252
|
message.childIndex = (_e = object.childIndex) !== null && _e !== void 0 ? _e : undefined;
|
|
2253
2253
|
message.childKey = (_f = object.childKey) !== null && _f !== void 0 ? _f : undefined;
|
|
2254
2254
|
message.additionalMetadata = (_g = object.additionalMetadata) !== null && _g !== void 0 ? _g : undefined;
|
package/step.d.ts
CHANGED
|
@@ -282,7 +282,7 @@ export declare class V0Context<T, K = {}> {
|
|
|
282
282
|
* Gets the ID of the current task run.
|
|
283
283
|
* @returns The task run ID.
|
|
284
284
|
*/
|
|
285
|
-
|
|
285
|
+
taskRunExternalId(): string;
|
|
286
286
|
/**
|
|
287
287
|
* Gets the number of times the current task has been retried.
|
|
288
288
|
* @returns The retry count.
|
package/step.js
CHANGED
|
@@ -267,7 +267,7 @@ class V0Context {
|
|
|
267
267
|
* @returns The name of the task.
|
|
268
268
|
*/
|
|
269
269
|
taskName() {
|
|
270
|
-
return this.action.
|
|
270
|
+
return this.action.taskName;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Gets the ID of the current workflow run.
|
|
@@ -280,8 +280,8 @@ class V0Context {
|
|
|
280
280
|
* Gets the ID of the current task run.
|
|
281
281
|
* @returns The task run ID.
|
|
282
282
|
*/
|
|
283
|
-
|
|
284
|
-
return this.action.
|
|
283
|
+
taskRunExternalId() {
|
|
284
|
+
return this.action.taskRunExternalId;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
287
|
* Gets the number of times the current task has been retried.
|
|
@@ -296,13 +296,13 @@ class V0Context {
|
|
|
296
296
|
* @param level - The log level (optional).
|
|
297
297
|
*/
|
|
298
298
|
log(message, level) {
|
|
299
|
-
const {
|
|
300
|
-
if (!
|
|
299
|
+
const { taskRunExternalId } = this.action;
|
|
300
|
+
if (!taskRunExternalId) {
|
|
301
301
|
// log a warning
|
|
302
302
|
this.logger.warn('cannot log from context without stepRunId');
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
|
-
this.v0.event.putLog(
|
|
305
|
+
this.v0.event.putLog(taskRunExternalId, message, level, this.retryCount());
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
308
|
* Refreshes the timeout for the current task.
|
|
@@ -311,13 +311,13 @@ class V0Context {
|
|
|
311
311
|
*/
|
|
312
312
|
refreshTimeout(incrementBy) {
|
|
313
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
-
const {
|
|
315
|
-
if (!
|
|
314
|
+
const { taskRunExternalId } = this.action;
|
|
315
|
+
if (!taskRunExternalId) {
|
|
316
316
|
// log a warning
|
|
317
317
|
this.logger.warn('cannot refresh timeout from context without stepRunId');
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
|
-
yield this.v0.dispatcher.refreshTimeout(incrementBy,
|
|
320
|
+
yield this.v0.dispatcher.refreshTimeout(incrementBy, taskRunExternalId);
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
@@ -328,7 +328,7 @@ class V0Context {
|
|
|
328
328
|
releaseSlot() {
|
|
329
329
|
return __awaiter(this, void 0, void 0, function* () {
|
|
330
330
|
yield this.v0.dispatcher.client.releaseSlot({
|
|
331
|
-
|
|
331
|
+
taskRunExternalId: this.action.taskRunExternalId,
|
|
332
332
|
});
|
|
333
333
|
});
|
|
334
334
|
}
|
|
@@ -339,13 +339,13 @@ class V0Context {
|
|
|
339
339
|
*/
|
|
340
340
|
putStream(data) {
|
|
341
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
-
const {
|
|
343
|
-
if (!
|
|
342
|
+
const { taskRunExternalId } = this.action;
|
|
343
|
+
if (!taskRunExternalId) {
|
|
344
344
|
// log a warning
|
|
345
345
|
this.logger.warn('cannot log from context without stepRunId');
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
|
-
yield this.v0.event.putStream(
|
|
348
|
+
yield this.v0.event.putStream(taskRunExternalId, data, undefined);
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
@@ -378,7 +378,7 @@ class V0Context {
|
|
|
378
378
|
*/
|
|
379
379
|
spawnWorkflows(workflows) {
|
|
380
380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
381
|
-
const { workflowRunId,
|
|
381
|
+
const { workflowRunId, taskRunExternalId } = this.action;
|
|
382
382
|
const workflowRuns = workflows.map(({ workflow, input, options }) => {
|
|
383
383
|
let workflowName;
|
|
384
384
|
if (typeof workflow === 'string') {
|
|
@@ -396,7 +396,7 @@ class V0Context {
|
|
|
396
396
|
const resp = {
|
|
397
397
|
workflowName: name,
|
|
398
398
|
input,
|
|
399
|
-
options: Object.assign(Object.assign({}, opts), { parentId: workflowRunId, parentStepRunId:
|
|
399
|
+
options: Object.assign(Object.assign({}, opts), { parentId: workflowRunId, parentStepRunId: taskRunExternalId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }),
|
|
400
400
|
};
|
|
401
401
|
this.spawnIndex += 1;
|
|
402
402
|
return resp;
|
|
@@ -463,7 +463,7 @@ class V0Context {
|
|
|
463
463
|
*/
|
|
464
464
|
spawnWorkflow(workflow, input, options) {
|
|
465
465
|
return __awaiter(this, void 0, void 0, function* () {
|
|
466
|
-
const { workflowRunId,
|
|
466
|
+
const { workflowRunId, taskRunExternalId } = this.action;
|
|
467
467
|
let workflowName = '';
|
|
468
468
|
if (typeof workflow === 'string') {
|
|
469
469
|
workflowName = workflow;
|
|
@@ -478,7 +478,7 @@ class V0Context {
|
|
|
478
478
|
throw new hatchet_error_1.default(`cannot run with sticky: workflow ${name} is not registered on the worker`);
|
|
479
479
|
}
|
|
480
480
|
try {
|
|
481
|
-
const resp = yield this.v0.admin.runWorkflow(name, input, Object.assign({ parentId: workflowRunId, parentStepRunId:
|
|
481
|
+
const resp = yield this.v0.admin.runWorkflow(name, input, Object.assign({ parentId: workflowRunId, parentStepRunId: taskRunExternalId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }, opts));
|
|
482
482
|
this.spawnIndex += 1;
|
|
483
483
|
if (workflow instanceof declaration_1.TaskWorkflowDeclaration) {
|
|
484
484
|
resp._standaloneTaskName = workflow._standalone_task_name;
|
|
@@ -565,13 +565,13 @@ class V0DurableContext extends V0Context {
|
|
|
565
565
|
// eslint-disable-next-line no-plusplus
|
|
566
566
|
const key = `waitFor-${this.waitKey++}`;
|
|
567
567
|
yield this.v0.durableListener.registerDurableEvent({
|
|
568
|
-
taskId: this.action.
|
|
568
|
+
taskId: this.action.taskRunExternalId,
|
|
569
569
|
signalKey: key,
|
|
570
570
|
sleepConditions: pbConditions.sleepConditions,
|
|
571
571
|
userEventConditions: pbConditions.userEventConditions,
|
|
572
572
|
});
|
|
573
573
|
const listener = this.v0.durableListener.subscribe({
|
|
574
|
-
taskId: this.action.
|
|
574
|
+
taskId: this.action.taskRunExternalId,
|
|
575
575
|
signalKey: key,
|
|
576
576
|
});
|
|
577
577
|
const event = yield listener.get();
|
package/util/workflow-run-ref.js
CHANGED
|
@@ -126,7 +126,7 @@ class WorkflowRunRef {
|
|
|
126
126
|
resolve(outputs[this._standaloneTaskName]);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
const result = event.results.reduce((acc, r) => (Object.assign(Object.assign({}, acc), { [r.
|
|
129
|
+
const result = event.results.reduce((acc, r) => (Object.assign(Object.assign({}, acc), { [r.taskName]: JSON.parse(r.output || '{}') })), {});
|
|
130
130
|
if (!this._standaloneTaskName) {
|
|
131
131
|
resolve(result);
|
|
132
132
|
return;
|
package/v1/client/admin.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export type WorkflowRun<T = object> = {
|
|
|
10
10
|
input: T;
|
|
11
11
|
options?: {
|
|
12
12
|
parentId?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* (optional) the parent task run external id.
|
|
15
|
+
*
|
|
16
|
+
* This is the field understood by the workflows gRPC API (`parent_task_run_external_id`).
|
|
17
|
+
*/
|
|
18
|
+
parentTaskRunExternalId?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `parentTaskRunExternalId` instead.
|
|
21
|
+
* Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
|
|
22
|
+
*/
|
|
13
23
|
parentStepRunId?: string | undefined;
|
|
14
24
|
childIndex?: number | undefined;
|
|
15
25
|
childKey?: string | undefined;
|
|
@@ -33,6 +43,16 @@ export declare class AdminClient {
|
|
|
33
43
|
*/
|
|
34
44
|
runWorkflow<Q = object, P = object>(workflowName: string, input: Q, options?: {
|
|
35
45
|
parentId?: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* (optional) the parent task run external id.
|
|
48
|
+
*
|
|
49
|
+
* This is the field understood by the workflows gRPC API (`parent_task_run_external_id`).
|
|
50
|
+
*/
|
|
51
|
+
parentTaskRunExternalId?: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use `parentTaskRunExternalId` instead.
|
|
54
|
+
* Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
|
|
55
|
+
*/
|
|
36
56
|
parentStepRunId?: string | undefined;
|
|
37
57
|
childIndex?: number | undefined;
|
|
38
58
|
childKey?: string | undefined;
|
|
@@ -52,6 +72,16 @@ export declare class AdminClient {
|
|
|
52
72
|
input: Q;
|
|
53
73
|
options?: {
|
|
54
74
|
parentId?: string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* (optional) the parent task run external id.
|
|
77
|
+
*
|
|
78
|
+
* This is the field understood by the workflows gRPC API (`parent_task_run_external_id`).
|
|
79
|
+
*/
|
|
80
|
+
parentTaskRunExternalId?: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `parentTaskRunExternalId` instead.
|
|
83
|
+
* Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
|
|
84
|
+
*/
|
|
55
85
|
parentStepRunId?: string | undefined;
|
|
56
86
|
childIndex?: number | undefined;
|
|
57
87
|
childKey?: string | undefined;
|
package/v1/client/admin.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
@@ -43,9 +54,11 @@ class AdminClient {
|
|
|
43
54
|
try {
|
|
44
55
|
const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace);
|
|
45
56
|
const inputStr = JSON.stringify(input);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
const opts = options !== null && options !== void 0 ? options : {};
|
|
58
|
+
const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
|
|
59
|
+
const request = Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), {
|
|
60
|
+
// API expects `parentTaskRunExternalId`; accept old names as aliases.
|
|
61
|
+
parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, priority: opts.priority });
|
|
49
62
|
const resp = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.grpc.triggerWorkflow(request); }), this.logger);
|
|
50
63
|
const id = resp.workflowRunId;
|
|
51
64
|
const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId,
|
|
@@ -71,9 +84,11 @@ class AdminClient {
|
|
|
71
84
|
const workflowRequests = workflowRuns.map(({ workflowName, input, options }) => {
|
|
72
85
|
const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace);
|
|
73
86
|
const inputStr = JSON.stringify(input);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
const opts = options !== null && options !== void 0 ? options : {};
|
|
88
|
+
const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
|
|
89
|
+
return Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), {
|
|
90
|
+
// API expects `parentTaskRunExternalId`; accept old names as aliases.
|
|
91
|
+
parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined });
|
|
77
92
|
});
|
|
78
93
|
const limit = 4 * 1024 * 1024; // FIXME configurable GRPC limit
|
|
79
94
|
const batches = (0, batch_1.batch)(workflowRequests, batchSize, limit);
|