@hatchet-dev/typescript-sdk 1.17.0 → 1.17.2

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v2.7.7
4
+ // protoc-gen-ts_proto v2.11.4
5
5
  // protoc v3.19.1
6
6
  // source: workflows/workflows.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -439,13 +439,19 @@ exports.CreateWorkflowVersionOpts = {
439
439
  version: isSet(object.version) ? globalThis.String(object.version) : '',
440
440
  eventTriggers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.eventTriggers)
441
441
  ? object.eventTriggers.map((e) => globalThis.String(e))
442
- : [],
442
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.event_triggers)
443
+ ? object.event_triggers.map((e) => globalThis.String(e))
444
+ : [],
443
445
  cronTriggers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.cronTriggers)
444
446
  ? object.cronTriggers.map((e) => globalThis.String(e))
445
- : [],
447
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.cron_triggers)
448
+ ? object.cron_triggers.map((e) => globalThis.String(e))
449
+ : [],
446
450
  scheduledTriggers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.scheduledTriggers)
447
451
  ? object.scheduledTriggers.map((e) => fromJsonTimestamp(e))
448
- : [],
452
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.scheduled_triggers)
453
+ ? object.scheduled_triggers.map((e) => fromJsonTimestamp(e))
454
+ : [],
449
455
  jobs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.jobs)
450
456
  ? object.jobs.map((e) => exports.CreateWorkflowJobOpts.fromJSON(e))
451
457
  : [],
@@ -454,16 +460,26 @@ exports.CreateWorkflowVersionOpts = {
454
460
  : undefined,
455
461
  scheduleTimeout: isSet(object.scheduleTimeout)
456
462
  ? globalThis.String(object.scheduleTimeout)
457
- : undefined,
458
- cronInput: isSet(object.cronInput) ? globalThis.String(object.cronInput) : undefined,
463
+ : isSet(object.schedule_timeout)
464
+ ? globalThis.String(object.schedule_timeout)
465
+ : undefined,
466
+ cronInput: isSet(object.cronInput)
467
+ ? globalThis.String(object.cronInput)
468
+ : isSet(object.cron_input)
469
+ ? globalThis.String(object.cron_input)
470
+ : undefined,
459
471
  onFailureJob: isSet(object.onFailureJob)
460
472
  ? exports.CreateWorkflowJobOpts.fromJSON(object.onFailureJob)
461
- : undefined,
473
+ : isSet(object.on_failure_job)
474
+ ? exports.CreateWorkflowJobOpts.fromJSON(object.on_failure_job)
475
+ : undefined,
462
476
  sticky: isSet(object.sticky) ? stickyStrategyFromJSON(object.sticky) : undefined,
463
477
  kind: isSet(object.kind) ? workflowKindFromJSON(object.kind) : undefined,
464
478
  defaultPriority: isSet(object.defaultPriority)
465
479
  ? globalThis.Number(object.defaultPriority)
466
- : undefined,
480
+ : isSet(object.default_priority)
481
+ ? globalThis.Number(object.default_priority)
482
+ : undefined,
467
483
  };
468
484
  },
