drapcode-utility 1.3.2 → 1.3.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.
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -76,9 +76,9 @@ exports.createS3Client = createS3Client;
76
76
  var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
77
77
  if (options === void 0) { options = {}; }
78
78
  return __awaiter(void 0, void 0, void 0, function () {
79
- var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _i, index, file, fileObj, fileObj;
80
- return __generator(this, function (_c) {
81
- switch (_c.label) {
79
+ var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _c, _i, index, file, fileObj, fileObj;
80
+ return __generator(this, function (_d) {
81
+ switch (_d.label) {
82
82
  case 0:
83
83
  if (!encryption) return [3 /*break*/, 2];
84
84
  awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
@@ -89,38 +89,41 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
89
89
  accessKeyId: accessKeyId,
90
90
  secretAccessKey: secretAccessKey,
91
91
  };
92
- return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
92
+ return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
93
93
  case 1:
94
- plainTextData = _c.sent();
94
+ plainTextData = _d.sent();
95
95
  if (plainTextData.status === "FAILED") {
96
96
  return [2 /*return*/, plainTextData];
97
97
  }
98
98
  encryption.dataKey = plainTextData.data;
99
- _c.label = 2;
99
+ _d.label = 2;
100
100
  case 2:
101
101
  if (!Array.isArray(files)) return [3 /*break*/, 7];
102
102
  console.log("I have multiple file");
103
103
  fileOptions = [];
104
104
  s3Key = s3Config.key;
105
- _a = [];
106
- for (_b in files)
107
- _a.push(_b);
105
+ _a = files;
106
+ _b = [];
107
+ for (_c in _a)
108
+ _b.push(_c);
108
109
  _i = 0;
109
- _c.label = 3;
110
+ _d.label = 3;
110
111
  case 3:
111
- if (!(_i < _a.length)) return [3 /*break*/, 6];
112
- index = _a[_i];
112
+ if (!(_i < _b.length)) return [3 /*break*/, 6];
113
+ _c = _b[_i];
114
+ if (!(_c in _a)) return [3 /*break*/, 5];
115
+ index = _c;
113
116
  file = files[index];
114
117
  if (s3Config.append) {
115
- s3Config.key = s3Key + "/" + uuid_1.v4() + "/" + file.originalname;
118
+ s3Config.key = "".concat(s3Key, "/").concat((0, uuid_1.v4)(), "/").concat(file.originalname);
116
119
  }
117
120
  return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, encryption, options, encryption ? true : false)];
118
121
  case 4:
119
- fileObj = _c.sent();
122
+ fileObj = _d.sent();
120
123
  if (fileObj) {
121
124
  fileOptions.push(fileObj);
122
125
  }
123
- _c.label = 5;
126
+ _d.label = 5;
124
127
  case 5:
125
128
  _i++;
126
129
  return [3 /*break*/, 3];
@@ -128,11 +131,11 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
128
131
  case 7:
129
132
  console.log("I have single file");
130
133
  if (s3Config.append) {
131
- s3Config.key = s3Config.key + "/" + uuid_1.v4() + "/" + files.originalname;
134
+ s3Config.key = "".concat(s3Config.key, "/").concat((0, uuid_1.v4)(), "/").concat(files.originalname);
132
135
  }
133
136
  return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, encryption, options, encryption ? true : false)];
134
137
  case 8:
135
- fileObj = _c.sent();
138
+ fileObj = _d.sent();
136
139
  return [2 /*return*/, fileObj];
137
140
  }
138
141
  });
@@ -156,7 +159,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, encryption, opti
156
159
  params = null;
157
160
  encryptedFilePath = null;
158
161
  if (!encrypt) return [3 /*break*/, 3];
159
- return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
162
+ return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
160
163
  case 2:
161
164
  encryptedFilePath = _a.sent();
162
165
  console.log("encryptedFilePath", encryptedFilePath);
@@ -1,6 +1,6 @@
1
1
  export declare const validateString: (str: string) => false | "String should not contain special characters" | "String should not contain any number";
2
2
  export declare const camelize: (str: string) => string;
3
- export declare const clearSpaceAndReformat: (text: string, separator?: string | undefined) => string;
3
+ export declare const clearSpaceAndReformat: (text: string, separator?: string) => string;
4
4
  export declare const isEmpty: (obj: any) => boolean;
5
5
  export declare const isEmptyObject: (object: any) => boolean;
6
6
  export declare const isObject: (item: any) => any;
@@ -21,10 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  }
22
22
  return t;
23
23
  };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
25
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26
- to[j] = from[i];
27
- return to;
24
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
+ if (ar || !(i in from)) {
27
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
+ ar[i] = from[i];
29
+ }
30
+ }
31
+ return to.concat(ar || Array.prototype.slice.call(from));
28
32
  };
29
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -74,7 +78,7 @@ var validateString = function (str) {
74
78
  };
75
79
  exports.validateString = validateString;
76
80
  var camelize = function (str) {
77
- str = exports.clearSpaceAndReformat(str);
81
+ str = (0, exports.clearSpaceAndReformat)(str);
78
82
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
79
83
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
80
84
  });
@@ -201,8 +205,8 @@ var cleanCollectionAndFieldName = function (str) {
201
205
  };
202
206
  exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
203
207
  var formatCollectionAndFieldName = function (str) {
204
- var updateString = exports.cleanCollectionAndFieldName(str);
205
- return exports.clearSpaceAndReformat(updateString.trim(), "_");
208
+ var updateString = (0, exports.cleanCollectionAndFieldName)(str);
209
+ return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
206
210
  };
