@hatchet-dev/typescript-sdk 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) 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.js +3 -3
  16. package/v1/examples/cancellations/run.js +1 -1
  17. package/v1/examples/cancellations/worker.js +1 -1
  18. package/v1/examples/cancellations/workflow.js +2 -2
  19. package/v1/examples/child_workflows/workflow.js +1 -1
  20. package/v1/examples/concurrency-rr/workflow.js +2 -2
  21. package/v1/examples/dag/interface-workflow.js +1 -1
  22. package/v1/examples/dag/workflow.js +1 -1
  23. package/v1/examples/dag_match_condition/complex-workflow.js +7 -7
  24. package/v1/examples/durable-event/workflow.js +2 -2
  25. package/v1/examples/durable-sleep/workflow.js +1 -1
  26. package/v1/examples/hatchet-client.d.ts +1 -1
  27. package/v1/examples/hatchet-client.js +2 -2
  28. package/v1/examples/landing_page/durable-excution.js +2 -2
  29. package/v1/examples/landing_page/event-signaling.js +1 -1
  30. package/v1/examples/landing_page/flow-control.js +1 -1
  31. package/v1/examples/landing_page/queues.js +2 -2
  32. package/v1/examples/landing_page/scheduling.js +1 -1
  33. package/v1/examples/landing_page/task-routing.js +1 -1
  34. package/v1/examples/migration-guides/mergent.js +5 -5
  35. package/v1/examples/multiple_wf_concurrency/workflow.js +1 -1
  36. package/v1/examples/non_retryable/workflow.js +1 -1
  37. package/v1/examples/on_cron/workflow.js +1 -1
  38. package/v1/examples/on_event/event.js +1 -1
  39. package/v1/examples/on_event/workflow.js +1 -1
  40. package/v1/examples/on_failure/workflow.js +1 -1
  41. package/v1/examples/on_success/workflow.js +1 -1
  42. package/v1/examples/priority/run.js +2 -2
  43. package/v1/examples/priority/workflow.js +2 -2
  44. package/v1/examples/quickstart/hatchet-client.d.ts +2 -0
  45. package/v1/examples/quickstart/hatchet-client.js +9 -0
  46. package/v1/examples/quickstart/run.d.ts +1 -0
  47. package/v1/examples/quickstart/run.js +25 -0
  48. package/v1/examples/quickstart/worker.d.ts +1 -0
  49. package/v1/examples/quickstart/worker.js +25 -0
  50. package/v1/examples/quickstart/workflows/first-task.d.ts +8 -0
  51. package/v1/examples/quickstart/workflows/first-task.js +12 -0
  52. package/v1/examples/rate_limit/workflow.js +3 -3
  53. package/v1/examples/retries/workflow.js +4 -4
  54. package/v1/examples/simple/bulk.js +2 -2
  55. package/v1/examples/simple/client-run.js +1 -1
  56. package/v1/examples/simple/cron.js +3 -3
  57. package/v1/examples/simple/enqueue.js +2 -2
  58. package/v1/examples/simple/run.js +7 -3
  59. package/v1/examples/simple/schedule.js +9 -1
  60. package/v1/examples/simple/stub-workflow.js +1 -1
  61. package/v1/examples/simple/worker.js +1 -1
  62. package/v1/examples/simple/workflow-with-child.d.ts +5 -1
  63. package/v1/examples/simple/workflow-with-child.js +18 -5
  64. package/v1/examples/simple/workflow.js +24 -3
  65. package/v1/examples/sticky/workflow.js +1 -1
  66. package/v1/examples/timeouts/run.js +1 -1
  67. package/v1/examples/timeouts/worker.js +1 -1
  68. package/v1/examples/timeouts/workflow.js +1 -1
  69. package/v1/examples/with_timeouts/workflow.js +3 -3
  70. package/version.d.ts +1 -1
  71. package/version.js +1 -1
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const workflows_1 = require("../protoc/workflows");
16
16
  const sdk_1 = __importDefault(require("../sdk"));
17
17
  const hatchet = sdk_1.default.init();
18
- // AffinityWorkflow
18
+ // > AffinityWorkflow
19
19
  const workflow = {
20
20
  id: 'affinity-workflow',
21
21
  description: 'test',
@@ -36,7 +36,7 @@ const workflow = {
36
36
  },
37
37
  ],
38
38
  };
