asv-hlps 1.2.21 → 1.2.24

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.
Files changed (53) hide show
  1. package/lib/cjs/index.d.ts +5 -3
  2. package/lib/cjs/index.js +5 -3
  3. package/lib/cjs/models/entities/users/Address.d.ts +8 -8
  4. package/lib/cjs/models/entities/users/UserAbs.d.ts +2 -2
  5. package/lib/cjs/{typeorm.d.ts → npms/typeorm.d.ts} +0 -0
  6. package/lib/cjs/{typeorm.js → npms/typeorm.js} +0 -0
  7. package/lib/cjs/npms/yup.d.ts +47 -0
  8. package/lib/cjs/npms/yup.js +158 -0
  9. package/lib/esm/index.d.ts +5 -3
  10. package/lib/esm/index.js +5 -3
  11. package/lib/esm/models/entities/users/Address.d.ts +8 -8
  12. package/lib/esm/models/entities/users/UserAbs.d.ts +2 -2
  13. package/lib/esm/{typeorm.d.ts → npms/typeorm.d.ts} +0 -0
  14. package/lib/esm/{typeorm.js → npms/typeorm.js} +0 -0
  15. package/lib/esm/npms/yup.d.ts +47 -0
  16. package/lib/esm/npms/yup.js +119 -0
  17. package/package.json +3 -2
  18. package/lib/cjs/models/entities/estates/Estate.d.ts +0 -24
  19. package/lib/cjs/models/entities/estates/Estate.js +0 -2
  20. package/lib/cjs/models/entities/estates/EstateAsset.d.ts +0 -7
  21. package/lib/cjs/models/entities/estates/EstateAsset.js +0 -2
  22. package/lib/cjs/models/entities/estates/EstateCat.d.ts +0 -3
  23. package/lib/cjs/models/entities/estates/EstateCat.js +0 -2
  24. package/lib/cjs/models/entities/estates/EstateElt.d.ts +0 -3
  25. package/lib/cjs/models/entities/estates/EstateElt.js +0 -2
  26. package/lib/cjs/models/entities/estates/EstateLevel.d.ts +0 -3
  27. package/lib/cjs/models/entities/estates/EstateLevel.js +0 -2
  28. package/lib/cjs/models/entities/estates/EstatePor.d.ts +0 -3
  29. package/lib/cjs/models/entities/estates/EstatePor.js +0 -2
  30. package/lib/cjs/models/entities/estates/Housing.d.ts +0 -17
  31. package/lib/cjs/models/entities/estates/Housing.js +0 -2
  32. package/lib/cjs/models/entities/estates/HousingRented.d.ts +0 -15
  33. package/lib/cjs/models/entities/estates/HousingRented.js +0 -2
  34. package/lib/cjs/models/entities/estates/index.d.ts +0 -9
  35. package/lib/cjs/models/entities/estates/index.js +0 -2
  36. package/lib/esm/models/entities/estates/Estate.d.ts +0 -24
  37. package/lib/esm/models/entities/estates/Estate.js +0 -1
  38. package/lib/esm/models/entities/estates/EstateAsset.d.ts +0 -7
  39. package/lib/esm/models/entities/estates/EstateAsset.js +0 -1
  40. package/lib/esm/models/entities/estates/EstateCat.d.ts +0 -3
  41. package/lib/esm/models/entities/estates/EstateCat.js +0 -1
  42. package/lib/esm/models/entities/estates/EstateElt.d.ts +0 -3
  43. package/lib/esm/models/entities/estates/EstateElt.js +0 -1
  44. package/lib/esm/models/entities/estates/EstateLevel.d.ts +0 -3
  45. package/lib/esm/models/entities/estates/EstateLevel.js +0 -1
  46. package/lib/esm/models/entities/estates/EstatePor.d.ts +0 -3
  47. package/lib/esm/models/entities/estates/EstatePor.js +0 -1
  48. package/lib/esm/models/entities/estates/Housing.d.ts +0 -17
  49. package/lib/esm/models/entities/estates/Housing.js +0 -1
  50. package/lib/esm/models/entities/estates/HousingRented.d.ts +0 -15
  51. package/lib/esm/models/entities/estates/HousingRented.js +0 -1
  52. package/lib/esm/models/entities/estates/index.d.ts +0 -9
  53. package/lib/esm/models/entities/estates/index.js +0 -1
