chainflow 0.1.8 → 0.1.9

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1 align="center" style="border-bottom: none;">🌊hainflow</h1>
2
- <h3 align="center">An Open Source library to create dynamic and composable API call workflows.</h3>
2
+ <h3 align="center">An Open Source library to create dynamic and composable API call workflows in TypeScript.</h3>
3
3
  <div align="center">
4
4
 
5
5
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/edwinlzs/chainflow/blob/main/LICENSE)
@@ -11,50 +11,62 @@
11
11
  [![codecov](https://img.shields.io/codecov/c/gh/edwinlzs/chainflow?token=O55JNRTCM5&style=flat-square&color=23a133)](https://codecov.io/gh/edwinlzs/chainflow)
12
12
  </div>
13
13
 
14
- ## Documentation
14
+ ## 📖 Documentation
15
15
 
16
- Read the guides over at [Chainflow Docs](https://edwinlzs.github.io/chainflow-docs/) to get started!
16
+ ### Read the guides over at [Chainflow Docs](https://edwinlzs.github.io/chainflow-docs/) to get started!
17
17
 
18
- ## When might Chainflow be useful?
18
+ ## ⚠️ (Important!) Note
19
+
20
+ Chainflow is my first and somewhat experimental open-source project which I started to assist my own dev work. It's similar to [Postman Flows](https://learning.postman.com/docs/postman-flows/gs/flows-overview/), but done in code so us engineers have more control to weave logic in between API endpoint calls (+ the ease of writing simple scripts with Chainflow to be run in your CLI or as pipeline jobs etc.).
21
+
22
+ I am still finding and ironing out pain points in using the library and releases should be considered unstable while I improve the library's usability. It is far from perfect in its current state, but I will continue to improve upon it if I or others find potential in its use. Therefore, your feedback and ideas are very important to me. I welcome thoughts on just about anything - useful dev tools to manage this project, QoL features to support easier coding patterns when using this library or even thoughts on the future direction of this project.
23
+
24
+ Drop them as a [Github issue](https://github.com/edwinlzs/chainflow/issues) or email me at <edwinlzscode@gmail.com>!
25
+
26
+ ## 💭 When might Chainflow be useful?
19
27
 
20
28
  1. **_Setting up demo data_**
21
29
 
22
- Say you have an application that you're developing new features for and you'd like to demonstrate those features. You may need your app to be in a certain context and hence your database in a specific state - perhaps a user has to be logged in with certain permissions, and to have already created a "group" in the app and added other users to that group. You may use raw SQL or other DB scripts to put your DB into that state by inserting users, roles, etc.. However, those scripts could miss out on important side effects relevant to the business context of your app that tend to be built into the services exposed by your backend server. Hence, you can use Chainflow to help compose API call workflows to setup the data in your app by calling the revelant service endpoints you have built e.g. `POST /user`, `POST /role`. You can then minimize your use of database scripts to mainly data that is not configurable with existing endpoints.
30
+ Say you have an app that you're developing new features for and you'd like to demo those features. You need your app to be in a certain context and your database in a specific state - perhaps that context requires that a user has logged in with certain permissions, has created a "group" in the app and has added other users to that group. To create that context, you could manually click through your app to log in as a user and set everything up, but that could be tedious. Alternatively, you may use raw SQL or other DB scripts to directly manipulate the DB and insert users, roles, etc. However, those scripts could miss out on important side effects relevant to the business context of your app - side effects that tend to be triggered by services exposed by your backend server.
31
+
32
+ Instead, you can setup the context in your app by calling the relevant service endpoints you have built (`POST /user`, `POST /role`, etc.) and triggering their business logic to make your data setup adhere closely to the way your app truly behaves - as if a user was _really_ logging in and doing everything. Chainflow helps you do this by providing tools to compose API call workflows. You can then avoid manual setups and minimize your use of database scripts to just data that is not configurable with existing endpoints!
23
33
 
24
34
  2. **_Speeding up development_**
25
35
 
26
- Similar to setting up demo data, often while coding new features you may want to test out how they behave in your app, and again you may want your app to be in a specific state locally for that. You can write API call workflow scripts built with Chainflow to help move your app into those states quickly.
36
+ Similar to setting up demo data, while coding new features you may often want to test out how they behave in your app, and again you may want your app to be in a specific state locally for that. You can write API call workflow scripts built with Chainflow to help move your app into those states quickly.
27
37
 
28
38
  3. **_Testing your endpoints_**
29
39
 
30
- An API call workflow could behave as if it were a frontend client calling the backend. In that way, you can create UI-agnostic end-to-end testing of backend endpoints by using API call workflows to simulate how a frontend would interact with the backend.
40
+ An API call workflow could behave as if it were a frontend client calling the backend. In that way, you can run UI-agnostic end-to-end testing of backend endpoints by using API call workflows to simulate how a frontend would interact with the backend.
31
41
 
32
42
  ## Basic Usage
33
43
 
44
+ _Note: Chainflow may not be compatible with Node versions past end-of-life (v16.x and below)._
45
+
34
46
  ```console
35
47
  npm install --save-dev chainflow
36
48
  ```
37
49
 
38
- Use `originServer` to define your endpoints and their request/response signatures with the `endpoint` method.
50
+ `origin` creates a template on which you define your API endpoints by calling the endpoint's HTTP method verb (e.g. `post`, `patch`) as methods.
39
51
 
40
52
  ```typescript
41
- import { originServer } from chainflow;
53
+ import { origin } from chainflow;
42
54
 
43
- const origin = originServer('127.0.0.1:5000');
55
+ const backend = origin('127.0.0.1:5000');
44
56
 
45
- const createUser = origin.post('/user').body({
57
+ const createUser = backend.post('/user').body({
46
58
  name: 'Tom',
47
59
  details: {
48
60
  age: 40,
49
61
  },
50
62
  });
51
63
 
52
- const createRole = origin.post('/role').body({
64
+ const createRole = backend.post('/role').body({
53
65
  type: 'Engineer',
54
66
  userId: createUser.resp.body.id,
55
67
  });
56
68
 
57
- const getUser = origin.get('/user').query({
69
+ const getUser = backend.get('/user').query({
58
70
  roleType: createRole.resp.body.type,
59
71
  });
60
72
  ```
@@ -75,7 +87,7 @@ flow.run();
75
87
  ---
76
88
 
77
89
  \
78
- The above setup will result in the following API calls:
90
+ The above setup will result in the following endpoint calls:
79
91
 
80
92
  1. `POST` Request to `/user` with body:
81
93
 
@@ -108,7 +120,7 @@ The above setup will result in the following API calls:
108
120
  Define query params with the `query` method on an endpoint.
109
121
 
110
122
  ```typescript
111
- const getUsersInGroup = origin.get('/user').query({ groupId: 'some-id' });
123
+ const getUsersInGroup = backend.get('/user').query({ groupId: 'some-id' });
112
124
  ```
113
125
 
114
126
  ### Path params
@@ -116,13 +128,13 @@ const getUsersInGroup = origin.get('/user').query({ groupId: 'some-id' });
116
128
  Define path params by wrapping a param name with `{}` in the endpoint path.
117
129
 
118
130
  ```typescript
119
- const getGroupsWithUser = origin.get('/groups/{userId}');
131
+ const getGroupsWithUser = backend.get('/groups/{userId}');
120
132
  ```
121
133
 
122
134
  You can specify values for your path params by calling `pathParams`. Note that path params which do not actually exist in the path will be discarded.
123
135
 
124
136
  ```typescript
125
- const getGroupsWithUser = origin.get('/groups/{userId}').pathParams({
137
+ const getGroupsWithUser = backend.get('/groups/{userId}').pathParams({
126
138
  userId: 'user123',
127
139
  });
128
140
  ```
@@ -132,15 +144,15 @@ const getGroupsWithUser = origin.get('/groups/{userId}').pathParams({
132
144
  Specify headers with `headers` method on endpoints.
133
145
 
134
146
  ```typescript
135
- const getInfo = origin.get('/info').headers({ token: 'some-token' });
147
+ const getInfo = backend.get('/info').headers({ token: 'some-token' });
136
148
  ```
137
149
 
138
- You can also use `headers` on an `OriginServer` to have all endpoints made for that origin bear those headers.
150
+ You can also use `headers` on an `Origin` to have all endpoints made for that origin bear those headers.
139
151
 
140
152
  ```typescript
141
- const origin = originServer('127.0.0.1:3001').headers({ token: 'some-token' });
153
+ const backend = origin('127.0.0.1:3001').headers({ token: 'some-token' });
142
154
 
143
- const getInfo = origin.get('/info'); // getInfo endpoint will have the headers defined above
155
+ const getInfo = backend.get('/info'); // getInfo endpoint will have the headers defined above
144
156
  ```
145
157
 
146
158
  ### Default headers
@@ -173,7 +185,7 @@ However, you can also use the following features to more flexibly define the val
173
185
  Marks a value as required but without a default. The chainflow will expect this value to be sourced from another node. If no such source is available, the endpoint call will throw an error.
174
186
 
175
187
  ```typescript
176
- const createUser = origin.post('/user').body({
188
+ const createUser = backend.post('/user').body({
177
189
  name: required(),
178
190
  });
179
191
  ```
@@ -185,7 +197,7 @@ Provide a callback that generates values for building requests.
185
197
  ```typescript
186
198
  const randAge = () => Math.floor(Math.random() * 100);
187
199
 
188
- const createUser = origin.post('/user').body({
200
+ const createUser = backend.post('/user').body({
189
201
  name: 'Tom',
190
202
  details: {
191
203
  age: gen(randAge),
@@ -200,7 +212,7 @@ You can use the `link` function to specify a callback to transform the response
200
212
  ```typescript
201
213
  const addGreeting = (name: string) => `Hello ${name}`;
202
214
 
203
- const createMessage = origin.post('message').body({
215
+ const createMessage = backend.post('message').body({
204
216
  msg: link(getUser.resp.body.name, addGreeting);
205
217
  });
206
218
  ```
@@ -238,7 +250,7 @@ For the argument containing the source nodes, you can either pass an _array_ of
238
250
  const mergeValues = ([name, favAnimal]: [string, string]) =>
239
251
  `${name} likes ${favAnimal}.`;
240
252
 
241
- const createMessage = origin.post('message').body({
253
+ const createMessage = backend.post('message').body({
242
254
  msg: linkMerge(
243
255
  // array of source nodes
244
256
  [getUser.resp.body.name, getFavAnimal.resp.body.favAnimal],
@@ -260,7 +272,7 @@ const mergeValues = ({
260
272
  }) => `${userName} likes ${favAnimal}.`;
261
273
 
262
274
 
263
- const createMessage = origin.post('message').body({
275
+ const createMessage = backend.post('message').body({
264
276
  msg: linkMerge(
265
277
  // object of source nodes
266
278
  {
@@ -310,7 +322,7 @@ You can declare manual values for an endpoint call in the chainflow itself, shou
310
322
  `body`, `pathParams`, `query` and `headers` can be set this way.
311
323
 
312
324
  ```typescript
313
- const createUser = origin.post('/user').body({
325
+ const createUser = backend.post('/user').body({
314
326
  name: 'Tom',
315
327
  });
316
328
 
@@ -326,7 +338,7 @@ You can specify request nodes to take values from the chainflow 'seed' by import
326
338
  ```typescript
327
339
  import { chainflow, link seed, } from 'chainflow';
328
340
 
329
- const createUser = origin.post('/user').body({
341
+ const createUser = backend.post('/user').body({
330
342
  name: required(),
331
343
  });
332
344
 
@@ -385,12 +397,12 @@ flow1.extend(flow2).run(); // calls endpoint 1, 2 and 3
385
397
  `respParser`
386
398
  By default, a chainflow parses response bodies as JSON objects UNLESS the status code is `204` or the `content-type` header does not contain `application/json` (to avoid errors when parsing an empty body), upon which they will instead parse it as text.
387
399
 
388
- To set a specific parsing format, you can call `.config` to change that configuration on an `endpoint` (or on an `OriginServer`, to apply it to all endpoints created from it) like so:
400
+ To set a specific parsing format, you can call `.config` to change that configuration on an `endpoint` (or on an `Origin`, to apply it to all endpoints created from it) like so:
389
401
 
390
402
  ```typescript
391
403
  import { RESP_PARSER } from 'chainflow';
392
404
 
393
- const getUser = origin.get('/user').config({
405
+ const getUser = backend.get('/user').config({
394
406
  respParser: RESP_PARSER.TEXT,
395
407
  });
396
408
  ```
@@ -398,18 +410,18 @@ const getUser = origin.get('/user').config({
398
410
  or with camelcase in JavaScript:
399
411
 
400
412
  ```javascript
401
- const getUser = origin.get('/user').config({
413
+ const getUser = backend.get('/user').config({
402
414
  respParser: 'text',
403
415
  });
404
416
  ```
405
417
 
406
- There are 4 supported ways to parse response bodies (as provided by the underlying HTTP client, `undici`): `arrayBuffer`, `blob`, `json` and `text`.
418
+ There are 4 supported ways to parse response bodies (provided by the underlying HTTP client `undici`): `arrayBuffer`, `blob`, `json` and `text`.
407
419
 
408
420
  `respValidator`
409
421
  Another configuration option is how to validate the response to an endpoint. By default, Chainflow rejects responses that have HTTP status code 400 and above and throws an error. You can pass in a custom `respValidator` to change when a response is rejected.
410
422
 
411
423
  ```typescript
412
- const getUser = origin.get('/user').config({
424
+ const getUser = backend.get('/user').config({
413
425
  respValidator: (resp) => {
414
426
  if (resp.statusCode !== 201) return { valid: false, msg: 'Failed to retrieve users.' };
415
427
  if (!Object.keys(resp.body as Record<string, unknown>).includes('id'))
@@ -435,7 +447,7 @@ Instead of direct links between endpoints, you can use a central store to keep v
435
447
  ```typescript
436
448
  import { store } from 'chainflow';
437
449
 
438
- const createUser = origin
450
+ const createUser = backend
439
451
  .post('/user')
440
452
  .body({
441
453
  name: 'Tom',
@@ -445,7 +457,7 @@ const createUser = origin
445
457
  userId: resp.body.id,
446
458
  }));
447
459
 
448
- const addRole = origin.post('/role').body({
460
+ const addRole = backend.post('/role').body({
449
461
  // this endpoint will take `userId` from the store, if available
450
462
  userId: store.userId,
451
463
  role: 'Engineer',
@@ -461,7 +473,7 @@ This is usually useful when you have endpoints that could take a value from any
461
473
  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.
462
474
 
463
475
  ```typescript
464
- const createGroup = origin
476
+ const createGroup = backend
465
477
  .post('/group')
466
478
  .headers({
467
479
  Authorization: login.resp.body.authToken,
@@ -487,23 +499,30 @@ We run a chainflow that calls `login` first to get a response from the login end
487
499
 
488
500
  Using the `continuesFrom` method, `createGroupFlow` will copy the state of source values (i.e. responses) from `loggedInFlow`. This means `createGroupFlow` will now have the logged in user's `authToken` received from calling `login`, and will use it when calling `createGroup` thrice for each group name in the `groupNames` array.
489
501
 
490
- ### `responses`
502
+ ### `events`
491
503
 
492
- After running a chainflow, you can retrieve the responses received from endpoint calls via the `responses` property on that chainflow.
504
+ After running a chainflow, you can retrieve the request and response event data from endpoint calls executed during that run via the `events` property on that chainflow.
493
505
 
494
506
  ```typescript
495
507
  const flow = chainflow().run(createUser).run(getRoles);
496
508
 
497
- const responses = flow.responses;
509
+ const events = flow.events;
498
510
  ```
499
511
 
500
- The responses will look something like:
512
+ The events will look something like:
501
513
 
502
514
  ```typescript
503
515
  [
504
516
  {
505
- details: '[POST] /user' // identifies the endpoint called
506
- val: { // the response to createUser
517
+ details: '[POST] /user', // identifies the endpoint called
518
+ req: {
519
+ method: 'POST',
520
+ url: ...,
521
+ body: ...,
522
+ headers: ...,
523
+ respParser: ..., // the format used to parse the response body
524
+ },
525
+ resp: {
507
526
  statusCode: 200,
508
527
  body: ...,
509
528
  headers: ...,
@@ -511,8 +530,9 @@ The responses will look something like:
511
530
  }
512
531
  },
513
532
  {
514
- details: '[GET] /roles'
515
- val: ... // the response to getRoles
533
+ details: '[GET] /roles',
534
+ req: ...,
535
+ resp: ...
516
536
  }
517
537
  ]
518
538
  ```
@@ -521,7 +541,13 @@ The responses in the array follow the order in which the respective endpoints ar
521
541
 
522
542
  ### `logging`
523
543
 
524
- Enable logs from Chainflow by setting `ENABLE_CHAINFLOW_LOGS=true` in your environment variables, or by simply importing and calling the `enableLogs` function.
544
+ Log requests/responses in your console by setting `ENABLE_CHAINFLOW_LOGS=true` in your environment variables, or by simply importing and calling the `enableLogs` function.
545
+
546
+ ```typescript
547
+ import { enableLogs } from 'chainflow';
548
+
549
+ enableLogs();
550
+ ```
525
551
 
526
552
  ### Misc Behaviors
527
553
 
@@ -530,17 +556,21 @@ Enable logs from Chainflow by setting `ENABLE_CHAINFLOW_LOGS=true` in your envir
530
556
  For example:
531
557
 
532
558
  ```typescript
533
- chainflow().call(getUser).call(addRole).call(getUser).call(createGroup);
559
+ chainflow()
560
+ .call(getUser) // 1st call
561
+ .call(addRole)
562
+ .call(getUser) // 2nd call
563
+ .call(createGroup);
534
564
  ```
535
565
 
536
- If an input node on `createGroup` requires a value from a response to `getUser`, then `createGroup` will take that value from the last call to `getUser` (i.e. from the response to the 2nd call to `getUser` that happens _after_ the call to `addRole`).
566
+ If an input node on `createGroup` requires a value from a response to `getUser`, then `createGroup` will take that value from the latest call to `getUser` (i.e. from the response to the 2nd call to `getUser` _after_ the call to `addRole`).
537
567
 
538
568
  ## Future Updates
539
569
 
540
570
  Below features are currently not yet supported but are planned in future releases.
541
571
 
542
572
  1. More flexibility to log and return responses
543
- 2. Conditional calls - execute an endpoint call only if some condition is met.
573
+ 2. Conditional calls - execute an endpoint call only if some condition is met
544
574
  3. (Exploratory) API performance measurement
545
575
  4. (Exploratory) Possibly some sort of UI/diagram generation
546
576
 
@@ -559,6 +589,10 @@ Below features are currently not yet supported but are planned in future release
559
589
  - Should further explore appropriate degree of detail for logging
560
590
  - Truncation of requests/responses with extremely large payloads
561
591
 
592
+ #### _Proxy performance_
593
+
594
+ - Creating proxies recursively when defining `SourceNode` paths could hit performance - not rigorously tested yet, so not 100% sure of how significant it is
595
+
562
596
  ### Trivia
563
597
 
564
598
  - You probably noticed that I enjoy using the Builder pattern for its clarity.
@@ -1,21 +1,22 @@
1
1
  import { SourceValues } from './inputNode';
2
2
  import { IStore } from './store';
3
- export interface CallResult {
4
- resp: any;
3
+ export interface CallResult<Req, Resp> {
4
+ req: Req;
5
+ resp: Resp;
5
6
  store?: IStore<unknown>;
6
7
  }
7
8
  /** Defines an endpoint that a chainflow can call upon. */
8
- export interface IEndpoint<T> {
9
- /** A value that uniquely identifies this endpoint. */
9
+ export interface IEndpoint<CallOpts, Req, Resp> {
10
+ /** Uniquely identifies this endpoint. */
10
11
  id: string;
11
- /** A string with info describing the endpoint. */
12
+ /** Describes the endpoint. */
12
13
  details: string;
13
- call: (sources: SourceValues, opts?: T) => Promise<CallResult>;
14
+ call: (sources: SourceValues, opts?: CallOpts) => Promise<CallResult<Req, Resp>>;
14
15
  }
15
- type Responses = IResponse[];
16
- interface IResponse {
16
+ interface CallEvent {
17
17
  details: string;
18
- val: unknown;
18
+ req: unknown;
19
+ resp: unknown;
19
20
  }
20
21
  /** Special object used to link an InputNode to a chainflow seed. */
21
22
  export declare const seed: import("./sourceNode").SourceNode;
@@ -23,14 +24,14 @@ export declare const seed: import("./sourceNode").SourceNode;
23
24
  export declare const store: import("./sourceNode").SourceNode;
24
25
  export declare class Chainflow {
25
26
  #private;
26
- /** Stores accumulated responses. */
27
- responses: Responses;
27
+ /** Stores accumulated endpoint call events. */
28
+ events: CallEvent[];
28
29
  /** Run the set up chain */
29
30
  run(): Promise<this>;
30
31
  /** Adds a seed to this chainflow. */
31
32
  seed(seed: Record<string, any>): this;
32
33
  /** Adds an endpoint call to the callchain. */
33
- call<T>(endpoint: IEndpoint<T>, opts?: T): this;
34
+ call<CallOpts, Req, Resp>(endpoint: IEndpoint<CallOpts, Req, Resp>, opts?: CallOpts): this;
34
35
  /** Resets the chainflow's state by clearing its accumulated sources. */
35
36
  reset(): void;
36
37
  /** Creates a clone of this chainflow's callqueue and initial sources
@@ -42,8 +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
+ /** Stores accumulated endpoint call events. */
46
+ this.events = [];
47
47
  }
48
48
  /** Run the set up chain */
49
49
  run() {
@@ -56,17 +56,14 @@ class Chainflow {
56
56
  // call endpoint
57
57
  const id = endpoint.id;
58
58
  (0, logger_1.log)(`Calling endpoint with id "${id}"`);
59
- try {
60
- const { resp, store } = yield endpoint.call(__classPrivateFieldGet(this, _Chainflow_sources, "f"), opts);
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 });
65
- }
66
- catch (e) {
67
- (0, logger_1.warn)(`Chainflow stopped at endpoint with id "${id}" and error: ${e}`);
68
- throw e;
69
- }
59
+ const { req, resp, store } = yield endpoint.call(__classPrivateFieldGet(this, _Chainflow_sources, "f"), opts).catch((err) => {
60
+ (0, logger_1.warn)(`Chainflow stopped at endpoint with id "${id}" and error: ${err}`);
61
+ throw err;
62
+ });
63
+ if (store && Object.keys(store).length > 0)
64
+ __classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0] = deepmerge(__classPrivateFieldGet(this, _Chainflow_sources, "f")[constants_1.STORE_ID][0], store);
65
+ __classPrivateFieldGet(this, _Chainflow_sources, "f")[id] = [resp];
66
+ this.events.push({ details: endpoint.details, req, resp });
70
67
  }
71
68
  (0, logger_1.log)('Finished running chainflow.');
72
69
  return this;
@@ -85,13 +82,16 @@ class Chainflow {
85
82
  /** Resets the chainflow's state by clearing its accumulated sources. */
86
83
  reset() {
87
84
  __classPrivateFieldSet(this, _Chainflow_sources, {}, "f");
88
- this.responses = [];
85
+ this.events = [];
89
86
  }
90
87
  /** Creates a clone of this chainflow's callqueue and initial sources
91
88
  * which can be extended and run independently. */
92
89
  clone() {
93
90
  const clone = new Chainflow();
94
- __classPrivateFieldSet(clone, _Chainflow_initSources, structuredClone(__classPrivateFieldGet(this, _Chainflow_initSources, "f")), "f");
91
+ __classPrivateFieldSet(clone, _Chainflow_initSources, Object.entries(__classPrivateFieldGet(this, _Chainflow_initSources, "f")).reduce((acc, [sourceId, sourceValues]) => {
92
+ acc[sourceId] = [...sourceValues];
93
+ return acc;
94
+ }, {}), "f");
95
95
  __classPrivateFieldSet(clone, _Chainflow_callqueue, [...__classPrivateFieldGet(this, _Chainflow_callqueue, "f")], "f");
96
96
  return clone;
97
97
  }
@@ -1 +1 @@
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,mEAAmE;QACnE,iCAA6B,EAAE,EAAC;QAChC,+BAAwB,EAAE,EAAC;QAC3B,oCAAoC;QACpC,cAAS,GAAc,EAAE,CAAC;IAmE5B,CAAC;IAjEC,2BAA2B;IACrB,GAAG;;YACP,IAAA,YAAG,EAAC,sBAAsB,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,uBAAA,IAAI,sBAAY,uBAAA,IAAI,8BAAa,MAAA,CAAC;YAClC,uBAAA,IAAI,0BAAS,CAAC,oBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAE/B,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,uBAAA,IAAI,4BAAW,EAAE,CAAC;gBACjD,gBAAgB;gBAChB,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,CA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,CAAC,IAAI,CAAC,GAAG,uBAAA,EAAE,4BAAW,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;8CAC0C;IAC1C,aAAa,CAAC,EAAa;QACzB,uBAAA,IAAI,0DAAqB,uBAAA,IAAI,8BAAa,GAAK,uBAAA,EAAE,0BAAS,OAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,8BA+EC;;AAEM,MAAM,SAAS,GAAG,GAAc,EAAE;IACvC,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
@@ -1,4 +1,3 @@
1
- import { CallResult } from './chainflow';
2
1
  import { SourceNode } from './sourceNode';
3
2
  export type StoreValue<T> = IStore<T> | T;
4
3
  export interface IStore<T> {
@@ -10,5 +9,5 @@ export declare class Store {
10
9
  /** Definition of values to be stored from responses to this endpoint. */
11
10
  def: IStore<SourceNode>;
12
11
  /** Assigns values to be put in the chainflow's store. */
13
- storeValues(resp: unknown): CallResult;
12
+ storeValues(resp: unknown): IStore<unknown>;
14
13
  }
@@ -39,7 +39,7 @@ class Store {
39
39
  });
40
40
  const store = __classPrivateFieldGet(this, _Store_store, "f");
41
41
  __classPrivateFieldSet(this, _Store_store, {}, "f"); // resets the store
42
- return { resp: resp, store };
42
+ return store;
43
43
  }
44
44
  }
45
45
  exports.Store = Store;
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,6CAA2D;AAO3D,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,C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C,wBAAc,CAAC;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;YAChF,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"}
@@ -6,7 +6,7 @@ export interface SourceInfo {
6
6
  source: SourceNode;
7
7
  callback: ((val: any) => any) | undefined;
8
8
  }
9
- /** Overload signatures for `linkMerge` function. */
9
+ /** Overload signatures for `link` function. */
10
10
  interface Link {
11
11
  /**
12
12
  * Link a Source node to an Input node.
@@ -1,5 +1,5 @@
1
1
  import { InputNode, SourceValues, NODE_VALUE } from '../core/inputNode';
2
- import { Dispatcher } from 'undici';
2
+ import { IHttpReq, RESP_PARSER, ParsedHttpResp } from './utils/client';
3
3
  import { CallResult, IEndpoint } from '../core/chainflow';
4
4
  import { SourceNode } from '../core/sourceNode';
5
5
  import { nodeValueIdentifier } from '../core/utils/symbols';
@@ -19,21 +19,11 @@ export interface HttpInputNodes {
19
19
  /** Configurations for the endpoint. */
20
20
  export interface EndpointConfig {
21
21
  respParser?: `${RESP_PARSER}`;
22
- respValidator?: (resp: ParsedResponse) => {
22
+ respValidator?: (resp: ParsedHttpResp) => {
23
23
  valid: boolean;
24
24
  msg?: string;
25
25
  };
26
26
  }
27
- type ParsedResponse = Omit<Dispatcher.ResponseData, 'body'> & {
28
- body: unknown;
29
- };
30
- /** Formats to parse the response body. */
31
- export declare enum RESP_PARSER {
32
- ARRAY_BUFFER = "arrayBuffer",
33
- BLOB = "blob",
34
- JSON = "json",
35
- TEXT = "text"
36
- }
37
27
  /** Options for configuring an endpoint call. */
38
28
  export interface HTTPCallOpts {
39
29
  headers?: Record<string, string>;
@@ -45,15 +35,15 @@ export interface HTTPCallOpts {
45
35
  * Manages request and response nodes,
46
36
  * as well as calls to that endpoint
47
37
  */
48
- export declare class Endpoint implements IEndpoint<HTTPCallOpts> {
38
+ export declare class Endpoint implements IEndpoint<HTTPCallOpts, IHttpReq, ParsedHttpResp> {
49
39
  #private;
50
40
  id: string;
51
- constructor({ addr, method, path }: {
52
- addr: string;
53
- method: string;
54
- path: string;
41
+ url: string;
42
+ method: SUPPORTED_METHOD;
43
+ constructor({ url, method }: {
44
+ url: string;
45
+ method: SUPPORTED_METHOD;
55
46
  });
56
- get method(): SUPPORTED_METHOD;
57
47
  /** @todo Update this when there is a better implementation of id. */
58
48
  get details(): string;
59
49
  /** Configures this endpoint. */
@@ -72,8 +62,7 @@ export declare class Endpoint implements IEndpoint<HTTPCallOpts> {
72
62
  /** Declare values to store from responses to this endpoint. */
73
63
  store(callback: (resp: SourceNode) => IStore<SourceNode>): this;
74
64
  /** Calls this endpoint with responses provided from earlier requests in the chain. */
75
- call(responses: SourceValues, opts?: HTTPCallOpts): Promise<CallResult>;
65
+ call(responses: SourceValues, opts?: HTTPCallOpts): Promise<CallResult<IHttpReq, ParsedHttpResp>>;
76
66
  /** Passes the request input nodes of this endpoint to a callback. */
77
67
  set(setter: (nodes: HttpInputNodes) => void): this;
78
68
  }
79
- export {};
@@ -22,9 +22,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
22
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
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_parseResponseBody;
25
+ var _Endpoint_instances, _Endpoint_req, _Endpoint_resp, _Endpoint_config, _Endpoint_store, _Endpoint_extractPathParams, _Endpoint_insertPathParams, _Endpoint_insertQueryParams, _Endpoint_validateResp, _Endpoint_findMissingValues;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.Endpoint = exports.RESP_PARSER = void 0;
27
+ exports.Endpoint = void 0;
28
28
  const id_1 = require("./utils/id");
29
29
  const inputNode_1 = require("../core/inputNode");
30
30
  const reqBuilder_1 = require("./reqBuilder");
@@ -36,46 +36,28 @@ const symbols_1 = require("../core/utils/symbols");
36
36
  const initializers_1 = require("../core/utils/initializers");
37
37
  const store_1 = require("../core/store");
38
38
  const logger_1 = require("./logger");
39
- const constants_1 = require("./utils/constants");
40
39
  const deepmerge = (0, deepmerge_1.default)();
41
40
  const PATH_PARAM_REGEX = /\/(\{[^{}]+\})/g;
42
- /** Formats to parse the response body. */
43
- var RESP_PARSER;
44
- (function (RESP_PARSER) {
45
- RESP_PARSER["ARRAY_BUFFER"] = "arrayBuffer";
46
- RESP_PARSER["BLOB"] = "blob";
47
- RESP_PARSER["JSON"] = "json";
48
- RESP_PARSER["TEXT"] = "text";
49
- })(RESP_PARSER || (exports.RESP_PARSER = RESP_PARSER = {}));
50
41
  /**
51
42
  * Manages request and response nodes,
52
43
  * as well as calls to that endpoint
53
44
  */
54
45
  class Endpoint {
55
- constructor({ addr, method, path }) {
46
+ constructor({ url, method }) {
56
47
  _Endpoint_instances.add(this);
57
- _Endpoint_addr.set(this, '127.0.0.1');
58
- _Endpoint_path.set(this, void 0);
59
- _Endpoint_method.set(this, void 0);
60
48
  _Endpoint_req.set(this, void 0);
61
49
  _Endpoint_resp.set(this, void 0);
62
50
  _Endpoint_config.set(this, {});
63
51
  _Endpoint_store.set(this, new store_1.Store());
64
- method = method.toLowerCase();
65
- if (!constants_1.SUPPORTED_METHODS.includes(method))
66
- throw new errors_1.UnsupportedMethodError(method);
67
- !(addr.startsWith('http://') || addr.startsWith('https://')) && (addr = `http://${addr}`);
68
- __classPrivateFieldSet(this, _Endpoint_addr, addr, "f");
69
- __classPrivateFieldSet(this, _Endpoint_path, path, "f");
70
- __classPrivateFieldSet(this, _Endpoint_method, method, "f");
71
- this.id = (0, id_1.getEndpointId)({ method: __classPrivateFieldGet(this, _Endpoint_method, "f"), route: __classPrivateFieldGet(this, _Endpoint_path, "f") });
52
+ /** @todo consider validating url */
53
+ !(url.startsWith('http://') || url.startsWith('https://')) && (url = `http://${url}`);
54
+ this.url = url;
55
+ this.method = method;
56
+ this.id = (0, id_1.getEndpointId)({ method, url });
72
57
  __classPrivateFieldSet(this, _Endpoint_req, new reqBuilder_1.ReqBuilder(), "f");
73
58
  __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_extractPathParams).call(this);
74
59
  __classPrivateFieldSet(this, _Endpoint_resp, (0, sourceNode_1.sourceNode)(this.id), "f");
75
60
  }
76
- get method() {
77
- return __classPrivateFieldGet(this, _Endpoint_method, "f");
78
- }
79
61
  /** @todo Update this when there is a better implementation of id. */
80
62
  get details() {
81
63
  return this.id;
@@ -127,12 +109,11 @@ class Endpoint {
127
109
  call(responses, opts) {
128
110
  var _a, _b, _c;
129
111
  return __awaiter(this, void 0, void 0, function* () {
130
- const method = __classPrivateFieldGet(this, _Endpoint_method, "f").toUpperCase();
112
+ const method = this.method.toUpperCase();
131
113
  let body;
132
114
  const missingValues = []; // contains path of missing required values
133
115
  if (method !== 'GET')
134
116
  body = __classPrivateFieldGet(this, _Endpoint_req, "f").body[symbols_1.getNodeValue](responses, missingValues, ['body']);
135
- let callPath = __classPrivateFieldGet(this, _Endpoint_path, "f");
136
117
  let pathParams = {};
137
118
  if (Object.keys(__classPrivateFieldGet(this, _Endpoint_req, "f").pathParams).length > 0) {
138
119
  pathParams = __classPrivateFieldGet(this, _Endpoint_req, "f").pathParams[symbols_1.getNodeValue](responses, missingValues, ['pathParams']);
@@ -155,22 +136,30 @@ class Endpoint {
155
136
  queryParams = deepmerge(queryParams, opts.query);
156
137
  if (opts === null || opts === void 0 ? void 0 : opts.headers)
157
138
  headers = deepmerge(headers, opts.headers);
158
- callPath = __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_insertPathParams).call(this, callPath, pathParams);
159
- callPath = __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_insertQueryParams).call(this, callPath, queryParams);
139
+ let url = this.url;
140
+ url = __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_insertPathParams).call(this, url, pathParams);
141
+ url = __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_insertQueryParams).call(this, url, queryParams);
160
142
  const resp = yield client_1.httpClient.request({
161
- addr: __classPrivateFieldGet(this, _Endpoint_addr, "f"),
162
- path: callPath,
163
- method: __classPrivateFieldGet(this, _Endpoint_method, "f").toUpperCase(),
143
+ url,
144
+ method: this.method.toUpperCase(),
164
145
  body,
165
146
  headers,
147
+ respParser: __classPrivateFieldGet(this, _Endpoint_config, "f").respParser,
166
148
  });
167
- if (resp == null)
168
- throw new errors_1.InvalidResponseError('No response received.');
169
- const parsedResp = Object.assign(Object.assign({}, resp), { body: yield __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_parseResponseBody).call(this, resp) });
170
- const results = (_c = (_b = (_a = __classPrivateFieldGet(this, _Endpoint_config, "f")).respValidator) === null || _b === void 0 ? void 0 : _b.call(_a, parsedResp)) !== null && _c !== void 0 ? _c : __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_validateResp).call(this, parsedResp);
149
+ const results = (_c = (_b = (_a = __classPrivateFieldGet(this, _Endpoint_config, "f")).respValidator) === null || _b === void 0 ? void 0 : _b.call(_a, resp)) !== null && _c !== void 0 ? _c : __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_validateResp).call(this, resp);
171
150
  if (!results.valid)
172
151
  throw new errors_1.InvalidResponseError(results.msg);
173
- return __classPrivateFieldGet(this, _Endpoint_store, "f").storeValues(parsedResp);
152
+ return {
153
+ req: {
154
+ method,
155
+ url,
156
+ body,
157
+ headers,
158
+ respParser: __classPrivateFieldGet(this, _Endpoint_config, "f").respParser,
159
+ },
160
+ resp,
161
+ store: __classPrivateFieldGet(this, _Endpoint_store, "f").storeValues(resp),
162
+ };
174
163
  });
175
164
  }
176
165
  /** Passes the request input nodes of this endpoint to a callback. */
@@ -185,11 +174,11 @@ class Endpoint {
185
174
  }
186
175
  }
187
176
  exports.Endpoint = Endpoint;
188
- _Endpoint_addr = new WeakMap(), _Endpoint_path = new WeakMap(), _Endpoint_method = new WeakMap(), _Endpoint_req = new WeakMap(), _Endpoint_resp = new WeakMap(), _Endpoint_config = new WeakMap(), _Endpoint_store = new WeakMap(), _Endpoint_instances = new WeakSet(), _Endpoint_extractPathParams = function _Endpoint_extractPathParams() {
177
+ _Endpoint_req = new WeakMap(), _Endpoint_resp = new WeakMap(), _Endpoint_config = new WeakMap(), _Endpoint_store = new WeakMap(), _Endpoint_instances = new WeakSet(), _Endpoint_extractPathParams = function _Endpoint_extractPathParams() {
189
178
  const pathParamRegex = new RegExp(PATH_PARAM_REGEX);
190
179
  let param;
191
180
  const params = {};
192
- while ((param = pathParamRegex.exec(__classPrivateFieldGet(this, _Endpoint_path, "f"))) !== null && typeof param[1] === 'string') {
181
+ while ((param = pathParamRegex.exec(this.url)) !== null && typeof param[1] === 'string') {
193
182
  const paramName = param[1].replace('{', '').replace('}', '');
194
183
  params[paramName] = (0, initializers_1.required)();
195
184
  }
@@ -229,22 +218,5 @@ _Endpoint_addr = new WeakMap(), _Endpoint_path = new WeakMap(), _Endpoint_method
229
218
  }
230
219
  }
231
220
  return finalMissingValues;
232
- }, _Endpoint_parseResponseBody = function _Endpoint_parseResponseBody(resp) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- switch (__classPrivateFieldGet(this, _Endpoint_config, "f").respParser) {
235
- case RESP_PARSER.ARRAY_BUFFER:
236
- return yield resp.body.arrayBuffer();
237
- case RESP_PARSER.BLOB:
238
- return yield resp.body.blob();
239
- case RESP_PARSER.TEXT:
240
- return yield resp.body.text();
241
- case RESP_PARSER.JSON:
242
- return yield resp.body.json();
243
- default:
244
- if ((0, client_1.checkJsonSafe)(resp))
245
- return yield resp.body.json();
246
- return yield resp.body.text();
247
- }
248
- });
249
221
  };
250
222
  //# sourceMappingURL=endpoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/http/endpoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA2C;AAC3C,iDAAwE;AACxE,6CAA0C;AAC1C,2CAAuF;AAEvF,qCAIkB;AAElB,mEAAgD;AAChD,mDAA4D;AAC5D,mDAA0E;AAC1E,6DAAsD;AACtD,yCAA8C;AAC9C,qCAAgC;AAChC,iDAAwE;AAGxE,MAAM,SAAS,GAAG,IAAA,mBAAc,GAAE,CAAC;AAEnC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAyB3C,0CAA0C;AAC1C,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AAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,2DAKa,IAAoB;IAChC,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAA,aAAI,EAAC,oCAAoC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC5D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,6BAA6B,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC,qEAGkB,aAAyB,EAAE,GAAyB;IACrE,MAAM,kBAAkB,GAAa,EAAE,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACxC,SAAS;QACX,CAAC;QACD,IAAI,KAAK,GAAG,GAAG,CAAC;QAChB,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC5B,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;YACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBACxC,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -1,11 +1,16 @@
1
- /** When an unsupported method is passed into an `Endpoint`. */
2
- export declare class UnsupportedMethodError extends Error {
3
- constructor(unsupportedMethod: string);
4
- }
5
1
  /** When there is no value available for a required input node. */
6
2
  export declare class RequiredValuesNotFoundError extends Error {
7
3
  constructor(id: string, missingValues: string[]);
8
4
  }
5
+ /** When a request to an endpoint fails to execute or receive a response. */
6
+ export declare class RequestFailedError extends Error {
7
+ constructor(msg?: string);
8
+ }
9
+ /** When a response fails a validation check. */
9
10
  export declare class InvalidResponseError extends Error {
10
11
  constructor(msg?: string);
11
12
  }
13
+ /** When the client fails to parse a response body. */
14
+ export declare class ParseResponseError extends Error {
15
+ constructor(msg?: string);
16
+ }
@@ -1,14 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidResponseError = exports.RequiredValuesNotFoundError = exports.UnsupportedMethodError = void 0;
4
- /** When an unsupported method is passed into an `Endpoint`. */
5
- class UnsupportedMethodError extends Error {
6
- constructor(unsupportedMethod) {
7
- super(`Method "${unsupportedMethod}" is not supported.`);
8
- this.name = 'UnsupportedMethodError';
9
- }
10
- }
11
- exports.UnsupportedMethodError = UnsupportedMethodError;
3
+ exports.ParseResponseError = exports.InvalidResponseError = exports.RequestFailedError = exports.RequiredValuesNotFoundError = void 0;
12
4
  /** When there is no value available for a required input node. */
13
5
  class RequiredValuesNotFoundError extends Error {
14
6
  constructor(id, missingValues) {
@@ -17,6 +9,15 @@ class RequiredValuesNotFoundError extends Error {
17
9
  }
18
10
  }
19
11
  exports.RequiredValuesNotFoundError = RequiredValuesNotFoundError;
12
+ /** When a request to an endpoint fails to execute or receive a response. */
13
+ class RequestFailedError extends Error {
14
+ constructor(msg) {
15
+ super(`Request failed: ${msg}`);
16
+ this.name = 'RequestFailedError';
17
+ }
18
+ }
19
+ exports.RequestFailedError = RequestFailedError;
20
+ /** When a response fails a validation check. */
20
21
  class InvalidResponseError extends Error {
21
22
  constructor(msg) {
22
23
  super(`Response is invalid: ${msg !== null && msg !== void 0 ? msg : '[No error message is configured for this validation error]'}`);
@@ -24,4 +25,12 @@ class InvalidResponseError extends Error {
24
25
  }
25
26
  }
26
27
  exports.InvalidResponseError = InvalidResponseError;
28
+ /** When the client fails to parse a response body. */
29
+ class ParseResponseError extends Error {
30
+ constructor(msg) {
31
+ super(`Failed to parse response: ${msg}`);
32
+ this.name = 'ParseResponseError';
33
+ }
34
+ }
35
+ exports.ParseResponseError = ParseResponseError;
27
36
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/http/errors.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,iBAAyB;QACnC,KAAK,CAAC,WAAW,iBAAiB,qBAAqB,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED,kEAAkE;AAClE,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,EAAU,EAAE,aAAuB;QAC7C,KAAK,CACH,qBAAqB,EAAE,kDAAkD,aAAa,CAAC,IAAI,CACzF,IAAI,CACL,EAAE,CACJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AATD,kEASC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,GAAY;QACtB,KAAK,CACH,wBAAwB,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,4DAA4D,EAAE,CAC9F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAPD,oDAOC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/http/errors.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAClE,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,EAAU,EAAE,aAAuB;QAC7C,KAAK,CACH,qBAAqB,EAAE,kDAAkD,aAAa,CAAC,IAAI,CACzF,IAAI,CACL,EAAE,CACJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AATD,kEASC;AAED,4EAA4E;AAC5E,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,GAAY;QACtB,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED,gDAAgD;AAChD,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,GAAY;QACtB,KAAK,CACH,wBAAwB,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,4DAA4D,EAAE,CAC9F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAPD,oDAOC;AACD,sDAAsD;AACtD,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,GAAY;QACtB,KAAK,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/http/logger.ts"],"names":[],"mappings":";;;;;;AAAA,0BAA0B;AAC1B,kDAA0B;AAC1B,2CAA+D;AAElD,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;IACpB,IAAA,mBAAe,GAAE,CAAC;AACpB,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;IACjD,IAAA,kBAAU,GAAE,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/http/logger.ts"],"names":[],"mappings":";;;;;;AAAA,0BAA0B;AAC1B,kDAA0B;AAC1B,2CAA8D;AAEjD,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;IACpB,IAAA,mBAAc,GAAE,CAAC;AACnB,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;IACjD,IAAA,kBAAU,GAAE,CAAC;AACf,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import { Endpoint, EndpointConfig, INodeWithValue } from './endpoint';
2
2
  import { InputNode } from '../core/inputNode';
3
- /** Convenience function for creating an endpoint builder with supported methods defined on it. */
4
- export declare const originServer: (addr?: string) => OriginServer;
5
- /** Function for making a new endpoint. */
3
+ /** Convenience function for creating an endpoint builder
4
+ * with supported HTTP methods defined on it. */
5
+ export declare const origin: (origin?: string) => Origin;
6
+ /** Function for defining a new endpoint. */
6
7
  type MakeEndpoint = (path: string) => Endpoint;
7
- export type OriginServer = OriginBase & {
8
+ export type Origin = OriginBase & {
8
9
  get: MakeEndpoint;
9
10
  post: MakeEndpoint;
10
11
  put: MakeEndpoint;
@@ -12,7 +13,7 @@ export type OriginServer = OriginBase & {
12
13
  patch: MakeEndpoint;
13
14
  options: MakeEndpoint;
14
15
  };
15
- /** Stores the base address and defines methods to build endpoints with methods. */
16
+ /** Stores the base url and defines methods to build endpoints with methods. */
16
17
  declare class OriginBase {
17
18
  #private;
18
19
  /** Sets configuration for all endpoints made by this origin. */
@@ -23,6 +24,6 @@ declare class OriginBase {
23
24
  set(setter: ({ headers }: {
24
25
  headers: InputNode;
25
26
  }) => void): this;
26
- constructor(addr?: string);
27
+ constructor(origin?: string);
27
28
  }
28
29
  export {};
@@ -10,16 +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 _OriginBase_addr, _OriginBase_headers, _OriginBase_config;
13
+ var _OriginBase_origin, _OriginBase_headers, _OriginBase_config;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.originServer = void 0;
15
+ exports.origin = void 0;
16
16
  const endpoint_1 = require("./endpoint");
17
17
  const inputNode_1 = require("../core/inputNode");
18
18
  const constants_1 = require("./utils/constants");
19
- /** Convenience function for creating an endpoint builder with supported methods defined on it. */
20
- const originServer = (addr) => new OriginBase(addr);
21
- exports.originServer = originServer;
22
- /** Stores the base address and defines methods to build endpoints with methods. */
19
+ /** Convenience function for creating an endpoint builder
20
+ * with supported HTTP methods defined on it. */
21
+ const origin = (origin) => new OriginBase(origin);
22
+ exports.origin = origin;
23
+ /** Stores the base url and defines methods to build endpoints with methods. */
23
24
  class OriginBase {
24
25
  /** Sets configuration for all endpoints made by this origin. */
25
26
  config(config) {
@@ -38,17 +39,18 @@ class OriginBase {
38
39
  });
39
40
  return this;
40
41
  }
41
- constructor(addr = 'http://127.0.0.1') {
42
- _OriginBase_addr.set(this, void 0);
42
+ constructor(origin) {
43
+ _OriginBase_origin.set(this, void 0);
43
44
  _OriginBase_headers.set(this, void 0);
44
45
  _OriginBase_config.set(this, {});
45
- __classPrivateFieldSet(this, _OriginBase_addr, addr, "f");
46
+ __classPrivateFieldSet(this, _OriginBase_origin, origin, "f");
46
47
  __classPrivateFieldSet(this, _OriginBase_headers, new inputNode_1.InputNode(undefined), "f");
47
48
  constants_1.SUPPORTED_METHODS.forEach((method) => {
48
49
  // define methods to create endpoints from HTTP methods
49
50
  Reflect.defineProperty(this, method, {
50
51
  value: (path) => {
51
- return new endpoint_1.Endpoint({ addr: __classPrivateFieldGet(this, _OriginBase_addr, "f"), method, path })
52
+ var _a;
53
+ return new endpoint_1.Endpoint({ url: `${(_a = __classPrivateFieldGet(this, _OriginBase_origin, "f")) !== null && _a !== void 0 ? _a : ''}${path}`, method })
52
54
  .baseHeaders(__classPrivateFieldGet(this, _OriginBase_headers, "f"))
53
55
  .config(__classPrivateFieldGet(this, _OriginBase_config, "f"));
54
56
  },
@@ -56,5 +58,5 @@ class OriginBase {
56
58
  });
57
59
  }
58
60
  }
59
- _OriginBase_addr = new WeakMap(), _OriginBase_headers = new WeakMap(), _OriginBase_config = new WeakMap();
60
- //# sourceMappingURL=originServer.js.map
61
+ _OriginBase_origin = new WeakMap(), _OriginBase_headers = new WeakMap(), _OriginBase_config = new WeakMap();
62
+ //# sourceMappingURL=origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/http/origin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAsE;AACtE,iDAA8C;AAC9C,iDAAsD;AAEtD;gDACgD;AACzC,MAAM,MAAM,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,CAAW,CAAC;AAA/D,QAAA,MAAM,UAAyD;AAc5E,+EAA+E;AAC/E,MAAM,UAAU;IAKd,gEAAgE;IAChE,MAAM,CAAC,MAAsB;QAC3B,uBAAA,IAAI,sBAAW,MAAM,MAAA,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,OAAO,CAAC,MAA2D;QACjE,uBAAA,IAAI,uBAAY,IAAI,qBAAS,CAAC,MAAM,CAAC,MAAA,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IACnD,GAAG,CAAC,MAAqD;QACvD,MAAM,CAAC;YACL,OAAO,EAAE,uBAAA,IAAI,2BAAS;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,MAAe;QAxB3B,qCAAiB;QACjB,sCAAoB;QACpB,6BAA0B,EAAE,EAAC;QAuB3B,uBAAA,IAAI,sBAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,uBAAY,IAAI,qBAAS,CAAC,SAAS,CAAC,MAAA,CAAC;QACzC,6BAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACnC,uDAAuD;YACvD,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;gBACnC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;;oBACtB,OAAO,IAAI,mBAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,MAAA,uBAAA,IAAI,0BAAQ,mCAAI,EAAE,GAAG,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC;yBACjE,WAAW,CAAC,uBAAA,IAAI,2BAAS,CAAC;yBAC1B,MAAM,CAAC,uBAAA,IAAI,0BAAQ,CAAC,CAAC;gBAC1B,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,20 +1,27 @@
1
1
  import { Dispatcher } from 'undici';
2
- export type SUPPORTED_METHOD_UPPERCASE = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
3
- /** @todo evaluate if defaults should change */
4
- export declare let _defaultHeaders: Record<string, string> | undefined;
2
+ import { SUPPORTED_METHOD } from './constants';
3
+ export type SUPPORTED_METHOD_UPPERCASE = Uppercase<SUPPORTED_METHOD>;
4
+ /** Formats to parse the response body. */
5
+ export declare enum RESP_PARSER {
6
+ ARRAY_BUFFER = "arrayBuffer",
7
+ BLOB = "blob",
8
+ JSON = "json",
9
+ TEXT = "text"
10
+ }
11
+ /** A utility to modify the default headers sent in every endpoint call. */
5
12
  export declare const defaultHeaders: (headers?: Record<string, string>, replace?: boolean) => void;
6
- export declare const httpClient: {
7
- request: ({ addr, path, method, body, headers, }: {
8
- addr: string;
9
- path: string;
10
- method: SUPPORTED_METHOD_UPPERCASE;
11
- body?: any;
12
- headers?: Record<string, string> | undefined;
13
- }) => Promise<Dispatcher.ResponseData | null>;
13
+ /** @todo explore allowing the client to be swapped out. */
14
+ export interface IHttpClient<Resp> {
15
+ request: (params: IHttpReq) => Promise<Resp>;
16
+ }
17
+ export interface IHttpReq {
18
+ url: string;
19
+ method: SUPPORTED_METHOD_UPPERCASE;
20
+ body?: any;
21
+ headers?: Record<string, string>;
22
+ respParser?: `${RESP_PARSER}`;
23
+ }
24
+ export type ParsedHttpResp = Omit<Dispatcher.ResponseData, 'body'> & {
25
+ body: unknown;
14
26
  };
15
- /**
16
- * Check required to avoid errors when attempting `json()` on an empty body.
17
- * Refer to issue under `ResponseData` at
18
- * https://github.com/nodejs/undici/blob/main/docs/docs/api/Dispatcher.md
19
- */
20
- export declare const checkJsonSafe: (resp: Dispatcher.ResponseData) => boolean;
27
+ export declare const httpClient: IHttpClient<ParsedHttpResp>;
@@ -9,46 +9,80 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.checkJsonSafe = exports.httpClient = exports.defaultHeaders = exports._defaultHeaders = void 0;
12
+ exports.httpClient = exports.defaultHeaders = exports.RESP_PARSER = void 0;
13
13
  const undici_1 = require("undici");
14
14
  const logger_1 = require("../logger");
15
- /** @todo evaluate if defaults should change */
16
- exports._defaultHeaders = {
15
+ const errors_1 = require("../errors");
16
+ /** Formats to parse the response body. */
17
+ var RESP_PARSER;
18
+ (function (RESP_PARSER) {
19
+ RESP_PARSER["ARRAY_BUFFER"] = "arrayBuffer";
20
+ RESP_PARSER["BLOB"] = "blob";
21
+ RESP_PARSER["JSON"] = "json";
22
+ RESP_PARSER["TEXT"] = "text";
23
+ })(RESP_PARSER || (exports.RESP_PARSER = RESP_PARSER = {}));
24
+ let _defaultHeaders = {
17
25
  'content-type': 'application/json',
18
26
  'User-Agent': 'Chainflow/0.1',
19
27
  };
28
+ /** A utility to modify the default headers sent in every endpoint call. */
20
29
  const defaultHeaders = (headers, replace) => {
21
30
  replace
22
- ? (exports._defaultHeaders = headers)
23
- : (exports._defaultHeaders = Object.assign(Object.assign({}, exports._defaultHeaders), headers));
31
+ ? (_defaultHeaders = headers)
32
+ : (_defaultHeaders = Object.assign(Object.assign({}, _defaultHeaders), headers));
24
33
  };
25
34
  exports.defaultHeaders = defaultHeaders;
26
- /** Sends a HTTP request. */
27
- const request = ({ addr, path, method, body, headers, }) => __awaiter(void 0, void 0, void 0, function* () {
28
- const finalHeaders = Object.assign(Object.assign({}, exports._defaultHeaders), headers);
29
- (0, logger_1.log)(`[${method}] [${addr}${path}] with headers %O${body ? ' and payload %O' : ''}`, finalHeaders, body !== null && body !== void 0 ? body : '');
30
- try {
31
- const resp = yield (0, undici_1.request)(`${addr}${path}`, {
32
- method,
33
- body: body ? JSON.stringify(body) : null,
34
- headers: Object.keys(finalHeaders).length > 0 ? finalHeaders : null,
35
+ /** Executes sending a HTTP request. */
36
+ const request = ({ url, method, body, headers, respParser }) => __awaiter(void 0, void 0, void 0, function* () {
37
+ const finalHeaders = Object.assign(Object.assign({}, _defaultHeaders), headers);
38
+ if (logger_1.log.enabled) {
39
+ (0, logger_1.log)(`[${method}] [${url}]`);
40
+ (0, logger_1.log)('headers: %O', finalHeaders);
41
+ body != null && (0, logger_1.log)('body: %O', body);
42
+ }
43
+ const resp = yield (0, undici_1.request)(url, {
44
+ method,
45
+ body: body ? JSON.stringify(body) : null /** @todo consider using buffer */,
46
+ headers: Object.keys(finalHeaders).length > 0 ? finalHeaders : null,
47
+ }).catch((err) => {
48
+ throw new errors_1.RequestFailedError(`${err}`);
49
+ });
50
+ const parsedResp = Object.assign(Object.assign({}, resp), { body: yield parseResponse(resp, respParser).catch((err) => {
51
+ throw new errors_1.ParseResponseError(err);
52
+ }) });
53
+ if (logger_1.log.enabled) {
54
+ (0, logger_1.log)('response: %O', {
55
+ statusCode: parsedResp.statusCode,
56
+ body: parsedResp.body,
35
57
  });
36
- return resp;
37
58
  }
38
- catch (err) {
39
- (0, logger_1.warn)(`Request failed: ${err}`);
40
- return null;
59
+ return parsedResp;
60
+ });
61
+ /** Parses a response body according to the specified parser. */
62
+ const parseResponse = (resp, respParser) => __awaiter(void 0, void 0, void 0, function* () {
63
+ switch (respParser) {
64
+ case RESP_PARSER.ARRAY_BUFFER:
65
+ return yield resp.body.arrayBuffer();
66
+ case RESP_PARSER.BLOB:
67
+ return yield resp.body.blob();
68
+ case RESP_PARSER.TEXT:
69
+ return yield resp.body.text();
70
+ case RESP_PARSER.JSON:
71
+ return yield resp.body.json();
72
+ default:
73
+ if (checkJsonSafe(resp))
74
+ return yield resp.body.json();
75
+ return yield resp.body.text();
41
76
  }
42
77
  });
43
- exports.httpClient = { request };
44
78
  /**
45
79
  * Check required to avoid errors when attempting `json()` on an empty body.
46
- * Refer to issue under `ResponseData` at
80
+ * Refer to section under `ResponseData` at
47
81
  * https://github.com/nodejs/undici/blob/main/docs/docs/api/Dispatcher.md
48
82
  */
49
83
  const checkJsonSafe = (resp) => {
50
84
  var _a;
51
85
  return Boolean(resp.statusCode !== 204 && ((_a = resp.headers['content-type']) === null || _a === void 0 ? void 0 : _a.includes('application/json')));
52
86
  };
53
- exports.checkJsonSafe = checkJsonSafe;
87
+ exports.httpClient = { request };
54
88
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/http/utils/client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA8D;AAC9D,sCAAsC;AAItC,+CAA+C;AACpC,QAAA,eAAe,GAAuC;IAC/D,cAAc,EAAE,kBAAkB;IAClC,YAAY,EAAE,eAAe;CAC9B,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,OAAgC,EAAE,O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,CAAC,IAAI;YACnB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,KAAK,WAAW,CAAC,IAAI;YACnB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC;YACE,IAAI,aAAa,CAAC,IAAI,CAAC;gBAAE,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACvD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;AACH,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,IAA6B,EAAW,EAAE;;IAC/D,OAAO,OAAO,CACZ,IAAI,CAAC,UAAU,KAAK,GAAG,KAAI,MAAA,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,0CAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAA,CACtF,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,UAAU,GAAgC,EAAE,OAAO,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** @todo explore improving this */
2
- export declare const getEndpointId: ({ route, method }: {
3
- route: string;
2
+ export declare const getEndpointId: ({ url, method }: {
3
+ url: string;
4
4
  method: string;
5
5
  }) => string;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEndpointId = void 0;
4
4
  /** @todo explore improving this */
5
- const getEndpointId = ({ route, method }) => {
6
- return `[${method.toUpperCase()}] ${route}`;
5
+ const getEndpointId = ({ url, method }) => {
6
+ return `[${method.toUpperCase()}] ${url}`;
7
7
  };
8
8
  exports.getEndpointId = getEndpointId;
9
9
  //# sourceMappingURL=id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"id.js","sourceRoot":"","sources":["../../../src/http/utils/id.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAC5B,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAqC,EAAU,EAAE;IAC5F,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB"}
1
+ {"version":3,"file":"id.js","sourceRoot":"","sources":["../../../src/http/utils/id.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAC5B,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,EAAmC,EAAU,EAAE;IACxF,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ export * from './core/utils/link';
5
5
  export * from './core/utils/config';
6
6
  export * from './http/endpoint';
7
7
  export * from './http/reqBuilder';
8
- export * from './http/originServer';
8
+ export * from './http/origin';
9
9
  export { enableLogs } from './http/logger';
10
10
  export { defaultHeaders } from './http/utils/client';
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ __exportStar(require("./core/utils/link"), exports);
22
22
  __exportStar(require("./core/utils/config"), exports);
23
23
  __exportStar(require("./http/endpoint"), exports);
24
24
  __exportStar(require("./http/reqBuilder"), exports);
25
- __exportStar(require("./http/originServer"), exports);
25
+ __exportStar(require("./http/origin"), exports);
26
26
  var logger_1 = require("./http/logger");
27
27
  Object.defineProperty(exports, "enableLogs", { enumerable: true, get: function () { return logger_1.enableLogs; } });
28
28
  var client_1 = require("./http/utils/client");
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,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,kDAAgC;AAChC,oDAAkC;AAClC,sDAAoC;AACpC,wCAA2C;AAAlC,oGAAA,UAAU,OAAA;AACnB,8CAAqD;AAA5C,wGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,4DAA0C;AAC1C,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,wCAA2C;AAAlC,oGAAA,UAAU,OAAA;AACnB,8CAAqD;AAA5C,wGAAA,cAAc,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chainflow",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Build dynamic and composable API workflows",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- {"version":3,"file":"originServer.js","sourceRoot":"","sources":["../../src/http/originServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAsE;AACtE,iDAA8C;AAC9C,iDAAsD;AAEtD,kGAAkG;AAC3F,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,IAAI,CAAiB,CAAC;AAAvE,QAAA,YAAY,gBAA2D;AAcpF,mFAAmF;AACnF,MAAM,UAAU;IAKd,gEAAgE;IAChE,MAAM,CAAC,MAAsB;QAC3B,uBAAA,IAAI,sBAAW,MAAM,MAAA,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,OAAO,CAAC,MAA2D;QACjE,uBAAA,IAAI,uBAAY,IAAI,qBAAS,CAAC,MAAM,CAAC,MAAA,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IACnD,GAAG,CAAC,MAAqD;QACvD,MAAM,CAAC;YACL,OAAO,EAAE,uBAAA,IAAI,2BAAS;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,OAAe,kBAAkB;QAxB7C,mC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