@grapadigital/shared-schemas 1.0.172 → 1.0.174
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/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/schemas/action.schema.d.ts +2 -0
- package/dist/schemas/action.schema.js +6 -0
- package/dist/schemas/campaign.schema.d.ts +3 -0
- package/dist/schemas/campaign.schema.js +12 -0
- package/dist/schemas/client.schema.d.ts +2 -2
- package/dist/schemas/client.schema.js +2 -2
- package/dist/schemas/group.schema.d.ts +43 -0
- package/dist/schemas/group.schema.js +34 -0
- package/dist/schemas/influencer.schema.d.ts +2 -2
- package/dist/schemas/influencer.schema.js +2 -2
- package/dist/schemas/notifications.schema.d.ts +69 -0
- package/dist/schemas/notifications.schema.js +90 -0
- package/dist/schemas/organization.schema.d.ts +45 -0
- package/dist/schemas/organization.schema.js +41 -0
- package/dist/schemas/party.schema.d.ts +116 -0
- package/dist/schemas/party.schema.js +175 -0
- package/dist/schemas/supplier.schema.d.ts +2 -2
- package/dist/schemas/supplier.schema.js +2 -2
- package/dist/schemas/task.schema.d.ts +2 -3
- package/dist/schemas/task.schema.js +12 -12
- package/dist/schemas/user.schema.d.ts +23 -78
- package/dist/schemas/user.schema.js +38 -143
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/schemas/action.schema.ts +4 -0
- package/src/schemas/campaign.schema.ts +8 -1
- package/src/schemas/client.schema.ts +2 -2
- package/src/schemas/group.schema.ts +23 -0
- package/src/schemas/influencer.schema.ts +2 -2
- package/src/schemas/notifications.schema.ts +61 -0
- package/src/schemas/organization.schema.ts +29 -0
- package/src/schemas/party.schema.ts +65 -0
- package/src/schemas/supplier.schema.ts +2 -2
- package/src/schemas/task.schema.ts +13 -13
- package/src/schemas/user.schema.ts +31 -107
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument, Types } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
export type GroupDocument = HydratedDocument<Group>;
|
|
5
|
+
|
|
6
|
+
@Schema({ timestamps: true, collection: 'group' })
|
|
7
|
+
export class Group {
|
|
8
|
+
@Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
|
|
9
|
+
organization: Types.ObjectId;
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true, trim: true })
|
|
12
|
+
name: string;
|
|
13
|
+
|
|
14
|
+
@Prop({ type: [Types.ObjectId], ref: 'User', default: [] })
|
|
15
|
+
memberIds: Types.ObjectId[];
|
|
16
|
+
|
|
17
|
+
createdAt?: Date;
|
|
18
|
+
updatedAt?: Date;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const GroupSchema = SchemaFactory.createForClass(Group);
|
|
22
|
+
|
|
23
|
+
GroupSchema.index({ organization: 1, name: 1 }, { unique: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
2
|
import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
|
|
3
3
|
import { Profile } from './profile.schema';
|
|
4
|
-
import {
|
|
4
|
+
import { Party } from './party.schema';
|
|
5
5
|
|
|
6
6
|
export type InfluencerDocument = HydratedDocument<Influencer>;
|
|
7
7
|
@Schema({ _id: false })
|
|
@@ -34,7 +34,7 @@ export class Note {
|
|
|
34
34
|
export const NoteSchema = SchemaFactory.createForClass(Note);
|
|
35
35
|
|
|
36
36
|
@Schema({ timestamps: true })
|
|
37
|
-
export class Influencer extends
|
|
37
|
+
export class Influencer extends Party {
|
|
38
38
|
@Prop({ required: false })
|
|
39
39
|
financialManagementSheet?: string;
|
|
40
40
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
3
|
+
import { HydratedDocument, model as MongooseModel } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export type NotificationDocument = HydratedDocument<Notification>;
|
|
8
|
+
|
|
9
|
+
@Schema({ _id: false })
|
|
10
|
+
export class NotificationRecipient {
|
|
11
|
+
@Prop({ type: String })
|
|
12
|
+
name?: string;
|
|
13
|
+
|
|
14
|
+
@Prop({ type: String })
|
|
15
|
+
username?: string;
|
|
16
|
+
|
|
17
|
+
@Prop({ type: String })
|
|
18
|
+
email?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Schema({ _id: false })
|
|
22
|
+
export class NotificationEntity {
|
|
23
|
+
@Prop({ type: String })
|
|
24
|
+
name?: string;
|
|
25
|
+
|
|
26
|
+
@Prop({ type: String })
|
|
27
|
+
title?: string;
|
|
28
|
+
|
|
29
|
+
@Prop({ type: String })
|
|
30
|
+
_id?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Schema({ timestamps: true, collection: 'notifications' })
|
|
34
|
+
export class Notification {
|
|
35
|
+
@Prop({ type: NotificationRecipient, required: true })
|
|
36
|
+
recipient: NotificationRecipient;
|
|
37
|
+
|
|
38
|
+
@Prop({ required: true, type: String })
|
|
39
|
+
event: string;
|
|
40
|
+
|
|
41
|
+
@Prop({ type: [String], default: [] })
|
|
42
|
+
channels: string[];
|
|
43
|
+
|
|
44
|
+
@Prop({ type: String })
|
|
45
|
+
title?: string;
|
|
46
|
+
|
|
47
|
+
@Prop({ type: String })
|
|
48
|
+
body?: string;
|
|
49
|
+
|
|
50
|
+
@Prop({ type: NotificationEntity })
|
|
51
|
+
entity?: NotificationEntity;
|
|
52
|
+
|
|
53
|
+
@Prop({ type: Boolean, default: false })
|
|
54
|
+
read: boolean;
|
|
55
|
+
|
|
56
|
+
@Prop({ type: Date, default: Date.now })
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const NotificationSchema = SchemaFactory.createForClass(Notification);
|
|
61
|
+
export const NotificationModel = MongooseModel('Notification', NotificationSchema);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
export type OrganizationDocument = HydratedDocument<Organization>;
|
|
5
|
+
|
|
6
|
+
@Schema({ timestamps: true, collection: 'organizations', strict: true })
|
|
7
|
+
export class Organization {
|
|
8
|
+
@Prop({ required: true, trim: true })
|
|
9
|
+
corporateName: string;
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true, trim: true })
|
|
12
|
+
fantasyName: string;
|
|
13
|
+
|
|
14
|
+
@Prop({ required: true, unique: true, index: true })
|
|
15
|
+
cnpj: string;
|
|
16
|
+
|
|
17
|
+
@Prop()
|
|
18
|
+
logo?: string;
|
|
19
|
+
|
|
20
|
+
@Prop()
|
|
21
|
+
logoSmall?: string;
|
|
22
|
+
|
|
23
|
+
createdAt?: Date;
|
|
24
|
+
updatedAt?: Date;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const OrganizationSchema = SchemaFactory.createForClass(Organization);
|
|
28
|
+
|
|
29
|
+
OrganizationSchema.index({ fantasyName: 'text', corporateName: 'text' });
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
export type PartyDocument = HydratedDocument<Party>;
|
|
5
|
+
|
|
6
|
+
@Schema({ _id: false })
|
|
7
|
+
export class Address {
|
|
8
|
+
@Prop() zipcode: string;
|
|
9
|
+
@Prop() city: string;
|
|
10
|
+
@Prop() state: string;
|
|
11
|
+
@Prop() street: string;
|
|
12
|
+
@Prop() number: string;
|
|
13
|
+
@Prop() complement: string;
|
|
14
|
+
}
|
|
15
|
+
export const AddressSchema = SchemaFactory.createForClass(Address);
|
|
16
|
+
|
|
17
|
+
@Schema({ _id: false })
|
|
18
|
+
export class Company {
|
|
19
|
+
@Prop() legalName: string;
|
|
20
|
+
@Prop() document: string;
|
|
21
|
+
@Prop() bank: string;
|
|
22
|
+
@Prop() agency: string;
|
|
23
|
+
@Prop() account: string;
|
|
24
|
+
@Prop() digit: string;
|
|
25
|
+
@Prop() pix: string;
|
|
26
|
+
@Prop() email: string;
|
|
27
|
+
@Prop({ required: false }) omieGrapaId?: string;
|
|
28
|
+
@Prop({ required: false }) omieOmaId?: string;
|
|
29
|
+
}
|
|
30
|
+
export const CompanySchema = SchemaFactory.createForClass(Company);
|
|
31
|
+
|
|
32
|
+
@Schema({ _id: false })
|
|
33
|
+
export class Individual {
|
|
34
|
+
@Prop() rg: string;
|
|
35
|
+
@Prop() cpf: string;
|
|
36
|
+
@Prop() birthday: Date;
|
|
37
|
+
@Prop() maritalStatus: string;
|
|
38
|
+
@Prop() nationality: string;
|
|
39
|
+
@Prop() profession: string;
|
|
40
|
+
}
|
|
41
|
+
export const IndividualSchema = SchemaFactory.createForClass(Individual);
|
|
42
|
+
|
|
43
|
+
@Schema({ timestamps: true })
|
|
44
|
+
export class Party {
|
|
45
|
+
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
46
|
+
_id?: Types.ObjectId;
|
|
47
|
+
|
|
48
|
+
@Prop() name: string;
|
|
49
|
+
@Prop({ required: false }) email?: string;
|
|
50
|
+
@Prop({ required: false }) phone?: string;
|
|
51
|
+
@Prop({ required: false }) picture?: string;
|
|
52
|
+
@Prop({ type: AddressSchema, required: false }) address?: Address;
|
|
53
|
+
@Prop({ type: CompanySchema, required: false }) company?: Company;
|
|
54
|
+
@Prop({ type: IndividualSchema, required: false }) individual?: Individual;
|
|
55
|
+
@Prop({ default: Date.now, required: false }) createdAt?: Date;
|
|
56
|
+
@Prop({ default: Date.now, required: false }) updatedAt?: Date;
|
|
57
|
+
}
|
|
58
|
+
export const PartySchema = SchemaFactory.createForClass(Party);
|
|
59
|
+
|
|
60
|
+
PartySchema.index({ name: 1 });
|
|
61
|
+
PartySchema.index({ 'company.document': 1 });
|
|
62
|
+
PartySchema.index({ 'company.legalName': 1 });
|
|
63
|
+
PartySchema.index({ createdAt: -1 });
|
|
64
|
+
|
|
65
|
+
export const PartyModel = MongooseModel('Party', PartySchema);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
2
|
import { HydratedDocument, model as MongooseModel } from 'mongoose';
|
|
3
|
-
import {
|
|
3
|
+
import { Party } from './party.schema';
|
|
4
4
|
|
|
5
5
|
export type SupplierDocument = HydratedDocument<Supplier>;
|
|
6
6
|
|
|
7
7
|
@Schema({ timestamps: true })
|
|
8
|
-
export class Supplier extends
|
|
8
|
+
export class Supplier extends Party {}
|
|
9
9
|
|
|
10
10
|
export const SupplierSchema = SchemaFactory.createForClass(Supplier);
|
|
11
11
|
export const SupplierModel = MongooseModel('Supplier', SupplierSchema);
|
|
@@ -52,16 +52,7 @@ export const TASK_STATUS_BY_TYPE: Record<TaskType, string[]> = {
|
|
|
52
52
|
diagnosis: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export
|
|
56
|
-
'awaiting',
|
|
57
|
-
'pending',
|
|
58
|
-
'late',
|
|
59
|
-
'done',
|
|
60
|
-
'approval',
|
|
61
|
-
'rework',
|
|
62
|
-
'cancelled',
|
|
63
|
-
] as const;
|
|
64
|
-
export type TaskStatus = (typeof TASK_STATUS_VALUES)[number];
|
|
55
|
+
export type TaskStatus = 'awaiting' | 'pending' | 'late' | 'done' | 'cancelled' | 'approval' | 'rework';
|
|
65
56
|
|
|
66
57
|
@Schema({ timestamps: true })
|
|
67
58
|
export class Task {
|
|
@@ -111,9 +102,18 @@ export class Task {
|
|
|
111
102
|
@Prop({ type: String, enum: TASK_TYPE_VALUES, required: true })
|
|
112
103
|
type: TaskType;
|
|
113
104
|
|
|
114
|
-
@ApiProperty({
|
|
115
|
-
@Prop({
|
|
116
|
-
|
|
105
|
+
@ApiProperty({ example: 'awaiting' })
|
|
106
|
+
@Prop({
|
|
107
|
+
type: String,
|
|
108
|
+
required: true,
|
|
109
|
+
validate: {
|
|
110
|
+
validator: function (this: Task, value: string) {
|
|
111
|
+
return TASK_STATUS_BY_TYPE[this.type]?.includes(value) ?? false;
|
|
112
|
+
},
|
|
113
|
+
message: 'status inválido para o type da task',
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
status: string;
|
|
117
117
|
|
|
118
118
|
@ApiProperty({ example: 'https://drive.google.com/...', required: false })
|
|
119
119
|
@Prop({ type: String, required: false })
|
|
@@ -1,130 +1,54 @@
|
|
|
1
1
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
-
import { HydratedDocument,
|
|
2
|
+
import { HydratedDocument, Types } from 'mongoose';
|
|
3
3
|
|
|
4
4
|
export type UserDocument = HydratedDocument<User>;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
@Schema({ timestamps: true })
|
|
21
|
+
@Schema({ timestamps: true, collection: 'user' })
|
|
90
22
|
export class User {
|
|
91
|
-
@Prop({ type:
|
|
92
|
-
|
|
23
|
+
@Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
|
|
24
|
+
organization: Types.ObjectId;
|
|
93
25
|
|
|
94
|
-
@Prop()
|
|
95
|
-
|
|
26
|
+
@Prop({ required: true, trim: true, lowercase: true, index: true })
|
|
27
|
+
email: string;
|
|
96
28
|
|
|
97
|
-
@Prop({ required:
|
|
98
|
-
|
|
29
|
+
@Prop({ required: true, trim: true })
|
|
30
|
+
name: string;
|
|
99
31
|
|
|
100
|
-
@Prop({ required:
|
|
101
|
-
|
|
32
|
+
@Prop({ required: true, trim: true })
|
|
33
|
+
username: string;
|
|
102
34
|
|
|
103
|
-
@Prop({
|
|
104
|
-
|
|
35
|
+
@Prop({ enum: OrganizationTeam })
|
|
36
|
+
team?: OrganizationTeam;
|
|
105
37
|
|
|
106
|
-
@Prop({
|
|
107
|
-
|
|
38
|
+
@Prop({ enum: UserRole })
|
|
39
|
+
role?: UserRole;
|
|
108
40
|
|
|
109
|
-
@Prop({
|
|
110
|
-
|
|
41
|
+
@Prop({ trim: true })
|
|
42
|
+
firebaseUid?: string;
|
|
111
43
|
|
|
112
|
-
@Prop({
|
|
113
|
-
|
|
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({
|
|
125
|
-
UserSchema.index({
|
|
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 });
|