@hatchet-dev/typescript-sdk 1.11.0 → 1.12.1

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.
Files changed (64) hide show
  1. package/clients/admin/admin-client.d.ts +38 -0
  2. package/clients/admin/admin-client.js +19 -6
  3. package/clients/dispatcher/action-listener.d.ts +6 -2
  4. package/clients/dispatcher/action-listener.js +2 -2
  5. package/clients/dispatcher/dispatcher-client.d.ts +22 -3
  6. package/clients/dispatcher/dispatcher-client.js +41 -4
  7. package/clients/event/event-client.d.ts +2 -2
  8. package/clients/event/event-client.js +4 -4
  9. package/clients/hatchet-client/hatchet-logger.js +2 -2
  10. package/clients/rest/generated/Api.d.ts +9 -1
  11. package/clients/rest/generated/data-contracts.d.ts +44 -8
  12. package/clients/rest/generated/data-contracts.js +13 -2
  13. package/clients/worker/worker.js +11 -11
  14. package/examples/webhooks.d.ts +1 -0
  15. package/examples/webhooks.js +45 -0
  16. package/package.json +1 -1
  17. package/protoc/dispatcher/dispatcher.d.ts +70 -25
  18. package/protoc/dispatcher/dispatcher.js +323 -97
  19. package/protoc/events/events.d.ts +4 -4
  20. package/protoc/events/events.js +20 -16
  21. package/protoc/v1/workflows.d.ts +18 -7
  22. package/protoc/v1/workflows.js +122 -2
  23. package/protoc/workflows/workflows.d.ts +22 -22
  24. package/protoc/workflows/workflows.js +18 -18
  25. package/step.d.ts +6 -0
  26. package/step.js +27 -19
  27. package/util/workflow-run-ref.js +1 -1
  28. package/v1/client/admin.d.ts +30 -0
  29. package/v1/client/admin.js +21 -6
  30. package/v1/client/client.d.ts +8 -1
  31. package/v1/client/client.js +13 -2
  32. package/v1/client/features/runs.d.ts +9 -1
  33. package/v1/client/features/runs.js +4 -2
  34. package/v1/client/features/webhooks.d.ts +28 -0
  35. package/v1/client/features/webhooks.js +97 -0
  36. package/v1/client/worker/context.d.ts +6 -0
  37. package/v1/client/worker/context.js +30 -22
  38. package/v1/client/worker/deprecated/deprecation.d.ts +44 -0
  39. package/v1/client/worker/deprecated/deprecation.js +95 -0
  40. package/v1/client/worker/deprecated/index.d.ts +4 -0
  41. package/v1/client/worker/deprecated/index.js +15 -0
  42. package/v1/client/worker/deprecated/legacy-registration.d.ts +18 -0
  43. package/v1/client/worker/deprecated/legacy-registration.js +35 -0
  44. package/v1/client/worker/deprecated/legacy-v1-worker.d.ts +15 -0
  45. package/v1/client/worker/deprecated/legacy-v1-worker.js +39 -0
  46. package/v1/client/worker/deprecated/legacy-worker.d.ts +41 -0
  47. package/v1/client/worker/deprecated/legacy-worker.js +148 -0
  48. package/v1/client/worker/slot-utils.d.ts +21 -0
  49. package/v1/client/worker/slot-utils.js +73 -0
  50. package/v1/client/worker/worker-internal.d.ts +16 -5
  51. package/v1/client/worker/worker-internal.js +54 -37
  52. package/v1/client/worker/worker.d.ts +12 -15
  53. package/v1/client/worker/worker.js +45 -49
  54. package/v1/declaration.js +1 -1
  55. package/v1/index.d.ts +1 -0
  56. package/v1/index.js +1 -0
  57. package/v1/parent-run-context-vars.d.ts +4 -1
  58. package/v1/parent-run-context-vars.js +1 -0
  59. package/v1/slot-types.d.ts +5 -0
  60. package/v1/slot-types.js +9 -0
  61. package/v1/task.d.ts +2 -0
  62. package/version.d.ts +1 -1
  63. package/version.js +1 -1
  64. package/workflow.d.ts +2 -2
