@nestia/fetcher 3.7.0 → 3.7.1
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/MigrateFetcher.d.ts +2 -0
- package/lib/MigrateFetcher.js +33 -0
- package/lib/MigrateFetcher.js.map +1 -1
- package/package.json +1 -1
- package/src/MigrateFetcher.ts +41 -0
package/lib/MigrateFetcher.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IMigrateRoute } from "@samchon/openapi";
|
|
2
2
|
import { IConnection } from "./IConnection";
|
|
3
|
+
import { IPropagation } from "./IPropagation";
|
|
3
4
|
export declare namespace MigrateFetcher {
|
|
4
5
|
interface IProps {
|
|
5
6
|
route: IMigrateRoute;
|
|
@@ -7,4 +8,5 @@ export declare namespace MigrateFetcher {
|
|
|
7
8
|
arguments: any[];
|
|
8
9
|
}
|
|
9
10
|
function request(props: IProps): Promise<any>;
|
|
11
|
+
function propagate(props: IProps): Promise<IPropagation.IBranch<boolean, number, any>>;
|
|
10
12
|
}
|
package/lib/MigrateFetcher.js
CHANGED
|
@@ -100,6 +100,39 @@ var MigrateFetcher;
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
MigrateFetcher.request = request;
|
|
103
|
+
function propagate(props) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
var length;
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
return __generator(this, function (_e) {
|
|
108
|
+
length = props.route.parameters.length +
|
|
109
|
+
(props.route.query ? 1 : 0) +
|
|
110
|
+
(props.route.body ? 1 : 0);
|
|
111
|
+
if (props.arguments.length !== length)
|
|
112
|
+
throw new Error("Error on MigrateFetcher.propagate(): arguments length is not matched with the route (expected: ".concat(length, ", actual: ").concat(props.arguments.length, ")."));
|
|
113
|
+
else if (((_a = props.route.body) === null || _a === void 0 ? void 0 : _a["x-nestia-encrypted"]) === true ||
|
|
114
|
+
((_b = props.route.success) === null || _b === void 0 ? void 0 : _b["x-nestia-encrypted"]) === true)
|
|
115
|
+
throw new Error("Error on MigrateFetcher.propagate(): encrypted API is not supported yet.");
|
|
116
|
+
return [2 /*return*/, PlainFetcher_1.PlainFetcher.propagate(props.connection, {
|
|
117
|
+
method: props.route.method.toUpperCase(),
|
|
118
|
+
path: getPath(props),
|
|
119
|
+
template: props.route.path,
|
|
120
|
+
status: null,
|
|
121
|
+
request: props.route.body
|
|
122
|
+
? {
|
|
123
|
+
encrypted: false,
|
|
124
|
+
type: props.route.body.type,
|
|
125
|
+
}
|
|
126
|
+
: null,
|
|
127
|
+
response: {
|
|
128
|
+
encrypted: false,
|
|
129
|
+
type: (_d = (_c = props.route.success) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : "application/json",
|
|
130
|
+
},
|
|
131
|
+
}, props.route.body ? props.arguments.at(-1) : undefined)];
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
MigrateFetcher.propagate = propagate;
|
|
103
136
|
function getPath(props) {
|
|
104
137
|
var path = props.route.emendedPath;
|
|
105
138
|
props.route.parameters.forEach(function (p, i) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateFetcher.js","sourceRoot":"","sources":["../src/MigrateFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MigrateFetcher.js","sourceRoot":"","sources":["../src/MigrateFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,+CAA8C;AAE9C,IAAiB,cAAc,CAwG9B;AAxGD,WAAiB,cAAc;IAO7B,SAAsB,OAAO,CAAC,KAAa;;;;;gBACnC,MAAM,GACV,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM;oB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AK,CAAC,CAAC,CAAC;;;YAJzC,KAA2B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA,gBAAA;gBAArC,IAAA,KAAA,mBAAY,EAAX,GAAG,QAAA,EAAE,KAAK,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/package.json
CHANGED
package/src/MigrateFetcher.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IMigrateRoute } from "@samchon/openapi";
|
|
2
2
|
|
|
3
3
|
import { IConnection } from "./IConnection";
|
|
4
|
+
import { IPropagation } from "./IPropagation";
|
|
4
5
|
import { PlainFetcher } from "./PlainFetcher";
|
|
5
6
|
|
|
6
7
|
export namespace MigrateFetcher {
|
|
@@ -48,6 +49,46 @@ export namespace MigrateFetcher {
|
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
export async function propagate(
|
|
53
|
+
props: IProps,
|
|
54
|
+
): Promise<IPropagation.IBranch<boolean, number, any>> {
|
|
55
|
+
const length: number =
|
|
56
|
+
props.route.parameters.length +
|
|
57
|
+
(props.route.query ? 1 : 0) +
|
|
58
|
+
(props.route.body ? 1 : 0);
|
|
59
|
+
if (props.arguments.length !== length)
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Error on MigrateFetcher.propagate(): arguments length is not matched with the route (expected: ${length}, actual: ${props.arguments.length}).`,
|
|
62
|
+
);
|
|
63
|
+
else if (
|
|
64
|
+
props.route.body?.["x-nestia-encrypted"] === true ||
|
|
65
|
+
props.route.success?.["x-nestia-encrypted"] === true
|
|
66
|
+
)
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Error on MigrateFetcher.propagate(): encrypted API is not supported yet.`,
|
|
69
|
+
);
|
|
70
|
+
return PlainFetcher.propagate(
|
|
71
|
+
props.connection,
|
|
72
|
+
{
|
|
73
|
+
method: props.route.method.toUpperCase() as "POST",
|
|
74
|
+
path: getPath(props),
|
|
75
|
+
template: props.route.path,
|
|
76
|
+
status: null,
|
|
77
|
+
request: props.route.body
|
|
78
|
+
? {
|
|
79
|
+
encrypted: false,
|
|
80
|
+
type: props.route.body.type,
|
|
81
|
+
}
|
|
82
|
+
: null,
|
|
83
|
+
response: {
|
|
84
|
+
encrypted: false,
|
|
85
|
+
type: props.route.success?.type ?? "application/json",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
props.route.body ? props.arguments.at(-1) : undefined,
|
|
89
|
+
) as Promise<IPropagation.IBranch<boolean, number, any>>;
|
|
90
|
+
}
|
|
91
|
+
|
|
51
92
|
function getPath(props: Pick<IProps, "arguments" | "route">): string {
|
|
52
93
|
let path: string = props.route.emendedPath;
|
|
53
94
|
props.route.parameters.forEach((p, i) => {
|