@@ -9,6 +9,8 @@ import "./auth";
9
9
  import "./bill";
10
10
  import "./bootstrap";
11
11
  import "./models/index";
12
+ import "./npms/typeorm";
13
+ import "./npms/yup";
12
14
  import "./pdfs/invoices/amountInvoice";
13
15
  import "./pdfs/invoices/infoInvoice";
14
16
  import "./pdfs/tools/tools";
@@ -16,21 +18,21 @@ import "./product";
16
18
  import "./react-utils";
17
19
  import "./sale";
18
20
  import "./services/authService";
19
- import "./typeorm";
20
21
  import "./user";
21
22
  import "./utils";
22
23
  export * from "./auth";
23
24
  export * from "./bill";
24
25
  export * from "./bootstrap";
26
+ export * from "./core/estates/index";
25
27
  export * from "./models/index";
28
+ export * from "./npms/typeorm";
29
+ export * from "./npms/yup";
26
30
  export * from "./pdfs/invoices/amountInvoice";
27
31
  export * from "./pdfs/invoices/infoInvoice";
28
32
  export * from "./pdfs/tools/tools";
29
33
  export * from "./product";
30
34
  export * from "./react-utils";
31
35
  export * from "./sale";
32
- export * from "./typeorm";
33
36
  export * from "./user";
34
37
  export * from "./utils";
35
- export * from "./core/estates/index";
36
38
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
package/lib/cjs/index.js CHANGED
@@ -39,6 +39,8 @@ require("./bootstrap");
39
39
  // import "./models/entities/users";
40
40
  // import "./models/entities/users/index";
41
41
  require("./models/index");
42
+ require("./npms/typeorm");
43
+ require("./npms/yup");
42
44
  require("./pdfs/invoices/amountInvoice");
43
45
  require("./pdfs/invoices/infoInvoice");
44
46
  require("./pdfs/tools/tools");
@@ -46,20 +48,20 @@ require("./product");
46
48
  require("./react-utils");
47
49
  require("./sale");
48
50
  require("./services/authService");
49
- require("./typeorm");
50
51
  require("./user");
51
52
  require("./utils");
52
53
  __exportStar(require("./auth"), exports);
53
54
  __exportStar(require("./bill"), exports);
54
55
  __exportStar(require("./bootstrap"), exports);
56
+ __exportStar(require("./core/estates/index"), exports);
55
57
  __exportStar(require("./models/index"), exports);
58
+ __exportStar(require("./npms/typeorm"), exports);
59
+ __exportStar(require("./npms/yup"), exports);
56
60
  __exportStar(require("./pdfs/invoices/amountInvoice"), exports);
57
61
  __exportStar(require("./pdfs/invoices/infoInvoice"), exports);
58
62
  __exportStar(require("./pdfs/tools/tools"), exports);
59
63
  __exportStar(require("./product"), exports);
60
64
  __exportStar(require("./react-utils"), exports);
61
65
  __exportStar(require("./sale"), exports);
62
- __exportStar(require("./typeorm"), exports);
63
66
  __exportStar(require("./user"), exports);
64
67
  __exportStar(require("./utils"), exports);
65
- __exportStar(require("./core/estates/index"), exports);
@@ -2,12 +2,12 @@ import { City } from "../world/City";
2
2
  import { Country } from "../world/Country";
3
3
  import { Region } from "../world/Region";
4
4
  export interface Address {
5
- phoneP: string;
6
- phoneS: string;
7
- address: string;
8
- city: City;
9
- country: Country;
10
- region: Region;
11
- email: string;
12
- cp: number;
5
+ phoneP?: string;
6
+ phoneS?: string;
7
+ address?: string;
8
+ city?: City;
9
+ country?: Country;
10
+ region?: Region;
11
+ email?: string;
12
+ cp?: number;
13
13
  }
@@ -6,7 +6,7 @@ import { UserGrp } from "./UserGrp";
6
6
  import { UserRole } from "./UserRole";
7
7
  import { UserTitr } from "./UserTitr";
