@grapadigital/shared-schemas 1.0.173 → 1.0.175

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.
@@ -1,130 +1,54 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
2
+ import { HydratedDocument, Types } from 'mongoose';
3
3
 
4
4
  export type UserDocument = HydratedDocument<User>;
5
5
 
6
- @Schema({ _id: false })
7
- export class Address {
8
- @Prop()
9
- zipcode: string;
10
-
11
- @Prop()
12
- city: string;
13
-
14
- @Prop()
15
- state: string;
16
-
17
- @Prop()
18
- street: string;
19
-
20
- @Prop()
21
- number: string;
22
-
23
- @Prop()
24
- complement: string;
25
- }
26
-
27
- export const AddressSchema = SchemaFactory.createForClass(Address);
28
-
29
- @Schema({ _id: false })
30
- export class Company {
31
- @Prop()
32
- legalName: string;
33
-
34
- @Prop()
35
- document: string;
36
-
37
- @Prop()
38
- bank: string;
39
-
40
- @Prop()
41
- agency: string;
42
-
43
- @Prop()
44
- account: string;
45
-
46
- @Prop()
47
- digit: string;
48
-
49
- @Prop()
50
- pix: string;
51
-
52
- @Prop()
53
- email: string;
54
-
55
- @Prop({ required: false })
56
- omieGrapaId?: string;
57
-
58
- @Prop({ required: false })
59
- omieOmaId?: string;
60
-
61
-
6
+ export enum OrganizationTeam {
7
+ SERVICE = 'service',
8
+ ADMIN = 'admin',
9
+ ARTISTIC = 'artistic',
10
+ FINANCIAL = 'financial',
11
+ COMERCIAL = 'comercial',
62
12
  }
63
13
 
64
- export const CompanySchema = SchemaFactory.createForClass(Company);
65
-
66
- @Schema({ _id: false })
67
- export class Individual {
68
- @Prop()
69
- rg: string;
70
-
71
- @Prop()
72
- cpf: string;
73
-
74
- @Prop()
75
- birthday: Date;
76
-
77
- @Prop()
78
- maritalStatus: string;
79
-
80
- @Prop()
81
- nationality: string;
82
-
83
- @Prop()
84
- profession: string;
14
+ export enum UserRole {
15
+ ADMIN = 'admin',
16
+ USER = 'user',
17
+ CLIENT = 'client',
18
+ INFLUENCER = 'influencer',
85
19
  }
86
20
 
87
- export const IndividualSchema = SchemaFactory.createForClass(Individual);
88
-
89
- @Schema({ timestamps: true })
21
+ @Schema({ timestamps: true, collection: 'user' })
90
22
  export class User {
91
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
92
- _id?: Types.ObjectId;
23
+ @Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
24
+ organization: Types.ObjectId;
93
25
 
94
- @Prop()
95
- name: string;
26
+ @Prop({ required: true, trim: true, lowercase: true, index: true })
27
+ email: string;
96
28
 
97
- @Prop({ required: false })
98
- email?: string;
29
+ @Prop({ required: true, trim: true })
30
+ name: string;
99
31
 
100
- @Prop({ required: false })
101
- phone?: string;
32
+ @Prop({ required: true, trim: true })
33
+ username: string;
102
34
 
103
- @Prop({ required: false })
104
- picture?: string;
35
+ @Prop({ enum: OrganizationTeam })
36
+ team?: OrganizationTeam;
105
37
 
106
- @Prop({ type: AddressSchema, required: false })
107
- address?: Address;
38
+ @Prop({ enum: UserRole })
39
+ role?: UserRole;
108
40
 
109
- @Prop({ type: CompanySchema, required: false })
110
- company?: Company;
41
+ @Prop({ trim: true })
42
+ firebaseUid?: string;
111
43
 
112
- @Prop({ type: IndividualSchema, required: false })
113
- individual?: Individual;
44
+ @Prop({ default: false })
45
+ disabled?: boolean;
114
46
 
115
- @Prop({ default: Date.now, required: false })
116
47
  createdAt?: Date;
117
-
118
- @Prop({ default: Date.now, required: false })
119
48
  updatedAt?: Date;
120
49
  }
121
50
 
122
51
  export const UserSchema = SchemaFactory.createForClass(User);
123
52
 
124
- UserSchema.index({ name: 1 });
125
- UserSchema.index({ 'company.document': 1 });
126
- UserSchema.index({ 'company.legalName': 1 });
127
- UserSchema.index({ createdAt: -1 });
128
-
129
- export const UserModel = MongooseModel('User', UserSchema);
130
-
53
+ UserSchema.index({ organization: 1, email: 1 }, { unique: true });
54
+ UserSchema.index({ organization: 1, username: 1 }, { unique: true });