echoapi-converter 0.0.41 → 0.0.42
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/dist/index.d.ts +8 -2
- package/dist/index.js +56 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -204,6 +204,7 @@ declare class InsomniaToApipost {
|
|
|
204
204
|
declare class PostmanToApipost {
|
|
205
205
|
apis: any;
|
|
206
206
|
project: any;
|
|
207
|
+
source: 'vscode' | 'workbench' | string;
|
|
207
208
|
constructor();
|
|
208
209
|
private clear;
|
|
209
210
|
private completionApiRequestAuth;
|
|
@@ -216,7 +217,9 @@ declare class PostmanToApipost {
|
|
|
216
217
|
private completionApis;
|
|
217
218
|
private initApis;
|
|
218
219
|
private initProject;
|
|
219
|
-
convert(json: any, project_id: string
|
|
220
|
+
convert(json: any, project_id: string, option?: {
|
|
221
|
+
source: string;
|
|
222
|
+
}): {
|
|
220
223
|
status: "error" | "success";
|
|
221
224
|
message: string;
|
|
222
225
|
data: any;
|
|
@@ -248,6 +251,7 @@ declare class ThunderToApipost {
|
|
|
248
251
|
folders: any;
|
|
249
252
|
project: any;
|
|
250
253
|
global: any;
|
|
254
|
+
source: 'vscode' | 'workbench' | string;
|
|
251
255
|
constructor();
|
|
252
256
|
private clear;
|
|
253
257
|
private initProject;
|
|
@@ -266,7 +270,9 @@ declare class ThunderToApipost {
|
|
|
266
270
|
private initApis;
|
|
267
271
|
private initGlobal;
|
|
268
272
|
private buildFolderApiTree;
|
|
269
|
-
convert(json: any, project_id: string
|
|
273
|
+
convert(json: any, project_id: string, option?: {
|
|
274
|
+
source: string;
|
|
275
|
+
}): {
|
|
270
276
|
status: "error" | "success";
|
|
271
277
|
message: string;
|
|
272
278
|
data: any;
|
package/dist/index.js
CHANGED
|
@@ -5494,12 +5494,20 @@ class PostmanToApipost {
|
|
|
5494
5494
|
writable: true,
|
|
5495
5495
|
value: void 0
|
|
5496
5496
|
});
|
|
5497
|
+
// 转换的来源端
|
|
5498
|
+
Object.defineProperty(this, "source", {
|
|
5499
|
+
enumerable: true,
|
|
5500
|
+
configurable: true,
|
|
5501
|
+
writable: true,
|
|
5502
|
+
value: void 0
|
|
5503
|
+
});
|
|
5497
5504
|
this.apis = [];
|
|
5498
5505
|
this.project = {
|
|
5499
5506
|
name: "",
|
|
5500
5507
|
intro: "",
|
|
5501
5508
|
project_id: "",
|
|
5502
5509
|
};
|
|
5510
|
+
this.source = 'workbench';
|
|
5503
5511
|
}
|
|
5504
5512
|
clear() {
|
|
5505
5513
|
this.apis = [];
|
|
@@ -5508,6 +5516,7 @@ class PostmanToApipost {
|
|
|
5508
5516
|
intro: "",
|
|
5509
5517
|
project_id: "",
|
|
5510
5518
|
};
|
|
5519
|
+
this.source = 'workbench';
|
|
5511
5520
|
}
|
|
5512
5521
|
completionApiRequestAuth(auth) {
|
|
5513
5522
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -5573,11 +5582,22 @@ class PostmanToApipost {
|
|
|
5573
5582
|
}
|
|
5574
5583
|
else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
|
|
5575
5584
|
customAuth["type"] = "oauth2";
|
|
5585
|
+
const getGrantType = (postman_grant_type) => {
|
|
5586
|
+
if (APIPOST_GRANT_TYPES.includes(postman_grant_type)) {
|
|
5587
|
+
return postman_grant_type;
|
|
5588
|
+
}
|
|
5589
|
+
else if (this.source === 'vscode') {
|
|
5590
|
+
return 'password_credentials';
|
|
5591
|
+
}
|
|
5592
|
+
else {
|
|
5593
|
+
return 'authorization_code';
|
|
5594
|
+
}
|
|
5595
|
+
};
|
|
5576
5596
|
customAuth["oauth2"] = {
|
|
5577
5597
|
addTokenTo: (authMap === null || authMap === void 0 ? void 0 : authMap.addTokenTo) || 'header',
|
|
5578
5598
|
headerPrefix: (authMap === null || authMap === void 0 ? void 0 : authMap.headerPrefix) || 'Bearer',
|
|
5579
5599
|
access_token: '',
|
|
5580
|
-
grant_type:
|
|
5600
|
+
grant_type: getGrantType(authMap === null || authMap === void 0 ? void 0 : authMap.grant_type),
|
|
5581
5601
|
redirect_uri: (authMap === null || authMap === void 0 ? void 0 : authMap.redirect_uri) || '',
|
|
5582
5602
|
authUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.authUrl) || '',
|
|
5583
5603
|
accessTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.accessTokenUrl) || '',
|
|
@@ -6010,9 +6030,10 @@ class PostmanToApipost {
|
|
|
6010
6030
|
this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || "";
|
|
6011
6031
|
this.project.project_id = project_id;
|
|
6012
6032
|
}
|
|
6013
|
-
convert(json, project_id) {
|
|
6033
|
+
convert(json, project_id, option) {
|
|
6014
6034
|
this.clear();
|
|
6015
6035
|
try {
|
|
6036
|
+
this.source = (option === null || option === void 0 ? void 0 : option.source) || 'workbench';
|
|
6016
6037
|
this.initProject(json, project_id);
|
|
6017
6038
|
this.initApis(json === null || json === void 0 ? void 0 : json.item);
|
|
6018
6039
|
const data = Object.assign(Object.assign({}, this.project), { apis: this.apis });
|
|
@@ -6319,6 +6340,13 @@ class ThunderToApipost {
|
|
|
6319
6340
|
writable: true,
|
|
6320
6341
|
value: void 0
|
|
6321
6342
|
});
|
|
6343
|
+
// 转换的来源端
|
|
6344
|
+
Object.defineProperty(this, "source", {
|
|
6345
|
+
enumerable: true,
|
|
6346
|
+
configurable: true,
|
|
6347
|
+
writable: true,
|
|
6348
|
+
value: void 0
|
|
6349
|
+
});
|
|
6322
6350
|
Object.defineProperty(this, "diyScript", {
|
|
6323
6351
|
enumerable: true,
|
|
6324
6352
|
configurable: true,
|
|
@@ -6487,6 +6515,7 @@ class ThunderToApipost {
|
|
|
6487
6515
|
intro: "",
|
|
6488
6516
|
project_id: "",
|
|
6489
6517
|
};
|
|
6518
|
+
this.source = 'vscode';
|
|
6490
6519
|
}
|
|
6491
6520
|
clear() {
|
|
6492
6521
|
this.apis = [];
|
|
@@ -6498,6 +6527,7 @@ class ThunderToApipost {
|
|
|
6498
6527
|
intro: "",
|
|
6499
6528
|
project_id: "",
|
|
6500
6529
|
};
|
|
6530
|
+
this.source = 'workbench';
|
|
6501
6531
|
}
|
|
6502
6532
|
initProject(json, project_id) {
|
|
6503
6533
|
var _a;
|
|
@@ -6544,7 +6574,7 @@ class ThunderToApipost {
|
|
|
6544
6574
|
}
|
|
6545
6575
|
// auth
|
|
6546
6576
|
completionApiRequestAuth(auth) {
|
|
6547
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w
|
|
6577
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
6548
6578
|
const customAuth = {};
|
|
6549
6579
|
if ((auth === null || auth === void 0 ? void 0 : auth.type) === "bearer") {
|
|
6550
6580
|
customAuth["type"] = "bearer";
|
|
@@ -6582,22 +6612,33 @@ class ThunderToApipost {
|
|
|
6582
6612
|
}
|
|
6583
6613
|
else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
|
|
6584
6614
|
customAuth["type"] = "oauth2";
|
|
6615
|
+
const getGrantType = (thunder_grant_type) => {
|
|
6616
|
+
if (THUNDER_CLIENT_GRANT_TYPES[thunder_grant_type]) {
|
|
6617
|
+
return THUNDER_CLIENT_GRANT_TYPES[thunder_grant_type];
|
|
6618
|
+
}
|
|
6619
|
+
else if (this.source === 'vscode') {
|
|
6620
|
+
return 'password_credentials';
|
|
6621
|
+
}
|
|
6622
|
+
else {
|
|
6623
|
+
return 'authorization_code';
|
|
6624
|
+
}
|
|
6625
|
+
};
|
|
6585
6626
|
customAuth["oauth2"] = {
|
|
6586
6627
|
addTokenTo: "header",
|
|
6587
6628
|
headerPrefix: "Bearer",
|
|
6588
6629
|
access_token: "",
|
|
6589
|
-
grant_type:
|
|
6590
|
-
redirect_uri: ((
|
|
6591
|
-
authUrl: ((
|
|
6592
|
-
accessTokenUrl: ((
|
|
6593
|
-
clientId: ((
|
|
6594
|
-
clientSecret: ((
|
|
6595
|
-
username: ((
|
|
6596
|
-
password: ((
|
|
6630
|
+
grant_type: getGrantType((_m = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _m === void 0 ? void 0 : _m.grantType),
|
|
6631
|
+
redirect_uri: ((_o = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _o === void 0 ? void 0 : _o.callbackUrl) || "",
|
|
6632
|
+
authUrl: ((_p = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _p === void 0 ? void 0 : _p.authUrl) || "",
|
|
6633
|
+
accessTokenUrl: ((_q = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _q === void 0 ? void 0 : _q.tokenUrl) || "",
|
|
6634
|
+
clientId: ((_r = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _r === void 0 ? void 0 : _r.clientId) || "",
|
|
6635
|
+
clientSecret: ((_s = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _s === void 0 ? void 0 : _s.clientSecret) || "",
|
|
6636
|
+
username: ((_t = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _t === void 0 ? void 0 : _t.username) || "",
|
|
6637
|
+
password: ((_u = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _u === void 0 ? void 0 : _u.password) || "",
|
|
6597
6638
|
challengeAlgorithm: "S256",
|
|
6598
6639
|
code_verifier: "Bearer",
|
|
6599
|
-
scope: ((
|
|
6600
|
-
state: ((
|
|
6640
|
+
scope: ((_v = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _v === void 0 ? void 0 : _v.scope) || "",
|
|
6641
|
+
state: ((_w = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _w === void 0 ? void 0 : _w.state) || "",
|
|
6601
6642
|
client_authentication: "header",
|
|
6602
6643
|
refreshTokenUrl: "",
|
|
6603
6644
|
authRequestParams: [],
|
|
@@ -7023,9 +7064,10 @@ class ThunderToApipost {
|
|
|
7023
7064
|
return throwResult$1("error", "Must contain a ThunderJson field", {});
|
|
7024
7065
|
}
|
|
7025
7066
|
}
|
|
7026
|
-
convert(json, project_id) {
|
|
7067
|
+
convert(json, project_id, option) {
|
|
7027
7068
|
this.clear();
|
|
7028
7069
|
try {
|
|
7070
|
+
this.source = (option === null || option === void 0 ? void 0 : option.source) || 'vscode';
|
|
7029
7071
|
this.initProject(json, project_id);
|
|
7030
7072
|
this.initGlobal(json === null || json === void 0 ? void 0 : json.settings);
|
|
7031
7073
|
const folders = lodash.map(json === null || json === void 0 ? void 0 : json.folders, (it) => (Object.assign(Object.assign({}, it), { type: "folder" })));
|