@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.
- package/dist-server/controllers/headless-pdf-to-image.js +7 -2
- package/dist-server/controllers/headless-pdf-to-image.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/views/internal-board-full-feature-view.html +1 -1
- package/server/constants/error-code.ts +0 -2
- package/server/controllers/analyzer/analyze-integration.ts +0 -142
- package/server/controllers/fonts.ts +0 -83
- package/server/controllers/headless-model.ts +0 -53
- package/server/controllers/headless-pdf-to-image.ts +0 -103
- package/server/controllers/headless-playlist.ts +0 -71
- package/server/controllers/headless-pool-for-board.ts +0 -71
- package/server/controllers/headless-pool-for-label.ts +0 -141
- package/server/controllers/index.ts +0 -11
- package/server/controllers/label-command.ts +0 -62
- package/server/controllers/pdf.ts +0 -132
- package/server/controllers/screenshot.ts +0 -127
- package/server/controllers/thumbnail.ts +0 -18
- package/server/errors/index.ts +0 -1
- package/server/errors/license-error.ts +0 -21
- package/server/index.ts +0 -36
- package/server/migrations/1556862253000-SeedGroup.ts +0 -51
- package/server/migrations/index.ts +0 -9
- package/server/routers/internal-board-view-router.ts +0 -33
- package/server/routers/standalone-board-service-router.ts +0 -326
- package/server/routes.ts +0 -25
- package/server/service/analysis/analysis-query.ts +0 -13
- package/server/service/analysis/index.ts +0 -3
- package/server/service/board/board-history.ts +0 -137
- package/server/service/board/board-mutation.ts +0 -446
- package/server/service/board/board-query.ts +0 -180
- package/server/service/board/board-subscription.ts +0 -43
- package/server/service/board/board-type.ts +0 -58
- package/server/service/board/board.ts +0 -125
- package/server/service/board/event-subscriber.ts +0 -68
- package/server/service/board/index.ts +0 -10
- package/server/service/board-favorite/board-favorite-query.ts +0 -53
- package/server/service/board-favorite/board-favorite-type.ts +0 -18
- package/server/service/board-favorite/index.ts +0 -4
- package/server/service/board-template/board-template-mutation.ts +0 -161
- package/server/service/board-template/board-template-query.ts +0 -121
- package/server/service/board-template/board-template-type.ts +0 -53
- package/server/service/board-template/board-template.ts +0 -114
- package/server/service/board-template/index.ts +0 -7
- package/server/service/group/group-mutation.ts +0 -82
- package/server/service/group/group-query.ts +0 -58
- package/server/service/group/group-type.ts +0 -30
- package/server/service/group/group.ts +0 -69
- package/server/service/group/index.ts +0 -6
- package/server/service/index.ts +0 -56
- package/server/service/permission/domain-permission-subscriber.ts +0 -27
- package/server/service/permission/index.ts +0 -3
- package/server/service/play-group/event-subscriber.ts +0 -58
- package/server/service/play-group/index.ts +0 -9
- package/server/service/play-group/play-group-mutation.ts +0 -148
- package/server/service/play-group/play-group-query.ts +0 -92
- package/server/service/play-group/play-group-subscription.ts +0 -43
- package/server/service/play-group/play-group-type.ts +0 -30
- package/server/service/play-group/play-group.ts +0 -74
- package/server/service/theme/index.ts +0 -7
- package/server/service/theme/theme-mutation.ts +0 -128
- package/server/service/theme/theme-query.ts +0 -48
- package/server/service/theme/theme-type.ts +0 -55
- package/server/service/theme/theme.ts +0 -97
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Board } from './board'
|
|
4
|
-
import { BoardHistory } from './board-history'
|
|
5
|
-
|
|
6
|
-
@InputType()
|
|
7
|
-
export class NewBoard {
|
|
8
|
-
@Field()
|
|
9
|
-
name: string
|
|
10
|
-
|
|
11
|
-
@Field({ nullable: true })
|
|
12
|
-
description?: string
|
|
13
|
-
|
|
14
|
-
@Field()
|
|
15
|
-
model: string
|
|
16
|
-
|
|
17
|
-
@Field({ nullable: true })
|
|
18
|
-
groupId?: string
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
thumbnail?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@InputType()
|
|
25
|
-
export class BoardPatch {
|
|
26
|
-
@Field({ nullable: true })
|
|
27
|
-
name?: string
|
|
28
|
-
|
|
29
|
-
@Field({ nullable: true })
|
|
30
|
-
description?: string
|
|
31
|
-
|
|
32
|
-
@Field({ nullable: true })
|
|
33
|
-
model?: string
|
|
34
|
-
|
|
35
|
-
@Field({ nullable: true })
|
|
36
|
-
groupId?: string
|
|
37
|
-
|
|
38
|
-
@Field({ nullable: true })
|
|
39
|
-
thumbnail?: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@ObjectType()
|
|
43
|
-
export class BoardList {
|
|
44
|
-
@Field(type => [Board])
|
|
45
|
-
items: Board[]
|
|
46
|
-
|
|
47
|
-
@Field(type => Int)
|
|
48
|
-
total: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ObjectType()
|
|
52
|
-
export class BoardHistoryList {
|
|
53
|
-
@Field(type => [BoardHistory])
|
|
54
|
-
items: BoardHistory[]
|
|
55
|
-
|
|
56
|
-
@Field(type => Int)
|
|
57
|
-
total: number
|
|
58
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Column,
|
|
3
|
-
CreateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
Index,
|
|
6
|
-
ManyToMany,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
PrimaryGeneratedColumn,
|
|
9
|
-
RelationId,
|
|
10
|
-
DeleteDateColumn,
|
|
11
|
-
UpdateDateColumn
|
|
12
|
-
} from 'typeorm'
|
|
13
|
-
import { Field, ID, ObjectType } from 'type-graphql'
|
|
14
|
-
|
|
15
|
-
import { Domain } from '@things-factory/shell'
|
|
16
|
-
import { Group } from '../group/group'
|
|
17
|
-
import { PlayGroup } from '../play-group/play-group'
|
|
18
|
-
import { User } from '@things-factory/auth-base'
|
|
19
|
-
import { config } from '@things-factory/env'
|
|
20
|
-
|
|
21
|
-
const ORMCONFIG = config.get('ormconfig', {})
|
|
22
|
-
const DATABASE_TYPE = ORMCONFIG.type
|
|
23
|
-
|
|
24
|
-
@Entity()
|
|
25
|
-
@Index('ix_board_1', (board: Board) => [board.domain, board.name], {
|
|
26
|
-
unique: true,
|
|
27
|
-
where: '"deleted_at" IS NULL'
|
|
28
|
-
})
|
|
29
|
-
@Index('ix_board_3', (board: Board) => [board.domain, board.group])
|
|
30
|
-
@ObjectType({ description: 'Entity for Visualization Board' })
|
|
31
|
-
export class Board {
|
|
32
|
-
@PrimaryGeneratedColumn('uuid')
|
|
33
|
-
@Field(type => ID, { nullable: true })
|
|
34
|
-
readonly id?: string
|
|
35
|
-
|
|
36
|
-
@Column({ nullable: true, default: 1 })
|
|
37
|
-
@Field({ nullable: true })
|
|
38
|
-
version?: number = 1
|
|
39
|
-
|
|
40
|
-
@ManyToOne(type => Domain)
|
|
41
|
-
@Field(type => Domain, { nullable: true })
|
|
42
|
-
domain?: Domain
|
|
43
|
-
|
|
44
|
-
@RelationId((board: Board) => board.domain)
|
|
45
|
-
domainId?: string
|
|
46
|
-
|
|
47
|
-
@Column()
|
|
48
|
-
@Field()
|
|
49
|
-
name?: string
|
|
50
|
-
|
|
51
|
-
@Column({ nullable: true })
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
description?: string
|
|
54
|
-
|
|
55
|
-
@Column({ nullable: true, default: 'draft' })
|
|
56
|
-
@Field({ nullable: true })
|
|
57
|
-
state?: 'draft' | 'released'
|
|
58
|
-
|
|
59
|
-
@Column({
|
|
60
|
-
nullable: true,
|
|
61
|
-
type:
|
|
62
|
-
DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
63
|
-
? 'longtext'
|
|
64
|
-
: DATABASE_TYPE == 'oracle'
|
|
65
|
-
? 'clob'
|
|
66
|
-
: DATABASE_TYPE == 'mssql'
|
|
67
|
-
? 'nvarchar'
|
|
68
|
-
: 'varchar',
|
|
69
|
-
length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined
|
|
70
|
-
})
|
|
71
|
-
@Field({ nullable: true })
|
|
72
|
-
model?: string
|
|
73
|
-
|
|
74
|
-
@Column({
|
|
75
|
-
nullable: true,
|
|
76
|
-
type:
|
|
77
|
-
DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
78
|
-
? 'longtext'
|
|
79
|
-
: DATABASE_TYPE == 'oracle'
|
|
80
|
-
? 'clob'
|
|
81
|
-
: DATABASE_TYPE == 'mssql'
|
|
82
|
-
? 'nvarchar'
|
|
83
|
-
: 'varchar',
|
|
84
|
-
length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined
|
|
85
|
-
})
|
|
86
|
-
@Field({ nullable: true })
|
|
87
|
-
thumbnail?: string
|
|
88
|
-
|
|
89
|
-
@ManyToOne(type => Group, group => group.boards)
|
|
90
|
-
@Field(type => Group, { nullable: true })
|
|
91
|
-
group?: Group
|
|
92
|
-
|
|
93
|
-
@RelationId((board: Board) => board.group)
|
|
94
|
-
groupId?: string
|
|
95
|
-
|
|
96
|
-
@ManyToMany(type => PlayGroup, playGroup => playGroup.boards)
|
|
97
|
-
@Field(type => [PlayGroup], { nullable: true })
|
|
98
|
-
playGroups?: PlayGroup[]
|
|
99
|
-
|
|
100
|
-
@CreateDateColumn()
|
|
101
|
-
@Field({ nullable: true })
|
|
102
|
-
createdAt?: Date
|
|
103
|
-
|
|
104
|
-
@UpdateDateColumn()
|
|
105
|
-
@Field({ nullable: true })
|
|
106
|
-
updatedAt?: Date
|
|
107
|
-
|
|
108
|
-
@ManyToOne(type => User, { nullable: true })
|
|
109
|
-
@Field(type => User, { nullable: true })
|
|
110
|
-
creator?: User
|
|
111
|
-
|
|
112
|
-
@RelationId((board: Board) => board.creator)
|
|
113
|
-
creatorId?: string
|
|
114
|
-
|
|
115
|
-
@ManyToOne(type => User, { nullable: true })
|
|
116
|
-
@Field(type => User, { nullable: true })
|
|
117
|
-
updater?: User
|
|
118
|
-
|
|
119
|
-
@RelationId((board: Board) => board.updater)
|
|
120
|
-
updaterId?: string
|
|
121
|
-
|
|
122
|
-
@DeleteDateColumn()
|
|
123
|
-
@Field({ nullable: true })
|
|
124
|
-
deletedAt?: Date
|
|
125
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { HistoryEntitySubscriber } from '@operato/typeorm-history'
|
|
4
|
-
import { pubsub, getRepository } from '@things-factory/shell'
|
|
5
|
-
|
|
6
|
-
import { Board } from './board'
|
|
7
|
-
import { BoardHistory } from './board-history'
|
|
8
|
-
|
|
9
|
-
@EventSubscriber()
|
|
10
|
-
export class BoardSubscriber implements EntitySubscriberInterface<Board> {
|
|
11
|
-
listenTo() {
|
|
12
|
-
return Board
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async beforeUpdate(event: UpdateEvent<Board>): Promise<any> {
|
|
16
|
-
var board = event.entity
|
|
17
|
-
|
|
18
|
-
if (!board.version) {
|
|
19
|
-
board.version = 0
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async afterUpdate(event: UpdateEvent<Board>): Promise<any> {
|
|
24
|
-
var board = event.entity
|
|
25
|
-
|
|
26
|
-
board = await event.manager.findOne(Board, {
|
|
27
|
-
where: { domain: { id: board.domainId }, id: board.id },
|
|
28
|
-
relations: ['playGroups']
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
if (!board || board.state != 'released') {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
board.playGroups.forEach(playGroup =>
|
|
36
|
-
pubsub.publish('play-group', {
|
|
37
|
-
playGroup
|
|
38
|
-
})
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
pubsub.publish('board', {
|
|
42
|
-
board
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@EventSubscriber()
|
|
48
|
-
export class BoardHistoryEntitySubscriber extends HistoryEntitySubscriber<Board, BoardHistory> {
|
|
49
|
-
public get entity() {
|
|
50
|
-
return Board
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public get historyEntity() {
|
|
54
|
-
return BoardHistory
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public async afterInsert(event: InsertEvent<Board>): Promise<void> {
|
|
58
|
-
if (event.entity.state == 'released') {
|
|
59
|
-
super.afterInsert(event)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public async afterUpdate(event: UpdateEvent<Board>): Promise<void> {
|
|
64
|
-
if (event.entity.state == 'released') {
|
|
65
|
-
super.afterUpdate(event)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Board } from './board'
|
|
2
|
-
import { BoardHistory } from './board-history'
|
|
3
|
-
import { BoardQuery } from './board-query'
|
|
4
|
-
import { BoardMutation } from './board-mutation'
|
|
5
|
-
import { BoardSubscription } from './board-subscription'
|
|
6
|
-
import { BoardSubscriber, BoardHistoryEntitySubscriber } from './event-subscriber'
|
|
7
|
-
|
|
8
|
-
export const entities = [Board, BoardHistory]
|
|
9
|
-
export const resolvers = [BoardQuery, BoardMutation, BoardSubscription]
|
|
10
|
-
export const subscribers = [BoardSubscriber, BoardHistoryEntitySubscriber]
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Args, Ctx, Query, Resolver } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { config } from '@things-factory/env'
|
|
4
|
-
import { Favorite } from '@things-factory/fav-base'
|
|
5
|
-
import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Board } from '../board/board'
|
|
8
|
-
import { BoardFavorite, BoardFavoriteList } from './board-favorite-type'
|
|
9
|
-
|
|
10
|
-
const ORMCONFIG = config.get('ormconfig', {})
|
|
11
|
-
const DATABASE_TYPE = ORMCONFIG.type
|
|
12
|
-
|
|
13
|
-
@Resolver(BoardFavorite)
|
|
14
|
-
export class BoardFavoriteQuery {
|
|
15
|
-
@Query(returns => BoardFavoriteList, { description: 'To fetch multiple BoardFavorites' })
|
|
16
|
-
async favoriteBoards(
|
|
17
|
-
@Args(type => ListParam) params: ListParam,
|
|
18
|
-
@Ctx() context: ResolverContext
|
|
19
|
-
): Promise<BoardFavoriteList> {
|
|
20
|
-
const { user } = context.state
|
|
21
|
-
|
|
22
|
-
const queryBuilder = getRepository(Board).createQueryBuilder()
|
|
23
|
-
buildQuery(queryBuilder, params, context)
|
|
24
|
-
|
|
25
|
-
var joinStatement = ''
|
|
26
|
-
switch (DATABASE_TYPE) {
|
|
27
|
-
case 'postgres':
|
|
28
|
-
joinStatement = 'CAST(Board.id as VARCHAR) = Favorite.routing'
|
|
29
|
-
break
|
|
30
|
-
case 'sqlite':
|
|
31
|
-
default:
|
|
32
|
-
joinStatement = 'Board.id = Favorite.routing'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var qb = queryBuilder
|
|
36
|
-
.innerJoin(Favorite, 'Favorite', joinStatement)
|
|
37
|
-
.select([
|
|
38
|
-
'Board.id as id',
|
|
39
|
-
'Board.name as name',
|
|
40
|
-
'Board.description as description',
|
|
41
|
-
'Board.thumbnail as thumbnail',
|
|
42
|
-
'Favorite.id as favoriteId'
|
|
43
|
-
])
|
|
44
|
-
.andWhere('Favorite.user = :userId', {
|
|
45
|
-
userId: user.id
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const items = await qb.getRawMany()
|
|
49
|
-
const total = await qb.getCount()
|
|
50
|
-
|
|
51
|
-
return { items, total }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, Int } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Board } from '../board/board'
|
|
4
|
-
|
|
5
|
-
@ObjectType()
|
|
6
|
-
export class BoardFavorite extends Board {
|
|
7
|
-
@Field({ nullable: true })
|
|
8
|
-
favoriteId?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@ObjectType()
|
|
12
|
-
export class BoardFavoriteList {
|
|
13
|
-
@Field(type => [BoardFavorite])
|
|
14
|
-
items: BoardFavorite[]
|
|
15
|
-
|
|
16
|
-
@Field(type => Int)
|
|
17
|
-
total: number
|
|
18
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { getRedirectSubdomainPath } from '@things-factory/shell'
|
|
4
|
-
import { BoardTemplate } from './board-template'
|
|
5
|
-
import { Board } from '../board/board'
|
|
6
|
-
import { NewBoardTemplate, BoardTemplatePatch } from './board-template-type'
|
|
7
|
-
import { thumbnail } from '../../controllers/thumbnail'
|
|
8
|
-
|
|
9
|
-
@Resolver(BoardTemplate)
|
|
10
|
-
export class BoardTemplateMutation {
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Directive('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)')
|
|
13
|
-
@Mutation(returns => BoardTemplate, { description: 'To create new BoardTemplate' })
|
|
14
|
-
async createBoardTemplate(
|
|
15
|
-
@Arg('boardTemplate') boardTemplate: NewBoardTemplate,
|
|
16
|
-
@Ctx() context: ResolverContext
|
|
17
|
-
): Promise<BoardTemplate> {
|
|
18
|
-
const { domain, user, tx } = context.state
|
|
19
|
-
const repository = tx.getRepository(BoardTemplate)
|
|
20
|
-
|
|
21
|
-
const oldBoardTemplate: BoardTemplate = await repository.findOneBy({
|
|
22
|
-
name: boardTemplate.name,
|
|
23
|
-
domain: { id: domain.id }
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
if (oldBoardTemplate) {
|
|
27
|
-
throw new Error(context.t('error.board-template name is already taken', { name: boardTemplate.name }))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const newBoardTemplate: Partial<BoardTemplate> = {
|
|
31
|
-
...boardTemplate
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const base64 = await thumbnail({
|
|
35
|
-
model: boardTemplate.model,
|
|
36
|
-
context
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
if (base64) {
|
|
40
|
-
newBoardTemplate.thumbnail = 'data:image/png;base64,' + base64.toString('base64')
|
|
41
|
-
} else {
|
|
42
|
-
newBoardTemplate.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return await repository.save({
|
|
46
|
-
domain,
|
|
47
|
-
...newBoardTemplate,
|
|
48
|
-
creator: user,
|
|
49
|
-
updater: user
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Directive('@transaction')
|
|
54
|
-
@Directive('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)')
|
|
55
|
-
@Mutation(returns => BoardTemplate, { description: 'To modify BoardTemplate information' })
|
|
56
|
-
async updateBoardTemplate(
|
|
57
|
-
@Arg('id') id: string,
|
|
58
|
-
@Arg('patch') patch: BoardTemplatePatch,
|
|
59
|
-
@Ctx() context: ResolverContext
|
|
60
|
-
): Promise<BoardTemplate> {
|
|
61
|
-
const { domain, user, tx } = context.state
|
|
62
|
-
const repository = tx.getRepository(BoardTemplate)
|
|
63
|
-
|
|
64
|
-
const boardTemplate = await repository.findOne({
|
|
65
|
-
where: { domain: { id: domain.id }, id }
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
if (patch.model) {
|
|
69
|
-
const base64 = await thumbnail({
|
|
70
|
-
model: patch.model,
|
|
71
|
-
context
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
if (base64) {
|
|
75
|
-
patch.thumbnail = 'data:image/png;base64,' + base64.toString('base64')
|
|
76
|
-
} else {
|
|
77
|
-
patch.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return await repository.save({
|
|
82
|
-
...boardTemplate,
|
|
83
|
-
...patch,
|
|
84
|
-
updater: user
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Directive('@transaction')
|
|
89
|
-
@Directive('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)')
|
|
90
|
-
@Mutation(returns => Boolean, { description: 'To delete BoardTemplate' })
|
|
91
|
-
async deleteBoardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
92
|
-
const { domain, tx } = context.state
|
|
93
|
-
|
|
94
|
-
await tx.getRepository(BoardTemplate).delete({ domain: { id: domain.id }, id })
|
|
95
|
-
|
|
96
|
-
return true
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@Directive('@transaction')
|
|
100
|
-
@Directive('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)')
|
|
101
|
-
@Mutation(returns => BoardTemplate, { description: 'To register a board as a board template with the given ID' })
|
|
102
|
-
async registerBoardAsTemplate(
|
|
103
|
-
@Arg('id', { description: 'board Id to be regiestered' }) id: string,
|
|
104
|
-
@Arg('name', { description: 'name of board template to be regiestered' }) name: string,
|
|
105
|
-
@Arg('description', { description: 'description of board template to be regiestered' }) description: string,
|
|
106
|
-
@Arg('visibility', { description: 'visibility of board template to be regiestered' }) visibility: string,
|
|
107
|
-
@Ctx() context: ResolverContext
|
|
108
|
-
): Promise<BoardTemplate> {
|
|
109
|
-
const { domain, user, notify, tx } = context.state
|
|
110
|
-
|
|
111
|
-
const boardTemplateRepository = tx.getRepository(BoardTemplate)
|
|
112
|
-
|
|
113
|
-
const board = await tx.getRepository(Board).findOne({
|
|
114
|
-
where: { domain: { id: domain.id }, id }
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
if (!board) {
|
|
118
|
-
throw `Board given id(${id}) is not found`
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
name ||= board.name
|
|
122
|
-
|
|
123
|
-
const { model, thumbnail } = board
|
|
124
|
-
|
|
125
|
-
const boardTemplate = await boardTemplateRepository.findOne({
|
|
126
|
-
where: { domain: { id: domain.id }, name }
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
const registered = boardTemplate
|
|
130
|
-
? await boardTemplateRepository.save({
|
|
131
|
-
...boardTemplate,
|
|
132
|
-
name,
|
|
133
|
-
description: description || boardTemplate.description,
|
|
134
|
-
visibility: visibility || boardTemplate.visibility,
|
|
135
|
-
model,
|
|
136
|
-
thumbnail,
|
|
137
|
-
updater: user
|
|
138
|
-
})
|
|
139
|
-
: await boardTemplateRepository.save({
|
|
140
|
-
domain: { id: domain.id },
|
|
141
|
-
name,
|
|
142
|
-
description: description || board.description,
|
|
143
|
-
model,
|
|
144
|
-
thumbnail,
|
|
145
|
-
visibility: visibility || 'private',
|
|
146
|
-
updater: user,
|
|
147
|
-
creator: user
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
notify &&
|
|
151
|
-
notify({
|
|
152
|
-
mode: 'in-app',
|
|
153
|
-
title: `BoardTemplate '${registered.name}' registered`,
|
|
154
|
-
body: `BoardTemplate '${registered.name}' registered by ${user.name}\n${registered.description}`,
|
|
155
|
-
image: getRedirectSubdomainPath(context, domain.subdomain, `/board-template-thumbnail/${registered.id}`),
|
|
156
|
-
url: getRedirectSubdomainPath(context, domain.subdomain, `/board-template-viewer/${registered.id}`)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
return registered
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Brackets, In } from 'typeorm'
|
|
2
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
3
|
-
import { Attachment } from '@things-factory/attachment-base'
|
|
4
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
5
|
-
import { User } from '@things-factory/auth-base'
|
|
6
|
-
import { BoardTemplate } from './board-template'
|
|
7
|
-
import { BoardTemplateList } from './board-template-type'
|
|
8
|
-
|
|
9
|
-
@Resolver(BoardTemplate)
|
|
10
|
-
export class BoardTemplateQuery {
|
|
11
|
-
@Query(returns => BoardTemplate!, { nullable: true, description: 'To fetch a BoardTemplate' })
|
|
12
|
-
@Directive('@privilege(category: "board-template", privilege: "query", domainOwnerGranted: true)')
|
|
13
|
-
async boardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<BoardTemplate> {
|
|
14
|
-
const { domain, user } = context.state
|
|
15
|
-
|
|
16
|
-
const qb = await getRepository(BoardTemplate)
|
|
17
|
-
.createQueryBuilder('BoardTemplate')
|
|
18
|
-
.where('id=:id', { id })
|
|
19
|
-
.andWhere(
|
|
20
|
-
new Brackets(qb => {
|
|
21
|
-
qb.where({ visibility: 'public' })
|
|
22
|
-
.orWhere({
|
|
23
|
-
visibility: 'domain',
|
|
24
|
-
domain: { id: In([domain.id, domain.parentId]) }
|
|
25
|
-
})
|
|
26
|
-
.orWhere({
|
|
27
|
-
visibility: 'private',
|
|
28
|
-
creator: { id: user.id }
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return qb.getOne()
|
|
34
|
-
|
|
35
|
-
// return await getRepository(BoardTemplate).findOne({
|
|
36
|
-
// where: {
|
|
37
|
-
// domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
|
|
38
|
-
// id
|
|
39
|
-
// }
|
|
40
|
-
// })
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@Query(returns => BoardTemplateList, { description: 'To fetch BoardTemplates created by me' })
|
|
44
|
-
async boardTemplatesCreatedByMe(
|
|
45
|
-
@Args(type => ListParam) params: ListParam,
|
|
46
|
-
@Ctx() context: ResolverContext
|
|
47
|
-
): Promise<BoardTemplateList> {
|
|
48
|
-
const { user } = context.state
|
|
49
|
-
|
|
50
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
51
|
-
repository: getRepository(BoardTemplate),
|
|
52
|
-
params,
|
|
53
|
-
alias: 'template',
|
|
54
|
-
searchables: ['name', 'description']
|
|
55
|
-
}).andWhere('template.creator = :user', { user: user.id })
|
|
56
|
-
|
|
57
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
58
|
-
|
|
59
|
-
return { items, total }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Query(returns => BoardTemplateList, { description: 'To fetch multiple BoardTemplates' })
|
|
63
|
-
@Directive('@privilege(category: "board-template", privilege: "query", domainOwnerGranted: true)')
|
|
64
|
-
async boardTemplates(
|
|
65
|
-
@Args(type => ListParam) params: ListParam,
|
|
66
|
-
@Ctx() context: ResolverContext
|
|
67
|
-
): Promise<BoardTemplateList> {
|
|
68
|
-
const { domain, user } = context.state
|
|
69
|
-
/*
|
|
70
|
-
리스트에 포함되는 보드템플릿들
|
|
71
|
-
- visibility가 public 인 경우
|
|
72
|
-
- visibility가 domain이며 컨텍스트의 도메인과 같은 경우
|
|
73
|
-
- visibility가 private 이며, creator가 나인 경우
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
77
|
-
params,
|
|
78
|
-
repository: await getRepository(BoardTemplate),
|
|
79
|
-
searchables: ['name', 'description']
|
|
80
|
-
}).andWhere(
|
|
81
|
-
new Brackets(qb => {
|
|
82
|
-
qb.where({ visibility: 'public' })
|
|
83
|
-
.orWhere({
|
|
84
|
-
visibility: 'domain',
|
|
85
|
-
domain: { id: In([domain.id, domain.parentId]) }
|
|
86
|
-
})
|
|
87
|
-
.orWhere({
|
|
88
|
-
visibility: 'private',
|
|
89
|
-
creator: { id: user.id }
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
95
|
-
|
|
96
|
-
return { items, total }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@FieldResolver(type => Boolean)
|
|
100
|
-
async mine(@Root() boardTemplate: BoardTemplate, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
101
|
-
const { creatorId } = boardTemplate
|
|
102
|
-
const { user } = context.state
|
|
103
|
-
|
|
104
|
-
return creatorId == user.id
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@FieldResolver(type => Domain)
|
|
108
|
-
async domain(@Root() boardTemplate: BoardTemplate): Promise<Domain> {
|
|
109
|
-
return boardTemplate.domainId && (await getRepository(Domain).findOneBy({ id: boardTemplate.domainId }))
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@FieldResolver(type => User)
|
|
113
|
-
async updater(@Root() boardTemplate: BoardTemplate): Promise<User> {
|
|
114
|
-
return boardTemplate.updaterId && (await getRepository(User).findOneBy({ id: boardTemplate.updaterId }))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@FieldResolver(type => User)
|
|
118
|
-
async creator(@Root() boardTemplate: BoardTemplate): Promise<User> {
|
|
119
|
-
return boardTemplate.creatorId && (await getRepository(User).findOneBy({ id: boardTemplate.creatorId }))
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
|
2
|
-
import { BoardTemplate } from './board-template'
|
|
3
|
-
|
|
4
|
-
@InputType()
|
|
5
|
-
export class NewBoardTemplate {
|
|
6
|
-
@Field()
|
|
7
|
-
name: string
|
|
8
|
-
|
|
9
|
-
@Field()
|
|
10
|
-
description: string
|
|
11
|
-
|
|
12
|
-
@Field()
|
|
13
|
-
model: string
|
|
14
|
-
|
|
15
|
-
@Field()
|
|
16
|
-
visibility: 'private' | 'public'
|
|
17
|
-
|
|
18
|
-
@Field({ nullable: true })
|
|
19
|
-
thumbnail: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@InputType()
|
|
23
|
-
export class BoardTemplatePatch {
|
|
24
|
-
@Field(type => ID, { nullable: true })
|
|
25
|
-
id?: string
|
|
26
|
-
|
|
27
|
-
@Field({ nullable: true })
|
|
28
|
-
name?: string
|
|
29
|
-
|
|
30
|
-
@Field({ nullable: true })
|
|
31
|
-
description?: string
|
|
32
|
-
|
|
33
|
-
@Field({ nullable: true })
|
|
34
|
-
model: string
|
|
35
|
-
|
|
36
|
-
@Field({ nullable: true })
|
|
37
|
-
visibility?: 'private' | 'public'
|
|
38
|
-
|
|
39
|
-
@Field({ nullable: true })
|
|
40
|
-
thumbnail?: string
|
|
41
|
-
|
|
42
|
-
@Field({ nullable: true })
|
|
43
|
-
cuFlag?: string
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@ObjectType()
|
|
47
|
-
export class BoardTemplateList {
|
|
48
|
-
@Field(type => [BoardTemplate])
|
|
49
|
-
items: BoardTemplate[]
|
|
50
|
-
|
|
51
|
-
@Field(type => Int)
|
|
52
|
-
total: number
|
|
53
|
-
}
|