@hatchet-dev/typescript-sdk 1.0.4 → 1.0.6

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.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/step.d.ts CHANGED
@@ -9,7 +9,7 @@ import { V0Worker } from './clients/worker';
9
9
  import { WorkerLabels } from './clients/dispatcher/dispatcher-client';
10
10
  import { CreateStepRateLimit, RateLimitDuration, WorkerLabelComparator } from './protoc/workflows';
11
11
  import { CreateWorkflowTaskOpts } from './v1/task';
12
- import { BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
12
+ import { TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
13
13
  import { Conditions } from './v1/conditions';
14
14
  import { Duration } from './v1/client/duration';
15
15
  import { JsonObject, JsonValue, OutputType } from './v1/types';
@@ -358,7 +358,7 @@ export declare class Context<T, K = {}> {
358
358
  * @param optionsOrKey - Either a string key or an options object containing key, sticky, and additionalMetadata.
359
359
  * @returns The result of the workflow.
360
360
  */
361
- runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, optionsOrKey?: string | {
361
+ runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, optionsOrKey?: string | {
362
362
  key?: string;
363
363
  sticky?: boolean;
364
364
  additionalMetadata?: Record<string, string>;
@@ -385,7 +385,7 @@ export declare class Context<T, K = {}> {
385
385
  * @returns A reference to the spawned workflow run.
386
386
  * @deprecated Use runChild or runNoWaitChild instead.
387
387
  */
388
- spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: string | {
388
+ spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: string | {
389
389
  key?: string;
390
390
  sticky?: boolean;
391
391
  additionalMetadata?: Record<string, string>;
package/step.js CHANGED
@@ -52,6 +52,7 @@ const hatchet_error_1 = __importDefault(require("./util/errors/hatchet-error"));
52
52
  const z = __importStar(require("zod"));
53
53
  const parse_1 = require("./util/parse");
54
54
  const workflows_1 = require("./protoc/workflows");
55
+ const declaration_1 = require("./v1/declaration");
55
56
  const conditions_1 = require("./v1/conditions");
56
57
  const condition_1 = require("./protoc/v1/shared/condition");
57
58
  const transformer_1 = require("./v1/conditions/transformer");
@@ -360,7 +361,14 @@ class Context {
360
361
  bulkRunChildren(children) {
361
362
  return __awaiter(this, void 0, void 0, function* () {
362
363
  const runs = yield this.bulkRunNoWaitChildren(children);
363
- const res = runs.map((run) => run.output);
364
+ const res = runs.map((run, index) => __awaiter(this, void 0, void 0, function* () {
365
+ const wf = children[index].workflow;
366
+ if (wf instanceof declaration_1.TaskWorkflowDeclaration) {
367
+ // eslint-disable-next-line no-underscore-dangle
368
+ return (yield run.output)[wf._standalone_task_name];
369
+ }
370
+ return run.output;
371
+ }));
364
372
  return Promise.all(res);
365
373
  });
366
374
  }
@@ -427,6 +435,13 @@ class Context {
427
435
  runChild(workflow, input, optionsOrKey) {
428
436
  return __awaiter(this, void 0, void 0, function* () {
429
437
  const run = yield this.spawnWorkflow(workflow, input, optionsOrKey);
438
+ if (workflow instanceof declaration_1.TaskWorkflowDeclaration) {
439
+ // eslint-disable-next-line no-underscore-dangle
440
+ if (workflow._standalone_task_name) {
441
+ // eslint-disable-next-line no-underscore-dangle
442
+ return (yield run.output)[workflow._standalone_task_name];
443
+ }
444
+ }
430
445
  return run.output;
431
446
  });
432
447
  }
@@ -298,7 +298,7 @@ export declare class WorkflowDeclaration<I extends InputType = UnknownInputType,
298
298
  }): CreateWorkflowDurableTaskOpts<I, TO>;
299
299
  }
300
300
  export declare class TaskWorkflowDeclaration<I extends InputType = UnknownInputType, O extends OutputType = void> extends BaseWorkflowDeclaration<I, O> {
301
- private _standalone_task_name;
301
+ _standalone_task_name: string;
302
302
  constructor(options: CreateTaskWorkflowOpts<I, O>, client?: IHatchetClient);
303
303
  run(input: I, options?: RunOpts): Promise<O>;
304
304
  run(input: I[], options?: RunOpts): Promise<O[]>;
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.0.4";
1
+ export declare const HATCHET_VERSION = "1.0.6";
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.0.4';
4
+ exports.HATCHET_VERSION = '1.0.6';