@things-factory/calendar 8.0.0 → 9.0.0-beta.3
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-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/client/bootstrap.ts +0 -1
- package/client/index.ts +0 -0
- package/client/pages/attendee/attendee-importer.ts +0 -87
- package/client/pages/attendee/attendee-list-page.ts +0 -324
- package/client/pages/calendar/calendar-importer.ts +0 -87
- package/client/pages/calendar/calendar-list-page.ts +0 -325
- package/client/pages/calendar/calendar-page.ts +0 -128
- package/client/pages/event/event-importer.ts +0 -87
- package/client/pages/event/event-list-page.ts +0 -324
- package/client/route.ts +0 -19
- package/client/tsconfig.json +0 -13
- package/server/controllers/index.ts +0 -0
- package/server/index.ts +0 -4
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -28
- package/server/service/attendee/attendee-mutation.ts +0 -122
- package/server/service/attendee/attendee-query.ts +0 -31
- package/server/service/attendee/attendee-type.ts +0 -44
- package/server/service/attendee/attendee.ts +0 -37
- package/server/service/attendee/index.ts +0 -7
- package/server/service/calendar/calendar-mutation.ts +0 -133
- package/server/service/calendar/calendar-query.ts +0 -48
- package/server/service/calendar/calendar-type.ts +0 -55
- package/server/service/calendar/calendar.ts +0 -82
- package/server/service/calendar/index.ts +0 -7
- package/server/service/event/event-mutation.ts +0 -125
- package/server/service/event/event-query.ts +0 -38
- package/server/service/event/event-type.ts +0 -61
- package/server/service/event/event.ts +0 -85
- package/server/service/event/index.ts +0 -7
- package/server/service/index.ts +0 -32
- package/server/tsconfig.json +0 -10
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { Calendar } from './calendar'
|
|
5
|
-
import { NewCalendar, CalendarPatch } from './calendar-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(Calendar)
|
|
8
|
-
export class CalendarMutation {
|
|
9
|
-
@Directive('@transaction')
|
|
10
|
-
@Mutation(returns => Calendar, { description: 'To create new Calendar' })
|
|
11
|
-
async createCalendar(@Arg('calendar') calendar: NewCalendar, @Ctx() context: ResolverContext): Promise<Calendar> {
|
|
12
|
-
const { domain, user, tx } = context.state
|
|
13
|
-
|
|
14
|
-
const result = await tx.getRepository(Calendar).save({
|
|
15
|
-
...calendar,
|
|
16
|
-
domain,
|
|
17
|
-
creator: user,
|
|
18
|
-
updater: user
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return result
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Directive('@transaction')
|
|
25
|
-
@Mutation(returns => Calendar, { description: 'To modify Calendar information' })
|
|
26
|
-
async updateCalendar(
|
|
27
|
-
@Arg('id') id: string,
|
|
28
|
-
@Arg('patch') patch: CalendarPatch,
|
|
29
|
-
@Ctx() context: ResolverContext
|
|
30
|
-
): Promise<Calendar> {
|
|
31
|
-
const { domain, user, tx } = context.state
|
|
32
|
-
|
|
33
|
-
const repository = tx.getRepository(Calendar)
|
|
34
|
-
const calendar = await repository.findOne({
|
|
35
|
-
where: { domain: { id: domain.id }, id }
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
return await repository.save({
|
|
39
|
-
...calendar,
|
|
40
|
-
...patch,
|
|
41
|
-
updater: user
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Directive('@transaction')
|
|
46
|
-
@Mutation(returns => [Calendar], { description: "To modify multiple Calendars' information" })
|
|
47
|
-
async updateMultipleCalendar(
|
|
48
|
-
@Arg('patches', type => [CalendarPatch]) patches: CalendarPatch[],
|
|
49
|
-
@Ctx() context: ResolverContext
|
|
50
|
-
): Promise<Calendar[]> {
|
|
51
|
-
const { domain, user, tx } = context.state
|
|
52
|
-
|
|
53
|
-
let results = []
|
|
54
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
55
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
56
|
-
const calendarRepo = tx.getRepository(Calendar)
|
|
57
|
-
|
|
58
|
-
if (_createRecords.length > 0) {
|
|
59
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
60
|
-
const newRecord = _createRecords[i]
|
|
61
|
-
|
|
62
|
-
const result = await calendarRepo.save({
|
|
63
|
-
...newRecord,
|
|
64
|
-
domain,
|
|
65
|
-
creator: user,
|
|
66
|
-
updater: user
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
results.push({ ...result, cuFlag: '+' })
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (_updateRecords.length > 0) {
|
|
74
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
75
|
-
const updateRecord = _updateRecords[i]
|
|
76
|
-
const calendar = await calendarRepo.findOneBy({ id: updateRecord.id })
|
|
77
|
-
|
|
78
|
-
const result = await calendarRepo.save({
|
|
79
|
-
...calendar,
|
|
80
|
-
...updateRecord,
|
|
81
|
-
updater: user
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return results
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@Directive('@transaction')
|
|
92
|
-
@Mutation(returns => Boolean, { description: 'To delete Calendar' })
|
|
93
|
-
async deleteCalendar(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
94
|
-
const { domain, tx } = context.state
|
|
95
|
-
|
|
96
|
-
await tx.getRepository(Calendar).delete({ domain: { id: domain.id }, id })
|
|
97
|
-
|
|
98
|
-
return true
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@Directive('@transaction')
|
|
102
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple Calendars' })
|
|
103
|
-
async deleteCalendars(
|
|
104
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
105
|
-
@Ctx() context: ResolverContext
|
|
106
|
-
): Promise<boolean> {
|
|
107
|
-
const { domain, tx } = context.state
|
|
108
|
-
|
|
109
|
-
await tx.getRepository(Calendar).delete({
|
|
110
|
-
domain: { id: domain.id },
|
|
111
|
-
id: In(ids)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
return true
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@Directive('@transaction')
|
|
118
|
-
@Mutation(returns => Boolean, { description: 'To import multiple Calendars' })
|
|
119
|
-
async importCalendars(
|
|
120
|
-
@Arg('calendars', type => [CalendarPatch]) calendars: CalendarPatch[],
|
|
121
|
-
@Ctx() context: ResolverContext
|
|
122
|
-
): Promise<boolean> {
|
|
123
|
-
const { domain, tx } = context.state
|
|
124
|
-
|
|
125
|
-
await Promise.all(
|
|
126
|
-
calendars.map(async (calendar: CalendarPatch) => {
|
|
127
|
-
const createdCalendar: Calendar = await tx.getRepository(Calendar).save({ domain, ...calendar })
|
|
128
|
-
})
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
return true
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { Calendar } from './calendar'
|
|
5
|
-
import { CalendarList } from './calendar-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(Calendar)
|
|
8
|
-
export class CalendarQuery {
|
|
9
|
-
@Query(returns => Calendar!, { nullable: true, description: 'To fetch a Calendar' })
|
|
10
|
-
async calendar(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Calendar> {
|
|
11
|
-
const { domain } = context.state
|
|
12
|
-
|
|
13
|
-
return await getRepository(Calendar).findOne({
|
|
14
|
-
where: { domain: { id: domain.id }, id }
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Query(returns => CalendarList, { description: 'To fetch multiple Calendars' })
|
|
19
|
-
async calendars(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CalendarList> {
|
|
20
|
-
const { domain } = context.state
|
|
21
|
-
|
|
22
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
23
|
-
domain,
|
|
24
|
-
params,
|
|
25
|
-
repository: await getRepository(Calendar),
|
|
26
|
-
searchables: ['name', 'description']
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
30
|
-
|
|
31
|
-
return { items, total }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@FieldResolver(type => Domain)
|
|
35
|
-
async domain(@Root() calendar: Calendar): Promise<Domain> {
|
|
36
|
-
return await getRepository(Domain).findOneBy({ id: calendar.domainId })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@FieldResolver(type => User)
|
|
40
|
-
async updater(@Root() calendar: Calendar): Promise<User> {
|
|
41
|
-
return await getRepository(User).findOneBy({ id: calendar.updaterId })
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@FieldResolver(type => User)
|
|
45
|
-
async creator(@Root() calendar: Calendar): Promise<User> {
|
|
46
|
-
return await getRepository(User).findOneBy({ id: calendar.creatorId })
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
-
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
-
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
-
|
|
5
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Calendar, CalendarStatus } from './calendar'
|
|
8
|
-
|
|
9
|
-
@InputType()
|
|
10
|
-
export class NewCalendar {
|
|
11
|
-
@Field()
|
|
12
|
-
name: string
|
|
13
|
-
|
|
14
|
-
@Field({ nullable: true })
|
|
15
|
-
description?: string
|
|
16
|
-
|
|
17
|
-
@Field(type => CalendarStatus, { nullable: true })
|
|
18
|
-
state?: CalendarStatus
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
active?: boolean
|
|
22
|
-
|
|
23
|
-
@Field({ nullable: true })
|
|
24
|
-
params?: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@InputType()
|
|
28
|
-
export class CalendarPatch {
|
|
29
|
-
@Field(type => ID, { nullable: true })
|
|
30
|
-
id?: string
|
|
31
|
-
|
|
32
|
-
@Field({ nullable: true })
|
|
33
|
-
name?: string
|
|
34
|
-
|
|
35
|
-
@Field({ nullable: true })
|
|
36
|
-
description?: string
|
|
37
|
-
|
|
38
|
-
@Field(type => CalendarStatus, { nullable: true })
|
|
39
|
-
state?: CalendarStatus
|
|
40
|
-
|
|
41
|
-
@Field({ nullable: true })
|
|
42
|
-
active?: boolean
|
|
43
|
-
|
|
44
|
-
@Field({ nullable: true })
|
|
45
|
-
cuFlag?: string
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@ObjectType()
|
|
49
|
-
export class CalendarList {
|
|
50
|
-
@Field(type => [Calendar])
|
|
51
|
-
items: Calendar[]
|
|
52
|
-
|
|
53
|
-
@Field(type => Int)
|
|
54
|
-
total: number
|
|
55
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateDateColumn,
|
|
3
|
-
UpdateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
Index,
|
|
6
|
-
Column,
|
|
7
|
-
RelationId,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
PrimaryGeneratedColumn
|
|
10
|
-
} from 'typeorm'
|
|
11
|
-
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
12
|
-
|
|
13
|
-
import { Domain } from '@things-factory/shell'
|
|
14
|
-
import { User } from '@things-factory/auth-base'
|
|
15
|
-
|
|
16
|
-
export enum CalendarStatus {
|
|
17
|
-
STATUS_A = 'STATUS_A',
|
|
18
|
-
STATUS_B = 'STATUS_B'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
registerEnumType(CalendarStatus, {
|
|
22
|
-
name: 'CalendarStatus',
|
|
23
|
-
description: 'state enumeration of a calendar'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
@Entity()
|
|
27
|
-
@Index('ix_calendar_0', (calendar: Calendar) => [calendar.domain, calendar.name], { unique: true })
|
|
28
|
-
@ObjectType({ description: 'Entity for Calendar' })
|
|
29
|
-
export class Calendar {
|
|
30
|
-
@PrimaryGeneratedColumn('uuid')
|
|
31
|
-
@Field(type => ID)
|
|
32
|
-
readonly id: string
|
|
33
|
-
|
|
34
|
-
@ManyToOne(type => Domain)
|
|
35
|
-
@Field(type => Domain)
|
|
36
|
-
domain?: Domain
|
|
37
|
-
|
|
38
|
-
@RelationId((calendar: Calendar) => calendar.domain)
|
|
39
|
-
domainId?: string
|
|
40
|
-
|
|
41
|
-
@Column()
|
|
42
|
-
@Field({ nullable: true })
|
|
43
|
-
name?: string
|
|
44
|
-
|
|
45
|
-
@Column({ nullable: true })
|
|
46
|
-
@Field({ nullable: true })
|
|
47
|
-
description?: string
|
|
48
|
-
|
|
49
|
-
@Column({ nullable: true })
|
|
50
|
-
@Field({ nullable: true })
|
|
51
|
-
active?: boolean
|
|
52
|
-
|
|
53
|
-
@Column({ nullable: true })
|
|
54
|
-
@Field({ nullable: true })
|
|
55
|
-
state?: CalendarStatus
|
|
56
|
-
|
|
57
|
-
@Column({ nullable: true })
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
params?: string
|
|
60
|
-
|
|
61
|
-
@CreateDateColumn()
|
|
62
|
-
@Field({ nullable: true })
|
|
63
|
-
createdAt?: Date
|
|
64
|
-
|
|
65
|
-
@UpdateDateColumn()
|
|
66
|
-
@Field({ nullable: true })
|
|
67
|
-
updatedAt?: Date
|
|
68
|
-
|
|
69
|
-
@ManyToOne(type => User, { nullable: true })
|
|
70
|
-
@Field(type => User, { nullable: true })
|
|
71
|
-
creator?: User
|
|
72
|
-
|
|
73
|
-
@RelationId((calendar: Calendar) => calendar.creator)
|
|
74
|
-
creatorId?: string
|
|
75
|
-
|
|
76
|
-
@ManyToOne(type => User, { nullable: true })
|
|
77
|
-
@Field(type => User, { nullable: true })
|
|
78
|
-
updater?: User
|
|
79
|
-
|
|
80
|
-
@RelationId((calendar: Calendar) => calendar.updater)
|
|
81
|
-
updaterId?: string
|
|
82
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Calendar } from './calendar'
|
|
2
|
-
import { CalendarQuery } from './calendar-query'
|
|
3
|
-
import { CalendarMutation } from './calendar-mutation'
|
|
4
|
-
|
|
5
|
-
export const entities = [Calendar]
|
|
6
|
-
export const resolvers = [CalendarQuery, CalendarMutation]
|
|
7
|
-
export const subscribers = []
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { Event } from './event'
|
|
5
|
-
import { NewEvent, EventPatch } from './event-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(Event)
|
|
8
|
-
export class EventMutation {
|
|
9
|
-
@Directive('@transaction')
|
|
10
|
-
@Mutation(returns => Event, { description: 'To create new Event' })
|
|
11
|
-
async createEvent(@Arg('event') event: NewEvent, @Ctx() context: ResolverContext): Promise<Event> {
|
|
12
|
-
const { user, tx } = context.state
|
|
13
|
-
|
|
14
|
-
return await tx.getRepository(Event).save({
|
|
15
|
-
...event,
|
|
16
|
-
creator: user,
|
|
17
|
-
updater: user
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Directive('@transaction')
|
|
22
|
-
@Mutation(returns => Event, { description: 'To modify Event information' })
|
|
23
|
-
async updateEvent(
|
|
24
|
-
@Arg('id') id: string,
|
|
25
|
-
@Arg('patch') patch: EventPatch,
|
|
26
|
-
@Ctx() context: ResolverContext
|
|
27
|
-
): Promise<Event> {
|
|
28
|
-
const { user, tx } = context.state
|
|
29
|
-
|
|
30
|
-
const repository = tx.getRepository(Event)
|
|
31
|
-
const event = await repository.findOne({
|
|
32
|
-
where: { id }
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return await repository.save({
|
|
36
|
-
...event,
|
|
37
|
-
...patch,
|
|
38
|
-
updater: user
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Directive('@transaction')
|
|
43
|
-
@Mutation(returns => [Event], { description: "To modify multiple Events' information" })
|
|
44
|
-
async updateMultipleEvent(
|
|
45
|
-
@Arg('patches', type => [EventPatch]) patches: EventPatch[],
|
|
46
|
-
@Ctx() context: ResolverContext
|
|
47
|
-
): Promise<Event[]> {
|
|
48
|
-
const { user, tx } = context.state
|
|
49
|
-
|
|
50
|
-
let results = []
|
|
51
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
52
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
53
|
-
const eventRepo = tx.getRepository(Event)
|
|
54
|
-
|
|
55
|
-
if (_createRecords.length > 0) {
|
|
56
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
57
|
-
const newRecord = _createRecords[i]
|
|
58
|
-
|
|
59
|
-
const result = await eventRepo.save({
|
|
60
|
-
...newRecord,
|
|
61
|
-
creator: user,
|
|
62
|
-
updater: user
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
results.push({ ...result, cuFlag: '+' })
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (_updateRecords.length > 0) {
|
|
70
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
71
|
-
const updateRecord = _updateRecords[i]
|
|
72
|
-
const event = await eventRepo.findOneBy({ id: updateRecord.id })
|
|
73
|
-
|
|
74
|
-
const result = await eventRepo.save({
|
|
75
|
-
...event,
|
|
76
|
-
...updateRecord,
|
|
77
|
-
updater: user
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return results
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@Directive('@transaction')
|
|
88
|
-
@Mutation(returns => Boolean, { description: 'To delete Event' })
|
|
89
|
-
async deleteEvent(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
90
|
-
const { tx } = context.state
|
|
91
|
-
|
|
92
|
-
await tx.getRepository(Event).delete({ id })
|
|
93
|
-
|
|
94
|
-
return true
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@Directive('@transaction')
|
|
98
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple Events' })
|
|
99
|
-
async deleteEvents(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
|
|
100
|
-
const { tx } = context.state
|
|
101
|
-
|
|
102
|
-
await tx.getRepository(Event).delete({
|
|
103
|
-
id: In(ids)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
return true
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@Directive('@transaction')
|
|
110
|
-
@Mutation(returns => Boolean, { description: 'To import multiple Events' })
|
|
111
|
-
async importEvents(
|
|
112
|
-
@Arg('events', type => [EventPatch]) events: EventPatch[],
|
|
113
|
-
@Ctx() context: ResolverContext
|
|
114
|
-
): Promise<boolean> {
|
|
115
|
-
const { tx } = context.state
|
|
116
|
-
|
|
117
|
-
await Promise.all(
|
|
118
|
-
events.map(async (event: EventPatch) => {
|
|
119
|
-
const createdEvent: Event = await tx.getRepository(Event).save({ ...event })
|
|
120
|
-
})
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
return true
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { Event } from './event'
|
|
5
|
-
import { EventList } from './event-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(Event)
|
|
8
|
-
export class EventQuery {
|
|
9
|
-
@Query(returns => Event!, { nullable: true, description: 'To fetch a Event' })
|
|
10
|
-
async event(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Event> {
|
|
11
|
-
return await getRepository(Event).findOne({
|
|
12
|
-
where: { id }
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@Query(returns => EventList, { description: 'To fetch multiple Events' })
|
|
17
|
-
async events(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<EventList> {
|
|
18
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
19
|
-
params,
|
|
20
|
-
repository: await getRepository(Event),
|
|
21
|
-
searchables: ['name', 'description']
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
25
|
-
|
|
26
|
-
return { items, total }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@FieldResolver(type => User)
|
|
30
|
-
async updater(@Root() event: Event): Promise<User> {
|
|
31
|
-
return await getRepository(User).findOneBy({ id: event.updaterId })
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@FieldResolver(type => User)
|
|
35
|
-
async creator(@Root() event: Event): Promise<User> {
|
|
36
|
-
return await getRepository(User).findOneBy({ id: event.creatorId })
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
-
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
-
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
-
|
|
5
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Event, EventStatus } from './event'
|
|
8
|
-
|
|
9
|
-
@InputType()
|
|
10
|
-
export class NewEvent {
|
|
11
|
-
@Field()
|
|
12
|
-
name: string
|
|
13
|
-
|
|
14
|
-
@Field({ nullable: true })
|
|
15
|
-
description?: string
|
|
16
|
-
|
|
17
|
-
@Field(type => EventStatus, { nullable: true })
|
|
18
|
-
state?: EventStatus
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
active?: boolean
|
|
22
|
-
|
|
23
|
-
@Field({ nullable: true })
|
|
24
|
-
params?: string
|
|
25
|
-
|
|
26
|
-
@Field(type => GraphQLUpload, { nullable: true })
|
|
27
|
-
thumbnail?: FileUpload
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@InputType()
|
|
31
|
-
export class EventPatch {
|
|
32
|
-
@Field(type => ID, { nullable: true })
|
|
33
|
-
id?: string
|
|
34
|
-
|
|
35
|
-
@Field({ nullable: true })
|
|
36
|
-
name?: string
|
|
37
|
-
|
|
38
|
-
@Field({ nullable: true })
|
|
39
|
-
description?: string
|
|
40
|
-
|
|
41
|
-
@Field(type => EventStatus, { nullable: true })
|
|
42
|
-
state?: EventStatus
|
|
43
|
-
|
|
44
|
-
@Field({ nullable: true })
|
|
45
|
-
active?: boolean
|
|
46
|
-
|
|
47
|
-
@Field(type => GraphQLUpload, { nullable: true })
|
|
48
|
-
thumbnail?: FileUpload
|
|
49
|
-
|
|
50
|
-
@Field({ nullable: true })
|
|
51
|
-
cuFlag?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@ObjectType()
|
|
55
|
-
export class EventList {
|
|
56
|
-
@Field(type => [Event])
|
|
57
|
-
items: Event[]
|
|
58
|
-
|
|
59
|
-
@Field(type => Int)
|
|
60
|
-
total: number
|
|
61
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateDateColumn,
|
|
3
|
-
UpdateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
Index,
|
|
6
|
-
Column,
|
|
7
|
-
RelationId,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
ManyToMany,
|
|
10
|
-
JoinTable,
|
|
11
|
-
PrimaryGeneratedColumn
|
|
12
|
-
} from 'typeorm'
|
|
13
|
-
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
14
|
-
|
|
15
|
-
import { User } from '@things-factory/auth-base'
|
|
16
|
-
import { Attendee } from '../attendee/attendee'
|
|
17
|
-
|
|
18
|
-
export enum EventStatus {
|
|
19
|
-
STATUS_A = 'STATUS_A',
|
|
20
|
-
STATUS_B = 'STATUS_B'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
registerEnumType(EventStatus, {
|
|
24
|
-
name: 'EventStatus',
|
|
25
|
-
description: 'state enumeration of a event'
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
@Entity()
|
|
29
|
-
@ObjectType({ description: 'Entity for Event' })
|
|
30
|
-
export class Event {
|
|
31
|
-
@PrimaryGeneratedColumn('uuid')
|
|
32
|
-
@Field(type => ID)
|
|
33
|
-
readonly id: string
|
|
34
|
-
|
|
35
|
-
@Column()
|
|
36
|
-
@Field({ nullable: true })
|
|
37
|
-
name?: string
|
|
38
|
-
|
|
39
|
-
@Column({ nullable: true })
|
|
40
|
-
@Field({ nullable: true })
|
|
41
|
-
description?: string
|
|
42
|
-
|
|
43
|
-
@Column({ type: 'datetime' })
|
|
44
|
-
@Field({ nullable: true })
|
|
45
|
-
startDateTime: Date
|
|
46
|
-
|
|
47
|
-
@Column({ type: 'datetime' })
|
|
48
|
-
@Field({ nullable: true })
|
|
49
|
-
endDateTime: Date
|
|
50
|
-
|
|
51
|
-
@Column({ nullable: true })
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
location: string
|
|
54
|
-
|
|
55
|
-
@ManyToMany(() => Attendee)
|
|
56
|
-
@JoinTable()
|
|
57
|
-
@Field(type => [Attendee], { nullable: true })
|
|
58
|
-
attendees: Attendee[]
|
|
59
|
-
|
|
60
|
-
@Column({ nullable: true })
|
|
61
|
-
@Field({ nullable: true })
|
|
62
|
-
state?: EventStatus
|
|
63
|
-
|
|
64
|
-
@CreateDateColumn()
|
|
65
|
-
@Field({ nullable: true })
|
|
66
|
-
createdAt?: Date
|
|
67
|
-
|
|
68
|
-
@UpdateDateColumn()
|
|
69
|
-
@Field({ nullable: true })
|
|
70
|
-
updatedAt?: Date
|
|
71
|
-
|
|
72
|
-
@ManyToOne(type => User, { nullable: true })
|
|
73
|
-
@Field(type => User, { nullable: true })
|
|
74
|
-
creator?: User
|
|
75
|
-
|
|
76
|
-
@RelationId((event: Event) => event.creator)
|
|
77
|
-
creatorId?: string
|
|
78
|
-
|
|
79
|
-
@ManyToOne(type => User, { nullable: true })
|
|
80
|
-
@Field(type => User, { nullable: true })
|
|
81
|
-
updater?: User
|
|
82
|
-
|
|
83
|
-
@RelationId((event: Event) => event.updater)
|
|
84
|
-
updaterId?: string
|
|
85
|
-
}
|
package/server/service/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/* EXPORT ENTITY TYPES */
|
|
2
|
-
export * from './attendee/attendee'
|
|
3
|
-
export * from './event/event'
|
|
4
|
-
export * from './calendar/calendar'
|
|
5
|
-
|
|
6
|
-
/* IMPORT ENTITIES AND RESOLVERS */
|
|
7
|
-
import { entities as AttendeeEntities, resolvers as AttendeeResolvers, subscribers as AttendeeSubscribers } from './attendee'
|
|
8
|
-
import { entities as EventEntities, resolvers as EventResolvers, subscribers as EventSubscribers } from './event'
|
|
9
|
-
import { entities as CalendarEntities, resolvers as CalendarResolvers, subscribers as CalendarSubscribers } from './calendar'
|
|
10
|
-
|
|
11
|
-
export const entities = [
|
|
12
|
-
/* ENTITIES */
|
|
13
|
-
...AttendeeEntities,
|
|
14
|
-
...EventEntities,
|
|
15
|
-
...CalendarEntities,
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
export const subscribers = [
|
|
19
|
-
/* SUBSCRIBERS */
|
|
20
|
-
...AttendeeSubscribers,
|
|
21
|
-
...EventSubscribers,
|
|
22
|
-
...CalendarSubscribers,
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
export const schema = {
|
|
26
|
-
resolverClasses: [
|
|
27
|
-
/* RESOLVER CLASSES */
|
|
28
|
-
...AttendeeResolvers,
|
|
29
|
-
...EventResolvers,
|
|
30
|
-
...CalendarResolvers,
|
|
31
|
-
]
|
|
32
|
-
}
|