@hatchet-dev/typescript-sdk 0.12.5 → 0.13.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/event/event-client.d.ts +5 -0
- package/clients/event/event-client.js +31 -0
- package/clients/rest/generated/Api.d.ts +140 -19
- package/clients/rest/generated/Api.js +99 -10
- package/clients/rest/generated/data-contracts.d.ts +180 -12
- package/clients/rest/generated/data-contracts.js +28 -1
- package/clients/rest/generated/http-client.js +4 -1
- package/clients/worker/worker.js +13 -6
- package/examples/concurrency/group-round-robin/{concurrency-worker.js → concurrency-worker-expression.js} +1 -1
- package/examples/concurrency/group-round-robin/concurrency-worker-key-fn.d.ts +1 -0
- package/examples/concurrency/group-round-robin/concurrency-worker-key-fn.js +62 -0
- package/examples/example-event.js +38 -0
- package/examples/fanout-worker.js +35 -12
- package/package.json +3 -2
- package/protoc/dispatcher/dispatcher.d.ts +65 -426
- package/protoc/dispatcher/dispatcher.js +124 -120
- package/protoc/events/events.d.ts +43 -122
- package/protoc/events/events.js +153 -50
- package/protoc/google/protobuf/timestamp.d.ts +10 -9
- package/protoc/google/protobuf/timestamp.js +16 -35
- package/protoc/workflows/workflows.d.ts +45 -206
- package/protoc/workflows/workflows.js +132 -103
- package/step.js +1 -1
- package/util/workflow-run-ref.js +27 -4
- package/workflow.d.ts +4 -1
- package/workflow.js +1 -0
- /package/examples/concurrency/group-round-robin/{concurrency-worker.d.ts → concurrency-worker-expression.d.ts} +0 -0
package/step.js
CHANGED
|
@@ -225,7 +225,7 @@ class Context {
|
|
|
225
225
|
const name = this.client.config.namespace + workflowName;
|
|
226
226
|
let key = '';
|
|
227
227
|
let sticky = false;
|
|
228
|
-
let metadata
|
|
228
|
+
let metadata;
|
|
229
229
|
if (typeof options === 'string') {
|
|
230
230
|
this.logger.warn('Using key param is deprecated and will be removed in a future release. Use options.key instead.');
|
|
231
231
|
key = options;
|
package/util/workflow-run-ref.js
CHANGED
|
@@ -73,16 +73,39 @@ class WorkflowRunRef {
|
|
|
73
73
|
return new Promise((resolve, reject) => {
|
|
74
74
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
var _a, e_1, _b, _c;
|
|
76
|
+
var _d, _e;
|
|
76
77
|
try {
|
|
77
|
-
for (var
|
|
78
|
-
_c =
|
|
79
|
-
|
|
78
|
+
for (var _f = true, _g = __asyncValues(streamable.stream()), _h; _h = yield _g.next(), _a = _h.done, !_a; _f = true) {
|
|
79
|
+
_c = _h.value;
|
|
80
|
+
_f = false;
|
|
80
81
|
const event = _c;
|
|
81
82
|
if (event.eventType === dispatcher_1.WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED) {
|
|
82
83
|
if (event.results.some((r) => !!r.error)) {
|
|
83
84
|
reject(event.results);
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
87
|
+
if (event.results.length === 0) {
|
|
88
|
+
const data = yield this.client.api.workflowRunGetShape(this.client.config.tenant_id, event.workflowRunId);
|
|
89
|
+
const mostRecentJobRun = (_d = data.data.jobRuns) === null || _d === void 0 ? void 0 : _d[0];
|
|
90
|
+
if (!mostRecentJobRun) {
|
|
91
|
+
reject(new Error('No job runs found'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const outputs = {};
|
|
95
|
+
(_e = mostRecentJobRun.stepRuns) === null || _e === void 0 ? void 0 : _e.forEach((stepRun) => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
const readable = (_b = (_a = mostRecentJobRun.job) === null || _a === void 0 ? void 0 : _a.steps) === null || _b === void 0 ? void 0 : _b.find((step) => step.metadata.id === stepRun.stepId);
|
|
98
|
+
const readableStepName = `${readable === null || readable === void 0 ? void 0 : readable.readableId}`;
|
|
99
|
+
try {
|
|
100
|
+
outputs[readableStepName] = JSON.parse(stepRun.output || '{}');
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
outputs[readableStepName] = stepRun.output;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
resolve(outputs);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
86
109
|
const result = event.results.reduce((acc, r) => (Object.assign(Object.assign({}, acc), { [r.stepReadableId]: JSON.parse(r.output || '{}') })), {});
|
|
87
110
|
resolve(result);
|
|
88
111
|
return;
|
|
@@ -92,7 +115,7 @@ class WorkflowRunRef {
|
|
|
92
115
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
116
|
finally {
|
|
94
117
|
try {
|
|
95
|
-
if (!
|
|
118
|
+
if (!_f && !_a && (_b = _g.return)) yield _b.call(_g);
|
|
96
119
|
}
|
|
97
120
|
finally { if (e_1) throw e_1.error; }
|
|
98
121
|
}
|
package/workflow.d.ts
CHANGED
|
@@ -69,14 +69,17 @@ export declare const WorkflowConcurrency: z.ZodObject<{
|
|
|
69
69
|
name: z.ZodString;
|
|
70
70
|
maxRuns: z.ZodOptional<z.ZodNumber>;
|
|
71
71
|
limitStrategy: z.ZodOptional<z.ZodNativeEnum<typeof PbConcurrencyLimitStrategy>>;
|
|
72
|
+
expression: z.ZodOptional<z.ZodString>;
|
|
72
73
|
}, "strip", z.ZodTypeAny, {
|
|
73
74
|
name: string;
|
|
74
75
|
maxRuns?: number | undefined;
|
|
75
76
|
limitStrategy?: PbConcurrencyLimitStrategy | undefined;
|
|
77
|
+
expression?: string | undefined;
|
|
76
78
|
}, {
|
|
77
79
|
name: string;
|
|
78
80
|
maxRuns?: number | undefined;
|
|
79
81
|
limitStrategy?: PbConcurrencyLimitStrategy | undefined;
|
|
82
|
+
expression?: string | undefined;
|
|
80
83
|
}>;
|
|
81
84
|
export declare const HatchetTimeoutSchema: z.ZodString;
|
|
82
85
|
export declare const StickyStrategy: typeof PbStickyStrategy;
|
|
@@ -331,7 +334,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
331
334
|
}>;
|
|
332
335
|
export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
|
|
333
336
|
concurrency?: z.infer<typeof WorkflowConcurrency> & {
|
|
334
|
-
key
|
|
337
|
+
key?: (ctx: any) => string;
|
|
335
338
|
};
|
|
336
339
|
steps: CreateStep<any, any>[];
|
|
337
340
|
onFailure?: CreateStep<any, any>;
|
package/workflow.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.WorkflowConcurrency = z.object({
|
|
|
42
42
|
name: z.string(),
|
|
43
43
|
maxRuns: z.number().optional(),
|
|
44
44
|
limitStrategy: z.nativeEnum(exports.ConcurrencyLimitStrategy).optional(),
|
|
45
|
+
expression: z.string().optional(),
|
|
45
46
|
});
|
|
46
47
|
exports.HatchetTimeoutSchema = z.string();
|
|
47
48
|
exports.StickyStrategy = workflows_1.StickyStrategy;
|
|
File without changes
|