asv-hlps 1.4.68 → 1.4.70
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/estates/models/Estate.d.ts +1 -0
- package/lib/cjs/estates/models/EstateElt.d.ts +1 -0
- package/lib/cjs/pdfs/tools.js +1 -1
- package/lib/cjs/shared/HlpCrud.d.ts +1 -2
- package/lib/cjs/shared/HlpCrud.js +32 -23
- package/lib/cjs/users/user.d.ts +2 -2
- package/lib/cjs/users/user.js +4 -8
- package/lib/esm/estates/models/Estate.d.ts +1 -0
- package/lib/esm/estates/models/EstateElt.d.ts +1 -0
- package/lib/esm/pdfs/tools.js +1 -1
- package/lib/esm/shared/HlpCrud.d.ts +1 -2
- package/lib/esm/shared/HlpCrud.js +32 -23
- package/lib/esm/users/user.d.ts +2 -2
- package/lib/esm/users/user.js +4 -8
- package/package.json +14 -14
package/lib/cjs/pdfs/tools.js
CHANGED
|
@@ -22,7 +22,7 @@ const displayTitle = (title) => {
|
|
|
22
22
|
exports.displayTitle = displayTitle;
|
|
23
23
|
const displayClient = (user) => {
|
|
24
24
|
// const clientSte = user.ste ? HlpUser.getSteShortname(user.ste) : '';
|
|
25
|
-
const clientSte = user.ste ? (0, user_1.getSteShortname)(user.ste, ["pharmacie", "clinique", "hopital"]) : "";
|
|
25
|
+
const clientSte = user.ste ? (0, user_1.getSteShortname)(user.ste, "code", ["pharmacie", "clinique", "hopital"]) : "";
|
|
26
26
|
/* const clientLastname = (user.lastname) ? user.lastname : '';
|
|
27
27
|
const clientFirstname = (user.firstname) ? user.firstname : '';
|
|
28
28
|
const clientGender = (user.gender) ? user.gender.abr : ''; */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Request, Response } from "express";
|
|
2
1
|
import { Entity } from "typeorm";
|
|
3
2
|
export declare class HlpCrud {
|
|
4
3
|
dataSource: any;
|
|
5
4
|
constructor(dataSource: any);
|
|
6
|
-
checkUniqProp(prop: string, model: any,
|
|
5
|
+
checkUniqProp(prop: string, model: any, body: any, bodyName?: string): Promise<boolean>;
|
|
7
6
|
toggleProp(id: number, prop: string, model: typeof Entity | any): Promise<any>;
|
|
8
7
|
create(tob: any, model: typeof Entity | any): any;
|
|
9
8
|
del(id: number, model: typeof Entity | any): any;
|
|
@@ -15,37 +15,46 @@ class HlpCrud {
|
|
|
15
15
|
constructor(dataSource) {
|
|
16
16
|
this.dataSource = dataSource;
|
|
17
17
|
}
|
|
18
|
-
checkUniqProp(
|
|
19
|
-
return __awaiter(this,
|
|
18
|
+
checkUniqProp(prop_1, model_1, body_1) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* (prop, model, body, bodyName = "name") {
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
const reqId = req.body.id;
|
|
23
|
-
const obj = yield this.dataSource.manager.findOneBy(model, { [prop]: reqName });
|
|
21
|
+
const obj = yield this.dataSource.manager.findOneBy(model, { [prop]: body[bodyName] });
|
|
24
22
|
// ------ no obj ------
|
|
25
|
-
if (!obj)
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
// ------ if id ------
|
|
29
|
-
if (reqId) {
|
|
30
|
-
return reqId === obj.id ? res.send(true) : res.send(false);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return res.send(false);
|
|
34
|
-
}
|
|
23
|
+
if (!obj)
|
|
24
|
+
return true;
|
|
25
|
+
return body.id ? body.id === obj.id : false;
|
|
35
26
|
}
|
|
36
27
|
catch (error) {
|
|
37
28
|
console.log(error);
|
|
38
29
|
}
|
|
39
|
-
/* try {
|
|
40
|
-
const repository = dataSource.manager
|
|
41
|
-
|
|
42
|
-
const obj = await repository.findOneBy(model, {[prop]: req.body.name})
|
|
43
|
-
this.checkObj(obj, req.body.id, res)
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.log(error);
|
|
46
|
-
} */
|
|
47
30
|
});
|
|
48
31
|
}
|
|
32
|
+
// async checkUniqProp(prop: string, model: any, req: Request, res: Response) {
|
|
33
|
+
// try {
|
|
34
|
+
// const reqName = req.body.name;
|
|
35
|
+
// const reqId = req.body.id;
|
|
36
|
+
// const obj: any = await this.dataSource.manager.findOneBy(model, { [prop]: reqName });
|
|
37
|
+
// // ------ no obj ------
|
|
38
|
+
// if (!obj) {
|
|
39
|
+
// return res.send(true);
|
|
40
|
+
// }
|
|
41
|
+
// // ------ if id ------
|
|
42
|
+
// if (reqId) {
|
|
43
|
+
// return reqId === obj.id ? res.send(true) : res.send(false);
|
|
44
|
+
// } else {
|
|
45
|
+
// return res.send(false);
|
|
46
|
+
// }
|
|
47
|
+
// } catch (error) {
|
|
48
|
+
// console.log(error);
|
|
49
|
+
// }
|
|
50
|
+
// /* try {
|
|
51
|
+
// const repository = dataSource.manager
|
|
52
|
+
// const obj = await repository.findOneBy(model, {[prop]: req.body.name})
|
|
53
|
+
// this.checkObj(obj, req.body.id, res)
|
|
54
|
+
// } catch (error) {
|
|
55
|
+
// console.log(error);
|
|
56
|
+
// } */
|
|
57
|
+
// }
|
|
49
58
|
toggleProp(id, prop, model) {
|
|
50
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
60
|
try {
|
package/lib/cjs/users/user.d.ts
CHANGED
|
@@ -48,6 +48,6 @@ export declare const userCoef: <T extends {
|
|
|
48
48
|
ste?: Ste;
|
|
49
49
|
grp?: UserGrp;
|
|
50
50
|
}>(user: T) => number;
|
|
51
|
-
export declare const labelSteName: (ste: Ste, size?: number, tabs?: string[]) => string;
|
|
52
|
-
export declare const getSteShortname: (ste: Ste, steGrpNames
|
|
51
|
+
export declare const labelSteName: (ste: Ste, size?: number, steGrpProp?: "code" | "shortname", tabs?: string[]) => string;
|
|
52
|
+
export declare const getSteShortname: (ste: Ste, steGrpProp?: "code" | "shortname", steGrpNames?: string[]) => string;
|
|
53
53
|
export {};
|
package/lib/cjs/users/user.js
CHANGED
|
@@ -118,11 +118,11 @@ const userCoef = (user) => {
|
|
|
118
118
|
return user.grp.code.toLowerCase() === "st" ? user.ste.grp.coef : user.grp.coef;
|
|
119
119
|
};
|
|
120
120
|
exports.userCoef = userCoef;
|
|
121
|
-
const labelSteName = (ste, size = 20, tabs = ["pharmacie", "clinique", "hopital"]) => {
|
|
121
|
+
const labelSteName = (ste, size = 20, steGrpProp = "code", tabs = ["pharmacie", "clinique", "hopital"]) => {
|
|
122
122
|
const steNameLength = ste.name.length;
|
|
123
123
|
if (steNameLength > size) {
|
|
124
|
+
const shortedName = (0, exports.getSteShortname)(ste, steGrpProp, tabs);
|
|
124
125
|
if (ste.shortname.length > size) {
|
|
125
|
-
const shortedName = (0, exports.getSteShortname)(ste, tabs);
|
|
126
126
|
if (shortedName.length > size) {
|
|
127
127
|
return (0, utils_1.limitTo)(shortedName, size - 2, "..");
|
|
128
128
|
}
|
|
@@ -133,17 +133,13 @@ const labelSteName = (ste, size = 20, tabs = ["pharmacie", "clinique", "hopital"
|
|
|
133
133
|
return ste.name;
|
|
134
134
|
};
|
|
135
135
|
exports.labelSteName = labelSteName;
|
|
136
|
-
const getSteShortname = (ste, steGrpNames) => {
|
|
136
|
+
const getSteShortname = (ste, steGrpProp = "code", steGrpNames = ["pharmacie", "clinique", "hopital"]) => {
|
|
137
137
|
if (!ste) {
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
|
-
// const tabs = ['pharmacie', 'clinique', 'hopital'];
|
|
141
140
|
const name = ste.name.trimStart();
|
|
142
141
|
const firstWord = name.substring(0, name.indexOf(" "));
|
|
143
142
|
const restWords = name.substring(name.indexOf(" ") + 1);
|
|
144
|
-
return steGrpNames.includes(firstWord.toLowerCase())
|
|
145
|
-
? // ste.grp.code.toLowerCase() + '. ' + restWords.trimLeft() :
|
|
146
|
-
ste.grp.code.toUpperCase() + ". " + restWords.trimStart()
|
|
147
|
-
: name;
|
|
143
|
+
return steGrpNames.includes(firstWord.toLowerCase()) ? ste.grp[steGrpProp].toUpperCase() + ". " + restWords.trimStart() : name;
|
|
148
144
|
};
|
|
149
145
|
exports.getSteShortname = getSteShortname;
|
package/lib/esm/pdfs/tools.js
CHANGED
|
@@ -17,7 +17,7 @@ export const displayTitle = (title) => {
|
|
|
17
17
|
};
|
|
18
18
|
export const displayClient = (user) => {
|
|
19
19
|
// const clientSte = user.ste ? HlpUser.getSteShortname(user.ste) : '';
|
|
20
|
-
const clientSte = user.ste ? getSteShortname(user.ste, ["pharmacie", "clinique", "hopital"]) : "";
|
|
20
|
+
const clientSte = user.ste ? getSteShortname(user.ste, "code", ["pharmacie", "clinique", "hopital"]) : "";
|
|
21
21
|
/* const clientLastname = (user.lastname) ? user.lastname : '';
|
|
22
22
|
const clientFirstname = (user.firstname) ? user.firstname : '';
|
|
23
23
|
const clientGender = (user.gender) ? user.gender.abr : ''; */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Request, Response } from "express";
|
|
2
1
|
import { Entity } from "typeorm";
|
|
3
2
|
export declare class HlpCrud {
|
|
4
3
|
dataSource: any;
|
|
5
4
|
constructor(dataSource: any);
|
|
6
|
-
checkUniqProp(prop: string, model: any,
|
|
5
|
+
checkUniqProp(prop: string, model: any, body: any, bodyName?: string): Promise<boolean>;
|
|
7
6
|
toggleProp(id: number, prop: string, model: typeof Entity | any): Promise<any>;
|
|
8
7
|
create(tob: any, model: typeof Entity | any): any;
|
|
9
8
|
del(id: number, model: typeof Entity | any): any;
|
|
@@ -12,37 +12,46 @@ export class HlpCrud {
|
|
|
12
12
|
constructor(dataSource) {
|
|
13
13
|
this.dataSource = dataSource;
|
|
14
14
|
}
|
|
15
|
-
checkUniqProp(
|
|
16
|
-
return __awaiter(this,
|
|
15
|
+
checkUniqProp(prop_1, model_1, body_1) {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* (prop, model, body, bodyName = "name") {
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
19
|
-
const reqId = req.body.id;
|
|
20
|
-
const obj = yield this.dataSource.manager.findOneBy(model, { [prop]: reqName });
|
|
18
|
+
const obj = yield this.dataSource.manager.findOneBy(model, { [prop]: body[bodyName] });
|
|
21
19
|
// ------ no obj ------
|
|
22
|
-
if (!obj)
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
// ------ if id ------
|
|
26
|
-
if (reqId) {
|
|
27
|
-
return reqId === obj.id ? res.send(true) : res.send(false);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return res.send(false);
|
|
31
|
-
}
|
|
20
|
+
if (!obj)
|
|
21
|
+
return true;
|
|
22
|
+
return body.id ? body.id === obj.id : false;
|
|
32
23
|
}
|
|
33
24
|
catch (error) {
|
|
34
25
|
console.log(error);
|
|
35
26
|
}
|
|
36
|
-
/* try {
|
|
37
|
-
const repository = dataSource.manager
|
|
38
|
-
|
|
39
|
-
const obj = await repository.findOneBy(model, {[prop]: req.body.name})
|
|
40
|
-
this.checkObj(obj, req.body.id, res)
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.log(error);
|
|
43
|
-
} */
|
|
44
27
|
});
|
|
45
28
|
}
|
|
29
|
+
// async checkUniqProp(prop: string, model: any, req: Request, res: Response) {
|
|
30
|
+
// try {
|
|
31
|
+
// const reqName = req.body.name;
|
|
32
|
+
// const reqId = req.body.id;
|
|
33
|
+
// const obj: any = await this.dataSource.manager.findOneBy(model, { [prop]: reqName });
|
|
34
|
+
// // ------ no obj ------
|
|
35
|
+
// if (!obj) {
|
|
36
|
+
// return res.send(true);
|
|
37
|
+
// }
|
|
38
|
+
// // ------ if id ------
|
|
39
|
+
// if (reqId) {
|
|
40
|
+
// return reqId === obj.id ? res.send(true) : res.send(false);
|
|
41
|
+
// } else {
|
|
42
|
+
// return res.send(false);
|
|
43
|
+
// }
|
|
44
|
+
// } catch (error) {
|
|
45
|
+
// console.log(error);
|
|
46
|
+
// }
|
|
47
|
+
// /* try {
|
|
48
|
+
// const repository = dataSource.manager
|
|
49
|
+
// const obj = await repository.findOneBy(model, {[prop]: req.body.name})
|
|
50
|
+
// this.checkObj(obj, req.body.id, res)
|
|
51
|
+
// } catch (error) {
|
|
52
|
+
// console.log(error);
|
|
53
|
+
// } */
|
|
54
|
+
// }
|
|
46
55
|
toggleProp(id, prop, model) {
|
|
47
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
57
|
try {
|
package/lib/esm/users/user.d.ts
CHANGED
|
@@ -48,6 +48,6 @@ export declare const userCoef: <T extends {
|
|
|
48
48
|
ste?: Ste;
|
|
49
49
|
grp?: UserGrp;
|
|
50
50
|
}>(user: T) => number;
|
|
51
|
-
export declare const labelSteName: (ste: Ste, size?: number, tabs?: string[]) => string;
|
|
52
|
-
export declare const getSteShortname: (ste: Ste, steGrpNames
|
|
51
|
+
export declare const labelSteName: (ste: Ste, size?: number, steGrpProp?: "code" | "shortname", tabs?: string[]) => string;
|
|
52
|
+
export declare const getSteShortname: (ste: Ste, steGrpProp?: "code" | "shortname", steGrpNames?: string[]) => string;
|
|
53
53
|
export {};
|
package/lib/esm/users/user.js
CHANGED
|
@@ -98,11 +98,11 @@ export const userGrpCode = (user) => {
|
|
|
98
98
|
export const userCoef = (user) => {
|
|
99
99
|
return user.grp.code.toLowerCase() === "st" ? user.ste.grp.coef : user.grp.coef;
|
|
100
100
|
};
|
|
101
|
-
export const labelSteName = (ste, size = 20, tabs = ["pharmacie", "clinique", "hopital"]) => {
|
|
101
|
+
export const labelSteName = (ste, size = 20, steGrpProp = "code", tabs = ["pharmacie", "clinique", "hopital"]) => {
|
|
102
102
|
const steNameLength = ste.name.length;
|
|
103
103
|
if (steNameLength > size) {
|
|
104
|
+
const shortedName = getSteShortname(ste, steGrpProp, tabs);
|
|
104
105
|
if (ste.shortname.length > size) {
|
|
105
|
-
const shortedName = getSteShortname(ste, tabs);
|
|
106
106
|
if (shortedName.length > size) {
|
|
107
107
|
return limitTo(shortedName, size - 2, "..");
|
|
108
108
|
}
|
|
@@ -112,16 +112,12 @@ export const labelSteName = (ste, size = 20, tabs = ["pharmacie", "clinique", "h
|
|
|
112
112
|
}
|
|
113
113
|
return ste.name;
|
|
114
114
|
};
|
|
115
|
-
export const getSteShortname = (ste, steGrpNames) => {
|
|
115
|
+
export const getSteShortname = (ste, steGrpProp = "code", steGrpNames = ["pharmacie", "clinique", "hopital"]) => {
|
|
116
116
|
if (!ste) {
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
|
-
// const tabs = ['pharmacie', 'clinique', 'hopital'];
|
|
120
119
|
const name = ste.name.trimStart();
|
|
121
120
|
const firstWord = name.substring(0, name.indexOf(" "));
|
|
122
121
|
const restWords = name.substring(name.indexOf(" ") + 1);
|
|
123
|
-
return steGrpNames.includes(firstWord.toLowerCase())
|
|
124
|
-
? // ste.grp.code.toLowerCase() + '. ' + restWords.trimLeft() :
|
|
125
|
-
ste.grp.code.toUpperCase() + ". " + restWords.trimStart()
|
|
126
|
-
: name;
|
|
122
|
+
return steGrpNames.includes(firstWord.toLowerCase()) ? ste.grp[steGrpProp].toUpperCase() + ". " + restWords.trimStart() : name;
|
|
127
123
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asv-hlps",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.70",
|
|
4
4
|
"description": "helpers",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -16,30 +16,30 @@
|
|
|
16
16
|
"author": "Aril Vignon",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/express": "^5.0.
|
|
19
|
+
"@types/express": "^5.0.6",
|
|
20
20
|
"@types/jwt-decode": "^3.1.0",
|
|
21
|
-
"@types/lodash": "^4.17.
|
|
22
|
-
"@types/pdfmake": "^0.2
|
|
21
|
+
"@types/lodash": "^4.17.24",
|
|
22
|
+
"@types/pdfmake": "^0.3.2",
|
|
23
23
|
"@types/randomatic": "^3.1.5",
|
|
24
|
-
"@types/react": "^19.2.
|
|
24
|
+
"@types/react": "^19.2.14"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tanstack/react-query": "^5.
|
|
28
|
-
"axios": "^1.13.
|
|
29
|
-
"class-validator": "^0.
|
|
27
|
+
"@tanstack/react-query": "^5.95.2",
|
|
28
|
+
"axios": "^1.13.6",
|
|
29
|
+
"class-validator": "^0.15.1",
|
|
30
30
|
"classnames": "^2.5.1",
|
|
31
|
-
"dayjs": "^1.11.
|
|
31
|
+
"dayjs": "^1.11.20",
|
|
32
32
|
"express": "^4.21.2",
|
|
33
33
|
"i": "^0.3.7",
|
|
34
34
|
"jwt-decode": "^4.0.0",
|
|
35
|
-
"lodash": "^4.17.
|
|
36
|
-
"npm": "^11.
|
|
37
|
-
"pdfmake": "^0.
|
|
35
|
+
"lodash": "^4.17.23",
|
|
36
|
+
"npm": "^11.12.0",
|
|
37
|
+
"pdfmake": "^0.3.7",
|
|
38
38
|
"randomatic": "^3.1.1",
|
|
39
39
|
"remove-accents": "^0.5.0",
|
|
40
|
-
"typeorm": "^0.3.
|
|
40
|
+
"typeorm": "^0.3.28",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"yup": "^1.7.1",
|
|
43
|
-
"zustand": "^5.0.
|
|
43
|
+
"zustand": "^5.0.12"
|
|
44
44
|
}
|
|
45
45
|
}
|