drapcode-utility 2.6.5 → 2.6.6-preview

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.
@@ -132,7 +132,6 @@ const drapcodeEncryptDecrypt = async (data, encrypt) => {
132
132
  };
133
133
  exports.drapcodeEncryptDecrypt = drapcodeEncryptDecrypt;
134
134
  const cryptFile = async (filePath, encryption, decrypt) => {
135
- console.log("encryption cryptFile:>> ", encryption);
136
135
  const data = await (0, file_1.processFileEncryptionDecryption)(filePath, encryption, decrypt);
137
136
  return data;
138
137
  };
@@ -26,6 +26,6 @@ export declare const createLogsDateFormat: (timezone?: string) => string;
26
26
  export declare const getDateValue: (value: string, timezone?: string, fieldType?: string) => string;
27
27
  export declare const getDateRangeValue: (key: string, field: string, value: string) => DateRangeValue;
28
28
  export declare const nextDayDate: (date: string | Date) => string;
29
- export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean) => Date;
29
+ export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean, isDateTime?: any) => any;
30
30
  export declare const formatProjectDates: (item: Record<string, any> | Record<string, any>[], dateFormat: string, fields: DateField[], reverse: boolean) => Record<string, any> | Record<string, any>[];
31
31
  export {};
@@ -161,8 +161,10 @@ const nextDayDate = (date) => {
161
161
  }
162
162
  };
163
163
  exports.nextDayDate = nextDayDate;
