echoapi-converter 0.0.86 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -1
- package/dist/index.js +43 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -205,6 +205,7 @@ declare class PostmanToApipost {
|
|
|
205
205
|
apis: any;
|
|
206
206
|
project: any;
|
|
207
207
|
source: 'vscode' | 'workbench' | string;
|
|
208
|
+
file_parsing_rules: 'normal' | 'use_case' | string;
|
|
208
209
|
constructor();
|
|
209
210
|
private clear;
|
|
210
211
|
private completionApiRequestAuth;
|
|
@@ -214,12 +215,14 @@ declare class PostmanToApipost {
|
|
|
214
215
|
private completionApiRequest;
|
|
215
216
|
private completionApiResponse;
|
|
216
217
|
private completionApiFolder;
|
|
218
|
+
private completionApiCase;
|
|
217
219
|
private completionApiTarget;
|
|
218
220
|
private completionApis;
|
|
219
221
|
private initApis;
|
|
220
222
|
private initProject;
|
|
221
223
|
convert(json: any, project_id: string, option?: {
|
|
222
|
-
source
|
|
224
|
+
source?: string;
|
|
225
|
+
file_parsing_rules?: string;
|
|
223
226
|
}): {
|
|
224
227
|
status: "error" | "success";
|
|
225
228
|
message: string;
|
package/dist/index.js
CHANGED
|
@@ -2145,6 +2145,7 @@ const deepModelRef = (originSchema, schemaMap, startSchema, count = 0) => {
|
|
|
2145
2145
|
if (!lodash.includes(lastRequired, item)) {
|
|
2146
2146
|
lastRequired.push(item);
|
|
2147
2147
|
}
|
|
2148
|
+
return lastRequired;
|
|
2148
2149
|
}, (schema === null || schema === void 0 ? void 0 : schema.required) || []);
|
|
2149
2150
|
}
|
|
2150
2151
|
pre = Object.assign(Object.assign({}, pre), ((mapSchema === null || mapSchema === void 0 ? void 0 : mapSchema.properties) || {}));
|
|
@@ -6944,6 +6945,13 @@ class PostmanToApipost {
|
|
|
6944
6945
|
writable: true,
|
|
6945
6946
|
value: void 0
|
|
6946
6947
|
});
|
|
6948
|
+
// 文件解析规则
|
|
6949
|
+
Object.defineProperty(this, "file_parsing_rules", {
|
|
6950
|
+
enumerable: true,
|
|
6951
|
+
configurable: true,
|
|
6952
|
+
writable: true,
|
|
6953
|
+
value: void 0
|
|
6954
|
+
});
|
|
6947
6955
|
this.apis = [];
|
|
6948
6956
|
this.project = {
|
|
6949
6957
|
name: "",
|
|
@@ -7469,6 +7477,24 @@ class PostmanToApipost {
|
|
|
7469
7477
|
is_socket: 1,
|
|
7470
7478
|
};
|
|
7471
7479
|
}
|
|
7480
|
+
completionApiCase(item, caseTarget) {
|
|
7481
|
+
const sample_id = apipostTools.snowflakeId();
|
|
7482
|
+
return {
|
|
7483
|
+
sample_id: sample_id,
|
|
7484
|
+
parent_id: item === null || item === void 0 ? void 0 : item.target_id,
|
|
7485
|
+
target_id: sample_id,
|
|
7486
|
+
project_id: this.project.project_id || "",
|
|
7487
|
+
name: caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.name,
|
|
7488
|
+
type: 'sample',
|
|
7489
|
+
target_type: "sample",
|
|
7490
|
+
method: caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.method,
|
|
7491
|
+
url: caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.url,
|
|
7492
|
+
sort: 0,
|
|
7493
|
+
description: caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.description,
|
|
7494
|
+
protocol: (caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.protocol) || "http/1.1",
|
|
7495
|
+
request: caseTarget === null || caseTarget === void 0 ? void 0 : caseTarget.request,
|
|
7496
|
+
};
|
|
7497
|
+
}
|
|
7472
7498
|
completionApiTarget(item, parentInfo) {
|
|
7473
7499
|
var _a, _b, _c;
|
|
7474
7500
|
const { request, response } = item || {};
|
|
@@ -7521,19 +7547,30 @@ class PostmanToApipost {
|
|
|
7521
7547
|
is_force: -1,
|
|
7522
7548
|
};
|
|
7523
7549
|
}
|
|
7524
|
-
completionApis(item, parentInfo) {
|
|
7550
|
+
completionApis(item, parentInfo, targetObj) {
|
|
7525
7551
|
if (item === null || item === void 0 ? void 0 : item.length) {
|
|
7526
7552
|
return item === null || item === void 0 ? void 0 : item.reduce((pre, targetItem) => {
|
|
7527
7553
|
if (!lodash.has(targetItem, "item")) {
|
|
7528
7554
|
// 接口
|
|
7529
|
-
|
|
7555
|
+
let target = this.completionApiTarget(targetItem, parentInfo);
|
|
7556
|
+
// 文件解析规则为同接口转用例 记录同mtehod和同url的接口
|
|
7557
|
+
if (this.file_parsing_rules === 'use_case' && target.target_type === 'api') {
|
|
7558
|
+
if (lodash.has(targetObj, `${target.method}:${target.url}`)) {
|
|
7559
|
+
// 有重复改为用例 并把parent_id 改掉
|
|
7560
|
+
target = this.completionApiCase(targetObj[`${target.method}:${target.url}`], target);
|
|
7561
|
+
// console.log(target,"case-target");
|
|
7562
|
+
}
|
|
7563
|
+
else {
|
|
7564
|
+
targetObj[`${target.method}:${target.url}`] = target;
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7530
7567
|
pre.push(target);
|
|
7531
7568
|
}
|
|
7532
7569
|
else {
|
|
7533
7570
|
// 目录
|
|
7534
7571
|
const parent = this.completionApiFolder(targetItem, parentInfo);
|
|
7535
7572
|
pre.push(parent);
|
|
7536
|
-
pre = pre.concat(this.completionApis(targetItem === null || targetItem === void 0 ? void 0 : targetItem.item, parent));
|
|
7573
|
+
pre = pre.concat(this.completionApis(targetItem === null || targetItem === void 0 ? void 0 : targetItem.item, parent, targetObj));
|
|
7537
7574
|
}
|
|
7538
7575
|
return pre;
|
|
7539
7576
|
}, []);
|
|
@@ -7542,7 +7579,8 @@ class PostmanToApipost {
|
|
|
7542
7579
|
}
|
|
7543
7580
|
initApis(item) {
|
|
7544
7581
|
if (isArray(item)) {
|
|
7545
|
-
|
|
7582
|
+
const targetObj = {};
|
|
7583
|
+
this.apis = this.completionApis(item, null, targetObj);
|
|
7546
7584
|
}
|
|
7547
7585
|
}
|
|
7548
7586
|
initProject(json, project_id) {
|
|
@@ -7555,6 +7593,7 @@ class PostmanToApipost {
|
|
|
7555
7593
|
this.clear();
|
|
7556
7594
|
try {
|
|
7557
7595
|
this.source = (option === null || option === void 0 ? void 0 : option.source) || 'workbench';
|
|
7596
|
+
this.file_parsing_rules = (option === null || option === void 0 ? void 0 : option.file_parsing_rules) || 'normal';
|
|
7558
7597
|
this.initProject(json, project_id);
|
|
7559
7598
|
this.initApis(json === null || json === void 0 ? void 0 : json.item);
|
|
7560
7599
|
const data = Object.assign(Object.assign({}, this.project), { apis: this.apis });
|