av6-core 1.0.0 → 1.0.2
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/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +119 -8
- package/dist/index.mjs +116 -7
- package/package.json +2 -4
package/dist/index.d.mts
CHANGED
|
@@ -246,7 +246,7 @@ interface CommonServiceResponse {
|
|
|
246
246
|
commonExcelExport: (exportParams: ExportExcelRequestService<DynamicShortCode>) => Promise<ExcelJs.Workbook>;
|
|
247
247
|
delete: (deleteParams: DeleteRequestRepository<DynamicShortCode>) => Promise<void>;
|
|
248
248
|
updateStatus: (updateStatusParams: UpdateStatusRequestRepository<DynamicShortCode>) => Promise<unknown>;
|
|
249
|
-
fetchImageStream: (fileName: string) => Promise<AxiosResponse<Readable>>;
|
|
249
|
+
fetchImageStream: (imageBaseUrl: string, fileName: string) => Promise<AxiosResponse<Readable>>;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
declare const commonService: (serviceDeps: Deps) => CommonServiceResponse;
|
|
@@ -257,6 +257,27 @@ declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K
|
|
|
257
257
|
};
|
|
258
258
|
declare function getDynamicValue(obj: Record<string, any> | null | undefined, accessorKey: string): any | null;
|
|
259
259
|
declare function objectTo2DArray<T>(obj: Record<string, T>, maxCols: number): (string | T)[][];
|
|
260
|
-
declare
|
|
260
|
+
declare function toNumberOrNull(value: unknown): number | null;
|
|
261
|
+
declare const getPattern: {
|
|
262
|
+
[key: string]: RegExp;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
interface CreateTransaction {
|
|
266
|
+
field: string;
|
|
267
|
+
changedFrom?: string | null;
|
|
268
|
+
changedTo?: string | null;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Compares two objects (including nested objects) by flattening them,
|
|
273
|
+
* and returns an array of differences. The returned array contains objects
|
|
274
|
+
* with the field name (underscores replaced by spaces), changedFrom, and
|
|
275
|
+
* changedTo values.
|
|
276
|
+
*
|
|
277
|
+
* @param obj1 - The first object.
|
|
278
|
+
* @param obj2 - The second object.
|
|
279
|
+
* @returns An array of DiffResult objects representing the differences.
|
|
280
|
+
*/
|
|
281
|
+
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
261
282
|
|
|
262
|
-
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, getDynamicValue, objectTo2DArray,
|
|
283
|
+
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -246,7 +246,7 @@ interface CommonServiceResponse {
|
|
|
246
246
|
commonExcelExport: (exportParams: ExportExcelRequestService<DynamicShortCode>) => Promise<ExcelJs.Workbook>;
|
|
247
247
|
delete: (deleteParams: DeleteRequestRepository<DynamicShortCode>) => Promise<void>;
|
|
248
248
|
updateStatus: (updateStatusParams: UpdateStatusRequestRepository<DynamicShortCode>) => Promise<unknown>;
|
|
249
|
-
fetchImageStream: (fileName: string) => Promise<AxiosResponse<Readable>>;
|
|
249
|
+
fetchImageStream: (imageBaseUrl: string, fileName: string) => Promise<AxiosResponse<Readable>>;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
declare const commonService: (serviceDeps: Deps) => CommonServiceResponse;
|
|
@@ -257,6 +257,27 @@ declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K
|
|
|
257
257
|
};
|
|
258
258
|
declare function getDynamicValue(obj: Record<string, any> | null | undefined, accessorKey: string): any | null;
|
|
259
259
|
declare function objectTo2DArray<T>(obj: Record<string, T>, maxCols: number): (string | T)[][];
|
|
260
|
-
declare
|
|
260
|
+
declare function toNumberOrNull(value: unknown): number | null;
|
|
261
|
+
declare const getPattern: {
|
|
262
|
+
[key: string]: RegExp;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
interface CreateTransaction {
|
|
266
|
+
field: string;
|
|
267
|
+
changedFrom?: string | null;
|
|
268
|
+
changedTo?: string | null;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Compares two objects (including nested objects) by flattening them,
|
|
273
|
+
* and returns an array of differences. The returned array contains objects
|
|
274
|
+
* with the field name (underscores replaced by spaces), changedFrom, and
|
|
275
|
+
* changedTo values.
|
|
276
|
+
*
|
|
277
|
+
* @param obj1 - The first object.
|
|
278
|
+
* @param obj2 - The second object.
|
|
279
|
+
* @returns An array of DiffResult objects representing the differences.
|
|
280
|
+
*/
|
|
281
|
+
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
261
282
|
|
|
262
|
-
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, getDynamicValue, objectTo2DArray,
|
|
283
|
+
export { type CacheAdapter, type CalculationRes, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
|
package/dist/index.js
CHANGED
|
@@ -32,9 +32,11 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
commonService: () => commonService,
|
|
34
34
|
customOmit: () => customOmit,
|
|
35
|
+
findDifferences: () => findDifferences,
|
|
35
36
|
getDynamicValue: () => getDynamicValue,
|
|
37
|
+
getPattern: () => getPattern,
|
|
36
38
|
objectTo2DArray: () => objectTo2DArray,
|
|
37
|
-
|
|
39
|
+
toNumberOrNull: () => toNumberOrNull
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(index_exports);
|
|
40
42
|
|
|
@@ -863,10 +865,70 @@ function objectTo2DArray(obj, maxCols) {
|
|
|
863
865
|
}
|
|
864
866
|
return rows;
|
|
865
867
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
868
|
+
function toNumberOrNull(value) {
|
|
869
|
+
if (typeof value === "number") {
|
|
870
|
+
return value;
|
|
871
|
+
}
|
|
872
|
+
const converted = Number(value);
|
|
873
|
+
return isNaN(converted) ? null : converted;
|
|
874
|
+
}
|
|
875
|
+
var getPattern = {
|
|
876
|
+
stringBaseNum: /^[1-9][0-9]*$/,
|
|
877
|
+
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
878
|
+
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
879
|
+
namePattern: /^[A-Za-z\s]+$/,
|
|
880
|
+
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
881
|
+
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
882
|
+
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
883
|
+
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
884
|
+
// phonePattern:
|
|
885
|
+
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
886
|
+
phonePattern: /^\d{9}$/,
|
|
887
|
+
postalCodePattern: /^[0-9]{5}$/,
|
|
888
|
+
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
889
|
+
numericPattern: /^[0-9]+$/,
|
|
890
|
+
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
891
|
+
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
892
|
+
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
893
|
+
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
894
|
+
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
895
|
+
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
896
|
+
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
897
|
+
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
898
|
+
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
899
|
+
binaryPattern: /^[01]+$/,
|
|
900
|
+
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
901
|
+
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
902
|
+
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
903
|
+
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
904
|
+
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
905
|
+
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
906
|
+
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
907
|
+
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
908
|
+
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
909
|
+
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
910
|
+
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
911
|
+
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
912
|
+
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
913
|
+
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
914
|
+
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
915
|
+
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
916
|
+
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
917
|
+
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
918
|
+
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
919
|
+
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
920
|
+
audioPattern: /\.(mp3|wav)$/i,
|
|
921
|
+
pdfPattern: /\.(pdf)$/i,
|
|
922
|
+
docPattern: /\.(doc|docx)$/i,
|
|
923
|
+
xlsPattern: /\.(xls|xlsx)$/i,
|
|
924
|
+
pptPattern: /\.(ppt|pptx)$/i,
|
|
925
|
+
zipPattern: /\.(zip)$/i,
|
|
926
|
+
rarPattern: /\.(rar)$/i,
|
|
927
|
+
tarPattern: /\.(tar)$/i,
|
|
928
|
+
gzipPattern: /\.(gz|gzip)$/i,
|
|
929
|
+
bz2Pattern: /\.(bz2)$/i,
|
|
930
|
+
isoPattern: /\.(iso)$/i,
|
|
931
|
+
txtPattern: /\.(txt)$/i
|
|
870
932
|
};
|
|
871
933
|
|
|
872
934
|
// src/services/common.service.ts
|
|
@@ -1138,17 +1200,66 @@ var commonService = (serviceDeps) => {
|
|
|
1138
1200
|
logger.info("exiting::updateStatus::service");
|
|
1139
1201
|
return updatedData;
|
|
1140
1202
|
},
|
|
1141
|
-
async fetchImageStream(fileName) {
|
|
1142
|
-
const url =
|
|
1203
|
+
async fetchImageStream(imageBaseUrl, fileName) {
|
|
1204
|
+
const url = imageBaseUrl + fileName;
|
|
1143
1205
|
return import_axios.default.get(url, { responseType: "stream" });
|
|
1144
1206
|
}
|
|
1145
1207
|
};
|
|
1146
1208
|
};
|
|
1209
|
+
|
|
1210
|
+
// src/utils/audit.utils.ts
|
|
1211
|
+
function isValidDate(value) {
|
|
1212
|
+
if (value instanceof Date) {
|
|
1213
|
+
return !isNaN(value.getTime());
|
|
1214
|
+
}
|
|
1215
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1216
|
+
const parsed = new Date(value);
|
|
1217
|
+
return !isNaN(parsed.getTime());
|
|
1218
|
+
}
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
function flattenObject(obj, parentKey = "") {
|
|
1222
|
+
const result = {};
|
|
1223
|
+
for (const key of Object.keys(obj)) {
|
|
1224
|
+
const raw = obj[key];
|
|
1225
|
+
const newKey = parentKey ? `${parentKey}_${key}` : key;
|
|
1226
|
+
if (typeof raw !== "number" && isValidDate(raw)) {
|
|
1227
|
+
const date = raw instanceof Date ? raw : new Date(raw);
|
|
1228
|
+
result[newKey] = date.toISOString().split("T")[0];
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
1232
|
+
Object.assign(result, flattenObject(raw, newKey));
|
|
1233
|
+
continue;
|
|
1234
|
+
}
|
|
1235
|
+
result[newKey] = raw;
|
|
1236
|
+
}
|
|
1237
|
+
return result;
|
|
1238
|
+
}
|
|
1239
|
+
function findDifferences(obj1, obj2) {
|
|
1240
|
+
const flatObj1 = flattenObject(obj1);
|
|
1241
|
+
const flatObj2 = flattenObject(obj2);
|
|
1242
|
+
const differences = [];
|
|
1243
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(flatObj1)]);
|
|
1244
|
+
allKeys.forEach((key) => {
|
|
1245
|
+
if (flatObj1[key] !== flatObj2[key]) {
|
|
1246
|
+
differences.push({
|
|
1247
|
+
// Replace underscores with spaces for a nicer field output
|
|
1248
|
+
field: key.replace(/_/g, " "),
|
|
1249
|
+
changedFrom: typeof flatObj1[key] !== "string" ? JSON.stringify(flatObj1[key]) : flatObj1[key],
|
|
1250
|
+
changedTo: typeof flatObj2[key] !== "string" ? JSON.stringify(flatObj2[key]) : flatObj2[key]
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
return differences;
|
|
1255
|
+
}
|
|
1147
1256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1148
1257
|
0 && (module.exports = {
|
|
1149
1258
|
commonService,
|
|
1150
1259
|
customOmit,
|
|
1260
|
+
findDifferences,
|
|
1151
1261
|
getDynamicValue,
|
|
1262
|
+
getPattern,
|
|
1152
1263
|
objectTo2DArray,
|
|
1153
|
-
|
|
1264
|
+
toNumberOrNull
|
|
1154
1265
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -823,10 +823,70 @@ function objectTo2DArray(obj, maxCols) {
|
|
|
823
823
|
}
|
|
824
824
|
return rows;
|
|
825
825
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
826
|
+
function toNumberOrNull(value) {
|
|
827
|
+
if (typeof value === "number") {
|
|
828
|
+
return value;
|
|
829
|
+
}
|
|
830
|
+
const converted = Number(value);
|
|
831
|
+
return isNaN(converted) ? null : converted;
|
|
832
|
+
}
|
|
833
|
+
var getPattern = {
|
|
834
|
+
stringBaseNum: /^[1-9][0-9]*$/,
|
|
835
|
+
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
836
|
+
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
837
|
+
namePattern: /^[A-Za-z\s]+$/,
|
|
838
|
+
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
839
|
+
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
840
|
+
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
841
|
+
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
842
|
+
// phonePattern:
|
|
843
|
+
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
844
|
+
phonePattern: /^\d{9}$/,
|
|
845
|
+
postalCodePattern: /^[0-9]{5}$/,
|
|
846
|
+
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
847
|
+
numericPattern: /^[0-9]+$/,
|
|
848
|
+
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
849
|
+
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
850
|
+
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
851
|
+
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
852
|
+
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
853
|
+
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
854
|
+
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
855
|
+
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
856
|
+
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
857
|
+
binaryPattern: /^[01]+$/,
|
|
858
|
+
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
859
|
+
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
860
|
+
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
861
|
+
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
862
|
+
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
863
|
+
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
864
|
+
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
865
|
+
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
866
|
+
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
867
|
+
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
868
|
+
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
869
|
+
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
870
|
+
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
871
|
+
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
872
|
+
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
873
|
+
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
874
|
+
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
875
|
+
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
876
|
+
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
877
|
+
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
878
|
+
audioPattern: /\.(mp3|wav)$/i,
|
|
879
|
+
pdfPattern: /\.(pdf)$/i,
|
|
880
|
+
docPattern: /\.(doc|docx)$/i,
|
|
881
|
+
xlsPattern: /\.(xls|xlsx)$/i,
|
|
882
|
+
pptPattern: /\.(ppt|pptx)$/i,
|
|
883
|
+
zipPattern: /\.(zip)$/i,
|
|
884
|
+
rarPattern: /\.(rar)$/i,
|
|
885
|
+
tarPattern: /\.(tar)$/i,
|
|
886
|
+
gzipPattern: /\.(gz|gzip)$/i,
|
|
887
|
+
bz2Pattern: /\.(bz2)$/i,
|
|
888
|
+
isoPattern: /\.(iso)$/i,
|
|
889
|
+
txtPattern: /\.(txt)$/i
|
|
830
890
|
};
|
|
831
891
|
|
|
832
892
|
// src/services/common.service.ts
|
|
@@ -1098,16 +1158,65 @@ var commonService = (serviceDeps) => {
|
|
|
1098
1158
|
logger.info("exiting::updateStatus::service");
|
|
1099
1159
|
return updatedData;
|
|
1100
1160
|
},
|
|
1101
|
-
async fetchImageStream(fileName) {
|
|
1102
|
-
const url =
|
|
1161
|
+
async fetchImageStream(imageBaseUrl, fileName) {
|
|
1162
|
+
const url = imageBaseUrl + fileName;
|
|
1103
1163
|
return axios.get(url, { responseType: "stream" });
|
|
1104
1164
|
}
|
|
1105
1165
|
};
|
|
1106
1166
|
};
|
|
1167
|
+
|
|
1168
|
+
// src/utils/audit.utils.ts
|
|
1169
|
+
function isValidDate(value) {
|
|
1170
|
+
if (value instanceof Date) {
|
|
1171
|
+
return !isNaN(value.getTime());
|
|
1172
|
+
}
|
|
1173
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1174
|
+
const parsed = new Date(value);
|
|
1175
|
+
return !isNaN(parsed.getTime());
|
|
1176
|
+
}
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
function flattenObject(obj, parentKey = "") {
|
|
1180
|
+
const result = {};
|
|
1181
|
+
for (const key of Object.keys(obj)) {
|
|
1182
|
+
const raw = obj[key];
|
|
1183
|
+
const newKey = parentKey ? `${parentKey}_${key}` : key;
|
|
1184
|
+
if (typeof raw !== "number" && isValidDate(raw)) {
|
|
1185
|
+
const date = raw instanceof Date ? raw : new Date(raw);
|
|
1186
|
+
result[newKey] = date.toISOString().split("T")[0];
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
1190
|
+
Object.assign(result, flattenObject(raw, newKey));
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
result[newKey] = raw;
|
|
1194
|
+
}
|
|
1195
|
+
return result;
|
|
1196
|
+
}
|
|
1197
|
+
function findDifferences(obj1, obj2) {
|
|
1198
|
+
const flatObj1 = flattenObject(obj1);
|
|
1199
|
+
const flatObj2 = flattenObject(obj2);
|
|
1200
|
+
const differences = [];
|
|
1201
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(flatObj1)]);
|
|
1202
|
+
allKeys.forEach((key) => {
|
|
1203
|
+
if (flatObj1[key] !== flatObj2[key]) {
|
|
1204
|
+
differences.push({
|
|
1205
|
+
// Replace underscores with spaces for a nicer field output
|
|
1206
|
+
field: key.replace(/_/g, " "),
|
|
1207
|
+
changedFrom: typeof flatObj1[key] !== "string" ? JSON.stringify(flatObj1[key]) : flatObj1[key],
|
|
1208
|
+
changedTo: typeof flatObj2[key] !== "string" ? JSON.stringify(flatObj2[key]) : flatObj2[key]
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
return differences;
|
|
1213
|
+
}
|
|
1107
1214
|
export {
|
|
1108
1215
|
commonService,
|
|
1109
1216
|
customOmit,
|
|
1217
|
+
findDifferences,
|
|
1110
1218
|
getDynamicValue,
|
|
1219
|
+
getPattern,
|
|
1111
1220
|
objectTo2DArray,
|
|
1112
|
-
|
|
1221
|
+
toNumberOrNull
|
|
1113
1222
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "av6-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsup"
|
|
9
|
-
"publish": "npm publish",
|
|
10
|
-
"prepublishOnly": "npm run build"
|
|
8
|
+
"build": "tsup"
|
|
11
9
|
},
|
|
12
10
|
"keywords": [],
|
|
13
11
|
"author": "Aniket Sarkar",
|