469
485
  toJSON(message) {
@@ -607,10 +623,16 @@ exports.WorkflowConcurrencyOpts = {
607
623
  fromJSON(object) {
608
624
  return {
609
625
  action: isSet(object.action) ? globalThis.String(object.action) : undefined,
610
- maxRuns: isSet(object.maxRuns) ? globalThis.Number(object.maxRuns) : undefined,
626
+ maxRuns: isSet(object.maxRuns)
627
+ ? globalThis.Number(object.maxRuns)
628
+ : isSet(object.max_runs)
629
+ ? globalThis.Number(object.max_runs)
630
+ : undefined,
611
631
  limitStrategy: isSet(object.limitStrategy)
612
632
  ? concurrencyLimitStrategyFromJSON(object.limitStrategy)
613
- : undefined,
633
+ : isSet(object.limit_strategy)
634
+ ? concurrencyLimitStrategyFromJSON(object.limit_strategy)
635
+ : undefined,
614
636
  expression: isSet(object.expression) ? globalThis.String(object.expression) : undefined,
615
637
  };
616
638
  },
@@ -771,7 +793,7 @@ exports.CreateWorkflowStepOpts = {
771
793
  for (const v of message.rateLimits) {
772
794
  exports.CreateStepRateLimit.encode(v, writer.uint32(66).fork()).join();
773
795
  }
774
- Object.entries(message.workerLabels).forEach(([key, value]) => {
796
+ globalThis.Object.entries(message.workerLabels).forEach(([key, value]) => {
775
797
  exports.CreateWorkflowStepOpts_WorkerLabelsEntry.encode({ key: key, value }, writer.uint32(74).fork()).join();
776
798
  });
777
799
  if (message.backoffFactor !== undefined) {
@@ -879,30 +901,49 @@ exports.CreateWorkflowStepOpts = {
879
901
  },
880
902
  fromJSON(object) {
881
903
  return {
882
- readableId: isSet(object.readableId) ? globalThis.String(object.readableId) : '',
904
+ readableId: isSet(object.readableId)
905
+ ? globalThis.String(object.readableId)
906
+ : isSet(object.readable_id)
907
+ ? globalThis.String(object.readable_id)
908
+ : '',
883
909
  action: isSet(object.action) ? globalThis.String(object.action) : '',
884
910
  timeout: isSet(object.timeout) ? globalThis.String(object.timeout) : '',
885
911
  inputs: isSet(object.inputs) ? globalThis.String(object.inputs) : '',
886
912
  parents: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.parents)
887
913
  ? object.parents.map((e) => globalThis.String(e))
888
914
  : [],
889
- userData: isSet(object.userData) ? globalThis.String(object.userData) : '',
915
+ userData: isSet(object.userData)
916
+ ? globalThis.String(object.userData)
917
+ : isSet(object.user_data)
918
+ ? globalThis.String(object.user_data)
919
+ : '',
890
920
  retries: isSet(object.retries) ? globalThis.Number(object.retries) : 0,
891
921
  rateLimits: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.rateLimits)
892
922
  ? object.rateLimits.map((e) => exports.CreateStepRateLimit.fromJSON(e))
893
- : [],
923
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.rate_limits)
924
+ ? object.rate_limits.map((e) => exports.CreateStepRateLimit.fromJSON(e))
925
+ : [],
894
926
  workerLabels: isObject(object.workerLabels)
895
- ? Object.entries(object.workerLabels).reduce((acc, [key, value]) => {
927
+ ? globalThis.Object.entries(object.workerLabels).reduce((acc, [key, value]) => {
896
928
  acc[key] = trigger_1.DesiredWorkerLabels.fromJSON(value);
897
929
  return acc;
898
930
  }, {})
899
- : {},
931
+ : isObject(object.worker_labels)
932
+ ? globalThis.Object.entries(object.worker_labels).reduce((acc, [key, value]) => {
933
+ acc[key] = trigger_1.DesiredWorkerLabels.fromJSON(value);
934
+ return acc;
935
+ }, {})
936
+ : {},
900
937
  backoffFactor: isSet(object.backoffFactor)
901
938
  ? globalThis.Number(object.backoffFactor)
902
- : undefined,
939
+ : isSet(object.backoff_factor)
940
+ ? globalThis.Number(object.backoff_factor)
941
+ : undefined,
903
942
  backoffMaxSeconds: isSet(object.backoffMaxSeconds)
904
943
  ? globalThis.Number(object.backoffMaxSeconds)
905
- : undefined,
944
+ : isSet(object.backoff_max_seconds)
945
+ ? globalThis.Number(object.backoff_max_seconds)
946
+ : undefined,
906
947
  };
907
948
  },
908
949
  toJSON(message) {
@@ -933,7 +974,7 @@ exports.CreateWorkflowStepOpts = {
933
974
  obj.rateLimits = message.rateLimits.map((e) => exports.CreateStepRateLimit.toJSON(e));
934
975
  }
935
976
  if (message.workerLabels) {
936
- const entries = Object.entries(message.workerLabels);
977
+ const entries = globalThis.Object.entries(message.workerLabels);
937
978
  if (entries.length > 0) {
938
979
  obj.workerLabels = {};
939
980
  entries.forEach(([k, v]) => {
@@ -963,7 +1004,7 @@ exports.CreateWorkflowStepOpts = {
963
1004
  message.userData = (_f = object.userData) !== null && _f !== void 0 ? _f : '';
964
1005
  message.retries = (_g = object.retries) !== null && _g !== void 0 ? _g : 0;
965
1006
  message.rateLimits = ((_h = object.rateLimits) === null || _h === void 0 ? void 0 : _h.map((e) => exports.CreateStepRateLimit.fromPartial(e))) || [];
966
- message.workerLabels = Object.entries((_j = object.workerLabels) !== null && _j !== void 0 ? _j : {}).reduce((acc, [key, value]) => {
1007
+ message.workerLabels = globalThis.Object.entries((_j = object.workerLabels) !== null && _j !== void 0 ? _j : {}).reduce((acc, [key, value]) => {
967
1008
  if (value !== undefined) {
968
1009
  acc[key] = trigger_1.DesiredWorkerLabels.fromPartial(value);
969
1010
  }
@@ -1139,11 +1180,21 @@ exports.CreateStepRateLimit = {
1139
1180
  return {
1140
1181
  key: isSet(object.key) ? globalThis.String(object.key) : '',
1141
1182
  units: isSet(object.units) ? globalThis.Number(object.units) : undefined,
1142
- keyExpr: isSet(object.keyExpr) ? globalThis.String(object.keyExpr) : undefined,
1143
- unitsExpr: isSet(object.unitsExpr) ? globalThis.String(object.unitsExpr) : undefined,
1183
+ keyExpr: isSet(object.keyExpr)
1184
+ ? globalThis.String(object.keyExpr)
1185
+ : isSet(object.key_expr)
1186
+ ? globalThis.String(object.key_expr)
1187
+ : undefined,
1188
+ unitsExpr: isSet(object.unitsExpr)
1189
+ ? globalThis.String(object.unitsExpr)
1190
+ : isSet(object.units_expr)
1191
+ ? globalThis.String(object.units_expr)
1192
+ : undefined,
1144
1193
  limitValuesExpr: isSet(object.limitValuesExpr)
1145
1194
  ? globalThis.String(object.limitValuesExpr)
1146
- : undefined,
1195
+ : isSet(object.limit_values_expr)
1196
+ ? globalThis.String(object.limit_values_expr)
1197
+ : undefined,
1147
1198
  duration: isSet(object.duration) ? rateLimitDurationFromJSON(object.duration) : undefined,
1148
1199
  };
1149
1200
  },
@@ -1350,15 +1401,31 @@ exports.ScheduleWorkflowRequest = {
1350
1401
  ? object.schedules.map((e) => fromJsonTimestamp(e))
1351
1402
  : [],
1352
1403
  input: isSet(object.input) ? globalThis.String(object.input) : '',
1353
- parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : undefined,
1404
+ parentId: isSet(object.parentId)
1405
+ ? globalThis.String(object.parentId)
1406
+ : isSet(object.parent_id)
1407
+ ? globalThis.String(object.parent_id)
1408
+ : undefined,
1354
1409
  parentTaskRunExternalId: isSet(object.parentTaskRunExternalId)
1355
1410
  ? globalThis.String(object.parentTaskRunExternalId)
1356
- : undefined,
1357
- childIndex: isSet(object.childIndex) ? globalThis.Number(object.childIndex) : undefined,
1358
- childKey: isSet(object.childKey) ? globalThis.String(object.childKey) : undefined,
1411
+ : isSet(object.parent_task_run_external_id)
1412
+ ? globalThis.String(object.parent_task_run_external_id)
1413
+ : undefined,
1414
+ childIndex: isSet(object.childIndex)
1415
+ ? globalThis.Number(object.childIndex)
1416
+ : isSet(object.child_index)
1417
+ ? globalThis.Number(object.child_index)
1418
+ : undefined,
1419
+ childKey: isSet(object.childKey)
1420
+ ? globalThis.String(object.childKey)
1421
+ : isSet(object.child_key)
1422
+ ? globalThis.String(object.child_key)
1423
+ : undefined,
1359
1424
  additionalMetadata: isSet(object.additionalMetadata)
1360
1425
  ? globalThis.String(object.additionalMetadata)
1361
- : undefined,
1426
+ : isSet(object.additional_metadata)
1427
+ ? globalThis.String(object.additional_metadata)
1428
+ : undefined,
1362
1429
  priority: isSet(object.priority) ? globalThis.Number(object.priority) : undefined,
1363
1430
  };
1364
1431
  },
@@ -1457,7 +1524,11 @@ exports.ScheduledWorkflow = {
1457
1524
  fromJSON(object) {
1458
1525
  return {
1459
1526
  id: isSet(object.id) ? globalThis.String(object.id) : '',
1460
- triggerAt: isSet(object.triggerAt) ? fromJsonTimestamp(object.triggerAt) : undefined,
1527
+ triggerAt: isSet(object.triggerAt)
1528
+ ? fromJsonTimestamp(object.triggerAt)
1529
+ : isSet(object.trigger_at)
1530
+ ? fromJsonTimestamp(object.trigger_at)
1531
+ : undefined,
1461
1532
  };
1462
1533
  },
1463
1534
  toJSON(message) {
@@ -1584,14 +1655,28 @@ exports.WorkflowVersion = {
1584
1655
  fromJSON(object) {
1585
1656
  return {
1586
1657
  id: isSet(object.id) ? globalThis.String(object.id) : '',
1587
- createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
1588
- updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined,
1658
+ createdAt: isSet(object.createdAt)
1659
+ ? fromJsonTimestamp(object.createdAt)
1660
+ : isSet(object.created_at)
1661
+ ? fromJsonTimestamp(object.created_at)
1662
+ : undefined,
1663
+ updatedAt: isSet(object.updatedAt)
1664
+ ? fromJsonTimestamp(object.updatedAt)
1665
+ : isSet(object.updated_at)
1666
+ ? fromJsonTimestamp(object.updated_at)
1667
+ : undefined,
1589
1668
  version: isSet(object.version) ? globalThis.String(object.version) : '',
1590
1669
  order: isSet(object.order) ? globalThis.Number(object.order) : 0,
1591
- workflowId: isSet(object.workflowId) ? globalThis.String(object.workflowId) : '',
1670
+ workflowId: isSet(object.workflowId)
1671
+ ? globalThis.String(object.workflowId)
1672
+ : isSet(object.workflow_id)
1673
+ ? globalThis.String(object.workflow_id)
1674
+ : '',
1592
1675
  scheduledWorkflows: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.scheduledWorkflows)
1593
1676
  ? object.scheduledWorkflows.map((e) => exports.ScheduledWorkflow.fromJSON(e))
1594
- : [],
1677
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.scheduled_workflows)
1678
+ ? object.scheduled_workflows.map((e) => exports.ScheduledWorkflow.fromJSON(e))
1679
+ : [],
1595
1680
  };
1596
1681
  },
1597
1682
  toJSON(message) {
@@ -1681,8 +1766,16 @@ exports.WorkflowTriggerEventRef = {
1681
1766
  },
1682
1767
  fromJSON(object) {
1683
1768
  return {
1684
- parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : '',
1685
- eventKey: isSet(object.eventKey) ? globalThis.String(object.eventKey) : '',
1769
+ parentId: isSet(object.parentId)
1770
+ ? globalThis.String(object.parentId)
1771
+ : isSet(object.parent_id)
1772
+ ? globalThis.String(object.parent_id)
1773
+ : '',
1774
+ eventKey: isSet(object.eventKey)
1775
+ ? globalThis.String(object.eventKey)
1776
+ : isSet(object.event_key)
1777
+ ? globalThis.String(object.event_key)
1778
+ : '',
1686
1779
  };
1687
1780
  },
1688
1781
  toJSON(message) {
@@ -1750,7 +1843,11 @@ exports.WorkflowTriggerCronRef = {
1750
1843
  },
1751
1844
  fromJSON(object) {
1752
1845
  return {
1753
- parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : '',
1846
+ parentId: isSet(object.parentId)
1847
+ ? globalThis.String(object.parentId)
1848
+ : isSet(object.parent_id)
1849
+ ? globalThis.String(object.parent_id)
1850
+ : '',
1754
1851
  cron: isSet(object.cron) ? globalThis.String(object.cron) : '',
1755
1852
  };
1756
1853
  },
@@ -1868,7 +1965,9 @@ exports.BulkTriggerWorkflowResponse = {
1868
1965
  return {
1869
1966
  workflowRunIds: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.workflowRunIds)
1870
1967
  ? object.workflowRunIds.map((e) => globalThis.String(e))
1871
- : [],
1968
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.workflow_run_ids)
1969
+ ? object.workflow_run_ids.map((e) => globalThis.String(e))
1970
+ : [],
1872
1971
  };
1873
1972
  },
1874
1973
  toJSON(message) {
@@ -1923,7 +2022,11 @@ exports.TriggerWorkflowResponse = {
1923
2022
  },
1924
2023
  fromJSON(object) {
1925
2024
  return {
1926
- workflowRunId: isSet(object.workflowRunId) ? globalThis.String(object.workflowRunId) : '',
2025
+ workflowRunId: isSet(object.workflowRunId)
2026
+ ? globalThis.String(object.workflowRunId)
2027
+ : isSet(object.workflow_run_id)
2028
+ ? globalThis.String(object.workflow_run_id)
2029
+ : '',
1927
2030
  };
1928
2031
  },
1929
2032
  toJSON(message) {
@@ -1,3 +1,4 @@
1
+ import { TaskStats } from '../../../clients/rest/generated/data-contracts';
1
2
  import { HatchetClient } from '../client';
2
3
  export type TaskStatusMetrics = {
3
4
  cancelled: number;
@@ -26,4 +27,14 @@ export declare class MetricsClient {
26
27
  * @returns The queue metrics for the current tenant.
27
28
  */
28
29
  getQueueMetrics(opts?: Parameters<typeof this.api.tenantGetStepRunQueueMetrics>[1]): Promise<import("../../../clients/rest/generated/data-contracts").TenantStepRunQueueMetrics>;
30
+ /**
31
+ * Scrape Prometheus metrics for the tenant.
32
+ * @returns The metrics in Prometheus text format.
33
+ */
34
+ scrapePrometheusMetrics(): Promise<string>;
35
+ /**
36
+ * Get task statistics for the tenant.
37
+ * @returns A record mapping task names to their statistics.
38
+ */
39
+ getTaskStats(): Promise<TaskStats>;
29
40
  }
@@ -44,5 +44,25 @@ class MetricsClient {
44
44
  return data;
45
45
  });
46
46
  }
47
+ /**
48
+ * Scrape Prometheus metrics for the tenant.
49
+ * @returns The metrics in Prometheus text format.
50
+ */
51
+ scrapePrometheusMetrics() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const { data } = yield this.api.tenantGetPrometheusMetrics(this.tenantId);
54
+ return data;
55
+ });
56
+ }
57
+ /**
58
+ * Get task statistics for the tenant.
59
+ * @returns A record mapping task names to their statistics.
60
+ */
61
+ getTaskStats() {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const { data } = yield this.api.tenantGetTaskStats(this.tenantId);
64
+ return data;
65
+ });
66
+ }
47
67
  }
48
68
  exports.MetricsClient = MetricsClient;
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.17.0";
1
+ export declare const HATCHET_VERSION = "1.17.2";
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.17.0';
4
+ exports.HATCHET_VERSION = '1.17.2';