@nestia/fetcher 11.0.0-dev.20260313 → 11.0.0-dev.20260313-3
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/lib/AesPkcs5.d.ts +30 -0
- package/lib/AesPkcs5.js +49 -0
- package/lib/AesPkcs5.js.map +1 -0
- package/lib/EncryptedFetcher.d.ts +47 -0
- package/lib/EncryptedFetcher.js +98 -0
- package/lib/EncryptedFetcher.js.map +1 -0
- package/lib/FormDataInput.d.ts +70 -0
- package/lib/FormDataInput.js +3 -0
- package/lib/FormDataInput.js.map +1 -0
- package/lib/HttpError.d.ts +1 -0
- package/lib/HttpError.js +6 -0
- package/lib/HttpError.js.map +1 -0
- package/lib/IConnection.d.ts +165 -0
- package/lib/IConnection.js +3 -0
- package/lib/IConnection.js.map +1 -0
- package/lib/IEncryptionPassword.d.ts +41 -0
- package/lib/IEncryptionPassword.js +3 -0
- package/lib/IEncryptionPassword.js.map +1 -0
- package/lib/IFetchEvent.d.ts +11 -0
- package/lib/IFetchEvent.js +21 -0
- package/lib/IFetchEvent.js.map +1 -0
- package/lib/IFetchRoute.d.ts +46 -0
- package/lib/IFetchRoute.js +3 -0
- package/lib/IFetchRoute.js.map +1 -0
- package/lib/IPropagation.d.ts +69 -0
- package/lib/IPropagation.js +3 -0
- package/lib/IPropagation.js.map +1 -0
- package/lib/NestiaSimulator.d.ts +13 -0
- package/lib/NestiaSimulator.js +44 -0
- package/lib/NestiaSimulator.js.map +1 -0
- package/lib/PlainFetcher.d.ts +46 -0
- package/lib/PlainFetcher.js +58 -0
- package/lib/PlainFetcher.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/FetcherBase.d.ts +1 -0
- package/lib/internal/FetcherBase.js +185 -0
- package/lib/internal/FetcherBase.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for the AES-128/256 encryption.
|
|
3
|
+
*
|
|
4
|
+
* - AES-128/256
|
|
5
|
+
* - CBC mode
|
|
6
|
+
* - PKCS#5 Padding
|
|
7
|
+
* - Base64 Encoding
|
|
8
|
+
*
|
|
9
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
+
*/
|
|
11
|
+
export declare namespace AesPkcs5 {
|
|
12
|
+
/**
|
|
13
|
+
* Encrypt data
|
|
14
|
+
*
|
|
15
|
+
* @param data Target data
|
|
16
|
+
* @param key Key value of the encryption.
|
|
17
|
+
* @param iv Initializer Vector for the encryption
|
|
18
|
+
* @returns Encrypted data
|
|
19
|
+
*/
|
|
20
|
+
function encrypt(data: string, key: string, iv: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Decrypt data.
|
|
23
|
+
*
|
|
24
|
+
* @param data Target data
|
|
25
|
+
* @param key Key value of the decryption.
|
|
26
|
+
* @param iv Initializer Vector for the decryption
|
|
27
|
+
* @returns Decrypted data.
|
|
28
|
+
*/
|
|
29
|
+
function decrypt(data: string, key: string, iv: string): string;
|
|
30
|
+
}
|
package/lib/AesPkcs5.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AesPkcs5 = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
/**
|
|
9
|
+
* Utility class for the AES-128/256 encryption.
|
|
10
|
+
*
|
|
11
|
+
* - AES-128/256
|
|
12
|
+
* - CBC mode
|
|
13
|
+
* - PKCS#5 Padding
|
|
14
|
+
* - Base64 Encoding
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
*/
|
|
18
|
+
var AesPkcs5;
|
|
19
|
+
(function (AesPkcs5) {
|
|
20
|
+
/**
|
|
21
|
+
* Encrypt data
|
|
22
|
+
*
|
|
23
|
+
* @param data Target data
|
|
24
|
+
* @param key Key value of the encryption.
|
|
25
|
+
* @param iv Initializer Vector for the encryption
|
|
26
|
+
* @returns Encrypted data
|
|
27
|
+
*/
|
|
28
|
+
function encrypt(data, key, iv) {
|
|
29
|
+
const bytes = key.length * 8;
|
|
30
|
+
const cipher = crypto_1.default.createCipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
31
|
+
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
32
|
+
}
|
|
33
|
+
AesPkcs5.encrypt = encrypt;
|
|
34
|
+
/**
|
|
35
|
+
* Decrypt data.
|
|
36
|
+
*
|
|
37
|
+
* @param data Target data
|
|
38
|
+
* @param key Key value of the decryption.
|
|
39
|
+
* @param iv Initializer Vector for the decryption
|
|
40
|
+
* @returns Decrypted data.
|
|
41
|
+
*/
|
|
42
|
+
function decrypt(data, key, iv) {
|
|
43
|
+
const bytes = key.length * 8;
|
|
44
|
+
const decipher = crypto_1.default.createDecipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
45
|
+
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
46
|
+
}
|
|
47
|
+
AesPkcs5.decrypt = decrypt;
|
|
48
|
+
})(AesPkcs5 || (exports.AesPkcs5 = AesPkcs5 = {}));
|
|
49
|
+
//# sourceMappingURL=AesPkcs5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CA4BxB;AA5BD,WAAiB,QAAQ;IACvB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,gBAAM,CAAC,cAAc,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAJe,gBAAO,UAItB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,gBAAM,CAAC,gBAAgB,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAJe,gBAAO,UAItB,CAAA;AACH,CAAC,EA5BgB,QAAQ,wBAAR,QAAQ,QA4BxB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
+
import { IPropagation } from "./IPropagation";
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
6
|
+
*
|
|
7
|
+
* `EncryptedFetcher` is a utility class designed for SDK functions generated by
|
|
8
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
9
|
+
* HTTP API encrypted by AES-PKCS algorithm. In other words, this is a
|
|
10
|
+
* collection of dedicated `fetch()` functions for `@nestia/sdk` with
|
|
11
|
+
* encryption.
|
|
12
|
+
*
|
|
13
|
+
* For reference, `EncryptedFetcher` class being used only when target
|
|
14
|
+
* controller method is encrypting body data by `@EncryptedRoute` or
|
|
15
|
+
* `@EncryptedBody` decorators. If those decorators are not used,
|
|
16
|
+
* {@link PlainFetcher} class would be used instead.
|
|
17
|
+
*
|
|
18
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
19
|
+
*/
|
|
20
|
+
export declare namespace EncryptedFetcher {
|
|
21
|
+
/**
|
|
22
|
+
* Fetch function only for `HEAD` method.
|
|
23
|
+
*
|
|
24
|
+
* @param connection Connection information for the remote HTTP server
|
|
25
|
+
* @param route Route information about the target API
|
|
26
|
+
* @returns Nothing because of `HEAD` method
|
|
27
|
+
*/
|
|
28
|
+
function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetch function only for `GET` method.
|
|
31
|
+
*
|
|
32
|
+
* @param connection Connection information for the remote HTTP server
|
|
33
|
+
* @param route Route information about the target API
|
|
34
|
+
* @returns Response body data from the remote API
|
|
35
|
+
*/
|
|
36
|
+
function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Output>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
|
|
39
|
+
*
|
|
40
|
+
* @param connection Connection information for the remote HTTP server
|
|
41
|
+
* @param route Route information about the target API
|
|
42
|
+
* @returns Response body data from the remote API
|
|
43
|
+
*/
|
|
44
|
+
function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
|
|
45
|
+
function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise<Output>;
|
|
46
|
+
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
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EncryptedFetcher = void 0;
|
|
13
|
+
const AesPkcs5_1 = require("./AesPkcs5");
|
|
14
|
+
const FetcherBase_1 = require("./internal/FetcherBase");
|
|
15
|
+
/**
|
|
16
|
+
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
17
|
+
*
|
|
18
|
+
* `EncryptedFetcher` is a utility class designed for SDK functions generated by
|
|
19
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
20
|
+
* HTTP API encrypted by AES-PKCS algorithm. In other words, this is a
|
|
21
|
+
* collection of dedicated `fetch()` functions for `@nestia/sdk` with
|
|
22
|
+
* encryption.
|
|
23
|
+
*
|
|
24
|
+
* For reference, `EncryptedFetcher` class being used only when target
|
|
25
|
+
* controller method is encrypting body data by `@EncryptedRoute` or
|
|
26
|
+
* `@EncryptedBody` decorators. If those decorators are not used,
|
|
27
|
+
* {@link PlainFetcher} class would be used instead.
|
|
28
|
+
*
|
|
29
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
30
|
+
*/
|
|
31
|
+
var EncryptedFetcher;
|
|
32
|
+
(function (EncryptedFetcher) {
|
|
33
|
+
function fetch(connection, route, input, stringify) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
37
|
+
connection.encryption === undefined)
|
|
38
|
+
throw new Error("Error on EncryptedFetcher.fetch(): the encryption password has not been configured.");
|
|
39
|
+
const closure = typeof connection.encryption === "function"
|
|
40
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
41
|
+
headers,
|
|
42
|
+
body,
|
|
43
|
+
direction,
|
|
44
|
+
})
|
|
45
|
+
: () => () => connection.encryption;
|
|
46
|
+
return FetcherBase_1.FetcherBase.request({
|
|
47
|
+
className: "EncryptedFetcher",
|
|
48
|
+
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
49
|
+
? (input, headers) => {
|
|
50
|
+
const p = closure("encode")(headers, input);
|
|
51
|
+
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
52
|
+
}
|
|
53
|
+
: (input) => input,
|
|
54
|
+
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
55
|
+
? (input, headers) => {
|
|
56
|
+
const p = closure("decode")(headers, input);
|
|
57
|
+
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
58
|
+
return s.length ? JSON.parse(s) : s;
|
|
59
|
+
}
|
|
60
|
+
: (input) => input,
|
|
61
|
+
})(connection, route, input, stringify);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
EncryptedFetcher.fetch = fetch;
|
|
65
|
+
function propagate(connection, route, input, stringify) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
69
|
+
connection.encryption === undefined)
|
|
70
|
+
throw new Error("Error on EncryptedFetcher.propagate(): the encryption password has not been configured.");
|
|
71
|
+
const closure = typeof connection.encryption === "function"
|
|
72
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
73
|
+
headers,
|
|
74
|
+
body,
|
|
75
|
+
direction,
|
|
76
|
+
})
|
|
77
|
+
: () => () => connection.encryption;
|
|
78
|
+
return FetcherBase_1.FetcherBase.propagate({
|
|
79
|
+
className: "EncryptedFetcher",
|
|
80
|
+
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
81
|
+
? (input, headers) => {
|
|
82
|
+
const p = closure("encode")(headers, input);
|
|
83
|
+
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
84
|
+
}
|
|
85
|
+
: (input) => input,
|
|
86
|
+
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
87
|
+
? (input, headers) => {
|
|
88
|
+
const p = closure("decode")(headers, input);
|
|
89
|
+
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
90
|
+
return s.length ? JSON.parse(s) : s;
|
|
91
|
+
}
|
|
92
|
+
: (input) => input,
|
|
93
|
+
})(connection, route, input, stringify);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
EncryptedFetcher.propagate = propagate;
|
|
97
|
+
})(EncryptedFetcher || (exports.EncryptedFetcher = EncryptedFetcher = {}));
|
|
98
|
+
//# sourceMappingURL=EncryptedFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptedFetcher.js","sourceRoot":"","sources":["../src/EncryptedFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AAKtC,wDAAqD;AAErD;;;;;;;;;;;;;;;GAeG;AACH,IAAiB,gBAAgB,CAwJhC;AAxJ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|
3
|
+
*
|
|
4
|
+
* `FormDataInput<T>` is a type for the input of the `FormData` request, casting
|
|
5
|
+
* `File` property value type as an union of `File` and
|
|
6
|
+
* {@link FormDataInput.IFileProps}, especially for the React Native
|
|
7
|
+
* environment.
|
|
8
|
+
*
|
|
9
|
+
* You know what? In the React Native environment, `File` class is not
|
|
10
|
+
* supported. Therefore, when composing a `FormData` request, you have to put
|
|
11
|
+
* the URI address of the local filesystem with file name and content type that
|
|
12
|
+
* is represented by the {@link FormDataInput.IFileProps} type.
|
|
13
|
+
*
|
|
14
|
+
* This `FormDataInput<T>` type is designed for that purpose. If the property
|
|
15
|
+
* value type is a `File` class, it converts it to an union type of `File` and
|
|
16
|
+
* {@link FormDataInput.IFileProps} type. Also, if the property value type is an
|
|
17
|
+
* array of `File` class, it converts it to an array of union type of `File` and
|
|
18
|
+
* {@link FormDataInput.IFileProps} type too.
|
|
19
|
+
*
|
|
20
|
+
* Before | After ----------|------------------------ `boolean` | `boolean`
|
|
21
|
+
* `bigint` | `bigint` `number` | `number` `string` | `string` `File` | `File \|
|
|
22
|
+
* IFileProps`
|
|
23
|
+
*
|
|
24
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
25
|
+
* @template T Target object type.
|
|
26
|
+
*/
|
|
27
|
+
export type FormDataInput<T extends object> = T extends Array<any> ? never : T extends Function ? never : {
|
|
28
|
+
[P in keyof T]: T[P] extends Array<infer U> ? FormDataInput.Value<U>[] : FormDataInput.Value<T[P]>;
|
|
29
|
+
};
|
|
30
|
+
export declare namespace FormDataInput {
|
|
31
|
+
/**
|
|
32
|
+
* Value type of the `FormDataInput`.
|
|
33
|
+
*
|
|
34
|
+
* `Value<T>` is a type for the property value defined in the `FormDataInput`.
|
|
35
|
+
*
|
|
36
|
+
* If the original value type is a `File` class, `Value<T>` converts it to an
|
|
37
|
+
* union type of `File` and {@link IFileProps} type which is a structured data
|
|
38
|
+
* for the URI file location in the React Native environment.
|
|
39
|
+
*/
|
|
40
|
+
type Value<T> = T extends File ? T | IFileProps : T;
|
|
41
|
+
/**
|
|
42
|
+
* Properties of a file.
|
|
43
|
+
*
|
|
44
|
+
* In the React Native, this `IFileProps` structured data can replace the
|
|
45
|
+
* `File` class instance in the `FormData` request.
|
|
46
|
+
*
|
|
47
|
+
* Just put the {@link uri URI address} of the local file system with the
|
|
48
|
+
* file's {@link name} and {@link type}. It would be casted to the `File` class
|
|
49
|
+
* instance automatically in the `FormData` request.
|
|
50
|
+
*
|
|
51
|
+
* Note that, this `IFileProps` type works only in the React Native
|
|
52
|
+
* environment. If you are developing a Web or NodeJS application, you have to
|
|
53
|
+
* utilize the `File` class instance directly.
|
|
54
|
+
*/
|
|
55
|
+
interface IFileProps {
|
|
56
|
+
/**
|
|
57
|
+
* URI address of the file.
|
|
58
|
+
*
|
|
59
|
+
* In the React Native, the URI address in the local file system can replace
|
|
60
|
+
* the `File` class instance. If
|
|
61
|
+
*
|
|
62
|
+
* @format uri
|
|
63
|
+
*/
|
|
64
|
+
uri: string;
|
|
65
|
+
/** Name of the file. */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Content type of the file. */
|
|
68
|
+
type: string;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDataInput.js","sourceRoot":"","sources":["../src/FormDataInput.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HttpError } from "@typia/utils";
|
package/lib/HttpError.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpError = void 0;
|
|
4
|
+
var utils_1 = require("@typia/utils");
|
|
5
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return utils_1.HttpError; } });
|
|
6
|
+
//# sourceMappingURL=HttpError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAAhC,kGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { IEncryptionPassword } from "./IEncryptionPassword";
|
|
2
|
+
import { IFetchEvent } from "./IFetchEvent";
|
|
3
|
+
/**
|
|
4
|
+
* Connection information.
|
|
5
|
+
*
|
|
6
|
+
* `IConnection` is an interface ttype who represents connection information of
|
|
7
|
+
* the remote HTTP server. You can target the remote HTTP server by wring the
|
|
8
|
+
* {@link IConnection.host} variable down. Also, you can configure special header
|
|
9
|
+
* values by specializing the {@link IConnection.headers} variable.
|
|
10
|
+
*
|
|
11
|
+
* If the remote HTTP server encrypts or decrypts its body data through the
|
|
12
|
+
* AES-128/256 algorithm, specify the {@link IConnection.encryption} with
|
|
13
|
+
* {@link IEncryptionPassword} or {@link IEncryptionPassword.Closure} variable.
|
|
14
|
+
*
|
|
15
|
+
* @author Jenogho Nam - https://github.com/samchon
|
|
16
|
+
* @author Seungjun We - https://github.com/SeungjunWe
|
|
17
|
+
*/
|
|
18
|
+
export interface IConnection<Headers extends object | undefined = object | undefined> {
|
|
19
|
+
/** Host address of the remote HTTP server. */
|
|
20
|
+
host: string;
|
|
21
|
+
/** Header values delivered to the remote HTTP server. */
|
|
22
|
+
headers?: Record<string, IConnection.HeaderValue> & IConnection.Headerify<Headers>;
|
|
23
|
+
/**
|
|
24
|
+
* Use simulation mode.
|
|
25
|
+
*
|
|
26
|
+
* If you configure this property to be `true`, your SDK library does not send
|
|
27
|
+
* any request to remote backend server, but just returns random data
|
|
28
|
+
* generated by `typia.random<T>()` function with request data validation.
|
|
29
|
+
*
|
|
30
|
+
* By the way, to utilize this simulation mode, SDK library must be generated
|
|
31
|
+
* with {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts`
|
|
32
|
+
* file, and configure {@link INestiaConfig.simulate} property to be `true`.
|
|
33
|
+
* Them, newly generated SDK library would have a built-in mock-up data
|
|
34
|
+
* generator.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
simulate?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Logger function.
|
|
41
|
+
*
|
|
42
|
+
* This function is called when the fetch event is completed.
|
|
43
|
+
*
|
|
44
|
+
* @param event Event information of the fetch event.
|
|
45
|
+
*/
|
|
46
|
+
logger?: (event: IFetchEvent) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Encryption password of its closure function.
|
|
49
|
+
*
|
|
50
|
+
* Define it only when target backend server is encrypting body data through
|
|
51
|
+
* `@EncryptedRoute` or `@EncryptedBody` decorators of `@nestia/core` for
|
|
52
|
+
* security reason.
|
|
53
|
+
*/
|
|
54
|
+
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
55
|
+
/** Additional options for the `fetch` function. */
|
|
56
|
+
options?: IConnection.IOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Custom fetch function.
|
|
59
|
+
*
|
|
60
|
+
* If you want to use custom `fetch` function instead of built-in, assign your
|
|
61
|
+
* custom `fetch` function into this property.
|
|
62
|
+
*
|
|
63
|
+
* For reference, the `fetch` function has started to be supported since
|
|
64
|
+
* version 20 of NodeJS. Therefore, if you are using NodeJS version 19 or
|
|
65
|
+
* lower, you have to assign the `node-fetch` module into this property.
|
|
66
|
+
*/
|
|
67
|
+
fetch?: typeof fetch;
|
|
68
|
+
}
|
|
69
|
+
export declare namespace IConnection {
|
|
70
|
+
/**
|
|
71
|
+
* Additional options for the `fetch` function.
|
|
72
|
+
*
|
|
73
|
+
* Almost same with {@link RequestInit} type of the {@link fetch} function, but
|
|
74
|
+
* `body`, `headers` and `method` properties are omitted.
|
|
75
|
+
*
|
|
76
|
+
* The reason why defining duplicated definition of {@link RequestInit} is for
|
|
77
|
+
* legacy NodeJS environments, which does not have the {@link fetch} function
|
|
78
|
+
* type.
|
|
79
|
+
*/
|
|
80
|
+
interface IOptions {
|
|
81
|
+
/**
|
|
82
|
+
* A string indicating how the request will interact with the browser's
|
|
83
|
+
* cache to set request's cache.
|
|
84
|
+
*/
|
|
85
|
+
cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
|
|
86
|
+
/**
|
|
87
|
+
* A string indicating whether credentials will be sent with the request
|
|
88
|
+
* always, never, or only when sent to a same-origin URL. Sets request's
|
|
89
|
+
* credentials.
|
|
90
|
+
*/
|
|
91
|
+
credentials?: "omit" | "same-origin" | "include";
|
|
92
|
+
/**
|
|
93
|
+
* A cryptographic hash of the resource to be fetched by request.
|
|
94
|
+
*
|
|
95
|
+
* Sets request's integrity.
|
|
96
|
+
*/
|
|
97
|
+
integrity?: string;
|
|
98
|
+
/** A boolean to set request's keepalive. */
|
|
99
|
+
keepalive?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A string to indicate whether the request will use CORS, or will be
|
|
102
|
+
* restricted to same-origin URLs.
|
|
103
|
+
*
|
|
104
|
+
* Sets request's mode.
|
|
105
|
+
*/
|
|
106
|
+
mode?: "cors" | "navigate" | "no-cors" | "same-origin";
|
|
107
|
+
/**
|
|
108
|
+
* A string indicating whether request follows redirects, results in an
|
|
109
|
+
* error upon encountering a redirect, or returns the redirect (in an opaque
|
|
110
|
+
* fashion).
|
|
111
|
+
*
|
|
112
|
+
* Sets request's redirect.
|
|
113
|
+
*/
|
|
114
|
+
redirect?: "error" | "follow" | "manual";
|
|
115
|
+
/**
|
|
116
|
+
* A string whose value is a same-origin URL, "about:client", or the empty
|
|
117
|
+
* string, to set request's referrer.
|
|
118
|
+
*/
|
|
119
|
+
referrer?: string;
|
|
120
|
+
/** A referrer policy to set request's referrerPolicy. */
|
|
121
|
+
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
122
|
+
/** An AbortSignal to set request's signal. */
|
|
123
|
+
signal?: AbortSignal | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Type of allowed header values.
|
|
127
|
+
*
|
|
128
|
+
* Only atomic or array of atomic values are allowed.
|
|
129
|
+
*/
|
|
130
|
+
type HeaderValue = string | boolean | number | bigint | string | Array<boolean> | Array<number> | Array<bigint> | Array<number> | Array<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Type of headers
|
|
133
|
+
*
|
|
134
|
+
* `Headerify` removes every properties that are not allowed in the HTTP
|
|
135
|
+
* headers type.
|
|
136
|
+
*
|
|
137
|
+
* Below are list of prohibited in HTTP headers.
|
|
138
|
+
*
|
|
139
|
+
* 1. Value type one of {@link HeaderValue}
|
|
140
|
+
* 2. Key is "set-cookie", but value is not an Array type
|
|
141
|
+
* 3. Key is one of them, but value is Array type
|
|
142
|
+
*
|
|
143
|
+
* - "age"
|
|
144
|
+
* - "authorization"
|
|
145
|
+
* - "content-length"
|
|
146
|
+
* - "content-type"
|
|
147
|
+
* - "etag"
|
|
148
|
+
* - "expires"
|
|
149
|
+
* - "from"
|
|
150
|
+
* - "host"
|
|
151
|
+
* - "if-modified-since"
|
|
152
|
+
* - "if-unmodified-since"
|
|
153
|
+
* - "last-modified"
|
|
154
|
+
* - "location"
|
|
155
|
+
* - "max-forwards"
|
|
156
|
+
* - "proxy-authorization"
|
|
157
|
+
* - "referer"
|
|
158
|
+
* - "retry-after"
|
|
159
|
+
* - "server"
|
|
160
|
+
* - "user-agent"
|
|
161
|
+
*/
|
|
162
|
+
type Headerify<T extends object | undefined> = {
|
|
163
|
+
[P in keyof T]?: T[P] extends HeaderValue | undefined ? P extends string ? Lowercase<P> extends "set-cookie" ? T[P] extends Array<HeaderValue> ? T[P] | undefined : never : Lowercase<P> extends "age" | "authorization" | "content-length" | "content-type" | "etag" | "expires" | "from" | "host" | "if-modified-since" | "if-unmodified-since" | "last-modified" | "location" | "max-forwards" | "proxy-authorization" | "referer" | "retry-after" | "server" | "user-agent" ? T[P] extends Array<HeaderValue> ? never : T[P] | undefined : T[P] | undefined : never : never;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConnection.js","sourceRoot":"","sources":["../src/IConnection.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
/**
|
|
3
|
+
* Encryption password.
|
|
4
|
+
*
|
|
5
|
+
* `IEncryptionPassword` is a type of interface who represents encryption
|
|
6
|
+
* password used by the {@link Fetcher} with AES-128/256 algorithm. If your
|
|
7
|
+
* encryption password is not fixed but changes according to the input content,
|
|
8
|
+
* you can utilize the {@link IEncryptionPassword.Closure} function type.
|
|
9
|
+
*
|
|
10
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
11
|
+
*/
|
|
12
|
+
export interface IEncryptionPassword {
|
|
13
|
+
/** Secret key. */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Initialization Vector. */
|
|
16
|
+
iv: string;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace IEncryptionPassword {
|
|
19
|
+
/**
|
|
20
|
+
* Type of a closure function returning the {@link IEncryptionPassword} object.
|
|
21
|
+
*
|
|
22
|
+
* `IEncryptionPassword.Closure` is a type of closure function who are
|
|
23
|
+
* returning the {@link IEncryptionPassword} object. It would be used when your
|
|
24
|
+
* encryption password be changed according to the input content.
|
|
25
|
+
*/
|
|
26
|
+
interface Closure {
|
|
27
|
+
/**
|
|
28
|
+
* Encryption password getter.
|
|
29
|
+
*
|
|
30
|
+
* @param props Properties for predication
|
|
31
|
+
* @returns Encryption password
|
|
32
|
+
*/
|
|
33
|
+
(props: IProps): IEncryptionPassword;
|
|
34
|
+
}
|
|
35
|
+
/** Properties for the closure. */
|
|
36
|
+
interface IProps {
|
|
37
|
+
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
38
|
+
body: string;
|
|
39
|
+
direction: "encode" | "decode";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEncryptionPassword.js","sourceRoot":"","sources":["../src/IEncryptionPassword.ts"],"names":[],"mappings":""}
|
|
@@ -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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties of remote API route.
|
|
3
|
+
*
|
|
4
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
+
*/
|
|
6
|
+
export interface IFetchRoute<Method extends "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE"> {
|
|
7
|
+
/** Method of the HTTP request. */
|
|
8
|
+
method: Method;
|
|
9
|
+
/** Path of the HTTP request. */
|
|
10
|
+
path: string;
|
|
11
|
+
/**
|
|
12
|
+
* Path template.
|
|
13
|
+
*
|
|
14
|
+
* Filled since 3.2.2 version.
|
|
15
|
+
*/
|
|
16
|
+
template?: string;
|
|
17
|
+
/** Request body data info. */
|
|
18
|
+
request: Method extends "DELETE" | "POST" | "PUT" | "PATCH" ? IFetchRoute.IBody | null : null;
|
|
19
|
+
/** Response body data info. */
|
|
20
|
+
response: Method extends "HEAD" ? null : IFetchRoute.IBody;
|
|
21
|
+
/** When special status code being used. */
|
|
22
|
+
status: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* Parser of the query string.
|
|
25
|
+
*
|
|
26
|
+
* If content type of response body is `application/x-www-form-urlencoded`,
|
|
27
|
+
* then this `parseQuery` function would be called.
|
|
28
|
+
*
|
|
29
|
+
* If you've forgotten to configuring this `parseQuery` property about the
|
|
30
|
+
* `application/x-www-form-urlencoded` typed response body data, then only the
|
|
31
|
+
* `URLSearchParams` typed instance would be returned instead.
|
|
32
|
+
*/
|
|
33
|
+
parseQuery?(input: URLSearchParams): any;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace IFetchRoute {
|
|
36
|
+
/**
|
|
37
|
+
* Metadata of body.
|
|
38
|
+
*
|
|
39
|
+
* Describes how content-type being used in body, and whether encrypted or
|
|
40
|
+
* not.
|
|
41
|
+
*/
|
|
42
|
+
interface IBody {
|
|
43
|
+
type: "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
44
|
+
encrypted?: boolean;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFetchRoute.js","sourceRoot":"","sources":["../src/IFetchRoute.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propagation type.
|
|
3
|
+
*
|
|
4
|
+
* `IPropagation` is a type gathering all possible status codes and their body
|
|
5
|
+
* data types as a discriminated union type. You can specify the status code and
|
|
6
|
+
* its body data type just by using conditional statement like below.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* type Output = IPropagation<{
|
|
10
|
+
* 200: ISeller.IAuthorized;
|
|
11
|
+
* 400: TypeGuardError.IProps;
|
|
12
|
+
* >};
|
|
13
|
+
*
|
|
14
|
+
* const output: Output = await sdk.sellers.authenticate.join(input);
|
|
15
|
+
* if (output.success) {
|
|
16
|
+
* // automatically casted to "ISeller.IAuthorized" type
|
|
17
|
+
* const authorized: ISeller.IAuthorized = output.data;
|
|
18
|
+
* } else if (output.status === 400) {
|
|
19
|
+
* // automatically casted to "TypeGuardError.IProps" type
|
|
20
|
+
* const error: TypeGuardError.IProps = output.data;
|
|
21
|
+
* } else {
|
|
22
|
+
* // unknown type when out of pre-defined status codes
|
|
23
|
+
* const result: unknown = output.data;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* For reference, this `IPropagation` type is utilized by SDK library generated
|
|
28
|
+
* by `@nestia/sdk`, when you've configured {@link INestiaConfig.propagate} to be
|
|
29
|
+
* `true`. In that case, SDK functions generated by `@nestia/sdk` no more
|
|
30
|
+
* returns response DTO typed data directly, but returns this `IPropagation`
|
|
31
|
+
* typed object instead.
|
|
32
|
+
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
* @template StatusMap Map of status code and its body data type.
|
|
35
|
+
* @template Success Default success status code.
|
|
36
|
+
*/
|
|
37
|
+
export type IPropagation<StatusMap extends {
|
|
38
|
+
[P in IPropagation.Status]?: any;
|
|
39
|
+
}, Success extends number = 200 | 201> = {
|
|
40
|
+
[P in keyof StatusMap]: IPropagation.IBranch<P extends Success ? true : false, P, StatusMap[P]>;
|
|
41
|
+
}[keyof StatusMap] | IPropagation.IBranch<false, unknown, unknown>;
|
|
42
|
+
export declare namespace IPropagation {
|
|
43
|
+
/**
|
|
44
|
+
* Type of configurable status codes.
|
|
45
|
+
*
|
|
46
|
+
* The special characters like `2XX`, `3XX`, `4XX`, `5XX` are meaning the
|
|
47
|
+
* range of status codes. If `5XX` is specified, it means the status code is
|
|
48
|
+
* in the range of `500` to `599`.
|
|
49
|
+
*/
|
|
50
|
+
export type Status = number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
51
|
+
/**
|
|
52
|
+
* Branch type of propagation.
|
|
53
|
+
*
|
|
54
|
+
* `IPropagation.IBranch` is a branch type composing `IPropagation` type,
|
|
55
|
+
* which is gathering all possible status codes and their body data types as a
|
|
56
|
+
* union type.
|
|
57
|
+
*/
|
|
58
|
+
export interface IBranch<Success extends boolean, StatusValue, BodyData> {
|
|
59
|
+
success: Success;
|
|
60
|
+
status: StatusValue extends "2XX" | "3XX" | "4XX" | "5XX" ? StatusRange<StatusValue> : StatusValue extends number ? StatusValue : never;
|
|
61
|
+
data: BodyData;
|
|
62
|
+
headers: Record<string, string | string[]>;
|
|
63
|
+
}
|
|
64
|
+
/** Range of status codes by the first digit. */
|
|
65
|
+
export type StatusRange<T extends "2XX" | "3XX" | "4XX" | "5XX"> = T extends 0 ? IntRange<200, 299> : T extends 3 ? IntRange<300, 399> : T extends 4 ? IntRange<400, 499> : IntRange<500, 599>;
|
|
66
|
+
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
|
|
67
|
+
type Enumerate<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc["length"]]>;
|
|
68
|
+
export {};
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPropagation.js","sourceRoot":"","sources":["../src/IPropagation.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>(task: () => T) => void;
|
|
11
|
+
body: <T>(task: () => T) => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NestiaSimulator = void 0;
|
|
4
|
+
const HttpError_1 = require("./HttpError");
|
|
5
|
+
var NestiaSimulator;
|
|
6
|
+
(function (NestiaSimulator) {
|
|
7
|
+
NestiaSimulator.assert = (props) => {
|
|
8
|
+
return {
|
|
9
|
+
param: param(props),
|
|
10
|
+
query: query(props),
|
|
11
|
+
body: body(props),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const param = (props) => (name) => (task) => {
|
|
15
|
+
validate((exp) => `URL parameter "${name}" is not ${exp.expected} type.`)(props)(task);
|
|
16
|
+
};
|
|
17
|
+
const query = (props) => (task) => validate(() => "Request query parameters are not following the promised type.")(props)(task);
|
|
18
|
+
const body = (props) => (task) => validate(() => "Request body is not following the promised type.")(props)(task);
|
|
19
|
+
const validate = (message, path) => (props) => (task) => {
|
|
20
|
+
try {
|
|
21
|
+
task();
|
|
22
|
+
}
|
|
23
|
+
catch (exp) {
|
|
24
|
+
if (isTypeGuardError(exp))
|
|
25
|
+
throw new HttpError_1.HttpError(props.method, props.host + props.path, 400, {
|
|
26
|
+
"Content-Type": props.contentType,
|
|
27
|
+
}, JSON.stringify({
|
|
28
|
+
method: exp.method,
|
|
29
|
+
path: path !== null && path !== void 0 ? path : exp.path,
|
|
30
|
+
expected: exp.expected,
|
|
31
|
+
value: exp.value,
|
|
32
|
+
message: message(exp),
|
|
33
|
+
}));
|
|
34
|
+
throw exp;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
})(NestiaSimulator || (exports.NestiaSimulator = NestiaSimulator = {}));
|
|
38
|
+
const isTypeGuardError = (input) => "string" === typeof input.method &&
|
|
39
|
+
(undefined === input.path || "string" === typeof input.path) &&
|
|
40
|
+
"string" === typeof input.expected &&
|
|
41
|
+
"string" === typeof input.name &&
|
|
42
|
+
"string" === typeof input.message &&
|
|
43
|
+
(undefined === input.stack || "string" === typeof input.stack);
|
|
44
|
+
//# sourceMappingURL=NestiaSimulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaSimulator.js","sourceRoot":"","sources":["../src/NestiaSimulator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,IAAiB,eAAe,CAgE/B;AAhED,WAAiB,eAAe;IAQjB,sBAAM,GAAG,CAAC,KAAa,EAAE,EAAE;QACtC,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;SAClB,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,KAAK,GACT,CAAC,KAAa,EAAE,EAAE,CAClB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAI,IAAa,EAAQ,EAAE;QACzB,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,IAAI,YAAY,GAAG,CAAC,QAAQ,QAAQ,CAAC,CACvE,KAAK,C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D,QAAQ,KAAK,OAAO,KAAK,CAAC,MAAM;IAChC,CAAC,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI,CAAC;IAC5D,QAAQ,KAAK,OAAO,KAAK,CAAC,QAAQ;IAClC,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI;IAC9B,QAAQ,KAAK,OAAO,KAAK,CAAC,OAAO;IACjC,CAAC,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
+
import { IPropagation } from "./IPropagation";
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
6
|
+
*
|
|
7
|
+
* `PlainFetcher` is a utility class designed for SDK functions generated by
|
|
8
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
9
|
+
* HTTP sever API. In other words, this is a collection of dedicated `fetch()`
|
|
10
|
+
* functions for `@nestia/sdk`.
|
|
11
|
+
*
|
|
12
|
+
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
13
|
+
* at all. It just delivers plain data without any post processing. If you've
|
|
14
|
+
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
15
|
+
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
16
|
+
*
|
|
17
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace PlainFetcher {
|
|
20
|
+
/**
|
|
21
|
+
* Fetch function only for `HEAD` method.
|
|
22
|
+
*
|
|
23
|
+
* @param connection Connection information for the remote HTTP server
|
|
24
|
+
* @param route Route information about the target API
|
|
25
|
+
* @returns Nothing because of `HEAD` method
|
|
26
|
+
*/
|
|
27
|
+
function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch function only for `GET` method.
|
|
30
|
+
*
|
|
31
|
+
* @param connection Connection information for the remote HTTP server
|
|
32
|
+
* @param route Route information about the target API
|
|
33
|
+
* @returns Response body data from the remote API
|
|
34
|
+
*/
|
|
35
|
+
function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Output>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
|
|
38
|
+
*
|
|
39
|
+
* @param connection Connection information for the remote HTTP server
|
|
40
|
+
* @param route Route information about the target API
|
|
41
|
+
* @returns Response body data from the remote API
|
|
42
|
+
*/
|
|
43
|
+
function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;
|
|
44
|
+
function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise<Output>;
|
|
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>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PlainFetcher = void 0;
|
|
13
|
+
const FetcherBase_1 = require("./internal/FetcherBase");
|
|
14
|
+
/**
|
|
15
|
+
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
16
|
+
*
|
|
17
|
+
* `PlainFetcher` is a utility class designed for SDK functions generated by
|
|
18
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
19
|
+
* HTTP sever API. In other words, this is a collection of dedicated `fetch()`
|
|
20
|
+
* functions for `@nestia/sdk`.
|
|
21
|
+
*
|
|
22
|
+
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
23
|
+
* at all. It just delivers plain data without any post processing. If you've
|
|
24
|
+
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
25
|
+
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
26
|
+
*
|
|
27
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
28
|
+
*/
|
|
29
|
+
var PlainFetcher;
|
|
30
|
+
(function (PlainFetcher) {
|
|
31
|
+
function fetch(connection, route, input, stringify) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
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)
|
|
35
|
+
throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
36
|
+
return FetcherBase_1.FetcherBase.request({
|
|
37
|
+
className: "PlainFetcher",
|
|
38
|
+
encode: (input) => input,
|
|
39
|
+
decode: (input) => input,
|
|
40
|
+
})(connection, route, input, stringify);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
PlainFetcher.fetch = fetch;
|
|
44
|
+
function propagate(connection, route, input, stringify) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
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)
|
|
48
|
+
throw new Error("Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
49
|
+
return FetcherBase_1.FetcherBase.propagate({
|
|
50
|
+
className: "PlainFetcher",
|
|
51
|
+
encode: (input) => input,
|
|
52
|
+
decode: (input) => input,
|
|
53
|
+
})(connection, route, input, stringify);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
PlainFetcher.propagate = propagate;
|
|
57
|
+
})(PlainFetcher || (exports.PlainFetcher = PlainFetcher = {}));
|
|
58
|
+
//# sourceMappingURL=PlainFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlainFetcher.js","sourceRoot":"","sources":["../src/PlainFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,wDAAqD;AAErD;;;;;;;;;;;;;;GAcG;AACH,IAAiB,YAAY,CAoF5B;AApFD,WAAiB,YAAY;IAuC3B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;gBACzE,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;YACJ,OAAO,yBAAW,CAAC,OAAO,CAAC;gBACzB,SAAS,EAAE,cAAc;gBACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;KAAA;IAfqB,kBAAK,QAe1B,CAAA;IAcD,SAAsB,SAAS,CAC7B,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;gBACzE,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;YACJ,OAAO,yBAAW,CAAC,SAAS,CAAC;gBAC3B,SAAS,EAAE,cAAc;gBACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,CAAC;QAC7D,CAAC;KAAA;IAfqB,sBAAS,YAe9B,CAAA;AACH,CAAC,EApFgB,YAAY,4BAAZ,YAAY,QAoF5B"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export * from "./NestiaSimulator";
|
|
11
|
+
export * from "./PlainFetcher";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AesPkcs5"), exports);
|
|
18
|
+
__exportStar(require("./EncryptedFetcher"), exports);
|
|
19
|
+
__exportStar(require("./FormDataInput"), exports);
|
|
20
|
+
__exportStar(require("./HttpError"), exports);
|
|
21
|
+
__exportStar(require("./IConnection"), exports);
|
|
22
|
+
__exportStar(require("./IEncryptionPassword"), exports);
|
|
23
|
+
__exportStar(require("./IFetchEvent"), exports);
|
|
24
|
+
__exportStar(require("./IFetchRoute"), exports);
|
|
25
|
+
__exportStar(require("./IPropagation"), exports);
|
|
26
|
+
__exportStar(require("./NestiaSimulator"), exports);
|
|
27
|
+
__exportStar(require("./PlainFetcher"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,qDAAmC;AACnC,kDAAgC;AAChC,8CAA4B;AAC5B,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAE/B,oDAAkC;AAClC,iDAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FetcherBase = void 0;
|
|
13
|
+
const HttpError_1 = require("../HttpError");
|
|
14
|
+
/** @internal */
|
|
15
|
+
var FetcherBase;
|
|
16
|
+
(function (FetcherBase) {
|
|
17
|
+
FetcherBase.request = (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const result = yield _Propagate("fetch")(props)(connection, route, input, stringify);
|
|
19
|
+
if (result.success === false)
|
|
20
|
+
throw new HttpError_1.HttpError(route.method, route.path, result.status, result.headers, result.data);
|
|
21
|
+
return result.data;
|
|
22
|
+
});
|
|
23
|
+
FetcherBase.propagate = (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () { return _Propagate("propagate")(props)(connection, route, input, stringify); });
|
|
24
|
+
/** @internal */
|
|
25
|
+
const _Propagate = (method) => (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
27
|
+
//----
|
|
28
|
+
// REQUEST MESSAGE
|
|
29
|
+
//----
|
|
30
|
+
// METHOD & HEADERS
|
|
31
|
+
const headers = Object.assign({}, ((_a = connection.headers) !== null && _a !== void 0 ? _a : {}));
|
|
32
|
+
if (input !== undefined) {
|
|
33
|
+
if (((_b = route.request) === null || _b === void 0 ? void 0 : _b.type) === undefined)
|
|
34
|
+
throw new Error(`Error on ${props.className}.fetch(): no content-type being configured.`);
|
|
35
|
+
else if (route.request.type !== "multipart/form-data")
|
|
36
|
+
headers["Content-Type"] = route.request.type;
|
|
37
|
+
}
|
|
38
|
+
else if (input === undefined && headers["Content-Type"] !== undefined)
|
|
39
|
+
delete headers["Content-Type"];
|
|
40
|
+
// INIT REQUEST DATA
|
|
41
|
+
const init = Object.assign(Object.assign({}, ((_c = connection.options) !== null && _c !== void 0 ? _c : {})), { method: route.method, headers: (() => {
|
|
42
|
+
const output = [];
|
|
43
|
+
for (const [key, value] of Object.entries(headers))
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
continue;
|
|
46
|
+
else if (Array.isArray(value))
|
|
47
|
+
for (const v of value)
|
|
48
|
+
output.push([key, String(v)]);
|
|
49
|
+
else
|
|
50
|
+
output.push([key, String(value)]);
|
|
51
|
+
return output;
|
|
52
|
+
})() });
|
|
53
|
+
// CONSTRUCT BODY DATA
|
|
54
|
+
if (input !== undefined)
|
|
55
|
+
init.body = props.encode(
|
|
56
|
+
// BODY TRANSFORM
|
|
57
|
+
((_d = route.request) === null || _d === void 0 ? void 0 : _d.type) === "application/x-www-form-urlencoded"
|
|
58
|
+
? request_query_body(input)
|
|
59
|
+
: ((_e = route.request) === null || _e === void 0 ? void 0 : _e.type) === "multipart/form-data"
|
|
60
|
+
? request_form_data_body(input)
|
|
61
|
+
: ((_f = route.request) === null || _f === void 0 ? void 0 : _f.type) !== "text/plain"
|
|
62
|
+
? (stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input)
|
|
63
|
+
: input, headers);
|
|
64
|
+
//----
|
|
65
|
+
// RESPONSE MESSAGE
|
|
66
|
+
//----
|
|
67
|
+
// URL SPECIFICATION
|
|
68
|
+
const path = connection.host[connection.host.length - 1] !== "/" &&
|
|
69
|
+
route.path[0] !== "/"
|
|
70
|
+
? `/${route.path}`
|
|
71
|
+
: route.path;
|
|
72
|
+
const url = new URL(`${connection.host}${path}`);
|
|
73
|
+
// DO FETCH
|
|
74
|
+
const event = {
|
|
75
|
+
route,
|
|
76
|
+
path,
|
|
77
|
+
status: null,
|
|
78
|
+
input,
|
|
79
|
+
output: undefined,
|
|
80
|
+
started_at: new Date(),
|
|
81
|
+
respond_at: null,
|
|
82
|
+
completed_at: null,
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
// TRY FETCH
|
|
86
|
+
const response = yield ((_g = connection.fetch) !== null && _g !== void 0 ? _g : fetch)(url.href, init);
|
|
87
|
+
event.respond_at = new Date();
|
|
88
|
+
event.status = response.status;
|
|
89
|
+
// CONSTRUCT RESULT DATA
|
|
90
|
+
const result = {
|
|
91
|
+
success: response.status === 200 ||
|
|
92
|
+
response.status === 201 ||
|
|
93
|
+
response.status === route.status,
|
|
94
|
+
status: response.status,
|
|
95
|
+
headers: response_headers_to_object(response.headers),
|
|
96
|
+
data: undefined,
|
|
97
|
+
};
|
|
98
|
+
if (result.success === false) {
|
|
99
|
+
// WHEN FAILED
|
|
100
|
+
result.data = yield response.text();
|
|
101
|
+
const type = response.headers.get("content-type");
|
|
102
|
+
if (method !== "fetch" &&
|
|
103
|
+
type &&
|
|
104
|
+
type.indexOf("application/json") !== -1)
|
|
105
|
+
try {
|
|
106
|
+
result.data = JSON.parse(result.data);
|
|
107
|
+
}
|
|
108
|
+
catch (_k) { }
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// WHEN SUCCESS
|
|
112
|
+
if (route.method === "HEAD")
|
|
113
|
+
result.data = undefined;
|
|
114
|
+
else if (((_h = route.response) === null || _h === void 0 ? void 0 : _h.type) === "application/json") {
|
|
115
|
+
const text = yield response.text();
|
|
116
|
+
result.data = text.length ? JSON.parse(text) : undefined;
|
|
117
|
+
}
|
|
118
|
+
else if (((_j = route.response) === null || _j === void 0 ? void 0 : _j.type) === "application/x-www-form-urlencoded") {
|
|
119
|
+
const query = new URLSearchParams(yield response.text());
|
|
120
|
+
result.data = route.parseQuery ? route.parseQuery(query) : query;
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
result.data = props.decode(yield response.text(), result.headers);
|
|
124
|
+
}
|
|
125
|
+
event.output = result.data;
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
catch (exp) {
|
|
129
|
+
throw exp;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
event.completed_at = new Date();
|
|
133
|
+
if (connection.logger)
|
|
134
|
+
try {
|
|
135
|
+
yield connection.logger(event);
|
|
136
|
+
}
|
|
137
|
+
catch (_l) { }
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
})(FetcherBase || (exports.FetcherBase = FetcherBase = {}));
|
|
141
|
+
/** @internal */
|
|
142
|
+
const request_query_body = (input) => {
|
|
143
|
+
const q = new URLSearchParams();
|
|
144
|
+
for (const [key, value] of Object.entries(input))
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
continue;
|
|
147
|
+
else if (Array.isArray(value))
|
|
148
|
+
value.forEach((elem) => q.append(key, String(elem)));
|
|
149
|
+
else
|
|
150
|
+
q.set(key, String(value));
|
|
151
|
+
return q;
|
|
152
|
+
};
|
|
153
|
+
/** @internal */
|
|
154
|
+
const request_form_data_body = (input) => {
|
|
155
|
+
const encoded = new FormData();
|
|
156
|
+
const append = (key) => (value) => {
|
|
157
|
+
if (value === undefined)
|
|
158
|
+
return;
|
|
159
|
+
else if (typeof File === "function" && value instanceof File)
|
|
160
|
+
encoded.append(key, value, value.name);
|
|
161
|
+
else
|
|
162
|
+
encoded.append(key, value);
|
|
163
|
+
};
|
|
164
|
+
for (const [key, value] of Object.entries(input))
|
|
165
|
+
if (Array.isArray(value))
|
|
166
|
+
value.map(append(key));
|
|
167
|
+
else
|
|
168
|
+
append(key)(value);
|
|
169
|
+
return encoded;
|
|
170
|
+
};
|
|
171
|
+
/** @internal */
|
|
172
|
+
const response_headers_to_object = (headers) => {
|
|
173
|
+
const output = {};
|
|
174
|
+
headers.forEach((value, key) => {
|
|
175
|
+
var _a;
|
|
176
|
+
if (key === "set-cookie") {
|
|
177
|
+
(_a = output[key]) !== null && _a !== void 0 ? _a : (output[key] = []);
|
|
178
|
+
output[key].push(...value.split(";").map((str) => str.trim()));
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
output[key] = value;
|
|
182
|
+
});
|
|
183
|
+
return output;
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=FetcherBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyC;AAMzC,gBAAgB;AAChB,IAAiB,WAAW,CAyL3B;AAzLD,WAAiB,WAAW;IAab,mBAAO,GAClB,CAAC,KAAa,EAAE,EAAE,CAClB,CACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EACnB,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAC7C,UAAU,EACV,KAAK,EACL,KAAK,EACL,SAAS,CACV,CAAC;QACF,IAAK,MAAc,CAAC,OAAO,KAAK,KAAK;YACnC,MAAM,IAAI,qBAAS,CACjB,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,MAAuB,EAC9B,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,IAAc,CACtB,CAAC;QACJ,OAAO,MAAM,CAAC,IAAc,CAAC;IAC/B,CAAC,CAAA,CAAC;IAES,qBAAS,GACpB,CAAC,KAAa,EAAE,EAAE,CAClB,CACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EACH,EAAE,gDACnC,OAAA,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,UA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