echoapi-converter 0.0.1 → 0.0.3
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/README.md +2 -2
- package/dist/index.js +57 -57
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# echoapi-converter
|
|
2
|
+
EchoAPI format conversion, including swagger, echo format, and posman format
|
package/dist/index.js
CHANGED
|
@@ -655,7 +655,7 @@ class ApipostToSwagger {
|
|
|
655
655
|
handleProject() {
|
|
656
656
|
const { name, intro } = this.apiToSwaggerOrigin.project || {};
|
|
657
657
|
this.apiToSwaggerResult.info = {
|
|
658
|
-
title: name || '
|
|
658
|
+
title: name || 'New Project',
|
|
659
659
|
description: intro || '',
|
|
660
660
|
version: '1.0.0',
|
|
661
661
|
};
|
|
@@ -718,7 +718,7 @@ class ApipostToSwagger {
|
|
|
718
718
|
for (const env of envs) {
|
|
719
719
|
const servers = {
|
|
720
720
|
url: (env === null || env === void 0 ? void 0 : env.url) || '',
|
|
721
|
-
description: (env === null || env === void 0 ? void 0 : env.name) || '
|
|
721
|
+
description: (env === null || env === void 0 ? void 0 : env.name) || 'New Environment',
|
|
722
722
|
};
|
|
723
723
|
if (lodash.isPlainObject(env === null || env === void 0 ? void 0 : env.env_var_list)) {
|
|
724
724
|
servers.variables = {};
|
|
@@ -846,7 +846,7 @@ class ApipostToSwagger {
|
|
|
846
846
|
this.apiToSwaggerResult.tags = [];
|
|
847
847
|
}
|
|
848
848
|
this.apiToSwaggerResult.tags.push({
|
|
849
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
849
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
850
850
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
851
851
|
});
|
|
852
852
|
folderObj[item === null || item === void 0 ? void 0 : item.name] = item;
|
|
@@ -1149,7 +1149,7 @@ const escapeRegExp = (str) => {
|
|
|
1149
1149
|
const createNewModelData2 = (item, model_name) => {
|
|
1150
1150
|
var model = {
|
|
1151
1151
|
model_id: `#/definitions/${model_name}`,
|
|
1152
|
-
name: model_name || '
|
|
1152
|
+
name: model_name || 'New Schema',
|
|
1153
1153
|
displayName: model_name || '',
|
|
1154
1154
|
model_type: 'model',
|
|
1155
1155
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -1164,7 +1164,7 @@ const createNewModelData2 = (item, model_name) => {
|
|
|
1164
1164
|
const createDataModelNewFolder = (folder_name) => {
|
|
1165
1165
|
var newFolder = {
|
|
1166
1166
|
'model_id': '',
|
|
1167
|
-
'name': folder_name || '
|
|
1167
|
+
'name': folder_name || 'New Folder',
|
|
1168
1168
|
'model_type': 'folder',
|
|
1169
1169
|
'description': folder_name || '',
|
|
1170
1170
|
'children': [],
|
|
@@ -1174,7 +1174,7 @@ const createDataModelNewFolder = (folder_name) => {
|
|
|
1174
1174
|
const createNewModelData = (item, key, folder_name) => {
|
|
1175
1175
|
var model = {
|
|
1176
1176
|
model_id: `#/components/${folder_name}/${key}`,
|
|
1177
|
-
name: (item === null || item === void 0 ? void 0 : item.title) || key || '
|
|
1177
|
+
name: (item === null || item === void 0 ? void 0 : item.title) || key || 'New Schema',
|
|
1178
1178
|
displayName: (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
1179
1179
|
model_type: 'model',
|
|
1180
1180
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -1303,7 +1303,7 @@ class SwaggerToApipost {
|
|
|
1303
1303
|
const that = this;
|
|
1304
1304
|
if (lodash.isArray(json === null || json === void 0 ? void 0 : json.tags)) {
|
|
1305
1305
|
json.tags.forEach((item) => {
|
|
1306
|
-
const folder_name = (item === null || item === void 0 ? void 0 : item.name) || '
|
|
1306
|
+
const folder_name = (item === null || item === void 0 ? void 0 : item.name) || 'New Folder';
|
|
1307
1307
|
if (!that.folderNames[folder_name] && !Object.keys(that.folders).includes(folder_name)) {
|
|
1308
1308
|
that.apis.push(Object.assign(Object.assign({}, that.createNewFolder(folder_name, json.tags)), { sort: 1 }));
|
|
1309
1309
|
}
|
|
@@ -1348,7 +1348,7 @@ class SwaggerToApipost {
|
|
|
1348
1348
|
validate(json) {
|
|
1349
1349
|
if (lodash.has(json, 'swagger')) {
|
|
1350
1350
|
if (json.swagger !== '2.0') {
|
|
1351
|
-
return throwResult$1('error', '
|
|
1351
|
+
return throwResult$1('error', 'Non standard format Swagger file, please check and upload again');
|
|
1352
1352
|
}
|
|
1353
1353
|
else {
|
|
1354
1354
|
this.version = '2.0';
|
|
@@ -1358,13 +1358,13 @@ class SwaggerToApipost {
|
|
|
1358
1358
|
this.version = '3.0';
|
|
1359
1359
|
}
|
|
1360
1360
|
if (!lodash.has(json, 'swagger') && !lodash.has(json, 'openapi')) {
|
|
1361
|
-
return throwResult$1('error', '
|
|
1361
|
+
return throwResult$1('error', 'Non standard format Swagger file, please check and upload again');
|
|
1362
1362
|
}
|
|
1363
1363
|
return throwResult$1('success', '');
|
|
1364
1364
|
}
|
|
1365
1365
|
handleInfo(json) {
|
|
1366
1366
|
var _a, _b;
|
|
1367
|
-
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.title) || '
|
|
1367
|
+
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.title) || 'New Project';
|
|
1368
1368
|
this.project.description = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || '';
|
|
1369
1369
|
}
|
|
1370
1370
|
setBasePath(json) {
|
|
@@ -1402,7 +1402,7 @@ class SwaggerToApipost {
|
|
|
1402
1402
|
return;
|
|
1403
1403
|
for (const server of servers) {
|
|
1404
1404
|
const newEnv = {
|
|
1405
|
-
name: (server === null || server === void 0 ? void 0 : server.description) || (server === null || server === void 0 ? void 0 : server.url) || '
|
|
1405
|
+
name: (server === null || server === void 0 ? void 0 : server.description) || (server === null || server === void 0 ? void 0 : server.url) || 'Unnamed environment',
|
|
1406
1406
|
url: server.url || '',
|
|
1407
1407
|
env_var_list: {},
|
|
1408
1408
|
};
|
|
@@ -1430,7 +1430,7 @@ class SwaggerToApipost {
|
|
|
1430
1430
|
this.handleTags(swaggerApi.tags, tags);
|
|
1431
1431
|
}
|
|
1432
1432
|
const api = {
|
|
1433
|
-
name: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.summary) || (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.operationId) || '
|
|
1433
|
+
name: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.summary) || (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.operationId) || 'New HTTP',
|
|
1434
1434
|
target_type: 'api',
|
|
1435
1435
|
tags: [],
|
|
1436
1436
|
url: url || '',
|
|
@@ -2270,7 +2270,7 @@ class SwaggerToApipost {
|
|
|
2270
2270
|
}
|
|
2271
2271
|
catch (err) {
|
|
2272
2272
|
if ((err === null || err === void 0 ? void 0 : err.name) === 'AbortError') {
|
|
2273
|
-
return throwResult$1('error', '
|
|
2273
|
+
return throwResult$1('error', 'The data is too large and the request has timed out.');
|
|
2274
2274
|
}
|
|
2275
2275
|
return throwResult$1('error', String(err));
|
|
2276
2276
|
}
|
|
@@ -2335,7 +2335,7 @@ class ApidocToApipost {
|
|
|
2335
2335
|
this.foldersMap = {};
|
|
2336
2336
|
}
|
|
2337
2337
|
initProject(project_id) {
|
|
2338
|
-
this.project.name = '
|
|
2338
|
+
this.project.name = 'New project';
|
|
2339
2339
|
this.project.intro = '';
|
|
2340
2340
|
this.project.project_id = project_id;
|
|
2341
2341
|
}
|
|
@@ -2485,7 +2485,7 @@ class ApidocToApipost {
|
|
|
2485
2485
|
content_type: 'json',
|
|
2486
2486
|
is_default: 1,
|
|
2487
2487
|
mock: '',
|
|
2488
|
-
name: '
|
|
2488
|
+
name: 'success',
|
|
2489
2489
|
schema: {
|
|
2490
2490
|
type: 'object',
|
|
2491
2491
|
properties: {},
|
|
@@ -2502,7 +2502,7 @@ class ApidocToApipost {
|
|
|
2502
2502
|
content_type: 'json',
|
|
2503
2503
|
is_default: -1,
|
|
2504
2504
|
mock: '',
|
|
2505
|
-
name: '
|
|
2505
|
+
name: 'fail',
|
|
2506
2506
|
schema: {
|
|
2507
2507
|
type: 'object',
|
|
2508
2508
|
properties: {},
|
|
@@ -2531,7 +2531,7 @@ class ApidocToApipost {
|
|
|
2531
2531
|
project_id: this.project.project_id || '',
|
|
2532
2532
|
parent_id: '0',
|
|
2533
2533
|
target_type: 'folder',
|
|
2534
|
-
name: (item === null || item === void 0 ? void 0 : item.group) || '
|
|
2534
|
+
name: (item === null || item === void 0 ? void 0 : item.group) || 'New Folder',
|
|
2535
2535
|
version: 0,
|
|
2536
2536
|
sort: 0,
|
|
2537
2537
|
description: (item === null || item === void 0 ? void 0 : item.groupTitle) || '',
|
|
@@ -2547,7 +2547,7 @@ class ApidocToApipost {
|
|
|
2547
2547
|
project_id: this.project.project_id || '',
|
|
2548
2548
|
parent_id: id || '0',
|
|
2549
2549
|
target_type: 'api',
|
|
2550
|
-
name: (item === null || item === void 0 ? void 0 : item.title) || '
|
|
2550
|
+
name: (item === null || item === void 0 ? void 0 : item.title) || 'New HTTP',
|
|
2551
2551
|
version: 0,
|
|
2552
2552
|
sort: 0,
|
|
2553
2553
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -2769,7 +2769,7 @@ class ApifoxToApipost {
|
|
|
2769
2769
|
}
|
|
2770
2770
|
initProject(json, project_id) {
|
|
2771
2771
|
var _a, _b;
|
|
2772
|
-
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || '
|
|
2772
|
+
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || 'New Project';
|
|
2773
2773
|
this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || '';
|
|
2774
2774
|
this.project.project_id = project_id;
|
|
2775
2775
|
}
|
|
@@ -2846,11 +2846,11 @@ class ApifoxToApipost {
|
|
|
2846
2846
|
const server_id = ATools.snowflakeId();
|
|
2847
2847
|
this.serversMap[item.id] = {
|
|
2848
2848
|
server_id: (item === null || item === void 0 ? void 0 : item.id) === 'default' ? '1' : server_id,
|
|
2849
|
-
name: (item === null || item === void 0 ? void 0 : item.name) ||
|
|
2849
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || `Server${server_id}`,
|
|
2850
2850
|
};
|
|
2851
2851
|
return {
|
|
2852
2852
|
server_id: (item === null || item === void 0 ? void 0 : item.id) === 'default' ? '1' : server_id,
|
|
2853
|
-
name: (item === null || item === void 0 ? void 0 : item.name) ||
|
|
2853
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || `Server${server_id}`,
|
|
2854
2854
|
};
|
|
2855
2855
|
});
|
|
2856
2856
|
}
|
|
@@ -2948,7 +2948,7 @@ class ApifoxToApipost {
|
|
|
2948
2948
|
model_type: 'folder',
|
|
2949
2949
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
2950
2950
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.model_id) || '0',
|
|
2951
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
2951
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
2952
2952
|
display_name: (item === null || item === void 0 ? void 0 : item.displayName) || '',
|
|
2953
2953
|
sort: 1000,
|
|
2954
2954
|
};
|
|
@@ -2963,7 +2963,7 @@ class ApifoxToApipost {
|
|
|
2963
2963
|
this.modelMap[item.id] = model_id;
|
|
2964
2964
|
}
|
|
2965
2965
|
pre.push({
|
|
2966
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
2966
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Schema',
|
|
2967
2967
|
model_id,
|
|
2968
2968
|
model_type: 'model',
|
|
2969
2969
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -3001,7 +3001,7 @@ class ApifoxToApipost {
|
|
|
3001
3001
|
type: item === null || item === void 0 ? void 0 : item.type,
|
|
3002
3002
|
enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
|
|
3003
3003
|
id: ATools.snowflakeId(),
|
|
3004
|
-
name: '
|
|
3004
|
+
name: 'Script',
|
|
3005
3005
|
data: (item === null || item === void 0 ? void 0 : item.data) || '',
|
|
3006
3006
|
});
|
|
3007
3007
|
}
|
|
@@ -3010,7 +3010,7 @@ class ApifoxToApipost {
|
|
|
3010
3010
|
type: item === null || item === void 0 ? void 0 : item.type,
|
|
3011
3011
|
enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
|
|
3012
3012
|
id: ATools.snowflakeId(),
|
|
3013
|
-
name: ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.name) || '
|
|
3013
|
+
name: ((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.name) || 'Database',
|
|
3014
3014
|
data: {
|
|
3015
3015
|
query: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.expression) || '',
|
|
3016
3016
|
isConsoleOutput: ((_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.printResults) ? 1 : -1,
|
|
@@ -3018,7 +3018,7 @@ class ApifoxToApipost {
|
|
|
3018
3018
|
variables: (_e = (_d = item === null || item === void 0 ? void 0 : item.data) === null || _d === void 0 ? void 0 : _d.extractors) === null || _e === void 0 ? void 0 : _e.reduce((pre, variablesItem) => {
|
|
3019
3019
|
if (item === null || item === void 0 ? void 0 : item.variableName) {
|
|
3020
3020
|
pre.push({
|
|
3021
|
-
name: (variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.variableName) || '
|
|
3021
|
+
name: (variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.variableName) || 'Variable',
|
|
3022
3022
|
type: (VARS_TYPE_MAP === null || VARS_TYPE_MAP === void 0 ? void 0 : VARS_TYPE_MAP[variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.variableType]) || 'variables',
|
|
3023
3023
|
pattern: (variablesItem === null || variablesItem === void 0 ? void 0 : variablesItem.jsonPath) || '',
|
|
3024
3024
|
param_id: ATools.snowflakeId(),
|
|
@@ -3034,7 +3034,7 @@ class ApifoxToApipost {
|
|
|
3034
3034
|
type: 'pickVars',
|
|
3035
3035
|
enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
|
|
3036
3036
|
id: ATools.snowflakeId(),
|
|
3037
|
-
name: ((_f = item === null || item === void 0 ? void 0 : item.data) === null || _f === void 0 ? void 0 : _f.variableName) || '
|
|
3037
|
+
name: ((_f = item === null || item === void 0 ? void 0 : item.data) === null || _f === void 0 ? void 0 : _f.variableName) || 'Variable Name',
|
|
3038
3038
|
data: {
|
|
3039
3039
|
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',
|
|
3040
3040
|
variables: [],
|
|
@@ -3046,7 +3046,7 @@ class ApifoxToApipost {
|
|
|
3046
3046
|
type: 'assert',
|
|
3047
3047
|
enabled: (item === null || item === void 0 ? void 0 : item.enable) ? 1 : -1,
|
|
3048
3048
|
id: ATools.snowflakeId(),
|
|
3049
|
-
name: ((_h = item === null || item === void 0 ? void 0 : item.data) === null || _h === void 0 ? void 0 : _h.name) || '
|
|
3049
|
+
name: ((_h = item === null || item === void 0 ? void 0 : item.data) === null || _h === void 0 ? void 0 : _h.name) || 'Assertion',
|
|
3050
3050
|
data: {
|
|
3051
3051
|
type: ASSERT_TYPES_MAP[(_j = item === null || item === void 0 ? void 0 : item.data) === null || _j === void 0 ? void 0 : _j.subject] || 'responseJson',
|
|
3052
3052
|
expression: {
|
|
@@ -3298,7 +3298,7 @@ class ApifoxToApipost {
|
|
|
3298
3298
|
project_id: this.project.project_id || '',
|
|
3299
3299
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0',
|
|
3300
3300
|
target_type: 'folder',
|
|
3301
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
3301
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
3302
3302
|
version: 0,
|
|
3303
3303
|
sort: 0,
|
|
3304
3304
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -3352,14 +3352,14 @@ class ApifoxToApipost {
|
|
|
3352
3352
|
completionApiTarget(item, baseInfo, parentInfo) {
|
|
3353
3353
|
var _a;
|
|
3354
3354
|
const { api } = item || {};
|
|
3355
|
-
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0', target_type: 'api', name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
3355
|
+
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0', target_type: 'api', name: (item === null || item === void 0 ? void 0 : item.name) || 'New HTTP', version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || '', method: (api === null || api === void 0 ? void 0 : api.method) ? (_a = api === null || api === void 0 ? void 0 : api.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : 'GET', url: (api === null || api === void 0 ? void 0 : api.path) || '', mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), protocol: 'http/1.1', request: this.completionApiRequest(Object.assign(Object.assign({}, api === null || api === void 0 ? void 0 : api.parameters), { preProcessors: api === null || api === void 0 ? void 0 : api.preProcessors, postProcessors: api === null || api === void 0 ? void 0 : api.postProcessors, auth: api === null || api === void 0 ? void 0 : api.auth }), 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), attribute_info: {}, tags: isArray(api === null || api === void 0 ? void 0 : api.tags) ? api === null || api === void 0 ? void 0 : api.tags : [], is_force: -1 });
|
|
3356
3356
|
}
|
|
3357
3357
|
completionApiSample(item, baseInfo) {
|
|
3358
3358
|
const { api } = item || {};
|
|
3359
3359
|
const { cases } = api || {};
|
|
3360
3360
|
return cases === null || cases === void 0 ? void 0 : cases.map((caseItem) => {
|
|
3361
3361
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
3362
|
-
return Object.assign(Object.assign({}, baseInfo), { created_at: 0, method: (api === null || api === void 0 ? void 0 : api.method) ? (_a = api === null || api === void 0 ? void 0 : api.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : 'GET', name: (caseItem === null || caseItem === void 0 ? void 0 : caseItem.name) || '
|
|
3362
|
+
return Object.assign(Object.assign({}, baseInfo), { created_at: 0, method: (api === null || api === void 0 ? void 0 : api.method) ? (_a = api === null || api === void 0 ? void 0 : api.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : 'GET', name: (caseItem === null || caseItem === void 0 ? void 0 : caseItem.name) || 'New Test Case', parent_id: '0', protocol: 'http/1.1', request: this.completionApiRequest({
|
|
3363
3363
|
header: (_c = (((_b = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _b === void 0 ? void 0 : _b.header) || [])) === null || _c === void 0 ? void 0 : _c.concat(((_d = api === null || api === void 0 ? void 0 : api.parameters) === null || _d === void 0 ? void 0 : _d.header) || []),
|
|
3364
3364
|
query: (_f = (((_e = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _e === void 0 ? void 0 : _e.query) || [])) === null || _f === void 0 ? void 0 : _f.concat(((_g = api === null || api === void 0 ? void 0 : api.parameters) === null || _g === void 0 ? void 0 : _g.query) || []),
|
|
3365
3365
|
cookie: (_j = (((_h = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _h === void 0 ? void 0 : _h.cookie) || [])) === null || _j === void 0 ? void 0 : _j.concat(((_k = api === null || api === void 0 ? void 0 : api.parameters) === null || _k === void 0 ? void 0 : _k.cookie) || []),
|
|
@@ -3417,7 +3417,7 @@ class ApifoxToApipost {
|
|
|
3417
3417
|
project_id: this.project.project_id || '',
|
|
3418
3418
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[docItem === null || docItem === void 0 ? void 0 : docItem.folderId]) || '0',
|
|
3419
3419
|
target_type: 'doc',
|
|
3420
|
-
name: (docItem === null || docItem === void 0 ? void 0 : docItem.name) || '
|
|
3420
|
+
name: (docItem === null || docItem === void 0 ? void 0 : docItem.name) || 'New Markdown',
|
|
3421
3421
|
version: 0,
|
|
3422
3422
|
sort: 0,
|
|
3423
3423
|
mark_id: '1',
|
|
@@ -3450,7 +3450,7 @@ class ApifoxToApipost {
|
|
|
3450
3450
|
project_id: this.project.project_id || '',
|
|
3451
3451
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[tcpClientItem === null || tcpClientItem === void 0 ? void 0 : tcpClientItem.folderId]) || '0',
|
|
3452
3452
|
target_type: 'socket',
|
|
3453
|
-
name: (tcpClientItem === null || tcpClientItem === void 0 ? void 0 : tcpClientItem.name) || '
|
|
3453
|
+
name: (tcpClientItem === null || tcpClientItem === void 0 ? void 0 : tcpClientItem.name) || 'New TCP Client',
|
|
3454
3454
|
version: 0,
|
|
3455
3455
|
sort: 0,
|
|
3456
3456
|
method: 'TCP',
|
|
@@ -3484,7 +3484,7 @@ class ApifoxToApipost {
|
|
|
3484
3484
|
completionTcpMethod(apis, parentInfo) {
|
|
3485
3485
|
if (isArray(apis) && apis.length) {
|
|
3486
3486
|
return apis === null || apis === void 0 ? void 0 : apis.reduce((pre, item) => {
|
|
3487
|
-
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) || '
|
|
3487
|
+
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 }));
|
|
3488
3488
|
return pre;
|
|
3489
3489
|
}, []);
|
|
3490
3490
|
}
|
|
@@ -3686,7 +3686,7 @@ class HarToApipost {
|
|
|
3686
3686
|
};
|
|
3687
3687
|
}
|
|
3688
3688
|
initProject(project_id) {
|
|
3689
|
-
this.project.name = '
|
|
3689
|
+
this.project.name = 'New Project';
|
|
3690
3690
|
this.project.intro = '';
|
|
3691
3691
|
this.project.project_id = project_id;
|
|
3692
3692
|
}
|
|
@@ -3762,7 +3762,7 @@ class HarToApipost {
|
|
|
3762
3762
|
content_type: 'json',
|
|
3763
3763
|
is_default: 1,
|
|
3764
3764
|
mock: '',
|
|
3765
|
-
name: '
|
|
3765
|
+
name: 'Success',
|
|
3766
3766
|
schema: {
|
|
3767
3767
|
type: 'object',
|
|
3768
3768
|
properties: {},
|
|
@@ -3779,7 +3779,7 @@ class HarToApipost {
|
|
|
3779
3779
|
content_type: 'json',
|
|
3780
3780
|
is_default: -1,
|
|
3781
3781
|
mock: '',
|
|
3782
|
-
name: '
|
|
3782
|
+
name: 'Failed',
|
|
3783
3783
|
schema: {
|
|
3784
3784
|
type: 'object',
|
|
3785
3785
|
properties: {},
|
|
@@ -3805,7 +3805,7 @@ class HarToApipost {
|
|
|
3805
3805
|
project_id: this.project.project_id || '',
|
|
3806
3806
|
parent_id: '0',
|
|
3807
3807
|
target_type: 'api',
|
|
3808
|
-
name: url || '
|
|
3808
|
+
name: url || 'New HTTP',
|
|
3809
3809
|
version: 0,
|
|
3810
3810
|
sort: 0,
|
|
3811
3811
|
description: '',
|
|
@@ -3898,7 +3898,7 @@ class InsomniaToApipost {
|
|
|
3898
3898
|
}
|
|
3899
3899
|
initProject(resources, project_id) {
|
|
3900
3900
|
const projectInfo = resources === null || resources === void 0 ? void 0 : resources.find((e) => (e === null || e === void 0 ? void 0 : e._type) === 'workspace');
|
|
3901
|
-
this.project.name = (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.name) || '
|
|
3901
|
+
this.project.name = (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.name) || 'New Project';
|
|
3902
3902
|
this.project.intro = (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.description) || '';
|
|
3903
3903
|
this.project.project_id = project_id;
|
|
3904
3904
|
}
|
|
@@ -3964,7 +3964,7 @@ class InsomniaToApipost {
|
|
|
3964
3964
|
{
|
|
3965
3965
|
type: 'customScript',
|
|
3966
3966
|
enabled: 1,
|
|
3967
|
-
name: '
|
|
3967
|
+
name: 'Script',
|
|
3968
3968
|
id: ATools.snowflakeId(),
|
|
3969
3969
|
data: (item === null || item === void 0 ? void 0 : item.preRequestScript) || '',
|
|
3970
3970
|
},
|
|
@@ -4051,7 +4051,7 @@ class InsomniaToApipost {
|
|
|
4051
4051
|
target_id: ATools.snowflakeId(),
|
|
4052
4052
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || '0',
|
|
4053
4053
|
target_type: 'websocket',
|
|
4054
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4054
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Websocket',
|
|
4055
4055
|
sort: 0,
|
|
4056
4056
|
version: 0,
|
|
4057
4057
|
mark_id: '1',
|
|
@@ -4081,7 +4081,7 @@ class InsomniaToApipost {
|
|
|
4081
4081
|
project_id: this.project.project_id || '',
|
|
4082
4082
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || '0',
|
|
4083
4083
|
target_type: 'api',
|
|
4084
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4084
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New HTTP',
|
|
4085
4085
|
version: 0,
|
|
4086
4086
|
sort: 0,
|
|
4087
4087
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -4100,7 +4100,7 @@ class InsomniaToApipost {
|
|
|
4100
4100
|
content_type: 'json',
|
|
4101
4101
|
is_default: 1,
|
|
4102
4102
|
mock: '',
|
|
4103
|
-
name: '
|
|
4103
|
+
name: 'Success',
|
|
4104
4104
|
schema: {
|
|
4105
4105
|
type: 'object',
|
|
4106
4106
|
properties: {},
|
|
@@ -4117,7 +4117,7 @@ class InsomniaToApipost {
|
|
|
4117
4117
|
content_type: 'json',
|
|
4118
4118
|
is_default: -1,
|
|
4119
4119
|
mock: '',
|
|
4120
|
-
name: '
|
|
4120
|
+
name: 'Failed',
|
|
4121
4121
|
schema: {
|
|
4122
4122
|
type: 'object',
|
|
4123
4123
|
properties: {},
|
|
@@ -4142,7 +4142,7 @@ class InsomniaToApipost {
|
|
|
4142
4142
|
project_id: this.project.project_id || '',
|
|
4143
4143
|
parent_id: this.foldersMap[item === null || item === void 0 ? void 0 : item.parentId] || '0',
|
|
4144
4144
|
target_type: 'folder',
|
|
4145
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4145
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
4146
4146
|
version: 0,
|
|
4147
4147
|
sort: 0,
|
|
4148
4148
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -4442,7 +4442,7 @@ class PostmanToApipost {
|
|
|
4442
4442
|
{
|
|
4443
4443
|
type: 'customScript',
|
|
4444
4444
|
enabled: 1,
|
|
4445
|
-
name: '
|
|
4445
|
+
name: 'Custom Script',
|
|
4446
4446
|
id: ATools.snowflakeId(),
|
|
4447
4447
|
data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec) ? (_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') : '',
|
|
4448
4448
|
},
|
|
@@ -4453,7 +4453,7 @@ class PostmanToApipost {
|
|
|
4453
4453
|
{
|
|
4454
4454
|
type: 'customScript',
|
|
4455
4455
|
enabled: 1,
|
|
4456
|
-
name: '
|
|
4456
|
+
name: 'Custom Script',
|
|
4457
4457
|
id: ATools.snowflakeId(),
|
|
4458
4458
|
data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec) ? (_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') : '',
|
|
4459
4459
|
},
|
|
@@ -4488,7 +4488,7 @@ class PostmanToApipost {
|
|
|
4488
4488
|
project_id: this.project.project_id || '',
|
|
4489
4489
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0',
|
|
4490
4490
|
target_type: 'folder',
|
|
4491
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4491
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
4492
4492
|
version: 0,
|
|
4493
4493
|
sort: 0,
|
|
4494
4494
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -4507,7 +4507,7 @@ class PostmanToApipost {
|
|
|
4507
4507
|
project_id: this.project.project_id || '',
|
|
4508
4508
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0',
|
|
4509
4509
|
target_type: 'api',
|
|
4510
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4510
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New HTTP',
|
|
4511
4511
|
version: 0,
|
|
4512
4512
|
sort: 0,
|
|
4513
4513
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -4526,7 +4526,7 @@ class PostmanToApipost {
|
|
|
4526
4526
|
content_type: 'json',
|
|
4527
4527
|
is_default: 1,
|
|
4528
4528
|
mock: '',
|
|
4529
|
-
name: '
|
|
4529
|
+
name: 'Success',
|
|
4530
4530
|
schema: {
|
|
4531
4531
|
type: 'object',
|
|
4532
4532
|
properties: {},
|
|
@@ -4543,7 +4543,7 @@ class PostmanToApipost {
|
|
|
4543
4543
|
content_type: 'json',
|
|
4544
4544
|
is_default: -1,
|
|
4545
4545
|
mock: '',
|
|
4546
|
-
name: '
|
|
4546
|
+
name: 'Failed',
|
|
4547
4547
|
schema: {
|
|
4548
4548
|
type: 'object',
|
|
4549
4549
|
properties: {},
|
|
@@ -4586,7 +4586,7 @@ class PostmanToApipost {
|
|
|
4586
4586
|
}
|
|
4587
4587
|
initProject(json, project_id) {
|
|
4588
4588
|
var _a, _b;
|
|
4589
|
-
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || '
|
|
4589
|
+
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || 'New Project';
|
|
4590
4590
|
this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || '';
|
|
4591
4591
|
this.project.project_id = project_id;
|
|
4592
4592
|
}
|
|
@@ -4634,7 +4634,7 @@ class YapiToApipost {
|
|
|
4634
4634
|
};
|
|
4635
4635
|
}
|
|
4636
4636
|
initProject(project_id) {
|
|
4637
|
-
this.project.name = '
|
|
4637
|
+
this.project.name = 'New Project';
|
|
4638
4638
|
this.project.intro = '';
|
|
4639
4639
|
this.project.project_id = project_id;
|
|
4640
4640
|
}
|
|
@@ -4644,7 +4644,7 @@ class YapiToApipost {
|
|
|
4644
4644
|
project_id: this.project.project_id || '',
|
|
4645
4645
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0',
|
|
4646
4646
|
target_type: 'folder',
|
|
4647
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || '
|
|
4647
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || 'New Folder',
|
|
4648
4648
|
version: 0,
|
|
4649
4649
|
sort: 0,
|
|
4650
4650
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
@@ -4782,7 +4782,7 @@ class YapiToApipost {
|
|
|
4782
4782
|
content_type: 'json',
|
|
4783
4783
|
is_default: 1,
|
|
4784
4784
|
mock: '',
|
|
4785
|
-
name: '
|
|
4785
|
+
name: 'Success',
|
|
4786
4786
|
schema,
|
|
4787
4787
|
verify_type: 'schema',
|
|
4788
4788
|
},
|
|
@@ -4796,7 +4796,7 @@ class YapiToApipost {
|
|
|
4796
4796
|
content_type: 'json',
|
|
4797
4797
|
is_default: -1,
|
|
4798
4798
|
mock: '',
|
|
4799
|
-
name: '
|
|
4799
|
+
name: 'Failed',
|
|
4800
4800
|
schema: {
|
|
4801
4801
|
type: 'object',
|
|
4802
4802
|
properties: {},
|
|
@@ -4816,7 +4816,7 @@ class YapiToApipost {
|
|
|
4816
4816
|
project_id: this.project.project_id || '',
|
|
4817
4817
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || '0',
|
|
4818
4818
|
target_type: 'api',
|
|
4819
|
-
name: (item === null || item === void 0 ? void 0 : item.title) || '
|
|
4819
|
+
name: (item === null || item === void 0 ? void 0 : item.title) || 'New HTTP',
|
|
4820
4820
|
version: 0,
|
|
4821
4821
|
sort: 0,
|
|
4822
4822
|
description: (item === null || item === void 0 ? void 0 : item.desc) || '',
|