asv-hlps 1.4.4 → 1.4.5

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,5 +1,4 @@
1
1
  import { Ste, SteGrp, UserGrp, UserRole } from "../users/models";
2
- import AuthTag from "./models/AuthTag";
3
2
  interface AuthParam {
4
3
  tag?: string;
5
4
  roles?: string[];
@@ -18,7 +17,7 @@ interface AuthParam {
18
17
  url?: string;
19
18
  }
20
19
  type TData = {
21
- tags?: AuthTag[];
20
+ tags?: string[];
22
21
  ste: Ste;
23
22
  role: UserRole;
24
23
  roles: string[];
@@ -6,18 +6,29 @@ const arraySome = (arr1, arr2) => {
6
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, _g, _h, _j;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10
+ /* if (param?.tag && authUser?.tags?.length) {
11
+ const tags: string[] = [];
12
+ for (const tag of authUser.tags) {
13
+ tags.push(tag?.code?.toLowerCase());
14
+ }
15
+ const authIn = tags?.includes(param?.tag?.toLowerCase());
16
+ if (authIn) {
17
+ return true;
18
+ }
19
+ } */
10
20
  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)) {
11
- const tags = [];
12
- for (const tag of authUser.tags) {
13
- tags.push((_b = tag === null || tag === void 0 ? void 0 : tag.code) === null || _b === void 0 ? void 0 : _b.toLowerCase());
14
- }
15
- 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());
21
+ // const tags: string[] = [];
22
+ /* for (const tag of authUser.tags) {
23
+ tags.push(tag?.code?.toLowerCase());
24
+ } */
25
+ const tags = authUser.tags;
26
+ const authIn = tags === null || tags === void 0 ? void 0 : tags.includes((_b = param === null || param === void 0 ? void 0 : param.tag) === null || _b === void 0 ? void 0 : _b.toLowerCase());
16
27
  if (authIn) {
17
28
  return true;
18
29
  }
19
30
  }
