@hatchet-dev/typescript-sdk 0.8.0-alpha.0 → 0.8.0-alpha.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.
|
@@ -86,13 +86,13 @@ class AdminClient {
|
|
|
86
86
|
*/
|
|
87
87
|
run_workflow(workflowName, input, options) {
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
let computedName = workflowName;
|
|
89
90
|
try {
|
|
90
|
-
let wfName = workflowName;
|
|
91
91
|
if (this.config.namespace && !workflowName.startsWith(this.config.namespace)) {
|
|
92
|
-
|
|
92
|
+
computedName = this.config.namespace + workflowName;
|
|
93
93
|
}
|
|
94
94
|
const inputStr = JSON.stringify(input);
|
|
95
|
-
const resp = yield this.client.triggerWorkflow(Object.assign(Object.assign({ name:
|
|
95
|
+
const resp = yield this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
96
96
|
? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
97
97
|
: undefined }));
|
|
98
98
|
return resp.workflowRunId;
|
|
@@ -21,6 +21,7 @@ export declare const ActionObject: z.ZodObject<{
|
|
|
21
21
|
workflowRunId: z.ZodString;
|
|
22
22
|
getGroupKeyRunId: z.ZodOptional<z.ZodString>;
|
|
23
23
|
stepName: z.ZodString;
|
|
24
|
+
retryCount: z.ZodNumber;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
26
|
tenantId: string;
|
|
26
27
|
stepRunId: string;
|
|
@@ -32,6 +33,7 @@ export declare const ActionObject: z.ZodObject<{
|
|
|
32
33
|
actionId: string;
|
|
33
34
|
actionPayload: string;
|
|
34
35
|
stepName: string;
|
|
36
|
+
retryCount: number;
|
|
35
37
|
getGroupKeyRunId?: string | undefined;
|
|
36
38
|
actionType?: number | undefined;
|
|
37
39
|
}, {
|
|
@@ -45,6 +47,7 @@ export declare const ActionObject: z.ZodObject<{
|
|
|
45
47
|
actionId: string;
|
|
46
48
|
actionPayload: string;
|
|
47
49
|
stepName: string;
|
|
50
|
+
retryCount: number;
|
|
48
51
|
getGroupKeyRunId?: string | undefined;
|
|
49
52
|
actionType?: unknown;
|
|
50
53
|
}>;
|
|
@@ -73,6 +76,7 @@ export declare class ActionListener {
|
|
|
73
76
|
actionId: string;
|
|
74
77
|
actionPayload: string;
|
|
75
78
|
stepName: string;
|
|
79
|
+
retryCount: number;
|
|
76
80
|
getGroupKeyRunId?: string | undefined;
|
|
77
81
|
actionType?: number | undefined;
|
|
78
82
|
}, void, unknown>;
|
|
@@ -61,6 +61,7 @@ exports.ActionObject = zod_1.z.object({
|
|
|
61
61
|
workflowRunId: zod_1.z.string(),
|
|
62
62
|
getGroupKeyRunId: zod_1.z.string().optional(),
|
|
63
63
|
stepName: zod_1.z.string(),
|
|
64
|
+
retryCount: zod_1.z.number(),
|
|
64
65
|
});
|
|
65
66
|
class ActionListener {
|
|
66
67
|
constructor(client, workerId, retryInterval = DEFAULT_ACTION_LISTENER_RETRY_INTERVAL, retryCount = DEFAULT_ACTION_LISTENER_RETRY_COUNT) {
|
package/clients/worker/worker.js
CHANGED
|
@@ -161,22 +161,29 @@ class Worker {
|
|
|
161
161
|
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
162
162
|
return step(context);
|
|
163
163
|
});
|
|
164
|
-
const success = (result) => {
|
|
164
|
+
const success = (result) => __awaiter(this, void 0, void 0, function* () {
|
|
165
165
|
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
166
166
|
try {
|
|
167
167
|
// Send the action event to the dispatcher
|
|
168
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result);
|
|
169
|
-
this.client.dispatcher.sendStepActionEvent(event)
|
|
170
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
171
|
-
});
|
|
168
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result || null);
|
|
169
|
+
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
172
170
|
// delete the run from the futures
|
|
173
171
|
delete this.futures[action.stepRunId];
|
|
174
172
|
}
|
|
175
|
-
catch (
|
|
176
|
-
this.logger.error(`Could not send action event: ${
|
|
173
|
+
catch (actionEventError) {
|
|
174
|
+
this.logger.error(`Could not send completed action event: ${actionEventError.message}`);
|
|
175
|
+
// send a failure event
|
|
176
|
+
const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, actionEventError.message);
|
|
177
|
+
try {
|
|
178
|
+
yield this.client.dispatcher.sendStepActionEvent(failureEvent);
|
|
179
|
+
}
|
|
180
|
+
catch (failureEventError) {
|
|
181
|
+
this.logger.error(`Could not send failed action event: ${failureEventError.message}`);
|
|
182
|
+
}
|
|
183
|
+
this.logger.error(`Could not send action event: ${actionEventError.message}`);
|
|
177
184
|
}
|
|
178
|
-
};
|
|
179
|
-
const failure = (error) => {
|
|
185
|
+
});
|
|
186
|
+
const failure = (error) => __awaiter(this, void 0, void 0, function* () {
|
|
180
187
|
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
181
188
|
if (error.stack) {
|
|
182
189
|
this.logger.error(error.stack);
|
|
@@ -187,17 +194,24 @@ class Worker {
|
|
|
187
194
|
message: error === null || error === void 0 ? void 0 : error.message,
|
|
188
195
|
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
189
196
|
});
|
|
190
|
-
this.client.dispatcher.sendStepActionEvent(event)
|
|
191
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
192
|
-
});
|
|
197
|
+
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
193
198
|
// delete the run from the futures
|
|
194
199
|
delete this.futures[action.stepRunId];
|
|
195
200
|
}
|
|
196
201
|
catch (e) {
|
|
197
202
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
198
203
|
}
|
|
199
|
-
};
|
|
200
|
-
const future = new hatchet_promise_1.default(
|
|
204
|
+
});
|
|
205
|
+
const future = new hatchet_promise_1.default((() => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
try {
|
|
207
|
+
yield run();
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
yield failure(e);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
yield success(null);
|
|
214
|
+
}))());
|
|
201
215
|
this.futures[action.stepRunId] = future;
|
|
202
216
|
// Send the action event to the dispatcher
|
|
203
217
|
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
|
package/package.json
CHANGED
package/step.d.ts
CHANGED
package/step.js
CHANGED
|
@@ -168,6 +168,9 @@ class Context {
|
|
|
168
168
|
workflowRunId() {
|
|
169
169
|
return this.action.workflowRunId;
|
|
170
170
|
}
|
|
171
|
+
retryCount() {
|
|
172
|
+
return this.action.retryCount;
|
|
173
|
+
}
|
|
171
174
|
playground(name, defaultValue = '') {
|
|
172
175
|
if (name in this.overridesData) {
|
|
173
176
|
return this.overridesData[name];
|