207
211
  exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
208
212
  var restructureData = function (data) {
@@ -233,7 +237,7 @@ var restructureData = function (data) {
233
237
  exports.restructureData = restructureData;
234
238
  var checkAndCompareValue = function (input1, input2) {
235
239
  return Array.isArray(input2)
236
- ? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
240
+ ? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
237
241
  : input1 === input2.value;
238
242
  };
239
243
  exports.checkAndCompareValue = checkAndCompareValue;
@@ -243,7 +247,7 @@ var arraysEqual = function (array1, array2) {
243
247
  return false;
244
248
  for (var i = 0; i < array1.length; i++ // assert each element equal
245
249
  )
246
- if (!exports.arraysEqual(array1[i], array2[i]))
250
+ if (!(0, exports.arraysEqual)(array1[i], array2[i]))
247
251
  return false;
248
252
  return true;
249
253
  }
@@ -278,7 +282,7 @@ var formatCustomCSSClasses = function (customClasses) {
278
282
  .replace(/"([^"]+)"/g, "$1")
279
283
  .split(",")
280
284
  .join(";");
281
- projectCustomCSSClassesData += "" + (element.class.startsWith(".") ? element.class : "." + element.class) + (element.pseudoClass ? ":" + element.pseudoClass : "") + unquotedClassWithProp + " ";
285
+ projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
282
286
  }
283
287
  });
284
288
  return projectCustomCSSClassesData;
@@ -289,18 +293,18 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
289
293
  var contentList = (_a = expression
290
294
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
291
295
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
292
- var needle = "{{" + prop + "}}";
296
+ var needle = "{{".concat(prop, "}}");
293
297
  var dataOfItem = "";
294
298
  if (prop.includes("current_user")) {
295
299
  prop = prop.replace("current_user.", "");
296
300
  if (Object.keys(user).length > 0) {
297
- dataOfItem = exports.parseValueFromData(user, prop);
301
+ dataOfItem = (0, exports.parseValueFromData)(user, prop);
298
302
  }
299
303
  }
300
304
  else if (prop.includes("current_tenant")) {
301
305
  prop = prop.replace("current_tenant.", "");
302
306
  if (Object.keys(tenant).length > 0) {
303
- dataOfItem = exports.parseValueFromData(tenant, prop);
307
+ dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
304
308
  }
305
309
  }
306
310
  else if (prop.includes("current_session")) {
@@ -326,7 +330,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
326
330
  }
327
331
  else {
328
332
  if (Object.keys(data).length > 0) {
329
- dataOfItem = exports.parseValueFromData(data, prop);
333
+ dataOfItem = (0, exports.parseValueFromData)(data, prop);
330
334
  //TODO: Need better way
331
335
  delete data[prop];
332
336
  }
@@ -426,7 +430,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
426
430
  var contentList = (_a = expression
427
431
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
428
432
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
429
- var needle = "{{" + prop + "}}";
433
+ var needle = "{{".concat(prop, "}}");
430
434
  var dataOfItem = "";
431
435
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
432
436
  expression = dataOfItem
@@ -472,8 +476,8 @@ var processFieldsInlcude = function (fieldsInclude) {
472
476
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
473
477
  var refFields = processReferenceFieldInclude(refFieldsInclude);
474
478
  var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
475
- var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
476
- result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
479
+ var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
480
+ result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
477
481
  return result;
478
482
  };
479
483
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -498,16 +502,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
498
502
  if (arg.name === "expression") {
499
503
  var needleList = (_a = arg.key
500
504
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
501
- var tempFields = exports.processFieldsInlcude(needleList);
502
- fields = __spreadArray(__spreadArray([], fields), tempFields);
505
+ var tempFields = (0, exports.processFieldsInlcude)(needleList);
506
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
503
507
  }
504
508
  else if (!derivedFieldExcludes.includes(arg.name)) {
505
509
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
506
- tempFields = exports.processFieldsInlcude(tempFields);
507
- fields = __spreadArray(__spreadArray([], fields), tempFields);
510
+ tempFields = (0, exports.processFieldsInlcude)(tempFields);
511
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
508
512
  }
509
513
  });
510
- derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
514
+ derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
511
515
  });
512
516
  return derivedFields;
513
517
  };
@@ -38,10 +38,10 @@ var nextGeneratedString = function (str, prepend, minLength, append, algorithm)
38
38
  finalValue = voca_1.default.padLeft(finalValue, minLength, "0");
39
39
  }
40
40
  if (prepend) {
41
- finalValue = "" + prepend + finalValue;
41
+ finalValue = "".concat(prepend).concat(finalValue);
42
42
  }
43
43
  if (append) {
44
- finalValue = "" + finalValue + append;
44
+ finalValue = "".concat(finalValue).concat(append);
45
45
  }
46
46
  return finalValue;
47
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -33,8 +33,8 @@
33
33
  "@types/express": "^4.17.7",
34
34
  "@types/voca": "^1.4.2",
35
35
  "axios": "^1.1.2",
36
- "drapcode-constant": "^1.3.1",
37
- "drapcode-logger": "^1.0.8",
36
+ "drapcode-constant": "^1.3.4",
37
+ "drapcode-logger": "^1.0.9",
38
38
  "drapcode-redis": "^1.0.4",
39
39
  "express": "^4.17.1",
40
40
  "lodash": "^4.17.21",