@things-factory/figure-service 10.1.278 → 10.1.279

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 (149) hide show
  1. package/package.json +23 -8
  2. package/coverage/clover.xml +0 -6
  3. package/coverage/coverage-final.json +0 -1
  4. package/coverage/lcov-report/base.css +0 -224
  5. package/coverage/lcov-report/block-navigation.js +0 -87
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +0 -101
  8. package/coverage/lcov-report/prettify.css +0 -1
  9. package/coverage/lcov-report/prettify.js +0 -2
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +0 -210
  12. package/coverage/lcov.info +0 -0
  13. package/dist-server/index.js.map +0 -1
  14. package/dist-server/migrations/index.js.map +0 -1
  15. package/dist-server/routers/figure-mesh-router.js.map +0 -1
  16. package/dist-server/routers/figure-package-router.js.map +0 -1
  17. package/dist-server/routers/figure-thumbnail-router.js.map +0 -1
  18. package/dist-server/routes.js.map +0 -1
  19. package/dist-server/service/figure/event-subscriber.js.map +0 -1
  20. package/dist-server/service/figure/figure-ai-scenarios-run.js.map +0 -1
  21. package/dist-server/service/figure/figure-ai-scenarios.js.map +0 -1
  22. package/dist-server/service/figure/figure-categories.js.map +0 -1
  23. package/dist-server/service/figure/figure-context.js.map +0 -1
  24. package/dist-server/service/figure/figure-format.js.map +0 -1
  25. package/dist-server/service/figure/figure-glb.js.map +0 -1
  26. package/dist-server/service/figure/figure-history.js.map +0 -1
  27. package/dist-server/service/figure/figure-llm-provider.js.map +0 -1
  28. package/dist-server/service/figure/figure-mesh-store.js.map +0 -1
  29. package/dist-server/service/figure/figure-mutation.js.map +0 -1
  30. package/dist-server/service/figure/figure-namespace-entity.js.map +0 -1
  31. package/dist-server/service/figure/figure-namespace-resolver.js.map +0 -1
  32. package/dist-server/service/figure/figure-namespace.js.map +0 -1
  33. package/dist-server/service/figure/figure-package-export.js.map +0 -1
  34. package/dist-server/service/figure/figure-proposal-record.js.map +0 -1
  35. package/dist-server/service/figure/figure-proposal.js.map +0 -1
  36. package/dist-server/service/figure/figure-propose-steps.js.map +0 -1
  37. package/dist-server/service/figure/figure-propose-type.js.map +0 -1
  38. package/dist-server/service/figure/figure-public.js.map +0 -1
  39. package/dist-server/service/figure/figure-query.js.map +0 -1
  40. package/dist-server/service/figure/figure-rename.js.map +0 -1
  41. package/dist-server/service/figure/figure-replaced-draft.js.map +0 -1
  42. package/dist-server/service/figure/figure-revert.js.map +0 -1
  43. package/dist-server/service/figure/figure-subject.js.map +0 -1
  44. package/dist-server/service/figure/figure-thumbnail-reader.js.map +0 -1
  45. package/dist-server/service/figure/figure-thumbnail-store.js.map +0 -1
  46. package/dist-server/service/figure/figure-thumbnail-upgrade.js.map +0 -1
  47. package/dist-server/service/figure/figure-tools.js.map +0 -1
  48. package/dist-server/service/figure/figure-type.js.map +0 -1
  49. package/dist-server/service/figure/figure-write.js.map +0 -1
  50. package/dist-server/service/figure/figure.js.map +0 -1
  51. package/dist-server/service/figure/index.js.map +0 -1
  52. package/dist-server/service/figure-recipe/figure-recipe-resolver.js.map +0 -1
  53. package/dist-server/service/figure-recipe/figure-recipe-templates.js.map +0 -1
  54. package/dist-server/service/figure-recipe/figure-recipe-type.js.map +0 -1
  55. package/dist-server/service/figure-recipe/index.js.map +0 -1
  56. package/dist-server/service/index.js.map +0 -1
  57. package/dist-server/tsconfig.tsbuildinfo +0 -1
  58. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
  59. package/logs/application-2026-09-14-23.log +0 -0
  60. package/logs/figure-ai-scenarios/2026-11-03T09-31-35-151Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1167
  61. package/logs/figure-ai-scenarios/2026-11-03T09-39-05-265Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -904
  62. package/logs/figure-ai-scenarios/2026-11-03T09-41-49-107Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1629
  63. package/logs/figure-ai-scenarios/2026-11-03T09-58-26-681Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4412
  64. package/logs/figure-ai-scenarios/2026-11-03T10-16-46-212Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4513
  65. package/logs/figure-ai-scenarios/2026-11-03T10-21-07-872Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4202
  66. package/logs/figure-ai-scenarios/2026-11-03T10-25-21-721Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1665
  67. package/logs/figure-ai-scenarios/2026-11-09T01-28-51-664Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4484
  68. package/scripts/build-templates.mts +0 -64
  69. package/scripts/figure-ai-scenarios-agent.cjs +0 -98
  70. package/scripts/rename-figures-to-full-names.mjs +0 -211
  71. package/scripts/templates.test.mts +0 -112
  72. package/server/index.ts +0 -46
  73. package/server/migrations/index.ts +0 -9
  74. package/server/routers/figure-mesh-router.ts +0 -63
  75. package/server/routers/figure-package-router.ts +0 -53
  76. package/server/routers/figure-thumbnail-router.ts +0 -159
  77. package/server/routes.ts +0 -30
  78. package/server/service/figure/catalog-db.test.ts +0 -162
  79. package/server/service/figure/event-subscriber.ts +0 -66
  80. package/server/service/figure/figure-ai-scenarios-run.ts +0 -127
  81. package/server/service/figure/figure-ai-scenarios.live.test.ts +0 -59
  82. package/server/service/figure/figure-ai-scenarios.test.ts +0 -109
  83. package/server/service/figure/figure-ai-scenarios.ts +0 -798
  84. package/server/service/figure/figure-blueprint-query.test.ts +0 -536
  85. package/server/service/figure/figure-catalog-seen-db.test.ts +0 -153
  86. package/server/service/figure/figure-categories.ts +0 -50
  87. package/server/service/figure/figure-category-db.test.ts +0 -127
  88. package/server/service/figure/figure-context.test.ts +0 -402
  89. package/server/service/figure/figure-context.ts +0 -510
  90. package/server/service/figure/figure-deprecation-db.test.ts +0 -218
  91. package/server/service/figure/figure-format.test.ts +0 -423
  92. package/server/service/figure/figure-format.ts +0 -783
  93. package/server/service/figure/figure-glb.test.ts +0 -112
  94. package/server/service/figure/figure-glb.ts +0 -251
  95. package/server/service/figure/figure-history.ts +0 -192
  96. package/server/service/figure/figure-inspect-db.test.ts +0 -131
  97. package/server/service/figure/figure-llm-provider.ts +0 -20
  98. package/server/service/figure/figure-llm-smoke.test.ts +0 -95
  99. package/server/service/figure/figure-mesh-db.test.ts +0 -246
  100. package/server/service/figure/figure-mesh-store.ts +0 -91
  101. package/server/service/figure/figure-mutation.ts +0 -656
  102. package/server/service/figure/figure-namespace-db.test.ts +0 -315
  103. package/server/service/figure/figure-namespace-entity.ts +0 -67
  104. package/server/service/figure/figure-namespace-resolver.ts +0 -54
  105. package/server/service/figure/figure-namespace.ts +0 -156
  106. package/server/service/figure/figure-package-export.ts +0 -136
  107. package/server/service/figure/figure-proposal-db.test.ts +0 -117
  108. package/server/service/figure/figure-proposal-record.ts +0 -38
  109. package/server/service/figure/figure-proposal.ts +0 -41
  110. package/server/service/figure/figure-propose-clips.test.ts +0 -69
  111. package/server/service/figure/figure-propose-steps.test.ts +0 -324
  112. package/server/service/figure/figure-propose-steps.ts +0 -354
  113. package/server/service/figure/figure-propose-type.ts +0 -46
  114. package/server/service/figure/figure-public-db.test.ts +0 -288
  115. package/server/service/figure/figure-public.ts +0 -60
  116. package/server/service/figure/figure-query.ts +0 -511
  117. package/server/service/figure/figure-release-check.test.ts +0 -63
  118. package/server/service/figure/figure-release-record-db.test.ts +0 -153
  119. package/server/service/figure/figure-release-size-db.test.ts +0 -156
  120. package/server/service/figure/figure-rename-db.test.ts +0 -237
  121. package/server/service/figure/figure-rename.test.ts +0 -117
  122. package/server/service/figure/figure-rename.ts +0 -143
  123. package/server/service/figure/figure-replaced-draft.ts +0 -99
  124. package/server/service/figure/figure-revert-db.test.ts +0 -163
  125. package/server/service/figure/figure-revert-race.pg.test.ts +0 -168
  126. package/server/service/figure/figure-revert.ts +0 -186
  127. package/server/service/figure/figure-subject.test.ts +0 -41
  128. package/server/service/figure/figure-subject.ts +0 -21
  129. package/server/service/figure/figure-thumbnail-db.test.ts +0 -279
  130. package/server/service/figure/figure-thumbnail-reader.ts +0 -20
  131. package/server/service/figure/figure-thumbnail-store.ts +0 -111
  132. package/server/service/figure/figure-thumbnail-upgrade.pg.test.ts +0 -93
  133. package/server/service/figure/figure-thumbnail-upgrade.ts +0 -70
  134. package/server/service/figure/figure-tool-doors.test.ts +0 -127
  135. package/server/service/figure/figure-tools-door-db.test.ts +0 -227
  136. package/server/service/figure/figure-tools.test.ts +0 -817
  137. package/server/service/figure/figure-tools.ts +0 -611
  138. package/server/service/figure/figure-type.ts +0 -241
  139. package/server/service/figure/figure-write.test.ts +0 -15
  140. package/server/service/figure/figure-write.ts +0 -131
  141. package/server/service/figure/figure.ts +0 -241
  142. package/server/service/figure/index.ts +0 -13
  143. package/server/service/figure-recipe/figure-recipe-resolver.ts +0 -38
  144. package/server/service/figure-recipe/figure-recipe-templates.test.ts +0 -47
  145. package/server/service/figure-recipe/figure-recipe-templates.ts +0 -70
  146. package/server/service/figure-recipe/figure-recipe-type.ts +0 -31
  147. package/server/service/figure-recipe/index.ts +0 -3
  148. package/server/service/index.ts +0 -34
  149. package/tsconfig.json +0 -14
