File tree Expand file tree Collapse file tree 3 files changed +72
-1
lines changed
service/src/tickets/ticket/_schemas Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Original file line number Diff line number Diff line change 1+ import { Prop , Schema , SchemaFactory } from '@nestjs/mongoose'
2+ import { IdnamePart } from '~/_common/schemas/parts/idname.part.schema'
3+ import { UserPart , UserPartSchema } from '~/_common/schemas/parts/user.part.schema'
4+ import { UserType } from '~/_common/enum/user-type.enum'
5+
6+ @Schema ( { _id : false } )
7+ export class EnvelopePart extends IdnamePart {
8+ @Prop ( {
9+ type : [ UserPartSchema ] ,
10+ required : true ,
11+ } )
12+ public senders : UserPart [ ]
13+
14+ @Prop ( {
15+ type : [ UserPartSchema ] ,
16+ required : true ,
17+ } )
18+ public observers : UserPart [ ]
19+
20+ @Prop ( {
21+ type : [ UserPartSchema ] ,
22+ validate : ( v : UserPart [ ] ) => {
23+ for ( const user of v ) {
24+ if ( user . type !== UserType . AGENT ) {
25+ return false
26+ }
27+ }
28+ return true
29+ } ,
30+ required : true ,
31+ } )
32+ public assigned : UserPart [ ]
33+ }
34+
35+ export const EnvelopePartSchema = SchemaFactory . createForClass ( EnvelopePart )
Original file line number Diff line number Diff line change 1+ import { Prop , Schema , SchemaFactory } from '@nestjs/mongoose'
2+ import { IdnamePart } from '~/_common/schemas/parts/idname.part.schema'
3+
4+ @Schema ( { _id : false } )
5+ export class TagPart extends IdnamePart {
6+ @Prop ( {
7+ type : Boolean ,
8+ required : true ,
9+ default : false ,
10+ } )
11+ public manual : boolean
12+
13+ @Prop ( {
14+ type : Object ,
15+ } )
16+ public metadata : object
17+ }
18+
19+ export const TagPartSchema = SchemaFactory . createForClass ( TagPart )
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import { TicketTypeList } from '~/tickets/ticket/_enum/ticket-type.enum'
77import { TicketLifestepList } from '~/tickets/ticket/_enum/ticket-lifestep.enum'
88import { Types } from 'mongoose'
99import { SlaPart , SlaPartSchema } from '~/tickets/ticket/_schemas/parts/sla.part.schema'
10+ import { TagPart , TagPartSchema } from '~/tickets/ticket/_schemas/parts/tag.part.schema'
11+ import { EnvelopePart , EnvelopePartSchema } from '~/tickets/ticket/_schemas/parts/envelope.part.schema'
1012
1113@Schema ( {
1214 collection : 'tickets' ,
@@ -20,6 +22,12 @@ export class Ticket extends AbstractSchema {
2022 } )
2123 public sequence : string
2224
25+ @Prop ( {
26+ type : EnvelopePartSchema ,
27+ required : true ,
28+ } )
29+ public envelope : EnvelopePart
30+
2331 @Prop ( {
2432 required : true ,
2533 type : String ,
@@ -33,7 +41,11 @@ export class Ticket extends AbstractSchema {
3341 } )
3442 public type : number
3543
36- public envelope
44+ @Prop ( {
45+ type : [ TagPartSchema ] ,
46+ required : true ,
47+ } )
48+ public tags : TagPart [ ]
3749
3850 @Prop ( {
3951 type : Number ,
@@ -87,6 +99,11 @@ export class Ticket extends AbstractSchema {
8799 default : [ ] ,
88100 } )
89101 public readFlags : string [ ]
102+
103+ @Prop ( {
104+ type : Object ,
105+ } )
106+ public customFields : object
90107}
91108
92109export const TicketSchema = SchemaFactory . createForClass ( Ticket )
You can’t perform that action at this time.
0 commit comments