chainflow 0.1.9 → 5.0.3

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.

Potentially problematic release.


This version of chainflow might be problematic. Click here for more details.

Files changed (77) hide show
  1. package/.idea/codeStyles/Project.xml +27 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/dotenv-master.iml +12 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/.vscode/settings.json +2 -0
  8. package/CHANGELOG.md +431 -0
  9. package/LICENSE +23 -21
  10. package/README-es.md +442 -0
  11. package/README.md +633 -599
  12. package/config.d.ts +1 -0
  13. package/config.js +9 -0
  14. package/index.js +35 -0
  15. package/lib/cli-options.js +11 -0
  16. package/lib/env-options.js +24 -0
  17. package/lib/main.d.ts +156 -0
  18. package/lib/main.js +314 -0
  19. package/package.json +56 -52
  20. package/pk.json +64 -0
  21. package/dist/core/chainflow.d.ts +0 -47
  22. package/dist/core/chainflow.js +0 -116
  23. package/dist/core/chainflow.js.map +0 -1
  24. package/dist/core/inputNode.d.ts +0 -34
  25. package/dist/core/inputNode.js +0 -218
  26. package/dist/core/inputNode.js.map +0 -1
  27. package/dist/core/logger.d.ts +0 -4
  28. package/dist/core/logger.js +0 -19
  29. package/dist/core/logger.js.map +0 -1
  30. package/dist/core/sourceNode.d.ts +0 -24
  31. package/dist/core/sourceNode.js +0 -37
  32. package/dist/core/sourceNode.js.map +0 -1
  33. package/dist/core/store.d.ts +0 -13
  34. package/dist/core/store.js +0 -91
  35. package/dist/core/store.js.map +0 -1
  36. package/dist/core/utils/config.d.ts +0 -16
  37. package/dist/core/utils/config.js +0 -13
  38. package/dist/core/utils/config.js.map +0 -1
  39. package/dist/core/utils/constants.d.ts +0 -2
  40. package/dist/core/utils/constants.js +0 -6
  41. package/dist/core/utils/constants.js.map +0 -1
  42. package/dist/core/utils/initializers.d.ts +0 -12
  43. package/dist/core/utils/initializers.js +0 -18
  44. package/dist/core/utils/initializers.js.map +0 -1
  45. package/dist/core/utils/link.d.ts +0 -65
  46. package/dist/core/utils/link.js +0 -34
  47. package/dist/core/utils/link.js.map +0 -1
  48. package/dist/core/utils/symbols.d.ts +0 -7
  49. package/dist/core/utils/symbols.js +0 -11
  50. package/dist/core/utils/symbols.js.map +0 -1
  51. package/dist/http/endpoint.d.ts +0 -68
  52. package/dist/http/endpoint.js +0 -222
  53. package/dist/http/endpoint.js.map +0 -1
  54. package/dist/http/errors.d.ts +0 -16
  55. package/dist/http/errors.js +0 -36
  56. package/dist/http/errors.js.map +0 -1
  57. package/dist/http/logger.d.ts +0 -4
  58. package/dist/http/logger.js +0 -21
  59. package/dist/http/logger.js.map +0 -1
  60. package/dist/http/origin.d.ts +0 -29
  61. package/dist/http/origin.js +0 -62
  62. package/dist/http/origin.js.map +0 -1
  63. package/dist/http/reqBuilder.d.ts +0 -14
  64. package/dist/http/reqBuilder.js +0 -50
  65. package/dist/http/reqBuilder.js.map +0 -1
  66. package/dist/http/utils/client.d.ts +0 -27
  67. package/dist/http/utils/client.js +0 -88
  68. package/dist/http/utils/client.js.map +0 -1
  69. package/dist/http/utils/constants.d.ts +0 -2
  70. package/dist/http/utils/constants.js +0 -12
  71. package/dist/http/utils/constants.js.map +0 -1
  72. package/dist/http/utils/id.d.ts +0 -5
  73. package/dist/http/utils/id.js +0 -9
  74. package/dist/http/utils/id.js.map +0 -1
  75. package/dist/index.d.ts +0 -10
  76. package/dist/index.js +0 -30
  77. package/dist/index.js.map +0 -1
