echoapi-converter 0.0.38 → 0.0.40
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 +3 -0
- package/dist/index.js +146 -43
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -259,6 +259,9 @@ declare class ThunderToApipost {
|
|
|
259
259
|
private completionTests;
|
|
260
260
|
private completionApiRequest;
|
|
261
261
|
private completionApiTarget;
|
|
262
|
+
private completionWs2Request;
|
|
263
|
+
private completionWs2Message;
|
|
264
|
+
private completionWs2Target;
|
|
262
265
|
private completionApis;
|
|
263
266
|
private initApis;
|
|
264
267
|
private initGlobal;
|
package/dist/index.js
CHANGED
|
@@ -503,7 +503,7 @@ const throwResult$1 = (status, message, data = '') => {
|
|
|
503
503
|
return {
|
|
504
504
|
status,
|
|
505
505
|
message,
|
|
506
|
-
data
|
|
506
|
+
data,
|
|
507
507
|
};
|
|
508
508
|
};
|
|
509
509
|
const transExample = (example) => {
|
|
@@ -523,21 +523,22 @@ const getBeautifulRaw = (raw) => {
|
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
525
|
const isArray = (value) => {
|
|
526
|
-
return Object.prototype.toString.call(value) ===
|
|
526
|
+
return Object.prototype.toString.call(value) === "[object Array]";
|
|
527
527
|
};
|
|
528
528
|
const isObject = (value) => {
|
|
529
|
-
return Object.prototype.toString.call(value) ===
|
|
529
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
530
530
|
};
|
|
531
531
|
const isURL = (_url) => {
|
|
532
532
|
if (!_url) {
|
|
533
533
|
return false;
|
|
534
534
|
}
|
|
535
535
|
_url = lodash.trim(_url);
|
|
536
|
-
return (_url.substr(0, 7).toLowerCase() ===
|
|
536
|
+
return (_url.substr(0, 7).toLowerCase() === "http://" ||
|
|
537
|
+
_url.substr(0, 8).toLowerCase() === "https://");
|
|
537
538
|
};
|
|
538
539
|
const createUrl = (_url) => {
|
|
539
|
-
if (typeof _url !==
|
|
540
|
-
_url +=
|
|
540
|
+
if (typeof _url !== "string") {
|
|
541
|
+
_url += "";
|
|
541
542
|
}
|
|
542
543
|
if (!isURL(_url)) {
|
|
543
544
|
_url = `http://${_url}`;
|
|
@@ -557,7 +558,7 @@ const createUrl = (_url) => {
|
|
|
557
558
|
}
|
|
558
559
|
catch (_a) {
|
|
559
560
|
const http_url = `https://www.echoapi.cn${_url.substring(origin.length)}`;
|
|
560
|
-
const a = document.createElement(
|
|
561
|
+
const a = document.createElement("a");
|
|
561
562
|
a.href = http_url;
|
|
562
563
|
urls = {
|
|
563
564
|
source: _url,
|
|
@@ -570,23 +571,23 @@ const createUrl = (_url) => {
|
|
|
570
571
|
search: a.search,
|
|
571
572
|
pathname: a.pathname,
|
|
572
573
|
// eslint-disable-next-line no-useless-escape
|
|
573
|
-
file: (a.pathname.match(/\/([^\/?#]+)$/i) || [
|
|
574
|
+
file: (a.pathname.match(/\/([^\/?#]+)$/i) || ["", ""])[1],
|
|
574
575
|
hash: a.hash,
|
|
575
576
|
};
|
|
576
577
|
}
|
|
577
578
|
return urls;
|
|
578
579
|
};
|
|
579
580
|
// 根据url生成新的restful数组
|
|
580
|
-
const genRestfulByUrl = (url, oldParameter, key =
|
|
581
|
+
const genRestfulByUrl = (url, oldParameter, key = "key") => {
|
|
581
582
|
const restfulList = [];
|
|
582
583
|
// 自动拼接url http://
|
|
583
584
|
if (!isURL(url)) {
|
|
584
585
|
url = `http://${url}`;
|
|
585
586
|
}
|
|
586
587
|
const urlObj = createUrl(url);
|
|
587
|
-
const paths = urlObj.pathname.split(
|
|
588
|
+
const paths = urlObj.pathname.split("/");
|
|
588
589
|
lodash.forEach(paths, (pathsItem) => {
|
|
589
|
-
if (pathsItem.substring(0, 1) ===
|
|
590
|
+
if (pathsItem.substring(0, 1) === ":" && pathsItem.length > 1) {
|
|
590
591
|
let obj = null;
|
|
591
592
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
592
593
|
[key]: pathsItem.substring(1, pathsItem.length),
|
|
@@ -596,12 +597,12 @@ const genRestfulByUrl = (url, oldParameter, key = 'key') => {
|
|
|
596
597
|
}
|
|
597
598
|
restfulList.push({
|
|
598
599
|
param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
|
|
599
|
-
field_type:
|
|
600
|
+
field_type: "String",
|
|
600
601
|
is_checked: 1,
|
|
601
602
|
key: pathsItem.substring(1, pathsItem.length),
|
|
602
603
|
not_null: 1,
|
|
603
|
-
value: (obj === null || obj === void 0 ? void 0 : obj.value) ||
|
|
604
|
-
description: (obj === null || obj === void 0 ? void 0 : obj.description) ||
|
|
604
|
+
value: (obj === null || obj === void 0 ? void 0 : obj.value) || "",
|
|
605
|
+
description: (obj === null || obj === void 0 ? void 0 : obj.description) || "",
|
|
605
606
|
});
|
|
606
607
|
}
|
|
607
608
|
});
|
|
@@ -611,7 +612,7 @@ const genRestfulByUrl = (url, oldParameter, key = 'key') => {
|
|
|
611
612
|
if (isArray(matches) && matches.length > 0) {
|
|
612
613
|
lodash.forEach(matches, (matchesItem) => {
|
|
613
614
|
if (matchesItem.length > 0) {
|
|
614
|
-
matchesItem = matchesItem.replace(/^{|}$/g,
|
|
615
|
+
matchesItem = matchesItem.replace(/^{|}$/g, "");
|
|
615
616
|
let obj = null;
|
|
616
617
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
617
618
|
[key]: matchesItem,
|
|
@@ -621,12 +622,12 @@ const genRestfulByUrl = (url, oldParameter, key = 'key') => {
|
|
|
621
622
|
}
|
|
622
623
|
restfulList.push({
|
|
623
624
|
param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
|
|
624
|
-
field_type:
|
|
625
|
+
field_type: "String",
|
|
625
626
|
is_checked: 1,
|
|
626
627
|
key: matchesItem,
|
|
627
628
|
not_null: 1,
|
|
628
|
-
value: (obj === null || obj === void 0 ? void 0 : obj.value) ||
|
|
629
|
-
description: (obj === null || obj === void 0 ? void 0 : obj.description) ||
|
|
629
|
+
value: (obj === null || obj === void 0 ? void 0 : obj.value) || "",
|
|
630
|
+
description: (obj === null || obj === void 0 ? void 0 : obj.description) || "",
|
|
630
631
|
});
|
|
631
632
|
}
|
|
632
633
|
});
|
|
@@ -637,7 +638,7 @@ const genRestfulByUrl = (url, oldParameter, key = 'key') => {
|
|
|
637
638
|
};
|
|
638
639
|
const removePTags = (str) => {
|
|
639
640
|
// 使用正则表达式替换<p>和</p>标签为空字符串
|
|
640
|
-
return str.replace(/<\/?[^>]+(>|$)/g,
|
|
641
|
+
return str.replace(/<\/?[^>]+(>|$)/g, "");
|
|
641
642
|
};
|
|
642
643
|
const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
643
644
|
const restfulList = [];
|
|
@@ -646,9 +647,9 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
646
647
|
url = `http://${url}`;
|
|
647
648
|
}
|
|
648
649
|
const urlObj = createUrl(url);
|
|
649
|
-
const paths = urlObj.pathname.split(
|
|
650
|
+
const paths = urlObj.pathname.split("/");
|
|
650
651
|
lodash.forEach(paths, (pathsItem) => {
|
|
651
|
-
if (pathsItem.substring(0, 1) ===
|
|
652
|
+
if (pathsItem.substring(0, 1) === ":" && pathsItem.length > 1) {
|
|
652
653
|
let obj = null;
|
|
653
654
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
654
655
|
name: pathsItem.substring(1, pathsItem.length),
|
|
@@ -658,12 +659,12 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
658
659
|
}
|
|
659
660
|
restfulList.push({
|
|
660
661
|
param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
|
|
661
|
-
field_type:
|
|
662
|
+
field_type: "String",
|
|
662
663
|
is_checked: 1,
|
|
663
664
|
key: pathsItem.substring(1, pathsItem.length),
|
|
664
665
|
not_null: 1,
|
|
665
|
-
value: (obj === null || obj === void 0 ? void 0 : obj.example) ||
|
|
666
|
-
description: (obj === null || obj === void 0 ? void 0 : obj.desc) ||
|
|
666
|
+
value: (obj === null || obj === void 0 ? void 0 : obj.example) || "",
|
|
667
|
+
description: (obj === null || obj === void 0 ? void 0 : obj.desc) || "",
|
|
667
668
|
});
|
|
668
669
|
}
|
|
669
670
|
});
|
|
@@ -673,7 +674,7 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
673
674
|
if (isArray(matches) && matches.length > 0) {
|
|
674
675
|
lodash.forEach(matches, (matchesItem) => {
|
|
675
676
|
if (matchesItem.length > 0) {
|
|
676
|
-
matchesItem = matchesItem.replace(/^{|}$/g,
|
|
677
|
+
matchesItem = matchesItem.replace(/^{|}$/g, "");
|
|
677
678
|
let obj = null;
|
|
678
679
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
679
680
|
name: matchesItem,
|
|
@@ -683,12 +684,12 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
683
684
|
}
|
|
684
685
|
restfulList.push({
|
|
685
686
|
param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
|
|
686
|
-
field_type:
|
|
687
|
+
field_type: "String",
|
|
687
688
|
is_checked: 1,
|
|
688
689
|
key: matchesItem,
|
|
689
690
|
not_null: 1,
|
|
690
|
-
value: (obj === null || obj === void 0 ? void 0 : obj.example) ||
|
|
691
|
-
description: (obj === null || obj === void 0 ? void 0 : obj.desc) ||
|
|
691
|
+
value: (obj === null || obj === void 0 ? void 0 : obj.example) || "",
|
|
692
|
+
description: (obj === null || obj === void 0 ? void 0 : obj.desc) || "",
|
|
692
693
|
});
|
|
693
694
|
}
|
|
694
695
|
});
|
|
@@ -699,9 +700,9 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
699
700
|
};
|
|
700
701
|
const fixUrlPath = (url) => {
|
|
701
702
|
try {
|
|
702
|
-
const index = url.indexOf(
|
|
703
|
+
const index = url.indexOf("://");
|
|
703
704
|
let path;
|
|
704
|
-
let protocolAndDomain =
|
|
705
|
+
let protocolAndDomain = "";
|
|
705
706
|
if (index === -1) {
|
|
706
707
|
path = url;
|
|
707
708
|
}
|
|
@@ -711,7 +712,7 @@ const fixUrlPath = (url) => {
|
|
|
711
712
|
path = url.slice(index + 3);
|
|
712
713
|
}
|
|
713
714
|
// 修正路径中的 '//'
|
|
714
|
-
const fixedPath = path.replace(/\/\/+/g,
|
|
715
|
+
const fixedPath = path.replace(/\/\/+/g, "/");
|
|
715
716
|
// 拼接返回
|
|
716
717
|
return `${protocolAndDomain}${fixedPath}`;
|
|
717
718
|
}
|
|
@@ -733,7 +734,7 @@ const anyToString = (desc) => {
|
|
|
733
734
|
};
|
|
734
735
|
const completionMethod = (method) => {
|
|
735
736
|
if (!method || !lodash.isString(method))
|
|
736
|
-
return
|
|
737
|
+
return "GET";
|
|
737
738
|
if (API_METHODS.includes(method === null || method === void 0 ? void 0 : method.toUpperCase())) {
|
|
738
739
|
return method === null || method === void 0 ? void 0 : method.toUpperCase();
|
|
739
740
|
}
|
|
@@ -742,26 +743,26 @@ const completionMethod = (method) => {
|
|
|
742
743
|
// 根据query数组生成新的url
|
|
743
744
|
const genUrlByQuery = (url, parameter, query_add_equal = 1) => {
|
|
744
745
|
var _a;
|
|
745
|
-
let paramsStr =
|
|
746
|
-
let newUrl = url ||
|
|
747
|
-
const handleEncode = (value =
|
|
746
|
+
let paramsStr = "";
|
|
747
|
+
let newUrl = url || "";
|
|
748
|
+
const handleEncode = (value = "") => {
|
|
748
749
|
let _value = lodash.cloneDeep(value);
|
|
749
750
|
try {
|
|
750
751
|
// 将#符号encode
|
|
751
|
-
_value = _value.replace(/#/g, encodeURIComponent(
|
|
752
|
+
_value = _value.replace(/#/g, encodeURIComponent("#"));
|
|
752
753
|
// 将&符号encode
|
|
753
|
-
_value = _value.replace(/&/g, encodeURIComponent(
|
|
754
|
+
_value = _value.replace(/&/g, encodeURIComponent("&"));
|
|
754
755
|
}
|
|
755
756
|
catch (e) { }
|
|
756
757
|
return _value;
|
|
757
758
|
};
|
|
758
759
|
lodash.forEach(parameter, (item) => {
|
|
759
760
|
if (item.key && lodash.isEqual(item.is_checked, 1)) {
|
|
760
|
-
paramsStr += `${paramsStr ?
|
|
761
|
+
paramsStr += `${paramsStr ? "&" : ""}${handleEncode(item.key)}${lodash.isEqual(query_add_equal, -1) && !item.value ? "" : "="}${handleEncode(item.value)}`;
|
|
761
762
|
}
|
|
762
763
|
});
|
|
763
764
|
// NOTE 原地址有hash的话,需拼接回去
|
|
764
|
-
newUrl = `${lodash.head(newUrl.split(
|
|
765
|
+
newUrl = `${lodash.head(newUrl.split("?"))}${paramsStr ? "?" : ""}${paramsStr}${((_a = urlParse__default["default"](newUrl)) === null || _a === void 0 ? void 0 : _a.hash) || ""}`;
|
|
765
766
|
return newUrl;
|
|
766
767
|
};
|
|
767
768
|
|
|
@@ -3875,6 +3876,7 @@ const completionPostmanTarget = (targetItem) => {
|
|
|
3875
3876
|
};
|
|
3876
3877
|
return {
|
|
3877
3878
|
raw: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || '',
|
|
3879
|
+
host: [(targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || ''],
|
|
3878
3880
|
query: getPostmanQuery((_b = (_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.parameter),
|
|
3879
3881
|
variable: getPostmanVariable((_d = (_c = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _c === void 0 ? void 0 : _c.restful) === null || _d === void 0 ? void 0 : _d.parameter)
|
|
3880
3882
|
};
|
|
@@ -5472,6 +5474,7 @@ class InsomniaToApipost {
|
|
|
5472
5474
|
|
|
5473
5475
|
// @ts-nocheck
|
|
5474
5476
|
const DEFAULT_FIELD_TYPE = ["string", "file"];
|
|
5477
|
+
const APIPOST_GRANT_TYPES = ['authorization_code', 'password_credentials', 'authorization_code_with_pkce'];
|
|
5475
5478
|
class PostmanToApipost {
|
|
5476
5479
|
constructor() {
|
|
5477
5480
|
Object.defineProperty(this, "apis", {
|
|
@@ -5569,7 +5572,7 @@ class PostmanToApipost {
|
|
|
5569
5572
|
addTokenTo: (authMap === null || authMap === void 0 ? void 0 : authMap.addTokenTo) || 'header',
|
|
5570
5573
|
headerPrefix: (authMap === null || authMap === void 0 ? void 0 : authMap.headerPrefix) || 'Bearer',
|
|
5571
5574
|
access_token: '',
|
|
5572
|
-
grant_type: 'authorization_code',
|
|
5575
|
+
grant_type: APIPOST_GRANT_TYPES.includes(authMap === null || authMap === void 0 ? void 0 : authMap.grant_type) ? authMap === null || authMap === void 0 ? void 0 : authMap.grant_type : 'authorization_code',
|
|
5573
5576
|
redirect_uri: (authMap === null || authMap === void 0 ? void 0 : authMap.redirect_uri) || '',
|
|
5574
5577
|
authUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.authUrl) || '',
|
|
5575
5578
|
accessTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.accessTokenUrl) || '',
|
|
@@ -6536,7 +6539,7 @@ class ThunderToApipost {
|
|
|
6536
6539
|
}
|
|
6537
6540
|
// auth
|
|
6538
6541
|
completionApiRequestAuth(auth) {
|
|
6539
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6542
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
6540
6543
|
const customAuth = {};
|
|
6541
6544
|
if ((auth === null || auth === void 0 ? void 0 : auth.type) === "bearer") {
|
|
6542
6545
|
customAuth["type"] = "bearer";
|
|
@@ -6572,6 +6575,31 @@ class ThunderToApipost {
|
|
|
6572
6575
|
sessionToken: ((_l = auth === null || auth === void 0 ? void 0 : auth.aws) === null || _l === void 0 ? void 0 : _l.sessionToken) || "",
|
|
6573
6576
|
};
|
|
6574
6577
|
}
|
|
6578
|
+
else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
|
|
6579
|
+
customAuth["type"] = "oauth2";
|
|
6580
|
+
customAuth["oauth2"] = {
|
|
6581
|
+
addTokenTo: "header",
|
|
6582
|
+
headerPrefix: "Bearer",
|
|
6583
|
+
access_token: "",
|
|
6584
|
+
grant_type: ((_m = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _m === void 0 ? void 0 : _m.grantType) || "authorization_code",
|
|
6585
|
+
redirect_uri: ((_o = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _o === void 0 ? void 0 : _o.callbackUrl) || "",
|
|
6586
|
+
authUrl: ((_p = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _p === void 0 ? void 0 : _p.authUrl) || "",
|
|
6587
|
+
accessTokenUrl: ((_q = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _q === void 0 ? void 0 : _q.tokenUrl) || "",
|
|
6588
|
+
clientId: ((_r = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _r === void 0 ? void 0 : _r.clientId) || "",
|
|
6589
|
+
clientSecret: ((_s = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _s === void 0 ? void 0 : _s.clientSecret) || "",
|
|
6590
|
+
username: ((_t = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _t === void 0 ? void 0 : _t.username) || "",
|
|
6591
|
+
password: ((_u = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _u === void 0 ? void 0 : _u.password) || "",
|
|
6592
|
+
challengeAlgorithm: "S256",
|
|
6593
|
+
code_verifier: "Bearer",
|
|
6594
|
+
scope: ((_v = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _v === void 0 ? void 0 : _v.scope) || "",
|
|
6595
|
+
state: ((_w = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _w === void 0 ? void 0 : _w.state) || "",
|
|
6596
|
+
client_authentication: "header",
|
|
6597
|
+
refreshTokenUrl: "",
|
|
6598
|
+
authRequestParams: [],
|
|
6599
|
+
tokenRequestParams: [],
|
|
6600
|
+
refreshRequestParams: [],
|
|
6601
|
+
};
|
|
6602
|
+
}
|
|
6575
6603
|
return Object.assign(Object.assign({}, DEFAULT_AUTH), customAuth);
|
|
6576
6604
|
}
|
|
6577
6605
|
// script
|
|
@@ -6878,13 +6906,88 @@ class ThunderToApipost {
|
|
|
6878
6906
|
is_force: -1,
|
|
6879
6907
|
};
|
|
6880
6908
|
}
|
|
6909
|
+
completionWs2Request(item) {
|
|
6910
|
+
const headerParameter = this.completionApiRequestParameter(item === null || item === void 0 ? void 0 : item.headers);
|
|
6911
|
+
const queryParameter = this.completionApiRequestParameter(item === null || item === void 0 ? void 0 : item.params);
|
|
6912
|
+
return {
|
|
6913
|
+
header: {
|
|
6914
|
+
parameter: headerParameter,
|
|
6915
|
+
},
|
|
6916
|
+
query: {
|
|
6917
|
+
parameter: queryParameter,
|
|
6918
|
+
},
|
|
6919
|
+
cookie: {
|
|
6920
|
+
parameter: [],
|
|
6921
|
+
},
|
|
6922
|
+
};
|
|
6923
|
+
}
|
|
6924
|
+
completionWs2Message(item) {
|
|
6925
|
+
var _a, _b;
|
|
6926
|
+
return [
|
|
6927
|
+
{
|
|
6928
|
+
name: "Message",
|
|
6929
|
+
param_id: apipostTools.snowflakeId(),
|
|
6930
|
+
request: {
|
|
6931
|
+
mode: (_a = item === null || item === void 0 ? void 0 : item.body) === null || _a === void 0 ? void 0 : _a.type,
|
|
6932
|
+
raw: ((_b = item === null || item === void 0 ? void 0 : item.body) === null || _b === void 0 ? void 0 : _b.raw) || "",
|
|
6933
|
+
raw_parameter: [],
|
|
6934
|
+
raw_schema: {
|
|
6935
|
+
type: "object",
|
|
6936
|
+
},
|
|
6937
|
+
},
|
|
6938
|
+
response: {
|
|
6939
|
+
mode: "text",
|
|
6940
|
+
raw: "",
|
|
6941
|
+
raw_parameter: [],
|
|
6942
|
+
raw_schema: {
|
|
6943
|
+
type: "object",
|
|
6944
|
+
},
|
|
6945
|
+
},
|
|
6946
|
+
},
|
|
6947
|
+
];
|
|
6948
|
+
}
|
|
6949
|
+
// websocket2
|
|
6950
|
+
completionWs2Target(item, parentInfo) {
|
|
6951
|
+
return {
|
|
6952
|
+
target_id: apipostTools.snowflakeId(),
|
|
6953
|
+
project_id: this.project.project_id || "",
|
|
6954
|
+
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
6955
|
+
target_type: "websocket2",
|
|
6956
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || "New Websocket",
|
|
6957
|
+
version: 0,
|
|
6958
|
+
sort: 0,
|
|
6959
|
+
description: (item === null || item === void 0 ? void 0 : item.docs) || "",
|
|
6960
|
+
method: "",
|
|
6961
|
+
url: (item === null || item === void 0 ? void 0 : item.url) || "",
|
|
6962
|
+
mark_id: "1",
|
|
6963
|
+
request: this.completionWs2Request(item),
|
|
6964
|
+
message: this.completionWs2Message(item),
|
|
6965
|
+
attribute_info: {},
|
|
6966
|
+
tags: [],
|
|
6967
|
+
is_force: -1,
|
|
6968
|
+
config: {
|
|
6969
|
+
certificate_verification: -1,
|
|
6970
|
+
information_size: 5,
|
|
6971
|
+
reconnect_num: 5,
|
|
6972
|
+
reconnect_time: 5000,
|
|
6973
|
+
shake_hands_timeout: 0,
|
|
6974
|
+
},
|
|
6975
|
+
};
|
|
6976
|
+
}
|
|
6881
6977
|
completionApis(arr, parentInfo) {
|
|
6882
6978
|
if (arr === null || arr === void 0 ? void 0 : arr.length) {
|
|
6883
6979
|
return arr === null || arr === void 0 ? void 0 : arr.reduce((pre, targetItem) => {
|
|
6980
|
+
console.log(targetItem, "targetItem.type");
|
|
6884
6981
|
if (!lodash.isEqual(targetItem.type, "folder")) {
|
|
6982
|
+
let target;
|
|
6885
6983
|
// 接口
|
|
6886
|
-
|
|
6887
|
-
|
|
6984
|
+
if (lodash.isEqual(targetItem === null || targetItem === void 0 ? void 0 : targetItem.reqType, "ws")) {
|
|
6985
|
+
target = this.completionWs2Target(targetItem, parentInfo);
|
|
6986
|
+
}
|
|
6987
|
+
else {
|
|
6988
|
+
target = this.completionApiTarget(targetItem, parentInfo);
|
|
6989
|
+
}
|
|
6990
|
+
target && pre.push(target);
|
|
6888
6991
|
}
|
|
6889
6992
|
else {
|
|
6890
6993
|
// 目录
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echoapi-converter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "echoapi to swagger",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"rollup-plugin-copy": "^3.5.0",
|
|
27
27
|
"rollup-plugin-dts": "^4.2.2",
|
|
28
28
|
"rollup-plugin-typescript": "^1.0.1",
|
|
29
|
-
"rollup-plugin-typescript2": "^0.36.0"
|
|
29
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
30
|
+
"ts-jest": "^29.2.5"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@types/lodash": "^4.14.202",
|