@things-factory/board-service 6.2.84 → 6.2.86

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": "6.2.84",
3
+ "version": "6.2.86",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -28,7 +28,7 @@
28
28
  "@things-factory/env": "^6.2.33",
29
29
  "@things-factory/fav-base": "^6.2.84",
30
30
  "@things-factory/font-base": "^6.2.84",
31
- "@things-factory/integration-base": "^6.2.84",
31
+ "@things-factory/integration-base": "^6.2.86",
32
32
  "@things-factory/operato-license-checker": "^4.0.4",
33
33
  "content-disposition": "^0.5.3",
34
34
  "generic-pool": "^3.8.2"
@@ -37,5 +37,5 @@
37
37
  "@thiagoelg/node-printer": "0.6.2",
38
38
  "puppeteer": "^20.7.3"
39
39
  },
40
- "gitHead": "3c272e989acc14bbd02f4ec79624dfd7dc4e6acd"
40
+ "gitHead": "f90a5c1ff2a93331bb6e375944972dc68dde8a1f"
41
41
  }
@@ -4,7 +4,7 @@ import { getContextPath, getRepository } from '@things-factory/shell'
4
4
  import { Board } from '../service/board/board'
5
5
  import { BoardHistory } from '../service/board/board-history'
6
6
 
7
- export const headlessModel = async (target, devmode: boolean = false) => {
7
+ export const headlessModel = async (target, draft: boolean = false) => {
8
8
  var { domain, id, model, name } = target || {}
9
9
 
10
10
  if (model) {
@@ -26,7 +26,7 @@ export const headlessModel = async (target, devmode: boolean = false) => {
26
26
  throw 'parameter model or id mandatory'
27
27
  }
28
28
 
29
- if (!devmode && board) {
29
+ if (!draft && board) {
30
30
  const latestReleased =
31
31
  board.state == 'released'
32
32
  ? board
@@ -37,12 +37,12 @@ export const headlessModel = async (target, devmode: boolean = false) => {
37
37
  .limit(1)
38
38
  .getOne()
39
39
 
40
- if (latestReleased) {
41
- model = latestReleased.model
42
- }
40
+ model = (latestReleased || board).model
41
+ } else {
42
+ model = board.model
43
43
  }
44
44
 
45
- model = JSON.parse(board.model)
45
+ model = JSON.parse(model)
46
46
  }
47
47
 
48
48
  return {
@@ -3,7 +3,7 @@ import { getContextPath, getRepository } from '@things-factory/shell'
3
3
  import { PlayGroup } from '../service/play-group/play-group'
4
4
  import { BoardHistory } from '../service/board/board-history'
5
5
 
6
- export const headlessPlaylist = async (target, devmode: boolean = false) => {
6
+ export const headlessPlaylist = async (target, draft: boolean = false) => {
7
7
  var { domain, id, name } = target || {}
8
8
 
9
9
  if (id || name) {
@@ -21,7 +21,7 @@ export const headlessPlaylist = async (target, devmode: boolean = false) => {
21
21
  })
22
22
  }
23
23
 
24
- if (!devmode && playGroup) {
24
+ if (!draft && playGroup) {
25
25
  const { boards } = playGroup
26
26
  for (let board of boards) {
27
27
  const latestReleased =
@@ -14,7 +14,7 @@ import { headlessModel } from './headless-model'
14
14
  * @param {boolean} mirror 좌우반전
15
15
  * @param {boolean} upsideDown 상하반전
16
16
  */
17
- export const labelcommand = async ({ id, model, data, orientation, mirror = false, upsideDown = false, context }) => {
17
+ export const labelcommand = async ({ id, model, data, orientation, mirror = false, upsideDown = false, context, draft = false }) => {
18
18
  const { domain } = context.state
19
19
 
20
20
  const browser = (await getHeadlessPool().acquire()) as any
@@ -24,7 +24,7 @@ export const labelcommand = async ({ id, model, data, orientation, mirror = fals
24
24
 
25
25
  const { page } = browser
26
26
 
27
- var { model } = await headlessModel({ domain, model, id })
27
+ var { model } = await headlessModel({ domain, model, id }, draft)
28
28
 
29
29
  const grf = await page.evaluate(
30
30
  async (model, data, orientation, mirror, upsideDown) => {
@@ -14,7 +14,8 @@ export const screenshot = async ({
14
14
  height: h = 0,
15
15
  options = { encoding: 'base64' } as any,
16
16
  isThumbnail = false,
17
- context = {} as any
17
+ context = {} as any,
18
+ draft = false
18
19
  } = {}) => {
19
20
  const browser = (await getHeadlessPool().acquire()) as any
20
21
  var screenshot = null
@@ -24,7 +25,7 @@ export const screenshot = async ({
24
25
  }
25
26
  const { domain, user } = context.state
26
27
 
27
- var { model, base } = await headlessModel({ domain, id, model })
28
+ var { model, base } = await headlessModel({ domain, id, model }, draft)
28
29
  const [fontsToUse, fontStyles] = await fonts(domain)
29
30
 
30
31
  model.fonts = fontsToUse
@@ -24,6 +24,7 @@ boardPrintRouter.post('/print', async (context, next) => {
24
24
  context.body = await printDirect(params.printerId, params.data)
25
25
  })
26
26
 
27
+ // for webpage scrap => zpl image print(grf format) command for released version board
27
28
  boardPrintRouter.get('/print-label/:id', async (context, next) => {
28
29
  const { id } = context.params
29
30
  let data = Object.keys(context.query).length ? context.query : null
@@ -37,3 +38,18 @@ boardPrintRouter.get('/print-label/:id', async (context, next) => {
37
38
  // TODO: 동기화
38
39
  context.body = printDirect(data.printerId, grf)
39
40
  })
41
+
42
+ // for webpage scrap => zpl image print(grf format) command for draft version board
43
+ boardPrintRouter.get('/print-label-draft/:id', async (context, next) => {
44
+ const { id } = context.params
45
+ let data = Object.keys(context.query).length ? context.query : null
46
+
47
+ let orientation = data && data.orientation
48
+ let mirror = data && data.mirror
49
+ let upsideDown = data && data.upsideDown
50
+ let grf = await labelcommand({ id, data, orientation, mirror, upsideDown, context, draft: true } as any)
51
+
52
+ context.type = 'text/plain'
53
+ // TODO: 동기화
54
+ context.body = printDirect(data.printerId, grf)
55
+ })
@@ -295,7 +295,7 @@ standaloneBoardServiceRouter.get('/board/pdf/:id', async (context, next) => {
295
295
  context.body = result
296
296
  })
297
297
 
298
- // for webpage scrap => zpl image print(grf format) command
298
+ // for webpage scrap => zpl image print(grf format) command for released version board
299
299
  standaloneBoardServiceRouter.get('/label-command/:id', async (context, next) => {
300
300
  const { id } = context.params
301
301
 
@@ -309,3 +309,18 @@ standaloneBoardServiceRouter.get('/label-command/:id', async (context, next) =>
309
309
  context.type = 'text/plain'
310
310
  context.body = await labelcommand({ id, data, orientation, mirror, upsideDown, context } as any)
311
311
  })
312
+
313
+ // for webpage scrap => zpl image print(grf format) command for draft version board
314
+ standaloneBoardServiceRouter.get('/label-command-draft/:id', async (context, next) => {
315
+ const { id } = context.params
316
+
317
+ const data = context.query
318
+ delete data.access_token
319
+
320
+ const orientation = data && data.orientation
321
+ const mirror = data && data.mirror
322
+ const upsideDown = data && data.upsideDown
323
+
324
+ context.type = 'text/plain'
325
+ context.body = await labelcommand({ id, data, orientation, mirror, upsideDown, context, draft: true } as any)
326
+ })