@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 +0,0 @@
1
- {"version":3,"file":"figure-categories.js","sourceRoot":"","sources":["../../../server/service/figure/figure-categories.ts"],"names":[],"mappings":";;AAYA,4DAMC;AAGD,4CAEC;AAGD,sDAEC;AAGD,oDAUC;AAGD,4DAKC;AAjDD,iDAA+C;AAE/C;;;;;GAKG;AAEH,IAAI,UAAU,GAA6B,IAAI,CAAA;AAE/C,sGAAsG;AACtG,SAAgB,wBAAwB,CAAC,KAAwB;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAA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CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,0DAA0D,CAAC,CAAA;IAChK,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,SAAgB,wBAAwB,CAAC,QAAmC,EAAE,IAAY;IACxF,IAAI,CAAC,UAAU;QAAE,OAAM;IACvB,IAAI,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,eAAO,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,mEAAmE,CAAC,CAAA;IAC7J,CAAC;AACH,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * The categories an app allows (LV figure-server design G5). Without a registration a category is free text, as\n * operato-figure has it. An app that registers its vocabulary -- the LV figure-server: EQUIPMENT, CARRIER, UTILITY,\n * COMPONENT -- gets three rules: a category outside it is refused, a category once set is not changed, and a figure\n * is not released without one. The vocabulary is the app's; this module does not know what the words mean.\n */\n\nlet registered: readonly string[] | null = null\n\n/** Registers the categories this server allows. Called once at the top of the app's server module. */\nexport function registerFigureCategories(codes: readonly string[]): void {\n const cleaned = codes.map(code => (typeof code === 'string' ? code.trim() : ''))\n if (!cleaned.length || cleaned.some(code => !code) || new Set(cleaned).size !== cleaned.length) {\n throw new Error(`registerFigureCategories needs distinct non-empty codes, not ${JSON.stringify(codes)}.`)\n }\n registered = Object.freeze([...cleaned])\n}\n\n/** The categories registered, or null when a category is free text. */\nexport function figureCategories(): readonly string[] | null {\n return registered\n}\n\n/** For tests: back to free text. */\nexport function clearFigureCategories(): void {\n registered = null\n}\n\n/** A category being set on a figure: refused outside the vocabulary, and when the figure already has another. */\nexport function assertFigureCategory(next: string | null | undefined, current?: string | null): void {\n if (!registered || next === undefined) return\n const wanted = (next ?? '').trim()\n const had = (current ?? '').trim()\n if (had && wanted !== had) {\n throw new Refusal('figure-category-fixed', { category: had }, 'the category {category} is set once and does not change.')\n }\n if (wanted && !registered.includes(wanted)) {\n throw new Refusal('figure-category-unknown', { category: wanted, allowed: registered.join(', ') }, '{category} is not a category here. use one of {allowed}.')\n }\n}\n\n/** A figure going out: with a vocabulary registered it carries one of its categories. */\nexport function assertReleasableCategory(category: string | null | undefined, type: string): void {\n if (!registered) return\n if (!(category ?? '').trim()) {\n throw new Refusal('figure-category-missing', { type, allowed: registered.join(', ') }, '{type} has no category. choose one of {allowed} before releasing.')\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-context.js","sourceRoot":"","sources":["../../../server/service/figure/figure-context.ts"],"names":[],"mappings":";;;AAuIA,4CAWC;AAyED,0CAuCC;AAiBD,oCAyFC;AAgFD,0CAiBC;AAoBD,gDA4BC;AA7fD;;;;;;;;;;;;;;;;;GAiBG;AACH,yDAAsD;AAGtD,oHAAoH;AACvG,QAAA,qBAAqB,GAAG,OAAO,CAAA;AAE5C,kHAAkH;AAClH,MAAM,aAAa,GAAG,6BAAqB,GAAG,CAAC,CAAA;AAE/C,qGAAqG;AACrG,MAAM,aAAa,GAAG,EAAE,CAAA;AAyExB,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,CAAA;AACrE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,EAAW,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAA;AAErH,4FAA4F;AAE5F,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACrF,MAAM,SAAS,GAAG,CAAC,M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,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAClE,CAAC;IACH,CAAC,CAAA;IACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAE,CAAA;QACzC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["/**\n * What of a figure the model is shown (ADR-0061 2026-10-16 decision 4).\n *\n * 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\n * model reads at once is another question with its own number. A figure that fits is shown whole. One that does not is\n * shown as an outline -- its sections, and every part by name, shape and what it is fastened to -- and in full only the\n * parts and sections asked for, while they fit. A section too large for the outline is left out, named by its JSON\n * Pointer with the entries inside it, and read by pointer. The full source stays on the server: a proposal is applied\n * and judged on it, on the version the request was made on.\n *\n * Beside the source or the outline the view carries what the writer works from that the source does not say plainly: each\n * pipe as set-pipe takes it and the palette's token names. They are chosen inside the same budget -- a pipe with the part\n * shown, the tokens of the parts shown first -- so nothing is added to the view after it was measured (outside review\n * 2026-11-09: an outline of 2,335 characters went out as a prompt of 129,994, every pipe and token appended to it).\n *\n * A proposal on a figure shown in part changes only what it was shown: no part not read in full, and nothing inside a\n * section left out and not read. Read is what the server put before the writer, never what a model says it read.\n */\nimport { figurePipesOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureProposalStep } from '@hatiolab/figure-model'\n\n/** The most of a figure, serialized, the model is shown in one read. Not a validity limit: that is the kernel's. */\nexport const FIGURE_CONTEXT_BUDGET = 100_000\n\n/** Of the budget, what the outline's sections may take; the rest is for the parts and sections read beside it. */\nconst OUTLINE_SHARE = FIGURE_CONTEXT_BUDGET / 2\n\n/** How many entries of a section left out, or pointers in a reason, are named: the largest first. */\nconst ENTRIES_NAMED = 20\n\ntype Dynamic = any\n\nexport interface FigureOutlinePart {\n id: string\n /** The operation that makes its shape (`box@1`, `extrude@1`, ...). */\n shape?: string\n /** What it is fastened to: `<part>.<face>`, `mounting-plane`, or nothing when unfastened. */\n on?: string\n /** Its joint, and how it moves: each axis's type in order (ADR-0159); no motion for a fastening. */\n joint?: { id: string; motion?: string[] }\n material?: string\n /** How long its part read is: what reading it costs. */\n chars: number\n}\n\nexport interface FigureOmittedSection {\n /** The JSON Pointer of the section left out. */\n section: string\n chars: number\n /** Its largest entries, by pointer: what to read when the whole does not fit. */\n entries?: { section: string; chars: number }[]\n}\n\nexport interface FigureOutline {\n /** The whole source's length, and the budget it does not fit. */\n chars: number\n budget: number\n parts: FigureOutlinePart[]\n /** Parts the outline had no room to list, past the ones listed. */\n partsNotListed?: number\n /** Sections left out because they would crowd the outline. */\n omitted?: FigureOmittedSection[]\n [section: string]: unknown\n}\n\nexport interface FigurePartRead {\n appearance: Dynamic\n /** The fastenings that name it: its own (body1) and its children's (body0). */\n joints: Dynamic[]\n /** The graph nodes and constants under its name: `<part>` and `<part>.*` (a part id has no dot). */\n nodes: Dynamic[]\n constants: Dynamic[]\n}\n\nexport interface FigureReadRequest {\n parts?: readonly string[]\n /** JSON Pointers (RFC 6901) into the source, such as `/document/capabilities/bindings/0`. */\n sections?: readonly string[]\n}\n\nexport interface FigureView {\n whole: boolean\n /** Whole: the source as it is. */\n source?: FigureAsset\n outline?: FigureOutline\n /** The parts shown in full, by id, in the order asked. */\n parts?: Record<string, FigurePartRead>\n shown?: string[]\n /** The sections read, by pointer. */\n sections?: Record<string, unknown>\n /** Each pipe and duct of the parts in the view, as set-pipe takes it: every one when whole, the shown parts' in part. */\n pipes?: Record<string, unknown>\n /**\n * The palette's token names, when the view does not already hold the palette: the shown parts' first, as many as fit,\n * with how many more there are in /palette.\n */\n palette?: { tokens: string[]; more?: number }\n /** What was asked for and not shown, with why and what to read instead. */\n notRead?: ({ part: string; reason: string } | { section: string; reason: string })[]\n}\n\nconst length = (value: unknown) => JSON.stringify(value)?.length ?? 0\nconst under = (part: string) => (id: unknown) => id === part || (typeof id === 'string' && id.startsWith(`${part}.`))\n\n/* ── JSON Pointer (RFC 6901) ─────────────────────────────────────────────────────────── */\n\nconst escapeToken = (token: string) => token.replace(/~/g, '~0').replace(/\\//g, '~1')\nconst pointerOf = (tokens: readonly (string | number)[]) => tokens.map(t => `/${escapeToken(String(t))}`).join('')\nfunction tokensOf(pointer: string): string[] | undefined {\n if (typeof pointer !== 'string' || !pointer.startsWith('/')) return undefined\n return pointer.slice(1).split('/').map(t => t.replace(/~1/g, '/').replace(/~0/g, '~'))\n}\nfunction valueAt(root: unknown, tokens: readonly string[]): { found: boolean; value?: unknown } {\n let at: Dynamic = root\n for (const token of tokens) {\n if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, token)) return { found: false }\n at = at[token]\n }\n return { found: true, value: at }\n}\n/** `inner` is `outer` or inside it. */\nconst within = (inner: string, outer: string) => inner === outer || inner.startsWith(`${outer}/`)\n\n/** A value's entries by pointer, largest first, the first ENTRIES_NAMED of them. */\nfunction entriesOf(pointer: string, value: unknown): { section: string; chars: number }[] {\n if (value === null || typeof value !== 'object') return []\n const tokens = tokensOf(pointer)!\n return Object.entries(value as object)\n .map(([key, entry]) => ({ section: pointerOf([...tokens, key]), chars: length(entry) }))\n .sort((a, b) => b.chars - a.chars)\n .slice(0, ENTRIES_NAMED)\n}\n\n/* ── Parts ───────────────────────────────────────────────────────────────────────────── */\n\nexport function figurePartReadOf(asset: FigureAsset, part: string): FigurePartRead | undefined {\n const appearance = asset.appearance.find(a => a.target === part)\n if (!appearance) return undefined\n const model = asset.document.model as Dynamic\n const own = under(part)\n return {\n appearance,\n joints: ((asset as Dynamic).joints ?? []).filter((j: Dynamic) => j?.body1?.part === part || j?.body0?.part === part),\n nodes: model.nodes.filter((n: Dynamic) => own(n.id)),\n constants: model.constants.filter((c: Dynamic) => own(c.id))\n }\n}\n\n/** Where a part's records are, by pointer: for a part too large to read as one. */\nfunction partPointers(asset: FigureAsset, part: string): string[] {\n const model = asset.document.model as Dynamic\n const own = under(part)\n return [\n ...asset.appearance.flatMap((a, i) => (a.target === part ? [pointerOf(['appearance', i])] : [])),\n ...((asset as Dynamic).joints ?? []).flatMap((j: Dynamic, i: number) => (j?.body1?.part === part || j?.body0?.part === part ? [pointerOf(['joints', i])] : [])),\n ...model.nodes.flatMap((n: Dynamic, i: number) => (own(n.id) ? [pointerOf(['document', 'model', 'nodes', i])] : [])),\n ...model.constants.flatMap((c: Dynamic, i: number) => (own(c.id) ? [pointerOf(['document', 'model', 'constants', i])] : []))\n ]\n}\n\n/* ── The outline ─────────────────────────────────────────────────────────────────────── */\n\n/*\n The sections of an outline: every top-level field but the parts' records, the document's fields but its model, and the\n model's fields but its graph. Each may be left out by its pointer.\n*/\nconst PART_RECORDS = ['/document', '/appearance', '/joints', '/document/model', '/document/model/nodes', '/document/model/constants']\nfunction sectionsOf(asset: FigureAsset): string[] {\n const out: string[] = []\n const walk = (tokens: string[]) => {\n const { value } = valueAt(asset, tokens)\n for (const key of Object.keys(value as object)) {\n const pointer = pointerOf([...tokens, key])\n if (pointer === '/document' || pointer === '/document/model') walk([...tokens, key])\n else if (!PART_RECORDS.includes(pointer)) out.push(pointer)\n }\n }\n walk([])\n return out\n}\n\nfunction outlinePartsOf(asset: FigureAsset): FigureOutlinePart[] {\n const nodes = (asset.document.model as Dynamic).nodes\n const joints = (asset as Dynamic).joints ?? []\n return asset.appearance.map((look: Dynamic) => {\n const id = look.target\n const joint = joints.find((j: Dynamic) => j?.body1?.part === id)\n const body0 = joint?.body0\n const on = !joint ? undefined : body0?.part ? `${body0.part}.${body0.face}` : (body0?.plane ?? 'mounting-plane')\n const shape = nodes.find((n: Dynamic) => n.id === `${id}.shape`)?.op\n return {\n id,\n ...(shape ? { shape } : {}),\n ...(on ? { on } : {}),\n /* How it moves: each axis of its joint in order (ADR-0159); none for a fastening. */\n ...(joint ? { joint: { id: joint.id, ...(joint.motion?.length ? { motion: joint.motion.map((m: Dynamic) => m.type) } : {}) } } : {}),\n ...(look.material?.token ? { material: look.material.token } : {}),\n chars: length(figurePartReadOf(asset, id))\n }\n })\n}\n\n/** Writes a section into the outline at its pointer, making the objects on the way. */\nfunction place(outline: Dynamic, tokens: readonly string[], value: unknown) {\n let at = outline\n tokens.slice(0, -1).forEach(token => (at = at[token] ??= {}))\n at[tokens[tokens.length - 1]!] = value\n}\n\n/**\n * What the view wraps the outline in, read or not: an outline that took the whole budget left the view over it by these\n * (53 characters, a figure of 3000 long-named parts, 2026-10-19).\n */\nconst VIEW_ENVELOPE = () => length({ whole: false, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({})\n\n/**\n * The outline: within OUTLINE_SHARE for its sections, the largest left out first; and, every field counted, within the\n * budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.\n */\nexport function figureOutlineOf(asset: FigureAsset, chars = length(asset)): FigureOutline {\n const limit = FIGURE_CONTEXT_BUDGET - VIEW_ENVELOPE()\n const model = asset.document.model as Dynamic\n const sections = sectionsOf(asset).map(pointer => ({ pointer, value: valueAt(asset, tokensOf(pointer)!).value }))\n const sized = sections.map(s => ({ ...s, chars: length(s.value) })).sort((a, b) => b.chars - a.chars)\n\n let total = sized.reduce((sum, s) => sum + s.chars, 0)\n const omitted: FigureOmittedSection[] = []\n const kept = new Set(sized.map(s => s.pointer))\n for (const s of sized) {\n if (total <= OUTLINE_SHARE) break\n kept.delete(s.pointer)\n total -= s.chars\n const entries = entriesOf(s.pointer, s.value)\n omitted.push({ section: s.pointer, chars: s.chars, ...(entries.length ? { entries } : {}) })\n }\n\n const outline: Dynamic = { chars, budget: FIGURE_CONTEXT_BUDGET }\n place(outline, ['document', 'model', 'nodes'], model.nodes.length)\n place(outline, ['document', 'model', 'constants'], model.constants.length)\n for (const s of sections) if (kept.has(s.pointer)) place(outline, tokensOf(s.pointer)!, s.value)\n if (omitted.length) outline.omitted = omitted\n\n let parts: Dynamic[] = outlinePartsOf(asset)\n outline.parts = parts\n if (length(outline) > limit) outline.parts = parts = parts.map(p => ({ id: p.id }))\n if (length(outline) > limit) {\n /* As many as fit, in part order, with how many more there are. */\n let room = limit - length({ ...outline, parts: [], partsNotListed: parts.length })\n const listed: Dynamic[] = []\n for (const p of parts) {\n room -= length(p) + 1\n if (room < 0) break\n listed.push(p)\n }\n outline.parts = listed\n outline.partsNotListed = parts.length - listed.length\n }\n return outline as FigureOutline\n}\n\n/**\n * Every pipe and duct of a figure as set-pipe takes it, from one evaluation that every part shown takes its own from.\n * A figure with no swept shape is not evaluated for it.\n */\nfunction pipesOf(asset: FigureAsset): Record<string, unknown> {\n const swept = ((asset.document.model as Dynamic).nodes as Dynamic[]).some(n => typeof n?.op === 'string' && n.op.startsWith('sweep@'))\n return swept ? figurePipesOf(asset) : {}\n}\n\n/* ── The view ────────────────────────────────────────────────────────────────────────── */\n\n/**\n * The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then\n * sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.\n */\nexport function figureViewOf(asset: FigureAsset, request: FigureReadRequest = {}): FigureView {\n const chars = length(asset)\n const pipes = pipesOf(asset)\n if (chars <= FIGURE_CONTEXT_BUDGET) {\n const whole: FigureView = { whole: true, source: asset, ...(Object.keys(pipes).length ? { pipes } : {}), palette: { tokens: Object.keys(asset.palette ?? {}) } }\n if (length(whole) <= FIGURE_CONTEXT_BUDGET) return whole\n }\n\n const outline = figureOutlineOf(asset, chars)\n const view: FigureView = { whole: false, outline, parts: {}, shown: [], sections: {}, pipes: {}, notRead: [] }\n const room = () => FIGURE_CONTEXT_BUDGET - length(view)\n const refuse = (one: { part: string; reason: string } | { section: string; reason: string }) => {\n if (length(one) + 1 <= room()) view.notRead!.push(one)\n }\n\n for (const part of [...new Set(request.parts ?? [])]) {\n const one = figurePartReadOf(asset, part)\n if (!one) {\n refuse({ part, reason: `${part} is not a part of this figure; the outline lists its parts` })\n continue\n }\n /* A pipe is shown with its set-pipe reading or not at all: the reading is how its path is written back. */\n const pipe = pipes[part]\n const cost = length(one) + length(part) + length(part) + 3 + (pipe ? length(pipe) + length(part) + 2 : 0)\n view.parts![part] = one\n view.shown!.push(part)\n if (pipe) view.pipes![part] = pipe\n if (room() >= 0) continue\n delete view.parts![part]\n delete view.pipes![part]\n view.shown!.pop()\n if (cost <= FIGURE_CONTEXT_BUDGET - length(outline)) {\n refuse({ part, reason: `${part} (${cost} characters) does not fit beside what is already read; read it in another call with fewer parts or sections` })\n } else {\n const pointers = partPointers(asset, part)\n refuse({\n part,\n reason:\n `${part} (${cost} characters) is too large to show beside the outline; read its records as sections: ` +\n `${pointers.slice(0, ENTRIES_NAMED).join(', ')}${pointers.length > ENTRIES_NAMED ? ` and ${pointers.length - ENTRIES_NAMED} more` : ''}. ` +\n 'Parts read as sections are not counted as read in full: they cannot be changed'\n })\n }\n }\n\n for (const section of [...new Set(request.sections ?? [])]) {\n const tokens = tokensOf(section)\n const at = tokens && tokens.length ? valueAt(asset, tokens) : { found: false }\n if (!at.found) {\n refuse({ section, reason: `there is no section ${section}; a section is a JSON Pointer such as /document/capabilities/bindings/0` })\n continue\n }\n const cost = length(at.value) + length(section) + 2\n view.sections![section] = at.value\n if (room() >= 0) continue\n delete view.sections![section]\n const entries = entriesOf(section, at.value)\n refuse({\n section,\n reason: entries.length\n ? `${section} (${cost} characters) is too large to show at once here; read its entries: ${entries.map(e => `${e.section} (${e.chars})`).join(', ')}`\n : `${section} is one value of ${length(at.value)} characters, larger than can be shown here; it cannot be read or changed by a proposal`\n })\n }\n\n /*\n The palette's token names, where the outline left /palette out: the shown parts' tokens first, then the rest, while\n they fit; the rest are counted, and /palette is read by pointer like any section left out.\n */\n if (!view.notRead!.length) delete view.notRead\n if (!Object.keys(view.pipes!).length) delete view.pipes\n if ((outline.omitted ?? []).some(o => o.section === '/palette')) {\n const used = view.shown!.map(part => (view.parts![part]!.appearance as Dynamic)?.material?.token).filter((t): t is string => typeof t === 'string')\n const all = Object.keys(asset.palette ?? {})\n const ordered = [...new Set([...used.filter(t => all.includes(t)), ...all])]\n const palette: { tokens: string[]; more?: number } = { tokens: [], more: ordered.length }\n view.palette = palette\n for (const token of ordered) {\n palette.tokens.push(token)\n palette.more = ordered.length - palette.tokens.length\n if (room() < 0) {\n palette.tokens.pop()\n palette.more = ordered.length - palette.tokens.length\n break\n }\n }\n if (!palette.more) delete palette.more\n }\n return view\n}\n\n/* ── What a proposal may change ──────────────────────────────────────────────────────── */\n\ntype StepOf<K extends FigureProposalStep['kind']> = Extract<FigureProposalStep, { kind: K }>\ntype Subject = string | undefined\n\n/**\n * The part each kind of step changes, read from the field the kernel reads for that kind (audit D4-R1: a `part` beside a\n * `set-material`'s `target` is not read by the kernel, so it may not stand in for it). Every kind of the kernel's step\n * type is here, or this does not compile. A step that changes no one part says so with undefined: what it does to the\n * figure's sections is held by `unreadSectionEdits`.\n */\nconst SUBJECT: { [K in FigureProposalStep['kind']]: (step: StepOf<K>, base: FigureAsset) => Subject } = {\n 'add-part': () => undefined,\n 'set-section-corner': step => step.part,\n 'set-cavity': step => step.part,\n 'set-section': step => step.part,\n 'set-pipe': step => step.part,\n attach: step => step.part,\n 'link-dimension': step => step.part,\n 'follow-size': step => step.part,\n 'unlink-dimension': step => step.part,\n 'size-by-state': step => step.part,\n 'scale-position': step => step.part,\n 'fix-position': step => step.part,\n 'nudge-part': step => step.part,\n detach: step => step.part,\n 'make-repeat': step => step.part,\n 'set-repeat': step => step.part,\n 'remove-repeat': step => step.part,\n 'set-mounting-face': step => step.part,\n 'add-binding': step => step.part,\n 'set-joint': step => step.joint?.body1?.part,\n 'remove-joint': (step, base) => ((base as Dynamic).joints ?? []).find((j: Dynamic) => j?.id === step.id)?.body1?.part,\n 'set-material': step => step.target,\n 'set-segments': step => step.target,\n 'rename-part': step => step.target,\n 'set-visibility': step => step.target,\n 'remove-part': step => step.target,\n 'duplicate-part': step => step.target,\n 'mirror-part': step => step.target,\n 'move-part': step => step.target,\n 'set-placement': () => undefined,\n 'declare-instance-size': () => undefined,\n 'clear-mounting-face': () => undefined,\n 'scale-uniformly': () => undefined,\n 'follow-size-in-proportion': () => undefined,\n 'set-detail-level': () => undefined,\n 'set-item': () => undefined,\n 'add-design-input': () => undefined,\n 'set-input-range': () => undefined,\n 'publish-input': () => undefined,\n 'unpublish-input': () => undefined,\n 'remove-binding': () => undefined,\n 'set-slot-layout': () => undefined,\n 'remove-slot-layout': () => undefined,\n 'set-extension': () => undefined,\n rename: () => undefined,\n 'set-capabilities': () => undefined,\n 'set-capability-settings': () => undefined,\n 'set-state-input': () => undefined,\n 'set-state-defaults': () => undefined,\n 'set-driver': () => undefined,\n 'remove-driver': () => undefined,\n 'set-clip': () => undefined,\n 'copy-clip': () => undefined,\n 'set-motion-group': () => undefined,\n 'remove-motion-group': () => undefined,\n 'set-data-schema': () => undefined,\n 'rename-data-field': () => undefined,\n 'set-data-binding': () => undefined,\n 'remove-data-binding': () => undefined\n}\n\n/**\n * 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\n * named to fasten to or to follow -- the kernel works from it, nothing about it is guessed -- and a new part is the\n * steps' own. A kind this table does not know is refused: it is not let through unjudged.\n */\nexport function unreadPartEdits(base: FigureAsset, steps: readonly FigureProposalStep[], view: FigureView): string[] {\n const existing = new Set(base.appearance.map(a => a.target))\n const shown = new Set(view.shown ?? [])\n const allowed = [...shown].join(', ') || 'none'\n return steps.flatMap((step, i) => {\n const kind = (step as Dynamic)?.kind\n if (typeof kind !== 'string') return []\n const judge = (SUBJECT as Record<string, (step: Dynamic, base: FigureAsset) => Subject>)[kind]\n if (!Object.prototype.hasOwnProperty.call(SUBJECT, kind) || !judge)\n return [`UNKNOWN_STEP: steps[${i}] has the kind \"${kind}\", which is not one of the commands; use only the commands taught.`]\n const part = judge(step, base)\n if (typeof part !== 'string' || !existing.has(part) || shown.has(part)) return []\n return [\n `UNREAD_PART: steps[${i}] (${kind}) changes \"${part}\", which was not shown in full, so its source is not known here. ` +\n `Change only the parts shown in full (${allowed}) or parts the steps add. To change ${part}, read it with getFigureSource parts and pass it in parts to proposeFigureCandidate.`\n ]\n })\n}\n\n/** Entries of a value, keyed by `id` when every entry of a list has a distinct one, else by place. */\nfunction keyedEntries(value: unknown): Map<string, { token: string; value: unknown }> {\n const out = new Map<string, { token: string; value: unknown }>()\n if (Array.isArray(value)) {\n const ids = value.map(v => (v && typeof v === 'object' && typeof (v as Dynamic).id === 'string' ? (v as Dynamic).id : undefined))\n const byId = ids.every(Boolean) && new Set(ids).size === ids.length\n value.forEach((v, i) => out.set(byId ? `id:${ids[i]}` : `at:${i}`, { token: String(i), value: v }))\n } else if (value && typeof value === 'object') {\n for (const [key, v] of Object.entries(value)) out.set(`key:${key}`, { token: key, value: v })\n }\n return out\n}\n\n/**\n * What of the sections left out of the outline and not read the steps changed, as reasons said back to the writer. Judged\n * on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a\n * record in a list, a key in a map -- is the steps' own.\n */\nexport function unreadSectionEdits(base: FigureAsset, after: FigureAsset, view: FigureView): string[] {\n const read = Object.keys(view.sections ?? {})\n const reasons: string[] = []\n const say = (pointer: string, what: string) =>\n reasons.push(\n `UNREAD_SECTION: the steps ${what} ${pointer}, which was left out of the outline and not read, so it is not known here. ` +\n `Leave it as it is; to change it, read it with getFigureSource sections and pass it in sections to proposeFigureCandidate.`\n )\n const check = (pointer: string, before: unknown, now: unknown) => {\n if (reasons.length >= ENTRIES_NAMED || read.some(r => within(pointer, r))) return\n const records = (v: unknown) => v !== null && typeof v === 'object'\n if (!records(before) || !records(now) || Array.isArray(before) !== Array.isArray(now)) {\n if (JSON.stringify(before) !== JSON.stringify(now)) say(pointer, 'change')\n return\n }\n const later = keyedEntries(now)\n for (const [key, entry] of keyedEntries(before)) {\n const child = `${pointer}/${escapeToken(entry.token)}`\n const kept = later.get(key)\n if (kept) check(child, entry.value, kept.value)\n else if (!read.some(r => within(child, r))) say(child, 'remove')\n }\n }\n for (const omitted of view.outline?.omitted ?? []) {\n const tokens = tokensOf(omitted.section)!\n check(omitted.section, valueAt(base, tokens).value, valueAt(after, tokens).value)\n }\n return reasons\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-format.js","sourceRoot":"","sources":["../../../server/service/figure/figure-format.ts"],"names":[],"mappings":";;;AA2EA,gEAMC;AA0CD,kCAmBC;AAuFD,sCA0DC;AAicD,0CAyBC;AAOD,oDAGC;AAMD,kDAKC;AA9wBD;;;;;GAKG;AACH,yDAAyV;AAKzV,uDAAuD;AAC1C,QAAA,oBAAoB,GAAG,gBAAgB,CAAA;AAapD,sDAAsD;AACtD,MAAa,iBAAkB,SAAQ,KAAK;IAG1C,YAAY,QAAyB;QACnC,KAAK,CAAC,iBAAiB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AARD,8CAQC;AAsCD,MAAM,aAAa,GAAyB,EAAE,CAAA;AAE9C,sHAAsH;AACtH,SAAgB,0BAA0B,CAAC,KAAyB;IAClE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,OAAO,GAAG,EAAE;QACV,MAAM,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,EAAE,IAAI,CAAC;YAAE,aAAa,CAAC,MAAM,CAAC,EA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,SAAgB,oBAAoB,CAAC,YAAoB;IACvD,YAAY,CAAC,YAAY,CAAC,CAAA;IAC1B,OAAO,IAAA,mCAAoB,EAAC,IAAA,yCAA0B,EAAC,IAAA,+BAAgB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAA;AACzF,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,UAAkB;IACpD,YAAY,CAAC,UAAU,CAAC,CAAA;IACxB,MAAM,KAAK,GAAG,IAAA,+BAAgB,EAAC,UAAU,CAAC,CAAA;IAC1C,IAAA,iCAAkB,EAAC,KAAK,CAAC,CAAA;IACzB,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC","sourcesContent":["/*\n * The doors a stored source goes through: saving (`parseSource`), publishing (`inspectSource`, and the release's own\n * copy in `releaseRecordOf`), bringing a release back as a draft (`draftSourceOfRelease`) and handing it to a board\n * (`consumablePayloadOf`). The format is `figure-asset-1`, and the asset says so in its `version`; a source\n * that does not is refused by name, because a source the server cannot identify is one it must not save.\n */\nimport { FIGURE_KERNEL_VERSION, compileFigureAsset, inspectFigureAsset, isPlaceholderType, parseFigureAsset, serializeFigureAsset, figureContractChanges, figureCostOf, figureItemNotesOf, figurePlaneGapOf, figureReleaseMetricsOf, figureScoreOf, figureTopViewOf, forgetRecordedInstanceSize, recordFigureInstanceSize } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureContractChange, FigureContractError, FigureReleaseMetrics, FigureTopView, FigureViolation } from '@hatiolab/figure-model'\n\nimport type { FigureFinding } from './figure-type.js'\n\n/** The version the format stamps on its own source. */\nexport const FIGURE_ASSET_VERSION = 'figure-asset-1'\n\n/** A source that passed the save door: what is stored, and the numbers the catalogue shows, computed here. */\nexport interface ParsedSource {\n /** The source to store, as the kernel serializes it. */\n source: string\n /** Computed from the source, never taken from the client -- a client's numbers could lie to the catalogue. */\n /** The catalogue's columns read from the source: its name, and the measures the card shows. */\n derived: { name: string; score: number; triangles: number; groups: number }\n /** Findings that do not block the save; the caller returns them with the answer. */\n violations: FigureFinding[]\n}\n\n/** The source breaks the format. It is not stored. */\nexport class FigureSourceError extends Error {\n readonly findings: FigureFinding[]\n\n constructor(findings: FigureFinding[]) {\n super(`정본이 형식을 어겼다 — ${findings.length}건: ${findings.map(f => f.code).join(', ')}`)\n this.name = 'FigureSourceError'\n this.findings = findings\n }\n}\n\n/** One thing the release gate found. `blocking` true means the figure cannot be published. */\nexport interface GateFinding {\n code: string\n message: string\n /** **Why it matters.** A measurement alone leaves the reader at \"so what?\". */\n why?: string\n /** **What to change.** By part name and value. */\n how?: string\n /** Where it points: the parts, or the path in the source. */\n at?: string\n blocking: boolean\n /** The released contract breaks: saved as a new figure type, the edits release and the placed figures keep the old one. */\n asNewType?: boolean\n}\n\nexport interface Inspection {\n findings: GateFinding[]\n /** Whether anything blocks. The screen locks the button with this. */\n blocked: boolean\n}\n\n/** What an app's release check is shown: the figure's asset, its row's type and category, and the reader's words. */\nexport interface FigureReleaseCheckInput {\n asset: FigureAsset\n type?: string\n category?: string | null\n t?: Translate\n}\n\n/**\n * A check an app adds to releasing (LV figure-server design G10): findings in the gate's own shape, blocking or said.\n * The LV figure-server refuses an origin off the middle of the floor, a receiving side's check (ADR-0104 decision 4),\n * and says its carrier and budget advice.\n */\nexport type FigureReleaseCheck = (input: FigureReleaseCheckInput) => GateFinding[]\n\nconst releaseChecks: FigureReleaseCheck[] = []\n\n/** Adds a check to every release verdict (`inspectFigure`, `releaseFigure`). Returns the way to take it off again. */\nexport function registerFigureReleaseCheck(check: FigureReleaseCheck): () => void {\n releaseChecks.push(check)\n return () => {\n const at = releaseChecks.indexOf(check)\n if (at >= 0) releaseChecks.splice(at, 1)\n }\n}\n\n/** The app's checks on an asset the kernel passed. A check that throws blocks, by name: a check is never skipped. */\nfunction appFindings(input: FigureReleaseCheckInput): GateFinding[] {\n const found: GateFinding[] = []\n for (const check of releaseChecks) {\n try {\n found.push(...check(input))\n } catch (e) {\n found.push({ code: 'release-check-failed', message: `a release check failed: ${(e as Error)?.message ?? String(e)}`, blocking: true })\n }\n }\n return found\n}\n\n/**\n * That the source is JSON and names the format.\n *\n * @throws {FigureSourceError} when the text is not JSON, or does not carry `version: 'figure-asset-1'`.\n */\nfunction assertFormat(sourceJson: string): void {\n let parsed: unknown\n try {\n parsed = JSON.parse(sourceJson)\n } catch (e) {\n throw new FigureSourceError([\n { code: 'source-not-json', message: `정본이 JSON 이 아니다: ${(e as Error).message}`, at: 'source' }\n ])\n }\n if ((parsed as { version?: unknown } | null)?.version !== FIGURE_ASSET_VERSION)\n throw new FigureSourceError([\n { code: 'source-format-unknown', message: `정본의 버전을 알 수 없다 — 피규어 자산은 version '${FIGURE_ASSET_VERSION}' 을 적는다`, at: 'version' }\n ])\n}\n\n/**\n * Validates a source and computes what the catalogue shows: the cost from `figureCostOf`, and the score from `figureScoreOf`\n * -- the headroom against placing `LIMITS.screenInstances` of it on one screen (chief architect, 2026-09-24), the\n * same number the modeller's maturity tab shows. An asset that draws nothing has no score, not a full one.\n *\n * @throws {FigureSourceError} when the source breaks the format.\n */\nexport function parseSource(sourceJson: string): ParsedSource {\n assertFormat(sourceJson)\n let asset\n try {\n asset = parseFigureAsset(sourceJson)\n compileFigureAsset(asset)\n } catch (e) {\n const error = e as FigureContractError & { path?: string }\n throw new FigureSourceError([\n { code: error.code ?? 'asset-invalid', message: error.message ?? String(e), at: error.path }\n ])\n }\n const cost = figureCostOf(asset)\n const score = figureScoreOf(asset)\n return {\n source: serializeFigureAsset(asset),\n derived: { name: asset.name, score: (score?.score ?? null) as unknown as number, triangles: cost.triangles, groups: cost.groups },\n violations: []\n }\n}\n\n/**\n * Whether this source may be published, and why not.\n *\n * The judgement is `inspectFigureAsset`: every part inside the volume the asset declares, over the whole\n * state range, and the face it says it is mounted on lying in that plane. A verdict reached by sampling is\n * reported as a finding of its own rather than hidden — an author releasing a figure the gate could only\n * sample should be told so, because nothing proved it holds between the states that were checked.\n */\n/** The request's translator. Always called with params — `t(key, undefined)` loses the locale. */\nexport type Translate = (key: string, options?: Record<string, unknown>) => string\n\n/**\n * A finding in the words of the release panel.\n *\n * The gate says what it measured as a code and values (`part`, `axis`, `mm`, `degrees`) and an English `detail`\n * for logs. The sentence an author reads is made here, where the request's language is known (ADR-0054) — not in\n * figure-model, which knows no locale, and not on the screen, which would then have a second account of the same\n * refusal. The English line is the fallback when a key is missing, so a missing translation reads as English\n * rather than as the key printed raw.\n *\n * The words are the modeller's (ADR-0097 §9 Q2 A): 「차지하는 공간」 for the volume a figure takes up, 「부품에 맞추기」 for\n * setting it from the parts, and 「장착면」 for the face it stands on (`figure.text.mounting-face-explained`). A fact, then the way out.\n */\nfunction figureWording(violation: FigureViolation, say: Say): Pick<GateFinding, 'message' | 'why' | 'how'> {\n const part = violation.part ?? ''\n const axis = (violation.axis ?? '').toUpperCase()\n const mm = violation.mm ?? 0\n const degrees = violation.degrees ?? 0\n const key = (field: string) => `figure.gate.${violation.code.toLowerCase().replace(/_/g, '-')}.${field}`\n\n switch (violation.code) {\n case 'PARTS_OFF_PLACEMENT_FACE':\n return {\n message: say(key('message'), { part, mm }, `The mounting face of '${part}' is ${mm} mm off the plane the figure stands on.`),\n why: say(key('why'), {}, 'The figure is declared to stand on that face. If the face does not reach the plane, the figure floats on the board by that much, and whatever is placed on it floats too.'),\n how: say(key('how'), { part, mm }, `Move '${part}' ${mm} mm on Y so the face meets the plane, or choose a different mounting face.`)\n }\n case 'PLACEMENT_FACE_TILTED':\n return {\n message: say(key('message'), { part, degrees }, `The mounting face of '${part}' is tilted ${degrees}° from the plane the figure stands on.`),\n why: say(key('why'), {}, 'A tilted face cannot lie on the plane, so how the figure stands is not settled.'),\n how: say(key('how'), { part }, `Choose a mounting face parallel to the plane, or turn '${part}' upright.`)\n }\n case 'PARTS_SPLIT_ON_RESIZE': {\n /*\n What comes off is every piece but the largest — the figure as the author sees it is the big piece, and the\n small ones are what they will see hanging in the air (2026-09-24).\n */\n const resize = violation.resize!\n const pieces = [...resize.pieces].sort((a, b) => b.length - a.length)\n const parts = pieces.slice(1).flat().map(one => `'${one}'`).join(', ')\n const axes = resize.axes.map(one => one.toUpperCase()).join('·')\n const factor = resize.factor\n return {\n message: say(key('message'), { parts, axes, factor }, `At ${factor}x on ${axes}, ${parts} come away from the rest of the figure.`),\n why: say(key('why'), {}, 'A figure placed at another size shows those parts hanging in the air — to a person, it looks broken.'),\n how: say(key('how'), { parts }, `Fasten ${parts} to a face of the part they rest on, or press \"fix here\" under position in the size tab, so they stay put when the figure is resized.`)\n }\n }\n case 'SIZING_NOT_UNIFORM': {\n /* The figure declares it grows by one ratio; these parts keep a size or place of their own (ruling 2026-09-24). */\n const resize = violation.resize!\n const parts = (violation.parts ?? []).map(one => `'${one}'`).join(', ')\n const axes = resize.axes.map(one => one.toUpperCase()).join('·')\n const factor = resize.factor\n return {\n message: say(key('message'), { parts, axes, factor }, `The figure grows by one ratio, but at ${factor}x on ${axes} ${parts} do not grow with it.`),\n why: say(key('why'), {}, 'A figure that grows by one ratio keeps its proportions at any size. A part with a size or place of its own comes apart from the rest.'),\n 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.`)\n }\n }\n }\n}\n\ntype Say = (key: string, params: Record<string, string | number>, english: string) => string\n\n/*\n The sentence is shown as text, never as HTML, so the values go in as they are. i18next escapes interpolated\n values by default, and the screen then showed `'lamp-in'` as `&#39;lamp-in&#39;`.\n*/\nfunction sayerOf(t?: Translate): Say {\n return (key, params, english) =>\n t ? t(key, { ...params, defaultValue: english, interpolation: { escapeValue: false } }) : english\n}\n\nexport function inspectSource(\n sourceJson?: string | null,\n releasedJson?: string | null,\n t?: Translate,\n /** The row's `type` -- the only place the name lives, since the asset carries none. */\n rowType?: string,\n /** The row's category, for an app's release checks (G10). */\n rowCategory?: string | null\n): Inspection {\n if (!sourceJson) {\n return { blocked: true, findings: [{ code: 'no-source', message: '저장된 정본이 없다. 저장하면 발행할 수 있다', blocking: true }] }\n }\n try {\n assertFormat(sourceJson)\n } catch (e) {\n const findings = (e as FigureSourceError).findings ?? [{ code: 'source-unreadable', message: String(e) }]\n return { blocked: true, findings: findings.map(f => ({ ...f, blocking: true })) }\n }\n\n let inspection\n let asset: FigureAsset | undefined\n try {\n asset = parseFigureAsset(sourceJson)\n inspection = inspectFigureAsset(asset)\n } catch (e) {\n const error = e as FigureContractError & { path?: string }\n return {\n blocked: true,\n findings: [{ code: error.code ?? 'asset-invalid', message: error.message ?? String(e), at: error.path, blocking: true }]\n }\n }\n\n const say = sayerOf(t)\n const findings: GateFinding[] = inspection.violations.map(violation => ({\n code: violation.code.toLowerCase().replace(/_/g, '-'),\n ...figureWording(violation, say),\n at: violation.part,\n blocking: true\n }))\n /*\n A machine-made name is refused at release. The asset has no `type`, so the name is read off the row; a new figure\n was once published as `FIGURE_<uuid>` (:3300, 2026-09-24). Publishing freezes the name (ADR-0063 decision 4) and\n boards call a figure by it.\n */\n if (rowType && isPlaceholderType(rowType)) {\n findings.push({\n code: 'type-is-placeholder',\n message: say('figure.gate.type-is-placeholder.message', { type: rowType }, `'${rowType}' is a temporary type given when the figure was first saved.`),\n why: say('figure.gate.type-is-placeholder.why', {}, 'Boards call a figure by its type, and it cannot change once the figure is published.'),\n how: say('figure.gate.type-is-placeholder.how', {}, 'Set the type in the type field, then publish.'),\n blocking: true\n })\n }\n findings.push(...planeGapFindings(asset!, say))\n findings.push(...itemFindings(asset!, say))\n if (releasedJson) findings.push(...figureContractFindings(asset!, releasedJson, say))\n findings.push(...appFindings({ asset: asset!, type: rowType, category: rowCategory, t }))\n return { blocked: findings.some(finding => finding.blocking), findings }\n}\n\n/*\n Said, never refused: a figure off the plane it is mounted on stands off it on every board -- a conveyor in the air, a\n hoist hung below a floor figure (the walk of 2026-10-18 found each passing release with no word). A gap can be meant,\n and so can a part through the plane, so it does not block. A figure that names its mounting face is checked on that\n face by the gate already; this is for the one that names none.\n*/\ntype Gap = { part: string; mm: number }\nconst PLANE_ENGLISH = {\n floor: {\n clear: (g: Gap) => `'${g.part}' is ${g.mm} mm above the floor.`,\n through: (g: Gap) => `'${g.part}' goes ${g.mm} mm below the floor.`,\n beyond: 'Every part is below the floor.',\n why: 'A board stands this figure on the floor, so it stands so on every board.',\n beyondHow: 'If it hangs from the ceiling, set where it stands to the ceiling.'\n },\n ceiling: {\n clear: (g: Gap) => `'${g.part}' is ${g.mm} mm below the ceiling.`,\n through: (g: Gap) => `'${g.part}' goes ${g.mm} mm above the ceiling.`,\n beyond: 'Every part is above the ceiling.',\n why: 'A board hangs this figure from the ceiling, so it hangs so on every board.',\n beyondHow: 'If it stands on the floor, set where it stands to the floor.'\n },\n wall: {\n clear: (g: Gap) => `'${g.part}' is ${g.mm} mm out from the wall.`,\n through: (g: Gap) => `'${g.part}' goes ${g.mm} mm into the wall.`,\n beyond: 'Every part is behind the wall.',\n why: 'A board puts this figure on the wall, so it sits so on every board.',\n beyondHow: 'Bring the parts out in front of the wall, or choose again where it stands.'\n }\n} as const\nfunction planeGapFindings(asset: FigureAsset, say: Say): GateFinding[] {\n if (asset.mountingFace) return []\n const gap = figurePlaneGapOf(asset)\n if (!gap || gap.touches) return []\n const english = PLANE_ENGLISH[gap.placement]\n const key = `figure.gate.off-mounting-plane.${gap.placement}`\n const kind = gap.beyond ? 'beyond' : gap.mm > 0 ? 'clear' : 'through'\n const said = { part: gap.part, mm: Math.round(Math.abs(gap.mm)) }\n return [\n {\n code: 'off-mounting-plane',\n message: say(`${key}.${kind}.message`, said, kind === 'beyond' ? english.beyond : english[kind](said)),\n why: say(`${key}.why`, {}, english.why),\n how:\n kind === 'beyond'\n ? say(`${key}.beyond.how`, {}, english.beyondHow)\n : say('figure.gate.off-mounting-plane.how', {}, 'Keep it if it is meant. Otherwise fasten that part to the mounting plane, or move it until it meets the plane.'),\n at: gap.part,\n blocking: false\n }\n ]\n}\n\n/*\n Said, never refused (ADR-0155 amendment 2): what a figure tagged as an item lacks for a seat to show it as its author\n expects, and whether it also holds. A figure may be an item without any of them.\n*/\nconst ITEM_ENGLISH = {\n 'item-mounting-face-missing': {\n message: 'This item names no mounting face.',\n why: 'An item stands in its seat on the bottom of its body. Naming the face it stands on lets the release check that this face is at the bottom.',\n how: 'Name its mounting face, or keep it if the bottom of its body is where it stands.'\n },\n 'item-size-inputs-missing': {\n message: 'This item cannot be resized by a drawing.',\n why: 'A seat gives an item its size. Without size inputs it grows in proportion and fills the seat along one side only.',\n how: 'Let a drawing resize it if it should fill its seat; keep it if it should keep its proportions.'\n },\n 'item-also-holder': {\n message: 'This item also holds things.',\n why: 'A holder carried by another holder holding things of its own is not supported by scenes yet.',\n how: 'Keep it if it is meant.'\n }\n} as const\nfunction itemFindings(asset: FigureAsset, say: Say): GateFinding[] {\n return figureItemNotesOf(asset).map(code => ({\n code,\n message: say(`figure.gate.${code}.message`, {}, ITEM_ENGLISH[code].message),\n why: say(`figure.gate.${code}.why`, {}, ITEM_ENGLISH[code].why),\n how: say(`figure.gate.${code}.how`, {}, ITEM_ENGLISH[code].how),\n blocking: false\n }))\n}\n\n/**\n * The last release against this one — what the drawings that already hold this type lean on (ADR-0063 decision 3).\n *\n * figure-model names the changes and whether each blocks (`figureContractChanges`); the sentence is made here. When\n * the last release no longer parses, the gate says so rather than passing in silence: a release that was not checked\n * against the last one is a different fact from one that was checked and found safe.\n */\nfunction figureContractFindings(asset: FigureAsset, releasedJson: string, say: Say): GateFinding[] {\n let before: FigureAsset\n try {\n before = parseFigureAsset(releasedJson)\n } catch (e) {\n return [\n {\n code: 'released-unreadable',\n message: say('figure.gate.released-not-compared.message', { reason: (e as Error).message }, `The last release could not be read, so this release was not compared with it: ${(e as Error).message}`),\n why: say('figure.gate.released-not-compared.why', {}, 'Whether this release breaks the instances already placed has not been checked.'),\n blocking: false\n }\n ]\n }\n return figureContractChanges(before, asset).map(change => ({\n code: change.code,\n ...figureContractWording(change, say),\n at: change.subject,\n blocking: change.blocking,\n ...(change.blocking ? { asNewType: true } : {})\n }))\n}\n\n/** One contract change in the words of the release panel. The English line is the fallback for a missing key. */\nfunction figureContractWording(change: FigureContractChange, say: Say): Pick<GateFinding, 'message' | 'why' | 'how'> {\n const v = change.values\n const key = (field: string) => `figure.gate.contract.${change.code}.${field}`\n const gone = {\n how: say('figure.gate.contract.gone.how', {}, 'Put it back as it was, or publish this as a new figure type so the placed ones keep the old one.')\n }\n switch (change.code) {\n case 'placement-changed':\n return {\n message: say(key('message'), v, `Placement changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'Placement sets the height of every placed instance. They all move with it.'),\n ...gone\n }\n case 'size-inputs-gone':\n return {\n message: say(key('message'), v, 'The figure no longer takes its size from the place it is given.'),\n why: say(key('why'), {}, 'Placed instances were sized on the board. After this release they all draw at the authored size.'),\n ...gone\n }\n case 'size-inputs-added':\n return {\n message: say(key('message'), v, 'The figure now takes its size from the place it is given.'),\n why: say(key('why'), {}, 'Placed instances now follow their own size on the board.')\n }\n case 'size-range-narrowed':\n return {\n message: say(key('message'), { ...v, input: change.subject ?? '' }, `The size range of ${change.subject} narrowed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'An instance placed at a size outside the new range will not draw. Which sizes are placed is not recorded.')\n }\n case 'authored-size-changed':\n return {\n message: say(key('message'), v, `The authored size changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'Placed instances keep their own size. An instance with no depth of its own takes its depth from this.')\n }\n case 'state-input-gone':\n return {\n message: say(key('message'), v, `The control '${v.id}' is gone.`),\n why: say(key('why'), {}, 'Placed instances and connectors give values under this name. After this release those values do nothing, and nothing on screen says why.'),\n ...gone\n }\n case 'state-unit-changed':\n return {\n message: say(key('message'), v, `The unit of the control '${v.id}' changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'Stored values keep their number. With another unit the same number means something else.'),\n ...gone\n }\n case 'state-range-narrowed':\n return {\n message: say(key('message'), v, `The range of the control '${v.id}' narrowed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'A value outside the new range may already be stored on a placed instance.')\n }\n case 'state-input-added':\n return {\n message: say(key('message'), v, `The control '${v.id}' is new.`),\n why: say(key('why'), {}, 'Placed instances that give no value stand at its default.')\n }\n case 'clip-gone':\n return {\n message: say(key('message'), v, `The clip '${v.clip}' is gone.`),\n why: say(key('why'), {}, 'Placed instances play clips by name. After this release that one plays nothing.'),\n ...gone\n }\n case 'clip-added':\n return {\n message: say(key('message'), v, `The clip '${v.clip}' is new.`),\n why: say(key('why'), {}, 'It stays still until an instance plays it.')\n }\n case 'binding-gone':\n return {\n message: say(key('message'), v, `The place '${v.binding}' is gone.`),\n why: say(key('why'), {}, 'What sits in it on a placed instance loses its place.'),\n ...gone\n }\n case 'binding-role-changed':\n return {\n message: say(key('message'), v, `The place '${v.binding}' changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'What sits in it was placed for the old role.'),\n ...gone\n }\n case 'binding-capacity-reduced':\n return {\n message: say(key('message'), v, `The place '${v.binding}' holds ${v.after} instead of ${v.before}.`),\n why: say(key('why'), {}, 'What sits in the places that went has nowhere to go.'),\n ...gone\n }\n case 'binding-accepts-narrowed':\n return {\n message: say(key('message'), v, `The place '${v.binding}' no longer accepts ${v.types}.`),\n why: say(key('why'), {}, 'What already sits there stays. The next one of that type is refused.')\n }\n case 'binding-added':\n return {\n message: say(key('message'), v, `The place '${v.binding}' is new.`),\n why: say(key('why'), {}, 'Placed instances do not know it yet and stand as they are.')\n }\n /* Slots a slot layout unfolds into, and the anchors they stand on (ADR-0051 §4.1, the old ADR-0118 decision 6). */\n case 'slot-moved':\n return {\n message: say(key('message'), v, `The slot '${v.binding}' is somewhere else on its anchor.`),\n why: say(key('why'), {}, 'What sits in it moves with it. Data that names the slot by its address now means the new place.')\n }\n case 'slot-anchor-gone':\n return {\n message: say(key('message'), v, `The anchor '${v.anchor}' that slots stand on is gone.`),\n why: say(key('why'), {}, 'A placement that lays its own slots on this anchor holds nothing after this release.'),\n ...gone\n }\n case 'slot-anchor-moved':\n return {\n message: say(key('message'), v, `The anchor '${v.anchor}' moved from the ${v.before} face to the ${v.after} face.`),\n why: say(key('why'), {}, 'Every slot on it, and what sits there, stands on the new face after this release.')\n }\n case 'capability-gone':\n return {\n message: say(key('message'), v, `The capability '${v.name}' is gone.`),\n why: say(key('why'), {}, 'Scenes attach behaviour by this name. Placed instances lose what it did.'),\n ...gone\n }\n case 'capability-added':\n return {\n message: say(key('message'), v, `The capability '${v.name}' is new.`),\n why: say(key('why'), {}, 'It adds what the figure can do. Placed instances stand as they are.')\n }\n case 'item-gone':\n return {\n message: say(key('message'), v, 'The figure is no longer an item.'),\n why: say(key('why'), {}, 'Item type tables draw their items with this figure. They lose its look.'),\n ...gone\n }\n case 'item-added':\n return {\n message: say(key('message'), v, 'The figure is now an item.'),\n why: say(key('why'), {}, 'Item type tables can draw their items with it. Placed instances stand as they are.')\n }\n /* Said, never refused (ADR-0104): a consumer that pins a release reads these before it moves to this one. */\n case 'size-changed':\n return {\n message: say(key('message'), v, `The figure's size changed from ${v.before || 'none'} to ${v.after || 'none'}.`),\n why: say(key('why'), {}, 'A board gives the figure a box of this size. One that moves to this release sees its box change.')\n }\n case 'motion-range-changed':\n return {\n message: say(key('message'), v, `The room the figure sweeps as it moves changed from ${v.before || 'none'} to ${v.after || 'none'}.`),\n why: say(key('why'), {}, 'It is what the figure reaches when it moves. One that moves to this release sees it reach differently.')\n }\n case 'contact-face-changed':\n return {\n message: say(key('message'), v, 'The face the figure is mounted by changed.'),\n why: say(key('why'), {}, 'A consumer that moves to this release sees it stand on the new face.')\n }\n case 'public-input-gone':\n return {\n message: say(key('message'), { ...v, input: change.subject ?? '' }, `'${change.subject}' is no longer set on a board.`),\n why: say(key('why'), {}, 'Values placed instances give it do nothing after this release.')\n }\n case 'public-input-range-narrowed':\n return {\n message: say(key('message'), { ...v, input: change.subject ?? '' }, `The range of '${change.subject}' narrowed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'An instance may have set a value outside the new range. Which values are placed is not recorded.')\n }\n case 'public-input-added':\n return {\n message: say(key('message'), { ...v, input: change.subject ?? '' }, `'${change.subject}' can now be set on a board.`),\n why: say(key('why'), {}, 'Placed instances that give no value stand at its default.')\n }\n /* A value another product reads by its key (ADR-0123): only a key that goes refuses; what a change means is its owner's. */\n case 'extension-gone':\n return {\n message: say(key('message'), v, `The extension '${v.key}' is gone.`),\n why: say(key('why'), {}, 'Another product reads this value by its key. After this release it finds none.'),\n ...gone\n }\n case 'extension-changed':\n return {\n message: say(key('message'), v, `The value of the extension '${v.key}' changed.`),\n why: say(key('why'), {}, 'The product that owns this key reads the new value and judges the change.')\n }\n case 'extension-added':\n return {\n message: say(key('message'), v, `The extension '${v.key}' is new.`),\n why: say(key('why'), {}, 'The product that owns this key reads this value.')\n }\n /* What a consumer's data mapping and a board's motion selection lean on (ADR-0051 §2.2, §3.2). */\n case 'data-field-gone':\n return {\n message: say(key('message'), v, `The data field '${v.id}' is gone.`),\n why: say(key('why'), {}, 'Boards map their data onto this id. After this release that data moves nothing.'),\n ...gone\n }\n case 'data-field-kind-changed':\n return {\n message: say(key('message'), v, `The data field '${v.id}' changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'Mapped data was written for the old kind or unit. After this release the same data is refused or means something else.'),\n ...gone\n }\n case 'data-field-narrowed':\n return {\n message: say(key('message'), v, `The data field '${v.id}' takes less: ${v.before} → ${v.after}.`),\n why: say(key('why'), {}, 'Data with a value it no longer takes is refused whole, and the figure keeps what it showed.'),\n ...gone\n }\n case 'data-field-added':\n return {\n message: say(key('message'), v, `The data field '${v.id}' is new.`),\n why: say(key('why'), {}, 'Until a board maps data onto it, it stands at its default.')\n }\n case 'data-field-label-changed':\n return {\n message: say(key('message'), v, `The data field '${v.id}' is now called '${v.after}'.`),\n why: say(key('why'), {}, 'Mappings name the id, so they keep working.')\n }\n case 'data-field-default-changed':\n return {\n message: say(key('message'), v, `The default of the data field '${v.id}' changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, 'A placed figure with no data or saved value for it stands differently after this release.')\n }\n case 'data-bindings-changed':\n return {\n message: say(key('message'), v, 'What the data moves (its bindings) changed.'),\n why: say(key('why'), {}, 'The same data gives another pose, colour or clip after this release.')\n }\n case 'motion-group-gone':\n return {\n message: say(key('message'), v, `The motion group '${v.group}' is gone.`),\n why: say(key('why'), {}, 'Boards and data choose its clip by this id. After this release that choice does nothing.'),\n ...gone\n }\n case 'motion-group-clip-removed':\n return {\n message: say(key('message'), v, `The motion group '${v.group}' no longer holds '${v.clip}'.`),\n why: say(key('why'), {}, 'A board or data that chooses this clip in the group is refused after this release.'),\n ...gone\n }\n case 'motion-clip-group-changed':\n return {\n message: say(key('message'), v, `The clip '${v.clip}' played on its own and is now in the motion group '${v.group}'.`),\n why: say(key('why'), {}, \"Boards played it by its own speed. After this release it plays only when the group's choice is this clip.\"),\n ...gone\n }\n case 'motion-group-added':\n return {\n message: say(key('message'), v, `The motion group '${v.group}' is new.`),\n why: say(key('why'), {}, 'Placed instances play its default clip until a board or data chooses another.')\n }\n case 'motion-group-clip-added':\n return {\n message: say(key('message'), v, `The motion group '${v.group}' now holds '${v.clip}'.`),\n why: say(key('why'), {}, 'It plays when a board or data chooses it.')\n }\n case 'motion-group-default-changed':\n return {\n message: say(key('message'), v, `The motion group '${v.group}' now starts with '${v.after}', not '${v.before}'.`),\n why: say(key('why'), {}, 'Placed instances with no choice of their own play the new default after this release.')\n }\n case 'motion-group-transition-changed':\n return {\n message: say(key('message'), v, `A change of clip in '${v.group}' now blends over ${v.after} s, not ${v.before} s.`),\n why: say(key('why'), {}, 'Only how a change of clip looks changes; which clip plays does not.')\n }\n /* What a legend leans on (ADR-0166 14): a table binding, the parts, controls and motion group it shows on, its role. */\n case 'data-table-gone':\n return {\n message: say(key('message'), v, `The table '${v.binding}' is gone.`),\n why: say(key('why'), {}, \"A legend a board or fmsim chose for this table's role has nothing to show on after this release.\"),\n ...gone\n }\n case 'data-table-target-withdrawn':\n return {\n message: say(key('message'), v, `The table '${v.binding}' no longer shows on the ${v.target} '${v.id}'.`),\n why: say(key('why'), {}, 'What a legend gave this target -- a colour, an effect, a value, a clip -- changes nothing after this release.'),\n ...gone\n }\n case 'data-table-added':\n return {\n message: say(key('message'), v, `There is a new table '${v.binding}'.`),\n why: say(key('why'), {}, \"Once the data gives a value it shows by the figure's table, or by the legend chosen for its role.\")\n }\n case 'data-table-target-added':\n return {\n message: say(key('message'), v, `The table '${v.binding}' now also shows on the ${v.target} '${v.id}'.`),\n why: say(key('why'), {}, \"If a legend has this target's column, it shows there too after this release.\")\n }\n case 'data-table-changed':\n return {\n message: say(key('message'), v, `The table '${v.binding}' changed.`),\n why: say(key('why'), {}, 'Where no legend is chosen, the same value may look different after this release.')\n }\n case 'data-table-role-changed':\n return {\n message: say(key('message'), v, `The legend role of the table '${v.binding}' changed from '${v.before}' to '${v.after}'.`),\n why: say(key('why'), {}, 'A legend a board chose for the old role is not used after this release. Choose one for the new role.')\n }\n /* The joints a controller drives (ADR-0107 decision 7): what writing a state input moves, compared release to release. */\n case 'state-input-joints-changed': {\n const after = v.after || say('figure.gate.contract.joints-none', {}, 'nothing')\n return {\n message: say(key('message'), { ...v, after }, `The control '${v.id}' moved ${v.before}. It now moves ${after}.`),\n why: say(key('why'), {}, 'A controller writes this value to drive those joints. After this release the same value moves other joints, or by other amounts.'),\n ...gone\n }\n }\n case 'joint-axis-changed':\n return {\n message: say(key('message'), v, `The axis of the joint '${v.joint}' changed from ${v.before} to ${v.after}.`),\n why: say(key('why'), {}, \"A controller's stored values turn or slide the joint about this axis. After this release the same value moves it another way.\"),\n ...gone\n }\n case 'joint-motion-unit-changed':\n return {\n message: say(key('message'), v, `The joint '${v.joint}' now moves in ${v.after}, not ${v.before}.`),\n why: say(key('why'), {}, \"A controller's stored values were written for the old unit. After this release the same value means another motion.\"),\n ...gone\n }\n case 'joint-child-changed':\n return {\n message: say(key('message'), v, `The joint '${v.joint}' now moves '${v.after}' instead of '${v.before}'.`),\n why: say(key('why'), {}, \"A controller's values keep their meaning. On screen the joint now moves the new part.\")\n }\n case 'joint-list-unread':\n return {\n message: say(key('message'), v, `The last release's joint list could not be read, so its joints were not compared: ${v.reason}`),\n why: say(key('why'), {}, \"Whether this release changes what a controller's values move has not been checked. The last release was made by a kernel that did not measure joints.\")\n }\n }\n}\n\n/**\n * What a release records about itself (ADR-0104 decision 5): the format its asset is written in, what it measured\n * (its cost at its largest, whether resizing is stretching), its plan from above, and what changed against the previous release -- the kernel's own comparison, kept as it was then so a consumer that pins releases\n * reads it rather than computing it again. `[]` for a first release; `null` when the previous release could not be\n * read, which is a different fact from \"nothing changed\".\n */\nexport function releaseRecordOf(\n sourceJson: string,\n releasedJson?: string | null\n): { source: string; format: string; kernel: string; changes: FigureContractChange[] | null; metrics: FigureReleaseMetrics; topView: FigureTopView } {\n const asset = parseFigureAsset(sourceJson)\n /*\n The release's own copy carries its size range as it is now: the author's ends, and the rest as far as the parts\n allow (ADR-0087 decision 6). A board reads the ends from it and does not measure; the figure's row keeps only what\n the author narrowed.\n */\n const measured = {\n source: serializeFigureAsset(recordFigureInstanceSize(asset)),\n format: asset.version,\n kernel: FIGURE_KERNEL_VERSION,\n metrics: figureReleaseMetricsOf(asset),\n topView: figureTopViewOf(asset, null)\n }\n if (!releasedJson) return { ...measured, changes: [] }\n let before: FigureAsset\n try {\n before = parseFigureAsset(releasedJson)\n } catch {\n return { ...measured, changes: null }\n }\n return { ...measured, changes: figureContractChanges(before, asset) }\n}\n\n/**\n * A release's source made a draft's again (a revert): the size ends its release wrote down, as far as the parts allow,\n * are opened, and the author's own are kept (ADR-0087 decision 6). An author's end that equals the computed one is\n * opened with them.\n */\nexport function draftSourceOfRelease(releasedJson: string): string {\n assertFormat(releasedJson)\n return serializeFigureAsset(forgetRecordedInstanceSize(parseFigureAsset(releasedJson)))\n}\n\n/**\n * What a consumer is handed for a released figure: the asset itself, because what draws it -- `registerFigure` in\n * things-scene -- takes the asset and compiles it with the kernel.\n */\nexport function consumablePayloadOf(sourceJson: string): { asset: FigureAsset } {\n assertFormat(sourceJson)\n const asset = parseFigureAsset(sourceJson)\n compileFigureAsset(asset)\n return { asset }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-glb.js","sourceRoot":"","sources":["../../../server/service/figure/figure-glb.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA6GH,0CAUC;AAiCD,0BAuFC;AA7OD,yDAAwF;AAExF,4GAA4G;AAC/F,QAAA,YAAY,GAAG,uCAAwB,CAAA;AACpD,4FAA4F;AAC/E,QAAA,aAAa,GAAG,oCAAqB,CAAA;AAElD,mHAAmH;AACnH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,yBAAyB,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,uBAAuB,CAAC,CAAC,CAAA;AA8BrJ,MAAa,UAAW,SAAQ,KAAK;IACnC,YACW,IAOU,EACnB,OAAe;IACf,gFAAgF;IACvE,SAA0C,EAAE;QAErD,KAAK,CAAC,OAAO,CAAC,CAAA;QAZL,SAAI,GAAJ,IAAI,CAOM;QAGV,WAAM,GAAN,MAAM,CAAsC;QAGrD,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC1B,CAAC;CACF;AAjBD,gCAiBC;AAGD,MAAM,QAAQ,GAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACrE,MAAM,GAAG,GAAG,CAAC,CAAK,EAAE,CAAK,EAAM,EAAE;IAC/B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAAE,KAAK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AAC,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;YACxE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAkB,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1F,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAC5J,CAAC","sourcesContent":["/*\n * What a GLB file holds, read on upload (ADR-0129 decision 6): whether it is a glTF 2.0 binary the board can draw, and\n * the numbers a mesh part carries -- its bounds in mm, its triangles, its primitives -- for the whole file and for each\n * node of it. The kernel never reads the file (figure-model `mesh@1`, contract §13); these numbers come from here.\n *\n * Nothing is decoded but the JSON chunk. glTF requires every POSITION accessor to carry its min and max, so the bounds\n * are those corners carried through the node transforms; a compressed buffer (Meshopt) keeps them too.\n *\n * A node's frame is its place in the file: its world translation and rotation, in the file's root frame. A part made\n * from a node stands there (its position and rotation), turns about the node's origin, and is drawn with the node's\n * world scale kept in the drawing. A node whose world transform shears or mirrors has no such frame and is not offered.\n */\n\nimport { FIGURE_MESH_CONTENT_TYPE, FIGURE_MESH_MAX_BYTES } from '@hatiolab/figure-model'\n\n/* The package contract's rule (figure-model): the same type and limit a board server holds an import to. */\nexport const GLB_MIMETYPE = FIGURE_MESH_CONTENT_TYPE\n/** The largest file kept, in bytes. A board downloads it for every figure that draws it. */\nexport const GLB_MAX_BYTES = FIGURE_MESH_MAX_BYTES\n\n/** The extensions a board can draw: Meshopt's decoder ships with the loader. Draco and KTX2 wait (ADR-0129 Q4). */\nconst DRAWABLE_EXTENSIONS = new Set(['EXT_meshopt_compression', 'KHR_mesh_quantization', 'KHR_materials_emissive_strength', 'KHR_texture_transform'])\n\nexport type Box = { min: { x: number; y: number; z: number }; max: { x: number; y: number; z: number } }\n\nexport interface GlbNode {\n /** Its place in the file's node list: what a mesh part names it by. */\n index: number\n name: string\n parent: number | null\n /** The node's subtree, in its own frame, in mm; none when it holds no mesh. */\n bounds: Box | null\n triangles: number\n primitives: number\n /** Where the node stands in the file's root frame: what a part made from it is placed at. */\n position: { x: number; y: number; z: number }\n rotation: { x: number; y: number; z: number }\n /** Why it cannot be a part, when it cannot. */\n refused?: 'no-mesh' | 'sheared'\n}\n\nexport interface GlbSummary {\n /** The whole file in its root frame, in mm. */\n bounds: Box\n triangles: number\n primitives: number\n unit: 'm'\n nodes: GlbNode[]\n extensions: string[]\n}\n\nexport class GlbRefusal extends Error {\n constructor(\n readonly code:\n | 'GLB_NOT_BINARY'\n | 'GLB_VERSION'\n | 'GLB_UNREADABLE'\n | 'GLB_EXTERNAL'\n | 'GLB_EXTENSION'\n | 'GLB_NO_MESH'\n | 'GLB_TOO_LARGE',\n message: string,\n /** What a screen says it with: the extensions it needs, the most bytes kept. */\n readonly params: Record<string, string | number> = {}\n ) {\n super(message)\n this.name = 'GlbRefusal'\n }\n}\n\ntype M4 = number[] // column-major, as glTF writes it\nconst IDENTITY: M4 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\nconst mul = (a: M4, b: M4): M4 => {\n const out = new Array(16).fill(0)\n for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) for (let k = 0; k < 4; k++) out[c * 4 + r] += a[k * 4 + r]! * b[c * 4 + k]!\n return out\n}\nconst apply = (m: M4, p: [number, number, number]): [number, number, number] => [\n m[0]! * p[0] + m[4]! * p[1] + m[8]! * p[2] + m[12]!,\n m[1]! * p[0] + m[5]! * p[1] + m[9]! * p[2] + m[13]!,\n m[2]! * p[0] + m[6]! * p[1] + m[10]! * p[2] + m[14]!\n]\nfunction local(node: any): M4 {\n if (Array.isArray(node.matrix) && node.matrix.length === 16) return node.matrix.map(Number)\n const [tx, ty, tz] = node.translation ?? [0, 0, 0]\n const [qx, qy, qz, qw] = node.rotation ?? [0, 0, 0, 1]\n const [sx, sy, sz] = node.scale ?? [1, 1, 1]\n const r = [\n 1 - 2 * (qy * qy + qz * qz), 2 * (qx * qy + qz * qw), 2 * (qx * qz - qy * qw),\n 2 * (qx * qy - qz * qw), 1 - 2 * (qx * qx + qz * qz), 2 * (qy * qz + qx * qw),\n 2 * (qx * qz + qy * qw), 2 * (qy * qz - qx * qw), 1 - 2 * (qx * qx + qy * qy)\n ]\n return [r[0]! * sx, r[1]! * sx, r[2]! * sx, 0, r[3]! * sy, r[4]! * sy, r[5]! * sy, 0, r[6]! * sz, r[7]! * sz, r[8]! * sz, 0, tx, ty, tz, 1]\n}\n\n/**\n * A world matrix as translation and rotation, the scale left in the drawing. Undefined when its axes are not square to\n * each other (a shear) or it mirrors: there is no frame to stand a part in.\n */\nfunction frameOf(m: M4): { rotation: number[][]; translation: [number, number, number]; inverse: M4 } | undefined {\n const cols = [0, 1, 2].map(c => [m[c * 4]!, m[c * 4 + 1]!, m[c * 4 + 2]!])\n const len = cols.map(c => Math.hypot(...c))\n if (len.some(l => !(l > 1e-12))) return undefined\n const unit = cols.map((c, i) => c.map(v => v / len[i]!))\n const dot = (a: number[], b: number[]) => a[0]! * b[0]! + a[1]! * b[1]! + a[2]! * b[2]!\n if (Math.abs(dot(unit[0]!, unit[1]!)) > 1e-6 || Math.abs(dot(unit[0]!, unit[2]!)) > 1e-6 || Math.abs(dot(unit[1]!, unit[2]!)) > 1e-6) return undefined\n const [a, b, c] = unit as [number[], number[], number[]]\n const det = a[0]! * (b[1]! * c[2]! - b[2]! * c[1]!) - b[0]! * (a[1]! * c[2]! - a[2]! * c[1]!) + c[0]! * (a[1]! * b[2]! - a[2]! * b[1]!)\n if (det < 0) return undefined\n /* rotation rows: R[r][c] = unit[c][r] */\n const rotation = [0, 1, 2].map(r => [0, 1, 2].map(col => unit[col]![r]!))\n const translation: [number, number, number] = [m[12]!, m[13]!, m[14]!]\n /* The inverse of the rigid part: Rᵀ and −Rᵀt. */\n const inv: M4 = [...IDENTITY]\n for (let r = 0; r < 3; r++) for (let col = 0; col < 3; col++) inv[col * 4 + r] = rotation[col]![r]!\n for (let r = 0; r < 3; r++) inv[12 + r] = -(rotation[0]![r]! * translation[0] + rotation[1]![r]! * translation[1] + rotation[2]![r]! * translation[2])\n return { rotation, translation, inverse: inv }\n}\n\n/** A rotation as degrees about X, Y and Z in the order `rigid@1` turns them (Rx · Ry · Rz). */\nexport function eulerOfRotation(r: number[][]): { x: number; y: number; z: number } {\n const deg = (a: number) => {\n const d = Math.round(((a * 180) / Math.PI) * 1e6) / 1e6\n return d === 0 ? 0 : d\n }\n const sy = Math.max(-1, Math.min(1, r[0]![2]!))\n const y = Math.asin(sy)\n if (Math.abs(sy) < 1 - 1e-9) return { x: deg(Math.atan2(-r[1]![2]!, r[2]![2]!)), y: deg(y), z: deg(Math.atan2(-r[0]![1]!, r[0]![0]!)) }\n /* About Y by a quarter turn: X and Z turn about one axis and only their sum counts; Z is taken as 0. */\n return { x: deg(Math.atan2(r[2]![1]!, r[1]![1]!)), y: deg(y), z: 0 }\n}\n\nconst TO_MM = 1000\nconst empty = (): Box => ({ min: { x: Infinity, y: Infinity, z: Infinity }, max: { x: -Infinity, y: -Infinity, z: -Infinity } })\nconst grow = (box: Box, p: [number, number, number]) => {\n box.min = { x: Math.min(box.min.x, p[0]), y: Math.min(box.min.y, p[1]), z: Math.min(box.min.z, p[2]) }\n box.max = { x: Math.max(box.max.x, p[0]), y: Math.max(box.max.y, p[1]), z: Math.max(box.max.z, p[2]) }\n}\nconst round = (v: number) => {\n const r = Math.round(v * 1e6) / 1e6\n return r === 0 ? 0 : r\n}\nconst inMm = (box: Box): Box => ({\n min: { x: round(box.min.x * TO_MM), y: round(box.min.y * TO_MM), z: round(box.min.z * TO_MM) },\n max: { x: round(box.max.x * TO_MM), y: round(box.max.y * TO_MM), z: round(box.max.z * TO_MM) }\n})\n\n/** Reads a GLB's JSON chunk, and refuses one a board cannot draw as it is. */\nfunction jsonOf(bytes: Uint8Array): any {\n if (bytes.length > GLB_MAX_BYTES) throw new GlbRefusal('GLB_TOO_LARGE', `the file is ${bytes.length} bytes; the most kept is ${GLB_MAX_BYTES}`, { max: Math.round(GLB_MAX_BYTES / 1024 / 1024) })\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n if (bytes.length < 20 || view.getUint32(0, true) !== 0x46546c67) throw new GlbRefusal('GLB_NOT_BINARY', 'not a binary glTF (.glb) file')\n if (view.getUint32(4, true) !== 2) throw new GlbRefusal('GLB_VERSION', `glTF ${view.getUint32(4, true)}; only glTF 2.0 is read`)\n if (view.getUint32(8, true) !== bytes.length) throw new GlbRefusal('GLB_UNREADABLE', 'the file is cut short or has bytes past its end')\n const length = view.getUint32(12, true)\n if (view.getUint32(16, true) !== 0x4e4f534a || 20 + length > bytes.length) throw new GlbRefusal('GLB_UNREADABLE', 'its first chunk is not its JSON')\n try {\n return JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + length)))\n } catch {\n throw new GlbRefusal('GLB_UNREADABLE', 'its JSON chunk is not JSON')\n }\n}\n\nexport function readGlb(bytes: Uint8Array): GlbSummary {\n const gltf = jsonOf(bytes)\n if (String(gltf?.asset?.version ?? '').split('.')[0] !== '2') throw new GlbRefusal('GLB_VERSION', `glTF ${gltf?.asset?.version}; only glTF 2.0 is read`)\n const required: string[] = Array.isArray(gltf.extensionsRequired) ? gltf.extensionsRequired : []\n const undrawable = required.filter(e => !DRAWABLE_EXTENSIONS.has(e))\n if (undrawable.length) throw new GlbRefusal('GLB_EXTENSION', `a board cannot draw it yet: it needs ${undrawable.join(', ')}`, { extensions: undrawable.join(', ') })\n /* Self-contained: one buffer, the file's own; no file beside it. */\n if ((gltf.buffers ?? []).some((b: any) => b?.uri !== undefined)) throw new GlbRefusal('GLB_EXTERNAL', 'it reads a buffer from another file')\n if ((gltf.images ?? []).some((i: any) => i?.uri !== undefined && !String(i.uri).startsWith('data:')))\n throw new GlbRefusal('GLB_EXTERNAL', 'it reads a picture from another file')\n\n const nodes: any[] = Array.isArray(gltf.nodes) ? gltf.nodes : []\n const meshes: any[] = Array.isArray(gltf.meshes) ? gltf.meshes : []\n const accessors: any[] = Array.isArray(gltf.accessors) ? gltf.accessors : []\n const parent = new Array<number | null>(nodes.length).fill(null)\n nodes.forEach((n, i) => (Array.isArray(n?.children) ? n.children : []).forEach((c: number) => (parent[c] = i)))\n\n /* World matrices, from the roots of the scene shown (or every root, when none is named). */\n const world = new Array<M4 | undefined>(nodes.length)\n const scene = gltf.scenes?.[gltf.scene ?? 0]\n const roots: number[] = Array.isArray(scene?.nodes) ? scene.nodes : nodes.map((_, i) => i).filter(i => parent[i] === null)\n const visit = (i: number, above: M4) => {\n if (world[i]) throw new GlbRefusal('GLB_UNREADABLE', `node ${i} is reached twice: the nodes are not a tree`)\n world[i] = mul(above, local(nodes[i]))\n for (const c of nodes[i]?.children ?? []) visit(c, world[i]!)\n }\n roots.forEach(i => visit(i, IDENTITY))\n\n /* What one primitive costs and where it reaches, in its mesh's own space. */\n const primitive = (p: any) => {\n const position = accessors[p?.attributes?.POSITION]\n if (!position || !Array.isArray(position.min) || !Array.isArray(position.max))\n throw new GlbRefusal('GLB_UNREADABLE', 'a primitive has no POSITION with its min and max')\n const count = p.indices !== undefined ? Number(accessors[p.indices]?.count) : Number(position.count)\n const mode = p.mode ?? 4\n const triangles = mode === 4 ? Math.floor(count / 3) : mode === 5 || mode === 6 ? Math.max(count - 2, 0) : 0\n const [x0, y0, z0] = position.min.map(Number)\n const [x1, y1, z1] = position.max.map(Number)\n const corners: Array<[number, number, number]> = [x0, x1].flatMap(x => [y0, y1].flatMap(y => [z0, z1].map(z => [x, y, z] as [number, number, number])))\n return { triangles, corners }\n }\n\n const drawn = (i: number) => (nodes[i]?.mesh !== undefined ? meshes[nodes[i].mesh]?.primitives ?? [] : [])\n const subtree = (i: number): number[] => [i, ...(nodes[i]?.children ?? []).flatMap((c: number) => subtree(c))]\n\n const whole = empty()\n let triangles = 0,\n primitives = 0\n for (let i = 0; i < nodes.length; i++) {\n if (!world[i]) continue\n for (const p of drawn(i)) {\n const one = primitive(p)\n triangles += one.triangles\n primitives++\n for (const c of one.corners) grow(whole, apply(world[i]!, c))\n }\n }\n if (!primitives) throw new GlbRefusal('GLB_NO_MESH', 'it holds no mesh to draw')\n\n const listed: GlbNode[] = nodes.map((n, i) => {\n const frame = world[i] ? frameOf(world[i]!) : undefined\n const below = subtree(i).filter(k => world[k])\n const box = empty()\n let t = 0,\n p = 0\n for (const k of below)\n for (const prim of drawn(k)) {\n const one = primitive(prim)\n t += one.triangles\n p++\n if (frame) for (const c of one.corners) grow(box, apply(mul(frame.inverse, world[k]!), c))\n }\n const position = frame ? { x: round(frame.translation[0] * TO_MM), y: round(frame.translation[1] * TO_MM), z: round(frame.translation[2] * TO_MM) } : { x: 0, y: 0, z: 0 }\n return {\n index: i,\n name: typeof n?.name === 'string' ? n.name : `node ${i}`,\n parent: parent[i]!,\n bounds: p && frame ? inMm(box) : null,\n triangles: t,\n primitives: p,\n position,\n rotation: frame ? eulerOfRotation(frame.rotation) : { x: 0, y: 0, z: 0 },\n ...(!p ? { refused: 'no-mesh' as const } : !frame ? { refused: 'sheared' as const } : {})\n }\n })\n\n return { bounds: inMm(whole), triangles, primitives, unit: 'm', nodes: listed, extensions: Array.isArray(gltf.extensionsUsed) ? gltf.extensionsUsed : [] }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-history.js","sourceRoot":"","sources":["../../../server/service/fig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M,EAAE,EAAE,EAAE,CAAC;IACrE,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC;;6CAClE;wBAhKtB,aAAa;IAHzB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,qBAAqB,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjH,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;GACxE,aAAa,CAiKzB","sourcesContent":["import { Field, ID, ObjectType, Float, Int } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { User } from '@things-factory/auth-base'\nimport { Domain, longTextColumn } from '@things-factory/shell'\n\nimport { Figure } from './figure.js'\n\n/**\n * 발행된 버전 하나 — **발행할 때만 남는다.**\n *\n * 저작 중 저장은 여기 오지 않는다. 스냅샷을 뜨는 subscriber 가 `state === 'released'` 인 저장에만\n * 움직인다(`event-subscriber.ts`) — board 가 같은 규칙으로 돈다.\n *\n * ## 왜 통째로 베끼나\n *\n * 버전을 되세우려면 그때의 정본만으로는 모자란다. 이름·분류·그림·비용까지 함께 있어야 「그 버전이\n * 무엇이었나」를 보여 주고 되돌릴 수 있다. 파생값(점수·삼각형·묶음)도 같이 둔다 — 다시 계산하면\n * 형식이 바뀐 오늘의 값이 나오고, 그것은 그 버전의 값이 아니다.\n */\n@Entity()\n@Index('ix_figure_history_0', (history: FigureHistory) => [history.originalId, history.version], { unique: true })\n@ObjectType({ description: 'A released version of a figure — one row per release.' })\nexport class FigureHistory implements HistoryEntityInterface<Figure> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for this history record.' })\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field(type => Int, { nullable: true, description: 'The published version number this record holds.' })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the figure belonged to.' })\n domain?: Domain\n\n @RelationId((history: FigureHistory) => history.domain)\n domainId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The stored identifier of the figure. It never changes.' })\n type?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Namespace of the full name {namespace}/{type} at this version.' })\n namespace?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The display name at this version.' })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The description at this version.' })\n description?: string\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Display names by language at this version.' })\n names?: Record<string, string>\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The classification code at this version.' })\n category?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The lifecycle state recorded with this version.' })\n state?: 'draft' | 'released'\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'The figure asset JSON (figure-asset-1) at this version.' })\n source?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'The master-data field definition at this version.' })\n properties?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'The thumbnail as it looked at this version.' })\n thumbnail?: string\n\n /*\n * 그림의 내용 해시(SHA-256). 그림 자체는 attachment-base 가 갖고(refType `figure-thumbnail`, refBy 이 해시),\n * `/figure-thumbnail/:id` 가 권한을 본 뒤 내준다(ADR-0104 결정 6). `thumbnail` 칸은 옛 base64 가 남은 행을\n * 기동 때 옮기기 위한 칸이다 — 옮긴 뒤에는 비어 있고, 새 그림은 그 칸에 쓰지 않는다.\n */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'SHA-256 of the thumbnail picture; the picture is served by /figure-thumbnail/:id.' })\n thumbnailHash?: string\n\n /*\n * 그때의 비용이다. 오늘 다시 계산하면 오늘의 형식으로 나온다 — 그 버전을 설명하지 못한다.\n */\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Reuse score as computed at this version.' })\n score?: number\n\n @Column({ nullable: true })\n @Field(type => Int, { nullable: true, description: 'Triangle count at this version.' })\n triangles?: number\n\n @Column({ nullable: true })\n @Field(type => Int, { nullable: true, description: 'Material group count at this version.' })\n groups?: number\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'The note left when this version was released.' })\n comment?: string\n\n /*\n * 이 버전의 정본 형식(`figure-asset-1`)과, 직전 버전에 견준 변경(ADR-0104 결정 5). 발행할 때 한 번 정하고 다시\n * 계산하지 않는다 — 버전을 고정해 쓰는 쪽은 다음 버전으로 옮기기 전에 이것을 읽는다.\n */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The asset format this version was written in (figure-asset-1).' })\n assetFormat?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({\n nullable: true,\n description:\n 'What changed against the previous release, as JSON: [{ code, blocking, subject?, values, detail }]. [] for the first release. null when it was not compared: the previous release could not be read, or this release was made before releases recorded it (figure-service 10.1.109).'\n })\n changes?: string\n\n /*\n * 이 버전을 잰 커널의 버전(figure-model `FIGURE_KERNEL_VERSION`). 점수 · 묶음 · metrics 는 그 커널의 규칙으로 센 값이다 —\n * 규칙이 바뀌어도 발행된 값을 다시 세서 덮지 않고(ADR-0109 C1), 읽는 쪽은 이 칸으로 「남긴 값」과 「지금 규칙의 값」을\n * 가른다. 이 칸이 생기기 전에 발행된 버전은 비어 있다.\n */\n @Column({ nullable: true })\n @Field({\n nullable: true,\n description:\n 'The figure-model kernel version that measured this release (score, groups, metrics). null for releases made before releases recorded it.'\n })\n kernelVersion?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({\n nullable: true,\n description:\n 'What this version measured once, as JSON (figure-model figureReleaseMetricsOf): { atLargest?: { size, triangles, groups }, linear?: { scalable, parts, probe }, origin?: { centred, off }, joints?: { schema, derivation, joints, unlisted } }. atLargest and linear only for a figure that takes its size from the instance. joints is the joint list a controller reads (schema 2, figure-model figureJointsOf), present when anything moves.'\n })\n metrics?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({\n nullable: true,\n description: 'The plan from above at the authored size, as JSON (figure-model figureTopViewOf): { shapes: [{ id, color, outline, holes, top, transparent }], size }.'\n })\n topView?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the original figure was created.' })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the figure was saved at this version.' })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created the original figure.' })\n creator?: User\n\n @RelationId((history: FigureHistory) => history.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who released this version.' })\n updater?: User\n\n @RelationId((history: FigureHistory) => history.updater)\n updaterId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the original figure was deleted, if it was.' })\n deletedAt?: Date\n\n @HistoryOriginalIdColumn()\n @Field({ description: 'The id of the figure this version belongs to.' })\n public originalId!: string\n\n @HistoryActionColumn({ nullable: false, type: 'varchar', length: 10 })\n @Field(type => String, { description: 'What produced this record (created · updated · deleted).' })\n public action!: HistoryActionType\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-llm-provider.js","sourceRoot":"","sources":["../../../server/service/figure/figure-llm-provider.ts"],"names":[],"mappings":";;AAMA,8CAaC;AAbD,SAAgB,iBAAiB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACpE,MAAM,SAAS,GAAG,GAAG,CAAC,mBAAoD,CAAA;IAC1E,MAAM,UAAU,GAA2D;QACzE,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,mBAAmB,CAAC,EAAE;QACtD,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,EAAE;QAClE,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,gBAAgB,CAAC,EAAE;KACjD,CAAA;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IACxG,KAAK,MAAM,SAAS,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChE,IAAI,MAAM;YAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/H,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["/**\n * Which provider a live figure-AI run asks (the smoke test, the scenarios): the one `FIGURE_LLM_PROVIDER` names, or the\n * first whose key is set. Its model is `FIGURE_LLM_MODEL`, or the adapter's default. Undefined: no key, nothing runs.\n */\nexport type FigureLLMProvider = 'anthropic' | 'gemini' | 'openai'\n\nexport function figureLLMProvider(env: NodeJS.ProcessEnv = process.env): { provider: FigureLLMProvider; apiKey: string; model?: string } | undefined {\n const requested = env.FIGURE_LLM_PROVIDER as FigureLLMProvider | undefined\n const candidates: Array<{ provider: FigureLLMProvider; keys: string[] }> = [\n { provider: 'anthropic', keys: ['ANTHROPIC_API_KEY'] },\n { provider: 'gemini', keys: ['GEMINI_API_KEY', 'GOOGLE_API_KEY'] },\n { provider: 'openai', keys: ['OPENAI_API_KEY'] }\n ]\n const usable = requested ? candidates.filter(candidate => candidate.provider === requested) : candidates\n for (const candidate of usable) {\n const apiKey = candidate.keys.map(key => env[key]).find(Boolean)\n if (apiKey) return { provider: candidate.provider, apiKey, ...(env.FIGURE_LLM_MODEL ? { model: env.FIGURE_LLM_MODEL } : {}) }\n }\n return undefined\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-mesh-store.js","sourceRoot":"","sources":["../../../server/service/figure/figure-mesh-store.ts"],"names":[],"mappings":";;;AAwBA,4CAMC;AAGD,4BA6BC;AAGD,sCAQC;AAMD,4CAWC;AA1FD,qCAA4B;AAE5B,qEAA4D;AAC5D,yDAAsD;AACtD,iDAA+C;AAE/C,mDAAwE;AACxE,2EAA2F;AAE3F;;;;;;;;GAQG;AAEU,QAAA,aAAa,GAAG,aAAa,CAAA;AAI1C,wHAAwH;AACjH,KAAK,UAAU,gBAAgB,CAAC,EAAM,EAAE,SAA4B,EAAE,IAAY;IACvF,MAAM,KAAK,GAAiB,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,CAAC;QAClE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAa,EAAE,KAAK,EAAE,IAAI,EAAE;QAClF,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;KAC5B,CAAC,CAAA;IACF,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,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,EAAE,CAAA;AAC1B,CAAC;AAED,qGAAqG;AAC9F,KAAK,UAAU,aAAa,CACjC,EAAM,EACN,MAAgD,EAChD,IAAY,EACZ,QAAwB,IAAA,0CAAc,GAAE;IAExC,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,EAAE,IAAI,CAAC,CAAA;IACvG,OAAO,IAAI,CAAC,CAAC,CAAC,IAAA,uBAAO,EAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACjE,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,EAAM,EAAE,MAAgD,EAAE,MAAc;IAC7G,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAM,CAAC,qDAAqD;IAC9D,CAAC;IACD,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAA;IACpE,KAAK,MAAM,IAAI,IAAI,IAAA,4BAAa,EAAC,MAAM,CAAC;QACtC,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAC1C,MAAM,IAAI,eAAO,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,EAAE,wFAAwF,CAAC,CAAA;AAClJ,CAAC","sourcesContent":["import { In } from 'typeorm'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { figureFilesOf } from '@hatiolab/figure-model'\nimport { Refusal } from '@things-factory/shell'\n\nimport { GLB_MIMETYPE, readGlb, type GlbSummary } from './figure-glb.js'\nimport { sha256Of, thumbnailFiles, type ThumbnailFiles } from './figure-thumbnail-store.js'\n\n/*\n * A mesh part's file (ADR-0129 decision 6), kept as a thumbnail is (ADR-0104 decision 6): by attachment-base's storage,\n * one attachment per (domain, content), refType `figure-mesh`, refBy the SHA-256 of the bytes. A figure's source names\n * it by that hash and nothing else; the bytes are served only through `/figure-mesh/:hash`, behind the figure query\n * permission.\n *\n * A file is read before it is kept (`readGlb`): one a board cannot draw is refused by name, never kept under a hash.\n * The file is written before the row that names it, as a picture is: a file cannot be rolled back.\n */\n\nexport const MESH_REF_TYPE = 'figure-mesh'\n\ntype Tx = { getRepository: (target: any) => any }\n\n/** The attachment holding this file in one of these domains -- the asker's first, then its parent's -- or undefined. */\nexport async function meshAttachmentOf(tx: Tx, domainIds: readonly string[], hash: string): Promise<Attachment | undefined> {\n const found: Attachment[] = await tx.getRepository(Attachment).find({\n where: { domain: { id: In([...domainIds]) }, refType: MESH_REF_TYPE, refBy: hash },\n relations: { domain: true }\n })\n return domainIds.map(id => found.find(a => a.domain?.id === id)).find(Boolean)\n}\n\n/** Keeps a GLB and gives its hash and what it holds. Refused, by the reader's code, when a board cannot draw it. */\nexport async function keepMesh(\n tx: Tx,\n domain: { id: string },\n user: unknown,\n bytes: Buffer,\n files: ThumbnailFiles = thumbnailFiles()\n): Promise<{ hash: string; summary: GlbSummary }> {\n const summary = readGlb(bytes)\n const hash = sha256Of(bytes)\n if (await meshAttachmentOf(tx, [domain.id], hash)) return { hash, summary }\n const name = `${hash}.glb`\n /* The file first: it cannot be rolled back. The row that names it comes after, in the caller's transaction. */\n const put = await files.put(bytes, GLB_MIMETYPE, name, { state: { domain, user, tx } })\n await tx.getRepository(Attachment).save({\n domain,\n creator: user,\n updater: user,\n id: put.id,\n name,\n mimetype: GLB_MIMETYPE,\n encoding: 'binary',\n refType: MESH_REF_TYPE,\n refBy: hash,\n category: 'model',\n size: String(put.size),\n path: put.path,\n ...(put.contents ? { contents: put.contents } : {})\n })\n return { hash, summary }\n}\n\n/** What a kept file holds, read again from its bytes: the modeller asks when it reopens a figure. */\nexport async function meshSummaryOf(\n tx: Tx,\n domain: { id: string; parentId?: string | null },\n hash: string,\n files: ThumbnailFiles = thumbnailFiles()\n): Promise<GlbSummary | undefined> {\n const kept = await meshAttachmentOf(tx, [domain.id, domain.parentId].filter(Boolean) as string[], hash)\n return kept ? readGlb(await files.read(kept.path!)) : undefined\n}\n\n/**\n * A source may name only files this domain holds (or its parent, whose figures it reads): a figure that names a file\n * nobody kept cannot be drawn anywhere, and is refused when it is saved, not when a board finds out.\n */\nexport async function requireMeshFiles(tx: Tx, domain: { id: string; parentId?: string | null }, source: string): Promise<void> {\n let parsed: unknown\n try {\n parsed = JSON.parse(source)\n } catch {\n return /* the format check refuses it, with its own words */\n }\n const ids = [domain.id, domain.parentId].filter(Boolean) as string[]\n for (const hash of figureFilesOf(parsed))\n if (!(await meshAttachmentOf(tx, ids, hash)))\n throw new Refusal('figure-mesh-missing', { hash }, 'the figure names a mesh file this domain does not hold: {hash}. Upload the file again.')\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"figure-mutation.js","sourceRoot":"","sources":["../../../server/service/figure/figure-mutation.ts"],"names":[],"mappings":";;;AA2CA,kCAMC;;AAjDD,qCAA4B;AAC5B,+CAAqF;AAErF,yDAAqG;AACrG,iDAA6E;AAC7E,mEAA4D;AAE5D,2CAAoC;AACpC,2DAAmD;AACnD,qDAAkH;AAElH,yDAAmE;AACnE,6DAAsD;AACtD,qEAAyE;AACzE,yDAAmE;AACnE,yDAA4G;AAC5G,+DAAqG;AACrG,iEAAuF;AACvF,yDAAgD;AAChD,uEAA8G;AAC9G,uDAAkK;AAClK,iEAAmE;AACnE,mDAA2D;AAC3D,qDAAmD;AACnD,+FAA2D;AAG3D;;;GAGG;AACH,MAAM,aAAa,GAAuC;IACxD,cAAc,EAAE,qBAAqB;IACrC,WAAW,EAAE,qBAAqB;IAClC,cAAc,EAAE,wBAAwB;IACxC,YAAY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EAAE,WAAW,EAAE,sGAAsG,EAAE,CAAC;IAC9H,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDAYpF;AAaK;IAJL,IAAA,wBAAS,EAAC,iFAAiF,CAAC;IAC5F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,uCAAc,EAAE;QACnC,WAAW,EAAE,oGAAoG;KAClH,CAAC;IACmB,mBAAA,IAAA,kBAAG,EAAC,SAAS,CAAC,CAAA;IAA2B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAtB,uCAAc;;mDAoC1D;yBA3kBU,cAAc;IAF1B,IAAA,uBAAQ,EAAC,kBAAM,CAAC;IAChB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,cAAc,CA6kB1B","sourcesContent":["import { In } from 'typeorm'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { isFigureType, parseFigureAsset, placeholderType, TYPE_LENGTH } from '@hatiolab/figure-model'\nimport { getRepository, Refusal, SpeakRefusals } from '@things-factory/shell'\nimport { aiClientFor } from '@things-factory/ai-client-base'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\nimport { FigureCatalogSeen, FigurePatch, FigureRevertResult, FigureSaveResult, NewFigure } from './figure-type.js'\nimport { FigureReplacedDraft } from './figure-replaced-draft.js'\nimport { revertKeepingDraft, undoRevert } from './figure-revert.js'\nimport { recordProposals } from './figure-proposal.js'\nimport { FigureProposal, ProposeRequest } from './figure-propose-type.js'\nimport { inspectSource, releaseRecordOf } from './figure-format.js'\nimport { releasedBeforeMessage, renameDraftType, renameFacts, typeReleasedBefore } from './figure-rename.js'\nimport { assertReleasableNamespace, namespaceForNewFigure, namespaceOf } from './figure-namespace.js'\nimport { assertFigureCategory, assertReleasableCategory } from './figure-categories.js'\nimport { parseSource } from './figure-format.js'\nimport { ProposeFigureFailure, proposalFailureForPerson, proposeFigureSteps } from './figure-propose-steps.js'\nimport { prepareFigureWrite, compareAndSwapFigure, pictureOf, assertCatalogSeen, catalogConflict, catalogConflictsOf, catalogCriteriaOf } from './figure-write.js'\nimport { keepMesh, requireMeshFiles } from './figure-mesh-store.js'\nimport { GlbRefusal, GLB_MAX_BYTES } from './figure-glb.js'\nimport { FigureMeshUpload } from './figure-type.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\n\n/*\n * A GLB a board cannot draw, said by its reason (ADR-0129): each reason its own code, so a screen speaks it in its own\n * words (`error.figure-mesh-*`) and never the reader's English.\n */\nconst MESH_REFUSALS: Record<GlbRefusal['code'], string> = {\n GLB_NOT_BINARY: 'figure-mesh-not-glb',\n GLB_VERSION: 'figure-mesh-version',\n GLB_UNREADABLE: 'figure-mesh-unreadable',\n GLB_EXTERNAL: 'figure-mesh-external',\n GLB_EXTENSION: 'figure-mesh-extension',\n GLB_NO_MESH: 'figure-mesh-empty',\n GLB_TOO_LARGE: 'figure-mesh-too-large'\n}\nconst meshRefusal = (e: GlbRefusal) => new Refusal(MESH_REFUSALS[e.code], e.params, e.message)\n\n/** Display names by language: a language code to a name of 1-128 characters. Refused whole, with the bad entry named. */\nexport function assertNames(names: unknown): asserts names is Record<string, string> {\n if (!names || typeof names !== 'object' || Array.isArray(names)) throw new Error('names 는 { 언어: 이름 } 이어야 한다')\n for (const [lang, name] of Object.entries(names)) {\n if (!/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(lang)) throw new Error(`'${lang}' 는 언어 코드가 아니다`)\n if (typeof name !== 'string' || !name.trim() || name.length > 128) throw new Error(`'${lang}' 의 이름은 1~128자 글이어야 한다`)\n }\n}\n\n/**\n * The figure a write may touch: one of this domain's own (LV figure-server design G3). A domain reads its parent's\n * figures but does not change them -- updating, releasing or retiring one from a child domain is refused as not found,\n * the same answer saving its draft has always given.\n */\nasync function ownFigure(repository: { findOne(options: any): Promise<Figure | null> }, domain: { id: string }, id: string): Promise<Figure> {\n const figure = await repository.findOne({ where: { domain: { id: domain.id }, id } })\n if (!figure) {\n throw new Error(`Figure ${id} 를 찾을 수 없다`)\n }\n return figure\n}\n\n@Resolver(Figure)\n@UseMiddleware(SpeakRefusals)\nexport class FigureMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Figure, { description: 'Save a asset draft using an exact-source concurrency check.' })\n async saveFigure(\n @Arg('source') source: string,\n @Ctx() context: ResolverContext,\n @Arg('id', { nullable: true }) id?: string,\n @Arg('expectedSource', { nullable: true }) expectedSource?: string,\n @Arg('creationId', { nullable: true }) creationId?: string,\n @Arg('thumbnail', { nullable: true }) thumbnail?: string,\n @Arg('type', { nullable: true, description: 'The type name a new figure is created under. Ignored for an existing one.' })\n type?: string,\n @Arg('proposalKeys', type => [String], {\n nullable: true,\n description: \"Keys of the AI proposals whose steps this source holds: recorded with the save, in its transaction.\"\n })\n proposalKeys?: string[],\n @Arg('namespace', { nullable: true, description: \"The domain's namespace a new figure is created under; its default when none. Ignored for an existing one.\" })\n namespace?: string\n ): Promise<Figure> {\n const saved = await this.writeSource(context, source, id, expectedSource, creationId, thumbnail, type, namespace)\n await recordProposals(context.state.tx, context.state.domain, saved.id!, proposalKeys)\n return saved\n }\n\n private async writeSource(\n context: ResolverContext,\n source: string,\n id?: string,\n expectedSource?: string,\n creationId?: string,\n thumbnail?: string,\n type?: string,\n chosenNamespace?: string\n ): Promise<Figure> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(Figure)\n /* Every file the source draws from is one this domain holds (ADR-0129). */\n await requireMeshFiles(tx, domain, source)\n if (!id) {\n if (!creationId || !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(creationId))\n throw Error('새 모델 저장에는 생성 요청 식별자가 필요합니다.')\n const prepared = { ...prepareFigureWrite(source), ...(await pictureOf(tx, domain, user, thumbnail)) }\n const previous = await repository.findOne({ where: { id: creationId, domain: { id: domain.id } } })\n if (previous) {\n if (previous.source !== prepared.source) throw Error('이 생성 요청은 이미 다른 내용으로 저장되었습니다. 저장된 모델을 다시 열어 주세요.')\n return previous\n }\n /*\n The temporary name comes from the format's `placeholderType()`, the one rule the release gate and the AI\n tools use to recognise it. This used to build its own (`FIGURE_<32 hex>`), which `isPlaceholderType` does\n not match, so a new figure could be published under a machine name that then froze (ADR-0063 decision 4)\n — seen on :3300, 2026-09-24. A retry is still safe: the row id is the creation id, not the name.\n */\n /*\n The author names it on the first save (2026-09-25): created under that\n name or not at all -- a taken name refuses the save, rather than saving under the temporary one and failing a\n rename after. Without a name (a caller that has none to give) it is the temporary one, renamed later.\n */\n const namespace = await namespaceForNewFigure(tx, domain, chosenNamespace, user)\n const named = type?.trim()\n if (named) {\n const facts = await renameFacts(\n { figures: repository, histories: tx.getRepository(FigureHistory) },\n { id: creationId },\n domain,\n named\n )\n renameDraftType({ type: named, source: prepared.source }, named, facts)\n }\n // insert, not save: a concurrent retry must never turn into an unchecked overwrite.\n await repository.insert({ ...prepared, id: creationId, type: named || placeholderType(), namespace,\n domain, creator: user, updater: user })\n return repository.findOneOrFail({ where: { id: creationId, domain: { id: domain.id } } })\n }\n // Exact tenant ownership: an inherited catalog entry is not writable in the child domain.\n const figure = await repository.findOne({ where: { id, domain: { id: domain.id } } })\n if (!figure) throw Error('편집할 Figure를 찾을 수 없습니다.')\n const prepared = { ...prepareFigureWrite(source, figure, expectedSource), ...(await pictureOf(tx, domain, user, thumbnail, figure)) }\n // Compare-and-swap in the UPDATE itself: supported by SQLite as well as PostgreSQL.\n // A pessimistic row lock is not supported by the product's SQLite deployment.\n await compareAndSwapFigure(criteria => repository.update(criteria, { ...prepared, updater: user }),\n id, domain.id, expectedSource)\n return repository.findOneOrFail({ where: { id, domain: { id: domain.id } } })\n }\n\n /**\n * A GLB for a mesh part (ADR-0129 decision 6): read, then kept by its hash. Answers the hash and what the file holds --\n * its bounds in mm, its triangles and primitives, and its nodes -- which the modeller turns into a part. A file a board\n * cannot draw is refused by name and not kept.\n */\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureMeshUpload, { description: 'Keeps a GLB for mesh parts and answers its hash and what it holds.' })\n async uploadFigureMesh(@Arg('file', type => GraphQLUpload) file: FileUpload, @Ctx() context: ResolverContext): Promise<FigureMeshUpload> {\n const { domain, user, tx } = context.state\n const { createReadStream } = await file\n const chunks: Buffer[] = []\n let size = 0\n for await (const chunk of createReadStream()) {\n size += chunk.length\n /* Refused as it arrives: a file past the limit is not read whole first. */\n if (size > GLB_MAX_BYTES) throw meshRefusal(new GlbRefusal('GLB_TOO_LARGE', 'too large', { max: Math.round(GLB_MAX_BYTES / 1024 / 1024) }))\n chunks.push(Buffer.from(chunk))\n }\n try {\n const { hash, summary } = await keepMesh(tx, domain, user, Buffer.concat(chunks))\n return { hash, summary }\n } catch (e) {\n if (e instanceof GlbRefusal) throw meshRefusal(e)\n throw e\n }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureSaveResult, { description: 'Creates a figure. Rejects when the source violates the format.' })\n async createFigure(\n @Arg('figure') figure: NewFigure,\n @Ctx() context: ResolverContext\n ): Promise<FigureSaveResult> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(Figure)\n\n if (!isFigureType(figure.type ?? '')) {\n throw new Refusal(\n 'figure-type-malformed',\n { type: figure.type ?? '', min: TYPE_LENGTH.min, max: TYPE_LENGTH.max },\n '{type} is not a figure type. use lower-case letters, digits and single hyphens, {min} to {max} characters, starting with a letter.'\n )\n }\n assertFigureCategory(figure.category)\n const namespace = await namespaceForNewFigure(tx, domain, figure.namespace, user)\n\n // 타입 이름은 도메인 안에서 유일하다. 유니크 인덱스가 있지만 여기서 먼저 본다 —\n // DB 오류 문구는 저작자에게 아무 말도 해 주지 못한다.\n const taken = await repository.findOne({ where: { domain: { id: domain.id }, type: figure.type } })\n if (taken) {\n throw new Error(`타입 이름 '${figure.type}' 은 이미 쓰이고 있다. 만든 뒤에는 고칠 수 없으므로 다른 이름을 고른다`)\n }\n if (await typeReleasedBefore({ figures: repository, histories: tx.getRepository(FigureHistory) }, domain, figure.type!)) {\n throw new Error(releasedBeforeMessage(figure.type!))\n }\n\n // 형식을 어기면 여기서 던진다. 파생값은 서버가 계산한다.\n const { source, derived, violations } = parseSource(figure.source)\n await requireMeshFiles(tx, domain, source)\n\n const { thumbnail, ...rest } = figure\n const saved = await repository.save({\n ...rest,\n source,\n ...derived,\n namespace,\n state: figure.state ?? 'draft',\n ...(await pictureOf(tx, domain, user, thumbnail)),\n domain,\n creator: user,\n updater: user\n })\n\n return { figure: saved, violations }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureSaveResult, { description: 'Updates a figure. The `type` field cannot be changed.' })\n async updateFigure(\n @Arg('id') id: string,\n @Arg('patch') patch: FigurePatch,\n @Ctx() context: ResolverContext,\n @Arg('seen', type => FigureCatalogSeen, {\n nullable: true,\n description:\n 'The type, category and tags as the editor saw them, null when empty. Required for each of them the patch changes (FIGURE_CATALOG_SEEN_REQUIRED); ' +\n 'the update goes on only while the row still holds them (FIGURE_CATALOG_CONFLICT).'\n })\n seen?: FigureCatalogSeen\n ): Promise<FigureSaveResult> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(Figure)\n\n const figure = await ownFigure(repository, domain, id)\n assertCatalogSeen(patch, seen)\n /* The catalogue fields are the row's, not the source's: checked here and again in the UPDATE (catalogCriteriaOf). */\n const conflicts = seen ? catalogConflictsOf(figure, seen) : []\n if (conflicts.length) throw catalogConflict(conflicts)\n\n /*\n **그림만 바꾸면 발행이 풀리지 않는다.** 미리보기에서 사람이 돌려 놓은 각도로 찍은 그림이 그렇게 온다.\n 그림은 발행이 약속하는 것이 아니다 — 발행본은 제 그림을 따로 갖고, 다음 발행이 이 그림을 가져간다.\n 버전 구독자를 거치지 않는다: 발행된 행의 저장을 버전으로 베끼는데, 이것은 버전이 아니다.\n */\n if (patch.thumbnail !== undefined && Object.keys(patch).every(key => key === 'thumbnail' || (patch as any)[key] === undefined)) {\n const picture = await pictureOf(tx, domain, user, patch.thumbnail, figure)\n if (picture.thumbnailHash) {\n await repository.createQueryBuilder().update(Figure).set({ ...picture, updater: user }).where('id = :id', { id }).callListeners(false).execute()\n }\n return { figure: await repository.findOneOrFail({ where: { id } }), violations: [] }\n }\n\n // 정본이 바뀌면 파생값도 다시 계산한다. 안 바뀌었으면 손대지 않는다 —\n // 이름만 고쳤는데 점수가 흔들리면 읽는 사람이 원인을 못 찾는다.\n let derived: { name: string; score: number; triangles: number; groups: number } | undefined\n let violations = []\n let source = figure.source\n\n if (patch.source !== undefined && patch.source !== figure.source) {\n const parsed = parseSource(patch.source)\n await requireMeshFiles(tx, domain, parsed.source)\n source = parsed.source\n derived = parsed.derived\n violations = parsed.violations\n }\n\n /*\n **타입은 발행 전에만 바뀐다** — ADR-0063 결정 4.\n\n 발행된 뒤에는 이미 배치된 도면이 이 이름을 가리키고, 바꾸면 그 도면이 아무 오류 없이\n 빈 자리가 된다. 발행된 적 없는 피규어는 가리키는 도면이 있을 수 없다 — 도면은 최신\n 발행 버전을 그리므로 그려질 자리가 없다.\n\n 행과 정본 둘 다 고친다. 정본 안에도 `type` 이 있어서 한쪽만 고치면 저장된 JSON 과\n 행이 다른 이름을 말하고, 발행할 때 어느 쪽이 도면에 적히는지가 갈린다.\n */\n if (patch.names !== undefined) assertNames(patch.names)\n /* An app's category vocabulary (G5): a category outside it is refused, and one once set does not change. */\n assertFigureCategory(patch.category, figure.category)\n /* The picture is kept by its content; the patch's data URL is never written to the row. */\n const { thumbnail: picturePatch, ...patchRest } = patch\n const picture = await pictureOf(tx, domain, user, picturePatch, figure)\n\n let renamed: string | undefined\n if (patch.type !== undefined && patch.type !== figure.type) {\n const change = await this.renameType(figure, domain, patch.type, source, tx)\n renamed = change.type\n source = change.source\n }\n\n /*\n **버전 번호는 여기서 손대지 않는다.** 저장은 저작이고, 버전은 발행에서 생긴다(`releaseFigure`).\n board 의 `updateBoard` 도 같다 — 저장 경로에는 version 이 없다.\n */\n /*\n **바뀐 칸만 쓴다** (2026-11-03 점검 2). 처음 읽은 행을 통째로 펼쳐 다시 쓰면, 그 사이 다른 편집이\n `saveFigure` 로 저장한 정본이 읽어 둔 옛 정본으로 되돌아간다 — 설명 한 줄을 고쳤을 뿐인데. 정본을 쓰는\n 경우(정본 패치, 타입 바꾸기)는 `saveFigure` 와 같이 읽어 둔 정본이 그대로일 때만 쓴다.\n\n **고치면 발행이 풀린다.** 발행은 「이 버전을 써도 된다」는 약속이고, 그 뒤에 바뀌면 약속한 것과\n 배포된 것이 달라진다. 그래서 저장은 언제나 초안으로 되돌린다. 버전 번호는 여기서 손대지 않는다 —\n 버전은 발행에서 생긴다(`releaseFigure`).\n */\n const { type: _type, source: _source, ...fields } = patchRest\n const changes = {\n ...Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined)),\n ...(renamed !== undefined ? { type: renamed } : {}),\n ...(source !== figure.source ? { source } : {}),\n state: 'draft' as const,\n ...(derived ?? {}),\n ...picture,\n updater: user\n }\n const unchanged = seen ? catalogCriteriaOf(seen) : {}\n const written = async (criteria: object) => {\n const result = await repository.update({ ...criteria, ...unchanged } as never, changes)\n /* Nothing written: a catalogue field changed since the check above is said as one; the source as before. */\n if (seen && result.affected !== 1) {\n const now = catalogConflictsOf(await repository.findOneOrFail({ where: { id, domain: { id: domain.id } } }), seen)\n if (now.length) throw catalogConflict(now)\n }\n return result\n }\n if ('source' in changes) await compareAndSwapFigure(written, id, domain.id, figure.source)\n else await written({ id, domain: { id: domain.id } })\n const saved = await repository.findOneOrFail({ where: { id, domain: { id: domain.id } } })\n\n return { figure: saved, violations }\n }\n\n /**\n * 초안의 타입을 고친다 — 규칙은 `figure-rename.ts`, 여기서는 그 규칙이 볼 **사실만** 읽는다.\n *\n * 겹침은 DB 인덱스(`ix_figure_1`)도 잡지만 먼저 읽어 본다. 인덱스가 던지는 말은 저작자가\n * 읽을 것이 못 되고, 어느 이름이 이미 쓰였는지도 안 알려 준다.\n */\n private async renameType(\n figure: Figure,\n domain: { id: string },\n wanted: string,\n source: string,\n tx: { getRepository: <T>(target: new () => T) => any }\n ): Promise<{ type: string; source: string }> {\n /* 읽어 온 엔티티에는 관계가 안 실려 있다 — 도메인은 문맥에서 온 것을 쓴다. */\n const facts = await renameFacts(\n { figures: tx.getRepository(Figure), histories: tx.getRepository(FigureHistory) },\n figure,\n domain,\n wanted\n )\n\n return renameDraftType({ type: figure.type, source }, wanted, facts)\n }\n\n /**\n * 발행한다 — **버전이 생기는 유일한 자리.**\n *\n * ## 무엇이 일어나나\n *\n * `state` 가 `released` 가 되고, 버전 번호가 하나 오르고, 그 순간의 피규어가 버전으로 남는다\n * (`FigureHistory` — 스냅샷은 구독자가 뜬다). 저작 중 저장은 이 셋 중 아무것도 하지 않는다.\n *\n * ## 왜 이미 발행된 것을 거절하나\n *\n * 발행은 소비처에게 하는 약속이다. 같은 버전을 두 번 발행하면 무엇이 약속인지 흐려진다. 고쳐서\n * 다시 내려면 초안으로 되돌린 뒤 발행한다 — board 가 같은 규칙이다.\n *\n * ## 번호는 버전에서 센다\n *\n * 피규어의 현재 번호가 아니라 **버전의 최대 번호 + 1** 이다. 되돌리기로 옛 버전이 현재가 되어도\n * 다음 발행이 이미 쓴 번호를 다시 쓰지 않는다.\n *\n * ## 게이트를 통과해야 한다\n *\n * 크기를 바꿨을 때 조각이 갈라지는 피규어는 발행되지 않는다(`figure-gate.ts`). 소비처는 형상을\n * 늘려 쓰므로 — 그것이 이 형식의 값이다 — 늘려도 견디는지가 약속의 일부다. 화면은 같은 판정을\n * `inspectFigure` 로 미리 물어 이유를 보여 준다.\n */\n @Directive('@transaction')\n /* Releasing, retiring and making public are their own gate (LV figure-server design G6): an author who edits drafts need not be one who sends releases out. */\n @Directive('@privilege(category: \"figure-release\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Figure, { description: 'Releases a figure — raises its version and keeps the released state as history.' })\n async releaseFigure(\n @Arg('id') id: string,\n @Arg('comment', { nullable: true }) comment: string,\n @Ctx() context: ResolverContext\n ): Promise<Figure> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(Figure)\n const historyRepository = tx.getRepository(FigureHistory)\n\n const figure = await ownFigure(repository, domain, id)\n\n if (figure.state === 'released') {\n throw new Error(`Figure '${figure.type}' 은 이미 발행되어 있다. 고쳐서 다시 내려면 초안으로 되돌린 뒤 발행한다`)\n }\n\n /* A release promises boards the full name {namespace}/{type}: it goes out only under a namespace the domain owns and has active. */\n const namespace = namespaceOf(figure)\n await assertReleasableNamespace(tx, domain, namespace, user)\n assertReleasableCategory(figure.category, figure.type)\n\n /*\n ── 게이트는 여기 있어야 한다 ────────────────────────────────────────────\n 화면도 같은 판정을 미리 물어(`inspectFigure`) 이유를 보여 주지만, **막는 자리는 이곳뿐이다.**\n 물어본 뒤 정본이 바뀌었을 수 있고, 화면을 거치지 않는 부름도 있다.\n\n 막는 이유는 사유와 함께 낸다. 「발행할 수 없습니다」로 뭉치면 무엇을 고쳐야 하는지 모른다.\n */\n /*\n 직전 발행 버전을 먼저 꺼낸다. 버전 번호를 세는 데도 쓰고, **약속을 깨는 발행인가**를 견주는 데도\n 쓴다(ADR-0063 결정 3) — 도면은 type 만 적고 늘 최신 발행 버전을 그리므로, 다시 발행하는 것은\n 그 type 을 놓아 둔 모든 도면에게 같은 약속을 다시 하는 일이다.\n */\n const released = await historyRepository\n .createQueryBuilder('history')\n .where('history.originalId = :id', { id: figure.id })\n .orderBy('history.version', 'DESC')\n .limit(1)\n .getOne()\n\n const inspection = inspectSource(figure.source, released?.source, context.t, figure.type, figure.category)\n if (inspection.blocked) {\n const reasons = inspection.findings\n .filter(finding => finding.blocking)\n .map(finding => (finding.at ? `${finding.message} (${finding.at})` : finding.message))\n\n throw new Error(`Figure '${figure.type}' 은 아직 발행할 수 없다 — ${reasons.join(' · ')}`)\n }\n\n const nextVersion = released?.version ? Number(released.version) + 1 : 1\n /* What this release records about itself: its format, and what changed against the last one (ADR-0104). */\n const record = releaseRecordOf(figure.source!, released?.source)\n\n return await repository.save({\n /*\n `domain` 을 명시로 넣는다 — 읽어 온 엔티티에는 관계가 안 실려 있다.\n\n 버전 스냅샷은 넘겨받은 엔티티를 베끼므로, 여기서 빠지면 버전의 도메인이 비고 그 버전은\n 도메인으로 거르는 조회에 **한 줄도 안 걸린다**(실제로 그랬다). board 의 저장들도 같은\n 자리에서 domain 을 함께 넣는다.\n */\n domain,\n ...figure,\n version: nextVersion,\n state: 'released',\n updater: user,\n /* 버전 구독자가 이것들을 버전의 comment · assetFormat · kernelVersion · changes 로 옮긴다. Figure 의 칸이 아니다. */\n /* The release's own copy, its size range written down; the figure keeps the author's (ADR-0087 decision 6). */\n __releaseSource: record.source,\n __releaseComment: comment ?? null,\n __releaseFormat: record.format,\n __releaseKernel: record.kernel,\n __releaseChanges: record.changes,\n __releaseMetrics: record.metrics,\n __releaseTopView: record.topView\n } as any)\n }\n\n /**\n * 옛 버전으로 되돌린다.\n *\n * ## 무엇이 돌아오나\n *\n * 그 버전의 **정본과 속성 정의, 그리고 그림**이다. 이름·설명·분류는 그대로 둔다 — 그것들은 언제든\n * 바꿔도 안전한 카탈로그의 말이고, 되돌리기가 개명까지 되돌리면 사람이 시키지 않은 일을 한다.\n *\n * ## 되돌려도 발행은 아니다\n *\n * 초안으로 돌아온다. 다시 내보내려면 발행을 한 번 더 하고, 그때 버전 번호는 **이미 쓴 번호 다음**을\n * 받는다 — 버전 3을 되살렸다고 다시 버전 3이 되지 않는다. board 도 같다.\n *\n * ## 비용은 다시 잰다\n *\n * 버전이 든 점수·삼각형은 **그때의 형식**으로 잰 값이다. 지금 이 피규어가 그 내용이 되었으므로\n * 오늘 기준으로 다시 계산한다. 옛 값은 버전에 그대로 남아 있다.\n */\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureRevertResult, {\n description:\n 'Reverts a figure to one of its released versions, keeping the draft it writes over. It comes back as a draft. ' +\n 'The same requestId again answers with the same revert.'\n })\n async revertFigureVersion(\n @Arg('id') id: string,\n @Arg('version') version: number,\n @Arg('requestId', { description: 'A UUID for this revert: a retry sends the same one.' }) requestId: string,\n @Arg('expectedSource', { description: \"The figure's source as the reverter saw it; the revert goes on only while it holds.\" }) expectedSource: string,\n @Ctx() context: ResolverContext\n ): Promise<FigureRevertResult> {\n /* Kept and written over in this transaction, or neither (ADR-0097 §5.6). */\n const { domain, user, tx } = context.state\n const { figure, violations, kept } = await revertKeepingDraft(tx, domain, user, { id, version, requestId, expectedSource })\n return { figure, violations, kept }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureRevertResult, {\n description: \"Brings back a draft a revert kept -- only while the figure still holds what that revert wrote. The same requestId again answers with the same undo.\"\n })\n async undoFigureRevert(\n @Arg('keptId') keptId: string,\n @Arg('requestId', { description: 'A UUID for this undo: a retry sends the same one.' }) requestId: string,\n @Ctx() context: ResolverContext\n ): Promise<FigureRevertResult> {\n const { domain, user, tx } = context.state\n const { figure, kept } = await undoRevert(tx, domain, user, { keptId, requestId })\n return { figure, violations: [], kept: kept as FigureReplacedDraft }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'Soft-deletes a figure that has never been released. A released figure is refused: it is retired instead.' })\n async deleteFigure(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n /*\n A figure once released is not deleted, only retired (LV figure-server design G4, fmsim design 01 D5). Its releases\n have gone out in packages as `ns/type@n`; deleting it would let the same type be made again and numbered from 1,\n and the same reference would then name other content, which an importing server refuses.\n */\n const figure = await tx.getRepository(Figure).findOne({ where: { domain: { id: domain.id }, id } })\n if (figure) {\n const releases = await tx.getRepository(FigureHistory).count({ where: { originalId: figure.id } })\n if (releases > 0 || Number(figure.version) > 0) {\n throw new Refusal('figure-released-not-deletable', { type: figure.type }, '{type} has been released and cannot be deleted.')\n }\n }\n\n // 소프트 삭제다 — 행을 지우지 않고 되살릴 길을 남긴다.\n await tx.getRepository(Figure).softDelete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n /**\n * 퇴역시키거나 되살린다(ADR-0104 결정 6).\n *\n * 표시일 뿐이다. 발행 버전은 그대로 남고 받는 쪽은 그대로 받는다 — 발행 버전은 지우지 않는다. 그래서 **발행을 풀지 않는다**:\n * 행을 엔티티로 저장하지 않고 질의로 고친다. 엔티티로 저장하면 발행된 행이라 버전 구독자가 같은 번호로 버전을 또\n * 뜬다. 대신 쓸 것(`supersededBy`)은 같은 도메인(또는 상위)에 있는 다른 type 이어야 한다. 퇴역은 소유 도메인의 figure 만 한다.\n */\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-release\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Figure, { description: 'Retires a figure or brings it back. It stays released and served; supersededBy names the type to use instead.' })\n async setFigureDeprecation(\n @Arg('id') id: string,\n @Arg('deprecated') deprecated: boolean,\n @Ctx() context: ResolverContext,\n @Arg('supersededBy', { nullable: true }) supersededBy?: string\n ): Promise<Figure> {\n const { domain, tx } = context.state\n const repository = tx.getRepository(Figure)\n const figure = await ownFigure(repository, domain, id)\n /* What to use instead may be the parent domain's: a domain reads its parent's figures, it writes only its own. */\n const scope = { id: In([domain.id, domain.parentId].filter(Boolean)) }\n const instead = deprecated ? supersededBy?.trim() || null : null\n if (instead) {\n if (instead === figure.type) throw new Error(`Figure '${figure.type}' 는 자기 자신으로 대신할 수 없다`)\n const other = await repository.findOne({ where: { domain: scope, type: instead } })\n if (!other) throw new Error(`대신 쓸 Figure '${instead}' 가 이 도메인에 없다`)\n }\n await repository.createQueryBuilder().update(Figure).set({ deprecated, supersededBy: instead }).where('id = :id', { id }).callListeners(false).execute()\n return await repository.findOneOrFail({ where: { id } })\n }\n\n /**\n * Makes a released figure public, or private again (LV figure-server design G2). Public, other domains read its\n * releases, package them and draw it by full name; its draft stays this domain's, and only this domain changes it.\n * Like retiring, it is a mark on the row: no release is written and the release state is not undone.\n */\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-release\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Figure, { description: 'Makes a released figure public to other domains, or private again. Its draft is never shown to them.' })\n async setFigurePublic(@Arg('id') id: string, @Arg('public') isPublic: boolean, @Ctx() context: ResolverContext): Promise<Figure> {\n const { domain, tx } = context.state\n const repository = tx.getRepository(Figure)\n const figure = await ownFigure(repository, domain, id)\n if (isPublic) {\n const releases = await tx.getRepository(FigureHistory).count({ where: { originalId: figure.id } })\n if (!releases && !(Number(figure.version) > 0)) {\n throw new Refusal('figure-public-unreleased', { type: figure.type }, '{type} has no release yet: only released figures are made public.')\n }\n }\n await repository.createQueryBuilder().update(Figure).set({ public: isPublic }).where('id = :id', { id }).callListeners(false).execute()\n return await repository.findOneOrFail({ where: { id } })\n }\n\n /**\n * 저작 보조에게 제안을 시킨다(ADR-0094).\n *\n * **저장하지 않는다.** 모델러 명령 목록과 그것이 만드는 피규어를 돌려줄 뿐이고, 정본이 되는 것은 저작자가 모델러에\n * 적용하고 저장한 뒤다. 커널이 거절한 명령이나 게이트가 잡은 것은 여기까지 오지 않는다 — 제안기가 사유를 모델에\n * 돌려주고 다시 시킨다. 끝내 못 만들면 **사유와 함께 던진다.** 반쯤 만든 것을 돌려주지 않는다.\n */\n @Directive('@privilege(category: \"figure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureProposal, {\n description: 'Asks the authoring assistant for modeller commands that make or revise a figure. Nothing is saved.'\n })\n async proposeFigure(@Arg('request') request: ProposeRequest, @Ctx() context: ResolverContext): Promise<FigureProposal> {\n // 그림은 메모리로 받는다. 참고용이라 저장하지 않는다 — 남기면 지울 사람이 없다.\n let image\n if (request.image) {\n const file = await request.image\n const chunks: Buffer[] = []\n for await (const chunk of file.createReadStream()) {\n chunks.push(chunk as Buffer)\n }\n image = { data: Buffer.concat(chunks), mediaType: file.mimetype as never }\n }\n\n try {\n const result = await proposeFigureSteps({\n client: await aiClientFor({ domain: context.state.domain, user: context.state.user }),\n prompt: request.prompt,\n base: request.base ? parseFigureAsset(request.base) : undefined,\n name: request.name,\n ...(image ? { images: [image] } : {})\n })\n\n return {\n steps: JSON.stringify(result.steps),\n source: JSON.stringify(result.source),\n score: result.score ? Math.round(result.score.score) : undefined,\n grade: result.score?.grade,\n triangles: result.cost.triangles,\n attempts: result.attempts\n }\n } catch (e) {\n if (e instanceof ProposeFigureFailure) {\n // 사유를 삼키지 않는다. 저작자가 무엇이 막혔는지 알아야 말을 고쳐 다시 시킨다.\n throw new Error(proposalFailureForPerson(e, (key, params) => context.t(key, params)))\n }\n throw e\n }\n }\n\n}\n"]}