@movalib/movalib-commons 1.0.6 → 1.0.8

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.
@@ -12,3 +12,25 @@ export declare enum MovaAppType {
12
12
  */
13
13
  ADMIN = "ADMIN"
14
14
  }
15
+ export declare enum RoleType {
16
+ /**
17
+ * Client du centre auto (automobiliste)
18
+ */
19
+ CUSTOMER = "CUSTOMER",
20
+ /**
21
+ * Technicien du centre auto
22
+ */
23
+ TECHNICIAN = "GARAGE_LEADER",
24
+ /**
25
+ * Chef d'atelier
26
+ */
27
+ GARAGE_LEADER = "GARAGE_LEADER",
28
+ /**
29
+ * Administrateur du centre auto (propriétaire ou dirigeant)
30
+ */
31
+ GARAGE_ADMIN = "ADMINISTRATOR",
32
+ /**
33
+ * Super-Administrateur (team Movalib)
34
+ */
35
+ MOVALIB_ADMIN = "MOVALIB_ADMIN"
36
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MovaAppType = void 0;
3
+ exports.RoleType = exports.MovaAppType = void 0;
4
4
  var MovaAppType;
5
5
  (function (MovaAppType) {
6
6
  /**
@@ -16,3 +16,26 @@ var MovaAppType;
16
16
  */
17
17
  MovaAppType["ADMIN"] = "ADMIN";
18
18
  })(MovaAppType = exports.MovaAppType || (exports.MovaAppType = {}));
19
+ var RoleType;
20
+ (function (RoleType) {
21
+ /**
22
+ * Client du centre auto (automobiliste)
23
+ */
24
+ RoleType["CUSTOMER"] = "CUSTOMER";
25
+ /**
26
+ * Technicien du centre auto
27
+ */
28
+ RoleType["TECHNICIAN"] = "GARAGE_LEADER";
29
+ /**
30
+ * Chef d'atelier
31
+ */
32
+ RoleType["GARAGE_LEADER"] = "GARAGE_LEADER";
33
+ /**
34
+ * Administrateur du centre auto (propriétaire ou dirigeant)
35
+ */
36
+ RoleType["GARAGE_ADMIN"] = "ADMINISTRATOR";
37
+ /**
38
+ * Super-Administrateur (team Movalib)
39
+ */
40
+ RoleType["MOVALIB_ADMIN"] = "MOVALIB_ADMIN";
41
+ })(RoleType = exports.RoleType || (exports.RoleType = {}));
package/dist/index.d.ts CHANGED
@@ -2,5 +2,10 @@ export { default as TestButton } from './TestButton';
2
2
  export { default as MovaSnackbar } from './MovaSnackbar';
3
3
  export { default as MovaLogin } from './MovaLogin';
4
4
  export { default as MovaCopyright } from './MovaCopyright';
5
+ export { default as User } from './models/User';
6
+ export { default as Role } from './models/Role';
7
+ export { default as Address } from './models/Address';
5
8
  export type { MovaFormField } from './helpers/Types';
6
9
  export type { MovaLoginForm } from './helpers/Types';
10
+ export { RoleType } from './helpers/Enums';
11
+ export { MovaAppType } from './helpers/Enums';
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.MovaCopyright = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = void 0;
7
+ exports.MovaAppType = exports.RoleType = exports.Address = exports.Role = exports.User = exports.MovaCopyright = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = void 0;
8
+ // Export des composants
8
9
  var TestButton_1 = require("./TestButton");
9
10
  Object.defineProperty(exports, "TestButton", { enumerable: true, get: function () { return __importDefault(TestButton_1).default; } });
10
11
  var MovaSnackbar_1 = require("./MovaSnackbar");
@@ -13,3 +14,15 @@ var MovaLogin_1 = require("./MovaLogin");
13
14
  Object.defineProperty(exports, "MovaLogin", { enumerable: true, get: function () { return __importDefault(MovaLogin_1).default; } });
14
15
  var MovaCopyright_1 = require("./MovaCopyright");
15
16
  Object.defineProperty(exports, "MovaCopyright", { enumerable: true, get: function () { return __importDefault(MovaCopyright_1).default; } });
17
+ // Export des classes
18
+ var User_1 = require("./models/User");
19
+ Object.defineProperty(exports, "User", { enumerable: true, get: function () { return __importDefault(User_1).default; } });
20
+ var Role_1 = require("./models/Role");
21
+ Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return __importDefault(Role_1).default; } });
22
+ var Address_1 = require("./models/Address");
23
+ Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return __importDefault(Address_1).default; } });
24
+ // Export des enums
25
+ var Enums_1 = require("./helpers/Enums");
26
+ Object.defineProperty(exports, "RoleType", { enumerable: true, get: function () { return Enums_1.RoleType; } });
27
+ var Enums_2 = require("./helpers/Enums");
28
+ Object.defineProperty(exports, "MovaAppType", { enumerable: true, get: function () { return Enums_2.MovaAppType; } });
@@ -0,0 +1,10 @@
1
+ export default class Address {
2
+ id: string;
3
+ streetName: string;
4
+ postalCode: string;
5
+ cityName: string;
6
+ country: string;
7
+ countryCode: string;
8
+ additional?: string;
9
+ constructor(id: string, streetName: string, postalCode: string, cityName: string, country: string, countryCode: string, additional?: string);
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Address = /** @class */ (function () {
4
+ function Address(id, streetName, postalCode, cityName, country, countryCode, additional) {
5
+ this.id = id;
6
+ this.streetName = streetName;
7
+ this.postalCode = postalCode;
8
+ this.cityName = cityName;
9
+ this.country = country;
10
+ this.countryCode = countryCode;
11
+ this.additional = additional;
12
+ }
13
+ return Address;
14
+ }());
15
+ exports.default = Address;
@@ -0,0 +1,6 @@
1
+ export default class Role {
2
+ id: string;
3
+ isActive: boolean;
4
+ authorizations: string[];
5
+ constructor(id: string, isActive: boolean | undefined, authorizations: string[]);
6
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Role = /** @class */ (function () {
4
+ function Role(id, isActive, authorizations) {
5
+ if (isActive === void 0) { isActive = true; }
6
+ this.id = id;
7
+ this.isActive = isActive;
8
+ this.authorizations = authorizations;
9
+ }
10
+ return Role;
11
+ }());
12
+ exports.default = Role;
@@ -0,0 +1,17 @@
1
+ import Address from './Address';
2
+ export default class User {
3
+ id: string;
4
+ roles: string[];
5
+ firstname: string;
6
+ lastname: string;
7
+ avatar: string;
8
+ email: string;
9
+ password: string;
10
+ created: Date;
11
+ addresses?: Address[];
12
+ phoneNumber?: string;
13
+ constructor(id: string, roles: string[], firstname?: string, lastname?: string, avatar?: string, email?: string, password?: string, created?: Date, addresses?: Address[], phoneNumber?: string);
14
+ static getFirstLetter: (user: User) => string;
15
+ static isCustomer: (user: User) => boolean;
16
+ static isTechnician: (user: User) => boolean;
17
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Enums_1 = require("../helpers/Enums");
4
+ var User = /** @class */ (function () {
5
+ function User(id, roles, firstname, lastname, avatar, email, password, created, addresses, phoneNumber) {
6
+ if (firstname === void 0) { firstname = ''; }
7
+ if (lastname === void 0) { lastname = ''; }
8
+ if (avatar === void 0) { avatar = ''; }
9
+ if (email === void 0) { email = ''; }
10
+ if (password === void 0) { password = ''; }
11
+ if (created === void 0) { created = new Date(); }
12
+ this.id = id;
13
+ this.roles = roles;
14
+ this.firstname = firstname;
15
+ this.lastname = lastname;
16
+ this.avatar = avatar;
17
+ this.email = email;
18
+ this.password = password;
19
+ this.created = created;
20
+ this.addresses = addresses;
21
+ this.phoneNumber = phoneNumber;
22
+ }
23
+ User.getFirstLetter = function (user) {
24
+ var firstLetter = user.lastname[0].toUpperCase();
25
+ return /[0-9]/.test(firstLetter) ? '0-9' : firstLetter;
26
+ };
27
+ User.isCustomer = function (user) {
28
+ if (!user || !user.roles)
29
+ return false;
30
+ return Boolean(user.roles.find(function (r) { return r = Enums_1.RoleType.CUSTOMER; }));
31
+ };
32
+ User.isTechnician = function (user) {
33
+ if (!user || !user.roles)
34
+ return false;
35
+ return Boolean(user.roles.find(function (r) { return r = Enums_1.RoleType.TECHNICIAN; }));
36
+ };
37
+ return User;
38
+ }());
39
+ exports.default = User;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,4 +12,27 @@ export enum MovaAppType {
12
12
  * Application Administrateur (MovaTeam)
13
13
  */
14
14
  ADMIN = "ADMIN"
15
+ }
16
+
17
+ export enum RoleType {
18
+ /**
19
+ * Client du centre auto (automobiliste)
20
+ */
21
+ CUSTOMER = "CUSTOMER",
22
+ /**
23
+ * Technicien du centre auto
24
+ */
25
+ TECHNICIAN = "GARAGE_LEADER",
26
+ /**
27
+ * Chef d'atelier
28
+ */
29
+ GARAGE_LEADER = "GARAGE_LEADER",
30
+ /**
31
+ * Administrateur du centre auto (propriétaire ou dirigeant)
32
+ */
33
+ GARAGE_ADMIN = "ADMINISTRATOR",
34
+ /**
35
+ * Super-Administrateur (team Movalib)
36
+ */
37
+ MOVALIB_ADMIN = "MOVALIB_ADMIN",
15
38
  }
package/src/index.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  // src/index.ts
2
2
 
3
+ // Export des composants
3
4
  export { default as TestButton } from './TestButton';
4
5
  export { default as MovaSnackbar } from './MovaSnackbar';
5
6
  export { default as MovaLogin } from './MovaLogin';
6
7
  export { default as MovaCopyright } from './MovaCopyright';
7
8
 
9
+ // Export des classes
10
+ export { default as User } from './models/User';
11
+ export { default as Role } from './models/Role';
12
+ export { default as Address } from './models/Address';
13
+
8
14
  // Export des types
9
15
  export type { MovaFormField } from './helpers/Types';
10
16
  export type { MovaLoginForm } from './helpers/Types';
17
+
18
+ // Export des enums
19
+ export { RoleType } from './helpers/Enums';
20
+ export { MovaAppType } from './helpers/Enums';
@@ -0,0 +1,28 @@
1
+ export default class Address {
2
+
3
+ id: string; // UUID
4
+ streetName: string; // Street number & name
5
+ postalCode: string; // Postal code
6
+ cityName: string; // City name
7
+ country: string; // Country name
8
+ countryCode: string; // Country ISO code
9
+ additional?: string; // Additional address information (optional)
10
+
11
+ constructor(
12
+ id: string,
13
+ streetName: string,
14
+ postalCode: string,
15
+ cityName: string,
16
+ country: string,
17
+ countryCode: string,
18
+ additional?: string
19
+ ) {
20
+ this.id = id;
21
+ this.streetName = streetName;
22
+ this.postalCode = postalCode;
23
+ this.cityName = cityName;
24
+ this.country = country;
25
+ this.countryCode = countryCode;
26
+ this.additional = additional;
27
+ }
28
+ }
@@ -0,0 +1,16 @@
1
+ export default class Role {
2
+
3
+ id:string;
4
+ isActive: boolean;
5
+ authorizations: string[];
6
+
7
+ constructor(
8
+ id:string,
9
+ isActive: boolean = true,
10
+ authorizations: string[]
11
+ ) {
12
+ this.id = id;
13
+ this.isActive = isActive;
14
+ this.authorizations = authorizations;
15
+ }
16
+ }
@@ -0,0 +1,59 @@
1
+ import { RoleType } from "../helpers/Enums";
2
+ import Address from './Address';
3
+
4
+ export default class User {
5
+
6
+ // Properties
7
+ id: string;
8
+ roles: string[];
9
+ firstname: string;
10
+ lastname: string;
11
+ avatar: string;
12
+ email: string;
13
+ password: string;
14
+ created: Date;
15
+ addresses? : Address[]
16
+ phoneNumber?: string;
17
+
18
+ constructor(
19
+ id: string,
20
+ roles: string[],
21
+ firstname: string = '',
22
+ lastname: string = '',
23
+ avatar: string = '',
24
+ email: string = '',
25
+ password: string = '',
26
+ created: Date = new Date(),
27
+ addresses?: Address[],
28
+ phoneNumber?: string
29
+ ) {
30
+ this.id = id;
31
+ this.roles = roles;
32
+ this.firstname = firstname;
33
+ this.lastname = lastname;
34
+ this.avatar = avatar;
35
+ this.email = email;
36
+ this.password = password;
37
+ this.created = created;
38
+ this.addresses = addresses;
39
+ this.phoneNumber = phoneNumber;
40
+ }
41
+
42
+ static getFirstLetter = (user: User) : string => {
43
+
44
+ const firstLetter = user.lastname[0].toUpperCase();
45
+ return /[0-9]/.test(firstLetter) ? '0-9' : firstLetter;
46
+ }
47
+
48
+ static isCustomer = (user: User) : boolean => {
49
+ if(!user || !user.roles) return false;
50
+
51
+ return Boolean(user.roles.find(r => r = RoleType.CUSTOMER));
52
+ }
53
+
54
+ static isTechnician = (user: User) : boolean => {
55
+ if(!user || !user.roles) return false;
56
+
57
+ return Boolean(user.roles.find(r => r = RoleType.TECHNICIAN));
58
+ }
59
+ }