@nestia/fetcher 3.0.0-dev.20231209 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +12 -9
  2. package/lib/{internal/AesPkcs5.d.ts → AesPkcs5.d.ts} +2 -2
  3. package/lib/{internal/AesPkcs5.js → AesPkcs5.js} +8 -16
  4. package/lib/AesPkcs5.js.map +1 -0
  5. package/lib/EncryptedFetcher.d.ts +3 -4
  6. package/lib/EncryptedFetcher.js +8 -11
  7. package/lib/EncryptedFetcher.js.map +1 -1
  8. package/lib/IConnection.d.ts +11 -2
  9. package/lib/IEncryptionPassword.d.ts +2 -8
  10. package/lib/IFetchEvent.d.ts +11 -0
  11. package/lib/IFetchEvent.js +21 -0
  12. package/lib/IFetchEvent.js.map +1 -0
  13. package/lib/{internal/IFetchRoute.d.ts → IFetchRoute.d.ts} +1 -1
  14. package/lib/{internal/IFetchRoute.js.map → IFetchRoute.js.map} +1 -1
  15. package/lib/NestiaSimulator.d.ts +13 -0
  16. package/lib/NestiaSimulator.js +62 -0
  17. package/lib/NestiaSimulator.js.map +1 -0
  18. package/lib/PlainFetcher.d.ts +3 -4
  19. package/lib/PlainFetcher.js +2 -2
  20. package/lib/PlainFetcher.js.map +1 -1
  21. package/lib/Resolved.d.ts +5 -5
  22. package/lib/index.d.ts +3 -1
  23. package/lib/index.js +3 -1
  24. package/lib/index.js.map +1 -1
  25. package/lib/internal/FetcherBase.d.ts +5 -6
  26. package/lib/internal/FetcherBase.js +143 -70
  27. package/lib/internal/FetcherBase.js.map +1 -1
  28. package/package.json +2 -2
  29. package/src/{internal/AesPkcs5.ts → AesPkcs5.ts} +50 -66
  30. package/src/EncryptedFetcher.ts +174 -179
  31. package/src/HttpError.ts +85 -85
  32. package/src/IConnection.ts +247 -237
  33. package/src/IEncryptionPassword.ts +50 -56
  34. package/src/IFetchEvent.ts +31 -0
  35. package/src/{internal/IFetchRoute.ts → IFetchRoute.ts} +62 -62
  36. package/src/IPropagation.ts +102 -102
  37. package/src/IRandomGenerator.ts +38 -38
  38. package/src/NestiaSimulator.ts +82 -0
  39. package/src/PlainFetcher.ts +105 -106
  40. package/src/Primitive.ts +136 -135
  41. package/src/Resolved.ts +119 -116
  42. package/src/index.ts +9 -7
  43. package/src/internal/FetcherBase.ts +124 -72
  44. package/src/internal/Singleton.ts +20 -20
  45. package/lib/internal/AesPkcs5.js.map +0 -1
  46. /package/lib/{internal/IFetchRoute.js → IFetchRoute.js} +0 -0
