@hatchet-dev/typescript-sdk 1.13.1 → 1.14.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/dispatcher/dispatcher-client.d.ts +1 -1
- package/clients/dispatcher/heartbeat/heartbeat-controller.js +13 -1
- package/clients/dispatcher/heartbeat/heartbeat-worker.js +4 -3
- package/clients/event/event-client.d.ts +1 -2
- package/clients/event/event-client.js +2 -2
- package/clients/hatchet-client/client-config.d.ts +15 -5
- package/clients/hatchet-client/client-config.js +3 -0
- package/clients/hatchet-client/hatchet-logger.js +1 -0
- package/clients/hatchet-client/index.d.ts +1 -1
- package/clients/hatchet-client/index.js +1 -1
- package/clients/listeners/durable-listener/durable-listener-client.d.ts +6 -0
- package/clients/listeners/durable-listener/durable-listener-client.js +8 -0
- package/clients/listeners/durable-listener/pooled-durable-listener-client.d.ts +9 -2
- package/clients/listeners/durable-listener/pooled-durable-listener-client.js +67 -15
- package/clients/listeners/run-listener/child-listener-client.js +1 -0
- package/clients/listeners/run-listener/pooled-child-listener-client.d.ts +10 -2
- package/clients/listeners/run-listener/pooled-child-listener-client.js +63 -7
- package/clients/rest/api.js +10 -2
- package/clients/rest/generated/Api.d.ts +2 -2
- package/clients/rest/generated/data-contracts.d.ts +6 -0
- package/index.d.ts +2 -3
- package/index.js +2 -3
- package/{examples → legacy/examples}/affinity-workers.js +2 -2
- package/{examples → legacy/examples}/bulk-fanout-trigger.js +1 -1
- package/{examples → legacy/examples}/bulk-fanout-worker.js +1 -1
- package/{examples → legacy/examples}/bulk-trigger.js +1 -1
- package/{examples → legacy/examples}/byo-logger.js +1 -1
- package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-event.js +1 -1
- package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.js +1 -1
- package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-event.js +1 -1
- package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.js +2 -2
- package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.js +2 -2
- package/{examples → legacy/examples}/crons/cron-worker.d.ts +1 -1
- package/{examples → legacy/examples}/crons/cron-worker.js +1 -1
- package/{examples → legacy/examples}/crons/programatic-crons.js +1 -1
- package/{examples → legacy/examples}/dag-worker.js +1 -1
- package/{examples → legacy/examples}/example-event-with-results.js +2 -2
- package/{examples → legacy/examples}/example-event.js +1 -1
- package/{examples → legacy/examples}/fanout-worker.js +1 -1
- package/{examples → legacy/examples}/logger.js +1 -1
- package/{examples → legacy/examples}/manual-trigger.js +1 -1
- package/{examples → legacy/examples}/multi-workflow.js +1 -1
- package/{examples → legacy/examples}/namespaced-worker.js +1 -1
- package/{examples → legacy/examples}/on-failure.js +1 -1
- package/{examples → legacy/examples}/rate-limit/events.js +1 -1
- package/{examples → legacy/examples}/rate-limit/worker.js +2 -2
- package/{examples → legacy/examples}/retries-with-backoff.js +1 -1
- package/{examples → legacy/examples}/retries-worker.js +1 -1
- package/{examples → legacy/examples}/scheduled-runs/programatic-schedules.js +1 -1
- package/{examples → legacy/examples}/simple-worker.d.ts +1 -1
- package/{examples → legacy/examples}/simple-worker.js +1 -1
- package/{examples → legacy/examples}/sticky-trigger.js +1 -1
- package/{examples → legacy/examples}/sticky-worker-with-check.js +2 -2
- package/{examples → legacy/examples}/sticky-worker.js +2 -2
- package/{examples → legacy/examples}/stream-by-additional-meta.js +2 -2
- package/legacy/legacy-client.d.ts +30 -0
- package/legacy/legacy-client.js +67 -0
- package/legacy/legacy-transformer.d.ts +38 -0
- package/legacy/legacy-transformer.js +181 -0
- package/legacy/step.d.ts +429 -0
- package/legacy/step.js +662 -0
- package/legacy/workflow.d.ts +488 -0
- package/legacy/workflow.js +72 -0
- package/package.json +2 -2
- package/step.d.ts +1 -430
- package/step.js +6 -647
- package/util/abort-error.d.ts +38 -0
- package/util/abort-error.js +58 -0
- package/util/hatchet-promise/hatchet-promise.d.ts +8 -1
- package/util/hatchet-promise/hatchet-promise.js +3 -2
- package/util/logger/index.d.ts +1 -0
- package/util/logger/index.js +1 -0
- package/util/logger/task-run-log.d.ts +3 -0
- package/util/logger/task-run-log.js +20 -0
- package/util/sleep.d.ts +5 -2
- package/util/sleep.js +27 -4
- package/util/workflow-run-ref.d.ts +7 -1
- package/util/workflow-run-ref.js +5 -3
- package/v1/client/admin.d.ts +8 -1
- package/v1/client/admin.js +22 -6
- package/v1/client/client.d.ts +36 -18
- package/v1/client/client.interface.d.ts +9 -2
- package/v1/client/client.js +47 -27
- package/v1/client/features/crons.d.ts +3 -3
- package/v1/client/features/crons.js +2 -2
- package/v1/client/features/schedules.js +2 -2
- package/v1/client/features/workflows.d.ts +5 -5
- package/v1/client/features/workflows.js +7 -8
- package/v1/client/worker/context.d.ts +49 -10
- package/v1/client/worker/context.js +92 -20
- package/v1/client/worker/deprecated/legacy-v1-worker.d.ts +3 -3
- package/v1/client/worker/deprecated/legacy-v1-worker.js +2 -2
- package/v1/client/worker/deprecated/legacy-worker.js +9 -7
- package/v1/client/worker/slot-utils.d.ts +3 -3
- package/v1/client/worker/worker-internal.d.ts +7 -16
- package/v1/client/worker/worker-internal.js +225 -209
- package/v1/client/worker/worker.d.ts +18 -18
- package/v1/client/worker/worker.js +45 -30
- package/v1/declaration.d.ts +28 -7
- package/v1/declaration.js +56 -6
- package/v1/examples/__e2e__/harness.d.ts +19 -0
- package/v1/examples/__e2e__/harness.js +70 -0
- package/v1/examples/affinity/affinity-workers.js +4 -4
- package/v1/examples/bulk_fanout/workflow.d.ts +9 -0
- package/v1/examples/bulk_fanout/workflow.js +34 -0
- package/v1/examples/bulk_operations/workflow.d.ts +3 -0
- package/v1/examples/bulk_operations/workflow.js +44 -0
- package/v1/examples/cancellation/cancellation-workflow.d.ts +2 -0
- package/v1/examples/cancellation/cancellation-workflow.js +69 -0
- package/v1/examples/cancellation/run.js +53 -0
- package/v1/examples/cancellation/worker.d.ts +1 -0
- package/v1/examples/cancellation/worker.js +29 -0
- package/v1/examples/concurrency-types.d.ts +5 -0
- package/v1/examples/concurrency-types.js +2 -0
- package/v1/examples/concurrency_cancel_in_progress/workflow.d.ts +9 -0
- package/v1/examples/concurrency_cancel_in_progress/workflow.js +45 -0
- package/v1/examples/concurrency_cancel_newest/workflow.d.ts +9 -0
- package/v1/examples/concurrency_cancel_newest/workflow.js +45 -0
- package/v1/examples/concurrency_limit_rr/load.d.ts +1 -0
- package/v1/examples/concurrency_limit_rr/load.js +54 -0
- package/v1/examples/concurrency_limit_rr/run.d.ts +1 -0
- package/v1/examples/concurrency_limit_rr/run.js +39 -0
- package/v1/examples/concurrency_limit_rr/worker.d.ts +1 -0
- package/v1/examples/concurrency_limit_rr/worker.js +24 -0
- package/v1/examples/concurrency_limit_rr/workflow.d.ts +12 -0
- package/v1/examples/concurrency_limit_rr/workflow.js +62 -0
- package/v1/examples/concurrency_multiple_keys/workflow.d.ts +12 -0
- package/v1/examples/concurrency_multiple_keys/workflow.js +42 -0
- package/v1/examples/concurrency_workflow_level/workflow.d.ts +13 -0
- package/v1/examples/concurrency_workflow_level/workflow.js +49 -0
- package/v1/examples/conditions/complex-workflow.d.ts +1 -0
- package/v1/examples/conditions/complex-workflow.js +107 -0
- package/v1/examples/conditions/event.d.ts +1 -0
- package/v1/examples/conditions/event.js +28 -0
- package/v1/examples/conditions/run.d.ts +1 -0
- package/v1/examples/conditions/run.js +25 -0
- package/v1/examples/conditions/worker.d.ts +1 -0
- package/v1/examples/conditions/worker.js +24 -0
- package/v1/examples/conditions/workflow.d.ts +11 -0
- package/v1/examples/conditions/workflow.js +41 -0
- package/v1/examples/durable/workflow.d.ts +7 -0
- package/v1/examples/durable/workflow.js +116 -0
- package/v1/examples/durable_event/event.d.ts +1 -0
- package/v1/examples/durable_event/event.js +28 -0
- package/v1/examples/durable_event/run.d.ts +1 -0
- package/v1/examples/durable_event/run.js +30 -0
- package/v1/examples/durable_event/worker.d.ts +1 -0
- package/v1/examples/durable_event/worker.js +24 -0
- package/v1/examples/durable_event/workflow.d.ts +6 -0
- package/v1/examples/durable_event/workflow.js +46 -0
- 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 +31 -0
- package/v1/examples/e2e-worker.d.ts +1 -0
- package/v1/examples/e2e-worker.js +82 -0
- package/v1/examples/events/event.d.ts +1 -0
- package/v1/examples/events/event.js +53 -0
- package/v1/examples/events/filter.d.ts +1 -0
- package/v1/examples/events/filter.js +32 -0
- package/v1/examples/events/worker.d.ts +1 -0
- package/v1/examples/events/worker.js +24 -0
- package/v1/examples/events/workflow.d.ts +19 -0
- package/v1/examples/events/workflow.js +60 -0
- package/v1/examples/high-memory/workflow-with-child.js +1 -1
- package/v1/examples/logger/byo-logger.d.ts +1 -0
- package/v1/examples/logger/byo-logger.js +73 -0
- package/v1/examples/logger/logger.d.ts +1 -0
- package/v1/examples/logger/logger.js +46 -0
- package/v1/examples/logger/workflow.d.ts +2 -0
- package/v1/examples/logger/workflow.js +38 -0
- package/v1/examples/multiple_wf_concurrency/workflow.js +3 -3
- package/v1/examples/on_failure/workflow.d.ts +1 -0
- package/v1/examples/on_failure/workflow.js +12 -7
- package/v1/examples/priority/workflow.js +1 -1
- package/v1/examples/retries/workflow.js +2 -2
- package/v1/examples/return_exceptions/workflow.d.ts +6 -0
- package/v1/examples/return_exceptions/workflow.js +22 -0
- package/v1/examples/run_details/workflow.d.ts +4 -0
- package/v1/examples/run_details/workflow.js +65 -0
- package/v1/examples/simple/e2e-workflows.d.ts +14 -0
- package/v1/examples/simple/e2e-workflows.js +27 -0
- package/v1/examples/simple/enqueue.js +2 -2
- package/v1/examples/sticky/workflow.js +2 -2
- package/v1/examples/timeout/run.d.ts +1 -0
- package/v1/examples/timeout/run.js +30 -0
- package/v1/examples/timeout/worker.d.ts +1 -0
- package/v1/examples/timeout/worker.js +25 -0
- package/v1/examples/timeout/workflow.d.ts +10 -0
- package/v1/examples/timeout/workflow.js +56 -0
- package/v1/examples/webhooks/workflow.d.ts +5 -0
- package/v1/examples/webhooks/workflow.js +23 -0
- package/v1/index.d.ts +1 -0
- package/v1/index.js +1 -0
- package/v1/parent-run-context-vars.d.ts +6 -0
- package/v1/parent-run-context-vars.js +3 -0
- package/v1/task.d.ts +22 -7
- package/v1/task.js +4 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/workflow.d.ts +3 -491
- package/workflow.js +12 -62
- package/clients/hatchet-client/hatchet-client.d.ts +0 -35
- package/clients/hatchet-client/hatchet-client.js +0 -108
- package/clients/worker/handler.d.ts +0 -50
- package/clients/worker/handler.js +0 -214
- package/clients/worker/index.d.ts +0 -1
- package/clients/worker/index.js +0 -17
- package/clients/worker/worker.d.ts +0 -59
- package/clients/worker/worker.js +0 -568
- package/examples/webhooks.js +0 -45
- /package/{examples → legacy/examples}/affinity-workers.d.ts +0 -0
- /package/{examples → legacy/examples}/bulk-fanout-trigger.d.ts +0 -0
- /package/{examples → legacy/examples}/bulk-fanout-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/bulk-trigger.d.ts +0 -0
- /package/{examples → legacy/examples}/byo-logger.d.ts +0 -0
- /package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-event.d.ts +0 -0
- /package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-event.d.ts +0 -0
- /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.d.ts +0 -0
- /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.d.ts +0 -0
- /package/{examples → legacy/examples}/crons/programatic-crons.d.ts +0 -0
- /package/{examples → legacy/examples}/dag-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/example-event-with-results.d.ts +0 -0
- /package/{examples → legacy/examples}/example-event.d.ts +0 -0
- /package/{examples → legacy/examples}/fanout-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/logger.d.ts +0 -0
- /package/{examples → legacy/examples}/manual-trigger.d.ts +0 -0
- /package/{examples → legacy/examples}/multi-workflow.d.ts +0 -0
- /package/{examples → legacy/examples}/namespaced-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/on-failure.d.ts +0 -0
- /package/{examples → legacy/examples}/rate-limit/events.d.ts +0 -0
- /package/{examples → legacy/examples}/rate-limit/worker.d.ts +0 -0
- /package/{examples → legacy/examples}/retries-with-backoff.d.ts +0 -0
- /package/{examples → legacy/examples}/retries-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/scheduled-runs/programatic-schedules.d.ts +0 -0
- /package/{examples → legacy/examples}/sticky-trigger.d.ts +0 -0
- /package/{examples → legacy/examples}/sticky-worker-with-check.d.ts +0 -0
- /package/{examples → legacy/examples}/sticky-worker.d.ts +0 -0
- /package/{examples → legacy/examples}/stream-by-additional-meta.d.ts +0 -0
- /package/{examples/webhooks.d.ts → v1/examples/cancellation/run.d.ts} +0 -0
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const sdk_1 = __importDefault(require("
|
|
22
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
23
23
|
const hatchet = sdk_1.default.init();
|
|
24
24
|
function main() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16
16
|
const pino_1 = __importDefault(require("pino"));
|
|
17
|
-
const sdk_1 = __importDefault(require("
|
|
17
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
18
18
|
// > Create Pino logger
|
|
19
19
|
const logger = (0, pino_1.default)();
|
|
20
20
|
class PinoLogger {
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
const sleep = (ms) => new Promise((resolve) => {
|
|
18
18
|
setTimeout(resolve, ms);
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
const sleep = (ms) => new Promise((resolve) => {
|
|
18
18
|
setTimeout(resolve, ms);
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
const sleep = (ms) => new Promise((resolve) => {
|
|
18
18
|
setTimeout(resolve, ms);
|
package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.js
RENAMED
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
-
const workflow_1 = require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../../sdk"));
|
|
16
|
+
const workflow_1 = require("../../../../workflow");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
const sleep = (ms) => new Promise((resolve) => {
|
|
19
19
|
setTimeout(resolve, ms);
|
package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.js
RENAMED
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
-
const workflow_1 = require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../../sdk"));
|
|
16
|
+
const workflow_1 = require("../../../../workflow");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
const sleep = (ms) => new Promise((resolve) => {
|
|
19
19
|
setTimeout(resolve, ms);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Workflow } from '
|
|
1
|
+
import { Workflow } from '../../../workflow';
|
|
2
2
|
export declare const simpleCronWorkflow: Workflow;
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.simpleCronWorkflow = void 0;
|
|
16
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
// > Workflow Definition Cron Trigger
|
|
19
19
|
// Adding a cron trigger to a workflow is as simple as adding a `cron expression` to the `on` prop of the workflow definition
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
16
16
|
const cron_worker_1 = require("./cron-worker");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
// This example assumes you have a worker already running
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init({
|
|
17
17
|
log_level: 'OFF',
|
|
18
18
|
});
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const sdk_1 = __importDefault(require("
|
|
22
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
23
23
|
function main() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
var _a, e_1, _b, _c;
|
|
@@ -27,7 +27,7 @@ function main() {
|
|
|
27
27
|
const ref = yield hatchet.admin.runWorkflow('simple-workflow', {
|
|
28
28
|
test: 'test',
|
|
29
29
|
});
|
|
30
|
-
const listener = yield hatchet.
|
|
30
|
+
const listener = yield hatchet.listener.stream(yield ref.getWorkflowRunId());
|
|
31
31
|
console.log('listening for events');
|
|
32
32
|
try {
|
|
33
33
|
for (var _d = true, listener_1 = __asyncValues(listener), listener_1_1; listener_1_1 = yield listener_1.next(), _a = listener_1_1.done, !_a; _d = true) {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const sdk_1 = __importDefault(require("
|
|
6
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
7
7
|
const hatchet = sdk_1.default.init();
|
|
8
8
|
// Push a single event (example)
|
|
9
9
|
hatchet.events.push('user:create', {
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
const parentWorkflow = {
|
|
18
18
|
id: 'parent-workflow',
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init({
|
|
17
17
|
log_level: 'OFF',
|
|
18
18
|
});
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const sdk_1 = __importDefault(require("
|
|
22
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
23
23
|
const hatchet = sdk_1.default.init();
|
|
24
24
|
function main() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
function main() {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init({
|
|
17
17
|
namespace: 'example-namespace',
|
|
18
18
|
});
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
// > OnFailure Step
|
|
18
18
|
// This workflow will fail because the step will throw an error
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const sdk_1 = __importDefault(require("
|
|
6
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
7
7
|
const hatchet = sdk_1.default.init();
|
|
8
8
|
hatchet.events.push('rate-limit:create', {
|
|
9
9
|
test: '1',
|
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const workflows_1 = require("
|
|
16
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const workflows_1 = require("../../../protoc/workflows");
|
|
16
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
const workflow = {
|
|
19
19
|
id: 'rate-limit-workflow',
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
let numRetries = 0;
|
|
18
18
|
// > Backoff
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
16
|
const hatchet = sdk_1.default.init();
|
|
17
17
|
const sleep = (ms) => new Promise((resolve) => {
|
|
18
18
|
setTimeout(resolve, ms);
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
16
16
|
const simple_worker_1 = require("../simple-worker");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
// This example assumes you have a worker already running
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Workflow } from '
|
|
1
|
+
import { Workflow } from '../../workflow';
|
|
2
2
|
export declare const simpleWorkflow: Workflow;
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.simpleWorkflow = void 0;
|
|
16
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
const sleep = (ms) => new Promise((resolve) => {
|
|
19
19
|
setTimeout(resolve, ms);
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const sdk_1 = __importDefault(require("
|
|
22
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
23
23
|
const hatchet = sdk_1.default.init();
|
|
24
24
|
function main() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
-
const workflow_1 = require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
|
+
const workflow_1 = require("../../workflow");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
const workflow = {
|
|
19
19
|
id: 'sticky-workflow',
|
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const sdk_1 = __importDefault(require("
|
|
16
|
-
const workflow_1 = require("
|
|
15
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
16
|
+
const workflow_1 = require("../../workflow");
|
|
17
17
|
const hatchet = sdk_1.default.init();
|
|
18
18
|
// > StickyWorker
|
|
19
19
|
const workflow = {
|
|
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const sdk_1 = __importDefault(require("
|
|
22
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
23
23
|
const hatchet = sdk_1.default.init();
|
|
24
24
|
function main() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,7 +34,7 @@ function main() {
|
|
|
34
34
|
// and can have an arbitrary property name.
|
|
35
35
|
yield hatchet.admin.runWorkflow('parent-workflow', {}, { additionalMetadata: { [streamKey]: streamVal } });
|
|
36
36
|
// Stream all events for the additional meta key value
|
|
37
|
-
const stream = yield hatchet.
|
|
37
|
+
const stream = yield hatchet.listener.streamByAdditionalMeta(streamKey, streamVal);
|
|
38
38
|
try {
|
|
39
39
|
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _a = stream_1_1.done, !_a; _d = true) {
|
|
40
40
|
_c = stream_1_1.value;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EventClient } from '../clients/event/event-client';
|
|
2
|
+
import { DispatcherClient } from '../clients/dispatcher/dispatcher-client';
|
|
3
|
+
import { AdminClient } from '../clients/admin/admin-client';
|
|
4
|
+
import { ChannelCredentials } from 'nice-grpc';
|
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
|
6
|
+
import { Logger } from '../util/logger';
|
|
7
|
+
import { RunsClient } from '../v1';
|
|
8
|
+
import { ClientConfig } from '../clients/hatchet-client/client-config';
|
|
9
|
+
import { RunListenerClient } from '../clients/listeners/run-listener/child-listener-client';
|
|
10
|
+
import { Api } from '../clients/rest/generated/Api';
|
|
11
|
+
import { DurableListenerClient } from '../clients/listeners/durable-listener/durable-listener-client';
|
|
12
|
+
export interface HatchetClientOptions {
|
|
13
|
+
config_path?: string;
|
|
14
|
+
credentials?: ChannelCredentials;
|
|
15
|
+
}
|
|
16
|
+
export declare class LegacyHatchetClient {
|
|
17
|
+
config: ClientConfig;
|
|
18
|
+
credentials: ChannelCredentials;
|
|
19
|
+
event: EventClient;
|
|
20
|
+
dispatcher: DispatcherClient;
|
|
21
|
+
admin: AdminClient;
|
|
22
|
+
api: Api;
|
|
23
|
+
runs: RunsClient | undefined;
|
|
24
|
+
listener: RunListenerClient;
|
|
25
|
+
tenantId: string;
|
|
26
|
+
durableListener: DurableListenerClient;
|
|
27
|
+
logger: Logger;
|
|
28
|
+
constructor(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosOpts?: AxiosRequestConfig, runs?: RunsClient, listener?: RunListenerClient, event?: EventClient, dispatcher?: DispatcherClient, logger?: Logger, durableListener?: DurableListenerClient);
|
|
29
|
+
static init(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosConfig?: AxiosRequestConfig): LegacyHatchetClient;
|
|
30
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LegacyHatchetClient = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const config_loader_1 = require("../util/config-loader");
|
|
9
|
+
const event_client_1 = require("../clients/event/event-client");
|
|
10
|
+
const dispatcher_client_1 = require("../clients/dispatcher/dispatcher-client");
|
|
11
|
+
const admin_client_1 = require("../clients/admin/admin-client");
|
|
12
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
13
|
+
const hatchet_logger_1 = require("../clients/hatchet-client/hatchet-logger");
|
|
14
|
+
const grpc_helpers_1 = require("../util/grpc-helpers");
|
|
15
|
+
const client_config_1 = require("../clients/hatchet-client/client-config");
|
|
16
|
+
const child_listener_client_1 = require("../clients/listeners/run-listener/child-listener-client");
|
|
17
|
+
const rest_1 = __importDefault(require("../clients/rest"));
|
|
18
|
+
const durable_listener_client_1 = require("../clients/listeners/durable-listener/durable-listener-client");
|
|
19
|
+
class LegacyHatchetClient {
|
|
20
|
+
constructor(config, options, axiosOpts, runs, listener, event, dispatcher, logger, durableListener) {
|
|
21
|
+
// Initializes a new Client instance.
|
|
22
|
+
// Loads config in the following order: config param > yaml file > env vars
|
|
23
|
+
var _a;
|
|
24
|
+
this.runs = runs;
|
|
25
|
+
const loaded = config_loader_1.ConfigLoader.loadClientConfig(config, {
|
|
26
|
+
path: options === null || options === void 0 ? void 0 : options.config_path,
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
const valid = client_config_1.ClientConfigSchema.parse(loaded);
|
|
30
|
+
let logConstructor = config === null || config === void 0 ? void 0 : config.logger;
|
|
31
|
+
if (logConstructor == null) {
|
|
32
|
+
logConstructor = hatchet_logger_1.DEFAULT_LOGGER;
|
|
33
|
+
}
|
|
34
|
+
this.config = Object.assign(Object.assign({}, valid), { logger: logConstructor });
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
if (e instanceof zod_1.z.ZodError) {
|
|
38
|
+
throw new Error(`Invalid client config: ${e.message}`);
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
this.credentials =
|
|
43
|
+
(_a = options === null || options === void 0 ? void 0 : options.credentials) !== null && _a !== void 0 ? _a : config_loader_1.ConfigLoader.createCredentials(this.config.tls_config);
|
|
44
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)().use((0, grpc_helpers_1.addTokenMiddleware)(this.config.token));
|
|
45
|
+
this.tenantId = this.config.tenant_id;
|
|
46
|
+
this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
|
|
47
|
+
this.event =
|
|
48
|
+
event ||
|
|
49
|
+
new event_client_1.EventClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
|
|
50
|
+
this.dispatcher =
|
|
51
|
+
dispatcher ||
|
|
52
|
+
new dispatcher_client_1.DispatcherClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory);
|
|
53
|
+
this.listener =
|
|
54
|
+
listener ||
|
|
55
|
+
new child_listener_client_1.RunListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
|
|
56
|
+
this.admin = new admin_client_1.AdminClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId, this.listener, this.runs);
|
|
57
|
+
this.durableListener =
|
|
58
|
+
durableListener ||
|
|
59
|
+
new durable_listener_client_1.DurableListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
|
|
60
|
+
this.logger = logger || this.config.logger('HatchetClient', this.config.log_level);
|
|
61
|
+
this.logger.debug(`Initialized HatchetClient`);
|
|
62
|
+
}
|
|
63
|
+
static init(config, options, axiosConfig) {
|
|
64
|
+
return new LegacyHatchetClient(config, options, axiosConfig);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.LegacyHatchetClient = LegacyHatchetClient;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Workflow } from './workflow';
|
|
2
|
+
import { BaseWorkflowDeclaration, WorkflowDeclaration } from '../v1/declaration';
|
|
3
|
+
export type { Workflow as LegacyWorkflow } from './workflow';
|
|
4
|
+
/**
|
|
5
|
+
* Type guard: returns true if the workflow is a legacy v0 Workflow (not a BaseWorkflowDeclaration).
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLegacyWorkflow(workflow: unknown): workflow is Workflow;
|
|
8
|
+
/**
|
|
9
|
+
* Emits a deprecation warning for legacy workflow usage.
|
|
10
|
+
*/
|
|
11
|
+
export declare function warnLegacyWorkflow(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Transforms a legacy v0 Workflow into a v1 WorkflowDeclaration.
|
|
14
|
+
*
|
|
15
|
+
* The transformed declaration can be registered with a worker and executed
|
|
16
|
+
* by the v1 runtime. Legacy step `run` functions are wrapped to receive
|
|
17
|
+
* a V0Context for backwards compatibility.
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformLegacyWorkflow(workflow: Workflow): WorkflowDeclaration<any, any>;
|
|
20
|
+
/**
|
|
21
|
+
* Normalizes a workflow: if it is a legacy Workflow, emits a deprecation warning
|
|
22
|
+
* and transforms it into a BaseWorkflowDeclaration. If already a v1 declaration,
|
|
23
|
+
* returns it as-is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeWorkflow(workflow: BaseWorkflowDeclaration<any, any> | Workflow): BaseWorkflowDeclaration<any, any>;
|
|
26
|
+
/**
|
|
27
|
+
* Normalizes an array of workflows, transforming any legacy workflows and
|
|
28
|
+
* emitting deprecation warnings.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeWorkflows(workflows: Array<BaseWorkflowDeclaration<any, any> | Workflow>): Array<BaseWorkflowDeclaration<any, any>>;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts the workflow name from a workflow-like value.
|
|
33
|
+
* Works for strings, BaseWorkflowDeclaration, WorkflowDefinition, and legacy Workflow.
|
|
34
|
+
* Emits a deprecation warning if a legacy workflow is detected.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getWorkflowName(workflow: string | BaseWorkflowDeclaration<any, any> | Workflow | {
|
|
37
|
+
name: string;
|
|
38
|
+
}): string;
|