asv-hlps 1.4.9 → 1.4.10

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.
Files changed (167) hide show
  1. package/lib/cjs/auth/auth.d.ts +1 -1
  2. package/lib/cjs/auth/auth.js +12 -18
  3. package/lib/cjs/auth/authService.js +0 -13
  4. package/lib/cjs/auth/models/AuthTag.d.ts +0 -2
  5. package/lib/cjs/auth/models/index.d.ts +0 -1
  6. package/lib/cjs/cashs/models/index.d.ts +0 -1
  7. package/lib/cjs/users/models/User.d.ts +1 -1
  8. package/lib/cjs/users/models/UserAbs.d.ts +1 -1
  9. package/lib/cjs/users/models/UserBase.d.ts +14 -14
  10. package/lib/cjs/utils.d.ts +0 -1
  11. package/lib/cjs/utils.js +0 -5
  12. package/lib/esm/auth/auth.d.ts +1 -1
  13. package/lib/esm/auth/auth.js +12 -18
  14. package/lib/esm/auth/authService.js +0 -13
  15. package/lib/esm/auth/models/AuthTag.d.ts +0 -2
  16. package/lib/esm/auth/models/index.d.ts +0 -1
  17. package/lib/esm/cashs/models/index.d.ts +0 -1
  18. package/lib/esm/users/models/User.d.ts +1 -1
  19. package/lib/esm/users/models/UserAbs.d.ts +1 -1
  20. package/lib/esm/users/models/UserBase.d.ts +14 -14
  21. package/lib/esm/utils.d.ts +0 -1
  22. package/lib/esm/utils.js +0 -4
  23. package/package.json +4 -3
  24. package/lib/cjs/auth/models/AuthTagGrp.d.ts +0 -3
  25. package/lib/cjs/auth/models/AuthTagGrp.js +0 -2
  26. package/lib/cjs/auth/models/AuthTagSub.d.ts +0 -3
  27. package/lib/cjs/auth/models/AuthTagSub.js +0 -2
  28. package/lib/cjs/bootstrap.d.ts +0 -1
  29. package/lib/cjs/bootstrap.js +0 -2
  30. package/lib/cjs/cashs/models/PaymentMode.d.ts +0 -5
  31. package/lib/cjs/cashs/models/PaymentMode.js +0 -2
  32. package/lib/cjs/markets/index.d.ts +0 -2
  33. package/lib/cjs/markets/index.js +0 -18
  34. package/lib/cjs/markets/models/Market.d.ts +0 -8
  35. package/lib/cjs/markets/models/Market.js +0 -2
  36. package/lib/cjs/markets/models/UMarket.d.ts +0 -11
  37. package/lib/cjs/markets/models/UMarket.js +0 -2
  38. package/lib/cjs/markets/models/index.d.ts +0 -2
  39. package/lib/cjs/markets/models/index.js +0 -18
  40. package/lib/cjs/markets/products/hlpProduct.d.ts +0 -13
  41. package/lib/cjs/markets/products/hlpProduct.js +0 -49
  42. package/lib/cjs/markets/products/index.d.ts +0 -2
  43. package/lib/cjs/markets/products/index.js +0 -23
  44. package/lib/cjs/markets/products/models/Product.d.ts +0 -39
  45. package/lib/cjs/markets/products/models/Product.js +0 -2
  46. package/lib/cjs/markets/products/models/ProductAsset.d.ts +0 -8
  47. package/lib/cjs/markets/products/models/ProductAsset.js +0 -2
  48. package/lib/cjs/markets/products/models/ProductCat.d.ts +0 -3
  49. package/lib/cjs/markets/products/models/ProductCat.js +0 -2
  50. package/lib/cjs/markets/products/models/ProductCollection.d.ts +0 -3
  51. package/lib/cjs/markets/products/models/ProductCollection.js +0 -2
  52. package/lib/cjs/markets/products/models/ProductDepot.d.ts +0 -11
  53. package/lib/cjs/markets/products/models/ProductDepot.js +0 -2
  54. package/lib/cjs/markets/products/models/ProductElt.d.ts +0 -3
  55. package/lib/cjs/markets/products/models/ProductElt.js +0 -2
  56. package/lib/cjs/markets/products/models/ProductGrp.d.ts +0 -3
  57. package/lib/cjs/markets/products/models/ProductGrp.js +0 -2
  58. package/lib/cjs/markets/products/models/ProductImage.d.ts +0 -5
  59. package/lib/cjs/markets/products/models/ProductImage.js +0 -2
  60. package/lib/cjs/markets/products/models/ProductIn.d.ts +0 -42
  61. package/lib/cjs/markets/products/models/ProductIn.js +0 -2
  62. package/lib/cjs/markets/products/models/ProductState.d.ts +0 -3
  63. package/lib/cjs/markets/products/models/ProductState.js +0 -2
  64. package/lib/cjs/markets/products/models/ProductStock.d.ts +0 -6
  65. package/lib/cjs/markets/products/models/ProductStock.js +0 -2
  66. package/lib/cjs/markets/products/models/ProductTag.d.ts +0 -3
  67. package/lib/cjs/markets/products/models/ProductTag.js +0 -2
  68. package/lib/cjs/markets/products/models/ProductVariant.d.ts +0 -6
  69. package/lib/cjs/markets/products/models/ProductVariant.js +0 -2
  70. package/lib/cjs/markets/products/models/index.d.ts +0 -13
  71. package/lib/cjs/markets/products/models/index.js +0 -29
  72. package/lib/cjs/markets/sales/index.d.ts +0 -1
  73. package/lib/cjs/markets/sales/index.js +0 -17
  74. package/lib/cjs/markets/sales/models/Sale.d.ts +0 -8
  75. package/lib/cjs/markets/sales/models/Sale.js +0 -2
  76. package/lib/cjs/markets/sales/models/SalePayment.d.ts +0 -23
  77. package/lib/cjs/markets/sales/models/SalePayment.js +0 -2
  78. package/lib/cjs/markets/sales/models/SaleProduct.d.ts +0 -8
  79. package/lib/cjs/markets/sales/models/SaleProduct.js +0 -2
  80. package/lib/cjs/markets/sales/models/index.d.ts +0 -3
  81. package/lib/cjs/markets/sales/models/index.js +0 -19
  82. package/lib/cjs/markets/shops/index.d.ts +0 -1
  83. package/lib/cjs/markets/shops/index.js +0 -17
  84. package/lib/cjs/markets/shops/models/Shop.d.ts +0 -13
  85. package/lib/cjs/markets/shops/models/Shop.js +0 -2
  86. package/lib/cjs/markets/users/models/User.d.ts +0 -7
  87. package/lib/cjs/markets/users/models/User.js +0 -2
  88. package/lib/cjs/shared/models/IIcon.d.ts +0 -4
  89. package/lib/cjs/shared/models/IIcon.js +0 -6
  90. package/lib/cjs/shared/models/NaAcIc.d.ts +0 -7
  91. package/lib/cjs/shared/models/NaAcIc.js +0 -7
  92. package/lib/cjs/shared/models/NaCoAcIc.d.ts +0 -4
  93. package/lib/cjs/shared/models/NaCoAcIc.js +0 -7
  94. package/lib/cjs/users/models/EUserTag.d.ts +0 -14
  95. package/lib/cjs/users/models/EUserTag.js +0 -2
  96. package/lib/esm/auth/models/AuthTagGrp.d.ts +0 -3
  97. package/lib/esm/auth/models/AuthTagGrp.js +0 -1
  98. package/lib/esm/auth/models/AuthTagSub.d.ts +0 -3
  99. package/lib/esm/auth/models/AuthTagSub.js +0 -1
  100. package/lib/esm/bootstrap.d.ts +0 -1
  101. package/lib/esm/bootstrap.js +0 -1
  102. package/lib/esm/cashs/models/PaymentMode.d.ts +0 -5
  103. package/lib/esm/cashs/models/PaymentMode.js +0 -1
  104. package/lib/esm/markets/index.d.ts +0 -2
  105. package/lib/esm/markets/index.js +0 -2
  106. package/lib/esm/markets/models/Market.d.ts +0 -8
  107. package/lib/esm/markets/models/Market.js +0 -1
  108. package/lib/esm/markets/models/UMarket.d.ts +0 -11
  109. package/lib/esm/markets/models/UMarket.js +0 -1
  110. package/lib/esm/markets/models/index.d.ts +0 -2
  111. package/lib/esm/markets/models/index.js +0 -2
  112. package/lib/esm/markets/products/hlpProduct.d.ts +0 -13
  113. package/lib/esm/markets/products/hlpProduct.js +0 -47
  114. package/lib/esm/markets/products/index.d.ts +0 -2
  115. package/lib/esm/markets/products/index.js +0 -2
  116. package/lib/esm/markets/products/models/Product.d.ts +0 -39
  117. package/lib/esm/markets/products/models/Product.js +0 -1
  118. package/lib/esm/markets/products/models/ProductAsset.d.ts +0 -8
  119. package/lib/esm/markets/products/models/ProductAsset.js +0 -1
  120. package/lib/esm/markets/products/models/ProductCat.d.ts +0 -3
  121. package/lib/esm/markets/products/models/ProductCat.js +0 -1
  122. package/lib/esm/markets/products/models/ProductCollection.d.ts +0 -3
  123. package/lib/esm/markets/products/models/ProductCollection.js +0 -1
  124. package/lib/esm/markets/products/models/ProductDepot.d.ts +0 -11
  125. package/lib/esm/markets/products/models/ProductDepot.js +0 -1
  126. package/lib/esm/markets/products/models/ProductElt.d.ts +0 -3
  127. package/lib/esm/markets/products/models/ProductElt.js +0 -1
  128. package/lib/esm/markets/products/models/ProductGrp.d.ts +0 -3
  129. package/lib/esm/markets/products/models/ProductGrp.js +0 -1
  130. package/lib/esm/markets/products/models/ProductImage.d.ts +0 -5
  131. package/lib/esm/markets/products/models/ProductImage.js +0 -1
  132. package/lib/esm/markets/products/models/ProductIn.d.ts +0 -42
  133. package/lib/esm/markets/products/models/ProductIn.js +0 -1
  134. package/lib/esm/markets/products/models/ProductState.d.ts +0 -3
  135. package/lib/esm/markets/products/models/ProductState.js +0 -1
  136. package/lib/esm/markets/products/models/ProductStock.d.ts +0 -6
  137. package/lib/esm/markets/products/models/ProductStock.js +0 -1
  138. package/lib/esm/markets/products/models/ProductTag.d.ts +0 -3
  139. package/lib/esm/markets/products/models/ProductTag.js +0 -1
  140. package/lib/esm/markets/products/models/ProductVariant.d.ts +0 -6
  141. package/lib/esm/markets/products/models/ProductVariant.js +0 -1
  142. package/lib/esm/markets/products/models/index.d.ts +0 -13
  143. package/lib/esm/markets/products/models/index.js +0 -13
  144. package/lib/esm/markets/sales/index.d.ts +0 -1
  145. package/lib/esm/markets/sales/index.js +0 -1
  146. package/lib/esm/markets/sales/models/Sale.d.ts +0 -8
  147. package/lib/esm/markets/sales/models/Sale.js +0 -1
  148. package/lib/esm/markets/sales/models/SalePayment.d.ts +0 -23
  149. package/lib/esm/markets/sales/models/SalePayment.js +0 -1
  150. package/lib/esm/markets/sales/models/SaleProduct.d.ts +0 -8
  151. package/lib/esm/markets/sales/models/SaleProduct.js +0 -1
  152. package/lib/esm/markets/sales/models/index.d.ts +0 -3
  153. package/lib/esm/markets/sales/models/index.js +0 -3
  154. package/lib/esm/markets/shops/index.d.ts +0 -1
  155. package/lib/esm/markets/shops/index.js +0 -1
  156. package/lib/esm/markets/shops/models/Shop.d.ts +0 -13
  157. package/lib/esm/markets/shops/models/Shop.js +0 -1
  158. package/lib/esm/markets/users/models/User.d.ts +0 -7
  159. package/lib/esm/markets/users/models/User.js +0 -1
  160. package/lib/esm/shared/models/IIcon.d.ts +0 -4
  161. package/lib/esm/shared/models/IIcon.js +0 -2
  162. package/lib/esm/shared/models/NaAcIc.d.ts +0 -7
  163. package/lib/esm/shared/models/NaAcIc.js +0 -3
  164. package/lib/esm/shared/models/NaCoAcIc.d.ts +0 -4
  165. package/lib/esm/shared/models/NaCoAcIc.js +0 -3
  166. package/lib/esm/users/models/EUserTag.d.ts +0 -14
  167. package/lib/esm/users/models/EUserTag.js +0 -1
