@hatchet-dev/typescript-sdk 0.18.0 → 0.19.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/examples/on-failure.js +2 -0
- package/package.json +2 -2
- package/step.d.ts +2 -0
- package/step.js +7 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/examples/on-failure.js
CHANGED
|
@@ -40,6 +40,8 @@ const workflow = {
|
|
|
40
40
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
// 👀 we can do things like perform cleanup logic
|
|
42
42
|
// or notify a user here
|
|
43
|
+
// 👀 you can access the error from the failed step(s) like this
|
|
44
|
+
console.log(ctx.stepRunErrors());
|
|
43
45
|
return { onFailure: 'step' };
|
|
44
46
|
}),
|
|
45
47
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"worker:affinity": "npm run exec -- ./src/examples/affinity-workers.ts",
|
|
43
43
|
"worker:sticky": "npm run exec -- ./src/examples/sticky-worker.ts",
|
|
44
44
|
"worker:sticky-with-check": "npm run exec -- ./src/examples/sticky-worker-with-check.ts",
|
|
45
|
-
"trigger:sticky": "npm run exec -- ./src/examples/sticky-trigger.ts",
|
|
45
|
+
"trigger:sticky": "npm run exec -- ./src/examples/sticky-trigger.ts",
|
|
46
46
|
"worker:on-failure": "npm run exec -- ./src/examples/on-failure.ts",
|
|
47
47
|
"manual:trigger": "npm run exec -- ./src/examples/manual-trigger.ts",
|
|
48
48
|
"manual:meta": "npm run exec -- ./src/examples/stream-by-additional-meta.ts",
|
package/step.d.ts
CHANGED
|
@@ -162,6 +162,7 @@ interface ContextData<T, K> {
|
|
|
162
162
|
parents: Record<string, any>;
|
|
163
163
|
triggered_by: string;
|
|
164
164
|
user_data: K;
|
|
165
|
+
step_run_errors: Record<string, string>;
|
|
165
166
|
}
|
|
166
167
|
export declare class ContextWorker {
|
|
167
168
|
private worker;
|
|
@@ -183,6 +184,7 @@ export declare class Context<T, K = {}> {
|
|
|
183
184
|
spawnIndex: number;
|
|
184
185
|
constructor(action: Action, client: HatchetClient, worker: Worker);
|
|
185
186
|
stepOutput(step: string): NextStep;
|
|
187
|
+
stepRunErrors(): Record<string, string>;
|
|
186
188
|
triggeredByEvent(): boolean;
|
|
187
189
|
workflowInput(): T;
|
|
188
190
|
workflowName(): string;
|
package/step.js
CHANGED
|
@@ -143,6 +143,13 @@ class Context {
|
|
|
143
143
|
}
|
|
144
144
|
return this.data.parents[step];
|
|
145
145
|
}
|
|
146
|
+
stepRunErrors() {
|
|
147
|
+
const errors = this.data.step_run_errors || {};
|
|
148
|
+
if (Object.keys(errors).length === 0) {
|
|
149
|
+
this.logger.error('No step run errors found. `ctx.stepRunErrors` is intended to be run in an on-failure step, and will only work on engine versions more recent than v0.53.10');
|
|
150
|
+
}
|
|
151
|
+
return errors;
|
|
152
|
+
}
|
|
146
153
|
triggeredByEvent() {
|
|
147
154
|
var _a;
|
|
148
155
|
return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.triggered_by) === 'event';
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "0.
|
|
1
|
+
export declare const HATCHET_VERSION = "0.19.0";
|
package/version.js
CHANGED