20
- if (((_d = param === null || param === void 0 ? void 0 : param.roles) === null || _d === void 0 ? void 0 : _d.length) > 0) {
31
+ if (((_c = param === null || param === void 0 ? void 0 : param.roles) === null || _c === void 0 ? void 0 : _c.length) > 0) {
21
32
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
22
33
  return true;
23
34
  } */
@@ -27,7 +38,7 @@ const getAuth = (authUser, authSte, param) => {
27
38
  }
28
39
  // ------ staff ------
29
40
  if (param === null || param === void 0 ? void 0 : param.staff) {
30
- if (((_e = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _e === void 0 ? void 0 : _e.length) > 0 &&
41
+ if (((_d = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _d === void 0 ? void 0 : _d.length) > 0 &&
31
42
  (0, user_1.isStaffSte)(authSte, authUser.ste.name) &&
32
43
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
33
44
  return true;
@@ -48,7 +59,7 @@ const getAuth = (authUser, authSte, param) => {
48
59
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
49
60
  return true;
50
61
  }
51
- if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
62
+ if (((_e = param === null || param === void 0 ? void 0 : param.client.roles) === null || _e === void 0 ? void 0 : _e.length) &&
52
63
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
53
64
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
54
65
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -57,13 +68,13 @@ const getAuth = (authUser, authSte, param) => {
57
68
  }
58
69
  }
59
70
  // ------ ste grps ------
60
- 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())) {
71
+ if (((_f = param === null || param === void 0 ? void 0 : param.steGrps) === null || _f === void 0 ? void 0 : _f.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
61
72
  return true;
62
73
  }
63
- 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())) {
74
+ if (((_g = param === null || param === void 0 ? void 0 : param.grps) === null || _g === void 0 ? void 0 : _g.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
64
75
  return true;
65
76
  }
66
- 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())) {
77
+ if (((_h = param === null || param === void 0 ? void 0 : param.steNames) === null || _h === void 0 ? void 0 : _h.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
67
78
  return true;
68
79
  }
69
80
  return false;
@@ -1,5 +1,4 @@
1
1
  import { Ste, SteGrp, UserGrp, UserRole } from "../users/models";
2
- import AuthTag from "./models/AuthTag";
3
2
  interface AuthParam {
4
3
  tag?: string;
5
4
  roles?: string[];
@@ -18,7 +17,7 @@ interface AuthParam {
18
17
  url?: string;
19
18
  }
20
19
  type TData = {
21
- tags?: AuthTag[];
20
+ tags?: string[];
22
21
  ste: Ste;
23
22
  role: UserRole;
24
23
  roles: string[];
@@ -3,18 +3,29 @@ const arraySome = (arr1, arr2) => {
3
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, _g, _h, _j;
6
+ var _a, _b, _c, _d, _e, _f, _g, _h;
7
+ /* if (param?.tag && authUser?.tags?.length) {
8
+ const tags: string[] = [];
9
+ for (const tag of authUser.tags) {
10
+ tags.push(tag?.code?.toLowerCase());
11
+ }
12
+ const authIn = tags?.includes(param?.tag?.toLowerCase());
13
+ if (authIn) {
14
+ return true;
15
+ }
16
+ } */
7
17
  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)) {
8
- const tags = [];
9
- for (const tag of authUser.tags) {
10
- tags.push((_b = tag === null || tag === void 0 ? void 0 : tag.code) === null || _b === void 0 ? void 0 : _b.toLowerCase());
11
- }
12
- 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());
18
+ // const tags: string[] = [];
19
+ /* for (const tag of authUser.tags) {
20
+ tags.push(tag?.code?.toLowerCase());
21
+ } */
22
+ const tags = authUser.tags;
23
+ const authIn = tags === null || tags === void 0 ? void 0 : tags.includes((_b = param === null || param === void 0 ? void 0 : param.tag) === null || _b === void 0 ? void 0 : _b.toLowerCase());
13
24
  if (authIn) {
14
25
  return true;
15
26
  }
16
27
  }
17
- if (((_d = param === null || param === void 0 ? void 0 : param.roles) === null || _d === void 0 ? void 0 : _d.length) > 0) {
28
+ if (((_c = param === null || param === void 0 ? void 0 : param.roles) === null || _c === void 0 ? void 0 : _c.length) > 0) {
18
29
  /* if (isStaffSte(authSte, authUser.ste.name) && ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
19
30
  return true;
20
31
  } */
@@ -24,7 +35,7 @@ const getAuth = (authUser, authSte, param) => {
24
35
  }
25
36
  // ------ staff ------
26
37
  if (param === null || param === void 0 ? void 0 : param.staff) {
27
- if (((_e = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _e === void 0 ? void 0 : _e.length) > 0 &&
38
+ if (((_d = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _d === void 0 ? void 0 : _d.length) > 0 &&
28
39
  isStaffSte(authSte, authUser.ste.name) &&
29
40
  ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
30
41
  return true;
@@ -45,7 +56,7 @@ const getAuth = (authUser, authSte, param) => {
45
56
  param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
46
57
  return true;
47
58
  }
48
- if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
59
+ if (((_e = param === null || param === void 0 ? void 0 : param.client.roles) === null || _e === void 0 ? void 0 : _e.length) &&
49
60
  (param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
50
61
  ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
51
62
  (param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
@@ -54,13 +65,13 @@ const getAuth = (authUser, authSte, param) => {
54
65
  }
55
66
  }
56
67
  // ------ ste grps ------
57
- 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())) {
68
+ if (((_f = param === null || param === void 0 ? void 0 : param.steGrps) === null || _f === void 0 ? void 0 : _f.length) > 0 && param.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
58
69
  return true;
59
70
  }
60
- 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())) {
71
+ if (((_g = param === null || param === void 0 ? void 0 : param.grps) === null || _g === void 0 ? void 0 : _g.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
61
72
  return true;
62
73
  }
63
- 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())) {
74
+ if (((_h = param === null || param === void 0 ? void 0 : param.steNames) === null || _h === void 0 ? void 0 : _h.length) > 0 && param.steNames.includes(authUser.ste.name.toLowerCase())) {
64
75
  return true;
65
76
  }
66
77
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",