@@ -18,7 +18,7 @@ interface AuthParam {
18
18
  url?: string;
19
19
  }
20
20
  type TData = {
21
- tags?: AuthTag[] | string[];
21
+ tags?: AuthTag[];
22
22
  ste: Ste;
23
23
  role: UserRole;
24
24
  roles: string[];
@@ -2,28 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAuth = void 0;
4
4
  const user_1 = require("../users/user");
5
- const utils_1 = require("../utils");
6
5
  const arraySome = (arr1, arr2) => {
7
6
  return arr1.some((x) => arr2.includes(x));
8
7
  };
9
8
  const getAuth = (authUser, authSte, param) => {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11
- if ((param === null || param === void 0 ? void 0 : param.tag) && ((_a = authUser === null || authUser === void 0 ? void 0 : authUser.tags) === null || _a === void 0 ? void 0 : _a.length)) {
12
- let tags = [];
13
- if ((0, utils_1.checkIsStringOfArray)(authUser.tags)) {
14
- tags = authUser === null || authUser === void 0 ? void 0 : authUser.tags;
9
+ var _a, _b, _c, _d, _e, _f;
10
+ if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
11
+ const tags = [];
12
+ for (const tag of authUser.tags) {
13
+ tags.push(tag.code.toLowerCase());
15
14
  }
16
- else {
17
- for (const tag of authUser.tags) {
18
- tags.push((_b = tag === null || tag === void 0 ? void 0 : tag.code) === null || _b === void 0 ? void 0 : _b.toLowerCase());
19
- }
20
- }
21
- const authIn = tags === null || tags === void 0 ? void 0 : tags.includes((_c = param === null || param === void 0 ? void 0 : param.tag) === null || _c === void 0 ? void 0 : _c.toLowerCase());
15
+ const authIn = tags.includes(param.tag.toLowerCase());
22
16
  if (authIn) {
23
17
  return true;
24
18
  }
25
19
  }
26
- if (((_d = param === null || param === void 0 ? void 0 : param.roles) === null || _d === void 0 ? void 0 : _d.length) > 0) {
20
+ if (((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) > 0) {
27
21
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
28
22
  return true;
29
23
  } */
@@ -33,7 +27,7 @@ const getAuth = (authUser, authSte, param) => {
33
27
  }
34
28
  // ------ staff ------
35
29
  if (param === null || param === void 0 ? void 0 : param.staff) {
36
- if (((_e = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _e === void 0 ? void 0 : _e.length) > 0 &&
30
+ if (((_b = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
37
31
  (0, user_1.isStaffSte)(authSte, authUser.ste.name) &&
38
32
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
39
33
  return true;
@@ -54,7 +48,7 @@ const getAuth = (authUser, authSte, param) => {
54
48
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
55
49
  return true;
56
50
  }
57
- if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
51
+ if (((_c = param === null || param === void 0 ? void 0 : param.client.roles) === null || _c === void 0 ? void 0 : _c.length) &&
58
52
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
59
53
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
60
54
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -63,13 +57,13 @@ const getAuth = (authUser, authSte, param) => {
63
57
  }
64
58
  }
65
59
  // ------ ste grps ------
66
- if (((_g = param === null || param === void 0 ? void 0 : param.steGrps) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
60
+ if (((_d = param === null || param === void 0 ? void 0 : param.steGrps) === null || _d === void 0 ? void 0 : _d.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
67
61
  return true;
68
62
  }
69
- if (((_h = param === null || param === void 0 ? void 0 : param.grps) === null || _h === void 0 ? void 0 : _h.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
63
+ if (((_e = param === null || param === void 0 ? void 0 : param.grps) === null || _e === void 0 ? void 0 : _e.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
70
64
  return true;
71
65
  }
72
- if (((_j = param === null || param === void 0 ? void 0 : param.steNames) === null || _j === void 0 ? void 0 : _j.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
66
+ if (((_f = param === null || param === void 0 ? void 0 : param.steNames) === null || _f === void 0 ? void 0 : _f.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
73
67
  return true;
74
68
  }
75
69
  return false;
@@ -53,15 +53,6 @@ class AuthService {
53
53
  return false;
54
54
  }
55
55
  });
56
- /* login = async (tob: LoginType, httpService: any) => {
57
- try {
58
- const { data: jwt } = await httpService.post("auth/login", tob);
59
- this.setStorageToken(jwt.token);
60
- return true;
61
- } catch (error) {
62
- console.log(error);
63
- }
64
- }; */
65
56
  this.logout = () => {
66
57
  this.removeStorageToken();
67
58
  // userAuthNavigate("/");
@@ -78,9 +69,6 @@ class AuthService {
78
69
  return null;
79
70
  }
80
71
  };
81
- /* getAuth = (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => {
82
- return getAuth(authUser, authSte, param);
83
- }; */
84
72
  this.getAuth = (param) => {
85
73
  return (0, auth_1.getAuth)(this.authUser(), this.authStes, param);
86
74
  };
@@ -92,4 +80,3 @@ class AuthService {
92
80
  }
93
81
  }
94
82
  exports.AuthService = AuthService;
95
- // export default new AuthService("awPharma");
@@ -1,8 +1,6 @@
1
1
  import NaCoAc from "../../shared/models/NaCoAc";
2
2
  import AuthTagCat from "./AuthTagCat";
3
- import AuthTagSub from "./AuthTagSub";
4
3
  export default interface AuthTag extends NaCoAc {
5
4
  cat?: AuthTagCat;
6
- subs?: AuthTagSub[];
7
5
  isChecked?: boolean;
8
6
  }
@@ -1,3 +1,2 @@
1
1
  export { default as AuthTag } from "./AuthTag";
2
2
  export { default as AuthTagCat } from "./AuthTagCat";
3
- export { default as AuthTagSub } from "./AuthTagSub";
@@ -3,5 +3,4 @@ export { default as BankAccount } from "./BankAccount";
3
3
  export { default as Currency } from "./Currency";
4
4
  export { default as Deposit } from "./Deposit";
5
5
  export { default as Feed } from "./Feed";
6
- export { default as PaymentMode } from "./PaymentMode";
7
6
  export { default as Spent } from "./Spent";
@@ -38,7 +38,7 @@ export default interface User extends Address {
38
38
  tags?: AuthTag[];
39
39
  zone?: Zone;
40
40
  role?: UserRole;
41
- roles?: UserRole[];
41
+ roles?: string[];
42
42
  ste?: Ste;
43
43
  fullname?: string;
44
44
  }
@@ -25,7 +25,7 @@ export default interface UserAbs extends Address {
25
25
  grp?: UserGrp;
26
26
  tags?: AuthTag[];
27
27
  role?: UserRole;
28
- roles?: UserRole[];
28
+ roles?: string[];
29
29
  ste?: Ste;
30
30
  fullname?: string;
31
31
  }
@@ -7,25 +7,25 @@ import UserRole from "./UserRole";
7
7
  import UserTitr from "./UserTitr";
8
8
  export default interface UserBase extends Address {
9
9
  id: number;
10
- codeCompta?: string | number;
11
- firstname: string;
12
- lastname: string;
13
- username?: string;
14
10
  birthday?: Date | string;
15
- password?: string;
16
- ip?: string;
17
- isActive: boolean;
18
- isValided?: boolean;
11
+ clp?: string;
12
+ codeCompta?: string | number;
19
13
  disabled?: boolean;
20
- isBadPayer?: boolean;
14
+ firstname: string;
21
15
  foto?: string;
22
- clp?: string;
16
+ fullname?: string;
23
17
  gender?: Gender;
24
- titr?: UserTitr;
25
18
  grp?: UserGrp;
26
- tags?: AuthTag[];
19
+ ip?: string;
20
+ isActive: boolean;
21
+ isBadPayer?: boolean;
22
+ isValided?: boolean;
23
+ lastname: string;
24
+ password?: string;
27
25
  role?: UserRole;
28
- roles?: UserRole[];
26
+ roles?: string[];
29
27
  ste?: Ste;
30
- fullname?: string;
28
+ tags?: AuthTag[];
29
+ titr?: UserTitr;
30
+ username?: string;
31
31
  }
@@ -108,4 +108,3 @@ export declare const toggleProp: (tob: any, propToToggle: string) => any;
108
108
  export declare const winMaxHeight: (step?: 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9) => number;
109
109
  export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
110
110
  export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
111
- export declare function checkIsStringOfArray(array: unknown[]): array is string[];
package/lib/cjs/utils.js CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = 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.formatToStringCfa = exports.currencyFormatter = exports.formatToString = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
7
  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.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = void 0;
8
- exports.checkIsStringOfArray = checkIsStringOfArray;
9
8
  const dayjs_1 = __importDefault(require("dayjs"));
10
9
  const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
11
10
  const lodash_1 = __importDefault(require("lodash"));
@@ -775,7 +774,3 @@ const checkObjInArray = (objs, checkProp, prop = "id") => {
775
774
  });
776
775
  };
777
776
  exports.checkObjInArray = checkObjInArray;
778
- function checkIsStringOfArray(array) {
779
- // return array.every((element) => typeof element === "string");
780
- return array.some((element) => typeof element === "string");
781
- }
@@ -18,7 +18,7 @@ interface AuthParam {
18
18
  url?: string;
19
19
  }
20
20
  type TData = {
21
- tags?: AuthTag[] | string[];
21
+ tags?: AuthTag[];
22
22
  ste: Ste;
23
23
  role: UserRole;
24
24
  roles: string[];
@@ -1,26 +1,20 @@
1
1
  import { isStaffSte } from "../users/user";
2
- import { checkIsStringOfArray } from "../utils";
3
2
  const arraySome = (arr1, arr2) => {
4
3
  return arr1.some((x) => arr2.includes(x));
5
4
  };
6
5
  const getAuth = (authUser, authSte, param) => {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8
- if ((param === null || param === void 0 ? void 0 : param.tag) && ((_a = authUser === null || authUser === void 0 ? void 0 : authUser.tags) === null || _a === void 0 ? void 0 : _a.length)) {
9
- let tags = [];
10
- if (checkIsStringOfArray(authUser.tags)) {
11
- tags = authUser === null || authUser === void 0 ? void 0 : authUser.tags;
6
+ var _a, _b, _c, _d, _e, _f;
7
+ if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
8
+ const tags = [];
9
+ for (const tag of authUser.tags) {
10
+ tags.push(tag.code.toLowerCase());
12
11
  }
13
- else {
14
- for (const tag of authUser.tags) {
15
- tags.push((_b = tag === null || tag === void 0 ? void 0 : tag.code) === null || _b === void 0 ? void 0 : _b.toLowerCase());
16
- }
17
- }
18
- const authIn = tags === null || tags === void 0 ? void 0 : tags.includes((_c = param === null || param === void 0 ? void 0 : param.tag) === null || _c === void 0 ? void 0 : _c.toLowerCase());
12
+ const authIn = tags.includes(param.tag.toLowerCase());
19
13
  if (authIn) {
20
14
  return true;
21
15
  }
22
16
  }
23
- if (((_d = param === null || param === void 0 ? void 0 : param.roles) === null || _d === void 0 ? void 0 : _d.length) > 0) {
17
+ if (((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) > 0) {
24
18
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
25
19
  return true;
26
20
  } */
@@ -30,7 +24,7 @@ const getAuth = (authUser, authSte, param) => {
30
24
  }
31
25
  // ------ staff ------
32
26
  if (param === null || param === void 0 ? void 0 : param.staff) {
33
- if (((_e = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _e === void 0 ? void 0 : _e.length) > 0 &&
27
+ if (((_b = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
34
28
  isStaffSte(authSte, authUser.ste.name) &&
35
29
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
36
30
  return true;
@@ -51,7 +45,7 @@ const getAuth = (authUser, authSte, param) => {
51
45
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
52
46
  return true;
53
47
  }
54
- if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
48
+ if (((_c = param === null || param === void 0 ? void 0 : param.client.roles) === null || _c === void 0 ? void 0 : _c.length) &&
55
49
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
56
50
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
57
51
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -60,13 +54,13 @@ const getAuth = (authUser, authSte, param) => {
60
54
  }
61
55
  }
62
56
  // ------ ste grps ------
63
- if (((_g = param === null || param === void 0 ? void 0 : param.steGrps) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
57
+ if (((_d = param === null || param === void 0 ? void 0 : param.steGrps) === null || _d === void 0 ? void 0 : _d.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
64
58
  return true;
65
59
  }
66
- if (((_h = param === null || param === void 0 ? void 0 : param.grps) === null || _h === void 0 ? void 0 : _h.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
60
+ if (((_e = param === null || param === void 0 ? void 0 : param.grps) === null || _e === void 0 ? void 0 : _e.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
67
61
  return true;
68
62
  }
69
- if (((_j = param === null || param === void 0 ? void 0 : param.steNames) === null || _j === void 0 ? void 0 : _j.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
63
+ if (((_f = param === null || param === void 0 ? void 0 : param.steNames) === null || _f === void 0 ? void 0 : _f.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
70
64
  return true;
71
65
  }
72
66
  return false;
@@ -47,15 +47,6 @@ export class AuthService {
47
47
  return false;
48
48
  }
49
49
  });
50
- /* login = async (tob: LoginType, httpService: any) => {
51
- try {
52
- const { data: jwt } = await httpService.post("auth/login", tob);
53
- this.setStorageToken(jwt.token);
54
- return true;
55
- } catch (error) {
56
- console.log(error);
57
- }
58
- }; */
59
50
  this.logout = () => {
60
51
  this.removeStorageToken();
61
52
  // userAuthNavigate("/");
@@ -72,9 +63,6 @@ export class AuthService {
72
63
  return null;
73
64
  }
74
65
  };
75
- /* getAuth = (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => {
76
- return getAuth(authUser, authSte, param);
77
- }; */
78
66
  this.getAuth = (param) => {
79
67
  return getAuth(this.authUser(), this.authStes, param);
80
68
  };
@@ -85,4 +73,3 @@ export class AuthService {
85
73
  this.authStes = authStes;
86
74
  }
87
75
  }
88
- // export default new AuthService("awPharma");
@@ -1,8 +1,6 @@
1
1
  import NaCoAc from "../../shared/models/NaCoAc";
2
2
  import AuthTagCat from "./AuthTagCat";
3
- import AuthTagSub from "./AuthTagSub";
4
3
  export default interface AuthTag extends NaCoAc {
5
4
  cat?: AuthTagCat;
6
- subs?: AuthTagSub[];
7
5
  isChecked?: boolean;
8
6
  }
@@ -1,3 +1,2 @@
1
1
  export { default as AuthTag } from "./AuthTag";
2
2
  export { default as AuthTagCat } from "./AuthTagCat";
3
- export { default as AuthTagSub } from "./AuthTagSub";
@@ -3,5 +3,4 @@ export { default as BankAccount } from "./BankAccount";
3
3
  export { default as Currency } from "./Currency";
4
4
  export { default as Deposit } from "./Deposit";
5
5
  export { default as Feed } from "./Feed";
6
- export { default as PaymentMode } from "./PaymentMode";
7
6
  export { default as Spent } from "./Spent";
@@ -38,7 +38,7 @@ export default interface User extends Address {
38
38
  tags?: AuthTag[];
39
39
  zone?: Zone;
40
40
  role?: UserRole;
41
- roles?: UserRole[];
41
+ roles?: string[];
42
42
  ste?: Ste;
43
43
  fullname?: string;
44
44
  }
@@ -25,7 +25,7 @@ export default interface UserAbs extends Address {
25
25
  grp?: UserGrp;
26
26
  tags?: AuthTag[];
27
27
  role?: UserRole;
28
- roles?: UserRole[];
28
+ roles?: string[];
29
29
  ste?: Ste;
30
30
  fullname?: string;
31
31
  }
@@ -7,25 +7,25 @@ import UserRole from "./UserRole";
7
7
  import UserTitr from "./UserTitr";
8
8
  export default interface UserBase extends Address {
9
9
  id: number;
10
- codeCompta?: string | number;
11
- firstname: string;
12
- lastname: string;
13
- username?: string;
14
10
  birthday?: Date | string;
15
- password?: string;
16
- ip?: string;
17
- isActive: boolean;
18
- isValided?: boolean;
11
+ clp?: string;
12
+ codeCompta?: string | number;
19
13
  disabled?: boolean;
20
- isBadPayer?: boolean;
14
+ firstname: string;
21
15
  foto?: string;
22
- clp?: string;
16
+ fullname?: string;
23
17
  gender?: Gender;
24
- titr?: UserTitr;
25
18
  grp?: UserGrp;
26
- tags?: AuthTag[];
19
+ ip?: string;
20
+ isActive: boolean;
21
+ isBadPayer?: boolean;
22
+ isValided?: boolean;
23
+ lastname: string;
24
+ password?: string;
27
25
  role?: UserRole;
28
- roles?: UserRole[];
26
+ roles?: string[];
29
27
  ste?: Ste;
30
- fullname?: string;
28
+ tags?: AuthTag[];
29
+ titr?: UserTitr;
30
+ username?: string;
31
31
  }
@@ -108,4 +108,3 @@ export declare const toggleProp: (tob: any, propToToggle: string) => any;
108
108
  export declare const winMaxHeight: (step?: 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9) => number;
109
109
  export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
110
110
  export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
111
- export declare function checkIsStringOfArray(array: unknown[]): array is string[];
package/lib/esm/utils.js CHANGED
@@ -685,7 +685,3 @@ export const checkObjInArray = (objs, checkProp, prop = "id") => {
685
685
  return x[prop] === checkProp;
686
686
  });
687
687
  };
688
- export function checkIsStringOfArray(array) {
689
- // return array.every((element) => typeof element === "string");
690
- return array.some((element) => typeof element === "string");
691
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -18,10 +18,11 @@
18
18
  "devDependencies": {
19
19
  "@types/bcryptjs": "^2.4.6",
20
20
  "@types/express": "^5.0.0",
21
- "@types/lodash": "^4.17.14",
21
+ "@types/jwt-decode": "^3.1.0",
22
+ "@types/lodash": "^4.17.15",
22
23
  "@types/pdfmake": "^0.2.11",
23
24
  "@types/randomatic": "^3.1.5",
24
- "@types/react": "^19.0.4"
25
+ "@types/react": "^19.0.8"
25
26
  },
26
27
  "dependencies": {
27
28
  "axios": "^1.7.9",
@@ -1,3 +0,0 @@
1
- import NaCoAc from "../../shared/models/NaCoAc";
2
- export default interface AuthTagGrp extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import NaCoAc from "../../shared/models/NaCoAc";
2
- export default interface AuthTagSub extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export type VariantType = "warning" | "purple" | "secondary" | "pink" | "primary" | "success" | "danger" | "light" | "white" | "info" | "link" | string;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export default interface PaymentMode {
2
- id: number;
3
- name: string;
4
- code: string;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export * from "./models";
2
- export * from "./products/models";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./models"), exports);
18
- __exportStar(require("./products/models"), exports);
@@ -1,8 +0,0 @@
1
- export interface Market {
2
- id?: number;
3
- name: string;
4
- code: string;
5
- iconName: string;
6
- iconPack: string;
7
- isActive: boolean;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- import User from "../../users/models/User";
2
- import { Market } from "./Market";
3
- export default interface UMarket {
4
- id: number;
5
- createdAt: Date;
6
- updatedAt: Date;
7
- isActive: boolean;
8
- disabled?: boolean;
9
- user: User;
10
- market: Market;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export * from "./Market";
2
- export * from "./UMarket";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Market"), exports);
18
- __exportStar(require("./UMarket"), exports);
@@ -1,13 +0,0 @@
1
- import Product from "./models/Product";
2
- import { ProductStock } from "./models/ProductStock";
3
- declare class HlpProduct {
4
- qtityInAllDepots(stock: ProductStock, prms?: {
5
- exceptDepots?: string[];
6
- main?: "master" | "slave";
7
- }): number;
8
- getStockSalable(product: Product): number;
9
- stock: (product: Product, param: "salable" | "packs" | "units") => number;
10
- extraFiilters: (row: Product) => string;
11
- }
12
- declare const _default: HlpProduct;
13
- export default _default;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class HlpProduct {
4
- constructor() {
5
- this.stock = (product, param) => {
6
- const salable = (+product.stock.sumIns || 0) - (+product.stock.sumOuts || 0);
7
- const packs = Math.trunc(salable / product.stock.qtityPerPackaging || 0);
8
- const units = salable % product.stock.qtityPerPackaging || 0;
9
- switch (param) {
10
- case "salable":
11
- return salable;
12
- case "packs":
13
- return packs;
14
- case "units":
15
- return units;
16
- default:
17
- return salable;
18
- }
19
- };
20
- this.extraFiilters = (row) => row.designation; /* +
21
- row.codeCompta +
22
- (row.tva > 0 ? "@tva" : "") +
23
- (row.isAvailable ? "@dispo" : "") +
24
- (!row.isAvailable ? "@indispo" : "") +
25
- (row.isActive ? "@actif" : "") +
26
- (!row.isActive ? "@inactif" : "") +
27
- (row.isPrivate ? "@private" : "") +
28
- (!row.isPrivate ? "@noprivate" : ""); */
29
- }
30
- qtityInAllDepots(stock, prms) {
31
- const ins = stock.sumIns - stock.sumOuts;
32
- return ins <= 0 ? 0 : ins;
33
- }
34
- getStockSalable(product) {
35
- const stockAllSalable = +this.qtityInAllDepots(product.stock);
36
- const stockProduct = Math.trunc(stockAllSalable / product.qtityUnit);
37
- /* let stockSalable: number = 0;
38
-
39
- if (stockAllSalable <= stockStore) {
40
- stockSalable = stockAllSalable;
41
- }
42
- if (stockAllSalable > stockStore) {
43
- stockSalable = stockStore;
44
- } */
45
- // return stockSalable || 0;
46
- return stockProduct || 0;
47
- }
48
- }
49
- exports.default = new HlpProduct();
@@ -1,2 +0,0 @@
1
- export { default as HlpProduct } from "./hlpProduct";
2
- export * from "./models";