@hatchet-dev/typescript-sdk 1.1.8-alpha.2 → 1.2.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.
@@ -4,7 +4,7 @@ import { ClientConfig } from '../hatchet-client/client-config';
4
4
  import { Logger } from '../../util/logger';
5
5
  import WorkflowRunRef from '../../util/workflow-run-ref';
6
6
  import { AdminServiceClient, CreateWorkflowVersionRequest } from '../../protoc/v1/workflows';
7
- import { RunsClient } from '../../v1';
7
+ import { Priority, RunsClient } from '../../v1';
8
8
  import { Api } from '../rest';
9
9
  import { WebhookWorkerCreateRequest, WorkflowRunStatus, WorkflowRunStatusList } from '../rest/generated/data-contracts';
10
10
  import { RunListenerClient } from '../listeners/run-listener/child-listener-client';
@@ -85,6 +85,7 @@ export declare class AdminClient {
85
85
  childKey?: string | undefined;
86
86
  additionalMetadata?: Record<string, string> | undefined;
87
87
  desiredWorkerId?: string | undefined;
88
+ priority?: Priority;
88
89
  }): WorkflowRunRef<P>;
89
90
  /**
90
91
  * Run multiple workflows runs with the given input and options. This will create new workflow runs and return their IDs.
@@ -102,6 +103,7 @@ export declare class AdminClient {
102
103
  childKey?: string | undefined;
103
104
  additionalMetadata?: Record<string, string> | undefined;
104
105
  desiredWorkerId?: string | undefined;
106
+ priority?: Priority;
105
107
  };
106
108
  }>): Promise<WorkflowRunRef<P>[]>;
107
109
  /**
@@ -124,7 +124,7 @@ class AdminClient {
124
124
  const inputStr = JSON.stringify(input);
125
125
  const resp = this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
126
126
  ? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
127
- : undefined }));
127
+ : undefined, priority: options === null || options === void 0 ? void 0 : options.priority }));
128
128
  return new workflow_run_ref_1.default(resp, this.listenerClient, this.workflows, options === null || options === void 0 ? void 0 : options.parentId);
129
129
  }
130
130
  catch (e) {
@@ -46,8 +46,6 @@ export declare const ClientConfigSchema: z.ZodObject<{
46
46
  log_level: z.ZodOptional<z.ZodEnum<["OFF", "DEBUG", "INFO", "WARN", "ERROR"]>>;
47
47
  tenant_id: z.ZodString;
48
48
  namespace: z.ZodOptional<z.ZodString>;
49
- grpc_max_send_message_length: z.ZodOptional<z.ZodNumber>;
50
- grpc_max_recv_message_length: z.ZodOptional<z.ZodNumber>;
51
49
  }, "strip", z.ZodTypeAny, {
52
50
  token: string;
53
51
  tls_config: {
@@ -62,8 +60,6 @@ export declare const ClientConfigSchema: z.ZodObject<{
62
60
  tenant_id: string;
63
61
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
64
62
  namespace?: string | undefined;
65
- grpc_max_send_message_length?: number | undefined;
66
- grpc_max_recv_message_length?: number | undefined;
67
63
  }, {
68
64
  token: string;
69
65
  tls_config: {
@@ -78,8 +74,6 @@ export declare const ClientConfigSchema: z.ZodObject<{
78
74
  tenant_id: string;
79
75
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
80
76
  namespace?: string | undefined;
81
- grpc_max_send_message_length?: number | undefined;
82
- grpc_max_recv_message_length?: number | undefined;
83
77
  }>;
84
78
  export type LogConstructor = (context: string, logLevel?: LogLevel) => Logger;
85
79
  export type ClientConfig = z.infer<typeof ClientConfigSchema> & {
@@ -17,6 +17,4 @@ exports.ClientConfigSchema = zod_1.z.object({
17
17
  log_level: zod_1.z.enum(['OFF', 'DEBUG', 'INFO', 'WARN', 'ERROR']).optional(),
18
18
  tenant_id: zod_1.z.string(),
19
19
  namespace: zod_1.z.string().optional(),
20
- grpc_max_send_message_length: zod_1.z.number().optional(),
21
- grpc_max_recv_message_length: zod_1.z.number().optional(),
22
20
  });
@@ -12,15 +12,18 @@ export declare const CreateCronTriggerSchema: z.ZodObject<{
12
12
  expression: z.ZodEffects<z.ZodString, string, string>;
13
13
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
14
14
  additionalMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
15
+ priority: z.ZodOptional<z.ZodNumber>;
15
16
  }, "strip", z.ZodTypeAny, {
16
17
  name: string;
17
18
  expression: string;
18
19
  additionalMetadata?: Record<string, string> | undefined;
20
+ priority?: number | undefined;
19
21
  input?: Record<string, any> | undefined;
20
22
  }, {
21
23
  name: string;
22
24
  expression: string;
23
25
  additionalMetadata?: Record<string, string> | undefined;
26
+ priority?: number | undefined;
24
27
  input?: Record<string, any> | undefined;
25
28
  }>;
26
29
  /**
@@ -24,6 +24,7 @@ exports.CreateCronTriggerSchema = zod_1.z.object({
24
24
  }, 'Invalid cron expression'),
25
25
  input: zod_1.z.record(zod_1.z.any()).optional(),
26
26
  additionalMetadata: zod_1.z.record(zod_1.z.string()).optional(),
27
+ priority: zod_1.z.number().optional(),
27
28
  });
28
29
  /**
29
30
  * Client for managing Cron Triggers.
@@ -70,6 +71,7 @@ class CronClient {
70
71
  cronExpression: parsedCron.expression,
71
72
  input: (_a = parsedCron.input) !== null && _a !== void 0 ? _a : {},
72
73
  additionalMetadata: (_b = parsedCron.additionalMetadata) !== null && _b !== void 0 ? _b : {},
74
+ priority: parsedCron.priority,
73
75
  });
74
76
  return response.data;
75
77
  }
@@ -11,13 +11,16 @@ export declare const CreateScheduledRunTriggerSchema: z.ZodObject<{
11
11
  triggerAt: z.ZodDate;
12
12
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
13
13
  additionalMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
14
+ priority: z.ZodOptional<z.ZodNumber>;
14
15
  }, "strip", z.ZodTypeAny, {
15
16
  triggerAt: Date;
16
17
  additionalMetadata?: Record<string, string> | undefined;
18
+ priority?: number | undefined;
17
19
  input?: Record<string, any> | undefined;
18
20
  }, {
19
21
  triggerAt: Date;
20
22
  additionalMetadata?: Record<string, string> | undefined;
23
+ priority?: number | undefined;
21
24
  input?: Record<string, any> | undefined;
22
25
  }>;
23
26
  /**
@@ -19,6 +19,7 @@ exports.CreateScheduledRunTriggerSchema = zod_1.z.object({
19
19
  triggerAt: zod_1.z.coerce.date(),
20
20
  input: zod_1.z.record(zod_1.z.any()).optional(),
21
21
  additionalMetadata: zod_1.z.record(zod_1.z.string()).optional(),
22
+ priority: zod_1.z.number().optional(),
22
23
  });
23
24
  /**
24
25
  * Client for managing Scheduled Runs.
@@ -64,6 +65,7 @@ class ScheduleClient {
64
65
  input: (_a = parsedCron.input) !== null && _a !== void 0 ? _a : {},
65
66
  additionalMetadata: (_b = parsedCron.additionalMetadata) !== null && _b !== void 0 ? _b : {},
66
67
  triggerAt: parsedCron.triggerAt.toISOString(),
68
+ priority: parsedCron.priority,
67
69
  });
68
70
  return response.data;
69
71
  }
@@ -53,15 +53,13 @@ const cron_client_1 = require("./features/cron-client");
53
53
  const schedule_client_1 = require("./features/schedule-client");
54
54
  const durable_listener_client_1 = require("../listeners/durable-listener/durable-listener-client");
55
55
  const channelFactory = (config, credentials) => (0, nice_grpc_1.createChannel)(config.host_port, credentials, {
56
- 'grpc.max_send_message_length': config.grpc_max_send_message_length,
57
- 'grpc.max_receive_message_length': config.grpc_max_recv_message_length,
58
56
  'grpc.ssl_target_name_override': config.tls_config.server_name,
59
57
  'grpc.keepalive_timeout_ms': 60 * 1000,
60
58
  'grpc.client_idle_timeout_ms': 60 * 1000,
61
- 'grpc.http2.max_pings_without_data': 0,
62
- 'grpc.http2.min_recv_ping_interval_without_data_ms': 60 * 1000,
59
+ // Send keepalive pings every 10 seconds, default is 2 hours.
60
+ 'grpc.keepalive_time_ms': 10 * 1000,
61
+ // Allow keepalive pings when there are no gRPC calls.
63
62
  'grpc.keepalive_permit_without_calls': 1,
64
- 'grpc-node.max_session_memory': Number.MAX_SAFE_INTEGER,
65
63
  });
66
64
  exports.channelFactory = channelFactory;
67
65
  const addTokenMiddleware = (token) => function _(call, options) {
@@ -705,6 +705,12 @@ export interface ScheduledWorkflows {
705
705
  */