@@ -1,218 +0,0 @@
1
- /**
2
- * Retiring a figure and its names by language (ADR-0104 decision 6), on sqlite with the history subscriber on.
3
- * A retired figure stays released and is served as before; retiring writes no history row.
4
- */
5
- import type { DataSource } from 'typeorm'
6
-
7
- const { DataSource: TypeOrmDataSource } = require('typeorm')
8
- const shell = require('@things-factory/shell')
9
- const authBase = require('@things-factory/auth-base')
10
- const settingBase = require('@things-factory/setting-base')
11
- const { createFigureAsset, addFigureBox, serializeFigureAsset, applyFigureAuthoring } = require('@hatiolab/figure-model')
12
-
13
- let FigureNamespace: any
14
- let dataSource: DataSource | null = null
15
- let Figure: any
16
- let FigureHistory: any
17
- let Subscriber: any
18
- let FigureMutation: any
19
- let assertNames: any
20
-
21
- function loadCompiled(modulePath: string): any {
22
- const { existsSync } = require('fs')
23
- const { join } = require('path')
24
- const resolved = join(__dirname, '..', '..', '..', 'dist-server', `${modulePath}.js`)
25
- if (!existsSync(resolved))
26
- throw new Error(`figure-service 산출물이 없다: ${resolved}\n먼저 빌드할 것:\n yarn workspace @things-factory/figure-service build:server`)
27
- return require(resolved)
28
- }
29
-
30
- beforeAll(async () => {
31
- Figure = loadCompiled('service/figure/figure').Figure
32
- FigureNamespace = loadCompiled('service/figure/figure-namespace-entity').FigureNamespace
33
- FigureHistory = loadCompiled('service/figure/figure-history').FigureHistory
34
- Subscriber = loadCompiled('service/figure/event-subscriber').FigureHistoryEntitySubscriber
35
- ;({ FigureMutation, assertNames } = loadCompiled('service/figure/figure-mutation'))
36
- dataSource = new TypeOrmDataSource({
37
- type: 'sqlite',
38
- database: ':memory:',
39
- synchronize: true,
40
- dropSchema: true,
41
- namingStrategy: new shell.NamingStrategy(),
42
- entities: [...shell.entities, ...authBase.entities, ...settingBase.entities, Figure, FigureHistory, FigureNamespace],
43
- subscribers: [Subscriber],
44
- logging: false
45
- })
46
- await dataSource.initialize()
47
- })
48
-
49
- afterAll(async () => {
50
- await dataSource?.destroy()
51
- dataSource = null
52
- })
53
-
54
- /** The domain's own default namespace, its subdomain, that every figure here is created and released under (G1). */
55
- async function namespaced(domain: any) {
56
- await dataSource!.getRepository(FigureNamespace).save({ domain, name: domain.subdomain, state: 'active', isDefault: true })
57
- return domain
58
- }
59
-
60
- const releasable = () => {
61
- let a = addFigureBox(createFigureAsset('Mixer'), { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } })
62
- a = applyFigureAuthoring(a, { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' } })
63
- return serializeFigureAsset(applyFigureAuthoring(a, { kind: 'set-placement', placement: 'floor' }))
64
- }
65
-
66
- let seq = 0
67
- async function released(type: string) {
68
- const name = `retire-${++seq}`
69
- const domain = await namespaced(await dataSource!.getRepository(shell.Domain).save({ name, subdomain: name }))
70
- const context = { state: { domain, user: undefined, tx: dataSource!.manager } }
71
- const figure = await dataSource!.getRepository(Figure).save({ namespace: domain.subdomain, type, name: 'mixer', source: releasable(), state: 'draft', version: 0, domain })
72
- await new FigureMutation().releaseFigure(figure.id, 'one', context)
73
- return { figure, context, domain }
74
- }
75
- const historyCount = (id: string) => dataSource!.getRepository(FigureHistory).count({ where: { originalId: id } })
76
-
77
- describe('retiring a figure', () => {
78
- it('stays released, writes no history row, and names what to use instead', async () => {
79
- const { figure, context, domain } = await released('OLD_MIXER')
80
- await dataSource!.getRepository(Figure).save({ namespace: domain.subdomain, type: 'NEW_MIXER', name: 'new', source: releasable(), state: 'draft', version: 0, domain })
81
- const retired = await new FigureMutation().setFigureDeprecation(figure.id, true, context, 'NEW_MIXER')
82
- expect([retired.deprecated, retired.supersededBy, retired.state, retired.version]).toEqual([true, 'NEW_MIXER', 'released', 1])
83
- expect(await historyCount(figure.id)).toBe(1)
84
- const back = await new FigureMutation().setFigureDeprecation(figure.id, false, context, 'NEW_MIXER')
85
- expect([back.deprecated, back.supersededBy, back.state]).toEqual([false, null, 'released'])
86
- expect(await historyCount(figure.id)).toBe(1)
87
- })
88
-
89
- it('refuses a replacement that is not there, or itself', async () => {
90
- const { figure, context } = await released('LONE_MIXER')
91
- await expect(new FigureMutation().setFigureDeprecation(figure.id, true, context, 'NOWHERE')).rejects.toThrow(/NOWHERE/)
92
- await expect(new FigureMutation().setFigureDeprecation(figure.id, true, context, 'LONE_MIXER')).rejects.toThrow(/자기 자신/)
93
- })
94
- })
95
-
96
- describe('names by language', () => {
97
- it('a language code to a name of 1-128 characters', () => {
98
- expect(() => assertNames({ en: 'Mixer', 'zh-Hans': '搅拌机' })).not.toThrow()
99
- expect(() => assertNames({ English: 'Mixer' })).toThrow(/English/)
100
- expect(() => assertNames({ en: '' })).toThrow(/en/)
101
- expect(() => assertNames({ en: 'x'.repeat(129) })).toThrow(/en/)
102
- expect(() => assertNames(['en'])).toThrow()
103
- })
104
-
105
- it('kept on the figure and copied onto the release it goes out with', async () => {
106
- const name = `names-${++seq}`
107
- const domain = await namespaced(await dataSource!.getRepository(shell.Domain).save({ name, subdomain: name }))
108
- const context = { state: { domain, user: undefined, tx: dataSource!.manager } }
109
- const figure = await dataSource!.getRepository(Figure).save({ namespace: domain.subdomain, type: 'NAMED', name: 'mixer', source: releasable(), state: 'draft', version: 0, domain })
110
- await new FigureMutation().updateFigure(figure.id, { names: { en: 'Mixer', ko: '믹서' } }, context)
111
- await new FigureMutation().releaseFigure(figure.id, 'one', context)
112
- const [row] = await dataSource!.getRepository(FigureHistory).find({ where: { originalId: figure.id } })
113
- expect(row.names).toEqual({ en: 'Mixer', ko: '믹서' })
114
- await expect(new FigureMutation().updateFigure(figure.id, { names: { English: 'x' } }, context)).rejects.toThrow(/English/)
115
- })
116
- })
117
-
118
- describe('deleting a figure', () => {
119
- const draftOnly = async (type: string) => {
120
- const name = `delete-${++seq}`
121
- const domain = await namespaced(await dataSource!.getRepository(shell.Domain).save({ name, subdomain: name }))
122
- const context = { state: { domain, user: undefined, tx: dataSource!.manager } }
123
- const figure = await dataSource!.getRepository(Figure).save({ namespace: domain.subdomain, type, name: 'mixer', source: releasable(), state: 'draft', version: 0, domain })
124
- return { figure, context }
125
- }
126
- const stillThere = (id: string) => dataSource!.getRepository(Figure).findOne({ where: { id } })
127
-
128
- it('deletes a figure that has never been released', async () => {
129
- const { figure, context } = await draftOnly('NEVER_RELEASED')
130
- expect(await new FigureMutation().deleteFigure(figure.id, context)).toBe(true)
131
- expect(await stillThere(figure.id)).toBeNull()
132
- const row = await dataSource!.getRepository(Figure).findOne({ where: { id: figure.id }, withDeleted: true })
133
- expect(row?.deletedAt).toBeTruthy()
134
- })
135
-
136
- it('refuses a released figure and leaves it and its release as they were', async () => {
137
- const { figure, context } = await released('SHIPPED_MIXER')
138
- await expect(new FigureMutation().deleteFigure(figure.id, context)).rejects.toMatchObject({
139
- code: 'figure-released-not-deletable',
140
- params: { type: 'SHIPPED_MIXER' }
141
- })
142
- expect((await stillThere(figure.id))?.version).toBe(1)
143
- expect(await historyCount(figure.id)).toBe(1)
144
- })
145
-
146
- it('refuses a released figure whose draft was edited again', async () => {
147
- const { figure, context } = await released('EDITED_MIXER')
148
- await new FigureMutation().updateFigure(figure.id, { description: 'changed after release' }, context)
149
- expect((await stillThere(figure.id))?.state).toBe('draft')
150
- await expect(new FigureMutation().deleteFigure(figure.id, context)).rejects.toMatchObject({ code: 'figure-released-not-deletable' })
151
- expect(await stillThere(figure.id)).not.toBeNull()
152
- })
153
-
154
- it('refuses by the release rows even when the figure says version 0', async () => {
155
- const { figure, context } = await released('ROWS_SAY_RELEASED')
156
- await dataSource!.getRepository(Figure).createQueryBuilder().update(Figure).set({ version: 0 }).where('id = :id', { id: figure.id }).callListeners(false).execute()
157
- await expect(new FigureMutation().deleteFigure(figure.id, context)).rejects.toMatchObject({ code: 'figure-released-not-deletable' })
158
- })
159
- })
160
-
161
- /*
162
- * A domain reads its parent's figures and writes only its own (LV figure-server design G3): updating, releasing and
163
- * retiring a parent's figure from a child domain are refused as not found, as saving its draft always was.
164
- */
165
- describe('writes stay in the domain that owns the figure', () => {
166
- async function parentAndChild() {
167
- const parent = await namespaced(await dataSource!.getRepository(shell.Domain).save({ name: `parent-${++seq}`, subdomain: `parent-${seq}` }))
168
- const saved = await dataSource!.getRepository(shell.Domain).save({ name: `child-${seq}`, subdomain: `child-${seq}`, parent })
169
- const child = await namespaced(await dataSource!.getRepository(shell.Domain).findOneOrFail({ where: { id: saved.id } }))
170
- expect(child.parentId).toBe(parent.id)
171
- const figure = await dataSource!.getRepository(Figure).save({ namespace: parent.subdomain, type: `parents-${seq}`, name: 'mixer', source: releasable(), state: 'draft', version: 0, domain: parent })
172
- const as = (domain: any) => ({ state: { domain, user: undefined, tx: dataSource!.manager } })
173
- return { figure, parentContext: as(parent), childContext: as(child) }
174
- }
175
-
176
- it('a child domain cannot update, release or retire its parent figure', async () => {
177
- const { figure, childContext } = await parentAndChild()
178
- await expect(new FigureMutation().updateFigure(figure.id, { description: 'from the child' }, childContext)).rejects.toThrow(/찾을 수 없다/)
179
- await expect(new FigureMutation().releaseFigure(figure.id, 'from the child', childContext)).rejects.toThrow(/찾을 수 없다/)
180
- await expect(new FigureMutation().setFigureDeprecation(figure.id, true, childContext)).rejects.toThrow(/찾을 수 없다/)
181
- const row = await dataSource!.getRepository(Figure).findOneOrFail({ where: { id: figure.id } })
182
- expect([row.description ?? null, row.version, row.deprecated]).toEqual([null, 0, false])
183
- expect(await historyCount(figure.id)).toBe(0)
184
- })
185
-
186
- it('the owning domain still does all three', async () => {
187
- const { figure, parentContext } = await parentAndChild()
188
- await new FigureMutation().updateFigure(figure.id, { description: 'from the owner' }, parentContext)
189
- await new FigureMutation().releaseFigure(figure.id, 'one', parentContext)
190
- const retired = await new FigureMutation().setFigureDeprecation(figure.id, true, parentContext)
191
- expect([retired.description, retired.version, retired.deprecated]).toEqual(['from the owner', 1, true])
192
- })
193
-
194
- it('a child figure may still name a parent figure to use instead', async () => {
195
- const { figure: parentFigure, childContext } = await parentAndChild()
196
- const child = childContext.state.domain
197
- const own = await dataSource!.getRepository(Figure).save({ namespace: child.subdomain, type: `childs-${seq}`, name: 'own', source: releasable(), state: 'draft', version: 0, domain: child })
198
- await new FigureMutation().releaseFigure(own.id, 'one', childContext)
199
- const retired = await new FigureMutation().setFigureDeprecation(own.id, true, childContext, parentFigure.type)
200
- expect(retired.supersededBy).toBe(parentFigure.type)
201
- })
202
- })
203
-
204
- /* Releasing and retiring are their own gate (LV figure-server design G6); editing a draft stays under figure:mutation. */
205
- describe('who may release', () => {
206
- const declarationOf = (method: string) => {
207
- const { readFileSync } = require('fs')
208
- const { join } = require('path')
209
- const source = readFileSync(join(__dirname, 'figure-mutation.ts'), 'utf-8')
210
- const preceding = source.slice(0, source.indexOf(`async ${method}(`))
211
- return preceding.slice(preceding.lastIndexOf("@Directive('@privilege("))
212
- }
213
-
214
- it('releasing and retiring ask figure-release, editing asks figure', () => {
215
- for (const method of ['releaseFigure', 'setFigureDeprecation']) expect(declarationOf(method)).toContain('category: "figure-release", privilege: "mutation"')
216
- for (const method of ['saveFigure', 'createFigure', 'updateFigure', 'deleteFigure', 'revertFigureVersion']) expect(declarationOf(method)).toContain('category: "figure", privilege: "mutation"')
217
- })
218
- })
@@ -1,423 +0,0 @@
1
- /**
2
- * figure-format — the doors a stored source goes through: save, release, hand to a board.
3
- *
4
- * What this file holds:
5
- * - the format is known from the `version` the asset carries, never guessed from its shape;
6
- * - a source that does not name the format is refused -- what cannot be identified is not stored;
7
- * - the budget columns (`triangles`, `groups`) and the score are the kernel's.
8
- */
9
- import { createFigureAsset, addFigureBox, addFigurePrimitive, serializeFigureAsset, applyFigureAuthoring, placeholderType, figureScoreOf, inspectFigureAsset } from '@hatiolab/figure-model'
10
- import type { FigureAsset } from '@hatiolab/figure-model'
11
-
12
- import { FigureSourceError, consumablePayloadOf, inspectSource, parseSource, releaseRecordOf } from './figure-format'
13
-
14
- /** 온전한 자산 하나: 바닥에 선 상자. */
15
- function figureAsset(): FigureAsset {
16
- let asset = createFigureAsset('Mixer')
17
- asset = addFigureBox(asset, { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } })
18
- asset = applyFigureAuthoring(asset, { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' } })
19
- return applyFigureAuthoring(asset, { kind: 'set-placement', placement: 'floor' })
20
- }
21
- const figureSource = () => serializeFigureAsset(figureAsset())
22
-
23
- describe('figure-format — 버전을 알아보는 문', () => {
24
- describe('버전은 자산이 적는다', () => {
25
- it('버전을 안 적은 정본은 거절한다 — 생김새로 짐작하지 않는다', () => {
26
- for (const text of [JSON.stringify({ type: 'MIXER', parts: [] }), JSON.stringify({ version: 2, type: 'MIXER', parts: [] })]) {
27
- expect(() => parseSource(text)).toThrow(FigureSourceError)
28
- try {
29
- parseSource(text)
30
- } catch (e) {
31
- expect((e as FigureSourceError).findings[0].code).toBe('source-format-unknown')
32
- }
33
- }
34
- })
35
-
36
- it('JSON 이 아니면 그 말로 거절한다', () => {
37
- try {
38
- parseSource('{')
39
- } catch (e) {
40
- expect((e as FigureSourceError).findings[0].code).toBe('source-not-json')
41
- }
42
- })
43
- })
44
-
45
- describe('저장', () => {
46
- it('예산 칸을 커널이 잰다 — 상자 하나는 삼각형 12, 묶음 1', () => {
47
- const parsed = parseSource(figureSource())
48
- expect(parsed.derived.triangles).toBe(12)
49
- expect(parsed.derived.groups).toBe(1)
50
- })
51
-
52
- it('점수 칸은 figureScoreOf 다 — 저작면의 성숙도 탭과 같은 수(수석 아키텍트 판정 09-24)', () => {
53
- const score = parseSource(figureSource()).derived.score
54
- expect(score).toBe(figureScoreOf(figureAsset())!.score)
55
- expect(score).toBeGreaterThan(0)
56
- })
57
-
58
- it('형식을 어긴 자산은 거절한다', () => {
59
- const broken = JSON.parse(figureSource())
60
- broken.appearance = []
61
- expect(() => parseSource(JSON.stringify(broken))).toThrow(FigureSourceError)
62
- })
63
- })
64
-
65
- describe('발행 판정', () => {
66
- it('온전한 자산은 막지 않는다', () => {
67
- const inspection = inspectSource(figureSource())
68
- expect(inspection.blocked).toBe(false)
69
- })
70
-
71
- it('표본으로 검사한 판정에도 다시 저작하라는 말은 없다', () => {
72
- /* 상태에 따라 도는 부품은 표본으로 검사된다. 그 사이에서 넘을 선언된 공간이 없으니 화면이 할 말도 없다(ADR-0145). */
73
- let asset = figureAsset()
74
- asset = addFigurePrimitive(asset, { id: 'wheel', kind: 'cylinder', dimensions: { radius: 20, length: 20 }, position: { x: 0, y: 20, z: 0 } })
75
- const m = asset.document.model as any
76
- m.inputs.push({ id: 'spin', unit: 'deg', min: -180, max: 180, role: 'state' })
77
- asset.stateDefaults['spin'] = 0
78
- m.constants.push({ id: 'axisY0', unit: 'ratio', value: 0 }, { id: 'axisY1', unit: 'ratio', value: 1 })
79
- m.nodes.push({
80
- id: 'wheel.turn',
81
- op: 'axis-turn@1',
82
- args: ['axisY0', 'axisY1', 'axisY0', 'spin'],
83
- outputs: { pose: 'wheel.turn.p' },
84
- params: { from: 'wheel.spun', to: 'asset' }
85
- })
86
- const pose = m.nodes.find((n: any) => n.id === 'wheel.pose')
87
- pose.params = { ...pose.params, to: 'wheel.spun' }
88
- m.nodes.push({ id: 'wheel.world', op: 'compose@1', args: ['wheel.turn.p', pose.outputs.pose], outputs: { pose: 'wheel.wp' } })
89
- m.nodes.find((n: any) => n.id === 'wheel').args = [m.nodes.find((n: any) => n.id === 'wheel.shape').outputs.shape, 'wheel.wp']
90
-
91
- expect(inspectFigureAsset(asset).coverage.method).toBe('sampled')
92
- const inspection = inspectSource(serializeFigureAsset(asset))
93
- expect(inspection.blocked).toBe(false)
94
- expect(inspection.findings).toEqual([])
95
- })
96
-
97
- it('정본이 없으면 전과 같이 그 말로 막는다', () => {
98
- expect(inspectSource(null).findings[0].code).toBe('no-source')
99
- })
100
-
101
- it('바뀐 것 없는 재발행은 아무 말도 없이 지난다', () => {
102
- const again = inspectSource(figureSource(), figureSource())
103
- expect(again.blocked).toBe(false)
104
- expect(again.findings).toEqual([])
105
- })
106
-
107
- it('놓인 인스턴스가 기대던 것을 없앤 재발행은 막는다 — 없어진 능력을 이름으로 댄다', () => {
108
- const before = figureAsset()
109
- before.document.capabilities.names = ['Holdable']
110
- const inspection = inspectSource(figureSource(), serializeFigureAsset(before))
111
- const gone = inspection.findings.find(f => f.code === 'capability-gone')
112
- expect(gone).toBeDefined()
113
- expect(gone!.blocking).toBe(true)
114
- expect(gone!.at).toBe('Holdable')
115
- expect(gone!.message).toContain('Holdable')
116
- expect(gone!.how).toBeTruthy()
117
- expect(inspection.blocked).toBe(true)
118
- })
119
-
120
- it("offers saving as a new figure type when a published contract would be broken", () => {
121
- const before = figureAsset()
122
- before.document.capabilities.names = ['Holdable']
123
- const inspection = inspectSource(figureSource(), serializeFigureAsset(before))
124
- expect(inspection.findings.find(f => f.code === 'capability-gone')!.asNewType).toBe(true)
125
- /* Something new is no break: no way to a new type offered for it */
126
- const added = inspectSource(serializeFigureAsset(before), figureSource()).findings.filter(f => !f.blocking)
127
- expect(added.every(f => f.asNewType === undefined)).toBe(true)
128
- expect(inspectSource(null).findings[0].asNewType).toBeUndefined()
129
- })
130
- })
131
-
132
- /*
133
- 이 판정은 한때 발행 패널에 영어 문장(`detail`)을 그대로 냈고 왜 · 어떻게가 없었다 — 사용자가 2026-09-19 에
134
- 「가장 큰 문제」로 짚은 모양이다. 문장은 요청의 언어를 아는 서버가 코드와 값에서 만든다(ADR-0054).
135
- */
136
- describe('판정의 문장 — 발행 패널의 말로', () => {
137
- const KO = require('../../../translations/ko.json') as Record<string, string>
138
- const EN = require('../../../translations/en.json') as Record<string, string>
139
-
140
- /** i18next 처럼 — 키가 있으면 `{이름}` 을 채우고, 없으면 defaultValue. */
141
- const translatorOf = (dict: Record<string, string>, asked: string[] = []) =>
142
- (key: string, options: Record<string, unknown> = {}) => {
143
- asked.push(key)
144
- const text = dict[key] ?? (options.defaultValue as string)
145
- return text.replace(/\{(\w+)\}/g, (_, name) => String(options[name] ?? `{${name}}`))
146
- }
147
-
148
- it('확장 속성의 키가 없어지면 발행을 막고 키 이름으로 말한다; 값이 바뀌면 알리기만 한다 (ADR-0123)', () => {
149
- const carrier = { type: 'ROLL', dimensions: { width: 1000, length: 600, height: 200 } }
150
- const withKey = applyFigureAuthoring(figureAsset(), { kind: 'set-extension', key: 'fmsim/carrier', value: carrier })
151
- const released = serializeFigureAsset(withKey)
152
-
153
- const gone = inspectSource(serializeFigureAsset(figureAsset()), released, translatorOf(KO)).findings.find(f => f.code === 'extension-gone')!
154
- expect(gone.blocking).toBe(true)
155
- expect(gone.message).toBe("'fmsim/carrier' 확장 속성이 없어졌습니다.")
156
-
157
- const changed = applyFigureAuthoring(withKey, { kind: 'set-extension', key: 'fmsim/carrier', value: { ...carrier, type: 'ROLL2' } })
158
- const said = inspectSource(serializeFigureAsset(changed), released, translatorOf(KO))
159
- const finding = said.findings.find(f => f.code === 'extension-changed')!
160
- expect(finding.blocking).toBe(false)
161
- expect(finding.message).toBe("'fmsim/carrier' 확장 속성의 값이 바뀌었습니다.")
162
- expect(said.findings.some(f => f.code === 'extension-gone')).toBe(false)
163
- })
164
-
165
- /* 첫 15분 다시 재기(10-16 저녁): 판정 문구만 옛 말 「공간 선언」을 썼다. 화면 말은 ADR-0097 §9 Q2 A 의 표다. */
166
- it('판정 문구는 화면 말을 쓴다 — 「공간 선언」은 쓰지 않는다', () => {
167
- const said = Object.entries(KO).filter(([key]) => key.startsWith('figure.gate.'))
168
- expect(said.filter(([, text]) => /공간 선언|공간을[^.]*선언/.test(text)).map(([key]) => key)).toEqual([])
169
- })
170
-
171
- /*
172
- (2026-09-24) 드라이룸 램프처럼 — 붙어 있던 부품이 피규어를 키우면 떨어진다.
173
- 여기서는 손으로 만든다: 램프의 높이가 피규어 높이(size.y)를 따라 올라가고, 몸통은 그대로다.
174
- */
175
- const splitting = () => {
176
- let asset = createFigureAsset('Lamp post')
177
- asset = addFigureBox(asset, { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } })
178
- asset = addFigureBox(asset, { id: 'lamp', size: { x: 40, y: 20, z: 40 }, position: { x: 0, y: 10, z: 0 } })
179
- const model = asset.document.model
180
- model.inputs.push({ id: 'size.y', unit: 'mm', min: 50, max: 20000, role: 'design' } as never)
181
- asset.designInputs['size.y'] = 100
182
- model.nodes.push({ id: 'lamp.lift', op: 'add@1', args: ['size.y', 'lamp.position.y'], outputs: { value: 'lamp.lift.value' } } as never)
183
- const pose = model.nodes.find(n => n.id === 'lamp.pose')!
184
- pose.args[1] = 'lamp.lift.value'
185
- return serializeFigureAsset(asset)
186
- }
187
-
188
- it('크기를 바꾸면 떨어지는 부품을 막고, 어느 부품이 어느 축에서인지 · 왜 · 어떻게를 말한다', () => {
189
- const finding = inspectSource(splitting(), null, translatorOf(KO)).findings.find(f => f.code === 'parts-split-on-resize')
190
-
191
- expect(finding?.blocking).toBe(true)
192
- expect(finding!.message).toBe("크기를 Y 로 2배로 하면 'lamp' 부품이 나머지에서 떨어집니다.")
193
- expect(finding!.why).toMatch(/부서진/)
194
- expect(finding!.how).toContain("'lamp'")
195
- expect(finding!.how).toContain('여기에 고정')
196
- expect(`${finding!.message}${finding!.why}${finding!.how}`).not.toMatch(/come away|piece/)
197
- })
198
-
199
- /* 한 비율로 커진다고 선언한 피규어에서 제 숫자를 가진 부품(수석 아키텍트 판정 2026-09-24 조건 ②). */
200
- it('한 비율로 커진다고 선언한 피규어에서 따라 커지지 않는 부품을 막고 이름을 댄다', () => {
201
- let asset = createFigureAsset('Uniform')
202
- asset = addFigureBox(asset, { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } })
203
- for (const axis of ['x', 'y', 'z']) {
204
- asset.document.model.inputs.push({ id: `size.${axis}`, unit: 'mm', min: 1, max: 20000, role: 'design' } as never)
205
- asset.designInputs[`size.${axis}`] = 100
206
- }
207
- asset = applyFigureAuthoring(asset, { kind: 'scale-uniformly' } as never)
208
- const finding = inspectSource(serializeFigureAsset(asset), null, translatorOf(KO)).findings.find(f => f.code === 'sizing-not-uniform')
209
-
210
- expect(finding?.blocking).toBe(true)
211
- expect(finding!.message).toBe("이 피규어는 한 비율로 커지는데, 크기를 X 로 2배로 하면 'body' 부품은 같이 커지지 않습니다.")
212
- expect(finding!.how).toContain('크기에 비례')
213
- })
214
-
215
- /* The server's translator is i18next with its defaults, which escape values for HTML. The panel draws text. */
216
- it('부품 이름의 따옴표가 HTML 로 바뀌지 않는다 — 서버와 같은 i18next 로', async () => {
217
- const i18next = require('i18next').createInstance()
218
- await i18next.init({
219
- lng: 'ko',
220
- resources: { ko: { translations: KO } },
221
- ns: ['translations'],
222
- defaultNS: 'translations',
223
- interpolation: { prefix: '{', suffix: '}' },
224
- keySeparator: false
225
- })
226
- const finding = inspectSource(splitting(), null, i18next.t.bind(i18next)).findings.find(f => f.code === 'parts-split-on-resize')!
227
-
228
- expect(finding.message).toBe("크기를 Y 로 2배로 하면 'lamp' 부품이 나머지에서 떨어집니다.")
229
- expect(`${finding.message}${finding.how}`).not.toContain('&#39;')
230
- })
231
-
232
- /* A particle fixed after a quoted name is wrong for half the names ('그리퍼' 이). A noun after the name is always right. */
233
- it('따옴표로 싼 이름 바로 뒤에 조사가 오지 않는다 — 이름 뒤에는 명사를 둔다', () => {
234
- const particle = /'\{[a-z]+\}'\s*(이|가|을|를|은|는|과|와|의|로|으로)(\s|$|[.,])/
235
- const bare = /\{parts\}\s*(이|가|을|를|은|는)(\s|$)/
236
- const offending = Object.entries(KO).filter(([key, text]) => key.startsWith('figure.gate.') && (particle.test(text) || bare.test(text)))
237
- expect(offending).toEqual([])
238
- })
239
-
240
- it('번역이 없으면 영어로 답한다 — 키를 찍지 않는다', () => {
241
- const finding = inspectSource(splitting()).findings.find(f => f.code === 'parts-split-on-resize')!
242
-
243
- expect(finding.message).toBe("At 2x on Y, 'lamp' come away from the rest of the figure.")
244
- expect(finding.message).not.toContain('figure.gate.')
245
- })
246
-
247
- /*
248
- 자산에는 type 이 없어 임시 이름 검사가 돌지 않았고, 새 피규어가 `FIGURE_<uuid>` 로 발행됐다(:3300, 2026-09-24).
249
- 발행하면 이름이 굳으므로 행의 type 으로 거절한다.
250
- */
251
- it('임시 이름인 피규어는 발행을 막는다 — 이름은 행에 있다', () => {
252
- /* The name a new figure gets — the format's rule, the one the gate recognises. */
253
- const placeholder = placeholderType()
254
- const finding = inspectSource(figureSource(), null, translatorOf(KO), placeholder).findings.find(f => f.code === 'type-is-placeholder')
255
-
256
- expect(finding?.blocking).toBe(true)
257
- expect(finding!.message).toBe(`'${placeholder}' 타입은 처음 저장할 때 붙은 임시 타입입니다.`)
258
- /* 화면의 칸 이름은 「타입」이다(`figure.label.figure-type`). */
259
- expect(finding!.how).toContain('타입 항목')
260
- expect(inspectSource(figureSource(), null, translatorOf(KO), 'ROLLER_CONVEYOR').blocked).toBe(false)
261
- })
262
-
263
- /* 코드가 묻는 키가 두 언어에 다 있어야 한다 — 없으면 그 언어의 화면에 영어가 섞인다. */
264
- it('판정이 묻는 키는 ko · en 에 다 있다', () => {
265
- const asked: string[] = []
266
- const t = translatorOf(KO, asked)
267
- inspectSource(splitting(), null, t)
268
- const raised = addFigureBox(createFigureAsset('Raised'), { id: 'body', size: { x: 100, y: 100, z: 100 }, position: { x: 0, y: 150, z: 0 } })
269
- inspectSource(serializeFigureAsset(applyFigureAuthoring(raised, { kind: 'set-mounting-face', part: 'body', face: 'bottom' })), null, t)
270
- inspectSource(figureSource(), figureSource(), t)
271
- inspectSource(figureSource(), null, t, 'FIGURE_ABCDEF12')
272
-
273
- const keys = [...new Set(asked)]
274
- expect(keys.length).toBeGreaterThan(5)
275
- expect(keys.filter(k => !(k in KO))).toEqual([])
276
- expect(keys.filter(k => !(k in EN))).toEqual([])
277
- })
278
- })
279
-
280
- describe('소비처', () => {
281
- it('자산을 그대로 받는다 — 그리는 쪽이 커널로 컴파일한다', () => {
282
- const payload = consumablePayloadOf(figureSource())
283
- expect(payload.asset.version).toBe('figure-asset-1')
284
- })
285
-
286
- it('컴파일되지 않는 자산은 소비처에 넘기지 않고 던진다', () => {
287
- const broken = JSON.parse(figureSource())
288
- broken.designInputs = {}
289
- expect(() => consumablePayloadOf(JSON.stringify(broken))).toThrow()
290
- })
291
- })
292
-
293
- /* ADR-0104 decision 5: a release records its format and what changed against the last one, once, as it was then. */
294
- describe('발행이 스스로 남기는 것 — 형식과 직전 버전에 견준 변경', () => {
295
- const wider = () => {
296
- let asset = createFigureAsset('Mixer')
297
- asset = addFigureBox(asset, { id: 'body', size: { x: 300, y: 100, z: 100 }, position: { x: 0, y: 50, z: 0 } })
298
- asset = applyFigureAuthoring(asset, { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' } })
299
- return serializeFigureAsset(applyFigureAuthoring(asset, { kind: 'set-placement', placement: 'floor' }))
300
- }
301
- it('a first release: its format, and nothing changed', () => {
302
- const record = releaseRecordOf(serializeFigureAsset(figureAsset()))
303
- expect([record.format, record.changes]).toEqual(['figure-asset-1', []])
304
- /* Not sized from the instance: nothing measured across sizes, only its body and the room it sweeps. Its plan is its one body from above. */
305
- const box = { x: { min: -50, max: 50 }, y: { min: 0, max: 100 }, z: { min: -50, max: 50 } }
306
- expect(record.metrics).toEqual({ body: box, motionRange: box })
307
- expect(record.topView.shapes.map(s => s.id)).toEqual(['body'])
308
- expect(record.topView.size).toBeNull()
309
- })
310
- it('the same again changes nothing; a wider body is said and does not block', () => {
311
- const v1 = serializeFigureAsset(figureAsset())
312
- expect(releaseRecordOf(v1, v1).changes).toEqual([])
313
- const size = releaseRecordOf(wider(), v1).changes!.find(c => c.code === 'size-changed')!
314
- expect(size.blocking).toBe(false)
315
- expect(String(size.values.after)).toMatch(/x -150…150/)
316
- })
317
- it('a last release that cannot be read is "not compared" (null), never "nothing changed" ([])', () => {
318
- expect(releaseRecordOf(serializeFigureAsset(figureAsset()), '{ not json').changes).toBeNull()
319
- })
320
- it('every new change has its sentence in both languages', () => {
321
- const KO = require('../../../translations/ko.json') as Record<string, string>
322
- const EN = require('../../../translations/en.json') as Record<string, string>
323
- for (const code of ['size-changed', 'motion-range-changed', 'contact-face-changed', 'public-input-gone', 'public-input-range-narrowed', 'public-input-added', 'state-input-joints-changed', 'joint-axis-changed', 'joint-motion-unit-changed', 'joint-child-changed', 'joint-list-unread', 'extension-gone', 'extension-changed', 'extension-added'])
324
- for (const dict of [KO, EN]) for (const field of ['message', 'why']) expect(dict[`figure.gate.contract.${code}.${field}`]).toBeTruthy()
325
- })
326
- it('what a legend leans on has its sentences in all six languages (ADR-0166 14)', () => {
327
- const codes = ['data-table-gone', 'data-table-target-withdrawn', 'data-table-added', 'data-table-target-added', 'data-table-changed', 'data-table-role-changed']
328
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
329
- const dict = require(`../../../translations/${lang}.json`) as Record<string, string>
330
- for (const code of codes) for (const field of ['message', 'why']) expect([lang, code, field, !!dict[`figure.gate.contract.${code}.${field}`]]).toEqual([lang, code, field, true])
331
- }
332
- })
333
- it('the data changes have their sentences under figure-model 0.6.6\'s codes, in all six languages', () => {
334
- /* 0.6.6 named them for data fields and bindings (data interface 2); a sentence under the old code is never found. */
335
- const codes = ['data-field-gone', 'data-field-kind-changed', 'data-field-narrowed', 'data-field-added', 'data-field-label-changed', 'data-field-default-changed', 'data-bindings-changed']
336
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
337
- const dict = require(`../../../translations/${lang}.json`) as Record<string, string>
338
- for (const code of codes) for (const field of ['message', 'why']) expect([lang, code, field, !!dict[`figure.gate.contract.${code}.${field}`]]).toEqual([lang, code, field, true])
339
- }
340
- })
341
- })
342
-
343
- /* The walk of 2026-10-18: a figure off its mounting plane passed release with no word. Said now, never refused. */
344
- describe('a figure off the plane it is mounted on', () => {
345
- const conveyor = (legBottom: number, placement: 'floor' | 'ceiling' | 'wall' | 'center' = 'floor') => {
346
- let a = applyFigureAuthoring(createFigureAsset('Conveyor'), { kind: 'set-placement', placement })
347
- a = addFigureBox(a, { id: 'bed', size: { x: 3000, y: 100, z: 800 }, position: { x: 0, y: legBottom + 750, z: 0 } })
348
- a = addFigureBox(a, { id: 'leg', size: { x: 60, y: 700, z: 60 }, position: { x: 0, y: legBottom + 350, z: 0 } })
349
- return applyFigureAuthoring(a, { kind: 'attach', part: 'leg', to: { part: 'bed', face: 'bottom' } })
350
- }
351
- const offPlane = (asset: ReturnType<typeof conveyor>) =>
352
- inspectSource(serializeFigureAsset(asset), null, undefined, 'CONVEYOR').findings.filter(f => f.code === 'off-mounting-plane')
353
-
354
- it('100 mm in the air: named by its lowest part, and the release goes on', () => {
355
- const [found, ...more] = offPlane(conveyor(100))
356
- expect(more).toEqual([])
357
- expect(found.blocking).toBe(false)
358
- expect(found.at).toBe('leg')
359
- expect(found.message).toBe("'leg' is 100 mm above the floor.")
360
- })
361
- it('standing on the floor says nothing; nor does a centred figure', () => {
362
- expect(offPlane(conveyor(0))).toEqual([])
363
- expect(offPlane(conveyor(100, 'center'))).toEqual([])
364
- })
365
- it('every part below the floor asks whether it hangs from the ceiling', () => {
366
- const [found] = offPlane(conveyor(-2000))
367
- expect(found.message).toBe('Every part is below the floor.')
368
- expect(found.how).toBe('If it hangs from the ceiling, set where it stands to the ceiling.')
369
- })
370
- it('a figure that names its mounting face is checked on that face, not told twice', () => {
371
- let a = conveyor(100)
372
- a = applyFigureAuthoring(a, { kind: 'set-mounting-face', part: 'leg', face: 'bottom' })
373
- const found = inspectSource(serializeFigureAsset(a), null, undefined, 'CONVEYOR').findings
374
- expect(found.map(f => f.code)).not.toContain('off-mounting-plane')
375
- expect(found.map(f => f.code)).toContain('parts-off-placement-face')
376
- })
377
- it('its sentences are in all six languages', () => {
378
- const keys = ['floor', 'ceiling', 'wall'].flatMap(p => [...['clear', 'through', 'beyond'].map(k => `${p}.${k}.message`), `${p}.why`, `${p}.beyond.how`]).concat('how')
379
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
380
- const dict = require(`../../../translations/${lang}.json`) as Record<string, string>
381
- for (const key of keys) expect([lang, key, !!dict[`figure.gate.off-mounting-plane.${key}`]]).toEqual([lang, key, true])
382
- }
383
- })
384
- })
385
-
386
- /* ADR-0155 amendment 2: a figure tagged as an item is told what it lacks for a seat, never refused. */
387
- describe('a figure tagged as an item', () => {
388
- const reel = () => {
389
- let a = applyFigureAuthoring(createFigureAsset('Reel'), { kind: 'set-placement', placement: 'floor' })
390
- a = addFigureBox(a, { id: 'body', size: { x: 760, y: 840, z: 840 }, position: { x: 0, y: 420, z: 0 } })
391
- return applyFigureAuthoring(a, { kind: 'set-item', item: true })
392
- }
393
- const itemNotes = (asset: FigureAsset) =>
394
- inspectSource(serializeFigureAsset(asset), null, undefined, 'REEL').findings.filter(f => f.code.startsWith('item-'))
395
-
396
- it('with no mounting face and no size inputs is told both, and the release goes on', () => {
397
- const found = itemNotes(reel())
398
- expect(found.map(f => [f.code, f.blocking])).toEqual([['item-mounting-face-missing', false], ['item-size-inputs-missing', false]])
399
- expect(found[0].message).toBe('This item names no mounting face.')
400
- /* Said of the figure, never of a part: the panel lists `at` under the parts it touches. */
401
- expect(found.map(f => f.at)).toEqual([undefined, undefined])
402
- })
403
- it('a figure that is no item is told nothing', () => {
404
- expect(itemNotes(applyFigureAuthoring(reel(), { kind: 'set-item', item: false }))).toEqual([])
405
- })
406
- it('a tag that goes refuses the release; one that comes is said', () => {
407
- const tagged = serializeFigureAsset(reel())
408
- const untagged = serializeFigureAsset(applyFigureAuthoring(reel(), { kind: 'set-item', item: false }))
409
- const gone = inspectSource(untagged, tagged, undefined, 'REEL').findings.find(f => f.code === 'item-gone')!
410
- expect([gone.blocking, gone.message]).toEqual([true, 'The figure is no longer an item.'])
411
- const added = inspectSource(tagged, untagged, undefined, 'REEL').findings.find(f => f.code === 'item-added')!
412
- expect(added.blocking).toBe(false)
413
- })
414
- it('its sentences are in all six languages', () => {
415
- const keys = ['item-mounting-face-missing', 'item-size-inputs-missing', 'item-also-holder'].flatMap(code => ['message', 'why', 'how'].map(field => `figure.gate.${code}.${field}`))
416
- .concat(['item-gone', 'item-added'].flatMap(code => ['message', 'why'].map(field => `figure.gate.contract.${code}.${field}`)))
417
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
418
- const dict = require(`../../../translations/${lang}.json`) as Record<string, string>
419
- for (const key of keys) expect([lang, key, !!dict[key]]).toEqual([lang, key, true])
420
- }
421
- })
422
- })
423
- })