@things-factory/figure-service 10.1.113 → 10.1.115

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/figure-service",
3
- "version": "10.1.113",
3
+ "version": "10.1.115",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "@things-factory:registry": "https://registry.npmjs.org"
@@ -25,9 +25,9 @@
25
25
  "test:templates": "node --test scripts/templates.test.mts"
26
26
  },
27
27
  "dependencies": {
28
- "@hatiolab/figure-model": "^0.2.10",
28
+ "@hatiolab/figure-model": "^0.2.15",
29
29
  "@operato/typeorm-history": "^10.0.0",
30
- "@things-factory/ai-client-base": "^10.1.81",
30
+ "@things-factory/ai-client-base": "^10.1.114",
31
31
  "@things-factory/attachment-base": "^10.1.113",
32
32
  "@things-factory/auth-base": "^10.1.113",
33
33
  "@things-factory/env": "^10.1.20",
@@ -36,5 +36,5 @@
36
36
  "graphql-upload": "^15.0.2",
37
37
  "koa-router": "^7.4.0"
38
38
  },
39
- "gitHead": "9da1e467ddce23e600e64f08454289cb3b806212"
39
+ "gitHead": "3d1f480028b680a6da3d0ae6a73c3121d644b64a"
40
40
  }
@@ -14,7 +14,7 @@ import { FigureHistory } from './figure-history.js'
14
14
  *
15
15
  * 발행 메모는 Figure 의 칸이 아니다. `releaseFigure` 가 저장할 엔티티에 `__releaseComment` 로 얹어
16
16
  * 두면 여기서 판본의 `comment` 로 옮긴다 — 메모는 그 판의 것이지 도형의 것이 아니다. 정본 형식
17
- * (`__releaseFormat`), 직전 판에 견준 변경(`__releaseChanges`), 발행 때 잰 값(`__releaseMetrics`)과
17
+ * (`__releaseFormat`), 잰 커널의 판(`__releaseKernel`, ADR-0109 C1), 직전 판에 견준 변경(`__releaseChanges`), 발행 때 잰 값(`__releaseMetrics`)과
18
18
  * 윗모습(`__releaseTopView`)도 같은 길로 옮긴다(ADR-0104).
19
19
  */
20
20
  /** What `releaseFigure` laid on the entity for this release, moved onto the history row. */
@@ -22,6 +22,7 @@ function releaseRecordOnto(history: FigureHistory, entity: Figure): FigureHistor
22
22
  const e = entity as any
23
23
  ;(history as any).comment = e.__releaseComment ?? null
24
24
  history.assetFormat = e.__releaseFormat ?? null
25
+ history.kernelVersion = e.__releaseKernel ?? null
25
26
  /* [] stays "[]" (nothing changed); null stays null (not compared). */
26
27
  history.changes = e.__releaseChanges == null ? null : JSON.stringify(e.__releaseChanges)
27
28
  history.metrics = e.__releaseMetrics == null ? null : JSON.stringify(e.__releaseMetrics)
@@ -3,7 +3,7 @@
3
3
  * board (`consumablePayloadOf`). The format is `figure-asset-1`, and the asset says so in its `version`; a source
4
4
  * that does not is refused by name, because a source the server cannot identify is one it must not save.
5
5
  */
6
- import { compileFigureAsset, inspectFigureAsset, isPlaceholderType, parseFigureAsset, serializeFigureAsset, figureContractChanges, figureCostOf, figureOriginCentredOf, figureReleaseMetricsOf, figureScoreOf, figureTopViewOf } from '@hatiolab/figure-model'
6
+ import { FIGURE_KERNEL_VERSION, compileFigureAsset, inspectFigureAsset, isPlaceholderType, parseFigureAsset, serializeFigureAsset, figureContractChanges, figureCostOf, figureOriginCentredOf, figureReleaseMetricsOf, figureScoreOf, figureTopViewOf } from '@hatiolab/figure-model'
7
7
  import type { FigureAsset, FigureContractChange, FigureContractError, FigureReleaseMetrics, FigureTopView, FigureViolation } from '@hatiolab/figure-model'
8
8
 
9
9
  import type { FigureFinding } from './figure-type.js'
