@things-factory/figure-service 10.1.298 → 10.1.302

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 (341) hide show
  1. package/dist-server/routers/figure-thumbnail-router.js +28 -0
  2. package/dist-server/service/figure/figure-catalog.d.ts +28 -0
  3. package/dist-server/service/figure/figure-catalog.js +72 -0
  4. package/dist-server/service/figure/figure-context.d.ts +12 -2
  5. package/dist-server/service/figure/figure-context.js +50 -10
  6. package/dist-server/service/figure/figure-format.js +42 -0
  7. package/dist-server/service/figure/figure-mutation.js +17 -5
  8. package/dist-server/service/figure/figure-propose-steps.d.ts +7 -2
  9. package/dist-server/service/figure/figure-propose-steps.js +16 -8
  10. package/dist-server/service/figure/figure-query.d.ts +1 -1
  11. package/dist-server/service/figure/figure-query.js +10 -5
  12. package/dist-server/service/figure/figure-tools.js +10 -3
  13. package/dist-server/service/figure/figure-type.d.ts +1 -1
  14. package/dist-server/service/figure/figure-type.js +4 -4
  15. package/dist-server/service/figure-recipe/figure-catalog-of.d.ts +8 -0
  16. package/dist-server/service/figure-recipe/figure-catalog-of.js +29 -0
  17. package/dist-server/service/figure-recipe/figure-recipe-resolver.d.ts +5 -2
  18. package/dist-server/service/figure-recipe/figure-recipe-resolver.js +76 -5
  19. package/dist-server/service/figure-recipe/figure-recipe-type.d.ts +14 -0
  20. package/dist-server/service/figure-recipe/figure-recipe-type.js +55 -1
  21. package/dist-server/service/figure-recipe/figure-shelf-recipe.d.ts +25 -0
  22. package/dist-server/service/figure-recipe/figure-shelf-recipe.js +99 -0
  23. package/dist-server/service/figure-recipe/figure-shelf.d.ts +27 -0
  24. package/dist-server/service/figure-recipe/figure-shelf.js +72 -0
  25. package/dist-server/service/figure-recipe/index.d.ts +2 -0
  26. package/dist-server/service/figure-recipe/index.js +3 -1
  27. package/dist-server/service/index.d.ts +3 -1
  28. package/dist-server/service/index.js +7 -2
  29. package/package.json +8 -8
  30. package/recipes/air-cylinder/guide.ko.md +1 -1
  31. package/recipes/air-cylinder/recipe.json +1 -1
  32. package/recipes/air-cylinder/spec.json +1 -1
  33. package/recipes/air-shower/guide.ko.md +1 -1
  34. package/recipes/air-shower/recipe.json +1 -1
  35. package/recipes/air-shower/spec.json +1 -1
  36. package/recipes/barrier-gate/guide.ko.md +1 -1
  37. package/recipes/barrier-gate/recipe.json +1 -1
  38. package/recipes/barrier-gate/spec.json +1 -1
  39. package/recipes/base-frame/guide.ko.md +1 -1
  40. package/recipes/base-frame/recipe.json +1 -1
  41. package/recipes/base-frame/spec.json +1 -1
  42. package/recipes/belt-surface/guide.ko.md +1 -1
  43. package/recipes/belt-surface/recipe.json +1 -1
  44. package/recipes/belt-surface/spec.json +1 -1
  45. package/recipes/bin-row/guide.ko.md +1 -1
  46. package/recipes/bin-row/recipe.json +1 -1
  47. package/recipes/bin-row/spec.json +1 -1
  48. package/recipes/bollard-row/guide.ko.md +1 -1
  49. package/recipes/bollard-row/recipe.json +1 -1
  50. package/recipes/bollard-row/spec.json +1 -1
  51. package/recipes/buzzer/guide.ko.md +1 -1
  52. package/recipes/buzzer/recipe.json +1 -1
  53. package/recipes/buzzer/spec.json +1 -1
  54. package/recipes/cabinet-doors/guide.ko.md +2 -2
  55. package/recipes/cabinet-doors/recipe.json +1 -1
  56. package/recipes/cabinet-doors/spec.json +1 -1
  57. package/recipes/cable-tray/guide.ko.md +1 -1
  58. package/recipes/cable-tray/recipe.json +1 -1
  59. package/recipes/cable-tray/spec.json +1 -1
  60. package/recipes/camera-mount/guide.ko.md +1 -1
  61. package/recipes/camera-mount/recipe.json +1 -1
  62. package/recipes/camera-mount/spec.json +1 -1
  63. package/recipes/canopy/guide.ko.md +1 -1
  64. package/recipes/canopy/recipe.json +1 -1
  65. package/recipes/canopy/spec.json +1 -1
  66. package/recipes/cart/guide.ko.md +1 -1
  67. package/recipes/cart/recipe.json +1 -1
  68. package/recipes/cart/spec.json +1 -1
  69. package/recipes/cart-handle/guide.ko.md +1 -1
  70. package/recipes/cart-handle/recipe.json +1 -1
  71. package/recipes/cart-handle/spec.json +1 -1
  72. package/recipes/casters-four/guide.ko.md +1 -1
  73. package/recipes/casters-four/recipe.json +1 -1
  74. package/recipes/casters-four/spec.json +1 -1
  75. package/recipes/ceiling-rail-carriage/guide.ko.md +1 -1
  76. package/recipes/ceiling-rail-carriage/recipe.json +1 -1
  77. package/recipes/ceiling-rail-carriage/spec.json +1 -1
  78. package/recipes/chain-rails/guide.ko.md +1 -1
  79. package/recipes/chain-rails/recipe.json +1 -1
  80. package/recipes/chain-rails/spec.json +1 -1
  81. package/recipes/charging-station/guide.ko.md +1 -1
  82. package/recipes/charging-station/recipe.json +1 -1
  83. package/recipes/charging-station/spec.json +1 -1
  84. package/recipes/column-row/guide.ko.md +1 -1
  85. package/recipes/column-row/recipe.json +1 -1
  86. package/recipes/column-row/spec.json +1 -1
  87. package/recipes/control-cabinet/guide.ko.md +1 -1
  88. package/recipes/control-cabinet/recipe.json +1 -1
  89. package/recipes/control-cabinet/spec.json +1 -1
  90. package/recipes/conveyor-skirts/guide.ko.md +1 -1
  91. package/recipes/conveyor-skirts/recipe.json +1 -1
  92. package/recipes/conveyor-skirts/spec.json +1 -1
  93. package/recipes/counter-display/guide.ko.md +1 -1
  94. package/recipes/counter-display/recipe.json +1 -1
  95. package/recipes/counter-display/spec.json +1 -1
  96. package/recipes/dock-bumpers/guide.ko.md +1 -1
  97. package/recipes/dock-bumpers/recipe.json +1 -1
  98. package/recipes/dock-bumpers/spec.json +1 -1
  99. package/recipes/dock-leveler/guide.ko.md +1 -1
  100. package/recipes/dock-leveler/recipe.json +1 -1
  101. package/recipes/dock-leveler/spec.json +1 -1
  102. package/recipes/double-hinged-door/guide.ko.md +1 -1
  103. package/recipes/double-hinged-door/recipe.json +3 -3
  104. package/recipes/double-hinged-door/spec.json +3 -3
  105. package/recipes/drawer-stack/guide.ko.md +2 -2
  106. package/recipes/drawer-stack/recipe.json +1 -1
  107. package/recipes/drawer-stack/spec.json +1 -1
  108. package/recipes/drip-tray/guide.ko.md +1 -1
  109. package/recipes/drip-tray/recipe.json +1 -1
  110. package/recipes/drip-tray/spec.json +1 -1
  111. package/recipes/duct-fan/guide.ko.md +1 -1
  112. package/recipes/duct-fan/recipe.json +1 -1
  113. package/recipes/duct-fan/spec.json +1 -1
  114. package/recipes/emergency-stop/guide.ko.md +1 -1
  115. package/recipes/emergency-stop/recipe.json +1 -1
  116. package/recipes/emergency-stop/spec.json +1 -1
  117. package/recipes/end-covers/guide.ko.md +1 -1
  118. package/recipes/end-covers/recipe.json +1 -1
  119. package/recipes/end-covers/spec.json +1 -1
  120. package/recipes/ffu-row/guide.ko.md +1 -1
  121. package/recipes/ffu-row/recipe.json +1 -1
  122. package/recipes/ffu-row/spec.json +1 -1
  123. package/recipes/fire-extinguisher/guide.ko.md +1 -1
  124. package/recipes/fire-extinguisher/recipe.json +1 -1
  125. package/recipes/fire-extinguisher/spec.json +1 -1
  126. package/recipes/first-aid-box/guide.ko.md +1 -1
  127. package/recipes/first-aid-box/recipe.json +1 -1
  128. package/recipes/first-aid-box/spec.json +1 -1
  129. package/recipes/floor-zone/guide.ko.md +1 -1
  130. package/recipes/floor-zone/recipe.json +1 -1
  131. package/recipes/floor-zone/spec.json +1 -1
  132. package/recipes/folding-door/guide.ko.md +1 -1
  133. package/recipes/folding-door/recipe.json +2 -2
  134. package/recipes/folding-door/spec.json +2 -2
  135. package/recipes/fork/guide.ko.md +1 -1
  136. package/recipes/fork/recipe.json +1 -1
  137. package/recipes/fork/spec.json +1 -1
  138. package/recipes/gantry-frame/guide.ko.md +1 -1
  139. package/recipes/gantry-frame/recipe.json +1 -1
  140. package/recipes/gantry-frame/spec.json +1 -1
  141. package/recipes/gripper-2f/guide.ko.md +1 -1
  142. package/recipes/gripper-2f/recipe.json +1 -1
  143. package/recipes/gripper-2f/spec.json +1 -1
  144. package/recipes/guard-cover/guide.ko.md +1 -1
  145. package/recipes/guard-cover/recipe.json +1 -1
  146. package/recipes/guard-cover/spec.json +1 -1
  147. package/recipes/handrail/guide.ko.md +1 -1
  148. package/recipes/handrail/recipe.json +1 -1
  149. package/recipes/handrail/spec.json +1 -1
  150. package/recipes/hatch/guide.ko.md +1 -1
  151. package/recipes/hatch/recipe.json +3 -3
  152. package/recipes/hatch/spec.json +3 -3
  153. package/recipes/hinged-door/facts.md +6 -6
  154. package/recipes/hinged-door/guide.ko.md +2 -2
  155. package/recipes/hinged-door/recipe.json +3 -3
  156. package/recipes/hinged-door/spec.json +3 -3
  157. package/recipes/hmi-monitor/guide.ko.md +1 -1
  158. package/recipes/hmi-monitor/recipe.json +1 -1
  159. package/recipes/hmi-monitor/spec.json +1 -1
  160. package/recipes/hopper/guide.ko.md +1 -1
  161. package/recipes/hopper/recipe.json +1 -1
  162. package/recipes/hopper/spec.json +1 -1
  163. package/recipes/interlock-switch/guide.ko.md +1 -1
  164. package/recipes/interlock-switch/recipe.json +1 -1
  165. package/recipes/interlock-switch/spec.json +1 -1
  166. package/recipes/junction-box/guide.ko.md +1 -1
  167. package/recipes/junction-box/recipe.json +1 -1
  168. package/recipes/junction-box/spec.json +1 -1
  169. package/recipes/ladder/guide.ko.md +1 -1
  170. package/recipes/ladder/recipe.json +1 -1
  171. package/recipes/ladder/spec.json +1 -1
  172. package/recipes/legs-four/guide.ko.md +1 -1
  173. package/recipes/legs-four/recipe.json +1 -1
  174. package/recipes/legs-four/spec.json +1 -1
  175. package/recipes/leveling-feet/guide.ko.md +1 -1
  176. package/recipes/leveling-feet/recipe.json +1 -1
  177. package/recipes/leveling-feet/spec.json +1 -1
  178. package/recipes/lift-updown/guide.ko.md +1 -1
  179. package/recipes/lift-updown/recipe.json +1 -1
  180. package/recipes/lift-updown/spec.json +1 -1
  181. package/recipes/light-curtain/guide.ko.md +1 -1
  182. package/recipes/light-curtain/recipe.json +1 -1
  183. package/recipes/light-curtain/spec.json +1 -1
  184. package/recipes/limit-switch/guide.ko.md +1 -1
  185. package/recipes/limit-switch/recipe.json +1 -1
  186. package/recipes/limit-switch/spec.json +1 -1
  187. package/recipes/linear-guide/guide.ko.md +1 -1
  188. package/recipes/linear-guide/recipe.json +1 -1
  189. package/recipes/linear-guide/spec.json +1 -1
  190. package/recipes/locker-row/guide.ko.md +1 -1
  191. package/recipes/locker-row/recipe.json +1 -1
  192. package/recipes/locker-row/spec.json +1 -1
  193. package/recipes/motor-box/guide.ko.md +1 -1
  194. package/recipes/motor-box/recipe.json +1 -1
  195. package/recipes/motor-box/spec.json +1 -1
  196. package/recipes/observation-window/guide.ko.md +1 -1
  197. package/recipes/observation-window/recipe.json +3 -3
  198. package/recipes/observation-window/spec.json +3 -3
  199. package/recipes/operator-panel/guide.ko.md +2 -2
  200. package/recipes/operator-panel/recipe.json +1 -1
  201. package/recipes/operator-panel/spec.json +1 -1
  202. package/recipes/pallet/guide.ko.md +1 -1
  203. package/recipes/pallet/recipe.json +1 -1
  204. package/recipes/pallet/spec.json +1 -1
  205. package/recipes/partition-wall/guide.ko.md +1 -1
  206. package/recipes/partition-wall/recipe.json +1 -1
  207. package/recipes/partition-wall/spec.json +1 -1
  208. package/recipes/pass-box/guide.ko.md +1 -1
  209. package/recipes/pass-box/recipe.json +1 -1
  210. package/recipes/pass-box/spec.json +1 -1
  211. package/recipes/peg-board/guide.ko.md +1 -1
  212. package/recipes/peg-board/recipe.json +1 -1
  213. package/recipes/peg-board/spec.json +1 -1
  214. package/recipes/photo-sensor-pair/guide.ko.md +1 -1
  215. package/recipes/photo-sensor-pair/recipe.json +1 -1
  216. package/recipes/photo-sensor-pair/spec.json +1 -1
  217. package/recipes/pipe-run/guide.ko.md +1 -1
  218. package/recipes/pipe-run/recipe.json +1 -1
  219. package/recipes/pipe-run/spec.json +1 -1
  220. package/recipes/platform/guide.ko.md +1 -1
  221. package/recipes/platform/recipe.json +1 -1
  222. package/recipes/platform/spec.json +1 -1
  223. package/recipes/power-box/guide.ko.md +1 -1
  224. package/recipes/power-box/recipe.json +1 -1
  225. package/recipes/power-box/spec.json +1 -1
  226. package/recipes/pressure-gauge/guide.ko.md +1 -1
  227. package/recipes/pressure-gauge/recipe.json +1 -1
  228. package/recipes/pressure-gauge/spec.json +1 -1
  229. package/recipes/pull-cord/guide.ko.md +1 -1
  230. package/recipes/pull-cord/recipe.json +1 -1
  231. package/recipes/pull-cord/spec.json +1 -1
  232. package/recipes/pump/guide.ko.md +1 -1
  233. package/recipes/pump/recipe.json +1 -1
  234. package/recipes/pump/spec.json +1 -1
  235. package/recipes/pusher/guide.ko.md +1 -1
  236. package/recipes/pusher/recipe.json +1 -1
  237. package/recipes/pusher/spec.json +1 -1
  238. package/recipes/robot-plinth/guide.ko.md +1 -1
  239. package/recipes/robot-plinth/recipe.json +1 -1
  240. package/recipes/robot-plinth/spec.json +1 -1
  241. package/recipes/roll-up-shutter/guide.ko.md +1 -1
  242. package/recipes/roll-up-shutter/recipe.json +3 -3
  243. package/recipes/roll-up-shutter/spec.json +3 -3
  244. package/recipes/roller-row/facts.md +4 -4
  245. package/recipes/roller-row/guide.ko.md +1 -1
  246. package/recipes/roller-row/recipe.json +1 -1
  247. package/recipes/roller-row/spec.json +1 -1
  248. package/recipes/room-shell/guide.ko.md +2 -2
  249. package/recipes/room-shell/recipe.json +1 -1
  250. package/recipes/room-shell/spec.json +1 -1
  251. package/recipes/rotating-beacon/guide.ko.md +1 -1
  252. package/recipes/rotating-beacon/recipe.json +1 -1
  253. package/recipes/rotating-beacon/spec.json +1 -1
  254. package/recipes/safety-fence/guide.ko.md +1 -1
  255. package/recipes/safety-fence/recipe.json +1 -1
  256. package/recipes/safety-fence/spec.json +1 -1
  257. package/recipes/safety-mat/guide.ko.md +1 -1
  258. package/recipes/safety-mat/recipe.json +1 -1
  259. package/recipes/safety-mat/spec.json +1 -1
  260. package/recipes/safety-sign-stand/guide.ko.md +1 -1
  261. package/recipes/safety-sign-stand/recipe.json +1 -1
  262. package/recipes/safety-sign-stand/spec.json +1 -1
  263. package/recipes/scanner-mount/guide.ko.md +1 -1
  264. package/recipes/scanner-mount/recipe.json +1 -1
  265. package/recipes/scanner-mount/spec.json +1 -1
  266. package/recipes/selector-switch/guide.ko.md +1 -1
  267. package/recipes/selector-switch/recipe.json +1 -1
  268. package/recipes/selector-switch/spec.json +1 -1
  269. package/recipes/shelf-tiers/guide.ko.md +1 -1
  270. package/recipes/shelf-tiers/recipe.json +1 -1
  271. package/recipes/shelf-tiers/spec.json +1 -1
  272. package/recipes/side-guides/guide.ko.md +1 -1
  273. package/recipes/side-guides/recipe.json +1 -1
  274. package/recipes/side-guides/spec.json +1 -1
  275. package/recipes/sign-board/guide.ko.md +1 -1
  276. package/recipes/sign-board/recipe.json +2 -2
  277. package/recipes/sign-board/spec.json +2 -2
  278. package/recipes/signal-tower-3/guide.ko.md +1 -1
  279. package/recipes/signal-tower-3/recipe.json +1 -1
  280. package/recipes/signal-tower-3/spec.json +1 -1
  281. package/recipes/sliding-door/facts.md +7 -7
  282. package/recipes/sliding-door/guide.ko.md +2 -2
  283. package/recipes/sliding-door/recipe.json +3 -3
  284. package/recipes/sliding-door/spec.json +3 -3
  285. package/recipes/stairs/guide.ko.md +1 -1
  286. package/recipes/stairs/recipe.json +1 -1
  287. package/recipes/stairs/spec.json +1 -1
  288. package/recipes/status-lamp/guide.ko.md +1 -1
  289. package/recipes/status-lamp/recipe.json +1 -1
  290. package/recipes/status-lamp/spec.json +1 -1
  291. package/recipes/stopper/guide.ko.md +1 -1
  292. package/recipes/stopper/recipe.json +1 -1
  293. package/recipes/stopper/spec.json +1 -1
  294. package/recipes/suction-pads/guide.ko.md +1 -1
  295. package/recipes/suction-pads/recipe.json +1 -1
  296. package/recipes/suction-pads/spec.json +1 -1
  297. package/recipes/tank/guide.ko.md +1 -1
  298. package/recipes/tank/recipe.json +1 -1
  299. package/recipes/tank/spec.json +1 -1
  300. package/recipes/telescopic-arm/guide.ko.md +1 -1
  301. package/recipes/telescopic-arm/recipe.json +1 -1
  302. package/recipes/telescopic-arm/spec.json +1 -1
  303. package/recipes/toe-board/guide.ko.md +1 -1
  304. package/recipes/toe-board/recipe.json +1 -1
  305. package/recipes/toe-board/spec.json +1 -1
  306. package/recipes/tote/guide.ko.md +1 -1
  307. package/recipes/tote/recipe.json +1 -1
  308. package/recipes/tote/spec.json +1 -1
  309. package/recipes/traffic-cones/guide.ko.md +1 -1
  310. package/recipes/traffic-cones/recipe.json +1 -1
  311. package/recipes/traffic-cones/spec.json +1 -1
  312. package/recipes/transfer-belts/guide.ko.md +1 -1
  313. package/recipes/transfer-belts/recipe.json +1 -1
  314. package/recipes/transfer-belts/spec.json +1 -1
  315. package/recipes/tray-stack/guide.ko.md +2 -2
  316. package/recipes/tray-stack/recipe.json +1 -1
  317. package/recipes/tray-stack/spec.json +1 -1
  318. package/recipes/trough/guide.ko.md +1 -1
  319. package/recipes/trough/recipe.json +1 -1
  320. package/recipes/trough/spec.json +1 -1
  321. package/recipes/turntable/guide.ko.md +1 -1
  322. package/recipes/turntable/recipe.json +1 -1
  323. package/recipes/turntable/spec.json +1 -1
  324. package/recipes/valve-handle/guide.ko.md +1 -1
  325. package/recipes/valve-handle/recipe.json +1 -1
  326. package/recipes/valve-handle/spec.json +1 -1
  327. package/recipes/waste-bin/guide.ko.md +1 -1
  328. package/recipes/waste-bin/recipe.json +1 -1
  329. package/recipes/waste-bin/spec.json +1 -1
  330. package/recipes/work-light/guide.ko.md +1 -1
  331. package/recipes/work-light/recipe.json +1 -1
  332. package/recipes/work-light/spec.json +1 -1
  333. package/recipes/workbench-top/guide.ko.md +1 -1
  334. package/recipes/workbench-top/recipe.json +1 -1
  335. package/recipes/workbench-top/spec.json +1 -1
  336. package/translations/en.json +12 -0
  337. package/translations/es.json +12 -0
  338. package/translations/ja.json +12 -0
  339. package/translations/ko.json +18 -6
  340. package/translations/ms.json +12 -0
  341. package/translations/zh.json +12 -0
