@hatchet-dev/typescript-sdk 0.20.2 → 1.0.0-alpha0
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/hatchet-client/features/cron-client.d.ts +0 -1
- package/clients/hatchet-client/features/cron-client.js +6 -3
- package/clients/hatchet-client/hatchet-client.d.ts +8 -7
- package/clients/hatchet-client/hatchet-client.js +9 -8
- package/clients/hatchet-client/hatchet-logger.js +2 -2
- package/clients/listener/listener-client.js +1 -0
- package/clients/rest/generated/Api.d.ts +201 -1
- package/clients/rest/generated/Api.js +108 -0
- package/clients/rest/generated/data-contracts.d.ts +270 -8
- package/clients/rest/generated/data-contracts.js +20 -1
- package/clients/worker/handler.d.ts +2 -2
- package/clients/worker/worker.d.ts +4 -4
- package/clients/worker/worker.js +3 -3
- package/examples/api.js +1 -1
- package/examples/example-event-with-results.js +1 -1
- package/examples/stream-by-additional-meta.js +1 -1
- package/index.d.ts +3 -1
- package/index.js +5 -3
- package/package.json +2 -2
- package/protoc/dispatcher/dispatcher.d.ts +2 -0
- package/protoc/dispatcher/dispatcher.js +17 -1
- package/protoc/workflows/v1-admin.d.ts +79 -0
- package/protoc/workflows/v1-admin.js +529 -0
- package/sdk.d.ts +1 -1
- package/sdk.js +2 -2
- package/step.d.ts +75 -9
- package/step.js +65 -2
- package/util/hatchet-promise/hatchet-promise.js +1 -0
- package/v1/client/client.d.ts +81 -0
- package/v1/client/client.interface.d.ts +4 -0
- package/v1/client/client.interface.js +2 -0
- package/v1/client/client.js +134 -0
- package/v1/client/worker.d.ts +82 -0
- package/v1/client/worker.js +125 -0
- package/v1/examples/child_workflows/run.d.ts +1 -0
- package/v1/examples/child_workflows/run.js +30 -0
- package/v1/examples/child_workflows/worker.d.ts +1 -0
- package/v1/examples/child_workflows/worker.js +24 -0
- package/v1/examples/child_workflows/workflow.d.ts +19 -0
- package/v1/examples/child_workflows/workflow.js +43 -0
- package/v1/examples/client.d.ts +2 -0
- package/v1/examples/client.js +5 -0
- package/v1/examples/concurrency-rr/load.d.ts +1 -0
- package/v1/examples/concurrency-rr/load.js +54 -0
- package/v1/examples/concurrency-rr/run.d.ts +1 -0
- package/v1/examples/concurrency-rr/run.js +39 -0
- package/v1/examples/concurrency-rr/worker.d.ts +1 -0
- package/v1/examples/concurrency-rr/worker.js +24 -0
- package/v1/examples/concurrency-rr/workflow.d.ts +11 -0
- package/v1/examples/concurrency-rr/workflow.js +35 -0
- package/v1/examples/dag/run.d.ts +1 -0
- package/v1/examples/dag/run.js +24 -0
- package/v1/examples/dag/worker.d.ts +1 -0
- package/v1/examples/dag/worker.js +24 -0
- package/v1/examples/dag/workflow.d.ts +11 -0
- package/v1/examples/dag/workflow.js +35 -0
- package/v1/examples/deep/run.d.ts +1 -0
- package/v1/examples/deep/run.js +28 -0
- package/v1/examples/deep/worker.d.ts +1 -0
- package/v1/examples/deep/worker.js +25 -0
- package/v1/examples/deep/workflow.d.ts +18 -0
- package/v1/examples/deep/workflow.js +110 -0
- package/v1/examples/legacy/run.d.ts +1 -0
- package/v1/examples/legacy/run.js +25 -0
- package/v1/examples/legacy/worker.d.ts +1 -0
- package/v1/examples/legacy/worker.js +24 -0
- package/v1/examples/legacy/workflow.d.ts +2 -0
- package/v1/examples/legacy/workflow.js +36 -0
- package/v1/examples/on_event/event.d.ts +1 -0
- package/v1/examples/on_event/event.js +25 -0
- package/v1/examples/on_event/worker.d.ts +1 -0
- package/v1/examples/on_event/worker.js +24 -0
- package/v1/examples/on_event/workflow.d.ts +17 -0
- package/v1/examples/on_event/workflow.js +33 -0
- package/v1/examples/simple/cron.d.ts +1 -0
- package/v1/examples/simple/cron.js +26 -0
- package/v1/examples/simple/delay.d.ts +1 -0
- package/v1/examples/simple/delay.js +27 -0
- package/v1/examples/simple/run.d.ts +1 -0
- package/v1/examples/simple/run.js +24 -0
- package/v1/examples/simple/schedule.d.ts +1 -0
- package/v1/examples/simple/schedule.js +27 -0
- package/v1/examples/simple/worker.d.ts +1 -0
- package/v1/examples/simple/worker.js +24 -0
- package/v1/examples/simple/workflow.d.ts +5 -0
- package/v1/examples/simple/workflow.js +15 -0
- package/v1/index.d.ts +0 -0
- package/v1/index.js +1 -0
- package/v1/task.d.ts +51 -0
- package/v1/task.js +2 -0
- package/v1/workflow.d.ts +152 -0
- package/v1/workflow.js +145 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/workflow.d.ts +3 -0
|
@@ -0,0 +1,110 @@
|
|
|
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.parent = exports.child5 = exports.child4 = exports.child3 = exports.child2 = exports.child1 = void 0;
|
|
16
|
+
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
|
+
const client_1 = require("../client");
|
|
18
|
+
exports.child1 = client_1.hatchet.workflow({
|
|
19
|
+
name: 'child1',
|
|
20
|
+
});
|
|
21
|
+
exports.child1.task({
|
|
22
|
+
name: 'transformer',
|
|
23
|
+
fn: () => {
|
|
24
|
+
(0, sleep_1.default)(15);
|
|
25
|
+
return {
|
|
26
|
+
Sum: 1,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
exports.child2 = client_1.hatchet.workflow({
|
|
31
|
+
name: 'child2',
|
|
32
|
+
});
|
|
33
|
+
exports.child2.task({
|
|
34
|
+
name: 'transformer',
|
|
35
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const count = input.N;
|
|
37
|
+
const promises = Array(count)
|
|
38
|
+
.fill(null)
|
|
39
|
+
.map(() => ({ workflow: exports.child1, input }));
|
|
40
|
+
const results = yield ctx.bulkRunChildren(promises);
|
|
41
|
+
(0, sleep_1.default)(15);
|
|
42
|
+
return {
|
|
43
|
+
Sum: results.reduce((acc, r) => acc + r.transformer.Sum, 0),
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
exports.child3 = client_1.hatchet.workflow({
|
|
48
|
+
name: 'child3',
|
|
49
|
+
});
|
|
50
|
+
exports.child3.task({
|
|
51
|
+
name: 'transformer',
|
|
52
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const count = input.N;
|
|
54
|
+
const promises = Array(count)
|
|
55
|
+
.fill(null)
|
|
56
|
+
.map(() => ({ workflow: exports.child2, input }));
|
|
57
|
+
const results = yield ctx.bulkRunChildren(promises);
|
|
58
|
+
return {
|
|
59
|
+
Sum: results.reduce((acc, r) => acc + r.transformer.Sum, 0),
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
exports.child4 = client_1.hatchet.workflow({
|
|
64
|
+
name: 'child4',
|
|
65
|
+
});
|
|
66
|
+
exports.child4.task({
|
|
67
|
+
name: 'transformer',
|
|
68
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const count = input.N;
|
|
70
|
+
const promises = Array(count)
|
|
71
|
+
.fill(null)
|
|
72
|
+
.map(() => ({ workflow: exports.child3, input }));
|
|
73
|
+
const results = yield ctx.bulkRunChildren(promises);
|
|
74
|
+
return {
|
|
75
|
+
Sum: results.reduce((acc, r) => acc + r.transformer.Sum, 0),
|
|
76
|
+
};
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
exports.child5 = client_1.hatchet.workflow({
|
|
80
|
+
name: 'child5',
|
|
81
|
+
});
|
|
82
|
+
exports.child5.task({
|
|
83
|
+
name: 'transformer',
|
|
84
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const count = input.N;
|
|
86
|
+
const promises = Array(count)
|
|
87
|
+
.fill(null)
|
|
88
|
+
.map(() => ({ workflow: exports.child4, input }));
|
|
89
|
+
const results = yield ctx.bulkRunChildren(promises);
|
|
90
|
+
return {
|
|
91
|
+
Sum: results.reduce((acc, r) => acc + r.transformer.Sum, 0),
|
|
92
|
+
};
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
exports.parent = client_1.hatchet.workflow({
|
|
96
|
+
name: 'parent',
|
|
97
|
+
});
|
|
98
|
+
exports.parent.task({
|
|
99
|
+
name: 'parent',
|
|
100
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
const count = input.N; // Random number between 2-4
|
|
102
|
+
const promises = Array(count)
|
|
103
|
+
.fill(null)
|
|
104
|
+
.map(() => ({ workflow: exports.child5, input }));
|
|
105
|
+
const results = yield ctx.bulkRunChildren(promises);
|
|
106
|
+
return {
|
|
107
|
+
Sum: results.reduce((acc, r) => acc + r.transformer.Sum, 0),
|
|
108
|
+
};
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
@@ -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
|
+
const client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const res = yield client_1.hatchet.run(workflow_1.simple, {
|
|
17
|
+
Message: 'hello',
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log(res.step2);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main();
|
|
25
|
+
}
|
|
@@ -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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield client_1.hatchet.worker('legacy-worker', {
|
|
17
|
+
workflows: [workflow_1.simple],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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.simple = void 0;
|
|
13
|
+
exports.simple = {
|
|
14
|
+
id: 'legacy-workflow',
|
|
15
|
+
description: 'test',
|
|
16
|
+
on: {
|
|
17
|
+
event: 'user:create',
|
|
18
|
+
},
|
|
19
|
+
steps: [
|
|
20
|
+
{
|
|
21
|
+
name: 'step1',
|
|
22
|
+
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const input = ctx.workflowInput();
|
|
24
|
+
return { step1: `original input: ${input.Message}` };
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'step2',
|
|
29
|
+
parents: ['step1'],
|
|
30
|
+
run: (ctx) => {
|
|
31
|
+
const step1Output = ctx.stepOutput('step1');
|
|
32
|
+
return { step2: `step1 output: ${step1Output.step1}` };
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
@@ -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
|
+
const client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const res = yield client_1.hatchet.event.push(workflow_1.SIMPLE_EVENT, {
|
|
17
|
+
Message: 'hello',
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log(res.eventId);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main();
|
|
25
|
+
}
|
|
@@ -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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield client_1.hatchet.worker('on-event-worker', {
|
|
17
|
+
workflows: [workflow_1.lower, workflow_1.upper],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const SIMPLE_EVENT = "simple-event:create";
|
|
2
|
+
type Input = {
|
|
3
|
+
Message: string;
|
|
4
|
+
};
|
|
5
|
+
type LowerOutput = {
|
|
6
|
+
lower: {
|
|
7
|
+
TransformedMessage: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const lower: import("../../workflow").Workflow<Input, LowerOutput>;
|
|
11
|
+
type UpperOutput = {
|
|
12
|
+
upper: {
|
|
13
|
+
TransformedMessage: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const upper: import("../../workflow").Workflow<Input, UpperOutput>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upper = exports.lower = exports.SIMPLE_EVENT = void 0;
|
|
4
|
+
const client_1 = require("../client");
|
|
5
|
+
exports.SIMPLE_EVENT = 'simple-event:create';
|
|
6
|
+
exports.lower = client_1.hatchet.workflow({
|
|
7
|
+
name: 'lower',
|
|
8
|
+
on: {
|
|
9
|
+
event: exports.SIMPLE_EVENT,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
exports.lower.task({
|
|
13
|
+
name: 'lower',
|
|
14
|
+
fn: (input) => {
|
|
15
|
+
return {
|
|
16
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
exports.upper = client_1.hatchet.workflow({
|
|
21
|
+
name: 'upper',
|
|
22
|
+
on: {
|
|
23
|
+
event: exports.SIMPLE_EVENT,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
exports.upper.task({
|
|
27
|
+
name: 'upper',
|
|
28
|
+
fn: (input) => {
|
|
29
|
+
return {
|
|
30
|
+
TransformedMessage: input.Message.toUpperCase(),
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const cron = yield workflow_1.simple.cron('simple-daily', '0 0 * * *', {
|
|
17
|
+
Message: 'hello',
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log(cron.metadata.id);
|
|
21
|
+
yield client_1.hatchet.cron.delete(cron);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (require.main === module) {
|
|
25
|
+
main();
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const tomorrow = 24 * 60 * 60; // 1 day
|
|
17
|
+
const scheduled = yield workflow_1.simple.delay(tomorrow, {
|
|
18
|
+
Message: 'hello',
|
|
19
|
+
});
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log(scheduled.metadata.id);
|
|
22
|
+
yield client_1.hatchet.schedule.delete(scheduled);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
main();
|
|
27
|
+
}
|
|
@@ -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 workflow_1 = require("./workflow");
|
|
13
|
+
function main() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const res = yield workflow_1.simple.run({
|
|
16
|
+
Message: 'hello',
|
|
17
|
+
});
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log(res.step2);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const runAt = new Date(Date.now() + 1000 * 60 * 60 * 24);
|
|
17
|
+
const scheduled = yield workflow_1.simple.schedule(runAt, {
|
|
18
|
+
Message: 'hello',
|
|
19
|
+
});
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log(scheduled.metadata.id);
|
|
22
|
+
yield client_1.hatchet.schedule.delete(scheduled);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
main();
|
|
27
|
+
}
|
|
@@ -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 client_1 = require("../client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield client_1.hatchet.worker('simple-worker', {
|
|
17
|
+
workflows: [workflow_1.simple],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.simple = void 0;
|
|
4
|
+
const client_1 = require("../client");
|
|
5
|
+
exports.simple = client_1.hatchet.workflow({
|
|
6
|
+
name: 'simple',
|
|
7
|
+
});
|
|
8
|
+
exports.simple.task({
|
|
9
|
+
name: 'to-lower',
|
|
10
|
+
fn: (input) => {
|
|
11
|
+
return {
|
|
12
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
});
|
package/v1/index.d.ts
ADDED
|
File without changes
|
package/v1/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/v1/task.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Context, CreateStep } from '../step';
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a hatchet task which is an atomic unit of work in a workflow.
|
|
4
|
+
* @template T The input type for the task function.
|
|
5
|
+
* @template K The return type of the task function (can be inferred from the return value of fn).
|
|
6
|
+
*/
|
|
7
|
+
export type CreateTaskOpts<T, K> = {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the task.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The function to execute when the task runs.
|
|
14
|
+
* @param input The input data for the workflow invocation.
|
|
15
|
+
* @param ctx The execution context for the task.
|
|
16
|
+
* @returns The result of the task execution.
|
|
17
|
+
*/
|
|
18
|
+
fn: (input: T, ctx: Context<T>) => K | Promise<K>;
|
|
19
|
+
/**
|
|
20
|
+
* Parent tasks that must complete before this task runs.
|
|
21
|
+
* Used to define the directed acyclic graph (DAG) of the workflow.
|
|
22
|
+
*/
|
|
23
|
+
parents?: CreateTaskOpts<T, any>[];
|
|
24
|
+
/**
|
|
25
|
+
* Timeout duration for the task in Go duration format (e.g., "1s", "5m", "1h").
|
|
26
|
+
*/
|
|
27
|
+
timeout?: CreateStep<T, K>['timeout'];
|
|
28
|
+
/**
|
|
29
|
+
* Optional retry configuration for the task.
|
|
30
|
+
*/
|
|
31
|
+
retries?: CreateStep<T, K>['retries'];
|
|
32
|
+
/**
|
|
33
|
+
* Backoff strategy configuration for retries.
|
|
34
|
+
* - factor: Multiplier for exponential backoff
|
|
35
|
+
* - maxSeconds: Maximum backoff duration in seconds
|
|
36
|
+
*/
|
|
37
|
+
backoff?: CreateStep<T, K>['backoff'];
|
|
38
|
+
/**
|
|
39
|
+
* Optional rate limiting configuration for the task.
|
|
40
|
+
*/
|
|
41
|
+
rateLimits?: CreateStep<T, K>['rate_limits'];
|
|
42
|
+
/**
|
|
43
|
+
* Worker labels for task routing and scheduling.
|
|
44
|
+
* Each label can be a simple string/number value or an object with additional configuration:
|
|
45
|
+
* - value: The label value (string or number)
|
|
46
|
+
* - required: Whether the label is required for worker matching
|
|
47
|
+
* - weight: Priority weight for worker selection
|
|
48
|
+
* - comparator: Custom comparison logic for label matching
|
|
49
|
+
*/
|
|
50
|
+
workerLabels?: CreateStep<T, K>['worker_labels'];
|
|
51
|
+
};
|
package/v1/task.js
ADDED