chainflow 0.1.5 → 0.1.7
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/LICENSE +20 -20
- package/README.md +542 -487
- package/dist/core/chainflow.d.ts +15 -13
- package/dist/core/chainflow.js +14 -11
- package/dist/core/chainflow.js.map +1 -1
- package/dist/core/inputNode.d.ts +2 -2
- package/dist/core/inputNode.js +37 -38
- package/dist/core/inputNode.js.map +1 -1
- package/dist/core/logger.d.ts +1 -0
- package/dist/core/logger.js +6 -2
- package/dist/core/logger.js.map +1 -1
- package/dist/core/sourceNode.d.ts +5 -5
- package/dist/core/sourceNode.js +5 -5
- package/dist/core/sourceNode.js.map +1 -1
- package/dist/core/utils/constants.d.ts +2 -2
- package/dist/core/utils/constants.js +3 -3
- package/dist/core/utils/constants.js.map +1 -1
- package/dist/core/utils/symbols.d.ts +1 -1
- package/dist/core/utils/symbols.js +2 -2
- package/dist/http/endpoint.d.ts +13 -5
- package/dist/http/endpoint.js +8 -4
- package/dist/http/endpoint.js.map +1 -1
- package/dist/http/errors.d.ts +1 -1
- package/dist/http/errors.js +2 -2
- package/dist/http/errors.js.map +1 -1
- package/dist/http/logger.d.ts +1 -0
- package/dist/http/logger.js +8 -2
- package/dist/http/logger.js.map +1 -1
- package/dist/http/utils/id.d.ts +5 -0
- package/dist/http/utils/id.js +9 -0
- package/dist/http/utils/id.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/dist/core/utils/source.d.ts +0 -14
- package/dist/core/utils/source.js +0 -19
- package/dist/core/utils/source.js.map +0 -1
- package/dist/http/utils/hash.d.ts +0 -4
- package/dist/http/utils/hash.js +0 -8
- package/dist/http/utils/hash.js.map +0 -1
package/dist/core/chainflow.d.ts
CHANGED
|
@@ -2,20 +2,20 @@ import { SourceValues } from './inputNode';
|
|
|
2
2
|
import { IStore } from './store';
|
|
3
3
|
export interface CallResult {
|
|
4
4
|
resp: any;
|
|
5
|
-
store
|
|
5
|
+
store?: IStore<unknown>;
|
|
6
6
|
}
|
|
7
7
|
/** Defines an endpoint that a chainflow can call upon. */
|
|
8
|
-
export interface IEndpoint {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export interface IEndpoint<T> {
|
|
9
|
+
/** A value that uniquely identifies this endpoint. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** A string with info describing the endpoint. */
|
|
12
|
+
details: string;
|
|
13
|
+
call: (sources: SourceValues, opts?: T) => Promise<CallResult>;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
query?: Record<string, string>;
|
|
17
|
-
pathParams?: Record<string, string>;
|
|
18
|
-
body?: Record<string, any>;
|
|
15
|
+
type Responses = IResponse[];
|
|
16
|
+
interface IResponse {
|
|
17
|
+
details: string;
|
|
18
|
+
val: unknown;
|
|
19
19
|
}
|
|
20
20
|
/** Special object used to link an InputNode to a chainflow seed. */
|
|
21
21
|
export declare const seed: import("./sourceNode").SourceNode;
|
|
@@ -23,12 +23,14 @@ export declare const seed: import("./sourceNode").SourceNode;
|
|
|
23
23
|
export declare const store: import("./sourceNode").SourceNode;
|
|
24
24
|
export declare class Chainflow {
|
|
25
25
|
#private;
|
|
26
|
+
/** Stores accumulated responses. */
|
|
27
|
+
responses: Responses;
|
|
26
28
|
/** Run the set up chain */
|
|
27
29
|
run(): Promise<this>;
|
|
28
30
|
/** Adds a seed to this chainflow. */
|
|
29
31
|
seed(seed: Record<string, any>): this;
|
|
30
32
|
/** Adds an endpoint call to the callchain. */
|
|
31
|
-
call(endpoint: IEndpoint
|
|
33
|
+
call<T>(endpoint: IEndpoint<T>, opts?: T): this;
|
|
32
34
|
/** Resets the chainflow's state by clearing its accumulated sources. */
|
|
33
35
|
reset(): void;
|
|
34
36
|
/** Creates a clone of this chainflow's callqueue and initial sources
|
|
@@ -39,6 +41,6 @@ export declare class Chainflow {
|
|
|
39
41
|
/** Causes this chainflow to continue from the state of
|
|
40
42
|
* sources values of another chainflow. */
|
|
41
43
|
continuesFrom(cf: Chainflow): this;
|
|
42
|
-
/** @todo Returns the accumulated responses of this chainflow. */ responses(): void;
|
|
43
44
|
}
|
|
44
45
|
export declare const chainflow: () => Chainflow;
|
|
46
|
+
export {};
|
package/dist/core/chainflow.js
CHANGED
|
@@ -31,9 +31,9 @@ const logger_1 = require("./logger");
|
|
|
31
31
|
const constants_1 = require("./utils/constants");
|
|
32
32
|
const deepmerge = (0, deepmerge_1.default)();
|
|
33
33
|
/** Special object used to link an InputNode to a chainflow seed. */
|
|
34
|
-
exports.seed = (0, sourceNode_1.sourceNode)(constants_1.
|
|
34
|
+
exports.seed = (0, sourceNode_1.sourceNode)(constants_1.SEED_ID);
|
|
35
35
|
/** Special object that acts as a central "gateway" between input and source values. */
|
|
36
|
-
exports.store = (0, sourceNode_1.sourceNode)(constants_1.
|
|
36
|
+
exports.store = (0, sourceNode_1.sourceNode)(constants_1.STORE_ID);
|
|
37
37
|
class Chainflow {
|
|
38
38
|
constructor() {
|
|
39
39
|
/** Stores sources such as the seed or values accumulated from
|
|
@@ -42,6 +42,8 @@ class Chainflow {
|
|
|
42
42
|
/** Stores the sources that this chainflow was initialized with. */
|
|
43
43
|
_Chainflow_initSources.set(this, {});
|
|
44
44
|
_Chainflow_callqueue.set(this, []);
|
|
45
|
+
/** Stores accumulated responses. */
|
|
46
|
+
this.responses = [];
|
|
45
47
|
}
|
|
46
48
|
/** Run the set up chain */
|
|
47
49
|
run() {
|
|
@@ -49,19 +51,20 @@ class Chainflow {
|
|
|
49
51
|
(0, logger_1.log)(`Running chainflow...`);
|
|
50
52
|
this.reset();
|
|
51
53
|
__classPrivateFieldSet(this, _Chainflow_sources, __classPrivateFieldGet(this, _Chainflow_initSources, "f"), "f");
|
|
52
|
-
__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.
|
|
54
|
+
__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID] = [{}];
|
|
53
55
|
for (const { endpoint, opts } of __classPrivateFieldGet(this, _Chainflow_callqueue, "f")) {
|
|
54
56
|
// call endpoint
|
|
55
|
-
const
|
|
56
|
-
(0, logger_1.log)(`Calling endpoint with
|
|
57
|
+
const id = endpoint.id;
|
|
58
|
+
(0, logger_1.log)(`Calling endpoint with id "${id}"`);
|
|
57
59
|
try {
|
|
58
60
|
const { resp, store } = yield endpoint.call(__classPrivateFieldGet(this, _Chainflow_sources, "f"), opts);
|
|
59
|
-
if (Object.keys(store).length > 0)
|
|
60
|
-
__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.
|
|
61
|
-
__classPrivateFieldGet(this, _Chainflow_sources, "f")[
|
|
61
|
+
if (store && Object.keys(store).length > 0)
|
|
62
|
+
__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0] = deepmerge(__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0], store);
|
|
63
|
+
__classPrivateFieldGet(this, _Chainflow_sources, "f")[id] = [resp];
|
|
64
|
+
this.responses.push({ details: endpoint.details, val: resp });
|
|
62
65
|
}
|
|
63
66
|
catch (e) {
|
|
64
|
-
(0, logger_1.warn)(`Chainflow stopped at endpoint with
|
|
67
|
+
(0, logger_1.warn)(`Chainflow stopped at endpoint with id "${id}" and error: ${e}`);
|
|
65
68
|
throw e;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -71,7 +74,7 @@ class Chainflow {
|
|
|
71
74
|
}
|
|
72
75
|
/** Adds a seed to this chainflow. */
|
|
73
76
|
seed(seed) {
|
|
74
|
-
__classPrivateFieldGet(this, _Chainflow_initSources, "f")[constants_1.
|
|
77
|
+
__classPrivateFieldGet(this, _Chainflow_initSources, "f")[constants_1.SEED_ID] = [seed];
|
|
75
78
|
return this;
|
|
76
79
|
}
|
|
77
80
|
/** Adds an endpoint call to the callchain. */
|
|
@@ -82,6 +85,7 @@ class Chainflow {
|
|
|
82
85
|
/** Resets the chainflow's state by clearing its accumulated sources. */
|
|
83
86
|
reset() {
|
|
84
87
|
__classPrivateFieldSet(this, _Chainflow_sources, {}, "f");
|
|
88
|
+
this.responses = [];
|
|
85
89
|
}
|
|
86
90
|
/** Creates a clone of this chainflow's callqueue and initial sources
|
|
87
91
|
* which can be extended and run independently. */
|
|
@@ -102,7 +106,6 @@ class Chainflow {
|
|
|
102
106
|
__classPrivateFieldSet(this, _Chainflow_initSources, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Chainflow_initSources, "f")), __classPrivateFieldGet(cf, _Chainflow_sources, "f")), "f");
|
|
103
107
|
return this;
|
|
104
108
|
}
|
|
105
|
-
/** @todo Returns the accumulated responses of this chainflow. */ responses() { }
|
|
106
109
|
}
|
|
107
110
|
exports.Chainflow = Chainflow;
|
|
108
111
|
_Chainflow_sources = new WeakMap(), _Chainflow_initSources = new WeakMap(), _Chainflow_callqueue = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainflow.js","sourceRoot":"","sources":["../../src/core/chainflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA0C;AAC1C,mEAAgD;AAEhD,qCAAqC;AACrC,
|
|
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;AA+BnC,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,mEA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EC;;AAEM,MAAM,SAAS,GAAG,GAAc,EAAE;IACvC,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
|
package/dist/core/inputNode.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare enum NODE_VALUE {
|
|
|
9
9
|
}
|
|
10
10
|
type SourceValue = any;
|
|
11
11
|
export type SourceValues = {
|
|
12
|
-
[
|
|
12
|
+
[id: string]: SourceValue[];
|
|
13
13
|
};
|
|
14
14
|
/** A data node for constructing an input object. */
|
|
15
15
|
export declare class InputNode {
|
|
@@ -19,7 +19,7 @@ export declare class InputNode {
|
|
|
19
19
|
constructor(val: any);
|
|
20
20
|
/** Sets a source node for this input node. */
|
|
21
21
|
[setSource](source: SourceNode, callback?: (val: any) => any): void;
|
|
22
|
-
/** Sets multiple source nodes to be
|
|
22
|
+
/** Sets multiple source nodes to be merged into a single value for this input node */
|
|
23
23
|
[setSources](sources: SourceNode[] | {
|
|
24
24
|
[key: string]: SourceNode;
|
|
25
25
|
}, callback?: (val: any) => any): void;
|
package/dist/core/inputNode.js
CHANGED
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
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
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _InputNode_instances, _InputNode_isKvObject, _InputNode_default, _InputNode_required, _InputNode_sources, _InputNode_generator,
|
|
13
|
+
var _InputNode_instances, _InputNode_isKvObject, _InputNode_default, _InputNode_required, _InputNode_sources, _InputNode_generator, _InputNode_matchSourceId, _InputNode_accessSource, _InputNode_getSingleSourceNodeValue, _InputNode_getMergeSourceNodeValues;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InputNode = exports.NODE_VALUE = void 0;
|
|
16
16
|
const symbols_1 = require("./utils/symbols");
|
|
@@ -76,42 +76,43 @@ class InputNode {
|
|
|
76
76
|
}
|
|
77
77
|
/** Sets a source node for this input node. */
|
|
78
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.
|
|
79
|
+
__classPrivateFieldGet(this, _InputNode_sources, "f")[source[symbols_1.sourceId]] = {
|
|
80
80
|
path: source[symbols_1.nodePath],
|
|
81
81
|
allowUndefined: source[symbols_1.allowUndefined],
|
|
82
82
|
callback,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
/** Sets multiple source nodes to be
|
|
85
|
+
/** Sets multiple source nodes to be merged into a single value for this input node */
|
|
86
86
|
[symbols_1.setSources](sources, callback) {
|
|
87
|
-
const
|
|
87
|
+
const ids = new Set();
|
|
88
88
|
let accessInfo;
|
|
89
89
|
let isArray = false;
|
|
90
90
|
if (Array.isArray(sources)) {
|
|
91
91
|
isArray = true;
|
|
92
92
|
accessInfo = sources.map((source) => {
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const id = source[symbols_1.sourceId];
|
|
94
|
+
ids.add(id);
|
|
95
95
|
return {
|
|
96
96
|
path: source[symbols_1.nodePath],
|
|
97
97
|
allowUndefined: source[symbols_1.allowUndefined],
|
|
98
|
-
|
|
98
|
+
id,
|
|
99
99
|
};
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
accessInfo = Object.entries(sources).map(([key, source]) => {
|
|
104
|
-
const
|
|
105
|
-
|
|
104
|
+
const id = source[symbols_1.sourceId];
|
|
105
|
+
ids.add(id);
|
|
106
106
|
return {
|
|
107
107
|
path: source[symbols_1.nodePath],
|
|
108
108
|
allowUndefined: source[symbols_1.allowUndefined],
|
|
109
|
-
|
|
109
|
+
id,
|
|
110
110
|
key,
|
|
111
111
|
};
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
/** @todo improve this */
|
|
115
|
+
__classPrivateFieldGet(this, _InputNode_sources, "f")[new Array(...ids).sort().join('|')] = {
|
|
115
116
|
accessInfo,
|
|
116
117
|
isArray,
|
|
117
118
|
callback,
|
|
@@ -121,21 +122,21 @@ class InputNode {
|
|
|
121
122
|
[symbols_1.getNodeValue](sourceValues, missingValues, currentPath) {
|
|
122
123
|
const usedSources = []; // stores sourceValues that are already tried
|
|
123
124
|
// attempt to get value from any source nodes available
|
|
124
|
-
let
|
|
125
|
-
while (
|
|
126
|
-
const source = __classPrivateFieldGet(this, _InputNode_sources, "f")[
|
|
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];
|
|
127
128
|
let sourceVal;
|
|
128
129
|
if ('accessInfo' in source) {
|
|
129
|
-
sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m",
|
|
130
|
+
sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getMergeSourceNodeValues).call(this, source, sourceValues);
|
|
130
131
|
}
|
|
131
132
|
else {
|
|
132
|
-
sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this,
|
|
133
|
+
sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, sourceEndpointId, source.path, sourceValues);
|
|
133
134
|
}
|
|
134
135
|
if (sourceVal !== undefined || ('allowUndefined' in source && source.allowUndefined)) {
|
|
135
136
|
return source.callback ? source.callback(sourceVal) : sourceVal;
|
|
136
137
|
}
|
|
137
|
-
usedSources.push(...
|
|
138
|
-
|
|
138
|
+
usedSources.push(...sourceEndpointId.split('|'));
|
|
139
|
+
sourceEndpointId = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_matchSourceId).call(this, sourceValues, usedSources);
|
|
139
140
|
}
|
|
140
141
|
// attempt to get value from generator function
|
|
141
142
|
if (__classPrivateFieldGet(this, _InputNode_generator, "f")) {
|
|
@@ -165,22 +166,22 @@ class InputNode {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
exports.InputNode = InputNode;
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
-
if (
|
|
173
|
-
// handle combined
|
|
174
|
-
const
|
|
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('|');
|
|
175
176
|
if (
|
|
176
177
|
// if every source is available
|
|
177
|
-
|
|
178
|
-
return
|
|
178
|
+
ids.every((id) => availSourceIds.includes(id) && !usedSources.includes(id))) {
|
|
179
|
+
return id;
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
|
-
return
|
|
182
|
+
return availSourceIds.includes(id) && !usedSources.includes(id);
|
|
182
183
|
});
|
|
183
|
-
}, _InputNode_accessSource = function _InputNode_accessSource(payload, path
|
|
184
|
+
}, _InputNode_accessSource = function _InputNode_accessSource(payload, path) {
|
|
184
185
|
let sourceVal = payload;
|
|
185
186
|
let i = 0;
|
|
186
187
|
while (i < path.length) {
|
|
@@ -188,25 +189,23 @@ _InputNode_matchSourceHash = function _InputNode_matchSourceHash(sourceValues, u
|
|
|
188
189
|
// source value, hence current sourceVal should be an object
|
|
189
190
|
// However, `typeof null` returns 'object'
|
|
190
191
|
// hence the 2nd condition checks against `null`
|
|
191
|
-
if (typeof sourceVal !== 'object' || sourceVal == null)
|
|
192
|
-
if (allowUndefined)
|
|
193
|
-
return undefined;
|
|
192
|
+
if (typeof sourceVal !== 'object' || sourceVal == null)
|
|
194
193
|
return;
|
|
195
|
-
}
|
|
196
194
|
const accessor = path[i];
|
|
197
195
|
sourceVal = sourceVal[accessor];
|
|
198
196
|
i += 1;
|
|
199
197
|
}
|
|
200
198
|
return sourceVal;
|
|
201
|
-
}, _InputNode_getSingleSourceNodeValue = function _InputNode_getSingleSourceNodeValue(
|
|
202
|
-
const
|
|
199
|
+
}, _InputNode_getSingleSourceNodeValue = function _InputNode_getSingleSourceNodeValue(id, path, sourceValues) {
|
|
200
|
+
const sourceValuesForId = sourceValues[id];
|
|
201
|
+
const sourceObject = sourceValuesForId[sourceValuesForId.length - 1];
|
|
203
202
|
// get value from a linked source
|
|
204
|
-
return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_accessSource).call(this, sourceObject, path
|
|
205
|
-
},
|
|
203
|
+
return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_accessSource).call(this, sourceObject, path);
|
|
204
|
+
}, _InputNode_getMergeSourceNodeValues = function _InputNode_getMergeSourceNodeValues(sources, sourceValues) {
|
|
206
205
|
let sourceVals;
|
|
207
206
|
sources.isArray ? (sourceVals = []) : (sourceVals = {});
|
|
208
207
|
for (const info of sources.accessInfo) {
|
|
209
|
-
const sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, info.
|
|
208
|
+
const sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, info.id, info.path, sourceValues);
|
|
210
209
|
// if one value is unavailable, stop constructing multi-source value
|
|
211
210
|
if (sourceVal === undefined)
|
|
212
211
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputN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AAO,SAAS,CAAC;AACnB,CAAC,qFAGyB,EAAU,EAAE,IAAc,EAAE,YAA0B;IAC9E,MAAM,iBAAiB,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAErE,iCAAiC;IACjC,OAAO,uBAAA,IAAI,qDAAc,MAAlB,IAAI,EAAe,YAAY,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC,qFAIyB,OAAiB,EAAE,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"}
|
package/dist/core/logger.d.ts
CHANGED
package/dist/core/logger.js
CHANGED
|
@@ -3,13 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.warn = exports.log = void 0;
|
|
6
|
+
exports.enableLogs = exports.warn = exports.log = void 0;
|
|
7
7
|
/* istanbul ignore file */
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
9
|
exports.log = (0, debug_1.default)('chainflow:core');
|
|
10
10
|
exports.warn = (0, debug_1.default)('chainflow:core:error');
|
|
11
|
-
|
|
11
|
+
const enableLogs = () => {
|
|
12
12
|
exports.log.enabled = true;
|
|
13
13
|
exports.warn.enabled = true;
|
|
14
|
+
};
|
|
15
|
+
exports.enableLogs = enableLogs;
|
|
16
|
+
if (process.env.ENABLE_CHAINFLOW_LOGS === 'true') {
|
|
17
|
+
(0, exports.enableLogs)();
|
|
14
18
|
}
|
|
15
19
|
//# sourceMappingURL=logger.js.map
|
package/dist/core/logger.js.map
CHANGED
|
@@ -1 +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;
|
|
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,10 +1,10 @@
|
|
|
1
1
|
import { NODE_VALUE } from './inputNode';
|
|
2
|
-
import {
|
|
3
|
-
/** Creates a new Source Node with the given
|
|
4
|
-
export declare const sourceNode: (
|
|
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
5
|
/** Describes a value in a source node e.g. the output of an endpoint call. */
|
|
6
6
|
export interface SourceNode {
|
|
7
|
-
[
|
|
7
|
+
[sourceId]: string;
|
|
8
8
|
[nodePath]: string[];
|
|
9
9
|
[allowUndefined]?: boolean;
|
|
10
10
|
[nodeValueIdentifier]: NODE_VALUE;
|
|
@@ -13,7 +13,7 @@ export interface SourceNode {
|
|
|
13
13
|
/** An intermediate object used to contain information on the SourceNode being built. */
|
|
14
14
|
interface RawSourceNode {
|
|
15
15
|
path: string[];
|
|
16
|
-
|
|
16
|
+
id: string;
|
|
17
17
|
allowUndefined?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/** Generates proxies recursively to handle nested property access of a source signature. */
|
package/dist/core/sourceNode.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SourceNodeHandler = exports.sourceNode = void 0;
|
|
4
4
|
const inputNode_1 = require("./inputNode");
|
|
5
5
|
const symbols_1 = require("./utils/symbols");
|
|
6
|
-
/** Creates a new Source Node with the given
|
|
7
|
-
const sourceNode = (
|
|
6
|
+
/** Creates a new Source Node with the given id. */
|
|
7
|
+
const sourceNode = (id) => new Proxy({ path: [], id }, exports.SourceNodeHandler);
|
|
8
8
|
exports.sourceNode = sourceNode;
|
|
9
9
|
/** Generates proxies recursively to handle nested property access of a source signature. */
|
|
10
10
|
exports.SourceNodeHandler = {
|
|
@@ -12,8 +12,8 @@ exports.SourceNodeHandler = {
|
|
|
12
12
|
switch (prop) {
|
|
13
13
|
case symbols_1.nodePath:
|
|
14
14
|
return obj.path;
|
|
15
|
-
case symbols_1.
|
|
16
|
-
return obj.
|
|
15
|
+
case symbols_1.sourceId:
|
|
16
|
+
return obj.id;
|
|
17
17
|
case symbols_1.allowUndefined:
|
|
18
18
|
return obj.allowUndefined;
|
|
19
19
|
case symbols_1.nodeValueIdentifier:
|
|
@@ -23,7 +23,7 @@ exports.SourceNodeHandler = {
|
|
|
23
23
|
newPath.push(prop);
|
|
24
24
|
return new Proxy({
|
|
25
25
|
path: newPath,
|
|
26
|
-
|
|
26
|
+
id: obj.id,
|
|
27
27
|
allowUndefined: obj.allowUndefined,
|
|
28
28
|
}, exports.SourceNodeHandler);
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceNode.js","sourceRoot":"","sources":["../../src/core/sourceNode.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,6CAA0F;AAE1F,
|
|
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,2 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const SEED_ID = "seed";
|
|
2
|
+
export declare const STORE_ID = "store";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
3
|
+
exports.STORE_ID = exports.SEED_ID = void 0;
|
|
4
|
+
exports.SEED_ID = 'seed';
|
|
5
|
+
exports.STORE_ID = 'store';
|
|
6
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,MAAM,CAAC;AACjB,QAAA,QAAQ,GAAG,OAAO,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const setSource: unique symbol;
|
|
2
2
|
export declare const setSources: unique symbol;
|
|
3
3
|
export declare const getNodeValue: unique symbol;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const sourceId: unique symbol;
|
|
5
5
|
export declare const nodePath: unique symbol;
|
|
6
6
|
export declare const nodeValueIdentifier: unique symbol;
|
|
7
7
|
export declare const allowUndefined: unique symbol;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allowUndefined = exports.nodeValueIdentifier = exports.nodePath = exports.
|
|
3
|
+
exports.allowUndefined = exports.nodeValueIdentifier = exports.nodePath = exports.sourceId = exports.getNodeValue = exports.setSources = exports.setSource = void 0;
|
|
4
4
|
exports.setSource = Symbol('setSource');
|
|
5
5
|
exports.setSources = Symbol('setSources');
|
|
6
6
|
exports.getNodeValue = Symbol('getNodeValue');
|
|
7
|
-
exports.
|
|
7
|
+
exports.sourceId = Symbol('sourceId');
|
|
8
8
|
exports.nodePath = Symbol('nodePath');
|
|
9
9
|
exports.nodeValueIdentifier = Symbol('nodeValueIdentifier');
|
|
10
10
|
exports.allowUndefined = Symbol('allowUndefined');
|
package/dist/http/endpoint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputNode, SourceValues, NODE_VALUE } from '../core/inputNode';
|
|
2
2
|
import { Dispatcher } from 'undici';
|
|
3
|
-
import {
|
|
3
|
+
import { CallResult, IEndpoint } from '../core/chainflow';
|
|
4
4
|
import { SourceNode } from '../core/sourceNode';
|
|
5
5
|
import { nodeValueIdentifier } from '../core/utils/symbols';
|
|
6
6
|
import { IStore } from '../core/store';
|
|
@@ -34,20 +34,28 @@ export declare enum RESP_PARSER {
|
|
|
34
34
|
JSON = "json",
|
|
35
35
|
TEXT = "text"
|
|
36
36
|
}
|
|
37
|
+
/** Options for configuring an endpoint call. */
|
|
38
|
+
export interface HTTPCallOpts {
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
query?: Record<string, string>;
|
|
41
|
+
pathParams?: Record<string, string>;
|
|
42
|
+
body?: Record<string, any>;
|
|
43
|
+
}
|
|
37
44
|
/**
|
|
38
45
|
* Manages request and response nodes,
|
|
39
46
|
* as well as calls to that endpoint
|
|
40
47
|
*/
|
|
41
|
-
export declare class Endpoint implements IEndpoint {
|
|
48
|
+
export declare class Endpoint implements IEndpoint<HTTPCallOpts> {
|
|
42
49
|
#private;
|
|
43
|
-
|
|
44
|
-
hash: string;
|
|
50
|
+
id: string;
|
|
45
51
|
constructor({ addr, method, path }: {
|
|
46
52
|
addr: string;
|
|
47
53
|
method: string;
|
|
48
54
|
path: string;
|
|
49
55
|
});
|
|
50
56
|
get method(): SUPPORTED_METHOD;
|
|
57
|
+
/** @todo Update this when there is a better implementation of id. */
|
|
58
|
+
get details(): string;
|
|
51
59
|
/** Configures this endpoint. */
|
|
52
60
|
config(config: EndpointConfig): this;
|
|
53
61
|
/** Sets the request body. */
|
|
@@ -64,7 +72,7 @@ export declare class Endpoint implements IEndpoint {
|
|
|
64
72
|
/** Declare values to store from responses to this endpoint. */
|
|
65
73
|
store(callback: (resp: SourceNode) => IStore<SourceNode>): this;
|
|
66
74
|
/** Calls this endpoint with responses provided from earlier requests in the chain. */
|
|
67
|
-
call(responses: SourceValues, opts?:
|
|
75
|
+
call(responses: SourceValues, opts?: HTTPCallOpts): Promise<CallResult>;
|
|
68
76
|
/** Passes the request input nodes of this endpoint to a callback. */
|
|
69
77
|
set(setter: (nodes: HttpInputNodes) => void): this;
|
|
70
78
|
}
|
package/dist/http/endpoint.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
var _Endpoint_instances, _Endpoint_addr, _Endpoint_path, _Endpoint_method, _Endpoint_req, _Endpoint_resp, _Endpoint_config, _Endpoint_store, _Endpoint_extractPathParams, _Endpoint_insertPathParams, _Endpoint_insertQueryParams, _Endpoint_validateResp, _Endpoint_findMissingValues, _Endpoint_parseResponse;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.Endpoint = exports.RESP_PARSER = void 0;
|
|
28
|
-
const
|
|
28
|
+
const id_1 = require("./utils/id");
|
|
29
29
|
const inputNode_1 = require("../core/inputNode");
|
|
30
30
|
const reqBuilder_1 = require("./reqBuilder");
|
|
31
31
|
const client_1 = __importDefault(require("./utils/client"));
|
|
@@ -68,14 +68,18 @@ class Endpoint {
|
|
|
68
68
|
__classPrivateFieldSet(this, _Endpoint_addr, addr, "f");
|
|
69
69
|
__classPrivateFieldSet(this, _Endpoint_path, path, "f");
|
|
70
70
|
__classPrivateFieldSet(this, _Endpoint_method, method, "f");
|
|
71
|
-
this.
|
|
71
|
+
this.id = (0, id_1.getEndpointId)({ method: __classPrivateFieldGet(this, _Endpoint_method, "f"), route: __classPrivateFieldGet(this, _Endpoint_path, "f") });
|
|
72
72
|
__classPrivateFieldSet(this, _Endpoint_req, new reqBuilder_1.ReqBuilder(), "f");
|
|
73
73
|
__classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_extractPathParams).call(this);
|
|
74
|
-
__classPrivateFieldSet(this, _Endpoint_resp, (0, sourceNode_1.sourceNode)(this.
|
|
74
|
+
__classPrivateFieldSet(this, _Endpoint_resp, (0, sourceNode_1.sourceNode)(this.id), "f");
|
|
75
75
|
}
|
|
76
76
|
get method() {
|
|
77
77
|
return __classPrivateFieldGet(this, _Endpoint_method, "f");
|
|
78
78
|
}
|
|
79
|
+
/** @todo Update this when there is a better implementation of id. */
|
|
80
|
+
get details() {
|
|
81
|
+
return this.id;
|
|
82
|
+
}
|
|
79
83
|
/** Configures this endpoint. */
|
|
80
84
|
config(config) {
|
|
81
85
|
__classPrivateFieldSet(this, _Endpoint_config, config, "f");
|
|
@@ -142,7 +146,7 @@ class Endpoint {
|
|
|
142
146
|
baseHeaders && (headers = deepmerge(baseHeaders, headers !== null && headers !== void 0 ? headers : {}));
|
|
143
147
|
const finalMissingValues = __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_findMissingValues).call(this, missingValues, opts);
|
|
144
148
|
if (finalMissingValues.length > 0)
|
|
145
|
-
throw new errors_1.RequiredValuesNotFoundError(this.
|
|
149
|
+
throw new errors_1.RequiredValuesNotFoundError(this.id, finalMissingValues);
|
|
146
150
|
if (opts === null || opts === void 0 ? void 0 : opts.body)
|
|
147
151
|
body = deepmerge(body, opts.body);
|
|
148
152
|
if (opts === null || opts === void 0 ? void 0 : opts.pathParams)
|