echoapi-converter 0.0.36 → 0.0.38

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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var lodash = require('lodash');
6
- var ATools = require('apipost-tools');
6
+ var apipostTools = require('apipost-tools');
7
7
  var urlParse = require('url-parse');
8
8
  var MockSchema = require('apipost-mock-schema');
9
9
  var axios = require('axios');
@@ -11,7 +11,6 @@ var SwaggerClient = require('swagger-client');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
14
- var ATools__default = /*#__PURE__*/_interopDefaultLegacy(ATools);
15
14
  var urlParse__default = /*#__PURE__*/_interopDefaultLegacy(urlParse);
16
15
  var MockSchema__default = /*#__PURE__*/_interopDefaultLegacy(MockSchema);
17
16
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
@@ -500,11 +499,11 @@ const handelPathItemResponse = (response) => {
500
499
  return temp_responses;
501
500
  };
502
501
 
503
- const throwResult$1 = (status, message, data = "") => {
502
+ const throwResult$1 = (status, message, data = '') => {
504
503
  return {
505
504
  status,
506
505
  message,
507
- data,
506
+ data
508
507
  };
509
508
  };
510
509
  const transExample = (example) => {
@@ -517,29 +516,28 @@ const transExample = (example) => {
517
516
  const getBeautifulRaw = (raw) => {
518
517
  var _a;
519
518
  try {
520
- return (_a = ATools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
519
+ return (_a = apipostTools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
521
520
  }
522
521
  catch (err) {
523
522
  return raw;
524
523
  }
525
524
  };
526
525
  const isArray = (value) => {
527
- return Object.prototype.toString.call(value) === "[object Array]";
526
+ return Object.prototype.toString.call(value) === '[object Array]';
528
527
  };
529
528
  const isObject = (value) => {
530
- return Object.prototype.toString.call(value) === "[object Object]";
529
+ return Object.prototype.toString.call(value) === '[object Object]';
531
530
  };
532
531
  const isURL = (_url) => {
533
532
  if (!_url) {
534
533
  return false;
535
534
  }
536
535
  _url = lodash.trim(_url);
537
- return (_url.substr(0, 7).toLowerCase() === "http://" ||
538
- _url.substr(0, 8).toLowerCase() === "https://");
536
+ return (_url.substr(0, 7).toLowerCase() === 'http://' || _url.substr(0, 8).toLowerCase() === 'https://');
539
537
  };
540
538
  const createUrl = (_url) => {
541
- if (typeof _url !== "string") {
542
- _url += "";
539
+ if (typeof _url !== 'string') {
540
+ _url += '';
543
541
  }
544
542
  if (!isURL(_url)) {
545
543
  _url = `http://${_url}`;
@@ -559,7 +557,7 @@ const createUrl = (_url) => {
559
557
  }
560
558
  catch (_a) {
561
559
  const http_url = `https://www.echoapi.cn${_url.substring(origin.length)}`;
562
- const a = document.createElement("a");
560
+ const a = document.createElement('a');
563
561
  a.href = http_url;
564
562
  urls = {
565
563
  source: _url,
@@ -572,23 +570,23 @@ const createUrl = (_url) => {
572
570
  search: a.search,
573
571
  pathname: a.pathname,
574
572
  // eslint-disable-next-line no-useless-escape
575
- file: (a.pathname.match(/\/([^\/?#]+)$/i) || ["", ""])[1],
573
+ file: (a.pathname.match(/\/([^\/?#]+)$/i) || ['', ''])[1],
576
574
  hash: a.hash,
577
575
  };
578
576
  }
579
577
  return urls;
580
578
  };
581
579
  // 根据url生成新的restful数组
582
- const genRestfulByUrl = (url, oldParameter, key = "key") => {
580
+ const genRestfulByUrl = (url, oldParameter, key = 'key') => {
583
581
  const restfulList = [];
584
582
  // 自动拼接url http://
585
583
  if (!isURL(url)) {
586
584
  url = `http://${url}`;
587
585
  }
588
586
  const urlObj = createUrl(url);
589
- const paths = urlObj.pathname.split("/");
587
+ const paths = urlObj.pathname.split('/');
590
588
  lodash.forEach(paths, (pathsItem) => {
591
- if (pathsItem.substring(0, 1) === ":" && pathsItem.length > 1) {
589
+ if (pathsItem.substring(0, 1) === ':' && pathsItem.length > 1) {
592
590
  let obj = null;
593
591
  const oldIndex = lodash.findIndex(oldParameter, {
594
592
  [key]: pathsItem.substring(1, pathsItem.length),
@@ -597,13 +595,13 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
597
595
  obj = oldParameter[oldIndex];
598
596
  }
599
597
  restfulList.push({
600
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
601
- field_type: "String",
598
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
599
+ field_type: 'String',
602
600
  is_checked: 1,
603
601
  key: pathsItem.substring(1, pathsItem.length),
604
602
  not_null: 1,
605
- value: (obj === null || obj === void 0 ? void 0 : obj.value) || "",
606
- description: (obj === null || obj === void 0 ? void 0 : obj.description) || "",
603
+ value: (obj === null || obj === void 0 ? void 0 : obj.value) || '',
604
+ description: (obj === null || obj === void 0 ? void 0 : obj.description) || '',
607
605
  });
608
606
  }
609
607
  });
@@ -613,7 +611,7 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
613
611
  if (isArray(matches) && matches.length > 0) {
614
612
  lodash.forEach(matches, (matchesItem) => {
615
613
  if (matchesItem.length > 0) {
616
- matchesItem = matchesItem.replace(/^{|}$/g, "");
614
+ matchesItem = matchesItem.replace(/^{|}$/g, '');
617
615
  let obj = null;
618
616
  const oldIndex = lodash.findIndex(oldParameter, {
619
617
  [key]: matchesItem,
@@ -622,13 +620,13 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
622
620
  obj = oldParameter[oldIndex];
623
621
  }
624
622
  restfulList.push({
625
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
626
- field_type: "String",
623
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
624
+ field_type: 'String',
627
625
  is_checked: 1,
628
626
  key: matchesItem,
629
627
  not_null: 1,
630
- value: (obj === null || obj === void 0 ? void 0 : obj.value) || "",
631
- description: (obj === null || obj === void 0 ? void 0 : obj.description) || "",
628
+ value: (obj === null || obj === void 0 ? void 0 : obj.value) || '',
629
+ description: (obj === null || obj === void 0 ? void 0 : obj.description) || '',
632
630
  });
633
631
  }
634
632
  });
@@ -639,7 +637,7 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
639
637
  };
640
638
  const removePTags = (str) => {
641
639
  // 使用正则表达式替换<p>和</p>标签为空字符串
642
- return str.replace(/<\/?[^>]+(>|$)/g, "");
640
+ return str.replace(/<\/?[^>]+(>|$)/g, '');
643
641
  };
644
642
  const yapiGenRestfulByUrl = (url, oldParameter) => {
645
643
  const restfulList = [];
@@ -648,9 +646,9 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
648
646
  url = `http://${url}`;
649
647
  }
650
648
  const urlObj = createUrl(url);
651
- const paths = urlObj.pathname.split("/");
649
+ const paths = urlObj.pathname.split('/');
652
650
  lodash.forEach(paths, (pathsItem) => {
653
- if (pathsItem.substring(0, 1) === ":" && pathsItem.length > 1) {
651
+ if (pathsItem.substring(0, 1) === ':' && pathsItem.length > 1) {
654
652
  let obj = null;
655
653
  const oldIndex = lodash.findIndex(oldParameter, {
656
654
  name: pathsItem.substring(1, pathsItem.length),
@@ -659,13 +657,13 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
659
657
  obj = oldParameter[oldIndex];
660
658
  }
661
659
  restfulList.push({
662
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
663
- field_type: "String",
660
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
661
+ field_type: 'String',
664
662
  is_checked: 1,
665
663
  key: pathsItem.substring(1, pathsItem.length),
666
664
  not_null: 1,
667
- value: (obj === null || obj === void 0 ? void 0 : obj.example) || "",
668
- description: (obj === null || obj === void 0 ? void 0 : obj.desc) || "",
665
+ value: (obj === null || obj === void 0 ? void 0 : obj.example) || '',
666
+ description: (obj === null || obj === void 0 ? void 0 : obj.desc) || '',
669
667
  });
670
668
  }
671
669
  });
@@ -675,7 +673,7 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
675
673
  if (isArray(matches) && matches.length > 0) {
676
674
  lodash.forEach(matches, (matchesItem) => {
677
675
  if (matchesItem.length > 0) {
678
- matchesItem = matchesItem.replace(/^{|}$/g, "");
676
+ matchesItem = matchesItem.replace(/^{|}$/g, '');
679
677
  let obj = null;
680
678
  const oldIndex = lodash.findIndex(oldParameter, {
681
679
  name: matchesItem,
@@ -684,13 +682,13 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
684
682
  obj = oldParameter[oldIndex];
685
683
  }
686
684
  restfulList.push({
687
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
688
- field_type: "String",
685
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
686
+ field_type: 'String',
689
687
  is_checked: 1,
690
688
  key: matchesItem,
691
689
  not_null: 1,
692
- value: (obj === null || obj === void 0 ? void 0 : obj.example) || "",
693
- description: (obj === null || obj === void 0 ? void 0 : obj.desc) || "",
690
+ value: (obj === null || obj === void 0 ? void 0 : obj.example) || '',
691
+ description: (obj === null || obj === void 0 ? void 0 : obj.desc) || '',
694
692
  });
695
693
  }
696
694
  });
@@ -701,9 +699,9 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
701
699
  };
702
700
  const fixUrlPath = (url) => {
703
701
  try {
704
- const index = url.indexOf("://");
702
+ const index = url.indexOf('://');
705
703
  let path;
706
- let protocolAndDomain = "";
704
+ let protocolAndDomain = '';
707
705
  if (index === -1) {
708
706
  path = url;
709
707
  }
@@ -713,7 +711,7 @@ const fixUrlPath = (url) => {
713
711
  path = url.slice(index + 3);
714
712
  }
715
713
  // 修正路径中的 '//'
716
- const fixedPath = path.replace(/\/\/+/g, "/");
714
+ const fixedPath = path.replace(/\/\/+/g, '/');
717
715
  // 拼接返回
718
716
  return `${protocolAndDomain}${fixedPath}`;
719
717
  }
@@ -735,7 +733,7 @@ const anyToString = (desc) => {
735
733
  };
736
734
  const completionMethod = (method) => {
737
735
  if (!method || !lodash.isString(method))
738
- return "GET";
736
+ return 'GET';
739
737
  if (API_METHODS.includes(method === null || method === void 0 ? void 0 : method.toUpperCase())) {
740
738
  return method === null || method === void 0 ? void 0 : method.toUpperCase();
741
739
  }
@@ -744,26 +742,26 @@ const completionMethod = (method) => {
744
742
  // 根据query数组生成新的url
745
743
  const genUrlByQuery = (url, parameter, query_add_equal = 1) => {
746
744
  var _a;
747
- let paramsStr = "";
748
- let newUrl = url || "";
749
- const handleEncode = (value = "") => {
745
+ let paramsStr = '';
746
+ let newUrl = url || '';
747
+ const handleEncode = (value = '') => {
750
748
  let _value = lodash.cloneDeep(value);
751
749
  try {
752
750
  // 将#符号encode
753
- _value = _value.replace(/#/g, encodeURIComponent("#"));
751
+ _value = _value.replace(/#/g, encodeURIComponent('#'));
754
752
  // 将&符号encode
755
- _value = _value.replace(/&/g, encodeURIComponent("&"));
753
+ _value = _value.replace(/&/g, encodeURIComponent('&'));
756
754
  }
757
755
  catch (e) { }
758
756
  return _value;
759
757
  };
760
758
  lodash.forEach(parameter, (item) => {
761
759
  if (item.key && lodash.isEqual(item.is_checked, 1)) {
762
- paramsStr += `${paramsStr ? "&" : ""}${handleEncode(item.key)}${lodash.isEqual(query_add_equal, -1) && !item.value ? "" : "="}${handleEncode(item.value)}`;
760
+ paramsStr += `${paramsStr ? '&' : ''}${handleEncode(item.key)}${lodash.isEqual(query_add_equal, -1) && !item.value ? '' : '='}${handleEncode(item.value)}`;
763
761
  }
764
762
  });
765
763
  // NOTE 原地址有hash的话,需拼接回去
766
- newUrl = `${lodash.head(newUrl.split("?"))}${paramsStr ? "?" : ""}${paramsStr}${((_a = urlParse__default["default"](newUrl)) === null || _a === void 0 ? void 0 : _a.hash) || ""}`;
764
+ newUrl = `${lodash.head(newUrl.split('?'))}${paramsStr ? '?' : ''}${paramsStr}${((_a = urlParse__default["default"](newUrl)) === null || _a === void 0 ? void 0 : _a.hash) || ''}`;
767
765
  return newUrl;
768
766
  };
769
767
 
@@ -1113,7 +1111,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1113
1111
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1114
1112
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1115
1113
  is_checked: 1,
1116
- param_id: ATools.snowflakeId(),
1114
+ param_id: apipostTools.snowflakeId(),
1117
1115
  });
1118
1116
  }
1119
1117
  return example;
@@ -1154,7 +1152,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1154
1152
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1155
1153
  type: "String",
1156
1154
  is_checked: 1,
1157
- param_id: ATools.snowflakeId(),
1155
+ param_id: apipostTools.snowflakeId(),
1158
1156
  });
1159
1157
  }
1160
1158
  example.push(value);
@@ -1170,7 +1168,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1170
1168
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1171
1169
  type: "String",
1172
1170
  is_checked: 1,
1173
- param_id: ATools.snowflakeId(),
1171
+ param_id: apipostTools.snowflakeId(),
1174
1172
  });
1175
1173
  }
1176
1174
  example.push(value);
@@ -1186,7 +1184,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1186
1184
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1187
1185
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1188
1186
  is_checked: 1,
1189
- param_id: ATools.snowflakeId(),
1187
+ param_id: apipostTools.snowflakeId(),
1190
1188
  });
1191
1189
  }
1192
1190
  return (schema === null || schema === void 0 ? void 0 : schema.example) || (schema === null || schema === void 0 ? void 0 : schema.default) || 0;
@@ -1200,7 +1198,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1200
1198
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1201
1199
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1202
1200
  is_checked: 1,
1203
- param_id: ATools.snowflakeId(),
1201
+ param_id: apipostTools.snowflakeId(),
1204
1202
  });
1205
1203
  }
1206
1204
  return (schema === null || schema === void 0 ? void 0 : schema.example) || (schema === null || schema === void 0 ? void 0 : schema.default) || "";
@@ -1215,7 +1213,7 @@ const replaceRef = (schemaObj) => {
1215
1213
  if (typeof value === 'object' && value !== null) {
1216
1214
  // 查找并替换 insAppInfo 对象
1217
1215
  if (lodash.has(value, 'ref') || lodash.has(value, '$$ref')) {
1218
- let newIuid = ATools.snowflakeId();
1216
+ let newIuid = apipostTools.snowflakeId();
1219
1217
  if ((value === null || value === void 0 ? void 0 : value.ref) && value.ref.startsWith('http://localhost:8000/')) {
1220
1218
  const index = (_a = value.ref) === null || _a === void 0 ? void 0 : _a.indexOf('#');
1221
1219
  if (index !== -1) {
@@ -1260,7 +1258,7 @@ const swaggerSchema2apipostSchema = (schemaObj) => {
1260
1258
  // 还原为对象
1261
1259
  jsonSchema = JSON.parse(jsonSchemaStr);
1262
1260
  if (lodash.has(jsonSchema, 'ref') || lodash.has(jsonSchema, '$$ref')) {
1263
- let newIuid = ATools.snowflakeId();
1261
+ let newIuid = apipostTools.snowflakeId();
1264
1262
  if ((jsonSchema === null || jsonSchema === void 0 ? void 0 : jsonSchema.ref) && jsonSchema.ref.startsWith("http://localhost:8000/")) {
1265
1263
  // jsonSchema.ref = jsonSchema.ref.substring(22);
1266
1264
  const index = (_a = jsonSchema.ref) === null || _a === void 0 ? void 0 : _a.indexOf('#');
@@ -1436,7 +1434,7 @@ class SwaggerToApipost {
1436
1434
  getBeautifulRaw(raw) {
1437
1435
  var _a;
1438
1436
  try {
1439
- return (_a = ATools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
1437
+ return (_a = apipostTools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
1440
1438
  }
1441
1439
  catch (err) {
1442
1440
  return raw;
@@ -1613,7 +1611,7 @@ class SwaggerToApipost {
1613
1611
  not_null: (parameter === null || parameter === void 0 ? void 0 : parameter.required) ? 1 : -1, // 是否为空
1614
1612
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1615
1613
  field_type: getFidldType((_b = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _b === void 0 ? void 0 : _b.type), // 类型
1616
- param_id: ATools.snowflakeId(),
1614
+ param_id: apipostTools.snowflakeId(),
1617
1615
  });
1618
1616
  }
1619
1617
  else if (parameter.in == "header") {
@@ -1633,7 +1631,7 @@ class SwaggerToApipost {
1633
1631
  not_null: parameter.required ? 1 : -1, // 是否为空
1634
1632
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1635
1633
  field_type: getFidldType((_d = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _d === void 0 ? void 0 : _d.type), // 类型
1636
- param_id: ATools.snowflakeId(),
1634
+ param_id: apipostTools.snowflakeId(),
1637
1635
  });
1638
1636
  }
1639
1637
  else if (parameter.in == "path") {
@@ -1653,7 +1651,7 @@ class SwaggerToApipost {
1653
1651
  not_null: parameter.required ? 1 : -1, // 是否为空
1654
1652
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1655
1653
  field_type: getFidldType((_f = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _f === void 0 ? void 0 : _f.type), // 类型
1656
- param_id: ATools.snowflakeId(),
1654
+ param_id: apipostTools.snowflakeId(),
1657
1655
  });
1658
1656
  }
1659
1657
  }
@@ -1697,7 +1695,7 @@ class SwaggerToApipost {
1697
1695
  field_type: lodash.has(item, "type")
1698
1696
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
1699
1697
  : "String",
1700
- param_id: ATools.snowflakeId(),
1698
+ param_id: apipostTools.snowflakeId(),
1701
1699
  });
1702
1700
  }
1703
1701
  }
@@ -1800,7 +1798,7 @@ class SwaggerToApipost {
1800
1798
  }
1801
1799
  else {
1802
1800
  // 其他示例
1803
- const newUUID = ATools.snowflakeId();
1801
+ const newUUID = apipostTools.snowflakeId();
1804
1802
  response.example.push({
1805
1803
  example_id: newUUID,
1806
1804
  raw: Raw_text,
@@ -1871,7 +1869,7 @@ class SwaggerToApipost {
1871
1869
  }
1872
1870
  else {
1873
1871
  // 其他示例
1874
- const newUUID = ATools.snowflakeId();
1872
+ const newUUID = apipostTools.snowflakeId();
1875
1873
  let originRaw;
1876
1874
  try {
1877
1875
  if (Object.prototype.toString.call(example) ===
@@ -1928,7 +1926,7 @@ class SwaggerToApipost {
1928
1926
  }
1929
1927
  else {
1930
1928
  // 其他示例
1931
- const newUUID = ATools.snowflakeId();
1929
+ const newUUID = apipostTools.snowflakeId();
1932
1930
  response.example.push({
1933
1931
  example_id: newUUID,
1934
1932
  raw: Raw_text,
@@ -1950,7 +1948,7 @@ class SwaggerToApipost {
1950
1948
  }
1951
1949
  else {
1952
1950
  response.example.push({
1953
- example_id: ATools.snowflakeId(),
1951
+ example_id: apipostTools.snowflakeId(),
1954
1952
  raw: "",
1955
1953
  raw_parameter: [],
1956
1954
  expect: {
@@ -2086,7 +2084,7 @@ class SwaggerToApipost {
2086
2084
  not_null: 1,
2087
2085
  description: "",
2088
2086
  field_type: "String",
2089
- param_id: ATools.snowflakeId(),
2087
+ param_id: apipostTools.snowflakeId(),
2090
2088
  });
2091
2089
  }
2092
2090
  if (lodash.has(swaggerApi, "parameters")) {
@@ -2120,7 +2118,7 @@ class SwaggerToApipost {
2120
2118
  not_null: parameter.required ? 1 : -1, // 是否为空
2121
2119
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2122
2120
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2123
- param_id: ATools.snowflakeId(),
2121
+ param_id: apipostTools.snowflakeId(),
2124
2122
  });
2125
2123
  }
2126
2124
  else if (parameter.in == "header") {
@@ -2140,7 +2138,7 @@ class SwaggerToApipost {
2140
2138
  not_null: parameter.required ? 1 : -1, // 是否为空
2141
2139
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2142
2140
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2143
- param_id: ATools.snowflakeId(),
2141
+ param_id: apipostTools.snowflakeId(),
2144
2142
  });
2145
2143
  }
2146
2144
  else if (parameter.in == "path") {
@@ -2160,7 +2158,7 @@ class SwaggerToApipost {
2160
2158
  not_null: parameter.required ? 1 : -1, // 是否为空
2161
2159
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2162
2160
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2163
- param_id: ATools.snowflakeId(),
2161
+ param_id: apipostTools.snowflakeId(),
2164
2162
  });
2165
2163
  }
2166
2164
  else if (parameter.in == "body") {
@@ -2209,7 +2207,7 @@ class SwaggerToApipost {
2209
2207
  not_null: parameter.required ? 1 : -1, // 是否为空
2210
2208
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2211
2209
  field_type: getFidldType(((_g = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _g === void 0 ? void 0 : _g.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type)), // 类型
2212
- param_id: ATools.snowflakeId(),
2210
+ param_id: apipostTools.snowflakeId(),
2213
2211
  });
2214
2212
  }
2215
2213
  }
@@ -2280,7 +2278,7 @@ class SwaggerToApipost {
2280
2278
  }
2281
2279
  else {
2282
2280
  // 其他示例
2283
- const newUUID = ATools.snowflakeId();
2281
+ const newUUID = apipostTools.snowflakeId();
2284
2282
  response.example.push({
2285
2283
  example_id: newUUID,
2286
2284
  raw: Raw_text,
@@ -2349,7 +2347,7 @@ class SwaggerToApipost {
2349
2347
  }
2350
2348
  else {
2351
2349
  // 其他示例
2352
- const newUUID = ATools.snowflakeId();
2350
+ const newUUID = apipostTools.snowflakeId();
2353
2351
  response.example.push({
2354
2352
  example_id: newUUID,
2355
2353
  raw: Raw_text,
@@ -2375,7 +2373,7 @@ class SwaggerToApipost {
2375
2373
  }
2376
2374
  else {
2377
2375
  // 其他示例
2378
- const newUUID = ATools.snowflakeId();
2376
+ const newUUID = apipostTools.snowflakeId();
2379
2377
  response.example.push({
2380
2378
  example_id: newUUID,
2381
2379
  raw: "",
@@ -2559,7 +2557,7 @@ class ApidocToApipost {
2559
2557
  return parameter.map((item) => {
2560
2558
  var _a;
2561
2559
  return ({
2562
- param_id: ATools.snowflakeId(),
2560
+ param_id: apipostTools.snowflakeId(),
2563
2561
  description: removePTags((item === null || item === void 0 ? void 0 : item.description) || ""),
2564
2562
  field_type: lodash.isString(item === null || item === void 0 ? void 0 : item.type) && ((_a = item === null || item === void 0 ? void 0 : item.type) === null || _a === void 0 ? void 0 : _a.includes("[]"))
2565
2563
  ? "Array"
@@ -2652,7 +2650,7 @@ class ApidocToApipost {
2652
2650
  ? (_g = (_f = (_e = item === null || item === void 0 ? void 0 : item.success) === null || _e === void 0 ? void 0 : _e.examples) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.content
2653
2651
  : "";
2654
2652
  pre.push({
2655
- example_id: ATools.snowflakeId(),
2653
+ example_id: apipostTools.snowflakeId(),
2656
2654
  raw_parameter: [],
2657
2655
  raw: getBeautifulRaw(raw || ""),
2658
2656
  expect: {
@@ -2676,7 +2674,7 @@ class ApidocToApipost {
2676
2674
  ? (_g = (_f = (_e = item === null || item === void 0 ? void 0 : item.error) === null || _e === void 0 ? void 0 : _e.examples) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.content
2677
2675
  : "";
2678
2676
  pre.push({
2679
- example_id: ATools.snowflakeId(),
2677
+ example_id: apipostTools.snowflakeId(),
2680
2678
  raw_parameter: [],
2681
2679
  raw: getBeautifulRaw(raw || ""),
2682
2680
  expect: {
@@ -2743,7 +2741,7 @@ class ApidocToApipost {
2743
2741
  id = this.foldersMap[item === null || item === void 0 ? void 0 : item.group];
2744
2742
  }
2745
2743
  else if (item === null || item === void 0 ? void 0 : item.group) {
2746
- id = ATools.snowflakeId();
2744
+ id = apipostTools.snowflakeId();
2747
2745
  this.foldersMap[item === null || item === void 0 ? void 0 : item.group] = id;
2748
2746
  pre.push({
2749
2747
  target_id: id,
@@ -2762,7 +2760,7 @@ class ApidocToApipost {
2762
2760
  });
2763
2761
  }
2764
2762
  pre.push({
2765
- target_id: ATools.snowflakeId(),
2763
+ target_id: apipostTools.snowflakeId(),
2766
2764
  project_id: this.project.project_id || "",
2767
2765
  parent_id: id || "0",
2768
2766
  target_type: "api",
@@ -2998,7 +2996,7 @@ class ApifoxToApipost {
2998
2996
  completionParameter(parameter) {
2999
2997
  if (isArray(parameter)) {
3000
2998
  return parameter.map(({ description = "", type = "String", defaultEnable = true, name = "", defaultValue = "", required = 1, }) => ({
3001
- param_id: ATools.snowflakeId(),
2999
+ param_id: apipostTools.snowflakeId(),
3002
3000
  description,
3003
3001
  field_type: type
3004
3002
  ? type.charAt(0).toUpperCase() + type.slice(1)
@@ -3048,7 +3046,7 @@ class ApifoxToApipost {
3048
3046
  if (isArray(environments)) {
3049
3047
  const envs = environments.reduce((pre, item) => {
3050
3048
  pre.push({
3051
- env_id: ATools.snowflakeId(),
3049
+ env_id: apipostTools.snowflakeId(),
3052
3050
  name: item === null || item === void 0 ? void 0 : item.name,
3053
3051
  is_private: (item === null || item === void 0 ? void 0 : item.visibility) === "protected"
3054
3052
  ? -1
@@ -3071,7 +3069,7 @@ class ApifoxToApipost {
3071
3069
  var _a;
3072
3070
  if (isArray(servers)) {
3073
3071
  this.global.servers = (_a = servers === null || servers === void 0 ? void 0 : servers.filter((item) => item === null || item === void 0 ? void 0 : item.id)) === null || _a === void 0 ? void 0 : _a.map((item) => {
3074
- const server_id = ATools.snowflakeId();
3072
+ const server_id = apipostTools.snowflakeId();
3075
3073
  this.serversMap[item.id] = {
3076
3074
  server_id: (item === null || item === void 0 ? void 0 : item.id) === "default" ? "1" : server_id,
3077
3075
  name: (item === null || item === void 0 ? void 0 : item.name) || `Server${server_id}`,
@@ -3102,7 +3100,7 @@ class ApifoxToApipost {
3102
3100
  this.global.mock_custom_rules = mapRules === null || mapRules === void 0 ? void 0 : mapRules.map((item) => {
3103
3101
  var _a;
3104
3102
  return ({
3105
- mock_custom_rule_id: ATools.snowflakeId(),
3103
+ mock_custom_rule_id: apipostTools.snowflakeId(),
3106
3104
  project_id: this.project.project_id,
3107
3105
  field_type: item === null || item === void 0 ? void 0 : item.type,
3108
3106
  match_type: ((_a = ["wildcard", "exact"]) === null || _a === void 0 ? void 0 : _a.includes(item === null || item === void 0 ? void 0 : item.matchType))
@@ -3174,7 +3172,7 @@ class ApifoxToApipost {
3174
3172
  if (lodash.has(item, "items") && !lodash.has(item, "schema")) {
3175
3173
  // 这是目录操作
3176
3174
  const parent = {
3177
- model_id: ATools.snowflakeId(),
3175
+ model_id: apipostTools.snowflakeId(),
3178
3176
  model_type: "folder",
3179
3177
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3180
3178
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.model_id) || "0",
@@ -3188,7 +3186,7 @@ class ApifoxToApipost {
3188
3186
  if (!lodash.has(item, "items") && lodash.has(item, "schema")) {
3189
3187
  // 这是模型操作
3190
3188
  // 这里要做Map映射 引用ref替换使用
3191
- const model_id = ATools.snowflakeId();
3189
+ const model_id = apipostTools.snowflakeId();
3192
3190
  if (item === null || item === void 0 ? void 0 : item.id) {
3193
3191
  this.modelMap[item.id] = model_id;
3194
3192
  }
@@ -3233,7 +3231,7 @@ class ApifoxToApipost {
3233
3231
  pre.push({
3234
3232
  type: item === null || item === void 0 ? void 0 : item.type,
3235
3233
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3236
- id: ATools.snowflakeId(),
3234
+ id: apipostTools.snowflakeId(),
3237
3235
  name: "Script",
3238
3236
  data: (item === null || item === void 0 ? void 0 : item.data) || "",
3239
3237
  });
@@ -3242,7 +3240,7 @@ class ApifoxToApipost {
3242
3240
  pre.push({
3243
3241
  type: item === null || item === void 0 ? void 0 : item.type,
3244
3242
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3245
- id: ATools.snowflakeId(),
3243
+ id: apipostTools.snowflakeId(),
3246
3244
  name: ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.name) || "Database",
3247
3245
  data: {
3248
3246
  query: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.expression) || "",
@@ -3255,7 +3253,7 @@ class ApifoxToApipost {
3255
3253
  type: (VARS_TYPE_MAP === null || VARS_TYPE_MAP === void 0 ? void 0 : VARS_TYPE_MAP[variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.variableType]) ||
3256
3254
  "variables",
3257
3255
  pattern: (variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.jsonPath) || "",
3258
- param_id: ATools.snowflakeId(),
3256
+ param_id: apipostTools.snowflakeId(),
3259
3257
  });
3260
3258
  }
3261
3259
  return pre;
@@ -3267,7 +3265,7 @@ class ApifoxToApipost {
3267
3265
  pre.push({
3268
3266
  type: "pickVars",
3269
3267
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3270
- id: ATools.snowflakeId(),
3268
+ id: apipostTools.snowflakeId(),
3271
3269
  name: ((_f = item === null || item === void 0 ? void 0 : item.data) === null || _f === void 0 ? void 0 : _f.variableName) || "Variable Name",
3272
3270
  data: {
3273
3271
  source: (PICK_VARS_TYPES_MAP === null || PICK_VARS_TYPES_MAP === void 0 ? void 0 : PICK_VARS_TYPES_MAP[(_g = item === null || item === void 0 ? void 0 : item.data) === null || _g === void 0 ? void 0 : _g.subject]) || "responseJson",
@@ -3279,7 +3277,7 @@ class ApifoxToApipost {
3279
3277
  pre.push({
3280
3278
  type: "assert",
3281
3279
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3282
- id: ATools.snowflakeId(),
3280
+ id: apipostTools.snowflakeId(),
3283
3281
  name: ((_h = item === null || item === void 0 ? void 0 : item.data) === null || _h === void 0 ? void 0 : _h.name) || "Assertion",
3284
3282
  data: {
3285
3283
  type: ASSERT_TYPES_MAP[(_j = item === null || item === void 0 ? void 0 : item.data) === null || _j === void 0 ? void 0 : _j.subject] || "responseJson",
@@ -3448,7 +3446,7 @@ class ApifoxToApipost {
3448
3446
  completionApiRequestParameter(parameter) {
3449
3447
  if (isArray(parameter)) {
3450
3448
  return parameter === null || parameter === void 0 ? void 0 : parameter.map((item) => ({
3451
- param_id: ATools.snowflakeId(),
3449
+ param_id: apipostTools.snowflakeId(),
3452
3450
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3453
3451
  field_type: lodash.has(item, "type") && (DEFAULT_FIELD_TYPE$1 === null || DEFAULT_FIELD_TYPE$1 === void 0 ? void 0 : DEFAULT_FIELD_TYPE$1.includes(item === null || item === void 0 ? void 0 : item.type))
3454
3452
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -3470,7 +3468,7 @@ class ApifoxToApipost {
3470
3468
  body["parameter"] = (_a = requestBody === null || requestBody === void 0 ? void 0 : requestBody.parameters) === null || _a === void 0 ? void 0 : _a.map((item) => {
3471
3469
  var _a;
3472
3470
  return ({
3473
- param_id: ATools.snowflakeId(),
3471
+ param_id: apipostTools.snowflakeId(),
3474
3472
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3475
3473
  field_type: ((_a = [...DEFAULT_FIELD_TYPE$1, "file"]) === null || _a === void 0 ? void 0 : _a.includes(item === null || item === void 0 ? void 0 : item.type))
3476
3474
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -3552,7 +3550,7 @@ class ApifoxToApipost {
3552
3550
  };
3553
3551
  }
3554
3552
  completionApiFolder(item, parentInfo) {
3555
- const target_id = ATools.snowflakeId();
3553
+ const target_id = apipostTools.snowflakeId();
3556
3554
  if (item === null || item === void 0 ? void 0 : item.id) {
3557
3555
  this.foldersMap[item.id] = target_id;
3558
3556
  }
@@ -3593,7 +3591,7 @@ class ApifoxToApipost {
3593
3591
  const example = responses === null || responses === void 0 ? void 0 : responses.map((item, index) => {
3594
3592
  const raw = responseExamples === null || responseExamples === void 0 ? void 0 : responseExamples.find((exampleItem) => (exampleItem === null || exampleItem === void 0 ? void 0 : exampleItem.responseId) == (item === null || item === void 0 ? void 0 : item.id));
3595
3593
  return {
3596
- example_id: ATools.snowflakeId(),
3594
+ example_id: apipostTools.snowflakeId(),
3597
3595
  raw: raw ? getBeautifulRaw((raw === null || raw === void 0 ? void 0 : raw.data) || "") : "",
3598
3596
  raw_parameter: [],
3599
3597
  expect: {
@@ -3619,7 +3617,7 @@ class ApifoxToApipost {
3619
3617
  return {
3620
3618
  query_schema: {},
3621
3619
  query_list: [{
3622
- param_id: ATools.snowflakeId(),
3620
+ param_id: apipostTools.snowflakeId(),
3623
3621
  name: 'New Query',
3624
3622
  query: lodash.isString((_a = requestBody === null || requestBody === void 0 ? void 0 : requestBody.graphql) === null || _a === void 0 ? void 0 : _a.query) ? (_b = requestBody === null || requestBody === void 0 ? void 0 : requestBody.graphql) === null || _b === void 0 ? void 0 : _b.query : '',
3625
3623
  variables: lodash.isString((_c = requestBody === null || requestBody === void 0 ? void 0 : requestBody.graphql) === null || _c === void 0 ? void 0 : _c.variables) ? (_d = requestBody === null || requestBody === void 0 ? void 0 : requestBody.graphql) === null || _d === void 0 ? void 0 : _d.variables : '',
@@ -3655,7 +3653,7 @@ class ApifoxToApipost {
3655
3653
  preProcessors: (_p = ((caseItem === null || caseItem === void 0 ? void 0 : caseItem.preProcessors) || [])) === null || _p === void 0 ? void 0 : _p.concat((api === null || api === void 0 ? void 0 : api.preProcessors) || []),
3656
3654
  postProcessors: (_q = ((caseItem === null || caseItem === void 0 ? void 0 : caseItem.postProcessors) || [])) === null || _q === void 0 ? void 0 : _q.concat((api === null || api === void 0 ? void 0 : api.postProcessors) || []),
3657
3655
  auth: api === null || api === void 0 ? void 0 : api.auth,
3658
- }, api === null || api === void 0 ? void 0 : api.requestBody), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), sample_id: ATools.snowflakeId(), sort: 1, target_id: (baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.target_id) || "", type: "sample", url: (api === null || api === void 0 ? void 0 : api.path) || "" });
3656
+ }, api === null || api === void 0 ? void 0 : api.requestBody), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), sample_id: apipostTools.snowflakeId(), sort: 1, target_id: (baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.target_id) || "", type: "sample", url: (api === null || api === void 0 ? void 0 : api.path) || "" });
3659
3657
  });
3660
3658
  }
3661
3659
  completionApis(items, parentInfo) {
@@ -3670,7 +3668,7 @@ class ApifoxToApipost {
3670
3668
  if (!lodash.has(item, "items") && lodash.has(item, "api")) {
3671
3669
  // 这是接口操作
3672
3670
  const base = {
3673
- target_id: ATools.snowflakeId(),
3671
+ target_id: apipostTools.snowflakeId(),
3674
3672
  project_id: this.project.project_id || "",
3675
3673
  };
3676
3674
  const target = this.completionApiTarget(item, base, parentInfo);
@@ -3701,7 +3699,7 @@ class ApifoxToApipost {
3701
3699
  var _a;
3702
3700
  if (lodash.has(this.foldersMap, docItem === null || docItem === void 0 ? void 0 : docItem.folderId)) {
3703
3701
  preItems.push({
3704
- target_id: ATools.snowflakeId(),
3702
+ target_id: apipostTools.snowflakeId(),
3705
3703
  project_id: this.project.project_id || "",
3706
3704
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[docItem === null || docItem === void 0 ? void 0 : docItem.folderId]) || "0",
3707
3705
  target_type: "doc",
@@ -3734,7 +3732,7 @@ class ApifoxToApipost {
3734
3732
  completionTcpClient(tcpClientItem) {
3735
3733
  var _a;
3736
3734
  return {
3737
- target_id: ATools.snowflakeId(),
3735
+ target_id: apipostTools.snowflakeId(),
3738
3736
  project_id: this.project.project_id || "",
3739
3737
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[tcpClientItem === null || tcpClientItem === void 0 ? void 0 : tcpClientItem.folderId]) || "0",
3740
3738
  target_type: "socket",
@@ -3772,7 +3770,7 @@ class ApifoxToApipost {
3772
3770
  completionTcpMethod(apis, parentInfo) {
3773
3771
  if (isArray(apis) && apis.length) {
3774
3772
  return apis === null || apis === void 0 ? void 0 : apis.reduce((pre, item) => {
3775
- pre.push(Object.assign(Object.assign({}, parentInfo), { target_id: ATools.snowflakeId(), project_id: this.project.project_id || "", target_type: "socket_method", name: (item === null || item === void 0 ? void 0 : item.name) || "New TCP Method", version: 0, sort: 0, method: "TCP", url: "", mark_id: this.completionApiTargetMark(item === null || item === void 0 ? void 0 : item.status), description: (item === null || item === void 0 ? void 0 : item.description) || "", request: this.completionTcpMethodRequest(item === null || item === void 0 ? void 0 : item.parameter), response: this.completionApiResponse(item === null || item === void 0 ? void 0 : item.responses, item === null || item === void 0 ? void 0 : item.responseExamples), attribute_info: {}, tags: isArray(item === null || item === void 0 ? void 0 : item.tags) ? item === null || item === void 0 ? void 0 : item.tags : [], created_at: 0, updated_at: 0 }));
3773
+ pre.push(Object.assign(Object.assign({}, parentInfo), { target_id: apipostTools.snowflakeId(), project_id: this.project.project_id || "", target_type: "socket_method", name: (item === null || item === void 0 ? void 0 : item.name) || "New TCP Method", version: 0, sort: 0, method: "TCP", url: "", mark_id: this.completionApiTargetMark(item === null || item === void 0 ? void 0 : item.status), description: (item === null || item === void 0 ? void 0 : item.description) || "", request: this.completionTcpMethodRequest(item === null || item === void 0 ? void 0 : item.parameter), response: this.completionApiResponse(item === null || item === void 0 ? void 0 : item.responses, item === null || item === void 0 ? void 0 : item.responseExamples), attribute_info: {}, tags: isArray(item === null || item === void 0 ? void 0 : item.tags) ? item === null || item === void 0 ? void 0 : item.tags : [], created_at: 0, updated_at: 0 }));
3776
3774
  return pre;
3777
3775
  }, []);
3778
3776
  }
@@ -3829,6 +3827,832 @@ class ApifoxToApipost {
3829
3827
  }
3830
3828
  }
3831
3829
 
3830
+ const completionPostmanTarget = (targetItem) => {
3831
+ var _a, _b, _c, _d, _e, _f, _g;
3832
+ try {
3833
+ const getPostmanHeader = (header) => {
3834
+ if (lodash.isArray(header)) {
3835
+ return lodash.reduce(header, (pre, cur) => {
3836
+ pre.push({
3837
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3838
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3839
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
3840
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || ''
3841
+ });
3842
+ return pre;
3843
+ }, []);
3844
+ }
3845
+ return [];
3846
+ };
3847
+ const getPostmanUrl = (targetItem) => {
3848
+ var _a, _b, _c, _d;
3849
+ const getPostmanQuery = (query) => {
3850
+ if (lodash.isArray(query)) {
3851
+ return lodash.reduce(query, (pre, cur) => {
3852
+ pre.push({
3853
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3854
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3855
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
3856
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
3857
+ });
3858
+ return pre;
3859
+ }, []);
3860
+ }
3861
+ return [];
3862
+ };
3863
+ const getPostmanVariable = (restful) => {
3864
+ if (lodash.isArray(restful)) {
3865
+ return lodash.reduce(restful, (pre, cur) => {
3866
+ pre.push({
3867
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3868
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3869
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
3870
+ });
3871
+ return pre;
3872
+ }, []);
3873
+ }
3874
+ return [];
3875
+ };
3876
+ return {
3877
+ raw: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || '',
3878
+ 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
+ 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
+ };
3881
+ };
3882
+ const result = {
3883
+ name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New HTTP',
3884
+ description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3885
+ request: {
3886
+ method: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.method) || 'GET',
3887
+ header: getPostmanHeader((_b = (_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.header) === null || _b === void 0 ? void 0 : _b.parameter),
3888
+ url: getPostmanUrl(targetItem),
3889
+ },
3890
+ };
3891
+ // 获取接口认证
3892
+ let auth = getPostmanAuth((_c = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _c === void 0 ? void 0 : _c.auth);
3893
+ if (lodash.isPlainObject(auth) && !lodash.isEmpty(auth)) {
3894
+ result.request.auth = auth;
3895
+ }
3896
+ // 获取接口前后置脚本
3897
+ let event = getPostmanEvent(targetItem === null || targetItem === void 0 ? void 0 : targetItem.request);
3898
+ if (event.length > 0) {
3899
+ result.event = event;
3900
+ }
3901
+ // 获取请求体
3902
+ if (lodash.isObject((_d = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _d === void 0 ? void 0 : _d.body) && ((_f = (_e = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _e === void 0 ? void 0 : _e.body) === null || _f === void 0 ? void 0 : _f.mode) != 'none') {
3903
+ result.request.body = getPostmanBody((_g = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _g === void 0 ? void 0 : _g.body);
3904
+ }
3905
+ return result;
3906
+ }
3907
+ catch (error) {
3908
+ // console.log(error,"error1111");
3909
+ }
3910
+ return {};
3911
+ };
3912
+ const completionPostmanFolder = (targetItem) => {
3913
+ var _a;
3914
+ try {
3915
+ const result = {
3916
+ name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New Folder',
3917
+ description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3918
+ };
3919
+ // 获取认证
3920
+ let auth = getPostmanAuth((_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.auth);
3921
+ if (lodash.isPlainObject(auth) && !lodash.isEmpty(auth)) {
3922
+ result.auth = auth;
3923
+ }
3924
+ // 获取前后置脚本
3925
+ let event = getPostmanEvent(targetItem === null || targetItem === void 0 ? void 0 : targetItem.request);
3926
+ if (event.length > 0) {
3927
+ result.event = event;
3928
+ }
3929
+ return result;
3930
+ }
3931
+ catch (error) {
3932
+ }
3933
+ return {};
3934
+ };
3935
+ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3936
+ try {
3937
+ const result = [];
3938
+ const itemMap = {};
3939
+ for (const target of items) {
3940
+ const id = target[idName];
3941
+ const pid = target[pidName];
3942
+ if (!id || id == undefined || !['api', 'folder'].includes(target === null || target === void 0 ? void 0 : target.target_type)) {
3943
+ continue;
3944
+ }
3945
+ if (!itemMap.hasOwnProperty(id) && (target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3946
+ itemMap[id] = {
3947
+ name: (target === null || target === void 0 ? void 0 : target.name) || '',
3948
+ item: [],
3949
+ };
3950
+ }
3951
+ if ((target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3952
+ itemMap[id] = Object.assign(Object.assign({}, completionPostmanFolder(target)), {
3953
+ // name: target?.name || '',
3954
+ item: itemMap[id]['item'] });
3955
+ }
3956
+ else {
3957
+ itemMap[id] = Object.assign({}, completionPostmanTarget(target));
3958
+ }
3959
+ const treeItem = itemMap[id];
3960
+ if (pid == 0 || pid == undefined) {
3961
+ result.push(treeItem);
3962
+ }
3963
+ else {
3964
+ if (!itemMap.hasOwnProperty(pid)) {
3965
+ itemMap[pid] = {
3966
+ item: [],
3967
+ };
3968
+ }
3969
+ itemMap[pid].item.push(treeItem);
3970
+ }
3971
+ }
3972
+ return result;
3973
+ }
3974
+ catch (error) {
3975
+ return [];
3976
+ }
3977
+ };
3978
+ const getPostmanAuth = (auth) => {
3979
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75;
3980
+ if (lodash.isPlainObject(auth)) {
3981
+ const { type } = auth;
3982
+ switch (type) {
3983
+ case 'basic':
3984
+ return {
3985
+ type: "basic",
3986
+ basic: [
3987
+ {
3988
+ key: "password",
3989
+ value: ((_a = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _a === void 0 ? void 0 : _a.password) || '',
3990
+ type: "string"
3991
+ },
3992
+ {
3993
+ key: "username",
3994
+ value: ((_b = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _b === void 0 ? void 0 : _b.username) || '',
3995
+ type: "string"
3996
+ }
3997
+ ]
3998
+ };
3999
+ case 'bearer':
4000
+ return {
4001
+ type: "bearer",
4002
+ bearer: [
4003
+ {
4004
+ key: "token",
4005
+ value: ((_c = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _c === void 0 ? void 0 : _c.key) || '',
4006
+ type: "string"
4007
+ }
4008
+ ]
4009
+ };
4010
+ case 'digest':
4011
+ return {
4012
+ type: "digest",
4013
+ digest: [
4014
+ {
4015
+ key: "clientNonce",
4016
+ value: ((_d = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _d === void 0 ? void 0 : _d.cnonce) || '',
4017
+ type: "string"
4018
+ },
4019
+ {
4020
+ key: "opaque",
4021
+ value: ((_e = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _e === void 0 ? void 0 : _e.opaque) || '',
4022
+ type: "string"
4023
+ },
4024
+ {
4025
+ key: "nonceCount",
4026
+ value: ((_f = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _f === void 0 ? void 0 : _f.nc) || '',
4027
+ type: "string"
4028
+ },
4029
+ {
4030
+ key: "qop",
4031
+ value: ((_g = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _g === void 0 ? void 0 : _g.qop) || '',
4032
+ type: "string"
4033
+ },
4034
+ {
4035
+ key: "nonce",
4036
+ value: ((_h = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _h === void 0 ? void 0 : _h.nonce) || '',
4037
+ type: "string"
4038
+ },
4039
+ {
4040
+ key: "realm",
4041
+ value: ((_j = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _j === void 0 ? void 0 : _j.realm) || '',
4042
+ type: "string"
4043
+ },
4044
+ {
4045
+ key: "password",
4046
+ value: ((_k = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _k === void 0 ? void 0 : _k.password) || '',
4047
+ type: "string"
4048
+ },
4049
+ {
4050
+ key: "username",
4051
+ value: ((_l = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _l === void 0 ? void 0 : _l.username) || '',
4052
+ type: "string"
4053
+ },
4054
+ {
4055
+ key: "disableRetryRequest",
4056
+ value: ((_m = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _m === void 0 ? void 0 : _m.disableRetryRequest) ? true : false,
4057
+ type: "boolean"
4058
+ },
4059
+ {
4060
+ key: "algorithm",
4061
+ value: ((_o = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _o === void 0 ? void 0 : _o.algorithm) || 'MD5',
4062
+ type: "string"
4063
+ },
4064
+ ]
4065
+ };
4066
+ case 'oauth1':
4067
+ return {
4068
+ type: "oauth1",
4069
+ oauth1: [
4070
+ {
4071
+ key: "addEmptyParamsToSign",
4072
+ value: ((_p = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _p === void 0 ? void 0 : _p.addEmptyParamsToSign) ? true : false,
4073
+ type: "boolean"
4074
+ },
4075
+ {
4076
+ key: "includeBodyHash",
4077
+ value: ((_q = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _q === void 0 ? void 0 : _q.includeBodyHash) ? true : false,
4078
+ type: "boolean"
4079
+ },
4080
+ {
4081
+ key: "realm",
4082
+ value: ((_r = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _r === void 0 ? void 0 : _r.realm) || '',
4083
+ type: "string"
4084
+ },
4085
+ {
4086
+ key: "nonce",
4087
+ value: ((_s = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _s === void 0 ? void 0 : _s.nonce) || '',
4088
+ type: "string"
4089
+ },
4090
+ {
4091
+ key: "timestamp",
4092
+ value: ((_t = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _t === void 0 ? void 0 : _t.timestamp) || '',
4093
+ type: "string"
4094
+ },
4095
+ {
4096
+ key: "verifier",
4097
+ value: ((_u = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _u === void 0 ? void 0 : _u.verifier) || '',
4098
+ type: "string"
4099
+ },
4100
+ {
4101
+ key: "callback",
4102
+ value: ((_v = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _v === void 0 ? void 0 : _v.callback) || '',
4103
+ type: "string"
4104
+ },
4105
+ {
4106
+ key: "tokenSecret",
4107
+ value: ((_w = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _w === void 0 ? void 0 : _w.tokenSecret) || '',
4108
+ type: "string"
4109
+ },
4110
+ {
4111
+ key: "token",
4112
+ value: ((_x = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _x === void 0 ? void 0 : _x.token) || '',
4113
+ type: "string"
4114
+ },
4115
+ {
4116
+ key: "consumerSecret",
4117
+ value: ((_y = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _y === void 0 ? void 0 : _y.consumerSecret) || '',
4118
+ type: "string"
4119
+ },
4120
+ {
4121
+ key: "consumerKey",
4122
+ value: ((_z = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _z === void 0 ? void 0 : _z.consumerKey) || '',
4123
+ type: "string"
4124
+ },
4125
+ {
4126
+ key: "signatureMethod",
4127
+ value: ((_0 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _0 === void 0 ? void 0 : _0.signatureMethod) || 'HMAC-SHA1',
4128
+ type: "string"
4129
+ },
4130
+ {
4131
+ key: "version",
4132
+ value: ((_1 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _1 === void 0 ? void 0 : _1.version) || '1.0',
4133
+ type: "string"
4134
+ },
4135
+ {
4136
+ key: "addParamsToHeader",
4137
+ value: ((_2 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _2 === void 0 ? void 0 : _2.addParamsToHeader) ? true : false,
4138
+ type: "boolean"
4139
+ },
4140
+ {
4141
+ key: "disableHeaderEncoding",
4142
+ value: ((_3 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _3 === void 0 ? void 0 : _3.disableHeaderEncoding) ? true : false,
4143
+ type: "boolean"
4144
+ }
4145
+ ]
4146
+ };
4147
+ case 'oauth2':
4148
+ return {
4149
+ type: "oauth2",
4150
+ oauth2: [
4151
+ {
4152
+ key: "addTokenTo",
4153
+ value: ((_4 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _4 === void 0 ? void 0 : _4.addTokenTo) || 'header',
4154
+ type: "string"
4155
+ },
4156
+ {
4157
+ key: "headerPrefix",
4158
+ value: ((_5 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _5 === void 0 ? void 0 : _5.headerPrefix) || 'Bearer',
4159
+ type: "string"
4160
+ },
4161
+ {
4162
+ key: "accessToken",
4163
+ value: ((_6 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _6 === void 0 ? void 0 : _6.access_token) || '',
4164
+ type: "string"
4165
+ },
4166
+ {
4167
+ key: "refreshTokenUrl",
4168
+ value: ((_7 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _7 === void 0 ? void 0 : _7.refreshTokenUrl) || '',
4169
+ type: "string"
4170
+ },
4171
+ {
4172
+ key: "grant_type",
4173
+ value: ((_8 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _8 === void 0 ? void 0 : _8.grant_type) || 'authorization_code',
4174
+ type: "string"
4175
+ },
4176
+ {
4177
+ key: "redirect_uri",
4178
+ value: ((_9 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _9 === void 0 ? void 0 : _9.redirect_uri) || '',
4179
+ type: "string"
4180
+ },
4181
+ {
4182
+ key: "authUrl",
4183
+ value: ((_10 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _10 === void 0 ? void 0 : _10.authUrl) || '',
4184
+ type: "string"
4185
+ },
4186
+ {
4187
+ key: "accessTokenUrl",
4188
+ value: ((_11 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _11 === void 0 ? void 0 : _11.accessTokenUrl) || '',
4189
+ type: "string"
4190
+ },
4191
+ {
4192
+ key: "clientId",
4193
+ value: ((_12 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _12 === void 0 ? void 0 : _12.clientId) || '',
4194
+ type: "string"
4195
+ },
4196
+ {
4197
+ key: "clientSecret",
4198
+ value: ((_13 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _13 === void 0 ? void 0 : _13.clientSecret) || '',
4199
+ type: "string"
4200
+ },
4201
+ {
4202
+ key: "username",
4203
+ value: ((_14 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _14 === void 0 ? void 0 : _14.username) || '',
4204
+ type: "string"
4205
+ },
4206
+ {
4207
+ key: "password",
4208
+ value: ((_15 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _15 === void 0 ? void 0 : _15.password) || '',
4209
+ type: "string"
4210
+ },
4211
+ {
4212
+ key: "challengeAlgorithm",
4213
+ value: ((_16 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _16 === void 0 ? void 0 : _16.challengeAlgorithm) || 'S256',
4214
+ type: "string"
4215
+ },
4216
+ {
4217
+ key: "code_verifier",
4218
+ value: ((_17 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _17 === void 0 ? void 0 : _17.code_verifier) || 'Bearer',
4219
+ type: "string"
4220
+ },
4221
+ {
4222
+ key: "state",
4223
+ value: ((_18 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _18 === void 0 ? void 0 : _18.state) || '',
4224
+ type: "string"
4225
+ },
4226
+ {
4227
+ key: "scope",
4228
+ value: ((_19 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _19 === void 0 ? void 0 : _19.scope) || '',
4229
+ type: "string"
4230
+ },
4231
+ {
4232
+ key: "client_authentication",
4233
+ value: ((_20 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _20 === void 0 ? void 0 : _20.client_authentication) || 'header',
4234
+ type: "string"
4235
+ },
4236
+ {
4237
+ key: "tokenName",
4238
+ value: ((_21 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _21 === void 0 ? void 0 : _21.tokenName) || '',
4239
+ type: "string"
4240
+ },
4241
+ {
4242
+ key: "refreshRequestParams",
4243
+ value: lodash.isArray((_22 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _22 === void 0 ? void 0 : _22.authRequestParams) ? (_23 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _23 === void 0 ? void 0 : _23.authRequestParams : [],
4244
+ type: "any"
4245
+ },
4246
+ {
4247
+ key: "tokenRequestParams",
4248
+ value: lodash.isArray((_24 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _24 === void 0 ? void 0 : _24.tokenRequestParams) ? (_25 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _25 === void 0 ? void 0 : _25.tokenRequestParams : [],
4249
+ type: "any"
4250
+ },
4251
+ {
4252
+ key: "authRequestParams",
4253
+ value: lodash.isArray((_26 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _26 === void 0 ? void 0 : _26.authRequestParams) ? (_27 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _27 === void 0 ? void 0 : _27.authRequestParams : [],
4254
+ type: "any"
4255
+ },
4256
+ ]
4257
+ };
4258
+ case 'hawk':
4259
+ return {
4260
+ type: "hawk",
4261
+ hawk: [
4262
+ {
4263
+ key: "authId",
4264
+ value: ((_28 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _28 === void 0 ? void 0 : _28.authId) || '',
4265
+ type: "string"
4266
+ },
4267
+ {
4268
+ key: "algorithm",
4269
+ value: ((_29 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _29 === void 0 ? void 0 : _29.algorithm) || '',
4270
+ type: "string"
4271
+ },
4272
+ {
4273
+ key: "authKey",
4274
+ value: ((_30 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _30 === void 0 ? void 0 : _30.authKey) || '',
4275
+ type: "string"
4276
+ },
4277
+ {
4278
+ key: "includePayloadHash",
4279
+ value: ((_31 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _31 === void 0 ? void 0 : _31.includePayloadHash) ? true : false,
4280
+ type: "boolean"
4281
+ },
4282
+ {
4283
+ key: "delegation",
4284
+ value: ((_32 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _32 === void 0 ? void 0 : _32.delegation) || '',
4285
+ type: "string"
4286
+ },
4287
+ {
4288
+ key: "timestamp",
4289
+ value: ((_33 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _33 === void 0 ? void 0 : _33.timestamp) || '',
4290
+ type: "string"
4291
+ },
4292
+ {
4293
+ key: "app",
4294
+ value: ((_34 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _34 === void 0 ? void 0 : _34.app) || '',
4295
+ type: "string"
4296
+ },
4297
+ {
4298
+ key: "extraData",
4299
+ value: ((_35 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _35 === void 0 ? void 0 : _35.extraData) || '',
4300
+ type: "string"
4301
+ },
4302
+ {
4303
+ key: "nonce",
4304
+ value: ((_36 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _36 === void 0 ? void 0 : _36.nonce) || '',
4305
+ type: "string"
4306
+ },
4307
+ {
4308
+ key: "user",
4309
+ value: ((_37 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _37 === void 0 ? void 0 : _37.user) || '',
4310
+ type: "string"
4311
+ },
4312
+ {
4313
+ key: "delegation",
4314
+ value: ((_38 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _38 === void 0 ? void 0 : _38.delegation) || '',
4315
+ type: "string"
4316
+ },
4317
+ ]
4318
+ };
4319
+ case 'awsv4':
4320
+ return {
4321
+ type: "awsv4",
4322
+ awsv4: [
4323
+ {
4324
+ key: "accessKey",
4325
+ value: ((_39 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _39 === void 0 ? void 0 : _39.accessKey) || '',
4326
+ type: "string"
4327
+ },
4328
+ {
4329
+ key: "secretKey",
4330
+ value: ((_40 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _40 === void 0 ? void 0 : _40.secretKey) || '',
4331
+ type: "string"
4332
+ },
4333
+ {
4334
+ key: "region",
4335
+ value: ((_41 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _41 === void 0 ? void 0 : _41.region) || '',
4336
+ type: "string"
4337
+ },
4338
+ {
4339
+ key: "addAuthDataToQuery",
4340
+ value: ((_42 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _42 === void 0 ? void 0 : _42.addAuthDataToQuery) ? true : false,
4341
+ type: "boolean"
4342
+ },
4343
+ {
4344
+ key: "service",
4345
+ value: ((_43 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _43 === void 0 ? void 0 : _43.service) || '',
4346
+ type: "string"
4347
+ },
4348
+ {
4349
+ key: "sessionToken",
4350
+ value: ((_44 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _44 === void 0 ? void 0 : _44.sessionToken) || '',
4351
+ type: "string"
4352
+ },
4353
+ ]
4354
+ };
4355
+ case 'ntlm':
4356
+ return {
4357
+ type: "ntlm",
4358
+ ntlm: [
4359
+ {
4360
+ key: "username",
4361
+ value: ((_45 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _45 === void 0 ? void 0 : _45.username) || '',
4362
+ type: "string"
4363
+ },
4364
+ {
4365
+ key: "password",
4366
+ value: ((_46 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _46 === void 0 ? void 0 : _46.password) || '',
4367
+ type: "string"
4368
+ },
4369
+ {
4370
+ key: "domain",
4371
+ value: ((_47 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _47 === void 0 ? void 0 : _47.domain) || '',
4372
+ type: "string"
4373
+ },
4374
+ {
4375
+ key: "workstation",
4376
+ value: ((_48 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _48 === void 0 ? void 0 : _48.workstation) || '',
4377
+ type: "string"
4378
+ },
4379
+ {
4380
+ key: "disableRetryRequest",
4381
+ value: ((_49 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _49 === void 0 ? void 0 : _49.disableRetryRequest) ? true : false,
4382
+ type: "boolean"
4383
+ },
4384
+ ]
4385
+ };
4386
+ case 'kv':
4387
+ return {
4388
+ type: "apikey",
4389
+ apikey: [
4390
+ {
4391
+ key: "key",
4392
+ value: ((_50 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _50 === void 0 ? void 0 : _50.key) || '',
4393
+ type: "string"
4394
+ },
4395
+ {
4396
+ key: "value",
4397
+ value: ((_51 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _51 === void 0 ? void 0 : _51.value) || '',
4398
+ type: "string"
4399
+ },
4400
+ {
4401
+ key: "in",
4402
+ value: ((_52 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _52 === void 0 ? void 0 : _52.in) || 'header',
4403
+ type: "string"
4404
+ },
4405
+ ]
4406
+ };
4407
+ case 'edgegrid':
4408
+ return {
4409
+ type: "edgegrid",
4410
+ edgegrid: [
4411
+ {
4412
+ key: "accessToken",
4413
+ value: ((_53 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _53 === void 0 ? void 0 : _53.accessToken) || '',
4414
+ type: "string"
4415
+ },
4416
+ {
4417
+ key: "clientToken",
4418
+ value: ((_54 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _54 === void 0 ? void 0 : _54.clientToken) || '',
4419
+ type: "string"
4420
+ },
4421
+ {
4422
+ key: "clientSecret",
4423
+ value: ((_55 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _55 === void 0 ? void 0 : _55.clientSecret) || '',
4424
+ type: "string"
4425
+ },
4426
+ {
4427
+ key: "nonce",
4428
+ value: ((_56 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _56 === void 0 ? void 0 : _56.nonce) || '',
4429
+ type: "string"
4430
+ },
4431
+ {
4432
+ key: "timestamp",
4433
+ value: ((_57 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _57 === void 0 ? void 0 : _57.timestamp) || '',
4434
+ type: "string"
4435
+ },
4436
+ {
4437
+ key: "baseURL",
4438
+ value: ((_58 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _58 === void 0 ? void 0 : _58.baseURi) || '',
4439
+ type: "string"
4440
+ },
4441
+ {
4442
+ key: "headersToSign",
4443
+ value: ((_59 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _59 === void 0 ? void 0 : _59.headersToSign) || '',
4444
+ type: "string"
4445
+ },
4446
+ ]
4447
+ };
4448
+ case 'jwt':
4449
+ return {
4450
+ type: "jwt",
4451
+ jwt: [
4452
+ {
4453
+ key: "addTokenTo",
4454
+ value: ((_60 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _60 === void 0 ? void 0 : _60.addTokenTo) || '',
4455
+ type: "string"
4456
+ },
4457
+ {
4458
+ key: "algorithm",
4459
+ value: ((_61 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _61 === void 0 ? void 0 : _61.algorithm) || '',
4460
+ type: "string"
4461
+ },
4462
+ {
4463
+ key: "secret",
4464
+ value: ((_62 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _62 === void 0 ? void 0 : _62.secret) || '',
4465
+ type: "string"
4466
+ },
4467
+ {
4468
+ key: "payload",
4469
+ value: ((_63 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _63 === void 0 ? void 0 : _63.payload) || '',
4470
+ type: "string"
4471
+ },
4472
+ {
4473
+ key: "headerPrefix",
4474
+ value: ((_64 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _64 === void 0 ? void 0 : _64.headerPrefix) || 'Bearer',
4475
+ type: "string"
4476
+ },
4477
+ {
4478
+ key: "queryParamKey",
4479
+ value: ((_65 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _65 === void 0 ? void 0 : _65.queryParamKey) || 'token',
4480
+ type: "string"
4481
+ },
4482
+ {
4483
+ key: "header",
4484
+ value: ((_66 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _66 === void 0 ? void 0 : _66.header) || '',
4485
+ type: "string"
4486
+ },
4487
+ {
4488
+ key: "isSecretBase64Encoded",
4489
+ value: ((_67 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _67 === void 0 ? void 0 : _67.isSecretBase64Encoded) ? true : false,
4490
+ type: "boolean"
4491
+ },
4492
+ ]
4493
+ };
4494
+ case 'asap':
4495
+ return {
4496
+ type: "asap",
4497
+ asap: [
4498
+ {
4499
+ key: "alg",
4500
+ value: ((_68 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _68 === void 0 ? void 0 : _68.alg) || 'HS256',
4501
+ type: "string"
4502
+ },
4503
+ {
4504
+ key: "iss",
4505
+ value: ((_69 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _69 === void 0 ? void 0 : _69.iss) || '',
4506
+ type: "string"
4507
+ },
4508
+ {
4509
+ key: "aud",
4510
+ value: ((_70 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _70 === void 0 ? void 0 : _70.aud) || '',
4511
+ type: "string"
4512
+ },
4513
+ {
4514
+ key: "kid",
4515
+ value: ((_71 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _71 === void 0 ? void 0 : _71.kid) || '',
4516
+ type: "string"
4517
+ },
4518
+ {
4519
+ key: "privateKey",
4520
+ value: ((_72 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _72 === void 0 ? void 0 : _72.privateKey) || '',
4521
+ type: "string"
4522
+ },
4523
+ {
4524
+ key: "sub",
4525
+ value: ((_73 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _73 === void 0 ? void 0 : _73.sub) || '',
4526
+ type: "string"
4527
+ },
4528
+ {
4529
+ key: "claims",
4530
+ value: ((_74 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _74 === void 0 ? void 0 : _74.claims) || '',
4531
+ type: "string"
4532
+ },
4533
+ {
4534
+ key: "exp",
4535
+ value: ((_75 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _75 === void 0 ? void 0 : _75.exp) || '',
4536
+ type: "string"
4537
+ },
4538
+ ]
4539
+ };
4540
+ }
4541
+ }
4542
+ return {};
4543
+ };
4544
+ const getPostmanEvent = (request) => {
4545
+ let event = [];
4546
+ if (lodash.isArray(request === null || request === void 0 ? void 0 : request.pre_tasks)) {
4547
+ lodash.forEach(request === null || request === void 0 ? void 0 : request.pre_tasks, (val) => {
4548
+ if ((val === null || val === void 0 ? void 0 : val.type) === 'customScript' && (val === null || val === void 0 ? void 0 : val.enabled) == 1) {
4549
+ event.push({
4550
+ listen: "prerequest",
4551
+ script: {
4552
+ "type": "text/javascript",
4553
+ "packages": {},
4554
+ "exec": lodash.isString(val === null || val === void 0 ? void 0 : val.data) ? val.data.split('\n') : []
4555
+ }
4556
+ });
4557
+ }
4558
+ });
4559
+ }
4560
+ if (lodash.isArray(request === null || request === void 0 ? void 0 : request.post_tasks)) {
4561
+ lodash.forEach(request === null || request === void 0 ? void 0 : request.post_tasks, (val) => {
4562
+ if ((val === null || val === void 0 ? void 0 : val.type) === 'customScript' && (val === null || val === void 0 ? void 0 : val.enabled) == 1) {
4563
+ event.push({
4564
+ listen: "test",
4565
+ script: {
4566
+ "type": "text/javascript",
4567
+ "packages": {},
4568
+ "exec": lodash.isString(val === null || val === void 0 ? void 0 : val.data) ? val.data.split('\n') : []
4569
+ }
4570
+ });
4571
+ }
4572
+ });
4573
+ }
4574
+ return event;
4575
+ };
4576
+ const getPostmanCommonParameter = (parameter) => {
4577
+ if (lodash.isArray(parameter)) {
4578
+ return lodash.reduce(parameter, (pre, cur) => {
4579
+ pre.push({
4580
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
4581
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
4582
+ type: (cur === null || cur === void 0 ? void 0 : cur.field_type) == 'File' ? 'file' : 'text',
4583
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
4584
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
4585
+ });
4586
+ return pre;
4587
+ }, []);
4588
+ }
4589
+ return [];
4590
+ };
4591
+ const getPostmanBody = (body) => {
4592
+ const params = {};
4593
+ if (body) {
4594
+ switch (body === null || body === void 0 ? void 0 : body.mode) {
4595
+ case 'form-data':
4596
+ params.mode = 'formdata';
4597
+ params.formdata = getPostmanCommonParameter(body === null || body === void 0 ? void 0 : body.parameter);
4598
+ break;
4599
+ case 'urlencoded':
4600
+ params.mode = 'urlencoded';
4601
+ params.urlencoded = getPostmanCommonParameter(body === null || body === void 0 ? void 0 : body.parameter);
4602
+ break;
4603
+ case 'binary':
4604
+ params.mode = 'file';
4605
+ break;
4606
+ case 'json':
4607
+ params.mode = 'raw';
4608
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4609
+ params.options = {
4610
+ raw: {
4611
+ language: "json"
4612
+ }
4613
+ };
4614
+ break;
4615
+ case 'xml':
4616
+ params.mode = 'raw';
4617
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4618
+ params.options = {
4619
+ raw: {
4620
+ language: "xml"
4621
+ }
4622
+ };
4623
+ break;
4624
+ case 'javascript':
4625
+ params.mode = 'raw';
4626
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4627
+ params.options = {
4628
+ raw: {
4629
+ language: "javascript"
4630
+ }
4631
+ };
4632
+ break;
4633
+ case 'plain':
4634
+ params.mode = 'raw';
4635
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4636
+ params.options = {
4637
+ raw: {
4638
+ language: "text"
4639
+ }
4640
+ };
4641
+ break;
4642
+ case 'html':
4643
+ params.mode = 'raw';
4644
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4645
+ params.options = {
4646
+ raw: {
4647
+ language: "html"
4648
+ }
4649
+ };
4650
+ break;
4651
+ }
4652
+ }
4653
+ return params;
4654
+ };
4655
+
3832
4656
  // @ts-nocheck
3833
4657
  class ApipostToPostman {
3834
4658
  constructor() {
@@ -3844,82 +4668,68 @@ class ApipostToPostman {
3844
4668
  writable: true,
3845
4669
  value: void 0
3846
4670
  });
4671
+ Object.defineProperty(this, "variable", {
4672
+ enumerable: true,
4673
+ configurable: true,
4674
+ writable: true,
4675
+ value: void 0
4676
+ });
4677
+ Object.defineProperty(this, "event", {
4678
+ enumerable: true,
4679
+ configurable: true,
4680
+ writable: true,
4681
+ value: void 0
4682
+ });
4683
+ Object.defineProperty(this, "auth", {
4684
+ enumerable: true,
4685
+ configurable: true,
4686
+ writable: true,
4687
+ value: void 0
4688
+ });
3847
4689
  this.item = [];
3848
4690
  this.info = {
3849
- _postman_id: "",
3850
4691
  name: "New Collection",
4692
+ description: '',
3851
4693
  schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
3852
- _exporter_id: "",
3853
- _collection_link: "",
3854
4694
  };
4695
+ this.variable = [];
4696
+ this.event = [];
4697
+ this.auth = {};
3855
4698
  }
3856
4699
  initInfo(json) {
3857
- this.info.name = (json === null || json === void 0 ? void 0 : json.name) || "New Collection";
3858
- }
3859
- completionTarget(item) {
3860
- return {
3861
- name: (item === null || item === void 0 ? void 0 : item.name) || "New Request",
3862
- };
3863
- }
3864
- completionEvent(tasks, listen) {
3865
- const scriptTasks = tasks === null || tasks === void 0 ? void 0 : tasks.filter((item) => (item === null || item === void 0 ? void 0 : item.type) === "customScript");
3866
- if (isArray(scriptTasks) && scriptTasks.length) {
3867
- return [
3868
- scriptTasks === null || scriptTasks === void 0 ? void 0 : scriptTasks.reduce((pre, item) => {
3869
- var _a, _b;
3870
- if (item === null || item === void 0 ? void 0 : item.data) {
3871
- (_b = (_a = pre === null || pre === void 0 ? void 0 : pre.script) === null || _a === void 0 ? void 0 : _a.exec) === null || _b === void 0 ? void 0 : _b.push(item === null || item === void 0 ? void 0 : item.data);
3872
- }
3873
- return pre;
3874
- }, {
3875
- listen,
3876
- script: {
3877
- type: "text/javascript",
3878
- packages: {},
3879
- exec: [],
3880
- },
3881
- }),
3882
- ];
3883
- }
3884
- return null;
3885
- }
3886
- completionFolder(item) {
3887
4700
  var _a, _b;
3888
- const prerequest = this.completionEvent((_a = item === null || item === void 0 ? void 0 : item.request) === null || _a === void 0 ? void 0 : _a.pre_tasks, "prerequest");
3889
- const test = this.completionEvent((_b = item === null || item === void 0 ? void 0 : item.request) === null || _b === void 0 ? void 0 : _b.post_tasks, "test");
3890
- const info = {};
3891
- if (prerequest || test) {
3892
- info["event"] = [...prerequest, ...test];
3893
- }
3894
- return Object.assign({ name: (item === null || item === void 0 ? void 0 : item.name) || "New Collection", description: (item === null || item === void 0 ? void 0 : item.description) || "", item: this.completionItem((item === null || item === void 0 ? void 0 : item.children) || []) }, info);
3895
- }
3896
- completionItem(collections) {
3897
- if (isArray(collections) && collections.length) {
3898
- return collections === null || collections === void 0 ? void 0 : collections.map((item) => {
3899
- if ((item === null || item === void 0 ? void 0 : item.target_type) === "folder") {
3900
- return Object.assign({}, this.completionFolder(item));
3901
- }
3902
- else if ((item === null || item === void 0 ? void 0 : item.target_type) === "api") {
3903
- // 接口
3904
- return Object.assign({}, this.completionTarget(item));
3905
- }
3906
- });
4701
+ this.info.name = (json === null || json === void 0 ? void 0 : json.name) || "New Collection";
4702
+ this.info.description = (json === null || json === void 0 ? void 0 : json.intro) || "";
4703
+ this.event = getPostmanEvent(global === null || global === void 0 ? void 0 : global.global_param);
4704
+ this.variable = this.initVariable(json === null || json === void 0 ? void 0 : json.global);
4705
+ this.auth = getPostmanAuth((_b = (_a = json === null || json === void 0 ? void 0 : json.global) === null || _a === void 0 ? void 0 : _a.global_param) === null || _b === void 0 ? void 0 : _b.auth);
4706
+ }
4707
+ initVariable(global) {
4708
+ if (lodash.isPlainObject(global === null || global === void 0 ? void 0 : global.global_vars)) {
4709
+ return lodash.reduce(global === null || global === void 0 ? void 0 : global.global_vars, (res, val, key) => {
4710
+ res.push({
4711
+ key,
4712
+ value: (val === null || val === void 0 ? void 0 : val.value) || '',
4713
+ type: "string"
4714
+ });
4715
+ return res;
4716
+ }, []);
3907
4717
  }
3908
4718
  return [];
3909
4719
  }
3910
4720
  initItem(json) {
3911
- const item = ATools__default["default"].array2Tree((json === null || json === void 0 ? void 0 : json.apis) || [], "target_id", "parent_id");
3912
- this.item = this.completionItem(item);
4721
+ this.item = array2PostmanTree((json === null || json === void 0 ? void 0 : json.apis) || [], "target_id", "parent_id");
3913
4722
  }
3914
4723
  clear() {
3915
4724
  this.item = [];
3916
4725
  this.info = {
3917
- _postman_id: "",
3918
4726
  name: "New Collection",
4727
+ description: '',
3919
4728
  schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
3920
- _exporter_id: "",
3921
- _collection_link: "",
3922
4729
  };
4730
+ this.variable = [];
4731
+ this.event = [];
4732
+ this.auth = {};
3923
4733
  }
3924
4734
  convert(json) {
3925
4735
  this.clear();
@@ -3929,6 +4739,9 @@ class ApipostToPostman {
3929
4739
  const data = {
3930
4740
  info: this.info,
3931
4741
  item: this.item,
4742
+ variable: this.variable,
4743
+ event: this.event,
4744
+ auth: this.auth,
3932
4745
  };
3933
4746
  return throwResult$1("success", "", data);
3934
4747
  }
@@ -3984,7 +4797,7 @@ class HarToApipost {
3984
4797
  if (isArray(headers) && headers.length) {
3985
4798
  return headers === null || headers === void 0 ? void 0 : headers.map((item) => {
3986
4799
  return {
3987
- param_id: ATools.snowflakeId(),
4800
+ param_id: apipostTools.snowflakeId(),
3988
4801
  description: "",
3989
4802
  field_type: "String",
3990
4803
  is_checked: 1,
@@ -4092,7 +4905,7 @@ class HarToApipost {
4092
4905
  if ((item === null || item === void 0 ? void 0 : item._resourceType) === "xhr" ||
4093
4906
  (item === null || item === void 0 ? void 0 : item._resourceType) === "preflight") {
4094
4907
  pre.push({
4095
- target_id: ATools.snowflakeId(),
4908
+ target_id: apipostTools.snowflakeId(),
4096
4909
  project_id: this.project.project_id || "",
4097
4910
  parent_id: "0",
4098
4911
  target_type: "api",
@@ -4197,7 +5010,7 @@ class InsomniaToApipost {
4197
5010
  completionParameter(parameter) {
4198
5011
  if (isArray(parameter)) {
4199
5012
  return parameter.map((item) => ({
4200
- param_id: ATools.snowflakeId(),
5013
+ param_id: apipostTools.snowflakeId(),
4201
5014
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4202
5015
  field_type: "String",
4203
5016
  is_checked: (item === null || item === void 0 ? void 0 : item.disabled) ? -1 : 1,
@@ -4257,7 +5070,7 @@ class InsomniaToApipost {
4257
5070
  type: "customScript",
4258
5071
  enabled: 1,
4259
5072
  name: "Script",
4260
- id: ATools.snowflakeId(),
5073
+ id: apipostTools.snowflakeId(),
4261
5074
  data: (item === null || item === void 0 ? void 0 : item.preRequestScript) || "",
4262
5075
  },
4263
5076
  ];
@@ -4268,7 +5081,7 @@ class InsomniaToApipost {
4268
5081
  type: "customScript",
4269
5082
  enabled: 1,
4270
5083
  name: "Script",
4271
- id: ATools.snowflakeId(),
5084
+ id: apipostTools.snowflakeId(),
4272
5085
  data: (item === null || item === void 0 ? void 0 : item.afterResponseScript) || "",
4273
5086
  },
4274
5087
  ];
@@ -4349,7 +5162,7 @@ class InsomniaToApipost {
4349
5162
  return [
4350
5163
  {
4351
5164
  name: 'Message',
4352
- param_id: ATools.snowflakeId(),
5165
+ param_id: apipostTools.snowflakeId(),
4353
5166
  request: message,
4354
5167
  response: {
4355
5168
  mode: 'text',
@@ -4388,7 +5201,7 @@ class InsomniaToApipost {
4388
5201
  var _a;
4389
5202
  return {
4390
5203
  project_id: this.project.project_id || "",
4391
- target_id: ATools.snowflakeId(),
5204
+ target_id: apipostTools.snowflakeId(),
4392
5205
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4393
5206
  description: (item === null || item === void 0 ? void 0 : item.description) || '',
4394
5207
  target_type: "websocket2",
@@ -4432,7 +5245,7 @@ class InsomniaToApipost {
4432
5245
  completionGraphqlRequestBody(body) {
4433
5246
  return {
4434
5247
  query_schema: {},
4435
- query_list: [Object.assign(Object.assign({ param_id: ATools.snowflakeId(), name: 'New Query' }, this.getGraphQLQuery(body === null || body === void 0 ? void 0 : body.text)), { response: {
5248
+ query_list: [Object.assign(Object.assign({ param_id: apipostTools.snowflakeId(), name: 'New Query' }, this.getGraphQLQuery(body === null || body === void 0 ? void 0 : body.text)), { response: {
4436
5249
  mode: 'json',
4437
5250
  raw: '',
4438
5251
  raw_parameter: [],
@@ -4445,7 +5258,7 @@ class InsomniaToApipost {
4445
5258
  const request = this.completionApiRequest(item);
4446
5259
  const body = this.completionGraphqlRequestBody(item === null || item === void 0 ? void 0 : item.body);
4447
5260
  return {
4448
- target_id: ATools.snowflakeId(),
5261
+ target_id: apipostTools.snowflakeId(),
4449
5262
  project_id: this.project.project_id || "",
4450
5263
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4451
5264
  target_type: "graphql",
@@ -4503,7 +5316,7 @@ class InsomniaToApipost {
4503
5316
  completionApiTarget(item) {
4504
5317
  var _a;
4505
5318
  return {
4506
- target_id: ATools.snowflakeId(),
5319
+ target_id: apipostTools.snowflakeId(),
4507
5320
  project_id: this.project.project_id || "",
4508
5321
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4509
5322
  target_type: "api",
@@ -4579,7 +5392,7 @@ class InsomniaToApipost {
4579
5392
  var _a, _b;
4580
5393
  if ((item === null || item === void 0 ? void 0 : item._type) === "request_group" && lodash.has(this.foldersMap, item === null || item === void 0 ? void 0 : item._id)) {
4581
5394
  pre.push({
4582
- target_id: this.foldersMap[item === null || item === void 0 ? void 0 : item._id] || ATools.snowflakeId(),
5395
+ target_id: this.foldersMap[item === null || item === void 0 ? void 0 : item._id] || apipostTools.snowflakeId(),
4583
5396
  project_id: this.project.project_id || "",
4584
5397
  parent_id: this.foldersMap[item === null || item === void 0 ? void 0 : item.parentId] || "0",
4585
5398
  target_type: "folder",
@@ -4612,7 +5425,7 @@ class InsomniaToApipost {
4612
5425
  if ((item === null || item === void 0 ? void 0 : item._type) === "environment" && (item === null || item === void 0 ? void 0 : item.name)) {
4613
5426
  this.envs = this.envs.concat([
4614
5427
  {
4615
- env_id: ATools.snowflakeId(),
5428
+ env_id: apipostTools.snowflakeId(),
4616
5429
  name: item === null || item === void 0 ? void 0 : item.name,
4617
5430
  is_private: (item === null || item === void 0 ? void 0 : item.isPrivate) ? 1 : -1,
4618
5431
  server_list: [],
@@ -4634,7 +5447,7 @@ class InsomniaToApipost {
4634
5447
  initFolders(resources) {
4635
5448
  this.foldersMap = resources === null || resources === void 0 ? void 0 : resources.reduce((pre, item) => {
4636
5449
  if ((item === null || item === void 0 ? void 0 : item._type) === "request_group" && (item === null || item === void 0 ? void 0 : item._id)) {
4637
- pre[item._id] = ATools.snowflakeId();
5450
+ pre[item._id] = apipostTools.snowflakeId();
4638
5451
  }
4639
5452
  if ((item === null || item === void 0 ? void 0 : item._type) === "workspace") {
4640
5453
  pre[item._id] = "0";
@@ -4770,9 +5583,9 @@ class PostmanToApipost {
4770
5583
  state: (authMap === null || authMap === void 0 ? void 0 : authMap.state) || '',
4771
5584
  client_authentication: (authMap === null || authMap === void 0 ? void 0 : authMap.client_authentication) || 'header',
4772
5585
  refreshTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.refreshTokenUrl) || '',
4773
- authRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) ? (_e = authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) === null || _e === void 0 ? void 0 : _e.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
4774
- tokenRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) ? (_f = authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) === null || _f === void 0 ? void 0 : _f.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
4775
- refreshRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) ? (_g = authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) === null || _g === void 0 ? void 0 : _g.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
5586
+ authRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) ? (_e = authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) === null || _e === void 0 ? void 0 : _e.map((e) => (Object.assign(Object.assign({}, e), { param_id: apipostTools.snowflakeId() }))) : [],
5587
+ tokenRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) ? (_f = authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) === null || _f === void 0 ? void 0 : _f.map((e) => (Object.assign(Object.assign({}, e), { param_id: apipostTools.snowflakeId() }))) : [],
5588
+ refreshRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) ? (_g = authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) === null || _g === void 0 ? void 0 : _g.map((e) => (Object.assign(Object.assign({}, e), { param_id: apipostTools.snowflakeId() }))) : [],
4776
5589
  };
4777
5590
  }
4778
5591
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
@@ -4864,7 +5677,7 @@ class PostmanToApipost {
4864
5677
  if (isArray(items)) {
4865
5678
  return items === null || items === void 0 ? void 0 : items.reduce((pre, item) => {
4866
5679
  pre.push({
4867
- param_id: ATools.snowflakeId(),
5680
+ param_id: apipostTools.snowflakeId(),
4868
5681
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4869
5682
  field_type: DEFAULT_FIELD_TYPE.includes(item === null || item === void 0 ? void 0 : item.type)
4870
5683
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -4917,7 +5730,7 @@ class PostmanToApipost {
4917
5730
  type: "customScript",
4918
5731
  enabled: 1,
4919
5732
  name: "Custom Script",
4920
- id: ATools.snowflakeId(),
5733
+ id: apipostTools.snowflakeId(),
4921
5734
  data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec)
4922
5735
  ? (_e = (_d = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _d === void 0 ? void 0 : _d.exec) === null || _e === void 0 ? void 0 : _e.join("\n")
4923
5736
  : "",
@@ -4930,7 +5743,7 @@ class PostmanToApipost {
4930
5743
  type: "customScript",
4931
5744
  enabled: 1,
4932
5745
  name: "Custom Script",
4933
- id: ATools.snowflakeId(),
5746
+ id: apipostTools.snowflakeId(),
4934
5747
  data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec)
4935
5748
  ? (_h = (_g = test === null || test === void 0 ? void 0 : test.script) === null || _g === void 0 ? void 0 : _g.exec) === null || _h === void 0 ? void 0 : _h.join("\n")
4936
5749
  : "",
@@ -4951,7 +5764,7 @@ class PostmanToApipost {
4951
5764
  body: {
4952
5765
  query_schema: {},
4953
5766
  query_list: [{
4954
- param_id: ATools.snowflakeId(),
5767
+ param_id: apipostTools.snowflakeId(),
4955
5768
  name: 'New Query',
4956
5769
  query: lodash.isString((_k = (_j = request === null || request === void 0 ? void 0 : request.body) === null || _j === void 0 ? void 0 : _j.graphql) === null || _k === void 0 ? void 0 : _k.query) ? (_m = (_l = request === null || request === void 0 ? void 0 : request.body) === null || _l === void 0 ? void 0 : _l.graphql) === null || _m === void 0 ? void 0 : _m.query : '',
4957
5770
  variables: lodash.isString((_p = (_o = request === null || request === void 0 ? void 0 : request.body) === null || _o === void 0 ? void 0 : _o.graphql) === null || _p === void 0 ? void 0 : _p.variables) ? (_r = (_q = request === null || request === void 0 ? void 0 : request.body) === null || _q === void 0 ? void 0 : _q.graphql) === null || _r === void 0 ? void 0 : _r.variables : '',
@@ -4975,7 +5788,7 @@ class PostmanToApipost {
4975
5788
  type: "customScript",
4976
5789
  enabled: 1,
4977
5790
  name: "Custom Script",
4978
- id: ATools.snowflakeId(),
5791
+ id: apipostTools.snowflakeId(),
4979
5792
  data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec)
4980
5793
  ? (_e = (_d = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _d === void 0 ? void 0 : _d.exec) === null || _e === void 0 ? void 0 : _e.join("\n")
4981
5794
  : "",
@@ -4988,7 +5801,7 @@ class PostmanToApipost {
4988
5801
  type: "customScript",
4989
5802
  enabled: 1,
4990
5803
  name: "Custom Script",
4991
- id: ATools.snowflakeId(),
5804
+ id: apipostTools.snowflakeId(),
4992
5805
  data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec)
4993
5806
  ? (_h = (_g = test === null || test === void 0 ? void 0 : test.script) === null || _g === void 0 ? void 0 : _g.exec) === null || _h === void 0 ? void 0 : _h.join("\n")
4994
5807
  : "",
@@ -5020,7 +5833,7 @@ class PostmanToApipost {
5020
5833
  }
5021
5834
  completionApiFolder(item, parentInfo) {
5022
5835
  return {
5023
- target_id: ATools.snowflakeId(),
5836
+ target_id: apipostTools.snowflakeId(),
5024
5837
  project_id: this.project.project_id || "",
5025
5838
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5026
5839
  target_type: "folder",
@@ -5040,7 +5853,7 @@ class PostmanToApipost {
5040
5853
  const { request } = item || {};
5041
5854
  if (lodash.isEqual((_a = request === null || request === void 0 ? void 0 : request.body) === null || _a === void 0 ? void 0 : _a.mode, 'graphql')) {
5042
5855
  return {
5043
- target_id: ATools.snowflakeId(),
5856
+ target_id: apipostTools.snowflakeId(),
5044
5857
  project_id: this.project.project_id || "",
5045
5858
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5046
5859
  target_type: "graphql",
@@ -5099,7 +5912,7 @@ class PostmanToApipost {
5099
5912
  };
5100
5913
  }
5101
5914
  return {
5102
- target_id: ATools.snowflakeId(),
5915
+ target_id: apipostTools.snowflakeId(),
5103
5916
  project_id: this.project.project_id || "",
5104
5917
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5105
5918
  target_type: "api",
@@ -5240,7 +6053,7 @@ class YapiToApipost {
5240
6053
  }
5241
6054
  completionApiFolder(item, parentInfo) {
5242
6055
  return {
5243
- target_id: ATools.snowflakeId(),
6056
+ target_id: apipostTools.snowflakeId(),
5244
6057
  project_id: this.project.project_id || "",
5245
6058
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5246
6059
  target_type: "folder",
@@ -5287,7 +6100,7 @@ class YapiToApipost {
5287
6100
  return req_headers === null || req_headers === void 0 ? void 0 : req_headers.reduce((pre, item) => {
5288
6101
  const field_type = (item === null || item === void 0 ? void 0 : item.type) === "file" ? "File" : "String";
5289
6102
  pre.push({
5290
- param_id: ATools.snowflakeId(),
6103
+ param_id: apipostTools.snowflakeId(),
5291
6104
  description: (item === null || item === void 0 ? void 0 : item.desc) || "",
5292
6105
  field_type,
5293
6106
  is_checked: 1,
@@ -5412,7 +6225,7 @@ class YapiToApipost {
5412
6225
  completionApiTarget(item, parentInfo) {
5413
6226
  var _a;
5414
6227
  return {
5415
- target_id: ATools.snowflakeId(),
6228
+ target_id: apipostTools.snowflakeId(),
5416
6229
  project_id: this.project.project_id || "",
5417
6230
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5418
6231
  target_type: "api",
@@ -5534,7 +6347,7 @@ class ThunderToApipost {
5534
6347
  if (action === "istype") {
5535
6348
  return {
5536
6349
  type: "customScript",
5537
- id: ATools.snowflakeId(),
6350
+ id: apipostTools.snowflakeId(),
5538
6351
  name: "Script",
5539
6352
  enabled: 1,
5540
6353
  data: `function isType(value, type) {
@@ -5583,7 +6396,7 @@ class ThunderToApipost {
5583
6396
  else if (action === "isjson") {
5584
6397
  return {
5585
6398
  type: "customScript",
5586
- id: ATools.snowflakeId(),
6399
+ id: apipostTools.snowflakeId(),
5587
6400
  name: "Script",
5588
6401
  enabled: 1,
5589
6402
  data: `function isJSON(str) {
@@ -5603,7 +6416,7 @@ class ThunderToApipost {
5603
6416
  else if (action === "count") {
5604
6417
  return {
5605
6418
  type: "customScript",
5606
- id: ATools.snowflakeId(),
6419
+ id: apipostTools.snowflakeId(),
5607
6420
  name: "Script",
5608
6421
  enabled: 1,
5609
6422
  data: ` pm.test("${action}", function () {
@@ -5615,7 +6428,7 @@ class ThunderToApipost {
5615
6428
  else if (action === "schema") {
5616
6429
  return {
5617
6430
  type: "customScript",
5618
- id: ATools.snowflakeId(),
6431
+ id: apipostTools.snowflakeId(),
5619
6432
  name: "Script",
5620
6433
  enabled: 1,
5621
6434
  data: `
@@ -5688,7 +6501,7 @@ class ThunderToApipost {
5688
6501
  completionApiFolder(item, parentInfo) {
5689
6502
  var _a;
5690
6503
  return {
5691
- target_id: ATools.snowflakeId(),
6504
+ target_id: apipostTools.snowflakeId(),
5692
6505
  project_id: this.project.project_id || "",
5693
6506
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5694
6507
  target_type: "folder",
@@ -5708,7 +6521,7 @@ class ThunderToApipost {
5708
6521
  return parameter === null || parameter === void 0 ? void 0 : parameter.reduce((pre, item) => {
5709
6522
  const field_type = (item === null || item === void 0 ? void 0 : item.type) === "file" ? "File" : "String";
5710
6523
  pre.push({
5711
- param_id: ATools.snowflakeId(),
6524
+ param_id: apipostTools.snowflakeId(),
5712
6525
  description: "",
5713
6526
  field_type,
5714
6527
  is_checked: (item === null || item === void 0 ? void 0 : item.isDisabled) ? -1 : 1,
@@ -5723,7 +6536,7 @@ class ThunderToApipost {
5723
6536
  }
5724
6537
  // auth
5725
6538
  completionApiRequestAuth(auth) {
5726
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
6539
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
5727
6540
  const customAuth = {};
5728
6541
  if ((auth === null || auth === void 0 ? void 0 : auth.type) === "bearer") {
5729
6542
  customAuth["type"] = "bearer";
@@ -5759,31 +6572,6 @@ class ThunderToApipost {
5759
6572
  sessionToken: ((_l = auth === null || auth === void 0 ? void 0 : auth.aws) === null || _l === void 0 ? void 0 : _l.sessionToken) || "",
5760
6573
  };
5761
6574
  }
5762
- else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
5763
- customAuth["type"] = "oauth2";
5764
- customAuth["oauth2"] = {
5765
- addTokenTo: "header",
5766
- headerPrefix: "Bearer",
5767
- access_token: "",
5768
- grant_type: ((_m = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _m === void 0 ? void 0 : _m.grantType) || "authorization_code",
5769
- redirect_uri: ((_o = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _o === void 0 ? void 0 : _o.callbackUrl) || "",
5770
- authUrl: ((_p = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _p === void 0 ? void 0 : _p.authUrl) || "",
5771
- accessTokenUrl: ((_q = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _q === void 0 ? void 0 : _q.tokenUrl) || "",
5772
- clientId: ((_r = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _r === void 0 ? void 0 : _r.clientId) || "",
5773
- clientSecret: ((_s = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _s === void 0 ? void 0 : _s.clientSecret) || "",
5774
- username: ((_t = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _t === void 0 ? void 0 : _t.username) || "",
5775
- password: ((_u = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _u === void 0 ? void 0 : _u.password) || "",
5776
- challengeAlgorithm: "S256",
5777
- code_verifier: "Bearer",
5778
- scope: ((_v = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _v === void 0 ? void 0 : _v.scope) || "",
5779
- state: ((_w = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _w === void 0 ? void 0 : _w.state) || "",
5780
- client_authentication: "header",
5781
- refreshTokenUrl: "",
5782
- authRequestParams: [],
5783
- tokenRequestParams: [],
5784
- refreshRequestParams: [],
5785
- };
5786
- }
5787
6575
  return Object.assign(Object.assign({}, DEFAULT_AUTH), customAuth);
5788
6576
  }
5789
6577
  // script
@@ -5795,7 +6583,7 @@ class ThunderToApipost {
5795
6583
  enabled: 1,
5796
6584
  data: lodash.join(script, "\n"),
5797
6585
  name: "Script",
5798
- id: ATools.snowflakeId(),
6586
+ id: apipostTools.snowflakeId(),
5799
6587
  },
5800
6588
  ];
5801
6589
  }
@@ -5813,7 +6601,7 @@ class ThunderToApipost {
5813
6601
  if (action) {
5814
6602
  asserts.push({
5815
6603
  type: "assert",
5816
- id: ATools.snowflakeId(),
6604
+ id: apipostTools.snowflakeId(),
5817
6605
  name: "Assertion",
5818
6606
  enabled: 1,
5819
6607
  data: {
@@ -5830,7 +6618,7 @@ class ThunderToApipost {
5830
6618
  case "res-body":
5831
6619
  asserts.push({
5832
6620
  type: "assert",
5833
- id: ATools.snowflakeId(),
6621
+ id: apipostTools.snowflakeId(),
5834
6622
  name: "Assertion",
5835
6623
  enabled: 1,
5836
6624
  data: {
@@ -5846,7 +6634,7 @@ class ThunderToApipost {
5846
6634
  case "res-time":
5847
6635
  asserts.push({
5848
6636
  type: "assert",
5849
- id: ATools.snowflakeId(),
6637
+ id: apipostTools.snowflakeId(),
5850
6638
  name: "Assertion",
5851
6639
  enabled: 1,
5852
6640
  data: {
@@ -5862,7 +6650,7 @@ class ThunderToApipost {
5862
6650
  case "Content-Type":
5863
6651
  asserts.push({
5864
6652
  type: "assert",
5865
- id: ATools.snowflakeId(),
6653
+ id: apipostTools.snowflakeId(),
5866
6654
  name: "Assertion",
5867
6655
  enabled: 1,
5868
6656
  data: {
@@ -5878,7 +6666,7 @@ class ThunderToApipost {
5878
6666
  case "Content-Length":
5879
6667
  asserts.push({
5880
6668
  type: "assert",
5881
- id: ATools.snowflakeId(),
6669
+ id: apipostTools.snowflakeId(),
5882
6670
  name: "Assertion",
5883
6671
  enabled: 1,
5884
6672
  data: {
@@ -5894,7 +6682,7 @@ class ThunderToApipost {
5894
6682
  case "Content-Encoding":
5895
6683
  asserts.push({
5896
6684
  type: "assert",
5897
- id: ATools.snowflakeId(),
6685
+ id: apipostTools.snowflakeId(),
5898
6686
  name: "Assertion",
5899
6687
  enabled: 1,
5900
6688
  data: {
@@ -5910,7 +6698,7 @@ class ThunderToApipost {
5910
6698
  case "custom-header":
5911
6699
  asserts.push({
5912
6700
  type: "assert",
5913
- id: ATools.snowflakeId(),
6701
+ id: apipostTools.snowflakeId(),
5914
6702
  name: "Assertion",
5915
6703
  enabled: 1,
5916
6704
  data: {
@@ -5926,7 +6714,7 @@ class ThunderToApipost {
5926
6714
  case "json-query":
5927
6715
  asserts.push({
5928
6716
  type: "assert",
5929
- id: ATools.snowflakeId(),
6717
+ id: apipostTools.snowflakeId(),
5930
6718
  name: "Assertion",
5931
6719
  enabled: 1,
5932
6720
  data: {
@@ -5942,14 +6730,14 @@ class ThunderToApipost {
5942
6730
  case "set-env-var":
5943
6731
  asserts.push({
5944
6732
  type: "pickVars",
5945
- id: ATools.snowflakeId(),
6733
+ id: apipostTools.snowflakeId(),
5946
6734
  name: "Variable Name",
5947
6735
  enabled: 1,
5948
6736
  data: {
5949
6737
  source: "responseJson",
5950
6738
  variables: [
5951
6739
  {
5952
- param_id: ATools.snowflakeId(),
6740
+ param_id: apipostTools.snowflakeId(),
5953
6741
  name: lodash.first(lodash.split(lodash.trim(test === null || test === void 0 ? void 0 : test.value, "{}"), ",")),
5954
6742
  expression: lodash.replace((test === null || test === void 0 ? void 0 : test.custom) || "", "json.", "$.") || "",
5955
6743
  type: "envVars",
@@ -6033,7 +6821,7 @@ class ThunderToApipost {
6033
6821
  completionApiTarget(item, parentInfo) {
6034
6822
  var _a;
6035
6823
  return {
6036
- target_id: ATools.snowflakeId(),
6824
+ target_id: apipostTools.snowflakeId(),
6037
6825
  project_id: this.project.project_id || "",
6038
6826
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
6039
6827
  target_type: "api",
@@ -6090,82 +6878,13 @@ class ThunderToApipost {
6090
6878
  is_force: -1,
6091
6879
  };
6092
6880
  }
6093
- completionWs2Request(item) {
6094
- const headerParameter = this.completionApiRequestParameter(item === null || item === void 0 ? void 0 : item.headers);
6095
- const queryParameter = this.completionApiRequestParameter(item === null || item === void 0 ? void 0 : item.params);
6096
- return {
6097
- header: {
6098
- parameter: headerParameter,
6099
- },
6100
- query: {
6101
- parameter: queryParameter,
6102
- },
6103
- cookie: {
6104
- parameter: [],
6105
- },
6106
- };
6107
- }
6108
- completionWs2Message(item) {
6109
- var _a, _b;
6110
- return [
6111
- {
6112
- name: "Message",
6113
- param_id: ATools.snowflakeId(),
6114
- request: {
6115
- mode: (_a = item === null || item === void 0 ? void 0 : item.body) === null || _a === void 0 ? void 0 : _a.type,
6116
- raw: ((_b = item === null || item === void 0 ? void 0 : item.body) === null || _b === void 0 ? void 0 : _b.raw) || "",
6117
- raw_parameter: [],
6118
- raw_schema: {
6119
- type: "object",
6120
- },
6121
- },
6122
- response: {
6123
- mode: "text",
6124
- raw: "",
6125
- raw_parameter: [],
6126
- raw_schema: {
6127
- type: "object",
6128
- },
6129
- },
6130
- },
6131
- ];
6132
- }
6133
- // websocket2
6134
- completionWs2Target(item, parentInfo) {
6135
- return {
6136
- target_id: ATools.snowflakeId(),
6137
- project_id: this.project.project_id || "",
6138
- parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
6139
- target_type: "websocket2",
6140
- name: (item === null || item === void 0 ? void 0 : item.name) || "New Websocket",
6141
- version: 0,
6142
- sort: 0,
6143
- description: (item === null || item === void 0 ? void 0 : item.docs) || "",
6144
- method: "",
6145
- url: (item === null || item === void 0 ? void 0 : item.url) || "",
6146
- mark_id: "1",
6147
- protocol: "http/1.1",
6148
- request: this.completionWs2Request(item),
6149
- message: this.completionWs2Message(item),
6150
- attribute_info: {},
6151
- tags: [],
6152
- is_force: -1,
6153
- };
6154
- }
6155
6881
  completionApis(arr, parentInfo) {
6156
6882
  if (arr === null || arr === void 0 ? void 0 : arr.length) {
6157
6883
  return arr === null || arr === void 0 ? void 0 : arr.reduce((pre, targetItem) => {
6158
- console.log(targetItem, "targetItem.type");
6159
6884
  if (!lodash.isEqual(targetItem.type, "folder")) {
6160
- let target;
6161
6885
  // 接口
6162
- if (lodash.isEqual(targetItem === null || targetItem === void 0 ? void 0 : targetItem.reqType, "ws")) {
6163
- target = this.completionWs2Target(targetItem, parentInfo);
6164
- }
6165
- else {
6166
- target = this.completionApiTarget(targetItem, parentInfo);
6167
- }
6168
- target && pre.push(target);
6886
+ const target = this.completionApiTarget(targetItem, parentInfo);
6887
+ pre.push(target);
6169
6888
  }
6170
6889
  else {
6171
6890
  // 目录