asv-hlps 1.2.26 → 1.2.29

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;
@@ -16,6 +16,7 @@ import "./pdfs/invoices/infoInvoice";
16
16
  import "./pdfs/tools/tools";
17
17
  import "./product";
18
18
  import "./react-utils";
19
+ import "./reacts/index";
19
20
  import "./sale";
20
21
  import "./services/authService";
21
22
  import "./user";
@@ -35,4 +36,5 @@ export * from "./react-utils";
35
36
  export * from "./sale";
36
37
  export * from "./user";
37
38
  export * from "./utils";
39
+ export * from "./reacts/index";
38
40
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
package/lib/cjs/index.js CHANGED
@@ -46,6 +46,7 @@ require("./pdfs/invoices/infoInvoice");
46
46
  require("./pdfs/tools/tools");
47
47
  require("./product");
48
48
  require("./react-utils");
49
+ require("./reacts/index");
49
50
  require("./sale");
50
51
  require("./services/authService");
51
52
  require("./user");
@@ -65,3 +66,4 @@ __exportStar(require("./react-utils"), exports);
65
66
  __exportStar(require("./sale"), exports);
66
67
  __exportStar(require("./user"), exports);
67
68
  __exportStar(require("./utils"), exports);
69
+ __exportStar(require("./reacts/index"), exports);
@@ -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
  }
@@ -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 FormPropsType = {
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 {
@@ -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;
@@ -0,0 +1,5 @@
1
+ declare const useReadonlyFetchTobs: (url: string, httpService: any, urlParam?: string | number, valueProp?: string, labelProp?: string) => {
2
+ tobs: any[];
3
+ options: any[];
4
+ };
5
+ export default useReadonlyFetchTobs;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const react_1 = require("react");
13
+ const react_utils_1 = require("../../react-utils");
14
+ const useReadonlyFetchTobs = (url, httpService, urlParam, valueProp = "id", labelProp = "name") => {
15
+ const [tobs, setTobs] = (0, react_1.useState)([]);
16
+ const getDatas = () => __awaiter(void 0, void 0, void 0, function* () {
17
+ try {
18
+ if (!urlParam) {
19
+ const { data: tobs } = yield httpService.get(url);
20
+ setTobs(tobs);
21
+ }
22
+ else {
23
+ const { data: tobs } = yield httpService.getByParam(urlParam, url);
24
+ setTobs(tobs);
25
+ }
26
+ }
27
+ catch (error) { }
28
+ });
29
+ (0, react_1.useEffect)(() => {
30
+ getDatas();
31
+ return () => { };
32
+ }, []);
33
+ // const options = useMemo(() => selectOptionsToLabelAndValue(tobs, valueProp, labelProp), []);
34
+ const options = (0, react_utils_1.selectOptionsToLabelAndValue)(tobs, valueProp, labelProp);
35
+ return { tobs, options };
36
+ };
37
+ exports.default = useReadonlyFetchTobs;
38
+ // export default {tobs , options} ;
@@ -0,0 +1,2 @@
1
+ import useReadonlyFetchTobs from "./hooks/useReadonlyFetchTobs";
2
+ export { useReadonlyFetchTobs };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useReadonlyFetchTobs = void 0;
7
+ const useReadonlyFetchTobs_1 = __importDefault(require("./hooks/useReadonlyFetchTobs"));
8
+ exports.useReadonlyFetchTobs = useReadonlyFetchTobs_1.default;
@@ -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;
@@ -16,6 +16,7 @@ import "./pdfs/invoices/infoInvoice";
16
16
  import "./pdfs/tools/tools";
17
17
  import "./product";
18
18
  import "./react-utils";
19
+ import "./reacts/index";
19
20
  import "./sale";
20
21
  import "./services/authService";
21
22
  import "./user";
@@ -35,4 +36,5 @@ export * from "./react-utils";
35
36
  export * from "./sale";
36
37
  export * from "./user";
37
38
  export * from "./utils";
39
+ export * from "./reacts/index";
38
40
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
package/lib/esm/index.js CHANGED
@@ -19,6 +19,7 @@ import "./pdfs/invoices/infoInvoice";
19
19
  import "./pdfs/tools/tools";
20
20
  import "./product";
21
21
  import "./react-utils";
22
+ import "./reacts/index";
22
23
  import "./sale";
23
24
  import "./services/authService";
24
25
  import "./user";
@@ -38,5 +39,6 @@ export * from "./react-utils";
38
39
  export * from "./sale";
39
40
  export * from "./user";
40
41
  export * from "./utils";
42
+ export * from "./reacts/index";
41
43
  // export * from "./helpers/hlpProduct";
42
44
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
@@ -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
  }
@@ -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 FormPropsType = {
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 {
@@ -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;
@@ -0,0 +1,5 @@
1
+ declare const useReadonlyFetchTobs: (url: string, httpService: any, urlParam?: string | number, valueProp?: string, labelProp?: string) => {
2
+ tobs: any[];
3
+ options: any[];
4
+ };
5
+ export default useReadonlyFetchTobs;
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useEffect, useState } from "react";
11
+ import { selectOptionsToLabelAndValue } from "../../react-utils";
12
+ const useReadonlyFetchTobs = (url, httpService, urlParam, valueProp = "id", labelProp = "name") => {
13
+ const [tobs, setTobs] = useState([]);
14
+ const getDatas = () => __awaiter(void 0, void 0, void 0, function* () {
15
+ try {
16
+ if (!urlParam) {
17
+ const { data: tobs } = yield httpService.get(url);
18
+ setTobs(tobs);
19
+ }
20
+ else {
21
+ const { data: tobs } = yield httpService.getByParam(urlParam, url);
22
+ setTobs(tobs);
23
+ }
24
+ }
25
+ catch (error) { }
26
+ });
27
+ useEffect(() => {
28
+ getDatas();
29
+ return () => { };
30
+ }, []);
31
+ // const options = useMemo(() => selectOptionsToLabelAndValue(tobs, valueProp, labelProp), []);
32
+ const options = selectOptionsToLabelAndValue(tobs, valueProp, labelProp);
33
+ return { tobs, options };
34
+ };
35
+ export default useReadonlyFetchTobs;
36
+ // export default {tobs , options} ;
@@ -0,0 +1,2 @@
1
+ import useReadonlyFetchTobs from "./hooks/useReadonlyFetchTobs";
2
+ export { useReadonlyFetchTobs };
@@ -0,0 +1,2 @@
1
+ import useReadonlyFetchTobs from "./hooks/useReadonlyFetchTobs";
2
+ export { useReadonlyFetchTobs };
@@ -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.26",
3
+ "version": "1.2.29",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -18,6 +18,7 @@
18
18
  "devDependencies": {
19
19
  "@types/bcryptjs": "^2.4.2",
20
20
  "@types/randomatic": "^3.1.3",
21
+ "@types/react": "^18.0.18",
21
22
  "typescript": "^4.7.4"
22
23
  },
23
24
  "dependencies": {
@@ -25,6 +26,7 @@
25
26
  "bcryptjs": "^2.4.3",
26
27
  "jwt-decode": "^3.1.2",
27
28
  "randomatic": "^3.1.1",
29
+ "react": "^18.2.0",
28
30
  "yup": "^0.32.11"
29
31
  }
30
32
  }