echoapi-converter 0.0.26 → 0.0.28

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
@@ -117,6 +117,7 @@ declare class ApifoxToApipost {
117
117
  private completionApiFolder;
118
118
  private completionApiTargetMark;
119
119
  private completionApiResponse;
120
+ private completionGraphqlRequestBody;
120
121
  private completionApiTarget;
121
122
  private completionApiSample;
122
123
  private completionApis;
@@ -182,8 +183,12 @@ declare class InsomniaToApipost {
182
183
  private completionParameter;
183
184
  private completionApiRequestBody;
184
185
  private completionApiRequest;
186
+ private completionWs2Message;
185
187
  private completionWsRequest;
186
188
  private completionWsTarget;
189
+ private getGraphQLQuery;
190
+ private completionGraphqlRequestBody;
191
+ private completionGraphqlTarget;
187
192
  private completionApiTarget;
188
193
  private getEnvVarList;
189
194
  private completionApis;
@@ -204,6 +209,7 @@ declare class PostmanToApipost {
204
209
  private completionApiRequestAuth;
205
210
  private completionApiRequestParameter;
206
211
  private completionApiRequestBody;
212
+ private completionGraphqlRequest;
207
213
  private completionApiRequest;
208
214
  private completionApiFolder;
209
215
  private completionApiTarget;
package/dist/index.js CHANGED
@@ -74,6 +74,28 @@ const DEFAULT_AUTH = {
74
74
  token: "",
75
75
  disableHeaderEncoding: false,
76
76
  },
77
+ oauth2: {
78
+ addTokenTo: 'header',
79
+ headerPrefix: 'Bearer',
80
+ access_token: '',
81
+ grant_type: 'authorization_code',
82
+ redirect_uri: '',
83
+ authUrl: '',
84
+ accessTokenUrl: '',
85
+ clientId: '',
86
+ clientSecret: '',
87
+ username: '',
88
+ password: '',
89
+ challengeAlgorithm: 'S256',
90
+ code_verifier: 'Bearer',
91
+ scope: '',
92
+ state: '',
93
+ client_authentication: 'header',
94
+ refreshTokenUrl: '',
95
+ authRequestParams: [],
96
+ tokenRequestParams: [],
97
+ refreshRequestParams: [],
98
+ },
77
99
  hawk: {
78
100
  authId: "",
79
101
  authKey: "",
@@ -210,6 +232,24 @@ const ASSERT_COMPARE_TYPES_MAP_THUNDER = {
210
232
  ">=": "gte",
211
233
  setto: "setto",
212
234
  };
235
+ // 请求方式
236
+ const API_METHODS = [
237
+ 'POST',
238
+ 'GET',
239
+ 'PUT',
240
+ 'PATCH',
241
+ 'DELETE',
242
+ 'COPY',
243
+ 'HEAD',
244
+ 'OPTIONS',
245
+ 'LINK',
246
+ 'UNLINK',
247
+ 'PURGE',
248
+ 'LOCK',
249
+ 'UNLOCK',
250
+ 'PROPFIND',
251
+ 'VIEW',
252
+ ];
213
253
 
214
254
  // @ts-nocheck
215
255
  const splicedPath = (name, version) => {
@@ -691,6 +731,14 @@ const anyToString = (desc) => {
691
731
  }
692
732
  return String(desc);
693
733
  };
734
+ const completionMethod = (method) => {
735
+ if (!method || !lodash.isString(method))
736
+ return 'GET';
737
+ if (API_METHODS.includes(method === null || method === void 0 ? void 0 : method.toUpperCase())) {
738
+ return method === null || method === void 0 ? void 0 : method.toUpperCase();
739
+ }
740
+ return method;
741
+ };
694
742
 
695
743
  // @ts-nocheck
696
744
  class ApipostToSwagger {
@@ -1488,8 +1536,8 @@ class SwaggerToApipost {
1488
1536
  }
1489
1537
  }
1490
1538
  handlePathV3(path, pathItem, tags) {
1539
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1491
1540
  return __awaiter(this, void 0, void 0, function* () {
1492
- var _a, _b, _c, _d, _e, _f, _g, _h;
1493
1541
  let url = path;
1494
1542
  for (const method in pathItem) {
1495
1543
  const swaggerApi = pathItem[method];
@@ -1906,8 +1954,8 @@ class SwaggerToApipost {
1906
1954
  });
1907
1955
  }
1908
1956
  handlePathsV3(json) {
1957
+ var _a, _b;
1909
1958
  return __awaiter(this, void 0, void 0, function* () {
1910
- var _a, _b;
1911
1959
  try {
1912
1960
  const paths = ((_a = json === null || json === void 0 ? void 0 : json.openapi) === null || _a === void 0 ? void 0 : _a.paths) || json.paths;
1913
1961
  const tags = ((_b = json === null || json === void 0 ? void 0 : json.openapi) === null || _b === void 0 ? void 0 : _b.tags) || json.tags;
@@ -1939,8 +1987,8 @@ class SwaggerToApipost {
1939
1987
  }
1940
1988
  }
1941
1989
  handlePath(path, pathItem, tags) {
1990
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1942
1991
  return __awaiter(this, void 0, void 0, function* () {
1943
- var _a, _b, _c, _d, _e, _f, _g, _h;
1944
1992
  let url = path;
1945
1993
  url = decodeURI(this.basePath + url);
1946
1994
  url = fixUrlPath(url);
@@ -2347,8 +2395,8 @@ class SwaggerToApipost {
2347
2395
  catch (err) { }
2348
2396
  });
2349
2397
  }
2350
- convert(json_1) {
2351
- return __awaiter(this, arguments, void 0, function* (json, options = null) {
2398
+ convert(json, options = null) {
2399
+ return __awaiter(this, void 0, void 0, function* () {
2352
2400
  this.clear();
2353
2401
  try {
2354
2402
  if (options && options instanceof Object) {
@@ -2729,7 +2777,7 @@ class ApidocToApipost {
2729
2777
  }
2730
2778
 
2731
2779
  // @ts-nocheck
2732
- const throwResult = (status, message, data) => {
2780
+ const throwResult = (status, message, data = "") => {
2733
2781
  return {
2734
2782
  status,
2735
2783
  message,
@@ -3222,7 +3270,7 @@ class ApifoxToApipost {
3222
3270
  return [];
3223
3271
  }
3224
3272
  completionApiRequestAuth(auth) {
3225
- 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;
3273
+ 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;
3226
3274
  const customAuth = {};
3227
3275
  if ((auth === null || auth === void 0 ? void 0 : auth.type) === "apikey") {
3228
3276
  customAuth["type"] = "kv";
@@ -3282,65 +3330,90 @@ class ApifoxToApipost {
3282
3330
  : false,
3283
3331
  };
3284
3332
  }
3333
+ else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
3334
+ customAuth["type"] = "oauth2";
3335
+ customAuth["oauth2"] = {
3336
+ addTokenTo: ((_7 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _7 === void 0 ? void 0 : _7.addTokenTo) || 'header',
3337
+ headerPrefix: ((_8 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _8 === void 0 ? void 0 : _8.headerPrefix) || 'Bearer',
3338
+ access_token: '',
3339
+ grant_type: 'authorization_code',
3340
+ redirect_uri: ((_9 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _9 === void 0 ? void 0 : _9.redirect_uri) || '',
3341
+ authUrl: ((_10 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _10 === void 0 ? void 0 : _10.authUrl) || '',
3342
+ accessTokenUrl: ((_11 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _11 === void 0 ? void 0 : _11.accessTokenUrl) || '',
3343
+ clientId: ((_12 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _12 === void 0 ? void 0 : _12.clientId) || '',
3344
+ clientSecret: ((_13 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _13 === void 0 ? void 0 : _13.clientSecret) || '',
3345
+ username: '',
3346
+ password: '',
3347
+ challengeAlgorithm: 'S256',
3348
+ code_verifier: 'Bearer',
3349
+ scope: ((_14 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _14 === void 0 ? void 0 : _14.scope) || '',
3350
+ state: ((_15 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _15 === void 0 ? void 0 : _15.state) || '',
3351
+ client_authentication: ((_16 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _16 === void 0 ? void 0 : _16.client_authentication) || 'header',
3352
+ refreshTokenUrl: '',
3353
+ authRequestParams: [],
3354
+ tokenRequestParams: [],
3355
+ refreshRequestParams: [],
3356
+ };
3357
+ }
3285
3358
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
3286
3359
  customAuth["type"] = "hawk";
3287
3360
  customAuth["hawk"] = {
3288
- authId: ((_7 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _7 === void 0 ? void 0 : _7.authId) || "",
3289
- authKey: ((_8 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _8 === void 0 ? void 0 : _8.authKey) || "",
3290
- algorithm: ((_9 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _9 === void 0 ? void 0 : _9.algorithm) || "",
3291
- user: ((_10 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _10 === void 0 ? void 0 : _10.user) || "",
3292
- nonce: ((_11 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _11 === void 0 ? void 0 : _11.nonce) || "",
3293
- extraData: ((_12 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _12 === void 0 ? void 0 : _12.extraData) || "",
3294
- app: ((_13 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _13 === void 0 ? void 0 : _13.app) || "",
3295
- delegation: ((_14 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _14 === void 0 ? void 0 : _14.delegation) || "",
3296
- timestamp: ((_15 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _15 === void 0 ? void 0 : _15.timestamp) || "",
3297
- includePayloadHash: ((_16 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _16 === void 0 ? void 0 : _16.includePayloadHash) ? true : false,
3361
+ authId: ((_17 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _17 === void 0 ? void 0 : _17.authId) || "",
3362
+ authKey: ((_18 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _18 === void 0 ? void 0 : _18.authKey) || "",
3363
+ algorithm: ((_19 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _19 === void 0 ? void 0 : _19.algorithm) || "",
3364
+ user: ((_20 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _20 === void 0 ? void 0 : _20.user) || "",
3365
+ nonce: ((_21 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _21 === void 0 ? void 0 : _21.nonce) || "",
3366
+ extraData: ((_22 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _22 === void 0 ? void 0 : _22.extraData) || "",
3367
+ app: ((_23 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _23 === void 0 ? void 0 : _23.app) || "",
3368
+ delegation: ((_24 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _24 === void 0 ? void 0 : _24.delegation) || "",
3369
+ timestamp: ((_25 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _25 === void 0 ? void 0 : _25.timestamp) || "",
3370
+ includePayloadHash: ((_26 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _26 === void 0 ? void 0 : _26.includePayloadHash) ? true : false,
3298
3371
  };
3299
3372
  }
3300
3373
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "awsv4") {
3301
3374
  customAuth["type"] = "awsv4";
3302
3375
  customAuth["awsv4"] = {
3303
- accessKey: ((_17 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _17 === void 0 ? void 0 : _17.accessKey) || "",
3304
- secretKey: ((_18 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _18 === void 0 ? void 0 : _18.secretKey) || "",
3305
- region: ((_19 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _19 === void 0 ? void 0 : _19.region) || "",
3306
- service: ((_20 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _20 === void 0 ? void 0 : _20.service) || "",
3307
- sessionToken: ((_21 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _21 === void 0 ? void 0 : _21.sessionToken) || "",
3308
- addAuthDataToQuery: ((_22 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _22 === void 0 ? void 0 : _22.addAuthDataToQuery) ? true : false,
3376
+ accessKey: ((_27 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _27 === void 0 ? void 0 : _27.accessKey) || "",
3377
+ secretKey: ((_28 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _28 === void 0 ? void 0 : _28.secretKey) || "",
3378
+ region: ((_29 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _29 === void 0 ? void 0 : _29.region) || "",
3379
+ service: ((_30 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _30 === void 0 ? void 0 : _30.service) || "",
3380
+ sessionToken: ((_31 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _31 === void 0 ? void 0 : _31.sessionToken) || "",
3381
+ addAuthDataToQuery: ((_32 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _32 === void 0 ? void 0 : _32.addAuthDataToQuery) ? true : false,
3309
3382
  };
3310
3383
  }
3311
3384
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "ntlm") {
3312
3385
  customAuth["type"] = "ntlm";
3313
3386
  customAuth["ntlm"] = {
3314
- username: ((_23 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _23 === void 0 ? void 0 : _23.username) || "",
3315
- password: ((_24 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _24 === void 0 ? void 0 : _24.password) || "",
3316
- domain: ((_25 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _25 === void 0 ? void 0 : _25.domain) || "",
3317
- workstation: ((_26 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _26 === void 0 ? void 0 : _26.workstation) || "",
3318
- disableRetryRequest: ((_27 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _27 === void 0 ? void 0 : _27.disableRetryRequest) ? true : false,
3387
+ username: ((_33 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _33 === void 0 ? void 0 : _33.username) || "",
3388
+ password: ((_34 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _34 === void 0 ? void 0 : _34.password) || "",
3389
+ domain: ((_35 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _35 === void 0 ? void 0 : _35.domain) || "",
3390
+ workstation: ((_36 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _36 === void 0 ? void 0 : _36.workstation) || "",
3391
+ disableRetryRequest: ((_37 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _37 === void 0 ? void 0 : _37.disableRetryRequest) ? true : false,
3319
3392
  };
3320
3393
  }
3321
3394
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "edgegrid") {
3322
3395
  customAuth["type"] = "edgegrid";
3323
3396
  customAuth["edgegrid"] = {
3324
- accessToken: ((_28 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _28 === void 0 ? void 0 : _28.accessToken) || "",
3325
- clientToken: ((_29 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _29 === void 0 ? void 0 : _29.clientToken) || "",
3326
- clientSecret: ((_30 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _30 === void 0 ? void 0 : _30.clientSecret) || "",
3327
- nonce: ((_31 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _31 === void 0 ? void 0 : _31.nonce) || "",
3328
- timestamp: ((_32 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _32 === void 0 ? void 0 : _32.timestamp) || "",
3329
- baseURi: ((_33 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _33 === void 0 ? void 0 : _33.baseURL) || "",
3330
- headersToSign: ((_34 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _34 === void 0 ? void 0 : _34.headersToSign) || "",
3397
+ accessToken: ((_38 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _38 === void 0 ? void 0 : _38.accessToken) || "",
3398
+ clientToken: ((_39 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _39 === void 0 ? void 0 : _39.clientToken) || "",
3399
+ clientSecret: ((_40 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _40 === void 0 ? void 0 : _40.clientSecret) || "",
3400
+ nonce: ((_41 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _41 === void 0 ? void 0 : _41.nonce) || "",
3401
+ timestamp: ((_42 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _42 === void 0 ? void 0 : _42.timestamp) || "",
3402
+ baseURi: ((_43 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _43 === void 0 ? void 0 : _43.baseURL) || "",
3403
+ headersToSign: ((_44 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _44 === void 0 ? void 0 : _44.headersToSign) || "",
3331
3404
  };
3332
3405
  }
3333
3406
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "jwt") {
3334
3407
  customAuth["type"] = "jwt";
3335
3408
  customAuth["jwt"] = {
3336
- addTokenTo: ((_35 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _35 === void 0 ? void 0 : _35.auth) || "header",
3337
- algorithm: ((_36 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _36 === void 0 ? void 0 : _36.algorithm) || "HS256",
3338
- secret: ((_37 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _37 === void 0 ? void 0 : _37.secret) || "",
3339
- isSecretBase64Encoded: ((_38 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _38 === void 0 ? void 0 : _38.isSecretBase64Encoded) ? true : false,
3340
- payload: ((_39 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _39 === void 0 ? void 0 : _39.payload) || "",
3341
- headerPrefix: ((_40 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _40 === void 0 ? void 0 : _40.headerPrefix) || "Bearer",
3342
- queryParamKey: ((_41 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _41 === void 0 ? void 0 : _41.queryParamKey) || "token",
3343
- header: ((_42 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _42 === void 0 ? void 0 : _42.header) || "",
3409
+ addTokenTo: ((_45 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _45 === void 0 ? void 0 : _45.auth) || "header",
3410
+ algorithm: ((_46 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _46 === void 0 ? void 0 : _46.algorithm) || "HS256",
3411
+ secret: ((_47 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _47 === void 0 ? void 0 : _47.secret) || "",
3412
+ isSecretBase64Encoded: ((_48 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _48 === void 0 ? void 0 : _48.isSecretBase64Encoded) ? true : false,
3413
+ payload: ((_49 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _49 === void 0 ? void 0 : _49.payload) || "",
3414
+ headerPrefix: ((_50 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _50 === void 0 ? void 0 : _50.headerPrefix) || "Bearer",
3415
+ queryParamKey: ((_51 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _51 === void 0 ? void 0 : _51.queryParamKey) || "token",
3416
+ header: ((_52 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _52 === void 0 ? void 0 : _52.header) || "",
3344
3417
  };
3345
3418
  }
3346
3419
  return Object.assign(Object.assign({}, DEFAULT_AUTH), customAuth);
@@ -3514,10 +3587,27 @@ class ApifoxToApipost {
3514
3587
  example,
3515
3588
  };
3516
3589
  }
3590
+ completionGraphqlRequestBody(requestBody) {
3591
+ var _a, _b, _c, _d;
3592
+ return {
3593
+ query_schema: {},
3594
+ query_list: [{
3595
+ param_id: ATools.snowflakeId(),
3596
+ name: 'New Query',
3597
+ 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 : '',
3598
+ 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 : '',
3599
+ }],
3600
+ };
3601
+ }
3517
3602
  completionApiTarget(item, baseInfo, parentInfo) {
3518
- var _a;
3603
+ var _a, _b;
3519
3604
  const { api } = item || {};
3520
- 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 });
3605
+ if (((_a = api === null || api === void 0 ? void 0 : api.requestBody) === null || _a === void 0 ? void 0 : _a.type) === 'graphql') {
3606
+ const 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);
3607
+ const body = this.completionGraphqlRequestBody(api === null || api === void 0 ? void 0 : api.requestBody);
3608
+ return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0", target_type: "graphql", name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL", version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || "", url: (api === null || api === void 0 ? void 0 : api.path) || "", mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), request: Object.assign(Object.assign({}, lodash.omit(request, ['body', 'query', 'restful'])), { body }), 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 });
3609
+ }
3610
+ 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) ? (_b = api === null || api === void 0 ? void 0 : api.method) === null || _b === void 0 ? void 0 : _b.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 });
3521
3611
  }
3522
3612
  completionApiSample(item, baseInfo) {
3523
3613
  const { api } = item || {};
@@ -4164,6 +4254,10 @@ class InsomniaToApipost {
4164
4254
  ? true
4165
4255
  : false, includeBodyHash: (authentication === null || authentication === void 0 ? void 0 : authentication.includeBodyHash) ? true : false, addParamsToHeader: (authentication === null || authentication === void 0 ? void 0 : authentication.addParamsToHeader) || 0, realm: (authentication === null || authentication === void 0 ? void 0 : authentication.realm) || "", version: (authentication === null || authentication === void 0 ? void 0 : authentication.version) || "", nonce: (authentication === null || authentication === void 0 ? void 0 : authentication.nonce) || "", verifier: (authentication === null || authentication === void 0 ? void 0 : authentication.verifier) || "", timestamp: (authentication === null || authentication === void 0 ? void 0 : authentication.timestamp) || "", callback: (authentication === null || authentication === void 0 ? void 0 : authentication.callback) || "", tokenSecret: (authentication === null || authentication === void 0 ? void 0 : authentication.tokenSecret) || "", token: (authentication === null || authentication === void 0 ? void 0 : authentication.token) || "" });
4166
4256
  }
4257
+ else if ((authentication === null || authentication === void 0 ? void 0 : authentication.type) === "oauth2") {
4258
+ request.auth["type"] = "oauth2";
4259
+ request.auth["oauth2"] = Object.assign(Object.assign({}, request.auth.oauth2), { addTokenTo: (authentication === null || authentication === void 0 ? void 0 : authentication.addTokenTo) || 'header', headerPrefix: (authentication === null || authentication === void 0 ? void 0 : authentication.tokenPrefix) || 'Bearer', access_token: '', grant_type: 'authorization_code', redirect_uri: (authentication === null || authentication === void 0 ? void 0 : authentication.redirectUrl) || '', authUrl: (authentication === null || authentication === void 0 ? void 0 : authentication.authorizationUrl) || '', accessTokenUrl: (authentication === null || authentication === void 0 ? void 0 : authentication.accessTokenUrl) || '', clientId: (authentication === null || authentication === void 0 ? void 0 : authentication.clientId) || '', clientSecret: (authentication === null || authentication === void 0 ? void 0 : authentication.clientSecret) || '', username: '', password: '', challengeAlgorithm: 'S256', code_verifier: 'Bearer', scope: '', state: '', client_authentication: 'header', refreshTokenUrl: '', authRequestParams: [], tokenRequestParams: [], refreshRequestParams: [] });
4260
+ }
4167
4261
  else if ((authentication === null || authentication === void 0 ? void 0 : authentication.type) === "ntlm") {
4168
4262
  request.auth["type"] = "ntlm";
4169
4263
  request.auth["ntlm"] = Object.assign(Object.assign({}, request.auth.ntlm), { username: (authentication === null || authentication === void 0 ? void 0 : authentication.username) || "", password: (authentication === null || authentication === void 0 ? void 0 : authentication.username) || "" });
@@ -4196,7 +4290,7 @@ class InsomniaToApipost {
4196
4290
  parameter: genRestfulByUrl((item === null || item === void 0 ? void 0 : item.url) || "", item === null || item === void 0 ? void 0 : item.pathParameters, "name"),
4197
4291
  } }, request);
4198
4292
  }
4199
- completionWsRequest(item, resources) {
4293
+ completionWs2Message(item, resources) {
4200
4294
  const messagePayload = resources === null || resources === void 0 ? void 0 : resources.find((e) => (e === null || e === void 0 ? void 0 : e._type) === "websocket_payload" && (e === null || e === void 0 ? void 0 : e.parentId) === (item === null || item === void 0 ? void 0 : item._id));
4201
4295
  const message = {
4202
4296
  mode: (messagePayload === null || messagePayload === void 0 ? void 0 : messagePayload.mode) === "text/plain"
@@ -4208,6 +4302,32 @@ class InsomniaToApipost {
4208
4302
  raw_parameter: [],
4209
4303
  raw_schema: { type: "object" },
4210
4304
  };
4305
+ return [
4306
+ {
4307
+ name: 'Message',
4308
+ param_id: ATools.snowflakeId(),
4309
+ request: message,
4310
+ response: {
4311
+ mode: 'text',
4312
+ raw: '',
4313
+ raw_parameter: [],
4314
+ raw_schema: { type: 'object' },
4315
+ },
4316
+ }
4317
+ ];
4318
+ }
4319
+ completionWsRequest(item, resources) {
4320
+ const messagePayload = resources === null || resources === void 0 ? void 0 : resources.find((e) => (e === null || e === void 0 ? void 0 : e._type) === "websocket_payload" && (e === null || e === void 0 ? void 0 : e.parentId) === (item === null || item === void 0 ? void 0 : item._id));
4321
+ ({
4322
+ mode: (messagePayload === null || messagePayload === void 0 ? void 0 : messagePayload.mode) === "text/plain"
4323
+ ? "text"
4324
+ : (messagePayload === null || messagePayload === void 0 ? void 0 : messagePayload.mode) === "application/json"
4325
+ ? "json"
4326
+ : "text",
4327
+ raw: (messagePayload === null || messagePayload === void 0 ? void 0 : messagePayload.value) || "",
4328
+ raw_parameter: [],
4329
+ raw_schema: { type: "object" },
4330
+ });
4211
4331
  return {
4212
4332
  header: {
4213
4333
  parameter: this.completionParameter(item === null || item === void 0 ? void 0 : item.headers),
@@ -4215,7 +4335,9 @@ class InsomniaToApipost {
4215
4335
  query: {
4216
4336
  parameter: this.completionParameter(item === null || item === void 0 ? void 0 : item.parameters),
4217
4337
  },
4218
- message,
4338
+ cookie: {
4339
+ parameter: []
4340
+ },
4219
4341
  };
4220
4342
  }
4221
4343
  completionWsTarget(item, resources) {
@@ -4224,7 +4346,7 @@ class InsomniaToApipost {
4224
4346
  project_id: this.project.project_id || "",
4225
4347
  target_id: ATools.snowflakeId(),
4226
4348
  parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4227
- target_type: "websocket",
4349
+ target_type: "websocket2",
4228
4350
  name: (item === null || item === void 0 ? void 0 : item.name) || "New Websocket",
4229
4351
  sort: 0,
4230
4352
  version: 0,
@@ -4233,23 +4355,103 @@ class InsomniaToApipost {
4233
4355
  status: 1,
4234
4356
  is_changed: -1,
4235
4357
  is_create: 1,
4236
- method: "Raw",
4237
- request: Object.assign({ event: {
4238
- parameter: [],
4239
- } }, this.completionWsRequest(item, resources)),
4358
+ method: "",
4359
+ request: Object.assign({}, this.completionWsRequest(item, resources)),
4360
+ message: this.completionWs2Message(item, resources),
4240
4361
  url: (item === null || item === void 0 ? void 0 : item.url) || "",
4241
4362
  config: {
4363
+ certificate_verification: -1,
4242
4364
  information_size: 5,
4243
4365
  reconnect_num: 5,
4244
4366
  reconnect_time: 5000,
4245
- shake_hands_path: "",
4246
4367
  shake_hands_timeout: 0,
4247
- socket_version: "v4",
4248
4368
  },
4249
4369
  };
4250
4370
  }
4371
+ getGraphQLQuery(body) {
4372
+ try {
4373
+ const { query = '', variables = '' } = JSON.parse(body);
4374
+ return {
4375
+ query,
4376
+ variables
4377
+ };
4378
+ }
4379
+ catch (err) {
4380
+ return {
4381
+ query: '',
4382
+ variables: ''
4383
+ };
4384
+ }
4385
+ }
4386
+ ;
4387
+ completionGraphqlRequestBody(body) {
4388
+ return {
4389
+ query_schema: {},
4390
+ query_list: [Object.assign({ param_id: ATools.snowflakeId(), name: 'New Query' }, this.getGraphQLQuery(body))],
4391
+ };
4392
+ }
4393
+ completionGraphqlTarget(item) {
4394
+ var _a;
4395
+ const request = this.completionApiRequest(item);
4396
+ const body = this.completionGraphqlRequestBody(item === null || item === void 0 ? void 0 : item.body);
4397
+ return {
4398
+ target_id: ATools.snowflakeId(),
4399
+ project_id: this.project.project_id || "",
4400
+ parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
4401
+ target_type: "graphql",
4402
+ name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL",
4403
+ version: 0,
4404
+ sort: 0,
4405
+ description: (item === null || item === void 0 ? void 0 : item.description) || "",
4406
+ url: (item === null || item === void 0 ? void 0 : item.url) || "",
4407
+ mark_id: "1",
4408
+ request: Object.assign(Object.assign({}, lodash.omit(request, ['body', 'query', 'restful'])), { body }),
4409
+ response: {
4410
+ is_check_result: 1,
4411
+ example: [
4412
+ {
4413
+ example_id: "1",
4414
+ expect: {
4415
+ code: "200",
4416
+ content_type: "json",
4417
+ is_default: 1,
4418
+ mock: "",
4419
+ name: "Success",
4420
+ schema: {
4421
+ type: "object",
4422
+ properties: {},
4423
+ },
4424
+ verify_type: "schema",
4425
+ },
4426
+ raw: "",
4427
+ raw_parameter: [],
4428
+ },
4429
+ {
4430
+ example_id: "2",
4431
+ expect: {
4432
+ code: "404",
4433
+ content_type: "json",
4434
+ is_default: -1,
4435
+ mock: "",
4436
+ name: "Failed",
4437
+ schema: {
4438
+ type: "object",
4439
+ properties: {},
4440
+ },
4441
+ verify_type: "schema",
4442
+ },
4443
+ raw: "",
4444
+ raw_parameter: [],
4445
+ },
4446
+ ],
4447
+ },
4448
+ attribute_info: {},
4449
+ tags: [],
4450
+ is_force: -1,
4451
+ };
4452
+ }
4251
4453
  completionApiTarget(item) {
4252
- var _a, _b;
4454
+ var _a;
4253
4455
  return {
4254
4456
  target_id: ATools.snowflakeId(),
4255
4457
  project_id: this.project.project_id || "",
@@ -4259,7 +4461,7 @@ class InsomniaToApipost {
4259
4461
  version: 0,
4260
4462
  sort: 0,
4261
4463
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4262
- method: (item === null || item === void 0 ? void 0 : item.method) ? (_b = item === null || item === void 0 ? void 0 : item.method) === null || _b === void 0 ? void 0 : _b.toUpperCase() : "GET",
4464
+ method: completionMethod(item === null || item === void 0 ? void 0 : item.method),
4263
4465
  url: (item === null || item === void 0 ? void 0 : item.url) || "",
4264
4466
  mark_id: "1",
4265
4467
  protocol: "http/1.1",
@@ -4342,8 +4544,14 @@ class InsomniaToApipost {
4342
4544
  });
4343
4545
  }
4344
4546
  if ((item === null || item === void 0 ? void 0 : item._type) === "request") {
4345
- const target = this.completionApiTarget(item);
4346
- pre.push(target);
4547
+ if ((item === null || item === void 0 ? void 0 : item.body) === 'application/graphql') {
4548
+ const target = this.completionGraphqlTarget(item);
4549
+ pre.push(target);
4550
+ }
4551
+ else {
4552
+ const target = this.completionApiTarget(item);
4553
+ pre.push(target);
4554
+ }
4347
4555
  }
4348
4556
  if ((item === null || item === void 0 ? void 0 : item._type) === "websocket_request") {
4349
4557
  const wsTarget = this.completionWsTarget(item, resources);
@@ -4429,7 +4637,7 @@ class PostmanToApipost {
4429
4637
  };
4430
4638
  }
4431
4639
  completionApiRequestAuth(auth) {
4432
- var _a, _b, _c, _d;
4640
+ var _a, _b, _c, _d, _e, _f, _g;
4433
4641
  // 后期会修改结构
4434
4642
  const customAuth = {};
4435
4643
  if (auth && lodash.has(auth, "type")) {
@@ -4490,6 +4698,31 @@ class PostmanToApipost {
4490
4698
  disableHeaderEncoding: (authMap === null || authMap === void 0 ? void 0 : authMap.disableHeaderEncoding) ? true : false,
4491
4699
  };
4492
4700
  }
4701
+ else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
4702
+ customAuth["type"] = "oauth2";
4703
+ customAuth["oauth2"] = {
4704
+ addTokenTo: (authMap === null || authMap === void 0 ? void 0 : authMap.addTokenTo) || 'header',
4705
+ headerPrefix: (authMap === null || authMap === void 0 ? void 0 : authMap.headerPrefix) || 'Bearer',
4706
+ access_token: '',
4707
+ grant_type: 'authorization_code',
4708
+ redirect_uri: (authMap === null || authMap === void 0 ? void 0 : authMap.redirect_uri) || '',
4709
+ authUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.authUrl) || '',
4710
+ accessTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.accessTokenUrl) || '',
4711
+ clientId: (authMap === null || authMap === void 0 ? void 0 : authMap.clientId) || '',
4712
+ clientSecret: (authMap === null || authMap === void 0 ? void 0 : authMap.clientSecret) || '',
4713
+ username: (authMap === null || authMap === void 0 ? void 0 : authMap.username) || '',
4714
+ password: (authMap === null || authMap === void 0 ? void 0 : authMap.password) || '',
4715
+ challengeAlgorithm: (authMap === null || authMap === void 0 ? void 0 : authMap.challengeAlgorithm) || 'S256',
4716
+ code_verifier: (authMap === null || authMap === void 0 ? void 0 : authMap.code_verifier) || 'Bearer',
4717
+ scope: (authMap === null || authMap === void 0 ? void 0 : authMap.scope) || '',
4718
+ state: (authMap === null || authMap === void 0 ? void 0 : authMap.state) || '',
4719
+ client_authentication: (authMap === null || authMap === void 0 ? void 0 : authMap.client_authentication) || 'header',
4720
+ refreshTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.refreshTokenUrl) || '',
4721
+ 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() }))) : [],
4722
+ 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() }))) : [],
4723
+ 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() }))) : [],
4724
+ };
4725
+ }
4493
4726
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
4494
4727
  customAuth["type"] = "hawk";
4495
4728
  customAuth["hawk"] = {
@@ -4622,6 +4855,58 @@ class PostmanToApipost {
4622
4855
  properties: {},
4623
4856
  }, binary: {} }, params);
4624
4857
  }
4858
+ completionGraphqlRequest(item, { request, auth }) {
4859
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4860
+ const prerequest = (_a = item === null || item === void 0 ? void 0 : item.event) === null || _a === void 0 ? void 0 : _a.find((e) => (e === null || e === void 0 ? void 0 : e.listen) === "prerequest");
4861
+ const test = (_b = item === null || item === void 0 ? void 0 : item.event) === null || _b === void 0 ? void 0 : _b.find((e) => (e === null || e === void 0 ? void 0 : e.listen) === "test");
4862
+ const pre_tasks = prerequest
4863
+ ? [
4864
+ {
4865
+ type: "customScript",
4866
+ enabled: 1,
4867
+ name: "Custom Script",
4868
+ id: ATools.snowflakeId(),
4869
+ data: isArray((_c = prerequest === null || prerequest === void 0 ? void 0 : prerequest.script) === null || _c === void 0 ? void 0 : _c.exec)
4870
+ ? (_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")
4871
+ : "",
4872
+ },
4873
+ ]
4874
+ : [];
4875
+ const post_tasks = test
4876
+ ? [
4877
+ {
4878
+ type: "customScript",
4879
+ enabled: 1,
4880
+ name: "Custom Script",
4881
+ id: ATools.snowflakeId(),
4882
+ data: isArray((_f = test === null || test === void 0 ? void 0 : test.script) === null || _f === void 0 ? void 0 : _f.exec)
4883
+ ? (_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")
4884
+ : "",
4885
+ },
4886
+ ]
4887
+ : [];
4888
+ const headerParameter = this.completionApiRequestParameter(request === null || request === void 0 ? void 0 : request.header);
4889
+ return {
4890
+ auth: this.completionApiRequestAuth(auth),
4891
+ pre_tasks,
4892
+ post_tasks,
4893
+ header: {
4894
+ parameter: headerParameter,
4895
+ },
4896
+ cookie: {
4897
+ parameter: [],
4898
+ },
4899
+ body: {
4900
+ query_schema: {},
4901
+ query_list: [{
4902
+ param_id: ATools.snowflakeId(),
4903
+ name: 'New Query',
4904
+ 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 : '',
4905
+ 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 : '',
4906
+ }],
4907
+ },
4908
+ };
4909
+ }
4625
4910
  completionApiRequest(item, { request, auth }) {
4626
4911
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4627
4912
  const prerequest = (_a = item === null || item === void 0 ? void 0 : item.event) === null || _a === void 0 ? void 0 : _a.find((e) => (e === null || e === void 0 ? void 0 : e.listen) === "prerequest");
@@ -4693,8 +4978,68 @@ class PostmanToApipost {
4693
4978
  };
4694
4979
  }
4695
4980
  completionApiTarget(item, parentInfo) {
4696
- var _a, _b;
4981
+ var _a, _b, _c;
4697
4982
  const { request } = item || {};
4983
+ if (lodash.isEqual((_a = request === null || request === void 0 ? void 0 : request.body) === null || _a === void 0 ? void 0 : _a.mode, 'graphql')) {
4984
+ return {
4985
+ target_id: ATools.snowflakeId(),
4986
+ project_id: this.project.project_id || "",
4987
+ parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
4988
+ target_type: "graphql",
4989
+ name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL",
4990
+ version: 0,
4991
+ sort: 0,
4992
+ description: (item === null || item === void 0 ? void 0 : item.description) || "",
4993
+ url: ((_b = request === null || request === void 0 ? void 0 : request.url) === null || _b === void 0 ? void 0 : _b.raw) || "",
4994
+ mark_id: "1",
4995
+ request: this.completionGraphqlRequest(item, {
4996
+ request,
4997
+ auth: (request === null || request === void 0 ? void 0 : request.auth) || {},
4998
+ }),
4999
+ response: {
5000
+ is_check_result: 1,
5001
+ example: [
5002
+ {
5003
+ example_id: "1",
5004
+ expect: {
5005
+ code: "200",
5006
+ content_type: "json",
5007
+ is_default: 1,
5008
+ mock: "",
5009
+ name: "Success",
5010
+ schema: {
5011
+ type: "object",
5012
+ properties: {},
5013
+ },
5014
+ verify_type: "schema",
5015
+ },
5016
+ raw: "",
5017
+ raw_parameter: [],
5018
+ },
5019
+ {
5020
+ example_id: "2",
5021
+ expect: {
5022
+ code: "404",
5023
+ content_type: "json",
5024
+ is_default: -1,
5025
+ mock: "",
5026
+ name: "Failed",
5027
+ schema: {
5028
+ type: "object",
5029
+ properties: {},
5030
+ },
5031
+ verify_type: "schema",
5032
+ },
5033
+ raw: "",
5034
+ raw_parameter: [],
5035
+ },
5036
+ ],
5037
+ },
5038
+ attribute_info: {},
5039
+ tags: [],
5040
+ is_force: -1,
5041
+ };
5042
+ }
4698
5043
  return {
4699
5044
  target_id: ATools.snowflakeId(),
4700
5045
  project_id: this.project.project_id || "",
@@ -4704,8 +5049,8 @@ class PostmanToApipost {
4704
5049
  version: 0,
4705
5050
  sort: 0,
4706
5051
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
4707
- method: (request === null || request === void 0 ? void 0 : request.method) ? (_a = request === null || request === void 0 ? void 0 : request.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : "GET",
4708
- url: ((_b = request === null || request === void 0 ? void 0 : request.url) === null || _b === void 0 ? void 0 : _b.raw) || "",
5052
+ method: completionMethod(request === null || request === void 0 ? void 0 : request.method),
5053
+ url: ((_c = request === null || request === void 0 ? void 0 : request.url) === null || _c === void 0 ? void 0 : _c.raw) || "",
4709
5054
  mark_id: "1",
4710
5055
  protocol: "http/1.1",
4711
5056
  request: this.completionApiRequest(item, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [