drapcode-utility 2.5.0-preview → 2.5.1

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.
@@ -155,7 +155,7 @@ const callCurlRequest = async (setting, user = {}, tenant = {}, userSetting = {}
155
155
  return prepareReturnObject(result.data, result.status, result?.success || (result.status >= 200 && result.status < 300), result?.headers, result?.mysqlError);
156
156
  }
157
157
  else {
158
- result = await makeAxiosCall(projectId, methodType, url, headerValue, data, timeout, wrapJsonDataInArray, awsSignPluginConfig);
158
+ result = await makeAxiosCall(projectId, methodType, url, headerValue, data, timeout, wrapJsonDataInArray, awsSignPluginConfig, dtoExternalAPI);
159
159
  }
160
160
  drapcode_logger_1.logger.info(`result.headers: ${result?.headers}`, { label: projectId });
161
161
  if (!result) {
@@ -234,14 +234,19 @@ const prepareReturnObject = (data, status = 400, success = false, headers = {},
234
234
  };
235
235
  }
236
236
  };
237
- const makeAxiosCall = async (projectId, methodType, url, axiosConfig, data, timeout, wrapJsonDataInArray, awsSignPluginConfig) => {
237
+ const makeAxiosCall = async (projectId, methodType, url, axiosConfig, data, timeout, wrapJsonDataInArray, awsSignPluginConfig, dtoExternalAPI) => {
238
238
  axiosConfig = { url, method: methodType, ...axiosConfig };
239
239
  let result = "";
240
240
  const instance = axios_1.default.create();
241
241
  instance.defaults.timeout = timeout * 1000;
242
+ const { dtoBodyDataFrom } = dtoExternalAPI || {};
243
+ const isNoBodyData = !dtoBodyDataFrom || dtoBodyDataFrom === "noDynamicData";
244
+ console.log(`\n ==> isNoBodyData for projectID: ${projectId}:`, isNoBodyData);
242
245
  switch (methodType) {
243
246
  case "GET":
244
- axiosConfig["data"] = data ? data : {};
247
+ if (!isNoBodyData) {
248
+ axiosConfig["data"] = data ? data : {};
249
+ }
245
250
  break;
246
251
  case "POST":
247
252
  case "PUT":
@@ -408,21 +408,19 @@ const parseJsonString = (str) => {
408
408
  exports.parseJsonString = parseJsonString;
409
409
  const parseValueFromData = (data, fieldName) => {
410
410
  let value = "";
411
- let valueIndex = "";
412
- let valueIndexFieldName = "";
413
411
  if (fieldName && fieldName.includes(".")) {
414
412
  let fullNameParts = fieldName.split(".");
415
413
  let prefix = "";
416
- let stack = data || {};
414
+ let stack = data || "";
417
415
  for (let k = 0; k < fullNameParts.length; k++) {
418
416
  prefix = fullNameParts[k];
419
- if (stack && Array.isArray(stack)) {
417
+ if (Array.isArray(stack)) {
420
418
  stack[prefix] = stack.map((item) => {
421
419
  if (item[prefix])
422
420
  return item[prefix];
423
421
  });
424
422
  }
425
- if (stack && !stack[prefix]) {
423
+ if (stack && stack[prefix] === undefined) {
426
424
  stack[prefix] = "";
427
425
  }
428
426
  stack = stack[prefix];
@@ -432,57 +430,14 @@ const parseValueFromData = (data, fieldName) => {
432
430
  value = value.filter(() => true);
433
431
  }
434
432
  }
435
- else if (fieldName && fieldName.includes("[")) {
436
- //Todo: Need to Refactor
437
- let fullNameParts = fieldName.split("[");
438
- let prefix = "";
439
- let stack = data || {};
440
- for (let k = 0; k < fullNameParts.length - 1; k++) {
441
- const cValue = fullNameParts[k];
442
- const nValue = fullNameParts[k + 1];
443
- prefix = cValue ? (!cValue.includes("]") ? cValue : "") : "";
444
- valueIndex = nValue
445
- ? nValue.includes("]")
446
- ? nValue.split("]")[0]
447
- : nValue
448
- : "";
449
- if (stack && Array.isArray(stack)) {
450
- stack[prefix] = stack.map((item) => {
451
- if (item[prefix])
452
- return item[prefix];
453
- });
454
- }
455
- if (stack && !stack[prefix]) {
456
- stack[prefix] = "";
457
- }
458
- stack = valueIndex ? stack[prefix][valueIndex] : stack[prefix];
459
- if (fieldName.includes("]:")) {
460
- valueIndexFieldName = nValue.split("]:")[1];
461
- if (valueIndexFieldName) {
462
- stack = stack[valueIndexFieldName];
463
- }
464
- }
465
- }
466
- value = stack ? stack : "";
467
- if (Array.isArray(value)) {
468
- value = value.filter(() => true);
469
- }
470
- }
471
433
  else {
472
434
  value = data ? data[fieldName] : "";
473
435
  }
474
- if (value && Array.isArray(value) && value.length === 1)
475
- return value[0];
476
436
  if (value && Array.isArray(value) && typeof value[0] === "string") {
477
- return value.join(",");
437
+ return value.join(", ");
478
438
  }
479
- if (!value || value == "undefined" || value === "undefined") {
480
- if (value === 0) {
481
- value = "0";
482
- }
483
- else {
484
- value = "";
485
- }
439
+ if (typeof value !== undefined && typeof value === "number") {
440
+ return value.toString();
486
441
  }
487
442
  return value;
488
443
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.5.0-preview",
3
+ "version": "2.5.1",
4
4
  "description": "DrapCode Utility",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,9 +42,9 @@
42
42
  "axios": "^1.1.2",
43
43
  "date-fns": "^4.1.0",
44
44
  "dompurify": "^3.1.7",
45
- "drapcode-constant": "^2.0.2-preview",
46
- "drapcode-logger": "^1.3.5-preview",
47
- "drapcode-redis": "^1.4.9-preview",
45
+ "drapcode-constant": "^2.0.2",
46
+ "drapcode-logger": "^1.3.5",
47
+ "drapcode-redis": "^1.4.9",
48
48
  "exiftool-vendored": "^28.2.1",
49
49
  "express": "^4.17.1",
50
50
  "gm": "^1.25.0",