@nestia/fetcher 10.0.2 → 11.0.0-dev.20260312
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/lib/AesPkcs5.js +5 -5
- package/lib/AesPkcs5.js.map +1 -1
- package/lib/EncryptedFetcher.js +54 -95
- package/lib/EncryptedFetcher.js.map +1 -1
- package/lib/HttpError.d.ts +1 -1
- package/lib/HttpError.js +2 -2
- package/lib/HttpError.js.map +1 -1
- package/lib/NestiaSimulator.js +29 -47
- package/lib/NestiaSimulator.js.map +1 -1
- package/lib/PlainFetcher.js +17 -48
- package/lib/PlainFetcher.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/internal/FetcherBase.js +141 -304
- package/lib/internal/FetcherBase.js.map +1 -1
- package/package.json +20 -13
- package/src/AesPkcs5.ts +41 -49
- package/src/HttpError.ts +1 -1
- package/src/index.ts +12 -7
- package/lib/MigrateFetcher.d.ts +0 -19
- package/lib/MigrateFetcher.js +0 -179
- package/lib/MigrateFetcher.js.map +0 -1
- package/src/MigrateFetcher.ts +0 -118
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":"
|
|
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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;AAChB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/fetcher",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-dev.20260312",
|
|
4
4
|
"description": "Fetcher library of Nestia SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
9
|
+
"default": "./lib/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -26,13 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://nestia.io",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
29
|
+
"@typia/interface": "12.0.0-dev.20260312-2",
|
|
30
|
+
"@typia/utils": "12.0.0-dev.20260312-2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^
|
|
33
|
-
"
|
|
34
|
-
"@typescript-eslint/parser": "^5.46.1",
|
|
35
|
-
"rimraf": "^6.0.1",
|
|
33
|
+
"@types/node": "^25.3.3",
|
|
34
|
+
"rimraf": "^6.1.3",
|
|
36
35
|
"typescript": "~5.9.3"
|
|
37
36
|
},
|
|
38
37
|
"files": [
|
|
@@ -41,5 +40,13 @@
|
|
|
41
40
|
"package.json",
|
|
42
41
|
"lib",
|
|
43
42
|
"src"
|
|
44
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "rimraf lib && tsc",
|
|
49
|
+
"dev": "rimraf lib && tsc --watch"
|
|
50
|
+
},
|
|
51
|
+
"types": "lib/index.d.ts"
|
|
45
52
|
}
|
package/src/AesPkcs5.ts
CHANGED
|
@@ -1,49 +1,41 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility class for the AES-128/256 encryption.
|
|
5
|
-
*
|
|
6
|
-
* - AES-128/256
|
|
7
|
-
* - CBC mode
|
|
8
|
-
* - PKCS#5 Padding
|
|
9
|
-
* - Base64 Encoding
|
|
10
|
-
*
|
|
11
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
-
*/
|
|
13
|
-
export namespace AesPkcs5 {
|
|
14
|
-
/**
|
|
15
|
-
* Encrypt data
|
|
16
|
-
*
|
|
17
|
-
* @param data Target data
|
|
18
|
-
* @param key Key value of the encryption.
|
|
19
|
-
* @param iv Initializer Vector for the encryption
|
|
20
|
-
* @returns Encrypted data
|
|
21
|
-
*/
|
|
22
|
-
export function encrypt(data: string, key: string, iv: string): string {
|
|
23
|
-
const bytes: number = key.length * 8;
|
|
24
|
-
const cipher
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const decipher: crypto.Decipher = crypto.createDecipheriv(
|
|
43
|
-
`AES-${bytes}-CBC`,
|
|
44
|
-
key,
|
|
45
|
-
iv,
|
|
46
|
-
);
|
|
47
|
-
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for the AES-128/256 encryption.
|
|
5
|
+
*
|
|
6
|
+
* - AES-128/256
|
|
7
|
+
* - CBC mode
|
|
8
|
+
* - PKCS#5 Padding
|
|
9
|
+
* - Base64 Encoding
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
export namespace AesPkcs5 {
|
|
14
|
+
/**
|
|
15
|
+
* Encrypt data
|
|
16
|
+
*
|
|
17
|
+
* @param data Target data
|
|
18
|
+
* @param key Key value of the encryption.
|
|
19
|
+
* @param iv Initializer Vector for the encryption
|
|
20
|
+
* @returns Encrypted data
|
|
21
|
+
*/
|
|
22
|
+
export function encrypt(data: string, key: string, iv: string): string {
|
|
23
|
+
const bytes: number = key.length * 8;
|
|
24
|
+
const cipher = crypto.createCipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
25
|
+
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Decrypt data.
|
|
30
|
+
*
|
|
31
|
+
* @param data Target data
|
|
32
|
+
* @param key Key value of the decryption.
|
|
33
|
+
* @param iv Initializer Vector for the decryption
|
|
34
|
+
* @returns Decrypted data.
|
|
35
|
+
*/
|
|
36
|
+
export function decrypt(data: string, key: string, iv: string): string {
|
|
37
|
+
const bytes: number = key.length * 8;
|
|
38
|
+
const decipher = crypto.createDecipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
39
|
+
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/HttpError.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { HttpError } from "@
|
|
1
|
+
export { HttpError } from "@typia/utils";
|
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";
|
package/lib/MigrateFetcher.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IHttpMigrateRoute } from "@samchon/openapi";
|
|
2
|
-
import { IConnection } from "./IConnection";
|
|
3
|
-
import { IPropagation } from "./IPropagation";
|
|
4
|
-
/**
|
|
5
|
-
* Use `HttpMigration.execute()` function of `@samchon/openapi` instead.
|
|
6
|
-
*
|
|
7
|
-
* This module would be removed in the next major update.
|
|
8
|
-
*
|
|
9
|
-
* @deprecated
|
|
10
|
-
*/
|
|
11
|
-
export declare namespace MigrateFetcher {
|
|
12
|
-
interface IProps {
|
|
13
|
-
route: IHttpMigrateRoute;
|
|
14
|
-
connection: IConnection;
|
|
15
|
-
arguments: any[];
|
|
16
|
-
}
|
|
17
|
-
function request(props: IProps): Promise<any>;
|
|
18
|
-
function propagate(props: IProps): Promise<IPropagation.IBranch<boolean, number, any>>;
|
|
19
|
-
}
|
package/lib/MigrateFetcher.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
exports.MigrateFetcher = void 0;
|
|
67
|
-
var PlainFetcher_1 = require("./PlainFetcher");
|
|
68
|
-
/**
|
|
69
|
-
* Use `HttpMigration.execute()` function of `@samchon/openapi` instead.
|
|
70
|
-
*
|
|
71
|
-
* This module would be removed in the next major update.
|
|
72
|
-
*
|
|
73
|
-
* @deprecated
|
|
74
|
-
*/
|
|
75
|
-
var MigrateFetcher;
|
|
76
|
-
(function (MigrateFetcher) {
|
|
77
|
-
function request(props) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var length;
|
|
80
|
-
var _a, _b, _c, _d;
|
|
81
|
-
return __generator(this, function (_e) {
|
|
82
|
-
length = props.route.parameters.length +
|
|
83
|
-
(props.route.query ? 1 : 0) +
|
|
84
|
-
(props.route.body ? 1 : 0);
|
|
85
|
-
if (props.arguments.length !== length)
|
|
86
|
-
throw new Error("Error on MigrateFetcher.request(): arguments length is not matched with the route (expected: ".concat(length, ", actual: ").concat(props.arguments.length, ")."));
|
|
87
|
-
else if (((_a = props.route.body) === null || _a === void 0 ? void 0 : _a["x-nestia-encrypted"]) === true ||
|
|
88
|
-
((_b = props.route.success) === null || _b === void 0 ? void 0 : _b["x-nestia-encrypted"]) === true)
|
|
89
|
-
throw new Error("Error on MigrateFetcher.request(): encrypted API is not supported yet.");
|
|
90
|
-
return [2 /*return*/, PlainFetcher_1.PlainFetcher.fetch(props.connection, {
|
|
91
|
-
method: props.route.method.toUpperCase(),
|
|
92
|
-
path: getPath(props),
|
|
93
|
-
template: props.route.path,
|
|
94
|
-
status: null,
|
|
95
|
-
request: props.route.body
|
|
96
|
-
? {
|
|
97
|
-
encrypted: false,
|
|
98
|
-
type: props.route.body.type,
|
|
99
|
-
}
|
|
100
|
-
: null,
|
|
101
|
-
response: {
|
|
102
|
-
encrypted: false,
|
|
103
|
-
type: (_d = (_c = props.route.success) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : "application/json",
|
|
104
|
-
},
|
|
105
|
-
}, props.route.body ? props.arguments.at(-1) : undefined)];
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
MigrateFetcher.request = request;
|
|
110
|
-
function propagate(props) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
var length;
|
|
113
|
-
var _a, _b, _c, _d;
|
|
114
|
-
return __generator(this, function (_e) {
|
|
115
|
-
length = props.route.parameters.length +
|
|
116
|
-
(props.route.query ? 1 : 0) +
|
|
117
|
-
(props.route.body ? 1 : 0);
|
|
118
|
-
if (props.arguments.length !== length)
|
|
119
|
-
throw new Error("Error on MigrateFetcher.propagate(): arguments length is not matched with the route (expected: ".concat(length, ", actual: ").concat(props.arguments.length, ")."));
|
|
120
|
-
else if (((_a = props.route.body) === null || _a === void 0 ? void 0 : _a["x-nestia-encrypted"]) === true ||
|
|
121
|
-
((_b = props.route.success) === null || _b === void 0 ? void 0 : _b["x-nestia-encrypted"]) === true)
|
|
122
|
-
throw new Error("Error on MigrateFetcher.propagate(): encrypted API is not supported yet.");
|
|
123
|
-
return [2 /*return*/, PlainFetcher_1.PlainFetcher.propagate(props.connection, {
|
|
124
|
-
method: props.route.method.toUpperCase(),
|
|
125
|
-
path: getPath(props),
|
|
126
|
-
template: props.route.path,
|
|
127
|
-
status: null,
|
|
128
|
-
request: props.route.body
|
|
129
|
-
? {
|
|
130
|
-
encrypted: false,
|
|
131
|
-
type: props.route.body.type,
|
|
132
|
-
}
|
|
133
|
-
: null,
|
|
134
|
-
response: {
|
|
135
|
-
encrypted: false,
|
|
136
|
-
type: (_d = (_c = props.route.success) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : "application/json",
|
|
137
|
-
},
|
|
138
|
-
}, props.route.body ? props.arguments.at(-1) : undefined)];
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
MigrateFetcher.propagate = propagate;
|
|
143
|
-
function getPath(props) {
|
|
144
|
-
var path = props.route.emendedPath;
|
|
145
|
-
props.route.parameters.forEach(function (p, i) {
|
|
146
|
-
path = path.replace(":".concat(p.key), props.arguments[i]);
|
|
147
|
-
});
|
|
148
|
-
if (props.route.query)
|
|
149
|
-
path += getQueryPath(props.arguments[props.route.parameters.length]);
|
|
150
|
-
return path;
|
|
151
|
-
}
|
|
152
|
-
function getQueryPath(query) {
|
|
153
|
-
var e_1, _a;
|
|
154
|
-
var variables = new URLSearchParams();
|
|
155
|
-
var _loop_1 = function (key, value) {
|
|
156
|
-
if (undefined === value)
|
|
157
|
-
return "continue";
|
|
158
|
-
else if (Array.isArray(value))
|
|
159
|
-
value.forEach(function (elem) { return variables.append(key, String(elem)); });
|
|
160
|
-
else
|
|
161
|
-
variables.set(key, String(value));
|
|
162
|
-
};
|
|
163
|
-
try {
|
|
164
|
-
for (var _b = __values(Object.entries(query)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
165
|
-
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
166
|
-
_loop_1(key, value);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
170
|
-
finally {
|
|
171
|
-
try {
|
|
172
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
173
|
-
}
|
|
174
|
-
finally { if (e_1) throw e_1.error; }
|
|
175
|
-
}
|
|
176
|
-
return 0 === variables.size ? "" : "?".concat(variables.toString());
|
|
177
|
-
}
|
|
178
|
-
})(MigrateFetcher || (exports.MigrateFetcher = MigrateFetcher = {}));
|
|
179
|
-
//# sourceMappingURL=MigrateFetcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateFetcher.js","sourceRoot":"","sources":["../src/MigrateFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,+CAA8C;AAE9C;;;;;;GAMG;AACH,IAAiB,cAAc,CAwG9B;AAxGD,WAAiB,cAAc;IAO7B,SAAsB,OAAO,CAAC,KAAa;;;;;gBACnC,MAAM,GACV,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM;oBAC7B,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC3B,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC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AAK,QAAA;wBAAV,GAAG,EAAE,KAAK;aAImB;;;;;;;;;QACzC,OAAO,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAI,SAAS,CAAC,QAAQ,EAAE,CAAE,CAAC;IAChE,CAAC;AACH,CAAC,EAxGgB,cAAc,8BAAd,cAAc,QAwG9B"}
|
package/src/MigrateFetcher.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { IHttpMigrateRoute } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { IConnection } from "./IConnection";
|
|
4
|
-
import { IPropagation } from "./IPropagation";
|
|
5
|
-
import { PlainFetcher } from "./PlainFetcher";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Use `HttpMigration.execute()` function of `@samchon/openapi` instead.
|
|
9
|
-
*
|
|
10
|
-
* This module would be removed in the next major update.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated
|
|
13
|
-
*/
|
|
14
|
-
export namespace MigrateFetcher {
|
|
15
|
-
export interface IProps {
|
|
16
|
-
route: IHttpMigrateRoute;
|
|
17
|
-
connection: IConnection;
|
|
18
|
-
arguments: any[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function request(props: IProps): Promise<any> {
|
|
22
|
-
const length: number =
|
|
23
|
-
props.route.parameters.length +
|
|
24
|
-
(props.route.query ? 1 : 0) +
|
|
25
|
-
(props.route.body ? 1 : 0);
|
|
26
|
-
if (props.arguments.length !== length)
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Error on MigrateFetcher.request(): arguments length is not matched with the route (expected: ${length}, actual: ${props.arguments.length}).`,
|
|
29
|
-
);
|
|
30
|
-
else if (
|
|
31
|
-
props.route.body?.["x-nestia-encrypted"] === true ||
|
|
32
|
-
props.route.success?.["x-nestia-encrypted"] === true
|
|
33
|
-
)
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Error on MigrateFetcher.request(): encrypted API is not supported yet.`,
|
|
36
|
-
);
|
|
37
|
-
return PlainFetcher.fetch(
|
|
38
|
-
props.connection,
|
|
39
|
-
{
|
|
40
|
-
method: props.route.method.toUpperCase() as "POST",
|
|
41
|
-
path: getPath(props),
|
|
42
|
-
template: props.route.path,
|
|
43
|
-
status: null,
|
|
44
|
-
request: props.route.body
|
|
45
|
-
? {
|
|
46
|
-
encrypted: false,
|
|
47
|
-
type: props.route.body.type,
|
|
48
|
-
}
|
|
49
|
-
: null,
|
|
50
|
-
response: {
|
|
51
|
-
encrypted: false,
|
|
52
|
-
type: props.route.success?.type ?? "application/json",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
props.route.body ? props.arguments.at(-1) : undefined,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function propagate(
|
|
60
|
-
props: IProps,
|
|
61
|
-
): Promise<IPropagation.IBranch<boolean, number, any>> {
|
|
62
|
-
const length: number =
|
|
63
|
-
props.route.parameters.length +
|
|
64
|
-
(props.route.query ? 1 : 0) +
|
|
65
|
-
(props.route.body ? 1 : 0);
|
|
66
|
-
if (props.arguments.length !== length)
|
|
67
|
-
throw new Error(
|
|
68
|
-
`Error on MigrateFetcher.propagate(): arguments length is not matched with the route (expected: ${length}, actual: ${props.arguments.length}).`,
|
|
69
|
-
);
|
|
70
|
-
else if (
|
|
71
|
-
props.route.body?.["x-nestia-encrypted"] === true ||
|
|
72
|
-
props.route.success?.["x-nestia-encrypted"] === true
|
|
73
|
-
)
|
|
74
|
-
throw new Error(
|
|
75
|
-
`Error on MigrateFetcher.propagate(): encrypted API is not supported yet.`,
|
|
76
|
-
);
|
|
77
|
-
return PlainFetcher.propagate(
|
|
78
|
-
props.connection,
|
|
79
|
-
{
|
|
80
|
-
method: props.route.method.toUpperCase() as "POST",
|
|
81
|
-
path: getPath(props),
|
|
82
|
-
template: props.route.path,
|
|
83
|
-
status: null,
|
|
84
|
-
request: props.route.body
|
|
85
|
-
? {
|
|
86
|
-
encrypted: false,
|
|
87
|
-
type: props.route.body.type,
|
|
88
|
-
}
|
|
89
|
-
: null,
|
|
90
|
-
response: {
|
|
91
|
-
encrypted: false,
|
|
92
|
-
type: props.route.success?.type ?? "application/json",
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
props.route.body ? props.arguments.at(-1) : undefined,
|
|
96
|
-
) as Promise<IPropagation.IBranch<boolean, number, any>>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getPath(props: Pick<IProps, "arguments" | "route">): string {
|
|
100
|
-
let path: string = props.route.emendedPath;
|
|
101
|
-
props.route.parameters.forEach((p, i) => {
|
|
102
|
-
path = path.replace(`:${p.key}`, props.arguments[i]);
|
|
103
|
-
});
|
|
104
|
-
if (props.route.query)
|
|
105
|
-
path += getQueryPath(props.arguments[props.route.parameters.length]);
|
|
106
|
-
return path;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getQueryPath(query: Record<string, any>): string {
|
|
110
|
-
const variables = new URLSearchParams();
|
|
111
|
-
for (const [key, value] of Object.entries(query))
|
|
112
|
-
if (undefined === value) continue;
|
|
113
|
-
else if (Array.isArray(value))
|
|
114
|
-
value.forEach((elem: any) => variables.append(key, String(elem)));
|
|
115
|
-
else variables.set(key, String(value));
|
|
116
|
-
return 0 === variables.size ? "" : `?${variables.toString()}`;
|
|
117
|
-
}
|
|
118
|
-
}
|