drapcode-utility 2.1.2 → 2.1.4

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.
@@ -11,24 +11,14 @@ var FormData = require("form-data");
11
11
  var fs = require("fs");
12
12
  const qs = require("qs");
13
13
  const callCurlRequest = async (setting, user = {}, tenant = {}, userSetting = {}, subTenant = {}, data = {}, timeout = 0, timeoutMessage = "", envConstants = {}, downloadBytes = false, requestDataType = "", wrapJsonDataInArray = false, projectId = "", dataTransferObject = {}, isRawJSON = false, browserStorageData = {}) => {
14
- let { url, params, methodType, authType, requestHeader, accessToken, headers = [], isMultipart, files, awsSignPluginConfig = null, } = setting;
14
+ let { url, params, methodType, authType, requestHeader, accessToken, headers = [], isMultipart, files, awsSignPluginConfig = null, body } = setting;
15
+ const { bodyRawJSONUrlEncoded, bodyDataFrom } = body || {};
15
16
  const { sessionValue, sessionFormValue,
16
17
  // sessionStorageData: sessionStorageValue,
17
18
  localStorageData: localStorageValue, cookiesData: cookiesValue, } = browserStorageData || {};
18
19
  drapcode_logger_1.logger.info(`STEP 1 Replacing placeholder key values...`, {
19
20
  label: projectId,
20
21
  });
21
- // Uncomment below only when needed for debugging
22
- // logger.info(
23
- // `STEP 1 Replacing URL Session Value: ${sessionValue ? JSON.stringify(sessionValue) : ""
24
- // }, Session Form Value: ${sessionFormValue ? JSON.stringify(sessionFormValue) : ""
25
- // }, Browser Storage Data: ${browserStorageData ? JSON.stringify(browserStorageData) : ""
26
- // }, Session Storage: ${sessionStorageValue ? JSON.stringify(sessionStorageValue) : ""
27
- // }, Local Storage: ${localStorageValue ? JSON.stringify(localStorageValue) : ""
28
- // }, Session Cookies: ${cookiesValue ? JSON.stringify(cookiesValue) : ""
29
- // }, Headers: ${headers ? JSON.stringify(headers) : ""}`,
30
- // { label: projectId }
31
- // );
32
22
  if (url.includes("{{current_user.") &&
33
23
  (!user || Object.keys(user).length == 0)) {
34
24
  drapcode_logger_1.logger.info("**2 Sending back", { label: projectId });
@@ -132,10 +122,20 @@ const callCurlRequest = async (setting, user = {}, tenant = {}, userSetting = {}
132
122
  }
133
123
  try {
134
124
  let result = null;
135
- if (!isRawJSON) {
136
- if (requestDataType === "FORM_URL_ENCODED" || isUrlEncoded) {
125
+ // console.log("🚀 ~ callCurlRequest ~ isRawJSON:", isRawJSON, "~ bodyRawJSONUrlEncoded:", bodyRawJSONUrlEncoded, "~ bodyDataFrom:", bodyDataFrom, "~ requestDataType:", requestDataType)
126
+ drapcode_logger_1.logger.info(`** isRawJSON: ${isRawJSON}, ~ bodyRawJSONUrlEncoded: ${bodyRawJSONUrlEncoded}, ~ bodyDataFrom: ${bodyDataFrom}, ~ requestDataType: ${requestDataType}`, { label: projectId });
127
+ if (isRawJSON) {
128
+ if (bodyDataFrom === "RAW_JSON" && bodyRawJSONUrlEncoded) {
137
129
  data = qs.stringify(data);
138
- drapcode_logger_1.logger.info("**17 Encoded data:", data, { label: projectId });
130
+ drapcode_logger_1.logger.info(`**17 Encoded data: ${data && JSON.stringify(data)}`, { label: projectId });
131
+ }
132
+ if (requestDataType === "NO_BODY_DATA")
133
+ data = {};
134
+ }
135
+ else if (!isRawJSON) {
136
+ if (requestDataType === "FORM_URL_ENCODED" || isUrlEncoded || bodyDataFrom === "formDataUrlEncoded") {
137
+ data = qs.stringify(data);
138
+ drapcode_logger_1.logger.info(`**18 Encoded data: ${data && JSON.stringify(data)}`, { label: projectId });
139
139
  }
140
140
  if (requestDataType === "NO_BODY_DATA")
141
141
  data = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "",
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": "^1.8.3",
45
+ "drapcode-constant": "^1.8.4",
46
46
  "drapcode-logger": "^1.3.5",
47
- "drapcode-redis": "^1.3.8",
47
+ "drapcode-redis": "^1.3.9",
48
48
  "exiftool-vendored": "^28.2.1",
49
49
  "express": "^4.17.1",
50
50
  "gm": "^1.25.0",