chainflow 0.1.0

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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +414 -0
  3. package/dist/core/chainflow.d.ts +44 -0
  4. package/dist/core/chainflow.js +113 -0
  5. package/dist/core/chainflow.js.map +1 -0
  6. package/dist/core/inputNode.d.ts +41 -0
  7. package/dist/core/inputNode.js +228 -0
  8. package/dist/core/inputNode.js.map +1 -0
  9. package/dist/core/logger.d.ts +3 -0
  10. package/dist/core/logger.js +15 -0
  11. package/dist/core/logger.js.map +1 -0
  12. package/dist/core/sourceNode.d.ts +24 -0
  13. package/dist/core/sourceNode.js +37 -0
  14. package/dist/core/sourceNode.js.map +1 -0
  15. package/dist/core/store.d.ts +14 -0
  16. package/dist/core/store.js +91 -0
  17. package/dist/core/store.js.map +1 -0
  18. package/dist/core/utils/constants.d.ts +2 -0
  19. package/dist/core/utils/constants.js +6 -0
  20. package/dist/core/utils/constants.js.map +1 -0
  21. package/dist/core/utils/initializers.d.ts +17 -0
  22. package/dist/core/utils/initializers.js +24 -0
  23. package/dist/core/utils/initializers.js.map +1 -0
  24. package/dist/core/utils/link.d.ts +24 -0
  25. package/dist/core/utils/link.js +35 -0
  26. package/dist/core/utils/link.js.map +1 -0
  27. package/dist/core/utils/source.d.ts +13 -0
  28. package/dist/core/utils/source.js +18 -0
  29. package/dist/core/utils/source.js.map +1 -0
  30. package/dist/core/utils/symbols.d.ts +8 -0
  31. package/dist/core/utils/symbols.js +12 -0
  32. package/dist/core/utils/symbols.js.map +1 -0
  33. package/dist/http/endpoint.d.ts +64 -0
  34. package/dist/http/endpoint.js +233 -0
  35. package/dist/http/endpoint.js.map +1 -0
  36. package/dist/http/errors.d.ts +11 -0
  37. package/dist/http/errors.js +27 -0
  38. package/dist/http/errors.js.map +1 -0
  39. package/dist/http/logger.d.ts +3 -0
  40. package/dist/http/logger.js +15 -0
  41. package/dist/http/logger.js.map +1 -0
  42. package/dist/http/originServer.d.ts +28 -0
  43. package/dist/http/originServer.js +60 -0
  44. package/dist/http/originServer.js.map +1 -0
  45. package/dist/http/reqBuilder.d.ts +14 -0
  46. package/dist/http/reqBuilder.js +50 -0
  47. package/dist/http/reqBuilder.js.map +1 -0
  48. package/dist/http/utils/client.d.ts +16 -0
  49. package/dist/http/utils/client.js +39 -0
  50. package/dist/http/utils/client.js.map +1 -0
  51. package/dist/http/utils/constants.d.ts +2 -0
  52. package/dist/http/utils/constants.js +12 -0
  53. package/dist/http/utils/constants.js.map +1 -0
  54. package/dist/http/utils/hash.d.ts +4 -0
  55. package/dist/http/utils/hash.js +8 -0
  56. package/dist/http/utils/hash.js.map +1 -0
  57. package/dist/index.d.ts +8 -0
  58. package/dist/index.js +25 -0
  59. package/dist/index.js.map +1 -0
  60. package/package.json +59 -0