@@ -9,6 +9,7 @@ const shell_1 = require("@things-factory/shell");
9
9
  const fs_1 = require("fs");
10
10
  const figure_thumbnail_store_js_1 = require("../service/figure/figure-thumbnail-store.js");
11
11
  const figure_recipe_templates_js_1 = require("../service/figure-recipe/figure-recipe-templates.js");
12
+ const figure_shelf_js_1 = require("../service/figure-recipe/figure-shelf.js");
12
13
  const figure_public_js_1 = require("../service/figure/figure-public.js");
13
14
  const figure_history_js_1 = require("../service/figure/figure-history.js");
14
15
  /**
@@ -133,6 +134,33 @@ async function sendFigureThumbnail(context, next, id, domain, files = (0, figure
133
134
  * A recipe template's thumbnail (ADR-0095 amended): the file drawn from its model, served behind the same door as the
134
135
  * templates themselves. The file changes only with a release, so a day's private cache is enough.
135
136
  */
137
+ /**
138
+ * A kept recipe's card picture (ADR-0216 5b, device 2): read where the recipe is read -- its domain, its parent, or any
139
+ * domain when it is public -- and found in the domain that kept it, as a figure's picture is.
140
+ */
141
+ exports.figureThumbnailRouter.get('/figure-recipe-thumbnail/shelf/:id', async (context, next) => {
142
+ const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
143
+ const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure', privilege: 'query', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
144
+ if (!allowed) {
145
+ context.status = 403;
146
+ return;
147
+ }
148
+ const row = await (0, figure_shelf_js_1.readableShelfRecipe)(domain, context.params.id);
149
+ const picture = row?.thumbnailHash ? await (0, figure_thumbnail_store_js_1.thumbnailAttachmentOf)({ getRepository: shell_1.getRepository }, row.domain.id, row.thumbnailHash) : undefined;
150
+ if (!picture) {
151
+ context.status = 404;
152
+ return;
153
+ }
154
+ context.type = picture.mimetype;
155
+ context.set('Cache-Control', 'private, max-age=31536000');
156
+ context.set('ETag', `"${row.thumbnailHash}"`);
157
+ context.status = 200;
158
+ if (context.fresh) {
159
+ context.status = 304;
160
+ return;
161
+ }
162
+ await (0, figure_thumbnail_store_js_1.thumbnailFiles)().send(context, picture.path, next);
163
+ });
136
164
  exports.figureThumbnailRouter.get('/figure-recipe-thumbnail/:name', async (context) => {
137
165
  const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
138
166
  const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure', privilege: 'query', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The parts catalog as the AI writer uses it (ADR-0216 5b, device 5): the entries this domain reads, told beside the
3
+ * grammar as a capability -- what each is and the values it takes -- and the recipe put into each `put-recipe` the
4
+ * writer names by its key. Whether the thing asked is one of them is the writer's to judge.
5
+ *
6
+ * Only the catalog's recipes are taken: a recipe written inline by the writer is refused, since a recipe may carry
7
+ * steps no proposal may (a part's own graph values). The steps handed on carry the recipe itself, so the modeller and a
8
+ * proposal's record apply what was checked here, whatever the catalog becomes afterwards.
9
+ */
10
+ import { type FigureProposalStep, type FigureRecipe } from '@hatiolab/figure-model';
11
+ /** One entry the writer may put in. */
12
+ export interface FigureCatalogEntry {
13
+ /** What the writer names it by: a product template's name, a kept recipe's id. */
14
+ key: string;
15
+ title: string;
16
+ description: string;
17
+ recipe: FigureRecipe;
18
+ }
19
+ /** The entries as the writer is told them, after the grammar; nothing when there are none. */
20
+ export declare function catalogPrompt(entries: readonly FigureCatalogEntry[]): string[];
21
+ /**
22
+ * Each `put-recipe` given the recipe of the entry it names. A key this domain does not read, or a recipe written in
23
+ * its place, is a reason said back to the writer; the steps are returned only when every one is the catalog's.
24
+ */
25
+ export declare function catalogSteps(steps: readonly unknown[], entries: readonly FigureCatalogEntry[]): {
26
+ steps?: FigureProposalStep[];
27
+ reasons: string[];
28
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.catalogPrompt = catalogPrompt;
4
+ exports.catalogSteps = catalogSteps;
5
+ /**
6
+ * The parts catalog as the AI writer uses it (ADR-0216 5b, device 5): the entries this domain reads, told beside the
7
+ * grammar as a capability -- what each is and the values it takes -- and the recipe put into each `put-recipe` the
8
+ * writer names by its key. Whether the thing asked is one of them is the writer's to judge.
9
+ *
10
+ * Only the catalog's recipes are taken: a recipe written inline by the writer is refused, since a recipe may carry
11
+ * steps no proposal may (a part's own graph values). The steps handed on carry the recipe itself, so the modeller and a
12
+ * proposal's record apply what was checked here, whatever the catalog becomes afterwards.
13
+ */
14
+ const figure_model_1 = require("@hatiolab/figure-model");
15
+ const range = (p) => {
16
+ if (p.kind === 'flag')
17
+ return `flag, default ${p.default}`;
18
+ if (p.kind === 'choice' || p.kind === 'face')
19
+ return `${p.kind} ${(p.options ?? []).join(' | ')}, default ${p.default}`;
20
+ const above0 = p.min !== undefined && p.min > 0 && p.min < 1e-9;
21
+ const low = above0 ? '>0' : p.min !== undefined ? String(p.min) : '';
22
+ const span = p.max !== undefined ? `${low}–${p.max}` : low ? `${low}` : '';
23
+ return `${p.kind}${span ? ` ${span}` : ''}, default ${p.default}`;
24
+ };
25
+ /** How many parts it puts in: a kept recipe lists them; a template's are counted from its steps. */
26
+ const partsOf = (recipe) => {
27
+ const kept = Object.keys(recipe.parts ?? {}).length;
28
+ if (kept)
29
+ return String(kept);
30
+ const d = (0, figure_model_1.describeFigureRecipe)(recipe).parts;
31
+ return d.min === d.max ? String(d.min) : `${d.min}-${d.max}`;
32
+ };
33
+ /** The entries as the writer is told them, after the grammar; nothing when there are none. */
34
+ function catalogPrompt(entries) {
35
+ if (!entries.length)
36
+ return [];
37
+ return [
38
+ '',
39
+ "THIS DOMAIN'S PARTS CATALOG (put one in with put-recipe, recipe: its key; a thing that is one of these can be put in whole, its values set):",
40
+ ...entries.map(e => {
41
+ const values = e.recipe.params.map(p => `${p.name} (${range(p)})`).join('; ');
42
+ /* A description ends with its own stop or none; the line's own follows it once. */
43
+ const what = [e.title, e.description].map(w => w.trim().replace(/[.。]+$/, '')).filter(Boolean).join(' -- ');
44
+ return `- ${e.key}: ${what}. Onto ${e.recipe.target === 'part' ? 'a part (target)' : 'the figure'}; ${partsOf(e.recipe)} ${partsOf(e.recipe) === '1' ? 'part' : 'parts'}${values ? `; values: ${values}` : ''}.`;
45
+ })
46
+ ];
47
+ }
48
+ /**
49
+ * Each `put-recipe` given the recipe of the entry it names. A key this domain does not read, or a recipe written in
50
+ * its place, is a reason said back to the writer; the steps are returned only when every one is the catalog's.
51
+ */
52
+ function catalogSteps(steps, entries) {
53
+ const byKey = new Map(entries.map(e => [e.key, e.recipe]));
54
+ const reasons = [];
55
+ const out = steps.map((step, i) => {
56
+ const s = step;
57
+ if (!s || s.kind !== 'put-recipe')
58
+ return step;
59
+ if (typeof s.recipe !== 'string') {
60
+ reasons.push(`CATALOG_ENTRY: steps[${i}] (put-recipe) writes a recipe; recipe is the key of an entry of this domain's parts catalog, and nothing else.`);
61
+ return step;
62
+ }
63
+ const recipe = byKey.get(s.recipe);
64
+ if (!recipe) {
65
+ reasons.push(`CATALOG_ENTRY: steps[${i}] (put-recipe) names "${s.recipe}", which is not an entry of this domain's parts catalog. Use a key listed there, or build the thing with commands.`);
66
+ return step;
67
+ }
68
+ return { ...s, recipe };
69
+ });
70
+ return reasons.length ? { reasons } : { steps: out, reasons };
71
+ }
72
+ //# sourceMappingURL=figure-catalog.js.map
@@ -53,6 +53,8 @@ export interface FigureReadRequest {
53
53
  }
54
54
  export interface FigureView {
55
55
  whole: boolean;
56
+ /** Said when the joints' nodes were left out of what is shown (ADR-0215 decision 4); counted in the budget. */
57
+ jointNodes?: string;
56
58
  /** Whole: the source as it is. */
57
59
  source?: FigureAsset;
58
60
  outline?: FigureOutline;
@@ -86,11 +88,19 @@ export declare function figurePartReadOf(asset: FigureAsset, part: string): Figu
86
88
  * budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.
87
89
  */
88
90
  export declare function figureOutlineOf(asset: FigureAsset, chars?: number): FigureOutline;
91
+ /**
92
+ * The figure as the model is shown it: without the nodes its joints own (figure-model ADR-0215 decision 4). The kernel
93
+ * writes them from the joint records on every edit, so a step never names them; left in, they were a third of a figure's
94
+ * text and crowded out what a change reads. Every view and every judgment of a proposal against a view is made on this,
95
+ * so a section's pointer means the same in both.
96
+ */
97
+ export declare const JOINT_NODES_LEFT_OUT = "The nodes each joint writes from its record (<part>.on.*, its row, seat, chain and motion) are left out: the kernel writes them again on every edit. Change a fastening through its joint record.";
98
+ export declare function figureShownOf(asset: FigureAsset): FigureAsset;
89
99
  /**
90
100
  * The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then
91
101
  * sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.
92
102
  */
93
- export declare function figureViewOf(asset: FigureAsset, request?: FigureReadRequest): FigureView;
103
+ export declare function figureViewOf(given: FigureAsset, request?: FigureReadRequest): FigureView;
94
104
  /**
95
105
  * The steps that change a part of the base not shown in full, as reasons said back to the writer. A part may still be
96
106
  * named to fasten to or to follow -- the kernel works from it, nothing about it is guessed -- and a new part is the
@@ -102,5 +112,5 @@ export declare function unreadPartEdits(base: FigureAsset, steps: readonly Figur
102
112
  * on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a
103
113
  * record in a list, a key in a map -- is the steps' own.
104
114
  */
105
- export declare function unreadSectionEdits(base: FigureAsset, after: FigureAsset, view: FigureView): string[];
115
+ export declare function unreadSectionEdits(givenBase: FigureAsset, givenAfter: FigureAsset, view: FigureView): string[];
106
116
  export {};
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIGURE_CONTEXT_BUDGET = void 0;
3
+ exports.JOINT_NODES_LEFT_OUT = exports.FIGURE_CONTEXT_BUDGET = void 0;
4
4
  exports.figurePartReadOf = figurePartReadOf;
5
5
  exports.figureOutlineOf = figureOutlineOf;
6
+ exports.figureShownOf = figureShownOf;
6
7
  exports.figureViewOf = figureViewOf;
7
8
  exports.unreadPartEdits = unreadPartEdits;
8
9
  exports.unreadSectionEdits = unreadSectionEdits;
9
10
  /**
10
11
  * What of a figure the model is shown (ADR-0061 2026-10-16 decision 4).
11
12
  *
12
- * The kernel keeps a figure up to 1 MiB (`FIGURE_JSON_MAX_BYTES`); that is whether the figure is valid. How much of it the
13
+ * The kernel keeps a figure up to 4 MiB (`FIGURE_JSON_MAX_BYTES`); that is whether the figure is valid. How much of it the
13
14
  * model reads at once is another question with its own number. A figure that fits is shown whole. One that does not is
14
15
  * shown as an outline -- its sections, and every part by name, shape and what it is fastened to -- and in full only the
15
16
  * parts and sections asked for, while they fit. A section too large for the outline is left out, named by its JSON
@@ -31,6 +32,12 @@ exports.FIGURE_CONTEXT_BUDGET = 100_000;
31
32
  const OUTLINE_SHARE = exports.FIGURE_CONTEXT_BUDGET / 2;
32
33
  /** How many entries of a section left out, or pointers in a reason, are named: the largest first. */
33
34
  const ENTRIES_NAMED = 20;
35
+ /*
36
+ Room kept, while parts and sections are added, for saying what was not read: a view filled to the last character had
37
+ none left, and the parts it could not show went unsaid (2026-11-19, once a part without its joints' nodes was small
38
+ enough to fill it exactly).
39
+ */
40
+ const REASON_ROOM = 400;
34
41
  const length = (value) => JSON.stringify(value)?.length ?? 0;
35
42
  const under = (part) => (id) => id === part || (typeof id === 'string' && id.startsWith(`${part}.`));
36
43
  /* ── JSON Pointer (RFC 6901) ─────────────────────────────────────────────────────────── */
@@ -138,7 +145,7 @@ function place(outline, tokens, value) {
138
145
  * What the view wraps the outline in, read or not: an outline that took the whole budget left the view over it by these
139
146
  * (53 characters, a figure of 3000 long-named parts, 2026-10-19).
140
147
  */
141
- const VIEW_ENVELOPE = () => length({ whole: false, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({});
148
+ const VIEW_ENVELOPE = () => length({ whole: false, jointNodes: exports.JOINT_NODES_LEFT_OUT, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({});
142
149
  /**
143
150
  * The outline: within OUTLINE_SHARE for its sections, the largest left out first; and, every field counted, within the
144
151
  * budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.
@@ -195,20 +202,40 @@ function pipesOf(asset) {
195
202
  return swept ? (0, figure_model_1.figurePipesOf)(asset) : {};
196
203
  }
197
204
  /* ── The view ────────────────────────────────────────────────────────────────────────── */
205
+ /**
206
+ * The figure as the model is shown it: without the nodes its joints own (figure-model ADR-0215 decision 4). The kernel
207
+ * writes them from the joint records on every edit, so a step never names them; left in, they were a third of a figure's
208
+ * text and crowded out what a change reads. Every view and every judgment of a proposal against a view is made on this,
209
+ * so a section's pointer means the same in both.
210
+ */
211
+ exports.JOINT_NODES_LEFT_OUT = 'The nodes each joint writes from its record (<part>.on.*, its row, seat, chain and motion) are left out: the kernel writes them again on every edit. Change a fastening through its joint record.';
212
+ function figureShownOf(asset) {
213
+ const parts = (asset.joints ?? []).map((j) => j.body1?.part).filter((p) => typeof p === 'string');
214
+ if (!parts.length)
215
+ return asset;
216
+ const model = asset.document.model;
217
+ const nodes = model.nodes.filter(n => !parts.some((p) => (0, figure_model_1.figureJointNodeOf)(p, n.id)));
218
+ if (nodes.length === model.nodes.length)
219
+ return asset;
220
+ return { ...asset, document: { ...asset.document, model: { ...model, nodes } } };
221
+ }
198
222
  /**
199
223
  * The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then
200
224
  * sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.
201
225
  */
202
- function figureViewOf(asset, request = {}) {
226
+ function figureViewOf(given, request = {}) {
227
+ const asset = figureShownOf(given);
228
+ const said = asset !== given ? { jointNodes: exports.JOINT_NODES_LEFT_OUT } : {};
203
229
  const chars = length(asset);
204
- const pipes = pipesOf(asset);
230
+ /* Read from the figure itself: a pipe's reading compiles it, and that needs the joints' nodes. */
231
+ const pipes = pipesOf(given);
205
232
  if (chars <= exports.FIGURE_CONTEXT_BUDGET) {
206
- const whole = { whole: true, source: asset, ...(Object.keys(pipes).length ? { pipes } : {}), palette: { tokens: Object.keys(asset.palette ?? {}) } };
233
+ const whole = { whole: true, ...said, source: asset, ...(Object.keys(pipes).length ? { pipes } : {}), palette: { tokens: Object.keys(asset.palette ?? {}) } };
207
234
  if (length(whole) <= exports.FIGURE_CONTEXT_BUDGET)
208
235
  return whole;
209
236
  }
210
237
  const outline = figureOutlineOf(asset, chars);
211
- const view = { whole: false, outline, parts: {}, shown: [], sections: {}, pipes: {}, notRead: [] };
238
+ const view = { whole: false, ...said, outline, parts: {}, shown: [], sections: {}, pipes: {}, notRead: [] };
212
239
  const room = () => exports.FIGURE_CONTEXT_BUDGET - length(view);
213
240
  const refuse = (one) => {
214
241
  if (length(one) + 1 <= room())
@@ -227,7 +254,7 @@ function figureViewOf(asset, request = {}) {
227
254
  view.shown.push(part);
228
255
  if (pipe)
229
256
  view.pipes[part] = pipe;
230
- if (room() >= 0)
257
+ if (room() >= REASON_ROOM)
231
258
  continue;
232
259
  delete view.parts[part];
233
260
  delete view.pipes[part];
@@ -254,7 +281,7 @@ function figureViewOf(asset, request = {}) {
254
281
  }
255
282
  const cost = length(at.value) + length(section) + 2;
256
283
  view.sections[section] = at.value;
257
- if (room() >= 0)
284
+ if (room() >= REASON_ROOM)
258
285
  continue;
259
286
  delete view.sections[section];
260
287
  const entries = entriesOf(section, at.value);
@@ -327,6 +354,10 @@ const SUBJECT = {
327
354
  'set-visibility': step => step.target,
328
355
  'remove-part': step => step.target,
329
356
  'duplicate-part': step => step.target,
357
+ /* Onto a part, which it does not change: the parts it makes are the steps' own, as attach onto a part is. */
358
+ 'put-recipe': () => undefined,
359
+ /* A typed measure changes the part whose value it is (<part>.dimension.…); a figure-level value, or a step without one, no part. */
360
+ 'set-design': (step, base) => (typeof step.input === 'string' ? base.appearance.map(a => a.target).find(part => step.input.startsWith(`${part}.`)) : undefined),
330
361
  'mirror-part': step => step.target,
331
362
  'move-part': step => step.target,
332
363
  'set-placement': () => undefined,
@@ -351,6 +382,12 @@ const SUBJECT = {
351
382
  'set-state-defaults': () => undefined,
352
383
  'set-driver': () => undefined,
353
384
  'remove-driver': () => undefined,
385
+ 'add-tracks': () => undefined,
386
+ 'add-graph-part': () => undefined,
387
+ 'set-hold': () => undefined,
388
+ /* A recipe's own step (ADR-0216 5b, figure-model 8292e73): a proposal that writes one is refused; it changes no one part. */
389
+ 'carry-hold': () => undefined,
390
+ 'remove-hold': () => undefined,
354
391
  'set-clip': () => undefined,
355
392
  'copy-clip': () => undefined,
356
393
  'set-motion-group': () => undefined,
@@ -404,7 +441,10 @@ function keyedEntries(value) {
404
441
  * on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a
405
442
  * record in a list, a key in a map -- is the steps' own.
406
443
  */
407
- function unreadSectionEdits(base, after, view) {
444
+ function unreadSectionEdits(givenBase, givenAfter, view) {
445
+ /* The view's pointers are into the figure as shown: so are the two judged here. */
446
+ const base = figureShownOf(givenBase);
447
+ const after = figureShownOf(givenAfter);
408
448
  const read = Object.keys(view.sections ?? {});
409
449
  const reasons = [];
410
450
  const say = (pointer, what) => reasons.push(`UNREAD_SECTION: the steps ${what} ${pointer}, which was left out of the outline and not read, so it is not known here. ` +
@@ -155,6 +155,48 @@ function figureWording(violation, say) {
155
155
  how: say(key('how'), { parts }, `Let ${parts} follow the figure's size ("in proportion" under position in the size tab), or remove their own fixed numbers.`)
156
156
  };
157
157
  }
158
+ case 'HOLD_SLIP': {
159
+ /* A part kept on the floor that an edit moved after its hold was solved (ADR-0217). */
160
+ const hold = violation.hold ?? '';
161
+ const seconds = violation.seconds ?? '';
162
+ /* Said to a tenth of a millimetre; the gate keeps the finer number. */
163
+ const mm = Math.round((violation.mm ?? 0) * 10) / 10;
164
+ return {
165
+ message: violation.planted
166
+ ? say(key('message-planted'), { hold, part, mm, from: violation.planted[0], to: violation.planted[1] }, `Hold '${hold}': '${part}' moves ${mm} mm along the floor while it stands planted from ${violation.planted[0]} s to ${violation.planted[1]} s.`)
167
+ : seconds === ''
168
+ ? say(key('message-start'), { hold, part, mm }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept in the starting pose.`)
169
+ : violation.leap
170
+ ? say(key('message-leap'), { hold, part, mm, a: violation.leap.between[0], b: violation.leap.between[1], label: violation.leap.label, from: violation.leap.from, to: violation.leap.to }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept between ${violation.leap.between[0]} s and ${violation.leap.between[1]} s, where ${violation.leap.label} changes sharply (${violation.leap.from} → ${violation.leap.to}).`)
171
+ : say(key('message'), { hold, part, mm, seconds }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept, at ${seconds} s.`),
172
+ /*
173
+ A hold its own controls cannot reach there (the gate solved it once at that pose): solving it again does not
174
+ mend it -- 「다시 맞추기」 refuses it -- so the reason and the remedy are the pose's (2026-11-21).
175
+ */
176
+ ...(violation.nearest !== undefined
177
+ ? (() => {
178
+ const nearest = Math.round(violation.nearest * 10) / 10;
179
+ return {
180
+ why: say(key('why-unreachable'), { hold, nearest }, `The controls hold '${hold}' solves cannot keep the part there in this pose: solved again, it stays ${nearest} mm away.`),
181
+ how: seconds === ''
182
+ ? say(key('how-unreachable-start'), { hold }, `Add a control for hold '${hold}' to solve, or change the starting pose.`)
183
+ : say(key('how-unreachable'), { hold, seconds }, `Add a control for hold '${hold}' to solve, or change the pose at ${seconds} s.`)
184
+ };
185
+ })()
186
+ : {
187
+ why: say(key('why'), {}, 'The hold was solved before a later edit changed the figure, such as a leg made longer. Played as it is, the part slides or sinks into the floor.'),
188
+ how: say(key('how'), { hold }, `Press 「Solve again」 for hold '${hold}' in the clip panel.`)
189
+ })
190
+ };
191
+ }
192
+ case 'HOLD_UNMEASURED': {
193
+ const hold = violation.hold ?? '';
194
+ return {
195
+ message: say(key('message'), { hold }, `Hold '${hold}' cannot be measured.`),
196
+ why: say(key('why'), {}, 'What it names is missing, or the figure cannot be posed as it asks, so whether the part stays on the floor is not known.'),
197
+ how: say(key('how'), { hold }, `Set hold '${hold}' again, or remove it.`)
198
+ };
199
+ }
158
200
  }
159
201
  }
160
202
  /*
@@ -4,6 +4,7 @@ exports.FigureMutation = void 0;
4
4
  exports.assertNames = assertNames;
5
5
  const tslib_1 = require("tslib");
6
6
  const capability_module_store_js_1 = require("../capability-module/capability-module-store.js");
7
+ const figure_catalog_of_js_1 = require("../figure-recipe/figure-catalog-of.js");
7
8
  const typeorm_1 = require("typeorm");
8
9
  const type_graphql_1 = require("type-graphql");
9
10
  const figure_model_1 = require("@hatiolab/figure-model");
@@ -170,7 +171,7 @@ let FigureMutation = class FigureMutation {
170
171
  source,
171
172
  ...derived,
172
173
  namespace,
173
- state: figure.state ?? 'draft',
174
+ state: 'draft',
174
175
  ...(await (0, figure_write_js_1.pictureOf)(tx, domain, user, thumbnail)),
175
176
  domain,
176
177
  creator: user,
@@ -187,6 +188,9 @@ let FigureMutation = class FigureMutation {
187
188
  const conflicts = seen ? (0, figure_write_js_1.catalogConflictsOf)(figure, seen) : [];
188
189
  if (conflicts.length)
189
190
  throw (0, figure_write_js_1.catalogConflict)(conflicts);
191
+ if (patch.source !== undefined && (patch.expectedSource === undefined || patch.expectedSource !== figure.source)) {
192
+ throw (0, figure_write_js_1.sourceConflict)('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 적용해 주세요.');
193
+ }
190
194
  /*
191
195
  **그림만 바꾸면 발행이 풀리지 않는다.** 미리보기에서 사람이 돌려 놓은 각도로 찍은 그림이 그렇게 온다.
192
196
  그림은 발행이 약속하는 것이 아니다 — 발행본은 제 그림을 따로 갖고, 다음 발행이 이 그림을 가져간다.
@@ -247,7 +251,7 @@ let FigureMutation = class FigureMutation {
247
251
  배포된 것이 달라진다. 그래서 저장은 언제나 초안으로 되돌린다. 버전 번호는 여기서 손대지 않는다 —
248
252
  버전은 발행에서 생긴다(`releaseFigure`).
249
253
  */
250
- const { type: _type, source: _source, ...fields } = patchRest;
254
+ const { type: _type, source: _source, expectedSource: _expectedSource, ...fields } = patchRest;
251
255
  const changes = {
252
256
  ...Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined)),
253
257
  ...(renamed !== undefined ? { type: renamed } : {}),
@@ -268,8 +272,8 @@ let FigureMutation = class FigureMutation {
268
272
  }
269
273
  return result;
270
274
  };
271
- if ('source' in changes)
272
- await (0, figure_write_js_1.compareAndSwapFigure)(written, id, domain.id, figure.source);
275
+ if (patch.source !== undefined || 'source' in changes)
276
+ await (0, figure_write_js_1.compareAndSwapFigure)(written, id, domain.id, patch.source !== undefined ? patch.expectedSource : figure.source);
273
277
  else
274
278
  await written({ id, domain: { id: domain.id } });
275
279
  const saved = await repository.findOneOrFail({ where: { id, domain: { id: domain.id } } });
@@ -314,10 +318,16 @@ let FigureMutation = class FigureMutation {
314
318
  const { domain, user, tx } = context.state;
315
319
  const repository = tx.getRepository(figure_js_1.Figure);
316
320
  const historyRepository = tx.getRepository(figure_history_js_1.FigureHistory);
317
- const figure = await ownFigure(repository, domain, id);
321
+ let figure = await ownFigure(repository, domain, id);
318
322
  if (figure.state === 'released') {
319
323
  throw new Error(`Figure '${figure.type}' 은 이미 발행되어 있다. 고쳐서 다시 내려면 초안으로 되돌린 뒤 발행한다`);
320
324
  }
325
+ /* Claim this exact draft before inspection. The no-op conditional UPDATE is portable to SQLite and
326
+ PostgreSQL and holds the row lock until @transaction commits the release and its history. A save that
327
+ already won is a named conflict; a save that follows waits and leaves the released snapshot intact.
328
+ Re-read under the claim so a catalogue edit made before it is not overwritten by the old entity. */
329
+ await (0, figure_write_js_1.compareAndSwapFigure)(criteria => repository.update({ ...criteria, state: figure.state, version: figure.version }, { state: figure.state }), id, domain.id, figure.source);
330
+ figure = await ownFigure(repository, domain, id);
321
331
  /* A release promises boards the full name {namespace}/{type}: it goes out only under a namespace the domain owns and has active. */
322
332
  const namespace = (0, figure_namespace_js_1.namespaceOf)(figure);
323
333
  await (0, figure_namespace_js_1.assertReleasableNamespace)(tx, domain, namespace, user);
@@ -492,6 +502,8 @@ let FigureMutation = class FigureMutation {
492
502
  /* The product capabilities the domain uses (ADR-0172 amendment 1, decision 16). */
493
503
  capabilities: [...(await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain)).values()],
494
504
  choices: await (0, capability_module_store_js_1.chosenCapabilityChoices)({ getRepository: shell_1.getRepository }, context.state.domain),
505
+ /* The parts catalog the domain reads, put in by put-recipe (ADR-0216 5b, device 5). */
506
+ catalog: await (0, figure_catalog_of_js_1.figureCatalogOf)({ getRepository: shell_1.getRepository }, context.state.domain),
495
507
  ...(image ? { images: [image] } : {})
496
508
  });
497
509
  return {
@@ -4,6 +4,7 @@ import { type AIClient } from '@things-factory/ai-client-base';
4
4
  import type { AIImageMediaType, AIMessage } from '@things-factory/ai-client-base';
5
5
  import { type FigureRelationCheck, type FigureRelationVerdict } from './figure-relation-checks.js';
6
6
  import { type FigureReadRequest, type FigureView } from './figure-context.js';
7
+ import { type FigureCatalogEntry } from './figure-catalog.js';
7
8
  /** A capability a provider the domain uses gives (ADR-0172 amendment 1, decision 16), as the model is told it. */
8
9
  export type ProposeFigureCapability = Pick<FigureCapabilityDescriptor, 'name' | 'label' | 'note' | 'needs' | 'data' | 'settings'>;
9
10
  export interface ProposeFigureInput {
@@ -22,6 +23,8 @@ export interface ProposeFigureInput {
22
23
  capabilities?: readonly ProposeFigureCapability[];
23
24
  /** Their settings' choice lists, by <capability>.<setting> (ADR-0172 amendment 2, decision 21). */
24
25
  choices?: FigureCapabilityChoices;
26
+ /** The parts catalog this domain reads (ADR-0216 5b, device 5): told beside the grammar, put in by put-recipe. */
27
+ catalog?: readonly FigureCatalogEntry[];
25
28
  /** Reference pictures, in the order the person gave them: proportions and masses, not surface detail. */
26
29
  images?: {
27
30
  data: Buffer;
@@ -185,7 +188,7 @@ export declare function proposalFailureForPerson(failure: ProposeFigureFailure,
185
188
  * What the model is told before the task: the answer's form, then figure-model's own guide and grammar, both made from
186
189
  * the kernel and held to it by its tests. Nothing here designs a thing for it.
187
190
  */
188
- export declare function rulesPromptFigure(capabilities?: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices): string;
191
+ export declare function rulesPromptFigure(capabilities?: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices, catalog?: readonly FigureCatalogEntry[]): string;
189
192
  export declare function capabilitiesPrompt(capabilities: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices): string[];
190
193
  /**
191
194
  * The observations on a figure the kernel and the gate took, said to the model once: what was measured, how, and that
@@ -205,7 +208,9 @@ export declare function taskPromptFigure(input: ProposeFigureInput, view?: Figur
205
208
  */
206
209
  export declare function judgeFigureAnswer(base: FigureAsset, answer: unknown, revising: boolean,
207
210
  /** What the writer was shown of a draft shown in part; absent, or whole, when it was shown whole. */
208
- view?: FigureView): {
211
+ view?: FigureView,
212
+ /** The parts catalog the writer was told: each put-recipe's key given its recipe, or refused. */
213
+ catalog?: readonly FigureCatalogEntry[]): {
209
214
  source?: FigureAsset;
210
215
  steps?: FigureProposalStep[];
211
216
  reasons: string[];
@@ -13,6 +13,7 @@ const figure_model_1 = require("@hatiolab/figure-model");
13
13
  const ai_client_base_1 = require("@things-factory/ai-client-base");
14
14
  const figure_relation_checks_js_1 = require("./figure-relation-checks.js");
15
15
  const figure_context_js_1 = require("./figure-context.js");
16
+ const figure_catalog_js_1 = require("./figure-catalog.js");
16
17
  /**
17
18
  * An AI proposal for a figure is a list of the modeller's own commands (ADR-0094).
18
19
  *
@@ -58,7 +59,7 @@ function proposalFailureForPerson(failure, t) {
58
59
  * What the model is told before the task: the answer's form, then figure-model's own guide and grammar, both made from
59
60
  * the kernel and held to it by its tests. Nothing here designs a thing for it.
60
61
  */
61
- function rulesPromptFigure(capabilities = [], choices = {}) {
62
+ function rulesPromptFigure(capabilities = [], choices = {}, catalog = []) {
62
63
  return [
63
64
  'You author a 3D figure for a factory digital twin by writing the commands a person gives in the figure modeller.',
64
65
  'What the thing is, how it looks and how it moves is your own knowledge; how it is said in this modeller is below.',
@@ -69,7 +70,8 @@ function rulesPromptFigure(capabilities = [], choices = {}) {
69
70
  '',
70
71
  'THE COMMANDS (shape, then what it means):',
71
72
  ...figure_model_1.FIGURE_PROPOSAL_GRAMMAR.map(word => `- ${word.shape}\n ${word.means}`),
72
- ...capabilitiesPrompt(capabilities, choices)
73
+ ...capabilitiesPrompt(capabilities, choices),
74
+ ...(0, figure_catalog_js_1.catalogPrompt)(catalog)
73
75
  ].join('\n');
74
76
  }
75
77
  /*
@@ -266,10 +268,16 @@ function partsAtRefusedStep(base, steps, error) {
266
268
  */
267
269
  function judgeFigureAnswer(base, answer, revising,
268
270
  /** What the writer was shown of a draft shown in part; absent, or whole, when it was shown whole. */
269
- view) {
270
- const steps = answer?.steps;
271
- if (!Array.isArray(steps))
271
+ view,
272
+ /** The parts catalog the writer was told: each put-recipe's key given its recipe, or refused. */
273
+ catalog = []) {
274
+ const written = answer?.steps;
275
+ if (!Array.isArray(written))
272
276
  return { reasons: ['The answer must be { "steps": [ ... ] }.'] };
277
+ const fromCatalog = (0, figure_catalog_js_1.catalogSteps)(written, catalog);
278
+ if (!fromCatalog.steps)
279
+ return { reasons: fromCatalog.reasons };
280
+ const steps = fromCatalog.steps;
273
281
  /* A part the writer was not shown is not changed on a guess (ADR-0061 2026-10-16 decision 4). */
274
282
  const partial = view && !view.whole ? view : undefined;
275
283
  const unread = partial ? (0, figure_context_js_1.unreadPartEdits)(base, steps, partial) : [];
@@ -323,7 +331,7 @@ async function proposeFigureSteps(input) {
323
331
  const { client } = input;
324
332
  const base = input.base ?? (0, figure_model_1.createFigureAsset)(input.name ?? 'Figure');
325
333
  const view = viewFor(input);
326
- const system = rulesPromptFigure(input.capabilities, input.choices);
334
+ const system = rulesPromptFigure(input.capabilities, input.choices, input.catalog);
327
335
  const hashOf = (said) => (0, crypto_1.createHash)('sha1').update(said).digest('hex').slice(0, 12);
328
336
  const record = {
329
337
  at: new Date().toISOString(),
@@ -422,7 +430,7 @@ async function proposeFigureSteps(input) {
422
430
  messages.push({ role: 'user', content: ['That was rejected. Answer with the JSON object only:', ...reasons].join('\n') });
423
431
  continue;
424
432
  }
425
- const judged = judgeFigureAnswer(base, answer, !!input.base, view);
433
+ const judged = judgeFigureAnswer(base, answer, !!input.base, view, input.catalog);
426
434
  record.attempts.push({ answer, reasons: judged.reasons });
427
435
  if (judged.source) {
428
436
  const candidate = { steps: judged.steps, source: judged.source };
@@ -458,7 +466,7 @@ async function proposeFigureSteps(input) {
458
466
  const note = text(reply?.note);
459
467
  if (reply?.keep === true)
460
468
  return done(candidate, attempt, { asked: true, decision: 'kept', why, note });
461
- const again = judgeFigureAnswer(base, reply, !!input.base, view);
469
+ const again = judgeFigureAnswer(base, reply, !!input.base, view, input.catalog);
462
470
  record.attempts.push({ answer: reply, reasons: again.reasons });
463
471
  if (again.source)
464
472
  return done({ steps: again.steps, source: again.source }, attempt, { asked: true, decision: 'revised', why, note, ...(recovery ? { recovered: true } : {}) });
@@ -52,7 +52,7 @@ export declare class FigureQuery {
52
52
  figureProposalOutcome(proposalKey: string, context: ResolverContext): Promise<FigureProposalOutcome[]>;
53
53
  /** The drafts reverts kept for a figure, newest first -- apart from its released versions (ADR-0097 §5.6). */
54
54
  figureReplacedDrafts(id: string, context: ResolverContext): Promise<FigureReplacedDraft[]>;
55
- figureReleased(id: string, context: ResolverContext): Promise<FigureHistory>;
55
+ figureReleased(id: string, context: ResolverContext, version?: number): Promise<FigureHistory>;
56
56
  /**
57
57
  * 발행해도 되나 — **누르기 전에** 묻는 자리.
58
58
  *
@@ -157,12 +157,12 @@ let FigureQuery = class FigureQuery {
157
157
  const { domain, tx } = context.state;
158
158
  return await (0, figure_revert_js_1.replacedDraftsOf)((0, shell_1.getRepository)(figure_replaced_draft_js_1.FigureReplacedDraft, tx).manager, domain, id);
159
159
  }
160
- async figureReleased(id, context) {
160
+ async figureReleased(id, context, version) {
161
161
  const { domain } = context.state;
162
162
  if (!(await (0, figure_public_js_1.readableFigure)(domain, id, { id: true, public: true, domain: { id: true } })))
163
163
  return null;
164
164
  return await (0, shell_1.getRepository)(figure_history_js_1.FigureHistory).findOne({
165
- where: { originalId: id },
165
+ where: { originalId: id, ...(version ? { version } : {}) },
166
166
  order: { version: 'DESC' }
167
167
  });
168
168
  }
@@ -327,6 +327,10 @@ let FigureQuery = class FigureQuery {
327
327
  if (names.length > FIGURE_BLUEPRINTS_MAX) {
328
328
  throw new shell_1.Refusal('figure-names-too-many', { count: names.length, max: FIGURE_BLUEPRINTS_MAX }, 'at most {max} figure names can be asked at once, not {count}.');
329
329
  }
330
+ /*
331
+ `jointsChecked`: each release is parsed here, joint check and all, before it is handed over (consumablePayloadOf),
332
+ so the board need not write its joints again (figure-model ADR-0215 decision 3).
333
+ */
330
334
  const items = [];
331
335
  const refused = [];
332
336
  /* Plain text: a board draws the reason on a canvas, so a name with `/` is not escaped. */
@@ -351,7 +355,7 @@ let FigureQuery = class FigureQuery {
351
355
  continue;
352
356
  }
353
357
  try {
354
- items.push({ type, ref: (0, figure_model_1.formatFigureRef)({ ...name, version: found.version }), asset: (0, figure_format_js_1.consumablePayloadOf)(found.source).asset });
358
+ items.push({ type, ref: (0, figure_model_1.formatFigureRef)({ ...name, version: found.version }), asset: (0, figure_format_js_1.consumablePayloadOf)(found.source).asset, jointsChecked: true });
355
359
  }
356
360
  catch {
357
361
  refuse(type, new shell_1.Refusal('figure-release-does-not-compile', { type, figureId: found.figure.id, version: found.version }, 'the released source of {type} does not compile. open it in the modeller and release it again.'));
@@ -446,11 +450,12 @@ tslib_1.__decorate([
446
450
  ], FigureQuery.prototype, "figureReplacedDrafts", null);
447
451
  tslib_1.__decorate([
448
452
  (0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "query", domainOwnerGranted: true)'),
449
- (0, type_graphql_1.Query)(returns => figure_history_js_1.FigureHistory, { nullable: true, description: 'The most recently released version of a figure.' }),
453
+ (0, type_graphql_1.Query)(returns => figure_history_js_1.FigureHistory, { nullable: true, description: 'The most recently released version of a figure, or the released version asked for.' }),
450
454
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
451
455
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
456
+ tslib_1.__param(2, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int, { nullable: true, description: 'A released version; omit for the most recent. A linked copy reads the version it came from (ADR-0216 5b, device 3).' })),
452
457
  tslib_1.__metadata("design:type", Function),
453
- tslib_1.__metadata("design:paramtypes", [String, Object]),
458
+ tslib_1.__metadata("design:paramtypes", [String, Object, Number]),
454
459
  tslib_1.__metadata("design:returntype", Promise)
455
460
  ], FigureQuery.prototype, "figureReleased", null);
456
461
  tslib_1.__decorate([