echoapi-converter 0.0.37 → 0.0.39

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,7 +499,7 @@ 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,
@@ -517,7 +516,7 @@ 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;
@@ -597,7 +596,7 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
597
596
  obj = oldParameter[oldIndex];
598
597
  }
599
598
  restfulList.push({
600
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
599
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
601
600
  field_type: "String",
602
601
  is_checked: 1,
603
602
  key: pathsItem.substring(1, pathsItem.length),
@@ -622,7 +621,7 @@ const genRestfulByUrl = (url, oldParameter, key = "key") => {
622
621
  obj = oldParameter[oldIndex];
623
622
  }
624
623
  restfulList.push({
625
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
624
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
626
625
  field_type: "String",
627
626
  is_checked: 1,
628
627
  key: matchesItem,
@@ -659,7 +658,7 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
659
658
  obj = oldParameter[oldIndex];
660
659
  }
661
660
  restfulList.push({
662
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
661
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
663
662
  field_type: "String",
664
663
  is_checked: 1,
665
664
  key: pathsItem.substring(1, pathsItem.length),
@@ -684,7 +683,7 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
684
683
  obj = oldParameter[oldIndex];
685
684
  }
686
685
  restfulList.push({
687
- param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || ATools.snowflakeId(),
686
+ param_id: (obj === null || obj === void 0 ? void 0 : obj.param_id) || apipostTools.snowflakeId(),
688
687
  field_type: "String",
689
688
  is_checked: 1,
690
689
  key: matchesItem,
@@ -1113,7 +1112,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1113
1112
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1114
1113
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1115
1114
  is_checked: 1,
1116
- param_id: ATools.snowflakeId(),
1115
+ param_id: apipostTools.snowflakeId(),
1117
1116
  });
1118
1117
  }
1119
1118
  return example;
@@ -1154,7 +1153,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1154
1153
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1155
1154
  type: "String",
1156
1155
  is_checked: 1,
1157
- param_id: ATools.snowflakeId(),
1156
+ param_id: apipostTools.snowflakeId(),
1158
1157
  });
1159
1158
  }
1160
1159
  example.push(value);
@@ -1170,7 +1169,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1170
1169
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1171
1170
  type: "String",
1172
1171
  is_checked: 1,
1173
- param_id: ATools.snowflakeId(),
1172
+ param_id: apipostTools.snowflakeId(),
1174
1173
  });
1175
1174
  }
1176
1175
  example.push(value);
@@ -1186,7 +1185,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1186
1185
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1187
1186
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1188
1187
  is_checked: 1,
1189
- param_id: ATools.snowflakeId(),
1188
+ param_id: apipostTools.snowflakeId(),
1190
1189
  });
1191
1190
  }
1192
1191
  return (schema === null || schema === void 0 ? void 0 : schema.example) || (schema === null || schema === void 0 ? void 0 : schema.default) || 0;
@@ -1200,7 +1199,7 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
1200
1199
  not_null: (requiredArr === null || requiredArr === void 0 ? void 0 : requiredArr.find(it => it == propName)) ? 1 : -1,
1201
1200
  field_type: type ? type.charAt(0).toUpperCase() + type.slice(1) : "String",
1202
1201
  is_checked: 1,
1203
- param_id: ATools.snowflakeId(),
1202
+ param_id: apipostTools.snowflakeId(),
1204
1203
  });
1205
1204
  }
1206
1205
  return (schema === null || schema === void 0 ? void 0 : schema.example) || (schema === null || schema === void 0 ? void 0 : schema.default) || "";