8
8
  export interface UserAbs extends Address {
9
- id: number;
9
+ id?: number;
10
10
  codeCompta?: string | number;
11
11
  firstname?: string;
12
12
  lastname?: string;
@@ -14,7 +14,7 @@ export interface UserAbs extends Address {
14
14
  birthday?: Date | string;
15
15
  password?: string;
16
16
  ip?: string;
17
- isActive: boolean;
17
+ isActive?: boolean;
18
18
  disabled?: boolean;
19
19
  foto?: string;
20
20
  clp?: string;
File without changes
File without changes
@@ -0,0 +1,47 @@
1
+ import * as yup from "yup";
2
+ export declare const schemaNaCoSh: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
4
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
5
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
6
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
8
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
9
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
10
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
11
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
12
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
13
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
14
+ }>>>;
15
+ export declare const schemaNaCo: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
17
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
18
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
19
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
20
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
21
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
23
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
24
+ }>>>;
25
+ export declare const schemaNa: (url: string, tob: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
26
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
27
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
28
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
29
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
30
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
31
+ }>>>;
32
+ export declare const schemaLogin: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
33
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
34
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
35
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
36
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
37
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
38
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
39
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
40
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
41
+ }>>>;
42
+ export declare const yupValideUniqName: (url: string, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
43
+ export declare const yupValideUniqEmail: (url: string, tob: any, isRequired?: boolean) => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
44
+ export declare const yupValideUniqNumber: (url: string, tob: any, isRequired?: boolean) => yup.NumberSchema<number, import("yup/lib/types").AnyObject, number>;
45
+ export declare const yupValideUniqCode: (url: string, max: number, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
46
+ export declare const yupValidateNoRequiredNumber: () => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
47
+ export declare const formatSelectOptions: (objs: any[], propLabel?: string, propValue?: string) => any[];
@@ -0,0 +1,158 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.formatSelectOptions = exports.yupValidateNoRequiredNumber = exports.yupValideUniqCode = exports.yupValideUniqNumber = exports.yupValideUniqEmail = exports.yupValideUniqName = exports.schemaLogin = exports.schemaNa = exports.schemaNaCo = exports.schemaNaCoSh = void 0;
39
+ const axios_1 = __importDefault(require("axios"));
40
+ const yup = __importStar(require("yup"));
41
+ const schemaNaCoSh = (url, tob, codeMaxLenth = 4) => yup.object().shape({
42
+ name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
43
+ code: (0, exports.yupValideUniqCode)(url + "/checkUniqueCode", codeMaxLenth, tob),
44
+ shortname: (0, exports.yupValideUniqName)(url + "/checkUniqueShortname", tob),
45
+ });
46
+ exports.schemaNaCoSh = schemaNaCoSh;
47
+ const schemaNaCo = (url, tob, codeMaxLenth = 4) => yup.object().shape({
48
+ name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
49
+ code: (0, exports.yupValideUniqCode)(url + "/checkUniqueCode", codeMaxLenth, tob),
50
+ });
51
+ exports.schemaNaCo = schemaNaCo;
52
+ const schemaNa = (url, tob) => yup.object().shape({
53
+ name: (0, exports.yupValideUniqName)(url + "/checkUniqueName", tob),
54
+ });
55
+ exports.schemaNa = schemaNa;
56
+ const schemaLogin = () => yup.object().shape({
57
+ // email: yup.string().required(t("Please enter Email")),
58
+ username: yup.string().required("Please enter Email"),
59
+ password: yup.string().required("Please enter Password"),
60
+ // checkbox: yup.bool().oneOf([true]),
61
+ });
62
+ exports.schemaLogin = schemaLogin;
63
+ const yupValideUniqName = (url, tob) => {
64
+ return yup
65
+ .string()
66
+ .required()
67
+ .test("Check_name", "This name is already taken", (value) => {
68
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
69
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
70
+ res ? resolve(true) : resolve(false);
71
+ }));
72
+ });
73
+ };
74
+ exports.yupValideUniqName = yupValideUniqName;
75
+ const yupValideUniqEmail = (url, tob, isRequired = true) => {
76
+ if (isRequired) {
77
+ return yup
78
+ .string()
79
+ .email("this value must be a valid email")
80
+ .required("this value is required")
81
+ .test("Check_name", "This name is already taken", (value) => {
82
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
83
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
84
+ res ? resolve(true) : resolve(false);
85
+ }));
86
+ });
87
+ }
88
+ return yup.string().when((val) => {
89
+ if (val) {
90
+ return yup
91
+ .string()
92
+ .email()
93
+ .test("Check_name", "This name is already taken", (value) => {
94
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
95
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
96
+ res ? resolve(true) : resolve(false);
97
+ }));
98
+ });
99
+ }
100
+ });
101
+ };
102
+ exports.yupValideUniqEmail = yupValideUniqEmail;
103
+ const yupValideUniqNumber = (url, tob, isRequired = true) => {
104
+ if (isRequired) {
105
+ return yup
106
+ .number()
107
+ .required()
108
+ .test("Check_name", "This name is already taken", (value) => {
109
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
110
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
111
+ res ? resolve(true) : resolve(false);
112
+ }));
113
+ });
114
+ }
115
+ return yup.number().test("Check_name", "This name is already taken", (value) => {
116
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
117
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
118
+ res ? resolve(true) : resolve(false);
119
+ }));
120
+ });
121
+ };
122
+ exports.yupValideUniqNumber = yupValideUniqNumber;
123
+ const yupValideUniqCode = (url, max = 4, tob) => {
124
+ return yup
125
+ .string()
126
+ .required()
127
+ .min(2)
128
+ .max(max)
129
+ .test("Check_name", "This name is already taken", (value) => {
130
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
131
+ const { data: res } = yield axios_1.default.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
132
+ res ? resolve(true) : resolve(false);
133
+ }));
134
+ });
135
+ };
136
+ exports.yupValideUniqCode = yupValideUniqCode;
137
+ const yupValidateNoRequiredNumber = () => {
138
+ return yup
139
+ .string()
140
+ .when((val) => {
141
+ if (val) {
142
+ return yup.number();
143
+ }
144
+ })
145
+ .typeError("must be number");
146
+ };
147
+ exports.yupValidateNoRequiredNumber = yupValidateNoRequiredNumber;
148
+ const formatSelectOptions = (objs, propLabel = "name", propValue = "id") => {
149
+ if (!objs.length) {
150
+ return objs;
151
+ }
152
+ let options = [];
153
+ for (const obj of objs) {
154
+ options.push({ value: obj[propValue], label: obj[propLabel] });
155
+ }
156
+ return options;
157
+ };
158
+ exports.formatSelectOptions = formatSelectOptions;
@@ -9,6 +9,8 @@ import "./auth";
9
9
  import "./bill";
