@hatchet-dev/typescript-sdk 1.14.0 → 1.15.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 (40) hide show
  1. package/clients/admin/admin-client.d.ts +9 -1
  2. package/clients/admin/admin-client.js +20 -4
  3. package/legacy/step.d.ts +12 -12
  4. package/legacy/workflow.d.ts +36 -36
  5. package/package.json +4 -3
  6. package/protoc/v1/workflows.d.ts +8 -0
  7. package/protoc/v1/workflows.js +109 -2
  8. package/protoc/workflows/workflows.d.ts +9 -0
  9. package/protoc/workflows/workflows.js +109 -2
  10. package/v1/client/admin.d.ts +10 -1
  11. package/v1/client/admin.js +20 -4
  12. package/v1/client/client.d.ts +19 -1
  13. package/v1/client/client.js +19 -1
  14. package/v1/client/features/crons.d.ts +3 -1
  15. package/v1/client/features/crons.js +2 -1
  16. package/v1/client/features/filters.d.ts +30 -0
  17. package/v1/client/features/filters.js +30 -0
  18. package/v1/client/features/metrics.d.ts +10 -6
  19. package/v1/client/features/metrics.js +10 -6
  20. package/v1/client/features/ratelimits.d.ts +11 -1
  21. package/v1/client/features/ratelimits.js +11 -1
  22. package/v1/client/features/runs.d.ts +36 -1
  23. package/v1/client/features/runs.js +36 -1
  24. package/v1/client/features/schedules.d.ts +4 -1
  25. package/v1/client/features/schedules.js +3 -1
  26. package/v1/client/features/tenant.d.ts +3 -0
  27. package/v1/client/features/webhooks.d.ts +30 -4
  28. package/v1/client/features/webhooks.js +30 -4
  29. package/v1/client/features/workers.d.ts +25 -1
  30. package/v1/client/features/workers.js +25 -1
  31. package/v1/client/features/workflows.d.ts +19 -1
  32. package/v1/client/features/workflows.js +19 -1
  33. package/v1/client/worker/context.d.ts +21 -0
  34. package/v1/client/worker/context.js +21 -0
  35. package/v1/declaration.d.ts +89 -5
  36. package/v1/declaration.js +62 -4
  37. package/v1/examples/runtime_affinity/workflow.d.ts +3 -0
  38. package/v1/examples/runtime_affinity/workflow.js +19 -0
  39. package/version.d.ts +1 -1
  40. package/version.js +1 -1
@@ -5,7 +5,7 @@
5
5
  // protoc v3.19.1
6
6
  // source: v1/workflows.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.AdminServiceDefinition = exports.GetRunDetailsResponse_TaskRunsEntry = exports.GetRunDetailsResponse = exports.TaskRunDetail = exports.GetRunDetailsRequest = exports.CreateWorkflowVersionResponse = exports.CreateTaskRateLimit = exports.CreateTaskOpts_SlotRequestsEntry = exports.CreateTaskOpts_WorkerLabelsEntry = exports.CreateTaskOpts = exports.DesiredWorkerLabels = exports.Concurrency = exports.DefaultFilter = exports.CreateWorkflowVersionRequest = exports.TriggerWorkflowRunResponse = exports.TriggerWorkflowRunRequest = exports.ReplayTasksResponse = exports.CancelTasksResponse = exports.TasksFilter = exports.ReplayTasksRequest = exports.CancelTasksRequest = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.RunStatus = exports.RateLimitDuration = exports.StickyStrategy = exports.protobufPackage = void 0;
8
+ exports.AdminServiceDefinition = exports.GetRunDetailsResponse_TaskRunsEntry = exports.GetRunDetailsResponse = exports.TaskRunDetail = exports.GetRunDetailsRequest = exports.CreateWorkflowVersionResponse = exports.CreateTaskRateLimit = exports.CreateTaskOpts_SlotRequestsEntry = exports.CreateTaskOpts_WorkerLabelsEntry = exports.CreateTaskOpts = exports.DesiredWorkerLabels = exports.Concurrency = exports.DefaultFilter = exports.CreateWorkflowVersionRequest = exports.TriggerWorkflowRunResponse = exports.TriggerWorkflowRunRequest_DesiredWorkerLabelsEntry = exports.TriggerWorkflowRunRequest = exports.ReplayTasksResponse = exports.CancelTasksResponse = exports.TasksFilter = exports.ReplayTasksRequest = exports.CancelTasksRequest = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.RunStatus = exports.RateLimitDuration = exports.StickyStrategy = exports.protobufPackage = void 0;
9
9
  exports.stickyStrategyFromJSON = stickyStrategyFromJSON;
10
10
  exports.stickyStrategyToJSON = stickyStrategyToJSON;
11
11
  exports.rateLimitDurationFromJSON = rateLimitDurationFromJSON;