164
- const timezoneDateParse = (value, nextDay = false, prevDay = false) => {
164
+ const timezoneDateParse = (value, nextDay = false, prevDay = false, isDateTime = null) => {
165
165
  try {
166
+ // Checking False because in case of null and true we need date with time
167
+ const format = isDateTime === false ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm:ss";
166
168
  let timeZoneDate = (0, moment_1.default)(value);
167
169
  if (!timeZoneDate.isValid()) {
168
170
  throw new Error("Invalid date input");
@@ -173,9 +175,9 @@ const timezoneDateParse = (value, nextDay = false, prevDay = false) => {
173
175
  if (prevDay && value.length <= 10) {
174
176
  timeZoneDate = timeZoneDate.subtract(1, "days");
175
177
  }
176
- const formatted = timeZoneDate.format("YYYY-MM-DDTHH:mm:ss");
177
- return new Date(formatted);
178
- // return timeZoneDate.toDate();
178
+ const formatted = timeZoneDate.format(format);
179
+ return typeof isDateTime === "boolean" ? formatted : new Date(formatted);
180
+ // return new Date(formatted);
179
181
  }
180
182
  catch (error) {
181
183
  console.error("Error in timezoneDateParse:", error);
@@ -83,8 +83,7 @@ const getSearchObjQuery = (searchObj, searchQueryTypeObj) => {
83
83
  ].includes(searchQueryTypeKey)) {
84
84
  const isDateTime = ["datetime", ...drapcode_constant_1.systemDateField].includes(searchQueryTypeKey);
85
85
  if (key.startsWith("start_") || key.startsWith("end_")) {
86
- let fieldKey = key.replace("start_", "");
87
- fieldKey = fieldKey.replace("end_", "");
86
+ let fieldKey = key.replace(/^start_/, "").replace(/^end_/, "");
88
87
  searchAggregateQuery.push({
89
88
  $addFields: {
90
89
  [`_${key}`]: { $toString: `$${fieldKey}` },
@@ -93,14 +92,14 @@ const getSearchObjQuery = (searchObj, searchQueryTypeObj) => {
93
92
  if (key.startsWith("start_")) {
94
93
  likeQuery.push({
95
94
  [`_${key}`]: {
96
- $gte: (0, date_util_1.timezoneDateParse)(value, isDateTime, true),
95
+ $gte: (0, date_util_1.timezoneDateParse)(value, false, false, isDateTime),
97
96
  },
98
97
  });
99
98
  }
100
99
  else if (key.startsWith("end_")) {
101
100
  likeQuery.push({
102
101
  [`_${key}`]: {
103
- $lt: (0, date_util_1.timezoneDateParse)(value, isDateTime),
102
+ $lt: (0, date_util_1.timezoneDateParse)(value, true, false, isDateTime),
104
103
  },
105
104
  });
106
105
  }
@@ -33,7 +33,6 @@ const createS3Client = (awsConfig) => {
33
33
  exports.createS3Client = createS3Client;
34
34
  const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}, encrypted = false) => {
35
35
  if (Array.isArray(files)) {
36
- console.log("Multiple file");
37
36
  const fileOptions = [];
38
37
  const s3Key = s3Config.key;
39
38
  for (const file of files) {
@@ -49,21 +48,17 @@ const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS
49
48
  return fileOptions;
50
49
  }
51
50
  else {
52
- console.log("Single file");
53
51
  const fileSlug = slugifyFileName(files.originalname);
54
52
  if (s3Config.append) {
55
53
  s3Config.key = `${s3Config.key}/${(0, uuid_1.v4)()}/${fileSlug}`;
56
54
  }
57
- console.log("encryption :>> ", encryption);
58
55
  return await processFileUploadToS3(files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encrypted);
59
56
  }
60
57
  };
61
58
  exports.fileUploadToS3 = fileUploadToS3;
62
59
  const processFileUploadToS3 = async (file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}, encrypt = false) => {
63
60
  try {
64
- console.log("encrypt :>> ", encrypt);
65
61
  const contentType = mime_types_1.default.lookup(file.originalname) || "";
66
- console.log("s3Config :>> ", s3Config);
67
62
  const { acl, key, bucket } = s3Config;
68
63
  let params = null;
69
64
  let encryptedFilePath = null;
@@ -88,8 +83,6 @@ const processFileUploadToS3 = async (file, s3Client, s3Config, publicS3Client, p
88
83
  ...options,
89
84
  };
90
85
  }
91
- console.log("encryptedFilePath :>> ", encryptedFilePath);
92
- console.log("params :>> ", params);
93
86
  const parallelUploads3 = new lib_storage_1.Upload({ client: s3Client, params });
94
87
  const data = await parallelUploads3.done();
95
88
  const { smallIcon, mediumIcon, largeIcon } = await handleIconUpload(file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options);
@@ -102,7 +102,7 @@ export declare const evaluateExpression: (expression: string, data: any, user: a
102
102
  export declare const evaluateCurrency: (formatType: string, subject: number | string | any, currency: string, position: string, maxFraction: number, user?: any, tenant?: any) => string;
103
103
  export declare const evaluateJSLogic: (expression: string, data: any, user: any, envConstants: any) => any;
104
104
  export declare const formatDate: (formatType: string, datentime: any, timezone: string, unixType: any, offset?: boolean) => string;
105
- export declare const dateDifference: (formatType: string, datentime1: any, datentime2: any, timezone: string) => string;
105
+ export declare const dateDifference: (formatType: string, datentime1: any, datentime2: any, timezone: string, dateFormat: string) => string;
106
106
  export declare const mergeObjects: (arrayOfObjects: any, data?: any, user?: any, tenant?: any, userSetting?: any, subTenant?: any, sessionValue?: any, envConstants?: any, sessionFormValue?: any, dataTransferObject?: any, localStorageValue?: any, cookiesValue?: any) => any;
107
107
  export declare const getFindQuery: (item: any, customKey?: string) => {
108
108
  [x: string]: any;
@@ -333,7 +333,6 @@ const replaceDataValueIntoExpression = (expression, data, user, tenant, userSett
333
333
  const contentList = expression
334
334
  .match(/{{(.*?)}}/g)
335
335
  ?.map((b) => b.replace(/{{(.*?)}}/g, "$1"));
336
- console.log("1 replaceDataValueIntoExpression");
337
336
  contentList?.forEach((prop) => {
338
337
  const needle = `{{${prop}}}`;
339
338
  prop = voca_1.default.trim(prop);
@@ -1114,15 +1113,15 @@ const formatDate = function (formatType, datentime, timezone, unixType, offset =
1114
1113
  return datentime ? formatDateNTime.format(formatType) : "";
1115
1114
  };
1116
1115
  exports.formatDate = formatDate;
1117
- const dateDifference = (formatType, datentime1, datentime2, timezone) => {
1116
+ const dateDifference = (formatType, datentime1, datentime2, timezone, dateFormat) => {
1118
1117
  let result = "";
1119
1118
  const dateExist = !datentime1 || !datentime2;
1120
1119
  const firstDate = datentime1 === "CURRENT_DATE_TIME"
1121
1120
  ? (0, moment_1.default)().utcOffset(timezone)
1122
- : (0, moment_1.default)(datentime1).utcOffset(timezone);
1121
+ : (0, moment_1.default)(datentime1, dateFormat).utcOffset(timezone);
1123
1122
  const secondDate = datentime2 === "CURRENT_DATE_TIME"
1124
1123
  ? (0, moment_1.default)().utcOffset(timezone)
1125
- : (0, moment_1.default)(datentime2).utcOffset(timezone);
1124
+ : (0, moment_1.default)(datentime2, dateFormat).utcOffset(timezone);
1126
1125
  const patterns = formatType.split(",");
1127
1126
  patterns.forEach((format, i) => {
1128
1127
  const diff = firstDate.diff(secondDate, format);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.6.5",
4
- "description": "DrapCode Utility",
3
+ "version": "2.6.6-preview",
4
+ "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
7
7
  "files": [
@@ -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.8",
46
- "drapcode-logger": "^1.3.6",
47
- "drapcode-redis": "^1.5.5",
45
+ "drapcode-constant": "^1.8.0",
46
+ "drapcode-logger": "^1.3.5",
47
+ "drapcode-redis": "^1.3.5",
48
48
  "exiftool-vendored": "^28.2.1",
49
49
  "express": "^4.17.1",
50
50
  "gm": "^1.25.0",