@hatchet-dev/typescript-sdk 1.15.1 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clients/admin/admin-client.js +8 -9
- package/clients/dispatcher/action-listener.js +42 -6
- package/clients/dispatcher/dispatcher-client.js +5 -8
- package/clients/dispatcher/heartbeat/heartbeat-worker.js +7 -4
- package/clients/event/event-client.d.ts +2 -2
- package/clients/event/event-client.js +5 -11
- package/clients/hatchet-client/hatchet-logger.js +8 -17
- package/clients/listeners/durable-listener/pooled-durable-listener-client.js +10 -8
- package/clients/listeners/run-listener/child-listener-client.d.ts +1 -1
- package/clients/listeners/run-listener/child-listener-client.js +34 -30
- package/clients/listeners/run-listener/pooled-child-listener-client.js +8 -5
- package/clients/rest/generated/Api.d.ts +21 -1
- package/clients/rest/generated/Api.js +20 -0
- package/clients/rest/generated/data-contracts.d.ts +46 -1
- package/clients/rest/generated/data-contracts.js +4 -0
- package/legacy/examples/affinity-workers.js +0 -1
- package/legacy/examples/byo-logger.js +0 -2
- package/legacy/examples/concurrency/cancel-in-progress/concurrency-worker.js +4 -2
- package/legacy/examples/concurrency/group-round-robin/concurrency-event.js +0 -1
- package/legacy/examples/concurrency/group-round-robin/concurrency-worker-expression.js +4 -2
- package/legacy/examples/concurrency/group-round-robin/concurrency-worker-key-fn.js +4 -2
- package/legacy/examples/example-event.js +0 -3
- package/legacy/examples/logger.js +0 -1
- package/legacy/examples/sticky-worker-with-check.js +0 -1
- package/legacy/examples/sticky-worker.js +0 -1
- package/legacy/legacy-client.js +1 -1
- package/legacy/legacy-transformer.js +2 -4
- package/legacy/step.d.ts +14 -14
- package/legacy/step.js +6 -16
- package/legacy/workflow.d.ts +56 -56
- package/package.json +20 -29
- package/util/abort-error.d.ts +5 -1
- package/util/abort-error.js +15 -5
- package/util/config-loader/config-loader.js +4 -3
- package/util/config-loader/token.js +9 -2
- package/util/errors/hatchet-error.d.ts +9 -1
- package/util/errors/hatchet-error.js +23 -2
- package/util/grpc-error.d.ts +9 -0
- package/util/grpc-error.js +25 -0
- package/util/hatchet-promise/hatchet-promise.d.ts +5 -1
- package/util/hatchet-promise/hatchet-promise.js +6 -1
- package/util/logger/logger.js +0 -1
- package/util/parse.d.ts +1 -1
- package/util/parse.js +4 -2
- package/util/retrier.js +2 -3
- package/util/workflow-run-ref.js +5 -3
- package/v1/client/admin.js +2 -6
- package/v1/client/client.d.ts +7 -11
- package/v1/client/client.interface.d.ts +6 -7
- package/v1/client/client.js +33 -39
- package/v1/client/features/cel.js +1 -1
- package/v1/client/features/crons.js +2 -2
- package/v1/client/features/index.d.ts +5 -0
- package/v1/client/features/index.js +5 -0
- package/v1/client/features/logs.d.ts +37 -0
- package/v1/client/features/logs.js +46 -0
- package/v1/client/features/runs.js +0 -1
- package/v1/client/features/schedules.js +4 -4
- package/v1/client/features/webhooks.js +4 -2
- package/v1/client/features/workflows.js +1 -1
- package/v1/client/worker/context.js +11 -24
- package/v1/client/worker/deprecated/deprecation.js +8 -4
- package/v1/client/worker/deprecated/legacy-worker.js +2 -2
- package/v1/client/worker/health-server.js +3 -3
- package/v1/client/worker/slot-utils.js +0 -3
- package/v1/client/worker/worker-internal.js +40 -11
- package/v1/client/worker/worker.js +2 -1
- package/v1/conditions/base.js +0 -1
- package/v1/conditions/index.js +2 -4
- package/v1/conditions/transformer.d.ts +2 -2
- package/v1/conditions/transformer.js +5 -4
- package/v1/declaration.d.ts +1 -1
- package/v1/declaration.js +12 -7
- package/v1/examples/__e2e__/harness.js +4 -3
- package/v1/examples/affinity/affinity-workers.js +0 -1
- package/v1/examples/bulk_operations/workflow.js +0 -1
- package/v1/examples/cancellation/run.js +0 -1
- package/v1/examples/cancellations/run.js +0 -1
- package/v1/examples/child_workflows/run.js +0 -2
- package/v1/examples/child_workflows/workflow.js +0 -1
- package/v1/examples/concurrency-rr/load.js +0 -1
- package/v1/examples/concurrency-rr/run.js +0 -3
- package/v1/examples/concurrency_limit_rr/load.js +0 -1
- package/v1/examples/concurrency_limit_rr/run.js +0 -3
- package/v1/examples/conditions/event.js +0 -1
- package/v1/examples/conditions/run.js +0 -1
- package/v1/examples/dag/run.js +0 -1
- package/v1/examples/dag_match_condition/event.js +0 -1
- package/v1/examples/dag_match_condition/run.js +0 -1
- package/v1/examples/deep/run.js +0 -2
- package/v1/examples/durable/workflow.js +2 -3
- package/v1/examples/durable-event/event.js +0 -1
- package/v1/examples/durable-event/run.js +0 -2
- package/v1/examples/durable-sleep/event.js +0 -1
- package/v1/examples/durable-sleep/run.js +0 -2
- package/v1/examples/durable_event/event.js +0 -1
- package/v1/examples/durable_event/run.js +0 -2
- package/v1/examples/durable_sleep/event.js +0 -1
- package/v1/examples/durable_sleep/run.js +0 -2
- package/v1/examples/events/event.js +0 -1
- package/v1/examples/high-memory/run.js +0 -1
- package/v1/examples/inferred-typing/run.js +0 -1
- package/v1/examples/landing_page/durable-excution.js +0 -1
- package/v1/examples/landing_page/queues.js +0 -1
- package/v1/examples/legacy/run.js +0 -1
- package/v1/examples/logger/byo-logger.js +0 -2
- package/v1/examples/logger/logger.js +0 -1
- package/v1/examples/logging/byo-logger.js +0 -2
- package/v1/examples/logging/logger.js +0 -1
- package/v1/examples/middleware/recipes.js +3 -1
- package/v1/examples/migration-guides/mergent.js +2 -1
- package/v1/examples/multiple_wf_concurrency/run.js +0 -3
- package/v1/examples/non_retryable/run.js +0 -1
- package/v1/examples/on_event/event.js +0 -1
- package/v1/examples/on_failure/run.js +0 -1
- package/v1/examples/on_failure/workflow.js +0 -1
- package/v1/examples/on_success/run.js +0 -1
- package/v1/examples/on_success/workflow.js +0 -1
- package/v1/examples/priority/run.js +0 -1
- package/v1/examples/priority/workflow.js +0 -1
- package/v1/examples/retries/run.js +0 -1
- package/v1/examples/retries/workflow.js +0 -1
- package/v1/examples/simple/bulk.js +0 -1
- package/v1/examples/simple/cron.js +0 -2
- package/v1/examples/simple/delay.js +0 -1
- package/v1/examples/simple/enqueue.js +0 -2
- package/v1/examples/simple/run.js +0 -1
- package/v1/examples/simple/schedule.js +0 -1
- package/v1/examples/simple/workflow-with-child.js +10 -4
- package/v1/examples/sticky/run.js +0 -1
- package/v1/examples/sticky/workflow.js +0 -1
- package/v1/examples/streaming/nextjs-proxy.js +0 -1
- package/v1/examples/streaming/run.js +0 -1
- package/v1/examples/timeout/run.js +0 -1
- package/v1/examples/timeouts/run.js +0 -1
- package/v1/slot-types.js +0 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1ReplayTaskRequest, V1ReplayedTasks, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
|
|
1
|
+
import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1BranchDurableTaskRequest, V1BranchDurableTaskResponse, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1ReplayTaskRequest, V1ReplayedTasks, V1RestoreTaskResponse, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
|
|
2
2
|
import { HttpClient, RequestParams } from './http-client';
|
|
3
3
|
export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
|
4
4
|
/**
|
|
@@ -89,6 +89,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
89
89
|
* @secure
|
|
90
90
|
*/
|
|
91
91
|
v1TaskReplay: (tenant: string, data: V1ReplayTaskRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ReplayedTasks, any, {}>>;
|
|
92
|
+
/**
|
|
93
|
+
* @description Restore an evicted durable task
|
|
94
|
+
*
|
|
95
|
+
* @tags Task
|
|
96
|
+
* @name V1TaskRestore
|
|
97
|
+
* @summary Restore a task
|
|
98
|
+
* @request POST:/api/v1/stable/tasks/{task}/restore
|
|
99
|
+
* @secure
|
|
100
|
+
*/
|
|
101
|
+
v1TaskRestore: (task: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1RestoreTaskResponse, any, {}>>;
|
|
92
102
|
/**
|
|
93
103
|
* @description Lists all tasks that belong a specific list of dags
|
|
94
104
|
*
|
|
@@ -221,6 +231,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
221
231
|
* @secure
|
|
222
232
|
*/
|
|
223
233
|
v1WorkflowRunCreate: (tenant: string, data: V1TriggerWorkflowRunRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1WorkflowRunDetails, any, {}>>;
|
|
234
|
+
/**
|
|
235
|
+
* @description Branch a durable task from a specific node, creating a new branch and re-processing its matches.
|
|
236
|
+
*
|
|
237
|
+
* @tags Workflow Runs
|
|
238
|
+
* @name V1DurableTaskBranch
|
|
239
|
+
* @summary Branch durable task
|
|
240
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/durable-tasks/branch
|
|
241
|
+
* @secure
|
|
242
|
+
*/
|
|
243
|
+
v1DurableTaskBranch: (tenant: string, data: V1BranchDurableTaskRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1BranchDurableTaskResponse, any, {}>>;
|
|
224
244
|
/**
|
|
225
245
|
* @description Get a workflow run and its metadata to display on the "detail" page
|
|
226
246
|
*
|
|
@@ -66,6 +66,16 @@ class Api extends http_client_1.HttpClient {
|
|
|
66
66
|
* @secure
|
|
67
67
|
*/
|
|
68
68
|
this.v1TaskReplay = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/tasks/replay`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
69
|
+
/**
|
|
70
|
+
* @description Restore an evicted durable task
|
|
71
|
+
*
|
|
72
|
+
* @tags Task
|
|
73
|
+
* @name V1TaskRestore
|
|
74
|
+
* @summary Restore a task
|
|
75
|
+
* @request POST:/api/v1/stable/tasks/{task}/restore
|
|
76
|
+
* @secure
|
|
77
|
+
*/
|
|
78
|
+
this.v1TaskRestore = (task, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tasks/${task}/restore`, method: 'POST', secure: true, format: 'json' }, params));
|
|
69
79
|
/**
|
|
70
80
|
* @description Lists all tasks that belong a specific list of dags
|
|
71
81
|
*
|
|
@@ -116,6 +126,16 @@ class Api extends http_client_1.HttpClient {
|
|
|
116
126
|
* @secure
|
|
117
127
|
*/
|
|
118
128
|
this.v1WorkflowRunCreate = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/workflow-runs/trigger`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
129
|
+
/**
|
|
130
|
+
* @description Branch a durable task from a specific node, creating a new branch and re-processing its matches.
|
|
131
|
+
*
|
|
132
|
+
* @tags Workflow Runs
|
|
133
|
+
* @name V1DurableTaskBranch
|
|
134
|
+
* @summary Branch durable task
|
|
135
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/durable-tasks/branch
|
|
136
|
+
* @secure
|
|
137
|
+
*/
|
|
138
|
+
this.v1DurableTaskBranch = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/durable-tasks/branch`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
119
139
|
/**
|
|
120
140
|
* @description Get a workflow run and its metadata to display on the "detail" page
|
|
121
141
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare enum V1TaskRunStatus {
|
|
2
2
|
PENDING = "PENDING",
|
|
3
3
|
RUNNING = "RUNNING",
|
|
4
|
+
EVICTED = "EVICTED",
|
|
4
5
|
COMPLETED = "COMPLETED",
|
|
5
6
|
FAILED = "FAILED",
|
|
6
7
|
CANCELLED = "CANCELLED"
|
|
@@ -239,7 +240,9 @@ export declare enum V1TaskEventType {
|
|
|
239
240
|
CREATED = "CREATED",
|
|
240
241
|
QUEUED = "QUEUED",
|
|
241
242
|
SKIPPED = "SKIPPED",
|
|
242
|
-
COULD_NOT_SEND_TO_WORKER = "COULD_NOT_SEND_TO_WORKER"
|
|
243
|
+
COULD_NOT_SEND_TO_WORKER = "COULD_NOT_SEND_TO_WORKER",
|
|
244
|
+
DURABLE_EVICTED = "DURABLE_EVICTED",
|
|
245
|
+
DURABLE_RESTORING = "DURABLE_RESTORING"
|
|
243
246
|
}
|
|
244
247
|
export declare enum V1WorkflowType {
|
|
245
248
|
DAG = "DAG",
|
|
@@ -248,6 +251,7 @@ export declare enum V1WorkflowType {
|
|
|
248
251
|
export declare enum V1TaskStatus {
|
|
249
252
|
QUEUED = "QUEUED",
|
|
250
253
|
RUNNING = "RUNNING",
|
|
254
|
+
EVICTED = "EVICTED",
|
|
251
255
|
COMPLETED = "COMPLETED",
|
|
252
256
|
CANCELLED = "CANCELLED",
|
|
253
257
|
FAILED = "FAILED"
|
|
@@ -481,6 +485,9 @@ export interface V1ReplayedTasks {
|
|
|
481
485
|
/** The list of task external ids that were replayed */
|
|
482
486
|
ids?: string[];
|
|
483
487
|
}
|
|
488
|
+
export interface V1RestoreTaskResponse {
|
|
489
|
+
requeued: boolean;
|
|
490
|
+
}
|
|
484
491
|
export interface V1DagChildren {
|
|
485
492
|
/** @format uuid */
|
|
486
493
|
dagId?: string;
|
|
@@ -587,6 +594,44 @@ export interface V1WorkflowRunDetails {
|
|
|
587
594
|
tasks: V1TaskSummary[];
|
|
588
595
|
workflowConfig?: object;
|
|
589
596
|
}
|
|
597
|
+
export interface V1BranchDurableTaskRequest {
|
|
598
|
+
/**
|
|
599
|
+
* The external id of the durable task to branch.
|
|
600
|
+
* @format uuid
|
|
601
|
+
* @minLength 36
|
|
602
|
+
* @maxLength 36
|
|
603
|
+
*/
|
|
604
|
+
taskExternalId: string;
|
|
605
|
+
/**
|
|
606
|
+
* The node id to replay from.
|
|
607
|
+
* @format int64
|
|
608
|
+
*/
|
|
609
|
+
nodeId: number;
|
|
610
|
+
/**
|
|
611
|
+
* The branch id to replay from.
|
|
612
|
+
* @format int64
|
|
613
|
+
*/
|
|
614
|
+
branchId: number;
|
|
615
|
+
}
|
|
616
|
+
export interface V1BranchDurableTaskResponse {
|
|
617
|
+
/**
|
|
618
|
+
* The external id of the durable task.
|
|
619
|
+
* @format uuid
|
|
620
|
+
* @minLength 36
|
|
621
|
+
* @maxLength 36
|
|
622
|
+
*/
|
|
623
|
+
taskExternalId: string;
|
|
624
|
+
/**
|
|
625
|
+
* The node id of the new entry.
|
|
626
|
+
* @format int64
|
|
627
|
+
*/
|
|
628
|
+
nodeId: number;
|
|
629
|
+
/**
|
|
630
|
+
* The branch id of the new entry.
|
|
631
|
+
* @format int64
|
|
632
|
+
*/
|
|
633
|
+
branchId: number;
|
|
634
|
+
}
|
|
590
635
|
export interface V1TaskTiming {
|
|
591
636
|
metadata: APIResourceMeta;
|
|
592
637
|
/** The depth of the task in the waterfall. */
|
|
@@ -16,6 +16,7 @@ var V1TaskRunStatus;
|
|
|
16
16
|
(function (V1TaskRunStatus) {
|
|
17
17
|
V1TaskRunStatus["PENDING"] = "PENDING";
|
|
18
18
|
V1TaskRunStatus["RUNNING"] = "RUNNING";
|
|
19
|
+
V1TaskRunStatus["EVICTED"] = "EVICTED";
|
|
19
20
|
V1TaskRunStatus["COMPLETED"] = "COMPLETED";
|
|
20
21
|
V1TaskRunStatus["FAILED"] = "FAILED";
|
|
21
22
|
V1TaskRunStatus["CANCELLED"] = "CANCELLED";
|
|
@@ -293,6 +294,8 @@ var V1TaskEventType;
|
|
|
293
294
|
V1TaskEventType["QUEUED"] = "QUEUED";
|
|
294
295
|
V1TaskEventType["SKIPPED"] = "SKIPPED";
|
|
295
296
|
V1TaskEventType["COULD_NOT_SEND_TO_WORKER"] = "COULD_NOT_SEND_TO_WORKER";
|
|
297
|
+
V1TaskEventType["DURABLE_EVICTED"] = "DURABLE_EVICTED";
|
|
298
|
+
V1TaskEventType["DURABLE_RESTORING"] = "DURABLE_RESTORING";
|
|
296
299
|
})(V1TaskEventType || (exports.V1TaskEventType = V1TaskEventType = {}));
|
|
297
300
|
var V1WorkflowType;
|
|
298
301
|
(function (V1WorkflowType) {
|
|
@@ -303,6 +306,7 @@ var V1TaskStatus;
|
|
|
303
306
|
(function (V1TaskStatus) {
|
|
304
307
|
V1TaskStatus["QUEUED"] = "QUEUED";
|
|
305
308
|
V1TaskStatus["RUNNING"] = "RUNNING";
|
|
309
|
+
V1TaskStatus["EVICTED"] = "EVICTED";
|
|
306
310
|
V1TaskStatus["COMPLETED"] = "COMPLETED";
|
|
307
311
|
V1TaskStatus["CANCELLED"] = "CANCELLED";
|
|
308
312
|
V1TaskStatus["FAILED"] = "FAILED";
|
|
@@ -24,7 +24,6 @@ const workflow = {
|
|
|
24
24
|
name: 'step1',
|
|
25
25
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
const results = [];
|
|
27
|
-
// eslint-disable-next-line no-plusplus
|
|
28
27
|
for (let i = 0; i < 50; i++) {
|
|
29
28
|
const result = yield ctx.spawnWorkflow(childWorkflow.id, {});
|
|
30
29
|
results.push(result.output);
|
|
@@ -12,7 +12,6 @@ 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
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16
15
|
const pino_1 = __importDefault(require("pino"));
|
|
17
16
|
const sdk_1 = __importDefault(require("../../sdk"));
|
|
18
17
|
// > Create Pino logger
|
|
@@ -54,7 +53,6 @@ const hatchet = sdk_1.default.init({
|
|
|
54
53
|
const workflow = hatchet.task({
|
|
55
54
|
name: 'byo-logger-example',
|
|
56
55
|
fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
// eslint-disable-next-line no-plusplus
|
|
58
56
|
for (let i = 0; i < 5; i++) {
|
|
59
57
|
logger.info(`log message ${i}`);
|
|
60
58
|
}
|
|
@@ -33,12 +33,14 @@ const workflow = {
|
|
|
33
33
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
const { data } = ctx.workflowInput();
|
|
35
35
|
const { signal } = ctx.controller;
|
|
36
|
-
if (signal.aborted)
|
|
36
|
+
if (signal.aborted) {
|
|
37
37
|
throw new Error('step1 was aborted');
|
|
38
|
+
}
|
|
38
39
|
console.log('starting step1 and waiting 5 seconds...', data);
|
|
39
40
|
yield sleep(5000);
|
|
40
|
-
if (signal.aborted)
|
|
41
|
+
if (signal.aborted) {
|
|
41
42
|
throw new Error('step1 was aborted');
|
|
43
|
+
}
|
|
42
44
|
// NOTE: the AbortController signal can be passed to many http libraries to cancel active requests
|
|
43
45
|
// fetch(url, { signal })
|
|
44
46
|
// axios.get(url, { signal })
|
|
@@ -36,12 +36,14 @@ const workflow = {
|
|
|
36
36
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
37
|
const { data } = ctx.workflowInput();
|
|
38
38
|
const { signal } = ctx.controller;
|
|
39
|
-
if (signal.aborted)
|
|
39
|
+
if (signal.aborted) {
|
|
40
40
|
throw new Error('step1 was aborted');
|
|
41
|
+
}
|
|
41
42
|
console.log('starting step1 and waiting 5 seconds...', data);
|
|
42
43
|
yield sleep(2000);
|
|
43
|
-
if (signal.aborted)
|
|
44
|
+
if (signal.aborted) {
|
|
44
45
|
throw new Error('step1 was aborted');
|
|
46
|
+
}
|
|
45
47
|
// NOTE: the AbortController signal can be passed to many http libraries to cancel active requests
|
|
46
48
|
// fetch(url, { signal })
|
|
47
49
|
// axios.get(url, { signal })
|
|
@@ -37,12 +37,14 @@ const workflow = {
|
|
|
37
37
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
38
|
const { data } = ctx.workflowInput();
|
|
39
39
|
const { signal } = ctx.controller;
|
|
40
|
-
if (signal.aborted)
|
|
40
|
+
if (signal.aborted) {
|
|
41
41
|
throw new Error('step1 was aborted');
|
|
42
|
+
}
|
|
42
43
|
console.log('starting step1 and waiting 5 seconds...', data);
|
|
43
44
|
yield sleep(2000);
|
|
44
|
-
if (signal.aborted)
|
|
45
|
+
if (signal.aborted) {
|
|
45
46
|
throw new Error('step1 was aborted');
|
|
47
|
+
}
|
|
46
48
|
// NOTE: the AbortController signal can be passed to many http libraries to cancel active requests
|
|
47
49
|
// fetch(url, { signal })
|
|
48
50
|
// axios.get(url, { signal })
|
|
@@ -34,15 +34,12 @@ hatchet.events
|
|
|
34
34
|
return returnedEvent.key === expectedKey;
|
|
35
35
|
});
|
|
36
36
|
if (keysMatch) {
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
37
|
console.log('All keys match the original events.');
|
|
39
38
|
}
|
|
40
39
|
else {
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
40
|
console.log('Mismatch found between original events and returned events.');
|
|
43
41
|
}
|
|
44
42
|
})
|
|
45
43
|
.catch((error) => {
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
44
|
console.error('Error during bulk push:', error);
|
|
48
45
|
});
|
|
@@ -31,7 +31,6 @@ const workflow = {
|
|
|
31
31
|
name: 'logger-step1',
|
|
32
32
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
33
|
// log in a for loop
|
|
34
|
-
// eslint-disable-next-line no-plusplus
|
|
35
34
|
for (let i = 0; i < 10; i++) {
|
|
36
35
|
ctx.logger.info(`log message ${i}`);
|
|
37
36
|
yield sleep(200);
|
|
@@ -25,7 +25,6 @@ const workflow = {
|
|
|
25
25
|
const results = [];
|
|
26
26
|
const count = 57;
|
|
27
27
|
hardChildWorkerId = undefined; // we reset this - if we run this multiple times at the same time it will break
|
|
28
|
-
// eslint-disable-next-line no-plusplus
|
|
29
28
|
for (let i = 0; i < count; i++) {
|
|
30
29
|
const result = yield ctx.spawnWorkflow(childWorkflow, {}, { sticky: true });
|
|
31
30
|
results.push(result.output);
|
|
@@ -24,7 +24,6 @@ const workflow = {
|
|
|
24
24
|
name: 'step1',
|
|
25
25
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
const results = [];
|
|
27
|
-
// eslint-disable-next-line no-plusplus
|
|
28
27
|
for (let i = 0; i < 50; i++) {
|
|
29
28
|
const result = yield ctx.spawnWorkflow(childWorkflow, {}, { sticky: true });
|
|
30
29
|
results.push(result.result());
|
package/legacy/legacy-client.js
CHANGED
|
@@ -76,7 +76,6 @@ function transformLegacyWorkflow(workflow) {
|
|
|
76
76
|
for (const step of workflow.steps) {
|
|
77
77
|
const taskOpts = legacyStepToTaskOpts(step, taskMap, workflow.timeout);
|
|
78
78
|
taskMap[step.name] = taskOpts;
|
|
79
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
80
79
|
declaration.definition._tasks.push(taskOpts);
|
|
81
80
|
}
|
|
82
81
|
// Handle onFailure
|
|
@@ -116,9 +115,7 @@ function wrapLegacyStepRun(step) {
|
|
|
116
115
|
return (input, ctx) => {
|
|
117
116
|
// Access the V1Worker from the ContextWorker's private field.
|
|
118
117
|
// This is intentionally accessing a private field for legacy compatibility.
|
|
119
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
120
118
|
const v1Worker = ctx.worker.worker;
|
|
121
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
122
119
|
const v0ctx = new step_1.V0Context(ctx.action, ctx.v1.v0, v1Worker);
|
|
123
120
|
// Share the abort controller so cancellation propagates
|
|
124
121
|
v0ctx.controller = ctx.controller;
|
|
@@ -129,8 +126,9 @@ function wrapLegacyStepRun(step) {
|
|
|
129
126
|
* Maps legacy rate limits to v1 format.
|
|
130
127
|
*/
|
|
131
128
|
function mapLegacyRateLimits(limits) {
|
|
132
|
-
if (!limits)
|
|
129
|
+
if (!limits) {
|
|
133
130
|
return undefined;
|
|
131
|
+
}
|
|
134
132
|
return limits.map((l) => ({
|
|
135
133
|
staticKey: l.staticKey || l.key,
|
|
136
134
|
dynamicKey: l.dynamicKey,
|
package/legacy/step.d.ts
CHANGED
|
@@ -25,16 +25,16 @@ export declare const CreateRateLimitSchema: z.ZodObject<{
|
|
|
25
25
|
units: string | number;
|
|
26
26
|
key?: string | undefined;
|
|
27
27
|
duration?: RateLimitDuration | undefined;
|
|
28
|
+
limit?: string | number | undefined;
|
|
28
29
|
staticKey?: string | undefined;
|
|
29
30
|
dynamicKey?: string | undefined;
|
|
30
|
-
limit?: string | number | undefined;
|
|
31
31
|
}, {
|
|
32
32
|
units: string | number;
|
|
33
33
|
key?: string | undefined;
|
|
34
34
|
duration?: RateLimitDuration | undefined;
|
|
35
|
+
limit?: string | number | undefined;
|
|
35
36
|
staticKey?: string | undefined;
|
|
36
37
|
dynamicKey?: string | undefined;
|
|
37
|
-
limit?: string | number | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
export declare const DesiredWorkerLabelSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
40
40
|
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
@@ -68,16 +68,16 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
68
68
|
units: string | number;
|
|
69
69
|
key?: string | undefined;
|
|
70
70
|
duration?: RateLimitDuration | undefined;
|
|
71
|
+
limit?: string | number | undefined;
|
|
71
72
|
staticKey?: string | undefined;
|
|
72
73
|
dynamicKey?: string | undefined;
|
|
73
|
-
limit?: string | number | undefined;
|
|
74
74
|
}, {
|
|
75
75
|
units: string | number;
|
|
76
76
|
key?: string | undefined;
|
|
77
77
|
duration?: RateLimitDuration | undefined;
|
|
78
|
+
limit?: string | number | undefined;
|
|
78
79
|
staticKey?: string | undefined;
|
|
79
80
|
dynamicKey?: string | undefined;
|
|
80
|
-
limit?: string | number | undefined;
|
|
81
81
|
}>, "many">>;
|
|
82
82
|
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
83
83
|
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
@@ -110,13 +110,17 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
110
110
|
timeout?: string | undefined;
|
|
111
111
|
parents?: string[] | undefined;
|
|
112
112
|
retries?: number | undefined;
|
|
113
|
+
backoff?: {
|
|
114
|
+
factor?: number | undefined;
|
|
115
|
+
maxSeconds?: number | undefined;
|
|
116
|
+
} | undefined;
|
|
113
117
|
rate_limits?: {
|
|
114
118
|
units: string | number;
|
|
115
119
|
key?: string | undefined;
|
|
116
120
|
duration?: RateLimitDuration | undefined;
|
|
121
|
+
limit?: string | number | undefined;
|
|
117
122
|
staticKey?: string | undefined;
|
|
118
123
|
dynamicKey?: string | undefined;
|
|
119
|
-
limit?: string | number | undefined;
|
|
120
124
|
}[] | undefined;
|
|
121
125
|
worker_labels?: Record<string, string | number | {
|
|
122
126
|
value: string | number;
|
|
@@ -124,22 +128,22 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
124
128
|
comparator?: WorkerLabelComparator | undefined;
|
|
125
129
|
weight?: number | undefined;
|
|
126
130
|
} | undefined> | undefined;
|
|
127
|
-
backoff?: {
|
|
128
|
-
factor?: number | undefined;
|
|
129
|
-
maxSeconds?: number | undefined;
|
|
130
|
-
} | undefined;
|
|
131
131
|
}, {
|
|
132
132
|
name: string;
|
|
133
133
|
timeout?: string | undefined;
|
|
134
134
|
parents?: string[] | undefined;
|
|
135
135
|
retries?: number | undefined;
|
|
136
|
+
backoff?: {
|
|
137
|
+
factor?: number | undefined;
|
|
138
|
+
maxSeconds?: number | undefined;
|
|
139
|
+
} | undefined;
|
|
136
140
|
rate_limits?: {
|
|
137
141
|
units: string | number;
|
|
138
142
|
key?: string | undefined;
|
|
139
143
|
duration?: RateLimitDuration | undefined;
|
|
144
|
+
limit?: string | number | undefined;
|
|
140
145
|
staticKey?: string | undefined;
|
|
141
146
|
dynamicKey?: string | undefined;
|
|
142
|
-
limit?: string | number | undefined;
|
|
143
147
|
}[] | undefined;
|
|
144
148
|
worker_labels?: Record<string, string | number | {
|
|
145
149
|
value: string | number;
|
|
@@ -147,10 +151,6 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
147
151
|
comparator?: WorkerLabelComparator | undefined;
|
|
148
152
|
weight?: number | undefined;
|
|
149
153
|
} | undefined> | undefined;
|
|
150
|
-
backoff?: {
|
|
151
|
-
factor?: number | undefined;
|
|
152
|
-
maxSeconds?: number | undefined;
|
|
153
|
-
} | undefined;
|
|
154
154
|
}>;
|
|
155
155
|
export type NextStep = {
|
|
156
156
|
[key: string]: JsonValue;
|
package/legacy/step.js
CHANGED
|
@@ -47,8 +47,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.V0DurableContext = exports.V0Context = exports.V0ContextWorker = exports.CreateStepSchema = exports.DesiredWorkerLabelSchema = exports.CreateRateLimitSchema = void 0;
|
|
49
49
|
exports.mapRateLimit = mapRateLimit;
|
|
50
|
-
/* eslint-disable no-underscore-dangle */
|
|
51
|
-
/* eslint-disable max-classes-per-file */
|
|
52
50
|
const hatchet_error_1 = __importDefault(require("../util/errors/hatchet-error"));
|
|
53
51
|
const z = __importStar(require("zod"));
|
|
54
52
|
const parse_1 = require("../util/parse");
|
|
@@ -421,7 +419,6 @@ class V0Context {
|
|
|
421
419
|
resp.forEach((ref, index) => {
|
|
422
420
|
const wf = workflows[index].workflow;
|
|
423
421
|
if (wf instanceof declaration_1.TaskWorkflowDeclaration) {
|
|
424
|
-
// eslint-disable-next-line no-param-reassign
|
|
425
422
|
ref._standaloneTaskName = wf._standalone_task_name;
|
|
426
423
|
}
|
|
427
424
|
res.push(ref);
|
|
@@ -472,13 +469,7 @@ class V0Context {
|
|
|
472
469
|
spawnWorkflow(workflow, input, options) {
|
|
473
470
|
return __awaiter(this, void 0, void 0, function* () {
|
|
474
471
|
const { workflowRunId, taskRunExternalId } = this.action;
|
|
475
|
-
|
|
476
|
-
if (typeof workflow === 'string') {
|
|
477
|
-
workflowName = workflow;
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
workflowName = workflow.id;
|
|
481
|
-
}
|
|
472
|
+
const workflowName = typeof workflow === 'string' ? workflow : workflow.id;
|
|
482
473
|
const name = (0, apply_namespace_1.applyNamespace)(workflowName, this.v0.config.namespace);
|
|
483
474
|
const opts = options || {};
|
|
484
475
|
const { sticky } = opts;
|
|
@@ -569,8 +560,7 @@ class V0DurableContext extends V0Context {
|
|
|
569
560
|
*/
|
|
570
561
|
waitFor(conditions) {
|
|
571
562
|
return __awaiter(this, void 0, void 0, function* () {
|
|
572
|
-
const pbConditions = (0, transformer_1.conditionsToPb)((0, conditions_1.Render)(condition_1.Action.CREATE, conditions));
|
|
573
|
-
// eslint-disable-next-line no-plusplus
|
|
563
|
+
const pbConditions = (0, transformer_1.conditionsToPb)((0, conditions_1.Render)(condition_1.Action.CREATE, conditions), this.v0.config.namespace);
|
|
574
564
|
const key = `waitFor-${this.waitKey++}`;
|
|
575
565
|
yield this.v0.durableListener.registerDurableEvent({
|
|
576
566
|
taskId: this.action.taskRunExternalId,
|
|
@@ -592,15 +582,15 @@ class V0DurableContext extends V0Context {
|
|
|
592
582
|
}
|
|
593
583
|
exports.V0DurableContext = V0DurableContext;
|
|
594
584
|
function mapRateLimit(limits) {
|
|
595
|
-
if (!limits)
|
|
585
|
+
if (!limits) {
|
|
596
586
|
return [];
|
|
587
|
+
}
|
|
597
588
|
return limits.map((l) => {
|
|
598
589
|
let key = l.staticKey;
|
|
599
590
|
const keyExpression = l.dynamicKey;
|
|
600
591
|
if (l.key !== undefined) {
|
|
601
|
-
// eslint-disable-next-line no-console
|
|
602
592
|
console.warn('key is deprecated and will be removed in a future release, please use staticKey instead');
|
|
603
|
-
key = l
|
|
593
|
+
({ key } = l);
|
|
604
594
|
}
|
|
605
595
|
if (keyExpression !== undefined) {
|
|
606
596
|
if (key !== undefined) {
|
|
@@ -617,7 +607,7 @@ function mapRateLimit(limits) {
|
|
|
617
607
|
let units;
|
|
618
608
|
let unitsExpression;
|
|
619
609
|
if (typeof l.units === 'number') {
|
|
620
|
-
units = l
|
|
610
|
+
({ units } = l);
|
|
621
611
|
}
|
|
622
612
|
else {
|
|
623
613
|
if (!validateCelExpression(l.units)) {
|