@@ -1215,7 +1214,7 @@ const replaceRef = (schemaObj) => {
1215
1214
  if (typeof value === 'object' && value !== null) {
1216
1215
  // 查找并替换 insAppInfo 对象
1217
1216
  if (lodash.has(value, 'ref') || lodash.has(value, '$$ref')) {
1218
- let newIuid = ATools.snowflakeId();
1217
+ let newIuid = apipostTools.snowflakeId();
1219
1218
  if ((value === null || value === void 0 ? void 0 : value.ref) && value.ref.startsWith('http://localhost:8000/')) {
1220
1219
  const index = (_a = value.ref) === null || _a === void 0 ? void 0 : _a.indexOf('#');
1221
1220
  if (index !== -1) {
@@ -1260,7 +1259,7 @@ const swaggerSchema2apipostSchema = (schemaObj) => {
1260
1259
  // 还原为对象
1261
1260
  jsonSchema = JSON.parse(jsonSchemaStr);
1262
1261
  if (lodash.has(jsonSchema, 'ref') || lodash.has(jsonSchema, '$$ref')) {
1263
- let newIuid = ATools.snowflakeId();
1262
+ let newIuid = apipostTools.snowflakeId();
1264
1263
  if ((jsonSchema === null || jsonSchema === void 0 ? void 0 : jsonSchema.ref) && jsonSchema.ref.startsWith("http://localhost:8000/")) {
1265
1264
  // jsonSchema.ref = jsonSchema.ref.substring(22);
1266
1265
  const index = (_a = jsonSchema.ref) === null || _a === void 0 ? void 0 : _a.indexOf('#');
@@ -1436,7 +1435,7 @@ class SwaggerToApipost {
1436
1435
  getBeautifulRaw(raw) {
1437
1436
  var _a;
1438
1437
  try {
1439
- return (_a = ATools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
1438
+ return (_a = apipostTools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
1440
1439
  }
1441
1440
  catch (err) {
1442
1441
  return raw;
@@ -1613,7 +1612,7 @@ class SwaggerToApipost {
1613
1612
  not_null: (parameter === null || parameter === void 0 ? void 0 : parameter.required) ? 1 : -1, // 是否为空
1614
1613
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1615
1614
  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(),
1615
+ param_id: apipostTools.snowflakeId(),
1617
1616
  });
1618
1617
  }
1619
1618
  else if (parameter.in == "header") {
@@ -1633,7 +1632,7 @@ class SwaggerToApipost {
1633
1632
  not_null: parameter.required ? 1 : -1, // 是否为空
1634
1633
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1635
1634
  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(),
1635
+ param_id: apipostTools.snowflakeId(),
1637
1636
  });
1638
1637
  }
1639
1638
  else if (parameter.in == "path") {
@@ -1653,7 +1652,7 @@ class SwaggerToApipost {
1653
1652
  not_null: parameter.required ? 1 : -1, // 是否为空
1654
1653
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
1655
1654
  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(),
1655
+ param_id: apipostTools.snowflakeId(),
1657
1656
  });
1658
1657
  }
1659
1658
  }
@@ -1697,7 +1696,7 @@ class SwaggerToApipost {
1697
1696
  field_type: lodash.has(item, "type")
1698
1697
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
1699
1698
  : "String",
1700
- param_id: ATools.snowflakeId(),
1699
+ param_id: apipostTools.snowflakeId(),
1701
1700
  });
1702
1701
  }
1703
1702
  }
@@ -1800,7 +1799,7 @@ class SwaggerToApipost {
1800
1799
  }
1801
1800
  else {
1802
1801
  // 其他示例
1803
- const newUUID = ATools.snowflakeId();
1802
+ const newUUID = apipostTools.snowflakeId();
1804
1803
  response.example.push({
1805
1804
  example_id: newUUID,
1806
1805
  raw: Raw_text,
@@ -1871,7 +1870,7 @@ class SwaggerToApipost {
1871
1870
  }
1872
1871
  else {
1873
1872
  // 其他示例
1874
- const newUUID = ATools.snowflakeId();
1873
+ const newUUID = apipostTools.snowflakeId();
1875
1874
  let originRaw;
1876
1875
  try {
1877
1876
  if (Object.prototype.toString.call(example) ===
@@ -1928,7 +1927,7 @@ class SwaggerToApipost {
1928
1927
  }
1929
1928
  else {
1930
1929
  // 其他示例
1931
- const newUUID = ATools.snowflakeId();
1930
+ const newUUID = apipostTools.snowflakeId();
1932
1931
  response.example.push({
1933
1932
  example_id: newUUID,
1934
1933
  raw: Raw_text,
@@ -1950,7 +1949,7 @@ class SwaggerToApipost {
1950
1949
  }
1951
1950
  else {
1952
1951
  response.example.push({
1953
- example_id: ATools.snowflakeId(),
1952
+ example_id: apipostTools.snowflakeId(),
1954
1953
  raw: "",
1955
1954
  raw_parameter: [],
1956
1955
  expect: {
@@ -2086,7 +2085,7 @@ class SwaggerToApipost {
2086
2085
  not_null: 1,
2087
2086
  description: "",
2088
2087
  field_type: "String",
2089
- param_id: ATools.snowflakeId(),
2088
+ param_id: apipostTools.snowflakeId(),
2090
2089
  });
2091
2090
  }
2092
2091
  if (lodash.has(swaggerApi, "parameters")) {
@@ -2120,7 +2119,7 @@ class SwaggerToApipost {
2120
2119
  not_null: parameter.required ? 1 : -1, // 是否为空
2121
2120
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2122
2121
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2123
- param_id: ATools.snowflakeId(),
2122
+ param_id: apipostTools.snowflakeId(),
2124
2123
  });
2125
2124
  }
2126
2125
  else if (parameter.in == "header") {
@@ -2140,7 +2139,7 @@ class SwaggerToApipost {
2140
2139
  not_null: parameter.required ? 1 : -1, // 是否为空
2141
2140
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2142
2141
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2143
- param_id: ATools.snowflakeId(),
2142
+ param_id: apipostTools.snowflakeId(),
2144
2143
  });
2145
2144
  }
2146
2145
  else if (parameter.in == "path") {
@@ -2160,7 +2159,7 @@ class SwaggerToApipost {
2160
2159
  not_null: parameter.required ? 1 : -1, // 是否为空
2161
2160
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2162
2161
  field_type: getFidldType(parameter === null || parameter === void 0 ? void 0 : parameter.type), // 类型
2163
- param_id: ATools.snowflakeId(),
2162
+ param_id: apipostTools.snowflakeId(),
2164
2163
  });
2165
2164
  }
2166
2165
  else if (parameter.in == "body") {
@@ -2209,7 +2208,7 @@ class SwaggerToApipost {
2209
2208
  not_null: parameter.required ? 1 : -1, // 是否为空
2210
2209
  description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
2211
2210
  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(),
2211
+ param_id: apipostTools.snowflakeId(),
2213
2212
  });
2214
2213
  }
2215
2214
  }
@@ -2280,7 +2279,7 @@ class SwaggerToApipost {
2280
2279
  }
2281
2280
  else {
2282
2281
  // 其他示例
2283
- const newUUID = ATools.snowflakeId();
2282
+ const newUUID = apipostTools.snowflakeId();
2284
2283
  response.example.push({
2285
2284
  example_id: newUUID,
2286
2285
  raw: Raw_text,
@@ -2349,7 +2348,7 @@ class SwaggerToApipost {
2349
2348
  }
2350
2349
  else {
2351
2350
  // 其他示例
2352
- const newUUID = ATools.snowflakeId();
2351
+ const newUUID = apipostTools.snowflakeId();
2353
2352
  response.example.push({
2354
2353
  example_id: newUUID,
2355
2354
  raw: Raw_text,
@@ -2375,7 +2374,7 @@ class SwaggerToApipost {
2375
2374
  }
2376
2375
  else {
2377
2376
  // 其他示例
2378
- const newUUID = ATools.snowflakeId();
2377
+ const newUUID = apipostTools.snowflakeId();
2379
2378
  response.example.push({
2380
2379
  example_id: newUUID,
2381
2380
  raw: "",
@@ -2559,7 +2558,7 @@ class ApidocToApipost {
2559
2558
  return parameter.map((item) => {
2560
2559
  var _a;
2561
2560
  return ({
2562
- param_id: ATools.snowflakeId(),
2561
+ param_id: apipostTools.snowflakeId(),
2563
2562
  description: removePTags((item === null || item === void 0 ? void 0 : item.description) || ""),
2564
2563
  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
2564
  ? "Array"
@@ -2652,7 +2651,7 @@ class ApidocToApipost {
2652
2651
  ? (_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
2652
  : "";
2654
2653
  pre.push({
2655
- example_id: ATools.snowflakeId(),
2654
+ example_id: apipostTools.snowflakeId(),
2656
2655
  raw_parameter: [],
2657
2656
  raw: getBeautifulRaw(raw || ""),
2658
2657
  expect: {
@@ -2676,7 +2675,7 @@ class ApidocToApipost {
2676
2675
  ? (_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
2676
  : "";
2678
2677
  pre.push({
2679
- example_id: ATools.snowflakeId(),
2678
+ example_id: apipostTools.snowflakeId(),
2680
2679
  raw_parameter: [],
2681
2680
  raw: getBeautifulRaw(raw || ""),
2682
2681
  expect: {
@@ -2743,7 +2742,7 @@ class ApidocToApipost {
2743
2742
  id = this.foldersMap[item === null || item === void 0 ? void 0 : item.group];
2744
2743
  }
2745
2744
  else if (item === null || item === void 0 ? void 0 : item.group) {
2746
- id = ATools.snowflakeId();
2745
+ id = apipostTools.snowflakeId();
2747
2746
  this.foldersMap[item === null || item === void 0 ? void 0 : item.group] = id;
2748
2747
  pre.push({
2749
2748
  target_id: id,
@@ -2762,7 +2761,7 @@ class ApidocToApipost {
2762
2761
  });
2763
2762
  }
2764
2763
  pre.push({
2765
- target_id: ATools.snowflakeId(),
2764
+ target_id: apipostTools.snowflakeId(),
2766
2765
  project_id: this.project.project_id || "",
2767
2766
  parent_id: id || "0",
2768
2767
  target_type: "api",
@@ -2998,7 +2997,7 @@ class ApifoxToApipost {
2998
2997
  completionParameter(parameter) {
2999
2998
  if (isArray(parameter)) {
3000
2999
  return parameter.map(({ description = "", type = "String", defaultEnable = true, name = "", defaultValue = "", required = 1, }) => ({
3001
- param_id: ATools.snowflakeId(),
3000
+ param_id: apipostTools.snowflakeId(),
3002
3001
  description,
3003
3002
  field_type: type
3004
3003
  ? type.charAt(0).toUpperCase() + type.slice(1)
@@ -3048,7 +3047,7 @@ class ApifoxToApipost {
3048
3047
  if (isArray(environments)) {
3049
3048
  const envs = environments.reduce((pre, item) => {
3050
3049
  pre.push({
3051
- env_id: ATools.snowflakeId(),
3050
+ env_id: apipostTools.snowflakeId(),
3052
3051
  name: item === null || item === void 0 ? void 0 : item.name,
3053
3052
  is_private: (item === null || item === void 0 ? void 0 : item.visibility) === "protected"
3054
3053
  ? -1
@@ -3071,7 +3070,7 @@ class ApifoxToApipost {
3071
3070
  var _a;
3072
3071
  if (isArray(servers)) {
3073
3072
  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();
3073
+ const server_id = apipostTools.snowflakeId();
3075
3074
  this.serversMap[item.id] = {
3076
3075
  server_id: (item === null || item === void 0 ? void 0 : item.id) === "default" ? "1" : server_id,
3077
3076
  name: (item === null || item === void 0 ? void 0 : item.name) || `Server${server_id}`,
@@ -3102,7 +3101,7 @@ class ApifoxToApipost {
3102
3101
  this.global.mock_custom_rules = mapRules === null || mapRules === void 0 ? void 0 : mapRules.map((item) => {
3103
3102
  var _a;
3104
3103
  return ({
3105
- mock_custom_rule_id: ATools.snowflakeId(),
3104
+ mock_custom_rule_id: apipostTools.snowflakeId(),
3106
3105
  project_id: this.project.project_id,
3107
3106
  field_type: item === null || item === void 0 ? void 0 : item.type,
3108
3107
  match_type: ((_a = ["wildcard", "exact"]) === null || _a === void 0 ? void 0 : _a.includes(item === null || item === void 0 ? void 0 : item.matchType))
@@ -3174,7 +3173,7 @@ class ApifoxToApipost {
3174
3173
  if (lodash.has(item, "items") && !lodash.has(item, "schema")) {
3175
3174
  // 这是目录操作
3176
3175
  const parent = {
3177
- model_id: ATools.snowflakeId(),
3176
+ model_id: apipostTools.snowflakeId(),
3178
3177
  model_type: "folder",
3179
3178
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3180
3179
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.model_id) || "0",
@@ -3188,7 +3187,7 @@ class ApifoxToApipost {
3188
3187
  if (!lodash.has(item, "items") && lodash.has(item, "schema")) {
3189
3188
  // 这是模型操作
3190
3189
  // 这里要做Map映射 引用ref替换使用
3191
- const model_id = ATools.snowflakeId();
3190
+ const model_id = apipostTools.snowflakeId();
3192
3191
  if (item === null || item === void 0 ? void 0 : item.id) {
3193
3192
  this.modelMap[item.id] = model_id;
3194
3193
  }
@@ -3233,7 +3232,7 @@ class ApifoxToApipost {
3233
3232
  pre.push({
3234
3233
  type: item === null || item === void 0 ? void 0 : item.type,
3235
3234
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3236
- id: ATools.snowflakeId(),
3235
+ id: apipostTools.snowflakeId(),
3237
3236
  name: "Script",
3238
3237
  data: (item === null || item === void 0 ? void 0 : item.data) || "",
3239
3238
  });
@@ -3242,7 +3241,7 @@ class ApifoxToApipost {
3242
3241
  pre.push({
3243
3242
  type: item === null || item === void 0 ? void 0 : item.type,
3244
3243
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3245
- id: ATools.snowflakeId(),
3244
+ id: apipostTools.snowflakeId(),
3246
3245
  name: ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.name) || "Database",
3247
3246
  data: {
3248
3247
  query: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.expression) || "",
@@ -3255,7 +3254,7 @@ class ApifoxToApipost {
3255
3254
  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
3255
  "variables",
3257
3256
  pattern: (variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.jsonPath) || "",
3258
- param_id: ATools.snowflakeId(),
3257
+ param_id: apipostTools.snowflakeId(),
3259
3258
  });
3260
3259
  }
3261
3260
  return pre;
@@ -3267,7 +3266,7 @@ class ApifoxToApipost {
3267
3266
  pre.push({
3268
3267
  type: "pickVars",
3269
3268
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3270
- id: ATools.snowflakeId(),
3269
+ id: apipostTools.snowflakeId(),
3271
3270
  name: ((_f = item === null || item === void 0 ? void 0 : item.data) === null || _f === void 0 ? void 0 : _f.variableName) || "Variable Name",
3272
3271
  data: {
3273
3272
  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 +3278,7 @@ class ApifoxToApipost {
3279
3278
  pre.push({
3280
3279
  type: "assert",
3281
3280
  enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
3282
- id: ATools.snowflakeId(),
3281
+ id: apipostTools.snowflakeId(),
3283
3282
  name: ((_h = item === null || item === void 0 ? void 0 : item.data) === null || _h === void 0 ? void 0 : _h.name) || "Assertion",
3284
3283
  data: {
3285
3284
  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 +3447,7 @@ class ApifoxToApipost {
3448
3447
  completionApiRequestParameter(parameter) {
3449
3448
  if (isArray(parameter)) {
3450
3449
  return parameter === null || parameter === void 0 ? void 0 : parameter.map((item) => ({
3451
- param_id: ATools.snowflakeId(),
3450
+ param_id: apipostTools.snowflakeId(),
3452
3451
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3453
3452
  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
3453
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -3470,7 +3469,7 @@ class ApifoxToApipost {
3470
3469
  body["parameter"] = (_a = requestBody === null || requestBody === void 0 ? void 0 : requestBody.parameters) === null || _a === void 0 ? void 0 : _a.map((item) => {
3471
3470
  var _a;
3472
3471
  return ({
3473
- param_id: ATools.snowflakeId(),
3472
+ param_id: apipostTools.snowflakeId(),
3474
3473
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
3475
3474
  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
3475
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -3552,7 +3551,7 @@ class ApifoxToApipost {
3552
3551
  };
3553
3552
  }
3554
3553
  completionApiFolder(item, parentInfo) {
3555
- const target_id = ATools.snowflakeId();
3554
+ const target_id = apipostTools.snowflakeId();
3556
3555
  if (item === null || item === void 0 ? void 0 : item.id) {
3557
3556
  this.foldersMap[item.id] = target_id;
3558
3557
  }
@@ -3593,7 +3592,7 @@ class ApifoxToApipost {
3593
3592
  const example = responses === null || responses === void 0 ? void 0 : responses.map((item, index) => {
3594
3593
  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
3594
  return {
3596
- example_id: ATools.snowflakeId(),
3595
+ example_id: apipostTools.snowflakeId(),
3597
3596
  raw: raw ? getBeautifulRaw((raw === null || raw === void 0 ? void 0 : raw.data) || "") : "",
3598
3597
  raw_parameter: [],
3599
3598
  expect: {
@@ -3619,7 +3618,7 @@ class ApifoxToApipost {
3619
3618
  return {
3620
3619
  query_schema: {},
3621
3620
  query_list: [{
3622
- param_id: ATools.snowflakeId(),
3621
+ param_id: apipostTools.snowflakeId(),
3623
3622
  name: 'New Query',
3624
3623
  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
3624
  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 +3654,7 @@ class ApifoxToApipost {
3655
3654
  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
3655
  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
3656
  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) || "" });
3657
+ }, 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
3658
  });
3660
3659
  }
3661
3660
  completionApis(items, parentInfo) {
@@ -3670,7 +3669,7 @@ class ApifoxToApipost {
3670
3669
  if (!lodash.has(item, "items") && lodash.has(item, "api")) {
3671
3670
  // 这是接口操作
3672
3671
  const base = {
3673
- target_id: ATools.snowflakeId(),
3672
+ target_id: apipostTools.snowflakeId(),
3674
3673
  project_id: this.project.project_id || "",
3675
3674
  };
3676
3675
  const target = this.completionApiTarget(item, base, parentInfo);
@@ -3701,7 +3700,7 @@ class ApifoxToApipost {
3701
3700
  var _a;
3702
3701
  if (lodash.has(this.foldersMap, docItem === null || docItem === void 0 ? void 0 : docItem.folderId)) {
3703
3702
  preItems.push({
3704
- target_id: ATools.snowflakeId(),
3703
+ target_id: apipostTools.snowflakeId(),
3705
3704
  project_id: this.project.project_id || "",
3706
3705
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[docItem === null || docItem === void 0 ? void 0 : docItem.folderId]) || "0",
3707
3706
  target_type: "doc",
@@ -3734,7 +3733,7 @@ class ApifoxToApipost {
3734
3733
  completionTcpClient(tcpClientItem) {
3735
3734
  var _a;
3736
3735
  return {
3737
- target_id: ATools.snowflakeId(),
3736
+ target_id: apipostTools.snowflakeId(),
3738
3737
  project_id: this.project.project_id || "",
3739
3738
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[tcpClientItem === null || tcpClientItem === void 0 ? void 0 : tcpClientItem.folderId]) || "0",
3740
3739
  target_type: "socket",
@@ -3772,7 +3771,7 @@ class ApifoxToApipost {
3772
3771
  completionTcpMethod(apis, parentInfo) {
3773
3772
  if (isArray(apis) && apis.length) {
3774
3773
  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 }));
3774
+ 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
3775
  return pre;
3777
3776
  }, []);
3778
3777
  }
@@ -3829,6 +3828,832 @@ class ApifoxToApipost {
3829
3828
  }
3830
3829
  }
3831
3830
 
3831
+ const completionPostmanTarget = (targetItem) => {
3832
+ var _a, _b, _c, _d, _e, _f, _g;
3833
+ try {
3834
+ const getPostmanHeader = (header) => {
3835
+ if (lodash.isArray(header)) {
3836
+ return lodash.reduce(header, (pre, cur) => {
3837
+ pre.push({
3838
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3839
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3840
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
3841
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || ''
3842
+ });
3843
+ return pre;
3844
+ }, []);
3845
+ }
3846
+ return [];
3847
+ };
3848
+ const getPostmanUrl = (targetItem) => {
3849
+ var _a, _b, _c, _d;
3850
+ const getPostmanQuery = (query) => {
3851
+ if (lodash.isArray(query)) {
3852
+ return lodash.reduce(query, (pre, cur) => {
3853
+ pre.push({
3854
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3855
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3856
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
3857
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
3858
+ });
3859
+ return pre;
3860
+ }, []);
3861
+ }
3862
+ return [];
3863
+ };
3864
+ const getPostmanVariable = (restful) => {
3865
+ if (lodash.isArray(restful)) {
3866
+ return lodash.reduce(restful, (pre, cur) => {
3867
+ pre.push({
3868
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
3869
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
3870
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
3871
+ });
3872
+ return pre;
3873
+ }, []);
3874
+ }
3875
+ return [];
3876
+ };
3877
+ return {
3878
+ raw: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || '',
3879
+ 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),
3880
+ 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)
3881
+ };
3882
+ };
3883
+ const result = {
3884
+ name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New HTTP',
3885
+ description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3886
+ request: {
3887
+ method: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.method) || 'GET',
3888
+ 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),
3889
+ url: getPostmanUrl(targetItem),
3890
+ },
3891
+ };
3892
+ // 获取接口认证
3893
+ let auth = getPostmanAuth((_c = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _c === void 0 ? void 0 : _c.auth);
3894
+ if (lodash.isPlainObject(auth) && !lodash.isEmpty(auth)) {
3895
+ result.request.auth = auth;
3896
+ }
3897
+ // 获取接口前后置脚本
3898
+ let event = getPostmanEvent(targetItem === null || targetItem === void 0 ? void 0 : targetItem.request);
3899
+ if (event.length > 0) {
3900
+ result.event = event;
3901
+ }
3902
+ // 获取请求体
3903
+ 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') {
3904
+ result.request.body = getPostmanBody((_g = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _g === void 0 ? void 0 : _g.body);
3905
+ }
3906
+ return result;
3907
+ }
3908
+ catch (error) {
3909
+ // console.log(error,"error1111");
3910
+ }
3911
+ return {};
3912
+ };
3913
+ const completionPostmanFolder = (targetItem) => {
3914
+ var _a;
3915
+ try {
3916
+ const result = {
3917
+ name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New Folder',
3918
+ description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3919
+ };
3920
+ // 获取认证
3921
+ let auth = getPostmanAuth((_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.auth);
3922
+ if (lodash.isPlainObject(auth) && !lodash.isEmpty(auth)) {
3923
+ result.auth = auth;
3924
+ }
3925
+ // 获取前后置脚本
3926
+ let event = getPostmanEvent(targetItem === null || targetItem === void 0 ? void 0 : targetItem.request);
3927
+ if (event.length > 0) {
3928
+ result.event = event;
3929
+ }
3930
+ return result;
3931
+ }
3932
+ catch (error) {
3933
+ }
3934
+ return {};
3935
+ };
3936
+ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3937
+ try {
3938
+ const result = [];
3939
+ const itemMap = {};
3940
+ for (const target of items) {
3941
+ const id = target[idName];
3942
+ const pid = target[pidName];
3943
+ if (!id || id == undefined || !['api', 'folder'].includes(target === null || target === void 0 ? void 0 : target.target_type)) {
3944
+ continue;
3945
+ }
3946
+ if (!itemMap.hasOwnProperty(id) && (target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3947
+ itemMap[id] = {
3948
+ name: (target === null || target === void 0 ? void 0 : target.name) || '',
3949
+ item: [],
3950
+ };
3951
+ }
3952
+ if ((target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3953
+ itemMap[id] = Object.assign(Object.assign({}, completionPostmanFolder(target)), {
3954
+ // name: target?.name || '',
3955
+ item: itemMap[id]['item'] });
3956
+ }
3957
+ else {
3958
+ itemMap[id] = Object.assign({}, completionPostmanTarget(target));
3959
+ }
3960
+ const treeItem = itemMap[id];
3961
+ if (pid == 0 || pid == undefined) {
3962
+ result.push(treeItem);
3963
+ }
3964
+ else {
3965
+ if (!itemMap.hasOwnProperty(pid)) {
3966
+ itemMap[pid] = {
3967
+ item: [],
3968
+ };
3969
+ }
3970
+ itemMap[pid].item.push(treeItem);
3971
+ }
3972
+ }
3973
+ return result;
3974
+ }
3975
+ catch (error) {
3976
+ return [];
3977
+ }
3978
+ };
3979
+ const getPostmanAuth = (auth) => {
3980
+ 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;
3981
+ if (lodash.isPlainObject(auth)) {
3982
+ const { type } = auth;
3983
+ switch (type) {
3984
+ case 'basic':
3985
+ return {
3986
+ type: "basic",
3987
+ basic: [
3988
+ {
3989
+ key: "password",
3990
+ value: ((_a = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _a === void 0 ? void 0 : _a.password) || '',
3991
+ type: "string"
3992
+ },
3993
+ {
3994
+ key: "username",
3995
+ value: ((_b = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _b === void 0 ? void 0 : _b.username) || '',
3996
+ type: "string"
3997
+ }
3998
+ ]
3999
+ };
4000
+ case 'bearer':
4001
+ return {
4002
+ type: "bearer",
4003
+ bearer: [
4004
+ {
4005
+ key: "token",
4006
+ value: ((_c = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _c === void 0 ? void 0 : _c.key) || '',
4007
+ type: "string"
4008
+ }
4009
+ ]
4010
+ };
4011
+ case 'digest':
4012
+ return {
4013
+ type: "digest",
4014
+ digest: [
4015
+ {
4016
+ key: "clientNonce",
4017
+ value: ((_d = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _d === void 0 ? void 0 : _d.cnonce) || '',
4018
+ type: "string"
4019
+ },
4020
+ {
4021
+ key: "opaque",
4022
+ value: ((_e = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _e === void 0 ? void 0 : _e.opaque) || '',
4023
+ type: "string"
4024
+ },
4025
+ {
4026
+ key: "nonceCount",
4027
+ value: ((_f = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _f === void 0 ? void 0 : _f.nc) || '',
4028
+ type: "string"
4029
+ },
4030
+ {
4031
+ key: "qop",
4032
+ value: ((_g = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _g === void 0 ? void 0 : _g.qop) || '',
4033
+ type: "string"
4034
+ },
4035
+ {
4036
+ key: "nonce",
4037
+ value: ((_h = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _h === void 0 ? void 0 : _h.nonce) || '',
4038
+ type: "string"
4039
+ },
4040
+ {
4041
+ key: "realm",
4042
+ value: ((_j = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _j === void 0 ? void 0 : _j.realm) || '',
4043
+ type: "string"
4044
+ },
4045
+ {
4046
+ key: "password",
4047
+ value: ((_k = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _k === void 0 ? void 0 : _k.password) || '',
4048
+ type: "string"
4049
+ },
4050
+ {
4051
+ key: "username",
4052
+ value: ((_l = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _l === void 0 ? void 0 : _l.username) || '',
4053
+ type: "string"
4054
+ },
4055
+ {
4056
+ key: "disableRetryRequest",
4057
+ value: ((_m = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _m === void 0 ? void 0 : _m.disableRetryRequest) ? true : false,
4058
+ type: "boolean"
4059
+ },
4060
+ {
4061
+ key: "algorithm",
4062
+ value: ((_o = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _o === void 0 ? void 0 : _o.algorithm) || 'MD5',
4063
+ type: "string"
4064
+ },
4065
+ ]
4066
+ };
4067
+ case 'oauth1':
4068
+ return {
4069
+ type: "oauth1",
4070
+ oauth1: [
4071
+ {
4072
+ key: "addEmptyParamsToSign",
4073
+ value: ((_p = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _p === void 0 ? void 0 : _p.addEmptyParamsToSign) ? true : false,
4074
+ type: "boolean"
4075
+ },
4076
+ {
4077
+ key: "includeBodyHash",
4078
+ value: ((_q = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _q === void 0 ? void 0 : _q.includeBodyHash) ? true : false,
4079
+ type: "boolean"
4080
+ },
4081
+ {
4082
+ key: "realm",
4083
+ value: ((_r = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _r === void 0 ? void 0 : _r.realm) || '',
4084
+ type: "string"
4085
+ },
4086
+ {
4087
+ key: "nonce",
4088
+ value: ((_s = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _s === void 0 ? void 0 : _s.nonce) || '',
4089
+ type: "string"
4090
+ },
4091
+ {
4092
+ key: "timestamp",
4093
+ value: ((_t = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _t === void 0 ? void 0 : _t.timestamp) || '',
4094
+ type: "string"
4095
+ },
4096
+ {
4097
+ key: "verifier",
4098
+ value: ((_u = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _u === void 0 ? void 0 : _u.verifier) || '',
4099
+ type: "string"
4100
+ },
4101
+ {
4102
+ key: "callback",
4103
+ value: ((_v = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _v === void 0 ? void 0 : _v.callback) || '',
4104
+ type: "string"
4105
+ },
4106
+ {
4107
+ key: "tokenSecret",
4108
+ value: ((_w = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _w === void 0 ? void 0 : _w.tokenSecret) || '',
4109
+ type: "string"
4110
+ },
4111
+ {
4112
+ key: "token",
4113
+ value: ((_x = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _x === void 0 ? void 0 : _x.token) || '',
4114
+ type: "string"
4115
+ },
4116
+ {
4117
+ key: "consumerSecret",
4118
+ value: ((_y = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _y === void 0 ? void 0 : _y.consumerSecret) || '',
4119
+ type: "string"
4120
+ },
4121
+ {
4122
+ key: "consumerKey",
4123
+ value: ((_z = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _z === void 0 ? void 0 : _z.consumerKey) || '',
4124
+ type: "string"
4125
+ },
4126
+ {
4127
+ key: "signatureMethod",
4128
+ value: ((_0 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _0 === void 0 ? void 0 : _0.signatureMethod) || 'HMAC-SHA1',
4129
+ type: "string"
4130
+ },
4131
+ {
4132
+ key: "version",
4133
+ value: ((_1 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _1 === void 0 ? void 0 : _1.version) || '1.0',
4134
+ type: "string"
4135
+ },
4136
+ {
4137
+ key: "addParamsToHeader",
4138
+ value: ((_2 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _2 === void 0 ? void 0 : _2.addParamsToHeader) ? true : false,
4139
+ type: "boolean"
4140
+ },
4141
+ {
4142
+ key: "disableHeaderEncoding",
4143
+ value: ((_3 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _3 === void 0 ? void 0 : _3.disableHeaderEncoding) ? true : false,
4144
+ type: "boolean"
4145
+ }
4146
+ ]
4147
+ };
4148
+ case 'oauth2':
4149
+ return {
4150
+ type: "oauth2",
4151
+ oauth2: [
4152
+ {
4153
+ key: "addTokenTo",
4154
+ value: ((_4 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _4 === void 0 ? void 0 : _4.addTokenTo) || 'header',
4155
+ type: "string"
4156
+ },
4157
+ {
4158
+ key: "headerPrefix",
4159
+ value: ((_5 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _5 === void 0 ? void 0 : _5.headerPrefix) || 'Bearer',
4160
+ type: "string"
4161
+ },
4162
+ {
4163
+ key: "accessToken",
4164
+ value: ((_6 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _6 === void 0 ? void 0 : _6.access_token) || '',
4165
+ type: "string"
4166
+ },
4167
+ {
4168
+ key: "refreshTokenUrl",
4169
+ value: ((_7 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _7 === void 0 ? void 0 : _7.refreshTokenUrl) || '',
4170
+ type: "string"
4171
+ },
4172
+ {
4173
+ key: "grant_type",
4174
+ value: ((_8 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _8 === void 0 ? void 0 : _8.grant_type) || 'authorization_code',
4175
+ type: "string"
4176
+ },
4177
+ {
4178
+ key: "redirect_uri",
4179
+ value: ((_9 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _9 === void 0 ? void 0 : _9.redirect_uri) || '',
4180
+ type: "string"
4181
+ },
4182
+ {
4183
+ key: "authUrl",
4184
+ value: ((_10 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _10 === void 0 ? void 0 : _10.authUrl) || '',
4185
+ type: "string"
4186
+ },
4187
+ {
4188
+ key: "accessTokenUrl",
4189
+ value: ((_11 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _11 === void 0 ? void 0 : _11.accessTokenUrl) || '',
4190
+ type: "string"
4191
+ },
4192
+ {
4193
+ key: "clientId",
4194
+ value: ((_12 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _12 === void 0 ? void 0 : _12.clientId) || '',
4195
+ type: "string"
4196
+ },
4197
+ {
4198
+ key: "clientSecret",
4199
+ value: ((_13 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _13 === void 0 ? void 0 : _13.clientSecret) || '',
4200
+ type: "string"
4201
+ },
4202
+ {
4203
+ key: "username",
4204
+ value: ((_14 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _14 === void 0 ? void 0 : _14.username) || '',
4205
+ type: "string"
4206
+ },
4207
+ {
4208
+ key: "password",
4209
+ value: ((_15 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _15 === void 0 ? void 0 : _15.password) || '',
4210
+ type: "string"
4211
+ },
4212
+ {
4213
+ key: "challengeAlgorithm",
4214
+ value: ((_16 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _16 === void 0 ? void 0 : _16.challengeAlgorithm) || 'S256',
4215
+ type: "string"
4216
+ },
4217
+ {
4218
+ key: "code_verifier",
4219
+ value: ((_17 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _17 === void 0 ? void 0 : _17.code_verifier) || 'Bearer',
4220
+ type: "string"
4221
+ },
4222
+ {
4223
+ key: "state",
4224
+ value: ((_18 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _18 === void 0 ? void 0 : _18.state) || '',
4225
+ type: "string"
4226
+ },
4227
+ {
4228
+ key: "scope",
4229
+ value: ((_19 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _19 === void 0 ? void 0 : _19.scope) || '',
4230
+ type: "string"
4231
+ },
4232
+ {
4233
+ key: "client_authentication",
4234
+ value: ((_20 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _20 === void 0 ? void 0 : _20.client_authentication) || 'header',
4235
+ type: "string"
4236
+ },
4237
+ {
4238
+ key: "tokenName",
4239
+ value: ((_21 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _21 === void 0 ? void 0 : _21.tokenName) || '',
4240
+ type: "string"
4241
+ },
4242
+ {
4243
+ key: "refreshRequestParams",
4244
+ 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 : [],
4245
+ type: "any"
4246
+ },
4247
+ {
4248
+ key: "tokenRequestParams",
4249
+ 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 : [],
4250
+ type: "any"
4251
+ },
4252
+ {
4253
+ key: "authRequestParams",
4254
+ 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 : [],
4255
+ type: "any"
4256
+ },
4257
+ ]
4258
+ };
4259
+ case 'hawk':
4260
+ return {
4261
+ type: "hawk",
4262
+ hawk: [
4263
+ {
4264
+ key: "authId",
4265
+ value: ((_28 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _28 === void 0 ? void 0 : _28.authId) || '',
4266
+ type: "string"
4267
+ },
4268
+ {
4269
+ key: "algorithm",
4270
+ value: ((_29 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _29 === void 0 ? void 0 : _29.algorithm) || '',
4271
+ type: "string"
4272
+ },
4273
+ {
4274
+ key: "authKey",
4275
+ value: ((_30 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _30 === void 0 ? void 0 : _30.authKey) || '',
4276
+ type: "string"
4277
+ },
4278
+ {
4279
+ key: "includePayloadHash",
4280
+ value: ((_31 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _31 === void 0 ? void 0 : _31.includePayloadHash) ? true : false,
4281
+ type: "boolean"
4282
+ },
4283
+ {
4284
+ key: "delegation",
4285
+ value: ((_32 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _32 === void 0 ? void 0 : _32.delegation) || '',
4286
+ type: "string"
4287
+ },
4288
+ {
4289
+ key: "timestamp",
4290
+ value: ((_33 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _33 === void 0 ? void 0 : _33.timestamp) || '',
4291
+ type: "string"
4292
+ },
4293
+ {
4294
+ key: "app",
4295
+ value: ((_34 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _34 === void 0 ? void 0 : _34.app) || '',
4296
+ type: "string"
4297
+ },
4298
+ {
4299
+ key: "extraData",
4300
+ value: ((_35 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _35 === void 0 ? void 0 : _35.extraData) || '',
4301
+ type: "string"
4302
+ },
4303
+ {
4304
+ key: "nonce",
4305
+ value: ((_36 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _36 === void 0 ? void 0 : _36.nonce) || '',
4306
+ type: "string"
4307
+ },
4308
+ {
4309
+ key: "user",
4310
+ value: ((_37 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _37 === void 0 ? void 0 : _37.user) || '',
4311
+ type: "string"
4312
+ },
4313
+ {
4314
+ key: "delegation",
4315
+ value: ((_38 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _38 === void 0 ? void 0 : _38.delegation) || '',
4316
+ type: "string"
4317
+ },
4318
+ ]
4319
+ };
4320
+ case 'awsv4':
4321
+ return {
4322
+ type: "awsv4",
4323
+ awsv4: [
4324
+ {
4325
+ key: "accessKey",
4326
+ value: ((_39 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _39 === void 0 ? void 0 : _39.accessKey) || '',
4327
+ type: "string"
4328
+ },
4329
+ {
4330
+ key: "secretKey",
4331
+ value: ((_40 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _40 === void 0 ? void 0 : _40.secretKey) || '',
4332
+ type: "string"
4333
+ },
4334
+ {
4335
+ key: "region",
4336
+ value: ((_41 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _41 === void 0 ? void 0 : _41.region) || '',
4337
+ type: "string"
4338
+ },
4339
+ {
4340
+ key: "addAuthDataToQuery",
4341
+ value: ((_42 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _42 === void 0 ? void 0 : _42.addAuthDataToQuery) ? true : false,
4342
+ type: "boolean"
4343
+ },
4344
+ {
4345
+ key: "service",
4346
+ value: ((_43 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _43 === void 0 ? void 0 : _43.service) || '',
4347
+ type: "string"
4348
+ },
4349
+ {
4350
+ key: "sessionToken",
4351
+ value: ((_44 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _44 === void 0 ? void 0 : _44.sessionToken) || '',
4352
+ type: "string"
4353
+ },
4354
+ ]
4355
+ };
4356
+ case 'ntlm':
4357
+ return {
4358
+ type: "ntlm",
4359
+ ntlm: [
4360
+ {
4361
+ key: "username",
4362
+ value: ((_45 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _45 === void 0 ? void 0 : _45.username) || '',
4363
+ type: "string"
4364
+ },
4365
+ {
4366
+ key: "password",
4367
+ value: ((_46 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _46 === void 0 ? void 0 : _46.password) || '',
4368
+ type: "string"
4369
+ },
4370
+ {
4371
+ key: "domain",
4372
+ value: ((_47 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _47 === void 0 ? void 0 : _47.domain) || '',
4373
+ type: "string"
4374
+ },
4375
+ {
4376
+ key: "workstation",
4377
+ value: ((_48 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _48 === void 0 ? void 0 : _48.workstation) || '',
4378
+ type: "string"
4379
+ },
4380
+ {
4381
+ key: "disableRetryRequest",
4382
+ value: ((_49 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _49 === void 0 ? void 0 : _49.disableRetryRequest) ? true : false,
4383
+ type: "boolean"
4384
+ },
4385
+ ]
4386
+ };
4387
+ case 'kv':
4388
+ return {
4389
+ type: "apikey",
4390
+ apikey: [
4391
+ {
4392
+ key: "key",
4393
+ value: ((_50 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _50 === void 0 ? void 0 : _50.key) || '',
4394
+ type: "string"
4395
+ },
4396
+ {
4397
+ key: "value",
4398
+ value: ((_51 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _51 === void 0 ? void 0 : _51.value) || '',
4399
+ type: "string"
4400
+ },
4401
+ {
4402
+ key: "in",
4403
+ value: ((_52 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _52 === void 0 ? void 0 : _52.in) || 'header',
4404
+ type: "string"
4405
+ },
4406
+ ]
4407
+ };
4408
+ case 'edgegrid':
4409
+ return {
4410
+ type: "edgegrid",
4411
+ edgegrid: [
4412
+ {
4413
+ key: "accessToken",
4414
+ value: ((_53 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _53 === void 0 ? void 0 : _53.accessToken) || '',
4415
+ type: "string"
4416
+ },
4417
+ {
4418
+ key: "clientToken",
4419
+ value: ((_54 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _54 === void 0 ? void 0 : _54.clientToken) || '',
4420
+ type: "string"
4421
+ },
4422
+ {
4423
+ key: "clientSecret",
4424
+ value: ((_55 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _55 === void 0 ? void 0 : _55.clientSecret) || '',
4425
+ type: "string"
4426
+ },
4427
+ {
4428
+ key: "nonce",
4429
+ value: ((_56 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _56 === void 0 ? void 0 : _56.nonce) || '',
4430
+ type: "string"
4431
+ },
4432
+ {
4433
+ key: "timestamp",
4434
+ value: ((_57 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _57 === void 0 ? void 0 : _57.timestamp) || '',
4435
+ type: "string"
4436
+ },
4437
+ {
4438
+ key: "baseURL",
4439
+ value: ((_58 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _58 === void 0 ? void 0 : _58.baseURi) || '',
4440
+ type: "string"
4441
+ },
4442
+ {
4443
+ key: "headersToSign",
4444
+ value: ((_59 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _59 === void 0 ? void 0 : _59.headersToSign) || '',
4445
+ type: "string"
4446
+ },
4447
+ ]
4448
+ };
4449
+ case 'jwt':
4450
+ return {
4451
+ type: "jwt",
4452
+ jwt: [
4453
+ {
4454
+ key: "addTokenTo",
4455
+ value: ((_60 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _60 === void 0 ? void 0 : _60.addTokenTo) || '',
4456
+ type: "string"
4457
+ },
4458
+ {
4459
+ key: "algorithm",
4460
+ value: ((_61 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _61 === void 0 ? void 0 : _61.algorithm) || '',
4461
+ type: "string"
4462
+ },
4463
+ {
4464
+ key: "secret",
4465
+ value: ((_62 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _62 === void 0 ? void 0 : _62.secret) || '',
4466
+ type: "string"
4467
+ },
4468
+ {
4469
+ key: "payload",
4470
+ value: ((_63 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _63 === void 0 ? void 0 : _63.payload) || '',
4471
+ type: "string"
4472
+ },
4473
+ {
4474
+ key: "headerPrefix",
4475
+ value: ((_64 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _64 === void 0 ? void 0 : _64.headerPrefix) || 'Bearer',
4476
+ type: "string"
4477
+ },
4478
+ {
4479
+ key: "queryParamKey",
4480
+ value: ((_65 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _65 === void 0 ? void 0 : _65.queryParamKey) || 'token',
4481
+ type: "string"
4482
+ },
4483
+ {
4484
+ key: "header",
4485
+ value: ((_66 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _66 === void 0 ? void 0 : _66.header) || '',
4486
+ type: "string"
4487
+ },
4488
+ {
4489
+ key: "isSecretBase64Encoded",
4490
+ value: ((_67 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _67 === void 0 ? void 0 : _67.isSecretBase64Encoded) ? true : false,
4491
+ type: "boolean"
4492
+ },
4493
+ ]
4494
+ };
4495
+ case 'asap':
4496
+ return {
4497
+ type: "asap",
4498
+ asap: [
4499
+ {
4500
+ key: "alg",
4501
+ value: ((_68 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _68 === void 0 ? void 0 : _68.alg) || 'HS256',
4502
+ type: "string"
4503
+ },
4504
+ {
4505
+ key: "iss",
4506
+ value: ((_69 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _69 === void 0 ? void 0 : _69.iss) || '',
4507
+ type: "string"
4508
+ },
4509
+ {
4510
+ key: "aud",
4511
+ value: ((_70 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _70 === void 0 ? void 0 : _70.aud) || '',
4512
+ type: "string"
4513
+ },
4514
+ {
4515
+ key: "kid",
4516
+ value: ((_71 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _71 === void 0 ? void 0 : _71.kid) || '',
4517
+ type: "string"
4518
+ },
4519
+ {
4520
+ key: "privateKey",
4521
+ value: ((_72 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _72 === void 0 ? void 0 : _72.privateKey) || '',
4522
+ type: "string"
4523
+ },
4524
+ {
4525
+ key: "sub",
4526
+ value: ((_73 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _73 === void 0 ? void 0 : _73.sub) || '',
4527
+ type: "string"
4528
+ },
4529
+ {
4530
+ key: "claims",
4531
+ value: ((_74 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _74 === void 0 ? void 0 : _74.claims) || '',
4532
+ type: "string"
4533
+ },
4534
+ {
4535
+ key: "exp",
4536
+ value: ((_75 = auth === null || auth === void 0 ? void 0 : auth[type]) === null || _75 === void 0 ? void 0 : _75.exp) || '',
4537
+ type: "string"
4538
+ },
4539
+ ]
4540
+ };
4541
+ }
4542
+ }
4543
+ return {};
4544
+ };
4545
+ const getPostmanEvent = (request) => {
4546
+ let event = [];
4547
+ if (lodash.isArray(request === null || request === void 0 ? void 0 : request.pre_tasks)) {
4548
+ lodash.forEach(request === null || request === void 0 ? void 0 : request.pre_tasks, (val) => {
4549
+ if ((val === null || val === void 0 ? void 0 : val.type) === 'customScript' && (val === null || val === void 0 ? void 0 : val.enabled) == 1) {
4550
+ event.push({
4551
+ listen: "prerequest",
4552
+ script: {
4553
+ "type": "text/javascript",
4554
+ "packages": {},
4555
+ "exec": lodash.isString(val === null || val === void 0 ? void 0 : val.data) ? val.data.split('\n') : []
4556
+ }
4557
+ });
4558
+ }
4559
+ });
4560
+ }
4561
+ if (lodash.isArray(request === null || request === void 0 ? void 0 : request.post_tasks)) {
4562
+ lodash.forEach(request === null || request === void 0 ? void 0 : request.post_tasks, (val) => {
4563
+ if ((val === null || val === void 0 ? void 0 : val.type) === 'customScript' && (val === null || val === void 0 ? void 0 : val.enabled) == 1) {
4564
+ event.push({
4565
+ listen: "test",
4566
+ script: {
4567
+ "type": "text/javascript",
4568
+ "packages": {},
4569
+ "exec": lodash.isString(val === null || val === void 0 ? void 0 : val.data) ? val.data.split('\n') : []
4570
+ }
4571
+ });
4572
+ }
4573
+ });
4574
+ }
4575
+ return event;
4576
+ };
4577
+ const getPostmanCommonParameter = (parameter) => {
4578
+ if (lodash.isArray(parameter)) {
4579
+ return lodash.reduce(parameter, (pre, cur) => {
4580
+ pre.push({
4581
+ key: (cur === null || cur === void 0 ? void 0 : cur.key) || '',
4582
+ description: (cur === null || cur === void 0 ? void 0 : cur.description) || '',
4583
+ type: (cur === null || cur === void 0 ? void 0 : cur.field_type) == 'File' ? 'file' : 'text',
4584
+ value: (cur === null || cur === void 0 ? void 0 : cur.value) || '',
4585
+ disabled: (cur === null || cur === void 0 ? void 0 : cur.is_checked) == 1 ? false : true,
4586
+ });
4587
+ return pre;
4588
+ }, []);
4589
+ }
4590
+ return [];
4591
+ };
4592
+ const getPostmanBody = (body) => {
4593
+ const params = {};
4594
+ if (body) {
4595
+ switch (body === null || body === void 0 ? void 0 : body.mode) {
4596
+ case 'form-data':
4597
+ params.mode = 'formdata';
4598
+ params.formdata = getPostmanCommonParameter(body === null || body === void 0 ? void 0 : body.parameter);
4599
+ break;
4600
+ case 'urlencoded':
4601
+ params.mode = 'urlencoded';
4602
+ params.urlencoded = getPostmanCommonParameter(body === null || body === void 0 ? void 0 : body.parameter);
4603
+ break;
4604
+ case 'binary':
4605
+ params.mode = 'file';
4606
+ break;
4607
+ case 'json':
4608
+ params.mode = 'raw';
4609
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4610
+ params.options = {
4611
+ raw: {
4612
+ language: "json"
4613
+ }
4614
+ };
4615
+ break;
4616
+ case 'xml':
4617
+ params.mode = 'raw';
4618
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4619
+ params.options = {
4620
+ raw: {
4621
+ language: "xml"
4622
+ }
4623
+ };
4624
+ break;
4625
+ case 'javascript':
4626
+ params.mode = 'raw';
4627
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4628
+ params.options = {
4629
+ raw: {
4630
+ language: "javascript"
4631
+ }
4632
+ };
4633
+ break;
4634
+ case 'plain':
4635
+ params.mode = 'raw';
4636
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4637
+ params.options = {
4638
+ raw: {
4639
+ language: "text"
4640
+ }
4641
+ };
4642
+ break;
4643
+ case 'html':
4644
+ params.mode = 'raw';
4645
+ params.raw = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? body.raw : '';
4646
+ params.options = {
4647
+ raw: {
4648
+ language: "html"
4649
+ }
4650
+ };
4651
+ break;
4652
+ }
4653
+ }
4654
+ return params;
4655
+ };
4656
+
3832
4657
  // @ts-nocheck
3833
4658
  class ApipostToPostman {
3834
4659
  constructor() {
@@ -3844,82 +4669,68 @@ class ApipostToPostman {
3844
4669
  writable: true,
3845
4670
  value: void 0
3846
4671
  });
4672
+ Object.defineProperty(this, "variable", {
4673
+ enumerable: true,
4674
+ configurable: true,
4675
+ writable: true,
4676
+ value: void 0
4677
+ });
4678
+ Object.defineProperty(this, "event", {
4679
+ enumerable: true,
4680
+ configurable: true,
4681
+ writable: true,
4682
+ value: void 0
4683
+ });
4684
+ Object.defineProperty(this, "auth", {
4685
+ enumerable: true,
4686
+ configurable: true,
4687
+ writable: true,
4688
+ value: void 0
4689
+ });
3847
4690
  this.item = [];
3848
4691
  this.info = {
3849
- _postman_id: "",
3850
4692
  name: "New Collection",
4693
+ description: '',
3851
4694
  schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
3852
- _exporter_id: "",
3853
- _collection_link: "",
3854
4695
  };
4696
+ this.variable = [];
4697
+ this.event = [];
4698
+ this.auth = {};
3855
4699
  }
3856
4700
  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
4701
  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
- });
4702
+ this.info.name = (json === null || json === void 0 ? void 0 : json.name) || "New Collection";
4703
+ this.info.description = (json === null || json === void 0 ? void 0 : json.intro) || "";
4704
+ this.event = getPostmanEvent(global === null || global === void 0 ? void 0 : global.global_param);
4705
+ this.variable = this.initVariable(json === null || json === void 0 ? void 0 : json.global);
4706
+ 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);
4707
+ }
4708
+ initVariable(global) {
4709
+ if (lodash.isPlainObject(global === null || global === void 0 ? void 0 : global.global_vars)) {
4710
+ return lodash.reduce(global === null || global === void 0 ? void 0 : global.global_vars, (res, val, key) => {
4711
+ res.push({
4712
+ key,
4713
+ value: (val === null || val === void 0 ? void 0 : val.value) || '',
4714
+ type: "string"
4715
+ });
4716
+ return res;
4717
+ }, []);
3907
4718
  }
3908
4719
  return [];
3909
4720
  }
3910
4721
  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);
4722
+ this.item = array2PostmanTree((json === null || json === void 0 ? void 0 : json.apis) || [], "target_id", "parent_id");
3913
4723
  }
3914
4724
  clear() {
3915
4725
  this.item = [];
3916
4726
  this.info = {
3917
- _postman_id: "",
3918
4727
  name: "New Collection",
4728
+ description: '',
3919
4729
  schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
3920
- _exporter_id: "",
3921
- _collection_link: "",
3922
4730
  };
4731
+ this.variable = [];
4732
+ this.event = [];
4733
+ this.auth = {};
3923
4734
  }
3924
4735
  convert(json) {
3925
4736
  this.clear();
@@ -3929,6 +4740,9 @@ class ApipostToPostman {
3929
4740
  const data = {
3930
4741
  info: this.info,
3931
4742
  item: this.item,
4743
+ variable: this.variable,
4744
+ event: this.event,
4745
+ auth: this.auth,
3932
4746
  };
3933
4747
  return throwResult$1("success", "", data);
3934
4748
  }
@@ -3984,7 +4798,7 @@ class HarToApipost {
3984
4798
  if (isArray(headers) && headers.length) {
3985
4799
  return headers === null || headers === void 0 ? void 0 : headers.map((item) => {
3986
4800
  return {
3987
- param_id: ATools.snowflakeId(),
4801
+ param_id: apipostTools.snowflakeId(),
3988
4802
  description: "",
3989
4803
  field_type: "String",
3990
4804
  is_checked: 1,
@@ -4092,7 +4906,7 @@ class HarToApipost {
4092
4906
  if ((item === null || item === void 0 ? void 0 : item._resourceType) === "xhr" ||
4093
4907
  (item === null || item === void 0 ? void 0 : item._resourceType) === "preflight") {
4094
4908
  pre.push({
4095
- target_id: ATools.snowflakeId(),
4909
+ target_id: apipostTools.snowflakeId(),
4096
4910
  project_id: this.project.project_id || "",
4097
4911
  parent_id: "0",
4098
4912
  target_type: "api",
@@ -4197,7 +5011,7 @@ class InsomniaToApipost {
4197
5011
  completionParameter(parameter) {
4198
5012
  if (isArray(parameter)) {
4199
5013
  return parameter.map((item) => ({
4200
- param_id: ATools.snowflakeId(),
5014
+ param_id: apipostTools.snowflakeId(),
4201
5015
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4202
5016
  field_type: "String",
4203
5017
  is_checked: (item === null || item === void 0 ? void 0 : item.disabled) ? -1 : 1,
@@ -4257,7 +5071,7 @@ class InsomniaToApipost {
4257
5071
  type: "customScript",
4258
5072
  enabled: 1,
4259
5073
  name: "Script",
4260
- id: ATools.snowflakeId(),
5074
+ id: apipostTools.snowflakeId(),
4261
5075
  data: (item === null || item === void 0 ? void 0 : item.preRequestScript) || "",
4262
5076
  },
4263
5077
  ];
@@ -4268,7 +5082,7 @@ class InsomniaToApipost {
4268
5082
  type: "customScript",
4269
5083
  enabled: 1,
4270
5084
  name: "Script",
4271
- id: ATools.snowflakeId(),
5085
+ id: apipostTools.snowflakeId(),
4272
5086
  data: (item === null || item === void 0 ? void 0 : item.afterResponseScript) || "",
4273
5087
  },
4274
5088
  ];
@@ -4349,7 +5163,7 @@ class InsomniaToApipost {
4349
5163
  return [
4350
5164
  {
4351
5165
  name: 'Message',
4352
- param_id: ATools.snowflakeId(),
5166
+ param_id: apipostTools.snowflakeId(),
4353
5167
  request: message,
4354
5168
  response: {
4355
5169
  mode: 'text',
@@ -4388,7 +5202,7 @@ class InsomniaToApipost {
4388
5202
  var _a;
4389
5203
  return {
4390
5204
  project_id: this.project.project_id || "",
4391
- target_id: ATools.snowflakeId(),
5205
+ target_id: apipostTools.snowflakeId(),
4392
5206
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4393
5207
  description: (item === null || item === void 0 ? void 0 : item.description) || '',
4394
5208
  target_type: "websocket2",
@@ -4432,7 +5246,7 @@ class InsomniaToApipost {
4432
5246
  completionGraphqlRequestBody(body) {
4433
5247
  return {
4434
5248
  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: {
5249
+ 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
5250
  mode: 'json',
4437
5251
  raw: '',
4438
5252
  raw_parameter: [],
@@ -4445,7 +5259,7 @@ class InsomniaToApipost {
4445
5259
  const request = this.completionApiRequest(item);
4446
5260
  const body = this.completionGraphqlRequestBody(item === null || item === void 0 ? void 0 : item.body);
4447
5261
  return {
4448
- target_id: ATools.snowflakeId(),
5262
+ target_id: apipostTools.snowflakeId(),
4449
5263
  project_id: this.project.project_id || "",
4450
5264
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4451
5265
  target_type: "graphql",
@@ -4503,7 +5317,7 @@ class InsomniaToApipost {
4503
5317
  completionApiTarget(item) {
4504
5318
  var _a;
4505
5319
  return {
4506
- target_id: ATools.snowflakeId(),
5320
+ target_id: apipostTools.snowflakeId(),
4507
5321
  project_id: this.project.project_id || "",
4508
5322
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4509
5323
  target_type: "api",
@@ -4579,7 +5393,7 @@ class InsomniaToApipost {
4579
5393
  var _a, _b;
4580
5394
  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
5395
  pre.push({
4582
- target_id: this.foldersMap[item === null || item === void 0 ? void 0 : item._id] || ATools.snowflakeId(),
5396
+ target_id: this.foldersMap[item === null || item === void 0 ? void 0 : item._id] || apipostTools.snowflakeId(),
4583
5397
  project_id: this.project.project_id || "",
4584
5398
  parent_id: this.foldersMap[item === null || item === void 0 ? void 0 : item.parentId] || "0",
4585
5399
  target_type: "folder",
@@ -4612,7 +5426,7 @@ class InsomniaToApipost {
4612
5426
  if ((item === null || item === void 0 ? void 0 : item._type) === "environment" && (item === null || item === void 0 ? void 0 : item.name)) {
4613
5427
  this.envs = this.envs.concat([
4614
5428
  {
4615
- env_id: ATools.snowflakeId(),
5429
+ env_id: apipostTools.snowflakeId(),
4616
5430
  name: item === null || item === void 0 ? void 0 : item.name,
4617
5431
  is_private: (item === null || item === void 0 ? void 0 : item.isPrivate) ? 1 : -1,
4618
5432
  server_list: [],
@@ -4634,7 +5448,7 @@ class InsomniaToApipost {
4634
5448
  initFolders(resources) {
4635
5449
  this.foldersMap = resources === null || resources === void 0 ? void 0 : resources.reduce((pre, item) => {
4636
5450
  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();
5451
+ pre[item._id] = apipostTools.snowflakeId();
4638
5452
  }
4639
5453
  if ((item === null || item === void 0 ? void 0 : item._type) === "workspace") {
4640
5454
  pre[item._id] = "0";
@@ -4770,9 +5584,9 @@ class PostmanToApipost {
4770
5584
  state: (authMap === null || authMap === void 0 ? void 0 : authMap.state) || '',
4771
5585
  client_authentication: (authMap === null || authMap === void 0 ? void 0 : authMap.client_authentication) || 'header',
4772
5586
  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() }))) : [],
5587
+ 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() }))) : [],
5588
+ 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() }))) : [],
5589
+ 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
5590
  };
4777
5591
  }
4778
5592
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
@@ -4864,7 +5678,7 @@ class PostmanToApipost {
4864
5678
  if (isArray(items)) {
4865
5679
  return items === null || items === void 0 ? void 0 : items.reduce((pre, item) => {
4866
5680
  pre.push({
4867
- param_id: ATools.snowflakeId(),
5681
+ param_id: apipostTools.snowflakeId(),
4868
5682
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4869
5683
  field_type: DEFAULT_FIELD_TYPE.includes(item === null || item === void 0 ? void 0 : item.type)
4870
5684
  ? item.type.charAt(0).toUpperCase() + item.type.slice(1)
@@ -4917,7 +5731,7 @@ class PostmanToApipost {
4917
5731
  type: "customScript",
4918
5732
  enabled: 1,
4919
5733
  name: "Custom Script",
4920
- id: ATools.snowflakeId(),
5734
+ id: apipostTools.snowflakeId(),
4921
5735
  data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec)
4922
5736
  ? (_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
5737
  : "",
@@ -4930,7 +5744,7 @@ class PostmanToApipost {
4930
5744
  type: "customScript",
4931
5745
  enabled: 1,
4932
5746
  name: "Custom Script",
4933
- id: ATools.snowflakeId(),
5747
+ id: apipostTools.snowflakeId(),
4934
5748
  data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec)
4935
5749
  ? (_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
5750
  : "",
@@ -4951,7 +5765,7 @@ class PostmanToApipost {
4951
5765
  body: {
4952
5766
  query_schema: {},
4953
5767
  query_list: [{
4954
- param_id: ATools.snowflakeId(),
5768
+ param_id: apipostTools.snowflakeId(),
4955
5769
  name: 'New Query',
4956
5770
  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
5771
  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 +5789,7 @@ class PostmanToApipost {
4975
5789
  type: "customScript",
4976
5790
  enabled: 1,
4977
5791
  name: "Custom Script",
4978
- id: ATools.snowflakeId(),
5792
+ id: apipostTools.snowflakeId(),
4979
5793
  data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec)
4980
5794
  ? (_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
5795
  : "",
@@ -4988,7 +5802,7 @@ class PostmanToApipost {
4988
5802
  type: "customScript",
4989
5803
  enabled: 1,
4990
5804
  name: "Custom Script",
4991
- id: ATools.snowflakeId(),
5805
+ id: apipostTools.snowflakeId(),
4992
5806
  data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec)
4993
5807
  ? (_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
5808
  : "",
@@ -5020,7 +5834,7 @@ class PostmanToApipost {
5020
5834
  }
5021
5835
  completionApiFolder(item, parentInfo) {
5022
5836
  return {
5023
- target_id: ATools.snowflakeId(),
5837
+ target_id: apipostTools.snowflakeId(),
5024
5838
  project_id: this.project.project_id || "",
5025
5839
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5026
5840
  target_type: "folder",
@@ -5040,7 +5854,7 @@ class PostmanToApipost {
5040
5854
  const { request } = item || {};
5041
5855
  if (lodash.isEqual((_a = request === null || request === void 0 ? void 0 : request.body) === null || _a === void 0 ? void 0 : _a.mode, 'graphql')) {
5042
5856
  return {
5043
- target_id: ATools.snowflakeId(),
5857
+ target_id: apipostTools.snowflakeId(),
5044
5858
  project_id: this.project.project_id || "",
5045
5859
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5046
5860
  target_type: "graphql",
@@ -5099,7 +5913,7 @@ class PostmanToApipost {
5099
5913
  };
5100
5914
  }
5101
5915
  return {
5102
- target_id: ATools.snowflakeId(),
5916
+ target_id: apipostTools.snowflakeId(),
5103
5917
  project_id: this.project.project_id || "",
5104
5918
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5105
5919
  target_type: "api",
@@ -5240,7 +6054,7 @@ class YapiToApipost {
5240
6054
  }
5241
6055
  completionApiFolder(item, parentInfo) {
5242
6056
  return {
5243
- target_id: ATools.snowflakeId(),
6057
+ target_id: apipostTools.snowflakeId(),
5244
6058
  project_id: this.project.project_id || "",
5245
6059
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5246
6060
  target_type: "folder",
@@ -5287,7 +6101,7 @@ class YapiToApipost {
5287
6101
  return req_headers === null || req_headers === void 0 ? void 0 : req_headers.reduce((pre, item) => {
5288
6102
  const field_type = (item === null || item === void 0 ? void 0 : item.type) === "file" ? "File" : "String";
5289
6103
  pre.push({
5290
- param_id: ATools.snowflakeId(),
6104
+ param_id: apipostTools.snowflakeId(),
5291
6105
  description: (item === null || item === void 0 ? void 0 : item.desc) || "",
5292
6106
  field_type,
5293
6107
  is_checked: 1,
@@ -5412,7 +6226,7 @@ class YapiToApipost {
5412
6226
  completionApiTarget(item, parentInfo) {
5413
6227
  var _a;
5414
6228
  return {
5415
- target_id: ATools.snowflakeId(),
6229
+ target_id: apipostTools.snowflakeId(),
5416
6230
  project_id: this.project.project_id || "",
5417
6231
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5418
6232
  target_type: "api",
@@ -5534,7 +6348,7 @@ class ThunderToApipost {
5534
6348
  if (action === "istype") {
5535
6349
  return {
5536
6350
  type: "customScript",
5537
- id: ATools.snowflakeId(),
6351
+ id: apipostTools.snowflakeId(),
5538
6352
  name: "Script",
5539
6353
  enabled: 1,
5540
6354
  data: `function isType(value, type) {
@@ -5583,7 +6397,7 @@ class ThunderToApipost {
5583
6397
  else if (action === "isjson") {
5584
6398
  return {
5585
6399
  type: "customScript",
5586
- id: ATools.snowflakeId(),
6400
+ id: apipostTools.snowflakeId(),
5587
6401
  name: "Script",
5588
6402
  enabled: 1,
5589
6403
  data: `function isJSON(str) {
@@ -5603,7 +6417,7 @@ class ThunderToApipost {
5603
6417
  else if (action === "count") {
5604
6418
  return {
5605
6419
  type: "customScript",
5606
- id: ATools.snowflakeId(),
6420
+ id: apipostTools.snowflakeId(),
5607
6421
  name: "Script",
5608
6422
  enabled: 1,
5609
6423
  data: ` pm.test("${action}", function () {
@@ -5615,7 +6429,7 @@ class ThunderToApipost {
5615
6429
  else if (action === "schema") {
5616
6430
  return {
5617
6431
  type: "customScript",
5618
- id: ATools.snowflakeId(),
6432
+ id: apipostTools.snowflakeId(),
5619
6433
  name: "Script",
5620
6434
  enabled: 1,
5621
6435
  data: `
@@ -5688,7 +6502,7 @@ class ThunderToApipost {
5688
6502
  completionApiFolder(item, parentInfo) {
5689
6503
  var _a;
5690
6504
  return {
5691
- target_id: ATools.snowflakeId(),
6505
+ target_id: apipostTools.snowflakeId(),
5692
6506
  project_id: this.project.project_id || "",
5693
6507
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
5694
6508
  target_type: "folder",
@@ -5708,7 +6522,7 @@ class ThunderToApipost {
5708
6522
  return parameter === null || parameter === void 0 ? void 0 : parameter.reduce((pre, item) => {
5709
6523
  const field_type = (item === null || item === void 0 ? void 0 : item.type) === "file" ? "File" : "String";
5710
6524
  pre.push({
5711
- param_id: ATools.snowflakeId(),
6525
+ param_id: apipostTools.snowflakeId(),
5712
6526
  description: "",
5713
6527
  field_type,
5714
6528
  is_checked: (item === null || item === void 0 ? void 0 : item.isDisabled) ? -1 : 1,
@@ -5795,7 +6609,7 @@ class ThunderToApipost {
5795
6609
  enabled: 1,
5796
6610
  data: lodash.join(script, "\n"),
5797
6611
  name: "Script",
5798
- id: ATools.snowflakeId(),
6612
+ id: apipostTools.snowflakeId(),
5799
6613
  },
5800
6614
  ];
5801
6615
  }
@@ -5813,7 +6627,7 @@ class ThunderToApipost {
5813
6627
  if (action) {
5814
6628
  asserts.push({
5815
6629
  type: "assert",
5816
- id: ATools.snowflakeId(),
6630
+ id: apipostTools.snowflakeId(),
5817
6631
  name: "Assertion",
5818
6632
  enabled: 1,
5819
6633
  data: {
@@ -5830,7 +6644,7 @@ class ThunderToApipost {
5830
6644
  case "res-body":
5831
6645
  asserts.push({
5832
6646
  type: "assert",
5833
- id: ATools.snowflakeId(),
6647
+ id: apipostTools.snowflakeId(),
5834
6648
  name: "Assertion",
5835
6649
  enabled: 1,
5836
6650
  data: {
@@ -5846,7 +6660,7 @@ class ThunderToApipost {
5846
6660
  case "res-time":
5847
6661
  asserts.push({
5848
6662
  type: "assert",
5849
- id: ATools.snowflakeId(),
6663
+ id: apipostTools.snowflakeId(),
5850
6664
  name: "Assertion",
5851
6665
  enabled: 1,
5852
6666
  data: {
@@ -5862,7 +6676,7 @@ class ThunderToApipost {
5862
6676
  case "Content-Type":
5863
6677
  asserts.push({
5864
6678
  type: "assert",
5865
- id: ATools.snowflakeId(),
6679
+ id: apipostTools.snowflakeId(),
5866
6680
  name: "Assertion",
5867
6681
  enabled: 1,
5868
6682
  data: {
@@ -5878,7 +6692,7 @@ class ThunderToApipost {
5878
6692
  case "Content-Length":
5879
6693
  asserts.push({
5880
6694
  type: "assert",
5881
- id: ATools.snowflakeId(),
6695
+ id: apipostTools.snowflakeId(),
5882
6696
  name: "Assertion",
5883
6697
  enabled: 1,
5884
6698
  data: {
@@ -5894,7 +6708,7 @@ class ThunderToApipost {
5894
6708
  case "Content-Encoding":
5895
6709
  asserts.push({
5896
6710
  type: "assert",
5897
- id: ATools.snowflakeId(),
6711
+ id: apipostTools.snowflakeId(),
5898
6712
  name: "Assertion",
5899
6713
  enabled: 1,
5900
6714
  data: {
@@ -5910,7 +6724,7 @@ class ThunderToApipost {
5910
6724
  case "custom-header":
5911
6725
  asserts.push({
5912
6726
  type: "assert",
5913
- id: ATools.snowflakeId(),
6727
+ id: apipostTools.snowflakeId(),
5914
6728
  name: "Assertion",
5915
6729
  enabled: 1,
5916
6730
  data: {
@@ -5926,7 +6740,7 @@ class ThunderToApipost {
5926
6740
  case "json-query":
5927
6741
  asserts.push({
5928
6742
  type: "assert",
5929
- id: ATools.snowflakeId(),
6743
+ id: apipostTools.snowflakeId(),
5930
6744
  name: "Assertion",
5931
6745
  enabled: 1,
5932
6746
  data: {
@@ -5942,14 +6756,14 @@ class ThunderToApipost {
5942
6756
  case "set-env-var":
5943
6757
  asserts.push({
5944
6758
  type: "pickVars",
5945
- id: ATools.snowflakeId(),
6759
+ id: apipostTools.snowflakeId(),
5946
6760
  name: "Variable Name",
5947
6761
  enabled: 1,
5948
6762
  data: {
5949
6763
  source: "responseJson",
5950
6764
  variables: [
5951
6765
  {
5952
- param_id: ATools.snowflakeId(),
6766
+ param_id: apipostTools.snowflakeId(),
5953
6767
  name: lodash.first(lodash.split(lodash.trim(test === null || test === void 0 ? void 0 : test.value, "{}"), ",")),
5954
6768
  expression: lodash.replace((test === null || test === void 0 ? void 0 : test.custom) || "", "json.", "$.") || "",
5955
6769
  type: "envVars",
@@ -6033,7 +6847,7 @@ class ThunderToApipost {
6033
6847
  completionApiTarget(item, parentInfo) {
6034
6848
  var _a;
6035
6849
  return {
6036
- target_id: ATools.snowflakeId(),
6850
+ target_id: apipostTools.snowflakeId(),
6037
6851
  project_id: this.project.project_id || "",
6038
6852
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
6039
6853
  target_type: "api",
@@ -6110,7 +6924,7 @@ class ThunderToApipost {
6110
6924
  return [
6111
6925
  {
6112
6926
  name: "Message",
6113
- param_id: ATools.snowflakeId(),
6927
+ param_id: apipostTools.snowflakeId(),
6114
6928
  request: {
6115
6929
  mode: (_a = item === null || item === void 0 ? void 0 : item.body) === null || _a === void 0 ? void 0 : _a.type,
6116
6930
  raw: ((_b = item === null || item === void 0 ? void 0 : item.body) === null || _b === void 0 ? void 0 : _b.raw) || "",
@@ -6133,7 +6947,7 @@ class ThunderToApipost {
6133
6947
  // websocket2
6134
6948
  completionWs2Target(item, parentInfo) {
6135
6949
  return {
6136
- target_id: ATools.snowflakeId(),
6950
+ target_id: apipostTools.snowflakeId(),
6137
6951
  project_id: this.project.project_id || "",
6138
6952
  parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
6139
6953
  target_type: "websocket2",