@nestia/fetcher 10.0.2 → 11.0.0-dev.20260305

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -93
  3. package/package.json +20 -13
  4. package/src/AesPkcs5.ts +41 -49
  5. package/src/EncryptedFetcher.ts +176 -176
  6. package/src/FormDataInput.ts +80 -80
  7. package/src/HttpError.ts +1 -1
  8. package/src/IConnection.ts +241 -241
  9. package/src/IEncryptionPassword.ts +44 -44
  10. package/src/IFetchEvent.ts +31 -31
  11. package/src/IFetchRoute.ts +60 -60
  12. package/src/IPropagation.ts +99 -99
  13. package/src/NestiaSimulator.ts +82 -82
  14. package/src/PlainFetcher.ts +105 -105
  15. package/src/index.ts +12 -7
  16. package/src/internal/FetcherBase.ts +235 -235
  17. package/lib/AesPkcs5.d.ts +0 -30
  18. package/lib/AesPkcs5.js +0 -49
  19. package/lib/AesPkcs5.js.map +0 -1
  20. package/lib/EncryptedFetcher.d.ts +0 -47
  21. package/lib/EncryptedFetcher.js +0 -139
  22. package/lib/EncryptedFetcher.js.map +0 -1
  23. package/lib/FormDataInput.d.ts +0 -70
  24. package/lib/FormDataInput.js +0 -3
  25. package/lib/FormDataInput.js.map +0 -1
  26. package/lib/HttpError.d.ts +0 -1
  27. package/lib/HttpError.js +0 -6
  28. package/lib/HttpError.js.map +0 -1
  29. package/lib/IConnection.d.ts +0 -165
  30. package/lib/IConnection.js +0 -3
  31. package/lib/IConnection.js.map +0 -1
  32. package/lib/IEncryptionPassword.d.ts +0 -41
  33. package/lib/IEncryptionPassword.js +0 -3
  34. package/lib/IEncryptionPassword.js.map +0 -1
  35. package/lib/IFetchEvent.d.ts +0 -11
  36. package/lib/IFetchEvent.js +0 -21
  37. package/lib/IFetchEvent.js.map +0 -1
  38. package/lib/IFetchRoute.d.ts +0 -46
  39. package/lib/IFetchRoute.js +0 -3
  40. package/lib/IFetchRoute.js.map +0 -1
  41. package/lib/IPropagation.d.ts +0 -69
  42. package/lib/IPropagation.js +0 -3
  43. package/lib/IPropagation.js.map +0 -1
  44. package/lib/MigrateFetcher.d.ts +0 -19
  45. package/lib/MigrateFetcher.js +0 -179
  46. package/lib/MigrateFetcher.js.map +0 -1
  47. package/lib/NestiaSimulator.d.ts +0 -13
  48. package/lib/NestiaSimulator.js +0 -62
  49. package/lib/NestiaSimulator.js.map +0 -1
  50. package/lib/PlainFetcher.d.ts +0 -46
  51. package/lib/PlainFetcher.js +0 -89
  52. package/lib/PlainFetcher.js.map +0 -1
  53. package/lib/index.d.ts +0 -7
  54. package/lib/index.js +0 -24
  55. package/lib/index.js.map +0 -1
  56. package/lib/internal/FetcherBase.d.ts +0 -1
  57. package/lib/internal/FetcherBase.js +0 -348
  58. package/lib/internal/FetcherBase.js.map +0 -1
  59. package/src/MigrateFetcher.ts +0 -118
