@hatchet-dev/typescript-sdk 1.13.1 → 1.15.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/docs/doc_types.d.ts +12 -0
- package/docs/doc_types.js +62 -0
- package/docs/generate.js +87 -0
- package/docs/paths.d.ts +2 -0
- package/docs/paths.js +16 -0
- package/docs/shared.d.ts +3 -0
- package/docs/shared.js +6 -0
- package/package.json +5 -4
- package/{clients → src/clients}/admin/admin-client.d.ts +17 -9
- package/{clients → src/clients}/admin/admin-client.js +26 -10
- package/{clients → src/clients}/dispatcher/action-listener.d.ts +4 -4
- package/{clients → src/clients}/dispatcher/action-listener.js +3 -3
- package/{clients → src/clients}/dispatcher/dispatcher-client.d.ts +10 -10
- package/{clients → src/clients}/dispatcher/dispatcher-client.js +5 -5
- package/{clients → src/clients}/dispatcher/heartbeat/heartbeat-controller.d.ts +2 -2
- package/{clients → src/clients}/dispatcher/heartbeat/heartbeat-controller.js +14 -2
- package/{clients → src/clients}/dispatcher/heartbeat/heartbeat-worker.js +7 -6
- package/{clients → src/clients}/event/event-client.d.ts +8 -9
- package/{clients → src/clients}/event/event-client.js +6 -6
- package/{clients → src/clients}/hatchet-client/client-config.d.ts +17 -7
- package/{clients → src/clients}/hatchet-client/client-config.js +3 -0
- package/{clients → src/clients}/hatchet-client/hatchet-logger.d.ts +1 -1
- package/{clients → src/clients}/hatchet-client/hatchet-logger.js +2 -1
- package/src/clients/hatchet-client/index.d.ts +3 -0
- package/{clients → src/clients}/hatchet-client/index.js +2 -2
- package/{clients → src/clients}/listeners/durable-listener/durable-listener-client.d.ts +11 -5
- package/{clients → src/clients}/listeners/durable-listener/durable-listener-client.js +9 -1
- package/{clients → src/clients}/listeners/durable-listener/pooled-durable-listener-client.d.ts +11 -4
- package/{clients → src/clients}/listeners/durable-listener/pooled-durable-listener-client.js +68 -16
- package/{clients → src/clients}/listeners/run-listener/child-listener-client.d.ts +3 -3
- package/{clients → src/clients}/listeners/run-listener/child-listener-client.js +4 -3
- package/{clients → src/clients}/listeners/run-listener/pooled-child-listener-client.d.ts +11 -3
- package/{clients → src/clients}/listeners/run-listener/pooled-child-listener-client.js +65 -9
- package/src/clients/rest/api.js +21 -0
- package/{clients → src/clients}/rest/generated/Api.d.ts +2 -2
- package/{clients → src/clients}/rest/generated/data-contracts.d.ts +6 -0
- package/{index.d.ts → src/index.d.ts} +3 -4
- package/{index.js → src/index.js} +3 -4
- package/{examples → src/legacy/examples}/affinity-workers.js +2 -2
- package/{examples → src/legacy/examples}/bulk-fanout-trigger.js +1 -1
- package/{examples → src/legacy/examples}/bulk-fanout-worker.js +1 -1
- package/{examples → src/legacy/examples}/bulk-trigger.js +1 -1
- package/{examples → src/legacy/examples}/concurrency/cancel-in-progress/concurrency-event.js +1 -1
- package/{examples → src/legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.js +1 -1
- package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-event.js +1 -1
- package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.js +2 -2
- package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.js +2 -2
- package/{examples → src/legacy/examples}/crons/cron-worker.d.ts +1 -1
- package/{examples → src/legacy/examples}/crons/cron-worker.js +1 -1
- package/{examples → src/legacy/examples}/crons/programatic-crons.js +1 -1
- package/{examples → src/legacy/examples}/dag-worker.js +1 -1
- package/{examples → src/legacy/examples}/example-event-with-results.js +2 -2
- package/{examples → src/legacy/examples}/example-event.js +1 -1
- package/{examples → src/legacy/examples}/fanout-worker.js +1 -1
- package/{examples → src/legacy/examples}/logger.js +1 -1
- package/{examples → src/legacy/examples}/manual-trigger.js +1 -1
- package/{examples → src/legacy/examples}/multi-workflow.js +1 -1
- package/{examples → src/legacy/examples}/namespaced-worker.js +1 -1
- package/{examples → src/legacy/examples}/on-failure.js +1 -1
- package/{examples → src/legacy/examples}/rate-limit/events.js +1 -1
- package/{examples → src/legacy/examples}/rate-limit/worker.js +2 -2
- package/{examples → src/legacy/examples}/retries-with-backoff.js +1 -1
- package/{examples → src/legacy/examples}/retries-worker.js +1 -1
- package/{examples → src/legacy/examples}/scheduled-runs/programatic-schedules.js +1 -1
- package/{examples → src/legacy/examples}/simple-worker.d.ts +1 -1
- package/{examples → src/legacy/examples}/simple-worker.js +1 -1
- package/{examples → src/legacy/examples}/sticky-trigger.js +1 -1
- package/{examples → src/legacy/examples}/sticky-worker-with-check.js +2 -2
- package/{examples → src/legacy/examples}/sticky-worker.js +2 -2
- package/{examples → src/legacy/examples}/stream-by-additional-meta.js +2 -2
- package/{clients/hatchet-client/hatchet-client.d.ts → src/legacy/legacy-client.d.ts} +8 -13
- package/src/legacy/legacy-client.js +67 -0
- package/src/legacy/legacy-transformer.d.ts +38 -0
- package/src/legacy/legacy-transformer.js +181 -0
- package/{step.d.ts → src/legacy/step.d.ts} +30 -31
- package/{step.js → src/legacy/step.js} +17 -16
- package/{workflow.d.ts → src/legacy/workflow.d.ts} +47 -50
- package/{workflow.js → src/legacy/workflow.js} +3 -6
- package/{protoc → src/protoc}/v1/workflows.d.ts +8 -0
- package/{protoc → src/protoc}/v1/workflows.js +109 -2
- package/{protoc → src/protoc}/workflows/workflows.d.ts +9 -0
- package/{protoc → src/protoc}/workflows/workflows.js +109 -2
- package/src/sdk.d.ts +2 -0
- package/{sdk.js → src/sdk.js} +1 -1
- package/src/step.d.ts +1 -0
- package/{clients/worker/index.js → src/step.js} +4 -1
- package/src/util/abort-error.d.ts +38 -0
- package/src/util/abort-error.js +58 -0
- package/{util → src/util}/config-loader/config-loader.d.ts +1 -1
- package/{util → src/util}/config-loader/config-loader.js +1 -1
- package/{util → src/util}/grpc-helpers.d.ts +1 -1
- package/src/util/hatchet-promise/hatchet-promise.d.ts +13 -0
- package/{util → src/util}/hatchet-promise/hatchet-promise.js +3 -2
- package/src/util/logger/index.d.ts +2 -0
- package/{util → src/util}/logger/index.js +1 -0
- package/{util → src/util}/logger/logger.d.ts +1 -1
- package/src/util/logger/task-run-log.d.ts +3 -0
- package/src/util/logger/task-run-log.js +20 -0
- package/{util → src/util}/sleep.d.ts +5 -2
- package/src/util/sleep.js +37 -0
- package/{util → src/util}/workflow-run-ref.d.ts +9 -3
- package/{util → src/util}/workflow-run-ref.js +5 -3
- package/{v1 → src/v1}/client/admin.d.ts +24 -8
- package/{v1 → src/v1}/client/admin.js +50 -18
- package/{v1 → src/v1}/client/client.d.ts +59 -23
- package/{v1 → src/v1}/client/client.interface.d.ts +9 -2
- package/{v1 → src/v1}/client/client.js +73 -35
- package/{v1 → src/v1}/client/features/cel.d.ts +1 -1
- package/{v1 → src/v1}/client/features/cel.js +1 -1
- package/{v1 → src/v1}/client/features/crons.d.ts +8 -6
- package/{v1 → src/v1}/client/features/crons.js +6 -5
- package/{v1 → src/v1}/client/features/filters.d.ts +30 -0
- package/{v1 → src/v1}/client/features/filters.js +30 -0
- package/{v1 → src/v1}/client/features/metrics.d.ts +10 -6
- package/{v1 → src/v1}/client/features/metrics.js +10 -6
- package/src/v1/client/features/ratelimits.d.ts +30 -0
- package/{v1 → src/v1}/client/features/ratelimits.js +13 -3
- package/{v1 → src/v1}/client/features/runs.d.ts +43 -8
- package/{v1 → src/v1}/client/features/runs.js +38 -3
- package/{v1 → src/v1}/client/features/schedules.d.ts +7 -4
- package/{v1 → src/v1}/client/features/schedules.js +7 -5
- package/{v1 → src/v1}/client/features/tenant.d.ts +4 -1
- package/src/v1/client/features/webhooks.d.ts +54 -0
- package/{v1 → src/v1}/client/features/webhooks.js +31 -5
- package/src/v1/client/features/workers.d.ts +38 -0
- package/{v1 → src/v1}/client/features/workers.js +25 -1
- package/src/v1/client/features/workflows.d.ts +42 -0
- package/{v1 → src/v1}/client/features/workflows.js +27 -10
- package/{v1 → src/v1}/client/worker/context.d.ts +78 -18
- package/{v1 → src/v1}/client/worker/context.js +120 -27
- package/{v1 → src/v1}/client/worker/deprecated/deprecation.d.ts +1 -1
- package/{v1 → src/v1}/client/worker/deprecated/legacy-registration.d.ts +2 -2
- package/{v1 → src/v1}/client/worker/deprecated/legacy-registration.js +2 -2
- package/{v1 → src/v1}/client/worker/deprecated/legacy-v1-worker.d.ts +5 -5
- package/{v1 → src/v1}/client/worker/deprecated/legacy-v1-worker.js +2 -2
- package/{v1 → src/v1}/client/worker/deprecated/legacy-worker.js +9 -7
- package/{v1 → src/v1}/client/worker/health-server.d.ts +1 -1
- package/{v1 → src/v1}/client/worker/slot-utils.d.ts +3 -3
- package/{v1 → src/v1}/client/worker/worker-internal.d.ts +13 -22
- package/{v1 → src/v1}/client/worker/worker-internal.js +232 -216
- package/{v1 → src/v1}/client/worker/worker.d.ts +19 -19
- package/{v1 → src/v1}/client/worker/worker.js +45 -30
- package/{v1 → src/v1}/conditions/transformer.d.ts +1 -1
- package/{v1 → src/v1}/declaration.d.ts +120 -15
- package/{v1 → src/v1}/declaration.js +118 -10
- package/src/v1/examples/__e2e__/harness.d.ts +19 -0
- package/src/v1/examples/__e2e__/harness.js +70 -0
- package/{v1 → src/v1}/examples/affinity/affinity-workers.js +4 -4
- package/src/v1/examples/bulk_fanout/workflow.d.ts +9 -0
- package/src/v1/examples/bulk_fanout/workflow.js +34 -0
- package/src/v1/examples/bulk_operations/workflow.d.ts +3 -0
- package/src/v1/examples/bulk_operations/workflow.js +44 -0
- package/src/v1/examples/cancellation/cancellation-workflow.d.ts +2 -0
- package/src/v1/examples/cancellation/cancellation-workflow.js +69 -0
- package/src/v1/examples/cancellation/run.js +53 -0
- package/src/v1/examples/cancellation/worker.js +29 -0
- package/{v1 → src/v1}/examples/cancellations/run.js +1 -1
- package/{v1 → src/v1}/examples/cancellations/workflow.js +1 -1
- package/{v1 → src/v1}/examples/concurrency-rr/workflow.js +1 -1
- package/src/v1/examples/concurrency-types.d.ts +5 -0
- package/src/v1/examples/concurrency_cancel_in_progress/workflow.d.ts +9 -0
- package/src/v1/examples/concurrency_cancel_in_progress/workflow.js +45 -0
- package/src/v1/examples/concurrency_cancel_newest/workflow.d.ts +9 -0
- package/src/v1/examples/concurrency_cancel_newest/workflow.js +45 -0
- package/src/v1/examples/concurrency_limit_rr/load.js +54 -0
- package/src/v1/examples/concurrency_limit_rr/run.js +39 -0
- package/src/v1/examples/concurrency_limit_rr/worker.js +24 -0
- package/src/v1/examples/concurrency_limit_rr/workflow.d.ts +12 -0
- package/src/v1/examples/concurrency_limit_rr/workflow.js +62 -0
- package/src/v1/examples/concurrency_multiple_keys/workflow.d.ts +12 -0
- package/src/v1/examples/concurrency_multiple_keys/workflow.js +42 -0
- package/src/v1/examples/concurrency_workflow_level/workflow.d.ts +13 -0
- package/src/v1/examples/concurrency_workflow_level/workflow.js +49 -0
- package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/complex-workflow.js +2 -2
- package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/workflow.js +2 -2
- package/{v1 → src/v1}/examples/dag/interface-workflow.d.ts +2 -2
- package/src/v1/examples/dag_match_condition/complex-workflow.d.ts +1 -0
- package/src/v1/examples/dag_match_condition/complex-workflow.js +107 -0
- package/src/v1/examples/dag_match_condition/run.js +25 -0
- package/src/v1/examples/dag_match_condition/worker.js +24 -0
- package/src/v1/examples/dag_match_condition/workflow.d.ts +11 -0
- package/src/v1/examples/dag_match_condition/workflow.js +41 -0
- package/{v1 → src/v1}/examples/deep/workflow.js +1 -1
- package/src/v1/examples/durable/workflow.d.ts +7 -0
- package/src/v1/examples/durable/workflow.js +116 -0
- package/{v1 → src/v1}/examples/durable-event/workflow.js +1 -1
- package/src/v1/examples/durable-sleep/event.js +28 -0
- package/{v1 → src/v1}/examples/durable-sleep/workflow.js +1 -1
- package/src/v1/examples/durable_event/event.js +28 -0
- package/src/v1/examples/durable_event/run.js +30 -0
- package/src/v1/examples/durable_event/worker.js +24 -0
- package/src/v1/examples/durable_event/workflow.d.ts +6 -0
- package/src/v1/examples/durable_event/workflow.js +46 -0
- package/src/v1/examples/durable_sleep/event.js +28 -0
- package/src/v1/examples/durable_sleep/run.js +30 -0
- package/src/v1/examples/durable_sleep/worker.js +24 -0
- package/src/v1/examples/durable_sleep/workflow.d.ts +1 -0
- package/src/v1/examples/durable_sleep/workflow.js +31 -0
- package/src/v1/examples/e2e-worker.js +82 -0
- package/src/v1/examples/events/filter.js +32 -0
- package/{v1 → src/v1}/examples/hatchet-client.d.ts +1 -1
- package/{v1 → src/v1}/examples/hatchet-client.js +1 -1
- package/{v1 → src/v1}/examples/high-memory/workflow-with-child.js +1 -1
- package/{v1 → src/v1}/examples/landing_page/durable-excution.js +1 -1
- package/{v1 → src/v1}/examples/landing_page/flow-control.js +1 -1
- package/src/v1/examples/legacy/workflow.d.ts +2 -0
- package/{examples → src/v1/examples/logger}/byo-logger.js +1 -1
- package/src/v1/examples/logger/workflow.d.ts +2 -0
- package/src/v1/examples/logger/workflow.js +38 -0
- package/src/v1/examples/logging/byo-logger.js +73 -0
- package/src/v1/examples/logging/logger.js +46 -0
- package/{v1 → src/v1}/examples/middleware/client.d.ts +1 -1
- package/{v1 → src/v1}/examples/middleware/client.js +1 -1
- package/{v1 → src/v1}/examples/middleware/recipes.js +1 -1
- package/{v1 → src/v1}/examples/migration-guides/hatchet-client.d.ts +1 -1
- package/{v1 → src/v1}/examples/migration-guides/hatchet-client.js +1 -1
- package/{v1 → src/v1}/examples/multiple_wf_concurrency/workflow.d.ts +1 -1
- package/{v1 → src/v1}/examples/multiple_wf_concurrency/workflow.js +3 -3
- package/{v1 → src/v1}/examples/non_retryable/workflow.js +1 -1
- package/src/v1/examples/on_event/event.js +53 -0
- package/src/v1/examples/on_event/worker.js +24 -0
- package/src/v1/examples/on_event/workflow.d.ts +19 -0
- package/src/v1/examples/on_event/workflow.js +60 -0
- package/{v1 → src/v1}/examples/on_failure/workflow.d.ts +1 -0
- package/{v1 → src/v1}/examples/on_failure/workflow.js +12 -7
- package/{v1 → src/v1}/examples/priority/run.js +1 -1
- package/src/v1/examples/priority/workflow.d.ts +8 -0
- package/{v1 → src/v1}/examples/priority/workflow.js +2 -2
- package/{v1 → src/v1}/examples/quickstart/hatchet-client.d.ts +1 -1
- package/{v1 → src/v1}/examples/quickstart/hatchet-client.js +1 -1
- package/src/v1/examples/quickstart/run.d.ts +1 -0
- package/src/v1/examples/quickstart/worker.d.ts +1 -0
- package/src/v1/examples/rate_limit/workflow.d.ts +1 -0
- package/{v1 → src/v1}/examples/rate_limit/workflow.js +1 -1
- package/src/v1/examples/retries/run.d.ts +1 -0
- package/src/v1/examples/retries/worker.d.ts +1 -0
- package/{v1 → src/v1}/examples/retries/workflow.js +2 -2
- package/src/v1/examples/return_exceptions/workflow.d.ts +6 -0
- package/src/v1/examples/return_exceptions/workflow.js +22 -0
- package/src/v1/examples/run_details/workflow.d.ts +4 -0
- package/src/v1/examples/run_details/workflow.js +65 -0
- package/src/v1/examples/runtime_affinity/workflow.d.ts +3 -0
- package/src/v1/examples/runtime_affinity/workflow.js +19 -0
- package/src/v1/examples/simple/bulk.d.ts +1 -0
- package/src/v1/examples/simple/client-run.d.ts +1 -0
- package/src/v1/examples/simple/cron.d.ts +1 -0
- package/src/v1/examples/simple/delay.d.ts +1 -0
- package/src/v1/examples/simple/e2e-workflows.d.ts +14 -0
- package/src/v1/examples/simple/e2e-workflows.js +27 -0
- package/src/v1/examples/simple/enqueue.d.ts +1 -0
- package/{v1 → src/v1}/examples/simple/enqueue.js +2 -2
- package/src/v1/examples/simple/replay-cancel.d.ts +1 -0
- package/{v1 → src/v1}/examples/simple/replay-cancel.js +1 -1
- package/src/v1/examples/simple/schedule.d.ts +1 -0
- package/src/v1/examples/simple/typed-run-methods.d.ts +1 -0
- package/src/v1/examples/simple/worker.d.ts +1 -0
- package/src/v1/examples/sticky/run.d.ts +1 -0
- package/src/v1/examples/sticky/worker.d.ts +1 -0
- package/src/v1/examples/sticky/workflow.d.ts +5 -0
- package/{v1 → src/v1}/examples/sticky/workflow.js +2 -2
- package/src/v1/examples/streaming/run.d.ts +1 -0
- package/src/v1/examples/streaming/worker.d.ts +1 -0
- package/src/v1/examples/timeout/run.d.ts +1 -0
- package/src/v1/examples/timeout/run.js +30 -0
- package/src/v1/examples/timeout/worker.d.ts +1 -0
- package/src/v1/examples/timeout/worker.js +25 -0
- package/src/v1/examples/timeout/workflow.d.ts +10 -0
- package/src/v1/examples/timeout/workflow.js +56 -0
- package/src/v1/examples/timeouts/run.d.ts +1 -0
- package/src/v1/examples/timeouts/worker.d.ts +1 -0
- package/{v1 → src/v1}/examples/timeouts/workflow.js +1 -1
- package/src/v1/examples/webhooks/workflow.d.ts +5 -0
- package/src/v1/examples/webhooks/workflow.js +23 -0
- package/{v1 → src/v1}/examples/with_timeouts/workflow.js +1 -1
- package/{v1 → src/v1}/index.d.ts +1 -0
- package/{v1 → src/v1}/index.js +1 -0
- package/{v1 → src/v1}/parent-run-context-vars.d.ts +6 -0
- package/{v1 → src/v1}/parent-run-context-vars.js +3 -0
- package/{v1 → src/v1}/task.d.ts +22 -7
- package/src/v1/task.js +14 -0
- package/{v1 → src/v1}/types.d.ts +1 -1
- package/src/v1/types.js +2 -0
- package/src/version.d.ts +1 -0
- package/{version.js → src/version.js} +1 -1
- package/src/workflow.d.ts +3 -0
- package/src/workflow.js +25 -0
- package/clients/hatchet-client/hatchet-client.js +0 -108
- package/clients/hatchet-client/index.d.ts +0 -3
- package/clients/rest/api.js +0 -13
- 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/worker.d.ts +0 -59
- package/clients/worker/worker.js +0 -568
- package/examples/webhooks.js +0 -45
- package/sdk.d.ts +0 -2
- package/util/hatchet-promise/hatchet-promise.d.ts +0 -6
- package/util/logger/index.d.ts +0 -1
- package/util/sleep.js +0 -14
- package/v1/client/features/ratelimits.d.ts +0 -20
- package/v1/client/features/webhooks.d.ts +0 -28
- package/v1/client/features/workers.d.ts +0 -14
- package/v1/client/features/workflows.d.ts +0 -24
- package/v1/examples/legacy/workflow.d.ts +0 -2
- package/v1/examples/priority/workflow.d.ts +0 -8
- package/v1/examples/sticky/workflow.d.ts +0 -5
- package/v1/task.js +0 -11
- package/version.d.ts +0 -1
- /package/{clients/dispatcher/heartbeat/heartbeat-worker.d.ts → docs/generate.d.ts} +0 -0
- /package/{clients → src/clients}/admin/index.d.ts +0 -0
- /package/{clients → src/clients}/admin/index.js +0 -0
- /package/{examples/affinity-workers.d.ts → src/clients/dispatcher/heartbeat/heartbeat-worker.d.ts} +0 -0
- /package/{clients → src/clients}/rest/api.d.ts +0 -0
- /package/{clients → src/clients}/rest/generated/Api.js +0 -0
- /package/{clients → src/clients}/rest/generated/data-contracts.js +0 -0
- /package/{clients → src/clients}/rest/generated/http-client.d.ts +0 -0
- /package/{clients → src/clients}/rest/generated/http-client.js +0 -0
- /package/{clients → src/clients}/rest/index.d.ts +0 -0
- /package/{clients → src/clients}/rest/index.js +0 -0
- /package/{v1/examples/affinity → src/legacy/examples}/affinity-workers.d.ts +0 -0
- /package/{examples → src/legacy/examples}/bulk-fanout-trigger.d.ts +0 -0
- /package/{examples → src/legacy/examples}/bulk-fanout-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/bulk-trigger.d.ts +0 -0
- /package/{examples → src/legacy/examples}/byo-logger.d.ts +0 -0
- /package/{v1/examples/logging → src/legacy/examples}/byo-logger.js +0 -0
- /package/{examples → src/legacy/examples}/concurrency/cancel-in-progress/concurrency-event.d.ts +0 -0
- /package/{examples → src/legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-event.d.ts +0 -0
- /package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.d.ts +0 -0
- /package/{examples → src/legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.d.ts +0 -0
- /package/{examples → src/legacy/examples}/crons/programatic-crons.d.ts +0 -0
- /package/{examples → src/legacy/examples}/dag-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/example-event-with-results.d.ts +0 -0
- /package/{examples → src/legacy/examples}/example-event.d.ts +0 -0
- /package/{examples → src/legacy/examples}/fanout-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/logger.d.ts +0 -0
- /package/{examples → src/legacy/examples}/manual-trigger.d.ts +0 -0
- /package/{examples → src/legacy/examples}/multi-workflow.d.ts +0 -0
- /package/{examples → src/legacy/examples}/namespaced-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/on-failure.d.ts +0 -0
- /package/{examples → src/legacy/examples}/rate-limit/events.d.ts +0 -0
- /package/{examples → src/legacy/examples}/rate-limit/worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/retries-with-backoff.d.ts +0 -0
- /package/{examples → src/legacy/examples}/retries-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/scheduled-runs/programatic-schedules.d.ts +0 -0
- /package/{examples → src/legacy/examples}/sticky-trigger.d.ts +0 -0
- /package/{examples → src/legacy/examples}/sticky-worker-with-check.d.ts +0 -0
- /package/{examples → src/legacy/examples}/sticky-worker.d.ts +0 -0
- /package/{examples → src/legacy/examples}/stream-by-additional-meta.d.ts +0 -0
- /package/{protoc → src/protoc}/dispatcher/dispatcher.d.ts +0 -0
- /package/{protoc → src/protoc}/dispatcher/dispatcher.js +0 -0
- /package/{protoc → src/protoc}/dispatcher/index.d.ts +0 -0
- /package/{protoc → src/protoc}/dispatcher/index.js +0 -0
- /package/{protoc → src/protoc}/events/events.d.ts +0 -0
- /package/{protoc → src/protoc}/events/events.js +0 -0
- /package/{protoc → src/protoc}/events/index.d.ts +0 -0
- /package/{protoc → src/protoc}/events/index.js +0 -0
- /package/{protoc → src/protoc}/google/protobuf/timestamp.d.ts +0 -0
- /package/{protoc → src/protoc}/google/protobuf/timestamp.js +0 -0
- /package/{protoc → src/protoc}/google/protobuf/wrappers.d.ts +0 -0
- /package/{protoc → src/protoc}/google/protobuf/wrappers.js +0 -0
- /package/{protoc → src/protoc}/v1/dispatcher.d.ts +0 -0
- /package/{protoc → src/protoc}/v1/dispatcher.js +0 -0
- /package/{protoc → src/protoc}/v1/shared/condition.d.ts +0 -0
- /package/{protoc → src/protoc}/v1/shared/condition.js +0 -0
- /package/{protoc → src/protoc}/workflows/index.d.ts +0 -0
- /package/{protoc → src/protoc}/workflows/index.js +0 -0
- /package/{protoc → src/protoc}/workflows/v1-admin.d.ts +0 -0
- /package/{protoc → src/protoc}/workflows/v1-admin.js +0 -0
- /package/{util → src/util}/apply-namespace.d.ts +0 -0
- /package/{util → src/util}/apply-namespace.js +0 -0
- /package/{util → src/util}/batch.d.ts +0 -0
- /package/{util → src/util}/batch.js +0 -0
- /package/{util → src/util}/config-loader/index.d.ts +0 -0
- /package/{util → src/util}/config-loader/index.js +0 -0
- /package/{util → src/util}/config-loader/token.d.ts +0 -0
- /package/{util → src/util}/config-loader/token.js +0 -0
- /package/{util → src/util}/errors/hatchet-error.d.ts +0 -0
- /package/{util → src/util}/errors/hatchet-error.js +0 -0
- /package/{util → src/util}/grpc-helpers.js +0 -0
- /package/{util → src/util}/logger/logger.js +0 -0
- /package/{util → src/util}/parse.d.ts +0 -0
- /package/{util → src/util}/parse.js +0 -0
- /package/{util → src/util}/retrier.d.ts +0 -0
- /package/{util → src/util}/retrier.js +0 -0
- /package/{util → src/util}/thread-helper.d.ts +0 -0
- /package/{util → src/util}/thread-helper.js +0 -0
- /package/{util → src/util}/uuid.d.ts +0 -0
- /package/{util → src/util}/uuid.js +0 -0
- /package/{v1 → src/v1}/client/client.interface.js +0 -0
- /package/{v1 → src/v1}/client/duration.d.ts +0 -0
- /package/{v1 → src/v1}/client/duration.js +0 -0
- /package/{v1 → src/v1}/client/features/index.d.ts +0 -0
- /package/{v1 → src/v1}/client/features/index.js +0 -0
- /package/{v1 → src/v1}/client/features/tenant.js +0 -0
- /package/{v1 → src/v1}/client/worker/deprecated/deprecation.js +0 -0
- /package/{v1 → src/v1}/client/worker/deprecated/index.d.ts +0 -0
- /package/{v1 → src/v1}/client/worker/deprecated/index.js +0 -0
- /package/{v1 → src/v1}/client/worker/deprecated/legacy-worker.d.ts +0 -0
- /package/{v1 → src/v1}/client/worker/health-server.js +0 -0
- /package/{v1 → src/v1}/client/worker/slot-utils.js +0 -0
- /package/{v1 → src/v1}/conditions/base.d.ts +0 -0
- /package/{v1 → src/v1}/conditions/base.js +0 -0
- /package/{v1 → src/v1}/conditions/index.d.ts +0 -0
- /package/{v1 → src/v1}/conditions/index.js +0 -0
- /package/{v1 → src/v1}/conditions/parent-condition.d.ts +0 -0
- /package/{v1 → src/v1}/conditions/parent-condition.js +0 -0
- /package/{v1 → src/v1}/conditions/sleep-condition.d.ts +0 -0
- /package/{v1 → src/v1}/conditions/sleep-condition.js +0 -0
- /package/{v1 → src/v1}/conditions/transformer.js +0 -0
- /package/{v1 → src/v1}/conditions/user-event-condition.d.ts +0 -0
- /package/{v1 → src/v1}/conditions/user-event-condition.js +0 -0
- /package/{examples/webhooks.d.ts → src/v1/examples/affinity/affinity-workers.d.ts} +0 -0
- /package/{v1/examples/cancellations → src/v1/examples/cancellation}/run.d.ts +0 -0
- /package/{v1/examples/cancellations → src/v1/examples/cancellation}/worker.d.ts +0 -0
- /package/{v1/examples/child_workflows → src/v1/examples/cancellations}/run.d.ts +0 -0
- /package/{v1/examples/child_workflows → src/v1/examples/cancellations}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/cancellations/worker.js +0 -0
- /package/{v1 → src/v1}/examples/cancellations/workflow.d.ts +0 -0
- /package/{v1/examples/concurrency-rr → src/v1/examples/child_workflows}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/child_workflows/run.js +0 -0
- /package/{v1/examples/concurrency-rr → src/v1/examples/child_workflows}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/child_workflows/worker.js +0 -0
- /package/{v1 → src/v1}/examples/child_workflows/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/child_workflows/workflow.js +0 -0
- /package/{v1 → src/v1}/examples/concurrency-rr/load.d.ts +0 -0
- /package/{v1 → src/v1}/examples/concurrency-rr/load.js +0 -0
- /package/{v1/examples/dag → src/v1/examples/concurrency-rr}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/concurrency-rr/run.js +0 -0
- /package/{v1/examples/dag → src/v1/examples/concurrency-rr}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/concurrency-rr/worker.js +0 -0
- /package/{v1 → src/v1}/examples/concurrency-rr/workflow.d.ts +0 -0
- /package/{v1/types.js → src/v1/examples/concurrency-types.js} +0 -0
- /package/{v1/examples/dag_match_condition/event.d.ts → src/v1/examples/concurrency_limit_rr/load.d.ts} +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/concurrency_limit_rr}/run.d.ts +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/concurrency_limit_rr}/worker.d.ts +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/complex-workflow.d.ts +0 -0
- /package/{v1/examples/durable-event → src/v1/examples/conditions}/event.d.ts +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/event.js +0 -0
- /package/{v1/examples/deep → src/v1/examples/conditions}/run.d.ts +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/run.js +0 -0
- /package/{v1/examples/deep → src/v1/examples/conditions}/worker.d.ts +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/worker.js +0 -0
- /package/{v1/examples/dag_match_condition → src/v1/examples/conditions}/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/dag/interface-workflow.js +0 -0
- /package/{v1/examples/durable-event → src/v1/examples/dag}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/dag/run.js +0 -0
- /package/{v1/examples/durable-event → src/v1/examples/dag}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/dag/worker.js +0 -0
- /package/{v1 → src/v1}/examples/dag/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/dag/workflow.js +0 -0
- /package/{v1/examples/durable-sleep → src/v1/examples/dag_match_condition}/event.d.ts +0 -0
- /package/{v1/examples/durable-sleep → src/v1/examples/dag_match_condition}/event.js +0 -0
- /package/{v1/examples/durable-sleep → src/v1/examples/dag_match_condition}/run.d.ts +0 -0
- /package/{v1/examples/durable-sleep → src/v1/examples/dag_match_condition}/worker.d.ts +0 -0
- /package/{v1/examples/high-memory → src/v1/examples/deep}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/deep/run.js +0 -0
- /package/{v1/examples/inferred-typing → src/v1/examples/deep}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/deep/worker.js +0 -0
- /package/{v1 → src/v1}/examples/deep/workflow.d.ts +0 -0
- /package/{v1/examples/on_event → src/v1/examples/durable-event}/event.d.ts +0 -0
- /package/{v1 → src/v1}/examples/durable-event/event.js +0 -0
- /package/{v1/examples/inferred-typing → src/v1/examples/durable-event}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/durable-event/run.js +0 -0
- /package/{v1/examples/legacy → src/v1/examples/durable-event}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/durable-event/worker.js +0 -0
- /package/{v1 → src/v1}/examples/durable-event/workflow.d.ts +0 -0
- /package/{v1/examples/high-memory/child-worker.d.ts → src/v1/examples/durable-sleep/event.d.ts} +0 -0
- /package/{v1/examples/legacy → src/v1/examples/durable-sleep}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/durable-sleep/run.js +0 -0
- /package/{v1/examples/middleware → src/v1/examples/durable-sleep}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/durable-sleep/worker.js +0 -0
- /package/{v1 → src/v1}/examples/durable-sleep/workflow.d.ts +0 -0
- /package/{v1/examples/high-memory/parent-worker.d.ts → src/v1/examples/durable_event/event.d.ts} +0 -0
- /package/{v1/examples/middleware → src/v1/examples/durable_event}/run.d.ts +0 -0
- /package/{v1/examples/multiple_wf_concurrency → src/v1/examples/durable_event}/worker.d.ts +0 -0
- /package/{v1/examples/landing_page/scheduling.d.ts → src/v1/examples/durable_sleep/event.d.ts} +0 -0
- /package/{v1/examples/multiple_wf_concurrency → src/v1/examples/durable_sleep}/run.d.ts +0 -0
- /package/{v1/examples/non_retryable → src/v1/examples/durable_sleep}/worker.d.ts +0 -0
- /package/{v1/examples/logging/byo-logger.d.ts → src/v1/examples/e2e-worker.d.ts} +0 -0
- /package/{v1/examples/logging/logger.d.ts → src/v1/examples/events/event.d.ts} +0 -0
- /package/{v1/examples/on_event → src/v1/examples/events}/event.js +0 -0
- /package/{v1/examples/on_event → src/v1/examples/events}/filter.d.ts +0 -0
- /package/{v1/examples/on_cron → src/v1/examples/events}/worker.d.ts +0 -0
- /package/{v1/examples/on_event → src/v1/examples/events}/worker.js +0 -0
- /package/{v1/examples/on_event → src/v1/examples/events}/workflow.d.ts +0 -0
- /package/{v1/examples/on_event → src/v1/examples/events}/workflow.js +0 -0
- /package/{v1/examples/middleware/recipes.d.ts → src/v1/examples/high-memory/child-worker.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/high-memory/child-worker.js +0 -0
- /package/{v1/examples/non_retryable/run.d.ts → src/v1/examples/high-memory/parent-worker.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/high-memory/parent-worker.js +0 -0
- /package/{v1/examples/on_failure → src/v1/examples/high-memory}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/high-memory/run.js +0 -0
- /package/{v1 → src/v1}/examples/high-memory/workflow-with-child.d.ts +0 -0
- /package/{v1/examples/on_success → src/v1/examples/inferred-typing}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/inferred-typing/run.js +0 -0
- /package/{v1/examples/on_event → src/v1/examples/inferred-typing}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/inferred-typing/worker.js +0 -0
- /package/{v1 → src/v1}/examples/inferred-typing/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/inferred-typing/workflow.js +0 -0
- /package/{v1 → src/v1}/examples/landing_page/durable-excution.d.ts +0 -0
- /package/{v1 → src/v1}/examples/landing_page/event-signaling.d.ts +0 -0
- /package/{v1 → src/v1}/examples/landing_page/event-signaling.js +0 -0
- /package/{v1 → src/v1}/examples/landing_page/flow-control.d.ts +0 -0
- /package/{v1 → src/v1}/examples/landing_page/queues.d.ts +0 -0
- /package/{v1 → src/v1}/examples/landing_page/queues.js +0 -0
- /package/{v1/examples/on_failure/worker.d.ts → src/v1/examples/landing_page/scheduling.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/landing_page/scheduling.js +0 -0
- /package/{v1 → src/v1}/examples/landing_page/task-routing.d.ts +0 -0
- /package/{v1 → src/v1}/examples/landing_page/task-routing.js +0 -0
- /package/{v1/examples/priority → src/v1/examples/legacy}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/legacy/run.js +0 -0
- /package/{v1/examples/on_success → src/v1/examples/legacy}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/legacy/worker.js +0 -0
- /package/{v1 → src/v1}/examples/legacy/workflow.js +0 -0
- /package/{v1/examples/priority/worker.d.ts → src/v1/examples/logger/byo-logger.d.ts} +0 -0
- /package/{v1/examples/quickstart/run.d.ts → src/v1/examples/logger/logger.d.ts} +0 -0
- /package/{v1/examples/logging → src/v1/examples/logger}/logger.js +0 -0
- /package/{v1/examples/quickstart/worker.d.ts → src/v1/examples/logging/byo-logger.d.ts} +0 -0
- /package/{v1/examples/rate_limit/workflow.d.ts → src/v1/examples/logging/logger.d.ts} +0 -0
- /package/{v1/examples/retries/run.d.ts → src/v1/examples/middleware/recipes.d.ts} +0 -0
- /package/{v1/examples/sticky → src/v1/examples/middleware}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/middleware/run.js +0 -0
- /package/{v1/examples/retries → src/v1/examples/middleware}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/middleware/worker.js +0 -0
- /package/{v1 → src/v1}/examples/middleware/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/middleware/workflow.js +0 -0
- /package/{v1 → src/v1}/examples/migration-guides/mergent.d.ts +0 -0
- /package/{v1 → src/v1}/examples/migration-guides/mergent.js +0 -0
- /package/{v1/examples/streaming → src/v1/examples/multiple_wf_concurrency}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/multiple_wf_concurrency/run.js +0 -0
- /package/{v1/examples/simple → src/v1/examples/multiple_wf_concurrency}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/multiple_wf_concurrency/worker.js +0 -0
- /package/{v1/examples/timeouts → src/v1/examples/non_retryable}/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/non_retryable/run.js +0 -0
- /package/{v1/examples/sticky → src/v1/examples/non_retryable}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/non_retryable/worker.js +0 -0
- /package/{v1 → src/v1}/examples/non_retryable/workflow.d.ts +0 -0
- /package/{v1/examples/streaming → src/v1/examples/on_cron}/worker.d.ts +0 -0
- /package/{v1 → src/v1}/examples/on_cron/worker.js +0 -0
- /package/{v1 → src/v1}/examples/on_cron/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/on_cron/workflow.js +0 -0
- /package/{v1/examples/simple/bulk.d.ts → src/v1/examples/on_event/event.d.ts} +0 -0
- /package/{v1/examples/simple/client-run.d.ts → src/v1/examples/on_event/filter.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/on_event/filter.js +0 -0
- /package/{v1/examples/timeouts → src/v1/examples/on_event}/worker.d.ts +0 -0
- /package/{v1/examples/simple/cron.d.ts → src/v1/examples/on_failure/run.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/on_failure/run.js +0 -0
- /package/{v1/examples/simple/delay.d.ts → src/v1/examples/on_failure/worker.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/on_failure/worker.js +0 -0
- /package/{v1/examples/simple/enqueue.d.ts → src/v1/examples/on_success/run.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/on_success/run.js +0 -0
- /package/{v1/examples/simple/replay-cancel.d.ts → src/v1/examples/on_success/worker.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/on_success/worker.js +0 -0
- /package/{v1 → src/v1}/examples/on_success/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/on_success/workflow.js +0 -0
- /package/{v1/examples/simple/schedule.d.ts → src/v1/examples/priority/run.d.ts} +0 -0
- /package/{v1/examples/simple/typed-run-methods.d.ts → src/v1/examples/priority/worker.d.ts} +0 -0
- /package/{v1 → src/v1}/examples/priority/worker.js +0 -0
- /package/{v1 → src/v1}/examples/quickstart/run.js +0 -0
- /package/{v1 → src/v1}/examples/quickstart/worker.js +0 -0
- /package/{v1 → src/v1}/examples/quickstart/workflows/first-task.d.ts +0 -0
- /package/{v1 → src/v1}/examples/quickstart/workflows/first-task.js +0 -0
- /package/{v1 → src/v1}/examples/retries/run.js +0 -0
- /package/{v1 → src/v1}/examples/retries/worker.js +0 -0
- /package/{v1 → src/v1}/examples/retries/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/bulk.js +0 -0
- /package/{v1 → src/v1}/examples/simple/client-run.js +0 -0
- /package/{v1 → src/v1}/examples/simple/cron.js +0 -0
- /package/{v1 → src/v1}/examples/simple/delay.js +0 -0
- /package/{v1 → src/v1}/examples/simple/run.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/run.js +0 -0
- /package/{v1 → src/v1}/examples/simple/schedule.js +0 -0
- /package/{v1 → src/v1}/examples/simple/stub-workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/stub-workflow.js +0 -0
- /package/{v1 → src/v1}/examples/simple/typed-run-methods.js +0 -0
- /package/{v1 → src/v1}/examples/simple/worker.js +0 -0
- /package/{v1 → src/v1}/examples/simple/workflow-with-child.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/workflow-with-child.js +0 -0
- /package/{v1 → src/v1}/examples/simple/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/workflow.js +0 -0
- /package/{v1 → src/v1}/examples/simple/zod.d.ts +0 -0
- /package/{v1 → src/v1}/examples/simple/zod.js +0 -0
- /package/{v1 → src/v1}/examples/sticky/run.js +0 -0
- /package/{v1 → src/v1}/examples/sticky/worker.js +0 -0
- /package/{v1 → src/v1}/examples/streaming/nextjs-proxy.d.ts +0 -0
- /package/{v1 → src/v1}/examples/streaming/nextjs-proxy.js +0 -0
- /package/{v1 → src/v1}/examples/streaming/run.js +0 -0
- /package/{v1 → src/v1}/examples/streaming/worker.js +0 -0
- /package/{v1 → src/v1}/examples/streaming/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/streaming/workflow.js +0 -0
- /package/{v1 → src/v1}/examples/timeouts/run.js +0 -0
- /package/{v1 → src/v1}/examples/timeouts/worker.js +0 -0
- /package/{v1 → src/v1}/examples/timeouts/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/examples/with_timeouts/workflow.d.ts +0 -0
- /package/{v1 → src/v1}/slot-types.d.ts +0 -0
- /package/{v1 → src/v1}/slot-types.js +0 -0
package/clients/worker/worker.js
DELETED
|
@@ -1,568 +0,0 @@
|
|
|
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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.V0Worker = void 0;
|
|
23
|
-
const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
|
|
24
|
-
const action_listener_1 = require("../dispatcher/action-listener");
|
|
25
|
-
const dispatcher_1 = require("../../protoc/dispatcher");
|
|
26
|
-
const hatchet_promise_1 = __importDefault(require("../../util/hatchet-promise/hatchet-promise"));
|
|
27
|
-
const workflows_1 = require("../../protoc/workflows");
|
|
28
|
-
const handler_1 = require("./handler");
|
|
29
|
-
const task_1 = require("../../v1/task");
|
|
30
|
-
const apply_namespace_1 = require("../../util/apply-namespace");
|
|
31
|
-
const step_1 = require("../../step");
|
|
32
|
-
class V0Worker {
|
|
33
|
-
constructor(client, options) {
|
|
34
|
-
this.workflow_registry = [];
|
|
35
|
-
this.futures = {};
|
|
36
|
-
this.contexts = {};
|
|
37
|
-
this.registeredWorkflowPromises = [];
|
|
38
|
-
this.labels = {};
|
|
39
|
-
this.client = client;
|
|
40
|
-
this.name = (0, apply_namespace_1.applyNamespace)(options.name, this.client.config.namespace);
|
|
41
|
-
this.action_registry = {};
|
|
42
|
-
this.maxRuns = options.maxRuns;
|
|
43
|
-
this.labels = options.labels || {};
|
|
44
|
-
process.on('SIGTERM', () => this.exitGracefully(true));
|
|
45
|
-
process.on('SIGINT', () => this.exitGracefully(true));
|
|
46
|
-
this.killing = false;
|
|
47
|
-
this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
|
|
48
|
-
this.logger = client.config.logger(`Worker/${this.name}`, this.client.config.log_level);
|
|
49
|
-
}
|
|
50
|
-
registerActions(workflow) {
|
|
51
|
-
var _a;
|
|
52
|
-
const newActions = workflow.steps.reduce((acc, step) => {
|
|
53
|
-
acc[`${workflow.id}:${step.name.toLowerCase()}`] = step.run;
|
|
54
|
-
return acc;
|
|
55
|
-
}, {});
|
|
56
|
-
const onFailureAction = workflow.onFailure
|
|
57
|
-
? {
|
|
58
|
-
[`${workflow.id}-on-failure:${workflow.onFailure.name}`]: workflow.onFailure.run,
|
|
59
|
-
}
|
|
60
|
-
: {};
|
|
61
|
-
this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
|
|
62
|
-
this.action_registry =
|
|
63
|
-
((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name) && workflow.concurrency.key
|
|
64
|
-
? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name.toLowerCase()}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
|
|
65
|
-
}
|
|
66
|
-
getHandler(workflows) {
|
|
67
|
-
// TODO v1
|
|
68
|
-
for (const workflow of workflows) {
|
|
69
|
-
const wf = Object.assign(Object.assign({}, workflow), { id: (0, apply_namespace_1.applyNamespace)(workflow.id, this.client.config.namespace) });
|
|
70
|
-
this.registerActions(wf);
|
|
71
|
-
}
|
|
72
|
-
return new handler_1.WebhookHandler(this, workflows);
|
|
73
|
-
}
|
|
74
|
-
registerWebhook(webhook) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
return this.client.admin.registerWebhook(Object.assign({}, webhook));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated use registerWorkflow instead
|
|
81
|
-
*/
|
|
82
|
-
register_workflow(initWorkflow) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return this.registerWorkflow(initWorkflow);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
registerWorkflow(initWorkflow) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
var _a, _b, _c;
|
|
90
|
-
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: (0, apply_namespace_1.applyNamespace)(initWorkflow.id, this.client.config.namespace).toLowerCase() });
|
|
91
|
-
try {
|
|
92
|
-
if (((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.key) && workflow.concurrency.expression) {
|
|
93
|
-
throw new hatchet_error_1.default('Cannot have both key function and expression in workflow concurrency configuration');
|
|
94
|
-
}
|
|
95
|
-
const concurrency = ((_b = workflow.concurrency) === null || _b === void 0 ? void 0 : _b.name) || ((_c = workflow.concurrency) === null || _c === void 0 ? void 0 : _c.expression)
|
|
96
|
-
? {
|
|
97
|
-
action: !workflow.concurrency.expression
|
|
98
|
-
? `${workflow.id}:${workflow.concurrency.name}`
|
|
99
|
-
: undefined,
|
|
100
|
-
maxRuns: workflow.concurrency.maxRuns || 1,
|
|
101
|
-
expression: workflow.concurrency.expression,
|
|
102
|
-
limitStrategy: workflow.concurrency.limitStrategy || workflows_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
|
|
103
|
-
}
|
|
104
|
-
: undefined;
|
|
105
|
-
const onFailureJob = workflow.onFailure
|
|
106
|
-
? {
|
|
107
|
-
name: `${workflow.id}-on-failure`,
|
|
108
|
-
description: workflow.description,
|
|
109
|
-
steps: [
|
|
110
|
-
{
|
|
111
|
-
readableId: workflow.onFailure.name,
|
|
112
|
-
action: `${workflow.id}-on-failure:${workflow.onFailure.name}`,
|
|
113
|
-
timeout: workflow.onFailure.timeout || '60s',
|
|
114
|
-
inputs: '{}',
|
|
115
|
-
parents: [],
|
|
116
|
-
userData: '{}',
|
|
117
|
-
retries: workflow.onFailure.retries || 0,
|
|
118
|
-
rateLimits: (0, step_1.mapRateLimit)(workflow.onFailure.rate_limits),
|
|
119
|
-
workerLabels: {}, // no worker labels for on failure steps
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
}
|
|
123
|
-
: undefined;
|
|
124
|
-
const registeredWorkflow = this.client.admin.putWorkflow({
|
|
125
|
-
name: workflow.id,
|
|
126
|
-
description: workflow.description,
|
|
127
|
-
version: workflow.version || '',
|
|
128
|
-
eventTriggers: workflow.on && workflow.on.event
|
|
129
|
-
? [(0, apply_namespace_1.applyNamespace)(workflow.on.event, this.client.config.namespace)]
|
|
130
|
-
: [],
|
|
131
|
-
cronTriggers: workflow.on && workflow.on.cron ? [workflow.on.cron] : [],
|
|
132
|
-
scheduledTriggers: [],
|
|
133
|
-
concurrency,
|
|
134
|
-
scheduleTimeout: workflow.scheduleTimeout,
|
|
135
|
-
onFailureJob,
|
|
136
|
-
sticky: workflow.sticky,
|
|
137
|
-
jobs: [
|
|
138
|
-
{
|
|
139
|
-
name: workflow.id,
|
|
140
|
-
description: workflow.description,
|
|
141
|
-
steps: workflow.steps.map((step) => {
|
|
142
|
-
var _a, _b, _c;
|
|
143
|
-
return ({
|
|
144
|
-
readableId: step.name,
|
|
145
|
-
action: `${workflow.id}:${step.name}`,
|
|
146
|
-
timeout: step.timeout || '60s',
|
|
147
|
-
inputs: '{}',
|
|
148
|
-
parents: (_a = step.parents) !== null && _a !== void 0 ? _a : [],
|
|
149
|
-
userData: '{}',
|
|
150
|
-
retries: step.retries || 0,
|
|
151
|
-
rateLimits: (0, step_1.mapRateLimit)(step.rate_limits),
|
|
152
|
-
workerLabels: toPbWorkerLabel(step.worker_labels),
|
|
153
|
-
backoffFactor: (_b = step.backoff) === null || _b === void 0 ? void 0 : _b.factor,
|
|
154
|
-
backoffMaxSeconds: (_c = step.backoff) === null || _c === void 0 ? void 0 : _c.maxSeconds,
|
|
155
|
-
});
|
|
156
|
-
}),
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
});
|
|
160
|
-
this.registeredWorkflowPromises.push(registeredWorkflow);
|
|
161
|
-
yield registeredWorkflow;
|
|
162
|
-
this.workflow_registry.push(workflow);
|
|
163
|
-
}
|
|
164
|
-
catch (e) {
|
|
165
|
-
throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
|
|
166
|
-
}
|
|
167
|
-
this.registerActions(workflow);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
registerAction(actionId, action) {
|
|
171
|
-
this.action_registry[actionId.toLowerCase()] = action;
|
|
172
|
-
}
|
|
173
|
-
handleStartStepRun(action) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const { actionId } = action;
|
|
176
|
-
try {
|
|
177
|
-
// Note: we always use a DurableContext since its a superset of the Context class
|
|
178
|
-
const context = new step_1.V0DurableContext(action, this.client, this);
|
|
179
|
-
this.contexts[(0, action_listener_1.createActionKey)(action)] = context;
|
|
180
|
-
const step = this.action_registry[actionId];
|
|
181
|
-
if (!step) {
|
|
182
|
-
this.logger.error(`Registered actions: '${Object.keys(this.action_registry).join(', ')}'`);
|
|
183
|
-
this.logger.error(`Could not find step '${actionId}'`);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const { middleware } = this.client.config;
|
|
188
|
-
if (middleware === null || middleware === void 0 ? void 0 : middleware.before) {
|
|
189
|
-
const hooks = Array.isArray(middleware.before) ? middleware.before : [middleware.before];
|
|
190
|
-
for (const hook of hooks) {
|
|
191
|
-
const extra = yield hook(context.input, context);
|
|
192
|
-
if (extra !== undefined) {
|
|
193
|
-
const merged = Object.assign(Object.assign({}, context.input), extra);
|
|
194
|
-
context.input = merged;
|
|
195
|
-
if (context.data && typeof context.data === 'object') {
|
|
196
|
-
context.data.input = merged;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
let result = yield step(context);
|
|
202
|
-
if (middleware === null || middleware === void 0 ? void 0 : middleware.after) {
|
|
203
|
-
const hooks = Array.isArray(middleware.after) ? middleware.after : [middleware.after];
|
|
204
|
-
for (const hook of hooks) {
|
|
205
|
-
const extra = yield hook(result, context, context.input);
|
|
206
|
-
if (extra !== undefined) {
|
|
207
|
-
result = Object.assign(Object.assign({}, result), extra);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return result;
|
|
212
|
-
});
|
|
213
|
-
const success = (result) => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
this.logger.info(`Task run ${action.taskRunExternalId} succeeded`);
|
|
215
|
-
try {
|
|
216
|
-
// Send the action event to the dispatcher
|
|
217
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
|
|
218
|
-
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
219
|
-
}
|
|
220
|
-
catch (actionEventError) {
|
|
221
|
-
this.logger.error(`Could not send completed action event: ${actionEventError.message || actionEventError}`);
|
|
222
|
-
// send a failure event
|
|
223
|
-
const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, false, actionEventError.message, action.retryCount);
|
|
224
|
-
try {
|
|
225
|
-
yield this.client.dispatcher.sendStepActionEvent(failureEvent);
|
|
226
|
-
}
|
|
227
|
-
catch (failureEventError) {
|
|
228
|
-
this.logger.error(`Could not send failed action event: ${failureEventError.message || failureEventError}`);
|
|
229
|
-
}
|
|
230
|
-
this.logger.error(`Could not send action event: ${actionEventError.message || actionEventError}`);
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
// delete the run from the futures
|
|
234
|
-
delete this.futures[(0, action_listener_1.createActionKey)(action)];
|
|
235
|
-
delete this.contexts[(0, action_listener_1.createActionKey)(action)];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
const failure = (error) => __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
this.logger.error(`Task run ${action.taskRunExternalId} failed: ${error.message}`);
|
|
240
|
-
if (error.stack) {
|
|
241
|
-
this.logger.error(error.stack);
|
|
242
|
-
}
|
|
243
|
-
const shouldNotRetry = error instanceof task_1.NonRetryableError;
|
|
244
|
-
try {
|
|
245
|
-
// Send the action event to the dispatcher
|
|
246
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, shouldNotRetry, {
|
|
247
|
-
message: error === null || error === void 0 ? void 0 : error.message,
|
|
248
|
-
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
249
|
-
}, action.retryCount);
|
|
250
|
-
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
251
|
-
}
|
|
252
|
-
catch (e) {
|
|
253
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
254
|
-
}
|
|
255
|
-
finally {
|
|
256
|
-
// delete the run from the futures
|
|
257
|
-
delete this.futures[(0, action_listener_1.createActionKey)(action)];
|
|
258
|
-
delete this.contexts[(0, action_listener_1.createActionKey)(action)];
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
const future = new hatchet_promise_1.default((() => __awaiter(this, void 0, void 0, function* () {
|
|
262
|
-
let result;
|
|
263
|
-
try {
|
|
264
|
-
result = yield run();
|
|
265
|
-
}
|
|
266
|
-
catch (e) {
|
|
267
|
-
yield failure(e);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
yield success(result);
|
|
271
|
-
}))());
|
|
272
|
-
this.futures[(0, action_listener_1.createActionKey)(action)] = future;
|
|
273
|
-
// Send the action event to the dispatcher
|
|
274
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED, false, undefined, action.retryCount);
|
|
275
|
-
this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
|
|
276
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
277
|
-
});
|
|
278
|
-
try {
|
|
279
|
-
yield future.promise;
|
|
280
|
-
}
|
|
281
|
-
catch (e) {
|
|
282
|
-
const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
|
|
283
|
-
if (message.includes('Cancelled')) {
|
|
284
|
-
this.logger.debug(`Task run ${action.taskRunExternalId} was cancelled`);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
this.logger.error(`Could not wait for task run ${action.taskRunExternalId} to finish. ` +
|
|
288
|
-
`See https://docs.hatchet.run/home/cancellation for best practices on handling cancellation: `, e);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch (e) {
|
|
293
|
-
this.logger.error('Could not send action event (outer): ', e);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
handleStartGroupKeyRun(action) {
|
|
298
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
-
const { actionId } = action;
|
|
300
|
-
try {
|
|
301
|
-
const context = new step_1.V0Context(action, this.client, this);
|
|
302
|
-
const key = (0, action_listener_1.createActionKey)(action);
|
|
303
|
-
if (!key) {
|
|
304
|
-
this.logger.error(`No group key run id provided for action ${actionId}`);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
this.contexts[key] = context;
|
|
308
|
-
this.logger.debug(`Starting group key run ${key}`);
|
|
309
|
-
const step = this.action_registry[actionId];
|
|
310
|
-
if (!step) {
|
|
311
|
-
this.logger.error(`Could not find step '${actionId}'`);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
315
|
-
return step(context);
|
|
316
|
-
});
|
|
317
|
-
const success = (result) => {
|
|
318
|
-
this.logger.info(`Task run ${action.taskRunExternalId} succeeded`);
|
|
319
|
-
try {
|
|
320
|
-
// Send the action event to the dispatcher
|
|
321
|
-
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
|
|
322
|
-
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
323
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
catch (e) {
|
|
327
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
328
|
-
}
|
|
329
|
-
finally {
|
|
330
|
-
// delete the run from the futures
|
|
331
|
-
delete this.futures[key];
|
|
332
|
-
delete this.contexts[key];
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
const failure = (error) => {
|
|
336
|
-
this.logger.error(`Task run ${key} failed: ${error.message}`);
|
|
337
|
-
try {
|
|
338
|
-
// Send the action event to the dispatcher
|
|
339
|
-
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
|
|
340
|
-
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
341
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
catch (e) {
|
|
345
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
346
|
-
}
|
|
347
|
-
finally {
|
|
348
|
-
// delete the run from the futures
|
|
349
|
-
delete this.futures[key];
|
|
350
|
-
delete this.contexts[key];
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
const future = new hatchet_promise_1.default(run().then(success).catch(failure));
|
|
354
|
-
this.futures[key] = future;
|
|
355
|
-
// Send the action event to the dispatcher
|
|
356
|
-
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_STARTED);
|
|
357
|
-
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
358
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
359
|
-
});
|
|
360
|
-
yield future.promise;
|
|
361
|
-
}
|
|
362
|
-
catch (e) {
|
|
363
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
getStepActionEvent(action, eventType, shouldNotRetry, payload = '', retryCount = 0) {
|
|
368
|
-
return {
|
|
369
|
-
workerId: this.name,
|
|
370
|
-
jobId: action.jobId,
|
|
371
|
-
jobRunId: action.jobRunId,
|
|
372
|
-
taskId: action.taskId,
|
|
373
|
-
taskRunExternalId: action.taskRunExternalId,
|
|
374
|
-
actionId: action.actionId,
|
|
375
|
-
eventTimestamp: new Date(),
|
|
376
|
-
eventType,
|
|
377
|
-
eventPayload: JSON.stringify(payload),
|
|
378
|
-
shouldNotRetry,
|
|
379
|
-
retryCount,
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
getGroupKeyActionEvent(action, eventType, payload = '') {
|
|
383
|
-
if (!action.getGroupKeyRunId) {
|
|
384
|
-
throw new hatchet_error_1.default('No group key run id provided');
|
|
385
|
-
}
|
|
386
|
-
return {
|
|
387
|
-
workerId: this.name,
|
|
388
|
-
workflowRunId: action.workflowRunId,
|
|
389
|
-
getGroupKeyRunId: action.getGroupKeyRunId,
|
|
390
|
-
actionId: action.actionId,
|
|
391
|
-
eventTimestamp: new Date(),
|
|
392
|
-
eventType,
|
|
393
|
-
eventPayload: JSON.stringify(payload),
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
handleCancelStepRun(action) {
|
|
397
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
-
const { taskRunExternalId } = action;
|
|
399
|
-
try {
|
|
400
|
-
this.logger.info(`Cancelling task run ${action.taskRunExternalId}`);
|
|
401
|
-
const future = this.futures[(0, action_listener_1.createActionKey)(action)];
|
|
402
|
-
const context = this.contexts[(0, action_listener_1.createActionKey)(action)];
|
|
403
|
-
if (context && context.controller) {
|
|
404
|
-
context.controller.abort('Cancelled by worker');
|
|
405
|
-
}
|
|
406
|
-
if (future) {
|
|
407
|
-
future.promise.catch(() => {
|
|
408
|
-
this.logger.info(`Cancelled task run ${action.taskRunExternalId}`);
|
|
409
|
-
});
|
|
410
|
-
future.cancel('Cancelled by worker');
|
|
411
|
-
yield future.promise;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
catch (e) {
|
|
415
|
-
// Expected: the promise rejects when cancelled
|
|
416
|
-
this.logger.debug(`Task run ${taskRunExternalId} cancellation completed`);
|
|
417
|
-
}
|
|
418
|
-
finally {
|
|
419
|
-
delete this.futures[(0, action_listener_1.createActionKey)(action)];
|
|
420
|
-
delete this.contexts[(0, action_listener_1.createActionKey)(action)];
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
stop() {
|
|
425
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
426
|
-
yield this.exitGracefully(false);
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
exitGracefully(handleKill) {
|
|
430
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
-
var _a;
|
|
432
|
-
this.killing = true;
|
|
433
|
-
this.logger.info('Starting to exit...');
|
|
434
|
-
try {
|
|
435
|
-
yield ((_a = this.listener) === null || _a === void 0 ? void 0 : _a.unregister());
|
|
436
|
-
}
|
|
437
|
-
catch (e) {
|
|
438
|
-
this.logger.error(`Could not unregister listener: ${e.message}`);
|
|
439
|
-
}
|
|
440
|
-
this.logger.info('Gracefully exiting hatchet worker, running tasks will attempt to finish...');
|
|
441
|
-
// attempt to wait for futures to finish
|
|
442
|
-
yield Promise.all(Object.values(this.futures).map(({ promise }) => promise));
|
|
443
|
-
this.logger.info('Successfully finished pending tasks.');
|
|
444
|
-
if (handleKill) {
|
|
445
|
-
this.logger.info('Exiting hatchet worker...');
|
|
446
|
-
process.exit(0);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
start() {
|
|
451
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
-
var _a, e_1, _b, _c;
|
|
453
|
-
// ensure all workflows are registered
|
|
454
|
-
yield Promise.all(this.registeredWorkflowPromises);
|
|
455
|
-
if (Object.keys(this.action_registry).length === 0) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
try {
|
|
459
|
-
this.listener = yield this.client.dispatcher.getActionListener({
|
|
460
|
-
workerName: this.name,
|
|
461
|
-
services: ['default'],
|
|
462
|
-
actions: Object.keys(this.action_registry),
|
|
463
|
-
maxRuns: this.maxRuns,
|
|
464
|
-
labels: this.labels,
|
|
465
|
-
});
|
|
466
|
-
this.workerId = this.listener.workerId;
|
|
467
|
-
const generator = this.listener.actions();
|
|
468
|
-
this.logger.info(`Worker ${this.name} listening for actions`);
|
|
469
|
-
try {
|
|
470
|
-
for (var _d = true, generator_1 = __asyncValues(generator), generator_1_1; generator_1_1 = yield generator_1.next(), _a = generator_1_1.done, !_a; _d = true) {
|
|
471
|
-
_c = generator_1_1.value;
|
|
472
|
-
_d = false;
|
|
473
|
-
const action = _c;
|
|
474
|
-
this.logger.info(`Worker ${this.name} received action ${action.actionId}:${action.actionType}`);
|
|
475
|
-
void this.handleAction(action);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
479
|
-
finally {
|
|
480
|
-
try {
|
|
481
|
-
if (!_d && !_a && (_b = generator_1.return)) yield _b.call(generator_1);
|
|
482
|
-
}
|
|
483
|
-
finally { if (e_1) throw e_1.error; }
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
catch (e) {
|
|
487
|
-
if (this.killing) {
|
|
488
|
-
this.logger.info(`Exiting worker, ignoring error: ${e.message}`);
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
this.logger.error(`Could not run worker: ${e.message}`);
|
|
492
|
-
throw new hatchet_error_1.default(`Could not run worker: ${e.message}`);
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
handleAction(action) {
|
|
497
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
498
|
-
const type = action.actionType
|
|
499
|
-
? (0, dispatcher_1.actionTypeFromJSON)(action.actionType)
|
|
500
|
-
: dispatcher_1.ActionType.START_STEP_RUN;
|
|
501
|
-
if (type === dispatcher_1.ActionType.START_STEP_RUN) {
|
|
502
|
-
yield this.handleStartStepRun(action);
|
|
503
|
-
}
|
|
504
|
-
else if (type === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
|
|
505
|
-
yield this.handleCancelStepRun(action);
|
|
506
|
-
}
|
|
507
|
-
else if (type === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
|
|
508
|
-
yield this.handleStartGroupKeyRun(action);
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
this.logger.error(`Worker ${this.name} received unknown action type ${type}`);
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
upsertLabels(labels) {
|
|
516
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
517
|
-
this.labels = labels;
|
|
518
|
-
if (!this.workerId) {
|
|
519
|
-
this.logger.warn('Worker not registered.');
|
|
520
|
-
return this.labels;
|
|
521
|
-
}
|
|
522
|
-
this.client.dispatcher.upsertWorkerLabels(this.workerId, labels);
|
|
523
|
-
return this.labels;
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
exports.V0Worker = V0Worker;
|
|
528
|
-
function toPbWorkerLabel(in_) {
|
|
529
|
-
if (!in_) {
|
|
530
|
-
return {};
|
|
531
|
-
}
|
|
532
|
-
return Object.entries(in_).reduce((acc, [key, value]) => {
|
|
533
|
-
if (!value) {
|
|
534
|
-
return Object.assign(Object.assign({}, acc), { [key]: {
|
|
535
|
-
strValue: undefined,
|
|
536
|
-
intValue: undefined,
|
|
537
|
-
} });
|
|
538
|
-
}
|
|
539
|
-
if (typeof value === 'string') {
|
|
540
|
-
return Object.assign(Object.assign({}, acc), { [key]: {
|
|
541
|
-
strValue: value,
|
|
542
|
-
intValue: undefined,
|
|
543
|
-
} });
|
|
544
|
-
}
|
|
545
|
-
if (typeof value === 'number') {
|
|
546
|
-
return Object.assign(Object.assign({}, acc), { [key]: {
|
|
547
|
-
strValue: undefined,
|
|
548
|
-
intValue: value,
|
|
549
|
-
} });
|
|
550
|
-
}
|
|
551
|
-
return Object.assign(Object.assign({}, acc), { [key]: {
|
|
552
|
-
strValue: typeof value.value === 'string' ? value.value : undefined,
|
|
553
|
-
intValue: typeof value.value === 'number' ? value.value : undefined,
|
|
554
|
-
required: value.required,
|
|
555
|
-
weight: value.weight,
|
|
556
|
-
comparator: value.comparator,
|
|
557
|
-
} });
|
|
558
|
-
}, {});
|
|
559
|
-
}
|
|
560
|
-
function onFailureTaskName(workflow) {
|
|
561
|
-
return `${workflow.name}:on-failure-task`;
|
|
562
|
-
}
|
|
563
|
-
function getLeaves(tasks) {
|
|
564
|
-
return tasks.filter((task) => isLeafTask(task, tasks));
|
|
565
|
-
}
|
|
566
|
-
function isLeafTask(task, allTasks) {
|
|
567
|
-
return !allTasks.some((t) => { var _a; return (_a = t.parents) === null || _a === void 0 ? void 0 : _a.some((p) => p.name === task.name); });
|
|
568
|
-
}
|
package/examples/webhooks.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
const sdk_1 = __importDefault(require("../sdk"));
|
|
16
|
-
const data_contracts_1 = require("../clients/rest/generated/data-contracts");
|
|
17
|
-
const hatchet = sdk_1.default.init();
|
|
18
|
-
function main() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
21
|
-
const webhookName = `example-webhook-${Date.now()}`;
|
|
22
|
-
const namespace = (_b = (_a = hatchet.config) === null || _a === void 0 ? void 0 : _a.namespace) !== null && _b !== void 0 ? _b : 'default';
|
|
23
|
-
const webhook = yield hatchet.webhooks.create({
|
|
24
|
-
sourceName: data_contracts_1.V1WebhookSourceName.GENERIC,
|
|
25
|
-
name: webhookName,
|
|
26
|
-
eventKeyExpression: `'${namespace}/webhook:' + input.type`,
|
|
27
|
-
scopeExpression: 'input.customer_id',
|
|
28
|
-
staticPayload: { customer_id: 'cust-123', environment: 'production' },
|
|
29
|
-
auth: { username: 'test_user', password: 'test_password' },
|
|
30
|
-
});
|
|
31
|
-
console.log('Created webhook:', webhook.name, webhook.scopeExpression, webhook.staticPayload);
|
|
32
|
-
const one = yield hatchet.webhooks.get(webhook.name);
|
|
33
|
-
console.log('Get webhook:', one.name);
|
|
34
|
-
yield hatchet.webhooks.update(webhook.name, {
|
|
35
|
-
scopeExpression: 'input.environment',
|
|
36
|
-
});
|
|
37
|
-
const updated = yield hatchet.webhooks.get(webhook.name);
|
|
38
|
-
console.log('Updated scope expression:', updated.scopeExpression);
|
|
39
|
-
const list = yield hatchet.webhooks.list({ limit: 10, offset: 0 });
|
|
40
|
-
console.log('List webhooks:', (_d = (_c = list.rows) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
|
|
41
|
-
yield hatchet.webhooks.delete(webhook.name);
|
|
42
|
-
console.log('Deleted example webhook');
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
main();
|
package/sdk.d.ts
DELETED
package/util/logger/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './logger';
|
package/util/sleep.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Sleeps for a given number of milliseconds without blocking the event loop
|
|
5
|
-
*
|
|
6
|
-
* WARNING: This is not a durable sleep. It will not be honored if the worker is
|
|
7
|
-
* restarted or crashes.
|
|
8
|
-
* @param ms - The number of milliseconds to sleep
|
|
9
|
-
* @returns A promise that resolves after the given number of milliseconds
|
|
10
|
-
*/
|
|
11
|
-
const sleep = (ms) => new Promise((resolve) => {
|
|
12
|
-
setTimeout(resolve, ms);
|
|
13
|
-
});
|
|
14
|
-
exports.default = sleep;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RateLimitDuration } from '../../../protoc/workflows';
|
|
2
|
-
import { RateLimitOrderByField, RateLimitOrderByDirection } from '../../../clients/rest/generated/data-contracts';
|
|
3
|
-
import { HatchetClient } from '../client';
|
|
4
|
-
export { RateLimitDuration, RateLimitOrderByField, RateLimitOrderByDirection };
|
|
5
|
-
export type CreateRateLimitOpts = {
|
|
6
|
-
key: string;
|
|
7
|
-
limit: number;
|
|
8
|
-
duration?: RateLimitDuration;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* RatelimitsClient is used to manage rate limits for the Hatchet
|
|
12
|
-
*/
|
|
13
|
-
export declare class RatelimitsClient {
|
|
14
|
-
api: HatchetClient['api'];
|
|
15
|
-
admin: HatchetClient['admin'];
|
|
16
|
-
tenantId: string;
|
|
17
|
-
constructor(client: HatchetClient);
|
|
18
|
-
upsert(opts: CreateRateLimitOpts): Promise<string>;
|
|
19
|
-
list(opts: Parameters<typeof this.api.rateLimitList>[1]): Promise<import("../../../clients/rest/generated/data-contracts").RateLimitList>;
|
|
20
|
-
}
|