39
- // ‼️
39
+ // !!
40
40
  const childWorkflow = {
41
41
  id: 'child-affinity-workflow',
42
42
  description: 'test',
@@ -72,14 +72,14 @@ const childWorkflow = {
72
72
  };
73
73
  function main() {
74
74
  return __awaiter(this, void 0, void 0, function* () {
75
- // AffinityWorker
75
+ // > AffinityWorker
76
76
  const worker1 = yield hatchet.worker('affinity-worker-1', {
77
77
  labels: {
78
78
  model: 'abc',
79
79
  memory: 1024,
80
80
  },
81
81
  });
82
- // ‼️
82
+ // !!
83
83
  yield worker1.registerWorkflow(workflow);
84
84
  yield worker1.registerWorkflow(childWorkflow);
85
85
  worker1.start();
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  // eslint-disable-next-line import/no-extraneous-dependencies
16
16
  const pino_1 = __importDefault(require("pino"));
17
17
  const sdk_1 = __importDefault(require("../sdk"));
18
- // Create Pino logger
18
+ // > Create Pino logger
19
19
  const logger = (0, pino_1.default)();
20
20
  class PinoLogger {
21
21
  constructor(context, logLevel = 'DEBUG') {
@@ -43,7 +43,7 @@ const hatchet = sdk_1.default.init({
43
43
  logger: (ctx, level) => new PinoLogger(ctx, level),
44
44
  });
45
45
  // !!
46
- // Use the logger
46
+ // > Use the logger
47
47
  const sleep = (ms) => new Promise((resolve) => {
48
48
  setTimeout(resolve, ms);
49
49
  });
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.simpleCronWorkflow = void 0;
16
16
  const sdk_1 = __importDefault(require("../../sdk"));
17
17
  const hatchet = sdk_1.default.init();
18
- // Workflow Definition Cron Trigger
18
+ // > Workflow Definition Cron Trigger
19
19
  // Adding a cron trigger to a workflow is as simple as adding a `cron expression` to the `on` prop of the workflow definition
20
20
  exports.simpleCronWorkflow = {
21
21
  id: 'simple-cron-workflow',
@@ -35,7 +35,7 @@ exports.simpleCronWorkflow = {
35
35
  ],
36
36
  // ,
37
37
  };
38
- // ‼️
38
+ // !!
39
39
  function main() {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const worker = yield hatchet.worker('example-worker');
@@ -19,7 +19,7 @@ const hatchet = sdk_1.default.init({
19
19
  const sleep = (ms) => new Promise((resolve) => {
20
20
  setTimeout(resolve, ms);
21
21
  });
22
- // Logger
22
+ // > Logger
23
23
  const workflow = {
24
24
  id: 'logger-example',
25
25
  description: 'test',
@@ -41,7 +41,7 @@ const workflow = {
41
41
  },
42
42
  ],
43
43
  };
44
- // ‼️
44
+ // !!
45
45
  function main() {
46
46
  return __awaiter(this, void 0, void 0, function* () {
47
47
  const worker = yield hatchet.worker('logger-worker', 1);
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const sdk_1 = __importDefault(require("../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
- // OnFailure Step
17
+ // > OnFailure Step
18
18
  // This workflow will fail because the step will throw an error
19
19
  // we define an onFailure step to handle this case
20
20
  const workflow = {
@@ -46,10 +46,10 @@ const workflow = {
46
46
  }),
47
47
  },
48
48
  };
49
- // ‼️
50
- // OnFailure With Details
49
+ // !!
50
+ // > OnFailure With Details
51
51
  // Coming soon to TypeScript! https://github.com/hatchet-dev/hatchet-typescript/issues/447
52
- // ‼️
52
+ // !!
53
53
  function main() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  const worker = yield hatchet.worker('example-worker', 1);
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const sdk_1 = __importDefault(require("../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  let numRetries = 0;
18
- // Backoff
18
+ // > Backoff
19
19
  const workflow = {
20
20
  // ... normal workflow definition
21
21
  id: 'retries-with-backoff',
@@ -45,7 +45,7 @@ const workflow = {
45
45
  },
46
46
  ],
47
47
  };
48
- // ‼️
48
+ // !!
49
49
  function main() {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
51
  const worker = yield hatchet.worker('backoff-worker');
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const sdk_1 = __importDefault(require("../sdk"));
16
16
  const workflow_1 = require("../workflow");
17
17
  const hatchet = sdk_1.default.init();
18
- // StickyWorker
18
+ // > StickyWorker
19
19
  const workflow = {
20
20
  id: 'sticky-workflow',
21
21
  description: 'test',
@@ -36,8 +36,8 @@ const workflow = {
36
36
  },
37
37
  ],
38
38
  };
39
- // ‼️
40
- // StickyChild
39
+ // !!
40
+ // > StickyChild
41
41
  const childWorkflow = {
42
42
  id: 'child-sticky-workflow',
43
43
  description: 'test',
@@ -62,7 +62,7 @@ const childWorkflow = {
62
62
  },
63
63
  ],
64
64
  };
65
- // ‼️
65
+ // !!
66
66
  function main() {
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  const worker1 = yield hatchet.worker('sticky-worker-1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/step.js CHANGED
@@ -413,7 +413,7 @@ class V0Context {
413
413
  const wf = workflows[index].workflow;
414
414
  if (wf instanceof declaration_1.TaskWorkflowDeclaration) {
415
415
  // eslint-disable-next-line no-param-reassign
416
- ref._standalone_task_name = wf._standalone_task_name;
416
+ ref._standaloneTaskName = wf._standalone_task_name;
417
417
  }
418
418
  res.push(ref);
419
419
  });
@@ -480,7 +480,7 @@ class V0Context {
480
480
  const resp = yield this.v0.admin.runWorkflow(name, input, Object.assign({ parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }, opts));
481
481
  this.spawnIndex += 1;
482
482
  if (workflow instanceof declaration_1.TaskWorkflowDeclaration) {
483
- resp._standalone_task_name = workflow._standalone_task_name;
483
+ resp._standaloneTaskName = workflow._standalone_task_name;
484
484
  }
485
485
  return resp;
486
486
  }
@@ -11,10 +11,10 @@ export default class WorkflowRunRef<T> {
11
11
  parentWorkflowRunId?: string;
12
12
  private client;
13
13
  private runs;
14
- _standalone_task_name?: string;
14
+ _standaloneTaskName?: string;
15
15
  constructor(workflowRunId: string | Promise<string> | Promise<{
16
16
  workflowRunId: string;
17
- }>, client: RunListenerClient, runsClient?: RunsClient, parentWorkflowRunId?: string);
17
+ }>, client: RunListenerClient, runsClient?: RunsClient, parentWorkflowRunId?: string, standaloneTaskName?: string);
18
18
  get runId(): Promise<string>;
19
19
  getWorkflowRunId(): Promise<string>;
20
20
  stream(): Promise<AsyncGenerator<StepRunEvent, void, unknown>>;
@@ -50,11 +50,12 @@ function getWorkflowRunId(workflowRunId) {
50
50
  });
51
51
  }
52
52
  class WorkflowRunRef {
53
- constructor(workflowRunId, client, runsClient, parentWorkflowRunId) {
53
+ constructor(workflowRunId, client, runsClient, parentWorkflowRunId, standaloneTaskName) {
54
54
  this.workflowRunId = workflowRunId;
55
55
  this.parentWorkflowRunId = parentWorkflowRunId;
56
56
  this.client = client;
57
57
  this.runs = runsClient;
58
+ this._standaloneTaskName = standaloneTaskName;
58
59
  }
59
60
  // TODO docstrings
60
61
  get runId() {
@@ -72,9 +73,7 @@ class WorkflowRunRef {
72
73
  return this.client.stream(workflowRunId);
73
74
  });
74
75
  }
75
- // TODO not sure if i want this to be a get since it might be blocking for a long time..
76
76
  get output() {
77
- // TODO output for single task workflows
78
77
  return this.result();
79
78
  }
80
79
  /**
@@ -118,19 +117,19 @@ class WorkflowRunRef {
118
117
  outputs[readableStepName] = stepRun.output;
119
118
  }
120
119
  });
121
- if (!this._standalone_task_name) {
120
+ if (!this._standaloneTaskName) {
122
121
  resolve(outputs);
123
122
  return;
124
123
  }
125
- resolve(outputs[this._standalone_task_name]);
124
+ resolve(outputs[this._standaloneTaskName]);
126
125
  return;
127
126
  }
128
127
  const result = event.results.reduce((acc, r) => (Object.assign(Object.assign({}, acc), { [r.stepReadableId]: JSON.parse(r.output || '{}') })), {});
129
- if (!this._standalone_task_name) {
128
+ if (!this._standaloneTaskName) {
130
129
  resolve(result);
131
130
  return;
132
131
  }
133
- resolve(result[this._standalone_task_name]);
132
+ resolve(result[this._standaloneTaskName]);
134
133
  return;
135
134
  }
136
135
  }
@@ -39,6 +39,7 @@ export declare class AdminClient {
39
39
  additionalMetadata?: Record<string, string> | undefined;
40
40
  desiredWorkerId?: string | undefined;
41
41
  priority?: Priority;
42
+ _standaloneTaskName?: string | undefined;
42
43
  }): Promise<WorkflowRunRef<P>>;
43
44
  /**
44
45
  * Run multiple workflows runs with the given input and options. This will create new workflow runs and return their IDs.
@@ -57,6 +58,7 @@ export declare class AdminClient {
57
58
  additionalMetadata?: Record<string, string> | undefined;
58
59
  desiredWorkerId?: string | undefined;
59
60
  priority?: Priority;
61
+ _standaloneTaskName?: string | undefined;
60
62
  };
61
63
  }>, batchSize?: number): Promise<WorkflowRunRef<P>[]>;
62
64
  putRateLimit(key: string, limit: number, duration?: RateLimitDuration): Promise<void>;
@@ -48,7 +48,9 @@ class AdminClient {
48
48
  ? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
49
49
  : undefined, priority: options === null || options === void 0 ? void 0 : options.priority }));
50
50
  const id = resp.workflowRunId;
51
- const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId);
51
+ const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId,
52
+ // eslint-disable-next-line no-underscore-dangle
53
+ options === null || options === void 0 ? void 0 : options._standaloneTaskName);
52
54
  yield ref.getWorkflowRunId();
53
55
  return ref;
54
56
  }
@@ -92,7 +94,9 @@ class AdminClient {
92
94
  const batchResults = bulkTriggerWorkflowResponse.workflowRunIds.map((resp, index) => {
93
95
  const originalIndex = originalIndices[index];
94
96
  const { options } = workflowRuns[originalIndex];
95
- return new workflow_run_ref_1.default(resp, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId);
97
+ return new workflow_run_ref_1.default(resp, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId,
98
+ // eslint-disable-next-line no-underscore-dangle
99
+ options === null || options === void 0 ? void 0 : options._standaloneTaskName);
96
100
  });
97
101
  results.push(...batchResults);
98
102
  }
@@ -240,7 +240,7 @@ class Context {
240
240
  throw new hatchet_error_1.default(`Cannot run with sticky: workflow ${workflowName} is not registered on the worker`);
241
241
  }
242
242
  const { workflowRunId, stepRunId } = this.action;
243
- const finalOpts = Object.assign(Object.assign({}, options), { parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined });
243
+ const finalOpts = Object.assign(Object.assign({}, options), { parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined, _standaloneTaskName: workflow instanceof declaration_1.TaskWorkflowDeclaration ? workflow._standalone_task_name : undefined });
244
244
  this.spawnIndex += 1;
245
245
  return { workflowName, opts: finalOpts };
246
246
  }
@@ -300,7 +300,8 @@ class Context {
300
300
  */
301
301
  runNoWaitChild(workflow, input, options) {
302
302
  return __awaiter(this, void 0, void 0, function* () {
303
- return this.spawn(workflow, input, options);
303
+ const ref = yield this.spawn(workflow, input, options);
304
+ return ref;
304
305
  });
305
306
  }
306
307
  /**
@@ -426,7 +427,7 @@ class Context {
426
427
  const wf = workflows[index].workflow;
427
428
  if (wf instanceof declaration_1.TaskWorkflowDeclaration) {
428
429
  // eslint-disable-next-line no-param-reassign
429
- ref._standalone_task_name = wf._standalone_task_name;
430
+ ref._standaloneTaskName = wf._standalone_task_name;
430
431
  }
431
432
  res.push(ref);
432
433
  });
@@ -466,7 +467,7 @@ class Context {
466
467
  const resp = yield this.v1._v0.admin.runWorkflow(name, input, Object.assign({ parentId: workflowRunId, parentStepRunId: stepRunId, childIndex: this.spawnIndex, desiredWorkerId: sticky ? this.worker.id() : undefined }, opts));
467
468
  this.spawnIndex += 1;
468
469
  if (workflow instanceof declaration_1.TaskWorkflowDeclaration) {
469
- resp._standalone_task_name = workflow._standalone_task_name;
470
+ resp._standaloneTaskName = workflow._standalone_task_name;
470
471
  }
471
472
  return resp;
472
473
  }
package/v1/declaration.js CHANGED
@@ -50,7 +50,7 @@ class BaseWorkflowDeclaration {
50
50
  }
51
51
  const res = yield this.client.admin.runWorkflow(this.name, input, options);
52
52
  if (_standaloneTaskName) {
53
- res._standalone_task_name = _standaloneTaskName;
53
+ res._standaloneTaskName = _standaloneTaskName;
54
54
  }
55
55
  return res;
56
56
  });
@@ -87,7 +87,7 @@ class BaseWorkflowDeclaration {
87
87
  const wf = input[index].workflow;
88
88
  if (wf instanceof TaskWorkflowDeclaration) {
89
89
  // eslint-disable-next-line no-param-reassign
90
- ref._standalone_task_name = wf._standalone_task_name;
90
+ ref._standaloneTaskName = wf._standalone_task_name;
91
91
  }
92
92
  res.push(ref.result());
93
93
  });
@@ -95,7 +95,7 @@ class BaseWorkflowDeclaration {
95
95
  }
96
96
  const res = yield this.client.admin.runWorkflow(this.definition.name, input, options);
97
97
  if (_standaloneTaskName) {
98
- res._standalone_task_name = _standaloneTaskName;
98
+ res._standaloneTaskName = _standaloneTaskName;
99
99
  }
100
100
  return res.result();
101
101
  });
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  /* eslint-disable no-console */
16
- // Running a Task with Results
16
+ // > Running a Task with Results
17
17
  const sleep_1 = __importDefault(require("../../../util/sleep"));
18
18
  const workflow_1 = require("./workflow");
19
19
  const hatchet_client_1 = require("../hatchet-client");
@@ -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() {
@@ -16,7 +16,7 @@ exports.abortSignal = exports.cancellation = void 0;
16
16
  const sleep_1 = __importDefault(require("../../../util/sleep"));
17
17
  const axios_1 = __importDefault(require("axios"));
18
18
  const hatchet_client_1 = require("../hatchet-client");
19
- // Declaring a Task
19
+ // > Declaring a Task
20
20
  exports.cancellation = hatchet_client_1.hatchet.task({
21
21
  name: 'cancellation',
22
22
  fn: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { cancelled }) {
@@ -30,7 +30,7 @@ exports.cancellation = hatchet_client_1.hatchet.task({
30
30
  }),
31
31
  });
32
32
  // !!
33
- // Abort Signal
33
+ // > Abort Signal
34
34
  exports.abortSignal = hatchet_client_1.hatchet.task({
35
35
  name: 'abort-signal',
36
36
  fn: (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { abortController }) {
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.parent = exports.child = void 0;
13
13
  /* eslint-disable no-plusplus */
14
- // Declaring a Child
14
+ // > Declaring a Child
15
15
  const hatchet_client_1 = require("../hatchet-client");
16
16
  exports.child = hatchet_client_1.hatchet.task({
17
17
  name: 'child',
@@ -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.simpleConcurrency = hatchet_client_1.hatchet.workflow({
20
20
  name: 'simple-concurrency',
21
21
  concurrency: {
@@ -34,7 +34,7 @@ exports.simpleConcurrency.task({
34
34
  };
35
35
  }),
36
36
  });
37
- // Multiple Concurrency Keys
37
+ // > Multiple Concurrency Keys
38
38
  exports.multipleConcurrencyKeys = hatchet_client_1.hatchet.workflow({
39
39
  name: 'simple-concurrency',
40
40
  concurrency: [
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.dag = void 0;
13
13
  const hatchet_client_1 = require("../hatchet-client");
14
- // Declaring a DAG Workflow
14
+ // > Declaring a DAG Workflow
15
15
  // First, we declare the workflow
16
16
  exports.dag = hatchet_client_1.hatchet.workflow({
17
17
  name: 'simple',
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.dag = void 0;
13
13
  const hatchet_client_1 = require("../hatchet-client");
14
- // Declaring a DAG Workflow
14
+ // > Declaring a DAG Workflow
15
15
  // First, we declare the workflow
16
16
  exports.dag = hatchet_client_1.hatchet.workflow({
17
17
  name: 'simple',
@@ -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
  exports.taskConditionWorkflow = void 0;
13
- // Create a workflow
13
+ // > Create a workflow
14
14
  const conditions_1 = require("../../conditions");
15
15
  const parent_condition_1 = require("../../conditions/parent-condition");
16
16
  const hatchet_client_1 = require("../hatchet-client");
@@ -18,7 +18,7 @@ exports.taskConditionWorkflow = hatchet_client_1.hatchet.workflow({
18
18
  name: 'TaskConditionWorkflow',
19
19
  });
20
20
  // !!
21
- // Add base task
21
+ // > Add base task
22
22
  const start = exports.taskConditionWorkflow.task({
23
23
  name: 'start',
24
24
  fn: () => {
@@ -28,7 +28,7 @@ const start = exports.taskConditionWorkflow.task({
28
28
  },
29
29
  });
30
30
  // !!
31
- // Add wait for sleep
31
+ // > Add wait for sleep
32
32
  const waitForSleep = exports.taskConditionWorkflow.task({
33
33
  name: 'waitForSleep',
34
34
  parents: [start],
@@ -40,7 +40,7 @@ const waitForSleep = exports.taskConditionWorkflow.task({
40
40
  },
41
41
  });
42
42
  // !!
43
- // Add skip on event
43
+ // > Add skip on event
44
44
  const skipOnEvent = exports.taskConditionWorkflow.task({
45
45
  name: 'skipOnEvent',
46
46
  parents: [start],
@@ -53,7 +53,7 @@ const skipOnEvent = exports.taskConditionWorkflow.task({
53
53
  },
54
54
  });
55
55
  // !!
56
- // Add branching
56
+ // > Add branching
57
57
  const leftBranch = exports.taskConditionWorkflow.task({
58
58
  name: 'leftBranch',
59
59
  parents: [waitForSleep],
@@ -75,7 +75,7 @@ const rightBranch = exports.taskConditionWorkflow.task({
75
75
  },
76
76
  });
77
77
  // !!
78
- // Add wait for event
78
+ // > Add wait for event
79
79
  const waitForEvent = exports.taskConditionWorkflow.task({
80
80
  name: 'waitForEvent',
81
81
  parents: [start],
@@ -87,7 +87,7 @@ const waitForEvent = exports.taskConditionWorkflow.task({
87
87
  },
88
88
  });
89
89
  // !!
90
- // Add sum
90
+ // > Add sum
91
91
  exports.taskConditionWorkflow.task({
92
92
  name: 'sum',
93
93
  parents: [start, waitForSleep, waitForEvent, skipOnEvent, leftBranch, rightBranch],
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.durableEventWithFilter = exports.durableEvent = void 0;
13
13
  // import sleep from '../../../util/sleep.js';
14
14
  const hatchet_client_1 = require("../hatchet-client");
15
- // Durable Event
15
+ // > Durable Event
16
16
  exports.durableEvent = hatchet_client_1.hatchet.durableTask({
17
17
  name: 'durable-event',
18
18
  executionTimeout: '10m',
@@ -31,7 +31,7 @@ exports.durableEventWithFilter = hatchet_client_1.hatchet.durableTask({
31
31
  name: 'durable-event-with-filter',
32
32
  executionTimeout: '10m',
33
33
  fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
34
- // Durable Event With Filter
34
+ // > Durable Event With Filter
35
35
  const res = ctx.waitFor({
36
36
  eventKey: 'user:update',
37
37
  expression: "input.userId == '1234'",
@@ -15,7 +15,7 @@ const hatchet_client_1 = require("../hatchet-client");
15
15
  exports.durableSleep = hatchet_client_1.hatchet.workflow({
16
16
  name: 'durable-sleep',
17
17
  });
18
- // Durable Sleep
18
+ // > Durable Sleep
19
19
  exports.durableSleep.durableTask({
20
20
  name: 'durable-sleep',
21
21
  executionTimeout: '10m',
@@ -1,2 +1,2 @@
1
- import { HatchetClient } from '../client/client';
1
+ import { HatchetClient } from './..';
2
2
  export declare const hatchet: HatchetClient;
@@ -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: {