@@ -665,6 +665,7 @@ function createBaseTriggerWorkflowRunRequest() {
665
665
  input: new Uint8Array(0),
666
666
  additionalMetadata: new Uint8Array(0),
667
667
  priority: undefined,
668
+ desiredWorkerLabels: {},
668
669
  };
669
670
  }
670
671
  exports.TriggerWorkflowRunRequest = {
@@ -681,6 +682,9 @@ exports.TriggerWorkflowRunRequest = {
681
682
  if (message.priority !== undefined) {
682
683
  writer.uint32(32).int32(message.priority);
683
684
  }
685
+ Object.entries(message.desiredWorkerLabels).forEach(([key, value]) => {
686
+ exports.TriggerWorkflowRunRequest_DesiredWorkerLabelsEntry.encode({ key: key, value }, writer.uint32(42).fork()).join();
687
+ });
684
688
  return writer;
685
689
  },
686
690
  decode(input, length) {
@@ -718,6 +722,16 @@ exports.TriggerWorkflowRunRequest = {
718
722
  message.priority = reader.int32();
719
723
  continue;
720
724
  }
725
+ case 5: {
726
+ if (tag !== 42) {
727
+ break;
728
+ }
729
+ const entry5 = exports.TriggerWorkflowRunRequest_DesiredWorkerLabelsEntry.decode(reader, reader.uint32());
730
+ if (entry5.value !== undefined) {
731
+ message.desiredWorkerLabels[entry5.key] = entry5.value;
732
+ }
733
+ continue;
734
+ }
721
735
  }
722
736
  if ((tag & 7) === 4 || tag === 0) {
723
737
  break;
@@ -734,6 +748,12 @@ exports.TriggerWorkflowRunRequest = {
734
748
  ? bytesFromBase64(object.additionalMetadata)
735
749
  : new Uint8Array(0),
736
750
  priority: isSet(object.priority) ? globalThis.Number(object.priority) : undefined,
751
+ desiredWorkerLabels: isObject(object.desiredWorkerLabels)
752
+ ? Object.entries(object.desiredWorkerLabels).reduce((acc, [key, value]) => {
753
+ acc[key] = exports.DesiredWorkerLabels.fromJSON(value);
754
+ return acc;
755
+ }, {})
756
+ : {},
737
757
  };
738
758
  },
739
759
  toJSON(message) {
@@ -750,18 +770,105 @@ exports.TriggerWorkflowRunRequest = {
750
770
  if (message.priority !== undefined) {
751
771
  obj.priority = Math.round(message.priority);
752
772
  }
773
+ if (message.desiredWorkerLabels) {
774
+ const entries = Object.entries(message.desiredWorkerLabels);
775
+ if (entries.length > 0) {
776
+ obj.desiredWorkerLabels = {};
777
+ entries.forEach(([k, v]) => {
778
+ obj.desiredWorkerLabels[k] = exports.DesiredWorkerLabels.toJSON(v);
779
+ });
780
+ }
781
+ }
753
782
  return obj;
754
783
  },
755
784
  create(base) {
756
785
  return exports.TriggerWorkflowRunRequest.fromPartial(base !== null && base !== void 0 ? base : {});
757
786
  },
758
787
  fromPartial(object) {
759
- var _a, _b, _c, _d;
788
+ var _a, _b, _c, _d, _e;
760
789
  const message = createBaseTriggerWorkflowRunRequest();
761
790
  message.workflowName = (_a = object.workflowName) !== null && _a !== void 0 ? _a : '';
762
791
  message.input = (_b = object.input) !== null && _b !== void 0 ? _b : new Uint8Array(0);
763
792
  message.additionalMetadata = (_c = object.additionalMetadata) !== null && _c !== void 0 ? _c : new Uint8Array(0);
764
793
  message.priority = (_d = object.priority) !== null && _d !== void 0 ? _d : undefined;
794
+ message.desiredWorkerLabels = Object.entries((_e = object.desiredWorkerLabels) !== null && _e !== void 0 ? _e : {}).reduce((acc, [key, value]) => {
795
+ if (value !== undefined) {
796
+ acc[key] = exports.DesiredWorkerLabels.fromPartial(value);
797
+ }
798
+ return acc;
799
+ }, {});
800
+ return message;
801
+ },
802
+ };
803
+ function createBaseTriggerWorkflowRunRequest_DesiredWorkerLabelsEntry() {
804
+ return { key: '', value: undefined };
805
+ }
806
+ exports.TriggerWorkflowRunRequest_DesiredWorkerLabelsEntry = {
807
+ encode(message, writer = new wire_1.BinaryWriter()) {
808
+ if (message.key !== '') {
809
+ writer.uint32(10).string(message.key);
810
+ }
811
+ if (message.value !== undefined) {
812
+ exports.DesiredWorkerLabels.encode(message.value, writer.uint32(18).fork()).join();
813
+ }
814
+ return writer;
815
+ },
816
+ decode(input, length) {
817
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
818
+ const end = length === undefined ? reader.len : reader.pos + length;
819
+ const message = createBaseTriggerWorkflowRunRequest_DesiredWorkerLabelsEntry();
820
+ while (reader.pos < end) {
821
+ const tag = reader.uint32();
822
+ switch (tag >>> 3) {
823
+ case 1: {
824
+ if (tag !== 10) {
825
+ break;
826
+ }
827
+ message.key = reader.string();
828
+ continue;
829
+ }
830
+ case 2: {
831
+ if (tag !== 18) {
832
+ break;
833
+ }
834
+ message.value = exports.DesiredWorkerLabels.decode(reader, reader.uint32());
835
+ continue;
836
+ }
837
+ }
838
+ if ((tag & 7) === 4 || tag === 0) {
839
+ break;
840
+ }
841
+ reader.skip(tag & 7);
842
+ }
843
+ return message;
844
+ },
845
+ fromJSON(object) {
846
+ return {
847
+ key: isSet(object.key) ? globalThis.String(object.key) : '',
848
+ value: isSet(object.value) ? exports.DesiredWorkerLabels.fromJSON(object.value) : undefined,
849
+ };
850
+ },
851
+ toJSON(message) {
852
+ const obj = {};
853
+ if (message.key !== '') {
854
+ obj.key = message.key;
855
+ }
856
+ if (message.value !== undefined) {
857
+ obj.value = exports.DesiredWorkerLabels.toJSON(message.value);
858
+ }
859
+ return obj;
860
+ },
861
+ create(base) {
862
+ return exports.TriggerWorkflowRunRequest_DesiredWorkerLabelsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
863
+ },
864
+ fromPartial(object) {
865
+ var _a;
866
+ const message = createBaseTriggerWorkflowRunRequest_DesiredWorkerLabelsEntry();
867
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
868
+ message.value =
869
+ object.value !== undefined && object.value !== null
870
+ ? exports.DesiredWorkerLabels.fromPartial(object.value)
871
+ : undefined;
765
872
  return message;
766
873
  },
767
874
  };
@@ -258,6 +258,14 @@ export interface TriggerWorkflowRequest {
258
258
  desiredWorkerId?: string | undefined;
259
259
  /** (optional) override for the priority of the workflow tasks, will set all tasks to this priority */
260
260
  priority?: number | undefined;
261
+ /** (optional) override for the desired worker labels for the workflow tasks, used for routing to specific workers (or worker pools) */
262
+ desiredWorkerLabels: {
263
+ [key: string]: DesiredWorkerLabels;
264
+ };
265
+ }
266
+ export interface TriggerWorkflowRequest_DesiredWorkerLabelsEntry {
267
+ key: string;
268
+ value: DesiredWorkerLabels | undefined;
261
269
  }
262
270
  export interface TriggerWorkflowResponse {
263
271
  workflowRunId: string;
@@ -289,6 +297,7 @@ export declare const WorkflowTriggerCronRef: MessageFns<WorkflowTriggerCronRef>;
289
297
  export declare const BulkTriggerWorkflowRequest: MessageFns<BulkTriggerWorkflowRequest>;
290
298
  export declare const BulkTriggerWorkflowResponse: MessageFns<BulkTriggerWorkflowResponse>;
291
299
  export declare const TriggerWorkflowRequest: MessageFns<TriggerWorkflowRequest>;
300
+ export declare const TriggerWorkflowRequest_DesiredWorkerLabelsEntry: MessageFns<TriggerWorkflowRequest_DesiredWorkerLabelsEntry>;
292
301
  export declare const TriggerWorkflowResponse: MessageFns<TriggerWorkflowResponse>;
293
302
  export declare const PutRateLimitRequest: MessageFns<PutRateLimitRequest>;
294
303
  export declare const PutRateLimitResponse: MessageFns<PutRateLimitResponse>;
@@ -5,7 +5,7 @@
5
5
  // protoc v3.19.1
6
6
  // source: workflows/workflows.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.WorkflowServiceDefinition = exports.PutRateLimitResponse = exports.PutRateLimitRequest = exports.TriggerWorkflowResponse = exports.TriggerWorkflowRequest = exports.BulkTriggerWorkflowResponse = exports.BulkTriggerWorkflowRequest = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowVersion = exports.ScheduledWorkflow = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateStepRateLimit = exports.CreateWorkflowStepOpts_WorkerLabelsEntry = exports.CreateWorkflowStepOpts = exports.DesiredWorkerLabels = exports.CreateWorkflowJobOpts = exports.WorkflowConcurrencyOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.RateLimitDuration = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.WorkflowKind = exports.StickyStrategy = exports.protobufPackage = void 0;
8
+ exports.WorkflowServiceDefinition = exports.PutRateLimitResponse = exports.PutRateLimitRequest = exports.TriggerWorkflowResponse = exports.TriggerWorkflowRequest_DesiredWorkerLabelsEntry = exports.TriggerWorkflowRequest = exports.BulkTriggerWorkflowResponse = exports.BulkTriggerWorkflowRequest = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowVersion = exports.ScheduledWorkflow = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateStepRateLimit = exports.CreateWorkflowStepOpts_WorkerLabelsEntry = exports.CreateWorkflowStepOpts = exports.DesiredWorkerLabels = exports.CreateWorkflowJobOpts = exports.WorkflowConcurrencyOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.RateLimitDuration = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.WorkflowKind = exports.StickyStrategy = exports.protobufPackage = void 0;
9
9
  exports.stickyStrategyFromJSON = stickyStrategyFromJSON;
10
10
  exports.stickyStrategyToJSON = stickyStrategyToJSON;
11
11
  exports.workflowKindFromJSON = workflowKindFromJSON;
@@ -2078,6 +2078,7 @@ function createBaseTriggerWorkflowRequest() {
2078
2078
  additionalMetadata: undefined,
2079
2079
  desiredWorkerId: undefined,
2080
2080
  priority: undefined,
2081
+ desiredWorkerLabels: {},
2081
2082
  };
2082
2083
  }
2083
2084
  exports.TriggerWorkflowRequest = {
@@ -2109,6 +2110,9 @@ exports.TriggerWorkflowRequest = {
2109
2110
  if (message.priority !== undefined) {
2110
2111
  writer.uint32(72).int32(message.priority);
2111
2112
  }
2113
+ Object.entries(message.desiredWorkerLabels).forEach(([key, value]) => {
2114
+ exports.TriggerWorkflowRequest_DesiredWorkerLabelsEntry.encode({ key: key, value }, writer.uint32(82).fork()).join();
2115
+ });
2112
2116
  return writer;
2113
2117
  },
2114
2118
  decode(input, length) {
@@ -2181,6 +2185,16 @@ exports.TriggerWorkflowRequest = {
2181
2185
  message.priority = reader.int32();
2182
2186
  continue;
2183
2187
  }
2188
+ case 10: {
2189
+ if (tag !== 82) {
2190
+ break;
2191
+ }
2192
+ const entry10 = exports.TriggerWorkflowRequest_DesiredWorkerLabelsEntry.decode(reader, reader.uint32());
2193
+ if (entry10.value !== undefined) {
2194
+ message.desiredWorkerLabels[entry10.key] = entry10.value;
2195
+ }
2196
+ continue;
2197
+ }
2184
2198
  }
2185
2199
  if ((tag & 7) === 4 || tag === 0) {
2186
2200
  break;
@@ -2206,6 +2220,12 @@ exports.TriggerWorkflowRequest = {
2206
2220
  ? globalThis.String(object.desiredWorkerId)
2207
2221
  : undefined,
2208
2222
  priority: isSet(object.priority) ? globalThis.Number(object.priority) : undefined,
2223
+ desiredWorkerLabels: isObject(object.desiredWorkerLabels)
2224
+ ? Object.entries(object.desiredWorkerLabels).reduce((acc, [key, value]) => {
2225
+ acc[key] = exports.DesiredWorkerLabels.fromJSON(value);
2226
+ return acc;
2227
+ }, {})
2228
+ : {},
2209
2229
  };
2210
2230
  },
2211
2231
  toJSON(message) {
@@ -2237,13 +2257,22 @@ exports.TriggerWorkflowRequest = {
2237
2257
  if (message.priority !== undefined) {
2238
2258
  obj.priority = Math.round(message.priority);
2239
2259
  }
2260
+ if (message.desiredWorkerLabels) {
2261
+ const entries = Object.entries(message.desiredWorkerLabels);
2262
+ if (entries.length > 0) {
2263
+ obj.desiredWorkerLabels = {};
2264
+ entries.forEach(([k, v]) => {
2265
+ obj.desiredWorkerLabels[k] = exports.DesiredWorkerLabels.toJSON(v);
2266
+ });
2267
+ }
2268
+ }
2240
2269
  return obj;
2241
2270
  },
2242
2271
  create(base) {
2243
2272
  return exports.TriggerWorkflowRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2244
2273
  },
2245
2274
  fromPartial(object) {
2246
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2275
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2247
2276
  const message = createBaseTriggerWorkflowRequest();
2248
2277
  message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
2249
2278
  message.input = (_b = object.input) !== null && _b !== void 0 ? _b : '';
@@ -2254,6 +2283,84 @@ exports.TriggerWorkflowRequest = {
2254
2283
  message.additionalMetadata = (_g = object.additionalMetadata) !== null && _g !== void 0 ? _g : undefined;
2255
2284
  message.desiredWorkerId = (_h = object.desiredWorkerId) !== null && _h !== void 0 ? _h : undefined;
2256
2285
  message.priority = (_j = object.priority) !== null && _j !== void 0 ? _j : undefined;
2286
+ message.desiredWorkerLabels = Object.entries((_k = object.desiredWorkerLabels) !== null && _k !== void 0 ? _k : {}).reduce((acc, [key, value]) => {
2287
+ if (value !== undefined) {
2288
+ acc[key] = exports.DesiredWorkerLabels.fromPartial(value);
2289
+ }
2290
+ return acc;
2291
+ }, {});
2292
+ return message;
2293
+ },
2294
+ };
2295
+ function createBaseTriggerWorkflowRequest_DesiredWorkerLabelsEntry() {
2296
+ return { key: '', value: undefined };
2297
+ }
2298
+ exports.TriggerWorkflowRequest_DesiredWorkerLabelsEntry = {
2299
+ encode(message, writer = new wire_1.BinaryWriter()) {
2300
+ if (message.key !== '') {
2301
+ writer.uint32(10).string(message.key);
2302
+ }
2303
+ if (message.value !== undefined) {
2304
+ exports.DesiredWorkerLabels.encode(message.value, writer.uint32(18).fork()).join();
2305
+ }
2306
+ return writer;
2307
+ },
2308
+ decode(input, length) {
2309
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2310
+ const end = length === undefined ? reader.len : reader.pos + length;
2311
+ const message = createBaseTriggerWorkflowRequest_DesiredWorkerLabelsEntry();
2312
+ while (reader.pos < end) {
2313
+ const tag = reader.uint32();
2314
+ switch (tag >>> 3) {
2315
+ case 1: {
2316
+ if (tag !== 10) {
2317
+ break;
2318
+ }
2319
+ message.key = reader.string();
2320
+ continue;
2321
+ }
2322
+ case 2: {
2323
+ if (tag !== 18) {
2324
+ break;
2325
+ }
2326
+ message.value = exports.DesiredWorkerLabels.decode(reader, reader.uint32());
2327
+ continue;
2328
+ }
2329
+ }
2330
+ if ((tag & 7) === 4 || tag === 0) {
2331
+ break;
2332
+ }
2333
+ reader.skip(tag & 7);
2334
+ }
2335
+ return message;
2336
+ },
2337
+ fromJSON(object) {
2338
+ return {
2339
+ key: isSet(object.key) ? globalThis.String(object.key) : '',
2340
+ value: isSet(object.value) ? exports.DesiredWorkerLabels.fromJSON(object.value) : undefined,
2341
+ };
2342
+ },
2343
+ toJSON(message) {
2344
+ const obj = {};
2345
+ if (message.key !== '') {
2346
+ obj.key = message.key;
2347
+ }
2348
+ if (message.value !== undefined) {
2349
+ obj.value = exports.DesiredWorkerLabels.toJSON(message.value);
2350
+ }
2351
+ return obj;
2352
+ },
2353
+ create(base) {
2354
+ return exports.TriggerWorkflowRequest_DesiredWorkerLabelsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
2355
+ },
2356
+ fromPartial(object) {
2357
+ var _a;
2358
+ const message = createBaseTriggerWorkflowRequest_DesiredWorkerLabelsEntry();
2359
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
2360
+ message.value =
2361
+ object.value !== undefined && object.value !== null
2362
+ ? exports.DesiredWorkerLabels.fromPartial(object.value)
2363
+ : undefined;
2257
2364
  return message;
2258
2365
  },
2259
2366
  };
@@ -3,9 +3,15 @@ import WorkflowRunRef from '../../util/workflow-run-ref';
3
3
  import { Priority, RateLimitDuration, RunsClient } from './..';
4
4
  import { RunListenerClient } from '../../clients/listeners/run-listener/child-listener-client';
5
5
  import { Api } from '../../clients/rest/generated/Api';
6
- import { WorkflowServiceClient } from '../../protoc/workflows';
6
+ import { WorkerLabelComparator, WorkflowServiceClient } from '../../protoc/workflows';
7
7
  import { AdminServiceClient, CreateWorkflowVersionRequest } from '../../protoc/v1/workflows';
8
8
  import { Logger } from '../../util/logger';
9
+ type DesiredWorkerLabelOpt = {
10
+ value: string | number;
11
+ required?: boolean;
12
+ weight?: number;
13
+ comparator?: WorkerLabelComparator;
14
+ };
9
15
  export type WorkflowRun<T = object> = {
10
16
  workflowName: string;
11
17
  input: T;
@@ -66,6 +72,7 @@ export declare class AdminClient {
66
72
  additionalMetadata?: Record<string, string> | undefined;
67
73
  desiredWorkerId?: string | undefined;
68
74
  priority?: Priority;
75
+ desiredWorkerLabels?: Record<string, DesiredWorkerLabelOpt>;
69
76
  _standaloneTaskName?: string | undefined;
70
77
  }): Promise<WorkflowRunRef<P>>;
71
78
  /**
@@ -95,8 +102,10 @@ export declare class AdminClient {
95
102
  additionalMetadata?: Record<string, string> | undefined;
96
103
  desiredWorkerId?: string | undefined;
97
104
  priority?: Priority;
105
+ desiredWorkerLabels?: Record<string, DesiredWorkerLabelOpt>;
98
106
  _standaloneTaskName?: string | undefined;
99
107
  };
100
108
  }>, batchSize?: number): Promise<WorkflowRunRef<P>[]>;
101
109
  putRateLimit(key: string, limit: number, duration?: RateLimitDuration): Promise<void>;
102
110
  }
111
+ export {};
@@ -33,6 +33,18 @@ const workflows_2 = require("../../protoc/v1/workflows");
33
33
  const retrier_1 = require("../../util/retrier");
34
34
  const batch_1 = require("../../util/batch");
35
35
  const apply_namespace_1 = require("../../util/apply-namespace");
36
+ function convertDesiredWorkerLabels(labels) {
37
+ return Object.fromEntries(Object.entries(labels).map(([key, label]) => [
38
+ key,
39
+ {
40
+ strValue: typeof label.value === 'string' ? label.value : undefined,
41
+ intValue: typeof label.value === 'number' ? label.value : undefined,
42
+ required: label.required,
43
+ weight: label.weight,
44
+ comparator: label.comparator,
45
+ },
46
+ ]));
47
+ }
36
48
  class AdminClient {
37
49
  constructor(config, api, runs) {
38
50
  this.config = config;
@@ -71,10 +83,12 @@ class AdminClient {
71
83
  const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace).toLowerCase();
72
84
  const inputStr = JSON.stringify(input);
73
85
  const opts = options !== null && options !== void 0 ? options : {};
74
- const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
86
+ const { additionalMetadata, parentStepRunId, parentTaskRunExternalId, desiredWorkerLabels } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId", "desiredWorkerLabels"]);
75
87
  const request = Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), {
76
88
  // API expects `parentTaskRunExternalId`; accept old names as aliases.
77
- parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, priority: opts.priority });
89
+ parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, priority: opts.priority, desiredWorkerLabels: desiredWorkerLabels
90
+ ? convertDesiredWorkerLabels(desiredWorkerLabels)
91
+ : {} });
78
92
  const resp = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.workflowsGrpc.triggerWorkflow(request); }), this.logger);
79
93
  const id = resp.workflowRunId;
80
94
  const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId,
@@ -101,10 +115,12 @@ class AdminClient {
101
115
  const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace).toLowerCase();
102
116
  const inputStr = JSON.stringify(input);
103
117
  const opts = options !== null && options !== void 0 ? options : {};
104
- const { additionalMetadata, parentStepRunId, parentTaskRunExternalId } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId"]);
118
+ const { additionalMetadata, parentStepRunId, parentTaskRunExternalId, desiredWorkerLabels } = opts, rest = __rest(opts, ["additionalMetadata", "parentStepRunId", "parentTaskRunExternalId", "desiredWorkerLabels"]);
105
119
  return Object.assign(Object.assign({ name: computedName, input: inputStr }, rest), {
106
120
  // API expects `parentTaskRunExternalId`; accept old names as aliases.
107
- parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined });
121
+ parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, desiredWorkerLabels: desiredWorkerLabels
122
+ ? convertDesiredWorkerLabels(desiredWorkerLabels)
123
+ : {} });
108
124
  });
109
125
  const limit = 4 * 1024 * 1024; // FIXME configurable GRPC limit
110
126
  const batches = (0, batch_1.batch)(workflowRequests, batchSize, limit);
@@ -1,3 +1,9 @@
1
+ /**
2
+ * This is the TypeScript SDK reference, documenting methods available for interacting with Hatchet resources.
3
+ * Check out the [user guide](https://docs.hatchet.run/home/) for an introduction to getting your first tasks running.
4
+ *
5
+ * @module Hatchet TypeScript SDK Reference
6
+ */
1
7
  import { ClientConfig, HatchetClientOptions, LegacyHatchetClient, TaskMiddleware, InferMiddlewareBefore, InferMiddlewareAfter } from '../../clients/hatchet-client';
2
8
  import { AxiosRequestConfig } from 'axios';
3
9
  import WorkflowRunRef from '../../util/workflow-run-ref';
@@ -44,6 +50,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
44
50
  private _credentials;
45
51
  /**
46
52
  * @deprecated v0 client will be removed in a future release, please upgrade to v1
53
+ * @hidden
47
54
  */
48
55
  get v0(): LegacyHatchetClient;
49
56
  /** The tenant ID for the Hatchet client */
@@ -56,6 +63,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
56
63
  * @param config - Optional configuration for the client
57
64
  * @param options - Optional client options
58
65
  * @param axiosConfig - Optional Axios configuration for HTTP requests
66
+ * @internal
59
67
  */
60
68
  constructor(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosConfig?: AxiosRequestConfig);
61
69
  /**
@@ -66,6 +74,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
66
74
  * @param options - Optional client options.
67
75
  * @param axiosConfig - Optional Axios configuration for HTTP requests.
68
76
  * @returns A new Hatchet client instance. Chain `.withMiddleware()` to attach typed middleware.
77
+ * @internal
69
78
  */
70
79
  static init<T extends Record<string, any> = {}, U extends Record<string, any> = {}>(config?: Omit<Partial<ClientConfig>, 'middleware'>, options?: HatchetClientOptions, axiosConfig?: AxiosRequestConfig): HatchetClient<T, U>;
71
80
  /**
@@ -74,6 +83,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
74
83
  *
75
84
  * Use this after `init<T, U>()` to get full middleware return-type inference
76
85
  * that TypeScript can't provide when global types are explicitly set on `init`.
86
+ * @internal
77
87
  */
78
88
  withMiddleware<const M extends TaskMiddleware<Resolved<GlobalInput, MiddlewareBefore>, Resolved<GlobalOutput, MiddlewareAfter>>>(middleware: M): HatchetClient<GlobalInput, GlobalOutput, MiddlewareBefore & InferMiddlewareBefore<M>, MiddlewareAfter & InferMiddlewareAfter<M>>;
79
89
  private _config;
@@ -134,12 +144,12 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
134
144
  */
135
145
  runNoWait<I extends InputType = UnknownInputType, O extends OutputType = void>(workflow: BaseWorkflowDeclaration<I, O> | LegacyWorkflow | string, input: I, options: RunOpts): Promise<WorkflowRunRef<O>>;
136
146
  /**
137
- * @alias run
138
147
  * Triggers a workflow run and waits for the result.
139
148
  * @template I - The input type for the workflow
140
149
  * @template O - The return type of the workflow
141
150
  * @param workflow - The workflow to run, either as a Workflow instance or workflow name
142
151
  * @param input - The input data for the workflow
152
+ * @alias run
143
153
  * @param options - Configuration options for the workflow run
144
154
  * @returns A promise that resolves with the workflow result
145
155
  */
@@ -158,6 +168,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
158
168
  /**
159
169
  * Get the CEL client for debugging CEL expressions
160
170
  * @returns A CEL client instance
171
+ * @internal
161
172
  */
162
173
  get cel(): CELClient;
163
174
  private _crons;
@@ -170,6 +181,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
170
181
  * Get the cron client for creating and managing cron workflow runs
171
182
  * @returns A cron client instance
172
183
  * @deprecated use client.crons instead
184
+ * @hidden
173
185
  */
174
186
  get cron(): CronClient;
175
187
  private _scheduled;
@@ -182,6 +194,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
182
194
  * Get the schedule client for creating and managing scheduled workflow runs
183
195
  * @returns A schedule client instance
184
196
  * @deprecated use client.scheduled instead
197
+ * @hidden
185
198
  */
186
199
  get schedule(): ScheduleClient;
187
200
  /**
@@ -192,6 +205,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
192
205
  /**
193
206
  * Get the dispatcher client for sending action events and managing worker registration
194
207
  * @returns A dispatcher client instance
208
+ * @internal
195
209
  */
196
210
  get dispatcher(): DispatcherClient;
197
211
  private _event;
@@ -204,15 +218,18 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
204
218
  /**
205
219
  * Get the durable listener client for managing durable event subscriptions
206
220
  * @returns A durable listener client instance
221
+ * @internal
207
222
  */
208
223
  get durableListener(): DurableListenerClient;
209
224
  /**
210
225
  * Get the run listener client for streaming workflow run results
211
226
  * @returns A run listener client instance
227
+ * @internal
212
228
  */
213
229
  get listener(): RunListenerClient;
214
230
  /**
215
231
  * @deprecated use client.events instead
232
+ * @hidden
216
233
  */
217
234
  get event(): EventClient;
218
235
  private _metrics;
@@ -278,6 +295,7 @@ export declare class HatchetClient<GlobalInput extends Record<string, any> = {},
278
295
  /**
279
296
  * Get the admin client for creating and managing workflows
280
297
  * @returns A admin client instance
298
+ * @internal
281
299
  */
282
300
  get admin(): AdminClient;
283
301
  /**
@@ -13,6 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.HatchetClient = void 0;
16
+ /**
17
+ * This is the TypeScript SDK reference, documenting methods available for interacting with Hatchet resources.
18
+ * Check out the [user guide](https://docs.hatchet.run/home/) for an introduction to getting your first tasks running.
19
+ *
20
+ * @module Hatchet TypeScript SDK Reference
21
+ */
16
22
  /* eslint-disable no-dupe-class-members */
17
23
  /* eslint-disable no-underscore-dangle */
18
24
  const hatchet_client_1 = require("../../clients/hatchet-client");
@@ -52,6 +58,7 @@ const webhooks_1 = require("./features/webhooks");
52
58
  class HatchetClient {
53
59
  /**
54
60
  * @deprecated v0 client will be removed in a future release, please upgrade to v1
61
+ * @hidden
55
62
  */
56
63
  get v0() {
57
64
  if (!this._v0) {
@@ -67,6 +74,7 @@ class HatchetClient {
67
74
  * @param config - Optional configuration for the client
68
75
  * @param options - Optional client options
69
76
  * @param axiosConfig - Optional Axios configuration for HTTP requests
77
+ * @internal
70
78
  */
71
79
  constructor(config, options, axiosConfig) {
72
80
  var _a;
@@ -124,6 +132,7 @@ class HatchetClient {
124
132
  * @param options - Optional client options.
125
133
  * @param axiosConfig - Optional Axios configuration for HTTP requests.
126
134
  * @returns A new Hatchet client instance. Chain `.withMiddleware()` to attach typed middleware.
135
+ * @internal
127
136
  */
128
137
  static init(config, options, axiosConfig) {
129
138
  return new HatchetClient(config, options, axiosConfig);
@@ -134,6 +143,7 @@ class HatchetClient {
134
143
  *
135
144
  * Use this after `init<T, U>()` to get full middleware return-type inference
136
145
  * that TypeScript can't provide when global types are explicitly set on `init`.
146
+ * @internal
137
147
  */
138
148
  withMiddleware(middleware) {
139
149
  const existing = this._config.middleware || {};
@@ -192,12 +202,12 @@ class HatchetClient {
192
202
  });
193
203
  }
194
204
  /**
195
- * @alias run
196
205
  * Triggers a workflow run and waits for the result.
197
206
  * @template I - The input type for the workflow
198
207
  * @template O - The return type of the workflow
199
208
  * @param workflow - The workflow to run, either as a Workflow instance or workflow name
200
209
  * @param input - The input data for the workflow
210
+ * @alias run
201
211
  * @param options - Configuration options for the workflow run
202
212
  * @returns A promise that resolves with the workflow result
203
213
  */
@@ -224,6 +234,7 @@ class HatchetClient {
224
234
  /**
225
235
  * Get the CEL client for debugging CEL expressions
226
236
  * @returns A CEL client instance
237
+ * @internal
227
238
  */
228
239
  get cel() {
229
240
  if (!this._cel) {
@@ -245,6 +256,7 @@ class HatchetClient {
245
256
  * Get the cron client for creating and managing cron workflow runs
246
257
  * @returns A cron client instance
247
258
  * @deprecated use client.crons instead
259
+ * @hidden
248
260
  */
249
261
  get cron() {
250
262
  return this.crons;
@@ -263,6 +275,7 @@ class HatchetClient {
263
275
  * Get the schedule client for creating and managing scheduled workflow runs
264
276
  * @returns A schedule client instance
265
277
  * @deprecated use client.scheduled instead
278
+ * @hidden
266
279
  */
267
280
  get schedule() {
268
281
  return this.scheduled;
@@ -276,6 +289,7 @@ class HatchetClient {
276
289
  /**
277
290
  * Get the dispatcher client for sending action events and managing worker registration
278
291
  * @returns A dispatcher client instance
292
+ * @internal
279
293
  */
280
294
  get dispatcher() {
281
295
  if (!this._dispatcher) {
@@ -296,6 +310,7 @@ class HatchetClient {
296
310
  /**
297
311
  * Get the durable listener client for managing durable event subscriptions
298
312
  * @returns A durable listener client instance
313
+ * @internal
299
314
  */
300
315
  get durableListener() {
301
316
  if (!this._durableListener) {
@@ -306,12 +321,14 @@ class HatchetClient {
306
321
  /**
307
322
  * Get the run listener client for streaming workflow run results
308
323
  * @returns A run listener client instance
324
+ * @internal
309
325
  */
310
326
  get listener() {
311
327
  return this._listener;
312
328
  }
313
329
  /**
314
330
  * @deprecated use client.events instead
331
+ * @hidden
315
332
  */
316
333
  get event() {
317
334
  return this.events;
@@ -414,6 +431,7 @@ class HatchetClient {
414
431
  /**
415
432
  * Get the admin client for creating and managing workflows
416
433
  * @returns A admin client instance
434
+ * @internal
417
435
  */
418
436
  get admin() {
419
437
  if (!this._admin) {