@abinnovision/nestjs-hatchet 0.8.0-beta.1 → 0.8.0-beta.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.
|
@@ -8,9 +8,9 @@ const require_helpers = require("../../references/helpers.cjs");
|
|
|
8
8
|
const workflowName = require_helpers.getRefAccessor(ref).name;
|
|
9
9
|
const wait = options?.wait ?? true;
|
|
10
10
|
if (Array.isArray(input)) {
|
|
11
|
-
const
|
|
12
|
-
if (wait) return await Promise.all(
|
|
13
|
-
return
|
|
11
|
+
const runs = input.map((i) => runner(workflowName, i, options));
|
|
12
|
+
if (wait) return await Promise.all(runs.map((p) => p.then((r) => r.output)));
|
|
13
|
+
return await Promise.all(runs);
|
|
14
14
|
}
|
|
15
15
|
const runRef = await runner(workflowName, input, options);
|
|
16
16
|
if (wait) return runRef.output;
|
|
@@ -8,9 +8,9 @@ import { getRefAccessor } from "../../references/helpers.mjs";
|
|
|
8
8
|
const workflowName = getRefAccessor(ref).name;
|
|
9
9
|
const wait = options?.wait ?? true;
|
|
10
10
|
if (Array.isArray(input)) {
|
|
11
|
-
const
|
|
12
|
-
if (wait) return await Promise.all(
|
|
13
|
-
return
|
|
11
|
+
const runs = input.map((i) => runner(workflowName, i, options));
|
|
12
|
+
if (wait) return await Promise.all(runs.map((p) => p.then((r) => r.output)));
|
|
13
|
+
return await Promise.all(runs);
|
|
14
14
|
}
|
|
15
15
|
const runRef = await runner(workflowName, input, options);
|
|
16
16
|
if (wait) return runRef.output;
|
|
@@ -3,6 +3,11 @@ const require_translator = require("./translator.cjs");
|
|
|
3
3
|
const require_hosts = require("../abstracts/hosts.cjs");
|
|
4
4
|
//#region src/metadata/accessor.ts
|
|
5
5
|
/**
|
|
6
|
+
* Cache of decorated method names keyed by host constructor. Decorator
|
|
7
|
+
* metadata is fixed at class-definition time, so this is safe to memoize for
|
|
8
|
+
* the lifetime of the constructor.
|
|
9
|
+
*/ const methodsCache = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
/**
|
|
6
11
|
* Accessor for host metadata and methods.
|
|
7
12
|
*/ let HostAccessor = class HostAccessor {
|
|
8
13
|
ctor;
|
|
@@ -29,9 +34,13 @@ const require_hosts = require("../abstracts/hosts.cjs");
|
|
|
29
34
|
return this.ctor.prototype instanceof require_hosts.TaskHost;
|
|
30
35
|
}
|
|
31
36
|
get methods() {
|
|
37
|
+
const cached = methodsCache.get(this.ctor);
|
|
38
|
+
if (cached !== void 0) return cached;
|
|
32
39
|
const markerKey = this.isWorkflow ? require_keys.METADATA_KEY_WORKFLOW_TASK_OPTS : require_keys.METADATA_KEY_TASK_OPTS;
|
|
33
40
|
const proto = this.ctor.prototype;
|
|
34
|
-
|
|
41
|
+
const result = Object.getOwnPropertyNames(proto).filter((name) => name !== "constructor" && typeof proto[name] === "function").filter((method) => Reflect.getMetadata(markerKey, proto[method]) !== void 0);
|
|
42
|
+
methodsCache.set(this.ctor, result);
|
|
43
|
+
return result;
|
|
35
44
|
}
|
|
36
45
|
getWorkflowTaskMeta(method) {
|
|
37
46
|
return Reflect.getMetadata(require_keys.METADATA_KEY_WORKFLOW_TASK_OPTS, this.ctor.prototype[method]);
|
|
@@ -3,6 +3,11 @@ import { translateHostOpts } from "./translator.mjs";
|
|
|
3
3
|
import { TaskHost, WorkflowHost } from "../abstracts/hosts.mjs";
|
|
4
4
|
//#region src/metadata/accessor.ts
|
|
5
5
|
/**
|
|
6
|
+
* Cache of decorated method names keyed by host constructor. Decorator
|
|
7
|
+
* metadata is fixed at class-definition time, so this is safe to memoize for
|
|
8
|
+
* the lifetime of the constructor.
|
|
9
|
+
*/ const methodsCache = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
/**
|
|
6
11
|
* Accessor for host metadata and methods.
|
|
7
12
|
*/ let HostAccessor = class HostAccessor {
|
|
8
13
|
ctor;
|
|
@@ -29,9 +34,13 @@ import { TaskHost, WorkflowHost } from "../abstracts/hosts.mjs";
|
|
|
29
34
|
return this.ctor.prototype instanceof TaskHost;
|
|
30
35
|
}
|
|
31
36
|
get methods() {
|
|
37
|
+
const cached = methodsCache.get(this.ctor);
|
|
38
|
+
if (cached !== void 0) return cached;
|
|
32
39
|
const markerKey = this.isWorkflow ? METADATA_KEY_WORKFLOW_TASK_OPTS : METADATA_KEY_TASK_OPTS;
|
|
33
40
|
const proto = this.ctor.prototype;
|
|
34
|
-
|
|
41
|
+
const result = Object.getOwnPropertyNames(proto).filter((name) => name !== "constructor" && typeof proto[name] === "function").filter((method) => Reflect.getMetadata(markerKey, proto[method]) !== void 0);
|
|
42
|
+
methodsCache.set(this.ctor, result);
|
|
43
|
+
return result;
|
|
35
44
|
}
|
|
36
45
|
getWorkflowTaskMeta(method) {
|
|
37
46
|
return Reflect.getMetadata(METADATA_KEY_WORKFLOW_TASK_OPTS, this.ctor.prototype[method]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@abinnovision/nestjs-hatchet",
|
|
4
|
-
"version": "0.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.2",
|
|
5
5
|
"description": "NestJS integration for Hatchet workflow orchestration with declarative task and workflow decorators for building distributed job systems.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"nestjs",
|