asv-hlps 1.2.0 → 1.2.3
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 +14 -0
- package/lib/cjs/auth.js +61 -0
- package/lib/cjs/bootstrap.d.ts +1 -0
- package/lib/cjs/bootstrap.js +2 -0
- package/lib/cjs/index.d.ts +4 -0
- package/lib/cjs/index.js +4 -0
- package/lib/cjs/models/types/Type.d.ts +2 -1
- package/lib/esm/auth.d.ts +14 -0
- package/lib/esm/auth.js +57 -0
- package/lib/esm/bootstrap.d.ts +1 -0
- package/lib/esm/bootstrap.js +1 -0
- package/lib/esm/index.d.ts +4 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/models/types/Type.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { User } from "./models/entities/users/User";
|
|
2
|
+
export interface AuthParam {
|
|
3
|
+
tag?: string;
|
|
4
|
+
roles?: string[];
|
|
5
|
+
grps?: string[];
|
|
6
|
+
client?: {
|
|
7
|
+
roles?: string[];
|
|
8
|
+
steGrps?: string[];
|
|
9
|
+
};
|
|
10
|
+
steGrps?: string[];
|
|
11
|
+
steNames?: string[];
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const getAuth: (authUser: User, param?: AuthParam) => boolean;
|
package/lib/cjs/auth.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuth = void 0;
|
|
4
|
+
const user_1 = require("./user");
|
|
5
|
+
const getAuth = (authUser, param) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7
|
+
// let auth: boolean = false;
|
|
8
|
+
if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags)) {
|
|
9
|
+
const tags = [];
|
|
10
|
+
for (const tag of authUser.tags) {
|
|
11
|
+
tags.push(tag.code.toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
const authIn = tags.includes(param.tag.toLowerCase());
|
|
14
|
+
if (authIn) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
|
|
19
|
+
if ((0, user_1.isStaffSte)(["cpa"], authUser)) {
|
|
20
|
+
return ((_b = param === null || param === void 0 ? void 0 : param.roles) === null || _b === void 0 ? void 0 : _b.length) ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
|
|
21
|
+
// ------ multi roles ------
|
|
22
|
+
// return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if ((_c = param === null || param === void 0 ? void 0 : param.steGrps) === null || _c === void 0 ? void 0 : _c.length) {
|
|
26
|
+
return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
if ((_d = param === null || param === void 0 ? void 0 : param.grps) === null || _d === void 0 ? void 0 : _d.length) {
|
|
29
|
+
return param.grps.includes(authUser.grp.code.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
if (param === null || param === void 0 ? void 0 : param.client) {
|
|
32
|
+
if (!(0, user_1.isStaffSte)(["cpa"], authUser)) {
|
|
33
|
+
if (param.client.roles && !param.client.steGrps) {
|
|
34
|
+
return param.client.roles.length ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) : false;
|
|
35
|
+
}
|
|
36
|
+
if (!param.client.roles && param.client.steGrps) {
|
|
37
|
+
return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
|
|
38
|
+
}
|
|
39
|
+
return ((_e = param === null || param === void 0 ? void 0 : param.client.roles) === null || _e === void 0 ? void 0 : _e.length) && (param === null || param === void 0 ? void 0 : param.client.steGrps.length)
|
|
40
|
+
? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
|
|
41
|
+
(param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
|
|
42
|
+
: false;
|
|
43
|
+
}
|
|
44
|
+
/* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
45
|
+
if(authIn) { return true} */
|
|
46
|
+
}
|
|
47
|
+
if ((_f = param === null || param === void 0 ? void 0 : param.steNames) === null || _f === void 0 ? void 0 : _f.length) {
|
|
48
|
+
return param.steNames.includes(authUser.ste.name.toLowerCase());
|
|
49
|
+
/* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
50
|
+
if(authIn) { return true} */
|
|
51
|
+
}
|
|
52
|
+
/* if (param?.url) {
|
|
53
|
+
return this.router.url === param.url;
|
|
54
|
+
} */
|
|
55
|
+
// return false;
|
|
56
|
+
// return auth;
|
|
57
|
+
/* if(param?.steGrps?.length) {
|
|
58
|
+
auth = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
59
|
+
} */
|
|
60
|
+
};
|
|
61
|
+
exports.getAuth = getAuth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type BtnVariant = "warning" | "purple" | "secondary" | "pink" | "primary" | "success" | "danger" | "info";
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import AmountOnBillPipe from "./helpers/pipes/amount-on-bill-pipe";
|
|
|
4
4
|
import AmountOnListBillPipe from "./helpers/pipes/amount-on-list-bill-pipe";
|
|
5
5
|
import StockPipe from "./helpers/pipes/stock-pipe";
|
|
6
6
|
import "./bill";
|
|
7
|
+
import "./bootstrap";
|
|
7
8
|
import "./models/index";
|
|
8
9
|
import "./pdfs/invoices/amountInvoice";
|
|
9
10
|
import "./pdfs/invoices/infoInvoice";
|
|
@@ -14,6 +15,7 @@ import "./sale";
|
|
|
14
15
|
import "./typeorm";
|
|
15
16
|
import "./user";
|
|
16
17
|
import "./utils";
|
|
18
|
+
import "./auth";
|
|
17
19
|
export * from "./bill";
|
|
18
20
|
export * from "./models/index";
|
|
19
21
|
export * from "./pdfs/invoices/amountInvoice";
|
|
@@ -25,4 +27,6 @@ export * from "./typeorm";
|
|
|
25
27
|
export * from "./user";
|
|
26
28
|
export * from "./utils";
|
|
27
29
|
export * from "./react-utils";
|
|
30
|
+
export * from "./bootstrap";
|
|
31
|
+
export * from "./auth";
|
|
28
32
|
export { HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
package/lib/cjs/index.js
CHANGED
|
@@ -29,6 +29,7 @@ exports.AmountOnListBillPipe = amount_on_list_bill_pipe_1.default;
|
|
|
29
29
|
const stock_pipe_1 = __importDefault(require("./helpers/pipes/stock-pipe"));
|
|
30
30
|
exports.StockPipe = stock_pipe_1.default;
|
|
31
31
|
require("./bill");
|
|
32
|
+
require("./bootstrap");
|
|
32
33
|
require("./models/index");
|
|
33
34
|
require("./pdfs/invoices/amountInvoice");
|
|
34
35
|
require("./pdfs/invoices/infoInvoice");
|
|
@@ -39,6 +40,7 @@ require("./sale");
|
|
|
39
40
|
require("./typeorm");
|
|
40
41
|
require("./user");
|
|
41
42
|
require("./utils");
|
|
43
|
+
require("./auth");
|
|
42
44
|
__exportStar(require("./bill"), exports);
|
|
43
45
|
__exportStar(require("./models/index"), exports);
|
|
44
46
|
__exportStar(require("./pdfs/invoices/amountInvoice"), exports);
|
|
@@ -50,3 +52,5 @@ __exportStar(require("./typeorm"), exports);
|
|
|
50
52
|
__exportStar(require("./user"), exports);
|
|
51
53
|
__exportStar(require("./utils"), exports);
|
|
52
54
|
__exportStar(require("./react-utils"), exports);
|
|
55
|
+
__exportStar(require("./bootstrap"), exports);
|
|
56
|
+
__exportStar(require("./auth"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthParam } from "../../auth";
|
|
1
2
|
export interface IPath {
|
|
2
3
|
id: number;
|
|
3
4
|
title: any;
|
|
@@ -13,7 +14,7 @@ export declare type HeaderTableColumnType = {
|
|
|
13
14
|
accessor?: string;
|
|
14
15
|
content?: any;
|
|
15
16
|
style?: any;
|
|
16
|
-
auth?:
|
|
17
|
+
auth?: AuthParam;
|
|
17
18
|
tooltipH?: any;
|
|
18
19
|
tooltipB?: any;
|
|
19
20
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { User } from "./models/entities/users/User";
|
|
2
|
+
export interface AuthParam {
|
|
3
|
+
tag?: string;
|
|
4
|
+
roles?: string[];
|
|
5
|
+
grps?: string[];
|
|
6
|
+
client?: {
|
|
7
|
+
roles?: string[];
|
|
8
|
+
steGrps?: string[];
|
|
9
|
+
};
|
|
10
|
+
steGrps?: string[];
|
|
11
|
+
steNames?: string[];
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const getAuth: (authUser: User, param?: AuthParam) => boolean;
|
package/lib/esm/auth.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isStaffSte } from "./user";
|
|
2
|
+
export const getAuth = (authUser, param) => {
|
|
3
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4
|
+
// let auth: boolean = false;
|
|
5
|
+
if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags)) {
|
|
6
|
+
const tags = [];
|
|
7
|
+
for (const tag of authUser.tags) {
|
|
8
|
+
tags.push(tag.code.toLowerCase());
|
|
9
|
+
}
|
|
10
|
+
const authIn = tags.includes(param.tag.toLowerCase());
|
|
11
|
+
if (authIn) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if ((_a = param === null || param === void 0 ? void 0 : param.roles) === null || _a === void 0 ? void 0 : _a.length) {
|
|
16
|
+
if (isStaffSte(["cpa"], authUser)) {
|
|
17
|
+
return ((_b = param === null || param === void 0 ? void 0 : param.roles) === null || _b === void 0 ? void 0 : _b.length) ? ["sadm", ...param.roles].includes(authUser.role.code.toLowerCase()) : false;
|
|
18
|
+
// ------ multi roles ------
|
|
19
|
+
// return param?.roles?.length ? this.checkRoles(["sadm", ...param.roles]) : false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if ((_c = param === null || param === void 0 ? void 0 : param.steGrps) === null || _c === void 0 ? void 0 : _c.length) {
|
|
23
|
+
return param.steGrps.includes(authUser.ste.grp.code.toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
if ((_d = param === null || param === void 0 ? void 0 : param.grps) === null || _d === void 0 ? void 0 : _d.length) {
|
|
26
|
+
return param.grps.includes(authUser.grp.code.toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
if (param === null || param === void 0 ? void 0 : param.client) {
|
|
29
|
+
if (!isStaffSte(["cpa"], authUser)) {
|
|
30
|
+
if (param.client.roles && !param.client.steGrps) {
|
|
31
|
+
return param.client.roles.length ? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) : false;
|
|
32
|
+
}
|
|
33
|
+
if (!param.client.roles && param.client.steGrps) {
|
|
34
|
+
return param.client.steGrps.length ? param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase()) : false;
|
|
35
|
+
}
|
|
36
|
+
return ((_e = param === null || param === void 0 ? void 0 : param.client.roles) === null || _e === void 0 ? void 0 : _e.length) && (param === null || param === void 0 ? void 0 : param.client.steGrps.length)
|
|
37
|
+
? ["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
|
|
38
|
+
(param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())
|
|
39
|
+
: false;
|
|
40
|
+
}
|
|
41
|
+
/* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
42
|
+
if(authIn) { return true} */
|
|
43
|
+
}
|
|
44
|
+
if ((_f = param === null || param === void 0 ? void 0 : param.steNames) === null || _f === void 0 ? void 0 : _f.length) {
|
|
45
|
+
return param.steNames.includes(authUser.ste.name.toLowerCase());
|
|
46
|
+
/* const authIn = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
47
|
+
if(authIn) { return true} */
|
|
48
|
+
}
|
|
49
|
+
/* if (param?.url) {
|
|
50
|
+
return this.router.url === param.url;
|
|
51
|
+
} */
|
|
52
|
+
// return false;
|
|
53
|
+
// return auth;
|
|
54
|
+
/* if(param?.steGrps?.length) {
|
|
55
|
+
auth = (param.steGrps).includes(this.authUser.ste.grp.code.toLowerCase());
|
|
56
|
+
} */
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type BtnVariant = "warning" | "purple" | "secondary" | "pink" | "primary" | "success" | "danger" | "info";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import AmountOnBillPipe from "./helpers/pipes/amount-on-bill-pipe";
|
|
|
4
4
|
import AmountOnListBillPipe from "./helpers/pipes/amount-on-list-bill-pipe";
|
|
5
5
|
import StockPipe from "./helpers/pipes/stock-pipe";
|
|
6
6
|
import "./bill";
|
|
7
|
+
import "./bootstrap";
|
|
7
8
|
import "./models/index";
|
|
8
9
|
import "./pdfs/invoices/amountInvoice";
|
|
9
10
|
import "./pdfs/invoices/infoInvoice";
|
|
@@ -14,6 +15,7 @@ import "./sale";
|
|
|
14
15
|
import "./typeorm";
|
|
15
16
|
import "./user";
|
|
16
17
|
import "./utils";
|
|
18
|
+
import "./auth";
|
|
17
19
|
export * from "./bill";
|
|
18
20
|
export * from "./models/index";
|
|
19
21
|
export * from "./pdfs/invoices/amountInvoice";
|
|
@@ -25,4 +27,6 @@ export * from "./typeorm";
|
|
|
25
27
|
export * from "./user";
|
|
26
28
|
export * from "./utils";
|
|
27
29
|
export * from "./react-utils";
|
|
30
|
+
export * from "./bootstrap";
|
|
31
|
+
export * from "./auth";
|
|
28
32
|
export { HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
package/lib/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import AmountOnBillPipe from "./helpers/pipes/amount-on-bill-pipe";
|
|
|
4
4
|
import AmountOnListBillPipe from "./helpers/pipes/amount-on-list-bill-pipe";
|
|
5
5
|
import StockPipe from "./helpers/pipes/stock-pipe";
|
|
6
6
|
import "./bill";
|
|
7
|
+
import "./bootstrap";
|
|
7
8
|
import "./models/index";
|
|
8
9
|
import "./pdfs/invoices/amountInvoice";
|
|
9
10
|
import "./pdfs/invoices/infoInvoice";
|
|
@@ -14,6 +15,7 @@ import "./sale";
|
|
|
14
15
|
import "./typeorm";
|
|
15
16
|
import "./user";
|
|
16
17
|
import "./utils";
|
|
18
|
+
import "./auth";
|
|
17
19
|
export * from "./bill";
|
|
18
20
|
export * from "./models/index";
|
|
19
21
|
export * from "./pdfs/invoices/amountInvoice";
|
|
@@ -25,5 +27,7 @@ export * from "./typeorm";
|
|
|
25
27
|
export * from "./user";
|
|
26
28
|
export * from "./utils";
|
|
27
29
|
export * from "./react-utils";
|
|
30
|
+
export * from "./bootstrap";
|
|
31
|
+
export * from "./auth";
|
|
28
32
|
// export * from "./helpers/hlpProduct";
|
|
29
33
|
export { HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthParam } from "../../auth";
|
|
1
2
|
export interface IPath {
|
|
2
3
|
id: number;
|
|
3
4
|
title: any;
|
|
@@ -13,7 +14,7 @@ export declare type HeaderTableColumnType = {
|
|
|
13
14
|
accessor?: string;
|
|
14
15
|
content?: any;
|
|
15
16
|
style?: any;
|
|
16
|
-
auth?:
|
|
17
|
+
auth?: AuthParam;
|
|
17
18
|
tooltipH?: any;
|
|
18
19
|
tooltipB?: any;
|
|
19
20
|
};
|