echoapi-converter 0.0.27 → 0.0.29
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 +6 -0
- package/dist/index.js +289 -20
- package/package.json +1 -1
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
|
@@ -232,6 +232,24 @@ const ASSERT_COMPARE_TYPES_MAP_THUNDER = {
|
|
|
232
232
|
">=": "gte",
|
|
233
233
|
setto: "setto",
|
|
234
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
|
+
];
|
|
235
253
|
|
|
236
254
|
// @ts-nocheck
|
|
237
255
|
const splicedPath = (name, version) => {
|
|
@@ -713,6 +731,14 @@ const anyToString = (desc) => {
|
|
|
713
731
|
}
|
|
714
732
|
return String(desc);
|
|
715
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
|
+
};
|
|
716
742
|
|
|
717
743
|
// @ts-nocheck
|
|
718
744
|
class ApipostToSwagger {
|
|
@@ -1528,7 +1554,7 @@ class SwaggerToApipost {
|
|
|
1528
1554
|
target_type: "api",
|
|
1529
1555
|
tags: [],
|
|
1530
1556
|
url: url || "",
|
|
1531
|
-
method: method
|
|
1557
|
+
method: completionMethod(method),
|
|
1532
1558
|
description: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.description) || "",
|
|
1533
1559
|
request: {},
|
|
1534
1560
|
response: {
|
|
@@ -1982,7 +2008,7 @@ class SwaggerToApipost {
|
|
|
1982
2008
|
tags: [],
|
|
1983
2009
|
target_type: "api",
|
|
1984
2010
|
url: url || "",
|
|
1985
|
-
method: method
|
|
2011
|
+
method: completionMethod(method),
|
|
1986
2012
|
description: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.description) || "",
|
|
1987
2013
|
request: {
|
|
1988
2014
|
header: {
|
|
@@ -3561,10 +3587,27 @@ class ApifoxToApipost {
|
|
|
3561
3587
|
example,
|
|
3562
3588
|
};
|
|
3563
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
|
+
}
|
|
3564
3602
|
completionApiTarget(item, baseInfo, parentInfo) {
|
|
3565
|
-
var _a;
|
|
3603
|
+
var _a, _b;
|
|
3566
3604
|
const { api } = item || {};
|
|
3567
|
-
|
|
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 });
|
|
3568
3611
|
}
|
|
3569
3612
|
completionApiSample(item, baseInfo) {
|
|
3570
3613
|
const { api } = item || {};
|
|
@@ -4247,7 +4290,7 @@ class InsomniaToApipost {
|
|
|
4247
4290
|
parameter: genRestfulByUrl((item === null || item === void 0 ? void 0 : item.url) || "", item === null || item === void 0 ? void 0 : item.pathParameters, "name"),
|
|
4248
4291
|
} }, request);
|
|
4249
4292
|
}
|
|
4250
|
-
|
|
4293
|
+
completionWs2Message(item, resources) {
|
|
4251
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));
|
|
4252
4295
|
const message = {
|
|
4253
4296
|
mode: (messagePayload === null || messagePayload === void 0 ? void 0 : messagePayload.mode) === "text/plain"
|
|
@@ -4259,6 +4302,32 @@ class InsomniaToApipost {
|
|
|
4259
4302
|
raw_parameter: [],
|
|
4260
4303
|
raw_schema: { type: "object" },
|
|
4261
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
|
+
});
|
|
4262
4331
|
return {
|
|
4263
4332
|
header: {
|
|
4264
4333
|
parameter: this.completionParameter(item === null || item === void 0 ? void 0 : item.headers),
|
|
@@ -4266,7 +4335,9 @@ class InsomniaToApipost {
|
|
|
4266
4335
|
query: {
|
|
4267
4336
|
parameter: this.completionParameter(item === null || item === void 0 ? void 0 : item.parameters),
|
|
4268
4337
|
},
|
|
4269
|
-
|
|
4338
|
+
cookie: {
|
|
4339
|
+
parameter: []
|
|
4340
|
+
},
|
|
4270
4341
|
};
|
|
4271
4342
|
}
|
|
4272
4343
|
completionWsTarget(item, resources) {
|
|
@@ -4275,7 +4346,7 @@ class InsomniaToApipost {
|
|
|
4275
4346
|
project_id: this.project.project_id || "",
|
|
4276
4347
|
target_id: ATools.snowflakeId(),
|
|
4277
4348
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
|
|
4278
|
-
target_type: "
|
|
4349
|
+
target_type: "websocket2",
|
|
4279
4350
|
name: (item === null || item === void 0 ? void 0 : item.name) || "New Websocket",
|
|
4280
4351
|
sort: 0,
|
|
4281
4352
|
version: 0,
|
|
@@ -4284,23 +4355,103 @@ class InsomniaToApipost {
|
|
|
4284
4355
|
status: 1,
|
|
4285
4356
|
is_changed: -1,
|
|
4286
4357
|
is_create: 1,
|
|
4287
|
-
method: "
|
|
4288
|
-
request: Object.assign({
|
|
4289
|
-
|
|
4290
|
-
} }, this.completionWsRequest(item, resources)),
|
|
4358
|
+
method: "",
|
|
4359
|
+
request: Object.assign({}, this.completionWsRequest(item, resources)),
|
|
4360
|
+
message: this.completionWs2Message(item, resources),
|
|
4291
4361
|
url: (item === null || item === void 0 ? void 0 : item.url) || "",
|
|
4292
4362
|
config: {
|
|
4363
|
+
certificate_verification: -1,
|
|
4293
4364
|
information_size: 5,
|
|
4294
4365
|
reconnect_num: 5,
|
|
4295
4366
|
reconnect_time: 5000,
|
|
4296
|
-
shake_hands_path: "",
|
|
4297
4367
|
shake_hands_timeout: 0,
|
|
4298
|
-
socket_version: "v4",
|
|
4299
4368
|
},
|
|
4300
4369
|
};
|
|
4301
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
|
+
}
|
|
4302
4453
|
completionApiTarget(item) {
|
|
4303
|
-
var _a
|
|
4454
|
+
var _a;
|
|
4304
4455
|
return {
|
|
4305
4456
|
target_id: ATools.snowflakeId(),
|
|
4306
4457
|
project_id: this.project.project_id || "",
|
|
@@ -4310,7 +4461,7 @@ class InsomniaToApipost {
|
|
|
4310
4461
|
version: 0,
|
|
4311
4462
|
sort: 0,
|
|
4312
4463
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
4313
|
-
method: (item === null || item === void 0 ? void 0 : item.method)
|
|
4464
|
+
method: completionMethod(item === null || item === void 0 ? void 0 : item.method),
|
|
4314
4465
|
url: (item === null || item === void 0 ? void 0 : item.url) || "",
|
|
4315
4466
|
mark_id: "1",
|
|
4316
4467
|
protocol: "http/1.1",
|
|
@@ -4393,8 +4544,14 @@ class InsomniaToApipost {
|
|
|
4393
4544
|
});
|
|
4394
4545
|
}
|
|
4395
4546
|
if ((item === null || item === void 0 ? void 0 : item._type) === "request") {
|
|
4396
|
-
|
|
4397
|
-
|
|
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
|
+
}
|
|
4398
4555
|
}
|
|
4399
4556
|
if ((item === null || item === void 0 ? void 0 : item._type) === "websocket_request") {
|
|
4400
4557
|
const wsTarget = this.completionWsTarget(item, resources);
|
|
@@ -4698,6 +4855,58 @@ class PostmanToApipost {
|
|
|
4698
4855
|
properties: {},
|
|
4699
4856
|
}, binary: {} }, params);
|
|
4700
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
|
+
}
|
|
4701
4910
|
completionApiRequest(item, { request, auth }) {
|
|
4702
4911
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4703
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");
|
|
@@ -4769,8 +4978,68 @@ class PostmanToApipost {
|
|
|
4769
4978
|
};
|
|
4770
4979
|
}
|
|
4771
4980
|
completionApiTarget(item, parentInfo) {
|
|
4772
|
-
var _a, _b;
|
|
4981
|
+
var _a, _b, _c;
|
|
4773
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
|
+
}
|
|
4774
5043
|
return {
|
|
4775
5044
|
target_id: ATools.snowflakeId(),
|
|
4776
5045
|
project_id: this.project.project_id || "",
|
|
@@ -4780,8 +5049,8 @@ class PostmanToApipost {
|
|
|
4780
5049
|
version: 0,
|
|
4781
5050
|
sort: 0,
|
|
4782
5051
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
4783
|
-
method: (request === null || request === void 0 ? void 0 : request.method)
|
|
4784
|
-
url: ((
|
|
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) || "",
|
|
4785
5054
|
mark_id: "1",
|
|
4786
5055
|
protocol: "http/1.1",
|
|
4787
5056
|
request: this.completionApiRequest(item, {
|