asv-hlps 1.4.31 → 1.4.33

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.
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAuth = void 0;
4
4
  const user_1 = require("../users/user");
5
5
  const arraySome = (arr1, arr2) => {
6
- return arr1.some((x) => arr2.includes(x));
6
+ return arr1.some(x => arr2.includes(x));
7
7
  };
8
8
  const getAuth = (authUser, authSte, param) => {
9
- var _a, _b, _c, _d, _e, _f;
9
+ var _a, _b, _c, _d, _e, _f, _g;
10
10
  if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
11
11
  const tags = [];
12
12
  for (const tag of authUser.tags) {
@@ -21,13 +21,13 @@ const getAuth = (authUser, authSte, param) => {
21
21
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
22
22
  return true;
23
23
  } */
24
- if ((0, user_1.isStaffSte)(authSte, authUser.ste.name) && arraySome(["sadm", ...param.roles], authUser.roles)) {
24
+ if ((0, user_1.isStaffSte)(authSte, (_b = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _b === void 0 ? void 0 : _b.name) && arraySome(["sadm", ...param.roles], authUser.roles)) {
25
25
  return true;
26
26
  }
27
27
  }
28
28
  // ------ staff ------
29
29
  if (param === null || param === void 0 ? void 0 : param.staff) {
30
- if (((_b = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
30
+ if (((_c = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
31
31
  (0, user_1.isStaffSte)(authSte, authUser.ste.name) &&
32
32
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
33
33
  return true;
@@ -48,7 +48,7 @@ const getAuth = (authUser, authSte, param) => {
48
48
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
49
49
  return true;
50
50
  }
51
- if (((_c = param === null || param === void 0 ? void 0 : param.client.roles) === null || _c === void 0 ? void 0 : _c.length) &&
51
+ if (((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) &&
52
52
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
53
53
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
54
54
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -57,13 +57,13 @@ const getAuth = (authUser, authSte, param) => {
57
57
  }
58
58
  }
59
59
  // ------ ste grps ------
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())) {
60
+ if (((_e = param === null || param === void 0 ? void 0 : param.steGrps) === null || _e === void 0 ? void 0 : _e.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
61
61
  return true;
62
62
  }
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())) {
63
+ if (((_f = param === null || param === void 0 ? void 0 : param.grps) === null || _f === void 0 ? void 0 : _f.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
64
64
  return true;
65
65
  }
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())) {
66
+ if (((_g = param === null || param === void 0 ? void 0 : param.steNames) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
67
67
  return true;
68
68
  }
69
69
  return false;
@@ -3,4 +3,5 @@ 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";
6
7
  export { default as Spent } from "./Spent";
@@ -1,5 +1,5 @@
1
1
  type AdditFormType<T = any> = {
2
- onSubmitForm?: (value: any) => any;
2
+ onSubmitForm?: (value: any) => void;
3
3
  onCancelForm?: any;
4
4
  tob?: T;
5
5
  url?: string;
@@ -38,8 +38,8 @@ export declare const entryDesignationUser: <T extends {
38
38
  username: string;
39
39
  fullname: string;
40
40
  }>(user: T) => string;
41
- export declare const secureUser: (user: any, username: string, heads: any) => void;
42
- export declare const secureUserPassword: (user: any, heads?: any) => void;
41
+ export declare const secureUser: (user: any, username: string, bcrypt: any, heads: any) => void;
42
+ export declare const secureUserPassword: (user: any, bcrypt: any, heads?: any) => void;
43
43
  export declare const userGrpCode: <T extends {
44
44
  ste?: Ste;
45
45
  grp?: UserGrp;
@@ -1,43 +1,10 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.getSteShortname = exports.labelSteName = exports.userCoef = exports.userGrpCode = exports.secureUserPassword = exports.secureUser = exports.entryDesignationUser = exports.getFullname = exports.isStaffSte = exports.isBillPeriod = exports.hasRoles = exports.hasRole = exports.inSteGrp = exports.displaySteOrFullname = exports.displaySteOrStaff = exports.inGrp = void 0;
40
- const bcrypt = __importStar(require("bcryptjs"));
7
+ // import * as bcrypt from "bcryptjs";
41
8
  const randomatic_1 = __importDefault(require("randomatic"));
42
9
  const utils_1 = require("../utils");
43
10
  // export const inGrp = (grps: string[], user: User | UserNotarial) => {
@@ -121,7 +88,8 @@ const entryDesignationUser = (user) => {
121
88
  return user.username.toUpperCase();
122
89
  };
123
90
  exports.entryDesignationUser = entryDesignationUser;
124
- const secureUser = (user, username, heads) => {
91
+ const secureUser = (user, username, bcrypt, heads) => {
92
+ // const bcrypt = require("bcryptjs");
125
93
  user.password = (0, randomatic_1.default)("Aa0", 8);
126
94
  user.dns = heads.host;
127
95
  user.clp = user.password;
@@ -130,7 +98,8 @@ const secureUser = (user, username, heads) => {
130
98
  user.username = username;
131
99
  };
132
100
  exports.secureUser = secureUser;
133
- const secureUserPassword = (user, heads) => {
101
+ const secureUserPassword = (user, bcrypt, heads) => {
102
+ // const bcrypt = require("bcryptjs");
134
103
  user.password = !user.password ? (0, randomatic_1.default)("Aa0", 8) : user.password;
135
104
  if (heads) {
136
105
  user.dns = heads.host;
@@ -1,9 +1,9 @@
1
1
  import { isStaffSte } from "../users/user";
2
2
  const arraySome = (arr1, arr2) => {
3
- return arr1.some((x) => arr2.includes(x));
3
+ return arr1.some(x => arr2.includes(x));
4
4
  };
5
5
  const getAuth = (authUser, authSte, param) => {
6
- var _a, _b, _c, _d, _e, _f;
6
+ var _a, _b, _c, _d, _e, _f, _g;
7
7
  if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
8
8
  const tags = [];
9
9
  for (const tag of authUser.tags) {
@@ -18,13 +18,13 @@ const getAuth = (authUser, authSte, param) => {
18
18
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
19
19
  return true;
20
20
  } */
21
- if (isStaffSte(authSte, authUser.ste.name) && arraySome(["sadm", ...param.roles], authUser.roles)) {
21
+ if (isStaffSte(authSte, (_b = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _b === void 0 ? void 0 : _b.name) && arraySome(["sadm", ...param.roles], authUser.roles)) {
22
22
  return true;
23
23
  }
24
24
  }
25
25
  // ------ staff ------
26
26
  if (param === null || param === void 0 ? void 0 : param.staff) {
27
- if (((_b = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
27
+ if (((_c = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
28
28
  isStaffSte(authSte, authUser.ste.name) &&
29
29
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
30
30
  return true;
@@ -45,7 +45,7 @@ const getAuth = (authUser, authSte, param) => {
45
45
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
46
46
  return true;
47
47
  }
48
- if (((_c = param === null || param === void 0 ? void 0 : param.client.roles) === null || _c === void 0 ? void 0 : _c.length) &&
48
+ if (((_d = param === null || param === void 0 ? void 0 : param.client.roles) === null || _d === void 0 ? void 0 : _d.length) &&
49
49
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
50
50
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
51
51
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -54,13 +54,13 @@ const getAuth = (authUser, authSte, param) => {
54
54
  }
55
55
  }
56
56
  // ------ ste grps ------
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())) {
57
+ if (((_e = param === null || param === void 0 ? void 0 : param.steGrps) === null || _e === void 0 ? void 0 : _e.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
58
58
  return true;
59
59
  }
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())) {
60
+ if (((_f = param === null || param === void 0 ? void 0 : param.grps) === null || _f === void 0 ? void 0 : _f.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
61
61
  return true;
62
62
  }
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())) {
63
+ if (((_g = param === null || param === void 0 ? void 0 : param.steNames) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
64
64
  return true;
65
65
  }
66
66
  return false;
@@ -3,4 +3,5 @@ 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";
6
7
  export { default as Spent } from "./Spent";
@@ -1,5 +1,5 @@
1
1
  type AdditFormType<T = any> = {
2
- onSubmitForm?: (value: any) => any;
2
+ onSubmitForm?: (value: any) => void;
3
3
  onCancelForm?: any;
4
4
  tob?: T;
5
5
  url?: string;
@@ -38,8 +38,8 @@ export declare const entryDesignationUser: <T extends {
38
38
  username: string;
39
39
  fullname: string;
40
40
  }>(user: T) => string;
41
- export declare const secureUser: (user: any, username: string, heads: any) => void;
42
- export declare const secureUserPassword: (user: any, heads?: any) => void;
41
+ export declare const secureUser: (user: any, username: string, bcrypt: any, heads: any) => void;
42
+ export declare const secureUserPassword: (user: any, bcrypt: any, heads?: any) => void;
43
43
  export declare const userGrpCode: <T extends {
44
44
  ste?: Ste;
45
45
  grp?: UserGrp;
@@ -1,4 +1,4 @@
1
- import * as bcrypt from "bcryptjs";
1
+ // import * as bcrypt from "bcryptjs";
2
2
  import randomatic from "randomatic";
3
3
  import { arraySome, limitTo, titleCase } from "../utils";
4
4
  // export const inGrp = (grps: string[], user: User | UserNotarial) => {
@@ -72,7 +72,8 @@ export const entryDesignationUser = (user) => {
72
72
  }
73
73
  return user.username.toUpperCase();
74
74
  };
75
- export const secureUser = (user, username, heads) => {
75
+ export const secureUser = (user, username, bcrypt, heads) => {
76
+ // const bcrypt = require("bcryptjs");
76
77
  user.password = randomatic("Aa0", 8);
77
78
  user.dns = heads.host;
78
79
  user.clp = user.password;
@@ -80,7 +81,8 @@ export const secureUser = (user, username, heads) => {
80
81
  // user.password = crypto.hashSync(user.password, 8);
81
82
  user.username = username;
82
83
  };
83
- export const secureUserPassword = (user, heads) => {
84
+ export const secureUserPassword = (user, bcrypt, heads) => {
85
+ // const bcrypt = require("bcryptjs");
84
86
  user.password = !user.password ? randomatic("Aa0", 8) : user.password;
85
87
  if (heads) {
86
88
  user.dns = heads.host;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.31",
3
+ "version": "1.4.33",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -26,7 +26,6 @@
26
26
  "dependencies": {
27
27
  "@tanstack/react-query": "^5.71.0",
28
28
  "axios": "^1.8.4",
29
- "bcryptjs": "^3.0.2",
30
29
  "class-validator": "^0.14.1",
31
30
  "classnames": "^2.5.1",
32
31
  "dayjs": "^1.11.13",