@@ -19,6 +19,16 @@ export type WorkflowRun<T = object> = {
19
19
  input: T;
20
20
  options?: {
21
21
  parentId?: string | undefined;
22
+ /**
23
+ * (optional) the parent task external run id.
24
+ *
25
+ * This is the field understood by the workflows gRPC API.
26
+ */
27
+ parentTaskRunExternalId?: string | undefined;
28
+ /**
29
+ * @deprecated Use `parentTaskRunExternalId` instead.
30
+ * Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
31
+ */
22
32
  parentStepRunId?: string | undefined;
23
33
  childIndex?: number | undefined;
24
34
  childKey?: string | undefined;
@@ -65,6 +75,14 @@ export declare class AdminClient {
65
75
  */
66
76
  run_workflow<T = object>(workflowName: string, input: T, options?: {
67
77
  parentId?: string | undefined;
78
+ /**
79
+ * (optional) the parent task external run id.
80
+ */
81
+ parentTaskRunExternalId?: string | undefined;
82
+ /**
83
+ * @deprecated Use `parentTaskRunExternalId` instead.
84
+ * Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
85
+ */
68
86
  parentStepRunId?: string | undefined;
69
87
  childIndex?: number | undefined;
70
88
  childKey?: string | undefined;
@@ -80,6 +98,16 @@ export declare class AdminClient {
80
98
  */
81
99
  runWorkflow<Q = object, P = object>(workflowName: string, input: Q, options?: {
82
100
  parentId?: string | undefined;
101
+ /**
102
+ * (optional) the parent task external run id.
103
+ *
104
+ * This is the field understood by the workflows gRPC API.
105
+ */
106
+ parentTaskRunExternalId?: string | undefined;
107
+ /**
108
+ * @deprecated Use `parentTaskRunExternalId` instead.
109
+ * Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
110
+ */
83
111
  parentStepRunId?: string | undefined;
84
112
  childIndex?: number | undefined;
85
113
  childKey?: string | undefined;
@@ -98,6 +126,16 @@ export declare class AdminClient {
98
126
  input: Q;
99
127
  options?: {
100
128
  parentId?: string | undefined;
129
+ /**
130
+ * (optional) the parent task external run id.
131
+ *
132
+ * This is the field understood by the workflows gRPC API.
133
+ */
134
+ parentTaskRunExternalId?: string | undefined;
135
+ /**
136
+ * @deprecated Use `parentTaskRunExternalId` instead.
137
+ * Kept for backward compatibility; will be mapped to `parentTaskRunExternalId`.
138
+ */
101
139
  parentStepRunId?: string | undefined;
102
140
  childIndex?: number | undefined;
103
141
  childKey?: string | undefined;
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
@@ -120,9 +131,11 @@ class AdminClient {
120
131
  const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace);
121
132
  try {
122
133
  const inputStr = JSON.stringify(input);
123
- const resp = this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
124
- ? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
125
- : undefined, priority: options === null || options === void 0 ? void 0 : options.priority }));
134
+ const opts = options !== null && options !== void 0 ? options : {};
135
+ const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
136
+ const resp = this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), {
137
+ // API expects `parentTaskRunExternalId`; accept the old name as an alias.
138
+ parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, priority: opts.priority }));
126
139
  return new workflow_run_ref_1.default(resp, this.listenerClient, this.workflows, options === null || options === void 0 ? void 0 : options.parentId);
127
140
  }
128
141
  catch (e) {
@@ -140,9 +153,9 @@ class AdminClient {
140
153
  const workflowRequests = workflowRuns.map(({ workflowName, input, options }) => {
141
154
  const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace);
142
155
  const inputStr = JSON.stringify(input);
143
- return Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
144
- ? JSON.stringify(options.additionalMetadata)
145
- : undefined });
156
+ const opts = options !== null && options !== void 0 ? options : {};
157
+ const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
158
+ return Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), { parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined });
146
159
  });
147
160
  try {
148
161
  // Call the bulk trigger workflow method
@@ -7,8 +7,12 @@ declare enum ListenStrategy {
7
7
  LISTEN_STRATEGY_V1 = 1,
8
8
  LISTEN_STRATEGY_V2 = 2
9
9
  }
10
- export interface Action extends AssignedAction {
11
- }
10
+ export type Action = AssignedAction & {
11
+ /** @deprecated use taskRunId */
12
+ stepRunId?: string;
13
+ /** @deprecated use taskId */
14
+ stepId?: string;
15
+ };
12
16
  export type ActionKey = string;
13
17
  export declare function createActionKey(action: Action): ActionKey;
14
18
  export declare class ActionListener {
@@ -55,7 +55,7 @@ function createActionKey(action) {
55
55
  case dispatcher_1.ActionType.CANCEL_STEP_RUN:
56
56
  case dispatcher_1.ActionType.START_STEP_RUN:
57
57
  case dispatcher_1.ActionType.UNRECOGNIZED:
58
- return `${action.stepRunId}/${action.retryCount}`;
58
+ return `${action.taskRunExternalId}/${action.retryCount}`;
59
59
  default:
60
60
  // eslint-disable-next-line no-case-declarations
61
61
  const exhaustivenessCheck = action.actionType;
@@ -84,7 +84,7 @@ class ActionListener {
84
84
  _c = listenClient_1_1.value;
85
85
  _d = false;
86
86
  const assignedAction = _c;
87
- const action = Object.assign({}, assignedAction);
87
+ const action = Object.assign(Object.assign({}, assignedAction), { stepRunId: assignedAction.taskRunExternalId, stepId: assignedAction.taskId });
88
88
  yield yield __await(action);
89
89
  }
90
90
  }
@@ -1,16 +1,29 @@
1
1
  import { Channel, ClientFactory } from 'nice-grpc';
2
- import { DispatcherClient as PbDispatcherClient, StepActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, RuntimeInfo } from '../../protoc/dispatcher';
2
+ import { DispatcherClient as PbDispatcherClient, StepActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, WorkerLabels as PbWorkerAffinityConfig, RuntimeInfo } from '../../protoc/dispatcher';
3
3
  import { ClientConfig } from '../hatchet-client/client-config';
4
4
  import { Logger } from '../../util/logger';
5
+ import { SlotConfig } from '../../v1/slot-types';
5
6
  import { ActionListener } from './action-listener';
6
7
  export type WorkerLabels = Record<string, string | number | undefined>;
7
8
  interface GetActionListenerOptions {
8
9
  workerName: string;
9
10
  services: string[];
10
11
  actions: string[];
12
+ slotConfig?: SlotConfig;
13
+ /** @deprecated use slotConfig */
14
+ slots?: number;
15
+ /** @deprecated use slotConfig */
16
+ durableSlots?: number;
17
+ /** @deprecated use slots */
11
18
  maxRuns?: number;
12
19
  labels: Record<string, string | number | undefined>;
13
20
  }
21
+ type StepActionEventInput = StepActionEvent & {
22
+ /** @deprecated use taskId */
23
+ stepId?: string;
24
+ /** @deprecated use taskRunId */
25
+ stepRunId?: string;
26
+ };
14
27
  export declare class DispatcherClient {
15
28
  config: ClientConfig;
16
29
  client: PbDispatcherClient;
@@ -18,10 +31,16 @@ export declare class DispatcherClient {
18
31
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
19
32
  getRuntimeInfo(): RuntimeInfo;
20
33
  getActionListener(options: GetActionListenerOptions): Promise<ActionListener>;
21
- sendStepActionEvent(in_: StepActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
34
+ /**
35
+ * Calls the GetVersion RPC. Returns the engine semantic version string.
36
+ * Throws a gRPC error with code UNIMPLEMENTED on older engines.
37
+ */
38
+ getVersion(): Promise<string>;
39
+ sendStepActionEvent(in_: StepActionEventInput): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
22
40
  sendGroupKeyActionEvent(in_: GroupKeyActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
23
41
  putOverridesData(in_: DeepPartial<OverridesData>): Promise<void | import("../../protoc/dispatcher").OverridesDataResponse>;
24
- refreshTimeout(incrementTimeoutBy: string, stepRunId: string): Promise<import("../../protoc/dispatcher").RefreshTimeoutResponse>;
42
+ refreshTimeout(incrementTimeoutBy: string, taskRunExternalId: string): Promise<import("../../protoc/dispatcher").RefreshTimeoutResponse>;
25
43
  upsertWorkerLabels(workerId: string, labels: WorkerLabels): Promise<import("../../protoc/dispatcher").UpsertWorkerLabelsResponse>;
26
44
  }
45
+ export declare function mapLabels(in_: WorkerLabels): Record<string, PbWorkerAffinityConfig>;
27
46
  export {};
@@ -8,15 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
14
25
  Object.defineProperty(exports, "__esModule", { value: true });
15
26
  exports.DispatcherClient = void 0;
27
+ exports.mapLabels = mapLabels;
16
28
  const dispatcher_1 = require("../../protoc/dispatcher");
17
29
  const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
18
30
  const retrier_1 = require("../../util/retrier");
19
31
  const version_1 = require("../../version");
32
+ const slot_types_1 = require("../../v1/slot-types");
20
33
  const action_listener_1 = require("./action-listener");
21
34
  class DispatcherClient {
22
35
  constructor(config, channel, factory) {
@@ -35,14 +48,38 @@ class DispatcherClient {
35
48
  getActionListener(options) {
36
49
  return __awaiter(this, void 0, void 0, function* () {
37
50
  // Register the worker
38
- const registration = yield this.client.register(Object.assign(Object.assign({}, options), { labels: options.labels ? mapLabels(options.labels) : undefined, runtimeInfo: this.getRuntimeInfo() }));
51
+ const slotConfig = options.slotConfig ||
52
+ (options.slots || options.durableSlots || options.maxRuns
53
+ ? Object.assign(Object.assign({}, (options.slots || options.maxRuns
54
+ ? { [slot_types_1.SlotType.Default]: options.slots || options.maxRuns || 0 }
55
+ : {})), (options.durableSlots ? { [slot_types_1.SlotType.Durable]: options.durableSlots } : {})) : undefined);
56
+ const registration = yield this.client.register({
57
+ workerName: options.workerName,
58
+ services: options.services,
59
+ actions: options.actions,
60
+ slotConfig,
61
+ labels: options.labels ? mapLabels(options.labels) : undefined,
62
+ runtimeInfo: this.getRuntimeInfo(),
63
+ });
39
64
  return new action_listener_1.ActionListener(this, registration.workerId);
40
65
  });
41
66
  }
67
+ /**
68
+ * Calls the GetVersion RPC. Returns the engine semantic version string.
69
+ * Throws a gRPC error with code UNIMPLEMENTED on older engines.
70
+ */
71
+ getVersion() {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const response = yield this.client.getVersion({});
74
+ return response.version;
75
+ });
76
+ }
42
77
  sendStepActionEvent(in_) {
43
78
  return __awaiter(this, void 0, void 0, function* () {
79
+ const { taskId, taskRunExternalId } = in_, rest = __rest(in_, ["taskId", "taskRunExternalId"]);
80
+ const event = Object.assign(Object.assign({}, rest), { taskId: taskId !== null && taskId !== void 0 ? taskId : '', taskRunExternalId: taskRunExternalId !== null && taskRunExternalId !== void 0 ? taskRunExternalId : '' });
44
81
  try {
45
- return yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.client.sendStepActionEvent(in_); }), this.logger);
82
+ return yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.client.sendStepActionEvent(event); }), this.logger);
46
83
  }
47
84
  catch (e) {
48
85
  throw new hatchet_error_1.default(e.message);
@@ -66,11 +103,11 @@ class DispatcherClient {
66
103
  });
67
104
  });
68
105
  }
69
- refreshTimeout(incrementTimeoutBy, stepRunId) {
106
+ refreshTimeout(incrementTimeoutBy, taskRunExternalId) {
70
107
  return __awaiter(this, void 0, void 0, function* () {
71
108
  try {
72
109
  return this.client.refreshTimeout({
73
- stepRunId,
110
+ taskRunExternalId,
74
111
  incrementTimeoutBy,
75
112
  });
76
113
  }
@@ -32,7 +32,7 @@ export declare class EventClient {
32
32
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory, hatchetClient: LegacyHatchetClient);
33
33
  push<T>(type: string, input: T, options?: PushEventOptions): Promise<import("../../protoc/events/events").Event>;
34
34
  bulkPush<T>(type: string, inputs: EventWithMetadata<T>[], options?: PushEventOptions): Promise<import("../../protoc/events/events").Events>;
35
- putLog(stepRunId: string, log: string, level?: LogLevel, taskRetryCount?: number, metadata?: Record<string, any>): Promise<void>;
36
- putStream(stepRunId: string, data: string | Uint8Array, index: number | undefined): Promise<void>;
35
+ putLog(taskRunExternalId: string, log: string, level?: LogLevel, taskRetryCount?: number, metadata?: Record<string, any>): Promise<void>;
36
+ putStream(taskRunExternalId: string, data: string | Uint8Array, index: number | undefined): Promise<void>;
37
37
  list(opts?: Parameters<typeof this.api.v1EventList>[1]): Promise<import("../rest/generated/data-contracts").V1EventList>;
38
38
  }
@@ -87,7 +87,7 @@ class EventClient {
87
87
  throw new hatchet_error_1.default(e.message);
88
88
  }
89
89
  }
90
- putLog(stepRunId, log, level, taskRetryCount, metadata) {
90
+ putLog(taskRunExternalId, log, level, taskRetryCount, metadata) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
92
  const createdAt = new Date();
93
93
  if (log.length > 1000) {
@@ -97,7 +97,7 @@ class EventClient {
97
97
  // fire and forget the log
98
98
  yield this.client
99
99
  .putLog({
100
- stepRunId,
100
+ taskRunExternalId,
101
101
  createdAt,
102
102
  message: log,
103
103
  level: level || LogLevel.INFO,
@@ -110,7 +110,7 @@ class EventClient {
110
110
  });
111
111
  });
112
112
  }
113
- putStream(stepRunId, data, index) {
113
+ putStream(taskRunExternalId, data, index) {
114
114
  return __awaiter(this, void 0, void 0, function* () {
115
115
  const createdAt = new Date();
116
116
  let dataBytes;
@@ -125,7 +125,7 @@ class EventClient {
125
125
  }
126
126
  (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () {
127
127
  return this.client.putStreamEvent({
128
- stepRunId,
128
+ taskRunExternalId,
129
129
  createdAt,
130
130
  message: dataBytes,
131
131
  eventIndex: index,
@@ -64,12 +64,12 @@ class HatchetLogger {
64
64
  }
65
65
  warn(message, error) {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
- yield this.log('WARN', `${message} ${error}`, '93');
67
+ yield this.log('WARN', error ? `${message} ${error}` : message, '93');
68
68
  });
69
69
  }
70
70
  error(message, error) {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
- yield this.log('ERROR', `${message} ${error}`, '91');
72
+ yield this.log('ERROR', error ? `${message} ${error}` : message, '91');
73
73
  });
74
74
  }
75
75
  util(key, message, extra) {
@@ -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, V1LogLineList, V1ReplayTaskRequest, V1ReplayedTasks, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, 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, 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, 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
  /**
@@ -60,6 +60,14 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
60
60
  * @format date-time
61
61
  */
62
62
  until?: string;
63
+ /** A full-text search query to filter for */
64
+ search?: string;
65
+ /** The log level(s) to include */
66
+ levels?: V1LogLineLevel[];
67
+ /** The direction to order by */
68
+ order_by_direction?: V1LogLineOrderByDirection;
69
+ /** The attempt number to filter for */
70
+ attempt?: number;
63
71
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1LogLineList, any, {}>>;
64
72
  /**
65
73
  * @description Cancel tasks
@@ -17,7 +17,8 @@ export declare enum WebhookWorkerRequestMethod {
17
17
  export declare enum WorkerRuntimeSDKs {
18
18
  GOLANG = "GOLANG",
19
19
  PYTHON = "PYTHON",
20
- TYPESCRIPT = "TYPESCRIPT"
20
+ TYPESCRIPT = "TYPESCRIPT",
21
+ RUBY = "RUBY"
21
22
  }
22
23
  export declare enum WorkerType {
23
24
  SELFHOSTED = "SELFHOSTED",
@@ -91,6 +92,10 @@ export declare enum StepRunStatus {
91
92
  CANCELLING = "CANCELLING",
92
93
  BACKOFF = "BACKOFF"
93
94
  }
95
+ export declare enum ConcurrencyScope {
96
+ WORKFLOW = "WORKFLOW",
97
+ TASK = "TASK"
98
+ }
94
99
  export declare enum ConcurrencyLimitStrategy {
95
100
  CANCEL_IN_PROGRESS = "CANCEL_IN_PROGRESS",
96
101
  DROP_NEWEST = "DROP_NEWEST",
@@ -160,7 +165,6 @@ export declare enum TenantResource {
160
165
  WORKER = "WORKER",
161
166
  WORKER_SLOT = "WORKER_SLOT",
162
167
  EVENT = "EVENT",
163
- WORKFLOW_RUN = "WORKFLOW_RUN",
164
168
  TASK_RUN = "TASK_RUN",
165
169
  CRON = "CRON",
166
170
  SCHEDULE = "SCHEDULE",
@@ -192,7 +196,8 @@ export declare enum V1WebhookSourceName {
192
196
  GITHUB = "GITHUB",
193
197
  STRIPE = "STRIPE",
194
198
  SLACK = "SLACK",
195
- LINEAR = "LINEAR"
199
+ LINEAR = "LINEAR",
200
+ SVIX = "SVIX"
196
201
  }
197
202
  export declare enum TenantEnvironment {
198
203
  Local = "local",
@@ -203,6 +208,10 @@ export declare enum TenantVersion {
203
208
  V0 = "V0",
204
209
  V1 = "V1"
205
210
  }
211
+ export declare enum V1LogLineOrderByDirection {
212
+ ASC = "ASC",
213
+ DESC = "DESC"
214
+ }
206
215
  export declare enum V1LogLineLevel {
207
216
  DEBUG = "DEBUG",
208
217
  INFO = "INFO",
@@ -870,7 +879,7 @@ export type V1CreateWebhookRequestHMAC = V1CreateWebhookRequestBase & {
870
879
  export type V1CreateWebhookRequest = V1CreateWebhookRequestBasicAuth | V1CreateWebhookRequestAPIKey | V1CreateWebhookRequestHMAC;
871
880
  export interface V1UpdateWebhookRequest {
872
881
  /** The CEL expression to use for the event key. This is used to create the event key from the webhook payload. */
873
- eventKeyExpression: string;
882
+ eventKeyExpression?: string;
874
883
  /** The CEL expression to use for the scope. This is used to filter the correct workflow to trigger. */
875
884
  scopeExpression?: string;
876
885
  /** The static payload to use for the webhook. This is used to send a static payload with the webhook. */
@@ -1392,6 +1401,10 @@ export interface Step {
1392
1401
  action: string;
1393
1402
  /** The timeout of the step. */
1394
1403
  timeout?: string;
1404
+ /** Whether the step is durable. */
1405
+ isDurable?: boolean;
1406
+ /** Slot requests for the step (slot_type -> units). */
1407
+ slotRequests?: Record<string, number>;
1395
1408
  children?: string[];
1396
1409
  parents?: string[];
1397
1410
  }
@@ -1598,6 +1611,21 @@ export interface WorkflowTriggers {
1598
1611
  events?: WorkflowTriggerEventRef[];
1599
1612
  crons?: WorkflowTriggerCronRef[];
1600
1613
  }
1614
+ export interface ConcurrencySetting {
1615
+ /**
1616
+ * The maximum number of concurrent workflow runs.
1617
+ * @format int32
1618
+ */
1619
+ maxRuns: number;
1620
+ /** The strategy to use when the concurrency limit is reached. */
1621
+ limitStrategy: ConcurrencyLimitStrategy;
1622
+ /** The concurrency expression, used to generate a key from task inputs, metadata, etc. */
1623
+ expression: string;
1624
+ /** The readable id of the step to which this concurrency setting applies. */
1625
+ stepReadableId?: string;
1626
+ /** The scope of the concurrency setting. */
1627
+ scope: ConcurrencyScope;
1628
+ }
1601
1629
  export interface WorkflowVersion {
1602
1630
  metadata: APIResourceMeta;
1603
1631
  /** The version of the workflow. */
@@ -1618,6 +1646,9 @@ export interface WorkflowVersion {
1618
1646
  scheduleTimeout?: string;
1619
1647
  jobs?: Job[];
1620
1648
  workflowConfig?: object;
1649
+ v1Concurrency?: ConcurrencySetting[];
1650
+ /** The JSON schema for the workflow input. */
1651
+ inputJsonSchema?: object;
1621
1652
  }
1622
1653
  export interface TriggerWorkflowRunRequest {
1623
1654
  input: object;
@@ -1900,6 +1931,13 @@ export interface RecentStepRuns {
1900
1931
  /** @format uuid */
1901
1932
  workflowRunId: string;
1902
1933
  }
1934
+ /** Slot availability and limits for a slot type. */
1935
+ export interface WorkerSlotConfig {
1936
+ /** The number of available units for this slot type. */
1937
+ available?: number;
1938
+ /** The maximum number of units for this slot type. */
1939
+ limit: number;
1940
+ }
1903
1941
  export interface WorkerLabel {
1904
1942
  metadata: APIResourceMeta;
1905
1943
  /** The key of the label. */
@@ -1941,10 +1979,8 @@ export interface Worker {
1941
1979
  recentStepRuns?: RecentStepRuns[];
1942
1980
  /** The status of the worker. */
1943
1981
  status?: 'ACTIVE' | 'INACTIVE' | 'PAUSED';
1944
- /** The maximum number of runs this worker can execute concurrently. */
1945
- maxRuns?: number;
1946
- /** The number of runs this worker can execute concurrently. */
1947
- availableRuns?: number;
1982
+ /** Slot availability and limits for this worker (slot_type -> { available, limit }). */
1983
+ slotConfig?: Record<string, WorkerSlotConfig>;
1948
1984
  /**
1949
1985
  * the id of the assigned dispatcher, in UUID format
1950
1986
  * @format uuid
@@ -11,7 +11,7 @@
11
11
  * ---------------------------------------------------------------
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.V1TaskStatus = exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.StepRunStatus = exports.JobRunStatus = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.PullRequestState = exports.V1TaskRunStatus = void 0;
14
+ exports.V1TaskStatus = exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.V1LogLineOrderByDirection = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.ConcurrencyScope = exports.StepRunStatus = exports.JobRunStatus = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.PullRequestState = exports.V1TaskRunStatus = void 0;
15
15
  var V1TaskRunStatus;
16
16
  (function (V1TaskRunStatus) {
17
17
  V1TaskRunStatus["PENDING"] = "PENDING";
@@ -36,6 +36,7 @@ var WorkerRuntimeSDKs;
36
36
  WorkerRuntimeSDKs["GOLANG"] = "GOLANG";
37
37
  WorkerRuntimeSDKs["PYTHON"] = "PYTHON";
38
38
  WorkerRuntimeSDKs["TYPESCRIPT"] = "TYPESCRIPT";
39
+ WorkerRuntimeSDKs["RUBY"] = "RUBY";
39
40
  })(WorkerRuntimeSDKs || (exports.WorkerRuntimeSDKs = WorkerRuntimeSDKs = {}));
40
41
  var WorkerType;
41
42
  (function (WorkerType) {
@@ -119,6 +120,11 @@ var StepRunStatus;
119
120
  StepRunStatus["CANCELLING"] = "CANCELLING";
120
121
  StepRunStatus["BACKOFF"] = "BACKOFF";
121
122
  })(StepRunStatus || (exports.StepRunStatus = StepRunStatus = {}));
123
+ var ConcurrencyScope;
124
+ (function (ConcurrencyScope) {
125
+ ConcurrencyScope["WORKFLOW"] = "WORKFLOW";
126
+ ConcurrencyScope["TASK"] = "TASK";
127
+ })(ConcurrencyScope || (exports.ConcurrencyScope = ConcurrencyScope = {}));
122
128
  var ConcurrencyLimitStrategy;
123
129
  (function (ConcurrencyLimitStrategy) {
124
130
  ConcurrencyLimitStrategy["CANCEL_IN_PROGRESS"] = "CANCEL_IN_PROGRESS";
@@ -202,7 +208,6 @@ var TenantResource;
202
208
  TenantResource["WORKER"] = "WORKER";
203
209
  TenantResource["WORKER_SLOT"] = "WORKER_SLOT";
204
210
  TenantResource["EVENT"] = "EVENT";
205
- TenantResource["WORKFLOW_RUN"] = "WORKFLOW_RUN";
206
211
  TenantResource["TASK_RUN"] = "TASK_RUN";
207
212
  TenantResource["CRON"] = "CRON";
208
213
  TenantResource["SCHEDULE"] = "SCHEDULE";
@@ -240,6 +245,7 @@ var V1WebhookSourceName;
240
245
  V1WebhookSourceName["STRIPE"] = "STRIPE";
241
246
  V1WebhookSourceName["SLACK"] = "SLACK";
242
247
  V1WebhookSourceName["LINEAR"] = "LINEAR";
248
+ V1WebhookSourceName["SVIX"] = "SVIX";
243
249
  })(V1WebhookSourceName || (exports.V1WebhookSourceName = V1WebhookSourceName = {}));
244
250
  var TenantEnvironment;
245
251
  (function (TenantEnvironment) {
@@ -252,6 +258,11 @@ var TenantVersion;
252
258
  TenantVersion["V0"] = "V0";
253
259
  TenantVersion["V1"] = "V1";
254
260
  })(TenantVersion || (exports.TenantVersion = TenantVersion = {}));
261
+ var V1LogLineOrderByDirection;
262
+ (function (V1LogLineOrderByDirection) {
263
+ V1LogLineOrderByDirection["ASC"] = "ASC";
264
+ V1LogLineOrderByDirection["DESC"] = "DESC";
265
+ })(V1LogLineOrderByDirection || (exports.V1LogLineOrderByDirection = V1LogLineOrderByDirection = {}));
255
266
  var V1LogLineLevel;
256
267
  (function (V1LogLineLevel) {
257
268
  V1LogLineLevel["DEBUG"] = "DEBUG";
@@ -187,7 +187,7 @@ class V0Worker {
187
187
  return step(context);
188
188
  });
189
189
  const success = (result) => __awaiter(this, void 0, void 0, function* () {
190
- this.logger.info(`Task run ${action.stepRunId} succeeded`);
190
+ this.logger.info(`Task run ${action.taskRunExternalId} succeeded`);
191
191
  try {
192
192
  // Send the action event to the dispatcher
193
193
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
@@ -212,7 +212,7 @@ class V0Worker {
212
212
  }
213
213
  });
214
214
  const failure = (error) => __awaiter(this, void 0, void 0, function* () {
215
- this.logger.error(`Task run ${action.stepRunId} failed: ${error.message}`);
215
+ this.logger.error(`Task run ${action.taskRunExternalId} failed: ${error.message}`);
216
216
  if (error.stack) {
217
217
  this.logger.error(error.stack);
218
218
  }
@@ -257,10 +257,10 @@ class V0Worker {
257
257
  catch (e) {
258
258
  const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
259
259
  if (message.includes('Cancelled')) {
260
- this.logger.debug(`Task run ${action.stepRunId} was cancelled`);
260
+ this.logger.debug(`Task run ${action.taskRunExternalId} was cancelled`);
261
261
  }
262
262
  else {
263
- this.logger.error(`Could not wait for task run ${action.stepRunId} to finish. ` +
263
+ this.logger.error(`Could not wait for task run ${action.taskRunExternalId} to finish. ` +
264
264
  `See https://docs.hatchet.run/home/cancellation for best practices on handling cancellation: `, e);
265
265
  }
266
266
  }
@@ -291,7 +291,7 @@ class V0Worker {
291
291
  return step(context);
292
292
  });
293
293
  const success = (result) => {
294
- this.logger.info(`Task run ${action.stepRunId} succeeded`);
294
+ this.logger.info(`Task run ${action.taskRunExternalId} succeeded`);
295
295
  try {
296
296
  // Send the action event to the dispatcher
297
297
  const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
@@ -345,8 +345,8 @@ class V0Worker {
345
345
  workerId: this.name,
346
346
  jobId: action.jobId,
347
347
  jobRunId: action.jobRunId,
348
- stepId: action.stepId,
349
- stepRunId: action.stepRunId,
348
+ taskId: action.taskId,
349
+ taskRunExternalId: action.taskRunExternalId,
350
350
  actionId: action.actionId,
351
351
  eventTimestamp: new Date(),
352
352
  eventType,
@@ -371,9 +371,9 @@ class V0Worker {
371
371
  }
372
372
  handleCancelStepRun(action) {
373
373
  return __awaiter(this, void 0, void 0, function* () {
374
- const { stepRunId } = action;
374
+ const { taskRunExternalId } = action;
375
375
  try {
376
- this.logger.info(`Cancelling task run ${action.stepRunId}`);
376
+ this.logger.info(`Cancelling task run ${action.taskRunExternalId}`);
377
377
  const future = this.futures[(0, action_listener_1.createActionKey)(action)];
378
378
  const context = this.contexts[(0, action_listener_1.createActionKey)(action)];
379
379
  if (context && context.controller) {
@@ -381,7 +381,7 @@ class V0Worker {
381
381
  }
382
382
  if (future) {
383
383
  future.promise.catch(() => {
384
- this.logger.info(`Cancelled task run ${action.stepRunId}`);
384
+ this.logger.info(`Cancelled task run ${action.taskRunExternalId}`);
385
385
  });
386
386
  future.cancel('Cancelled by worker');
387
387
  yield future.promise;
@@ -389,7 +389,7 @@ class V0Worker {
389
389
  }
390
390
  catch (e) {
391
391
  // Expected: the promise rejects when cancelled
392
- this.logger.debug(`Task run ${stepRunId} cancellation completed`);
392
+ this.logger.debug(`Task run ${taskRunExternalId} cancellation completed`);
393
393
  }
394
394
  finally {
395
395
  delete this.futures[(0, action_listener_1.createActionKey)(action)];
@@ -0,0 +1 @@
1
+ export {};