asv-hlps 1.2.24 → 1.2.27

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/lib/cjs/auth.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { User } from "./models/entities/users/User";
2
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
2
3
  export interface AuthParam {
3
4
  tag?: string;
4
5
  roles?: string[];
@@ -11,4 +12,4 @@ export interface AuthParam {
11
12
  steNames?: string[];
12
13
  url?: string;
13
14
  }
14
- export declare const getAuth: (authUser: User, authSte: string[], param?: AuthParam) => boolean;
15
+ export declare const getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
@@ -1,7 +1,7 @@
1
1
  export interface SteGrp {
2
- id: number;
3
- name: string;
2
+ id?: number;
3
+ name?: string;
4
4
  code?: string;
5
- shortname: string;
6
- coef: number;
5
+ shortname?: string;
6
+ coef?: number;
7
7
  }
@@ -1,8 +1,9 @@
1
- import { User } from './User';
1
+ import { User } from "./User";
2
+ import { UserNotarial } from "./UserNotatial";
2
3
  export interface UserOnline {
3
4
  id: number;
4
5
  date: Date;
5
6
  logged: string;
6
7
  logout: string;
7
- user: User;
8
+ user: User | UserNotarial;
8
9
  }
@@ -1,17 +1,17 @@
1
1
  import { NaAc } from "./shared/NaAc";
2
2
  import { NaCoAc } from "./shared/NaCoAc";
3
3
  import { NaCoShortAc } from "./shared/NaCoShortAc";
4
- import { colNa, colNaCo, colNaCoSh, FormProps, HeaderTableColumnType, IPath, MenuItemType } from "./types/Type";
4
+ import { colNa, colNaCo, colNaCoSh, FormPropsType, HeaderTableColumnType, IPath, MenuItemType } from "./types/Type";
5
+ export * from "./entities/auth/index";
5
6
  export * from "./entities/bills/index";
6
7
  export * from "./entities/buys/index";
7
- export * from "./entities/comptas/index";
8
- export * from "./entities/sales/index";
9
- export * from "./entities/users/index";
10
- export * from "./entities/world/index";
11
8
  export * from "./entities/cashs/index";
12
- export * from "./entities/auth/index";
9
+ export * from "./entities/comptas/index";
13
10
  export * from "./entities/docs/index";
14
11
  export * from "./entities/mails/index";
15
12
  export * from "./entities/products/index";
13
+ export * from "./entities/sales/index";
14
+ export * from "./entities/users/index";
16
15
  export * from "./entities/utilities/index";
17
- export { NaAc, NaCoAc, NaCoShortAc, MenuItemType, HeaderTableColumnType, IPath, colNa, colNaCo, colNaCoSh, FormProps };
16
+ export * from "./entities/world/index";
17
+ export { NaAc, NaCoAc, NaCoShortAc, MenuItemType, HeaderTableColumnType, IPath, colNa, colNaCo, colNaCoSh, FormPropsType };
@@ -19,15 +19,15 @@ const Type_1 = require("./types/Type");
19
19
  Object.defineProperty(exports, "colNa", { enumerable: true, get: function () { return Type_1.colNa; } });
20
20
  Object.defineProperty(exports, "colNaCo", { enumerable: true, get: function () { return Type_1.colNaCo; } });
21
21
  Object.defineProperty(exports, "colNaCoSh", { enumerable: true, get: function () { return Type_1.colNaCoSh; } });
22
+ __exportStar(require("./entities/auth/index"), exports);
22
23
  __exportStar(require("./entities/bills/index"), exports);
23
24
  __exportStar(require("./entities/buys/index"), exports);
24
- __exportStar(require("./entities/comptas/index"), exports);
25
- __exportStar(require("./entities/sales/index"), exports);
26
- __exportStar(require("./entities/users/index"), exports);
27
- __exportStar(require("./entities/world/index"), exports);
28
25
  __exportStar(require("./entities/cashs/index"), exports);
29
- __exportStar(require("./entities/auth/index"), exports);
26
+ __exportStar(require("./entities/comptas/index"), exports);
30
27
  __exportStar(require("./entities/docs/index"), exports);
31
28
  __exportStar(require("./entities/mails/index"), exports);
32
29
  __exportStar(require("./entities/products/index"), exports);
30
+ __exportStar(require("./entities/sales/index"), exports);
31
+ __exportStar(require("./entities/users/index"), exports);
33
32
  __exportStar(require("./entities/utilities/index"), exports);
33
+ __exportStar(require("./entities/world/index"), exports);
@@ -53,10 +53,10 @@ export declare type HeaderTableColumnType = {
53
53
  export declare const colNa: HeaderTableColumnType[];
54
54
  export declare const colNaCo: HeaderTableColumnType[];
55
55
  export declare const colNaCoSh: HeaderTableColumnType[];
56
- export declare type FormProps = {
56
+ export declare type FormPropsType<T> = {
57
57
  onSubmitForm?: (value: any) => any;
58
58
  onCancelForm?: (value: any) => any;
59
- tob?: any;
59
+ tob?: T;
60
60
  url?: string;
61
61
  };
62
62
  export interface TabContentType {
@@ -76,8 +76,8 @@ const yupValideUniqEmail = (url, tob, isRequired = true) => {
76
76
  if (isRequired) {
77
77
  return yup
78
78
  .string()
79
- .email("this value must be a valid email")
80
79
  .required("this value is required")
80
+ .email("this value must be a valid email")
81
81
  .test("Check_name", "This name is already taken", (value) => {
82
82
  return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
83
83
  const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
@@ -86,7 +86,7 @@ const yupValideUniqEmail = (url, tob, isRequired = true) => {
86
86
  });
87
87
  }
88
88
  return yup.string().when((val) => {
89
- if (val) {
89
+ if (val !== "") {
90
90
  return yup
91
91
  .string()
92
92
  .email()
@@ -137,9 +137,10 @@ exports.yupValideUniqCode = yupValideUniqCode;
137
137
  const yupValidateNoRequiredNumber = () => {
138
138
  return yup
139
139
  .string()
140
+ .nullable()
140
141
  .when((val) => {
141
142
  if (val) {
142
- return yup.number();
143
+ return yup.number().nullable();
143
144
  }
144
145
  })
145
146
  .typeError("must be number");
@@ -1,4 +1,5 @@
1
1
  import { User } from "../../models/entities/users/User";
2
+ import { UserNotarial } from "../../models/entities/users/UserNotatial";
2
3
  export declare const displayPdfDate: (label: string, fromDate: string, toDate: string) => string;
3
4
  export declare const displayTitle: (title: string) => {
4
5
  width: string;
@@ -8,7 +9,7 @@ export declare const displayTitle: (title: string) => {
8
9
  margin: number[];
9
10
  fontSize: number;
10
11
  };
11
- export declare const displayClient: (user: User) => {
12
+ export declare const displayClient: (user: User | UserNotarial) => {
12
13
  absolutePosition: {
13
14
  x: number;
14
15
  y: number;
@@ -1,3 +1,6 @@
1
+ import { AuthParam } from "../auth";
2
+ import { User } from "../models/entities/users/User";
3
+ import { UserNotarial } from "../models/entities/users/UserNotatial";
1
4
  export declare class AuthService {
2
5
  tokenKey: string;
3
6
  constructor(tokenkey: string);
@@ -8,6 +11,7 @@ export declare class AuthService {
8
11
  login: (tob: LoginType, httpService: any) => Promise<boolean>;
9
12
  logout: () => boolean;
10
13
  authUser: () => unknown;
14
+ getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
11
15
  }
12
16
  declare type LoginType = {
13
17
  username: string;
@@ -14,16 +14,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AuthService = void 0;
16
16
  const jwt_decode_1 = __importDefault(require("jwt-decode"));
17
+ const auth_1 = require("../auth");
17
18
  const storageService_1 = __importDefault(require("./storageService"));
18
19
  class AuthService {
19
20
  constructor(tokenkey) {
20
- this.tokenKey = "awPharma";
21
+ this.tokenKey = "";
21
22
  // getStorageToken = (tokenKey, local = false) => {
22
23
  this.getStorageToken = (local = false) => {
23
24
  if (!this.tokenKey) {
24
25
  return null;
25
26
  }
26
- return storageService_1.default.getStorage(this.tokenKey);
27
+ return storageService_1.default.getStorage(this.tokenKey, local);
27
28
  };
28
29
  // setStorageToken = (tokenKey, jwt) => {
29
30
  this.setStorageToken = (jwt) => {
@@ -67,6 +68,9 @@ class AuthService {
67
68
  return null;
68
69
  }
69
70
  };
71
+ this.getAuth = (authUser, authSte, param) => {
72
+ return (0, auth_1.getAuth)(authUser, authSte, param);
73
+ };
70
74
  this.tokenKey = tokenkey;
71
75
  }
72
76
  }
package/lib/cjs/user.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { Ste } from "./models/entities/users/Ste";
2
2
  import { User } from "./models/entities/users/User";
3
- export declare const inGrp: (grps: string[], user: User) => boolean;
4
- export declare const inSteGrp: (grps: string[], user: User) => boolean;
5
- export declare const hasRole: (roles: string[], user: User) => boolean;
6
- export declare const isBillPeriod: (user: User, period: string) => boolean;
7
- export declare const isStaffSte: (steNames: string[], user: User) => boolean;
8
- export declare const getFullname: (user: User) => string;
9
- export declare const entryDesignationUser: (user: User) => string;
3
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
4
+ export declare const inGrp: (grps: string[], user: User | UserNotarial) => boolean;
5
+ export declare const inSteGrp: (grps: string[], user: User | UserNotarial) => boolean;
6
+ export declare const hasRole: (roles: string[], user: User | UserNotarial) => boolean;
7
+ export declare const isBillPeriod: (user: User | UserNotarial, period: string) => boolean;
8
+ export declare const isStaffSte: (steNames: string[], user: User | UserNotarial) => boolean;
9
+ export declare const getFullname: (user: User | UserNotarial) => string;
10
+ export declare const entryDesignationUser: (user: User | UserNotarial) => string;
10
11
  export declare const secureUser: (user: any, username: string, heads: any) => void;
11
12
  export declare const secureUserPassword: (user: any, heads: any) => void;
12
- export declare const userGrpCode: (user: User) => string;
13
- export declare const userCoef: (user: User) => number;
13
+ export declare const userGrpCode: (user: User | UserNotarial) => string;
14
+ export declare const userCoef: (user: User | UserNotarial) => number;
14
15
  export declare const labelSteName: (ste: Ste, size?: number, tabs?: string[]) => string;
15
16
  export declare const getSteShortname: (ste: Ste, steGrpNames: string[]) => string;
package/lib/cjs/user.js CHANGED
@@ -49,7 +49,7 @@ const isBillPeriod = (user, period) => {
49
49
  return user.periodBill.toLowerCase() === period ? true : false;
50
50
  };
51
51
  exports.isBillPeriod = isBillPeriod;
52
- // export const isStaffSte = (user: User, steNames: string|string[]) => {
52
+ // export const isStaffSte = (user: User | UserNotarial, steNames: string|string[]) => {
53
53
  const isStaffSte = (steNames, user) => {
54
54
  /* if(!Array.isArray(steNames)) {
55
55
  return (user.ste.name.toLowerCase() === steNames.toLowerCase());
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
64
64
  export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
65
65
  export declare const validEmail: (email: string) => boolean;
66
66
  export declare const calculPercent: (nbr: number, percentage: number) => number;
67
+ export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
68
+ localLanguage?: string;
69
+ minusOne?: boolean;
70
+ }) => string;
67
71
  export declare const padStartWithZero: (num: any, targetLength: number) => any;
68
72
  export declare const padEndWithZero: (num: any, targetLength: number) => any;
69
73
  export declare const isBirthday: (birthDayDate: any) => boolean;
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
73
77
  export declare const randomHexColor: () => string;
74
78
  export declare const randomHslColor: () => number[];
75
79
  export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
80
+ export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
81
+ export declare const returnDates: (fromDate: any, toDate: any) => {
82
+ fromDate: any;
83
+ toDate: any;
84
+ };
85
+ export declare const absFromSequence: (arr: number[]) => number[];
86
+ export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
87
+ export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
package/lib/cjs/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateToString = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.reformatDates = exports.formatToStringCfa = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.removeDuplicatesByKey = exports.removeDuplicates = exports.getRandomColor = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.convertFrDateToEnDate = exports.convertEnDateToFr = exports.formatDateMd = exports.formatDateYm = exports.formatDateYmFirstDay = exports.formatDateYmd = exports.formatFromAndToDate = exports.formatDateYmHypen = exports.formatDateFirstDayFr = exports.formatDateYmdHypenFr = exports.formatDateYmdHypen = void 0;
4
- exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.calculPercent = void 0;
4
+ exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = void 0;
5
5
  const formatDateYmdHypen = (date) => {
6
6
  return (0, exports.formatDateYmd)(date, "-");
7
7
  };
@@ -379,6 +379,17 @@ const calculPercent = (nbr, percentage) => {
379
379
  return (nbr * percentage) / 100;
380
380
  };
381
381
  exports.calculPercent = calculPercent;
382
+ const formatMonthYearToLocaleString = (date, prms) => {
383
+ if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
384
+ date.setMonth(date.getMonth() - 1);
385
+ }
386
+ const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
387
+ ? date.toLocaleDateString("FR-fr", { month: "long" })
388
+ : date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
389
+ const year = date.getFullYear();
390
+ return month.toUpperCase() + " " + year;
391
+ };
392
+ exports.formatMonthYearToLocaleString = formatMonthYearToLocaleString;
382
393
  const padStartWithZero = (num, targetLength) => {
383
394
  return num.toString().padStart(targetLength, 0);
384
395
  };
@@ -450,3 +461,32 @@ const getArrayOfRandomColor = (length, type = "hex") => {
450
461
  return colors;
451
462
  };
452
463
  exports.getArrayOfRandomColor = getArrayOfRandomColor;
464
+ const displayFrDatePeriode = (getFromDate, getToDate) => {
465
+ const fromDate = !getFromDate ? new Date() : getFromDate;
466
+ const toDate = !getToDate ? fromDate : getToDate;
467
+ return (0, exports.formatDateYmdHypenFr)(new Date(fromDate)) + " au " + (0, exports.formatDateYmdHypenFr)(new Date(toDate));
468
+ };
469
+ exports.displayFrDatePeriode = displayFrDatePeriode;
470
+ const returnDates = (fromDate, toDate) => {
471
+ if (fromDate === undefined || fromDate === null) {
472
+ return;
473
+ }
474
+ // toDate = toDate !== 'null' ? toDate : fromDate;
475
+ toDate = !toDate ? fromDate : toDate;
476
+ return { fromDate, toDate };
477
+ };
478
+ exports.returnDates = returnDates;
479
+ const absFromSequence = (arr) => {
480
+ let [min, max] = [Math.min(...arr), Math.max(...arr)];
481
+ // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
482
+ return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
483
+ };
484
+ exports.absFromSequence = absFromSequence;
485
+ const fillStartWithZero = (num, targetLength) => {
486
+ return num.toString().padStart(targetLength, "0");
487
+ };
488
+ exports.fillStartWithZero = fillStartWithZero;
489
+ const fillEndWithZero = (num, targetLength) => {
490
+ return num.toString().padEnd(targetLength, "0");
491
+ };
492
+ exports.fillEndWithZero = fillEndWithZero;
package/lib/esm/auth.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { User } from "./models/entities/users/User";
2
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
2
3
  export interface AuthParam {
3
4
  tag?: string;
4
5
  roles?: string[];
@@ -11,4 +12,4 @@ export interface AuthParam {
11
12
  steNames?: string[];
12
13
  url?: string;
13
14
  }
14
- export declare const getAuth: (authUser: User, authSte: string[], param?: AuthParam) => boolean;
15
+ export declare const getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
@@ -1,7 +1,7 @@
1
1
  export interface SteGrp {
2
- id: number;
3
- name: string;
2
+ id?: number;
3
+ name?: string;
4
4
  code?: string;
5
- shortname: string;
6
- coef: number;
5
+ shortname?: string;
6
+ coef?: number;
7
7
  }
@@ -1,8 +1,9 @@
1
- import { User } from './User';
1
+ import { User } from "./User";
2
+ import { UserNotarial } from "./UserNotatial";
2
3
  export interface UserOnline {
3
4
  id: number;
4
5
  date: Date;
5
6
  logged: string;
6
7
  logout: string;
7
- user: User;
8
+ user: User | UserNotarial;
8
9
  }
@@ -1,17 +1,17 @@
1
1
  import { NaAc } from "./shared/NaAc";
2
2
  import { NaCoAc } from "./shared/NaCoAc";
3
3
  import { NaCoShortAc } from "./shared/NaCoShortAc";
4
- import { colNa, colNaCo, colNaCoSh, FormProps, HeaderTableColumnType, IPath, MenuItemType } from "./types/Type";
4
+ import { colNa, colNaCo, colNaCoSh, FormPropsType, HeaderTableColumnType, IPath, MenuItemType } from "./types/Type";
5
+ export * from "./entities/auth/index";
5
6
  export * from "./entities/bills/index";
6
7
  export * from "./entities/buys/index";
7
- export * from "./entities/comptas/index";
8
- export * from "./entities/sales/index";
9
- export * from "./entities/users/index";
10
- export * from "./entities/world/index";
11
8
  export * from "./entities/cashs/index";
12
- export * from "./entities/auth/index";
9
+ export * from "./entities/comptas/index";
13
10
  export * from "./entities/docs/index";
14
11
  export * from "./entities/mails/index";
15
12
  export * from "./entities/products/index";
13
+ export * from "./entities/sales/index";
14
+ export * from "./entities/users/index";
16
15
  export * from "./entities/utilities/index";
17
- export { NaAc, NaCoAc, NaCoShortAc, MenuItemType, HeaderTableColumnType, IPath, colNa, colNaCo, colNaCoSh, FormProps };
16
+ export * from "./entities/world/index";
17
+ export { NaAc, NaCoAc, NaCoShortAc, MenuItemType, HeaderTableColumnType, IPath, colNa, colNaCo, colNaCoSh, FormPropsType };
@@ -1,14 +1,14 @@
1
1
  import { colNa, colNaCo, colNaCoSh } from "./types/Type";
2
+ export * from "./entities/auth/index";
2
3
  export * from "./entities/bills/index";
3
4
  export * from "./entities/buys/index";
4
- export * from "./entities/comptas/index";
5
- export * from "./entities/sales/index";
6
- export * from "./entities/users/index";
7
- export * from "./entities/world/index";
8
5
  export * from "./entities/cashs/index";
9
- export * from "./entities/auth/index";
6
+ export * from "./entities/comptas/index";
10
7
  export * from "./entities/docs/index";
11
8
  export * from "./entities/mails/index";
12
9
  export * from "./entities/products/index";
10
+ export * from "./entities/sales/index";
11
+ export * from "./entities/users/index";
13
12
  export * from "./entities/utilities/index";
13
+ export * from "./entities/world/index";
14
14
  export { colNa, colNaCo, colNaCoSh };
@@ -53,10 +53,10 @@ export declare type HeaderTableColumnType = {
53
53
  export declare const colNa: HeaderTableColumnType[];
54
54
  export declare const colNaCo: HeaderTableColumnType[];
55
55
  export declare const colNaCoSh: HeaderTableColumnType[];
56
- export declare type FormProps = {
56
+ export declare type FormPropsType<T> = {
57
57
  onSubmitForm?: (value: any) => any;
58
58
  onCancelForm?: (value: any) => any;
59
- tob?: any;
59
+ tob?: T;
60
60
  url?: string;
61
61
  };
62
62
  export interface TabContentType {
@@ -42,8 +42,8 @@ export const yupValideUniqEmail = (url, tob, isRequired = true) => {
42
42
  if (isRequired) {
43
43
  return yup
44
44
  .string()
45
- .email("this value must be a valid email")
46
45
  .required("this value is required")
46
+ .email("this value must be a valid email")
47
47
  .test("Check_name", "This name is already taken", (value) => {
48
48
  return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
49
49
  const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
@@ -52,7 +52,7 @@ export const yupValideUniqEmail = (url, tob, isRequired = true) => {
52
52
  });
53
53
  }
54
54
  return yup.string().when((val) => {
55
- if (val) {
55
+ if (val !== "") {
56
56
  return yup
57
57
  .string()
58
58
  .email()
@@ -100,9 +100,10 @@ export const yupValideUniqCode = (url, max = 4, tob) => {
100
100
  export const yupValidateNoRequiredNumber = () => {
101
101
  return yup
102
102
  .string()
103
+ .nullable()
103
104
  .when((val) => {
104
105
  if (val) {
105
- return yup.number();
106
+ return yup.number().nullable();
106
107
  }
107
108
  })
108
109
  .typeError("must be number");
@@ -1,4 +1,5 @@
1
1
  import { User } from "../../models/entities/users/User";
2
+ import { UserNotarial } from "../../models/entities/users/UserNotatial";
2
3
  export declare const displayPdfDate: (label: string, fromDate: string, toDate: string) => string;
3
4
  export declare const displayTitle: (title: string) => {
4
5
  width: string;
@@ -8,7 +9,7 @@ export declare const displayTitle: (title: string) => {
8
9
  margin: number[];
9
10
  fontSize: number;
10
11
  };
11
- export declare const displayClient: (user: User) => {
12
+ export declare const displayClient: (user: User | UserNotarial) => {
12
13
  absolutePosition: {
13
14
  x: number;
14
15
  y: number;
@@ -1,3 +1,6 @@
1
+ import { AuthParam } from "../auth";
2
+ import { User } from "../models/entities/users/User";
3
+ import { UserNotarial } from "../models/entities/users/UserNotatial";
1
4
  export declare class AuthService {
2
5
  tokenKey: string;
3
6
  constructor(tokenkey: string);
@@ -8,6 +11,7 @@ export declare class AuthService {
8
11
  login: (tob: LoginType, httpService: any) => Promise<boolean>;
9
12
  logout: () => boolean;
10
13
  authUser: () => unknown;
14
+ getAuth: (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => boolean;
11
15
  }
12
16
  declare type LoginType = {
13
17
  username: string;
@@ -8,16 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import jwtDecode from "jwt-decode";
11
+ import { getAuth } from "../auth";
11
12
  import storageService from "./storageService";
12
13
  export class AuthService {
13
14
  constructor(tokenkey) {
14
- this.tokenKey = "awPharma";
15
+ this.tokenKey = "";
15
16
  // getStorageToken = (tokenKey, local = false) => {
16
17
  this.getStorageToken = (local = false) => {
17
18
  if (!this.tokenKey) {
18
19
  return null;
19
20
  }
20
- return storageService.getStorage(this.tokenKey);
21
+ return storageService.getStorage(this.tokenKey, local);
21
22
  };
22
23
  // setStorageToken = (tokenKey, jwt) => {
23
24
  this.setStorageToken = (jwt) => {
@@ -61,6 +62,9 @@ export class AuthService {
61
62
  return null;
62
63
  }
63
64
  };
65
+ this.getAuth = (authUser, authSte, param) => {
66
+ return getAuth(authUser, authSte, param);
67
+ };
64
68
  this.tokenKey = tokenkey;
65
69
  }
66
70
  }
package/lib/esm/user.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { Ste } from "./models/entities/users/Ste";
2
2
  import { User } from "./models/entities/users/User";
3
- export declare const inGrp: (grps: string[], user: User) => boolean;
4
- export declare const inSteGrp: (grps: string[], user: User) => boolean;
5
- export declare const hasRole: (roles: string[], user: User) => boolean;
6
- export declare const isBillPeriod: (user: User, period: string) => boolean;
7
- export declare const isStaffSte: (steNames: string[], user: User) => boolean;
8
- export declare const getFullname: (user: User) => string;
9
- export declare const entryDesignationUser: (user: User) => string;
3
+ import { UserNotarial } from "./models/entities/users/UserNotatial";
4
+ export declare const inGrp: (grps: string[], user: User | UserNotarial) => boolean;
5
+ export declare const inSteGrp: (grps: string[], user: User | UserNotarial) => boolean;
6
+ export declare const hasRole: (roles: string[], user: User | UserNotarial) => boolean;
7
+ export declare const isBillPeriod: (user: User | UserNotarial, period: string) => boolean;
8
+ export declare const isStaffSte: (steNames: string[], user: User | UserNotarial) => boolean;
9
+ export declare const getFullname: (user: User | UserNotarial) => string;
10
+ export declare const entryDesignationUser: (user: User | UserNotarial) => string;
10
11
  export declare const secureUser: (user: any, username: string, heads: any) => void;
11
12
  export declare const secureUserPassword: (user: any, heads: any) => void;
12
- export declare const userGrpCode: (user: User) => string;
13
- export declare const userCoef: (user: User) => number;
13
+ export declare const userGrpCode: (user: User | UserNotarial) => string;
14
+ export declare const userCoef: (user: User | UserNotarial) => number;
14
15
  export declare const labelSteName: (ste: Ste, size?: number, tabs?: string[]) => string;
15
16
  export declare const getSteShortname: (ste: Ste, steGrpNames: string[]) => string;
package/lib/esm/user.js CHANGED
@@ -16,7 +16,7 @@ export const hasRole = (roles, user) => {
16
16
  export const isBillPeriod = (user, period) => {
17
17
  return user.periodBill.toLowerCase() === period ? true : false;
18
18
  };
19
- // export const isStaffSte = (user: User, steNames: string|string[]) => {
19
+ // export const isStaffSte = (user: User | UserNotarial, steNames: string|string[]) => {
20
20
  export const isStaffSte = (steNames, user) => {
21
21
  /* if(!Array.isArray(steNames)) {
22
22
  return (user.ste.name.toLowerCase() === steNames.toLowerCase());
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
64
64
  export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
65
65
  export declare const validEmail: (email: string) => boolean;
66
66
  export declare const calculPercent: (nbr: number, percentage: number) => number;
67
+ export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
68
+ localLanguage?: string;
69
+ minusOne?: boolean;
70
+ }) => string;
67
71
  export declare const padStartWithZero: (num: any, targetLength: number) => any;
68
72
  export declare const padEndWithZero: (num: any, targetLength: number) => any;
69
73
  export declare const isBirthday: (birthDayDate: any) => boolean;
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
73
77
  export declare const randomHexColor: () => string;
74
78
  export declare const randomHslColor: () => number[];
75
79
  export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
80
+ export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
81
+ export declare const returnDates: (fromDate: any, toDate: any) => {
82
+ fromDate: any;
83
+ toDate: any;
84
+ };
85
+ export declare const absFromSequence: (arr: number[]) => number[];
86
+ export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
87
+ export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
package/lib/esm/utils.js CHANGED
@@ -324,6 +324,16 @@ export const validEmail = (email) => {
324
324
  export const calculPercent = (nbr, percentage) => {
325
325
  return (nbr * percentage) / 100;
326
326
  };
327
+ export const formatMonthYearToLocaleString = (date, prms) => {
328
+ if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
329
+ date.setMonth(date.getMonth() - 1);
330
+ }
331
+ const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
332
+ ? date.toLocaleDateString("FR-fr", { month: "long" })
333
+ : date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
334
+ const year = date.getFullYear();
335
+ return month.toUpperCase() + " " + year;
336
+ };
327
337
  export const padStartWithZero = (num, targetLength) => {
328
338
  return num.toString().padStart(targetLength, 0);
329
339
  };
@@ -386,3 +396,27 @@ export const getArrayOfRandomColor = (length, type = "hex") => {
386
396
  }
387
397
  return colors;
388
398
  };
399
+ export const displayFrDatePeriode = (getFromDate, getToDate) => {
400
+ const fromDate = !getFromDate ? new Date() : getFromDate;
401
+ const toDate = !getToDate ? fromDate : getToDate;
402
+ return formatDateYmdHypenFr(new Date(fromDate)) + " au " + formatDateYmdHypenFr(new Date(toDate));
403
+ };
404
+ export const returnDates = (fromDate, toDate) => {
405
+ if (fromDate === undefined || fromDate === null) {
406
+ return;
407
+ }
408
+ // toDate = toDate !== 'null' ? toDate : fromDate;
409
+ toDate = !toDate ? fromDate : toDate;
410
+ return { fromDate, toDate };
411
+ };
412
+ export const absFromSequence = (arr) => {
413
+ let [min, max] = [Math.min(...arr), Math.max(...arr)];
414
+ // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
415
+ return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
416
+ };
417
+ export const fillStartWithZero = (num, targetLength) => {
418
+ return num.toString().padStart(targetLength, "0");
419
+ };
420
+ export const fillEndWithZero = (num, targetLength) => {
421
+ return num.toString().padEnd(targetLength, "0");
422
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.24",
3
+ "version": "1.2.27",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",