@things-factory/figure-service 10.1.110 → 10.1.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/index.js +15 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routers/figure-thumbnail-router.d.ts +12 -3
- package/dist-server/routers/figure-thumbnail-router.js +36 -30
- package/dist-server/routers/figure-thumbnail-router.js.map +1 -1
- package/dist-server/service/figure/event-subscriber.js +4 -1
- package/dist-server/service/figure/event-subscriber.js.map +1 -1
- package/dist-server/service/figure/figure-format.d.ts +5 -3
- package/dist-server/service/figure/figure-format.js +21 -5
- package/dist-server/service/figure/figure-format.js.map +1 -1
- package/dist-server/service/figure/figure-history.d.ts +4 -0
- package/dist-server/service/figure/figure-history.js +27 -0
- package/dist-server/service/figure/figure-history.js.map +1 -1
- package/dist-server/service/figure/figure-mutation.d.ts +10 -0
- package/dist-server/service/figure/figure-mutation.js +65 -9
- package/dist-server/service/figure/figure-mutation.js.map +1 -1
- package/dist-server/service/figure/figure-replaced-draft.d.ts +1 -0
- package/dist-server/service/figure/figure-replaced-draft.js +5 -0
- package/dist-server/service/figure/figure-replaced-draft.js.map +1 -1
- package/dist-server/service/figure/figure-revert.js +9 -4
- package/dist-server/service/figure/figure-revert.js.map +1 -1
- package/dist-server/service/figure/figure-thumbnail-store.d.ts +35 -0
- package/dist-server/service/figure/figure-thumbnail-store.js +96 -0
- package/dist-server/service/figure/figure-thumbnail-store.js.map +1 -0
- package/dist-server/service/figure/figure-thumbnail-upgrade.d.ts +8 -0
- package/dist-server/service/figure/figure-thumbnail-upgrade.js +56 -0
- package/dist-server/service/figure/figure-thumbnail-upgrade.js.map +1 -0
- package/dist-server/service/figure/figure-type.d.ts +1 -0
- package/dist-server/service/figure/figure-type.js +5 -0
- package/dist-server/service/figure/figure-type.js.map +1 -1
- package/dist-server/service/figure/figure-write.d.ts +14 -10
- package/dist-server/service/figure/figure-write.js +9 -4
- package/dist-server/service/figure/figure-write.js.map +1 -1
- package/dist-server/service/figure/figure.d.ts +4 -0
- package/dist-server/service/figure/figure.js +21 -0
- package/dist-server/service/figure/figure.js.map +1 -1
- package/dist-server/service/figure/index.d.ts +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/server/index.ts +15 -0
- package/server/routers/figure-thumbnail-router.ts +40 -36
- package/server/service/figure/event-subscriber.ts +4 -1
- package/server/service/figure/figure-deprecation-db.test.ts +107 -0
- package/server/service/figure/figure-format.test.ts +19 -1
- package/server/service/figure/figure-format.ts +27 -8
- package/server/service/figure/figure-history.ts +29 -0
- package/server/service/figure/figure-mutation.ts +56 -10
- package/server/service/figure/figure-release-record-db.test.ts +5 -0
- package/server/service/figure/figure-replaced-draft.ts +9 -0
- package/server/service/figure/figure-revert-db.test.ts +6 -5
- package/server/service/figure/figure-revert.ts +9 -4
- package/server/service/figure/figure-thumbnail-db.test.ts +218 -0
- package/server/service/figure/figure-thumbnail-store.ts +107 -0
- package/server/service/figure/figure-thumbnail-upgrade.pg.test.ts +93 -0
- package/server/service/figure/figure-thumbnail-upgrade.ts +70 -0
- package/server/service/figure/figure-type.ts +5 -0
- package/server/service/figure/figure-write.ts +15 -4
- package/server/service/figure/figure.ts +30 -0
- package/translations/en.json +4 -1
- package/translations/ko.json +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figure-revert.js","sourceRoot":"","sources":["../../../server/service/figure/figure-revert.ts"],"names":[],"mappings":";;AAmDA,gDA6DC;AAGD,gCAwDC;AAGD,4CAMC;AApLD,mCAAmC;AACnC,qCAAgD;AAChD,qCAAsC;AAEtC,2CAAoC;AACpC,2DAAmD;AACnD,yEAAgE;AAChE,yDAAgD;AAChD,uDAAkD;AAElD;;;;;;;;;;;;;GAaG;AAEH,MAAM,IAAI,GAAG,wEAAwE,CAAA;AACrF,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC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I,EAAE,EAAE,gBAAgB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;IACrG,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,gBAAgB,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAA;AAC3L,CAAC;AAED,wFAAwF;AACjF,KAAK,UAAU,gBAAgB,CAAC,EAAiB,EAAE,MAAsB,EAAE,QAAgB;IAChG,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,8CAAmB,CAAC,CAAC,IAAI,CAAC;QACtD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE;QAC9C,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;QAC5B,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { createHash } from 'crypto'\nimport { In, type EntityManager } from 'typeorm'\nimport { GraphQLError } from 'graphql'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\nimport { FigureReplacedDraft } from './figure-replaced-draft.js'\nimport { parseSource } from './figure-format.js'\nimport { sourceConflict } from './figure-write.js'\n\n/*\n * Reverting a figure to a released version, keeping the draft it writes over (ADR-0097 §5.6, designer 2026-09-27;\n * chief architect's ruling on the storage the same day).\n *\n * - One transaction: the draft is kept, then the figure is written over -- conditional on it being what the reverter\n * saw (`expectedSource`). If either fails, neither stays: the caller's transaction is rolled back.\n * - One request, one revert: `requestId` is unique in the domain. A retry -- the answer lost -- finds the revert it\n * asked for and answers with it; nothing is kept or written twice.\n * - An undo brings a kept draft back only while the figure still holds exactly what that revert wrote\n * (`WHERE id = ? AND source = ?`, as a save's compare-and-swap); edited since, it is refused and the kept draft stays.\n * It keeps what it replaces the same way.\n *\n * Every function here runs on the caller's transaction (`tx`); the resolvers open it (`@transaction`).\n */\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nconst hashOf = (text: string) => createHash('sha256').update(text).digest('hex')\nconst refused = (code: string, message: string) => new GraphQLError(message, { extensions: { code } })\n\n/*\n * The same request arriving twice at once: the second waits on the first's requestId and then meets the unique index.\n * Named, not a raw database error -- asked again after the first has finished, it gets the first's answer.\n */\nasync function keep(kept: { save: (row: any) => Promise<any> }, row: any) {\n try {\n return await kept.save(row)\n } catch (error: any) {\n const unique = error?.code === '23505' || error?.driverError?.code === '23505' || /UNIQUE constraint failed/.test(String(error?.message))\n if (unique) throw refused('FIGURE_REVERT_IN_FLIGHT', '같은 요청이 처리 중입니다. 잠시 뒤 다시 확인해 주세요.')\n throw error\n }\n}\n\nexport interface RevertRequest {\n id: string\n version: number\n requestId: string\n /** The figure's source as the reverter saw it; the revert goes on only while the figure still holds it. */\n expectedSource: string\n}\n\nexport async function revertKeepingDraft(\n tx: EntityManager,\n domain: { id: string; parentId?: string | null },\n user: { id: string } | undefined,\n request: RevertRequest\n) {\n if (!UUID.test(request.requestId ?? '')) throw refused('FIGURE_REVERT_REQUEST', '되돌리기 요청 식별자가 필요합니다.')\n const figures = tx.getRepository(Figure)\n const kept = tx.getRepository(FigureReplacedDraft)\n\n /* The same request again: the revert it made, answered again. */\n const before = await kept.findOne({ where: { domain: { id: domain.id }, requestId: request.requestId } })\n if (before) {\n if (before.figureId !== request.id || before.revertedToVersion !== request.version || before.kind !== 'revert')\n throw refused('FIGURE_REVERT_REQUEST', '이 되돌리기 요청 식별자는 다른 되돌리기에 이미 쓰였습니다.')\n return { figure: await figures.findOneOrFail({ where: { id: request.id, domain: { id: domain.id } } }), violations: [], kept: before }\n }\n\n /* Exact tenant ownership, as a save: an inherited figure is not written from a child domain. */\n const figure = await figures.findOne({ where: { id: request.id, domain: { id: domain.id } } })\n if (!figure) throw refused('FIGURE_NOT_FOUND', `Figure ${request.id} 를 찾을 수 없습니다.`)\n if (figure.source !== request.expectedSource) throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.')\n\n const history = await tx.getRepository(FigureHistory).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean) as string[]) }, originalId: request.id, version: request.version }\n })\n if (!history) throw refused('FIGURE_VERSION_NOT_FOUND', `Figure '${figure.type}' 에 ${request.version} 판이 없습니다.`)\n /* The format is checked again: an old version may break today's rules, and is not let in quietly. */\n const { source, derived, violations } = parseSource(history.source)\n\n const record = await keep(kept, {\n domain: { id: domain.id },\n figureId: figure.id,\n kind: 'revert' as const,\n source: figure.source,\n properties: figure.properties,\n thumbnail: figure.thumbnail,\n state: figure.state,\n version: figure.version,\n revertedToVersion: request.version,\n writtenSource: source,\n writtenSourceHash: hashOf(source),\n requestId: request.requestId,\n ...(user ? { creator: { id: user.id } } : {})\n })\n\n const written = await figures.update(\n { id: figure.id, domain: { id: domain.id }, source: request.expectedSource },\n {\n source,\n ...derived,\n properties: history.properties,\n thumbnail: history.thumbnail,\n thumbnailUpdatedAt: history.thumbnail === figure.thumbnail ? figure.thumbnailUpdatedAt : new Date(),\n state: 'draft',\n ...(user ? { updater: { id: user.id } } : {})\n }\n )\n if (written.affected !== 1) throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.')\n\n return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), violations, kept: record }\n}\n\n/** Brings a kept draft back -- only while the figure holds exactly what that revert wrote. */\nexport async function undoRevert(\n tx: EntityManager,\n domain: { id: string },\n user: { id: string } | undefined,\n request: { keptId: string; requestId: string }\n) {\n if (!UUID.test(request.requestId ?? '')) throw refused('FIGURE_REVERT_REQUEST', '되돌리기 취소 요청 식별자가 필요합니다.')\n const figures = tx.getRepository(Figure)\n const kept = tx.getRepository(FigureReplacedDraft)\n\n const record = await kept.findOne({ where: { id: request.keptId, domain: { id: domain.id } } })\n if (!record) throw refused('FIGURE_KEPT_NOT_FOUND', '되살릴 초안을 찾을 수 없습니다.')\n if (record.restoredAt) {\n /* Asked again with the same request: the undo it made. Another request for a draft already back: refused. */\n if (record.restoreRequestId === request.requestId)\n return { figure: await figures.findOneOrFail({ where: { id: record.figureId, domain: { id: domain.id } } }), kept: record }\n throw refused('FIGURE_KEPT_RESTORED', '이 초안은 이미 되살렸습니다.')\n }\n\n const figure = await figures.findOne({ where: { id: record.figureId, domain: { id: domain.id } } })\n if (!figure) throw refused('FIGURE_NOT_FOUND', `Figure ${record.figureId} 를 찾을 수 없습니다.`)\n\n /* What the undo replaces is kept too -- the same rule as a revert. */\n const { derived } = parseSource(record.source!)\n await keep(kept, {\n domain: { id: domain.id },\n figureId: figure.id,\n kind: 'undo' as const,\n source: figure.source,\n properties: figure.properties,\n thumbnail: figure.thumbnail,\n state: figure.state,\n version: figure.version,\n writtenSource: record.source,\n writtenSourceHash: hashOf(record.source!),\n requestId: request.requestId,\n ...(user ? { creator: { id: user.id } } : {})\n })\n\n const written = await figures.update(\n { id: figure.id, domain: { id: domain.id }, source: record.writtenSource },\n {\n source: record.source,\n ...derived,\n properties: record.properties,\n thumbnail: record.thumbnail,\n thumbnailUpdatedAt: record.thumbnail === figure.thumbnail ? figure.thumbnailUpdatedAt : new Date(),\n state: 'draft',\n ...(user ? { updater: { id: user.id } } : {})\n }\n )\n if (written.affected !== 1)\n throw sourceConflict('되돌린 뒤 모델이 다시 바뀌어 되돌리기를 취소하지 않았습니다. 보관한 초안은 그대로 남아 있습니다.')\n\n await kept.update({ id: record.id }, { restoredAt: new Date(), restoreRequestId: request.requestId })\n return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), kept: { ...record, restoredAt: new Date(), restoreRequestId: request.requestId } }\n}\n\n/** The drafts reverts kept for a figure, newest first -- found again after a reload. */\nexport async function replacedDraftsOf(tx: EntityManager, domain: { id: string }, figureId: string) {\n return await tx.getRepository(FigureReplacedDraft).find({\n where: { domain: { id: domain.id }, figureId },\n order: { createdAt: 'DESC' },\n relations: ['creator']\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"figure-revert.js","sourceRoot":"","sources":["../../../server/service/figure/figure-revert.ts"],"names":[],"mappings":";;AAmDA,gDAgEC;AAGD,gCA0DC;AAGD,4CAMC;AAzLD,mCAAmC;AACnC,qCAAgD;AAChD,qCAAsC;AAEtC,2CAAoC;AACpC,2DAAmD;AACnD,yEAAgE;AAChE,yDAAgD;AAChD,uDAAkD;AAElD;;;;;;;;;;;;;GAaG;AAEH,MAAM,IAAI,GAAG,wEAAwE,CAAA;AACrF,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAChF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAAC,IAAI,sBAAY,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;AAEtG;;;GAGG;AACH,KAAK,UAAU,IAAI,CAAC,IAA0C,EAAE,GAAQ;IACtE,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,KAAK,OAAO,IAAI,KAAK,EAAE,WAAW,EAAE,IAAI,KAAK,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,C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iB,EAAE,MAAsB,EAAE,QAAgB;IAChG,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,8CAAmB,CAAC,CAAC,IAAI,CAAC;QACtD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE;QAC9C,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;QAC5B,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { createHash } from 'crypto'\nimport { In, type EntityManager } from 'typeorm'\nimport { GraphQLError } from 'graphql'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\nimport { FigureReplacedDraft } from './figure-replaced-draft.js'\nimport { parseSource } from './figure-format.js'\nimport { sourceConflict } from './figure-write.js'\n\n/*\n * Reverting a figure to a released version, keeping the draft it writes over (ADR-0097 §5.6, designer 2026-09-27;\n * chief architect's ruling on the storage the same day).\n *\n * - One transaction: the draft is kept, then the figure is written over -- conditional on it being what the reverter\n * saw (`expectedSource`). If either fails, neither stays: the caller's transaction is rolled back.\n * - One request, one revert: `requestId` is unique in the domain. A retry -- the answer lost -- finds the revert it\n * asked for and answers with it; nothing is kept or written twice.\n * - An undo brings a kept draft back only while the figure still holds exactly what that revert wrote\n * (`WHERE id = ? AND source = ?`, as a save's compare-and-swap); edited since, it is refused and the kept draft stays.\n * It keeps what it replaces the same way.\n *\n * Every function here runs on the caller's transaction (`tx`); the resolvers open it (`@transaction`).\n */\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nconst hashOf = (text: string) => createHash('sha256').update(text).digest('hex')\nconst refused = (code: string, message: string) => new GraphQLError(message, { extensions: { code } })\n\n/*\n * The same request arriving twice at once: the second waits on the first's requestId and then meets the unique index.\n * Named, not a raw database error -- asked again after the first has finished, it gets the first's answer.\n */\nasync function keep(kept: { save: (row: any) => Promise<any> }, row: any) {\n try {\n return await kept.save(row)\n } catch (error: any) {\n const unique = error?.code === '23505' || error?.driverError?.code === '23505' || /UNIQUE constraint failed/.test(String(error?.message))\n if (unique) throw refused('FIGURE_REVERT_IN_FLIGHT', '같은 요청이 처리 중입니다. 잠시 뒤 다시 확인해 주세요.')\n throw error\n }\n}\n\nexport interface RevertRequest {\n id: string\n version: number\n requestId: string\n /** The figure's source as the reverter saw it; the revert goes on only while the figure still holds it. */\n expectedSource: string\n}\n\nexport async function revertKeepingDraft(\n tx: EntityManager,\n domain: { id: string; parentId?: string | null },\n user: { id: string } | undefined,\n request: RevertRequest\n) {\n if (!UUID.test(request.requestId ?? '')) throw refused('FIGURE_REVERT_REQUEST', '되돌리기 요청 식별자가 필요합니다.')\n const figures = tx.getRepository(Figure)\n const kept = tx.getRepository(FigureReplacedDraft)\n\n /* The same request again: the revert it made, answered again. */\n const before = await kept.findOne({ where: { domain: { id: domain.id }, requestId: request.requestId } })\n if (before) {\n if (before.figureId !== request.id || before.revertedToVersion !== request.version || before.kind !== 'revert')\n throw refused('FIGURE_REVERT_REQUEST', '이 되돌리기 요청 식별자는 다른 되돌리기에 이미 쓰였습니다.')\n return { figure: await figures.findOneOrFail({ where: { id: request.id, domain: { id: domain.id } } }), violations: [], kept: before }\n }\n\n /* Exact tenant ownership, as a save: an inherited figure is not written from a child domain. */\n const figure = await figures.findOne({ where: { id: request.id, domain: { id: domain.id } } })\n if (!figure) throw refused('FIGURE_NOT_FOUND', `Figure ${request.id} 를 찾을 수 없습니다.`)\n if (figure.source !== request.expectedSource) throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.')\n\n const history = await tx.getRepository(FigureHistory).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean) as string[]) }, originalId: request.id, version: request.version }\n })\n if (!history) throw refused('FIGURE_VERSION_NOT_FOUND', `Figure '${figure.type}' 에 ${request.version} 판이 없습니다.`)\n /* The format is checked again: an old version may break today's rules, and is not let in quietly. */\n const { source, derived, violations } = parseSource(history.source)\n\n const record = await keep(kept, {\n domain: { id: domain.id },\n figureId: figure.id,\n kind: 'revert' as const,\n source: figure.source,\n properties: figure.properties,\n thumbnail: figure.thumbnail,\n thumbnailHash: figure.thumbnailHash,\n state: figure.state,\n version: figure.version,\n revertedToVersion: request.version,\n writtenSource: source,\n writtenSourceHash: hashOf(source),\n requestId: request.requestId,\n ...(user ? { creator: { id: user.id } } : {})\n })\n\n const written = await figures.update(\n { id: figure.id, domain: { id: domain.id }, source: request.expectedSource },\n {\n source,\n ...derived,\n properties: history.properties,\n /* The picture goes by its hash (ADR-0104 decision 6); the release's own, as the source is. */\n thumbnail: null,\n thumbnailHash: history.thumbnailHash ?? null,\n thumbnailUpdatedAt: history.thumbnailHash === figure.thumbnailHash ? figure.thumbnailUpdatedAt : new Date(),\n state: 'draft',\n ...(user ? { updater: { id: user.id } } : {})\n }\n )\n if (written.affected !== 1) throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.')\n\n return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), violations, kept: record }\n}\n\n/** Brings a kept draft back -- only while the figure holds exactly what that revert wrote. */\nexport async function undoRevert(\n tx: EntityManager,\n domain: { id: string },\n user: { id: string } | undefined,\n request: { keptId: string; requestId: string }\n) {\n if (!UUID.test(request.requestId ?? '')) throw refused('FIGURE_REVERT_REQUEST', '되돌리기 취소 요청 식별자가 필요합니다.')\n const figures = tx.getRepository(Figure)\n const kept = tx.getRepository(FigureReplacedDraft)\n\n const record = await kept.findOne({ where: { id: request.keptId, domain: { id: domain.id } } })\n if (!record) throw refused('FIGURE_KEPT_NOT_FOUND', '되살릴 초안을 찾을 수 없습니다.')\n if (record.restoredAt) {\n /* Asked again with the same request: the undo it made. Another request for a draft already back: refused. */\n if (record.restoreRequestId === request.requestId)\n return { figure: await figures.findOneOrFail({ where: { id: record.figureId, domain: { id: domain.id } } }), kept: record }\n throw refused('FIGURE_KEPT_RESTORED', '이 초안은 이미 되살렸습니다.')\n }\n\n const figure = await figures.findOne({ where: { id: record.figureId, domain: { id: domain.id } } })\n if (!figure) throw refused('FIGURE_NOT_FOUND', `Figure ${record.figureId} 를 찾을 수 없습니다.`)\n\n /* What the undo replaces is kept too -- the same rule as a revert. */\n const { derived } = parseSource(record.source!)\n await keep(kept, {\n domain: { id: domain.id },\n figureId: figure.id,\n kind: 'undo' as const,\n source: figure.source,\n properties: figure.properties,\n thumbnail: figure.thumbnail,\n thumbnailHash: figure.thumbnailHash,\n state: figure.state,\n version: figure.version,\n writtenSource: record.source,\n writtenSourceHash: hashOf(record.source!),\n requestId: request.requestId,\n ...(user ? { creator: { id: user.id } } : {})\n })\n\n const written = await figures.update(\n { id: figure.id, domain: { id: domain.id }, source: record.writtenSource },\n {\n source: record.source,\n ...derived,\n properties: record.properties,\n thumbnail: null,\n thumbnailHash: record.thumbnailHash ?? null,\n thumbnailUpdatedAt: record.thumbnailHash === figure.thumbnailHash ? figure.thumbnailUpdatedAt : new Date(),\n state: 'draft',\n ...(user ? { updater: { id: user.id } } : {})\n }\n )\n if (written.affected !== 1)\n throw sourceConflict('되돌린 뒤 모델이 다시 바뀌어 되돌리기를 취소하지 않았습니다. 보관한 초안은 그대로 남아 있습니다.')\n\n await kept.update({ id: record.id }, { restoredAt: new Date(), restoreRequestId: request.requestId })\n return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), kept: { ...record, restoredAt: new Date(), restoreRequestId: request.requestId } }\n}\n\n/** The drafts reverts kept for a figure, newest first -- found again after a reload. */\nexport async function replacedDraftsOf(tx: EntityManager, domain: { id: string }, figureId: string) {\n return await tx.getRepository(FigureReplacedDraft).find({\n where: { domain: { id: domain.id }, figureId },\n order: { createdAt: 'DESC' },\n relations: ['creator']\n })\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Attachment } from '@things-factory/attachment-base';
|
|
2
|
+
export declare const THUMBNAIL_REF_TYPE = "figure-thumbnail";
|
|
3
|
+
/** `data:image/webp;base64,....` as its type and bytes; undefined when it is not one. */
|
|
4
|
+
export declare function decodeDataUrl(dataUrl: string): {
|
|
5
|
+
type: string;
|
|
6
|
+
bytes: Buffer;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export declare const sha256Of: (bytes: Buffer) => string;
|
|
9
|
+
/** Where the bytes go: attachment-base's storage. Tests give another. */
|
|
10
|
+
export interface ThumbnailFiles {
|
|
11
|
+
put(bytes: Buffer, mimetype: string, name: string, context: any): Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
path: string;
|
|
14
|
+
size: number;
|
|
15
|
+
contents?: Buffer;
|
|
16
|
+
}>;
|
|
17
|
+
send(koa: any, path: string, next: () => Promise<any>): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare const attachmentFiles: ThumbnailFiles;
|
|
20
|
+
export declare const thumbnailFiles: () => ThumbnailFiles;
|
|
21
|
+
/** For tests: use these files until set back; returns the ones it replaced. */
|
|
22
|
+
export declare function useThumbnailFiles(files: ThumbnailFiles): ThumbnailFiles;
|
|
23
|
+
type Tx = {
|
|
24
|
+
getRepository: (target: any) => any;
|
|
25
|
+
};
|
|
26
|
+
/** The attachment holding this content in this domain, or undefined. */
|
|
27
|
+
export declare function thumbnailAttachmentOf(tx: Tx, domainId: string, hash: string): Promise<Attachment | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Keeps a picture and gives its hash. Refused when it is not a data URL -- a picture the server cannot read is one it
|
|
30
|
+
* must not keep under a name.
|
|
31
|
+
*/
|
|
32
|
+
export declare function keepThumbnail(tx: Tx, domain: {
|
|
33
|
+
id: string;
|
|
34
|
+
}, user: unknown, dataUrl: string, files?: ThumbnailFiles): Promise<string>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.thumbnailFiles = exports.attachmentFiles = exports.sha256Of = exports.THUMBNAIL_REF_TYPE = void 0;
|
|
4
|
+
exports.decodeDataUrl = decodeDataUrl;
|
|
5
|
+
exports.useThumbnailFiles = useThumbnailFiles;
|
|
6
|
+
exports.thumbnailAttachmentOf = thumbnailAttachmentOf;
|
|
7
|
+
exports.keepThumbnail = keepThumbnail;
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
const stream_1 = require("stream");
|
|
10
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
11
|
+
/*
|
|
12
|
+
* A figure's picture, kept by attachment-base and named by its content (ADR-0104 decision 6, chief architect's ruling
|
|
13
|
+
* 2026-10-02).
|
|
14
|
+
*
|
|
15
|
+
* stored by attachment-base's storage (file, S3, database -- whichever the install configures), one attachment
|
|
16
|
+
* per (domain, content): refType `figure-thumbnail`, refBy the SHA-256 of the bytes. A figure, its
|
|
17
|
+
* releases and the drafts a revert kept carry that hash, never the bytes.
|
|
18
|
+
* served only through `/figure-thumbnail/:id`, behind the figure query permission -- never through attachment-
|
|
19
|
+
* base's public `/attachment/:path`, which checks nothing (a known gap, recorded in ADR-0104).
|
|
20
|
+
* the same content twice in one domain is one attachment, read by its hash. Two writers that both find none both
|
|
21
|
+
* write one; either serves the same bytes, so the result is the same (ruling, condition 2).
|
|
22
|
+
*
|
|
23
|
+
* The file is written before the row that names it: a file cannot be rolled back, so it goes first, and a row that
|
|
24
|
+
* fails to commit leaves a file the next write of the same content writes again.
|
|
25
|
+
*/
|
|
26
|
+
exports.THUMBNAIL_REF_TYPE = 'figure-thumbnail';
|
|
27
|
+
/** `data:image/webp;base64,....` as its type and bytes; undefined when it is not one. */
|
|
28
|
+
function decodeDataUrl(dataUrl) {
|
|
29
|
+
const matched = /^data:([^;,]+);base64,(.*)$/s.exec(dataUrl);
|
|
30
|
+
return matched ? { type: matched[1], bytes: Buffer.from(matched[2], 'base64') } : undefined;
|
|
31
|
+
}
|
|
32
|
+
const sha256Of = (bytes) => (0, crypto_1.createHash)('sha256').update(bytes).digest('hex');
|
|
33
|
+
exports.sha256Of = sha256Of;
|
|
34
|
+
exports.attachmentFiles = {
|
|
35
|
+
async put(bytes, mimetype, name, context) {
|
|
36
|
+
const file = Promise.resolve({
|
|
37
|
+
createReadStream: () => stream_1.Readable.from([bytes]),
|
|
38
|
+
filename: name,
|
|
39
|
+
mimetype,
|
|
40
|
+
encoding: 'binary'
|
|
41
|
+
});
|
|
42
|
+
const { id, path, size, contents } = await attachment_base_1.STORAGE.uploadFile({ file, context });
|
|
43
|
+
return { id, path, size, contents };
|
|
44
|
+
},
|
|
45
|
+
send: (koa, path, next) => attachment_base_1.STORAGE.sendFile(koa, path, next)
|
|
46
|
+
};
|
|
47
|
+
/*
|
|
48
|
+
* The files in use: attachment-base's storage, unless a test gives its own. One seam for every writer and the router,
|
|
49
|
+
* so a test of a save or a revert need not reach into each.
|
|
50
|
+
*/
|
|
51
|
+
let inUse = exports.attachmentFiles;
|
|
52
|
+
const thumbnailFiles = () => inUse;
|
|
53
|
+
exports.thumbnailFiles = thumbnailFiles;
|
|
54
|
+
/** For tests: use these files until set back; returns the ones it replaced. */
|
|
55
|
+
function useThumbnailFiles(files) {
|
|
56
|
+
const was = inUse;
|
|
57
|
+
inUse = files;
|
|
58
|
+
return was;
|
|
59
|
+
}
|
|
60
|
+
/** The attachment holding this content in this domain, or undefined. */
|
|
61
|
+
async function thumbnailAttachmentOf(tx, domainId, hash) {
|
|
62
|
+
return (await tx.getRepository(attachment_base_1.Attachment).findOne({ where: { domain: { id: domainId }, refType: exports.THUMBNAIL_REF_TYPE, refBy: hash } })) ?? undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Keeps a picture and gives its hash. Refused when it is not a data URL -- a picture the server cannot read is one it
|
|
66
|
+
* must not keep under a name.
|
|
67
|
+
*/
|
|
68
|
+
async function keepThumbnail(tx, domain, user, dataUrl, files = (0, exports.thumbnailFiles)()) {
|
|
69
|
+
const decoded = decodeDataUrl(dataUrl);
|
|
70
|
+
if (!decoded)
|
|
71
|
+
throw new Error('썸네일은 data URL(data:image/...;base64,...) 이어야 한다');
|
|
72
|
+
const hash = (0, exports.sha256Of)(decoded.bytes);
|
|
73
|
+
if (await thumbnailAttachmentOf(tx, domain.id, hash))
|
|
74
|
+
return hash;
|
|
75
|
+
const ext = decoded.type.split('/')[1]?.split('+')[0] || 'bin';
|
|
76
|
+
const name = `${hash}.${ext}`;
|
|
77
|
+
/* The file first: it cannot be rolled back. The row that names it comes after, in the caller's transaction. */
|
|
78
|
+
const put = await files.put(decoded.bytes, decoded.type, name, { state: { domain, user, tx } });
|
|
79
|
+
await tx.getRepository(attachment_base_1.Attachment).save({
|
|
80
|
+
domain,
|
|
81
|
+
creator: user,
|
|
82
|
+
updater: user,
|
|
83
|
+
id: put.id,
|
|
84
|
+
name,
|
|
85
|
+
mimetype: decoded.type,
|
|
86
|
+
encoding: 'binary',
|
|
87
|
+
refType: exports.THUMBNAIL_REF_TYPE,
|
|
88
|
+
refBy: hash,
|
|
89
|
+
category: 'image',
|
|
90
|
+
size: String(put.size),
|
|
91
|
+
path: put.path,
|
|
92
|
+
...(put.contents ? { contents: put.contents } : {})
|
|
93
|
+
});
|
|
94
|
+
return hash;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=figure-thumbnail-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-thumbnail-store.js","sourceRoot":"","sources":["../../../server/service/figure/figure-thumbnail-store.ts"],"names":[],"mappings":";;;AAwBA,sCAGC;AA+BD,8CAIC;AAKD,sDAEC;AAMD,sCA+BC;AA1GD,mCAAmC;AACnC,mCAAiC;AAEjC,qEAAqE;AAErE;;;;;;;;;;;;;;GAcG;AAEU,QAAA,kBAAkB,GAAG,kBAAkB,CAAA;AAEpD,yFAAyF;AACzF,SAAgB,aAAa,CAAC,OAAe;IAC3C,MAAM,OAAO,GAAG,8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,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/F,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,CAAC;QACtC,MAAM;QACN,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,0BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { createHash } from 'crypto'\nimport { Readable } from 'stream'\n\nimport { Attachment, STORAGE } from '@things-factory/attachment-base'\n\n/*\n * A figure's picture, kept by attachment-base and named by its content (ADR-0104 decision 6, chief architect's ruling\n * 2026-10-02).\n *\n * stored by attachment-base's storage (file, S3, database -- whichever the install configures), one attachment\n * per (domain, content): refType `figure-thumbnail`, refBy the SHA-256 of the bytes. A figure, its\n * releases and the drafts a revert kept carry that hash, never the bytes.\n * served only through `/figure-thumbnail/:id`, behind the figure query permission -- never through attachment-\n * base's public `/attachment/:path`, which checks nothing (a known gap, recorded in ADR-0104).\n * the same content twice in one domain is one attachment, read by its hash. Two writers that both find none both\n * write one; either serves the same bytes, so the result is the same (ruling, condition 2).\n *\n * The file is written before the row that names it: a file cannot be rolled back, so it goes first, and a row that\n * fails to commit leaves a file the next write of the same content writes again.\n */\n\nexport const THUMBNAIL_REF_TYPE = 'figure-thumbnail'\n\n/** `data:image/webp;base64,....` as its type and bytes; undefined when it is not one. */\nexport function decodeDataUrl(dataUrl: string): { type: string; bytes: Buffer } | undefined {\n const matched = /^data:([^;,]+);base64,(.*)$/s.exec(dataUrl)\n return matched ? { type: matched[1]!, bytes: Buffer.from(matched[2]!, 'base64') } : undefined\n}\n\nexport const sha256Of = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')\n\n/** Where the bytes go: attachment-base's storage. Tests give another. */\nexport interface ThumbnailFiles {\n put(bytes: Buffer, mimetype: string, name: string, context: any): Promise<{ id: string; path: string; size: number; contents?: Buffer }>\n send(koa: any, path: string, next: () => Promise<any>): Promise<void>\n}\n\nexport const attachmentFiles: ThumbnailFiles = {\n async put(bytes, mimetype, name, context) {\n const file = Promise.resolve({\n createReadStream: () => Readable.from([bytes]),\n filename: name,\n mimetype,\n encoding: 'binary'\n })\n const { id, path, size, contents } = await STORAGE.uploadFile({ file, context })\n return { id, path, size, contents }\n },\n send: (koa, path, next) => STORAGE.sendFile(koa, path, next)\n}\n\n/*\n * The files in use: attachment-base's storage, unless a test gives its own. One seam for every writer and the router,\n * so a test of a save or a revert need not reach into each.\n */\nlet inUse: ThumbnailFiles = attachmentFiles\nexport const thumbnailFiles = (): ThumbnailFiles => inUse\n/** For tests: use these files until set back; returns the ones it replaced. */\nexport function useThumbnailFiles(files: ThumbnailFiles): ThumbnailFiles {\n const was = inUse\n inUse = files\n return was\n}\n\ntype Tx = { getRepository: (target: any) => any }\n\n/** The attachment holding this content in this domain, or undefined. */\nexport async function thumbnailAttachmentOf(tx: Tx, domainId: string, hash: string): Promise<Attachment | undefined> {\n return (await tx.getRepository(Attachment).findOne({ where: { domain: { id: domainId }, refType: THUMBNAIL_REF_TYPE, refBy: hash } })) ?? undefined\n}\n\n/**\n * Keeps a picture and gives its hash. Refused when it is not a data URL -- a picture the server cannot read is one it\n * must not keep under a name.\n */\nexport async function keepThumbnail(\n tx: Tx,\n domain: { id: string },\n user: unknown,\n dataUrl: string,\n files: ThumbnailFiles = thumbnailFiles()\n): Promise<string> {\n const decoded = decodeDataUrl(dataUrl)\n if (!decoded) throw new Error('썸네일은 data URL(data:image/...;base64,...) 이어야 한다')\n const hash = sha256Of(decoded.bytes)\n if (await thumbnailAttachmentOf(tx, domain.id, hash)) return hash\n const ext = decoded.type.split('/')[1]?.split('+')[0] || 'bin'\n const name = `${hash}.${ext}`\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(decoded.bytes, decoded.type, 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: decoded.type,\n encoding: 'binary',\n refType: THUMBNAIL_REF_TYPE,\n refBy: hash,\n category: 'image',\n size: String(put.size),\n path: put.path,\n ...(put.contents ? { contents: put.contents } : {})\n })\n return hash\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moveBase64Thumbnails = moveBase64Thumbnails;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const figure_js_1 = require("./figure.js");
|
|
6
|
+
const figure_history_js_1 = require("./figure-history.js");
|
|
7
|
+
const figure_replaced_draft_js_1 = require("./figure-replaced-draft.js");
|
|
8
|
+
const figure_thumbnail_store_js_1 = require("./figure-thumbnail-store.js");
|
|
9
|
+
const TABLES = [
|
|
10
|
+
{ table: 'figure', entity: figure_js_1.Figure },
|
|
11
|
+
{ table: 'figure_history', entity: figure_history_js_1.FigureHistory },
|
|
12
|
+
{ table: 'figure_replaced_draft', entity: figure_replaced_draft_js_1.FigureReplacedDraft }
|
|
13
|
+
];
|
|
14
|
+
async function moveBase64Thumbnails(dataSource, files = (0, figure_thumbnail_store_js_1.thumbnailFiles)()) {
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const { table, entity } of TABLES) {
|
|
17
|
+
const rows = await dataSource.getRepository(entity).find({
|
|
18
|
+
where: { thumbnail: (0, typeorm_1.Not)((0, typeorm_1.IsNull)()) },
|
|
19
|
+
relations: { domain: true },
|
|
20
|
+
select: { id: true, thumbnail: true, domain: { id: true }, ...(entity === figure_history_js_1.FigureHistory ? { originalId: true } : {}) },
|
|
21
|
+
withDeleted: true
|
|
22
|
+
});
|
|
23
|
+
let moved = 0, kept = 0;
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
/* A release written before releases carried their domain names it through the figure it belongs to. */
|
|
26
|
+
const domainId = row.domain?.id ??
|
|
27
|
+
(entity === figure_history_js_1.FigureHistory && row.originalId
|
|
28
|
+
? (await dataSource.getRepository(figure_js_1.Figure).findOne({ where: { id: row.originalId }, relations: { domain: true }, select: { id: true, domain: { id: true } }, withDeleted: true }))?.domain?.id
|
|
29
|
+
: undefined);
|
|
30
|
+
if (!domainId) {
|
|
31
|
+
kept++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await dataSource.transaction(async (tx) => {
|
|
36
|
+
const hash = await (0, figure_thumbnail_store_js_1.keepThumbnail)(tx, { id: domainId }, undefined, row.thumbnail, files);
|
|
37
|
+
await tx
|
|
38
|
+
.createQueryBuilder()
|
|
39
|
+
.update(entity)
|
|
40
|
+
.set({ thumbnailHash: hash, thumbnail: null })
|
|
41
|
+
.where('id = :id AND thumbnail = :was', { id: row.id, was: row.thumbnail })
|
|
42
|
+
.callListeners(false)
|
|
43
|
+
.execute();
|
|
44
|
+
});
|
|
45
|
+
moved++;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error(`[figure-service] ${table} ${row.id} 의 썸네일을 옮기지 못했다 — base64 를 그대로 둔다: ${error?.message ?? error}`);
|
|
49
|
+
kept++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
out.push({ table, moved, kept });
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=figure-thumbnail-upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-thumbnail-upgrade.js","sourceRoot":"","sources":["../../../server/service/figure/figure-thumbnail-upgrade.ts"],"names":[],"mappings":";;AA2BA,oDA0CC;AArED,qCAAqC;AAErC,2CAAoC;AACpC,2DAAmD;AACnD,yEAAgE;AAChE,2EAAgG;AAgBhG,MAAM,MAAM,GAAG;IACb,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAM,EAAE;IACnC,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,iCAAa,EAAE;IAClD,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,8CAAmB,EAAE;CACvD,CAAA;AAEH,KAAK,UAAU,oBAAoB,CAAC,UAAe,EAAE,QAAwB,IAAA,0CAAc,GAAE;IAClG,MAAM,GAAG,GAAY,EAAE,CAAA;IACvB,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACvC,MAAM,IAAI,GAAU,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YAC9D,KAAK,EAAE,EAAE,SAAS,EAAE,IAAA,aAAG,EAAC,IAAA,gBAAM,GAAE,CAAC,EAAE;YACnC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YAC3B,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,MAAM,KAAK,iCAAa,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;YACtH,WAAW,EAAE,IAAI;SAClB,CAAC,CAAA;QACF,IAAI,KAAK,GAAG,CAAC,E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,EAAE,CAAA;gBACd,CAAC,CAAC,CAAA;gBACF,KAAK,EAAE,CAAA;YACT,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,KAAK,IAAI,GAAG,CAAC,EAAE,sCAAuC,KAAe,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAA;gBAC5H,IAAI,EAAE,CAAA;YACR,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { IsNull, Not } from 'typeorm'\n\nimport { Figure } from './figure.js'\nimport { FigureHistory } from './figure-history.js'\nimport { FigureReplacedDraft } from './figure-replaced-draft.js'\nimport { keepThumbnail, thumbnailFiles, type ThumbnailFiles } from './figure-thumbnail-store.js'\n\n/*\n * Moves the pictures an install kept as base64 into attachment-base, by their content (ADR-0104 decision 6; chief\n * architect's ruling 2026-10-02, condition 3). Run at start, in the boot's one line (`inBootTurn`).\n *\n * per row the file first -- it cannot be rolled back -- then, in one transaction, the attachment row, the hash,\n * and the base64 emptied. The update only takes a row whose base64 is still the one read, so two starts\n * at once, or a save in between, never empty a picture that was not moved.\n * again safe: a row already moved has no base64 and is not read; a picture already kept is found by its hash.\n * kept a picture that is not a data URL, or a row whose domain cannot be found, keeps its base64 and is\n * counted -- nothing is emptied that was not moved.\n */\n\ntype Moved = { table: string; moved: number; kept: number }\n\nconst TABLES = [\n { table: 'figure', entity: Figure },\n { table: 'figure_history', entity: FigureHistory },\n { table: 'figure_replaced_draft', entity: FigureReplacedDraft }\n] as const\n\nexport async function moveBase64Thumbnails(dataSource: any, files: ThumbnailFiles = thumbnailFiles()): Promise<Moved[]> {\n const out: Moved[] = []\n for (const { table, entity } of TABLES) {\n const rows: any[] = await dataSource.getRepository(entity).find({\n where: { thumbnail: Not(IsNull()) },\n relations: { domain: true },\n select: { id: true, thumbnail: true, domain: { id: true }, ...(entity === FigureHistory ? { originalId: true } : {}) },\n withDeleted: true\n })\n let moved = 0,\n kept = 0\n for (const row of rows) {\n /* A release written before releases carried their domain names it through the figure it belongs to. */\n const domainId: string | undefined =\n row.domain?.id ??\n (entity === FigureHistory && row.originalId\n ? (await dataSource.getRepository(Figure).findOne({ where: { id: row.originalId }, relations: { domain: true }, select: { id: true, domain: { id: true } }, withDeleted: true }))?.domain?.id\n : undefined)\n if (!domainId) {\n kept++\n continue\n }\n try {\n await dataSource.transaction(async (tx: any) => {\n const hash = await keepThumbnail(tx, { id: domainId }, undefined, row.thumbnail, files)\n await tx\n .createQueryBuilder()\n .update(entity)\n .set({ thumbnailHash: hash, thumbnail: null })\n .where('id = :id AND thumbnail = :was', { id: row.id, was: row.thumbnail })\n .callListeners(false)\n .execute()\n })\n moved++\n } catch (error) {\n console.error(`[figure-service] ${table} ${row.id} 의 썸네일을 옮기지 못했다 — base64 를 그대로 둔다: ${(error as Error)?.message ?? error}`)\n kept++\n }\n }\n out.push({ table, moved, kept })\n }\n return out\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.FigureInspection = exports.FigureGateFinding = exports.FigureRevertResul
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const figure_replaced_draft_js_1 = require("./figure-replaced-draft.js");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const graphql_scalars_1 = require("graphql-scalars");
|
|
7
8
|
const figure_js_1 = require("./figure.js");
|
|
8
9
|
/**
|
|
9
10
|
* 새 Figure.
|
|
@@ -79,6 +80,10 @@ tslib_1.__decorate([
|
|
|
79
80
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The new description.' }),
|
|
80
81
|
tslib_1.__metadata("design:type", String)
|
|
81
82
|
], FigurePatch.prototype, "description", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Display names by language. {} clears them; omitting the field leaves them.' }),
|
|
85
|
+
tslib_1.__metadata("design:type", Object)
|
|
86
|
+
], FigurePatch.prototype, "names", void 0);
|
|
82
87
|
tslib_1.__decorate([
|
|
83
88
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The new classification code.' }),
|
|
84
89
|
tslib_1.__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figure-type.js","sourceRoot":"","sources":["../../../server/service/figure/figure-type.ts"],"names":[],"mappings":";;;;AAAA,yEAAgE;AAChE,+CAAgE;AAEhE,2CAAoC;AAEpC;;;;;GAKG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAS;CA2BrB,CAAA;AA3BY,8BAAS;AAEpB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;;uCAC9E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;uCAC7C;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;8CAC7D;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;;2CACnF;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;uCACzF;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;yCACpD;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gEAAgE,EAAE,CAAC;;6CACtF;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAA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ObjectType } from 'type-graphql'\n\nimport { Figure } from './figure.js'\n\n/**\n * 새 Figure.\n *\n * `score`·`triangles`·`groups` 는 **받지 않는다.** 서버가 `source` 에서 계산한다 —\n * 받으면 거짓이 들어오고 목록이 실물과 다른 것을 보여 준다.\n */\n@InputType({ description: 'Input for creating a new figure.' })\nexport class NewFigure {\n @Field({ description: 'Component type name. Immutable once created, unique per domain.' })\n type: string\n\n @Field({ description: 'Display name shown to authors.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the figure.' })\n description?: string\n\n @Field({ nullable: true, description: 'Classification code used to group figures in the palette.' })\n category?: string\n\n @Field(type => [String], { nullable: true, description: 'Free-form tags. A figure may carry several.' })\n tags?: string[]\n\n @Field({ description: 'The figure asset JSON (figure-asset-1).' })\n source: string\n\n @Field({ nullable: true, description: 'JSON definition of the master-data fields an instance carries.' })\n properties?: string\n\n @Field({ nullable: true, description: \"Lifecycle state — defaults to 'draft'.\" })\n state?: 'draft' | 'released'\n\n @Field({ nullable: true, description: 'A base64 encoded thumbnail image.' })\n thumbnail?: string\n}\n\n/**\n * 수정.\n *\n * `type` 은 **한 번도 발행되지 않은 초안에서만** 바뀐다(ADR-0063 결정 4). 저장되는 식별자라\n * 발행된 뒤에 바꾸면 이미 배치된 보드가 타입을 못 찾아 오류 없이 빈 화면이 된다. 발행 전에는\n * 그 도형을 가리키는 도면이 있을 수 없다 — 도면은 최신 발행판을 그리므로 발행된 적 없는\n * 도형은 그려질 자리가 없다.\n *\n * 닫아 두었더니 저작자가 이름을 한 번도 정하지 못했다. 새 Figure 에는 기계가 지은 이름이\n * 붙고(`FIGURE_MU6RJH47`) 칸에 자물쇠가 걸려서, 그 이름이 그대로 도면에 적히는 이름이 됐다.\n */\n@InputType({ description: 'Input for updating an existing figure. `type` is accepted only while the figure has never been released.' })\nexport class FigurePatch {\n @Field({ nullable: true, description: 'The stored identifier. Accepted only before the first release; rejected once a version exists.' })\n type?: string\n\n @Field({ nullable: true, description: 'The new display name.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new classification code.' })\n category?: string\n\n /*\n 빈 배열과 안 준 것을 가른다. `undefined` 는 「건드리지 않는다」, `[]` 는 「전부 지운다」다.\n 둘을 뭉개면 태그를 다 지우려는 저작자가 지울 방법을 잃는다.\n */\n @Field(type => [String], { nullable: true, description: 'The new tags. An empty list clears them; omitting the field leaves them.' })\n tags?: string[]\n\n @Field({ nullable: true, description: 'The new figure asset JSON (figure-asset-1).' })\n source?: string\n\n @Field({ nullable: true, description: 'The new master-data field definition.' })\n properties?: string\n\n /*\n `state` 는 여기 없다 — **상태는 저장이 정하지 않는다.**\n\n 발행은 `releaseFigure` 가 한다. 저장으로 상태를 바꿀 수 있게 두면 발행된 판을 덮어쓰면서 같은\n 판 번호로 판본을 또 뜨게 되고(유니크 충돌), 무엇이 약속된 판인지도 흐려진다. board 도 같다.\n */\n\n @Field({ nullable: true, description: 'A base64 encoded thumbnail image.' })\n thumbnail?: string\n}\n\n@ObjectType({ description: 'A paginated list of figures.' })\nexport class FigureList {\n @Field(type => [Figure], { description: 'The figures on this page.' })\n items: Figure[]\n\n @Field(type => Int, { description: 'Total number of figures matching the query.' })\n total: number\n}\n\n/**\n * 검증 결과 한 줄.\n *\n * 정본 형식의 검증은 `@hatiolab/figure-model` 이 두 단계로 나눈다 — `errors` 는\n * 막고, `violations` 는 알린다. 그 경계를 서버가 다시 정하지 않는다.\n */\n@ObjectType({ description: 'One validation finding from figure-model.' })\nexport class FigureFinding {\n @Field({ description: 'Stable code from figure-model (ERROR_CODES / VIOLATION_CODES).' })\n code: string\n\n @Field({ description: 'Human-readable message.' })\n message: string\n\n @Field({ nullable: true, description: 'Path within the source that the finding points at.' })\n at?: string\n}\n\n/**\n * 저장 결과.\n *\n * `violations` 가 있어도 저장은 된다 — 막는 것과 알리는 것을 가른다. 화면이\n * 이것을 그대로 보여 줘야 한다. 조용히 버리면 저작자가 모른다.\n */\n@ObjectType({ description: 'Result of saving a figure, carrying non-blocking violations.' })\nexport class FigureSaveResult {\n @Field(type => Figure, { description: 'The saved figure.' })\n figure: Figure\n\n @Field(type => [FigureFinding], { description: 'Non-blocking findings. The save succeeded despite these.' })\n violations: FigureFinding[]\n}\n\n/** An AI proposal saved into a figure, with the figure's names as they are now (ADR-0097 §5.6 item 5). */\n@ObjectType({ description: 'A figure an AI proposal was saved into.' })\nexport class FigureProposalOutcome {\n @Field({ description: 'The figure it was saved into.' })\n figureId: string\n\n @Field({ nullable: true, description: \"The figure's type name now.\" })\n type?: string\n\n @Field({ nullable: true, description: \"The figure's display name now.\" })\n name?: string\n\n @Field({ nullable: true, description: 'When the save that held it was made.' })\n recordedAt?: Date\n}\n\n/** A revert's outcome: the figure as it now is, and the draft kept for it (ADR-0097 §5.6). */\n@ObjectType({ description: 'The result of a revert, or of an undo of one.' })\nexport class FigureRevertResult {\n @Field(type => Figure, { description: 'The figure, as it now is.' })\n figure: Figure\n\n @Field(type => [FigureFinding], { description: 'Non-blocking findings on the source written.' })\n violations: FigureFinding[]\n\n @Field(type => FigureReplacedDraft, { description: 'The draft kept for this revert -- or, for an undo, the one brought back.' })\n kept: FigureReplacedDraft\n}\n\n/**\n * 발행 판정 한 줄.\n *\n * `FigureFinding` 과 칸이 겹치지만 **`blocking` 이 하나 더 있다.** 저장 쪽 발견은 정의상 막지 않는\n * 것들이라 그 칸이 필요 없었다. 발행 판정은 막는 것과 알리는 것을 함께 내므로, 어느 쪽인지를 값이\n * 스스로 말해야 한다 — 코드를 보고 화면이 다시 분류하면 규칙이 두 벌이 된다.\n */\n@ObjectType({ description: 'One finding from the release gate.' })\nexport class FigureGateFinding {\n @Field({ description: 'Stable code of the gate finding, for example part-outside-occupancy or parts-split-on-resize.' })\n code: string\n\n @Field({ description: 'Human-readable message.' })\n message: string\n\n @Field({ nullable: true, description: 'Why this is a problem — what a person sees when it happens.' })\n why?: string\n\n @Field({ nullable: true, description: 'What to change, naming the part and the value.' })\n how?: string\n\n @Field({ nullable: true, description: 'Where it points: part names that came apart, or a path in the source.' })\n at?: string\n\n @Field({ description: 'True when this finding blocks the release.' })\n blocking: boolean\n}\n\n/**\n * 발행 판정.\n *\n * 화면이 **발행을 누르기 전에** 물어보는 자리다. 눌러 보고 거절당하는 것으로 알게 되면, 무엇을\n * 고쳐야 하는지 모른 채 단추만 두드리게 된다.\n */\n@ObjectType({ description: 'Whether a figure may be released, and why not.' })\nexport class FigureInspection {\n @Field({ description: 'True when at least one finding blocks the release.' })\n blocked: boolean\n\n @Field(type => [FigureGateFinding], { description: 'Findings, blocking and advisory together.' })\n findings: FigureGateFinding[]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"figure-type.js","sourceRoot":"","sources":["../../../server/service/figure/figure-type.ts"],"names":[],"mappings":";;;;AAAA,yEAAgE;AAChE,+CAAgE;AAChE,qDAA6C;AAE7C,2CAAoC;AAEpC;;;;;GAKG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAS;CA2BrB,CAAA;AA3BY,8BAAS;AAEpB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;;uCAC9E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;uCAC7C;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;8CAC7D;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;;2CACnF;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;uCACzF;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;yCACpD;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AE,CAAC;;iDAC7D;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;kDACpE;2BALlB,gBAAgB;IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;GACjE,gBAAgB,CAM5B","sourcesContent":["import { FigureReplacedDraft } from './figure-replaced-draft.js'\nimport { Field, InputType, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { Figure } from './figure.js'\n\n/**\n * 새 Figure.\n *\n * `score`·`triangles`·`groups` 는 **받지 않는다.** 서버가 `source` 에서 계산한다 —\n * 받으면 거짓이 들어오고 목록이 실물과 다른 것을 보여 준다.\n */\n@InputType({ description: 'Input for creating a new figure.' })\nexport class NewFigure {\n @Field({ description: 'Component type name. Immutable once created, unique per domain.' })\n type: string\n\n @Field({ description: 'Display name shown to authors.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the figure.' })\n description?: string\n\n @Field({ nullable: true, description: 'Classification code used to group figures in the palette.' })\n category?: string\n\n @Field(type => [String], { nullable: true, description: 'Free-form tags. A figure may carry several.' })\n tags?: string[]\n\n @Field({ description: 'The figure asset JSON (figure-asset-1).' })\n source: string\n\n @Field({ nullable: true, description: 'JSON definition of the master-data fields an instance carries.' })\n properties?: string\n\n @Field({ nullable: true, description: \"Lifecycle state — defaults to 'draft'.\" })\n state?: 'draft' | 'released'\n\n @Field({ nullable: true, description: 'A base64 encoded thumbnail image.' })\n thumbnail?: string\n}\n\n/**\n * 수정.\n *\n * `type` 은 **한 번도 발행되지 않은 초안에서만** 바뀐다(ADR-0063 결정 4). 저장되는 식별자라\n * 발행된 뒤에 바꾸면 이미 배치된 보드가 타입을 못 찾아 오류 없이 빈 화면이 된다. 발행 전에는\n * 그 도형을 가리키는 도면이 있을 수 없다 — 도면은 최신 발행판을 그리므로 발행된 적 없는\n * 도형은 그려질 자리가 없다.\n *\n * 닫아 두었더니 저작자가 이름을 한 번도 정하지 못했다. 새 Figure 에는 기계가 지은 이름이\n * 붙고(`FIGURE_MU6RJH47`) 칸에 자물쇠가 걸려서, 그 이름이 그대로 도면에 적히는 이름이 됐다.\n */\n@InputType({ description: 'Input for updating an existing figure. `type` is accepted only while the figure has never been released.' })\nexport class FigurePatch {\n @Field({ nullable: true, description: 'The stored identifier. Accepted only before the first release; rejected once a version exists.' })\n type?: string\n\n @Field({ nullable: true, description: 'The new display name.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description.' })\n description?: string\n\n /* 언어별 표시 이름. 안 준 것은 그대로, `{}` 는 전부 지운다. */\n @Field(type => GraphQLJSON, { nullable: true, description: 'Display names by language. {} clears them; omitting the field leaves them.' })\n names?: Record<string, string>\n\n @Field({ nullable: true, description: 'The new classification code.' })\n category?: string\n\n /*\n 빈 배열과 안 준 것을 가른다. `undefined` 는 「건드리지 않는다」, `[]` 는 「전부 지운다」다.\n 둘을 뭉개면 태그를 다 지우려는 저작자가 지울 방법을 잃는다.\n */\n @Field(type => [String], { nullable: true, description: 'The new tags. An empty list clears them; omitting the field leaves them.' })\n tags?: string[]\n\n @Field({ nullable: true, description: 'The new figure asset JSON (figure-asset-1).' })\n source?: string\n\n @Field({ nullable: true, description: 'The new master-data field definition.' })\n properties?: string\n\n /*\n `state` 는 여기 없다 — **상태는 저장이 정하지 않는다.**\n\n 발행은 `releaseFigure` 가 한다. 저장으로 상태를 바꿀 수 있게 두면 발행된 판을 덮어쓰면서 같은\n 판 번호로 판본을 또 뜨게 되고(유니크 충돌), 무엇이 약속된 판인지도 흐려진다. board 도 같다.\n */\n\n @Field({ nullable: true, description: 'A base64 encoded thumbnail image.' })\n thumbnail?: string\n}\n\n@ObjectType({ description: 'A paginated list of figures.' })\nexport class FigureList {\n @Field(type => [Figure], { description: 'The figures on this page.' })\n items: Figure[]\n\n @Field(type => Int, { description: 'Total number of figures matching the query.' })\n total: number\n}\n\n/**\n * 검증 결과 한 줄.\n *\n * 정본 형식의 검증은 `@hatiolab/figure-model` 이 두 단계로 나눈다 — `errors` 는\n * 막고, `violations` 는 알린다. 그 경계를 서버가 다시 정하지 않는다.\n */\n@ObjectType({ description: 'One validation finding from figure-model.' })\nexport class FigureFinding {\n @Field({ description: 'Stable code from figure-model (ERROR_CODES / VIOLATION_CODES).' })\n code: string\n\n @Field({ description: 'Human-readable message.' })\n message: string\n\n @Field({ nullable: true, description: 'Path within the source that the finding points at.' })\n at?: string\n}\n\n/**\n * 저장 결과.\n *\n * `violations` 가 있어도 저장은 된다 — 막는 것과 알리는 것을 가른다. 화면이\n * 이것을 그대로 보여 줘야 한다. 조용히 버리면 저작자가 모른다.\n */\n@ObjectType({ description: 'Result of saving a figure, carrying non-blocking violations.' })\nexport class FigureSaveResult {\n @Field(type => Figure, { description: 'The saved figure.' })\n figure: Figure\n\n @Field(type => [FigureFinding], { description: 'Non-blocking findings. The save succeeded despite these.' })\n violations: FigureFinding[]\n}\n\n/** An AI proposal saved into a figure, with the figure's names as they are now (ADR-0097 §5.6 item 5). */\n@ObjectType({ description: 'A figure an AI proposal was saved into.' })\nexport class FigureProposalOutcome {\n @Field({ description: 'The figure it was saved into.' })\n figureId: string\n\n @Field({ nullable: true, description: \"The figure's type name now.\" })\n type?: string\n\n @Field({ nullable: true, description: \"The figure's display name now.\" })\n name?: string\n\n @Field({ nullable: true, description: 'When the save that held it was made.' })\n recordedAt?: Date\n}\n\n/** A revert's outcome: the figure as it now is, and the draft kept for it (ADR-0097 §5.6). */\n@ObjectType({ description: 'The result of a revert, or of an undo of one.' })\nexport class FigureRevertResult {\n @Field(type => Figure, { description: 'The figure, as it now is.' })\n figure: Figure\n\n @Field(type => [FigureFinding], { description: 'Non-blocking findings on the source written.' })\n violations: FigureFinding[]\n\n @Field(type => FigureReplacedDraft, { description: 'The draft kept for this revert -- or, for an undo, the one brought back.' })\n kept: FigureReplacedDraft\n}\n\n/**\n * 발행 판정 한 줄.\n *\n * `FigureFinding` 과 칸이 겹치지만 **`blocking` 이 하나 더 있다.** 저장 쪽 발견은 정의상 막지 않는\n * 것들이라 그 칸이 필요 없었다. 발행 판정은 막는 것과 알리는 것을 함께 내므로, 어느 쪽인지를 값이\n * 스스로 말해야 한다 — 코드를 보고 화면이 다시 분류하면 규칙이 두 벌이 된다.\n */\n@ObjectType({ description: 'One finding from the release gate.' })\nexport class FigureGateFinding {\n @Field({ description: 'Stable code of the gate finding, for example part-outside-occupancy or parts-split-on-resize.' })\n code: string\n\n @Field({ description: 'Human-readable message.' })\n message: string\n\n @Field({ nullable: true, description: 'Why this is a problem — what a person sees when it happens.' })\n why?: string\n\n @Field({ nullable: true, description: 'What to change, naming the part and the value.' })\n how?: string\n\n @Field({ nullable: true, description: 'Where it points: part names that came apart, or a path in the source.' })\n at?: string\n\n @Field({ description: 'True when this finding blocks the release.' })\n blocking: boolean\n}\n\n/**\n * 발행 판정.\n *\n * 화면이 **발행을 누르기 전에** 물어보는 자리다. 눌러 보고 거절당하는 것으로 알게 되면, 무엇을\n * 고쳐야 하는지 모른 채 단추만 두드리게 된다.\n */\n@ObjectType({ description: 'Whether a figure may be released, and why not.' })\nexport class FigureInspection {\n @Field({ description: 'True when at least one finding blocks the release.' })\n blocked: boolean\n\n @Field(type => [FigureGateFinding], { description: 'Findings, blocking and advisory together.' })\n findings: FigureGateFinding[]\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ThumbnailFiles } from './figure-thumbnail-store.js';
|
|
1
2
|
import { GraphQLError } from 'graphql';
|
|
2
3
|
/**
|
|
3
4
|
* The row is not what the writer expected: another edit, or the writer's own earlier save whose answer it never got.
|
|
@@ -27,18 +28,21 @@ export declare function prepareFigureWrite(source: string, existing?: {
|
|
|
27
28
|
state: "draft";
|
|
28
29
|
};
|
|
29
30
|
/**
|
|
30
|
-
* The picture a card shows, when the modeller sent one
|
|
31
|
+
* The picture a card shows, when the modeller sent one: kept by its content (`keepThumbnail`) and named on the row by
|
|
32
|
+
* its hash.
|
|
31
33
|
*
|
|
32
34
|
* Absent means the author saved without one — a tab in the background cannot draw, and the source matters more
|
|
33
35
|
* than the picture, so the save goes on and the modeller fills it in next time. The timestamp moves only when
|
|
34
36
|
* the picture itself is new, so renaming a figure does not make every card look freshly drawn.
|
|
35
37
|
*/
|
|
36
|
-
export declare function pictureOf(
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
export declare function pictureOf(tx: {
|
|
39
|
+
getRepository: (target: any) => any;
|
|
40
|
+
}, domain: {
|
|
41
|
+
id: string;
|
|
42
|
+
}, user: unknown, thumbnail?: string, existing?: {
|
|
43
|
+
thumbnailHash?: string | null;
|
|
44
|
+
}, files?: ThumbnailFiles): Promise<{
|
|
45
|
+
thumbnailHash?: string;
|
|
46
|
+
thumbnail?: null;
|
|
47
|
+
thumbnailUpdatedAt?: Date;
|
|
48
|
+
}>;
|
|
@@ -4,6 +4,7 @@ exports.sourceConflict = sourceConflict;
|
|
|
4
4
|
exports.compareAndSwapFigure = compareAndSwapFigure;
|
|
5
5
|
exports.prepareFigureWrite = prepareFigureWrite;
|
|
6
6
|
exports.pictureOf = pictureOf;
|
|
7
|
+
const figure_thumbnail_store_js_1 = require("./figure-thumbnail-store.js");
|
|
7
8
|
const graphql_1 = require("graphql");
|
|
8
9
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
9
10
|
/**
|
|
@@ -42,15 +43,19 @@ function prepareFigureWrite(source, existing, expectedSource) {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
|
-
* The picture a card shows, when the modeller sent one
|
|
46
|
+
* The picture a card shows, when the modeller sent one: kept by its content (`keepThumbnail`) and named on the row by
|
|
47
|
+
* its hash.
|
|
46
48
|
*
|
|
47
49
|
* Absent means the author saved without one — a tab in the background cannot draw, and the source matters more
|
|
48
50
|
* than the picture, so the save goes on and the modeller fills it in next time. The timestamp moves only when
|
|
49
51
|
* the picture itself is new, so renaming a figure does not make every card look freshly drawn.
|
|
50
52
|
*/
|
|
51
|
-
function pictureOf(thumbnail, existing) {
|
|
52
|
-
if (thumbnail === undefined
|
|
53
|
+
async function pictureOf(tx, domain, user, thumbnail, existing, files) {
|
|
54
|
+
if (thumbnail === undefined)
|
|
53
55
|
return {};
|
|
54
|
-
|
|
56
|
+
const thumbnailHash = await (0, figure_thumbnail_store_js_1.keepThumbnail)(tx, domain, user, thumbnail, files);
|
|
57
|
+
if (thumbnailHash === existing?.thumbnailHash)
|
|
58
|
+
return {};
|
|
59
|
+
return { thumbnailHash, thumbnail: null, thumbnailUpdatedAt: new Date() };
|
|
55
60
|
}
|
|
56
61
|
//# sourceMappingURL=figure-write.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figure-write.js","sourceRoot":"","sources":["../../../server/service/figure/figure-write.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"figure-write.js","sourceRoot":"","sources":["../../../server/service/figure/figure-write.ts"],"names":[],"mappings":";;AASA,wCAEC;AAOD,oDASC;AAGD,gDAkBC;AAUD,8BAYC;AAtED,2EAAgF;AAChF,qCAAsC;AACtC,yDAAgI;AAEhI;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,IAAI,sBAAY,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,CAAC,CAAA;AACtF,CAAC;AAOM,KAAK,UAAU,oBAAoB,CACxC,MAAgF,EAChF,EAAU,EACV,QAAgB,EAChB,cAAkC;IAElC,IAAI,cAAc,KAAK,SAAS;QAAE,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EA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aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,IAAI,EAAE,EAAE,CAAA;AAC3E,CAAC","sourcesContent":["import { keepThumbnail, type ThumbnailFiles } from './figure-thumbnail-store.js'\nimport { GraphQLError } from 'graphql'\nimport { parseFigureAsset, serializeFigureAsset, compileFigureAsset, figureCostOf, figureScoreOf } from '@hatiolab/figure-model'\n\n/**\n * The row is not what the writer expected: another edit, or the writer's own earlier save whose answer it never got.\n * Coded, so a client can tell it from a refusal on grounds (permission, validation) and read the row back before\n * saying its save failed (D, designer 2026-09-27).\n */\nexport function sourceConflict(message: string) {\n return new GraphQLError(message, { extensions: { code: 'FIGURE_SOURCE_CONFLICT' } })\n}\n\nexport interface FigureWriteCriteria {\n id: string\n domain: { id: string }\n source: string\n}\nexport async function compareAndSwapFigure(\n update: (criteria: FigureWriteCriteria) => Promise<{ affected?: number | null }>,\n id: string,\n domainId: string,\n expectedSource: string | undefined\n) {\n if (expectedSource === undefined) throw Error('수정 전 정본이 필요합니다.')\n const result = await update({ id, domain: { id: domainId }, source: expectedSource })\n if (result.affected !== 1) throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 열어 주세요.')\n}\n\n/** Early validation only. The repository must also compare expectedSource in its atomic UPDATE. */\nexport function prepareFigureWrite(source: string, existing?: { source?: string }, expectedSource?: string) {\n if (existing && (expectedSource === undefined || existing.source !== expectedSource)) {\n throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 적용해 주세요.')\n }\n const asset = parseFigureAsset(source)\n compileFigureAsset(asset)\n /*\n The same measure `parseSource` uses, so the catalogue's columns do not depend on which mutation wrote the row.\n */\n const cost = figureCostOf(asset)\n return {\n source: serializeFigureAsset(asset),\n name: asset.name,\n score: figureScoreOf(asset)?.score ?? null,\n triangles: cost.triangles,\n groups: cost.groups,\n state: 'draft' as const\n }\n}\n\n/**\n * The picture a card shows, when the modeller sent one: kept by its content (`keepThumbnail`) and named on the row by\n * its hash.\n *\n * Absent means the author saved without one — a tab in the background cannot draw, and the source matters more\n * than the picture, so the save goes on and the modeller fills it in next time. The timestamp moves only when\n * the picture itself is new, so renaming a figure does not make every card look freshly drawn.\n */\nexport async function pictureOf(\n tx: { getRepository: (target: any) => any },\n domain: { id: string },\n user: unknown,\n thumbnail?: string,\n existing?: { thumbnailHash?: string | null },\n files?: ThumbnailFiles\n): Promise<{ thumbnailHash?: string; thumbnail?: null; thumbnailUpdatedAt?: Date }> {\n if (thumbnail === undefined) return {}\n const thumbnailHash = await keepThumbnail(tx, domain, user, thumbnail, files)\n if (thumbnailHash === existing?.thumbnailHash) return {}\n return { thumbnailHash, thumbnail: null, thumbnailUpdatedAt: new Date() }\n}\n"]}
|
|
@@ -40,6 +40,9 @@ export declare class Figure {
|
|
|
40
40
|
type?: string;
|
|
41
41
|
name?: string;
|
|
42
42
|
description?: string;
|
|
43
|
+
names?: Record<string, string>;
|
|
44
|
+
deprecated?: boolean;
|
|
45
|
+
supersededBy?: string;
|
|
43
46
|
/**
|
|
44
47
|
* 분류 하나. **팔레트에서 묶어 보이는 기준이다.**
|
|
45
48
|
*
|
|
@@ -75,6 +78,7 @@ export declare class Figure {
|
|
|
75
78
|
/** 기준정보 항목 정의. Figure 를 배치할 때 인스턴스가 채우는 자리. */
|
|
76
79
|
properties?: string;
|
|
77
80
|
thumbnail?: string;
|
|
81
|
+
thumbnailHash?: string;
|
|
78
82
|
/**
|
|
79
83
|
* 썸네일이 **썸네일로서** 마지막으로 갱신된 시각. `updatedAt` 과는 별개 도메인이다 —
|
|
80
84
|
* 이름·설명만 고쳤을 때는 갱신되지 않는다. `Board` 와 같은 방식.
|
|
@@ -4,6 +4,7 @@ exports.Figure = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const graphql_scalars_1 = require("graphql-scalars");
|
|
7
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
9
|
const shell_1 = require("@things-factory/shell");
|
|
9
10
|
/**
|
|
@@ -72,6 +73,21 @@ tslib_1.__decorate([
|
|
|
72
73
|
(0, type_graphql_1.Field)({ nullable: true, description: 'A detailed description for the figure.' }),
|
|
73
74
|
tslib_1.__metadata("design:type", String)
|
|
74
75
|
], Figure.prototype, "description", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
78
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Display names by language, e.g. { "en": "...", "ko": "..." }. A language not here shows `name`.' }),
|
|
79
|
+
tslib_1.__metadata("design:type", Object)
|
|
80
|
+
], Figure.prototype, "names", void 0);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, typeorm_1.Column)({ nullable: true, default: false }),
|
|
83
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Retired: still released and still served, but not to be chosen for new work.' }),
|
|
84
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
85
|
+
], Figure.prototype, "deprecated", void 0);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
88
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The type to use instead of a retired figure.' }),
|
|
89
|
+
tslib_1.__metadata("design:type", String)
|
|
90
|
+
], Figure.prototype, "supersededBy", void 0);
|
|
75
91
|
tslib_1.__decorate([
|
|
76
92
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
77
93
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Classification code used to group figures in the palette. One per figure.' }),
|
|
@@ -117,6 +133,11 @@ tslib_1.__decorate([
|
|
|
117
133
|
(0, type_graphql_1.Field)({ nullable: true, description: 'A base64 encoded thumbnail image of the figure.' }),
|
|
118
134
|
tslib_1.__metadata("design:type", String)
|
|
119
135
|
], Figure.prototype, "thumbnail", void 0);
|
|
136
|
+
tslib_1.__decorate([
|
|
137
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
138
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'SHA-256 of the thumbnail picture; the picture is served by /figure-thumbnail/:id.' }),
|
|
139
|
+
tslib_1.__metadata("design:type", String)
|
|
140
|
+
], Figure.prototype, "thumbnailHash", void 0);
|
|
120
141
|
tslib_1.__decorate([
|
|
121
142
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
122
143
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp of the last thumbnail generation. Separate lifecycle from updatedAt.' }),
|