@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.
- package/LICENSE +21 -0
- package/README.md +93 -93
- package/package.json +20 -13
- package/src/AesPkcs5.ts +41 -49
- package/src/EncryptedFetcher.ts +176 -176
- package/src/FormDataInput.ts +80 -80
- package/src/HttpError.ts +1 -1
- package/src/IConnection.ts +241 -241
- package/src/IEncryptionPassword.ts +44 -44
- package/src/IFetchEvent.ts +31 -31
- package/src/IFetchRoute.ts +60 -60
- package/src/IPropagation.ts +99 -99
- package/src/NestiaSimulator.ts +82 -82
- package/src/PlainFetcher.ts +105 -105
- package/src/index.ts +12 -7
- package/src/internal/FetcherBase.ts +235 -235
- package/lib/AesPkcs5.d.ts +0 -30
- package/lib/AesPkcs5.js +0 -49
- package/lib/AesPkcs5.js.map +0 -1
- package/lib/EncryptedFetcher.d.ts +0 -47
- package/lib/EncryptedFetcher.js +0 -139
- package/lib/EncryptedFetcher.js.map +0 -1
- package/lib/FormDataInput.d.ts +0 -70
- package/lib/FormDataInput.js +0 -3
- package/lib/FormDataInput.js.map +0 -1
- package/lib/HttpError.d.ts +0 -1
- package/lib/HttpError.js +0 -6
- package/lib/HttpError.js.map +0 -1
- package/lib/IConnection.d.ts +0 -165
- package/lib/IConnection.js +0 -3
- package/lib/IConnection.js.map +0 -1
- package/lib/IEncryptionPassword.d.ts +0 -41
- package/lib/IEncryptionPassword.js +0 -3
- package/lib/IEncryptionPassword.js.map +0 -1
- package/lib/IFetchEvent.d.ts +0 -11
- package/lib/IFetchEvent.js +0 -21
- package/lib/IFetchEvent.js.map +0 -1
- package/lib/IFetchRoute.d.ts +0 -46
- package/lib/IFetchRoute.js +0 -3
- package/lib/IFetchRoute.js.map +0 -1
- package/lib/IPropagation.d.ts +0 -69
- package/lib/IPropagation.js +0 -3
- package/lib/IPropagation.js.map +0 -1
- package/lib/MigrateFetcher.d.ts +0 -19
- package/lib/MigrateFetcher.js +0 -179
- package/lib/MigrateFetcher.js.map +0 -1
- package/lib/NestiaSimulator.d.ts +0 -13
- package/lib/NestiaSimulator.js +0 -62
- package/lib/NestiaSimulator.js.map +0 -1
- package/lib/PlainFetcher.d.ts +0 -46
- package/lib/PlainFetcher.js +0 -89
- package/lib/PlainFetcher.js.map +0 -1
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -24
- package/lib/index.js.map +0 -1
- package/lib/internal/FetcherBase.d.ts +0 -1
- package/lib/internal/FetcherBase.js +0 -348
- package/lib/internal/FetcherBase.js.map +0 -1
- package/src/MigrateFetcher.ts +0 -118
package/src/PlainFetcher.ts
CHANGED
|
@@ -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 "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
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";
|