package/pk.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "chainflow",
3
+ "version": "5.0.3",
4
+ "description": "Loads environment variables from .env file",
5
+ "main": "lib/main.js",
6
+ "types": "lib/main.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./lib/main.d.ts",
10
+ "require": "./lib/main.js",
11
+ "default": "./lib/main.js"
12
+ },
13
+ "./config": "./config.js",
14
+ "./config.js": "./config.js",
15
+ "./lib/env-options": "./lib/env-options.js",
16
+ "./lib/env-options.js": "./lib/env-options.js",
17
+ "./lib/cli-options": "./lib/cli-options.js",
18
+ "./lib/cli-options.js": "./lib/cli-options.js",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "scripts": {
22
+ "dts-check": "tsc --project tests/types/tsconfig.json",
23
+ "lint": "standard",
24
+ "lint-readme": "standard-markdown",
25
+ "pretest": "npm run lint && npm run dts-check",
26
+ "test": "tap tests/*.js --100 -Rspec",
27
+ "prerelease": "npm test",
28
+ "release": "standard-version"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/jhonnpmdev/config-envi.git"
33
+ },
34
+ "funding": "https://github.com/jhonnpmdev/config-envi.git?sponsor=1",
35
+ "keywords": [
36
+ "dotenv",
37
+ "env",
38
+ ".env",
39
+ "environment",
40
+ "variables",
41
+ "config",
42
+ "settings"
43
+ ],
44
+ "readmeFilename": "README.md",
45
+ "license": "BSD-2-Clause",
46
+ "devDependencies": {
47
+ "@definitelytyped/dtslint": "^0.0.133",
48
+ "@types/node": "^18.11.3",
49
+ "decache": "^4.6.1",
50
+ "sinon": "^14.0.1",
51
+ "standard": "^17.0.0",
52
+ "standard-markdown": "^7.1.0",
53
+ "standard-version": "^9.5.0",
54
+ "tap": "^16.3.0",
55
+ "tar": "^6.1.11",
56
+ "typescript": "^4.8.4"
57
+ },
58
+ "engines": {
59
+ "node": ">=12"
60
+ },
61
+ "browser": {
62
+ "fs": false
63
+ }
64
+ }
@@ -1,47 +0,0 @@
1
- import { SourceValues } from './inputNode';
2
- import { IStore } from './store';
3
- export interface CallResult<Req, Resp> {
4
- req: Req;
5
- resp: Resp;
6
- store?: IStore<unknown>;
7
- }
8
- /** Defines an endpoint that a chainflow can call upon. */
9
- export interface IEndpoint<CallOpts, Req, Resp> {
10
- /** Uniquely identifies this endpoint. */
11
- id: string;
12
- /** Describes the endpoint. */
13
- details: string;
14
- call: (sources: SourceValues, opts?: CallOpts) => Promise<CallResult<Req, Resp>>;
15
- }
16
- interface CallEvent {
17
- details: string;
18
- req: unknown;
19
- resp: unknown;
20
- }
21
- /** Special object used to link an InputNode to a chainflow seed. */
22
- export declare const seed: import("./sourceNode").SourceNode;
23
- /** Special object that acts as a central "gateway" between input and source values. */
24
- export declare const store: import("./sourceNode").SourceNode;
25
- export declare class Chainflow {
26
- #private;
27
- /** Stores accumulated endpoint call events. */
28
- events: CallEvent[];
29
- /** Run the set up chain */
30
- run(): Promise<this>;
31
- /** Adds a seed to this chainflow. */
32
- seed(seed: Record<string, any>): this;
33
- /** Adds an endpoint call to the callchain. */
34
- call<CallOpts, Req, Resp>(endpoint: IEndpoint<CallOpts, Req, Resp>, opts?: CallOpts): this;
35
- /** Resets the chainflow's state by clearing its accumulated sources. */
36
- reset(): void;
37
- /** Creates a clone of this chainflow's callqueue and initial sources
38
- * which can be extended and run independently. */
39
- clone(): Chainflow;
40
- /** Extends this chainflow's callqueue with that of another flow. */
41
- extend(cf: Chainflow): this;
42
- /** Causes this chainflow to continue from the state of
43
- * sources values of another chainflow. */
44
- continuesFrom(cf: Chainflow): this;
45
- }
46
- export declare const chainflow: () => Chainflow;
47
- export {};
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
- };
16
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
17
- if (kind === "m") throw new TypeError("Private method is not writable");
18
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
19
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
20
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- var _Chainflow_sources, _Chainflow_initSources, _Chainflow_callqueue;
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.chainflow = exports.Chainflow = exports.store = exports.seed = void 0;
28
- const sourceNode_1 = require("./sourceNode");
29
- const deepmerge_1 = __importDefault(require("@fastify/deepmerge"));
30
- const logger_1 = require("./logger");
31
- const constants_1 = require("./utils/constants");
32
- const deepmerge = (0, deepmerge_1.default)();
33
- /** Special object used to link an InputNode to a chainflow seed. */
34
- exports.seed = (0, sourceNode_1.sourceNode)(constants_1.SEED_ID);
35
- /** Special object that acts as a central "gateway" between input and source values. */
36
- exports.store = (0, sourceNode_1.sourceNode)(constants_1.STORE_ID);
37
- class Chainflow {
38
- constructor() {
39
- /** Stores sources such as the seed or values accumulated from
40
- * endpoint calls in the current flow. */
41
- _Chainflow_sources.set(this, {});
42
- /** Stores the sources that this chainflow was initialized with. */
43
- _Chainflow_initSources.set(this, {});
44
- _Chainflow_callqueue.set(this, []);
45
- /** Stores accumulated endpoint call events. */
46
- this.events = [];
47
- }
48
- /** Run the set up chain */
49
- run() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- (0, logger_1.log)(`Running chainflow...`);
52
- this.reset();
53
- __classPrivateFieldSet(this, _Chainflow_sources, __classPrivateFieldGet(this, _Chainflow_initSources, "f"), "f");
54
- __classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID] = [{}];
55
- for (const { endpoint, opts } of __classPrivateFieldGet(this, _Chainflow_callqueue, "f")) {
56
- // call endpoint
57
- const id = endpoint.id;
58
- (0, logger_1.log)(`Calling endpoint with id "${id}"`);
59
- const { req, resp, store } = yield endpoint.call(__classPrivateFieldGet(this, _Chainflow_sources, "f"), opts).catch((err) => {
60
- (0, logger_1.warn)(`Chainflow stopped at endpoint with id "${id}" and error: ${err}`);
61
- throw err;
62
- });
63
- if (store && Object.keys(store).length > 0)
64
- __classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0] = deepmerge(__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0], store);
65
- __classPrivateFieldGet(this, _Chainflow_sources, "f")[id] = [resp];
66
- this.events.push({ details: endpoint.details, req, resp });
67
- }
68
- (0, logger_1.log)('Finished running chainflow.');
69
- return this;
70
- });
71
- }
72
- /** Adds a seed to this chainflow. */
73
- seed(seed) {
74
- __classPrivateFieldGet(this, _Chainflow_initSources, "f")[constants_1.SEED_ID] = [seed];
75
- return this;
76
- }
77
- /** Adds an endpoint call to the callchain. */
78
- call(endpoint, opts) {
79
- __classPrivateFieldGet(this, _Chainflow_callqueue, "f").push({ endpoint, opts });
80
- return this;
81
- }
82
- /** Resets the chainflow's state by clearing its accumulated sources. */
83
- reset() {
84
- __classPrivateFieldSet(this, _Chainflow_sources, {}, "f");
85
- this.events = [];
86
- }
87
- /** Creates a clone of this chainflow's callqueue and initial sources
88
- * which can be extended and run independently. */
89
- clone() {
90
- const clone = new Chainflow();
91
- __classPrivateFieldSet(clone, _Chainflow_initSources, Object.entries(__classPrivateFieldGet(this, _Chainflow_initSources, "f")).reduce((acc, [sourceId, sourceValues]) => {
92
- acc[sourceId] = [...sourceValues];
93
- return acc;
94
- }, {}), "f");
95
- __classPrivateFieldSet(clone, _Chainflow_callqueue, [...__classPrivateFieldGet(this, _Chainflow_callqueue, "f")], "f");
96
- return clone;
97
- }
98
- /** Extends this chainflow's callqueue with that of another flow. */
99
- extend(cf) {
100
- __classPrivateFieldGet(this, _Chainflow_callqueue, "f").push(...__classPrivateFieldGet(cf, _Chainflow_callqueue, "f"));
101
- return this;
102
- }
103
- /** Causes this chainflow to continue from the state of
104
- * sources values of another chainflow. */
105
- continuesFrom(cf) {
106
- __classPrivateFieldSet(this, _Chainflow_initSources, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Chainflow_initSources, "f")), __classPrivateFieldGet(cf, _Chainflow_sources, "f")), "f");
107
- return this;
108
- }
109
- }
110
- exports.Chainflow = Chainflow;
111
- _Chainflow_sources = new WeakMap(), _Chainflow_initSources = new WeakMap(), _Chainflow_callqueue = new WeakMap();
112
- const chainflow = () => {
113
- return new Chainflow();
114
- };
115
- exports.chainflow = chainflow;
116
- //# sourceMappingURL=chainflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chainflow.js","sourceRoot":"","sources":["../../src/core/chainflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA0C;AAC1C,mEAAgD;AAEhD,qCAAqC;AACrC,iDAAsD;AAEtD,MAAM,SAAS,GAAG,IAAA,mBAAc,GAAE,CAAC;AAgCnC,oEAAoE;AACvD,QAAA,IAAI,GAAG,IAAA,uBAAU,EAAC,mBAAO,CAAC,CAAC;AAExC,uFAAuF;AAC1E,QAAA,KAAK,GAAG,IAAA,uBAAU,EAAC,oBAAQ,CAAC,CAAC;AAE1C,MAAa,SAAS;IAAtB;QACE;iDACyC;QACzC,6BAAyB,EAAE,EAAC;QAC5B,mEAAmE;QACnE,iCAA6B,EAAE,EAAC;QAChC,+BAAwB,EAAE,EAAC;QAC3B,+CAA+C;QAC/C,WAAM,GAAgB,EAAE,CAAC;IAuE3B,CAAC;IArEC,2BAA2B;I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EAAE,0BAAS,OAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,8BA+EC;;AAEM,MAAM,SAAS,GAAG,GAAc,EAAE;IACvC,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
@@ -1,34 +0,0 @@
1
- import { SourceNode } from './sourceNode';
2
- import { getNodeValue, setSource, setSources } from './utils/symbols';
3
- export declare enum NODE_VALUE {
4
- GENERATOR = 0,
5
- REQUIRED = 1,
6
- SOURCE = 2,
7
- SOURCE_WITH_CALLBACK = 3,
8
- MERGE_SOURCES_WITH_CALLBACK = 4
9
- }
10
- type SourceValue = any;
11
- export type SourceValues = {
12
- [id: string]: SourceValue[];
13
- };
14
- /** A data node for constructing an input object. */
15
- export declare class InputNode {
16
- #private;
17
- /** Key-values under this node, if this node represents an object. */
18
- [key: string]: any;
19
- constructor(val: any);
20
- /** Sets a source node for this input node. */
21
- [setSource](source: SourceNode, callback?: (val: any) => any): void;
22
- /** Sets multiple source nodes to be merged into a single value for this input node */
23
- [setSources](sources: SourceNode[] | {
24
- [key: string]: SourceNode;
25
- }, callback?: (val: any) => any): void;
26
- /** Retrieve value of a node. */
27
- [getNodeValue](sourceValues: SourceValues, missingValues: string[][], currentPath: string[]): any;
28
- /**
29
- * Builds a key-value object from input node values and
30
- * any available linked sources.
31
- */
32
- buildKvObject(currentPath: string[], missingValues: string[][], sourceValues: SourceValues): any;
33
- }
34
- export {};
@@ -1,218 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _InputNode_instances, _InputNode_isKvObject, _InputNode_default, _InputNode_required, _InputNode_sources, _InputNode_generator, _InputNode_matchSourceId, _InputNode_accessSource, _InputNode_getSingleSourceNodeValue, _InputNode_getMergeSourceNodeValues;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.InputNode = exports.NODE_VALUE = void 0;
16
- const symbols_1 = require("./utils/symbols");
17
- var NODE_VALUE;
18
- (function (NODE_VALUE) {
19
- NODE_VALUE[NODE_VALUE["GENERATOR"] = 0] = "GENERATOR";
20
- NODE_VALUE[NODE_VALUE["REQUIRED"] = 1] = "REQUIRED";
21
- NODE_VALUE[NODE_VALUE["SOURCE"] = 2] = "SOURCE";
22
- NODE_VALUE[NODE_VALUE["SOURCE_WITH_CALLBACK"] = 3] = "SOURCE_WITH_CALLBACK";
23
- NODE_VALUE[NODE_VALUE["MERGE_SOURCES_WITH_CALLBACK"] = 4] = "MERGE_SOURCES_WITH_CALLBACK";
24
- })(NODE_VALUE || (exports.NODE_VALUE = NODE_VALUE = {}));
25
- /** A data node for constructing an input object. */
26
- class InputNode {
27
- constructor(val) {
28
- _InputNode_instances.add(this);
29
- /** Determines if this is a key-value object that needs to be built further. */
30
- _InputNode_isKvObject.set(this, false);
31
- /** Default value of this node */
32
- _InputNode_default.set(this, void 0);
33
- /** Whether this node requires a value from a source object. */
34
- _InputNode_required.set(this, false);
35
- /** Stores what source node values can be passed into this node. */
36
- _InputNode_sources.set(this, {});
37
- /** Generator function to generate values on demand for this node. */
38
- _InputNode_generator.set(this, void 0);
39
- if (val == null) {
40
- __classPrivateFieldSet(this, _InputNode_default, val, "f");
41
- return;
42
- }
43
- switch (val[symbols_1.nodeValueIdentifier]) {
44
- case NODE_VALUE.GENERATOR:
45
- __classPrivateFieldSet(this, _InputNode_generator, val.generator, "f");
46
- return;
47
- case NODE_VALUE.REQUIRED:
48
- __classPrivateFieldSet(this, _InputNode_required, true, "f");
49
- return;
50
- case NODE_VALUE.SOURCE:
51
- this[symbols_1.setSource](val);
52
- return;
53
- case NODE_VALUE.SOURCE_WITH_CALLBACK /** @todo explore refactoring here */:
54
- this[symbols_1.setSource](val.source, val.callback);
55
- return;
56
- case NODE_VALUE.MERGE_SOURCES_WITH_CALLBACK:
57
- this[symbols_1.setSources](val.sources, val.callback);
58
- return;
59
- }
60
- switch (typeof val) {
61
- case 'object':
62
- if (Array.isArray(val)) {
63
- // this means you can't put a source node into an array
64
- __classPrivateFieldSet(this, _InputNode_default, val, "f");
65
- break;
66
- }
67
- __classPrivateFieldSet(this, _InputNode_isKvObject, true, "f");
68
- Object.entries(val).forEach(([key, val]) => {
69
- this[key] = new InputNode(val);
70
- });
71
- break;
72
- default:
73
- __classPrivateFieldSet(this, _InputNode_default, val, "f");
74
- break;
75
- }
76
- }
77
- /** Sets a source node for this input node. */
78
- [(_InputNode_isKvObject = new WeakMap(), _InputNode_default = new WeakMap(), _InputNode_required = new WeakMap(), _InputNode_sources = new WeakMap(), _InputNode_generator = new WeakMap(), _InputNode_instances = new WeakSet(), symbols_1.setSource)](source, callback) {
79
- __classPrivateFieldGet(this, _InputNode_sources, "f")[source[symbols_1.sourceId]] = {
80
- path: source[symbols_1.nodePath],
81
- allowUndefined: source[symbols_1.allowUndefined],
82
- callback,
83
- };
84
- }
85
- /** Sets multiple source nodes to be merged into a single value for this input node */
86
- [symbols_1.setSources](sources, callback) {
87
- const ids = new Set();
88
- let accessInfo;
89
- let isArray = false;
90
- if (Array.isArray(sources)) {
91
- isArray = true;
92
- accessInfo = sources.map((source) => {
93
- const id = source[symbols_1.sourceId];
94
- ids.add(id);
95
- return {
96
- path: source[symbols_1.nodePath],
97
- allowUndefined: source[symbols_1.allowUndefined],
98
- id,
99
- };
100
- });
101
- }
102
- else {
103
- accessInfo = Object.entries(sources).map(([key, source]) => {
104
- const id = source[symbols_1.sourceId];
105
- ids.add(id);
106
- return {
107
- path: source[symbols_1.nodePath],
108
- allowUndefined: source[symbols_1.allowUndefined],
109
- id,
110
- key,
111
- };
112
- });
113
- }
114
- /** @todo improve this */
115
- __classPrivateFieldGet(this, _InputNode_sources, "f")[new Array(...ids).sort().join('|')] = {
116
- accessInfo,
117
- isArray,
118
- callback,
119
- };
120
- }
121
- /** Retrieve value of a node. */
122
- [symbols_1.getNodeValue](sourceValues, missingValues, currentPath) {
123
- const usedSources = []; // stores sourceValues that are already tried
124
- // attempt to get value from any source nodes available
125
- let sourceEndpointId = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_matchSourceId).call(this, sourceValues, usedSources);
126
- while (sourceEndpointId) {
127
- const source = __classPrivateFieldGet(this, _InputNode_sources, "f")[sourceEndpointId];
128
- let sourceVal;
129
- if ('accessInfo' in source) {
130
- sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getMergeSourceNodeValues).call(this, source, sourceValues);
131
- }
132
- else {
133
- sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, sourceEndpointId, source.path, sourceValues);
134
- }
135
- if (sourceVal !== undefined || ('allowUndefined' in source && source.allowUndefined)) {
136
- return source.callback ? source.callback(sourceVal) : sourceVal;
137
- }
138
- usedSources.push(...sourceEndpointId.split('|'));
139
- sourceEndpointId = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_matchSourceId).call(this, sourceValues, usedSources);
140
- }
141
- // attempt to get value from generator function
142
- if (__classPrivateFieldGet(this, _InputNode_generator, "f")) {
143
- return __classPrivateFieldGet(this, _InputNode_generator, "f").call(this);
144
- }
145
- if (__classPrivateFieldGet(this, _InputNode_isKvObject, "f")) {
146
- return this.buildKvObject(currentPath, missingValues, sourceValues);
147
- }
148
- // default will only be undefined for objects that need to be built further
149
- if (__classPrivateFieldGet(this, _InputNode_default, "f") === undefined && __classPrivateFieldGet(this, _InputNode_required, "f")) {
150
- missingValues.push(currentPath);
151
- return;
152
- }
153
- // if other options are exhausted, revert to default
154
- return __classPrivateFieldGet(this, _InputNode_default, "f");
155
- }
156
- /**
157
- * Builds a key-value object from input node values and
158
- * any available linked sources.
159
- */
160
- buildKvObject(currentPath, missingValues, sourceValues) {
161
- return Object.entries(this).reduce((acc, [key, val]) => {
162
- const nextPath = [...currentPath, key];
163
- acc[key] = val[symbols_1.getNodeValue](sourceValues, missingValues, nextPath);
164
- return acc;
165
- }, {});
166
- }
167
- }
168
- exports.InputNode = InputNode;
169
- _InputNode_matchSourceId = function _InputNode_matchSourceId(sourceValues, usedSources) {
170
- const sourceEndpointIds = Object.keys(__classPrivateFieldGet(this, _InputNode_sources, "f"));
171
- const availSourceIds = Object.keys(sourceValues);
172
- return sourceEndpointIds.find((id) => {
173
- if (id.includes('|')) {
174
- // handle combined id for multi-node source
175
- const ids = id.split('|');
176
- if (
177
- // if every source is available
178
- ids.every((id) => availSourceIds.includes(id) && !usedSources.includes(id))) {
179
- return id;
180
- }
181
- }
182
- return availSourceIds.includes(id) && !usedSources.includes(id);
183
- });
184
- }, _InputNode_accessSource = function _InputNode_accessSource(payload, path) {
185
- let sourceVal = payload;
186
- let i = 0;
187
- while (i < path.length) {
188
- // still in the process of walking the path to the actual
189
- // source value, hence current sourceVal should be an object
190
- // However, `typeof null` returns 'object'
191
- // hence the 2nd condition checks against `null`
192
- if (typeof sourceVal !== 'object' || sourceVal == null)
193
- return;
194
- const accessor = path[i];
195
- sourceVal = sourceVal[accessor];
196
- i += 1;
197
- }
198
- return sourceVal;
199
- }, _InputNode_getSingleSourceNodeValue = function _InputNode_getSingleSourceNodeValue(id, path, sourceValues) {
200
- const sourceValuesForId = sourceValues[id];
201
- const sourceObject = sourceValuesForId[sourceValuesForId.length - 1];
202
- // get value from a linked source
203
- return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_accessSource).call(this, sourceObject, path);
204
- }, _InputNode_getMergeSourceNodeValues = function _InputNode_getMergeSourceNodeValues(sources, sourceValues) {
205
- let sourceVals;
206
- sources.isArray ? (sourceVals = []) : (sourceVals = {});
207
- for (const info of sources.accessInfo) {
208
- const sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, info.id, info.path, sourceValues);
209
- // if one value is unavailable, stop constructing multi-source value
210
- if (sourceVal === undefined)
211
- return undefined;
212
- sources.isArray
213
- ? sourceVals.push(sourceVal)
214
- : (sourceVals[info.key] = sourceVal);
215
- }
216
- return sourceVals;
217
- };
218
- //# sourceMappingURL=inputNode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inputNode.js","sourceRoot":"","sources":["../../src/core/inputNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6CAQyB;AAEzB,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,qDAAS,CAAA;IACT,mDAAQ,CAAA;IACR,+CAAM,CAAA;IACN,2EAAoB,CAAA;IACpB,yFAA2B,CAAA;AAC7B,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAiCD,oDAAoD;AACpD,MAAa,SAAS;IAcpB,YAAY,GAAQ;;QAXpB,+EAA+E;QAC/E,gCAAuB,KAAK,EAAC;QAC7B,iCAAiC;QACjC,qCAAc;QACd,+DAA+D;QAC/D,8BAAqB,KAAK,EAAC;QAC3B,mEAAmE;QACnE,6BAAuD,EAAE,EAAC;QAC1D,qEAAqE;QACrE,uCAAoC;QAGlC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,uBAAA,IAAI,sBAAY,GAAG,MAAA,CAAC;YACpB,OAAO;QACT,CAAC;QAED,QAAQ,GAAG,CAAC,6BAAmB,CAAC,EAAE,CAAC;YACjC,KAAK,UAAU,CAAC,SAAS;gBACvB,u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E,YAA0B;IACrE,IAAI,UAAkD,CAAC;IACvD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;IAExD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,uBAAA,IAAI,iEAA0B,MAA9B,IAAI,EAA2B,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnF,oEAAoE;QACpE,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,CAAC,OAAO;YACb,CAAC,CAAE,UAAwB,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3C,CAAC,CAAC,CAAE,UAAyC,CAAC,IAAI,CAAC,GAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -1,4 +0,0 @@
1
- import debug from 'debug';
2
- export declare const log: debug.Debugger;
3
- export declare const warn: debug.Debugger;
4
- export declare const enableLogs: () => void;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.enableLogs = exports.warn = exports.log = void 0;
7
- /* istanbul ignore file */
8
- const debug_1 = __importDefault(require("debug"));
9
- exports.log = (0, debug_1.default)('chainflow:core');
10
- exports.warn = (0, debug_1.default)('chainflow:core:error');
11
- const enableLogs = () => {
12
- exports.log.enabled = true;
13
- exports.warn.enabled = true;
14
- };
15
- exports.enableLogs = enableLogs;
16
- if (process.env.ENABLE_CHAINFLOW_LOGS === 'true') {
17
- (0, exports.enableLogs)();
18
- }
19
- //# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";;;;;;AAAA,0BAA0B;AAC1B,kDAA0B;AAEb,QAAA,GAAG,GAAG,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC;AAC9B,QAAA,IAAI,GAAG,IAAA,eAAK,EAAC,sBAAsB,CAAC,CAAC;AAE3C,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,WAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACnB,YAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACtB,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;IACjD,IAAA,kBAAU,GAAE,CAAC;AACf,CAAC"}
@@ -1,24 +0,0 @@
1
- import { NODE_VALUE } from './inputNode';
2
- import { sourceId, nodePath, nodeValueIdentifier, allowUndefined } from './utils/symbols';
3
- /** Creates a new Source Node with the given id. */
4
- export declare const sourceNode: (id: string) => SourceNode;
5
- /** Describes a value in a source node e.g. the output of an endpoint call. */
6
- export interface SourceNode {
7
- [sourceId]: string;
8
- [nodePath]: string[];
9
- [allowUndefined]?: boolean;
10
- [nodeValueIdentifier]: NODE_VALUE;
11
- [key: string]: SourceNode;
12
- }
13
- /** An intermediate object used to contain information on the SourceNode being built. */
14
- interface RawSourceNode {
15
- path: string[];
16
- id: string;
17
- allowUndefined?: boolean;
18
- }
19
- /** Generates proxies recursively to handle nested property access of a source signature. */
20
- export declare const SourceNodeHandler: {
21
- get(obj: RawSourceNode, prop: any): unknown;
22
- set(obj: RawSourceNode, prop: any, val: any): any;
23
- };
24
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SourceNodeHandler = exports.sourceNode = void 0;
4
- const inputNode_1 = require("./inputNode");
5
- const symbols_1 = require("./utils/symbols");
6
- /** Creates a new Source Node with the given id. */
7
- const sourceNode = (id) => new Proxy({ path: [], id }, exports.SourceNodeHandler);
8
- exports.sourceNode = sourceNode;
9
- /** Generates proxies recursively to handle nested property access of a source signature. */
10
- exports.SourceNodeHandler = {
11
- get(obj, prop) {
12
- switch (prop) {
13
- case symbols_1.nodePath:
14
- return obj.path;
15
- case symbols_1.sourceId:
16
- return obj.id;
17
- case symbols_1.allowUndefined:
18
- return obj.allowUndefined;
19
- case symbols_1.nodeValueIdentifier:
20
- return inputNode_1.NODE_VALUE.SOURCE;
21
- default: {
22
- const newPath = [...obj.path];
23
- newPath.push(prop);
24
- return new Proxy({
25
- path: newPath,
26
- id: obj.id,
27
- allowUndefined: obj.allowUndefined,
28
- }, exports.SourceNodeHandler);
29
- }
30
- }
31
- },
32
- set(obj, prop, val) {
33
- if (prop === symbols_1.allowUndefined)
34
- return (obj.allowUndefined = val);
35
- },
36
- };
37
- //# sourceMappingURL=sourceNode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sourceNode.js","sourceRoot":"","sources":["../../src/core/sourceNode.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,6CAA0F;AAE1F,mDAAmD;AAC5C,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CACvC,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,yBAAiB,CAA0B,CAAC;AAD7D,QAAA,UAAU,cACmD;AAkB1E,4FAA4F;AAC/E,QAAA,iBAAiB,GAAG;IAC/B,GAAG,CAAC,GAAkB,EAAE,IAAS;QAC/B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,kBAAQ;gBACX,OAAO,GAAG,CAAC,IAAI,CAAC;YAClB,KAAK,kBAAQ;gBACX,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,KAAK,wBAAc;gBACjB,OAAO,GAAG,CAAC,cAAc,CAAC;YAC5B,KAAK,6BAAmB;gBACtB,OAAO,sBAAU,CAAC,MAAM,CAAC;YAC3B,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,OAAO,IAAI,KAAK,CACd;oBACE,IAAI,EAAE,OAAO;oBACb,EAAE,EAAE,GAAG,CAAC,EAAE;oBACV,cAAc,EAAE,GAAG,CAAC,cAAc;iBACnC,EACD,yBAAiB,CACO,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAkB,EAAE,IAAS,EAAE,GAAQ;QACzC,IAAI,IAAI,KAAK,wBAAc;YAAE,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC;IACjE,CAAC;CACF,CAAC"}
@@ -1,13 +0,0 @@
1
- import { SourceNode } from './sourceNode';
2
- export type StoreValue<T> = IStore<T> | T;
3
- export interface IStore<T> {
4
- [key: string]: StoreValue<T>;
5
- }
6
- /** Manages the storing of values for an endpoint. */
7
- export declare class Store {
8
- #private;
9
- /** Definition of values to be stored from responses to this endpoint. */
10
- def: IStore<SourceNode>;
11
- /** Assigns values to be put in the chainflow's store. */
12
- storeValues(resp: unknown): IStore<unknown>;
13
- }