asv-hlps 1.4.44 → 1.4.46

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.
@@ -1,6 +1,8 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  declare class HlpQuery {
3
3
  where: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
+ whereIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
5
+ whereNotIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
6
  opDate: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any) => void;
5
7
  join: <T = any>(qb: SelectQueryBuilder<T>, key: string, rStr: string, status?: "lj" | "ljs") => void;
6
8
  joker: <T = any>(qb: SelectQueryBuilder<T>, joker: {
@@ -9,6 +9,19 @@ class HlpQuery {
9
9
  qb.andWhere(`${key} = :${qVar}`, { [qVar]: prm });
10
10
  }
11
11
  };
12
+ this.whereIn = (qb, key, prm, qOn) => {
13
+ const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
14
+ if (prm) {
15
+ qb.andWhere(`LOWER(${key}) IN (:...${qVar}) `, { [qVar]: prm });
16
+ }
17
+ };
18
+ this.whereNotIn = (qb, key, prm, qOn) => {
19
+ const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
20
+ if (prm) {
21
+ qb.andWhere(`LOWER(${key}) NOT IN (:...${qVar}) `, { [qVar]: prm });
22
+ // qb.andWhere("LOWER(role.code) IN (:...roleCodes)", { roleCodes: prms.roleCodes.ins });
23
+ }
24
+ };
12
25
  this.opDate = (qb, key, prm) => {
13
26
  var _a, _b, _c;
14
27
  if (prm === null || prm === void 0 ? void 0 : prm.opDate) {
@@ -130,7 +130,7 @@ const tabLabel = (sale) => {
130
130
  exports.tabLabel = tabLabel;
131
131
  const refSaleGenerator = () => {
132
132
  let date = new Date();
133
- const nDate = "C" + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString().split(":").join("");
133
+ const nDate = "C" + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString("en-US", { hour12: false }).split(":").join("");
134
134
  return (0, utils_1.removeBackSlashOccurences)(nDate, "").toLocaleUpperCase();
135
135
  // return randomatic('A', 4) + date.toLocaleDateString().split('-').join('') + date.toLocaleTimeString().split(':').join('')
136
136
  };
@@ -16,6 +16,10 @@ export declare const getRandomColor: (brightness: number) => string;
16
16
  export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
17
17
  export declare const removeDuplicateValues: (array: any[]) => any[];
18
18
  export declare const duplicateObjects: (array: any[], property: string) => any[];
19
+ export declare const duplicateObjectsGrouped: (array: any[], keyProp?: string, prms?: {
20
+ arrProp?: string;
21
+ groupedByKeyProp?: boolean;
22
+ }) => any[];
19
23
  export declare const toObjectDate: (fromDate: any, toDate: string) => {
20
24
  fromDate: any;
21
25
  toDate: string;
@@ -64,7 +68,7 @@ export declare const formatNgbDate: (date: any) => {
64
68
  toDate: string;
65
69
  };
66
70
  export declare const genRandomColour: () => string;
67
- export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
71
+ export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean, options?: {}) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
68
72
  export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
69
73
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
70
74
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
package/lib/cjs/utils.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateNth = exports.dateNthMonth = exports.dateNthDay = exports.dateNthWeek = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
- exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = void 0;
6
+ exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateNth = exports.dateNthMonth = exports.dateNthDay = exports.dateNthWeek = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjectsGrouped = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
+ exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = void 0;
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const dayOfYear_1 = __importDefault(require("dayjs/plugin/dayOfYear"));
10
10
  const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
@@ -146,6 +146,23 @@ const duplicateObjects = (array, property) => {
146
146
  return array.filter((obj, index) => array.findIndex(item => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) !== index);
147
147
  };
148
148
  exports.duplicateObjects = duplicateObjects;
149
+ const duplicateObjectsGrouped = (array, keyProp = "id", prms) => {
150
+ const objs = array.reduce((acc, obj) => {
151
+ const key = obj[keyProp];
152
+ if (!acc[key]) {
153
+ acc[key] = [];
154
+ }
155
+ acc[key].push(obj);
156
+ return acc;
157
+ }, {});
158
+ const grouped = Object.values(objs);
159
+ const groupedByKeyProp = grouped.map((obj) => ({
160
+ [keyProp]: obj[0][keyProp],
161
+ [(prms === null || prms === void 0 ? void 0 : prms.arrProp) || "arr"]: obj,
162
+ }));
163
+ return (prms === null || prms === void 0 ? void 0 : prms.groupedByKeyProp) || true ? groupedByKeyProp : grouped;
164
+ };
165
+ exports.duplicateObjectsGrouped = duplicateObjectsGrouped;
149
166
  const toObjectDate = (fromDate, toDate) => {
150
167
  toDate = toDate !== "null" ? toDate : fromDate;
151
168
  return { fromDate: fromDate, toDate: toDate };
@@ -260,7 +277,9 @@ exports.removeBackSlashOccurences = removeBackSlashOccurences;
260
277
  }; */
261
278
  const refGenerator = (char = "c", regex = /\/+/gi, toChar = "") => {
262
279
  let date = new Date();
263
- let nDate = char.toUpperCase() + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString().split(":").join("");
280
+ let nDate = char.toUpperCase() +
281
+ date.toLocaleDateString().split("-").join("") +
282
+ date.toLocaleTimeString("en-US", { hour12: false }).split(":").join("");
264
283
  nDate = (0, exports.replaceAllIn)(nDate, regex, toChar).toLocaleUpperCase();
265
284
  return nDate.indexOf(" ") ? nDate.substring(0, nDate.indexOf(" ")).trim() : nDate;
266
285
  };
@@ -440,7 +459,7 @@ const genRandomColour = () => {
440
459
  return "#" + Math.floor(Math.random() * 16777215).toString(16);
441
460
  };
442
461
  exports.genRandomColour = genRandomColour;
443
- const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
462
+ const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass, options) => {
444
463
  const date = new Date();
445
464
  const date2 = new Date(inputDate);
446
465
  const diffNumber = Math.ceil((0, exports.getNbOfDaysBetweenTwoDates)(date2, date));
@@ -1,6 +1,8 @@
1
1
  import { SelectQueryBuilder } from "typeorm";
2
2
  declare class HlpQuery {
3
3
  where: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
+ whereIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
5
+ whereNotIn: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any, qOn?: string) => void;
4
6
  opDate: <T = any>(qb: SelectQueryBuilder<T>, key: string, prm: any) => void;
5
7
  join: <T = any>(qb: SelectQueryBuilder<T>, key: string, rStr: string, status?: "lj" | "ljs") => void;
6
8
  joker: <T = any>(qb: SelectQueryBuilder<T>, joker: {
@@ -7,6 +7,19 @@ class HlpQuery {
7
7
  qb.andWhere(`${key} = :${qVar}`, { [qVar]: prm });
8
8
  }
9
9
  };
10
+ this.whereIn = (qb, key, prm, qOn) => {
11
+ const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
12
+ if (prm) {
13
+ qb.andWhere(`LOWER(${key}) IN (:...${qVar}) `, { [qVar]: prm });
14
+ }
15
+ };
16
+ this.whereNotIn = (qb, key, prm, qOn) => {
17
+ const qVar = !qOn ? key.substring(key.indexOf(".") + 1) : qOn;
18
+ if (prm) {
19
+ qb.andWhere(`LOWER(${key}) NOT IN (:...${qVar}) `, { [qVar]: prm });
20
+ // qb.andWhere("LOWER(role.code) IN (:...roleCodes)", { roleCodes: prms.roleCodes.ins });
21
+ }
22
+ };
10
23
  this.opDate = (qb, key, prm) => {
11
24
  var _a, _b, _c;
12
25
  if (prm === null || prm === void 0 ? void 0 : prm.opDate) {
@@ -110,7 +110,7 @@ export const tabLabel = (sale) => {
110
110
  };
111
111
  export const refSaleGenerator = () => {
112
112
  let date = new Date();
113
- const nDate = "C" + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString().split(":").join("");
113
+ const nDate = "C" + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString("en-US", { hour12: false }).split(":").join("");
114
114
  return removeBackSlashOccurences(nDate, "").toLocaleUpperCase();
115
115
  // return randomatic('A', 4) + date.toLocaleDateString().split('-').join('') + date.toLocaleTimeString().split(':').join('')
116
116
  };
@@ -16,6 +16,10 @@ export declare const getRandomColor: (brightness: number) => string;
16
16
  export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
17
17
  export declare const removeDuplicateValues: (array: any[]) => any[];
18
18
  export declare const duplicateObjects: (array: any[], property: string) => any[];
19
+ export declare const duplicateObjectsGrouped: (array: any[], keyProp?: string, prms?: {
20
+ arrProp?: string;
21
+ groupedByKeyProp?: boolean;
22
+ }) => any[];
19
23
  export declare const toObjectDate: (fromDate: any, toDate: string) => {
20
24
  fromDate: any;
21
25
  toDate: string;
@@ -64,7 +68,7 @@ export declare const formatNgbDate: (date: any) => {
64
68
  toDate: string;
65
69
  };
66
70
  export declare const genRandomColour: () => string;
67
- export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
71
+ export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean, options?: {}) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
68
72
  export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
69
73
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
70
74
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
package/lib/esm/utils.js CHANGED
@@ -130,6 +130,22 @@ export const removeDuplicateValues = (array) => {
130
130
  export const duplicateObjects = (array, property) => {
131
131
  return array.filter((obj, index) => array.findIndex(item => lodash.get(item, property) === lodash.get(obj, property)) !== index);
132
132
  };
133
+ export const duplicateObjectsGrouped = (array, keyProp = "id", prms) => {
134
+ const objs = array.reduce((acc, obj) => {
135
+ const key = obj[keyProp];
136
+ if (!acc[key]) {
137
+ acc[key] = [];
138
+ }
139
+ acc[key].push(obj);
140
+ return acc;
141
+ }, {});
142
+ const grouped = Object.values(objs);
143
+ const groupedByKeyProp = grouped.map((obj) => ({
144
+ [keyProp]: obj[0][keyProp],
145
+ [(prms === null || prms === void 0 ? void 0 : prms.arrProp) || "arr"]: obj,
146
+ }));
147
+ return (prms === null || prms === void 0 ? void 0 : prms.groupedByKeyProp) || true ? groupedByKeyProp : grouped;
148
+ };
133
149
  export const toObjectDate = (fromDate, toDate) => {
134
150
  toDate = toDate !== "null" ? toDate : fromDate;
135
151
  return { fromDate: fromDate, toDate: toDate };
@@ -225,7 +241,9 @@ export const removeBackSlashOccurences = (text, toChar) => {
225
241
  }; */
226
242
  export const refGenerator = (char = "c", regex = /\/+/gi, toChar = "") => {
227
243
  let date = new Date();
228
- let nDate = char.toUpperCase() + date.toLocaleDateString().split("-").join("") + date.toLocaleTimeString().split(":").join("");
244
+ let nDate = char.toUpperCase() +
245
+ date.toLocaleDateString().split("-").join("") +
246
+ date.toLocaleTimeString("en-US", { hour12: false }).split(":").join("");
229
247
  nDate = replaceAllIn(nDate, regex, toChar).toLocaleUpperCase();
230
248
  return nDate.indexOf(" ") ? nDate.substring(0, nDate.indexOf(" ")).trim() : nDate;
231
249
  };
@@ -385,7 +403,7 @@ export const formatNgbDate = (date) => {
385
403
  export const genRandomColour = () => {
386
404
  return "#" + Math.floor(Math.random() * 16777215).toString(16);
387
405
  };
388
- export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
406
+ export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass, options) => {
389
407
  const date = new Date();
390
408
  const date2 = new Date(inputDate);
391
409
  const diffNumber = Math.ceil(getNbOfDaysBetweenTwoDates(date2, date));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.44",
3
+ "version": "1.4.46",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -18,14 +18,14 @@
18
18
  "devDependencies": {
19
19
  "@types/express": "^5.0.3",
20
20
  "@types/jwt-decode": "^3.1.0",
21
- "@types/lodash": "^4.17.17",
21
+ "@types/lodash": "^4.17.19",
22
22
  "@types/pdfmake": "^0.2.11",
23
23
  "@types/randomatic": "^3.1.5",
24
- "@types/react": "^19.1.7"
24
+ "@types/react": "^19.1.8"
25
25
  },
26
26
  "dependencies": {
27
- "@tanstack/react-query": "^5.80.6",
28
- "axios": "^1.9.0",
27
+ "@tanstack/react-query": "^5.81.2",
28
+ "axios": "^1.10.0",
29
29
  "class-validator": "^0.14.2",
30
30
  "classnames": "^2.5.1",
31
31
  "dayjs": "^1.11.13",
@@ -34,7 +34,7 @@
34
34
  "lodash": "^4.17.21",
35
35
  "pdfmake": "^0.2.20",
36
36
  "randomatic": "^3.1.1",
37
- "typeorm": "^0.3.24",
37
+ "typeorm": "^0.3.25",
38
38
  "typescript": "^5.8.3",
39
39
  "yup": "^1.6.1",
40
40
  "zustand": "^5.0.5"