artes 1.0.62 → 1.0.63
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 +356 -356
- package/cucumber.config.js +98 -98
- package/docs/functionDefinitions.md +2342 -2342
- package/docs/stepDefinitions.md +352 -352
- package/executer.js +59 -59
- package/index.js +44 -44
- package/package.json +50 -50
- package/src/helper/contextManager/browserManager.js +66 -66
- package/src/helper/contextManager/requestManager.js +30 -30
- package/src/helper/executers/cleaner.js +23 -23
- package/src/helper/executers/exporter.js +15 -15
- package/src/helper/executers/helper.js +44 -44
- package/src/helper/executers/projectCreator.js +162 -162
- package/src/helper/executers/reportGenerator.js +29 -29
- package/src/helper/executers/testRunner.js +59 -59
- package/src/helper/executers/versionChecker.js +13 -13
- package/src/helper/imports/commons.js +51 -51
- package/src/helper/pomController/elementController.js +146 -146
- package/src/helper/pomController/pomCollector.js +20 -20
- package/src/helper/stepFunctions/APIActions.js +271 -271
- package/src/helper/stepFunctions/assertions.js +523 -523
- package/src/helper/stepFunctions/browserActions.js +21 -21
- package/src/helper/stepFunctions/elementInteractions.js +38 -38
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +50 -50
- package/src/helper/stepFunctions/keyboardActions.js +41 -41
- package/src/helper/stepFunctions/mouseActions.js +145 -145
- package/src/helper/stepFunctions/pageActions.js +27 -27
- package/src/hooks/context.js +15 -15
- package/src/hooks/hooks.js +76 -76
- package/src/stepDefinitions/API.steps.js +248 -248
- package/src/stepDefinitions/assertions.steps.js +826 -826
- package/src/stepDefinitions/browser.steps.js +7 -7
- package/src/stepDefinitions/frameActions.steps.js +76 -76
- package/src/stepDefinitions/keyboardActions.steps.js +87 -87
- package/src/stepDefinitions/mouseActions.steps.js +256 -256
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +25 -25
|
@@ -1,271 +1,271 @@
|
|
|
1
|
-
const { context, selector, resolveVariable } = require("../imports/commons");
|
|
2
|
-
|
|
3
|
-
function getMimeType(filePath) {
|
|
4
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
5
|
-
const mimeTypes = {
|
|
6
|
-
".jpg": "image/jpeg",
|
|
7
|
-
".jpeg": "image/jpeg",
|
|
8
|
-
".png": "image/png",
|
|
9
|
-
".gif": "image/gif",
|
|
10
|
-
".pdf": "application/pdf",
|
|
11
|
-
".txt": "text/plain",
|
|
12
|
-
".json": "application/json",
|
|
13
|
-
".xml": "application/xml",
|
|
14
|
-
".zip": "application/zip",
|
|
15
|
-
".doc": "application/msword",
|
|
16
|
-
".docx":
|
|
17
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
-
".csv": "text/csv",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return mimeTypes[ext] || "application/octet-stream";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function processForm(key, value) {
|
|
25
|
-
let formData = {};
|
|
26
|
-
|
|
27
|
-
if (typeof value === "object") {
|
|
28
|
-
if (value.contentType) {
|
|
29
|
-
const content =
|
|
30
|
-
typeof value.data === "object"
|
|
31
|
-
? JSON.stringify(value.data)
|
|
32
|
-
: String(value.data);
|
|
33
|
-
|
|
34
|
-
formData[key] = {
|
|
35
|
-
name: value.filename || key,
|
|
36
|
-
mimeType: value.contentType,
|
|
37
|
-
buffer: Buffer.from(content, "utf8"),
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
formData[key] = JSON.stringify(value);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
typeof value === "string" &&
|
|
46
|
-
(value.endsWith(".pdf") ||
|
|
47
|
-
value.endsWith(".jpg") ||
|
|
48
|
-
value.endsWith(".png") ||
|
|
49
|
-
value.endsWith(".txt") ||
|
|
50
|
-
value.endsWith(".doc") ||
|
|
51
|
-
value.endsWith(".docx") ||
|
|
52
|
-
value.includes("/"))
|
|
53
|
-
) {
|
|
54
|
-
try {
|
|
55
|
-
if (fs.existsSync(value)) {
|
|
56
|
-
formData[key] = {
|
|
57
|
-
name: path.basename(value),
|
|
58
|
-
mimeType: getMimeType(value),
|
|
59
|
-
buffer: fs.readFileSync(value),
|
|
60
|
-
};
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
} catch (error) {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return formData;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function requestMaker(headers, data, requestDataType) {
|
|
70
|
-
let request = {};
|
|
71
|
-
|
|
72
|
-
Object.assign(request, { headers: headers });
|
|
73
|
-
|
|
74
|
-
switch (requestDataType) {
|
|
75
|
-
case "multipart":
|
|
76
|
-
Object.assign(request, { multipart: data });
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
Object.assign(request, { data: data });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return request;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function responseMaker(request, response) {
|
|
86
|
-
const responseObject = {};
|
|
87
|
-
|
|
88
|
-
response && Object.assign(responseObject, { URL: response.url() });
|
|
89
|
-
|
|
90
|
-
request
|
|
91
|
-
Object.assign(responseObject, { "Request Headers": await request.headers });
|
|
92
|
-
|
|
93
|
-
request
|
|
94
|
-
Object.assign(responseObject, { "Request Body": await request.body });
|
|
95
|
-
|
|
96
|
-
response && Object.assign(responseObject, { Response: await response });
|
|
97
|
-
|
|
98
|
-
response &&
|
|
99
|
-
Object.assign(responseObject, {
|
|
100
|
-
"Response Headers": await response.headers(),
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
if (response) {
|
|
104
|
-
try {
|
|
105
|
-
Object.assign(responseObject, { "Response Body": await response.json() });
|
|
106
|
-
} catch (e) {
|
|
107
|
-
Object.assign(responseObject, { "Response Body": await response.text() });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return responseObject;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const api = {
|
|
115
|
-
get: async (url, payload) => {
|
|
116
|
-
const URL = await selector(url);
|
|
117
|
-
const resolvedURL = await resolveVariable(URL);
|
|
118
|
-
|
|
119
|
-
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
120
|
-
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
121
|
-
|
|
122
|
-
const req = await requestMaker(payloadJSON?.headers || {});
|
|
123
|
-
|
|
124
|
-
const res = await context.request.get(resolvedURL, req);
|
|
125
|
-
|
|
126
|
-
const response = responseMaker(payloadJSON, res);
|
|
127
|
-
|
|
128
|
-
context.response = await response;
|
|
129
|
-
},
|
|
130
|
-
head: async (url) => {
|
|
131
|
-
const URL = await selector(url);
|
|
132
|
-
const resolvedURL = await resolveVariable(URL);
|
|
133
|
-
|
|
134
|
-
const res = await context.request.head(resolvedURL);
|
|
135
|
-
|
|
136
|
-
const response = responseMaker(payloadJSON, res);
|
|
137
|
-
|
|
138
|
-
context.response = await response;
|
|
139
|
-
},
|
|
140
|
-
post: async (url, payload, requestDataType) => {
|
|
141
|
-
const URL = await selector(url);
|
|
142
|
-
const resolvedURL = await resolveVariable(URL);
|
|
143
|
-
|
|
144
|
-
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
145
|
-
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
146
|
-
|
|
147
|
-
let req;
|
|
148
|
-
|
|
149
|
-
switch (requestDataType) {
|
|
150
|
-
case "multipart":
|
|
151
|
-
let combinedFormData = {};
|
|
152
|
-
|
|
153
|
-
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
154
|
-
const formData = processForm(key, value);
|
|
155
|
-
Object.assign(combinedFormData, formData);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
req = await requestMaker(
|
|
159
|
-
payloadJSON.headers || {},
|
|
160
|
-
combinedFormData || {},
|
|
161
|
-
requestDataType,
|
|
162
|
-
);
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
req = await requestMaker(
|
|
166
|
-
payloadJSON.headers || {},
|
|
167
|
-
payloadJSON.body || {},
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const res = await context.request.post(resolvedURL, req);
|
|
172
|
-
|
|
173
|
-
const response = await responseMaker(payloadJSON, res);
|
|
174
|
-
|
|
175
|
-
context.response = await response;
|
|
176
|
-
},
|
|
177
|
-
put: async (url, payload, requestDataType) => {
|
|
178
|
-
const URL = await selector(url);
|
|
179
|
-
const resolvedURL = await resolveVariable(URL);
|
|
180
|
-
|
|
181
|
-
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
182
|
-
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
183
|
-
|
|
184
|
-
let req;
|
|
185
|
-
|
|
186
|
-
switch (requestDataType) {
|
|
187
|
-
case "multipart":
|
|
188
|
-
let combinedFormData = {};
|
|
189
|
-
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
190
|
-
const formData = processForm(key, value);
|
|
191
|
-
Object.assign(combinedFormData, formData);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
req = await requestMaker(
|
|
195
|
-
payloadJSON.headers || {},
|
|
196
|
-
combinedFormData || {},
|
|
197
|
-
requestDataType,
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
req = await requestMaker(
|
|
203
|
-
payloadJSON.headers || {},
|
|
204
|
-
payloadJSON.body || {},
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const res = await context.request.put(resolvedURL, req);
|
|
209
|
-
|
|
210
|
-
const response = await responseMaker(payloadJSON, res);
|
|
211
|
-
|
|
212
|
-
context.response = await response;
|
|
213
|
-
},
|
|
214
|
-
patch: async (url, payload, requestDataType) => {
|
|
215
|
-
const URL = await selector(url);
|
|
216
|
-
const resolvedURL = await resolveVariable(URL);
|
|
217
|
-
|
|
218
|
-
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
219
|
-
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
220
|
-
|
|
221
|
-
let req;
|
|
222
|
-
|
|
223
|
-
switch (requestDataType) {
|
|
224
|
-
case "multipart":
|
|
225
|
-
let combinedFormData = {};
|
|
226
|
-
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
227
|
-
const formData = processForm(key, value);
|
|
228
|
-
Object.assign(combinedFormData, formData);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
req = await requestMaker(
|
|
232
|
-
payloadJSON.headers || {},
|
|
233
|
-
combinedFormData || {},
|
|
234
|
-
requestDataType,
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
break;
|
|
238
|
-
default:
|
|
239
|
-
req = await requestMaker(
|
|
240
|
-
payloadJSON.headers || {},
|
|
241
|
-
payloadJSON.body || {},
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const res = await context.request.patch(resolvedURL, req);
|
|
246
|
-
|
|
247
|
-
const response = responseMaker(payloadJSON, res);
|
|
248
|
-
|
|
249
|
-
context.response = await response;
|
|
250
|
-
},
|
|
251
|
-
delete: async (url, payload) => {
|
|
252
|
-
const URL = await selector(url);
|
|
253
|
-
const resolvedURL = await resolveVariable(URL);
|
|
254
|
-
|
|
255
|
-
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
256
|
-
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
257
|
-
|
|
258
|
-
const req = await requestMaker(payloadJSON.headers || {});
|
|
259
|
-
|
|
260
|
-
const res = await context.request.delete(resolvedURL, req);
|
|
261
|
-
|
|
262
|
-
const response = responseMaker(payloadJSON, res);
|
|
263
|
-
|
|
264
|
-
context.response = await response;
|
|
265
|
-
},
|
|
266
|
-
vars: () => {
|
|
267
|
-
return context.vars;
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
module.exports = { api };
|
|
1
|
+
const { context, selector, resolveVariable } = require("../imports/commons");
|
|
2
|
+
|
|
3
|
+
function getMimeType(filePath) {
|
|
4
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
5
|
+
const mimeTypes = {
|
|
6
|
+
".jpg": "image/jpeg",
|
|
7
|
+
".jpeg": "image/jpeg",
|
|
8
|
+
".png": "image/png",
|
|
9
|
+
".gif": "image/gif",
|
|
10
|
+
".pdf": "application/pdf",
|
|
11
|
+
".txt": "text/plain",
|
|
12
|
+
".json": "application/json",
|
|
13
|
+
".xml": "application/xml",
|
|
14
|
+
".zip": "application/zip",
|
|
15
|
+
".doc": "application/msword",
|
|
16
|
+
".docx":
|
|
17
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
+
".csv": "text/csv",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return mimeTypes[ext] || "application/octet-stream";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function processForm(key, value) {
|
|
25
|
+
let formData = {};
|
|
26
|
+
|
|
27
|
+
if (typeof value === "object") {
|
|
28
|
+
if (value.contentType) {
|
|
29
|
+
const content =
|
|
30
|
+
typeof value.data === "object"
|
|
31
|
+
? JSON.stringify(value.data)
|
|
32
|
+
: String(value.data);
|
|
33
|
+
|
|
34
|
+
formData[key] = {
|
|
35
|
+
name: value.filename || key,
|
|
36
|
+
mimeType: value.contentType,
|
|
37
|
+
buffer: Buffer.from(content, "utf8"),
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
formData[key] = JSON.stringify(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
typeof value === "string" &&
|
|
46
|
+
(value.endsWith(".pdf") ||
|
|
47
|
+
value.endsWith(".jpg") ||
|
|
48
|
+
value.endsWith(".png") ||
|
|
49
|
+
value.endsWith(".txt") ||
|
|
50
|
+
value.endsWith(".doc") ||
|
|
51
|
+
value.endsWith(".docx") ||
|
|
52
|
+
value.includes("/"))
|
|
53
|
+
) {
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(value)) {
|
|
56
|
+
formData[key] = {
|
|
57
|
+
name: path.basename(value),
|
|
58
|
+
mimeType: getMimeType(value),
|
|
59
|
+
buffer: fs.readFileSync(value),
|
|
60
|
+
};
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return formData;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function requestMaker(headers, data, requestDataType) {
|
|
70
|
+
let request = {};
|
|
71
|
+
|
|
72
|
+
Object.assign(request, { headers: headers });
|
|
73
|
+
|
|
74
|
+
switch (requestDataType) {
|
|
75
|
+
case "multipart":
|
|
76
|
+
Object.assign(request, { multipart: data });
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
Object.assign(request, { data: data });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return request;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function responseMaker(request, response) {
|
|
86
|
+
const responseObject = {};
|
|
87
|
+
|
|
88
|
+
response && Object.assign(responseObject, { URL: response.url() });
|
|
89
|
+
|
|
90
|
+
request?.headers &&
|
|
91
|
+
Object.assign(responseObject, { "Request Headers": await request.headers });
|
|
92
|
+
|
|
93
|
+
request?.body &&
|
|
94
|
+
Object.assign(responseObject, { "Request Body": await request.body });
|
|
95
|
+
|
|
96
|
+
response && Object.assign(responseObject, { Response: await response });
|
|
97
|
+
|
|
98
|
+
response &&
|
|
99
|
+
Object.assign(responseObject, {
|
|
100
|
+
"Response Headers": await response.headers(),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (response) {
|
|
104
|
+
try {
|
|
105
|
+
Object.assign(responseObject, { "Response Body": await response.json() });
|
|
106
|
+
} catch (e) {
|
|
107
|
+
Object.assign(responseObject, { "Response Body": await response.text() });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return responseObject;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const api = {
|
|
115
|
+
get: async (url, payload) => {
|
|
116
|
+
const URL = await selector(url);
|
|
117
|
+
const resolvedURL = await resolveVariable(URL);
|
|
118
|
+
|
|
119
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
120
|
+
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
121
|
+
|
|
122
|
+
const req = await requestMaker(payloadJSON?.headers || {});
|
|
123
|
+
|
|
124
|
+
const res = await context.request.get(resolvedURL, req);
|
|
125
|
+
|
|
126
|
+
const response = responseMaker(payloadJSON, res);
|
|
127
|
+
|
|
128
|
+
context.response = await response;
|
|
129
|
+
},
|
|
130
|
+
head: async (url) => {
|
|
131
|
+
const URL = await selector(url);
|
|
132
|
+
const resolvedURL = await resolveVariable(URL);
|
|
133
|
+
|
|
134
|
+
const res = await context.request.head(resolvedURL);
|
|
135
|
+
|
|
136
|
+
const response = responseMaker(payloadJSON, res);
|
|
137
|
+
|
|
138
|
+
context.response = await response;
|
|
139
|
+
},
|
|
140
|
+
post: async (url, payload, requestDataType) => {
|
|
141
|
+
const URL = await selector(url);
|
|
142
|
+
const resolvedURL = await resolveVariable(URL);
|
|
143
|
+
|
|
144
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
145
|
+
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
146
|
+
|
|
147
|
+
let req;
|
|
148
|
+
|
|
149
|
+
switch (requestDataType) {
|
|
150
|
+
case "multipart":
|
|
151
|
+
let combinedFormData = {};
|
|
152
|
+
|
|
153
|
+
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
154
|
+
const formData = processForm(key, value);
|
|
155
|
+
Object.assign(combinedFormData, formData);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
req = await requestMaker(
|
|
159
|
+
payloadJSON.headers || {},
|
|
160
|
+
combinedFormData || {},
|
|
161
|
+
requestDataType,
|
|
162
|
+
);
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
req = await requestMaker(
|
|
166
|
+
payloadJSON.headers || {},
|
|
167
|
+
payloadJSON.body || {},
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const res = await context.request.post(resolvedURL, req);
|
|
172
|
+
|
|
173
|
+
const response = await responseMaker(payloadJSON, res);
|
|
174
|
+
|
|
175
|
+
context.response = await response;
|
|
176
|
+
},
|
|
177
|
+
put: async (url, payload, requestDataType) => {
|
|
178
|
+
const URL = await selector(url);
|
|
179
|
+
const resolvedURL = await resolveVariable(URL);
|
|
180
|
+
|
|
181
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
182
|
+
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
183
|
+
|
|
184
|
+
let req;
|
|
185
|
+
|
|
186
|
+
switch (requestDataType) {
|
|
187
|
+
case "multipart":
|
|
188
|
+
let combinedFormData = {};
|
|
189
|
+
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
190
|
+
const formData = processForm(key, value);
|
|
191
|
+
Object.assign(combinedFormData, formData);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
req = await requestMaker(
|
|
195
|
+
payloadJSON.headers || {},
|
|
196
|
+
combinedFormData || {},
|
|
197
|
+
requestDataType,
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
req = await requestMaker(
|
|
203
|
+
payloadJSON.headers || {},
|
|
204
|
+
payloadJSON.body || {},
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const res = await context.request.put(resolvedURL, req);
|
|
209
|
+
|
|
210
|
+
const response = await responseMaker(payloadJSON, res);
|
|
211
|
+
|
|
212
|
+
context.response = await response;
|
|
213
|
+
},
|
|
214
|
+
patch: async (url, payload, requestDataType) => {
|
|
215
|
+
const URL = await selector(url);
|
|
216
|
+
const resolvedURL = await resolveVariable(URL);
|
|
217
|
+
|
|
218
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
219
|
+
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
220
|
+
|
|
221
|
+
let req;
|
|
222
|
+
|
|
223
|
+
switch (requestDataType) {
|
|
224
|
+
case "multipart":
|
|
225
|
+
let combinedFormData = {};
|
|
226
|
+
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
227
|
+
const formData = processForm(key, value);
|
|
228
|
+
Object.assign(combinedFormData, formData);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
req = await requestMaker(
|
|
232
|
+
payloadJSON.headers || {},
|
|
233
|
+
combinedFormData || {},
|
|
234
|
+
requestDataType,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
req = await requestMaker(
|
|
240
|
+
payloadJSON.headers || {},
|
|
241
|
+
payloadJSON.body || {},
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const res = await context.request.patch(resolvedURL, req);
|
|
246
|
+
|
|
247
|
+
const response = responseMaker(payloadJSON, res);
|
|
248
|
+
|
|
249
|
+
context.response = await response;
|
|
250
|
+
},
|
|
251
|
+
delete: async (url, payload) => {
|
|
252
|
+
const URL = await selector(url);
|
|
253
|
+
const resolvedURL = await resolveVariable(URL);
|
|
254
|
+
|
|
255
|
+
const resolvedPayload = (await payload) && resolveVariable(payload);
|
|
256
|
+
const payloadJSON = (await resolvedPayload) && JSON.parse(resolvedPayload);
|
|
257
|
+
|
|
258
|
+
const req = await requestMaker(payloadJSON.headers || {});
|
|
259
|
+
|
|
260
|
+
const res = await context.request.delete(resolvedURL, req);
|
|
261
|
+
|
|
262
|
+
const response = responseMaker(payloadJSON, res);
|
|
263
|
+
|
|
264
|
+
context.response = await response;
|
|
265
|
+
},
|
|
266
|
+
vars: () => {
|
|
267
|
+
return context.vars;
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
module.exports = { api };
|