@hatchet-dev/typescript-sdk 1.0.0-alpha2 → 1.0.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 +3 -1
- package/clients/admin/admin-client.js +5 -4
- package/clients/hatchet-client/hatchet-client.d.ts +3 -1
- package/clients/hatchet-client/hatchet-client.js +3 -2
- package/clients/worker/worker.js +4 -4
- package/package.json +1 -1
- package/step.d.ts +2 -0
- package/step.js +7 -0
- package/util/sleep.d.ts +1 -0
- package/util/sleep.js +1 -0
- package/util/workflow-run-ref.d.ts +5 -1
- package/util/workflow-run-ref.js +25 -1
- package/v1/client/client.d.ts +4 -2
- package/v1/client/client.js +26 -7
- package/v1/client/features/runs.d.ts +21 -2
- package/v1/client/features/runs.js +24 -10
- package/v1/declaration.d.ts +1 -1
- package/v1/examples/cancellations/run.d.ts +1 -0
- package/v1/examples/cancellations/run.js +50 -0
- package/v1/examples/cancellations/worker.d.ts +1 -0
- package/v1/examples/cancellations/worker.js +29 -0
- package/v1/examples/cancellations/workflow.d.ts +3 -0
- package/v1/examples/cancellations/workflow.js +33 -0
- package/v1/examples/child_workflows/run.js +1 -1
- package/v1/examples/child_workflows/workflow.d.ts +6 -12
- package/v1/examples/child_workflows/workflow.js +5 -11
- package/v1/examples/dag/workflow.js +5 -0
- package/v1/examples/landing_page/durable-excution.d.ts +3 -0
- package/v1/examples/landing_page/durable-excution.js +40 -0
- package/v1/examples/landing_page/event-signaling.d.ts +6 -0
- package/v1/examples/landing_page/event-signaling.js +16 -0
- package/v1/examples/landing_page/flow-control.d.ts +6 -0
- package/v1/examples/landing_page/flow-control.js +26 -0
- package/v1/examples/landing_page/queues.d.ts +3 -0
- package/v1/examples/landing_page/queues.js +33 -0
- package/v1/examples/landing_page/scheduling.d.ts +1 -0
- package/v1/examples/landing_page/scheduling.js +12 -0
- package/v1/examples/landing_page/task-routing.d.ts +6 -0
- package/v1/examples/landing_page/task-routing.js +25 -0
- package/v1/examples/on_failure/workflow.d.ts +1 -1
- package/v1/examples/on_failure/workflow.js +4 -5
- package/v1/examples/retries/run.d.ts +1 -0
- package/v1/examples/retries/run.js +29 -0
- package/v1/examples/retries/worker.d.ts +1 -0
- package/v1/examples/retries/worker.js +24 -0
- package/v1/examples/retries/workflow.d.ts +5 -0
- package/v1/examples/retries/workflow.js +53 -0
- package/v1/examples/simple/run.js +1 -1
- package/v1/examples/sticky/run.d.ts +1 -0
- package/v1/examples/sticky/run.js +29 -0
- package/v1/examples/sticky/worker.d.ts +1 -0
- package/v1/examples/sticky/worker.js +24 -0
- package/v1/examples/sticky/workflow.d.ts +5 -0
- package/v1/examples/sticky/workflow.js +32 -0
- package/v1/examples/timeouts/run.d.ts +1 -0
- package/v1/examples/timeouts/run.js +29 -0
- package/v1/examples/timeouts/worker.d.ts +1 -0
- package/v1/examples/timeouts/worker.js +29 -0
- package/v1/examples/timeouts/workflow.d.ts +3 -0
- package/v1/examples/timeouts/workflow.js +34 -0
- package/v1/examples/with_timeouts/workflow.d.ts +9 -0
- package/v1/examples/with_timeouts/workflow.js +62 -0
- package/v1/task.d.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.refreshTimeout = exports.withTimeouts = void 0;
|
|
16
|
+
// ❓ Declaring a Task
|
|
17
|
+
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
18
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
19
|
+
// ❓ Execution Timeout
|
|
20
|
+
exports.withTimeouts = hatchet_client_1.hatchet.task({
|
|
21
|
+
name: 'with-timeouts',
|
|
22
|
+
// time the task can wait in the queue before it is cancelled
|
|
23
|
+
scheduleTimeout: '10s',
|
|
24
|
+
// time the task can run before it is cancelled
|
|
25
|
+
executionTimeout: '10s',
|
|
26
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
// wait 15 seconds
|
|
28
|
+
yield (0, sleep_1.default)(15000);
|
|
29
|
+
// get the abort controller
|
|
30
|
+
const { controller } = ctx;
|
|
31
|
+
// if the abort controller is aborted, throw an error
|
|
32
|
+
if (controller.signal.aborted) {
|
|
33
|
+
throw new Error('cancelled');
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
37
|
+
};
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
// !!
|
|
41
|
+
// ❓ Refresh Timeout
|
|
42
|
+
exports.refreshTimeout = hatchet_client_1.hatchet.task({
|
|
43
|
+
name: 'refresh-timeout',
|
|
44
|
+
executionTimeout: '10s',
|
|
45
|
+
scheduleTimeout: '10s',
|
|
46
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
// adds 15 seconds to the execution timeout
|
|
48
|
+
ctx.refreshTimeout('15s');
|
|
49
|
+
yield (0, sleep_1.default)(15000);
|
|
50
|
+
// get the abort controller
|
|
51
|
+
const { controller } = ctx;
|
|
52
|
+
// now this condition will not be met
|
|
53
|
+
// if the abort controller is aborted, throw an error
|
|
54
|
+
if (controller.signal.aborted) {
|
|
55
|
+
throw new Error('cancelled');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
59
|
+
};
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
// !!
|
package/v1/task.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export type CreateBaseTaskOpts<T, K, C> = {
|
|
|
89
89
|
* - weight: Priority weight for worker selection
|
|
90
90
|
* - comparator: Custom comparison logic for label matching
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
desiredWorkerLabels?: CreateStep<T, K>['worker_labels'];
|
|
93
93
|
/**
|
|
94
94
|
* (optional) the concurrency options for the task
|
|
95
95
|
*/
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.0.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.0.1";
|
package/version.js
CHANGED