@things-factory/board-service 8.0.5 → 8.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/board-service",
3
- "version": "8.0.5",
3
+ "version": "8.0.13",
4
4
  "main": "dist-server/index.js",
5
5
  "things-factory": true,
6
6
  "author": "",
@@ -23,15 +23,15 @@
23
23
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/auth-base": "^8.0.5",
27
- "@things-factory/env": "^8.0.2",
28
- "@things-factory/fav-base": "^8.0.5",
29
- "@things-factory/font-base": "^8.0.5",
30
- "@things-factory/integration-base": "^8.0.5",
26
+ "@things-factory/auth-base": "^8.0.13",
27
+ "@things-factory/env": "^8.0.8",
28
+ "@things-factory/fav-base": "^8.0.13",
29
+ "@things-factory/font-base": "^8.0.13",
30
+ "@things-factory/integration-base": "^8.0.13",
31
31
  "@things-factory/operato-license-checker": "^4.0.4",
32
32
  "content-disposition": "^0.5.3",
33
33
  "generic-pool": "^3.8.2",
34
34
  "puppeteer": "^23.0.0"
35
35
  },
36
- "gitHead": "9ab6fca18eeb58b9d2f3411661508a39d0ab6aee"
36
+ "gitHead": "66c1356c18b5c9a21e8280460eb40020f7ea2b37"
37
37
  }
@@ -46,7 +46,7 @@ export const headlessModel = async (target, draft: boolean = false) => {
46
46
  }
47
47
 
48
48
  return {
49
- base: getContextPath(domain?.subdomain) + (domain ? '/' : ''),
49
+ base: getContextPath(domain),
50
50
  model,
51
51
  board
52
52
  }
@@ -65,7 +65,7 @@ export const headlessPlaylist = async (target, draft: boolean = false) => {
65
65
  }
66
66
 
67
67
  return {
68
- base: getContextPath(domain?.subdomain) + (domain ? '/' : ''),
68
+ base: getContextPath(domain),
69
69
  playGroup
70
70
  }
71
71
  }
package/server/routes.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { config } from '@things-factory/env'
2
- import { getHeadlessPool as getHeadlessPoolForBoard } from './controllers/headless-pool-for-board'
3
- import { getHeadlessPool as getHeadlessPoolForLabel } from './controllers/headless-pool-for-label'
4
- import { internalBoardViewRouter } from './routers/internal-board-view-router'
5
- import { standaloneBoardServiceRouter } from './routers/standalone-board-service-router'
2
+ import { getRoutePrefixForDomainType } from '@things-factory/shell'
3
+ import { getHeadlessPool as getHeadlessPoolForBoard } from './controllers/headless-pool-for-board.js'
4
+ import { getHeadlessPool as getHeadlessPoolForLabel } from './controllers/headless-pool-for-label.js'
5
+ import { internalBoardViewRouter } from './routers/internal-board-view-router.js'
6
+ import { standaloneBoardServiceRouter } from './routers/standalone-board-service-router.js'
6
7
 
7
- const isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')
8
+ const isPathBaseDomain = !config.get('subdomain')
8
9
 