@@ -0,0 +1,228 @@
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_valuePool, _InputNode_valuePoolSelect, _InputNode_generator, _InputNode_matchSourceHash, _InputNode_accessSource, _InputNode_getSingleSourceNodeValue, _InputNode_getMultiSourceNodeValues, _InputNode_selectValue;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InputNode = exports.NodeValue = exports.VALUE_POOL_SELECT = void 0;
16
+ const symbols_1 = require("./utils/symbols");
17
+ /** @experimental How a value pool should choose its values. */
18
+ var VALUE_POOL_SELECT;
19
+ (function (VALUE_POOL_SELECT) {
20
+ VALUE_POOL_SELECT[VALUE_POOL_SELECT["UNIFORM"] = 0] = "UNIFORM";
21
+ })(VALUE_POOL_SELECT || (exports.VALUE_POOL_SELECT = VALUE_POOL_SELECT = {}));
22
+ var NodeValue;
23
+ (function (NodeValue) {
24
+ NodeValue[NodeValue["ValuePool"] = 0] = "ValuePool";
25
+ NodeValue[NodeValue["Generator"] = 1] = "Generator";
26
+ NodeValue[NodeValue["Required"] = 2] = "Required";
27
+ NodeValue[NodeValue["Source"] = 3] = "Source";
28
+ NodeValue[NodeValue["SourceWithCallback"] = 4] = "SourceWithCallback";
29
+ NodeValue[NodeValue["Sources"] = 5] = "Sources";
30
+ })(NodeValue || (exports.NodeValue = NodeValue = {}));
31
+ /** A data node for constructing an input object. */
32
+ class InputNode {
33
+ constructor(val) {
34
+ _InputNode_instances.add(this);
35
+ /** Determines if this is a key-value object that needs to be built further. */
36
+ _InputNode_isKvObject.set(this, false);
37
+ /** Default value of this node */
38
+ _InputNode_default.set(this, void 0);
39
+ /** Whether this node requires a value from a source object. */
40
+ _InputNode_required.set(this, false);
41
+ /** Stores what source node values can be passed into this node. */
42
+ _InputNode_sources.set(this, {});
43
+ /** @experimental Stores possible values this node can take. */
44
+ _InputNode_valuePool.set(this, []);
45
+ /** @experimental Determines what strategy to select from pool of values */
46
+ _InputNode_valuePoolSelect.set(this, VALUE_POOL_SELECT.UNIFORM);
47
+ /** Generator function to generate values on demand for this node. */
48
+ _InputNode_generator.set(this, void 0);
49
+ if (val == null) {
50
+ __classPrivateFieldSet(this, _InputNode_default, val, "f");
51
+ return;
52
+ }
53
+ switch (val[symbols_1.nodeValueIdentifier]) {
54
+ case NodeValue.ValuePool:
55
+ __classPrivateFieldSet(this, _InputNode_valuePool, val.valuePool, "f");
56
+ return;
57
+ case NodeValue.Generator:
58
+ __classPrivateFieldSet(this, _InputNode_generator, val.generator, "f");
59
+ return;
60
+ case NodeValue.Required:
61
+ __classPrivateFieldSet(this, _InputNode_required, true, "f");
62
+ return;
63
+ case NodeValue.Source:
64
+ this[symbols_1.setSource](val);
65
+ return;
66
+ case NodeValue.SourceWithCallback: // TODO: explore refactoring here
67
+ this[symbols_1.setSource](val.source, val.callback);
68
+ return;
69
+ case NodeValue.Sources:
70
+ // TODO: validation here
71
+ val.sources.forEach((source) => {
72
+ this[symbols_1.setSource](source, val.callback);
73
+ });
74
+ return;
75
+ }
76
+ switch (typeof val) {
77
+ case 'object':
78
+ if (Array.isArray(val)) {
79
+ // this means you can't put a source node into an array
80
+ __classPrivateFieldSet(this, _InputNode_default, val, "f");
81
+ break;
82
+ }
83
+ __classPrivateFieldSet(this, _InputNode_isKvObject, true, "f");
84
+ Object.entries(val).forEach(([key, val]) => {
85
+ this[key] = new InputNode(val);
86
+ });
87
+ break;
88
+ default:
89
+ __classPrivateFieldSet(this, _InputNode_default, val, "f");
90
+ break;
91
+ }
92
+ }
93
+ /** Sets a source node for this input node. */
94
+ [(_InputNode_isKvObject = new WeakMap(), _InputNode_default = new WeakMap(), _InputNode_required = new WeakMap(), _InputNode_sources = new WeakMap(), _InputNode_valuePool = new WeakMap(), _InputNode_valuePoolSelect = new WeakMap(), _InputNode_generator = new WeakMap(), _InputNode_instances = new WeakSet(), symbols_1.setSource)](source, callback) {
95
+ __classPrivateFieldGet(this, _InputNode_sources, "f")[source[symbols_1.nodeHash]] = {
96
+ path: source[symbols_1.nodePath],
97
+ undefinedAllowed: source[symbols_1.undefinedAllowed],
98
+ callback,
99
+ };
100
+ }
101
+ /** Sets multiple source nodes to be combined into a single value for this input node */
102
+ [symbols_1.setSources](sources, callback) {
103
+ const hashes = new Set();
104
+ const accessInfo = Object.entries(sources).map(([key, source]) => {
105
+ const hash = source[symbols_1.nodeHash];
106
+ hashes.add(hash);
107
+ return {
108
+ path: source[symbols_1.nodePath],
109
+ undefinedAllowed: source[symbols_1.undefinedAllowed],
110
+ hash,
111
+ key,
112
+ };
113
+ });
114
+ __classPrivateFieldGet(this, _InputNode_sources, "f")[new Array(...hashes).sort().join('|')] = {
115
+ accessInfo,
116
+ callback,
117
+ };
118
+ }
119
+ /** Sets the pool of values for this input node. */
120
+ [symbols_1.setValuePool](valuePool) {
121
+ __classPrivateFieldSet(this, _InputNode_valuePool, valuePool, "f");
122
+ }
123
+ /** Retrieve value of a node. */
124
+ [symbols_1.getNodeValue](sourceValues, missingValues, currentPath) {
125
+ const usedSources = []; // stores sourceValues that are already tried
126
+ // attempt to get value from any source nodes available
127
+ let sourceHash = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_matchSourceHash).call(this, sourceValues, usedSources);
128
+ while (sourceHash) {
129
+ const source = __classPrivateFieldGet(this, _InputNode_sources, "f")[sourceHash];
130
+ let sourceVal;
131
+ if ('accessInfo' in source) {
132
+ sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getMultiSourceNodeValues).call(this, source, sourceValues);
133
+ }
134
+ else {
135
+ sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, sourceHash, source.path, sourceValues, source.undefinedAllowed);
136
+ }
137
+ if (sourceVal !== undefined || ('undefinedAllowed' in source && source.undefinedAllowed)) {
138
+ return source.callback ? source.callback(sourceVal) : sourceVal;
139
+ }
140
+ usedSources.push(...sourceHash.split('|'));
141
+ sourceHash = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_matchSourceHash).call(this, sourceValues, usedSources);
142
+ }
143
+ // attempt to get value from generator function
144
+ if (__classPrivateFieldGet(this, _InputNode_generator, "f")) {
145
+ return __classPrivateFieldGet(this, _InputNode_generator, "f").call(this);
146
+ }
147
+ // attempt to get value from value pool
148
+ if (__classPrivateFieldGet(this, _InputNode_valuePool, "f").length > 0) {
149
+ return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_selectValue).call(this);
150
+ }
151
+ if (__classPrivateFieldGet(this, _InputNode_isKvObject, "f")) {
152
+ return this.buildKvObject(currentPath, missingValues, sourceValues);
153
+ }
154
+ // default will only be undefined for objects that need to be built further
155
+ if (__classPrivateFieldGet(this, _InputNode_default, "f") === undefined && __classPrivateFieldGet(this, _InputNode_required, "f")) {
156
+ missingValues.push(currentPath);
157
+ return;
158
+ }
159
+ // if other options are exhausted, revert to default
160
+ return __classPrivateFieldGet(this, _InputNode_default, "f");
161
+ }
162
+ /**
163
+ * Builds a key-value object from input node values and
164
+ * any available linked sources.
165
+ */
166
+ buildKvObject(currentPath, missingValues, sourceValues) {
167
+ return Object.entries(this).reduce((acc, [key, val]) => {
168
+ const nextPath = [...currentPath, key];
169
+ acc[key] = val[symbols_1.getNodeValue](sourceValues, missingValues, nextPath);
170
+ return acc;
171
+ }, {});
172
+ }
173
+ }
174
+ exports.InputNode = InputNode;
175
+ _InputNode_matchSourceHash = function _InputNode_matchSourceHash(sourceValues, usedSources) {
176
+ const sourceHashes = Object.keys(__classPrivateFieldGet(this, _InputNode_sources, "f"));
177
+ const availSourceHashes = Object.keys(sourceValues);
178
+ return sourceHashes.find((hash) => {
179
+ if (hash.includes('|')) {
180
+ // handle combined hash for multi-node source
181
+ const hashes = hash.split('|');
182
+ if (
183
+ // if every source is available
184
+ hashes.every((hash) => availSourceHashes.includes(hash) && !usedSources.includes(hash))) {
185
+ return hash;
186
+ }
187
+ }
188
+ return availSourceHashes.includes(hash) && !usedSources.includes(hash);
189
+ });
190
+ }, _InputNode_accessSource = function _InputNode_accessSource(payload, path, undefinedAllowed) {
191
+ let sourceVal = payload;
192
+ let i = 0;
193
+ while (i < path.length) {
194
+ // recall that `typeof null` returns 'object'
195
+ if (sourceVal == null || typeof sourceVal !== 'object') {
196
+ if (undefinedAllowed)
197
+ return undefined;
198
+ return;
199
+ }
200
+ const accessor = path[i];
201
+ sourceVal = sourceVal[accessor];
202
+ i += 1;
203
+ }
204
+ return sourceVal;
205
+ }, _InputNode_getSingleSourceNodeValue = function _InputNode_getSingleSourceNodeValue(hash, path, sourceValues, undefinedAllowed) {
206
+ const sourceObject = sourceValues[hash][0];
207
+ // get value from a linked source
208
+ return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_accessSource).call(this, sourceObject, path, undefinedAllowed);
209
+ }, _InputNode_getMultiSourceNodeValues = function _InputNode_getMultiSourceNodeValues(sources, sourceValues) {
210
+ const sourceVals = {};
211
+ for (const info of sources.accessInfo) {
212
+ const sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, info.hash, info.path, sourceValues);
213
+ // if one value is unavailable, stop constructing multi-source value
214
+ if (sourceVal === undefined)
215
+ return undefined;
216
+ sourceVals[info.key] = sourceVal;
217
+ }
218
+ return sourceVals;
219
+ }, _InputNode_selectValue = function _InputNode_selectValue() {
220
+ if (__classPrivateFieldGet(this, _InputNode_valuePool, "f").length === 0)
221
+ return;
222
+ switch (__classPrivateFieldGet(this, _InputNode_valuePoolSelect, "f")) {
223
+ case VALUE_POOL_SELECT.UNIFORM:
224
+ default:
225
+ return __classPrivateFieldGet(this, _InputNode_valuePool, "f")[Math.floor(Math.random() * __classPrivateFieldGet(this, _InputNode_valuePool, "f").length)];
226
+ }
227
+ };
228
+ //# sourceMappingURL=inputNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputNode.js","sourceRoot":"","sources":["../../src/core/inputNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6CASyB;AAEzB,+DAA+D;AAC/D,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,+DAAO,CAAA;AACT,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B;AAED,IAAY,SAOX;AAPD,WAA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AAO,uBAAA,IAAI,4BAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,uBAAA,IAAI,4BAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import debug from 'debug';
2
+ export declare const log: debug.Debugger;
3
+ export declare const warn: debug.Debugger;
@@ -0,0 +1,15 @@
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.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
+ if (process.env.ENABLE_CHAINFLOW_LOGS === 'true') {
12
+ exports.log.enabled = true;
13
+ exports.warn.enabled = true;
14
+ }
15
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
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;AAElD,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;IACjD,WAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACnB,YAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACtB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { NodeValue } from './inputNode';
2
+ import { nodeHash, nodePath, nodeValueIdentifier, undefinedAllowed } from './utils/symbols';
3
+ /** Creates a new Source Node with the given hash. */
4
+ export declare const sourceNode: (hash: string) => SourceNode;
5
+ /** Describes a value in a source node e.g. the output of an endpoint call. */
6
+ export interface SourceNode {
7
+ [nodeHash]: string;
8
+ [nodePath]: string[];
9
+ [undefinedAllowed]?: boolean;
10
+ [nodeValueIdentifier]: NodeValue;
11
+ [key: string]: any;
12
+ }
13
+ /** An intermediate object used to contain information on the SourceNode being built. */
14
+ interface RawSourceNode {
15
+ path: string[];
16
+ hash: string;
17
+ undefinedAllowed?: 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): any;
22
+ set(obj: RawSourceNode, prop: any, val: any): any;
23
+ };
24
+ export {};
@@ -0,0 +1,37 @@
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 hash. */
7
+ const sourceNode = (hash) => new Proxy({ path: [], hash }, 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.nodeHash:
16
+ return obj.hash;
17
+ case symbols_1.undefinedAllowed:
18
+ return obj.undefinedAllowed;
19
+ case symbols_1.nodeValueIdentifier:
20
+ return inputNode_1.NodeValue.Source;
21
+ default: {
22
+ const newPath = [...obj.path];
23
+ newPath.push(prop);
24
+ return new Proxy({
25
+ path: newPath,
26
+ hash: obj.hash,
27
+ undefinedAllowed: obj.undefinedAllowed,
28
+ }, exports.SourceNodeHandler);
29
+ }
30
+ }
31
+ },
32
+ set(obj, prop, val) {
33
+ if (prop === symbols_1.undefinedAllowed)
34
+ return (obj.undefinedAllowed = val);
35
+ },
36
+ };
37
+ //# sourceMappingURL=sourceNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceNode.js","sourceRoot":"","sources":["../../src/core/sourceNode.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,6CAA4F;AAE5F,qDAAqD;AAC9C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CACzC,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,yBAAiB,CAA0B,CAAC;AAD/D,QAAA,UAAU,cACqD;AAkB5E,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,IAAI,CAAC;YAClB,KAAK,0BAAgB;gBACnB,OAAO,GAAG,CAAC,gBAAgB,CAAC;YAC9B,KAAK,6BAAmB;gBACtB,OAAO,qBAAS,CAAC,MAAM,CAAC;YAC1B,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,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;iBACvC,EACD,yBAAiB,CACO,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAkB,EAAE,IAAS,EAAE,GAAQ;QACzC,IAAI,IAAI,KAAK,0BAAgB;YAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC;IACrE,CAAC;CACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { CallResult } from './chainflow';
2
+ import { SourceNode } from './sourceNode';
3
+ export type StoreValue<T> = IStore<T> | T;
4
+ export interface IStore<T> {
5
+ [key: string]: StoreValue<T>;
6
+ }
7
+ /** Manages the storing of values for an endpoint. */
8
+ export declare class Store {
9
+ #private;
10
+ /** Definition of values to be stored from responses to this endpoint. */
11
+ def: IStore<SourceNode>;
12
+ /** Assigns values to be put in the chainflow's store. */
13
+ storeValues(resp: unknown): CallResult;
14
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ 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");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _Store_instances, _Store_store, _Store_getStoreValue, _Store_accessRespValue, _Store_putInStore;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Store = void 0;
16
+ const symbols_1 = require("./utils/symbols");
17
+ /** Manages the storing of values for an endpoint. */
18
+ class Store {
19
+ constructor() {
20
+ _Store_instances.add(this);
21
+ /** Definition of values to be stored from responses to this endpoint. */
22
+ this.def = {};
23
+ /** Actual store of values received */
24
+ _Store_store.set(this, {});
25
+ }
26
+ /** Assigns values to be put in the chainflow's store. */
27
+ storeValues(resp) {
28
+ Object.entries(this.def).map(([key, val]) => {
29
+ if (val[symbols_1.nodePath]) {
30
+ // SourceNode
31
+ const { found, value, storePath } = __classPrivateFieldGet(this, _Store_instances, "m", _Store_accessRespValue).call(this, resp, [key], val);
32
+ if (found && storePath)
33
+ __classPrivateFieldGet(this, _Store_instances, "m", _Store_putInStore).call(this, storePath, value);
34
+ }
35
+ else {
36
+ // a nested store value
37
+ __classPrivateFieldGet(this, _Store_instances, "m", _Store_getStoreValue).call(this, resp, [key], val);
38
+ }
39
+ });
40
+ const store = __classPrivateFieldGet(this, _Store_store, "f");
41
+ __classPrivateFieldSet(this, _Store_store, {}, "f"); // resets the store
42
+ return { resp: resp, store };
43
+ }
44
+ }
45
+ exports.Store = Store;
46
+ _Store_store = new WeakMap(), _Store_instances = new WeakSet(), _Store_getStoreValue = function _Store_getStoreValue(resp, currentPath, storeDef) {
47
+ Object.entries(storeDef).map(([key, val]) => {
48
+ if (val[symbols_1.nodePath]) {
49
+ // SourceNode
50
+ const { found, value, storePath } = __classPrivateFieldGet(this, _Store_instances, "m", _Store_accessRespValue).call(this, resp, [...currentPath, key], val);
51
+ if (found && storePath)
52
+ __classPrivateFieldGet(this, _Store_instances, "m", _Store_putInStore).call(this, storePath, value);
53
+ }
54
+ else {
55
+ // a nested store value
56
+ __classPrivateFieldGet(this, _Store_instances, "m", _Store_getStoreValue).call(this, resp, [...currentPath, key], val);
57
+ }
58
+ });
59
+ }, _Store_accessRespValue = function _Store_accessRespValue(resp, storePath, source) {
60
+ const sourcePath = source[symbols_1.nodePath];
61
+ let sourceVal = resp;
62
+ let i = 0;
63
+ while (i < sourcePath.length) {
64
+ // recall that `typeof null` returns 'object'
65
+ if (sourceVal == null || typeof sourceVal !== 'object') {
66
+ if (source[symbols_1.undefinedAllowed])
67
+ return { found: true, value: sourceVal, storePath };
68
+ return { found: false };
69
+ }
70
+ const accessor = sourcePath[i];
71
+ sourceVal = sourceVal[accessor];
72
+ i += 1;
73
+ }
74
+ return { found: true, value: sourceVal, storePath };
75
+ }, _Store_putInStore = function _Store_putInStore(storePath, value) {
76
+ let storeNode = __classPrivateFieldGet(this, _Store_store, "f");
77
+ let accessor;
78
+ for (let i = 0; i < storePath.length; i++) {
79
+ accessor = storePath[i];
80
+ if (i === storePath.length - 1) {
81
+ // reached final node
82
+ storeNode[accessor] = value;
83
+ break;
84
+ }
85
+ if (storeNode[accessor] === undefined) {
86
+ storeNode[accessor] = {};
87
+ }
88
+ storeNode = storeNode[accessor];
89
+ }
90
+ };
91
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,6CAA6D;AAO7D,qDAAqD;AACrD,MAAa,KAAK;IAAlB;;QACE,yEAAyE;QACzE,QAAG,GAAuB,EAAE,CAAC;QAC7B,sCAAsC;QACtC,uBAA0B,EAAE,EAAC;IA4E/B,CAAC;IA1EC,yDAAyD;IACzD,WAAW,CAAC,IAAa;QACvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;YAC1C,IAAK,GAAkB,CAAC,kBAAQ,CAAC,EAAE,CAAC;gBAClC,aAAa;gBACb,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,uBAAA,IAAI,gDAAiB,MAArB,IAAI,EAAkB,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAiB,CAAC,CAAC;gBAC1F,IAAI,KAAK,IAAI,SAAS;oBAAE,uBAAA,IAAI,2CAAY,MAAhB,IAAI,EAAa,SAAS,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACN,uBAAuB;gBACvB,uBAAA,IAAI,8CAAe,MAAnB,IAAI,EAAgB,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,uBAAA,IAAI,oBAA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AE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;YAClF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC;QAChC,SAAS,GAAI,SAAqC,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACtD,CAAC,iDAGW,SAAmB,EAAE,KAAc;IAC7C,IAAI,SAAS,GAAQ,uBAAA,IAAI,oBAAO,CAAC;IACjC,IAAI,QAAQ,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,qBAAqB;YACrB,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;YAC5B,MAAM;QACR,CAAC;QAED,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE,CAAC;YACtC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const SEED_HASH = "seed";
2
+ export declare const STORE_HASH = "store";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STORE_HASH = exports.SEED_HASH = void 0;
4
+ exports.SEED_HASH = 'seed';
5
+ exports.STORE_HASH = 'store';
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,MAAM,CAAC;AACnB,QAAA,UAAU,GAAG,OAAO,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { NodeValue } from '../inputNode';
2
+ import { nodeValueIdentifier } from './symbols';
3
+ /** Defines a set of values to choose from when constructing an input. */
4
+ export declare const pool: (valuePool: any[]) => {
5
+ valuePool: any[];
6
+ [nodeValueIdentifier]: NodeValue;
7
+ };
8
+ /** Provides a generator function to produce a value for an input. */
9
+ export declare const gen: (generator: () => any) => {
10
+ generator: () => any;
11
+ [nodeValueIdentifier]: NodeValue;
12
+ };
13
+ /** Used to mark a param without a default value
14
+ * as required to be taken from another source. */
15
+ export declare const required: () => {
16
+ [nodeValueIdentifier]: NodeValue;
17
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.required = exports.gen = exports.pool = void 0;
4
+ const inputNode_1 = require("../inputNode");
5
+ const symbols_1 = require("./symbols");
6
+ /** Defines a set of values to choose from when constructing an input. */
7
+ const pool = (valuePool) => ({
8
+ valuePool,
9
+ [symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.ValuePool,
10
+ });
11
+ exports.pool = pool;
12
+ /** Provides a generator function to produce a value for an input. */
13
+ const gen = (generator) => ({
14
+ generator,
15
+ [symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.Generator,
16
+ });
17
+ exports.gen = gen;
18
+ /** Used to mark a param without a default value
19
+ * as required to be taken from another source. */
20
+ const required = () => ({
21
+ [symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.Required,
22
+ });
23
+ exports.required = required;
24
+ //# sourceMappingURL=initializers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializers.js","sourceRoot":"","sources":["../../../src/core/utils/initializers.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,uCAAgD;AAEhD,yEAAyE;AAClE,MAAM,IAAI,GAAG,CAAC,SAAgB,EAAE,EAAE,CAAC,CAAC;IACzC,SAAS;IACT,CAAC,6BAAmB,CAAC,EAAE,qBAAS,CAAC,SAAS;CAC3C,CAAC,CAAC;AAHU,QAAA,IAAI,QAGd;AAEH,qEAAqE;AAC9D,MAAM,GAAG,GAAG,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC;IAC5C,SAAS;IACT,CAAC,6BAAmB,CAAC,EAAE,qBAAS,CAAC,SAAS;CAC3C,CAAC,CAAC;AAHU,QAAA,GAAG,OAGb;AAEH;kDACkD;AAC3C,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC,6BAAmB,CAAC,EAAE,qBAAS,CAAC,QAAQ;CAC1C,CAAC,CAAC;AAFU,QAAA,QAAQ,YAElB"}
@@ -0,0 +1,24 @@
1
+ import { InputNode } from '../inputNode';
2
+ import { SourceNode } from '../sourceNode';
3
+ /**
4
+ * Link a Source node to a Input node.
5
+ * @param dest the input node that should take a value from a source.
6
+ * @param source the source node that will provide the value for a input.
7
+ * @param callback an optional function that is called on the source source value.
8
+ */
9
+ export declare const link: (dest: InputNode, source: SourceNode, callback?: ((val: any) => any) | undefined) => void;
10
+ /**
11
+ * Links multiple Source nodes to a Input node via a callback.
12
+ * @param dest the input node that should take a value from the callback.
13
+ * @param sources an array of source nodes that will be passed into the callback.
14
+ * @param callback a function to merge the sources into a single source for the dest.
15
+ */
16
+ export declare const linkMany: (dest: InputNode, sources: {
17
+ [key: string]: SourceNode;
18
+ }, callback: (val: any) => any) => void;
19
+ /**
20
+ * Modifier function that allows a SourceNode to return `undefined` values to an input node.
21
+ * Note that doing so will make it such that this SourceNode will ALWAYS be used to retrieve
22
+ * a value for any linked input node, unless there is another SourceNode with higher priority.
23
+ */
24
+ export declare const allowUndefined: (source: SourceNode) => SourceNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allowUndefined = exports.linkMany = exports.link = void 0;
4
+ const symbols_1 = require("./symbols");
5
+ /**
6
+ * Link a Source node to a Input node.
7
+ * @param dest the input node that should take a value from a source.
8
+ * @param source the source node that will provide the value for a input.
9
+ * @param callback an optional function that is called on the source source value.
10
+ */
11
+ const link = (dest, source, callback) => {
12
+ dest[symbols_1.setSource](source, callback);
13
+ };
14
+ exports.link = link;
15
+ /**
16
+ * Links multiple Source nodes to a Input node via a callback.
17
+ * @param dest the input node that should take a value from the callback.
18
+ * @param sources an array of source nodes that will be passed into the callback.
19
+ * @param callback a function to merge the sources into a single source for the dest.
20
+ */
21
+ const linkMany = (dest, sources, callback) => {
22
+ dest[symbols_1.setSources](sources, callback);
23
+ };
24
+ exports.linkMany = linkMany;
25
+ /**
26
+ * Modifier function that allows a SourceNode to return `undefined` values to an input node.
27
+ * Note that doing so will make it such that this SourceNode will ALWAYS be used to retrieve
28
+ * a value for any linked input node, unless there is another SourceNode with higher priority.
29
+ */
30
+ const allowUndefined = (source) => {
31
+ source[symbols_1.undefinedAllowed] = true;
32
+ return source;
33
+ };
34
+ exports.allowUndefined = allowUndefined;
35
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/core/utils/link.ts"],"names":[],"mappings":";;;AACA,uCAAoE;AAGpE;;;;;GAKG;AACI,MAAM,IAAI,GAAG,CAAC,IAAe,EAAE,MAAkB,EAAE,QAA4B,EAAE,EAAE;IACxF,IAAI,CAAC,mBAAS,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpC,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf;AAEF;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CACtB,IAAe,EACf,OAAsC,EACtC,QAA2B,EAC3B,EAAE;IACF,IAAI,CAAC,oBAAU,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAE,EAAE;IACnD,MAAM,CAAC,0BAAgB,CAAC,GAAG,IAAI,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB"}
@@ -0,0 +1,13 @@
1
+ import { NodeValue } from '../inputNode';
2
+ import { SourceNode } from '../sourceNode';
3
+ import { nodeValueIdentifier } from './symbols';
4
+ export declare const source: (source: SourceNode, callback?: ((val: any) => any) | undefined) => {
5
+ [nodeValueIdentifier]: NodeValue;
6
+ source: SourceNode;
7
+ callback: ((val: any) => any) | undefined;
8
+ };
9
+ export declare const sources: (sources: SourceNode[], callback?: ((val: any) => any) | undefined) => {
10
+ [nodeValueIdentifier]: NodeValue;
11
+ sources: SourceNode[];
12
+ callback: ((val: any) => any) | undefined;
13
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sources = exports.source = void 0;
4
+ const inputNode_1 = require("../inputNode");
5
+ const symbols_1 = require("./symbols");
6
+ const source = (source, callback) => ({
7
+ [symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.SourceWithCallback,
8
+ source,
9
+ callback,
10
+ });
11
+ exports.source = source;
12
+ const sources = (sources, callback) => ({
13
+ [symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.Sources,
14
+ sources,
15
+ callback,
16
+ });
17
+ exports.sources = sources;
18
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/core/utils/source.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAEzC,uCAAgD;AAEzC,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,QAA4B,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC,6BAAmB,CAAC,EAAE,qBAAS,CAAC,kBAAkB;IACnD,MAAM;IACN,QAAQ;CACT,CAAC,CAAC;AAJU,QAAA,MAAM,UAIhB;AAEI,MAAM,OAAO,GAAG,CAAC,OAAqB,EAAE,QAA4B,EAAE,EAAE,CAAC,CAAC;IAC/E,CAAC,6BAAmB,CAAC,EAAE,qBAAS,CAAC,OAAO;IACxC,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;AAJU,QAAA,OAAO,WAIjB"}
@@ -0,0 +1,8 @@
1
+ export declare const setSource: unique symbol;
2
+ export declare const setSources: unique symbol;
3
+ export declare const setValuePool: unique symbol;
4
+ export declare const getNodeValue: unique symbol;
5
+ export declare const nodeHash: unique symbol;
6
+ export declare const nodePath: unique symbol;
7
+ export declare const nodeValueIdentifier: unique symbol;
8
+ export declare const undefinedAllowed: unique symbol;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.undefinedAllowed = exports.nodeValueIdentifier = exports.nodePath = exports.nodeHash = exports.getNodeValue = exports.setValuePool = exports.setSources = exports.setSource = void 0;
4
+ exports.setSource = Symbol('setSource');
5
+ exports.setSources = Symbol('setSources');
6
+ exports.setValuePool = Symbol('setValuePool');
7
+ exports.getNodeValue = Symbol('getNodeValue');
8
+ exports.nodeHash = Symbol('nodeHash');
9
+ exports.nodePath = Symbol('nodePath');
10
+ exports.nodeValueIdentifier = Symbol('nodeValueIdentifier');
11
+ exports.undefinedAllowed = Symbol('undefinedAllowed');
12
+ //# sourceMappingURL=symbols.js.map