10
10
  import "./bootstrap";
11
11
  import "./models/index";
12
+ import "./npms/typeorm";
13
+ import "./npms/yup";
12
14
  import "./pdfs/invoices/amountInvoice";
13
15
  import "./pdfs/invoices/infoInvoice";
14
16
  import "./pdfs/tools/tools";
@@ -16,21 +18,21 @@ import "./product";
16
18
  import "./react-utils";
17
19
  import "./sale";
18
20
  import "./services/authService";
19
- import "./typeorm";
20
21
  import "./user";
21
22
  import "./utils";
22
23
  export * from "./auth";
23
24
  export * from "./bill";
24
25
  export * from "./bootstrap";
26
+ export * from "./core/estates/index";
25
27
  export * from "./models/index";
28
+ export * from "./npms/typeorm";
29
+ export * from "./npms/yup";
26
30
  export * from "./pdfs/invoices/amountInvoice";
27
31
  export * from "./pdfs/invoices/infoInvoice";
28
32
  export * from "./pdfs/tools/tools";
29
33
  export * from "./product";
30
34
  export * from "./react-utils";
31
35
  export * from "./sale";
32
- export * from "./typeorm";
33
36
  export * from "./user";
34
37
  export * from "./utils";
35
- export * from "./core/estates/index";
36
38
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
package/lib/esm/index.js CHANGED
@@ -12,6 +12,8 @@ import "./bootstrap";
12
12
  // import "./models/entities/users";
13
13
  // import "./models/entities/users/index";
14
14
  import "./models/index";
15
+ import "./npms/typeorm";
16
+ import "./npms/yup";
15
17
  import "./pdfs/invoices/amountInvoice";
16
18
  import "./pdfs/invoices/infoInvoice";
17
19
  import "./pdfs/tools/tools";
@@ -19,22 +21,22 @@ import "./product";
19
21
  import "./react-utils";
20
22
  import "./sale";
21
23
  import "./services/authService";
22
- import "./typeorm";
23
24
  import "./user";
24
25
  import "./utils";
25
26
  export * from "./auth";
26
27
  export * from "./bill";
27
28
  export * from "./bootstrap";
29
+ export * from "./core/estates/index";
28
30
  export * from "./models/index";
