@hatchet-dev/typescript-sdk 1.0.0-alpha1 → 1.0.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 +15 -20
- package/clients/admin/admin-client.js +21 -17
- package/clients/hatchet-client/hatchet-client.d.ts +5 -4
- package/clients/hatchet-client/hatchet-client.js +6 -4
- package/clients/listeners/durable-listener/durable-listener-client.d.ts +25 -0
- package/clients/listeners/durable-listener/durable-listener-client.js +30 -0
- package/clients/listeners/durable-listener/pooled-durable-listener-client.d.ts +43 -0
- package/clients/listeners/durable-listener/pooled-durable-listener-client.js +241 -0
- package/clients/{listener/listener-client.d.ts → listeners/run-listener/child-listener-client.d.ts} +8 -8
- package/clients/{listener/listener-client.js → listeners/run-listener/child-listener-client.js} +8 -19
- package/clients/{listener/child-listener-client.d.ts → listeners/run-listener/pooled-child-listener-client.d.ts} +5 -5
- package/clients/{listener/child-listener-client.js → listeners/run-listener/pooled-child-listener-client.js} +5 -5
- package/clients/rest/generated/Api.d.ts +49 -2
- package/clients/rest/generated/Api.js +30 -0
- package/clients/rest/generated/data-contracts.d.ts +88 -82
- package/clients/rest/generated/data-contracts.js +8 -1
- package/clients/worker/worker.d.ts +5 -1
- package/clients/worker/worker.js +173 -2
- package/examples/affinity-workers.js +5 -1
- package/examples/api.js +1 -1
- package/examples/bulk-fanout-worker.js +1 -1
- package/examples/byo-logger.js +4 -0
- package/examples/concurrency/cancel-in-progress/concurrency-event.js +2 -2
- package/examples/concurrency/group-round-robin/concurrency-event.js +1 -1
- package/examples/crons/programatic-crons.js +4 -4
- package/examples/dag-worker.js +0 -1
- package/examples/example-event.js +2 -2
- package/examples/logger.js +2 -0
- package/examples/on-failure.js +1 -1
- package/examples/rate-limit/events.js +3 -3
- package/examples/scheduled-runs/programatic-schedules.js +4 -4
- package/examples/sticky-worker-with-check.js +2 -2
- package/examples/sticky-worker.js +5 -0
- package/index.d.ts +1 -3
- package/index.js +1 -3
- package/package.json +2 -2
- package/protoc/dispatcher/dispatcher.d.ts +2 -0
- package/protoc/dispatcher/dispatcher.js +1 -1
- package/protoc/events/events.js +1 -1
- package/protoc/google/protobuf/timestamp.js +1 -1
- package/protoc/v1/dispatcher.d.ts +77 -0
- package/protoc/v1/dispatcher.js +341 -0
- package/protoc/v1/shared/condition.d.ts +59 -0
- package/protoc/v1/shared/condition.js +549 -0
- package/protoc/v1/workflows.d.ts +263 -0
- package/protoc/v1/workflows.js +1823 -0
- package/protoc/workflows/workflows.js +1 -1
- package/step.d.ts +173 -47
- package/step.js +208 -64
- package/util/sleep.d.ts +7 -0
- package/util/sleep.js +7 -0
- package/util/workflow-run-ref.d.ts +8 -2
- package/util/workflow-run-ref.js +13 -0
- package/v1/client/client.d.ts +125 -7
- package/v1/client/client.interface.d.ts +9 -1
- package/v1/client/client.js +148 -17
- package/v1/client/duration.d.ts +7 -0
- package/v1/client/duration.js +2 -0
- package/v1/client/features/index.d.ts +5 -0
- package/v1/client/features/index.js +21 -0
- package/v1/client/features/metrics.d.ts +14 -0
- package/v1/client/features/metrics.js +45 -0
- package/v1/client/features/ratelimits.d.ts +20 -0
- package/v1/client/features/ratelimits.js +40 -0
- package/v1/client/features/runs.d.ts +15 -0
- package/v1/client/features/runs.js +60 -0
- package/v1/client/features/workers.d.ts +14 -0
- package/v1/client/features/workers.js +56 -0
- package/v1/client/features/workflows.d.ts +17 -0
- package/v1/client/features/workflows.js +93 -0
- package/v1/client/worker.d.ts +25 -15
- package/v1/client/worker.js +76 -47
- package/v1/conditions/base.d.ts +18 -0
- package/v1/conditions/base.js +18 -0
- package/v1/conditions/index.d.ts +31 -0
- package/v1/conditions/index.js +91 -0
- package/v1/conditions/parent-condition.d.ts +40 -0
- package/v1/conditions/parent-condition.js +36 -0
- package/v1/conditions/sleep-condition.d.ts +47 -0
- package/v1/conditions/sleep-condition.js +38 -0
- package/v1/conditions/transformer.d.ts +5 -0
- package/v1/conditions/transformer.js +52 -0
- package/v1/conditions/user-event-condition.d.ts +50 -0
- package/v1/conditions/user-event-condition.js +39 -0
- package/v1/declaration.d.ts +309 -0
- package/v1/declaration.js +296 -0
- package/v1/examples/child_workflows/worker.js +2 -2
- package/v1/examples/child_workflows/workflow.d.ts +2 -2
- package/v1/examples/child_workflows/workflow.js +5 -3
- package/v1/examples/concurrency-rr/load.js +2 -2
- package/v1/examples/concurrency-rr/worker.js +2 -2
- package/v1/examples/concurrency-rr/workflow.d.ts +1 -1
- package/v1/examples/concurrency-rr/workflow.js +2 -3
- package/v1/examples/dag/worker.js +2 -2
- package/v1/examples/dag/workflow.d.ts +1 -1
- package/v1/examples/dag/workflow.js +3 -3
- package/v1/examples/dag_match_condition/event.js +28 -0
- package/v1/examples/dag_match_condition/run.d.ts +1 -0
- package/v1/examples/dag_match_condition/run.js +25 -0
- package/v1/examples/dag_match_condition/worker.d.ts +1 -0
- package/{examples/playground.js → v1/examples/dag_match_condition/worker.js} +7 -22
- package/v1/examples/dag_match_condition/workflow.d.ts +11 -0
- package/v1/examples/dag_match_condition/workflow.js +41 -0
- package/v1/examples/deep/worker.js +2 -2
- package/v1/examples/deep/workflow.d.ts +6 -6
- package/v1/examples/deep/workflow.js +7 -7
- package/v1/examples/durable-sleep/event.d.ts +1 -0
- package/v1/examples/durable-sleep/event.js +28 -0
- package/v1/examples/durable-sleep/run.d.ts +1 -0
- package/v1/examples/durable-sleep/run.js +30 -0
- package/v1/examples/durable-sleep/worker.d.ts +1 -0
- package/v1/examples/durable-sleep/worker.js +24 -0
- package/v1/examples/durable-sleep/workflow.d.ts +1 -0
- package/v1/examples/durable-sleep/workflow.js +37 -0
- package/v1/examples/inferred-typing/run.d.ts +1 -0
- package/v1/examples/inferred-typing/run.js +41 -0
- package/v1/examples/inferred-typing/worker.d.ts +1 -0
- package/v1/examples/inferred-typing/worker.js +24 -0
- package/v1/examples/inferred-typing/workflow.d.ts +15 -0
- package/v1/examples/inferred-typing/workflow.js +44 -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/legacy/run.js +2 -2
- package/v1/examples/legacy/worker.js +2 -2
- package/v1/examples/on_cron/worker.d.ts +1 -0
- package/v1/examples/on_cron/worker.js +24 -0
- package/v1/examples/on_cron/workflow.d.ts +10 -0
- package/v1/examples/on_cron/workflow.js +21 -0
- package/v1/examples/on_event/event.js +3 -2
- package/v1/examples/on_event/worker.js +2 -2
- package/v1/examples/on_event/workflow.d.ts +4 -4
- package/v1/examples/on_event/workflow.js +6 -3
- package/v1/examples/on_event copy/event.d.ts +1 -0
- package/v1/examples/on_event copy/event.js +26 -0
- package/v1/examples/on_event copy/worker.d.ts +1 -0
- package/v1/examples/on_event copy/worker.js +24 -0
- package/v1/examples/on_event copy/workflow.d.ts +16 -0
- package/v1/examples/on_event copy/workflow.js +35 -0
- package/v1/examples/on_failure/worker.js +2 -2
- package/v1/examples/on_failure/workflow.d.ts +1 -1
- package/v1/examples/on_failure/workflow.js +18 -8
- package/v1/examples/on_success/run.d.ts +1 -0
- package/v1/examples/on_success/run.js +31 -0
- package/v1/examples/on_success/worker.d.ts +1 -0
- package/v1/examples/on_success/worker.js +24 -0
- package/v1/examples/on_success/workflow.d.ts +4 -0
- package/v1/examples/on_success/workflow.js +59 -0
- 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/client-run.d.ts +1 -0
- package/v1/examples/simple/client-run.js +16 -0
- package/v1/examples/simple/cron.js +6 -2
- package/v1/examples/simple/delay.js +2 -2
- package/v1/examples/simple/enqueue.d.ts +1 -0
- package/v1/examples/simple/enqueue.js +43 -0
- package/v1/examples/simple/run.js +8 -3
- package/v1/examples/simple/schedule.js +11 -5
- package/v1/examples/simple/stub-workflow.d.ts +9 -0
- package/v1/examples/simple/stub-workflow.js +17 -0
- package/v1/examples/simple/worker.js +7 -2
- package/v1/examples/simple/workflow.d.ts +4 -3
- package/v1/examples/simple/workflow.js +5 -5
- 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 +7 -0
- package/v1/examples/sticky/workflow.js +32 -0
- package/v1/examples/with_timeouts/workflow.d.ts +9 -0
- package/v1/examples/with_timeouts/workflow.js +62 -0
- package/v1/index.d.ts +5 -0
- package/v1/index.js +20 -0
- package/v1/task.d.ts +144 -14
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/v1/workflow.d.ts +0 -158
- package/v1/workflow.js +0 -145
- /package/{examples/playground.d.ts → v1/examples/dag_match_condition/event.d.ts} +0 -0
- /package/v1/examples/{client.d.ts → hatchet-client.d.ts} +0 -0
- /package/v1/examples/{client.js → hatchet-client.js} +0 -0
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
13
|
const workflow_1 = require("./workflow");
|
|
14
14
|
function main() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const worker = yield
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('simple-concurrency-worker', {
|
|
17
17
|
workflows: [workflow_1.simpleConcurrency],
|
|
18
18
|
});
|
|
19
19
|
yield worker.start();
|
|
@@ -7,5 +7,5 @@ type SimpleOutput = {
|
|
|
7
7
|
TransformedMessage: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export declare const simpleConcurrency: import("
|
|
10
|
+
export declare const simpleConcurrency: import("../..").WorkflowDeclaration<SimpleInput, SimpleOutput>;
|
|
11
11
|
export {};
|
|
@@ -11,14 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.simpleConcurrency = void 0;
|
|
13
13
|
const workflow_1 = require("../../../workflow");
|
|
14
|
-
const
|
|
14
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
15
15
|
const sleep = (ms) => new Promise((resolve) => {
|
|
16
16
|
setTimeout(resolve, ms);
|
|
17
17
|
});
|
|
18
|
-
exports.simpleConcurrency =
|
|
18
|
+
exports.simpleConcurrency = hatchet_client_1.hatchet.workflow({
|
|
19
19
|
name: 'simple-concurrency',
|
|
20
20
|
concurrency: {
|
|
21
|
-
name: 'simple-concurrency',
|
|
22
21
|
maxRuns: 100,
|
|
23
22
|
limitStrategy: workflow_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
24
23
|
expression: 'input.GroupKey',
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
13
|
const workflow_1 = require("./workflow");
|
|
14
14
|
function main() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const worker = yield
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('dag-worker', {
|
|
17
17
|
workflows: [workflow_1.dag],
|
|
18
18
|
});
|
|
19
19
|
yield worker.start();
|
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.dag = void 0;
|
|
13
|
-
const
|
|
14
|
-
exports.dag =
|
|
13
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
14
|
+
exports.dag = hatchet_client_1.hatchet.workflow({
|
|
15
15
|
name: 'simple',
|
|
16
16
|
});
|
|
17
17
|
const toLower = exports.dag.task({
|
|
@@ -26,7 +26,7 @@ exports.dag.task({
|
|
|
26
26
|
name: 'reverse',
|
|
27
27
|
parents: [toLower],
|
|
28
28
|
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const lower = yield ctx.
|
|
29
|
+
const lower = yield ctx.parentOutput(toLower);
|
|
30
30
|
return {
|
|
31
31
|
Original: input.Message,
|
|
32
32
|
Transformed: lower.TransformedMessage.split('').reverse().join(''),
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
function main() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const event = yield hatchet_client_1.hatchet.events.push('user:event', {
|
|
16
|
+
Data: { Hello: 'World' },
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (require.main === module) {
|
|
21
|
+
main()
|
|
22
|
+
.then(() => process.exit(0))
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error('Error:', error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/* eslint-disable no-console */
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const res = yield workflow_1.dagWithConditions.run({});
|
|
17
|
+
console.log(res['first-task'].Completed);
|
|
18
|
+
console.log(res['second-task'].Completed);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (require.main === module) {
|
|
22
|
+
main()
|
|
23
|
+
.catch(console.error)
|
|
24
|
+
.finally(() => process.exit(0));
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,32 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
17
14
|
function main() {
|
|
18
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const worker = yield hatchet.worker('
|
|
20
|
-
|
|
21
|
-
id: 'playground-ts',
|
|
22
|
-
description: 'desc',
|
|
23
|
-
on: {
|
|
24
|
-
event: 'test1',
|
|
25
|
-
},
|
|
26
|
-
steps: [
|
|
27
|
-
{
|
|
28
|
-
name: 'test1-step1',
|
|
29
|
-
run: (ctx) => {
|
|
30
|
-
const playground = ctx.playground('test1', 'default');
|
|
31
|
-
return { step1: playground, name: ctx.stepName(), workflowRunId: ctx.workflowRunId() };
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
],
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('dag-worker', {
|
|
17
|
+
workflows: [workflow_1.dagWithConditions],
|
|
35
18
|
});
|
|
36
19
|
yield worker.start();
|
|
37
20
|
});
|
|
38
21
|
}
|
|
39
|
-
main
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.dagWithConditions = void 0;
|
|
16
|
+
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
|
+
const conditions_1 = require("../../conditions");
|
|
18
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
19
|
+
exports.dagWithConditions = hatchet_client_1.hatchet.workflow({
|
|
20
|
+
name: 'simple',
|
|
21
|
+
});
|
|
22
|
+
const firstTask = exports.dagWithConditions.task({
|
|
23
|
+
name: 'first-task',
|
|
24
|
+
fn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
yield (0, sleep_1.default)(2000);
|
|
26
|
+
return {
|
|
27
|
+
Completed: true,
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
exports.dagWithConditions.task({
|
|
32
|
+
name: 'second-task',
|
|
33
|
+
parents: [firstTask],
|
|
34
|
+
waitFor: (0, conditions_1.Or)({ eventKey: 'user:event' }, { sleepFor: '10s' }),
|
|
35
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
console.log('triggered by condition', ctx.triggers());
|
|
37
|
+
return {
|
|
38
|
+
Completed: true,
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
13
|
const workflow_1 = require("./workflow");
|
|
14
14
|
function main() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const worker = yield
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('simple-worker', {
|
|
17
17
|
workflows: [workflow_1.parent, workflow_1.child1, workflow_1.child2, workflow_1.child3, workflow_1.child4, workflow_1.child5],
|
|
18
18
|
slots: 5000,
|
|
19
19
|
});
|
|
@@ -7,12 +7,12 @@ type Output = {
|
|
|
7
7
|
Sum: number;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export declare const child1: import("
|
|
11
|
-
export declare const child2: import("
|
|
12
|
-
export declare const child3: import("
|
|
13
|
-
export declare const child4: import("
|
|
14
|
-
export declare const child5: import("
|
|
15
|
-
export declare const parent: import("
|
|
10
|
+
export declare const child1: import("../..").WorkflowDeclaration<SimpleInput, Output>;
|
|
11
|
+
export declare const child2: import("../..").WorkflowDeclaration<SimpleInput, Output>;
|
|
12
|
+
export declare const child3: import("../..").WorkflowDeclaration<SimpleInput, Output>;
|
|
13
|
+
export declare const child4: import("../..").WorkflowDeclaration<SimpleInput, Output>;
|
|
14
|
+
export declare const child5: import("../..").WorkflowDeclaration<SimpleInput, Output>;
|
|
15
|
+
export declare const parent: import("../..").WorkflowDeclaration<SimpleInput, {
|
|
16
16
|
parent: Output["transformer"];
|
|
17
17
|
}>;
|
|
18
18
|
export {};
|
|
@@ -14,8 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.parent = exports.child5 = exports.child4 = exports.child3 = exports.child2 = exports.child1 = void 0;
|
|
16
16
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
|
-
const
|
|
18
|
-
exports.child1 =
|
|
17
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
18
|
+
exports.child1 = hatchet_client_1.hatchet.workflow({
|
|
19
19
|
name: 'child1',
|
|
20
20
|
});
|
|
21
21
|
exports.child1.task({
|
|
@@ -27,7 +27,7 @@ exports.child1.task({
|
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
|
-
exports.child2 =
|
|
30
|
+
exports.child2 = hatchet_client_1.hatchet.workflow({
|
|
31
31
|
name: 'child2',
|
|
32
32
|
});
|
|
33
33
|
exports.child2.task({
|
|
@@ -44,7 +44,7 @@ exports.child2.task({
|
|
|
44
44
|
};
|
|
45
45
|
}),
|
|
46
46
|
});
|
|
47
|
-
exports.child3 =
|
|
47
|
+
exports.child3 = hatchet_client_1.hatchet.workflow({
|
|
48
48
|
name: 'child3',
|
|
49
49
|
});
|
|
50
50
|
exports.child3.task({
|
|
@@ -60,7 +60,7 @@ exports.child3.task({
|
|
|
60
60
|
};
|
|
61
61
|
}),
|
|
62
62
|
});
|
|
63
|
-
exports.child4 =
|
|
63
|
+
exports.child4 = hatchet_client_1.hatchet.workflow({
|
|
64
64
|
name: 'child4',
|
|
65
65
|
});
|
|
66
66
|
exports.child4.task({
|
|
@@ -76,7 +76,7 @@ exports.child4.task({
|
|
|
76
76
|
};
|
|
77
77
|
}),
|
|
78
78
|
});
|
|
79
|
-
exports.child5 =
|
|
79
|
+
exports.child5 = hatchet_client_1.hatchet.workflow({
|
|
80
80
|
name: 'child5',
|
|
81
81
|
});
|
|
82
82
|
exports.child5.task({
|
|
@@ -92,7 +92,7 @@ exports.child5.task({
|
|
|
92
92
|
};
|
|
93
93
|
}),
|
|
94
94
|
});
|
|
95
|
-
exports.parent =
|
|
95
|
+
exports.parent = hatchet_client_1.hatchet.workflow({
|
|
96
96
|
name: 'parent',
|
|
97
97
|
});
|
|
98
98
|
exports.parent.task({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
function main() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const event = yield hatchet_client_1.hatchet.events.push('user:event', {
|
|
16
|
+
Data: { Hello: 'World' },
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (require.main === module) {
|
|
21
|
+
main()
|
|
22
|
+
.then(() => process.exit(0))
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error('Error:', error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const workflow_1 = require("./workflow");
|
|
13
|
+
function main() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const timeStart = Date.now();
|
|
16
|
+
const res = yield workflow_1.durableSleep.run({});
|
|
17
|
+
const timeEnd = Date.now();
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log(`Time taken: ${timeEnd - timeStart}ms`);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main()
|
|
24
|
+
.then(() => process.exit(0))
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.error('Error:', error);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('sleep-worker', {
|
|
17
|
+
workflows: [workflow_1.durableSleep],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const durableSleep: import("../..").WorkflowDeclaration<any, any>;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.durableSleep = void 0;
|
|
13
|
+
// import sleep from '../../../util/sleep.js';
|
|
14
|
+
const conditions_1 = require("../../conditions");
|
|
15
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
16
|
+
exports.durableSleep = hatchet_client_1.hatchet.workflow({
|
|
17
|
+
name: 'durable-sleep',
|
|
18
|
+
});
|
|
19
|
+
exports.durableSleep.durableTask({
|
|
20
|
+
name: 'durable-sleep',
|
|
21
|
+
executionTimeout: '10m',
|
|
22
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
console.log('sleeping for 5s');
|
|
24
|
+
const sleepRes = yield ctx.sleepFor('5s');
|
|
25
|
+
console.log('done sleeping for 5s', sleepRes);
|
|
26
|
+
// wait for an event or a sleep
|
|
27
|
+
const res = yield ctx.waitFor((0, conditions_1.Or)({
|
|
28
|
+
eventKey: 'user:event',
|
|
29
|
+
}, {
|
|
30
|
+
sleepFor: '1m',
|
|
31
|
+
}));
|
|
32
|
+
console.log('res', res);
|
|
33
|
+
return {
|
|
34
|
+
Value: 'done',
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/* eslint-disable no-console */
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const declaredTypeRun = workflow_1.declaredType.run({
|
|
17
|
+
Message: 'hello',
|
|
18
|
+
});
|
|
19
|
+
const inferredTypeRun = workflow_1.inferredType.run({
|
|
20
|
+
Message: 'hello',
|
|
21
|
+
});
|
|
22
|
+
const crazyWorkflowRun = workflow_1.crazyWorkflow.run({
|
|
23
|
+
Message: 'hello',
|
|
24
|
+
});
|
|
25
|
+
const inferredTypeDurableRun = workflow_1.inferredTypeDurable.run({
|
|
26
|
+
Message: 'Durable Task',
|
|
27
|
+
});
|
|
28
|
+
const [declaredTypeResult, inferredTypeResult, inferredTypeDurableResult, crazyWorkflowResult] = yield Promise.all([declaredTypeRun, inferredTypeRun, inferredTypeDurableRun, crazyWorkflowRun]);
|
|
29
|
+
console.log('declaredTypeResult', declaredTypeResult);
|
|
30
|
+
console.log('inferredTypeResult', inferredTypeResult);
|
|
31
|
+
console.log('inferredTypeDurableResult', inferredTypeDurableResult);
|
|
32
|
+
console.log('crazyWorkflowResult', crazyWorkflowResult);
|
|
33
|
+
console.log('declaredTypeResult.TransformedMessage', declaredTypeResult.TransformedMessage);
|
|
34
|
+
console.log('inferredTypeResult.TransformedMessage', inferredTypeResult.TransformedMessage);
|
|
35
|
+
console.log('inferredTypeDurableResult.TransformedMessage', inferredTypeDurableResult.TransformedMessage);
|
|
36
|
+
console.log('crazyWorkflowResult.TransformedMessage', crazyWorkflowResult.TransformedMessage);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (require.main === module) {
|
|
40
|
+
main();
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('simple-worker', {
|
|
17
|
+
workflows: [workflow_1.declaredType, workflow_1.inferredType, workflow_1.inferredTypeDurable, workflow_1.crazyWorkflow],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SimpleInput = {
|
|
2
|
+
Message: string;
|
|
3
|
+
};
|
|
4
|
+
type SimpleOutput = {
|
|
5
|
+
TransformedMessage: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const declaredType: import("../..").TaskWorkflowDeclaration<SimpleInput, SimpleOutput>;
|
|
8
|
+
export declare const inferredType: import("../..").TaskWorkflowDeclaration<SimpleInput, {
|
|
9
|
+
TransformedMessage: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const inferredTypeDurable: import("../..").TaskWorkflowDeclaration<SimpleInput, {
|
|
12
|
+
TransformedMessage: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const crazyWorkflow: import("../..").WorkflowDeclaration<any, any>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.crazyWorkflow = exports.inferredTypeDurable = exports.inferredType = exports.declaredType = void 0;
|
|
13
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
14
|
+
exports.declaredType = hatchet_client_1.hatchet.task({
|
|
15
|
+
name: 'declared-type',
|
|
16
|
+
fn: (input) => {
|
|
17
|
+
return {
|
|
18
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
exports.inferredType = hatchet_client_1.hatchet.task({
|
|
23
|
+
name: 'inferred-type',
|
|
24
|
+
fn: (input) => {
|
|
25
|
+
return {
|
|
26
|
+
TransformedMessage: input.Message.toUpperCase(),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
exports.inferredTypeDurable = hatchet_client_1.hatchet.durableTask({
|
|
31
|
+
name: 'inferred-type-durable',
|
|
32
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
// await ctx.sleepFor('5s');
|
|
34
|
+
return {
|
|
35
|
+
TransformedMessage: input.Message.toUpperCase(),
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
exports.crazyWorkflow = hatchet_client_1.hatchet.workflow({
|
|
40
|
+
name: 'crazy-workflow',
|
|
41
|
+
});
|
|
42
|
+
const step1 = exports.crazyWorkflow.task(exports.declaredType);
|
|
43
|
+
// crazyWorkflow.task(inferredTypeDurable);
|
|
44
|
+
exports.crazyWorkflow.task(Object.assign({ parents: [step1] }, exports.inferredType.taskDef));
|