@hatchet-dev/typescript-sdk 1.19.2-alpha.0 → 1.19.2-alpha.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.19.2-alpha.0",
3
+ "version": "1.19.2-alpha.1",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/v1/declaration.js CHANGED
@@ -64,11 +64,6 @@ class BaseWorkflowDeclaration {
64
64
  throw UNBOUND_ERR;
65
65
  }
66
66
  const parentRunContext = parent_run_context_vars_1.parentRunContextManager.getContext();
67
- // Snapshot the child index BEFORE incrementing — getContext() returns a mutable
68
- // reference, so any later increment would corrupt this value.
69
- const childIndex = parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.childIndex;
70
- const inputCount = Array.isArray(input) ? input.length : 1;
71
- parent_run_context_vars_1.parentRunContextManager.incrementChildIndex(inputCount);
72
67
  if (!parentRunContext && ((options === null || options === void 0 ? void 0 : options.childKey) || (options === null || options === void 0 ? void 0 : options.sticky))) {
73
68
  this.client.admin.logger.warn('ignoring childKey or sticky because run is not being spawned from a parent task');
74
69
  }
@@ -82,19 +77,22 @@ class BaseWorkflowDeclaration {
82
77
  : undefined,
83
78
  warn: (message) => this.client.admin.logger.warn(message),
84
79
  });
85
- const runOpts = Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { parentId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentId, parentTaskRunExternalId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentTaskRunExternalId, childIndex, sticky: (options === null || options === void 0 ? void 0 : options.sticky) ? parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.desiredWorkerId : undefined, childKey: options === null || options === void 0 ? void 0 : options.childKey });
80
+ // Snapshot the base child index before incrementing. We use 1-based child
81
+ // indices because Context.spawnIndex occupies the 0-based range.
82
+ const baseChildIndex = parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.childIndex;
83
+ const inputCount = Array.isArray(input) ? input.length : 1;
84
+ parent_run_context_vars_1.parentRunContextManager.incrementChildIndex(inputCount);
85
+ const childIndexForRun = baseChildIndex != null ? baseChildIndex + 1 : undefined;
86
+ const runOpts = Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { parentId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentId, parentTaskRunExternalId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentTaskRunExternalId, childIndex: childIndexForRun, sticky: (options === null || options === void 0 ? void 0 : options.sticky) ? parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.desiredWorkerId : undefined, childKey: options === null || options === void 0 ? void 0 : options.childKey });
86
87
  if (Array.isArray(input)) {
87
88
  let resp = [];
88
89
  for (let i = 0; i < input.length; i += 500) {
89
90
  const batch = input.slice(i, i + 500);
90
- const batchResp = yield this.client.admin.runWorkflows(batch.map((inp, batchIdx) => {
91
- var _a;
92
- return ({
93
- workflowName: this.definition.name,
94
- input: inp,
95
- options: Object.assign(Object.assign({}, runOpts), { childIndex: ((_a = runOpts.childIndex) !== null && _a !== void 0 ? _a : 0) + i + batchIdx }),
96
- });
97
- }));
91
+ const batchResp = yield this.client.admin.runWorkflows(batch.map((inp, batchIdx) => ({
92
+ workflowName: this.definition.name,
93
+ input: inp,
94
+ options: Object.assign(Object.assign({}, runOpts), { childIndex: (childIndexForRun !== null && childIndexForRun !== void 0 ? childIndexForRun : 0) + i + batchIdx }),
95
+ })));
98
96
  resp = resp.concat(batchResp);
99
97
  }
100
98
  const res = [];
@@ -1,4 +1,4 @@
1
- import { DurableContext } from './client/worker/context';
1
+ import type { DurableContext } from './client/worker/context';
2
2
  export interface ParentRunContext {
3
3
  parentId: string;
4
4
  /**
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.19.2-alpha.0";
1
+ export declare const HATCHET_VERSION = "1.19.2-alpha.1";
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.19.2-alpha.0';
4
+ exports.HATCHET_VERSION = '1.19.2-alpha.1';