@@ -1,105 +1,105 @@
1
- import { IConnection } from "./IConnection";
2
- import { IFetchRoute } from "./IFetchRoute";
3
- import { IPropagation } from "./IPropagation";
4
- import { FetcherBase } from "./internal/FetcherBase";
5
-
6
- /**
7
- * Utility class for `fetch` functions used in `@nestia/sdk`.
8
- *
9
- * `PlainFetcher` is a utility class designed for SDK functions generated by
10
- * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
11
- * HTTP sever API. In other words, this is a collection of dedicated `fetch()`
12
- * functions for `@nestia/sdk`.
13
- *
14
- * For reference, `PlainFetcher` class does not encrypt or decrypt the body data
15
- * at all. It just delivers plain data without any post processing. If you've
16
- * defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
17
- * decorator, then {@liink EncryptedFetcher} class would be used instead.
18
- *
19
- * @author Jeongho Nam - https://github.com/samchon
20
- */
21
- export namespace PlainFetcher {
22
- /**
23
- * Fetch function only for `HEAD` method.
24
- *
25
- * @param connection Connection information for the remote HTTP server
26
- * @param route Route information about the target API
27
- * @returns Nothing because of `HEAD` method
28
- */
29
- export function fetch(
30
- connection: IConnection,
31
- route: IFetchRoute<"HEAD">,
32
- ): Promise<void>;
33
-
34
- /**
35
- * Fetch function only for `GET` method.
36
- *
37
- * @param connection Connection information for the remote HTTP server
38
- * @param route Route information about the target API
39
- * @returns Response body data from the remote API
40
- */
41
- export function fetch<Output>(
42
- connection: IConnection,
43
- route: IFetchRoute<"GET">,
44
- ): Promise<Output>;
45
-
46
- /**
47
- * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
48
- *
49
- * @param connection Connection information for the remote HTTP server
50
- * @param route Route information about the target API
51
- * @returns Response body data from the remote API
52
- */
53
- export function fetch<Input, Output>(
54
- connection: IConnection,
55
- route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">,
56
- input?: Input,
57
- stringify?: (input: Input) => string,
58
- ): Promise<Output>;
59
-
60
- export async function fetch<Input, Output>(
61
- connection: IConnection,
62
- route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
63
- input?: Input,
64
- stringify?: (input: Input) => string,
65
- ): Promise<Output> {
66
- if (route.request?.encrypted === true || route.response?.encrypted === true)
67
- throw new Error(
68
- "Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.",
69
- );
70
- return FetcherBase.request({
71
- className: "PlainFetcher",
72
- encode: (input) => input,
73
- decode: (input) => input,
74
- })(connection, route, input, stringify);
75
- }
76
-
77
- export function propagate<Output extends IPropagation<any, any>>(
78
- connection: IConnection,
79
- route: IFetchRoute<"GET" | "HEAD">,
80
- ): Promise<Output>;
81
-
82
- export function propagate<Input, Output extends IPropagation<any, any>>(
83
- connection: IConnection,
84
- route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
85
- input?: Input,
86
- stringify?: (input: Input) => string,
87
- ): Promise<Output>;
88
-
89
- export async function propagate<Input, Output extends IPropagation<any, any>>(
90
- connection: IConnection,
91
- route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
92
- input?: Input,
93
- stringify?: (input: Input) => string,
94
- ): Promise<Output> {
95
- if (route.request?.encrypted === true || route.response?.encrypted === true)
96
- throw new Error(
97
- "Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.",
98
- );
99
- return FetcherBase.propagate({
100
- className: "PlainFetcher",
101
- encode: (input) => input,
102
- decode: (input) => input,
103
- })(connection, route, input, stringify) as Promise<Output>;
104
- }
105
- }
1
+ import { IConnection } from "./IConnection";
2
+ import { IFetchRoute } from "./IFetchRoute";
3
+ import { IPropagation } from "./IPropagation";
4
+ import { FetcherBase } from "./internal/FetcherBase";
5
+
6
+ /**
7
+ * Utility class for `fetch` functions used in `@nestia/sdk`.
8
+ *
9
+ * `PlainFetcher` is a utility class designed for SDK functions generated by
10
+ * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
11
+ * HTTP sever API. In other words, this is a collection of dedicated `fetch()`
12
+ * functions for `@nestia/sdk`.
13
+ *
14
+ * For reference, `PlainFetcher` class does not encrypt or decrypt the body data
15
+ * at all. It just delivers plain data without any post processing. If you've
16
+ * defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
17
+ * decorator, then {@liink EncryptedFetcher} class would be used instead.
18
+ *
19
+ * @author Jeongho Nam - https://github.com/samchon
20
+ */
21
+ export namespace PlainFetcher {
22
+ /**
23
+ * Fetch function only for `HEAD` method.
24
+ *
25
+ * @param connection Connection information for the remote HTTP server
26
+ * @param route Route information about the target API
27
+ * @returns Nothing because of `HEAD` method
28
+ */
29
+ export function fetch(
30
+ connection: IConnection,
31
+ route: IFetchRoute<"HEAD">,
32
+ ): Promise<void>;
33
+
34
+ /**
35
+ * Fetch function only for `GET` method.
36
+ *
37
+ * @param connection Connection information for the remote HTTP server
38
+ * @param route Route information about the target API
39
+ * @returns Response body data from the remote API
40
+ */
41
+ export function fetch<Output>(
42
+ connection: IConnection,
43
+ route: IFetchRoute<"GET">,
44
+ ): Promise<Output>;
45
+
46
+ /**
47
+ * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
48
+ *
49
+ * @param connection Connection information for the remote HTTP server
50
+ * @param route Route information about the target API
51
+ * @returns Response body data from the remote API
52
+ */
53
+ export function fetch<Input, Output>(
54
+ connection: IConnection,
55
+ route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">,
56
+ input?: Input,
57
+ stringify?: (input: Input) => string,
58
+ ): Promise<Output>;
59
+
60
+ export async function fetch<Input, Output>(
61
+ connection: IConnection,
62
+ route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
63
+ input?: Input,
64
+ stringify?: (input: Input) => string,
65
+ ): Promise<Output> {
66
+ if (route.request?.encrypted === true || route.response?.encrypted === true)
67
+ throw new Error(
68
+ "Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.",
69
+ );
70
+ return FetcherBase.request({
71
+ className: "PlainFetcher",
72
+ encode: (input) => input,
73
+ decode: (input) => input,
74
+ })(connection, route, input, stringify);
75
+ }
76
+
77
+ export function propagate<Output extends IPropagation<any, any>>(
78
+ connection: IConnection,
79
+ route: IFetchRoute<"GET" | "HEAD">,
80
+ ): Promise<Output>;
81
+
82
+ export function propagate<Input, Output extends IPropagation<any, any>>(
83
+ connection: IConnection,
84
+ route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
85
+ input?: Input,
86
+ stringify?: (input: Input) => string,
87
+ ): Promise<Output>;
88
+
89
+ export async function propagate<Input, Output extends IPropagation<any, any>>(
90
+ connection: IConnection,
91
+ route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">,
92
+ input?: Input,
93
+ stringify?: (input: Input) => string,
94
+ ): Promise<Output> {
95
+ if (route.request?.encrypted === true || route.response?.encrypted === true)
96
+ throw new Error(
97
+ "Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.",
98
+ );
99
+ return FetcherBase.propagate({
100
+ className: "PlainFetcher",
101
+ encode: (input) => input,
102
+ decode: (input) => input,
103
+ })(connection, route, input, stringify) as Promise<Output>;
104
+ }
105
+ }
package/src/index.ts CHANGED
@@ -1,7 +1,12 @@
1
- export * from "./FormDataInput";
2
- export * from "./HttpError";
3
- export * from "./IConnection";
4
- export * from "./IEncryptionPassword";
5
- export * from "./IFetchEvent";
6
- export * from "./IFetchRoute";
7
- export * from "./IPropagation";
1
+ export * from "./AesPkcs5";
2
+ export * from "./EncryptedFetcher";
3
+ export * from "./FormDataInput";
4
+ export * from "./HttpError";
5
+ export * from "./IConnection";
6
+ export * from "./IEncryptionPassword";
7
+ export * from "./IFetchEvent";
8
+ export * from "./IFetchRoute";
9
+ export * from "./IPropagation";
10
+
11
+ export * from "./NestiaSimulator";
12
+ export * from "./PlainFetcher";