31
+ export * from "./npms/typeorm";
32
+ export * from "./npms/yup";
29
33
  export * from "./pdfs/invoices/amountInvoice";
30
34
  export * from "./pdfs/invoices/infoInvoice";
31
35
  export * from "./pdfs/tools/tools";
32
36
  export * from "./product";
33
37
  export * from "./react-utils";
34
38
  export * from "./sale";
35
- export * from "./typeorm";
36
39
  export * from "./user";
37
40
  export * from "./utils";
38
- export * from "./core/estates/index";
39
41
  // export * from "./helpers/hlpProduct";
40
42
  export { AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe };
@@ -2,12 +2,12 @@ import { City } from "../world/City";
2
2
  import { Country } from "../world/Country";
3
3
  import { Region } from "../world/Region";
4
4
  export interface Address {
5
- phoneP: string;
6
- phoneS: string;
7
- address: string;
8
- city: City;
9
- country: Country;
10
- region: Region;
11
- email: string;
12
- cp: number;
5
+ phoneP?: string;
6
+ phoneS?: string;
7
+ address?: string;
8
+ city?: City;
9
+ country?: Country;
10
+ region?: Region;
11
+ email?: string;
12
+ cp?: number;
13
13
  }
@@ -6,7 +6,7 @@ import { UserGrp } from "./UserGrp";
6
6
  import { UserRole } from "./UserRole";
7
7
  import { UserTitr } from "./UserTitr";
