@hatchet-dev/typescript-sdk 0.12.4 → 0.12.5

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.
@@ -29,7 +29,7 @@ const parentWorkflow = {
29
29
  timeout: '10s',
30
30
  run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
31
31
  ctx.putStream('spawning children');
32
- const promises = Array.from({ length: 7 }, (_, i) => ctx.spawnWorkflow('child-workflow', { input: `child-input-${i}` }).result());
32
+ const promises = Array.from({ length: 7 }, (_, i) => ctx.spawnWorkflow('child-workflow', { input: `child-input-${i}` }, { additionalMetadata: { childKey: "childValue" } }).result());
33
33
  const results = yield Promise.all(promises);
34
34
  console.log('spawned workflow results:', results);
35
35
  console.log('number of spawned workflows:', results.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.12.4",
3
+ "version": "0.12.5",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/step.d.ts CHANGED
@@ -167,6 +167,7 @@ export declare class Context<T, K = {}> {
167
167
  spawnWorkflow<Q = JsonValue, P = JsonValue>(workflow: string | Workflow, input: Q, options?: string | {
168
168
  key?: string;
169
169
  sticky?: boolean;
170
+ additionalMetadata?: Record<string, string>;
170
171
  }): WorkflowRunRef<P>;
171
172
  additionalMetadata(): Record<string, string>;
172
173
  childIndex(): number | undefined;
package/step.js CHANGED
@@ -225,6 +225,7 @@ class Context {
225
225
  const name = this.client.config.namespace + workflowName;
226
226
  let key = '';
227
227
  let sticky = false;
228
+ let metadata = undefined;
228
229
  if (typeof options === 'string') {
229
230
  this.logger.warn('Using key param is deprecated and will be removed in a future release. Use options.key instead.');
230
231
  key = options;
@@ -232,6 +233,7 @@ class Context {
232
233
  else {
233
234
  key = options === null || options === void 0 ? void 0 : options.key;
234
235
  sticky = options === null || options === void 0 ? void 0 : options.sticky;
236
+ metadata = options === null || options === void 0 ? void 0 : options.additionalMetadata;
235
237
  }
236
238
  if (sticky && !this.worker.hasWorkflow(name)) {
237
239
  throw new hatchet_error_1.default(`cannot run with sticky: workflow ${name} is not registered on the worker`);
@@ -243,6 +245,7 @@ class Context {
243
245
  childKey: key,
244
246
  childIndex: this.spawnIndex,
245
247
  desiredWorkerId: sticky ? this.worker.id() : undefined,
248
+ additionalMetadata: metadata,
246
249
  });
247
250
  this.spawnIndex += 1;
248
251
  return resp;