echoapi-converter 0.0.41 → 0.0.43

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 CHANGED
@@ -204,6 +204,7 @@ declare class InsomniaToApipost {
204
204
  declare class PostmanToApipost {
205
205
  apis: any;
206
206
  project: any;
207
+ source: 'vscode' | 'workbench' | string;
207
208
  constructor();
208
209
  private clear;
209
210
  private completionApiRequestAuth;
@@ -216,7 +217,9 @@ declare class PostmanToApipost {
216
217
  private completionApis;
217
218
  private initApis;
218
219
  private initProject;
219
- convert(json: any, project_id: string): {
220
+ convert(json: any, project_id: string, option?: {
221
+ source: string;
222
+ }): {
220
223
  status: "error" | "success";
221
224
  message: string;
222
225
  data: any;
@@ -248,6 +251,7 @@ declare class ThunderToApipost {
248
251
  folders: any;
249
252
  project: any;
250
253
  global: any;
254
+ source: 'vscode' | 'workbench' | string;
251
255
  constructor();
252
256
  private clear;
253
257
  private initProject;
@@ -266,7 +270,9 @@ declare class ThunderToApipost {
266
270
  private initApis;
267
271
  private initGlobal;
268
272
  private buildFolderApiTree;
269
- convert(json: any, project_id: string): {
273
+ convert(json: any, project_id: string, option?: {
274
+ source: string;
275
+ }): {
270
276
  status: "error" | "success";
271
277
  message: string;
272
278
  data: any;
package/dist/index.js CHANGED
@@ -3890,6 +3890,9 @@ const completionPostmanTarget = (targetItem) => {
3890
3890
  const result = {
3891
3891
  name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New HTTP',
3892
3892
  description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3893
+ protocolProfileBehavior: {
3894
+ disableBodyPruning: true // 禁止get请求把body丢弃
3895
+ },
3893
3896
  request: {
3894
3897
  method: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.method) || 'GET',
3895
3898
  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),
@@ -5494,12 +5497,20 @@ class PostmanToApipost {
5494
5497
  writable: true,
5495
5498
  value: void 0
5496
5499
  });
5500
+ // 转换的来源端
5501
+ Object.defineProperty(this, "source", {
5502
+ enumerable: true,
5503
+ configurable: true,
5504
+ writable: true,
5505
+ value: void 0
5506
+ });
5497
5507
  this.apis = [];
5498
5508
  this.project = {
5499
5509
  name: "",
5500
5510
  intro: "",
5501
5511
  project_id: "",
5502
5512
  };
5513
+ this.source = 'workbench';
5503
5514
  }
5504
5515
  clear() {
5505
5516
  this.apis = [];
@@ -5508,6 +5519,7 @@ class PostmanToApipost {
5508
5519
  intro: "",
5509
5520
  project_id: "",
5510
5521
  };
5522
+ this.source = 'workbench';
5511
5523
  }
5512
5524
  completionApiRequestAuth(auth) {
5513
5525
  var _a, _b, _c, _d, _e, _f, _g;
@@ -5573,11 +5585,22 @@ class PostmanToApipost {
5573
5585
  }
5574
5586
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
5575
5587
  customAuth["type"] = "oauth2";
5588
+ const getGrantType = (postman_grant_type) => {
5589
+ if (APIPOST_GRANT_TYPES.includes(postman_grant_type)) {
5590
+ return postman_grant_type;
5591
+ }
5592
+ else if (this.source === 'vscode') {
5593
+ return 'password_credentials';
5594
+ }
5595
+ else {
5596
+ return 'authorization_code';
5597
+ }
5598
+ };
5576
5599
  customAuth["oauth2"] = {
5577
5600
  addTokenTo: (authMap === null || authMap === void 0 ? void 0 : authMap.addTokenTo) || 'header',
5578
5601
  headerPrefix: (authMap === null || authMap === void 0 ? void 0 : authMap.headerPrefix) || 'Bearer',
5579
5602
  access_token: '',
5580
- grant_type: APIPOST_GRANT_TYPES.includes(authMap === null || authMap === void 0 ? void 0 : authMap.grant_type) ? authMap === null || authMap === void 0 ? void 0 : authMap.grant_type : 'authorization_code',
5603
+ grant_type: getGrantType(authMap === null || authMap === void 0 ? void 0 : authMap.grant_type),
5581
5604
  redirect_uri: (authMap === null || authMap === void 0 ? void 0 : authMap.redirect_uri) || '',
5582
5605
  authUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.authUrl) || '',
5583
5606
  accessTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.accessTokenUrl) || '',
@@ -6010,9 +6033,10 @@ class PostmanToApipost {
6010
6033
  this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || "";
6011
6034
  this.project.project_id = project_id;
6012
6035
  }
6013
- convert(json, project_id) {
6036
+ convert(json, project_id, option) {
6014
6037
  this.clear();
6015
6038
  try {
6039
+ this.source = (option === null || option === void 0 ? void 0 : option.source) || 'workbench';
6016
6040
  this.initProject(json, project_id);
6017
6041
  this.initApis(json === null || json === void 0 ? void 0 : json.item);
6018
6042
  const data = Object.assign(Object.assign({}, this.project), { apis: this.apis });
@@ -6319,6 +6343,13 @@ class ThunderToApipost {
6319
6343
  writable: true,
6320
6344
  value: void 0
6321
6345
  });
6346
+ // 转换的来源端
6347
+ Object.defineProperty(this, "source", {
6348
+ enumerable: true,
6349
+ configurable: true,
6350
+ writable: true,
6351
+ value: void 0
6352
+ });
6322
6353
  Object.defineProperty(this, "diyScript", {
6323
6354
  enumerable: true,
6324
6355
  configurable: true,
@@ -6487,6 +6518,7 @@ class ThunderToApipost {
6487
6518
  intro: "",
6488
6519
  project_id: "",
6489
6520
  };
6521
+ this.source = 'vscode';
6490
6522
  }
6491
6523
  clear() {
6492
6524
  this.apis = [];
@@ -6498,6 +6530,7 @@ class ThunderToApipost {
6498
6530
  intro: "",
6499
6531
  project_id: "",
6500
6532
  };
6533
+ this.source = 'workbench';
6501
6534
  }
6502
6535
  initProject(json, project_id) {
6503
6536
  var _a;
@@ -6544,7 +6577,7 @@ class ThunderToApipost {
6544
6577
  }
6545
6578
  // auth
6546
6579
  completionApiRequestAuth(auth) {
6547
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
6580
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
6548
6581
  const customAuth = {};
6549
6582
  if ((auth === null || auth === void 0 ? void 0 : auth.type) === "bearer") {
6550
6583
  customAuth["type"] = "bearer";
@@ -6582,22 +6615,33 @@ class ThunderToApipost {
6582
6615
  }
6583
6616
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
6584
6617
  customAuth["type"] = "oauth2";
6618
+ const getGrantType = (thunder_grant_type) => {
6619
+ if (THUNDER_CLIENT_GRANT_TYPES[thunder_grant_type]) {
6620
+ return THUNDER_CLIENT_GRANT_TYPES[thunder_grant_type];
6621
+ }
6622
+ else if (this.source === 'vscode') {
6623
+ return 'password_credentials';
6624
+ }
6625
+ else {
6626
+ return 'authorization_code';
6627
+ }
6628
+ };
6585
6629
  customAuth["oauth2"] = {
6586
6630
  addTokenTo: "header",
6587
6631
  headerPrefix: "Bearer",
6588
6632
  access_token: "",
6589
- grant_type: THUNDER_CLIENT_GRANT_TYPES[(_m = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _m === void 0 ? void 0 : _m.grantType] ? THUNDER_CLIENT_GRANT_TYPES[(_o = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _o === void 0 ? void 0 : _o.grantType] : "authorization_code",
6590
- redirect_uri: ((_p = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _p === void 0 ? void 0 : _p.callbackUrl) || "",
6591
- authUrl: ((_q = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _q === void 0 ? void 0 : _q.authUrl) || "",
6592
- accessTokenUrl: ((_r = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _r === void 0 ? void 0 : _r.tokenUrl) || "",
6593
- clientId: ((_s = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _s === void 0 ? void 0 : _s.clientId) || "",
6594
- clientSecret: ((_t = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _t === void 0 ? void 0 : _t.clientSecret) || "",
6595
- username: ((_u = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _u === void 0 ? void 0 : _u.username) || "",
6596
- password: ((_v = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _v === void 0 ? void 0 : _v.password) || "",
6633
+ grant_type: getGrantType((_m = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _m === void 0 ? void 0 : _m.grantType),
6634
+ redirect_uri: ((_o = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _o === void 0 ? void 0 : _o.callbackUrl) || "",
6635
+ authUrl: ((_p = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _p === void 0 ? void 0 : _p.authUrl) || "",
6636
+ accessTokenUrl: ((_q = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _q === void 0 ? void 0 : _q.tokenUrl) || "",
6637
+ clientId: ((_r = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _r === void 0 ? void 0 : _r.clientId) || "",
6638
+ clientSecret: ((_s = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _s === void 0 ? void 0 : _s.clientSecret) || "",
6639
+ username: ((_t = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _t === void 0 ? void 0 : _t.username) || "",
6640
+ password: ((_u = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _u === void 0 ? void 0 : _u.password) || "",
6597
6641
  challengeAlgorithm: "S256",
6598
6642
  code_verifier: "Bearer",
6599
- scope: ((_w = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _w === void 0 ? void 0 : _w.scope) || "",
6600
- state: ((_x = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _x === void 0 ? void 0 : _x.state) || "",
6643
+ scope: ((_v = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _v === void 0 ? void 0 : _v.scope) || "",
6644
+ state: ((_w = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _w === void 0 ? void 0 : _w.state) || "",
6601
6645
  client_authentication: "header",
6602
6646
  refreshTokenUrl: "",
6603
6647
  authRequestParams: [],
@@ -7023,9 +7067,10 @@ class ThunderToApipost {
7023
7067
  return throwResult$1("error", "Must contain a ThunderJson field", {});
7024
7068
  }
7025
7069
  }
7026
- convert(json, project_id) {
7070
+ convert(json, project_id, option) {
7027
7071
  this.clear();
7028
7072
  try {
7073
+ this.source = (option === null || option === void 0 ? void 0 : option.source) || 'vscode';
7029
7074
  this.initProject(json, project_id);
7030
7075
  this.initGlobal(json === null || json === void 0 ? void 0 : json.settings);
7031
7076
  const folders = lodash.map(json === null || json === void 0 ? void 0 : json.folders, (it) => (Object.assign(Object.assign({}, it), { type: "folder" })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [