@hatchet-dev/typescript-sdk 1.5.0 → 1.5.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.
Files changed (74) hide show
  1. package/examples/affinity-workers.js +4 -4
  2. package/examples/byo-logger.js +2 -2
  3. package/examples/crons/cron-worker.js +2 -2
  4. package/examples/logger.js +2 -2
  5. package/examples/on-failure.js +4 -4
  6. package/examples/retries-with-backoff.js +2 -2
  7. package/examples/sticky-worker.js +4 -4
  8. package/package.json +1 -1
  9. package/step.js +2 -2
  10. package/util/workflow-run-ref.d.ts +2 -2
  11. package/util/workflow-run-ref.js +6 -7
  12. package/v1/client/admin.d.ts +2 -0
  13. package/v1/client/admin.js +6 -2
  14. package/v1/client/worker/context.js +5 -4
  15. package/v1/declaration.d.ts +2 -0
  16. package/v1/declaration.js +40 -46
  17. package/v1/examples/cancellations/run.js +1 -1
  18. package/v1/examples/cancellations/worker.js +1 -1
  19. package/v1/examples/cancellations/workflow.js +2 -2
  20. package/v1/examples/child_workflows/workflow.js +1 -1
  21. package/v1/examples/concurrency-rr/workflow.js +2 -2
  22. package/v1/examples/dag/interface-workflow.js +1 -1
  23. package/v1/examples/dag/workflow.js +1 -1
  24. package/v1/examples/dag_match_condition/complex-workflow.js +7 -7
  25. package/v1/examples/durable-event/workflow.js +2 -2
  26. package/v1/examples/durable-sleep/workflow.js +1 -1
  27. package/v1/examples/hatchet-client.d.ts +1 -1
  28. package/v1/examples/hatchet-client.js +2 -2
  29. package/v1/examples/landing_page/durable-excution.js +2 -2
  30. package/v1/examples/landing_page/event-signaling.js +1 -1
  31. package/v1/examples/landing_page/flow-control.js +1 -1
  32. package/v1/examples/landing_page/queues.js +2 -2
  33. package/v1/examples/landing_page/scheduling.js +1 -1
  34. package/v1/examples/landing_page/task-routing.js +1 -1
  35. package/v1/examples/migration-guides/mergent.js +5 -5
  36. package/v1/examples/multiple_wf_concurrency/workflow.js +1 -1
  37. package/v1/examples/non_retryable/workflow.js +1 -1
  38. package/v1/examples/on_cron/workflow.js +1 -1
  39. package/v1/examples/on_event/event.js +1 -1
  40. package/v1/examples/on_event/workflow.js +1 -1
  41. package/v1/examples/on_failure/workflow.js +1 -1
  42. package/v1/examples/on_success/workflow.js +1 -1
  43. package/v1/examples/priority/run.js +2 -2
  44. package/v1/examples/priority/workflow.js +2 -2
  45. package/v1/examples/quickstart/hatchet-client.d.ts +2 -0
  46. package/v1/examples/quickstart/hatchet-client.js +9 -0
  47. package/v1/examples/{on_event copy/event.js → quickstart/run.js} +7 -8
  48. package/v1/examples/{on_event copy/worker.js → quickstart/worker.js} +4 -3
  49. package/v1/examples/quickstart/workflows/first-task.d.ts +8 -0
  50. package/v1/examples/quickstart/workflows/first-task.js +12 -0
  51. package/v1/examples/rate_limit/workflow.js +3 -3
  52. package/v1/examples/retries/workflow.js +4 -4
  53. package/v1/examples/simple/bulk.js +2 -2
  54. package/v1/examples/simple/client-run.js +1 -1
  55. package/v1/examples/simple/cron.js +3 -3
  56. package/v1/examples/simple/enqueue.js +2 -2
  57. package/v1/examples/simple/run.js +7 -3
  58. package/v1/examples/simple/schedule.js +9 -1
  59. package/v1/examples/simple/stub-workflow.js +1 -1
  60. package/v1/examples/simple/worker.js +1 -1
  61. package/v1/examples/simple/workflow-with-child.d.ts +5 -1
  62. package/v1/examples/simple/workflow-with-child.js +18 -5
  63. package/v1/examples/simple/workflow.js +13 -3
  64. package/v1/examples/sticky/workflow.js +1 -1
  65. package/v1/examples/timeouts/run.js +1 -1
  66. package/v1/examples/timeouts/worker.js +1 -1
  67. package/v1/examples/timeouts/workflow.js +1 -1
  68. package/v1/examples/with_timeouts/workflow.js +3 -3
  69. package/version.d.ts +1 -1
  70. package/version.js +1 -1
  71. package/v1/examples/on_event copy/workflow.d.ts +0 -16
  72. package/v1/examples/on_event copy/workflow.js +0 -35
  73. /package/v1/examples/{on_event copy/event.d.ts → quickstart/run.d.ts} +0 -0
  74. /package/v1/examples/{on_event copy → quickstart}/worker.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hatchet = void 0;