package/README.md CHANGED
@@ -2,21 +2,23 @@
2
2
  ![Nestia Logo](https://nestia.io/logo.png)
3
3
 
4
4
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
5
- [![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)
6
- [![Downloads](https://img.shields.io/npm/dm/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)
5
+ [![npm version](https://img.shields.io/npm/v/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
6
+ [![Downloads](https://img.shields.io/npm/dm/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
7
7
  [![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
8
8
  [![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](https://nestia.io/docs/)
9
+ [![Discord Badge](https://img.shields.io/badge/discord-NestJS/Nestia-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.com/channels/520622812742811698/1197293125434093701)](https://discord.com/channels/520622812742811698/1181877086797967420)
9
10
 
10
11
  Nestia is a set of helper libraries for NestJS, supporting below features:
11
12
 
12
- - `@nestia/core`: super-fast decorators
13
+ - `@nestia/core`: Super-fast decorators
13
14
  - `@nestia/sdk`:
14
15
  - Swagger generator evolved than ever
15
16
  - SDK library generator for clients
16
17
  - Mockup Simulator for client applications
17
18
  - Automatic E2E test functions generator
18
- - `@nestia/migrate`: migration from Swagger to NestJS
19
- - `nestia`: just CLI (command line interface) tool
19
+ - `@nestia/migrate`: Migration from Swagger to NestJS
20
+ - `@nestia/editor`: Online TypeScript Swagger Editor
21
+ - `nestia`: Just CLI (command line interface) tool
20
22
 
21
23
  > **Note**
22
24
  >
@@ -25,8 +27,8 @@ Nestia is a set of helper libraries for NestJS, supporting below features:
25
27
  > - Runtime validator is **20,000x faster** than `class-validator`
26
28
  > - JSON serialization is **200x faster** than `class-transformer`
27
29
  > - Software Development Kit
28
- > - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://trpc.io/)
29
- > - Mockup simulator means embedded backend simulator in SDK
30
+ > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
31
+ > - Mockup simulator means embedded backend simulator in the SDK
30
32
  > - similar with [msw](https://mswjs.io/), but fully automated
31
33
 
32
34
  ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
@@ -59,15 +61,16 @@ Check out the document in the [website](https://nestia.io/docs/):
59
61
  - [TypedRoute](https://nestia.io/docs/core/TypedRoute/)
60
62
  - [TypedBody](https://nestia.io/docs/core/TypedBody/)
61
63
  - [TypedParam](https://nestia.io/docs/core/TypedParam/)
62
- - [TypedQuery](https://nestia.io/docs/core/TypedRoute/)
64
+ - [TypedQuery](https://nestia.io/docs/core/TypedQuery/)
63
65
  - [TypedHeaders](https://nestia.io/docs/core/TypedHeaders/)
64
66
  - [TypedException](https://nestia.io/docs/core/TypedException/)
65
67
  - Generators
66
68
  - [Swagger Documents](https://nestia.io/docs/sdk/swagger/)
67
- - [SDK Library](https://nestia.io/docs/sdk/sdk/)
69
+ - [Software Development Kit](https://nestia.io/docs/sdk/sdk/)
68
70
  - [E2E Functions](https://nestia.io/docs/sdk/e2e/)
69
71
  - [Mockup Simulator](https://nestia.io/docs/sdk/simulator/)
70
72
  - [Swagger to NestJS](https://nestia.io/docs/migrate/)
73
+ - [TypeScript Swagger Editor](https://nestia.io/docs/editor/)
71
74
 
72
75
  ### 🔗 Appendix
73
76
  - [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
@@ -17,7 +17,7 @@ export declare namespace AesPkcs5 {
17
17
  * @param iv Initializer Vector for the encryption
18
18
  * @return Encrypted data
19
19
  */
20
- const encrypt: (data: string | Uint8Array, key: string, iv: string) => Uint8Array;
20
+ function encrypt(data: string, key: string, iv: string): string;
21
21
  /**
22
22
  * Decrypt data.
23
23
  *
@@ -26,5 +26,5 @@ export declare namespace AesPkcs5 {
26
26
  * @param iv Initializer Vector for the decryption
27
27
  * @return Decrypted data.
28
28
  */
29
- const decrypt: (data: Uint8Array, key: string, iv: string) => Uint8Array;
29
+ function decrypt(data: string, key: string, iv: string): string;
30
30
  }
@@ -25,11 +25,12 @@ var AesPkcs5;
25
25
  * @param iv Initializer Vector for the encryption
26
26
  * @return Encrypted data
27
27
  */
28
- AesPkcs5.encrypt = function (data, key, iv) {
28
+ function encrypt(data, key, iv) {
29
29
  var bytes = key.length * 8;
30
30
  var cipher = crypto_1.default.createCipheriv("AES-".concat(bytes, "-CBC"), key, iv);
31
- return concat(cipher.update(data), cipher.final());
32
- };
31
+ return cipher.update(data, "utf8", "base64") + cipher.final("base64");
32
+ }
33
+ AesPkcs5.encrypt = encrypt;
33
34
  /**
34
35
  * Decrypt data.
35
36
  *
@@ -38,20 +39,11 @@ var AesPkcs5;
38
39
  * @param iv Initializer Vector for the decryption
39
40
  * @return Decrypted data.
40
41
  */
41
- AesPkcs5.decrypt = function (data, key, iv) {
42
+ function decrypt(data, key, iv) {
42
43
  var bytes = key.length * 8;
43
44
  var decipher = crypto_1.default.createDecipheriv("AES-".concat(bytes, "-CBC"), key, iv);
44
- return concat(decipher.update(data), decipher.final());
45
- };
46
- /**
47
- * @internal
48
- */
49
- var concat = function (x, y) {
50
- if (x.length === 0)
51
- return y;
52
- if (y.length === 0)
53
- return x;
54
- return Buffer.concat([x, y]);
55
- };
45
+ return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
46
+ }
47
+ AesPkcs5.decrypt = decrypt;
56
48
  })(AesPkcs5 || (exports.AesPkcs5 = AesPkcs5 = {}));
57
49
  //# sourceMappingURL=AesPkcs5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CAqCxB;AArCD,WAAiB,QAAQ;IACvB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,MAAM,GAAkB,gBAAM,CAAC,cAAc,CACjD,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACH,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IARe,gBAAO,UAQtB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,QAAQ,GAAoB,gBAAM,CAAC,gBAAgB,CACvD,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACH,CAAC;QAEF,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IATe,gBAAO,UAStB,CAAA;AACH,CAAC,EArCgB,QAAQ,wBAAR,QAAQ,QAqCxB"}
@@ -1,7 +1,6 @@
1
1
  import { IConnection } from "./IConnection";
2
+ import { IFetchRoute } from "./IFetchRoute";
2
3
  import { IPropagation } from "./IPropagation";
3
- import { Primitive } from "./Primitive";
4
- import { IFetchRoute } from "./internal/IFetchRoute";
5
4
  /**
6
5
  * Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
7
6
  *
@@ -32,7 +31,7 @@ export declare namespace EncryptedFetcher {
32
31
  * @param route Route information about the target API
33
32
  * @return Response body data from the remote API
34
33
  */
35
- function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Primitive<Output>>;
34
+ function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Output>;
36
35
  /**
37
36
  * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
38
37
  *
@@ -40,7 +39,7 @@ export declare namespace EncryptedFetcher {
40
39
  * @param route Route information about the target API
41
40
  * @return Response body data from the remote API
42
41
  */
43
- function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Primitive<Output>>;
42
+ function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
44
43
  function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise<Output>;
45
44
  function propagate<Input, Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
46
45
  }
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.EncryptedFetcher = void 0;
40
- var AesPkcs5_1 = require("./internal/AesPkcs5");
40
+ var AesPkcs5_1 = require("./AesPkcs5");
41
41
  var FetcherBase_1 = require("./internal/FetcherBase");
42
42
  /**
43
43
  * Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
@@ -56,9 +56,9 @@ var FetcherBase_1 = require("./internal/FetcherBase");
56
56
  var EncryptedFetcher;
57
57
  (function (EncryptedFetcher) {
58
58
  function fetch(connection, route, input, stringify) {
59
- var _a, _b, _c, _d;
60
59
  return __awaiter(this, void 0, void 0, function () {
61
60
  var closure;
61
+ var _a, _b, _c, _d;
62
62
  return __generator(this, function (_e) {
63
63
  if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
64
64
  connection.encryption === undefined)
@@ -85,8 +85,8 @@ var EncryptedFetcher;
85
85
  decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
86
86
  ? function (input, headers) {
87
87
  var p = closure("decode")(headers, input);
88
- var str = new TextDecoder().decode(AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv));
89
- return str.length ? JSON.parse(str) : str;
88
+ var s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
89
+ return s.length ? JSON.parse(s) : s;
90
90
  }
91
91
  : function (input) { return input; },
92
92
  })(connection, route, input, stringify)];
@@ -95,9 +95,9 @@ var EncryptedFetcher;
95
95
  }
96
96
  EncryptedFetcher.fetch = fetch;
97
97
  function propagate(connection, route, input, stringify) {
98
- var _a, _b, _c, _d;
99
98
  return __awaiter(this, void 0, void 0, function () {
100
99
  var closure;
100
+ var _a, _b, _c, _d;
101
101
  return __generator(this, function (_e) {
102
102
  if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
103
103
  connection.encryption === undefined)
@@ -123,12 +123,9 @@ var EncryptedFetcher;
123
123
  : function (input) { return input; },
124
124
  decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
125
125
  ? function (input, headers) {
126
- var binary = input;
127
- var p = closure("decode")(headers, binary);
128
- if (!binary.length)
129
- return;
130
- var str = new TextDecoder().decode(AesPkcs5_1.AesPkcs5.decrypt(binary, p.key, p.iv));
131
- return str.length ? JSON.parse(str) : str;
126
+ var p = closure("decode")(headers, input);
127
+ var s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
128
+ return s.length ? JSON.parse(s) : s;
132
129
  }
133
130
  : function (input) { return input; },
134
131
  })(connection, route, input, stringify)];
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptedFetcher.js","sourceRoot":"","sources":["../src/EncryptedFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAA+C;AAC/C,sDAAqD;AAGrD;;;;;;;;;;;;;GAaG;AACH,IAAiB,gBAAgB,CA4JhC;AA5JD,WAAiB,gBAAgB;IAuC/B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;;;gBAEpC,IACE,CAAC,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,KAAI,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,CAAA,CAAC;oBAChE,UAAU,CAAC,UAAU,KAAK,SAAS;oBAEnC,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;gBACE,OAAO,GACX,OAAO,UAAU,CAAC,UAAU,KAAK,UAAU;oBACzC,CAAC,CAAC,UAAC,SAA8B;wBAC7B,OAAA,UACE,OAA4D,EAC5D,IAAyB;4BAEzB,OAAC,UAAU,CAAC,UAA0C,CAAC;gCACrD,OAAO,SAAA;gCACP,IAAI,EAAE,IAAW;gCACjB,SAAS,WAAA;6BACV,CAAC;wBAJF,CAIE;oBARJ,CAQI;oBACR,CAAC,CAAC,cAAM,OAAA,cAAM,OAAA,UAAU,CAAC,UA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AAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gCACjE,OAAO,mBAAQ,CAAC,OAAO,CACrB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,EACpC,CAAC,CAAC,GAAG,EACL,CAAC,CAAC,EAAE,CACL,CAAC;4BACJ,CAAC;4BACH,CAAC,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;wBACtB,MAAM,EACJ,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;4BAChC,CAAC,CAAC,UAAC,KAAK,EAAE,OAAO;gCACb,IAAM,CAAC,GAAwB,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gCACjE,IAAM,CAAC,GAAW,mBAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;gCACvD,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;4BACtC,CAAC;4BACH,CAAC,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;qBACvB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,EAAC;;;KAC5D;IAjDqB,0BAAS,YAiD9B,CAAA;AACH,CAAC,EAxJgB,gBAAgB,gCAAhB,gBAAgB,QAwJhC"}
@@ -1,5 +1,6 @@
1
1
  /// <reference lib="dom" />
2
2
  import { IEncryptionPassword } from "./IEncryptionPassword";
3
+ import { IFetchEvent } from "./IFetchEvent";
3
4
  import { IRandomGenerator } from "./IRandomGenerator";
4
5
  /**
5
6
  * Connection information.
@@ -42,9 +43,13 @@ export interface IConnection<Headers extends object = {}> {
42
43
  */
43
44
  simulate?: boolean | Partial<IRandomGenerator>;
44
45
  /**
45
- * Additional options for the `fetch` function.
46
+ * Logger function.
47
+ *
48
+ * This function is called when the fetch event is completed.
49
+ *
50
+ * @param event Event information of the fetch event.
46
51
  */
47
- options?: IConnection.IOptions;
52
+ logger?: (event: IFetchEvent) => Promise<void>;
48
53
  /**
49
54
  * Encryption password of its closure function.
50
55
  *
@@ -53,6 +58,10 @@ export interface IConnection<Headers extends object = {}> {
53
58
  * security reason.
54
59
  */
55
60
  encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
61
+ /**
62
+ * Additional options for the `fetch` function.
63
+ */
64
+ options?: IConnection.IOptions;
56
65
  /**
57
66
  * Custom fetch function.
58
67
  *
@@ -39,15 +39,9 @@ export declare namespace IEncryptionPassword {
39
39
  /**
40
40
  * Properties for the closure.
41
41
  */
42
- type IProps = IDecodeProps | IEncodeProps;
43
- interface IDecodeProps {
44
- headers: Record<string, IConnection.HeaderValue | undefined>;
45
- body: Uint8Array;
46
- direction: "decode";
47
- }
48
- interface IEncodeProps {
42
+ interface IProps {
49
43
  headers: Record<string, IConnection.HeaderValue | undefined>;
50
44
  body: string;
51
- direction: "encode";
45
+ direction: "encode" | "decode";
52
46
  }
53
47
  }
@@ -0,0 +1,11 @@
1
+ import { IFetchRoute } from "./IFetchRoute";
2
+ export interface IFetchEvent {
3
+ route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">;
4
+ path: string;
5
+ status: number | null;
6
+ input: any;
7
+ output: any;
8
+ started_at: Date;
9
+ respond_at: Date | null;
10
+ completed_at: Date;
11
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // export namespace IFetchEvent {
4
+ // export interface IFunction {
5
+ // (connection: IConnection, ...args: any[]): Promise<any>;
6
+ // METADATA: {
7
+ // method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
8
+ // path: string;
9
+ // request: null | {
10
+ // type: string;
11
+ // encrypted: boolean;
12
+ // };
13
+ // response: null | {
14
+ // type: string;
15
+ // encrypted: boolean;
16
+ // };
17
+ // };
18
+ // status: null | number;
19
+ // }
20
+ // }
21
+ //# sourceMappingURL=IFetchEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFetchEvent.js","sourceRoot":"","sources":["../src/IFetchEvent.ts"],"names":[],"mappings":";;AAaA,iCAAiC;AACjC,iCAAiC;AACjC,+DAA+D;AAC/D,kBAAkB;AAClB,kFAAkF;AAClF,sBAAsB;AACtB,0BAA0B;AAC1B,wBAAwB;AACxB,8BAA8B;AAC9B,WAAW;AACX,2BAA2B;AAC3B,wBAAwB;AACxB,8BAA8B;AAC9B,WAAW;AACX,SAAS;AACT,6BAA6B;AAC7B,MAAM;AACN,IAAI"}
@@ -43,7 +43,7 @@ export declare namespace IFetchRoute {
43
43
  * Describes how content-type being used in body, and whether encrypted or not.
44
44
  */
45
45
  interface IBody {
46
- type: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "text/plain";
46
+ type: "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
47
47
  encrypted?: boolean;
48
48
  }
49
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IFetchRoute.js","sourceRoot":"","sources":["../../src/internal/IFetchRoute.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"IFetchRoute.js","sourceRoot":"","sources":["../src/IFetchRoute.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export declare namespace NestiaSimulator {
2
+ interface IProps {
3
+ host: string;
4
+ path: string;
5
+ method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
6
+ contentType: string;
7
+ }
8
+ const assert: (props: IProps) => {
9
+ param: (name: string) => <T>(task: () => T) => void;
10
+ query: <T_1>(task: () => T_1) => void;
11
+ body: <T_2>(task: () => T_2) => void;
12
+ };
13
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NestiaSimulator = void 0;
4
+ var HttpError_1 = require("./HttpError");
5
+ var NestiaSimulator;
6
+ (function (NestiaSimulator) {
7
+ NestiaSimulator.assert = function (props) {
8
+ return {
9
+ param: param(props),
10
+ query: query(props),
11
+ body: body(props),
12
+ };
13
+ };
14
+ var param = function (props) {
15
+ return function (name) {
16
+ return function (task) {
17
+ validate(function (exp) { return "URL parameter \"".concat(name, "\" is not ").concat(exp.expected, " type."); })(props)(task);
18
+ };
19
+ };
20
+ };
21
+ var query = function (props) {
22
+ return function (task) {
23
+ return validate(function () { return "Request query parameters are not following the promised type."; })(props)(task);
24
+ };
25
+ };
26
+ var body = function (props) {
27
+ return function (task) {
28
+ return validate(function () { return "Request body is not following the promised type."; })(props)(task);
29
+ };
30
+ };
31
+ var validate = function (message, path) {
32
+ return function (props) {
33
+ return function (task) {
34
+ try {
35
+ task();
36
+ }
37
+ catch (exp) {
38
+ if (isTypeGuardError(exp))
39
+ throw new HttpError_1.HttpError(props.method, props.host + props.path, 400, {
40
+ "Content-Type": props.contentType,
41
+ }, JSON.stringify({
42
+ method: exp.method,
43
+ path: path !== null && path !== void 0 ? path : exp.path,
44
+ expected: exp.expected,
45
+ value: exp.value,
46
+ message: message(exp),
47
+ }));
48
+ throw exp;
49
+ }
50
+ };
51
+ };
52
+ };
53
+ })(NestiaSimulator || (exports.NestiaSimulator = NestiaSimulator = {}));
54
+ var isTypeGuardError = function (input) {
55
+ return "string" === typeof input.method &&
56
+ (undefined === input.path || "string" === typeof input.path) &&
57
+ "string" === typeof input.expected &&
58
+ "string" === typeof input.name &&
59
+ "string" === typeof input.message &&
60
+ (undefined === input.stack || "string" === typeof input.stack);
61
+ };
62
+ //# sourceMappingURL=NestiaSimulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NestiaSimulator.js","sourceRoot":"","sources":["../src/NestiaSimulator.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAExC,IAAiB,eAAe,CA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KAAK,CAAC,WAAW;yBAClC,EACD,IAAI,CAAC,SAAS,CAAC;4BACb,MAAM,EAAE,GAAG,CAAC,MAAM;4BAClB,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,GAAG,CAAC,IAAI;4BACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;4BACtB,KAAK,EAAE,GAAG,CAAC,KAAK;4BAChB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;yBACtB,CAAC,CACH,CAAC;oBACJ,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;QAtBD,CAsBC;IAvBD,CAuBC,CAAC;AACN,CAAC,EAhEgB,eAAe,+BAAf,eAAe,QAgE/B;AAED,IAAM,gBAAgB,GAAG,UAAC,KAAU;IAClC,OAAA,QAAQ,KAAK,OAAO,KAAK,CAAC,MAAM;QAChC,CAAC,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI,CAAC;QAC5D,QAAQ,KAAK,OAAO,KAAK,CAAC,QAAQ;QAClC,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI;QAC9B,QAAQ,KAAK,OAAO,KAAK,CAAC,OAAO;QACjC,CAAC,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,KAAK,CAAC;AAL9D,CAK8D,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { IConnection } from "./IConnection";
2
+ import { IFetchRoute } from "./IFetchRoute";
2
3
  import { IPropagation } from "./IPropagation";
3
- import { Primitive } from "./Primitive";
4
- import { IFetchRoute } from "./internal/IFetchRoute";
5
4
  /**
6
5
  * Utility class for `fetch` functions used in `@nestia/sdk`.
7
6
  *
@@ -33,7 +32,7 @@ export declare namespace PlainFetcher {
33
32
  * @param route Route information about the target API
34
33
  * @return Response body data from the remote API
35
34
  */
36
- function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Primitive<Output>>;
35
+ function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Output>;
37
36
  /**
38
37
  * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
39
38
  *
@@ -41,7 +40,7 @@ export declare namespace PlainFetcher {
41
40
  * @param route Route information about the target API
42
41
  * @return Response body data from the remote API
43
42
  */
44
- function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Primitive<Output>>;
43
+ function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
45
44
  function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise<Output>;
46
45
  function propagate<Input, Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
47
46
  }
@@ -56,8 +56,8 @@ var FetcherBase_1 = require("./internal/FetcherBase");
56
56
  var PlainFetcher;
57
57
  (function (PlainFetcher) {
58
58
  function fetch(connection, route, input, stringify) {
59
- var _a, _b;
60
59
  return __awaiter(this, void 0, void 0, function () {
60
+ var _a, _b;
61
61
  return __generator(this, function (_c) {
62
62
  if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted) === true)
63
63
  throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
@@ -71,8 +71,8 @@ var PlainFetcher;
71
71
  }
72
72
  PlainFetcher.fetch = fetch;
73
73
  function propagate(connection, route, input, stringify) {
74
- var _a, _b;
75
74
  return __awaiter(this, void 0, void 0, function () {
75
+ var _a, _b;
76
76
  return __generator(this, function (_c) {
77
77
  if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted) === true)
78
78
  throw new Error("Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
@@ -1 +1 @@
1
- {"version":3,"file":"PlainFetcher.js","sourceRoot":"","sources":["../src/PlainFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sDAAqD;AAGrD;;;;;;;;;;;;;;GAcG;AACH,IAAiB,YAAY,CAoF5B;AApFD,WAAiB,YAAY;IAuC3B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;;gBAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;oBACzE,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;gBACJ,sBAAO,yBAAW,CAAC,KAAK,CAAC;wBACvB,SAAS,EAAE,cAAc;wBACzB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;wBACxB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;qBACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAC;;;KACzC;IAfqB,kBAAK,QAe1B,CAAA;IAcD,SAAsB,SAAS,CAC7B,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;;gBAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;oBACzE,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;gBACJ,sBAAO,yBAAW,CAAC,SAAS,CAAC;wBAC3B,SAAS,EAAE,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AAQ,0CAAE,SAAS,MAAK,IAAI;oBACzE,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;gBACJ,sBAAO,yBAAW,CAAC,SAAS,CAAC;wBAC3B,SAAS,EAAE,cAAc;wBACzB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;wBACxB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;qBACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,EAAC;;;KAC5D;IAfqB,sBAAS,YAe9B,CAAA;AACH,CAAC,EApFgB,YAAY,4BAAZ,YAAY,QAoF5B"}
package/lib/Resolved.d.ts CHANGED
@@ -22,23 +22,23 @@
22
22
  * `Class` | `interface`
23
23
  * Native Class or Others | No change
24
24
  *
25
- * @template Instance Target argument type.
25
+ * @template T Target argument type.
26
26
  * @author Jeongho Nam - https://github.com/samchon
27
27
  * @author Kyungsu Kang - https://github.com/kakasoo
28
28
  */
29
29
  export type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
30
30
  type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
31
- type ResolvedMain<Instance> = Instance extends [never] ? never : ValueOf<Instance> extends boolean | number | bigint | string ? ValueOf<Instance> : Instance extends Function ? never : Instance extends object ? ResolvedObject<Instance> : ValueOf<Instance>;
32
- type ResolvedObject<Instance extends object> = Instance extends Array<infer T> ? IsTuple<Instance> extends true ? ResolvedTuple<Instance> : ResolvedMain<T>[] : Instance extends Set<infer U> ? Set<ResolvedMain<U>> : Instance extends Map<infer K, infer V> ? Map<ResolvedMain<K>, ResolvedMain<V>> : Instance extends WeakSet<any> | WeakMap<any, any> ? never : Instance extends Date | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array | ArrayBuffer | SharedArrayBuffer | DataView ? Instance : {
33
- [P in keyof Instance]: ResolvedMain<Instance[P]>;
31
+ type ResolvedMain<T> = T extends [never] ? never : ValueOf<T> extends boolean | number | bigint | string ? ValueOf<T> : T extends Function ? never : T extends object ? ResolvedObject<T> : ValueOf<T>;
32
+ type ResolvedObject<T extends object> = T extends Array<infer U> ? IsTuple<T> extends true ? ResolvedTuple<T> : ResolvedMain<U>[] : T extends Set<infer U> ? Set<ResolvedMain<U>> : T extends Map<infer K, infer V> ? Map<ResolvedMain<K>, ResolvedMain<V>> : T extends WeakSet<any> | WeakMap<any, any> ? never : T extends Date | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array | ArrayBuffer | SharedArrayBuffer | DataView | Blob | File ? T : {
33
+ [P in keyof T]: ResolvedMain<T[P]>;
34
34
  };
35
35
  type ResolvedTuple<T extends readonly any[]> = T extends [] ? [] : T extends [infer F] ? [ResolvedMain<F>] : T extends [infer F, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>, ...ResolvedTuple<Rest>] : T extends [(infer F)?] ? [ResolvedMain<F>?] : T extends [(infer F)?, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>] : [];
36
- type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true ? boolean : IsValueOf<Instance, Number> extends true ? number : IsValueOf<Instance, String> extends true ? string : Instance;
37
36
  type IsTuple<T extends readonly any[] | {
38
37
  length: number;
39
38
  }> = [T] extends [
40
39
  never
41
40
  ] ? false : T extends readonly any[] ? number extends T["length"] ? false : true : false;
41
+ type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true ? boolean : IsValueOf<Instance, Number> extends true ? number : IsValueOf<Instance, String> extends true ? string : Instance;
42
42
  type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object ? Object extends IValueOf<infer Primitive> ? Instance extends Primitive ? false : true : false : false;
43
43
  interface IValueOf<T> {
44
44
  valueOf(): T;
package/lib/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
+ export * from "./HttpError";
1
2
  export * from "./IConnection";
2
3
  export * from "./IEncryptionPassword";
4
+ export * from "./IFetchEvent";
5
+ export * from "./IFetchRoute";
3
6
  export * from "./IPropagation";
4
7
  export * from "./IRandomGenerator";
5
- export * from "./HttpError";
6
8
  export * from "./Primitive";
7
9
  export * from "./Resolved";
package/lib/index.js CHANGED
@@ -14,11 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./HttpError"), exports);
17
18
  __exportStar(require("./IConnection"), exports);
18
19
  __exportStar(require("./IEncryptionPassword"), exports);
20
+ __exportStar(require("./IFetchEvent"), exports);
21
+ __exportStar(require("./IFetchRoute"), exports);
19
22
  __exportStar(require("./IPropagation"), exports);
20
23
  __exportStar(require("./IRandomGenerator"), exports);
21
- __exportStar(require("./HttpError"), exports);
22
24
  __exportStar(require("./Primitive"), exports);
23
25
  __exportStar(require("./Resolved"), exports);
24
26
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wDAAsC;AACtC,iDAA+B;AAC/B,qDAAmC;AACnC,8CAA4B;AAC5B,8CAA4B;AAC5B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAC/B,qDAAmC;AACnC,8CAA4B;AAC5B,6CAA2B"}
@@ -1,13 +1,12 @@
1
1
  import { IConnection } from "../IConnection";
2
+ import { IFetchRoute } from "../IFetchRoute";
2
3
  import { IPropagation } from "../IPropagation";
3
- import { Primitive } from "../Primitive";
4
- import { IFetchRoute } from "./IFetchRoute";
5
4
  export declare namespace FetcherBase {
6
5
  interface IProps {
7
6
  className: string;
8
- encode: (input: any, headers: Record<string, IConnection.HeaderValue | undefined>) => string | Uint8Array;
9
- decode: (input: string | Uint8Array, headers: Record<string, IConnection.HeaderValue | undefined>) => any;
7
+ encode: (input: any, headers: Record<string, IConnection.HeaderValue | undefined>) => string;
8
+ decode: (input: string, headers: Record<string, IConnection.HeaderValue | undefined>) => any;
10
9
  }
11
- const fetch: (props: IProps) => <Input, Output>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input | undefined, stringify?: ((input: Input) => string) | undefined) => Promise<Primitive<Output>>;
12
- const propagate: (props: IProps) => <Input>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input | undefined, stringify?: ((input: Input) => string) | undefined) => Promise<IPropagation<any, any>>;
10
+ const fetch: (props: IProps) => <Input, Output>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string) => Promise<Output>;
11
+ const propagate: (props: IProps) => <Input>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string) => Promise<IPropagation<any, any>>;
13
12
  }