@things-factory/board-service 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.
Files changed (64) hide show
  1. package/dist-server/controllers/headless-pdf-to-image.js +7 -2
  2. package/dist-server/controllers/headless-pdf-to-image.js.map +1 -1
  3. package/dist-server/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +7 -7
  5. package/views/internal-board-full-feature-view.html +1 -1
  6. package/server/constants/error-code.ts +0 -2
  7. package/server/controllers/analyzer/analyze-integration.ts +0 -142
  8. package/server/controllers/fonts.ts +0 -83
  9. package/server/controllers/headless-model.ts +0 -53
  10. package/server/controllers/headless-pdf-to-image.ts +0 -103
  11. package/server/controllers/headless-playlist.ts +0 -71
  12. package/server/controllers/headless-pool-for-board.ts +0 -71
  13. package/server/controllers/headless-pool-for-label.ts +0 -141
  14. package/server/controllers/index.ts +0 -11
  15. package/server/controllers/label-command.ts +0 -62
  16. package/server/controllers/pdf.ts +0 -132
  17. package/server/controllers/screenshot.ts +0 -127
  18. package/server/controllers/thumbnail.ts +0 -18
  19. package/server/errors/index.ts +0 -1
  20. package/server/errors/license-error.ts +0 -21
  21. package/server/index.ts +0 -36
  22. package/server/migrations/1556862253000-SeedGroup.ts +0 -51
  23. package/server/migrations/index.ts +0 -9
  24. package/server/routers/internal-board-view-router.ts +0 -33
  25. package/server/routers/standalone-board-service-router.ts +0 -326
  26. package/server/routes.ts +0 -25
  27. package/server/service/analysis/analysis-query.ts +0 -13
  28. package/server/service/analysis/index.ts +0 -3
  29. package/server/service/board/board-history.ts +0 -137
  30. package/server/service/board/board-mutation.ts +0 -446
  31. package/server/service/board/board-query.ts +0 -180
  32. package/server/service/board/board-subscription.ts +0 -43
  33. package/server/service/board/board-type.ts +0 -58
  34. package/server/service/board/board.ts +0 -125
  35. package/server/service/board/event-subscriber.ts +0 -68
  36. package/server/service/board/index.ts +0 -10
  37. package/server/service/board-favorite/board-favorite-query.ts +0 -53
  38. package/server/service/board-favorite/board-favorite-type.ts +0 -18
  39. package/server/service/board-favorite/index.ts +0 -4
  40. package/server/service/board-template/board-template-mutation.ts +0 -161
  41. package/server/service/board-template/board-template-query.ts +0 -121
  42. package/server/service/board-template/board-template-type.ts +0 -53
  43. package/server/service/board-template/board-template.ts +0 -114
  44. package/server/service/board-template/index.ts +0 -7
  45. package/server/service/group/group-mutation.ts +0 -82
  46. package/server/service/group/group-query.ts +0 -58
  47. package/server/service/group/group-type.ts +0 -30
  48. package/server/service/group/group.ts +0 -69
  49. package/server/service/group/index.ts +0 -6
  50. package/server/service/index.ts +0 -56
  51. package/server/service/permission/domain-permission-subscriber.ts +0 -27
  52. package/server/service/permission/index.ts +0 -3
  53. package/server/service/play-group/event-subscriber.ts +0 -58
  54. package/server/service/play-group/index.ts +0 -9
  55. package/server/service/play-group/play-group-mutation.ts +0 -148
  56. package/server/service/play-group/play-group-query.ts +0 -92
  57. package/server/service/play-group/play-group-subscription.ts +0 -43
  58. package/server/service/play-group/play-group-type.ts +0 -30
  59. package/server/service/play-group/play-group.ts +0 -74
  60. package/server/service/theme/index.ts +0 -7
  61. package/server/service/theme/theme-mutation.ts +0 -128
  62. package/server/service/theme/theme-query.ts +0 -48
  63. package/server/service/theme/theme-type.ts +0 -55
  64. package/server/service/theme/theme.ts +0 -97
