artes 1.0.65 → 1.0.67
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/index.js +2 -0
- package/package.json +1 -1
- package/src/helper/stepFunctions/APIActions.js +43 -39
package/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
page,
|
|
12
12
|
request,
|
|
13
13
|
random,
|
|
14
|
+
resolveVariable
|
|
14
15
|
} = require("./src/helper/imports/commons");
|
|
15
16
|
const {
|
|
16
17
|
keyboard,
|
|
@@ -30,6 +31,7 @@ module.exports = {
|
|
|
30
31
|
selector,
|
|
31
32
|
saveVar,
|
|
32
33
|
extractVarsFromResponse,
|
|
34
|
+
resolveVariable,
|
|
33
35
|
context,
|
|
34
36
|
api,
|
|
35
37
|
random,
|
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const { context, selector, resolveVariable, moduleConfig } = require("../imports/commons");
|
|
2
4
|
|
|
3
5
|
function getMimeType(filePath) {
|
|
4
6
|
const ext = path.extname(filePath).toLowerCase();
|
|
@@ -21,9 +23,7 @@ function getMimeType(filePath) {
|
|
|
21
23
|
return mimeTypes[ext] || "application/octet-stream";
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
function processForm(key, value) {
|
|
25
|
-
let formData = {};
|
|
26
|
-
|
|
26
|
+
function processForm(formData, key, value) {
|
|
27
27
|
if (typeof value === "object") {
|
|
28
28
|
if (value.contentType) {
|
|
29
29
|
const content =
|
|
@@ -36,8 +36,10 @@ function processForm(key, value) {
|
|
|
36
36
|
mimeType: value.contentType,
|
|
37
37
|
buffer: Buffer.from(content, "utf8"),
|
|
38
38
|
};
|
|
39
|
+
return;
|
|
39
40
|
} else {
|
|
40
41
|
formData[key] = JSON.stringify(value);
|
|
42
|
+
return;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -52,18 +54,21 @@ function processForm(key, value) {
|
|
|
52
54
|
value.includes("/"))
|
|
53
55
|
) {
|
|
54
56
|
try {
|
|
55
|
-
|
|
57
|
+
const filePath = path.join(moduleConfig.projectPath, value);
|
|
58
|
+
if (fs.existsSync(filePath)) {
|
|
56
59
|
formData[key] = {
|
|
57
|
-
name: path.basename(
|
|
58
|
-
mimeType: getMimeType(
|
|
59
|
-
buffer: fs.readFileSync(
|
|
60
|
+
name: path.basename(filePath),
|
|
61
|
+
mimeType: getMimeType(filePath),
|
|
62
|
+
buffer: fs.readFileSync(filePath),
|
|
60
63
|
};
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
|
-
} catch (error) {
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.log(error);
|
|
68
|
+
}
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
formData[key] = value;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
async function requestMaker(headers, data, requestDataType) {
|
|
@@ -148,23 +153,22 @@ const api = {
|
|
|
148
153
|
|
|
149
154
|
switch (requestDataType) {
|
|
150
155
|
case "multipart":
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
for (const [key, value] of Object.entries(payloadJSON
|
|
154
|
-
|
|
155
|
-
Object.assign(combinedFormData, formData);
|
|
156
|
+
let formData = {};
|
|
157
|
+
|
|
158
|
+
for (const [key, value] of Object.entries(payloadJSON?.body)) {
|
|
159
|
+
processForm(formData, key, value);
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
req = await requestMaker(
|
|
159
|
-
payloadJSON
|
|
160
|
-
|
|
163
|
+
payloadJSON?.headers || {},
|
|
164
|
+
formData || {},
|
|
161
165
|
requestDataType,
|
|
162
166
|
);
|
|
163
167
|
break;
|
|
164
168
|
default:
|
|
165
169
|
req = await requestMaker(
|
|
166
|
-
payloadJSON
|
|
167
|
-
payloadJSON
|
|
170
|
+
payloadJSON?.headers || {},
|
|
171
|
+
payloadJSON?.body || {},
|
|
168
172
|
);
|
|
169
173
|
}
|
|
170
174
|
|
|
@@ -172,7 +176,7 @@ const api = {
|
|
|
172
176
|
|
|
173
177
|
const response = await responseMaker(payloadJSON, res);
|
|
174
178
|
|
|
175
|
-
context.response =
|
|
179
|
+
context.response = response;
|
|
176
180
|
},
|
|
177
181
|
put: async (url, payload, requestDataType) => {
|
|
178
182
|
const URL = await selector(url);
|
|
@@ -185,23 +189,23 @@ const api = {
|
|
|
185
189
|
|
|
186
190
|
switch (requestDataType) {
|
|
187
191
|
case "multipart":
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
let formData = {};
|
|
193
|
+
|
|
194
|
+
for (const [key, value] of Object.entries(payloadJSON?.body)) {
|
|
195
|
+
processForm(formData, key, value);
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
req = await requestMaker(
|
|
195
|
-
payloadJSON
|
|
196
|
-
|
|
199
|
+
payloadJSON?.headers || {},
|
|
200
|
+
formData || {},
|
|
197
201
|
requestDataType,
|
|
198
202
|
);
|
|
199
203
|
|
|
200
204
|
break;
|
|
201
205
|
default:
|
|
202
206
|
req = await requestMaker(
|
|
203
|
-
payloadJSON
|
|
204
|
-
payloadJSON
|
|
207
|
+
payloadJSON?.headers || {},
|
|
208
|
+
payloadJSON?.body || {},
|
|
205
209
|
);
|
|
206
210
|
}
|
|
207
211
|
|
|
@@ -209,7 +213,7 @@ const api = {
|
|
|
209
213
|
|
|
210
214
|
const response = await responseMaker(payloadJSON, res);
|
|
211
215
|
|
|
212
|
-
context.response =
|
|
216
|
+
context.response = response;
|
|
213
217
|
},
|
|
214
218
|
patch: async (url, payload, requestDataType) => {
|
|
215
219
|
const URL = await selector(url);
|
|
@@ -222,31 +226,31 @@ const api = {
|
|
|
222
226
|
|
|
223
227
|
switch (requestDataType) {
|
|
224
228
|
case "multipart":
|
|
225
|
-
let
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
+
let formData = {};
|
|
230
|
+
|
|
231
|
+
for (const [key, value] of Object.entries(payloadJSON?.body)) {
|
|
232
|
+
processForm(formData, key, value);
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
req = await requestMaker(
|
|
232
|
-
payloadJSON
|
|
233
|
-
|
|
236
|
+
payloadJSON?.headers || {},
|
|
237
|
+
formData || {},
|
|
234
238
|
requestDataType,
|
|
235
239
|
);
|
|
236
240
|
|
|
237
241
|
break;
|
|
238
242
|
default:
|
|
239
243
|
req = await requestMaker(
|
|
240
|
-
payloadJSON
|
|
241
|
-
payloadJSON
|
|
244
|
+
payloadJSON?.headers || {},
|
|
245
|
+
payloadJSON?.body || {},
|
|
242
246
|
);
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
const res = await context.request.patch(resolvedURL, req);
|
|
246
250
|
|
|
247
|
-
const response = responseMaker(payloadJSON, res);
|
|
251
|
+
const response = await responseMaker(payloadJSON, res);
|
|
248
252
|
|
|
249
|
-
context.response =
|
|
253
|
+
context.response = response;
|
|
250
254
|
},
|
|
251
255
|
delete: async (url, payload) => {
|
|
252
256
|
const URL = await selector(url);
|