706
706
  workflowRunId?: string;
707
707
  method: 'DEFAULT' | 'API';
708
+ /**
709
+ * @format int32
710
+ * @min 1
711
+ * @max 3
712
+ */
713
+ priority?: number;
708
714
  }
709
715
  export interface ScheduledWorkflowsList {
710
716
  rows?: ScheduledWorkflows[];
@@ -735,6 +741,12 @@ export interface CronWorkflows {
735
741
  additionalMetadata?: Record<string, any>;
736
742
  enabled: boolean;
737
743
  method: 'DEFAULT' | 'API';
744
+ /**
745
+ * @format int32
746
+ * @min 1
747
+ * @max 3
748
+ */
749
+ priority?: number;
738
750
  }
739
751
  export interface CronWorkflowsList {
740
752
  rows?: CronWorkflows[];
@@ -1091,12 +1103,24 @@ export interface ScheduleWorkflowRunRequest {
1091
1103
  additionalMetadata: object;
1092
1104
  /** @format date-time */
1093
1105
  triggerAt: string;
1106
+ /**
1107
+ * @format int32
1108
+ * @min 1
1109
+ * @max 3
1110
+ */
1111
+ priority?: number;
1094
1112
  }
1095
1113
  export interface CreateCronWorkflowTriggerRequest {
1096
1114
  input: object;
1097
1115
  additionalMetadata: object;
1098
1116
  cronName: string;
1099
1117
  cronExpression: string;
1118
+ /**
1119
+ * @format int32
1120
+ * @min 1
1121
+ * @max 3
1122
+ */
1123
+ priority?: number;
1100
1124
  }
1101
1125
  export interface CreatePullRequestFromStepRun {
1102
1126
  branchName: string;
@@ -199,6 +199,7 @@ class V0Worker {
199
199
  sticky: workflow.sticky,
200
200
  concurrency,
201
201
  onFailureTask,
202
+ defaultPriority: workflow.defaultPriority,
202
203
  tasks: [...workflow._tasks, ...workflow._durableTasks].map((task) => {
203
204
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
204
205
  return ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.1.8-alpha.2",
3
+ "version": "1.2.0",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -158,6 +158,7 @@ export interface AssignedAction {
158
158
  childWorkflowKey?: string | undefined;
159
159
  /** (optional) the parent workflow run id (if this is a child workflow) */
160
160
  parentWorkflowRunId?: string | undefined;
161
+ priority: number;
161
162
  }
162
163
  export interface WorkerListenRequest {
163
164
  /** the id of the worker */
@@ -1093,6 +1093,7 @@ function createBaseAssignedAction() {
1093
1093
  childWorkflowIndex: undefined,
1094
1094
  childWorkflowKey: undefined,
1095
1095
  parentWorkflowRunId: undefined,
1096
+ priority: 0,
1096
1097
  };
1097
1098
  }
1098
1099
  exports.AssignedAction = {
@@ -1148,6 +1149,9 @@ exports.AssignedAction = {
1148
1149
  if (message.parentWorkflowRunId !== undefined) {
1149
1150
  writer.uint32(138).string(message.parentWorkflowRunId);
1150
1151
  }
1152
+ if (message.priority !== 0) {
1153
+ writer.uint32(144).int32(message.priority);
1154
+ }
1151
1155
  return writer;
1152
1156
  },
1153
1157
  decode(input, length) {
@@ -1276,6 +1280,13 @@ exports.AssignedAction = {
1276
1280
  message.parentWorkflowRunId = reader.string();
1277
1281
  continue;
1278
1282
  }
1283
+ case 18: {
1284
+ if (tag !== 144) {
1285
+ break;
1286
+ }
1287
+ message.priority = reader.int32();
1288
+ continue;
1289
+ }
1279
1290
  }
1280
1291
  if ((tag & 7) === 4 || tag === 0) {
1281
1292
  break;
@@ -1313,6 +1324,7 @@ exports.AssignedAction = {
1313
1324
  parentWorkflowRunId: isSet(object.parentWorkflowRunId)
1314
1325
  ? globalThis.String(object.parentWorkflowRunId)
1315
1326
  : undefined,
1327
+ priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0,
1316
1328
  };
1317
1329
  },
1318
1330
  toJSON(message) {
@@ -1368,13 +1380,16 @@ exports.AssignedAction = {
1368
1380
  if (message.parentWorkflowRunId !== undefined) {
1369
1381
  obj.parentWorkflowRunId = message.parentWorkflowRunId;
1370
1382
  }
1383
+ if (message.priority !== 0) {
1384
+ obj.priority = Math.round(message.priority);
1385
+ }
1371
1386
  return obj;
1372
1387
  },
1373
1388
  create(base) {
1374
1389
  return exports.AssignedAction.fromPartial(base !== null && base !== void 0 ? base : {});
1375
1390
  },
1376
1391
  fromPartial(object) {
1377
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
1392
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1378
1393
  const message = createBaseAssignedAction();
1379
1394
  message.tenantId = (_a = object.tenantId) !== null && _a !== void 0 ? _a : '';
1380
1395
  message.workflowRunId = (_b = object.workflowRunId) !== null && _b !== void 0 ? _b : '';
@@ -1393,6 +1408,7 @@ exports.AssignedAction = {
1393
1408
  message.childWorkflowIndex = (_q = object.childWorkflowIndex) !== null && _q !== void 0 ? _q : undefined;
1394
1409
  message.childWorkflowKey = (_r = object.childWorkflowKey) !== null && _r !== void 0 ? _r : undefined;
1395
1410
  message.parentWorkflowRunId = (_s = object.parentWorkflowRunId) !== null && _s !== void 0 ? _s : undefined;
1411
+ message.priority = (_t = object.priority) !== null && _t !== void 0 ? _t : 0;
1396
1412
  return message;
1397
1413
  },
1398
1414
  };
@@ -97,6 +97,8 @@ export interface CreateWorkflowVersionRequest {
97
97
  onFailureTask?: CreateTaskOpts | undefined;
98
98
  /** (optional) the sticky strategy for assigning steps to workers */
99
99
  sticky?: StickyStrategy | undefined;
100
+ /** (optional) the default priority for the workflow */
101
+ defaultPriority?: number | undefined;
100
102
  }
101
103
  export interface Concurrency {
102
104
  /** (required) the expression to use for concurrency */
@@ -758,6 +758,7 @@ function createBaseCreateWorkflowVersionRequest() {
758
758
  cronInput: undefined,
759
759
  onFailureTask: undefined,
760
760
  sticky: undefined,
761
+ defaultPriority: undefined,
761
762
  };
762
763
  }
763
764
  exports.CreateWorkflowVersionRequest = {
@@ -792,6 +793,9 @@ exports.CreateWorkflowVersionRequest = {
792
793
  if (message.sticky !== undefined) {
793
794
  writer.uint32(80).int32(message.sticky);
794
795
  }
796
+ if (message.defaultPriority !== undefined) {
797
+ writer.uint32(88).int32(message.defaultPriority);
798
+ }
795
799
  return writer;
796
800
  },
797
801
  decode(input, length) {
@@ -871,6 +875,13 @@ exports.CreateWorkflowVersionRequest = {
871
875
  message.sticky = reader.int32();
872
876
  continue;
873
877
  }
878
+ case 11: {
879
+ if (tag !== 88) {
880
+ break;
881
+ }
882
+ message.defaultPriority = reader.int32();
883
+ continue;
884
+ }
874
885
  }
875
886
  if ((tag & 7) === 4 || tag === 0) {
876
887
  break;
@@ -899,6 +910,9 @@ exports.CreateWorkflowVersionRequest = {
899
910
  ? exports.CreateTaskOpts.fromJSON(object.onFailureTask)
900
911
  : undefined,
901
912
  sticky: isSet(object.sticky) ? stickyStrategyFromJSON(object.sticky) : undefined,
913
+ defaultPriority: isSet(object.defaultPriority)
914
+ ? globalThis.Number(object.defaultPriority)
915
+ : undefined,
902
916
  };
903
917
  },
904
918
  toJSON(message) {
@@ -934,13 +948,16 @@ exports.CreateWorkflowVersionRequest = {
934
948
  if (message.sticky !== undefined) {
935
949
  obj.sticky = stickyStrategyToJSON(message.sticky);
936
950
  }
951
+ if (message.defaultPriority !== undefined) {
952
+ obj.defaultPriority = Math.round(message.defaultPriority);
953
+ }
937
954
  return obj;
938
955
  },
939
956
  create(base) {
940
957
  return exports.CreateWorkflowVersionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
941
958
  },
942
959
  fromPartial(object) {
943
- var _a, _b, _c, _d, _e, _f, _g, _h;
960
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
944
961
  const message = createBaseCreateWorkflowVersionRequest();
945
962
  message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
946
963
  message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
@@ -958,6 +975,7 @@ exports.CreateWorkflowVersionRequest = {
958
975
  ? exports.CreateTaskOpts.fromPartial(object.onFailureTask)
959
976
  : undefined;
960
977
  message.sticky = (_h = object.sticky) !== null && _h !== void 0 ? _h : undefined;
978
+ message.defaultPriority = (_j = object.defaultPriority) !== null && _j !== void 0 ? _j : undefined;
961
979
  return message;
962
980
  },
963
981
  };
@@ -195,6 +195,8 @@ export interface ScheduleWorkflowRequest {
195
195
  childKey?: string | undefined;
196
196
  /** (optional) the additional metadata for the workflow */
197
197
  additionalMetadata?: string | undefined;
198
+ /** (optional) the priority of the workflow */
199
+ priority: number;
198
200
  }
199
201
  /** ScheduledWorkflow represents a scheduled workflow. */
200
202
  export interface ScheduledWorkflow {
@@ -1409,6 +1409,7 @@ function createBaseScheduleWorkflowRequest() {
1409
1409
  childIndex: undefined,
1410
1410
  childKey: undefined,
1411
1411
  additionalMetadata: undefined,
1412
+ priority: 0,
1412
1413
  };
1413
1414
  }
1414
1415
  exports.ScheduleWorkflowRequest = {
@@ -1437,6 +1438,9 @@ exports.ScheduleWorkflowRequest = {
1437
1438
  if (message.additionalMetadata !== undefined) {
1438
1439
  writer.uint32(66).string(message.additionalMetadata);
1439
1440
  }
1441
+ if (message.priority !== 0) {
1442
+ writer.uint32(72).int32(message.priority);
1443
+ }
1440
1444
  return writer;
1441
1445
  },
1442
1446
  decode(input, length) {
@@ -1502,6 +1506,13 @@ exports.ScheduleWorkflowRequest = {
1502
1506
  message.additionalMetadata = reader.string();
1503
1507
  continue;
1504
1508
  }
1509
+ case 9: {
1510
+ if (tag !== 72) {
1511
+ break;
1512
+ }
1513
+ message.priority = reader.int32();
1514
+ continue;
1515
+ }
1505
1516
  }
1506
1517
  if ((tag & 7) === 4 || tag === 0) {
1507
1518
  break;
@@ -1526,6 +1537,7 @@ exports.ScheduleWorkflowRequest = {
1526
1537
  additionalMetadata: isSet(object.additionalMetadata)
1527
1538
  ? globalThis.String(object.additionalMetadata)
1528
1539
  : undefined,
1540
+ priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0,
1529
1541
  };
1530
1542
  },
1531
1543
  toJSON(message) {
@@ -1555,13 +1567,16 @@ exports.ScheduleWorkflowRequest = {
1555
1567
  if (message.additionalMetadata !== undefined) {
1556
1568
  obj.additionalMetadata = message.additionalMetadata;
1557
1569
  }
1570
+ if (message.priority !== 0) {
1571
+ obj.priority = Math.round(message.priority);
1572
+ }
1558
1573
  return obj;
1559
1574
  },
1560
1575
  create(base) {
1561
1576
  return exports.ScheduleWorkflowRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1562
1577
  },
1563
1578
  fromPartial(object) {
1564
- var _a, _b, _c, _d, _e, _f, _g, _h;
1579
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1565
1580
  const message = createBaseScheduleWorkflowRequest();
1566
1581
  message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
1567
1582
  message.schedules = ((_b = object.schedules) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
@@ -1571,6 +1586,7 @@ exports.ScheduleWorkflowRequest = {
1571
1586
  message.childIndex = (_f = object.childIndex) !== null && _f !== void 0 ? _f : undefined;
1572
1587
  message.childKey = (_g = object.childKey) !== null && _g !== void 0 ? _g : undefined;
1573
1588
  message.additionalMetadata = (_h = object.additionalMetadata) !== null && _h !== void 0 ? _h : undefined;
1589
+ message.priority = (_j = object.priority) !== null && _j !== void 0 ? _j : 0;
1574
1590
  return message;
1575
1591
  },
1576
1592
  };
package/step.d.ts CHANGED
@@ -8,8 +8,8 @@ import WorkflowRunRef from './util/workflow-run-ref';
8
8
  import { V0Worker } from './clients/worker';
9
9
  import { WorkerLabels } from './clients/dispatcher/dispatcher-client';
10
10
  import { CreateStepRateLimit, RateLimitDuration, WorkerLabelComparator } from './protoc/workflows';
11
- import { CreateWorkflowTaskOpts } from './v1/task';
12
- import { TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
11
+ import { CreateWorkflowTaskOpts, Priority } from './v1';
12
+ import { RunOpts, TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
13
13
  import { Conditions } from './v1/conditions';
14
14
  import { Duration } from './v1/client/duration';
15
15
  import { JsonObject, JsonValue, OutputType } from './v1/types';
@@ -155,6 +155,10 @@ export type NextStep = {
155
155
  [key: string]: JsonValue;
156
156
  };
157
157
  type TriggerData = Record<string, Record<string, any>>;
158
+ type ChildRunOpts = RunOpts & {
159
+ key?: string;
160
+ sticky?: boolean;
161
+ };
158
162
  interface ContextData<T, K> {
159
163
  input: T;
160
164
  triggers: TriggerData;
@@ -314,11 +318,7 @@ export declare class Context<T, K = {}> {
314
318
  bulkRunNoWaitChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
315
319
  workflow: string | Workflow | WorkflowV1<Q, P>;
316
320
  input: Q;
317
- options?: {
318
- key?: string;
319
- sticky?: boolean;
320
- additionalMetadata?: Record<string, string>;
321
- };
321
+ options?: ChildRunOpts;
322
322
  }>): Promise<WorkflowRunRef<P>[]>;
323
323
  /**
324
324
  * Runs multiple children workflows in parallel and waits for all results.
@@ -328,11 +328,7 @@ export declare class Context<T, K = {}> {
328
328
  bulkRunChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
329
329
  workflow: string | Workflow | WorkflowV1<Q, P>;
330
330
  input: Q;
331
- options?: {
332
- key?: string;
333
- sticky?: boolean;
334
- additionalMetadata?: Record<string, string>;
335
- };
331
+ options?: ChildRunOpts;
336
332
  }>): Promise<P[]>;
337
333
  /**
338
334
  * Spawns multiple workflows.
@@ -344,38 +340,26 @@ export declare class Context<T, K = {}> {
344
340
  spawnWorkflows<Q extends JsonObject = any, P extends JsonObject = any>(workflows: Array<{
345
341
  workflow: string | Workflow | WorkflowV1<Q, P>;
346
342
  input: Q;
347
- options?: {
348
- key?: string;
349
- sticky?: boolean;
350
- additionalMetadata?: Record<string, string>;
351
- };
343
+ options?: ChildRunOpts;
352
344
  }>): Promise<WorkflowRunRef<P>[]>;
353
345
  /**
354
346
  * Runs a new workflow and waits for its result.
355
347
  *
356
348
  * @param workflow - The workflow to run (name, Workflow instance, or WorkflowV1 instance).
357
349
  * @param input - The input data for the workflow.
358
- * @param optionsOrKey - Either a string key or an options object containing key, sticky, and additionalMetadata.
350
+ * @param options - An options object containing key, sticky, priority, and additionalMetadata.
359
351
  * @returns The result of the workflow.
360
352
  */
361
- runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, optionsOrKey?: string | {
362
- key?: string;
363
- sticky?: boolean;
364
- additionalMetadata?: Record<string, string>;
365
- }): Promise<P>;
353
+ runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: ChildRunOpts): Promise<P>;
366
354
  /**
367
355
  * Enqueues a new workflow without waiting for its result.
368
356
  *
369
357
  * @param workflow - The workflow to enqueue (name, Workflow instance, or WorkflowV1 instance).
370
358
  * @param input - The input data for the workflow.
371
- * @param optionsOrKey - Either a string key or an options object containing key, sticky, and additionalMetadata.
359
+ * @param options - An options object containing key, sticky, priority, and additionalMetadata.
372
360
  * @returns A reference to the spawned workflow run.
373
361
  */
374
- runNoWaitChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, optionsOrKey?: string | {
375
- key?: string;
376
- sticky?: boolean;
377
- additionalMetadata?: Record<string, string>;
378
- }): WorkflowRunRef<P>;
362
+ runNoWaitChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: ChildRunOpts): WorkflowRunRef<P>;
379
363
  /**
380
364
  * Spawns a new workflow.
381
365
  *
@@ -385,11 +369,7 @@ export declare class Context<T, K = {}> {
385
369
  * @returns A reference to the spawned workflow run.
386
370
  * @deprecated Use runChild or runNoWaitChild instead.
387
371
  */
388
- spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: string | {
389
- key?: string;
390
- sticky?: boolean;
391
- additionalMetadata?: Record<string, string>;
392
- }): WorkflowRunRef<P>;
372
+ spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: ChildRunOpts): WorkflowRunRef<P>;
393
373
  /**
394
374
  * Retrieves additional metadata associated with the current workflow run.
395
375
  * @returns A record of metadata key-value pairs.
@@ -410,6 +390,7 @@ export declare class Context<T, K = {}> {
410
390
  * @returns The parent workflow run ID, or undefined if not a child workflow.
411
391
  */
412
392
  parentWorkflowRunId(): string | undefined;
393
+ priority(): Priority | undefined;
413
394
  }
414
395
  export declare class DurableContext<T, K = {}> extends Context<T, K> {
415
396
  waitKey: number;
package/step.js CHANGED
@@ -53,6 +53,7 @@ const hatchet_error_1 = __importDefault(require("./util/errors/hatchet-error"));
53
53
  const z = __importStar(require("zod"));
54
54
  const parse_1 = require("./util/parse");
55
55
  const workflows_1 = require("./protoc/workflows");
56
+ const v1_1 = require("./v1");
56
57
  const declaration_1 = require("./v1/declaration");
57
58
  const conditions_1 = require("./v1/conditions");
58
59
  const condition_1 = require("./protoc/v1/shared/condition");
@@ -386,28 +387,15 @@ class Context {
386
387
  workflowName = workflow.id;
387
388
  }
388
389
  const name = this.client.config.namespace + workflowName;
389
- let key;
390
- let sticky = false;
391
- let metadata;
392
- if (options) {
393
- key = options.key;
394
- sticky = options.sticky;
395
- metadata = options.additionalMetadata;
396
- }
390
+ const opts = options || {};
391
+ const { sticky } = opts;
397
392
  if (sticky && !this.worker.hasWorkflow(name)) {
398
393
  throw new hatchet_error_1.default(`Cannot run with sticky: workflow ${name} is not registered on the worker`);
399
394
  }
400
395
  const resp = {
401
396
  workflowName: name,
402
397
  input,
403
- options: {
404
- parentId: workflowRunId,
405
- parentStepRunId: stepRunId,
406
- childKey: key,
407
- childIndex: this.spawnIndex,
408
- desiredWorkerId: sticky ? this.worker.id() : undefined,
409
- additionalMetadata: metadata,
410
- },
398
+ options: Object.assign(Object.assign({}, opts), { parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }),
411
399
  };
412
400
  this.spawnIndex += 1;
413
401
  return resp;
@@ -441,12 +429,12 @@ class Context {
441
429
  *
442
430
  * @param workflow - The workflow to run (name, Workflow instance, or WorkflowV1 instance).
443
431
  * @param input - The input data for the workflow.
444
- * @param optionsOrKey - Either a string key or an options object containing key, sticky, and additionalMetadata.
432
+ * @param options - An options object containing key, sticky, priority, and additionalMetadata.
445
433
  * @returns The result of the workflow.
446
434
  */
447
- runChild(workflow, input, optionsOrKey) {
435
+ runChild(workflow, input, options) {
448
436
  return __awaiter(this, void 0, void 0, function* () {
449
- const run = yield this.spawnWorkflow(workflow, input, optionsOrKey);
437
+ const run = yield this.spawnWorkflow(workflow, input, options);
450
438
  return run.output;
451
439
  });
452
440
  }
@@ -455,11 +443,11 @@ class Context {
455
443
  *
456
444
  * @param workflow - The workflow to enqueue (name, Workflow instance, or WorkflowV1 instance).
457
445
  * @param input - The input data for the workflow.
458
- * @param optionsOrKey - Either a string key or an options object containing key, sticky, and additionalMetadata.
446
+ * @param options - An options object containing key, sticky, priority, and additionalMetadata.
459
447
  * @returns A reference to the spawned workflow run.
460
448
  */
461
- runNoWaitChild(workflow, input, optionsOrKey) {
462
- return this.spawnWorkflow(workflow, input, optionsOrKey);
449
+ runNoWaitChild(workflow, input, options) {
450
+ return this.spawnWorkflow(workflow, input, options);
463
451
  }
464
452
  /**
465
453
  * Spawns a new workflow.
@@ -480,30 +468,13 @@ class Context {
480
468
  workflowName = workflow.id;
481
469
  }
482
470
  const name = this.client.config.namespace + workflowName;
483
- let key = '';
484
- let sticky = false;
485
- let metadata;
486
- if (typeof options === 'string') {
487
- this.logger.warn('Using key param is deprecated and will be removed in a future release. Use options.key instead.');
488
- key = options;
489
- }
490
- else {
491
- key = options === null || options === void 0 ? void 0 : options.key;
492
- sticky = options === null || options === void 0 ? void 0 : options.sticky;
493
- metadata = options === null || options === void 0 ? void 0 : options.additionalMetadata;
494
- }
471
+ const opts = options || {};
472
+ const { sticky } = opts;
495
473
  if (sticky && !this.worker.hasWorkflow(name)) {
496
474
  throw new hatchet_error_1.default(`cannot run with sticky: workflow ${name} is not registered on the worker`);
497
475
  }
498
476
  try {
499
- const resp = this.client.admin.runWorkflow(name, input, {
500
- parentId: workflowRunId,
501
- parentStepRunId: stepRunId,
502
- childKey: key,
503
- childIndex: this.spawnIndex,
504
- desiredWorkerId: sticky ? this.worker.id() : undefined,
505
- additionalMetadata: metadata,
506
- });
477
+ const resp = this.client.admin.runWorkflow(name, input, Object.assign({ parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }, opts));
507
478
  this.spawnIndex += 1;
508
479
  if (workflow instanceof declaration_1.TaskWorkflowDeclaration) {
509
480
  resp._standalone_task_name = workflow._standalone_task_name;
@@ -547,6 +518,18 @@ class Context {
547
518
  parentWorkflowRunId() {
548
519
  return this.action.parentWorkflowRunId;
549
520
  }
521
+ priority() {
522
+ switch (this.action.priority) {
523
+ case 1:
524
+ return v1_1.Priority.LOW;
525
+ case 2:
526
+ return v1_1.Priority.MEDIUM;
527
+ case 3:
528
+ return v1_1.Priority.HIGH;
529
+ default:
530
+ return undefined;
531
+ }
532
+ }
550
533
  }
551
534
  exports.Context = Context;
552
535
  class DurableContext extends Context {
@@ -44,7 +44,7 @@ const token_1 = require("./token");
44
44
  const DEFAULT_CONFIG_FILE = '.hatchet.yaml';
45
45
  class ConfigLoader {
46
46
  static loadClientConfig(override, config) {
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
48
48
  const yaml = this.loadYamlConfig(config === null || config === void 0 ? void 0 : config.path);
49
49
  const tlsConfig = (_a = override === null || override === void 0 ? void 0 : override.tls_config) !== null && _a !== void 0 ? _a : {
50
50
  tls_strategy: (_d = (_c = (_b = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _b === void 0 ? void 0 : _b.tls_strategy) !== null && _c !== void 0 ? _c : this.env('HATCHET_CLIENT_TLS_STRATEGY')) !== null && _d !== void 0 ? _d : 'tls',
@@ -76,18 +76,14 @@ class ConfigLoader {
76
76
  apiUrl = (_z = (_y = override === null || override === void 0 ? void 0 : override.api_url) !== null && _y !== void 0 ? _y : yaml === null || yaml === void 0 ? void 0 : yaml.api_url) !== null && _z !== void 0 ? _z : this.env('HATCHET_CLIENT_API_URL');
77
77
  }
78
78
  const namespace = (_1 = (_0 = override === null || override === void 0 ? void 0 : override.namespace) !== null && _0 !== void 0 ? _0 : yaml === null || yaml === void 0 ? void 0 : yaml.namespace) !== null && _1 !== void 0 ? _1 : this.env('HATCHET_CLIENT_NAMESPACE');
79
- const grpcMaxSendMessageLength = (_3 = (_2 = override === null || override === void 0 ? void 0 : override.grpc_max_send_message_length) !== null && _2 !== void 0 ? _2 : yaml === null || yaml === void 0 ? void 0 : yaml.grpc_max_send_message_length) !== null && _3 !== void 0 ? _3 : parseInt((_4 = this.env('HATCHET_CLIENT_GRPC_MAX_SEND_MESSAGE_LENGTH')) !== null && _4 !== void 0 ? _4 : '-1', 10);
80
- const grpcMaxRecvMessageLength = (_6 = (_5 = override === null || override === void 0 ? void 0 : override.grpc_max_recv_message_length) !== null && _5 !== void 0 ? _5 : yaml === null || yaml === void 0 ? void 0 : yaml.grpc_max_recv_message_length) !== null && _6 !== void 0 ? _6 : parseInt((_7 = this.env('HATCHET_CLIENT_GRPC_MAX_RECV_MESSAGE_LENGTH')) !== null && _7 !== void 0 ? _7 : '-1', 10);
81
79
  return {
82
- token: (_9 = (_8 = override === null || override === void 0 ? void 0 : override.token) !== null && _8 !== void 0 ? _8 : yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _9 !== void 0 ? _9 : this.env('HATCHET_CLIENT_TOKEN'),
80
+ token: (_3 = (_2 = override === null || override === void 0 ? void 0 : override.token) !== null && _2 !== void 0 ? _2 : yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _3 !== void 0 ? _3 : this.env('HATCHET_CLIENT_TOKEN'),
83
81
  host_port: grpcBroadcastAddress,
84
82
  api_url: apiUrl,
85
83
  tls_config: tlsConfig,
86
- log_level: (_12 = (_11 = (_10 = override === null || override === void 0 ? void 0 : override.log_level) !== null && _10 !== void 0 ? _10 : yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _11 !== void 0 ? _11 : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _12 !== void 0 ? _12 : 'INFO',
84
+ log_level: (_6 = (_5 = (_4 = override === null || override === void 0 ? void 0 : override.log_level) !== null && _4 !== void 0 ? _4 : yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _5 !== void 0 ? _5 : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _6 !== void 0 ? _6 : 'INFO',
87
85
  tenant_id: tenantId,
88
86
  namespace: namespace ? `${namespace}_`.toLowerCase() : '',
89
- grpc_max_send_message_length: grpcMaxSendMessageLength > 0 ? grpcMaxSendMessageLength : undefined,
90
- grpc_max_recv_message_length: grpcMaxRecvMessageLength > 0 ? grpcMaxRecvMessageLength : undefined,
91
87
  };
92
88
  }
93
89
  static get default_yaml_config_path() {
@@ -7,6 +7,11 @@ import { CreateWorkflowTaskOpts, CreateOnFailureTaskOpts, TaskConcurrency, TaskF
7
7
  import { Duration } from './client/duration';
8
8
  import { MetricsClient } from './client/features/metrics';
9
9
  import { InputType, OutputType, UnknownInputType, JsonObject } from './types';
10
+ export declare enum Priority {
11
+ LOW = 1,
12
+ MEDIUM = 2,
13
+ HIGH = 3
14
+ }
10
15
  /**
11
16
  * Additional metadata that can be attached to a workflow run.
12
17
  */
@@ -16,9 +21,15 @@ type AdditionalMetadata = Record<string, string>;
16
21
  */
17
22
  export type RunOpts = {
18
23
  /**
19
- * Additional metadata to attach to the workflow run.
24
+ * (optional) additional metadata to attach to the workflow run.
20
25
  */
21
26
  additionalMetadata?: AdditionalMetadata;
27
+ /**
28
+ * (optional) the priority for the workflow run.
29
+ *
30
+ * values: Priority.LOW, Priority.MEDIUM, Priority.HIGH (1, 2, or 3 )
31
+ */
32
+ priority?: Priority;
22
33
  };
23
34
  /**
24
35
  * Helper type to safely extract output types from task results
@@ -59,6 +70,11 @@ export type CreateBaseWorkflowOpts = {
59
70
  */
60
71
  onEvents?: string[];
61
72
  concurrency?: TaskConcurrency;
73
+ /**
74
+ * (optional) the priority for the workflow.
75
+ * values: Priority.LOW, Priority.MEDIUM, Priority.HIGH (1, 2, or 3 )
76
+ */
77
+ defaultPriority?: Priority;
62
78
  };
63
79
  export type CreateTaskWorkflowOpts<I extends InputType = UnknownInputType, O extends OutputType = void> = CreateBaseWorkflowOpts & CreateBaseTaskOpts<I, O, TaskFn<I, O>>;
64
80
  export type CreateDurableTaskWorkflowOpts<I extends InputType = UnknownInputType, O extends OutputType = void> = CreateBaseWorkflowOpts & CreateBaseTaskOpts<I, O, DurableTaskFn<I, O>>;
package/v1/declaration.js CHANGED
@@ -9,11 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TaskWorkflowDeclaration = exports.WorkflowDeclaration = exports.BaseWorkflowDeclaration = void 0;
12
+ exports.TaskWorkflowDeclaration = exports.WorkflowDeclaration = exports.BaseWorkflowDeclaration = exports.Priority = void 0;
13
13
  exports.CreateTaskWorkflow = CreateTaskWorkflow;
14
14
  exports.CreateWorkflow = CreateWorkflow;
15
15
  exports.CreateDurableTaskWorkflow = CreateDurableTaskWorkflow;
16
16
  const UNBOUND_ERR = new Error('workflow unbound to hatchet client, hint: use client.run instead');
17
+ // eslint-disable-next-line no-shadow
18
+ var Priority;
19
+ (function (Priority) {
20
+ Priority[Priority["LOW"] = 1] = "LOW";
21
+ Priority[Priority["MEDIUM"] = 2] = "MEDIUM";
22
+ Priority[Priority["HIGH"] = 3] = "HIGH";
23
+ })(Priority || (exports.Priority = Priority = {}));
17
24
  /**
18
25
  * Represents a workflow that can be executed by Hatchet.
19
26
  * @template I The input type for the workflow.
@@ -104,11 +111,7 @@ class BaseWorkflowDeclaration {
104
111
  if (!this.client) {
105
112
  throw UNBOUND_ERR;
106
113
  }
107
- const scheduled = this.client._v0.schedule.create(this.definition.name, {
108
- triggerAt: enqueueAt,
109
- input: input,
110
- additionalMetadata: options === null || options === void 0 ? void 0 : options.additionalMetadata,
111
- });
114
+ const scheduled = this.client._v0.schedule.create(this.definition.name, Object.assign({ triggerAt: enqueueAt, input: input }, options));
112
115
  return scheduled;
113
116
  });
114
117
  }
@@ -141,12 +144,7 @@ class BaseWorkflowDeclaration {
141
144
  if (!this.client) {
142
145
  throw UNBOUND_ERR;
143
146
  }
144
- const cronDef = this.client._v0.cron.create(this.definition.name, {
145
- expression,
146
- input: input,
147
- additionalMetadata: options === null || options === void 0 ? void 0 : options.additionalMetadata,
148
- name,
149
- });
147
+ const cronDef = this.client._v0.cron.create(this.definition.name, Object.assign(Object.assign({ expression, input: input }, options), { additionalMetadata: options === null || options === void 0 ? void 0 : options.additionalMetadata, name }));
150
148
  return cronDef;
151
149
  });
152
150
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const v1_1 = require("../..");
13
+ const workflow_1 = require("./workflow");
14
+ /* eslint-disable no-console */
15
+ function main() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ try {
18
+ console.log('running priority workflow');
19
+ // ❓ Run a Task with a Priority
20
+ const run = workflow_1.priority.run(new Date(Date.now() + 60 * 60 * 1000), { priority: v1_1.Priority.HIGH });
21
+ // !!
22
+ // ❓ Schedule and cron
23
+ const scheduled = workflow_1.priority.schedule(new Date(Date.now() + 60 * 60 * 1000), {}, { priority: v1_1.Priority.HIGH });
24
+ const delayed = workflow_1.priority.delay(60 * 60 * 1000, {}, { priority: v1_1.Priority.HIGH });
25
+ const cron = workflow_1.priority.cron(`daily-cron-${Math.random()}`, '0 0 * * *', {}, { priority: v1_1.Priority.HIGH });
26
+ // !!
27
+ const [scheduledResult, delayedResult] = yield Promise.all([scheduled, delayed]);
28
+ console.log('scheduledResult', scheduledResult);
29
+ console.log('delayedResult', delayedResult);
30
+ // !!
31
+ }
32
+ catch (e) {
33
+ console.log('error', e);
34
+ }
35
+ });
36
+ }
37
+ if (require.main === module) {
38
+ main()
39
+ .catch(console.error)
40
+ .finally(() => process.exit(0));
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const hatchet_client_1 = require("../hatchet-client");
13
+ const workflow_1 = require("./workflow");
14
+ function main() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const worker = yield hatchet_client_1.hatchet.worker('priority-worker', {
17
+ workflows: [...workflow_1.priorityTasks],
18
+ });
19
+ yield worker.start();
20
+ });
21
+ }
22
+ if (require.main === module) {
23
+ main();
24
+ }
@@ -0,0 +1,8 @@
1
+ import { Priority } from '../..';
2
+ export declare const priority: import("../..").TaskWorkflowDeclaration<import("../..").UnknownInputType, {
3
+ priority: Priority | undefined;
4
+ }>;
5
+ export declare const priorityWf: import("../..").WorkflowDeclaration<import("../..").UnknownInputType, {}>;
6
+ export declare const priorityTasks: (import("../..").WorkflowDeclaration<import("../..").UnknownInputType, {}> | import("../..").TaskWorkflowDeclaration<import("../..").UnknownInputType, {
7
+ priority: Priority | undefined;
8
+ }>)[];
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.priorityTasks = exports.priorityWf = exports.priority = void 0;
13
+ /* eslint-disable no-console */
14
+ const v1_1 = require("../..");
15
+ const hatchet_client_1 = require("../hatchet-client");
16
+ // ❓ Simple Task Priority
17
+ exports.priority = hatchet_client_1.hatchet.task({
18
+ name: 'priority',
19
+ defaultPriority: v1_1.Priority.MEDIUM,
20
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
21
+ return {
22
+ priority: ctx.priority(),
23
+ };
24
+ }),
25
+ });
26
+ // !!
27
+ // ❓ Task Priority in a Workflow
28
+ exports.priorityWf = hatchet_client_1.hatchet.workflow({
29
+ name: 'priorityWf',
30
+ defaultPriority: v1_1.Priority.LOW,
31
+ });
32
+ // !!
33
+ exports.priorityWf.task({
34
+ name: 'child-medium',
35
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
36
+ return {
37
+ priority: ctx.priority(),
38
+ };
39
+ }),
40
+ });
41
+ exports.priorityWf.task({
42
+ name: 'child-high',
43
+ // will inherit the default priority from the workflow
44
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
45
+ return {
46
+ priority: ctx.priority(),
47
+ };
48
+ }),
49
+ });
50
+ exports.priorityTasks = [exports.priority, exports.priorityWf];
package/v1/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './declaration';
5
5
  export * from './conditions';
6
6
  export * from './client/duration';
7
7
  export * from './types';
8
+ export * from './task';
package/v1/index.js CHANGED
@@ -21,3 +21,4 @@ __exportStar(require("./declaration"), exports);
21
21
  __exportStar(require("./conditions"), exports);
22
22
  __exportStar(require("./client/duration"), exports);
23
23
  __exportStar(require("./types"), exports);
24
+ __exportStar(require("./task"), exports);
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.1.8-alpha.2";
1
+ export declare const HATCHET_VERSION = "1.2.0";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '1.1.8-alpha.2';
4
+ exports.HATCHET_VERSION = '1.2.0';