8
8
  export interface UserAbs extends Address {
9
- id: number;
9
+ id?: number;
10
10
  codeCompta?: string | number;
11
11
  firstname?: string;
12
12
  lastname?: string;
@@ -14,7 +14,7 @@ export interface UserAbs extends Address {
14
14
  birthday?: Date | string;
15
15
  password?: string;
16
16
  ip?: string;
17
- isActive: boolean;
17
+ isActive?: boolean;
18
18
  disabled?: boolean;
19
19
  foto?: string;
20
20
  clp?: string;
File without changes
File without changes
@@ -0,0 +1,47 @@
1
+ import * as yup from "yup";
2
+ export declare const schemaNaCoSh: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
4
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
5
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
6
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
8
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
9
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
10
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
11
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
12
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
13
+ shortname: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
14
+ }>>>;
15
+ export declare const schemaNaCo: (url: string, tob: any, codeMaxLenth?: number) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
17
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
18
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
19
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
20
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
21
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
23
+ code: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
24
+ }>>>;
25
+ export declare const schemaNa: (url: string, tob: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
26
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
27
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
28
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
29
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
30
+ name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
31
+ }>>>;
32
+ export declare const schemaLogin: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
33
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
34
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
35
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
36
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
37
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
38
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
39
+ username: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
40
+ password: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
41
+ }>>>;
42
+ export declare const yupValideUniqName: (url: string, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
43
+ export declare const yupValideUniqEmail: (url: string, tob: any, isRequired?: boolean) => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
44
+ export declare const yupValideUniqNumber: (url: string, tob: any, isRequired?: boolean) => yup.NumberSchema<number, import("yup/lib/types").AnyObject, number>;
45
+ export declare const yupValideUniqCode: (url: string, max: number, tob: any) => import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
46
+ export declare const yupValidateNoRequiredNumber: () => yup.StringSchema<string, import("yup/lib/types").AnyObject, string>;
47
+ export declare const formatSelectOptions: (objs: any[], propLabel?: string, propValue?: string) => any[];
@@ -0,0 +1,119 @@
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 axios from "axios";
11
+ import * as yup from "yup";
12
+ export const schemaNaCoSh = (url, tob, codeMaxLenth = 4) => yup.object().shape({
13
+ name: yupValideUniqName(url + "/checkUniqueName", tob),
14
+ code: yupValideUniqCode(url + "/checkUniqueCode", codeMaxLenth, tob),
15
+ shortname: yupValideUniqName(url + "/checkUniqueShortname", tob),
16
+ });
17
+ export const schemaNaCo = (url, tob, codeMaxLenth = 4) => yup.object().shape({
18
+ name: yupValideUniqName(url + "/checkUniqueName", tob),
19
+ code: yupValideUniqCode(url + "/checkUniqueCode", codeMaxLenth, tob),
20
+ });
21
+ export const schemaNa = (url, tob) => yup.object().shape({
22
+ name: yupValideUniqName(url + "/checkUniqueName", tob),
23
+ });
24
+ export const schemaLogin = () => yup.object().shape({
25
+ // email: yup.string().required(t("Please enter Email")),
26
+ username: yup.string().required("Please enter Email"),
27
+ password: yup.string().required("Please enter Password"),
28
+ // checkbox: yup.bool().oneOf([true]),
29
+ });
30
+ export const yupValideUniqName = (url, tob) => {
31
+ return yup
32
+ .string()
33
+ .required()
34
+ .test("Check_name", "This name is already taken", (value) => {
35
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
37
+ res ? resolve(true) : resolve(false);
38
+ }));
39
+ });
40
+ };
41
+ export const yupValideUniqEmail = (url, tob, isRequired = true) => {
42
+ if (isRequired) {
43
+ return yup
44
+ .string()
45
+ .email("this value must be a valid email")
46
+ .required("this value is required")
47
+ .test("Check_name", "This name is already taken", (value) => {
48
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
49
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
50
+ res ? resolve(true) : resolve(false);
51
+ }));
52
+ });
53
+ }
54
+ return yup.string().when((val) => {
55
+ if (val) {
56
+ return yup
57
+ .string()
58
+ .email()
59
+ .test("Check_name", "This name is already taken", (value) => {
60
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
61
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
62
+ res ? resolve(true) : resolve(false);
63
+ }));
64
+ });
65
+ }
66
+ });
67
+ };
68
+ export const yupValideUniqNumber = (url, tob, isRequired = true) => {
69
+ if (isRequired) {
70
+ return yup
71
+ .number()
72
+ .required()
73
+ .test("Check_name", "This name is already taken", (value) => {
74
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
75
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
76
+ res ? resolve(true) : resolve(false);
77
+ }));
78
+ });
79
+ }
80
+ return yup.number().test("Check_name", "This name is already taken", (value) => {
81
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
82
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
83
+ res ? resolve(true) : resolve(false);
84
+ }));
85
+ });
86
+ };
87
+ export const yupValideUniqCode = (url, max = 4, tob) => {
88
+ return yup
89
+ .string()
90
+ .required()
91
+ .min(2)
92
+ .max(max)
93
+ .test("Check_name", "This name is already taken", (value) => {
94
+ return new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
95
+ const { data: res } = yield axios.post(url, { id: tob === null || tob === void 0 ? void 0 : tob.id, name: value });
96
+ res ? resolve(true) : resolve(false);
97
+ }));
98
+ });
99
+ };
100
+ export const yupValidateNoRequiredNumber = () => {
101
+ return yup
102
+ .string()
103
+ .when((val) => {
104
+ if (val) {
105
+ return yup.number();
106
+ }
107
+ })
108
+ .typeError("must be number");
109
+ };
110
+ export const formatSelectOptions = (objs, propLabel = "name", propValue = "id") => {
111
+ if (!objs.length) {
112
+ return objs;
113
+ }
114
+ let options = [];
115
+ for (const obj of objs) {
116
+ options.push({ value: obj[propValue], label: obj[propLabel] });
117
+ }
118
+ return options;
119
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.21",
3
+ "version": "1.2.24",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -24,6 +24,7 @@
24
24
  "axios": "^0.27.2",
25
25
  "bcryptjs": "^2.4.3",
26
26
  "jwt-decode": "^3.1.2",
27
- "randomatic": "^3.1.1"
27
+ "randomatic": "^3.1.1",
28
+ "yup": "^0.32.11"
28
29
  }
29
30
  }
