@hatchet-dev/typescript-sdk 0.20.3 → 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.js +0 -1
- 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 +1 -17
- package/clients/worker/handler.d.ts +2 -2
- package/clients/worker/worker.d.ts +4 -4
- package/clients/worker/worker.js +14 -28
- 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 +1 -1
- 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,39 @@
|
|
|
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.simpleConcurrency.run([
|
|
16
|
+
{
|
|
17
|
+
Message: 'Hello World',
|
|
18
|
+
GroupKey: 'A',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
Message: 'Goodbye Moon',
|
|
22
|
+
GroupKey: 'A',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
Message: 'Hello World B',
|
|
26
|
+
GroupKey: 'B',
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.log(res[0]['to-lower'].TransformedMessage);
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.log(res[1]['to-lower'].TransformedMessage);
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log(res[2]['to-lower'].TransformedMessage);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (require.main === module) {
|
|
38
|
+
main().then(() => process.exit(0));
|
|
39
|
+
}
|
|
@@ -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-concurrency-worker', {
|
|
17
|
+
workflows: [workflow_1.simpleConcurrency],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type SimpleInput = {
|
|
2
|
+
Message: string;
|
|
3
|
+
GroupKey: string;
|
|
4
|
+
};
|
|
5
|
+
type SimpleOutput = {
|
|
6
|
+
'to-lower': {
|
|
7
|
+
TransformedMessage: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const simpleConcurrency: import("../../workflow").Workflow<SimpleInput, SimpleOutput>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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.simpleConcurrency = void 0;
|
|
13
|
+
const workflow_1 = require("../../../workflow");
|
|
14
|
+
const client_1 = require("../client");
|
|
15
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
16
|
+
setTimeout(resolve, ms);
|
|
17
|
+
});
|
|
18
|
+
exports.simpleConcurrency = client_1.hatchet.workflow({
|
|
19
|
+
name: 'simple-concurrency',
|
|
20
|
+
concurrency: {
|
|
21
|
+
name: 'simple-concurrency',
|
|
22
|
+
maxRuns: 100,
|
|
23
|
+
limitStrategy: workflow_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
24
|
+
expression: 'input.GroupKey',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
exports.simpleConcurrency.task({
|
|
28
|
+
name: 'to-lower',
|
|
29
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
yield sleep(Math.floor(Math.random() * (1000 - 200 + 1)) + 200);
|
|
31
|
+
return {
|
|
32
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
@@ -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.dag.run({
|
|
16
|
+
Message: 'hello world',
|
|
17
|
+
});
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log(res.reverse.Transformed);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -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('dag-worker', {
|
|
17
|
+
workflows: [workflow_1.dag],
|
|
18
|
+
});
|
|
19
|
+
yield worker.start();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (require.main === module) {
|
|
23
|
+
main();
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.dag = void 0;
|
|
13
|
+
const client_1 = require("../client");
|
|
14
|
+
exports.dag = client_1.hatchet.workflow({
|
|
15
|
+
name: 'simple',
|
|
16
|
+
});
|
|
17
|
+
const toLower = exports.dag.task({
|
|
18
|
+
name: 'to-lower',
|
|
19
|
+
fn: (input) => {
|
|
20
|
+
return {
|
|
21
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
exports.dag.task({
|
|
26
|
+
name: 'reverse',
|
|
27
|
+
parents: [toLower],
|
|
28
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
const lower = yield ctx.parentData(toLower);
|
|
30
|
+
return {
|
|
31
|
+
Original: input.Message,
|
|
32
|
+
Transformed: lower.TransformedMessage.split('').reverse().join(''),
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
@@ -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 workflow_1 = require("./workflow");
|
|
13
|
+
function main() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const res = yield workflow_1.parent.run({
|
|
16
|
+
Message: 'hello',
|
|
17
|
+
N: 5,
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log(res.parent.Sum);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main()
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
.catch(console.error)
|
|
27
|
+
.finally(() => process.exit(0));
|
|
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
|
+
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.parent, workflow_1.child1, workflow_1.child2, workflow_1.child3, workflow_1.child4, workflow_1.child5],
|
|
18
|
+
slots: 5000,
|
|
19
|
+
});
|
|
20
|
+
yield worker.start();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main();
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type SimpleInput = {
|
|
2
|
+
Message: string;
|
|
3
|
+
N: number;
|
|
4
|
+
};
|
|
5
|
+
type Output = {
|
|
6
|
+
transformer: {
|
|
7
|
+
Sum: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const child1: import("../../workflow").Workflow<SimpleInput, Output>;
|
|
11
|
+
export declare const child2: import("../../workflow").Workflow<SimpleInput, Output>;
|
|
12
|
+
export declare const child3: import("../../workflow").Workflow<SimpleInput, Output>;
|
|
13
|
+
export declare const child4: import("../../workflow").Workflow<SimpleInput, Output>;
|
|
14
|
+
export declare const child5: import("../../workflow").Workflow<SimpleInput, Output>;
|
|
15
|
+
export declare const parent: import("../../workflow").Workflow<SimpleInput, {
|
|
16
|
+
parent: Output["transformer"];
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
|
@@ -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 {};
|