@things-factory/figure-service 10.1.81 → 10.1.84
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/service/figure/figure-format.js +4 -3
- package/dist-server/service/figure/figure-format.js.map +1 -1
- package/dist-server/service/figure/figure-mutation.d.ts +5 -3
- package/dist-server/service/figure/figure-mutation.js +43 -41
- package/dist-server/service/figure/figure-mutation.js.map +1 -1
- package/dist-server/service/figure/figure-proposal-record.d.ts +16 -0
- package/dist-server/service/figure/figure-proposal-record.js +51 -0
- package/dist-server/service/figure/figure-proposal-record.js.map +1 -0
- package/dist-server/service/figure/figure-proposal.d.ts +14 -0
- package/dist-server/service/figure/figure-proposal.js +39 -0
- package/dist-server/service/figure/figure-proposal.js.map +1 -0
- package/dist-server/service/figure/figure-propose-steps.js +12 -0
- package/dist-server/service/figure/figure-propose-steps.js.map +1 -1
- package/dist-server/service/figure/figure-query.d.ts +6 -1
- package/dist-server/service/figure/figure-query.js +33 -0
- package/dist-server/service/figure/figure-query.js.map +1 -1
- package/dist-server/service/figure/figure-rename.d.ts +2 -2
- package/dist-server/service/figure/figure-rename.js +8 -20
- package/dist-server/service/figure/figure-rename.js.map +1 -1
- package/dist-server/service/figure/figure-replaced-draft.d.ts +33 -0
- package/dist-server/service/figure/figure-replaced-draft.js +114 -0
- package/dist-server/service/figure/figure-replaced-draft.js.map +1 -0
- package/dist-server/service/figure/figure-revert.d.ts +36 -0
- package/dist-server/service/figure/figure-revert.js +155 -0
- package/dist-server/service/figure/figure-revert.js.map +1 -0
- package/dist-server/service/figure/figure-tools.js +7 -0
- package/dist-server/service/figure/figure-tools.js.map +1 -1
- package/dist-server/service/figure/figure-type.d.ts +14 -0
- package/dist-server/service/figure/figure-type.js +44 -1
- package/dist-server/service/figure/figure-type.js.map +1 -1
- package/dist-server/service/figure/figure-write.d.ts +7 -0
- package/dist-server/service/figure/figure-write.js +12 -2
- package/dist-server/service/figure/figure-write.js.map +1 -1
- package/dist-server/service/figure/index.d.ts +3 -1
- package/dist-server/service/figure/index.js +3 -1
- package/dist-server/service/figure/index.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/recipes/air-cylinder/models/default.json +1 -1
- package/recipes/air-shower/models/default.json +1 -1
- package/recipes/barrier-gate/models/default.json +1 -1
- package/recipes/base-frame/models/default.json +1 -1
- package/recipes/belt-surface/models/default.json +1 -1
- package/recipes/bin-row/models/default.json +1 -1
- package/recipes/bollard-row/models/default.json +1 -1
- package/recipes/buzzer/models/default.json +1 -1
- package/recipes/cabinet-doors/models/default.json +1 -1
- package/recipes/cabinet-doors/models/doors=1.json +1 -1
- package/recipes/cabinet-doors/models/doors=2.json +1 -1
- package/recipes/cable-tray/models/default.json +1 -1
- package/recipes/camera-mount/models/default.json +1 -1
- package/recipes/canopy/models/default.json +1 -1
- package/recipes/cart/models/default.json +1 -1
- package/recipes/cart-handle/models/default.json +1 -1
- package/recipes/casters-four/models/default.json +1 -1
- package/recipes/ceiling-rail-carriage/models/default.json +1 -1
- package/recipes/chain-rails/models/default.json +1 -1
- package/recipes/charging-station/models/default.json +1 -1
- package/recipes/column-row/models/default.json +1 -1
- package/recipes/control-cabinet/models/default.json +1 -1
- package/recipes/conveyor-skirts/models/default.json +1 -1
- package/recipes/counter-display/models/default.json +1 -1
- package/recipes/dock-bumpers/models/default.json +1 -1
- package/recipes/dock-leveler/models/default.json +1 -1
- package/recipes/double-hinged-door/models/default.json +1 -1
- package/recipes/drawer-stack/models/default.json +1 -1
- package/recipes/drawer-stack/models/drawers=2.json +1 -1
- package/recipes/drawer-stack/models/drawers=3.json +1 -1
- package/recipes/drawer-stack/models/drawers=4.json +1 -1
- package/recipes/drip-tray/models/default.json +1 -1
- package/recipes/duct-fan/models/default.json +1 -1
- package/recipes/emergency-stop/models/default.json +1 -1
- package/recipes/end-covers/models/default.json +1 -1
- package/recipes/ffu-row/models/default.json +1 -1
- package/recipes/fire-extinguisher/models/default.json +1 -1
- package/recipes/first-aid-box/models/default.json +1 -1
- package/recipes/floor-zone/models/default.json +1 -1
- package/recipes/folding-door/models/default.json +1 -1
- package/recipes/fork/models/default.json +1 -1
- package/recipes/gantry-frame/models/default.json +1 -1
- package/recipes/gripper-2f/models/default.json +1 -1
- package/recipes/guard-cover/models/default.json +1 -1
- package/recipes/handrail/models/default.json +1 -1
- package/recipes/hatch/models/default.json +1 -1
- package/recipes/hinged-door/models/default.json +1 -1
- package/recipes/hinged-door/models/hinge=left.json +1 -1
- package/recipes/hinged-door/models/hinge=right.json +1 -1
- package/recipes/hmi-monitor/models/default.json +1 -1
- package/recipes/hopper/models/default.json +1 -1
- package/recipes/interlock-switch/models/default.json +1 -1
- package/recipes/junction-box/models/default.json +1 -1
- package/recipes/ladder/models/default.json +1 -1
- package/recipes/legs-four/models/default.json +1 -1
- package/recipes/leveling-feet/models/default.json +1 -1
- package/recipes/lift-updown/models/default.json +1 -1
- package/recipes/light-curtain/models/default.json +1 -1
- package/recipes/limit-switch/models/default.json +1 -1
- package/recipes/linear-guide/models/default.json +1 -1
- package/recipes/locker-row/models/default.json +1 -1
- package/recipes/motor-box/models/default.json +1 -1
- package/recipes/observation-window/models/default.json +1 -1
- package/recipes/operator-panel/models/buttons=2.json +1 -1
- package/recipes/operator-panel/models/buttons=3.json +1 -1
- package/recipes/operator-panel/models/buttons=4.json +1 -1
- package/recipes/operator-panel/models/buttons=5.json +1 -1
- package/recipes/operator-panel/models/default.json +1 -1
- package/recipes/pallet/models/default.json +1 -1
- package/recipes/partition-wall/models/default.json +1 -1
- package/recipes/pass-box/models/default.json +1 -1
- package/recipes/peg-board/models/default.json +1 -1
- package/recipes/photo-sensor-pair/models/default.json +1 -1
- package/recipes/pipe-run/models/default.json +1 -1
- package/recipes/platform/models/default.json +1 -1
- package/recipes/power-box/models/default.json +1 -1
- package/recipes/pressure-gauge/models/default.json +1 -1
- package/recipes/pull-cord/models/default.json +1 -1
- package/recipes/pump/models/default.json +1 -1
- package/recipes/pusher/models/default.json +1 -1
- package/recipes/robot-plinth/models/default.json +1 -1
- package/recipes/roll-up-shutter/models/default.json +1 -1
- package/recipes/roller-row/models/default.json +1 -1
- package/recipes/room-shell/models/default.json +1 -1
- package/recipes/rotating-beacon/models/default.json +1 -1
- package/recipes/safety-fence/models/default.json +1 -1
- package/recipes/safety-mat/models/default.json +1 -1
- package/recipes/safety-sign-stand/models/default.json +1 -1
- package/recipes/scanner-mount/models/default.json +1 -1
- package/recipes/selector-switch/models/default.json +1 -1
- package/recipes/shelf-tiers/models/default.json +1 -1
- package/recipes/shelf-tiers/models/tiers=2.json +1 -1
- package/recipes/shelf-tiers/models/tiers=3.json +1 -1
- package/recipes/shelf-tiers/models/tiers=4.json +1 -1
- package/recipes/shelf-tiers/models/tiers=5.json +1 -1
- package/recipes/side-guides/models/default.json +1 -1
- package/recipes/sign-board/models/default.json +1 -1
- package/recipes/signal-tower-3/models/default.json +1 -1
- package/recipes/sliding-door/models/default.json +1 -1
- package/recipes/sliding-door/models/leaves=1,lamp=false.json +1 -1
- package/recipes/sliding-door/models/leaves=1,lamp=true.json +1 -1
- package/recipes/sliding-door/models/leaves=2,lamp=false.json +1 -1
- package/recipes/sliding-door/models/leaves=2,lamp=true.json +1 -1
- package/recipes/stairs/models/default.json +1 -1
- package/recipes/status-lamp/models/default.json +1 -1
- package/recipes/stopper/models/default.json +1 -1
- package/recipes/suction-pads/models/default.json +1 -1
- package/recipes/tank/models/default.json +1 -1
- package/recipes/telescopic-arm/models/default.json +1 -1
- package/recipes/toe-board/models/default.json +1 -1
- package/recipes/tote/models/default.json +1 -1
- package/recipes/traffic-cones/models/default.json +1 -1
- package/recipes/transfer-belts/models/default.json +1 -1
- package/recipes/tray-stack/models/default.json +1 -1
- package/recipes/tray-stack/models/trays=3.json +1 -1
- package/recipes/tray-stack/models/trays=4.json +1 -1
- package/recipes/tray-stack/models/trays=5.json +1 -1
- package/recipes/trough/models/default.json +1 -1
- package/recipes/turntable/models/default.json +1 -1
- package/recipes/valve-handle/models/default.json +1 -1
- package/recipes/waste-bin/models/default.json +1 -1
- package/recipes/work-light/models/default.json +1 -1
- package/recipes/workbench-top/models/default.json +1 -1
- package/server/service/figure/figure-format.ts +4 -3
- package/server/service/figure/figure-mutation.ts +48 -42
- package/server/service/figure/figure-proposal-db.test.ts +108 -0
- package/server/service/figure/figure-proposal-record.ts +38 -0
- package/server/service/figure/figure-proposal.ts +39 -0
- package/server/service/figure/figure-propose-clips.test.ts +73 -0
- package/server/service/figure/figure-propose-steps.ts +12 -0
- package/server/service/figure/figure-query.ts +22 -1
- package/server/service/figure/figure-rename.test.ts +13 -2
- package/server/service/figure/figure-rename.ts +13 -1
- package/server/service/figure/figure-replaced-draft.ts +90 -0
- package/server/service/figure/figure-revert-db.test.ts +159 -0
- package/server/service/figure/figure-revert-race.pg.test.ts +168 -0
- package/server/service/figure/figure-revert.ts +181 -0
- package/server/service/figure/figure-tools.ts +7 -0
- package/server/service/figure/figure-type.ts +30 -0
- package/server/service/figure/figure-write.test.ts +15 -0
- package/server/service/figure/figure-write.ts +12 -2
- package/server/service/figure/index.ts +3 -1
- package/translations/en.json +3 -3
- package/translations/ko.json +3 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type EntityManager } from 'typeorm';
|
|
2
|
+
import { Figure } from './figure.js';
|
|
3
|
+
import { FigureReplacedDraft } from './figure-replaced-draft.js';
|
|
4
|
+
export interface RevertRequest {
|
|
5
|
+
id: string;
|
|
6
|
+
version: number;
|
|
7
|
+
requestId: string;
|
|
8
|
+
/** The figure's source as the reverter saw it; the revert goes on only while the figure still holds it. */
|
|
9
|
+
expectedSource: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function revertKeepingDraft(tx: EntityManager, domain: {
|
|
12
|
+
id: string;
|
|
13
|
+
parentId?: string | null;
|
|
14
|
+
}, user: {
|
|
15
|
+
id: string;
|
|
16
|
+
} | undefined, request: RevertRequest): Promise<{
|
|
17
|
+
figure: Figure;
|
|
18
|
+
violations: import("./figure-type.js").FigureFinding[];
|
|
19
|
+
kept: any;
|
|
20
|
+
}>;
|
|
21
|
+
/** Brings a kept draft back -- only while the figure holds exactly what that revert wrote. */
|
|
22
|
+
export declare function undoRevert(tx: EntityManager, domain: {
|
|
23
|
+
id: string;
|
|
24
|
+
}, user: {
|
|
25
|
+
id: string;
|
|
26
|
+
} | undefined, request: {
|
|
27
|
+
keptId: string;
|
|
28
|
+
requestId: string;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
figure: Figure;
|
|
31
|
+
kept: FigureReplacedDraft;
|
|
32
|
+
}>;
|
|
33
|
+
/** The drafts reverts kept for a figure, newest first -- found again after a reload. */
|
|
34
|
+
export declare function replacedDraftsOf(tx: EntityManager, domain: {
|
|
35
|
+
id: string;
|
|
36
|
+
}, figureId: string): Promise<FigureReplacedDraft[]>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revertKeepingDraft = revertKeepingDraft;
|
|
4
|
+
exports.undoRevert = undoRevert;
|
|
5
|
+
exports.replacedDraftsOf = replacedDraftsOf;
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
const typeorm_1 = require("typeorm");
|
|
8
|
+
const graphql_1 = require("graphql");
|
|
9
|
+
const figure_js_1 = require("./figure.js");
|
|
10
|
+
const figure_history_js_1 = require("./figure-history.js");
|
|
11
|
+
const figure_replaced_draft_js_1 = require("./figure-replaced-draft.js");
|
|
12
|
+
const figure_format_js_1 = require("./figure-format.js");
|
|
13
|
+
const figure_write_js_1 = require("./figure-write.js");
|
|
14
|
+
/*
|
|
15
|
+
* Reverting a figure to a released version, keeping the draft it writes over (ADR-0097 §5.6, designer 2026-09-27;
|
|
16
|
+
* chief architect's ruling on the storage the same day).
|
|
17
|
+
*
|
|
18
|
+
* - One transaction: the draft is kept, then the figure is written over -- conditional on it being what the reverter
|
|
19
|
+
* saw (`expectedSource`). If either fails, neither stays: the caller's transaction is rolled back.
|
|
20
|
+
* - One request, one revert: `requestId` is unique in the domain. A retry -- the answer lost -- finds the revert it
|
|
21
|
+
* asked for and answers with it; nothing is kept or written twice.
|
|
22
|
+
* - An undo brings a kept draft back only while the figure still holds exactly what that revert wrote
|
|
23
|
+
* (`WHERE id = ? AND source = ?`, as a save's compare-and-swap); edited since, it is refused and the kept draft stays.
|
|
24
|
+
* It keeps what it replaces the same way.
|
|
25
|
+
*
|
|
26
|
+
* Every function here runs on the caller's transaction (`tx`); the resolvers open it (`@transaction`).
|
|
27
|
+
*/
|
|
28
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
29
|
+
const hashOf = (text) => (0, crypto_1.createHash)('sha256').update(text).digest('hex');
|
|
30
|
+
const refused = (code, message) => new graphql_1.GraphQLError(message, { extensions: { code } });
|
|
31
|
+
/*
|
|
32
|
+
* The same request arriving twice at once: the second waits on the first's requestId and then meets the unique index.
|
|
33
|
+
* Named, not a raw database error -- asked again after the first has finished, it gets the first's answer.
|
|
34
|
+
*/
|
|
35
|
+
async function keep(kept, row) {
|
|
36
|
+
try {
|
|
37
|
+
return await kept.save(row);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const unique = error?.code === '23505' || error?.driverError?.code === '23505' || /UNIQUE constraint failed/.test(String(error?.message));
|
|
41
|
+
if (unique)
|
|
42
|
+
throw refused('FIGURE_REVERT_IN_FLIGHT', '같은 요청이 처리 중입니다. 잠시 뒤 다시 확인해 주세요.');
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function revertKeepingDraft(tx, domain, user, request) {
|
|
47
|
+
if (!UUID.test(request.requestId ?? ''))
|
|
48
|
+
throw refused('FIGURE_REVERT_REQUEST', '되돌리기 요청 식별자가 필요합니다.');
|
|
49
|
+
const figures = tx.getRepository(figure_js_1.Figure);
|
|
50
|
+
const kept = tx.getRepository(figure_replaced_draft_js_1.FigureReplacedDraft);
|
|
51
|
+
/* The same request again: the revert it made, answered again. */
|
|
52
|
+
const before = await kept.findOne({ where: { domain: { id: domain.id }, requestId: request.requestId } });
|
|
53
|
+
if (before) {
|
|
54
|
+
if (before.figureId !== request.id || before.revertedToVersion !== request.version || before.kind !== 'revert')
|
|
55
|
+
throw refused('FIGURE_REVERT_REQUEST', '이 되돌리기 요청 식별자는 다른 되돌리기에 이미 쓰였습니다.');
|
|
56
|
+
return { figure: await figures.findOneOrFail({ where: { id: request.id, domain: { id: domain.id } } }), violations: [], kept: before };
|
|
57
|
+
}
|
|
58
|
+
/* Exact tenant ownership, as a save: an inherited figure is not written from a child domain. */
|
|
59
|
+
const figure = await figures.findOne({ where: { id: request.id, domain: { id: domain.id } } });
|
|
60
|
+
if (!figure)
|
|
61
|
+
throw refused('FIGURE_NOT_FOUND', `Figure ${request.id} 를 찾을 수 없습니다.`);
|
|
62
|
+
if (figure.source !== request.expectedSource)
|
|
63
|
+
throw (0, figure_write_js_1.sourceConflict)('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.');
|
|
64
|
+
const history = await tx.getRepository(figure_history_js_1.FigureHistory).findOne({
|
|
65
|
+
where: { domain: { id: (0, typeorm_1.In)([domain.id, domain.parentId].filter(Boolean)) }, originalId: request.id, version: request.version }
|
|
66
|
+
});
|
|
67
|
+
if (!history)
|
|
68
|
+
throw refused('FIGURE_VERSION_NOT_FOUND', `Figure '${figure.type}' 에 ${request.version} 판이 없습니다.`);
|
|
69
|
+
/* The format is checked again: an old version may break today's rules, and is not let in quietly. */
|
|
70
|
+
const { source, derived, violations } = (0, figure_format_js_1.parseSource)(history.source);
|
|
71
|
+
const record = await keep(kept, {
|
|
72
|
+
domain: { id: domain.id },
|
|
73
|
+
figureId: figure.id,
|
|
74
|
+
kind: 'revert',
|
|
75
|
+
source: figure.source,
|
|
76
|
+
properties: figure.properties,
|
|
77
|
+
thumbnail: figure.thumbnail,
|
|
78
|
+
state: figure.state,
|
|
79
|
+
version: figure.version,
|
|
80
|
+
revertedToVersion: request.version,
|
|
81
|
+
writtenSource: source,
|
|
82
|
+
writtenSourceHash: hashOf(source),
|
|
83
|
+
requestId: request.requestId,
|
|
84
|
+
...(user ? { creator: { id: user.id } } : {})
|
|
85
|
+
});
|
|
86
|
+
const written = await figures.update({ id: figure.id, domain: { id: domain.id }, source: request.expectedSource }, {
|
|
87
|
+
source,
|
|
88
|
+
...derived,
|
|
89
|
+
properties: history.properties,
|
|
90
|
+
thumbnail: history.thumbnail,
|
|
91
|
+
thumbnailUpdatedAt: history.thumbnail === figure.thumbnail ? figure.thumbnailUpdatedAt : new Date(),
|
|
92
|
+
state: 'draft',
|
|
93
|
+
...(user ? { updater: { id: user.id } } : {})
|
|
94
|
+
});
|
|
95
|
+
if (written.affected !== 1)
|
|
96
|
+
throw (0, figure_write_js_1.sourceConflict)('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 되돌려 주세요.');
|
|
97
|
+
return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), violations, kept: record };
|
|
98
|
+
}
|
|
99
|
+
/** Brings a kept draft back -- only while the figure holds exactly what that revert wrote. */
|
|
100
|
+
async function undoRevert(tx, domain, user, request) {
|
|
101
|
+
if (!UUID.test(request.requestId ?? ''))
|
|
102
|
+
throw refused('FIGURE_REVERT_REQUEST', '되돌리기 취소 요청 식별자가 필요합니다.');
|
|
103
|
+
const figures = tx.getRepository(figure_js_1.Figure);
|
|
104
|
+
const kept = tx.getRepository(figure_replaced_draft_js_1.FigureReplacedDraft);
|
|
105
|
+
const record = await kept.findOne({ where: { id: request.keptId, domain: { id: domain.id } } });
|
|
106
|
+
if (!record)
|
|
107
|
+
throw refused('FIGURE_KEPT_NOT_FOUND', '되살릴 초안을 찾을 수 없습니다.');
|
|
108
|
+
if (record.restoredAt) {
|
|
109
|
+
/* Asked again with the same request: the undo it made. Another request for a draft already back: refused. */
|
|
110
|
+
if (record.restoreRequestId === request.requestId)
|
|
111
|
+
return { figure: await figures.findOneOrFail({ where: { id: record.figureId, domain: { id: domain.id } } }), kept: record };
|
|
112
|
+
throw refused('FIGURE_KEPT_RESTORED', '이 초안은 이미 되살렸습니다.');
|
|
113
|
+
}
|
|
114
|
+
const figure = await figures.findOne({ where: { id: record.figureId, domain: { id: domain.id } } });
|
|
115
|
+
if (!figure)
|
|
116
|
+
throw refused('FIGURE_NOT_FOUND', `Figure ${record.figureId} 를 찾을 수 없습니다.`);
|
|
117
|
+
/* What the undo replaces is kept too -- the same rule as a revert. */
|
|
118
|
+
const { derived } = (0, figure_format_js_1.parseSource)(record.source);
|
|
119
|
+
await keep(kept, {
|
|
120
|
+
domain: { id: domain.id },
|
|
121
|
+
figureId: figure.id,
|
|
122
|
+
kind: 'undo',
|
|
123
|
+
source: figure.source,
|
|
124
|
+
properties: figure.properties,
|
|
125
|
+
thumbnail: figure.thumbnail,
|
|
126
|
+
state: figure.state,
|
|
127
|
+
version: figure.version,
|
|
128
|
+
writtenSource: record.source,
|
|
129
|
+
writtenSourceHash: hashOf(record.source),
|
|
130
|
+
requestId: request.requestId,
|
|
131
|
+
...(user ? { creator: { id: user.id } } : {})
|
|
132
|
+
});
|
|
133
|
+
const written = await figures.update({ id: figure.id, domain: { id: domain.id }, source: record.writtenSource }, {
|
|
134
|
+
source: record.source,
|
|
135
|
+
...derived,
|
|
136
|
+
properties: record.properties,
|
|
137
|
+
thumbnail: record.thumbnail,
|
|
138
|
+
thumbnailUpdatedAt: record.thumbnail === figure.thumbnail ? figure.thumbnailUpdatedAt : new Date(),
|
|
139
|
+
state: 'draft',
|
|
140
|
+
...(user ? { updater: { id: user.id } } : {})
|
|
141
|
+
});
|
|
142
|
+
if (written.affected !== 1)
|
|
143
|
+
throw (0, figure_write_js_1.sourceConflict)('되돌린 뒤 모델이 다시 바뀌어 되돌리기를 취소하지 않았습니다. 보관한 초안은 그대로 남아 있습니다.');
|
|
144
|
+
await kept.update({ id: record.id }, { restoredAt: new Date(), restoreRequestId: request.requestId });
|
|
145
|
+
return { figure: await figures.findOneOrFail({ where: { id: figure.id, domain: { id: domain.id } } }), kept: { ...record, restoredAt: new Date(), restoreRequestId: request.requestId } };
|
|
146
|
+
}
|
|
147
|
+
/** The drafts reverts kept for a figure, newest first -- found again after a reload. */
|
|
148
|
+
async function replacedDraftsOf(tx, domain, figureId) {
|
|
149
|
+
return await tx.getRepository(figure_replaced_draft_js_1.FigureReplacedDraft).find({
|
|
150
|
+
where: { domain: { id: domain.id }, figureId },
|
|
151
|
+
order: { createdAt: 'DESC' },
|
|
152
|
+
relations: ['creator']
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=figure-revert.js.map
|
|
@@ -0,0 +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,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,G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,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"]}
|
|
@@ -38,6 +38,7 @@ exports.registerFigureToolCategories = registerFigureToolCategories;
|
|
|
38
38
|
* 사람이 목록에서 고르는 길에서는 드러나지 않지만, 모델은 대화 내용에 이끌려 임의의 id 를 넘길 수
|
|
39
39
|
* 있다. 그래서 호출자 도메인 소속을 먼저 확인한다.
|
|
40
40
|
*/
|
|
41
|
+
const crypto_1 = require("crypto");
|
|
41
42
|
const ai_client_base_1 = require("@things-factory/ai-client-base");
|
|
42
43
|
/*
|
|
43
44
|
서버 의존성은 lazy require 다. 등록은 부팅 초반에 평가되고 그때 typeorm DataSource 가 준비되지
|
|
@@ -368,6 +369,12 @@ function figureToolSpecs() {
|
|
|
368
369
|
const name = result.source.name || 'Figure';
|
|
369
370
|
return {
|
|
370
371
|
proposed: true,
|
|
372
|
+
/*
|
|
373
|
+
The proposal's own name, given once here (ADR-0097 §5.6 item 5; AI lane, 09-27): the dock keys its card by
|
|
374
|
+
it, a new figure made from it is created under it (the row id), and a save records it -- so what became of
|
|
375
|
+
it can be asked after a reload, and the same proposal never makes two figures.
|
|
376
|
+
*/
|
|
377
|
+
key: (0, crypto_1.randomUUID)(),
|
|
371
378
|
icon: 'view_in_ar',
|
|
372
379
|
label: create ? `${name} 만들기` : `${name} 고치기`,
|
|
373
380
|
reason: `명령 ${result.steps.length}개 · 등급 ${result.score?.grade ?? '-'} · 삼각형 ${result.cost.triangles} · ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figure-tools.js","sourceRoot":"","sources":["../../../server/service/figure/figure-tools.ts"],"names":[],"mappings":";;AAwEA,gEAEC;AA2UD,oEAuBC;AA5aD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,mEAAuG;AAEvG;;;EAGE;AACF,IAAI,KAAsB,CAAA;AAE1B,SAAS,OAAO;IACd,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,8DAA8D;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;QAC9C,8DAA8D;QAC9D,MAAM,KAAK,GAAG,OAAO,CA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OAAO;oBAC1C,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;oBAC5C,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B,CAAA;YACH,CAAC;SACF;KACY,CAAA;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,4BAA4B;IAC1C,MAAM,SAAS,GAAiB;QAC9B,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,8CAA8C;QAC3D,QAAQ,EAAE;YACR,iEAAiE;YACjE,wBAAwB;YACxB,mGAAmG;YACnG,mGAAmG;YACnG,qFAAqF;YACrF,oDAAoD;YACpD,qEAAqE;YACrE,yGAAyG;YACzG,sNAAsN;YACtN,+GAA+G;YAC/G,yEAAyE;YACzE,gGAAgG;YAChG,gEAAgE;SACjE,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,eAAe,EAAE;KACzB,CAAA;IAED,IAAA,qCAAoB,EAAC,SAAS,CAAC,CAAA;AACjC,CAAC","sourcesContent":["/*\n * figure 저작 도구를 어시스턴트 도구 레지스트리에 등록 — **대화면(도크)에서 저작을 돕기 위함.**\n *\n * 왜 필요한가: `proposeFigure` 는 한 번 시키고 한 번 받는다. 그것으로 되는 일이 있지만, 저작은\n * 대개 「이걸 이렇게 고쳐 봐 → 무게가 얼마나 되나 → 발행은 되나」처럼 여러 차례 오간다. 그 대화를\n * 하려면 어시스턴트가 **지금 무엇이 있는지 읽을 수 있어야** 한다. 읽지 못하면 매번 사람이 정본을\n * 붙여 넣어야 하고, 그러면 대화가 아니다.\n *\n * 능력을 복제하지 않는다. figure-service 가 이미 가진 진입점(`inspectSource` · `proposeFigureSteps` ·\n * 조회)을 레지스트리에 투영한다.\n *\n * ── 전부 조회·제안 전용이다 ─────────────────────────────────────────────────\n * 정본을 고치는 도구를 넣지 않는다. 형식의 설계가 그렇게 정해져 있다 — 어시스턴트는 **후보**를\n * 내고, 받을지 버릴지는 저작자가 정한다(`figure-propose-steps.ts`, ADR-0094). 되돌릴 수 없는 조작이 대화면으로\n * 새지 않으므로 전부 `kind: 'read'` 다.\n *\n * 저장은 저작면이 `updateFigure` 로 한다. 그 mutation 은 `figure:mutation` 이 지키고, 대화는\n * `ai-assistant:mutation` 이 지킨다 — 서로 다른 질문이라 서로 다른 권한이 지킨다. figure 가 board\n * 의 권한을 빌리지 않는다.\n *\n * ── No privilege here. The gate reads what the door declares ─────────────────────\n * Until 2026-09-18 each tool carried `privilege: { category: 'figure', ... }`. It matched the door's\n * directive then, and would drift the day the door changed its declaration — and the looser copy wins.\n * Now the gate reads the declaration of each door in `doors` from AUTH's table (ADR-0071 decision 2,\n * addendum). What stays here is **the doors it reaches**.\n *\n * ── 규율을 도구와 함께 보낸다 ───────────────────────────────────────────────\n * 도구 목록만으로는 「언제 반드시 불러야 하는지」를 모른다. twin 이 그 공백에서 사고를 냈다 —\n * 조치 요청에 도구를 부르지 않고 「제안해 두었습니다」라고만 답해, 사용자에게 **없는 버튼을 누르라고\n * 안내했다.** figure 도 똑같은 자리가 있다: 후보 화면(「지금 / 후보」 두 칸)은 **도구 호출 결과에서만**\n * 만들어진다. 문장으로는 아무 일도 일어나지 않는다.\n *\n * ── LLM 이 넘긴 id 를 믿지 않는다 ───────────────────────────────────────────\n * 사람이 목록에서 고르는 길에서는 드러나지 않지만, 모델은 대화 내용에 이끌려 임의의 id 를 넘길 수\n * 있다. 그래서 호출자 도메인 소속을 먼저 확인한다.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\n/*\n 서버 의존성은 lazy require 다. 등록은 부팅 초반에 평가되고 그때 typeorm DataSource 가 준비되지\n 않았을 수 있다(board-import · twin-ai 와 같은 정책).\n*/\nlet _deps: any | undefined\n\nfunction getDeps(): any {\n if (!_deps) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const shell = require('@things-factory/shell')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const model = require('@hatiolab/figure-model')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const entity = require('./figure.js')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const format = require('./figure-format.js')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const proposer = require('./figure-propose-steps.js')\n _deps = {\n getRepository: shell.getRepository,\n Figure: entity.Figure,\n /* The same doors a save and a release go through. The tool reads; it never saves. */\n inspectSource: format.inspectSource,\n parseSource: format.parseSource,\n figureCostOf: model.figureCostOf,\n figureScoreOf: model.figureScoreOf,\n proposeFigureSteps: proposer.proposeFigureSteps,\n isPlaceholderType: model.isPlaceholderType\n }\n }\n return _deps\n}\n\n/** 시험·검증 하네스 전용 주입 시임. 운영 경로에서 호출 금지. */\nexport function __setFigureToolDepsForTest(deps: any): void {\n _deps = deps\n}\n\nfunction requireDomainId(state: any): string {\n const id = state?.domain?.id\n if (!id) {\n // 도메인을 모르면 무엇을 읽어도 남의 것일 수 있다. 조용히 넘기지 않는다.\n throw new Error('domain context is missing — the figure tools cannot resolve tenant scope')\n }\n return id\n}\n\n/**\n * 이 도형이 호출자 도메인 것인가.\n *\n * 모델이 넘긴 id 를 그대로 쓰지 않는다. 없으면 못 찾았다고 말한다 — 「권한이 없다」와 구별해\n * 알려 줄 것이 없다(다른 테넌트에 그 id 가 있다는 사실 자체가 알려 줄 것이 아니다).\n */\nasync function figureInDomain(figureId: string, domainId: string): Promise<any> {\n const { getRepository, Figure } = getDeps()\n const found = await getRepository(Figure).findOne({\n where: { id: figureId, domain: { id: domainId } }\n })\n if (!found) {\n throw new Error(`figure not found in this tenant: ${figureId}`)\n }\n return found\n}\n\n/**\n * The figure a tool is about: by id, or by its type name, in the caller's domain. None named: none.\n */\nasync function resolveFigureTarget(figureId: string | undefined, domainId: string, _host: any): Promise<any> {\n if (!figureId) return undefined\n const { getRepository, Figure } = getDeps()\n const found =\n (await getRepository(Figure).findOne({ where: { id: figureId, domain: { id: domainId } } })) ??\n (await getRepository(Figure).findOne({ where: { type: figureId, domain: { id: domainId } } }))\n if (!found) throw new Error(`figure not found in this tenant: ${figureId}`)\n return found\n}\n\n/**\n * The source a tool reads: the draft on screen when the modeller has this figure open, else the stored one.\n *\n * The host context is the browser's, so it is no ground for access: the row is found in the domain first, and the\n * draft is put through the same door a save goes through before anything reads it.\n */\nconst isFigure = (source: any) => source?.version === 'figure-asset-1'\n\n/**\n * A revision is applied by the modeller on the version the model saw (ADR-0094), so only the figure open there can be\n * revised. Said as what is true, with what the assistant can do instead.\n */\nfunction figureNotOpen() {\n return {\n error: 'FIGURE_NOT_OPEN',\n message: '고치는 제안은 모델러에 열려 있는 도형에만 낼 수 있습니다.',\n nextStep:\n 'Tell the person to open the figure in the modeller and ask again there. A new figure needs no open one: call proposeFigureCandidate with create: true.'\n }\n}\n\nfunction sourceForTool(row: any, host: any): { source: any; draft: boolean } {\n const draft = host?.figureId === row.id ? host?.draftSource : undefined\n if (!draft) return { source: row.source ? JSON.parse(row.source) : null, draft: false }\n\n if (typeof draft !== 'object' || Array.isArray(draft)) throw new Error('the unsaved draft is not a figure asset')\n const serialized = JSON.stringify(draft)\n if (serialized.length > 100_000) throw new Error('the unsaved draft is too large to safely review')\n try {\n getDeps().parseSource(serialized)\n } catch (e: any) {\n const findings = Array.isArray(e?.findings) ? e.findings.map((one: any) => one.message).join(' · ') : String(e?.message ?? e)\n throw new Error(`the unsaved draft is invalid: ${findings}`)\n }\n return { source: draft, draft: true }\n}\n\n/**\n * 무엇을 고치라는 것인지 대화면 문맥에서 해소한다.\n *\n * 모델이 대상을 안 줬으면 **저작면이 지금 열고 있는 도형**이다. 사용자에게 식별자를 되묻지\n * 않는다 — 화면에 그 도형이 떠 있는데 「어느 도형입니까」를 묻는 것은 문맥을 안 읽은 것이다.\n */\nfunction figureIdFrom(args: any, host: any): string | undefined {\n const said = typeof args?.figureId === 'string' ? args.figureId.trim() : ''\n if (said) return said\n\n const open = typeof host?.figureId === 'string' ? host.figureId.trim() : ''\n if (open) return open\n\n return undefined\n}\n\nfunction missingFigureTarget() {\n return {\n error: 'FIGURE_TARGET_REQUIRED',\n message: '현재 화면에는 선택된 도형이 없습니다.',\n nextStep: 'For an existing figure, call listFigures and match the user’s requested name or type; ask which figure only if ambiguous. For a new figure, call proposeFigureCandidate with create: true and the user’s prompt. Do not invent an id or repeat this call without a target.'\n }\n}\n\nconst FIGURE_ID_ARG = {\n figureId: {\n type: 'string',\n description: 'The figure to read. Omit to read the one the person has open, saved or not — the server fills it in, and you cannot see which it is. On the catalog nothing is open, so resolve the figure the person asked for with listFigures first.'\n }\n} as const\n\n/**\n * 도구 넷.\n *\n * 목록 · 정본 · 발행 판정 · 후보. 저작 대화에서 실제로 묻는 것이 그 넷이다 — 「무엇이 있나」\n * 「지금 어떻게 생겼나」 「발행이 왜 안 되나」 「이렇게 고쳐 봐」.\n */\nfunction figureToolSpecs(): ToolSpec[] {\n return [\n {\n kind: 'read',\n name: 'listFigures',\n /* 이 도메인의 도형 목록 — 저장소를 직접 읽지만 같은 일을 하는 문은 이것이다. */\n doors: ['Query.figures'],\n description:\n 'Lists the figures in this tenant with their type names, states and part counts. ' +\n 'Call it before naming a type — type names are stored identifiers and must not be invented.',\n schema: { type: 'object', properties: {} },\n builder: async (_args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const { getRepository, Figure } = getDeps()\n const rows = await getRepository(Figure).find({\n where: { domain: { id: domainId } },\n order: { updatedAt: 'DESC' },\n take: 200\n })\n return {\n figures: rows.map((row: any) => ({\n id: row.id,\n type: row.type,\n name: row.name,\n state: row.state,\n score: row.score,\n triangles: row.triangles\n }))\n }\n }\n },\n {\n kind: 'read',\n name: 'getFigureSource',\n /* 저장된 도형의 원본. **저장 전 초안**을 물으면 저장소에 갈 것이 없어 화면이 보낸 것을 그대로 돌려준다 —\n * 그 갈래에는 닿는 문이 없지만 `doors: []` 로 적지 않는다. 그러면 저장된 도형을 읽는 권한 검사가 선언에서 사라진다. */\n doors: ['Query.figure'],\n description:\n 'Returns the source (the figure asset) of one figure, with its measured cost ' +\n '(triangles, part groups, and how many of it hold 60fps on one screen). Call it before proposing a revision — ' +\n 'revising without reading it means proposing against a guess.',\n schema: { type: 'object', properties: { ...FIGURE_ID_ARG } },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const figureId = figureIdFrom(args, ctx?.host)\n const row = await resolveFigureTarget(figureId, domainId, ctx?.host)\n if (!row) return missingFigureTarget()\n\n const current = sourceForTool(row, ctx?.host)\n if (!current.source) {\n // 저장된 정본이 없는 상태가 실제로 있다(새로 만들고 저장 안 한 것). 지어내지 않는다.\n return { id: row.id, type: row.type, name: row.name, source: null, cost: null }\n }\n\n /* Measured as the catalogue measures it: triangles, draw groups, and its grade against one screen. */\n const { figureCostOf, figureScoreOf } = getDeps()\n return {\n id: row.id,\n type: row.type,\n name: row.name,\n state: row.state,\n source: current.source,\n draft: current.draft,\n cost: figureCostOf(current.source),\n score: figureScoreOf(current.source) ?? null\n }\n }\n },\n {\n kind: 'read',\n name: 'inspectFigure',\n /* 검사 결과 — 같은 일을 하는 문. */\n doors: ['Query.inspectFigure'],\n description:\n 'Says whether a figure may be released and, when it may not, what is wrong — each finding ' +\n 'carries why it is a problem and what to change. Call it when asked about releasing, or ' +\n 'when asked to fix a figure that will not release.',\n schema: { type: 'object', properties: { ...FIGURE_ID_ARG } },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const figureId = figureIdFrom(args, ctx?.host)\n const row = await resolveFigureTarget(figureId, domainId, ctx?.host)\n if (!row) return missingFigureTarget()\n\n const current = sourceForTool(row, ctx?.host)\n const { inspectSource } = getDeps()\n return { ...inspectSource(current.source ? JSON.stringify(current.source) : null, null, undefined, row.type), draft: current.draft }\n }\n },\n {\n kind: 'read',\n name: 'proposeFigureCandidate',\n /* 후보 생성 — 저장은 하지 않지만 같은 문의 권한을 쓴다. */\n doors: ['Mutation.proposeFigure'],\n description:\n 'Asks for a proposal: the modeller commands that make a new figure or revise the one open in the modeller. ' +\n 'Returns the commands with the score and cost of the figure they make. NOTHING IS SAVED — the author applies ' +\n 'the proposal in the modeller as one step, or leaves it. This is the only way a proposal reaches the screen.',\n schema: {\n type: 'object',\n properties: {\n prompt: {\n type: 'string',\n description: 'What to make or change, in the words the author used.'\n },\n figureId: {\n type: 'string',\n description: 'Revise this figure; it must be the one open in the modeller. Omit to revise the open one; pass null to create anew.'\n },\n name: {\n type: 'string',\n description: 'The name a person reads for a new figure.'\n },\n create: {\n type: 'boolean',\n description: 'True to create rather than revise, even with a figure open.'\n }\n },\n required: ['prompt']\n },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const prompt = typeof args?.prompt === 'string' ? args.prompt.trim() : ''\n if (!prompt) throw new Error('prompt is required: there is nothing to ask for')\n\n /*\n 고치는 것인지 만드는 것인지를 **문맥에서 정한다.** 열린 도형이 있으면 고치는 것이 기본이고,\n 모델이 `create` 를 켜면 만드는 것이다. 이것을 모델의 짐작에 맡기면 열려 있는 도형을 덮어쓰는\n 후보가 온다.\n\n 고치는 제안은 모델러가 **요청 당시의 판(context · revision)** 위에 한 단계로 적용한다(ADR-0094).\n 그래서 고칠 수 있는 것은 모델러에 열린 도형뿐이고, 그 판을 문맥이 함께 실어 와야 한다.\n */\n const host = ctx?.host\n const create = args?.create === true || args?.figureId === null\n let base: unknown\n let figureId: string | undefined\n if (!create) {\n const said = typeof args?.figureId === 'string' ? args.figureId.trim() : ''\n const open = typeof host?.figureId === 'string' ? host.figureId.trim() : ''\n if (said && said !== open) {\n await figureInDomain(said, domainId)\n return figureNotOpen()\n }\n if (!open) return missingFigureTarget()\n const row = await resolveFigureTarget(open, domainId, host)\n if (!row) return missingFigureTarget()\n base = sourceForTool(row, host).source ?? undefined\n if (!isFigure(base)) return figureNotOpen()\n if (typeof host?.context !== 'string' || !Number.isInteger(host?.revision)) return figureNotOpen()\n figureId = open\n }\n\n let hostImage: { data: Buffer; mediaType: any } | undefined\n const rawImage = host?.image || (Array.isArray(host?.attachments) ? host.attachments.find((a: any) => a?.mediaType?.startsWith('image/')) : undefined)\n if (rawImage?.data) {\n const rawData = typeof rawImage.data === 'string' ? rawImage.data.replace(/^data:image\\/[a-zA-Z]+;base64,/, '') : rawImage.data\n const buf = typeof rawData === 'string' ? Buffer.from(rawData, 'base64') : Buffer.from(rawData)\n hostImage = { data: buf, mediaType: rawImage.mediaType || 'image/png' }\n }\n\n const { proposeFigureSteps } = getDeps()\n let result: any\n try {\n result = await proposeFigureSteps({\n prompt,\n base,\n name: typeof args?.name === 'string' && args.name.trim() ? args.name.trim() : undefined,\n image: hostImage\n })\n } catch (error) {\n /*\n * 세 번 거절된 끝의 사유를 ProposeFigureFailure.reasons 에만 두면 agentic-loop 은 「만들지 못했습니다」만\n * 받아 화면에는 「응답이 비어있습니다」가 된다. 다시 시도할 수 있는 말로 경계를 넘긴다.\n * 다른 예외(권한·통신)는 원문을 보존한다.\n */\n const reasons = Array.isArray((error as any)?.reasons) ? (error as any).reasons : []\n if (reasons.length > 0) throw new Error([(error as Error).message, ...reasons].join('\\n'))\n throw error\n }\n\n /*\n **`proposed: true` 가 카드를 만든다.** 이 표시가 없으면 제안은 도구 추적 안에 묻히고 화면에는\n 아무것도 생기지 않는다. 카드의 실행 단추가 figure-ui 의 처리기에 넘기고, 처리기가 모델러에 명령\n 목록을 한 단계로 적용한다. `args` 는 같은 제안을 두 번 세지 않기 위한 열쇠의 일부다.\n */\n const name = result.source.name || 'Figure'\n return {\n proposed: true,\n icon: 'view_in_ar',\n label: create ? `${name} 만들기` : `${name} 고치기`,\n reason:\n `명령 ${result.steps.length}개 · 등급 ${result.score?.grade ?? '-'} · 삼각형 ${result.cost.triangles} · ` +\n `${result.attempts}번에 만들었다`,\n args: { prompt, figureId, create },\n create,\n figureId,\n context: create ? undefined : host.context,\n revision: create ? undefined : host.revision,\n steps: result.steps,\n score: result.score,\n cost: result.cost,\n attempts: result.attempts\n }\n }\n }\n ] as ToolSpec[]\n}\n\n/**\n * 등록 — 부팅 시 1회.\n *\n * 범주가 하나다. twin 은 관찰과 생성을 둘로 갈랐는데(운영 협의에 생성 도구가 들려 있으면 대화의\n * 성격이 흐려진다), figure 의 대화면은 저작면 하나뿐이고 그 자리에서 읽기와 후보 요청이 함께 필요하다.\n * 대화면이 늘면 그때 가른다.\n */\nexport function registerFigureToolCategories(): void {\n const authoring: ToolCategory = {\n name: 'figure-authoring',\n description: '저작 중인 Figure 의 정본·비용·발행 판정 조회와 후보 제안(저장 아님).',\n guidance: [\n '- **도형을 만들거나 고쳐 달라는 요청에는 반드시 `proposeFigureCandidate` 를 호출한다.**',\n ' 후보는 도구 호출 결과에서만 생긴다.',\n ' 호출 없이 \"후보를 만들었습니다\" · \"적용 버튼을 누르세요\" 라고 쓰는 것은 **거짓이다** — 화면에 후보 칸이 생기지 않으므로 사용자는 존재하지 않는 버튼을 찾는다.',\n ' 후보는 모델러 명령 목록이다. 도크 카드의 실행 단추를 눌러야 모델러에 한 단계로 적용되고, 되돌리기 한 번에 통째로 돌아간다. 적용 전에 이미 바뀌었다고 말하지 않는다.',\n ' 고치는 제안은 모델러에 열린 도형에만 낼 수 있다. 결과의 `steps` 가 무엇을 하는지 그대로 전한다 — 명령에 없는 변경을 지어내지 않는다.',\n '- 정본을 직접 저장하지 않는다. 후보만 내고, 받을지 버릴지는 저작자가 화면에서 정한다.',\n '- 좌표와 크기는 X/Y/Z 축 이름으로 정확하게 표시한다. 확인되지 않은 가로·세로·높이 의미를 임의로 붙이지 않는다.',\n '- **고치라는 요청이면 먼저 `getFigureSource` 를 부른다.** 읽지 않고 고치면 짐작을 상대로 후보를 내게 되고, 부품 이름이 갈려 이미 배치된 보드의 바인딩이 끊긴다.',\n '- 목록 화면에는 열린 도형이 없다. 기존 도형을 조회할 때는 `listFigures`에서 사용자가 말한 이름·타입의 id를 찾는다. 대상이 모호할 때만 어느 도형인지 묻는다. 기존 도형을 고치려면 모델러에서 그 도형을 열고 거기서 요청하도록 안내한다. 새 제작 요청에는 기존 정본을 조회하지 않고 `proposeFigureCandidate`를 create: true로 호출한다.',\n '- 타입 이름을 지어내지 않는다 — `listFigures` 로 확인한다. **타입 이름은 저장되는 식별자**이고 보드가 그 이름으로 도형을 찾는다. 새 도형의 타입은 첫 저장 때 사람이 정한다.',\n '- 발행이 안 되는 이유를 물으면 `inspectFigure` 를 부른다. 판정 없이 \"발행할 수 있습니다\"라고 말하지 않는다.',\n ' 판정의 각 항목은 **왜 문제인지와 무엇을 바꾸면 되는지**를 함께 담고 있다. 그대로 전한다 — 요약하면 저작자가 어느 부품의 어느 축을 고칠지 다시 찾아야 한다.',\n '- 무게·삼각형 수를 물으면 `getFigureSource` 의 `cost` 를 쓴다. 눈대중으로 세지 않는다.'\n ].join('\\n'),\n specs: figureToolSpecs()\n }\n\n registerToolCategory(authoring)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"figure-tools.js","sourceRoot":"","sources":["../../../server/service/figure/figure-tools.ts"],"names":[],"mappings":";;AAyEA,gEAEC;AAiVD,oEAuBC;AAnbD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,mCAAmC;AACnC,mEAAuG;AAEvG;;;EAGE;AACF,IAAI,KAAsB,CAAA;AAE1B,SAAS,OAAO;IACd,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,8DAA8D;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;QAC9C,8DAA8D;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;QAC/C,8DAA8D;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;QACrC,8DAA8D;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;QAC5C,8DAA8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C,KAAK;oBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B,CAAA;YACH,CAAC;SACF;KACY,CAAA;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,4BAA4B;IAC1C,MAAM,SAAS,GAAiB;QAC9B,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,8CAA8C;QAC3D,QAAQ,EAAE;YACR,iEAAiE;YACjE,wBAAwB;YACxB,mGAAmG;YACnG,mGAAmG;YACnG,qFAAqF;YACrF,oDAAoD;YACpD,qEAAqE;YACrE,yGAAyG;YACzG,sNAAsN;YACtN,+GAA+G;YAC/G,yEAAyE;YACzE,gGAAgG;YAChG,gEAAgE;SACjE,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,eAAe,EAAE;KACzB,CAAA;IAED,IAAA,qCAAoB,EAAC,SAAS,CAAC,CAAA;AACjC,CAAC","sourcesContent":["/*\n * figure 저작 도구를 어시스턴트 도구 레지스트리에 등록 — **대화면(도크)에서 저작을 돕기 위함.**\n *\n * 왜 필요한가: `proposeFigure` 는 한 번 시키고 한 번 받는다. 그것으로 되는 일이 있지만, 저작은\n * 대개 「이걸 이렇게 고쳐 봐 → 무게가 얼마나 되나 → 발행은 되나」처럼 여러 차례 오간다. 그 대화를\n * 하려면 어시스턴트가 **지금 무엇이 있는지 읽을 수 있어야** 한다. 읽지 못하면 매번 사람이 정본을\n * 붙여 넣어야 하고, 그러면 대화가 아니다.\n *\n * 능력을 복제하지 않는다. figure-service 가 이미 가진 진입점(`inspectSource` · `proposeFigureSteps` ·\n * 조회)을 레지스트리에 투영한다.\n *\n * ── 전부 조회·제안 전용이다 ─────────────────────────────────────────────────\n * 정본을 고치는 도구를 넣지 않는다. 형식의 설계가 그렇게 정해져 있다 — 어시스턴트는 **후보**를\n * 내고, 받을지 버릴지는 저작자가 정한다(`figure-propose-steps.ts`, ADR-0094). 되돌릴 수 없는 조작이 대화면으로\n * 새지 않으므로 전부 `kind: 'read'` 다.\n *\n * 저장은 저작면이 `updateFigure` 로 한다. 그 mutation 은 `figure:mutation` 이 지키고, 대화는\n * `ai-assistant:mutation` 이 지킨다 — 서로 다른 질문이라 서로 다른 권한이 지킨다. figure 가 board\n * 의 권한을 빌리지 않는다.\n *\n * ── No privilege here. The gate reads what the door declares ─────────────────────\n * Until 2026-09-18 each tool carried `privilege: { category: 'figure', ... }`. It matched the door's\n * directive then, and would drift the day the door changed its declaration — and the looser copy wins.\n * Now the gate reads the declaration of each door in `doors` from AUTH's table (ADR-0071 decision 2,\n * addendum). What stays here is **the doors it reaches**.\n *\n * ── 규율을 도구와 함께 보낸다 ───────────────────────────────────────────────\n * 도구 목록만으로는 「언제 반드시 불러야 하는지」를 모른다. twin 이 그 공백에서 사고를 냈다 —\n * 조치 요청에 도구를 부르지 않고 「제안해 두었습니다」라고만 답해, 사용자에게 **없는 버튼을 누르라고\n * 안내했다.** figure 도 똑같은 자리가 있다: 후보 화면(「지금 / 후보」 두 칸)은 **도구 호출 결과에서만**\n * 만들어진다. 문장으로는 아무 일도 일어나지 않는다.\n *\n * ── LLM 이 넘긴 id 를 믿지 않는다 ───────────────────────────────────────────\n * 사람이 목록에서 고르는 길에서는 드러나지 않지만, 모델은 대화 내용에 이끌려 임의의 id 를 넘길 수\n * 있다. 그래서 호출자 도메인 소속을 먼저 확인한다.\n */\nimport { randomUUID } from 'crypto'\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\n/*\n 서버 의존성은 lazy require 다. 등록은 부팅 초반에 평가되고 그때 typeorm DataSource 가 준비되지\n 않았을 수 있다(board-import · twin-ai 와 같은 정책).\n*/\nlet _deps: any | undefined\n\nfunction getDeps(): any {\n if (!_deps) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const shell = require('@things-factory/shell')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const model = require('@hatiolab/figure-model')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const entity = require('./figure.js')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const format = require('./figure-format.js')\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const proposer = require('./figure-propose-steps.js')\n _deps = {\n getRepository: shell.getRepository,\n Figure: entity.Figure,\n /* The same doors a save and a release go through. The tool reads; it never saves. */\n inspectSource: format.inspectSource,\n parseSource: format.parseSource,\n figureCostOf: model.figureCostOf,\n figureScoreOf: model.figureScoreOf,\n proposeFigureSteps: proposer.proposeFigureSteps,\n isPlaceholderType: model.isPlaceholderType\n }\n }\n return _deps\n}\n\n/** 시험·검증 하네스 전용 주입 시임. 운영 경로에서 호출 금지. */\nexport function __setFigureToolDepsForTest(deps: any): void {\n _deps = deps\n}\n\nfunction requireDomainId(state: any): string {\n const id = state?.domain?.id\n if (!id) {\n // 도메인을 모르면 무엇을 읽어도 남의 것일 수 있다. 조용히 넘기지 않는다.\n throw new Error('domain context is missing — the figure tools cannot resolve tenant scope')\n }\n return id\n}\n\n/**\n * 이 도형이 호출자 도메인 것인가.\n *\n * 모델이 넘긴 id 를 그대로 쓰지 않는다. 없으면 못 찾았다고 말한다 — 「권한이 없다」와 구별해\n * 알려 줄 것이 없다(다른 테넌트에 그 id 가 있다는 사실 자체가 알려 줄 것이 아니다).\n */\nasync function figureInDomain(figureId: string, domainId: string): Promise<any> {\n const { getRepository, Figure } = getDeps()\n const found = await getRepository(Figure).findOne({\n where: { id: figureId, domain: { id: domainId } }\n })\n if (!found) {\n throw new Error(`figure not found in this tenant: ${figureId}`)\n }\n return found\n}\n\n/**\n * The figure a tool is about: by id, or by its type name, in the caller's domain. None named: none.\n */\nasync function resolveFigureTarget(figureId: string | undefined, domainId: string, _host: any): Promise<any> {\n if (!figureId) return undefined\n const { getRepository, Figure } = getDeps()\n const found =\n (await getRepository(Figure).findOne({ where: { id: figureId, domain: { id: domainId } } })) ??\n (await getRepository(Figure).findOne({ where: { type: figureId, domain: { id: domainId } } }))\n if (!found) throw new Error(`figure not found in this tenant: ${figureId}`)\n return found\n}\n\n/**\n * The source a tool reads: the draft on screen when the modeller has this figure open, else the stored one.\n *\n * The host context is the browser's, so it is no ground for access: the row is found in the domain first, and the\n * draft is put through the same door a save goes through before anything reads it.\n */\nconst isFigure = (source: any) => source?.version === 'figure-asset-1'\n\n/**\n * A revision is applied by the modeller on the version the model saw (ADR-0094), so only the figure open there can be\n * revised. Said as what is true, with what the assistant can do instead.\n */\nfunction figureNotOpen() {\n return {\n error: 'FIGURE_NOT_OPEN',\n message: '고치는 제안은 모델러에 열려 있는 도형에만 낼 수 있습니다.',\n nextStep:\n 'Tell the person to open the figure in the modeller and ask again there. A new figure needs no open one: call proposeFigureCandidate with create: true.'\n }\n}\n\nfunction sourceForTool(row: any, host: any): { source: any; draft: boolean } {\n const draft = host?.figureId === row.id ? host?.draftSource : undefined\n if (!draft) return { source: row.source ? JSON.parse(row.source) : null, draft: false }\n\n if (typeof draft !== 'object' || Array.isArray(draft)) throw new Error('the unsaved draft is not a figure asset')\n const serialized = JSON.stringify(draft)\n if (serialized.length > 100_000) throw new Error('the unsaved draft is too large to safely review')\n try {\n getDeps().parseSource(serialized)\n } catch (e: any) {\n const findings = Array.isArray(e?.findings) ? e.findings.map((one: any) => one.message).join(' · ') : String(e?.message ?? e)\n throw new Error(`the unsaved draft is invalid: ${findings}`)\n }\n return { source: draft, draft: true }\n}\n\n/**\n * 무엇을 고치라는 것인지 대화면 문맥에서 해소한다.\n *\n * 모델이 대상을 안 줬으면 **저작면이 지금 열고 있는 도형**이다. 사용자에게 식별자를 되묻지\n * 않는다 — 화면에 그 도형이 떠 있는데 「어느 도형입니까」를 묻는 것은 문맥을 안 읽은 것이다.\n */\nfunction figureIdFrom(args: any, host: any): string | undefined {\n const said = typeof args?.figureId === 'string' ? args.figureId.trim() : ''\n if (said) return said\n\n const open = typeof host?.figureId === 'string' ? host.figureId.trim() : ''\n if (open) return open\n\n return undefined\n}\n\nfunction missingFigureTarget() {\n return {\n error: 'FIGURE_TARGET_REQUIRED',\n message: '현재 화면에는 선택된 도형이 없습니다.',\n nextStep: 'For an existing figure, call listFigures and match the user’s requested name or type; ask which figure only if ambiguous. For a new figure, call proposeFigureCandidate with create: true and the user’s prompt. Do not invent an id or repeat this call without a target.'\n }\n}\n\nconst FIGURE_ID_ARG = {\n figureId: {\n type: 'string',\n description: 'The figure to read. Omit to read the one the person has open, saved or not — the server fills it in, and you cannot see which it is. On the catalog nothing is open, so resolve the figure the person asked for with listFigures first.'\n }\n} as const\n\n/**\n * 도구 넷.\n *\n * 목록 · 정본 · 발행 판정 · 후보. 저작 대화에서 실제로 묻는 것이 그 넷이다 — 「무엇이 있나」\n * 「지금 어떻게 생겼나」 「발행이 왜 안 되나」 「이렇게 고쳐 봐」.\n */\nfunction figureToolSpecs(): ToolSpec[] {\n return [\n {\n kind: 'read',\n name: 'listFigures',\n /* 이 도메인의 도형 목록 — 저장소를 직접 읽지만 같은 일을 하는 문은 이것이다. */\n doors: ['Query.figures'],\n description:\n 'Lists the figures in this tenant with their type names, states and part counts. ' +\n 'Call it before naming a type — type names are stored identifiers and must not be invented.',\n schema: { type: 'object', properties: {} },\n builder: async (_args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const { getRepository, Figure } = getDeps()\n const rows = await getRepository(Figure).find({\n where: { domain: { id: domainId } },\n order: { updatedAt: 'DESC' },\n take: 200\n })\n return {\n figures: rows.map((row: any) => ({\n id: row.id,\n type: row.type,\n name: row.name,\n state: row.state,\n score: row.score,\n triangles: row.triangles\n }))\n }\n }\n },\n {\n kind: 'read',\n name: 'getFigureSource',\n /* 저장된 도형의 원본. **저장 전 초안**을 물으면 저장소에 갈 것이 없어 화면이 보낸 것을 그대로 돌려준다 —\n * 그 갈래에는 닿는 문이 없지만 `doors: []` 로 적지 않는다. 그러면 저장된 도형을 읽는 권한 검사가 선언에서 사라진다. */\n doors: ['Query.figure'],\n description:\n 'Returns the source (the figure asset) of one figure, with its measured cost ' +\n '(triangles, part groups, and how many of it hold 60fps on one screen). Call it before proposing a revision — ' +\n 'revising without reading it means proposing against a guess.',\n schema: { type: 'object', properties: { ...FIGURE_ID_ARG } },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const figureId = figureIdFrom(args, ctx?.host)\n const row = await resolveFigureTarget(figureId, domainId, ctx?.host)\n if (!row) return missingFigureTarget()\n\n const current = sourceForTool(row, ctx?.host)\n if (!current.source) {\n // 저장된 정본이 없는 상태가 실제로 있다(새로 만들고 저장 안 한 것). 지어내지 않는다.\n return { id: row.id, type: row.type, name: row.name, source: null, cost: null }\n }\n\n /* Measured as the catalogue measures it: triangles, draw groups, and its grade against one screen. */\n const { figureCostOf, figureScoreOf } = getDeps()\n return {\n id: row.id,\n type: row.type,\n name: row.name,\n state: row.state,\n source: current.source,\n draft: current.draft,\n cost: figureCostOf(current.source),\n score: figureScoreOf(current.source) ?? null\n }\n }\n },\n {\n kind: 'read',\n name: 'inspectFigure',\n /* 검사 결과 — 같은 일을 하는 문. */\n doors: ['Query.inspectFigure'],\n description:\n 'Says whether a figure may be released and, when it may not, what is wrong — each finding ' +\n 'carries why it is a problem and what to change. Call it when asked about releasing, or ' +\n 'when asked to fix a figure that will not release.',\n schema: { type: 'object', properties: { ...FIGURE_ID_ARG } },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const figureId = figureIdFrom(args, ctx?.host)\n const row = await resolveFigureTarget(figureId, domainId, ctx?.host)\n if (!row) return missingFigureTarget()\n\n const current = sourceForTool(row, ctx?.host)\n const { inspectSource } = getDeps()\n return { ...inspectSource(current.source ? JSON.stringify(current.source) : null, null, undefined, row.type), draft: current.draft }\n }\n },\n {\n kind: 'read',\n name: 'proposeFigureCandidate',\n /* 후보 생성 — 저장은 하지 않지만 같은 문의 권한을 쓴다. */\n doors: ['Mutation.proposeFigure'],\n description:\n 'Asks for a proposal: the modeller commands that make a new figure or revise the one open in the modeller. ' +\n 'Returns the commands with the score and cost of the figure they make. NOTHING IS SAVED — the author applies ' +\n 'the proposal in the modeller as one step, or leaves it. This is the only way a proposal reaches the screen.',\n schema: {\n type: 'object',\n properties: {\n prompt: {\n type: 'string',\n description: 'What to make or change, in the words the author used.'\n },\n figureId: {\n type: 'string',\n description: 'Revise this figure; it must be the one open in the modeller. Omit to revise the open one; pass null to create anew.'\n },\n name: {\n type: 'string',\n description: 'The name a person reads for a new figure.'\n },\n create: {\n type: 'boolean',\n description: 'True to create rather than revise, even with a figure open.'\n }\n },\n required: ['prompt']\n },\n builder: async (args: any, ctx: any) => {\n const domainId = requireDomainId(ctx?.state)\n const prompt = typeof args?.prompt === 'string' ? args.prompt.trim() : ''\n if (!prompt) throw new Error('prompt is required: there is nothing to ask for')\n\n /*\n 고치는 것인지 만드는 것인지를 **문맥에서 정한다.** 열린 도형이 있으면 고치는 것이 기본이고,\n 모델이 `create` 를 켜면 만드는 것이다. 이것을 모델의 짐작에 맡기면 열려 있는 도형을 덮어쓰는\n 후보가 온다.\n\n 고치는 제안은 모델러가 **요청 당시의 판(context · revision)** 위에 한 단계로 적용한다(ADR-0094).\n 그래서 고칠 수 있는 것은 모델러에 열린 도형뿐이고, 그 판을 문맥이 함께 실어 와야 한다.\n */\n const host = ctx?.host\n const create = args?.create === true || args?.figureId === null\n let base: unknown\n let figureId: string | undefined\n if (!create) {\n const said = typeof args?.figureId === 'string' ? args.figureId.trim() : ''\n const open = typeof host?.figureId === 'string' ? host.figureId.trim() : ''\n if (said && said !== open) {\n await figureInDomain(said, domainId)\n return figureNotOpen()\n }\n if (!open) return missingFigureTarget()\n const row = await resolveFigureTarget(open, domainId, host)\n if (!row) return missingFigureTarget()\n base = sourceForTool(row, host).source ?? undefined\n if (!isFigure(base)) return figureNotOpen()\n if (typeof host?.context !== 'string' || !Number.isInteger(host?.revision)) return figureNotOpen()\n figureId = open\n }\n\n let hostImage: { data: Buffer; mediaType: any } | undefined\n const rawImage = host?.image || (Array.isArray(host?.attachments) ? host.attachments.find((a: any) => a?.mediaType?.startsWith('image/')) : undefined)\n if (rawImage?.data) {\n const rawData = typeof rawImage.data === 'string' ? rawImage.data.replace(/^data:image\\/[a-zA-Z]+;base64,/, '') : rawImage.data\n const buf = typeof rawData === 'string' ? Buffer.from(rawData, 'base64') : Buffer.from(rawData)\n hostImage = { data: buf, mediaType: rawImage.mediaType || 'image/png' }\n }\n\n const { proposeFigureSteps } = getDeps()\n let result: any\n try {\n result = await proposeFigureSteps({\n prompt,\n base,\n name: typeof args?.name === 'string' && args.name.trim() ? args.name.trim() : undefined,\n image: hostImage\n })\n } catch (error) {\n /*\n * 세 번 거절된 끝의 사유를 ProposeFigureFailure.reasons 에만 두면 agentic-loop 은 「만들지 못했습니다」만\n * 받아 화면에는 「응답이 비어있습니다」가 된다. 다시 시도할 수 있는 말로 경계를 넘긴다.\n * 다른 예외(권한·통신)는 원문을 보존한다.\n */\n const reasons = Array.isArray((error as any)?.reasons) ? (error as any).reasons : []\n if (reasons.length > 0) throw new Error([(error as Error).message, ...reasons].join('\\n'))\n throw error\n }\n\n /*\n **`proposed: true` 가 카드를 만든다.** 이 표시가 없으면 제안은 도구 추적 안에 묻히고 화면에는\n 아무것도 생기지 않는다. 카드의 실행 단추가 figure-ui 의 처리기에 넘기고, 처리기가 모델러에 명령\n 목록을 한 단계로 적용한다. `args` 는 같은 제안을 두 번 세지 않기 위한 열쇠의 일부다.\n */\n const name = result.source.name || 'Figure'\n return {\n proposed: true,\n /*\n The proposal's own name, given once here (ADR-0097 §5.6 item 5; AI lane, 09-27): the dock keys its card by\n it, a new figure made from it is created under it (the row id), and a save records it -- so what became of\n it can be asked after a reload, and the same proposal never makes two figures.\n */\n key: randomUUID(),\n icon: 'view_in_ar',\n label: create ? `${name} 만들기` : `${name} 고치기`,\n reason:\n `명령 ${result.steps.length}개 · 등급 ${result.score?.grade ?? '-'} · 삼각형 ${result.cost.triangles} · ` +\n `${result.attempts}번에 만들었다`,\n args: { prompt, figureId, create },\n create,\n figureId,\n context: create ? undefined : host.context,\n revision: create ? undefined : host.revision,\n steps: result.steps,\n score: result.score,\n cost: result.cost,\n attempts: result.attempts\n }\n }\n }\n ] as ToolSpec[]\n}\n\n/**\n * 등록 — 부팅 시 1회.\n *\n * 범주가 하나다. twin 은 관찰과 생성을 둘로 갈랐는데(운영 협의에 생성 도구가 들려 있으면 대화의\n * 성격이 흐려진다), figure 의 대화면은 저작면 하나뿐이고 그 자리에서 읽기와 후보 요청이 함께 필요하다.\n * 대화면이 늘면 그때 가른다.\n */\nexport function registerFigureToolCategories(): void {\n const authoring: ToolCategory = {\n name: 'figure-authoring',\n description: '저작 중인 Figure 의 정본·비용·발행 판정 조회와 후보 제안(저장 아님).',\n guidance: [\n '- **도형을 만들거나 고쳐 달라는 요청에는 반드시 `proposeFigureCandidate` 를 호출한다.**',\n ' 후보는 도구 호출 결과에서만 생긴다.',\n ' 호출 없이 \"후보를 만들었습니다\" · \"적용 버튼을 누르세요\" 라고 쓰는 것은 **거짓이다** — 화면에 후보 칸이 생기지 않으므로 사용자는 존재하지 않는 버튼을 찾는다.',\n ' 후보는 모델러 명령 목록이다. 도크 카드의 실행 단추를 눌러야 모델러에 한 단계로 적용되고, 되돌리기 한 번에 통째로 돌아간다. 적용 전에 이미 바뀌었다고 말하지 않는다.',\n ' 고치는 제안은 모델러에 열린 도형에만 낼 수 있다. 결과의 `steps` 가 무엇을 하는지 그대로 전한다 — 명령에 없는 변경을 지어내지 않는다.',\n '- 정본을 직접 저장하지 않는다. 후보만 내고, 받을지 버릴지는 저작자가 화면에서 정한다.',\n '- 좌표와 크기는 X/Y/Z 축 이름으로 정확하게 표시한다. 확인되지 않은 가로·세로·높이 의미를 임의로 붙이지 않는다.',\n '- **고치라는 요청이면 먼저 `getFigureSource` 를 부른다.** 읽지 않고 고치면 짐작을 상대로 후보를 내게 되고, 부품 이름이 갈려 이미 배치된 보드의 바인딩이 끊긴다.',\n '- 목록 화면에는 열린 도형이 없다. 기존 도형을 조회할 때는 `listFigures`에서 사용자가 말한 이름·타입의 id를 찾는다. 대상이 모호할 때만 어느 도형인지 묻는다. 기존 도형을 고치려면 모델러에서 그 도형을 열고 거기서 요청하도록 안내한다. 새 제작 요청에는 기존 정본을 조회하지 않고 `proposeFigureCandidate`를 create: true로 호출한다.',\n '- 타입 이름을 지어내지 않는다 — `listFigures` 로 확인한다. **타입 이름은 저장되는 식별자**이고 보드가 그 이름으로 도형을 찾는다. 새 도형의 타입은 첫 저장 때 사람이 정한다.',\n '- 발행이 안 되는 이유를 물으면 `inspectFigure` 를 부른다. 판정 없이 \"발행할 수 있습니다\"라고 말하지 않는다.',\n ' 판정의 각 항목은 **왜 문제인지와 무엇을 바꾸면 되는지**를 함께 담고 있다. 그대로 전한다 — 요약하면 저작자가 어느 부품의 어느 축을 고칠지 다시 찾아야 한다.',\n '- 무게·삼각형 수를 물으면 `getFigureSource` 의 `cost` 를 쓴다. 눈대중으로 세지 않는다.'\n ].join('\\n'),\n specs: figureToolSpecs()\n }\n\n registerToolCategory(authoring)\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FigureReplacedDraft } from './figure-replaced-draft.js';
|
|
1
2
|
import { Figure } from './figure.js';
|
|
2
3
|
/**
|
|
3
4
|
* 새 Figure.
|
|
@@ -62,6 +63,19 @@ export declare class FigureSaveResult {
|
|
|
62
63
|
figure: Figure;
|
|
63
64
|
violations: FigureFinding[];
|
|
64
65
|
}
|
|
66
|
+
/** An AI proposal saved into a figure, with the figure's names as they are now (ADR-0097 §5.6 item 5). */
|
|
67
|
+
export declare class FigureProposalOutcome {
|
|
68
|
+
figureId: string;
|
|
69
|
+
type?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
recordedAt?: Date;
|
|
72
|
+
}
|
|
73
|
+
/** A revert's outcome: the figure as it now is, and the draft kept for it (ADR-0097 §5.6). */
|
|
74
|
+
export declare class FigureRevertResult {
|
|
75
|
+
figure: Figure;
|
|
76
|
+
violations: FigureFinding[];
|
|
77
|
+
kept: FigureReplacedDraft;
|
|
78
|
+
}
|
|
65
79
|
/**
|
|
66
80
|
* 발행 판정 한 줄.
|
|
67
81
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FigureInspection = exports.FigureGateFinding = exports.FigureSaveResult = exports.FigureFinding = exports.FigureList = exports.FigurePatch = exports.NewFigure = void 0;
|
|
3
|
+
exports.FigureInspection = exports.FigureGateFinding = exports.FigureRevertResult = exports.FigureProposalOutcome = exports.FigureSaveResult = exports.FigureFinding = exports.FigureList = exports.FigurePatch = exports.NewFigure = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const figure_replaced_draft_js_1 = require("./figure-replaced-draft.js");
|
|
5
6
|
const type_graphql_1 = require("type-graphql");
|
|
6
7
|
const figure_js_1 = require("./figure.js");
|
|
7
8
|
/**
|
|
@@ -159,6 +160,48 @@ tslib_1.__decorate([
|
|
|
159
160
|
exports.FigureSaveResult = FigureSaveResult = tslib_1.__decorate([
|
|
160
161
|
(0, type_graphql_1.ObjectType)({ description: 'Result of saving a figure, carrying non-blocking violations.' })
|
|
161
162
|
], FigureSaveResult);
|
|
163
|
+
/** An AI proposal saved into a figure, with the figure's names as they are now (ADR-0097 §5.6 item 5). */
|
|
164
|
+
let FigureProposalOutcome = class FigureProposalOutcome {
|
|
165
|
+
};
|
|
166
|
+
exports.FigureProposalOutcome = FigureProposalOutcome;
|
|
167
|
+
tslib_1.__decorate([
|
|
168
|
+
(0, type_graphql_1.Field)({ description: 'The figure it was saved into.' }),
|
|
169
|
+
tslib_1.__metadata("design:type", String)
|
|
170
|
+
], FigureProposalOutcome.prototype, "figureId", void 0);
|
|
171
|
+
tslib_1.__decorate([
|
|
172
|
+
(0, type_graphql_1.Field)({ nullable: true, description: "The figure's type name now." }),
|
|
173
|
+
tslib_1.__metadata("design:type", String)
|
|
174
|
+
], FigureProposalOutcome.prototype, "type", void 0);
|
|
175
|
+
tslib_1.__decorate([
|
|
176
|
+
(0, type_graphql_1.Field)({ nullable: true, description: "The figure's display name now." }),
|
|
177
|
+
tslib_1.__metadata("design:type", String)
|
|
178
|
+
], FigureProposalOutcome.prototype, "name", void 0);
|
|
179
|
+
tslib_1.__decorate([
|
|
180
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When the save that held it was made.' }),
|
|
181
|
+
tslib_1.__metadata("design:type", Date)
|
|
182
|
+
], FigureProposalOutcome.prototype, "recordedAt", void 0);
|
|
183
|
+
exports.FigureProposalOutcome = FigureProposalOutcome = tslib_1.__decorate([
|
|
184
|
+
(0, type_graphql_1.ObjectType)({ description: 'A figure an AI proposal was saved into.' })
|
|
185
|
+
], FigureProposalOutcome);
|
|
186
|
+
/** A revert's outcome: the figure as it now is, and the draft kept for it (ADR-0097 §5.6). */
|
|
187
|
+
let FigureRevertResult = class FigureRevertResult {
|
|
188
|
+
};
|
|
189
|
+
exports.FigureRevertResult = FigureRevertResult;
|
|
190
|
+
tslib_1.__decorate([
|
|
191
|
+
(0, type_graphql_1.Field)(type => figure_js_1.Figure, { description: 'The figure, as it now is.' }),
|
|
192
|
+
tslib_1.__metadata("design:type", figure_js_1.Figure)
|
|
193
|
+
], FigureRevertResult.prototype, "figure", void 0);
|
|
194
|
+
tslib_1.__decorate([
|
|
195
|
+
(0, type_graphql_1.Field)(type => [FigureFinding], { description: 'Non-blocking findings on the source written.' }),
|
|
196
|
+
tslib_1.__metadata("design:type", Array)
|
|
197
|
+
], FigureRevertResult.prototype, "violations", void 0);
|
|
198
|
+
tslib_1.__decorate([
|
|
199
|
+
(0, type_graphql_1.Field)(type => figure_replaced_draft_js_1.FigureReplacedDraft, { description: 'The draft kept for this revert -- or, for an undo, the one brought back.' }),
|
|
200
|
+
tslib_1.__metadata("design:type", figure_replaced_draft_js_1.FigureReplacedDraft)
|
|
201
|
+
], FigureRevertResult.prototype, "kept", void 0);
|
|
202
|
+
exports.FigureRevertResult = FigureRevertResult = tslib_1.__decorate([
|
|
203
|
+
(0, type_graphql_1.ObjectType)({ description: 'The result of a revert, or of an undo of one.' })
|
|
204
|
+
], FigureRevertResult);
|
|
162
205
|
/**
|
|
163
206
|
* 발행 판정 한 줄.
|
|
164
207
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figure-type.js","sourceRoot":"","sources":["../../../server/service/figure/figure-type.ts"],"names":[],"mappings":";;;;AAAA,+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,WAAW,EAAE,wCAAwC,EAAE,CAAC;;wCACr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Int, 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/**\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;AAEhE,2CAAoC;AAEpC;;;;;GAKG;AAEI,IAAM,SAAS,GAA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QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;;8CAC7E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uEAAuE,EAAE,CAAC;;6CACrG;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;mDACpD;4BAjBN,iBAAiB;IAD7B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;GACrD,iBAAiB,CAkB7B;AAED;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAM5B,CAAA;AANY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,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'\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,3 +1,10 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* The row is not what the writer expected: another edit, or the writer's own earlier save whose answer it never got.
|
|
4
|
+
* Coded, so a client can tell it from a refusal on grounds (permission, validation) and read the row back before
|
|
5
|
+
* saying its save failed (D, designer 2026-09-27).
|
|
6
|
+
*/
|
|
7
|
+
export declare function sourceConflict(message: string): GraphQLError;
|
|
1
8
|
export interface FigureWriteCriteria {
|
|
2
9
|
id: string;
|
|
3
10
|
domain: {
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceConflict = sourceConflict;
|
|
3
4
|
exports.compareAndSwapFigure = compareAndSwapFigure;
|
|
4
5
|
exports.prepareFigureWrite = prepareFigureWrite;
|
|
5
6
|
exports.pictureOf = pictureOf;
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
6
8
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
9
|
+
/**
|
|
10
|
+
* The row is not what the writer expected: another edit, or the writer's own earlier save whose answer it never got.
|
|
11
|
+
* Coded, so a client can tell it from a refusal on grounds (permission, validation) and read the row back before
|
|
12
|
+
* saying its save failed (D, designer 2026-09-27).
|
|
13
|
+
*/
|
|
14
|
+
function sourceConflict(message) {
|
|
15
|
+
return new graphql_1.GraphQLError(message, { extensions: { code: 'FIGURE_SOURCE_CONFLICT' } });
|
|
16
|
+
}
|
|
7
17
|
async function compareAndSwapFigure(update, id, domainId, expectedSource) {
|
|
8
18
|
if (expectedSource === undefined)
|
|
9
19
|
throw Error('수정 전 정본이 필요합니다.');
|
|
10
20
|
const result = await update({ id, domain: { id: domainId }, source: expectedSource });
|
|
11
21
|
if (result.affected !== 1)
|
|
12
|
-
throw
|
|
22
|
+
throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 열어 주세요.');
|
|
13
23
|
}
|
|
14
24
|
/** Early validation only. The repository must also compare expectedSource in its atomic UPDATE. */
|
|
15
25
|
function prepareFigureWrite(source, existing, expectedSource) {
|
|
16
26
|
if (existing && (expectedSource === undefined || existing.source !== expectedSource)) {
|
|
17
|
-
throw
|
|
27
|
+
throw sourceConflict('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 적용해 주세요.');
|
|
18
28
|
}
|
|
19
29
|
const asset = (0, figure_model_1.parseFigureAsset)(source);
|
|
20
30
|
(0, figure_model_1.compileFigureAsset)(asset);
|