@@ -1,24 +0,0 @@
1
- import { User } from "../users/User";
2
- import { City } from "../world/City";
3
- import { Quarter } from "../world/Quarter";
4
- import { Region } from "../world/Region";
5
- import { EstateAsset } from "./EstateAsset";
6
- import { EstateCat } from "./EstateCat";
7
- import { EstatePor } from "./EstatePor";
8
- import { Housing } from "./Housing";
9
- export interface Estate {
10
- id: number;
11
- ref: string;
12
- createdAt: Date;
13
- description: string;
14
- salePrice: number;
15
- cat: EstateCat;
16
- por: EstatePor;
17
- region?: Region;
18
- city?: City;
19
- quarter?: Quarter;
20
- prop?: User;
21
- isActive?: boolean;
22
- housings?: Housing[];
23
- assets?: EstateAsset[];
24
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- export interface EstateAsset {
2
- id: number;
3
- name: string;
4
- elt: string;
5
- qtity: number;
6
- size: string;
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateCat extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateElt extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateLevel extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstatePor extends NaCoAc {
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- import { User } from "../users/User";
2
- import { Estate } from "./Estate";
3
- import { HousingRented } from "./HousingRented";
4
- export interface Housing {
5
- id: number;
6
- createdAt: Date;
7
- description: string;
8
- ref: string;
9
- price: number;
10
- deposit: number;
11
- chargesPrice: number;
12
- isActive: boolean;
13
- estate: Estate;
14
- lodger: User;
15
- encoder: User;
16
- rented: HousingRented;
17
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,15 +0,0 @@
1
- import { User } from "../users/User";
2
- import { Housing } from "./Housing";
3
- export interface HousingRented {
4
- id: number;
5
- dateIn: Date;
6
- dateOut: Date;
7
- price: number;
8
- deposit: number;
9
- prepaid: number;
10
- lodger?: User;
11
- lodgerId?: number;
12
- housingId?: number;
13
- housing?: Housing;
14
- encoder?: User;
15
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { Estate } from "./Estate";
2
- import { EstateAsset } from "./EstateAsset";
3
- import { EstateCat } from "./EstateCat";
4
- import { EstateElt } from "./EstateElt";
5
- import { EstateLevel } from "./EstateLevel";
6
- import { EstatePor } from "./EstatePor";
7
- import { Housing } from "./Housing";
8
- import { HousingRented } from "./HousingRented";
9
- export { Estate, EstateAsset, EstateCat, EstateElt, EstateLevel, EstatePor, Housing, HousingRented };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- import { User } from "../users/User";
2
- import { City } from "../world/City";
3
- import { Quarter } from "../world/Quarter";
4
- import { Region } from "../world/Region";
5
- import { EstateAsset } from "./EstateAsset";
6
- import { EstateCat } from "./EstateCat";
7
- import { EstatePor } from "./EstatePor";
8
- import { Housing } from "./Housing";
9
- export interface Estate {
10
- id: number;
11
- ref: string;
12
- createdAt: Date;
13
- description: string;
14
- salePrice: number;
15
- cat: EstateCat;
16
- por: EstatePor;
17
- region?: Region;
18
- city?: City;
19
- quarter?: Quarter;
20
- prop?: User;
21
- isActive?: boolean;
22
- housings?: Housing[];
23
- assets?: EstateAsset[];
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export interface EstateAsset {
2
- id: number;
3
- name: string;
4
- elt: string;
5
- qtity: number;
6
- size: string;
7
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateCat extends NaCoAc {
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateElt extends NaCoAc {
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstateLevel extends NaCoAc {
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { NaCoAc } from "../../shared/NaCoAc";
2
- export interface EstatePor extends NaCoAc {
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import { User } from "../users/User";
2
- import { Estate } from "./Estate";
3
- import { HousingRented } from "./HousingRented";
4
- export interface Housing {
5
- id: number;
6
- createdAt: Date;
7
- description: string;
8
- ref: string;
9
- price: number;
10
- deposit: number;
11
- chargesPrice: number;
12
- isActive: boolean;
13
- estate: Estate;
14
- lodger: User;
15
- encoder: User;
16
- rented: HousingRented;
17
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import { User } from "../users/User";
2
- import { Housing } from "./Housing";
3
- export interface HousingRented {
4
- id: number;
5
- dateIn: Date;
6
- dateOut: Date;
7
- price: number;
8
- deposit: number;
9
- prepaid: number;
10
- lodger?: User;
11
- lodgerId?: number;
12
- housingId?: number;
13
- housing?: Housing;
14
- encoder?: User;
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { Estate } from "./Estate";
2
- import { EstateAsset } from "./EstateAsset";
3
- import { EstateCat } from "./EstateCat";
4
- import { EstateElt } from "./EstateElt";
5
- import { EstateLevel } from "./EstateLevel";
6
- import { EstatePor } from "./EstatePor";
7
- import { Housing } from "./Housing";
8
- import { HousingRented } from "./HousingRented";
9
- export { Estate, EstateAsset, EstateCat, EstateElt, EstateLevel, EstatePor, Housing, HousingRented };
@@ -1 +0,0 @@
1
- export {};