@@ -1,114 +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, ScalarObject } from '@things-factory/shell'
14
- import { User } from '@things-factory/auth-base'
15
- import { config } from '@things-factory/env'
16
-
17
- const ORMCONFIG = config.get('ormconfig', {})
18
- const DATABASE_TYPE = ORMCONFIG.type
19
-
20
- export enum BoardTemplateStatus {
21
- DRAFT = 'DRAFT',
22
- RELEASED = 'RELEASED'
23
- }
24
-
25
- registerEnumType(BoardTemplateStatus, {
26
- name: 'BoardTemplateStatus',
27
- description: 'state enumeration of a boardTemplate'
28
- })
29
-
30
- @Entity()
31
- @Index('ix_board_template_0', (boardTemplate: BoardTemplate) => [boardTemplate.domain, boardTemplate.name], {
32
- unique: true
33
- })
34
- @ObjectType({ description: 'Entity for BoardTemplate' })
35
- export class BoardTemplate {
36
- @PrimaryGeneratedColumn('uuid')
37
- @Field(type => ID)
38
- readonly id: string
39
-
40
- @ManyToOne(type => Domain)
41
- @Field(type => Domain)
42
- domain?: Domain
43
-
44
- @RelationId((boardTemplate: BoardTemplate) => boardTemplate.domain)
45
- domainId?: string
46
-
47
- @Column()
48
- @Field({ nullable: true })
49
- name?: string
50
-
51
- @Column({ nullable: true })
52
- @Field({ nullable: true })
53
- description?: string
54
-
55
- @Column('simple-json', { nullable: true, default: null })
56
- @Field(type => ScalarObject, { nullable: true })
57
- tags?: string[]
58
-
59
- @Column({ nullable: true, default: 'private' })
60
- @Field({ nullable: true })
61
- visibility?: string // 'private' | 'public' | 'domain'
62
-
63
- @Column({
64
- nullable: true,
65
- type:
66
- DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
67
- ? 'longtext'
68
- : DATABASE_TYPE == 'oracle'
69
- ? 'clob'
70
- : DATABASE_TYPE == 'mssql'
71
- ? 'nvarchar'
72
- : 'varchar',
73
- length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined
74
- })
75
- @Field({ nullable: true })
76
- model?: string
77
-
78
- @Column({
79
- nullable: true,
80
- type:
81
- DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
82
- ? 'longtext'
83
- : DATABASE_TYPE == 'oracle'
84
- ? 'clob'
85
- : DATABASE_TYPE == 'mssql'
86
- ? 'nvarchar'
87
- : 'varchar',
88
- length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined
89
- })
90
- @Field({ nullable: true })
91
- thumbnail?: string
92
-
93
- @CreateDateColumn()
94
- @Field({ nullable: true })
95
- createdAt?: Date
96
-
97
- @UpdateDateColumn()
98
- @Field({ nullable: true })
99
- updatedAt?: Date
100
-
101
- @ManyToOne(type => User, { nullable: true })
102
- @Field(type => User, { nullable: true })
103
- creator?: User
104
-
105
- @RelationId((boardTemplate: BoardTemplate) => boardTemplate.creator)
106
- creatorId?: string
107
-
108
- @ManyToOne(type => User, { nullable: true })
109
- @Field(type => User, { nullable: true })
110
- updater?: User
111
-
112
- @RelationId((boardTemplate: BoardTemplate) => boardTemplate.updater)
113
- updaterId?: string
114
- }
@@ -1,7 +0,0 @@
1
- import { BoardTemplate } from './board-template'
2
- import { BoardTemplateQuery } from './board-template-query'
3
- import { BoardTemplateMutation } from './board-template-mutation'
4
-
5
- export const entities = [BoardTemplate]
6
- export const resolvers = [BoardTemplateQuery, BoardTemplateMutation]
7
- export const subscribers = []
@@ -1,82 +0,0 @@
1
- import { Arg, Ctx, Mutation, Resolver, Directive } from 'type-graphql'
2
-
3
- import { Board } from '../board/board'
4
- import { Group } from './group'
5
- import { GroupPatch, NewGroup } from './group-type'
6
-
7
- @Resolver(Group)
8
- export class GroupMutation {
9
- @Directive('@transaction')
10
- @Mutation(returns => Group, { nullable: true, description: 'To create new Group' })
11
- async createGroup(@Arg('group') group: NewGroup, @Ctx() context: ResolverContext): Promise<Group> {
12
- const { domain, user, tx } = context.state
13
-
14
- return await tx.getRepository(Group).save({
15
- domain,
16
- ...group,
17
- creator: user,
18
- updater: user
19
- })
20
- }
21
-
22
- @Directive('@transaction')
23
- @Mutation(returns => Group, { description: 'To modify Group information' })
24
- async updateGroup(
25
- @Arg('id') id: string,
26
- @Arg('patch') patch: GroupPatch,
27
- @Ctx() context: ResolverContext
28
- ): Promise<Group> {
29
- const { domain, user, tx } = context.state
30
- const repository = tx.getRepository(Group)
31
-
32
- const group = await repository.findOneBy({ domain: { id: domain.id }, id })
33
-
34
- return await repository.save({
35
- ...group,
36
- ...patch,
37
- updater: user
38
- })
39
- }
40
-
41
- @Directive('@transaction')
42
- @Mutation(returns => Group, { description: 'To make the board to join the group' })
43
- async joinGroup(
44
- @Arg('id') id: string,
45
- @Arg('boardIds', type => [String]) boardIds: string[],
46
- @Ctx() context: ResolverContext
47
- ) {
48
- const { domain, tx } = context.state
49
- const repository = tx.getRepository(Group)
50
- const group = await repository.findOneBy({ domain: { id: domain.id }, id })
51
-
52
- const boardRepository = tx.getRepository(Board)
53
-
54
- await boardIds.forEach(async boardId => {
55
- let board = await boardRepository.findOneBy({ domain: { id: domain.id }, id: boardId })
56
- board.group = group
57
- await boardRepository.save(board)
58
- })
59
-
60
- return await repository.findOne({
61
- where: { domain: { id: domain.id }, id },
62
- relations: ['boards']
63
- })
64
- }
65
-
66
- @Directive('@transaction')
67
- @Mutation(returns => Boolean, { description: 'To delete Group' })
68
- async deleteGroup(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
69
- const { domain, tx } = context.state
70
-
71
- const repository = tx.getRepository(Group)
72
-
73
- /* TODO - 그룹에 소속된 보드가 있는 경우에는 그룹을 지워서는 안된다. */
74
- const group = await repository.findOneBy({
75
- domain: { id: domain.id },
76
- id
77
- })
78
-
79
- await repository.delete(id)
80
- return true
81
- }
82
- }
@@ -1,58 +0,0 @@
1
- import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
-
6
- import { Board } from '../board/board'
7
- import { Group } from './group'
8
- import { GroupList } from './group-type'
9
-
10
- @Resolver(Group)
11
- export class GroupQuery {
12
- @Query(returns => Group, { nullable: true, description: 'To fetch a Group' })
13
- async group(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Group> {
14
- const { domain } = context.state
15
-
16
- return await getRepository(Group).findOne({
17
- where: { domain: { id: domain.id }, id }
18
- })
19
- }
20
-
21
- @Query(returns => GroupList, { description: 'To fetch multiple Groups' })
22
- async groups(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<GroupList> {
23
- const { domain } = context.state
24
-
25
- const queryBuilder = getQueryBuilderFromListParams({
26
- repository: getRepository(Group),
27
- params,
28
- domain,
29
- searchables: ['name', 'description']
30
- })
31
-
32
- const [items, total] = await queryBuilder.getManyAndCount()
33
-
34
- return { items, total }
35
- }
36
-
37
- @FieldResolver(type => [Board])
38
- async boards(@Root() group: Group) {
39
- return await getRepository(Board).findBy({
40
- group: { id: group.id }
41
- })
42
- }
43
-
44
- @FieldResolver(type => Domain)
45
- async domain(@Root() group: Group) {
46
- return await getRepository(Domain).findOneBy({ id: group.domainId })
47
- }
48
-
49
- @FieldResolver(type => User)
50
- async updater(@Root() group: Group): Promise<User> {
51
- return await getRepository(User).findOneBy({ id: group.updaterId })
52
- }
53
-
54
- @FieldResolver(type => User)
55
- async creator(@Root() group: Group): Promise<User> {
56
- return await getRepository(User).findOneBy({ id: group.creatorId })
57
- }
58
- }
@@ -1,30 +0,0 @@
1
- import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
2
-
3
- import { Group } from './group'
4
-
5
- @InputType()
6
- export class NewGroup {
7
- @Field()
8
- name: string
9
-
10
- @Field({ nullable: true })
11
- description?: string
12
- }
13
-
14
- @InputType()
15
- export class GroupPatch {
16
- @Field({ nullable: true })
17
- name: string
18
-
19
- @Field({ nullable: true })
20
- description?: string
21
- }
22
-
23
- @ObjectType()
24
- export class GroupList {
25
- @Field(type => [Group])
26
- items: Group[]
27
-
28
- @Field(type => Int)
29
- total: number
30
- }
@@ -1,69 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- Entity,
5
- Index,
6
- Column,
7
- RelationId,
8
- ManyToOne,
9
- OneToMany,
10
- PrimaryGeneratedColumn
11
- } from 'typeorm'
12
- import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
13
-
14
- import { Domain } from '@things-factory/shell'
15
- import { User } from '@things-factory/auth-base'
16
- import { Board } from '../board/board'
17
- import { BoardHistory } from '../board/board-history'
18
-
19
- @Entity()
20
- @Index('ix_group_0', (group: Group) => [group.domain, group.name], { unique: true })
21
- @ObjectType({ description: 'Entity for Board Management Group' })
22
- export class Group {
23
- @PrimaryGeneratedColumn('uuid')
24
- @Field(type => ID)
25
- readonly id: string
26
-
27
- @ManyToOne(type => Domain)
28
- @Field(type => Domain, { nullable: true })
29
- domain?: Domain
30
-
31
- @RelationId((group: Group) => group.domain)
32
- domainId?: string
33
-
34
- @Column()
35
- @Field()
36
- name: string
37
-
38
- @Column({
39
- nullable: true
40
- })
41
- @Field({ nullable: true })
42
- description?: string
43
-
44
- @OneToMany(type => Board, board => board.group)
45
- @Field(type => [Board], { nullable: true })
46
- boards: Board[]
47
-
48
- @CreateDateColumn()
49
- @Field({ nullable: true })
50
- createdAt?: Date
51
-
52
- @UpdateDateColumn()
53
- @Field({ nullable: true })
54
- updatedAt?: Date
55
-
56
- @ManyToOne(type => User, { nullable: true })
57
- @Field(type => User, { nullable: true })
58
- creator?: User
59
-
60
- @RelationId((group: Group) => group.creator)
61
- creatorId?: string
62
-
63
- @ManyToOne(type => User, { nullable: true })
64
- @Field(type => User, { nullable: true })
65
- updater?: User
66
-
67
- @RelationId((group: Group) => group.updater)
68
- updaterId?: string
69
- }
@@ -1,6 +0,0 @@
1
- import { Group } from './group'
2
- import { GroupQuery } from './group-query'
3
- import { GroupMutation } from './group-mutation'
4
-
5
- export const entities = [Group]
6
- export const resolvers = [GroupQuery, GroupMutation]
@@ -1,56 +0,0 @@
1
- /* EXPORT ENTITY TYPES */
2
- export * from './board-template/board-template'
3
- export * from './theme/theme'
4
- export * from './board/board'
5
- export * from './group/group'
6
- export * from './play-group/play-group'
7
-
8
- /* IMPORT ENTITIES AND RESOLVERS */
9
- import {
10
- entities as BoardTemplateEntities,
11
- resolvers as BoardTemplateResolvers,
12
- subscribers as BoardTemplateSubscribers
13
- } from './board-template'
14
- import { entities as ThemeEntities, resolvers as ThemeResolvers, subscribers as ThemeSubscribers } from './theme'
15
- import { entities as BoardEntities, resolvers as BoardResolvers, subscribers as BoardSubscribers } from './board'
16
- import { entities as GroupEntities, resolvers as GroupResolvers } from './group'
17
- import {
18
- entities as PlayGroupEntities,
19
- resolvers as PlayGroupResolvers,
20
- subscribers as PlayGroupSubscribers
21
- } from './play-group'
22
- import { resolvers as IntegrationAnalysisQuery } from './analysis'
23
- import { entities as BoardFavoriteEntities, resolvers as BoardFavoriteResolvers } from './board-favorite'
24
- import { subscribers as PermissionSubscriber } from './permission'
25
-
26
- export const entities = [
27
- /* ENTITIES */
28
- ...BoardTemplateEntities,
29
- ...ThemeEntities,
30
- ...BoardEntities,
31
- ...GroupEntities,
32
- ...PlayGroupEntities,
33
- ...BoardFavoriteEntities
34
- ]
35
-
36
- export const subscribers = [
37
- /* SUBSCRIBERS */
38
- ...BoardTemplateSubscribers,
39
- ...ThemeSubscribers,
40
- ...BoardSubscribers,
41
- ...PlayGroupSubscribers,
42
- ...PermissionSubscriber
43
- ]
44
-
45
- export const schema = {
46
- resolverClasses: [
47
- /* RESOLVER CLASSES */
48
- ...BoardTemplateResolvers,
49
- ...ThemeResolvers,
50
- ...BoardResolvers,
51
- ...GroupResolvers,
52
- ...PlayGroupResolvers,
53
- ...IntegrationAnalysisQuery,
54
- ...BoardFavoriteResolvers
55
- ]
56
- }
@@ -1,27 +0,0 @@
1
- import { EntitySubscriberInterface, EventSubscriber, InsertEvent } from 'typeorm'
2
-
3
- import { checkDomain } from '@things-factory/operato-license-checker'
4
- import { Domain } from '@things-factory/shell'
5
-
6
- import { LicenseError } from '../../errors/license-error'
7
-
8
- @EventSubscriber()
9
- export class DomainPermissionSubscriber implements EntitySubscriberInterface<Domain> {
10
- listenTo() {
11
- return Domain
12
- }
13
- /**
14
- * Called before domain insertion.
15
- */
16
- async afterInsert(event: InsertEvent<Domain>) {
17
- var entityManager = event.manager
18
-
19
- var count = (await entityManager.createQueryBuilder().select('id').from(Domain, 'domain').getCount()) + 1
20
-
21
- if (!checkDomain(count)) {
22
- throw new LicenseError({
23
- errorCode: LicenseError.ERROR_CODES.VERIFICATION_ERROR
24
- })
25
- }
26
- }
27
- }
@@ -1,3 +0,0 @@
1
- import { DomainPermissionSubscriber } from './domain-permission-subscriber'
2
-
3
- export const subscribers = [DomainPermissionSubscriber]
@@ -1,58 +0,0 @@
1
- import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
2
-
3
- import { pubsub, getRepository } from '@things-factory/shell'
4
-
5
- import { PlayGroup } from './play-group'
6
-
7
- @EventSubscriber()
8
- export class PlayGroupSubscriber implements EntitySubscriberInterface<PlayGroup> {
9
- listenTo() {
10
- return PlayGroup
11
- }
12
-
13
- // afterInsert(event: InsertEvent<PlayGroup>): Promise<any> | void {
14
- // const playGroup = event.entity
15
-
16
- // pubsub.publish('playGroup', {
17
- // playGroup
18
- // })
19
- // }
20
-
21
- async afterUpdate(event: UpdateEvent<PlayGroup>): Promise<any> {
22
- var playGroup = event.entity
23
-
24
- playGroup = await getRepository(PlayGroup).findOne({
25
- where: { domain: { id: playGroup.domainId }, id: playGroup.id },
26
- relations: ['domain', 'boards']
27
- })
28
-
29
- if (!playGroup) {
30
- return
31
- }
32
-
33
- playGroup.boards = playGroup.boards.sort((a, b) => {
34
- // 배열 A에 포함된 아이디의 순서를 가져옵니다.
35
- const indexOfOrder = (playGroup.order || []).indexOf(a.id)
36
- const indexOfBoards = (playGroup.order || []).indexOf(b.id)
37
-
38
- // 두 아이디의 순서를 비교하여 정렬합니다.
39
- if (indexOfOrder === -1 && indexOfBoards === -1) {
40
- // 두 아이디 모두 배열 A에 없는 경우, 그대로 유지합니다.
41
- return 0
42
- } else if (indexOfOrder === -1) {
43
- // 아이디 A만 배열 A에 없는 경우, 아이디 B를 먼저 정렬합니다.
44
- return 1
45
- } else if (indexOfBoards === -1) {
46
- // 아이디 B만 배열 A에 없는 경우, 아이디 A를 먼저 정렬합니다.
47
- return -1
48
- } else {
49
- // 두 아이디 모두 배열 A에 있는 경우, 배열 A의 아이디 순서대로 정렬합니다.
50
- return indexOfOrder - indexOfBoards
51
- }
52
- })
53
-
54
- pubsub.publish('play-group', {
55
- playGroup
56
- })
57
- }
58
- }
@@ -1,9 +0,0 @@
1
- import { PlayGroup } from './play-group'
2
- import { PlayGroupQuery } from './play-group-query'
3
- import { PlayGroupMutation } from './play-group-mutation'
4
- import { PlayGroupSubscription } from './play-group-subscription'
5
- import { PlayGroupSubscriber } from './event-subscriber'
6
-
7
- export const entities = [PlayGroup]
8
- export const resolvers = [PlayGroupQuery, PlayGroupMutation, PlayGroupSubscription]
9
- export const subscribers = [PlayGroupSubscriber]
@@ -1,148 +0,0 @@
1
- import { Data } from '@things-factory/shell'
2
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
3
- import { In } from 'typeorm'
4
-
5
- import { Board } from '../board/board'
6
- import { PlayGroup } from './play-group'
7
- import { NewPlayGroup, PlayGroupPatch } from './play-group-type'
8
-
9
- @Resolver(PlayGroup)
10
- export class PlayGroupMutation {
11
- @Mutation(returns => PlayGroup, { description: 'To create new PlayGroup' })
12
- @Directive('@transaction')
13
- async createPlayGroup(
14
- @Arg('playGroup') playGroup: NewPlayGroup,
15
- @Ctx() context: ResolverContext
16
- ): Promise<PlayGroup> {
17
- const { domain, user, tx } = context.state
18
-
19
- return await tx.getRepository(PlayGroup).save({
20
- domain,
21
- ...playGroup,
22
- creator: user,
23
- updater: user
24
- })
25
- }
26
-
27
- @Mutation(returns => PlayGroup, { description: 'To modify PlayGroup information' })
28
- @Directive('@transaction')
29
- async updatePlayGroup(
30
- @Arg('id') id: string,
31
- @Arg('patch') patch: PlayGroupPatch,
32
- @Ctx() context: ResolverContext
33
- ): Promise<PlayGroup> {
34
- const { domain, user, tx } = context.state
35
- const repository = tx.getRepository(PlayGroup)
36
-
37
- const playGroup = await repository.findOneBy({ domain: { id: domain.id }, id })
38
-
39
- return await repository.save({
40
- ...playGroup,
41
- ...patch,
42
- updater: user
43
- })
44
- }
45
-
46
- @Mutation(returns => PlayGroup, { description: 'To modify board order of a PlayGroup' })
47
- @Directive('@transaction')
48
- async reorderPlayGroup(
49
- @Arg('id') id: string,
50
- @Arg('boardIds', type => [String]) boardIds: string[],
51
- @Ctx() context: ResolverContext
52
- ): Promise<PlayGroup> {
53
- const { domain, user, tx } = context.state
54
- const repository = tx.getRepository(PlayGroup)
55
-
56
- const playGroup = await repository.findOneBy({ domain: { id: domain.id }, id })
57
-
58
- return await repository.save({
59
- ...playGroup,
60
- order: boardIds,
61
- updater: user
62
- })
63
- }
64
-
65
- @Mutation(returns => PlayGroup, { description: 'To make the board to join the play group' })
66
- @Directive('@transaction')
67
- async joinPlayGroup(
68
- @Arg('id') id: string,
69
- @Arg('boardIds', type => [String]) boardIds: string[],
70
- @Ctx() context: ResolverContext
71
- ) {
72
- const { tx } = context.state
73
-
74
- const repository = tx.getRepository(PlayGroup)
75
- const playGroup = await repository.findOne({
76
- where: { id },
77
- relations: ['boards']
78
- })
79
- const order = playGroup.order || []
80
-
81
- const boardIdList = playGroup.boards.map(board => board.id)
82
- boardIds.forEach(boardId => {
83
- if (boardIdList.indexOf(boardId) == -1) {
84
- boardIdList.push(boardId)
85
- }
86
- if (order.indexOf(boardId) == -1) {
87
- order.push(boardId)
88
- }
89
- })
90
-
91
- const boardRepository = tx.getRepository(Board)
92
- playGroup.boards = await boardRepository.findBy({ id: In(boardIdList) })
93
- playGroup.updatedAt = new Date()
94
- playGroup.order = order
95
-
96
- return await repository.save(playGroup)
97
- }
98
-
99
- @Mutation(returns => PlayGroup, { description: 'To make the board to leave from the play group' })
100
- @Directive('@transaction')
101
- async leavePlayGroup(
102
- @Arg('id') id: string,
103
- @Arg('boardIds', type => [String]) boardIds: string[],
104
- @Ctx() context: ResolverContext
105
- ) {
106
- const { tx } = context.state
107
-
108
- const repository = tx.getRepository(PlayGroup)
109
- const playGroup = await repository.findOne({
110
- where: { id },
111
- relations: ['boards']
112
- })
113
- const order = playGroup.order || []
114
-
115
- const boardIdList = playGroup.boards.map(board => board.id)
116
- boardIds.forEach(boardId => {
117
- let index = boardIdList.indexOf(boardId)
118
- if (index !== -1) {
119
- boardIdList.splice(index, 1)
120
- }
121
-
122
- index = order.indexOf(boardId)
123
- if (index !== -1) {
124
- order.splice(index, 1)
125
- }
126
- })
127
-
128
- const boardRepository = tx.getRepository(Board)
129
- playGroup.boards = await boardRepository.findBy({ id: In(boardIdList) })
130
- playGroup.updatedAt = new Date()
131
- playGroup.order = order
132
-
133
- return await repository.save(playGroup)
134
- }
135
-
136
- @Mutation(returns => Boolean, { description: 'To delete PlayGroup' })
137
- @Directive('@transaction')
138
- async deletePlayGroup(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
139
- const { domain, tx } = context.state
140
- const repository = tx.getRepository(PlayGroup)
141
-
142
- /* TODO - 플레이 그룹은 소속된 보드-플레이그룹 관계들도 제거되어야 한다. */
143
- const playGroup = await repository.findOneBy({ domain: { id: domain.id }, id })
144
-
145
- await repository.delete(id)
146
- return true
147
- }
148
- }