chainflow 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -58
- package/dist/core/inputNode.d.ts +8 -15
- package/dist/core/inputNode.js +43 -55
- package/dist/core/inputNode.js.map +1 -1
- package/dist/core/sourceNode.d.ts +2 -2
- package/dist/core/utils/initializers.d.ts +0 -5
- package/dist/core/utils/initializers.js +1 -7
- package/dist/core/utils/initializers.js.map +1 -1
- package/dist/core/utils/link.d.ts +64 -17
- package/dist/core/utils/link.js +30 -21
- package/dist/core/utils/link.js.map +1 -1
- package/dist/core/utils/source.d.ts +1 -0
- package/dist/core/utils/source.js +1 -0
- package/dist/core/utils/source.js.map +1 -1
- package/dist/core/utils/symbols.d.ts +0 -1
- package/dist/core/utils/symbols.js +1 -2
- package/dist/core/utils/symbols.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
<h1 align="center" style="border-bottom: none;">🌊hainflow</h1>
|
|
2
|
-
<h3 align="center">
|
|
2
|
+
<h3 align="center">A library to create dynamic and composable API call workflows.</h3>
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](https://github.com/edwinlzs/chainflow/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/chainflow)
|
|
8
|
+
|
|
9
|
+
[](https://github.com/edwinlzs/chainflow/actions)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
3
12
|
|
|
4
13
|
## Not Released Yet
|
|
5
14
|
|
|
6
15
|
Hi! If you are here, you're a bit early. I'm still setting up some stuff for the first release. Check back in later!
|
|
7
16
|
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
Read the guides over at <https://edwinlzs.github.io/chainflow-docs/> to get started!
|
|
20
|
+
|
|
8
21
|
## Use Cases
|
|
9
22
|
|
|
10
|
-
|
|
23
|
+
Create multiple sets of API call workflows with this library that can be used to:
|
|
24
|
+
|
|
25
|
+
1. Insert demo data via your app's APIs (instead of SQL/db scripts)
|
|
11
26
|
2. Simulate frontend interactions with backend APIs
|
|
12
|
-
3.
|
|
27
|
+
3. UI-agnostic end-to-end testing of backend APIs
|
|
28
|
+
4. Test edge cases on backend endpoints with input variations
|
|
13
29
|
|
|
14
30
|
## Basic Usage
|
|
15
31
|
|
|
@@ -131,19 +147,6 @@ const createUser = origin.post('/user').body({
|
|
|
131
147
|
});
|
|
132
148
|
```
|
|
133
149
|
|
|
134
|
-
### [_EXPERIMENTAL_] - `pool`
|
|
135
|
-
|
|
136
|
-
Provide a pool of values to take from when building requests. By default, Chainflow will randomly choose a value from the pool for each call in a non-exhaustive manner.
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
const createUser = origin.post('/user').body({
|
|
140
|
-
name: pool(['Tom', 'Harry', 'Jane']),
|
|
141
|
-
details: {
|
|
142
|
-
age: 40,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
150
|
### `gen`
|
|
148
151
|
|
|
149
152
|
Provide a callback that generates values for building requests.
|
|
@@ -159,69 +162,110 @@ const createUser = origin.post('/user').body({
|
|
|
159
162
|
});
|
|
160
163
|
```
|
|
161
164
|
|
|
162
|
-
### `
|
|
165
|
+
### `link`
|
|
163
166
|
|
|
164
|
-
|
|
167
|
+
You can use the `link` function to specify a callback to transform the response value before it is passed to the node.
|
|
165
168
|
|
|
166
169
|
```typescript
|
|
167
170
|
const addGreeting = (name: string) => `Hello ${name}`;
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
msg:
|
|
172
|
+
const createMessage = origin.post('message').body({
|
|
173
|
+
msg: link(getUser.resp.body.name, addGreeting);
|
|
171
174
|
});
|
|
172
175
|
```
|
|
173
176
|
|
|
174
|
-
### `
|
|
177
|
+
### `set`
|
|
178
|
+
|
|
179
|
+
The `link` has another function signature.
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
You can use the `set` method on an endpoint to expose its input nodes, then use the 2nd function signature of `link` as shown below: pass in the input node first (`msg`), then the source node second and optionally a callback third.
|
|
177
182
|
|
|
178
183
|
```typescript
|
|
179
|
-
|
|
180
|
-
msg
|
|
184
|
+
createMessage.set(({ body: { msg } }) => {
|
|
185
|
+
link(msg, getUser.resp.body.name);
|
|
186
|
+
link(msg, createUser.resp.body.name);
|
|
181
187
|
});
|
|
182
188
|
```
|
|
183
189
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
Link a response values to a single request node.
|
|
190
|
+
With a callback:
|
|
187
191
|
|
|
188
192
|
```typescript
|
|
189
|
-
|
|
190
|
-
link(msg, getUser.resp.body.name);
|
|
193
|
+
createMessage.set(({ body: { msg } }) => {
|
|
194
|
+
link(msg, getUser.resp.body.name, addGreeting);
|
|
195
|
+
link(msg, createUser.resp.body.name, addGreeting);
|
|
191
196
|
});
|
|
192
197
|
```
|
|
193
198
|
|
|
194
|
-
|
|
199
|
+
### `linkMerge`
|
|
200
|
+
|
|
201
|
+
Link multiple response values to a single request node with an optional callback to merge the values into a single input value. This has 4 function signatures:
|
|
202
|
+
|
|
203
|
+
For the argument containing the source nodes, you can either pass an _array_ of SourceNodes:
|
|
195
204
|
|
|
196
205
|
```typescript
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
// note the callback has an array parameter
|
|
207
|
+
const mergeValues = ([name, favAnimal]: [string, string]) =>
|
|
208
|
+
`${name} likes ${favAnimal}.`;
|
|
209
|
+
|
|
210
|
+
const createMessage = origin.post('message').body({
|
|
211
|
+
msg: linkMerge(
|
|
212
|
+
// array of source nodes
|
|
213
|
+
[getUser.resp.body.name, getFavAnimal.resp.body.favAnimal],
|
|
214
|
+
mergeValues,
|
|
215
|
+
);
|
|
199
216
|
});
|
|
200
217
|
```
|
|
201
218
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
Link multiple response values to a single request node, providing a callback to transform the values into a single output.
|
|
219
|
+
or you can pass an _object_ with SourceNodes as the values:
|
|
205
220
|
|
|
206
221
|
```typescript
|
|
222
|
+
// note the callback has an object parameter
|
|
207
223
|
const mergeValues = ({ userName, favAnimal }: { userName: string; favAnimal: string }) =>
|
|
208
224
|
`${userName} likes ${favAnimal}.`;
|
|
209
225
|
|
|
226
|
+
const createMessage = origin.post('message').body({
|
|
227
|
+
msg: linkMerge(
|
|
228
|
+
// object of source nodes
|
|
229
|
+
{
|
|
230
|
+
userName: getUser.resp.body.name,
|
|
231
|
+
favAnimal: getFavAnimal.resp.body.favAnimal,
|
|
232
|
+
},
|
|
233
|
+
mergeValues,
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
alternatively, you can use the `set` method in addition with the other function signature of `linkMerge` (similar to how `link` above has overloads to work with `set`).
|
|
239
|
+
|
|
240
|
+
with array:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
210
243
|
createNotification.set(({ body: { msg } }) => {
|
|
211
|
-
|
|
212
|
-
msg, // the
|
|
213
|
-
|
|
244
|
+
linkMerge(
|
|
245
|
+
msg, // the input node
|
|
246
|
+
[getUser.resp.body.name, getFavAnimal.resp.body.favAnimal],
|
|
247
|
+
mergeValues,
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
with object:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
createNotification.set(({ body: { msg } }) => {
|
|
256
|
+
linkMerge(
|
|
257
|
+
msg, // the input node
|
|
214
258
|
{
|
|
215
259
|
userName: getUser.resp.body.name,
|
|
216
260
|
favAnimal: getFavAnimal.resp.body.favAnimal,
|
|
217
261
|
},
|
|
218
|
-
// callback that takes the response values as its argument
|
|
219
|
-
// and returns a single output value for the request node
|
|
220
262
|
mergeValues,
|
|
221
263
|
);
|
|
222
264
|
});
|
|
223
265
|
```
|
|
224
266
|
|
|
267
|
+
Note that the merging link created by this method will only be used if ALL the source nodes specified are available i.e. if either one of `getUser.resp.body.name` or `getFavAnimal.resp.body.favAnimal` does not have a value, this link will not be used at all.
|
|
268
|
+
|
|
225
269
|
### Call Options
|
|
226
270
|
|
|
227
271
|
You can declare manual values for an endpoint call in the chainflow itself, should you need to do so, by passing in a Call Options object as a second argument in the `call` method.
|
|
@@ -341,12 +385,15 @@ Instead of direct links between endpoints, you can use a central store to keep v
|
|
|
341
385
|
```typescript
|
|
342
386
|
import { store } from 'chainflow';
|
|
343
387
|
|
|
344
|
-
const createUser = origin
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
388
|
+
const createUser = origin
|
|
389
|
+
.post('/user')
|
|
390
|
+
.body({
|
|
391
|
+
name: 'Tom',
|
|
392
|
+
})
|
|
393
|
+
.store((resp) => ({
|
|
394
|
+
// this endpoint will store `id` from a response to `userId` in the store
|
|
395
|
+
userId: resp.body.id,
|
|
396
|
+
}));
|
|
350
397
|
|
|
351
398
|
const addRole = origin.post('/role').body({
|
|
352
399
|
// this endpoint will take `userId` from the store, if available
|
|
@@ -364,22 +411,21 @@ This is usually useful when you have endpoints that could take a value from any
|
|
|
364
411
|
Say we have 2 endpoints, `login` and `createGroup`. We want to login as a user once, then proceed to proceed 3 groups as that same user without having to login 3 times.
|
|
365
412
|
|
|
366
413
|
```typescript
|
|
367
|
-
const createGroup = origin
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
})
|
|
414
|
+
const createGroup = origin
|
|
415
|
+
.post('/group')
|
|
416
|
+
.headers({
|
|
417
|
+
Authorization: login.resp.body.authToken,
|
|
418
|
+
})
|
|
419
|
+
.body({
|
|
420
|
+
groupName: seed.groupName,
|
|
421
|
+
});
|
|
372
422
|
|
|
373
423
|
// loggedInFlow will contain a response from the `login` endpoint
|
|
374
|
-
const loggedInFlow = chainflow()
|
|
375
|
-
.call(login)
|
|
376
|
-
.run();
|
|
424
|
+
const loggedInFlow = chainflow().call(login).run();
|
|
377
425
|
|
|
378
426
|
// createGroupFlow will take the response that
|
|
379
427
|
// loggedInFlow received and carry on from there
|
|
380
|
-
const createGroupFlow = chainflow()
|
|
381
|
-
.call(createGroup)
|
|
382
|
-
.continuesFrom(loggedInFlow);
|
|
428
|
+
const createGroupFlow = chainflow().call(createGroup).continuesFrom(loggedInFlow);
|
|
383
429
|
|
|
384
430
|
const groupNames = ['RapGPT', 'Averageexpedition', 'Shaky Osmosis'];
|
|
385
431
|
for (const groupName in groupNames) {
|
|
@@ -411,4 +457,5 @@ Run specific test files:
|
|
|
411
457
|
|
|
412
458
|
### Trivia
|
|
413
459
|
|
|
414
|
-
|
|
460
|
+
- You probably noticed that I enjoy using the Builder pattern for its clarity.
|
|
461
|
+
- I'm praying the wave 🌊 emoji remains sufficiently shaped like a "C" to avoid confusion. Please let me know if there is some system where it does not!
|
package/dist/core/inputNode.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { SourceNode } from './sourceNode';
|
|
2
|
-
import { getNodeValue, setSource, setSources
|
|
3
|
-
/** @experimental How a value pool should choose its values. */
|
|
4
|
-
export declare enum VALUE_POOL_SELECT {
|
|
5
|
-
UNIFORM = 0
|
|
6
|
-
}
|
|
2
|
+
import { getNodeValue, setSource, setSources } from './utils/symbols';
|
|
7
3
|
export declare enum NodeValue {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Sources = 5
|
|
4
|
+
Generator = 0,
|
|
5
|
+
Required = 1,
|
|
6
|
+
Source = 2,
|
|
7
|
+
SourceWithCallback = 3,
|
|
8
|
+
MergeSourcesWithCallback = 4
|
|
14
9
|
}
|
|
15
10
|
type SourceValue = any;
|
|
16
11
|
export type SourceValues = {
|
|
@@ -25,11 +20,9 @@ export declare class InputNode {
|
|
|
25
20
|
/** Sets a source node for this input node. */
|
|
26
21
|
[setSource](source: SourceNode, callback?: (val: any) => any): void;
|
|
27
22
|
/** Sets multiple source nodes to be combined into a single value for this input node */
|
|
28
|
-
[setSources](sources: {
|
|
23
|
+
[setSources](sources: SourceNode[] | {
|
|
29
24
|
[key: string]: SourceNode;
|
|
30
|
-
}, callback
|
|
31
|
-
/** Sets the pool of values for this input node. */
|
|
32
|
-
[setValuePool](valuePool: any[]): void;
|
|
25
|
+
}, callback?: (val: any) => any): void;
|
|
33
26
|
/** Retrieve value of a node. */
|
|
34
27
|
[getNodeValue](sourceValues: SourceValues, missingValues: string[][], currentPath: string[]): any;
|
|
35
28
|
/**
|
package/dist/core/inputNode.js
CHANGED
|
@@ -10,23 +10,17 @@ 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,
|
|
13
|
+
var _InputNode_instances, _InputNode_isKvObject, _InputNode_default, _InputNode_required, _InputNode_sources, _InputNode_generator, _InputNode_matchSourceHash, _InputNode_accessSource, _InputNode_getSingleSourceNodeValue, _InputNode_getMultiSourceNodeValues;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.InputNode = exports.NodeValue =
|
|
15
|
+
exports.InputNode = exports.NodeValue = void 0;
|
|
16
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
17
|
var NodeValue;
|
|
23
18
|
(function (NodeValue) {
|
|
24
|
-
NodeValue[NodeValue["
|
|
25
|
-
NodeValue[NodeValue["
|
|
26
|
-
NodeValue[NodeValue["
|
|
27
|
-
NodeValue[NodeValue["
|
|
28
|
-
NodeValue[NodeValue["
|
|
29
|
-
NodeValue[NodeValue["Sources"] = 5] = "Sources";
|
|
19
|
+
NodeValue[NodeValue["Generator"] = 0] = "Generator";
|
|
20
|
+
NodeValue[NodeValue["Required"] = 1] = "Required";
|
|
21
|
+
NodeValue[NodeValue["Source"] = 2] = "Source";
|
|
22
|
+
NodeValue[NodeValue["SourceWithCallback"] = 3] = "SourceWithCallback";
|
|
23
|
+
NodeValue[NodeValue["MergeSourcesWithCallback"] = 4] = "MergeSourcesWithCallback";
|
|
30
24
|
})(NodeValue || (exports.NodeValue = NodeValue = {}));
|
|
31
25
|
/** A data node for constructing an input object. */
|
|
32
26
|
class InputNode {
|
|
@@ -40,10 +34,6 @@ class InputNode {
|
|
|
40
34
|
_InputNode_required.set(this, false);
|
|
41
35
|
/** Stores what source node values can be passed into this node. */
|
|
42
36
|
_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
37
|
/** Generator function to generate values on demand for this node. */
|
|
48
38
|
_InputNode_generator.set(this, void 0);
|
|
49
39
|
if (val == null) {
|
|
@@ -51,9 +41,6 @@ class InputNode {
|
|
|
51
41
|
return;
|
|
52
42
|
}
|
|
53
43
|
switch (val[symbols_1.nodeValueIdentifier]) {
|
|
54
|
-
case NodeValue.ValuePool:
|
|
55
|
-
__classPrivateFieldSet(this, _InputNode_valuePool, val.valuePool, "f");
|
|
56
|
-
return;
|
|
57
44
|
case NodeValue.Generator:
|
|
58
45
|
__classPrivateFieldSet(this, _InputNode_generator, val.generator, "f");
|
|
59
46
|
return;
|
|
@@ -63,14 +50,11 @@ class InputNode {
|
|
|
63
50
|
case NodeValue.Source:
|
|
64
51
|
this[symbols_1.setSource](val);
|
|
65
52
|
return;
|
|
66
|
-
case NodeValue.SourceWithCallback
|
|
53
|
+
case NodeValue.SourceWithCallback /** @todo explore refactoring here */:
|
|
67
54
|
this[symbols_1.setSource](val.source, val.callback);
|
|
68
55
|
return;
|
|
69
|
-
case NodeValue.
|
|
70
|
-
|
|
71
|
-
val.sources.forEach((source) => {
|
|
72
|
-
this[symbols_1.setSource](source, val.callback);
|
|
73
|
-
});
|
|
56
|
+
case NodeValue.MergeSourcesWithCallback:
|
|
57
|
+
this[symbols_1.setSources](val.sources, val.callback);
|
|
74
58
|
return;
|
|
75
59
|
}
|
|
76
60
|
switch (typeof val) {
|
|
@@ -91,7 +75,7 @@ class InputNode {
|
|
|
91
75
|
}
|
|
92
76
|
}
|
|
93
77
|
/** 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(),
|
|
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) {
|
|
95
79
|
__classPrivateFieldGet(this, _InputNode_sources, "f")[source[symbols_1.nodeHash]] = {
|
|
96
80
|
path: source[symbols_1.nodePath],
|
|
97
81
|
undefinedAllowed: source[symbols_1.undefinedAllowed],
|
|
@@ -101,25 +85,38 @@ class InputNode {
|
|
|
101
85
|
/** Sets multiple source nodes to be combined into a single value for this input node */
|
|
102
86
|
[symbols_1.setSources](sources, callback) {
|
|
103
87
|
const hashes = new Set();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
hash
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
88
|
+
let accessInfo;
|
|
89
|
+
let isArray = false;
|
|
90
|
+
if (Array.isArray(sources)) {
|
|
91
|
+
isArray = true;
|
|
92
|
+
accessInfo = sources.map((source) => {
|
|
93
|
+
const hash = source[symbols_1.nodeHash];
|
|
94
|
+
hashes.add(hash);
|
|
95
|
+
return {
|
|
96
|
+
path: source[symbols_1.nodePath],
|
|
97
|
+
undefinedAllowed: source[symbols_1.undefinedAllowed],
|
|
98
|
+
hash,
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
accessInfo = Object.entries(sources).map(([key, source]) => {
|
|
104
|
+
const hash = source[symbols_1.nodeHash];
|
|
105
|
+
hashes.add(hash);
|
|
106
|
+
return {
|
|
107
|
+
path: source[symbols_1.nodePath],
|
|
108
|
+
undefinedAllowed: source[symbols_1.undefinedAllowed],
|
|
109
|
+
hash,
|
|
110
|
+
key,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
114
|
__classPrivateFieldGet(this, _InputNode_sources, "f")[new Array(...hashes).sort().join('|')] = {
|
|
115
115
|
accessInfo,
|
|
116
|
+
isArray,
|
|
116
117
|
callback,
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
/** Sets the pool of values for this input node. */
|
|
120
|
-
[symbols_1.setValuePool](valuePool) {
|
|
121
|
-
__classPrivateFieldSet(this, _InputNode_valuePool, valuePool, "f");
|
|
122
|
-
}
|
|
123
120
|
/** Retrieve value of a node. */
|
|
124
121
|
[symbols_1.getNodeValue](sourceValues, missingValues, currentPath) {
|
|
125
122
|
const usedSources = []; // stores sourceValues that are already tried
|
|
@@ -144,10 +141,6 @@ class InputNode {
|
|
|
144
141
|
if (__classPrivateFieldGet(this, _InputNode_generator, "f")) {
|
|
145
142
|
return __classPrivateFieldGet(this, _InputNode_generator, "f").call(this);
|
|
146
143
|
}
|
|
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
144
|
if (__classPrivateFieldGet(this, _InputNode_isKvObject, "f")) {
|
|
152
145
|
return this.buildKvObject(currentPath, missingValues, sourceValues);
|
|
153
146
|
}
|
|
@@ -207,22 +200,17 @@ _InputNode_matchSourceHash = function _InputNode_matchSourceHash(sourceValues, u
|
|
|
207
200
|
// get value from a linked source
|
|
208
201
|
return __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_accessSource).call(this, sourceObject, path, undefinedAllowed);
|
|
209
202
|
}, _InputNode_getMultiSourceNodeValues = function _InputNode_getMultiSourceNodeValues(sources, sourceValues) {
|
|
210
|
-
|
|
203
|
+
let sourceVals;
|
|
204
|
+
sources.isArray ? (sourceVals = []) : (sourceVals = {});
|
|
211
205
|
for (const info of sources.accessInfo) {
|
|
212
206
|
const sourceVal = __classPrivateFieldGet(this, _InputNode_instances, "m", _InputNode_getSingleSourceNodeValue).call(this, info.hash, info.path, sourceValues);
|
|
213
207
|
// if one value is unavailable, stop constructing multi-source value
|
|
214
208
|
if (sourceVal === undefined)
|
|
215
209
|
return undefined;
|
|
216
|
-
|
|
210
|
+
sources.isArray
|
|
211
|
+
? sourceVals.push(sourceVal)
|
|
212
|
+
: (sourceVals[info.key] = sourceVal);
|
|
217
213
|
}
|
|
218
214
|
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
215
|
};
|
|
228
216
|
//# sourceMappingURL=inputNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputNode.js","sourceRoot":"","sources":["../../src/core/inputNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"inputNode.js","sourceRoot":"","sources":["../../src/core/inputNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6CAQyB;AAEzB,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,mDAAS,CAAA;IACT,iDAAQ,CAAA;IACR,6CAAM,CAAA;IACN,qEAAkB,CAAA;IAClB,iFAAwB,CAAA;AAC1B,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;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,SAAS,CAAC,SAAS;gBACtB,uBAAA,IAAI,wBAAc,GAAG,CAAC,SAAS,MAAA,CAAC;gBAChC,OAAO;YACT,KAAK,SAAS,CAAC,QAAQ;gBACrB,uBAAA,IAAI,uBAAa,IAAI,MAAA,CAAC;gBACtB,OAAO;YACT,KAAK,SAAS,CAAC,MAAM;gBACnB,IAAI,CAAC,mBAAS,CAAC,CAAC,GAAG,CAAC,CAAC;gBACrB,OAAO;YACT,KAAK,SAAS,CAAC,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MAA9B,IAAI,EAA2B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACrF,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"}
|
|
@@ -8,7 +8,7 @@ export interface SourceNode {
|
|
|
8
8
|
[nodePath]: string[];
|
|
9
9
|
[undefinedAllowed]?: boolean;
|
|
10
10
|
[nodeValueIdentifier]: NodeValue;
|
|
11
|
-
[key: string]:
|
|
11
|
+
[key: string]: SourceNode;
|
|
12
12
|
}
|
|
13
13
|
/** An intermediate object used to contain information on the SourceNode being built. */
|
|
14
14
|
interface RawSourceNode {
|
|
@@ -18,7 +18,7 @@ interface RawSourceNode {
|
|
|
18
18
|
}
|
|
19
19
|
/** Generates proxies recursively to handle nested property access of a source signature. */
|
|
20
20
|
export declare const SourceNodeHandler: {
|
|
21
|
-
get(obj: RawSourceNode, prop: any):
|
|
21
|
+
get(obj: RawSourceNode, prop: any): unknown;
|
|
22
22
|
set(obj: RawSourceNode, prop: any, val: any): any;
|
|
23
23
|
};
|
|
24
24
|
export {};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { NodeValue } from '../inputNode';
|
|
2
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
3
|
/** Provides a generator function to produce a value for an input. */
|
|
9
4
|
export declare const gen: (generator: () => any) => {
|
|
10
5
|
generator: () => any;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.required = exports.gen =
|
|
3
|
+
exports.required = exports.gen = void 0;
|
|
4
4
|
const inputNode_1 = require("../inputNode");
|
|
5
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
6
|
/** Provides a generator function to produce a value for an input. */
|
|
13
7
|
const gen = (generator) => ({
|
|
14
8
|
generator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializers.js","sourceRoot":"","sources":["../../../src/core/utils/initializers.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,uCAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"initializers.js","sourceRoot":"","sources":["../../../src/core/utils/initializers.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,uCAAgD;AAEhD,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"}
|
|
@@ -1,24 +1,71 @@
|
|
|
1
|
-
import { InputNode } from '../inputNode';
|
|
1
|
+
import { InputNode, NodeValue } from '../inputNode';
|
|
2
|
+
import { nodeValueIdentifier } from './symbols';
|
|
2
3
|
import { SourceNode } from '../sourceNode';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
interface SourceInfo {
|
|
5
|
+
[nodeValueIdentifier]: NodeValue;
|
|
6
|
+
source: SourceNode;
|
|
7
|
+
callback: ((val: any) => any) | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Overload signatures for `linkMerge` function. */
|
|
10
|
+
interface Link {
|
|
11
|
+
/**
|
|
12
|
+
* Link a Source node to an Input node.
|
|
13
|
+
* @param source the source node that will provide the value for an input.
|
|
14
|
+
* @param callback an optional function that is called on the source source value.
|
|
15
|
+
*/
|
|
16
|
+
(source: SourceNode, callback?: (val: any) => any): SourceInfo;
|
|
17
|
+
/**
|
|
18
|
+
* Link a Source node to an Input node.
|
|
19
|
+
* @param dest the input node that should take a value from a source.
|
|
20
|
+
* @param source the source node that will provide the value for an input.
|
|
21
|
+
* @param callback an optional function that is called on the source source value.
|
|
22
|
+
*/
|
|
23
|
+
(dest: InputNode, source: SourceNode, callback?: (val: any) => any): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const link: Link;
|
|
26
|
+
interface MergeSourcesInfo {
|
|
27
|
+
[nodeValueIdentifier]: NodeValue;
|
|
28
|
+
sources: SourceNode[];
|
|
29
|
+
callback: ((val: any) => any) | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Overload signatures for `linkMerge` function. */
|
|
32
|
+
interface LinkMerge {
|
|
33
|
+
/**
|
|
34
|
+
* Links multiple Source nodes to an Input node via a callback.
|
|
35
|
+
* @param sources an array of source nodes to merge values from.
|
|
36
|
+
* @param callback a function to merge the sources into a single source for the dest.
|
|
37
|
+
*/
|
|
38
|
+
(sources: SourceNode[], callback?: (val: any) => any): MergeSourcesInfo;
|
|
39
|
+
/**
|
|
40
|
+
* Links multiple Source nodes to an Input node via a callback.
|
|
41
|
+
* @param sources an object with source nodes to merge values from.
|
|
42
|
+
* @param callback a function to merge the sources into a single source for the dest.
|
|
43
|
+
*/
|
|
44
|
+
(sources: {
|
|
45
|
+
[key: string]: SourceNode;
|
|
46
|
+
}, callback?: (val: any) => any): void;
|
|
47
|
+
/**
|
|
48
|
+
* Links multiple Source nodes to an Input node via a callback.
|
|
49
|
+
* @param dest the input node that should take a value from the callback.
|
|
50
|
+
* @param sources an array of source nodes to merge values from.
|
|
51
|
+
* @param callback a function to merge the sources into a single source for the dest.
|
|
52
|
+
*/
|
|
53
|
+
(dest: InputNode, sources: SourceNode[], callback?: (val: any) => any): void;
|
|
54
|
+
/**
|
|
55
|
+
* Links multiple Source nodes to an Input node via a callback.
|
|
56
|
+
* @param dest the input node that should take a value from the callback.
|
|
57
|
+
* @param sources an object with source nodes to merge values from.
|
|
58
|
+
* @param callback a function to merge the sources into a single source for the dest.
|
|
59
|
+
*/
|
|
60
|
+
(dest: InputNode, sources: {
|
|
61
|
+
[key: string]: SourceNode;
|
|
62
|
+
}, callback?: (val: any) => any): void;
|
|
63
|
+
}
|
|
64
|
+
export declare const linkMerge: LinkMerge;
|
|
19
65
|
/**
|
|
20
66
|
* Modifier function that allows a SourceNode to return `undefined` values to an input node.
|
|
21
67
|
* Note that doing so will make it such that this SourceNode will ALWAYS be used to retrieve
|
|
22
68
|
* a value for any linked input node, unless there is another SourceNode with higher priority.
|
|
23
69
|
*/
|
|
24
70
|
export declare const allowUndefined: (source: SourceNode) => SourceNode;
|
|
71
|
+
export {};
|
package/dist/core/utils/link.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allowUndefined = exports.
|
|
3
|
+
exports.allowUndefined = exports.linkMerge = exports.link = void 0;
|
|
4
|
+
const inputNode_1 = require("../inputNode");
|
|
4
5
|
const symbols_1 = require("./symbols");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
exports.link = ((...args) => {
|
|
7
|
+
if (['function', 'undefined'].includes(typeof args[1])) {
|
|
8
|
+
const [source, callback] = args;
|
|
9
|
+
return {
|
|
10
|
+
[symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.SourceWithCallback,
|
|
11
|
+
source,
|
|
12
|
+
callback,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const [dest, source, callback] = args;
|
|
17
|
+
dest[symbols_1.setSource](source, callback);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.linkMerge = ((...args) => {
|
|
21
|
+
if (['function', 'undefined'].includes(typeof args[1])) {
|
|
22
|
+
const [sources, callback] = args;
|
|
23
|
+
return {
|
|
24
|
+
[symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.MergeSourcesWithCallback,
|
|
25
|
+
sources,
|
|
26
|
+
callback,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const [dest, source, callback] = args;
|
|
31
|
+
dest[symbols_1.setSources](source, callback);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
25
34
|
/**
|
|
26
35
|
* Modifier function that allows a SourceNode to return `undefined` values to an input node.
|
|
27
36
|
* Note that doing so will make it such that this SourceNode will ALWAYS be used to retrieve
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/core/utils/link.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"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CAAC,GAAG,IAAI,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB"}
|
|
@@ -6,6 +6,7 @@ export declare const source: (source: SourceNode, callback?: ((val: any) => any)
|
|
|
6
6
|
source: SourceNode;
|
|
7
7
|
callback: ((val: any) => any) | undefined;
|
|
8
8
|
};
|
|
9
|
+
/** @experimental - evaluating if this is important enough to retain */
|
|
9
10
|
export declare const sources: (sources: SourceNode[], callback?: ((val: any) => any) | undefined) => {
|
|
10
11
|
[nodeValueIdentifier]: NodeValue;
|
|
11
12
|
sources: SourceNode[];
|
|
@@ -9,6 +9,7 @@ const source = (source, callback) => ({
|
|
|
9
9
|
callback,
|
|
10
10
|
});
|
|
11
11
|
exports.source = source;
|
|
12
|
+
/** @experimental - evaluating if this is important enough to retain */
|
|
12
13
|
const sources = (sources, callback) => ({
|
|
13
14
|
[symbols_1.nodeValueIdentifier]: inputNode_1.NodeValue.Sources,
|
|
14
15
|
sources,
|
|
@@ -1 +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;
|
|
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;AAEH,uEAAuE;AAChE,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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const setSource: unique symbol;
|
|
2
2
|
export declare const setSources: unique symbol;
|
|
3
|
-
export declare const setValuePool: unique symbol;
|
|
4
3
|
export declare const getNodeValue: unique symbol;
|
|
5
4
|
export declare const nodeHash: unique symbol;
|
|
6
5
|
export declare const nodePath: unique symbol;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.undefinedAllowed = exports.nodeValueIdentifier = exports.nodePath = exports.nodeHash = exports.getNodeValue = exports.
|
|
3
|
+
exports.undefinedAllowed = exports.nodeValueIdentifier = exports.nodePath = exports.nodeHash = exports.getNodeValue = exports.setSources = exports.setSource = void 0;
|
|
4
4
|
exports.setSource = Symbol('setSource');
|
|
5
5
|
exports.setSources = Symbol('setSources');
|
|
6
|
-
exports.setValuePool = Symbol('setValuePool');
|
|
7
6
|
exports.getNodeValue = Symbol('getNodeValue');
|
|
8
7
|
exports.nodeHash = Symbol('nodeHash');
|
|
9
8
|
exports.nodePath = Symbol('nodePath');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../../src/core/utils/symbols.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAChC,QAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAClC,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACtC,QAAA,
|
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../../src/core/utils/symbols.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAChC,QAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAClC,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACtC,QAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAC9B,QAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAC9B,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpD,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./core/chainflow"), exports);
|
|
18
18
|
__exportStar(require("./core/utils/initializers"), exports);
|
|
19
|
-
__exportStar(require("./core/utils/source"), exports);
|
|
20
19
|
__exportStar(require("./core/inputNode"), exports);
|
|
21
20
|
__exportStar(require("./core/utils/link"), exports);
|
|
22
21
|
__exportStar(require("./http/endpoint"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,4DAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,4DAA0C;AAC1C,mDAAiC;AACjC,oDAAkC;AAClC,kDAAgC;AAChC,oDAAkC;AAClC,sDAAoC"}
|