@taiger-common/model 1.0.45 → 1.0.47

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.
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Role = void 0;
4
+ exports.Role = {
5
+ Admin: 'Admin',
6
+ Manager: 'Manager',
7
+ External: 'External',
8
+ Guest: 'Guest',
9
+ Agent: 'Agent',
10
+ Editor: 'Editor',
11
+ Student: 'Student'
12
+ };
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var mongoose_1 = require("mongoose");
7
- var isEmail_1 = __importDefault(require("validator/lib/isEmail"));
7
+ var validator_1 = __importDefault(require("validator"));
8
8
  var core_1 = require("@taiger-common/core");
9
+ var users_1 = require("../constants/users");
9
10
  var Program_1 = require("./Program");
10
11
  var ManagerType = {
11
12
  Agent: 'Agent',
@@ -25,6 +26,11 @@ var attributeSchema = new mongoose_1.Schema({
25
26
  }
26
27
  });
27
28
  var userSchema = new mongoose_1.Schema({
29
+ role: {
30
+ type: String,
31
+ enum: Object.values(users_1.Role),
32
+ required: true
33
+ },
28
34
  firstname: {
29
35
  type: String,
30
36
  trim: true
@@ -45,7 +51,7 @@ var userSchema = new mongoose_1.Schema({
45
51
  type: String,
46
52
  unique: true,
47
53
  lowercase: true,
48
- validate: [isEmail_1.default, 'Invalid email address']
54
+ validate: [validator_1.default.isEmail, 'Invalid email address']
49
55
  },
50
56
  pictureUrl: {
51
57
  type: String
@@ -0,0 +1,9 @@
1
+ export var Role = {
2
+ Admin: 'Admin',
3
+ Manager: 'Manager',
4
+ External: 'External',
5
+ Guest: 'Guest',
6
+ Agent: 'Agent',
7
+ Editor: 'Editor',
8
+ Student: 'Student'
9
+ };
@@ -1,6 +1,7 @@
1
1
  import { Schema } from 'mongoose';
2
- import isEmail from 'validator/lib/isEmail';
2
+ import validator from 'validator';
3
3
  import { DocumentStatusType } from '@taiger-common/core';
4
+ import { Role } from '../constants/users';
4
5
  import { PROGRAM_SUBJECT_KEYS } from './Program';
5
6
  var ManagerType = {
6
7
  Agent: 'Agent',
@@ -20,6 +21,11 @@ var attributeSchema = new Schema({
20
21
  }
21
22
  });
22
23
  var userSchema = new Schema({
24
+ role: {
25
+ type: String,
26
+ enum: Object.values(Role),
27
+ required: true
28
+ },
23
29
  firstname: {
24
30
  type: String,
25
31
  trim: true
@@ -40,7 +46,7 @@ var userSchema = new Schema({
40
46
  type: String,
41
47
  unique: true,
42
48
  lowercase: true,
43
- validate: [isEmail, 'Invalid email address']
49
+ validate: [validator.isEmail, 'Invalid email address']
44
50
  },
45
51
  pictureUrl: {
46
52
  type: String
@@ -0,0 +1,9 @@
1
+ export declare const Role: {
2
+ Admin: string;
3
+ Manager: string;
4
+ External: string;
5
+ Guest: string;
6
+ Agent: string;
7
+ Editor: string;
8
+ Student: string;
9
+ };
@@ -93,6 +93,7 @@ export interface IUserAttribute {
93
93
  name: string;
94
94
  }
95
95
  export interface IUser {
96
+ role?: string;
96
97
  firstname?: string;
97
98
  firstname_chinese?: string;
98
99
  lastname?: string;