9
10
  process.on('bootstrap-module-global-public-route' as any, (app, domainGlobalPublicRouter) => {
10
11
  getHeadlessPoolForLabel()
@@ -14,8 +15,9 @@ process.on('bootstrap-module-global-public-route' as any, (app, domainGlobalPubl
14
15
 
15
16
  process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
16
17
  if (isPathBaseDomain) {
18
+ const domainType = 'domain'
17
19
  domainPrivateRouter.use(
18
- '/domain/:domain',
20
+ `/${getRoutePrefixForDomainType()}/:domain`,
19
21
  standaloneBoardServiceRouter.routes(),
20
22
  standaloneBoardServiceRouter.allowedMethods()
21
23
  )
@@ -42,8 +42,8 @@ export class BoardMutation {
42
42
  @Mutation(returns => Board, { description: 'To create new Board' })
43
43
  async createBoard(@Arg('board') board: NewBoard, @Ctx() context: ResolverContext): Promise<Board> {
44
44
  const { domain, user, notify, tx } = context.state
45
- const repository = tx.getRepository(Board)
46
- const groupRepository = tx.getRepository(Group)
45
+ const repository = getRepository(Board, tx)
46
+ const groupRepository = getRepository(Group, tx)
47
47
 
48
48
  const oldBoard: Board = await repository.findOneBy({
49
49
  name: board.name,
@@ -80,7 +80,7 @@ export class BoardMutation {
80
80
  mode: 'in-app',
81
81
  title: `Board '${created.name}' created`,
82
82
  body: `Board '${created.name}' created by ${user.name}\n${created.description}`,
83
- url: getRedirectSubdomainPath(context, domain.subdomain, `/board-viewer/${created.id}`)
83
+ url: getRedirectSubdomainPath(context, domain, `/board-viewer/${created.id}`)
84
84
  })
85
85
 
86
86
  return created
@@ -98,7 +98,7 @@ export class BoardMutation {
98
98
  ): Promise<Board> {
99
99
  const { domain, user, notify, tx } = context.state
100
100
  const { t } = context
101
- const repository = tx.getRepository(Board)
101
+ const repository = getRepository(Board, tx)
102
102
 
103
103
  const board = await repository.findOneBy({ domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id })
104
104
 
@@ -114,7 +114,7 @@ export class BoardMutation {
114
114
 
115
115
  var targetDomain = domain
116
116
  if (targetDomain && domain.subdomain != targetSubdomain) {
117
- targetDomain = await tx.getRepository(Domain).findOneBy({ subdomain: targetSubdomain })
117
+ targetDomain = await getRepository(Domain, tx).findOneBy({ subdomain: targetSubdomain })
118
118
  if (!targetDomain) {
119
119
  throw `given subdomain(${targetSubdomain}) not found`
120
120
  }
@@ -122,7 +122,7 @@ export class BoardMutation {
122
122
 
123
123
  var targetGroup = null
124
124
  if (targetGroupId) {
125
- targetGroup = await tx.getRepository(Group).findOneBy({ domain: { id: targetDomain.id }, id: targetGroupId })
125
+ targetGroup = await getRepository(Group, tx).findOneBy({ domain: { id: targetDomain.id }, id: targetGroupId })
126
126
  if (!targetGroup) {
127
127
  throw `given group(${targetGroupId}) in domain(${targetSubdomain}) not found`
128
128
  }
@@ -146,8 +146,8 @@ export class BoardMutation {
146
146
  mode: 'in-app',
147
147
  title: `Board '${cloned.name}' cloned`,
148
148
  body: `Board '${cloned.name}' cloned by ${user.name}\n${cloned.description}`,
149
- image: getRedirectSubdomainPath(context, targetSubdomain, `/thumbnail/${cloned.id}`),
150
- url: getRedirectSubdomainPath(context, targetSubdomain, `/board-viewer/${cloned.id}`)
149
+ image: getRedirectSubdomainPath(context, targetDomain, `/thumbnail/${cloned.id}`),
150
+ url: getRedirectSubdomainPath(context, targetDomain, `/board-viewer/${cloned.id}`)
151
151
  })
152
152
 
153
153
  return cloned
@@ -162,7 +162,7 @@ export class BoardMutation {
162
162
  @Ctx() context: ResolverContext
163
163
  ): Promise<Board> {
164
164
  const { domain, user, notify, tx } = context.state
165
- const repository = tx.getRepository(Board)
165
+ const repository = getRepository(Board, tx)
166
166
 
167
167
  const board = await repository.findOne({
168
168
  where: { domain: { id: domain.id }, id },
@@ -195,7 +195,7 @@ export class BoardMutation {
195
195
  .then(async thumbnailBase64 => {
196
196
  /* use new resource manager */
197
197
  await getDataSource().transaction(async (tx: EntityManager) => {
198
- await tx.getRepository(Board).save({
198
+ await getRepository(Board, tx).save({
199
199
  id: updated.id,
200
200
  thumbnail: 'data:image/png;base64,' + thumbnailBase64.toString('base64')
201
201
  })
@@ -210,7 +210,7 @@ export class BoardMutation {
210
210
  const { groupId, ...patched } = patch
211
211
 
212
212
  if (groupId !== undefined) {
213
- const groupRepository = tx.getRepository(Group)
213
+ const groupRepository = getRepository(Group, tx)
214
214
  board.group = groupId
215
215
  ? (await groupRepository.findOneBy({
216
216
  domain: { id: domain.id },
@@ -232,8 +232,8 @@ export class BoardMutation {
232
232
  mode: 'in-app',
233
233
  title: `Board '${updated.name}' updated`,
234
234
  body: `Board '${updated.name}' updated by ${user.name}\n${updated.description}`,
235
- image: getRedirectSubdomainPath(context, domain.subdomain, `/thumbnail/${updated.id}`),
236
- url: getRedirectSubdomainPath(context, domain.subdomain, `/board-viewer/${updated.id}`)
235
+ image: getRedirectSubdomainPath(context, domain, `/thumbnail/${updated.id}`),
236
+ url: getRedirectSubdomainPath(context, domain, `/board-viewer/${updated.id}`)
237
237
  })
238
238
 
239
239
  return updated
@@ -244,7 +244,7 @@ export class BoardMutation {
244
244
  @Mutation(returns => Board, { description: 'To release a Board' })
245
245
  async releaseBoard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Board> {
246
246
  const { domain, user, notify, tx } = context.state
247
- const repository = tx.getRepository(Board)
247
+ const repository = getRepository(Board, tx)
248
248
 
249
249
  const board = await repository.findOne({
250
250
  where: { domain: { id: domain.id }, id },
@@ -272,8 +272,8 @@ export class BoardMutation {
272
272
  mode: 'in-app',
273
273
  title: `Board '${updated.name}' released`,
274
274
  body: `Board '${updated.name}' released by ${user.name}\n${updated.description}`,
275
- image: getRedirectSubdomainPath(context, domain.subdomain, `/thumbnail/${updated.id}`),
276
- url: getRedirectSubdomainPath(context, domain.subdomain, `/board-viewer/${updated.id}`)
275
+ image: getRedirectSubdomainPath(context, domain, `/thumbnail/${updated.id}`),
276
+ url: getRedirectSubdomainPath(context, domain, `/board-viewer/${updated.id}`)
277
277
  })
278
278
 
279
279
  return updated
@@ -288,7 +288,7 @@ export class BoardMutation {
288
288
  @Ctx() context: ResolverContext
289
289
  ): Promise<Board> {
290
290
  const { domain, user, notify, tx } = context.state
291
- const repository = tx.getRepository(Board)
291
+ const repository = getRepository(Board, tx)
292
292
 
293
293
  const board = await repository.findOne({
294
294
  where: { domain: { id: domain.id }, id },
@@ -299,7 +299,7 @@ export class BoardMutation {
299
299
  throw `Board with id(${id}) is not found`
300
300
  }
301
301
 
302
- const historyRepository = tx.getRepository(BoardHistory)
302
+ const historyRepository = getRepository(BoardHistory, tx)
303
303
 
304
304
  const boardHistory = await historyRepository.findOne({
305
305
  where: { domain: { id: domain.id }, originalId: id, version },
@@ -324,8 +324,8 @@ export class BoardMutation {
324
324
  mode: 'in-app',
325
325
  title: `Board '${updated.name}' updated`,
326
326
  body: `Board '${updated.name}' updated by ${user.name}\n${updated.description}`,
327
- image: getRedirectSubdomainPath(context, domain.subdomain, `/thumbnail/${updated.id}`),
328
- url: getRedirectSubdomainPath(context, domain.subdomain, `/board-viewer/${updated.id}`)
327
+ image: getRedirectSubdomainPath(context, domain, `/thumbnail/${updated.id}`),
328
+ url: getRedirectSubdomainPath(context, domain, `/board-viewer/${updated.id}`)
329
329
  })
330
330
 
331
331
  return updated
@@ -336,7 +336,7 @@ export class BoardMutation {
336
336
  @Mutation(returns => Boolean, { description: 'To delete Board' })
337
337
  async deleteBoard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
338
338
  const { domain, user, notify, tx } = context.state
339
- const repository = tx.getRepository(Board)
339
+ const repository = getRepository(Board, tx)
340
340
  const board = await repository.findOneBy({ domain: { id: domain.id }, id })
341
341
 
342
342
  const deleted = await repository.softDelete(id)
@@ -361,8 +361,8 @@ export class BoardMutation {
361
361
  @Ctx() context: ResolverContext
362
362
  ): Promise<Board[]> {
363
363
  const { domain, user, notify, tx } = context.state
364
- const groupRepository = tx.getRepository(Group)
365
- const boardRepository = tx.getRepository(Board)
364
+ const groupRepository = getRepository(Group, tx)
365
+ const boardRepository = getRepository(Board, tx)
366
366
  const group = await groupRepository.findOneBy({ domain: { id: domain.id }, id: groupId })
367
367
 
368
368
  if (!group) {
@@ -1,10 +1,10 @@
1
1
  import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
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'
3
+ import { getRedirectSubdomainPath, getRepository } from '@things-factory/shell'
4
+ import { BoardTemplate } from './board-template.js'
5
+ import { Board } from '../board/board.js'
6
+ import { NewBoardTemplate, BoardTemplatePatch } from './board-template-type.js'
7
+ import { thumbnail } from '../../controllers/thumbnail.js'
8
8
 
9
9
  @Resolver(BoardTemplate)
10
10
  export class BoardTemplateMutation {
@@ -16,7 +16,7 @@ export class BoardTemplateMutation {
16
16
  @Ctx() context: ResolverContext
17
17
  ): Promise<BoardTemplate> {
18
18
  const { domain, user, tx } = context.state
19
- const repository = tx.getRepository(BoardTemplate)
19
+ const repository = getRepository(BoardTemplate, tx)
20
20
 
21
21
  const oldBoardTemplate: BoardTemplate = await repository.findOneBy({
22
22
  name: boardTemplate.name,
@@ -59,7 +59,7 @@ export class BoardTemplateMutation {
59
59
  @Ctx() context: ResolverContext
60
60
  ): Promise<BoardTemplate> {
61
61
  const { domain, user, tx } = context.state
62
- const repository = tx.getRepository(BoardTemplate)
62
+ const repository = getRepository(BoardTemplate, tx)
63
63
 
64
64
  const boardTemplate = await repository.findOne({
65
65
  where: { domain: { id: domain.id }, id }
@@ -91,7 +91,7 @@ export class BoardTemplateMutation {
91
91
  async deleteBoardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
92
92
  const { domain, tx } = context.state
93
93
 
94
- await tx.getRepository(BoardTemplate).delete({ domain: { id: domain.id }, id })
94
+ await getRepository(BoardTemplate, tx).delete({ domain: { id: domain.id }, id })
95
95
 
96
96
  return true
97
97
  }
@@ -108,9 +108,9 @@ export class BoardTemplateMutation {
108
108
  ): Promise<BoardTemplate> {
109
109
  const { domain, user, notify, tx } = context.state
110
110
 
111
- const boardTemplateRepository = tx.getRepository(BoardTemplate)
111
+ const boardTemplateRepository = getRepository(BoardTemplate, tx)
112
112
 
113
- const board = await tx.getRepository(Board).findOne({
113
+ const board = await getRepository(Board, tx).findOne({
114
114
  where: { domain: { id: domain.id }, id }
115
115
  })
116
116
 
@@ -152,8 +152,8 @@ export class BoardTemplateMutation {
152
152
  mode: 'in-app',
153
153
  title: `BoardTemplate '${registered.name}' registered`,
154
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}`)
155
+ image: getRedirectSubdomainPath(context, domain, `/board-template-thumbnail/${registered.id}`),
156
+ url: getRedirectSubdomainPath(context, domain, `/board-template-viewer/${registered.id}`)
157
157
  })
158
158
 
159
159
  return registered