asv-hlps 1.2.25 → 1.2.28

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,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,6 +1,8 @@
1
+ import { AuthParam } from "../auth";
1
2
  export declare class AuthService {
2
3
  tokenKey: string;
3
- constructor(tokenkey: string);
4
+ authStes: string[];
5
+ constructor(tokenkey: string, authStes: string[]);
4
6
  getStorageToken: (local?: boolean) => string;
5
7
  setStorageToken: (jwt: any) => any;
6
8
  decodeToken: () => unknown;
@@ -8,6 +10,7 @@ export declare class AuthService {
8
10
  login: (tob: LoginType, httpService: any) => Promise<boolean>;
9
11
  logout: () => boolean;
10
12
  authUser: () => unknown;
13
+ getAuth: (param?: AuthParam) => boolean;
11
14
  }
12
15
  declare type LoginType = {
13
16
  username: string;
@@ -14,16 +14,18 @@ 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
- constructor(tokenkey) {
20
- this.tokenKey = "awPharma";
20
+ constructor(tokenkey, authStes) {
21
+ this.tokenKey = "";
22
+ this.authStes = [];
21
23
  // getStorageToken = (tokenKey, local = false) => {
22
24
  this.getStorageToken = (local = false) => {
23
25
  if (!this.tokenKey) {
24
26
  return null;
25
27
  }
26
- return storageService_1.default.getStorage(this.tokenKey);
28
+ return storageService_1.default.getStorage(this.tokenKey, local);
27
29
  };
28
30
  // setStorageToken = (tokenKey, jwt) => {
29
31
  this.setStorageToken = (jwt) => {
@@ -67,7 +69,14 @@ class AuthService {
67
69
  return null;
68
70
  }
69
71
  };
72
+ /* getAuth = (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => {
73
+ return getAuth(authUser, authSte, param);
74
+ }; */
75
+ this.getAuth = (param) => {
76
+ return (0, auth_1.getAuth)(this.authUser(), this.authStes, param);
77
+ };
70
78
  this.tokenKey = tokenkey;
79
+ this.authStes = authStes;
71
80
  }
72
81
  }
73
82
  exports.AuthService = AuthService;
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());
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,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,6 +1,8 @@
1
+ import { AuthParam } from "../auth";
1
2
  export declare class AuthService {
2
3
  tokenKey: string;
3
- constructor(tokenkey: string);
4
+ authStes: string[];
5
+ constructor(tokenkey: string, authStes: string[]);
4
6
  getStorageToken: (local?: boolean) => string;
5
7
  setStorageToken: (jwt: any) => any;
6
8
  decodeToken: () => unknown;
@@ -8,6 +10,7 @@ export declare class AuthService {
8
10
  login: (tob: LoginType, httpService: any) => Promise<boolean>;
9
11
  logout: () => boolean;
10
12
  authUser: () => unknown;
13
+ getAuth: (param?: AuthParam) => boolean;
11
14
  }
12
15
  declare type LoginType = {
13
16
  username: string;
@@ -8,16 +8,18 @@ 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
- constructor(tokenkey) {
14
- this.tokenKey = "awPharma";
14
+ constructor(tokenkey, authStes) {
15
+ this.tokenKey = "";
16
+ this.authStes = [];
15
17
  // getStorageToken = (tokenKey, local = false) => {
16
18
  this.getStorageToken = (local = false) => {
17
19
  if (!this.tokenKey) {
18
20
  return null;
19
21
  }
20
- return storageService.getStorage(this.tokenKey);
22
+ return storageService.getStorage(this.tokenKey, local);
21
23
  };
22
24
  // setStorageToken = (tokenKey, jwt) => {
23
25
  this.setStorageToken = (jwt) => {
@@ -61,7 +63,14 @@ export class AuthService {
61
63
  return null;
62
64
  }
63
65
  };
66
+ /* getAuth = (authUser: User | UserNotarial, authSte: string[], param?: AuthParam) => {
67
+ return getAuth(authUser, authSte, param);
68
+ }; */
69
+ this.getAuth = (param) => {
70
+ return getAuth(this.authUser(), this.authStes, param);
71
+ };
64
72
  this.tokenKey = tokenkey;
73
+ this.authStes = authStes;
65
74
  }
66
75
  }
67
76
  // export default new AuthService("awPharma");
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());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.25",
3
+ "version": "1.2.28",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",