@@ -473,9 +473,9 @@ function figureContractWording(change: FigureContractChange, say: Say): Pick<Gat
473
473
  export function releaseRecordOf(
474
474
  sourceJson: string,
475
475
  releasedJson?: string | null
476
- ): { format: string; changes: FigureContractChange[] | null; metrics: FigureReleaseMetrics; topView: FigureTopView } {
476
+ ): { format: string; kernel: string; changes: FigureContractChange[] | null; metrics: FigureReleaseMetrics; topView: FigureTopView } {
477
477
  const asset = parseFigureAsset(sourceJson)
478
- const measured = { format: asset.version, metrics: figureReleaseMetricsOf(asset), topView: figureTopViewOf(asset, null) }
478
+ const measured = { format: asset.version, kernel: FIGURE_KERNEL_VERSION, metrics: figureReleaseMetricsOf(asset), topView: figureTopViewOf(asset, null) }
479
479
  if (!releasedJson) return { ...measured, changes: [] }
480
480
  let before: FigureAsset
481
481
  try {
@@ -124,6 +124,19 @@ export class FigureHistory implements HistoryEntityInterface<Figure> {
124
124
  })
125
125
  changes?: string
126
126
 
127
+ /*
128
+ * 이 판을 잰 커널의 판(figure-model `FIGURE_KERNEL_VERSION`). 점수 · 묶음 · metrics 는 그 커널의 규칙으로 센 값이다 —
129
+ * 규칙이 바뀌어도 발행된 값을 다시 세서 덮지 않고(ADR-0109 C1), 읽는 쪽은 이 칸으로 「남긴 값」과 「지금 규칙의 값」을
130
+ * 가른다. 이 칸이 생기기 전에 발행된 판은 비어 있다.
131
+ */
132
+ @Column({ nullable: true })
133
+ @Field({
134
+ nullable: true,
135
+ description:
136
+ 'The figure-model kernel version that measured this release (score, groups, metrics). null for releases made before releases recorded it.'
137
+ })
138
+ kernelVersion?: string
139
+
127
140
  @Column({ nullable: true, ...longTextColumn() })
128
141
  @Field({
129
142
  nullable: true,
@@ -348,9 +348,10 @@ export class FigureMutation {
348
348
  version: nextVersion,
349
349
  state: 'released',
350
350
  updater: user,
351
- /* 판본 구독자가 이것들을 판본의 comment · assetFormat · changes 로 옮긴다. Figure 의 칸이 아니다. */
351
+ /* 판본 구독자가 이것들을 판본의 comment · assetFormat · kernelVersion · changes 로 옮긴다. Figure 의 칸이 아니다. */
352
352
  __releaseComment: comment ?? null,
353
353
  __releaseFormat: record.format,
354
+ __releaseKernel: record.kernel,
354
355
  __releaseChanges: record.changes,
355
356
  __releaseMetrics: record.metrics,
356
357
  __releaseTopView: record.topView
@@ -7,7 +7,7 @@ import type { DataSource } from 'typeorm'
7
7
  const { DataSource: TypeOrmDataSource } = require('typeorm')
8
8
  const shell = require('@things-factory/shell')
9
9
  const authBase = require('@things-factory/auth-base')
10
- const { createFigureAsset, addFigureBox, serializeFigureAsset, applyFigureAuthoring, proposeFigureOccupancy } = require('@hatiolab/figure-model')
10
+ const { createFigureAsset, addFigureBox, serializeFigureAsset, applyFigureAuthoring, proposeFigureOccupancy, FIGURE_KERNEL_VERSION } = require('@hatiolab/figure-model')
11
11
 
12
12
  let dataSource: DataSource | null = null
13
13
  let Figure: any
@@ -65,6 +65,8 @@ describe('a release record on its history row', () => {
65
65
  expect(row.comment).toBe('first')
66
66
  expect(row.metrics).toBeNull()
67
67
  expect(row.topView).toBeNull()
68
+ /* A row the release did not stamp says so: not measured by a known kernel, rather than by today's. */
69
+ expect(row.kernelVersion).toBeNull()
68
70
  })
69
71
  it('[] stays nothing changed, null stays not compared', async () => {
70
72
  expect((await release({ __releaseFormat: 'figure-asset-1', __releaseChanges: [] })).changes).toBe('[]')
@@ -90,6 +92,8 @@ describe('releaseFigure records it', () => {
90
92
  const rows = await dataSource!.getRepository(FigureHistory).find({ where: { originalId: figure.id }, order: { version: 'ASC' } })
91
93
  expect(rows.map((r: any) => [r.version, r.assetFormat, r.comment])).toEqual([[1, 'figure-asset-1', 'one'], [2, 'figure-asset-1', 'two']])
92
94
  expect(rows[0].changes).toBe('[]')
95
+ /* Each release names the kernel that measured it (ADR-0109 C1). */
96
+ expect(rows.map((r: any) => r.kernelVersion)).toEqual([FIGURE_KERNEL_VERSION, FIGURE_KERNEL_VERSION])
93
97
  const codes = JSON.parse(rows[1].changes).map((c: any) => c.code)
94
98
  expect(codes).toContain('occupancy-changed')
95
99
  /* What each release measured, and its plan from above, are on its own row. */