@things-factory/figure-service 10.1.300 → 10.1.303
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/routers/figure-thumbnail-router.js +28 -0
- package/dist-server/service/figure/figure-catalog.d.ts +28 -0
- package/dist-server/service/figure/figure-catalog.js +72 -0
- package/dist-server/service/figure/figure-context.js +10 -0
- package/dist-server/service/figure/figure-format.js +42 -0
- package/dist-server/service/figure/figure-mutation.js +17 -5
- package/dist-server/service/figure/figure-propose-steps.d.ts +7 -2
- package/dist-server/service/figure/figure-propose-steps.js +16 -8
- package/dist-server/service/figure/figure-query.d.ts +1 -1
- package/dist-server/service/figure/figure-query.js +5 -4
- package/dist-server/service/figure/figure-tools.js +7 -1
- package/dist-server/service/figure/figure-type.d.ts +1 -1
- package/dist-server/service/figure/figure-type.js +4 -4
- package/dist-server/service/figure-recipe/figure-catalog-of.d.ts +8 -0
- package/dist-server/service/figure-recipe/figure-catalog-of.js +29 -0
- package/dist-server/service/figure-recipe/figure-recipe-resolver.d.ts +5 -2
- package/dist-server/service/figure-recipe/figure-recipe-resolver.js +76 -5
- package/dist-server/service/figure-recipe/figure-recipe-type.d.ts +14 -0
- package/dist-server/service/figure-recipe/figure-recipe-type.js +55 -1
- package/dist-server/service/figure-recipe/figure-shelf-recipe.d.ts +25 -0
- package/dist-server/service/figure-recipe/figure-shelf-recipe.js +99 -0
- package/dist-server/service/figure-recipe/figure-shelf.d.ts +27 -0
- package/dist-server/service/figure-recipe/figure-shelf.js +72 -0
- package/dist-server/service/figure-recipe/index.d.ts +2 -0
- package/dist-server/service/figure-recipe/index.js +3 -1
- package/dist-server/service/index.d.ts +3 -1
- package/dist-server/service/index.js +7 -2
- package/package.json +7 -7
- package/recipes/air-cylinder/guide.ko.md +1 -1
- package/recipes/air-cylinder/recipe.json +1 -1
- package/recipes/air-cylinder/spec.json +1 -1
- package/recipes/air-shower/guide.ko.md +1 -1
- package/recipes/air-shower/recipe.json +1 -1
- package/recipes/air-shower/spec.json +1 -1
- package/recipes/barrier-gate/guide.ko.md +1 -1
- package/recipes/barrier-gate/recipe.json +1 -1
- package/recipes/barrier-gate/spec.json +1 -1
- package/recipes/base-frame/guide.ko.md +1 -1
- package/recipes/base-frame/recipe.json +1 -1
- package/recipes/base-frame/spec.json +1 -1
- package/recipes/belt-surface/guide.ko.md +1 -1
- package/recipes/belt-surface/recipe.json +1 -1
- package/recipes/belt-surface/spec.json +1 -1
- package/recipes/bin-row/guide.ko.md +1 -1
- package/recipes/bin-row/recipe.json +1 -1
- package/recipes/bin-row/spec.json +1 -1
- package/recipes/bollard-row/guide.ko.md +1 -1
- package/recipes/bollard-row/recipe.json +1 -1
- package/recipes/bollard-row/spec.json +1 -1
- package/recipes/buzzer/guide.ko.md +1 -1
- package/recipes/buzzer/recipe.json +1 -1
- package/recipes/buzzer/spec.json +1 -1
- package/recipes/cabinet-doors/guide.ko.md +2 -2
- package/recipes/cabinet-doors/recipe.json +1 -1
- package/recipes/cabinet-doors/spec.json +1 -1
- package/recipes/cable-tray/guide.ko.md +1 -1
- package/recipes/cable-tray/recipe.json +1 -1
- package/recipes/cable-tray/spec.json +1 -1
- package/recipes/camera-mount/guide.ko.md +1 -1
- package/recipes/camera-mount/recipe.json +1 -1
- package/recipes/camera-mount/spec.json +1 -1
- package/recipes/canopy/guide.ko.md +1 -1
- package/recipes/canopy/recipe.json +1 -1
- package/recipes/canopy/spec.json +1 -1
- package/recipes/cart/guide.ko.md +1 -1
- package/recipes/cart/recipe.json +1 -1
- package/recipes/cart/spec.json +1 -1
- package/recipes/cart-handle/guide.ko.md +1 -1
- package/recipes/cart-handle/recipe.json +1 -1
- package/recipes/cart-handle/spec.json +1 -1
- package/recipes/casters-four/guide.ko.md +1 -1
- package/recipes/casters-four/recipe.json +1 -1
- package/recipes/casters-four/spec.json +1 -1
- package/recipes/ceiling-rail-carriage/guide.ko.md +1 -1
- package/recipes/ceiling-rail-carriage/recipe.json +1 -1
- package/recipes/ceiling-rail-carriage/spec.json +1 -1
- package/recipes/chain-rails/guide.ko.md +1 -1
- package/recipes/chain-rails/recipe.json +1 -1
- package/recipes/chain-rails/spec.json +1 -1
- package/recipes/charging-station/guide.ko.md +1 -1
- package/recipes/charging-station/recipe.json +1 -1
- package/recipes/charging-station/spec.json +1 -1
- package/recipes/column-row/guide.ko.md +1 -1
- package/recipes/column-row/recipe.json +1 -1
- package/recipes/column-row/spec.json +1 -1
- package/recipes/control-cabinet/guide.ko.md +1 -1
- package/recipes/control-cabinet/recipe.json +1 -1
- package/recipes/control-cabinet/spec.json +1 -1
- package/recipes/conveyor-skirts/guide.ko.md +1 -1
- package/recipes/conveyor-skirts/recipe.json +1 -1
- package/recipes/conveyor-skirts/spec.json +1 -1
- package/recipes/counter-display/guide.ko.md +1 -1
- package/recipes/counter-display/recipe.json +1 -1
- package/recipes/counter-display/spec.json +1 -1
- package/recipes/dock-bumpers/guide.ko.md +1 -1
- package/recipes/dock-bumpers/recipe.json +1 -1
- package/recipes/dock-bumpers/spec.json +1 -1
- package/recipes/dock-leveler/guide.ko.md +1 -1
- package/recipes/dock-leveler/recipe.json +1 -1
- package/recipes/dock-leveler/spec.json +1 -1
- package/recipes/double-hinged-door/guide.ko.md +1 -1
- package/recipes/double-hinged-door/recipe.json +3 -3
- package/recipes/double-hinged-door/spec.json +3 -3
- package/recipes/drawer-stack/guide.ko.md +2 -2
- package/recipes/drawer-stack/recipe.json +1 -1
- package/recipes/drawer-stack/spec.json +1 -1
- package/recipes/drip-tray/guide.ko.md +1 -1
- package/recipes/drip-tray/recipe.json +1 -1
- package/recipes/drip-tray/spec.json +1 -1
- package/recipes/duct-fan/guide.ko.md +1 -1
- package/recipes/duct-fan/recipe.json +1 -1
- package/recipes/duct-fan/spec.json +1 -1
- package/recipes/emergency-stop/guide.ko.md +1 -1
- package/recipes/emergency-stop/recipe.json +1 -1
- package/recipes/emergency-stop/spec.json +1 -1
- package/recipes/end-covers/guide.ko.md +1 -1
- package/recipes/end-covers/recipe.json +1 -1
- package/recipes/end-covers/spec.json +1 -1
- package/recipes/ffu-row/guide.ko.md +1 -1
- package/recipes/ffu-row/recipe.json +1 -1
- package/recipes/ffu-row/spec.json +1 -1
- package/recipes/fire-extinguisher/guide.ko.md +1 -1
- package/recipes/fire-extinguisher/recipe.json +1 -1
- package/recipes/fire-extinguisher/spec.json +1 -1
- package/recipes/first-aid-box/guide.ko.md +1 -1
- package/recipes/first-aid-box/recipe.json +1 -1
- package/recipes/first-aid-box/spec.json +1 -1
- package/recipes/floor-zone/guide.ko.md +1 -1
- package/recipes/floor-zone/recipe.json +1 -1
- package/recipes/floor-zone/spec.json +1 -1
- package/recipes/folding-door/guide.ko.md +1 -1
- package/recipes/folding-door/recipe.json +2 -2
- package/recipes/folding-door/spec.json +2 -2
- package/recipes/fork/guide.ko.md +1 -1
- package/recipes/fork/recipe.json +1 -1
- package/recipes/fork/spec.json +1 -1
- package/recipes/gantry-frame/guide.ko.md +1 -1
- package/recipes/gantry-frame/recipe.json +1 -1
- package/recipes/gantry-frame/spec.json +1 -1
- package/recipes/gripper-2f/guide.ko.md +1 -1
- package/recipes/gripper-2f/recipe.json +1 -1
- package/recipes/gripper-2f/spec.json +1 -1
- package/recipes/guard-cover/guide.ko.md +1 -1
- package/recipes/guard-cover/recipe.json +1 -1
- package/recipes/guard-cover/spec.json +1 -1
- package/recipes/handrail/guide.ko.md +1 -1
- package/recipes/handrail/recipe.json +1 -1
- package/recipes/handrail/spec.json +1 -1
- package/recipes/hatch/guide.ko.md +1 -1
- package/recipes/hatch/recipe.json +3 -3
- package/recipes/hatch/spec.json +3 -3
- package/recipes/hinged-door/facts.md +6 -6
- package/recipes/hinged-door/guide.ko.md +2 -2
- package/recipes/hinged-door/recipe.json +3 -3
- package/recipes/hinged-door/spec.json +3 -3
- package/recipes/hmi-monitor/guide.ko.md +1 -1
- package/recipes/hmi-monitor/recipe.json +1 -1
- package/recipes/hmi-monitor/spec.json +1 -1
- package/recipes/hopper/guide.ko.md +1 -1
- package/recipes/hopper/recipe.json +1 -1
- package/recipes/hopper/spec.json +1 -1
- package/recipes/interlock-switch/guide.ko.md +1 -1
- package/recipes/interlock-switch/recipe.json +1 -1
- package/recipes/interlock-switch/spec.json +1 -1
- package/recipes/junction-box/guide.ko.md +1 -1
- package/recipes/junction-box/recipe.json +1 -1
- package/recipes/junction-box/spec.json +1 -1
- package/recipes/ladder/guide.ko.md +1 -1
- package/recipes/ladder/recipe.json +1 -1
- package/recipes/ladder/spec.json +1 -1
- package/recipes/legs-four/guide.ko.md +1 -1
- package/recipes/legs-four/recipe.json +1 -1
- package/recipes/legs-four/spec.json +1 -1
- package/recipes/leveling-feet/guide.ko.md +1 -1
- package/recipes/leveling-feet/recipe.json +1 -1
- package/recipes/leveling-feet/spec.json +1 -1
- package/recipes/lift-updown/guide.ko.md +1 -1
- package/recipes/lift-updown/recipe.json +1 -1
- package/recipes/lift-updown/spec.json +1 -1
- package/recipes/light-curtain/guide.ko.md +1 -1
- package/recipes/light-curtain/recipe.json +1 -1
- package/recipes/light-curtain/spec.json +1 -1
- package/recipes/limit-switch/guide.ko.md +1 -1
- package/recipes/limit-switch/recipe.json +1 -1
- package/recipes/limit-switch/spec.json +1 -1
- package/recipes/linear-guide/guide.ko.md +1 -1
- package/recipes/linear-guide/recipe.json +1 -1
- package/recipes/linear-guide/spec.json +1 -1
- package/recipes/locker-row/guide.ko.md +1 -1
- package/recipes/locker-row/recipe.json +1 -1
- package/recipes/locker-row/spec.json +1 -1
- package/recipes/motor-box/guide.ko.md +1 -1
- package/recipes/motor-box/recipe.json +1 -1
- package/recipes/motor-box/spec.json +1 -1
- package/recipes/observation-window/guide.ko.md +1 -1
- package/recipes/observation-window/recipe.json +3 -3
- package/recipes/observation-window/spec.json +3 -3
- package/recipes/operator-panel/guide.ko.md +2 -2
- package/recipes/operator-panel/recipe.json +1 -1
- package/recipes/operator-panel/spec.json +1 -1
- package/recipes/pallet/guide.ko.md +1 -1
- package/recipes/pallet/recipe.json +1 -1
- package/recipes/pallet/spec.json +1 -1
- package/recipes/partition-wall/guide.ko.md +1 -1
- package/recipes/partition-wall/recipe.json +1 -1
- package/recipes/partition-wall/spec.json +1 -1
- package/recipes/pass-box/guide.ko.md +1 -1
- package/recipes/pass-box/recipe.json +1 -1
- package/recipes/pass-box/spec.json +1 -1
- package/recipes/peg-board/guide.ko.md +1 -1
- package/recipes/peg-board/recipe.json +1 -1
- package/recipes/peg-board/spec.json +1 -1
- package/recipes/photo-sensor-pair/guide.ko.md +1 -1
- package/recipes/photo-sensor-pair/recipe.json +1 -1
- package/recipes/photo-sensor-pair/spec.json +1 -1
- package/recipes/pipe-run/guide.ko.md +1 -1
- package/recipes/pipe-run/recipe.json +1 -1
- package/recipes/pipe-run/spec.json +1 -1
- package/recipes/platform/guide.ko.md +1 -1
- package/recipes/platform/recipe.json +1 -1
- package/recipes/platform/spec.json +1 -1
- package/recipes/power-box/guide.ko.md +1 -1
- package/recipes/power-box/recipe.json +1 -1
- package/recipes/power-box/spec.json +1 -1
- package/recipes/pressure-gauge/guide.ko.md +1 -1
- package/recipes/pressure-gauge/recipe.json +1 -1
- package/recipes/pressure-gauge/spec.json +1 -1
- package/recipes/pull-cord/guide.ko.md +1 -1
- package/recipes/pull-cord/recipe.json +1 -1
- package/recipes/pull-cord/spec.json +1 -1
- package/recipes/pump/guide.ko.md +1 -1
- package/recipes/pump/recipe.json +1 -1
- package/recipes/pump/spec.json +1 -1
- package/recipes/pusher/guide.ko.md +1 -1
- package/recipes/pusher/recipe.json +1 -1
- package/recipes/pusher/spec.json +1 -1
- package/recipes/robot-plinth/guide.ko.md +1 -1
- package/recipes/robot-plinth/recipe.json +1 -1
- package/recipes/robot-plinth/spec.json +1 -1
- package/recipes/roll-up-shutter/guide.ko.md +1 -1
- package/recipes/roll-up-shutter/recipe.json +3 -3
- package/recipes/roll-up-shutter/spec.json +3 -3
- package/recipes/roller-row/facts.md +4 -4
- package/recipes/roller-row/guide.ko.md +1 -1
- package/recipes/roller-row/recipe.json +1 -1
- package/recipes/roller-row/spec.json +1 -1
- package/recipes/room-shell/guide.ko.md +2 -2
- package/recipes/room-shell/recipe.json +1 -1
- package/recipes/room-shell/spec.json +1 -1
- package/recipes/rotating-beacon/guide.ko.md +1 -1
- package/recipes/rotating-beacon/recipe.json +1 -1
- package/recipes/rotating-beacon/spec.json +1 -1
- package/recipes/safety-fence/guide.ko.md +1 -1
- package/recipes/safety-fence/recipe.json +1 -1
- package/recipes/safety-fence/spec.json +1 -1
- package/recipes/safety-mat/guide.ko.md +1 -1
- package/recipes/safety-mat/recipe.json +1 -1
- package/recipes/safety-mat/spec.json +1 -1
- package/recipes/safety-sign-stand/guide.ko.md +1 -1
- package/recipes/safety-sign-stand/recipe.json +1 -1
- package/recipes/safety-sign-stand/spec.json +1 -1
- package/recipes/scanner-mount/guide.ko.md +1 -1
- package/recipes/scanner-mount/recipe.json +1 -1
- package/recipes/scanner-mount/spec.json +1 -1
- package/recipes/selector-switch/guide.ko.md +1 -1
- package/recipes/selector-switch/recipe.json +1 -1
- package/recipes/selector-switch/spec.json +1 -1
- package/recipes/shelf-tiers/guide.ko.md +1 -1
- package/recipes/shelf-tiers/recipe.json +1 -1
- package/recipes/shelf-tiers/spec.json +1 -1
- package/recipes/side-guides/guide.ko.md +1 -1
- package/recipes/side-guides/recipe.json +1 -1
- package/recipes/side-guides/spec.json +1 -1
- package/recipes/sign-board/guide.ko.md +1 -1
- package/recipes/sign-board/recipe.json +2 -2
- package/recipes/sign-board/spec.json +2 -2
- package/recipes/signal-tower-3/guide.ko.md +1 -1
- package/recipes/signal-tower-3/recipe.json +1 -1
- package/recipes/signal-tower-3/spec.json +1 -1
- package/recipes/sliding-door/facts.md +7 -7
- package/recipes/sliding-door/guide.ko.md +2 -2
- package/recipes/sliding-door/recipe.json +3 -3
- package/recipes/sliding-door/spec.json +3 -3
- package/recipes/stairs/guide.ko.md +1 -1
- package/recipes/stairs/recipe.json +1 -1
- package/recipes/stairs/spec.json +1 -1
- package/recipes/status-lamp/guide.ko.md +1 -1
- package/recipes/status-lamp/recipe.json +1 -1
- package/recipes/status-lamp/spec.json +1 -1
- package/recipes/stopper/guide.ko.md +1 -1
- package/recipes/stopper/recipe.json +1 -1
- package/recipes/stopper/spec.json +1 -1
- package/recipes/suction-pads/guide.ko.md +1 -1
- package/recipes/suction-pads/recipe.json +1 -1
- package/recipes/suction-pads/spec.json +1 -1
- package/recipes/tank/guide.ko.md +1 -1
- package/recipes/tank/recipe.json +1 -1
- package/recipes/tank/spec.json +1 -1
- package/recipes/telescopic-arm/guide.ko.md +1 -1
- package/recipes/telescopic-arm/recipe.json +1 -1
- package/recipes/telescopic-arm/spec.json +1 -1
- package/recipes/toe-board/guide.ko.md +1 -1
- package/recipes/toe-board/recipe.json +1 -1
- package/recipes/toe-board/spec.json +1 -1
- package/recipes/tote/guide.ko.md +1 -1
- package/recipes/tote/recipe.json +1 -1
- package/recipes/tote/spec.json +1 -1
- package/recipes/traffic-cones/guide.ko.md +1 -1
- package/recipes/traffic-cones/recipe.json +1 -1
- package/recipes/traffic-cones/spec.json +1 -1
- package/recipes/transfer-belts/guide.ko.md +1 -1
- package/recipes/transfer-belts/recipe.json +1 -1
- package/recipes/transfer-belts/spec.json +1 -1
- package/recipes/tray-stack/guide.ko.md +2 -2
- package/recipes/tray-stack/recipe.json +1 -1
- package/recipes/tray-stack/spec.json +1 -1
- package/recipes/trough/guide.ko.md +1 -1
- package/recipes/trough/recipe.json +1 -1
- package/recipes/trough/spec.json +1 -1
- package/recipes/turntable/guide.ko.md +1 -1
- package/recipes/turntable/recipe.json +1 -1
- package/recipes/turntable/spec.json +1 -1
- package/recipes/valve-handle/guide.ko.md +1 -1
- package/recipes/valve-handle/recipe.json +1 -1
- package/recipes/valve-handle/spec.json +1 -1
- package/recipes/waste-bin/guide.ko.md +1 -1
- package/recipes/waste-bin/recipe.json +1 -1
- package/recipes/waste-bin/spec.json +1 -1
- package/recipes/work-light/guide.ko.md +1 -1
- package/recipes/work-light/recipe.json +1 -1
- package/recipes/work-light/spec.json +1 -1
- package/recipes/workbench-top/guide.ko.md +1 -1
- package/recipes/workbench-top/recipe.json +1 -1
- package/recipes/workbench-top/spec.json +1 -1
- package/translations/en.json +12 -0
- package/translations/es.json +12 -0
- package/translations/ja.json +12 -0
- package/translations/ko.json +18 -6
- package/translations/ms.json +12 -0
- package/translations/zh.json +12 -0
|
@@ -9,6 +9,7 @@ const shell_1 = require("@things-factory/shell");
|
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const figure_thumbnail_store_js_1 = require("../service/figure/figure-thumbnail-store.js");
|
|
11
11
|
const figure_recipe_templates_js_1 = require("../service/figure-recipe/figure-recipe-templates.js");
|
|
12
|
+
const figure_shelf_js_1 = require("../service/figure-recipe/figure-shelf.js");
|
|
12
13
|
const figure_public_js_1 = require("../service/figure/figure-public.js");
|
|
13
14
|
const figure_history_js_1 = require("../service/figure/figure-history.js");
|
|
14
15
|
/**
|
|
@@ -133,6 +134,33 @@ async function sendFigureThumbnail(context, next, id, domain, files = (0, figure
|
|
|
133
134
|
* A recipe template's thumbnail (ADR-0095 amended): the file drawn from its model, served behind the same door as the
|
|
134
135
|
* templates themselves. The file changes only with a release, so a day's private cache is enough.
|
|
135
136
|
*/
|
|
137
|
+
/**
|
|
138
|
+
* A kept recipe's card picture (ADR-0216 5b, device 2): read where the recipe is read -- its domain, its parent, or any
|
|
139
|
+
* domain when it is public -- and found in the domain that kept it, as a figure's picture is.
|
|
140
|
+
*/
|
|
141
|
+
exports.figureThumbnailRouter.get('/figure-recipe-thumbnail/shelf/:id', async (context, next) => {
|
|
142
|
+
const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
|
|
143
|
+
const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure', privilege: 'query', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
|
|
144
|
+
if (!allowed) {
|
|
145
|
+
context.status = 403;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const row = await (0, figure_shelf_js_1.readableShelfRecipe)(domain, context.params.id);
|
|
149
|
+
const picture = row?.thumbnailHash ? await (0, figure_thumbnail_store_js_1.thumbnailAttachmentOf)({ getRepository: shell_1.getRepository }, row.domain.id, row.thumbnailHash) : undefined;
|
|
150
|
+
if (!picture) {
|
|
151
|
+
context.status = 404;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
context.type = picture.mimetype;
|
|
155
|
+
context.set('Cache-Control', 'private, max-age=31536000');
|
|
156
|
+
context.set('ETag', `"${row.thumbnailHash}"`);
|
|
157
|
+
context.status = 200;
|
|
158
|
+
if (context.fresh) {
|
|
159
|
+
context.status = 304;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
await (0, figure_thumbnail_store_js_1.thumbnailFiles)().send(context, picture.path, next);
|
|
163
|
+
});
|
|
136
164
|
exports.figureThumbnailRouter.get('/figure-recipe-thumbnail/:name', async (context) => {
|
|
137
165
|
const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
|
|
138
166
|
const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure', privilege: 'query', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts catalog as the AI writer uses it (ADR-0216 5b, device 5): the entries this domain reads, told beside the
|
|
3
|
+
* grammar as a capability -- what each is and the values it takes -- and the recipe put into each `put-recipe` the
|
|
4
|
+
* writer names by its key. Whether the thing asked is one of them is the writer's to judge.
|
|
5
|
+
*
|
|
6
|
+
* Only the catalog's recipes are taken: a recipe written inline by the writer is refused, since a recipe may carry
|
|
7
|
+
* steps no proposal may (a part's own graph values). The steps handed on carry the recipe itself, so the modeller and a
|
|
8
|
+
* proposal's record apply what was checked here, whatever the catalog becomes afterwards.
|
|
9
|
+
*/
|
|
10
|
+
import { type FigureProposalStep, type FigureRecipe } from '@hatiolab/figure-model';
|
|
11
|
+
/** One entry the writer may put in. */
|
|
12
|
+
export interface FigureCatalogEntry {
|
|
13
|
+
/** What the writer names it by: a product template's name, a kept recipe's id. */
|
|
14
|
+
key: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
recipe: FigureRecipe;
|
|
18
|
+
}
|
|
19
|
+
/** The entries as the writer is told them, after the grammar; nothing when there are none. */
|
|
20
|
+
export declare function catalogPrompt(entries: readonly FigureCatalogEntry[]): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Each `put-recipe` given the recipe of the entry it names. A key this domain does not read, or a recipe written in
|
|
23
|
+
* its place, is a reason said back to the writer; the steps are returned only when every one is the catalog's.
|
|
24
|
+
*/
|
|
25
|
+
export declare function catalogSteps(steps: readonly unknown[], entries: readonly FigureCatalogEntry[]): {
|
|
26
|
+
steps?: FigureProposalStep[];
|
|
27
|
+
reasons: string[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.catalogPrompt = catalogPrompt;
|
|
4
|
+
exports.catalogSteps = catalogSteps;
|
|
5
|
+
/**
|
|
6
|
+
* The parts catalog as the AI writer uses it (ADR-0216 5b, device 5): the entries this domain reads, told beside the
|
|
7
|
+
* grammar as a capability -- what each is and the values it takes -- and the recipe put into each `put-recipe` the
|
|
8
|
+
* writer names by its key. Whether the thing asked is one of them is the writer's to judge.
|
|
9
|
+
*
|
|
10
|
+
* Only the catalog's recipes are taken: a recipe written inline by the writer is refused, since a recipe may carry
|
|
11
|
+
* steps no proposal may (a part's own graph values). The steps handed on carry the recipe itself, so the modeller and a
|
|
12
|
+
* proposal's record apply what was checked here, whatever the catalog becomes afterwards.
|
|
13
|
+
*/
|
|
14
|
+
const figure_model_1 = require("@hatiolab/figure-model");
|
|
15
|
+
const range = (p) => {
|
|
16
|
+
if (p.kind === 'flag')
|
|
17
|
+
return `flag, default ${p.default}`;
|
|
18
|
+
if (p.kind === 'choice' || p.kind === 'face')
|
|
19
|
+
return `${p.kind} ${(p.options ?? []).join(' | ')}, default ${p.default}`;
|
|
20
|
+
const above0 = p.min !== undefined && p.min > 0 && p.min < 1e-9;
|
|
21
|
+
const low = above0 ? '>0' : p.min !== undefined ? String(p.min) : '';
|
|
22
|
+
const span = p.max !== undefined ? `${low}–${p.max}` : low ? `${low}` : '';
|
|
23
|
+
return `${p.kind}${span ? ` ${span}` : ''}, default ${p.default}`;
|
|
24
|
+
};
|
|
25
|
+
/** How many parts it puts in: a kept recipe lists them; a template's are counted from its steps. */
|
|
26
|
+
const partsOf = (recipe) => {
|
|
27
|
+
const kept = Object.keys(recipe.parts ?? {}).length;
|
|
28
|
+
if (kept)
|
|
29
|
+
return String(kept);
|
|
30
|
+
const d = (0, figure_model_1.describeFigureRecipe)(recipe).parts;
|
|
31
|
+
return d.min === d.max ? String(d.min) : `${d.min}-${d.max}`;
|
|
32
|
+
};
|
|
33
|
+
/** The entries as the writer is told them, after the grammar; nothing when there are none. */
|
|
34
|
+
function catalogPrompt(entries) {
|
|
35
|
+
if (!entries.length)
|
|
36
|
+
return [];
|
|
37
|
+
return [
|
|
38
|
+
'',
|
|
39
|
+
"THIS DOMAIN'S PARTS CATALOG (put one in with put-recipe, recipe: its key; a thing that is one of these can be put in whole, its values set):",
|
|
40
|
+
...entries.map(e => {
|
|
41
|
+
const values = e.recipe.params.map(p => `${p.name} (${range(p)})`).join('; ');
|
|
42
|
+
/* A description ends with its own stop or none; the line's own follows it once. */
|
|
43
|
+
const what = [e.title, e.description].map(w => w.trim().replace(/[.。]+$/, '')).filter(Boolean).join(' -- ');
|
|
44
|
+
return `- ${e.key}: ${what}. Onto ${e.recipe.target === 'part' ? 'a part (target)' : 'the figure'}; ${partsOf(e.recipe)} ${partsOf(e.recipe) === '1' ? 'part' : 'parts'}${values ? `; values: ${values}` : ''}.`;
|
|
45
|
+
})
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Each `put-recipe` given the recipe of the entry it names. A key this domain does not read, or a recipe written in
|
|
50
|
+
* its place, is a reason said back to the writer; the steps are returned only when every one is the catalog's.
|
|
51
|
+
*/
|
|
52
|
+
function catalogSteps(steps, entries) {
|
|
53
|
+
const byKey = new Map(entries.map(e => [e.key, e.recipe]));
|
|
54
|
+
const reasons = [];
|
|
55
|
+
const out = steps.map((step, i) => {
|
|
56
|
+
const s = step;
|
|
57
|
+
if (!s || s.kind !== 'put-recipe')
|
|
58
|
+
return step;
|
|
59
|
+
if (typeof s.recipe !== 'string') {
|
|
60
|
+
reasons.push(`CATALOG_ENTRY: steps[${i}] (put-recipe) writes a recipe; recipe is the key of an entry of this domain's parts catalog, and nothing else.`);
|
|
61
|
+
return step;
|
|
62
|
+
}
|
|
63
|
+
const recipe = byKey.get(s.recipe);
|
|
64
|
+
if (!recipe) {
|
|
65
|
+
reasons.push(`CATALOG_ENTRY: steps[${i}] (put-recipe) names "${s.recipe}", which is not an entry of this domain's parts catalog. Use a key listed there, or build the thing with commands.`);
|
|
66
|
+
return step;
|
|
67
|
+
}
|
|
68
|
+
return { ...s, recipe };
|
|
69
|
+
});
|
|
70
|
+
return reasons.length ? { reasons } : { steps: out, reasons };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=figure-catalog.js.map
|
|
@@ -354,6 +354,10 @@ const SUBJECT = {
|
|
|
354
354
|
'set-visibility': step => step.target,
|
|
355
355
|
'remove-part': step => step.target,
|
|
356
356
|
'duplicate-part': step => step.target,
|
|
357
|
+
/* Onto a part, which it does not change: the parts it makes are the steps' own, as attach onto a part is. */
|
|
358
|
+
'put-recipe': () => undefined,
|
|
359
|
+
/* A typed measure changes the part whose value it is (<part>.dimension.…); a figure-level value, or a step without one, no part. */
|
|
360
|
+
'set-design': (step, base) => (typeof step.input === 'string' ? base.appearance.map(a => a.target).find(part => step.input.startsWith(`${part}.`)) : undefined),
|
|
357
361
|
'mirror-part': step => step.target,
|
|
358
362
|
'move-part': step => step.target,
|
|
359
363
|
'set-placement': () => undefined,
|
|
@@ -378,6 +382,12 @@ const SUBJECT = {
|
|
|
378
382
|
'set-state-defaults': () => undefined,
|
|
379
383
|
'set-driver': () => undefined,
|
|
380
384
|
'remove-driver': () => undefined,
|
|
385
|
+
'add-tracks': () => undefined,
|
|
386
|
+
'add-graph-part': () => undefined,
|
|
387
|
+
'set-hold': () => undefined,
|
|
388
|
+
/* A recipe's own step (ADR-0216 5b, figure-model 8292e73): a proposal that writes one is refused; it changes no one part. */
|
|
389
|
+
'carry-hold': () => undefined,
|
|
390
|
+
'remove-hold': () => undefined,
|
|
381
391
|
'set-clip': () => undefined,
|
|
382
392
|
'copy-clip': () => undefined,
|
|
383
393
|
'set-motion-group': () => undefined,
|
|
@@ -155,6 +155,48 @@ function figureWording(violation, say) {
|
|
|
155
155
|
how: say(key('how'), { parts }, `Let ${parts} follow the figure's size ("in proportion" under position in the size tab), or remove their own fixed numbers.`)
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
+
case 'HOLD_SLIP': {
|
|
159
|
+
/* A part kept on the floor that an edit moved after its hold was solved (ADR-0217). */
|
|
160
|
+
const hold = violation.hold ?? '';
|
|
161
|
+
const seconds = violation.seconds ?? '';
|
|
162
|
+
/* Said to a tenth of a millimetre; the gate keeps the finer number. */
|
|
163
|
+
const mm = Math.round((violation.mm ?? 0) * 10) / 10;
|
|
164
|
+
return {
|
|
165
|
+
message: violation.planted
|
|
166
|
+
? say(key('message-planted'), { hold, part, mm, from: violation.planted[0], to: violation.planted[1] }, `Hold '${hold}': '${part}' moves ${mm} mm along the floor while it stands planted from ${violation.planted[0]} s to ${violation.planted[1]} s.`)
|
|
167
|
+
: seconds === ''
|
|
168
|
+
? say(key('message-start'), { hold, part, mm }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept in the starting pose.`)
|
|
169
|
+
: violation.leap
|
|
170
|
+
? say(key('message-leap'), { hold, part, mm, a: violation.leap.between[0], b: violation.leap.between[1], label: violation.leap.label, from: violation.leap.from, to: violation.leap.to }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept between ${violation.leap.between[0]} s and ${violation.leap.between[1]} s, where ${violation.leap.label} changes sharply (${violation.leap.from} → ${violation.leap.to}).`)
|
|
171
|
+
: say(key('message'), { hold, part, mm, seconds }, `Hold '${hold}': '${part}' is ${mm} mm from where it is kept, at ${seconds} s.`),
|
|
172
|
+
/*
|
|
173
|
+
A hold its own controls cannot reach there (the gate solved it once at that pose): solving it again does not
|
|
174
|
+
mend it -- 「다시 맞추기」 refuses it -- so the reason and the remedy are the pose's (2026-11-21).
|
|
175
|
+
*/
|
|
176
|
+
...(violation.nearest !== undefined
|
|
177
|
+
? (() => {
|
|
178
|
+
const nearest = Math.round(violation.nearest * 10) / 10;
|
|
179
|
+
return {
|
|
180
|
+
why: say(key('why-unreachable'), { hold, nearest }, `The controls hold '${hold}' solves cannot keep the part there in this pose: solved again, it stays ${nearest} mm away.`),
|
|
181
|
+
how: seconds === ''
|
|
182
|
+
? say(key('how-unreachable-start'), { hold }, `Add a control for hold '${hold}' to solve, or change the starting pose.`)
|
|
183
|
+
: say(key('how-unreachable'), { hold, seconds }, `Add a control for hold '${hold}' to solve, or change the pose at ${seconds} s.`)
|
|
184
|
+
};
|
|
185
|
+
})()
|
|
186
|
+
: {
|
|
187
|
+
why: say(key('why'), {}, 'The hold was solved before a later edit changed the figure, such as a leg made longer. Played as it is, the part slides or sinks into the floor.'),
|
|
188
|
+
how: say(key('how'), { hold }, `Press 「Solve again」 for hold '${hold}' in the clip panel.`)
|
|
189
|
+
})
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
case 'HOLD_UNMEASURED': {
|
|
193
|
+
const hold = violation.hold ?? '';
|
|
194
|
+
return {
|
|
195
|
+
message: say(key('message'), { hold }, `Hold '${hold}' cannot be measured.`),
|
|
196
|
+
why: say(key('why'), {}, 'What it names is missing, or the figure cannot be posed as it asks, so whether the part stays on the floor is not known.'),
|
|
197
|
+
how: say(key('how'), { hold }, `Set hold '${hold}' again, or remove it.`)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
158
200
|
}
|
|
159
201
|
}
|
|
160
202
|
/*
|
|
@@ -4,6 +4,7 @@ exports.FigureMutation = void 0;
|
|
|
4
4
|
exports.assertNames = assertNames;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const capability_module_store_js_1 = require("../capability-module/capability-module-store.js");
|
|
7
|
+
const figure_catalog_of_js_1 = require("../figure-recipe/figure-catalog-of.js");
|
|
7
8
|
const typeorm_1 = require("typeorm");
|
|
8
9
|
const type_graphql_1 = require("type-graphql");
|
|
9
10
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
@@ -170,7 +171,7 @@ let FigureMutation = class FigureMutation {
|
|
|
170
171
|
source,
|
|
171
172
|
...derived,
|
|
172
173
|
namespace,
|
|
173
|
-
state:
|
|
174
|
+
state: 'draft',
|
|
174
175
|
...(await (0, figure_write_js_1.pictureOf)(tx, domain, user, thumbnail)),
|
|
175
176
|
domain,
|
|
176
177
|
creator: user,
|
|
@@ -187,6 +188,9 @@ let FigureMutation = class FigureMutation {
|
|
|
187
188
|
const conflicts = seen ? (0, figure_write_js_1.catalogConflictsOf)(figure, seen) : [];
|
|
188
189
|
if (conflicts.length)
|
|
189
190
|
throw (0, figure_write_js_1.catalogConflict)(conflicts);
|
|
191
|
+
if (patch.source !== undefined && (patch.expectedSource === undefined || patch.expectedSource !== figure.source)) {
|
|
192
|
+
throw (0, figure_write_js_1.sourceConflict)('다른 편집에서 모델이 변경되었습니다. 최신 모델을 다시 연 뒤 적용해 주세요.');
|
|
193
|
+
}
|
|
190
194
|
/*
|
|
191
195
|
**그림만 바꾸면 발행이 풀리지 않는다.** 미리보기에서 사람이 돌려 놓은 각도로 찍은 그림이 그렇게 온다.
|
|
192
196
|
그림은 발행이 약속하는 것이 아니다 — 발행본은 제 그림을 따로 갖고, 다음 발행이 이 그림을 가져간다.
|
|
@@ -247,7 +251,7 @@ let FigureMutation = class FigureMutation {
|
|
|
247
251
|
배포된 것이 달라진다. 그래서 저장은 언제나 초안으로 되돌린다. 버전 번호는 여기서 손대지 않는다 —
|
|
248
252
|
버전은 발행에서 생긴다(`releaseFigure`).
|
|
249
253
|
*/
|
|
250
|
-
const { type: _type, source: _source, ...fields } = patchRest;
|
|
254
|
+
const { type: _type, source: _source, expectedSource: _expectedSource, ...fields } = patchRest;
|
|
251
255
|
const changes = {
|
|
252
256
|
...Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined)),
|
|
253
257
|
...(renamed !== undefined ? { type: renamed } : {}),
|
|
@@ -268,8 +272,8 @@ let FigureMutation = class FigureMutation {
|
|
|
268
272
|
}
|
|
269
273
|
return result;
|
|
270
274
|
};
|
|
271
|
-
if ('source' in changes)
|
|
272
|
-
await (0, figure_write_js_1.compareAndSwapFigure)(written, id, domain.id, figure.source);
|
|
275
|
+
if (patch.source !== undefined || 'source' in changes)
|
|
276
|
+
await (0, figure_write_js_1.compareAndSwapFigure)(written, id, domain.id, patch.source !== undefined ? patch.expectedSource : figure.source);
|
|
273
277
|
else
|
|
274
278
|
await written({ id, domain: { id: domain.id } });
|
|
275
279
|
const saved = await repository.findOneOrFail({ where: { id, domain: { id: domain.id } } });
|
|
@@ -314,10 +318,16 @@ let FigureMutation = class FigureMutation {
|
|
|
314
318
|
const { domain, user, tx } = context.state;
|
|
315
319
|
const repository = tx.getRepository(figure_js_1.Figure);
|
|
316
320
|
const historyRepository = tx.getRepository(figure_history_js_1.FigureHistory);
|
|
317
|
-
|
|
321
|
+
let figure = await ownFigure(repository, domain, id);
|
|
318
322
|
if (figure.state === 'released') {
|
|
319
323
|
throw new Error(`Figure '${figure.type}' 은 이미 발행되어 있다. 고쳐서 다시 내려면 초안으로 되돌린 뒤 발행한다`);
|
|
320
324
|
}
|
|
325
|
+
/* Claim this exact draft before inspection. The no-op conditional UPDATE is portable to SQLite and
|
|
326
|
+
PostgreSQL and holds the row lock until @transaction commits the release and its history. A save that
|
|
327
|
+
already won is a named conflict; a save that follows waits and leaves the released snapshot intact.
|
|
328
|
+
Re-read under the claim so a catalogue edit made before it is not overwritten by the old entity. */
|
|
329
|
+
await (0, figure_write_js_1.compareAndSwapFigure)(criteria => repository.update({ ...criteria, state: figure.state, version: figure.version }, { state: figure.state }), id, domain.id, figure.source);
|
|
330
|
+
figure = await ownFigure(repository, domain, id);
|
|
321
331
|
/* A release promises boards the full name {namespace}/{type}: it goes out only under a namespace the domain owns and has active. */
|
|
322
332
|
const namespace = (0, figure_namespace_js_1.namespaceOf)(figure);
|
|
323
333
|
await (0, figure_namespace_js_1.assertReleasableNamespace)(tx, domain, namespace, user);
|
|
@@ -492,6 +502,8 @@ let FigureMutation = class FigureMutation {
|
|
|
492
502
|
/* The product capabilities the domain uses (ADR-0172 amendment 1, decision 16). */
|
|
493
503
|
capabilities: [...(await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: shell_1.getRepository }, context.state.domain)).values()],
|
|
494
504
|
choices: await (0, capability_module_store_js_1.chosenCapabilityChoices)({ getRepository: shell_1.getRepository }, context.state.domain),
|
|
505
|
+
/* The parts catalog the domain reads, put in by put-recipe (ADR-0216 5b, device 5). */
|
|
506
|
+
catalog: await (0, figure_catalog_of_js_1.figureCatalogOf)({ getRepository: shell_1.getRepository }, context.state.domain),
|
|
495
507
|
...(image ? { images: [image] } : {})
|
|
496
508
|
});
|
|
497
509
|
return {
|
|
@@ -4,6 +4,7 @@ import { type AIClient } from '@things-factory/ai-client-base';
|
|
|
4
4
|
import type { AIImageMediaType, AIMessage } from '@things-factory/ai-client-base';
|
|
5
5
|
import { type FigureRelationCheck, type FigureRelationVerdict } from './figure-relation-checks.js';
|
|
6
6
|
import { type FigureReadRequest, type FigureView } from './figure-context.js';
|
|
7
|
+
import { type FigureCatalogEntry } from './figure-catalog.js';
|
|
7
8
|
/** A capability a provider the domain uses gives (ADR-0172 amendment 1, decision 16), as the model is told it. */
|
|
8
9
|
export type ProposeFigureCapability = Pick<FigureCapabilityDescriptor, 'name' | 'label' | 'note' | 'needs' | 'data' | 'settings'>;
|
|
9
10
|
export interface ProposeFigureInput {
|
|
@@ -22,6 +23,8 @@ export interface ProposeFigureInput {
|
|
|
22
23
|
capabilities?: readonly ProposeFigureCapability[];
|
|
23
24
|
/** Their settings' choice lists, by <capability>.<setting> (ADR-0172 amendment 2, decision 21). */
|
|
24
25
|
choices?: FigureCapabilityChoices;
|
|
26
|
+
/** The parts catalog this domain reads (ADR-0216 5b, device 5): told beside the grammar, put in by put-recipe. */
|
|
27
|
+
catalog?: readonly FigureCatalogEntry[];
|
|
25
28
|
/** Reference pictures, in the order the person gave them: proportions and masses, not surface detail. */
|
|
26
29
|
images?: {
|
|
27
30
|
data: Buffer;
|
|
@@ -185,7 +188,7 @@ export declare function proposalFailureForPerson(failure: ProposeFigureFailure,
|
|
|
185
188
|
* What the model is told before the task: the answer's form, then figure-model's own guide and grammar, both made from
|
|
186
189
|
* the kernel and held to it by its tests. Nothing here designs a thing for it.
|
|
187
190
|
*/
|
|
188
|
-
export declare function rulesPromptFigure(capabilities?: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices): string;
|
|
191
|
+
export declare function rulesPromptFigure(capabilities?: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices, catalog?: readonly FigureCatalogEntry[]): string;
|
|
189
192
|
export declare function capabilitiesPrompt(capabilities: readonly ProposeFigureCapability[], choices?: FigureCapabilityChoices): string[];
|
|
190
193
|
/**
|
|
191
194
|
* The observations on a figure the kernel and the gate took, said to the model once: what was measured, how, and that
|
|
@@ -205,7 +208,9 @@ export declare function taskPromptFigure(input: ProposeFigureInput, view?: Figur
|
|
|
205
208
|
*/
|
|
206
209
|
export declare function judgeFigureAnswer(base: FigureAsset, answer: unknown, revising: boolean,
|
|
207
210
|
/** What the writer was shown of a draft shown in part; absent, or whole, when it was shown whole. */
|
|
208
|
-
view?: FigureView
|
|
211
|
+
view?: FigureView,
|
|
212
|
+
/** The parts catalog the writer was told: each put-recipe's key given its recipe, or refused. */
|
|
213
|
+
catalog?: readonly FigureCatalogEntry[]): {
|
|
209
214
|
source?: FigureAsset;
|
|
210
215
|
steps?: FigureProposalStep[];
|
|
211
216
|
reasons: string[];
|
|
@@ -13,6 +13,7 @@ const figure_model_1 = require("@hatiolab/figure-model");
|
|
|
13
13
|
const ai_client_base_1 = require("@things-factory/ai-client-base");
|
|
14
14
|
const figure_relation_checks_js_1 = require("./figure-relation-checks.js");
|
|
15
15
|
const figure_context_js_1 = require("./figure-context.js");
|
|
16
|
+
const figure_catalog_js_1 = require("./figure-catalog.js");
|
|
16
17
|
/**
|
|
17
18
|
* An AI proposal for a figure is a list of the modeller's own commands (ADR-0094).
|
|
18
19
|
*
|
|
@@ -58,7 +59,7 @@ function proposalFailureForPerson(failure, t) {
|
|
|
58
59
|
* What the model is told before the task: the answer's form, then figure-model's own guide and grammar, both made from
|
|
59
60
|
* the kernel and held to it by its tests. Nothing here designs a thing for it.
|
|
60
61
|
*/
|
|
61
|
-
function rulesPromptFigure(capabilities = [], choices = {}) {
|
|
62
|
+
function rulesPromptFigure(capabilities = [], choices = {}, catalog = []) {
|
|
62
63
|
return [
|
|
63
64
|
'You author a 3D figure for a factory digital twin by writing the commands a person gives in the figure modeller.',
|
|
64
65
|
'What the thing is, how it looks and how it moves is your own knowledge; how it is said in this modeller is below.',
|
|
@@ -69,7 +70,8 @@ function rulesPromptFigure(capabilities = [], choices = {}) {
|
|
|
69
70
|
'',
|
|
70
71
|
'THE COMMANDS (shape, then what it means):',
|
|
71
72
|
...figure_model_1.FIGURE_PROPOSAL_GRAMMAR.map(word => `- ${word.shape}\n ${word.means}`),
|
|
72
|
-
...capabilitiesPrompt(capabilities, choices)
|
|
73
|
+
...capabilitiesPrompt(capabilities, choices),
|
|
74
|
+
...(0, figure_catalog_js_1.catalogPrompt)(catalog)
|
|
73
75
|
].join('\n');
|
|
74
76
|
}
|
|
75
77
|
/*
|
|
@@ -266,10 +268,16 @@ function partsAtRefusedStep(base, steps, error) {
|
|
|
266
268
|
*/
|
|
267
269
|
function judgeFigureAnswer(base, answer, revising,
|
|
268
270
|
/** What the writer was shown of a draft shown in part; absent, or whole, when it was shown whole. */
|
|
269
|
-
view
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
view,
|
|
272
|
+
/** The parts catalog the writer was told: each put-recipe's key given its recipe, or refused. */
|
|
273
|
+
catalog = []) {
|
|
274
|
+
const written = answer?.steps;
|
|
275
|
+
if (!Array.isArray(written))
|
|
272
276
|
return { reasons: ['The answer must be { "steps": [ ... ] }.'] };
|
|
277
|
+
const fromCatalog = (0, figure_catalog_js_1.catalogSteps)(written, catalog);
|
|
278
|
+
if (!fromCatalog.steps)
|
|
279
|
+
return { reasons: fromCatalog.reasons };
|
|
280
|
+
const steps = fromCatalog.steps;
|
|
273
281
|
/* A part the writer was not shown is not changed on a guess (ADR-0061 2026-10-16 decision 4). */
|
|
274
282
|
const partial = view && !view.whole ? view : undefined;
|
|
275
283
|
const unread = partial ? (0, figure_context_js_1.unreadPartEdits)(base, steps, partial) : [];
|
|
@@ -323,7 +331,7 @@ async function proposeFigureSteps(input) {
|
|
|
323
331
|
const { client } = input;
|
|
324
332
|
const base = input.base ?? (0, figure_model_1.createFigureAsset)(input.name ?? 'Figure');
|
|
325
333
|
const view = viewFor(input);
|
|
326
|
-
const system = rulesPromptFigure(input.capabilities, input.choices);
|
|
334
|
+
const system = rulesPromptFigure(input.capabilities, input.choices, input.catalog);
|
|
327
335
|
const hashOf = (said) => (0, crypto_1.createHash)('sha1').update(said).digest('hex').slice(0, 12);
|
|
328
336
|
const record = {
|
|
329
337
|
at: new Date().toISOString(),
|
|
@@ -422,7 +430,7 @@ async function proposeFigureSteps(input) {
|
|
|
422
430
|
messages.push({ role: 'user', content: ['That was rejected. Answer with the JSON object only:', ...reasons].join('\n') });
|
|
423
431
|
continue;
|
|
424
432
|
}
|
|
425
|
-
const judged = judgeFigureAnswer(base, answer, !!input.base, view);
|
|
433
|
+
const judged = judgeFigureAnswer(base, answer, !!input.base, view, input.catalog);
|
|
426
434
|
record.attempts.push({ answer, reasons: judged.reasons });
|
|
427
435
|
if (judged.source) {
|
|
428
436
|
const candidate = { steps: judged.steps, source: judged.source };
|
|
@@ -458,7 +466,7 @@ async function proposeFigureSteps(input) {
|
|
|
458
466
|
const note = text(reply?.note);
|
|
459
467
|
if (reply?.keep === true)
|
|
460
468
|
return done(candidate, attempt, { asked: true, decision: 'kept', why, note });
|
|
461
|
-
const again = judgeFigureAnswer(base, reply, !!input.base, view);
|
|
469
|
+
const again = judgeFigureAnswer(base, reply, !!input.base, view, input.catalog);
|
|
462
470
|
record.attempts.push({ answer: reply, reasons: again.reasons });
|
|
463
471
|
if (again.source)
|
|
464
472
|
return done({ steps: again.steps, source: again.source }, attempt, { asked: true, decision: 'revised', why, note, ...(recovery ? { recovered: true } : {}) });
|
|
@@ -52,7 +52,7 @@ export declare class FigureQuery {
|
|
|
52
52
|
figureProposalOutcome(proposalKey: string, context: ResolverContext): Promise<FigureProposalOutcome[]>;
|
|
53
53
|
/** The drafts reverts kept for a figure, newest first -- apart from its released versions (ADR-0097 §5.6). */
|
|
54
54
|
figureReplacedDrafts(id: string, context: ResolverContext): Promise<FigureReplacedDraft[]>;
|
|
55
|
-
figureReleased(id: string, context: ResolverContext): Promise<FigureHistory>;
|
|
55
|
+
figureReleased(id: string, context: ResolverContext, version?: number): Promise<FigureHistory>;
|
|
56
56
|
/**
|
|
57
57
|
* 발행해도 되나 — **누르기 전에** 묻는 자리.
|
|
58
58
|
*
|
|
@@ -157,12 +157,12 @@ let FigureQuery = class FigureQuery {
|
|
|
157
157
|
const { domain, tx } = context.state;
|
|
158
158
|
return await (0, figure_revert_js_1.replacedDraftsOf)((0, shell_1.getRepository)(figure_replaced_draft_js_1.FigureReplacedDraft, tx).manager, domain, id);
|
|
159
159
|
}
|
|
160
|
-
async figureReleased(id, context) {
|
|
160
|
+
async figureReleased(id, context, version) {
|
|
161
161
|
const { domain } = context.state;
|
|
162
162
|
if (!(await (0, figure_public_js_1.readableFigure)(domain, id, { id: true, public: true, domain: { id: true } })))
|
|
163
163
|
return null;
|
|
164
164
|
return await (0, shell_1.getRepository)(figure_history_js_1.FigureHistory).findOne({
|
|
165
|
-
where: { originalId: id },
|
|
165
|
+
where: { originalId: id, ...(version ? { version } : {}) },
|
|
166
166
|
order: { version: 'DESC' }
|
|
167
167
|
});
|
|
168
168
|
}
|
|
@@ -450,11 +450,12 @@ tslib_1.__decorate([
|
|
|
450
450
|
], FigureQuery.prototype, "figureReplacedDrafts", null);
|
|
451
451
|
tslib_1.__decorate([
|
|
452
452
|
(0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "query", domainOwnerGranted: true)'),
|
|
453
|
-
(0, type_graphql_1.Query)(returns => figure_history_js_1.FigureHistory, { nullable: true, description: 'The most recently released version of a figure.' }),
|
|
453
|
+
(0, type_graphql_1.Query)(returns => figure_history_js_1.FigureHistory, { nullable: true, description: 'The most recently released version of a figure, or the released version asked for.' }),
|
|
454
454
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
455
455
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
456
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int, { nullable: true, description: 'A released version; omit for the most recent. A linked copy reads the version it came from (ADR-0216 5b, device 3).' })),
|
|
456
457
|
tslib_1.__metadata("design:type", Function),
|
|
457
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
458
|
+
tslib_1.__metadata("design:paramtypes", [String, Object, Number]),
|
|
458
459
|
tslib_1.__metadata("design:returntype", Promise)
|
|
459
460
|
], FigureQuery.prototype, "figureReleased", null);
|
|
460
461
|
tslib_1.__decorate([
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.__setFigureToolDepsForTest = __setFigureToolDepsForTest;
|
|
4
4
|
exports.registerFigureToolCategories = registerFigureToolCategories;
|
|
5
5
|
const capability_module_store_js_1 = require("../capability-module/capability-module-store.js");
|
|
6
|
+
const figure_catalog_of_js_1 = require("../figure-recipe/figure-catalog-of.js");
|
|
6
7
|
/* The domain's choice lists for the guide; none when they cannot be read (a test's repository has no table for them). */
|
|
7
8
|
const capabilityChoicesOf = (domain) => (0, capability_module_store_js_1.chosenCapabilityChoices)({ getRepository: getDeps().getRepository }, domain).catch(() => ({}));
|
|
8
9
|
/*
|
|
@@ -442,7 +443,10 @@ function figureToolSpecs() {
|
|
|
442
443
|
doors: ['Mutation.proposeFigure'],
|
|
443
444
|
description: 'Asks for a proposal: the modeller commands that make a new figure or revise the one open in the modeller. ' +
|
|
444
445
|
'Returns the commands with the score and cost of the figure they make. NOTHING IS SAVED — the author applies ' +
|
|
445
|
-
'the proposal in the modeller as one step, or leaves it. This is the only way a proposal reaches the screen.'
|
|
446
|
+
'the proposal in the modeller as one step, or leaves it. This is the only way a proposal reaches the screen. ' +
|
|
447
|
+
"The writer knows this domain's parts catalog -- ready-made assemblies such as doors, air cylinders and roller rows, " +
|
|
448
|
+
'with their values -- and puts one in whole when the thing asked is one of them; a prompt that designs the parts ' +
|
|
449
|
+
'itself has it build them from parts instead.',
|
|
446
450
|
schema: {
|
|
447
451
|
type: 'object',
|
|
448
452
|
properties: {
|
|
@@ -559,6 +563,8 @@ function figureToolSpecs() {
|
|
|
559
563
|
/* The product capabilities the domain uses (ADR-0172 amendment 1, decision 16). */
|
|
560
564
|
capabilities: ctx?.state?.domain?.id ? [...(await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: getDeps().getRepository }, ctx.state.domain)).values()] : [],
|
|
561
565
|
choices: ctx?.state?.domain?.id ? await capabilityChoicesOf(ctx.state.domain) : {},
|
|
566
|
+
/* The parts catalog the domain reads, put in by put-recipe (ADR-0216 5b, device 5). */
|
|
567
|
+
catalog: ctx?.state?.domain?.id ? await (0, figure_catalog_of_js_1.figureCatalogOf)({ getRepository: getDeps().getRepository }, ctx.state.domain) : [],
|
|
562
568
|
...(images.length ? { images } : {}),
|
|
563
569
|
...(focus && Object.keys(focus).length ? { focus } : {}),
|
|
564
570
|
...(!create && (stringsOf(args?.parts).length || stringsOf(args?.sections).length)
|
|
@@ -20,7 +20,6 @@ export declare class NewFigure {
|
|
|
20
20
|
tags?: string[];
|
|
21
21
|
source: string;
|
|
22
22
|
properties?: string;
|
|
23
|
-
state?: 'draft' | 'released';
|
|
24
23
|
thumbnail?: string;
|
|
25
24
|
namespace?: string;
|
|
26
25
|
}
|
|
@@ -43,6 +42,7 @@ export declare class FigurePatch {
|
|
|
43
42
|
category?: string;
|
|
44
43
|
tags?: string[];
|
|
45
44
|
source?: string;
|
|
45
|
+
expectedSource?: string;
|
|
46
46
|
properties?: string;
|
|
47
47
|
thumbnail?: string;
|
|
48
48
|
}
|
|
@@ -62,10 +62,6 @@ tslib_1.__decorate([
|
|
|
62
62
|
(0, type_graphql_1.Field)({ nullable: true, description: 'JSON definition of the master-data fields an instance carries.' }),
|
|
63
63
|
tslib_1.__metadata("design:type", String)
|
|
64
64
|
], NewFigure.prototype, "properties", void 0);
|
|
65
|
-
tslib_1.__decorate([
|
|
66
|
-
(0, type_graphql_1.Field)({ nullable: true, description: "Lifecycle state — defaults to 'draft'." }),
|
|
67
|
-
tslib_1.__metadata("design:type", String)
|
|
68
|
-
], NewFigure.prototype, "state", void 0);
|
|
69
65
|
tslib_1.__decorate([
|
|
70
66
|
(0, type_graphql_1.Field)({ nullable: true, description: 'A base64 encoded thumbnail image.' }),
|
|
71
67
|
tslib_1.__metadata("design:type", String)
|
|
@@ -119,6 +115,10 @@ tslib_1.__decorate([
|
|
|
119
115
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The new figure asset JSON (figure-asset-1).' }),
|
|
120
116
|
tslib_1.__metadata("design:type", String)
|
|
121
117
|
], FigurePatch.prototype, "source", void 0);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The source the editor read. Required whenever source is supplied; compared atomically before writing.' }),
|
|
120
|
+
tslib_1.__metadata("design:type", String)
|
|
121
|
+
], FigurePatch.prototype, "expectedSource", void 0);
|
|
122
122
|
tslib_1.__decorate([
|
|
123
123
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The new master-data field definition.' }),
|
|
124
124
|
tslib_1.__metadata("design:type", String)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { getRepository } from '@things-factory/shell';
|
|
2
|
+
import type { FigureCatalogEntry } from '../figure/figure-catalog.js';
|
|
3
|
+
export declare function figureCatalogOf(tx: {
|
|
4
|
+
getRepository: typeof getRepository;
|
|
5
|
+
}, domain: {
|
|
6
|
+
id: string;
|
|
7
|
+
parentId?: string | null;
|
|
8
|
+
}): Promise<FigureCatalogEntry[]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.figureCatalogOf = figureCatalogOf;
|
|
4
|
+
/*
|
|
5
|
+
* The parts catalog a domain's AI writer may put in (ADR-0216 5b, device 5): the product's templates and the kept
|
|
6
|
+
* recipes the domain reads (its own and its parent's, and the public ones), as one list -- the catalog the person sees.
|
|
7
|
+
*/
|
|
8
|
+
const figure_model_1 = require("@hatiolab/figure-model");
|
|
9
|
+
const figure_recipe_templates_js_1 = require("./figure-recipe-templates.js");
|
|
10
|
+
const figure_shelf_js_1 = require("./figure-shelf.js");
|
|
11
|
+
async function figureCatalogOf(tx, domain) {
|
|
12
|
+
const product = (0, figure_recipe_templates_js_1.recipeTemplates)().templates.map(t => ({
|
|
13
|
+
key: t.recipe.name,
|
|
14
|
+
title: (0, figure_recipe_templates_js_1.inLanguage)(t.recipe.title, 'en'),
|
|
15
|
+
description: (0, figure_recipe_templates_js_1.inLanguage)(t.recipe.description, 'en'),
|
|
16
|
+
recipe: t.recipe
|
|
17
|
+
}));
|
|
18
|
+
/* A kept row that no longer reads as a recipe is left out, not offered. */
|
|
19
|
+
const kept = (await (0, figure_shelf_js_1.readableShelfRecipes)(domain, tx)).flatMap(row => {
|
|
20
|
+
try {
|
|
21
|
+
return [{ key: row.id, title: row.title ?? '', description: row.description ?? '', recipe: (0, figure_model_1.parseFigureRecipe)(JSON.parse(row.source)) }];
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return [...product, ...kept];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=figure-catalog-of.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { FigureRecipeTemplate } from './figure-recipe-type.js';
|
|
1
|
+
import { FigureRecipeKeep, FigureRecipeTemplate } from './figure-recipe-type.js';
|
|
2
2
|
export declare class FigureRecipeTemplateQuery {
|
|
3
|
-
figureRecipeTemplates(lang: string): FigureRecipeTemplate[]
|
|
3
|
+
figureRecipeTemplates(lang: string, context: ResolverContext): Promise<FigureRecipeTemplate[]>;
|
|
4
|
+
keepFigureRecipe(recipe: FigureRecipeKeep, context: ResolverContext): Promise<FigureRecipeTemplate>;
|
|
5
|
+
removeFigureRecipe(id: string, context: ResolverContext): Promise<boolean>;
|
|
6
|
+
setFigureRecipePublic(id: string, isPublic: boolean, context: ResolverContext): Promise<FigureRecipeTemplate>;
|
|
4
7
|
figureRecipeTemplate(name: string, lang: string): FigureRecipeTemplate | null;
|
|
5
8
|
}
|