4
- const client_1 = require("../client/client");
5
- exports.hatchet = client_1.HatchetClient.init();
4
+ const v1_1 = require("./..");
5
+ exports.hatchet = v1_1.HatchetClient.init();
@@ -14,7 +14,7 @@ const conditions_1 = require("../../conditions");
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
15
  function main() {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
- // Declaring a Durable Task
17
+ // > Declaring a Durable Task
18
18
  const simple = hatchet_client_1.hatchet.durableTask({
19
19
  name: 'simple',
20
20
  fn: (input, ctx) => __awaiter(this, void 0, void 0, function* () {
@@ -30,7 +30,7 @@ function main() {
30
30
  }),
31
31
  });
32
32
  // !!
33
- // Running a Task
33
+ // > Running a Task
34
34
  const result = yield simple.run({ Message: 'Hello, World!' });
35
35
  // !!
36
36
  });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simple = void 0;
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
- // Trigger on an event
5
+ // > Trigger on an event
6
6
  exports.simple = hatchet_client_1.hatchet.task({
7
7
  name: 'simple',
8
8
  onEvents: ['user:created'],
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simple = void 0;
4
4
  const workflows_1 = require("../../../protoc/v1/workflows");
5
5
  const hatchet_client_1 = require("../hatchet-client");
6
- // Process what you can handle
6
+ // > Process what you can handle
7
7
  exports.simple = hatchet_client_1.hatchet.task({
8
8
  name: 'simple',
9
9
  concurrency: {
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  const hatchet_client_1 = require("../hatchet-client");
14
14
  function main() {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- // Declaring a Task
16
+ // > Declaring a Task
17
17
  const simple = hatchet_client_1.hatchet.task({
18
18
  name: 'simple',
19
19
  fn: (input) => {
@@ -23,7 +23,7 @@ function main() {
23
23
  },
24
24
  });
25
25
  // !!
26
- // Running a Task
26
+ // > Running a Task
27
27
  const result = yield simple.run({ Message: 'Hello, World!' });
28
28
  // !!
29
29
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const flow_control_1 = require("./flow-control");
4
- // Schedules and Crons
4
+ // > Schedules and Crons
5
5
  const tomorrow = new Date(Date.now() + 1000 * 60 * 60 * 24);
6
6
  const scheduled = flow_control_1.simple.schedule(tomorrow, {
7
7
  Message: 'Hello, World!',
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simple = void 0;
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
- // Route tasks to workers with matching labels
5
+ // > Route tasks to workers with matching labels
6
6
  exports.simple = hatchet_client_1.hatchet.task({
7
7
  name: 'simple',
8
8
  desiredWorkerLabels: {
@@ -16,7 +16,7 @@ function processImage(imageUrl, filters) {
16
16
  // Do some image processing
17
17
  return Promise.resolve({ url: imageUrl, size: 100, format: 'png' });
18
18
  }
19
- // Before (Mergent)
19
+ // > Before (Mergent)
20
20
  function processImageTask(req) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const { imageUrl, filters } = req.body;
@@ -52,7 +52,7 @@ exports.imageProcessor = hatchet_client_1.hatchet.task({
52
52
  // !!
53
53
  function run() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
- // Running a task (Mergent)
55
+ // > Running a task (Mergent)
56
56
  const options = {
57
57
  method: 'POST',
58
58
  headers: { Authorization: 'Bearer <token>', 'Content-Type': 'application/json' },
@@ -71,7 +71,7 @@ function run() {
71
71
  .then((response) => console.log(response))
72
72
  .catch((err) => console.error(err));
73
73
  // !!
74
- // Running a task (Hatchet)
74
+ // > Running a task (Hatchet)
75
75
  const result = yield exports.imageProcessor.run({
76
76
  imageUrl: 'https://example.com/image.png',
77
77
  filters: ['blur'],
@@ -83,7 +83,7 @@ function run() {
83
83
  }
84
84
  function schedule() {
85
85
  return __awaiter(this, void 0, void 0, function* () {
86
- // Scheduling tasks (Mergent)
86
+ // > Scheduling tasks (Mergent)
87
87
  const options = {
88
88
  // same options as before
89
89
  body: JSON.stringify({
@@ -92,7 +92,7 @@ function schedule() {
92
92
  }),
93
93
  };
94
94
  // !!
95
- // Scheduling tasks (Hatchet)
95
+ // > Scheduling tasks (Hatchet)
96
96
  // Schedule the task to run at a specific time
97
97
  const runAt = new Date(Date.now() + 1000 * 60 * 60 * 24);
98
98
  exports.imageProcessor.schedule(runAt, {
@@ -15,7 +15,7 @@ const hatchet_client_1 = require("../hatchet-client");
15
15
  const sleep = (ms) => new Promise((resolve) => {
16
16
  setTimeout(resolve, ms);
17
17
  });
18
- // Concurrency Strategy With Key
18
+ // > Concurrency Strategy With Key
19
19
  exports.multiConcurrency = hatchet_client_1.hatchet.workflow({
20
20
  name: 'simple-concurrency',
21
21
  concurrency: [
@@ -6,7 +6,7 @@ const hatchet_client_1 = require("../hatchet-client");
6
6
  exports.nonRetryableWorkflow = hatchet_client_1.hatchet.workflow({
7
7
  name: 'no-retry-workflow',
8
8
  });
9
- // Non-retrying task
9
+ // > Non-retrying task
10
10
  const shouldNotRetry = exports.nonRetryableWorkflow.task({
11
11
  name: 'should-not-retry',
12
12
  fn: () => {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onCron = void 0;
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
- // Run Workflow on Cron
5
+ // > Run Workflow on Cron
6
6
  exports.onCron = hatchet_client_1.hatchet.workflow({
7
7
  name: 'on-cron-workflow',
8
8
  on: {
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const hatchet_client_1 = require("../hatchet-client");
13
13
  function main() {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
- // Pushing an Event
15
+ // > Pushing an Event
16
16
  const res = yield hatchet_client_1.hatchet.events.push('simple-event:create', {
17
17
  Message: 'hello',
18
18
  });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.upper = exports.lower = exports.SIMPLE_EVENT = void 0;
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
5
  exports.SIMPLE_EVENT = 'simple-event:create';
6
- // Run workflow on event
6
+ // > Run workflow on event
7
7
  exports.lower = hatchet_client_1.hatchet.workflow({
8
8
  name: 'lower',
9
9
  // 👀 Declare the event that will trigger the workflow
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.failureWorkflow = void 0;
13
13
  /* eslint-disable no-console */
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- // On Failure Task
15
+ // > On Failure Task
16
16
  exports.failureWorkflow = hatchet_client_1.hatchet.workflow({
17
17
  name: 'always-fail',
18
18
  });
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.onSuccessDag = void 0;
13
13
  /* eslint-disable no-console */
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- // On Success DAG
15
+ // > On Success DAG
16
16
  exports.onSuccessDag = hatchet_client_1.hatchet.workflow({
17
17
  name: 'on-success-dag',
18
18
  });
@@ -16,10 +16,10 @@ function main() {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
17
  try {
18
18
  console.log('running priority workflow');
19
- // Run a Task with a Priority
19
+ // > Run a Task with a Priority
20
20
  const run = workflow_1.priority.run(new Date(Date.now() + 60 * 60 * 1000), { priority: v1_1.Priority.HIGH });
21
21
  // !!
22
- // Schedule and cron
22
+ // > Schedule and cron
23
23
  const scheduled = workflow_1.priority.schedule(new Date(Date.now() + 60 * 60 * 1000), {}, { priority: v1_1.Priority.HIGH });
24
24
  const delayed = workflow_1.priority.delay(60 * 60 * 1000, {}, { priority: v1_1.Priority.HIGH });
25
25
  const cron = workflow_1.priority.cron(`daily-cron-${Math.random()}`, '0 0 * * *', {}, { priority: v1_1.Priority.HIGH });
@@ -13,7 +13,7 @@ exports.priorityTasks = exports.priorityWf = exports.priority = void 0;
13
13
  /* eslint-disable no-console */
14
14
  const v1_1 = require("../..");
15
15
  const hatchet_client_1 = require("../hatchet-client");
16
- // Simple Task Priority
16
+ // > Simple Task Priority
17
17
  exports.priority = hatchet_client_1.hatchet.task({
18
18
  name: 'priority',
19
19
  defaultPriority: v1_1.Priority.MEDIUM,
@@ -24,7 +24,7 @@ exports.priority = hatchet_client_1.hatchet.task({
24
24
  }),
25
25
  });
26
26
  // !!
27
- // Task Priority in a Workflow
27
+ // > Task Priority in a Workflow
28
28
  exports.priorityWf = hatchet_client_1.hatchet.workflow({
29
29
  name: 'priorityWf',
30
30
  defaultPriority: v1_1.Priority.LOW,
@@ -0,0 +1,2 @@
1
+ import Hatchet from '../../../sdk';
2
+ export declare const hatchet: Hatchet;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hatchet = void 0;
7
+ const sdk_1 = __importDefault(require("../../../sdk"));
8
+ // HH-client 1 Client
9
+ exports.hatchet = sdk_1.default.init();
@@ -9,18 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const hatchet_client_1 = require("../hatchet-client");
12
+ const first_task_1 = require("./workflows/first-task");
13
13
  function main() {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
- // Pushing an Event
16
- const res = yield hatchet_client_1.hatchet.event.push('simple-event:create', {
17
- Message: 'hello',
15
+ const res = yield first_task_1.firstTask.run({
16
+ Message: 'Hello World!',
18
17
  });
19
- // !!
20
- // eslint-disable-next-line no-console
21
- console.log(res.eventId);
18
+ console.log('Finished running task, and got the transformed message! The transformed message is:', res.TransformedMessage);
22
19
  });
23
20
  }
24
21
  if (require.main === module) {
25
- main();
22
+ main()
23
+ .catch(console.error)
24
+ .finally(() => process.exit(0));
26
25
  }
@@ -10,11 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const hatchet_client_1 = require("../hatchet-client");
13
- const workflow_1 = require("./workflow");
13
+ const first_task_1 = require("./workflows/first-task");
14
14
  function main() {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- const worker = yield hatchet_client_1.hatchet.worker('on-event-worker', {
17
- workflows: [workflow_1.lower, workflow_1.upper],
16
+ const worker = yield hatchet_client_1.hatchet.worker('first-worker', {
17
+ workflows: [first_task_1.firstTask],
18
+ slots: 10,
18
19
  });
19
20
  yield worker.start();
20
21
  });
@@ -0,0 +1,8 @@
1
+ type SimpleInput = {
2
+ Message: string;
3
+ };
4
+ type SimpleOutput = {
5
+ TransformedMessage: string;
6
+ };
7
+ export declare const firstTask: import("../../..").TaskWorkflowDeclaration<SimpleInput, SimpleOutput>;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.firstTask = void 0;
4
+ const hatchet_client_1 = require("../../hatchet-client");
5
+ exports.firstTask = hatchet_client_1.hatchet.task({
6
+ name: 'first-task',
7
+ fn: (input, ctx) => {
8
+ return {
9
+ TransformedMessage: input.Message.toLowerCase(),
10
+ };
11
+ },
12
+ });
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const workflows_1 = require("../../../protoc/v1/workflows");
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
- // Upsert Rate Limit
5
+ // > Upsert Rate Limit
6
6
  hatchet_client_1.hatchet.ratelimits.upsert({
7
7
  key: 'api-service-rate-limit',
8
8
  limit: 10,
9
9
  duration: workflows_1.RateLimitDuration.SECOND,
10
10
  });
11
11
  // !!
12
- // Static
12
+ // > Static
13
13
  const RATE_LIMIT_KEY = 'api-service-rate-limit';
14
14
  const task1 = hatchet_client_1.hatchet.task({
15
15
  name: 'task1',
@@ -24,7 +24,7 @@ const task1 = hatchet_client_1.hatchet.task({
24
24
  },
25
25
  });
26
26
  // !!
27
- // Dynamic
27
+ // > Dynamic
28
28
  const task2 = hatchet_client_1.hatchet.task({
29
29
  name: 'task2',
30
30
  fn: (input) => {
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.withBackoff = exports.retriesWithCount = exports.retries = void 0;
13
13
  /* eslint-disable no-console */
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- // Simple Step Retries
15
+ // > Simple Step Retries
16
16
  exports.retries = hatchet_client_1.hatchet.task({
17
17
  name: 'retries',
18
18
  retries: 3,
@@ -21,12 +21,12 @@ exports.retries = hatchet_client_1.hatchet.task({
21
21
  }),
22
22
  });
23
23
  // !!
24
- // Retries with Count
24
+ // > Retries with Count
25
25
  exports.retriesWithCount = hatchet_client_1.hatchet.task({
26
26
  name: 'retriesWithCount',
27
27
  retries: 3,
28
28
  fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
29
- // Get the current retry count
29
+ // > Get the current retry count
30
30
  const retryCount = ctx.retryCount();
31
31
  console.log(`Retry count: ${retryCount}`);
32
32
  if (retryCount < 2) {
@@ -38,7 +38,7 @@ exports.retriesWithCount = hatchet_client_1.hatchet.task({
38
38
  }),
39
39
  });
40
40
  // !!
41
- // Retries with Backoff
41
+ // > Retries with Backoff
42
42
  exports.withBackoff = hatchet_client_1.hatchet.task({
43
43
  name: 'withBackoff',
44
44
  retries: 10,
@@ -14,7 +14,7 @@ const hatchet_client_1 = require("../hatchet-client");
14
14
  const workflow_1 = require("./workflow");
15
15
  function main() {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
- // Bulk Run a Task
17
+ // > Bulk Run a Task
18
18
  const res = yield workflow_1.simple.run([
19
19
  {
20
20
  Message: 'HeLlO WoRlD',
@@ -27,7 +27,7 @@ function main() {
27
27
  console.log(res[0].TransformedMessage);
28
28
  console.log(res[1].TransformedMessage);
29
29
  // !!
30
- // Bulk Run Tasks from within a Task
30
+ // > Bulk Run Tasks from within a Task
31
31
  const parent = hatchet_client_1.hatchet.task({
32
32
  name: 'simple',
33
33
  fn: (input, ctx) => __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Client Run Methods
3
+ // > Client Run Methods
4
4
  const hatchet_client_1 = require("../hatchet-client");
5
5
  hatchet_client_1.hatchet.run('simple', { Message: 'Hello, World!' });
6
6
  hatchet_client_1.hatchet.runNoWait('simple', { Message: 'Hello, World!' }, {});
@@ -13,7 +13,7 @@ const hatchet_client_1 = require("../hatchet-client");
13
13
  const workflow_1 = require("./workflow");
14
14
  function main() {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- // Create
16
+ // > Create
17
17
  const cron = yield workflow_1.simple.cron('simple-daily', '0 0 * * *', {
18
18
  Message: 'hello',
19
19
  });
@@ -22,10 +22,10 @@ function main() {
22
22
  // !!
23
23
  // eslint-disable-next-line no-console
24
24
  console.log(cron.metadata.id);
25
- // Delete
25
+ // > Delete
26
26
  yield hatchet_client_1.hatchet.crons.delete(cronId);
27
27
  // !!
28
- // List
28
+ // > List
29
29
  const crons = yield hatchet_client_1.hatchet.crons.list({
30
30
  workflowId: workflow_1.simple.id,
31
31
  });
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  /* eslint-disable import/no-duplicates */
13
13
  /* eslint-disable no-console */
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- // Enqueuing a Workflow (Fire and Forget)
15
+ // > Enqueuing a Workflow (Fire and Forget)
16
16
  const workflow_1 = require("./workflow");
17
17
  // ...
18
18
  function main() {
@@ -27,7 +27,7 @@ function main() {
27
27
  // in a database or other persistent storage for later use
28
28
  console.log(runId);
29
29
  // !!
30
- // Subscribing to results
30
+ // > Subscribing to results
31
31
  // the return object of the enqueue method is a WorkflowRunRef which includes a listener for the result of the workflow
32
32
  const result = yield run.result();
33
33
  console.log(result);
@@ -15,9 +15,13 @@ const hatchet_client_1 = require("../hatchet-client");
15
15
  const workflow_1 = require("./workflow");
16
16
  function main() {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- // Running a Task
18
+ // > Running a Task
19
19
  const res = yield workflow_1.simple.run({
20
20
  Message: 'HeLlO WoRlD',
21
+ }, {
22
+ additionalMetadata: {
23
+ test: 'test',
24
+ },
21
25
  });
22
26
  // 👀 Access the results of the Task
23
27
  console.log(res.TransformedMessage);
@@ -26,7 +30,7 @@ function main() {
26
30
  }
27
31
  function extra() {
28
32
  return __awaiter(this, void 0, void 0, function* () {
29
- // Running Multiple Tasks
33
+ // > Running Multiple Tasks
30
34
  const res1 = workflow_1.simple.run({
31
35
  Message: 'HeLlO WoRlD',
32
36
  });
@@ -37,7 +41,7 @@ function extra() {
37
41
  console.log(results[0].TransformedMessage);
38
42
  console.log(results[1].TransformedMessage);
39
43
  // !!
40
- // Spawning Tasks from within a Task
44
+ // > Spawning Tasks from within a Task
41
45
  const parent = hatchet_client_1.hatchet.task({
42
46
  name: 'parent',
43
47
  fn: (input, ctx) => __awaiter(this, void 0, void 0, function* () {
@@ -14,7 +14,7 @@ const hatchet_client_1 = require("../hatchet-client");
14
14
  const workflow_1 = require("./workflow");
15
15
  function main() {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
- // Create a Scheduled Run
17
+ // > Create a Scheduled Run
18
18
  const runAt = new Date(new Date().setHours(12, 0, 0, 0) + 24 * 60 * 60 * 1000);
19
19
  const scheduled = yield workflow_1.simple.schedule(runAt, {
20
20
  Message: 'hello',
@@ -25,7 +25,15 @@ function main() {
25
25
  const scheduledRunId = scheduled.metadata.id;
26
26
  console.log(scheduledRunId);
27
27
  // !!
28
+ // > Delete a Scheduled Run
28
29
  yield hatchet_client_1.hatchet.schedules.delete(scheduled);
30
+ // !!
31
+ // > List Scheduled Runs
32
+ const scheduledRuns = yield hatchet_client_1.hatchet.schedules.list({
33
+ workflowId: workflow_1.simple.id,
34
+ });
35
+ console.log(scheduledRuns);
36
+ // !!
29
37
  });
30
38
  }
31
39
  if (require.main === module) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simple = void 0;
4
- // Declaring an External Workflow Reference
4
+ // > Declaring an External Workflow Reference
5
5
  const hatchet_client_1 = require("../hatchet-client");
6
6
  // declare the workflow with the same name as the
7
7
  // workflow name on the worker
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- // Declaring a Worker
12
+ // > Declaring a Worker
13
13
  const hatchet_client_1 = require("../hatchet-client");
14
14
  const workflow_1 = require("./workflow");
15
15
  const workflow_with_child_1 = require("./workflow-with-child");
@@ -4,7 +4,11 @@ export type ChildInput = {
4
4
  export type ParentInput = {
5
5
  Message: string;
6
6
  };
7
- export declare const child: import("../..").TaskWorkflowDeclaration<ChildInput, {
7
+ export declare const child: import("../..").WorkflowDeclaration<ChildInput, {}>;
8
+ export declare const child1: import("../..").CreateWorkflowTaskOpts<ChildInput, {
9
+ TransformedMessage: string;
10
+ }>;
11
+ export declare const child2: import("../..").CreateWorkflowTaskOpts<ChildInput, {
8
12
  TransformedMessage: string;
9
13
  }>;
10
14
  export declare const parent: import("../..").TaskWorkflowDeclaration<ParentInput, {
@@ -9,12 +9,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.parent = exports.child = void 0;
13
- // Declaring a Task
12
+ exports.parent = exports.child2 = exports.child1 = exports.child = void 0;
13
+ // > Declaring a Task
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- exports.child = hatchet_client_1.hatchet.task({
15
+ exports.child = hatchet_client_1.hatchet.workflow({
16
16
  name: 'child',
17
- fn: (input) => {
17
+ });
18
+ exports.child1 = exports.child.task({
19
+ name: 'child1',
20
+ fn: (input, ctx) => {
21
+ ctx.log('hello from the child1');
22
+ return {
23
+ TransformedMessage: input.Message.toLowerCase(),
24
+ };
25
+ },
26
+ });
27
+ exports.child2 = exports.child.task({
28
+ name: 'child2',
29
+ fn: (input, ctx) => {
30
+ ctx.log('hello from the child2');
18
31
  return {
19
32
  TransformedMessage: input.Message.toLowerCase(),
20
33
  };
@@ -27,7 +40,7 @@ exports.parent = hatchet_client_1.hatchet.task({
27
40
  Message: input.Message,
28
41
  });
29
42
  return {
30
- TransformedMessage: c.TransformedMessage,
43
+ TransformedMessage: 'not implemented',
31
44
  };
32
45
  }),
33
46
  });
@@ -1,15 +1,25 @@
1
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.simple = void 0;
4
- // Declaring a Task
13
+ // > Declaring a Task
5
14
  const hatchet_client_1 = require("../hatchet-client");
6
15
  exports.simple = hatchet_client_1.hatchet.task({
7
16
  name: 'simple',
8
- fn: (input) => {
17
+ retries: 3,
18
+ fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
9
19
  return {
10
20
  TransformedMessage: input.Message.toLowerCase(),
11
21
  };
12
- },
22
+ }),
13
23
  });
14
24
  // !!
15
25
  // see ./worker.ts and ./run.ts for how to run the workflow
@@ -14,7 +14,7 @@ exports.sticky = void 0;
14
14
  const workflows_1 = require("../../../protoc/workflows");
15
15
  const hatchet_client_1 = require("../hatchet-client");
16
16
  const workflow_1 = require("../child_workflows/workflow");
17
- // Sticky Task
17
+ // > Sticky Task
18
18
  exports.sticky = hatchet_client_1.hatchet.task({
19
19
  name: 'sticky',
20
20
  retries: 3,
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  /* eslint-disable no-console */
13
- // Running a Task with Results
13
+ // > Running a Task with Results
14
14
  const workflow_1 = require("./workflow");
15
15
  // ...
16
16
  function main() {
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- // Declaring a Worker
12
+ // > Declaring a Worker
13
13
  const hatchet_client_1 = require("../hatchet-client");
14
14
  const workflow_1 = require("./workflow");
15
15
  function main() {