@things-factory/figure-service 10.1.298 → 10.1.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.d.ts +12 -2
- package/dist-server/service/figure/figure-context.js +50 -10
- 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 +10 -5
- package/dist-server/service/figure/figure-tools.js +10 -3
- 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 +8 -8
- 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
|
@@ -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
|
/*
|
|
@@ -197,7 +198,7 @@ function sourceForTool(row, host) {
|
|
|
197
198
|
if (typeof draft !== 'object' || Array.isArray(draft))
|
|
198
199
|
throw new Error('the unsaved draft is not a figure asset');
|
|
199
200
|
const serialized = JSON.stringify(draft);
|
|
200
|
-
/* Validity is the save door's (the kernel's
|
|
201
|
+
/* Validity is the save door's (the kernel's 4 MiB); how much the model is shown is `figure-context`'s. */
|
|
201
202
|
try {
|
|
202
203
|
getDeps().parseSource(serialized);
|
|
203
204
|
}
|
|
@@ -282,12 +283,13 @@ const PARTS_ARG = {
|
|
|
282
283
|
function partialRead(source, request) {
|
|
283
284
|
const view = (0, figure_context_js_1.figureViewOf)(source, request);
|
|
284
285
|
if (view.whole)
|
|
285
|
-
return { source };
|
|
286
|
+
return { source: view.source, ...(view.jointNodes ? { jointNodes: view.jointNodes } : {}) };
|
|
286
287
|
return {
|
|
287
288
|
outline: view.outline,
|
|
288
289
|
partSources: view.parts,
|
|
289
290
|
...(Object.keys(view.sections ?? {}).length ? { sectionSources: view.sections } : {}),
|
|
290
291
|
...(view.notRead ? { notRead: view.notRead } : {}),
|
|
292
|
+
...(view.jointNodes ? { jointNodes: view.jointNodes } : {}),
|
|
291
293
|
note: `This figure is too large to read whole (${view.outline.chars} characters; ${figure_context_js_1.FIGURE_CONTEXT_BUDGET} are read at once), so this is its outline, the parts in partSources and the sections in sectionSources. ` +
|
|
292
294
|
'Read what a change touches with parts and sections, then pass the same to proposeFigureCandidate: only parts read in full may be changed, and nothing in a section in outline.omitted that was not read.'
|
|
293
295
|
};
|
|
@@ -441,7 +443,10 @@ function figureToolSpecs() {
|
|
|
441
443
|
doors: ['Mutation.proposeFigure'],
|
|
442
444
|
description: 'Asks for a proposal: the modeller commands that make a new figure or revise the one open in the modeller. ' +
|
|
443
445
|
'Returns the commands with the score and cost of the figure they make. NOTHING IS SAVED — the author applies ' +
|
|
444
|
-
'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.',
|
|
445
450
|
schema: {
|
|
446
451
|
type: 'object',
|
|
447
452
|
properties: {
|
|
@@ -558,6 +563,8 @@ function figureToolSpecs() {
|
|
|
558
563
|
/* The product capabilities the domain uses (ADR-0172 amendment 1, decision 16). */
|
|
559
564
|
capabilities: ctx?.state?.domain?.id ? [...(await (0, capability_module_store_js_1.prepareCapabilityModules)({ getRepository: getDeps().getRepository }, ctx.state.domain)).values()] : [],
|
|
560
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) : [],
|
|
561
568
|
...(images.length ? { images } : {}),
|
|
562
569
|
...(focus && Object.keys(focus).length ? { focus } : {}),
|
|
563
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
|
}
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
|
7
7
|
const figure_recipe_type_js_1 = require("./figure-recipe-type.js");
|
|
8
|
+
const figure_shelf_js_1 = require("./figure-shelf.js");
|
|
8
9
|
const figure_recipe_templates_js_1 = require("./figure-recipe-templates.js");
|
|
9
10
|
const view = (t, lang, withGuide) => ({
|
|
10
11
|
name: t.recipe.name,
|
|
@@ -15,11 +16,49 @@ const view = (t, lang, withGuide) => ({
|
|
|
15
16
|
description: (0, figure_recipe_templates_js_1.inLanguage)(t.recipe.description, lang),
|
|
16
17
|
source: JSON.stringify(t.recipe),
|
|
17
18
|
...(withGuide ? { guide: (0, figure_recipe_templates_js_1.inLanguage)(t.guides, lang) } : {}),
|
|
18
|
-
hasThumbnail: !!t.thumbnail
|
|
19
|
+
hasThumbnail: !!t.thumbnail,
|
|
20
|
+
origin: 'product',
|
|
21
|
+
editable: false,
|
|
22
|
+
...(t.thumbnail ? { thumbnailPath: `/figure-recipe-thumbnail/${encodeURIComponent(t.recipe.name)}` } : {})
|
|
19
23
|
});
|
|
24
|
+
/* A kept recipe on the same shelf (ADR-0216 5b, device 2): where it is from, and whether this domain may change it. */
|
|
25
|
+
const kept = (row, domain) => {
|
|
26
|
+
const recipe = JSON.parse(row.source);
|
|
27
|
+
return {
|
|
28
|
+
name: recipe.name,
|
|
29
|
+
category: row.category ?? '',
|
|
30
|
+
tags: row.tags ?? [],
|
|
31
|
+
target: recipe.target,
|
|
32
|
+
title: row.title,
|
|
33
|
+
description: row.description ?? '',
|
|
34
|
+
source: row.source,
|
|
35
|
+
hasThumbnail: !!row.thumbnailHash,
|
|
36
|
+
origin: row.domain?.id === domain.id || !row.public ? 'domain' : 'public',
|
|
37
|
+
id: row.id,
|
|
38
|
+
editable: row.domain?.id === domain.id,
|
|
39
|
+
public: !!row.public,
|
|
40
|
+
...(row.thumbnailHash ? { thumbnailPath: `/figure-recipe-thumbnail/shelf/${row.id}?v=${row.thumbnailHash.slice(0, 12)}` } : {})
|
|
41
|
+
};
|
|
42
|
+
};
|
|
20
43
|
let FigureRecipeTemplateQuery = class FigureRecipeTemplateQuery {
|
|
21
|
-
figureRecipeTemplates(lang) {
|
|
22
|
-
|
|
44
|
+
async figureRecipeTemplates(lang, context) {
|
|
45
|
+
/* One shelf: the product's templates, then the recipes this domain reads (ADR-0216 5b, device 2). */
|
|
46
|
+
const { domain } = context.state;
|
|
47
|
+
return [...(0, figure_recipe_templates_js_1.recipeTemplates)().templates.map(t => view(t, lang, false)), ...(await (0, figure_shelf_js_1.readableShelfRecipes)(domain)).map(row => kept(row, domain))];
|
|
48
|
+
}
|
|
49
|
+
async keepFigureRecipe(recipe, context) {
|
|
50
|
+
const { domain, user, tx } = context.state;
|
|
51
|
+
const row = await (0, figure_shelf_js_1.keepShelfRecipe)(tx, domain, user, recipe);
|
|
52
|
+
return kept({ ...row, domain }, domain);
|
|
53
|
+
}
|
|
54
|
+
async removeFigureRecipe(id, context) {
|
|
55
|
+
const { domain, tx } = context.state;
|
|
56
|
+
return (0, figure_shelf_js_1.removeShelfRecipe)(tx, domain, id);
|
|
57
|
+
}
|
|
58
|
+
async setFigureRecipePublic(id, isPublic, context) {
|
|
59
|
+
const { domain, tx } = context.state;
|
|
60
|
+
const row = await (0, figure_shelf_js_1.setShelfRecipePublic)(tx, domain, id, isPublic);
|
|
61
|
+
return kept({ ...row, domain }, domain);
|
|
23
62
|
}
|
|
24
63
|
figureRecipeTemplate(name, lang) {
|
|
25
64
|
const t = (0, figure_recipe_templates_js_1.recipeTemplates)().templates.find(one => one.recipe.name === name);
|
|
@@ -31,10 +70,42 @@ tslib_1.__decorate([
|
|
|
31
70
|
(0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "query", domainOwnerGranted: true)'),
|
|
32
71
|
(0, type_graphql_1.Query)(returns => [figure_recipe_type_js_1.FigureRecipeTemplate], { description: 'The recipe templates the product ships, in the language asked. Guides are left out of the list.' }),
|
|
33
72
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('lang', { nullable: true, description: 'The language of the titles (ko, en, …).' })),
|
|
73
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
34
74
|
tslib_1.__metadata("design:type", Function),
|
|
35
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
36
|
-
tslib_1.__metadata("design:returntype",
|
|
75
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
76
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
37
77
|
], FigureRecipeTemplateQuery.prototype, "figureRecipeTemplates", null);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
80
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "mutation", domainOwnerGranted: true)'),
|
|
81
|
+
(0, type_graphql_1.Mutation)(returns => figure_recipe_type_js_1.FigureRecipeTemplate, { description: 'Keeps a recipe made from parts on the shelf, or keeps one of this domain again (ADR-0216 5b, device 2).' }),
|
|
82
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('recipe', type => figure_recipe_type_js_1.FigureRecipeKeep)),
|
|
83
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
84
|
+
tslib_1.__metadata("design:type", Function),
|
|
85
|
+
tslib_1.__metadata("design:paramtypes", [figure_recipe_type_js_1.FigureRecipeKeep, Object]),
|
|
86
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
87
|
+
], FigureRecipeTemplateQuery.prototype, "keepFigureRecipe", null);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
90
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "mutation", domainOwnerGranted: true)'),
|
|
91
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Removes a recipe this domain kept.' }),
|
|
92
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
93
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
94
|
+
tslib_1.__metadata("design:type", Function),
|
|
95
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
96
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
97
|
+
], FigureRecipeTemplateQuery.prototype, "removeFigureRecipe", null);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
100
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-release", privilege: "mutation", domainOwnerGranted: true)'),
|
|
101
|
+
(0, type_graphql_1.Mutation)(returns => figure_recipe_type_js_1.FigureRecipeTemplate, { description: 'Makes a recipe this domain kept public to every domain, or its own again.' }),
|
|
102
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
103
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('public')),
|
|
104
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
105
|
+
tslib_1.__metadata("design:type", Function),
|
|
106
|
+
tslib_1.__metadata("design:paramtypes", [String, Boolean, Object]),
|
|
107
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
108
|
+
], FigureRecipeTemplateQuery.prototype, "setFigureRecipePublic", null);
|
|
38
109
|
tslib_1.__decorate([
|
|
39
110
|
(0, type_graphql_1.Directive)('@privilege(category: "figure", privilege: "query", domainOwnerGranted: true)'),
|
|
40
111
|
(0, type_graphql_1.Query)(returns => figure_recipe_type_js_1.FigureRecipeTemplate, { nullable: true, description: 'One recipe template with its guide, in the language asked.' }),
|
|
@@ -8,4 +8,18 @@ export declare class FigureRecipeTemplate {
|
|
|
8
8
|
source: string;
|
|
9
9
|
guide?: string;
|
|
10
10
|
hasThumbnail: boolean;
|
|
11
|
+
origin: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
editable: boolean;
|
|
14
|
+
public?: boolean;
|
|
15
|
+
thumbnailPath?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class FigureRecipeKeep {
|
|
18
|
+
id?: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
category?: string;
|
|
22
|
+
tags?: string[];
|
|
23
|
+
source: string;
|
|
24
|
+
thumbnail?: string;
|
|
11
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FigureRecipeTemplate = void 0;
|
|
3
|
+
exports.FigureRecipeKeep = exports.FigureRecipeTemplate = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
let FigureRecipeTemplate = class FigureRecipeTemplate {
|
|
@@ -42,7 +42,61 @@ tslib_1.__decorate([
|
|
|
42
42
|
(0, type_graphql_1.Field)({ description: 'Whether it has a thumbnail image.' }),
|
|
43
43
|
tslib_1.__metadata("design:type", Boolean)
|
|
44
44
|
], FigureRecipeTemplate.prototype, "hasThumbnail", void 0);
|
|
45
|
+
tslib_1.__decorate([
|
|
46
|
+
(0, type_graphql_1.Field)({ description: "Where it is from: 'product' (shipped with the code), 'domain' (kept by this domain or its parent), or 'public' (kept by another domain and made public)." }),
|
|
47
|
+
tslib_1.__metadata("design:type", String)
|
|
48
|
+
], FigureRecipeTemplate.prototype, "origin", void 0);
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The kept recipe id; none for the templates the product ships.' }),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
52
|
+
], FigureRecipeTemplate.prototype, "id", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, type_graphql_1.Field)({ description: 'Whether this domain may change or remove it: only a recipe it kept.' }),
|
|
55
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
56
|
+
], FigureRecipeTemplate.prototype, "editable", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Whether a kept recipe is public to every domain.' }),
|
|
59
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
60
|
+
], FigureRecipeTemplate.prototype, "public", void 0);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Where its card picture is read from, behind the figure query permission.' }),
|
|
63
|
+
tslib_1.__metadata("design:type", String)
|
|
64
|
+
], FigureRecipeTemplate.prototype, "thumbnailPath", void 0);
|
|
45
65
|
exports.FigureRecipeTemplate = FigureRecipeTemplate = tslib_1.__decorate([
|
|
46
66
|
(0, type_graphql_1.ObjectType)({ description: 'A recipe template the product ships: parts, their fastenings and motion, put onto a part in one step (ADR-0095).' })
|
|
47
67
|
], FigureRecipeTemplate);
|
|
68
|
+
let FigureRecipeKeep = class FigureRecipeKeep {
|
|
69
|
+
};
|
|
70
|
+
exports.FigureRecipeKeep = FigureRecipeKeep;
|
|
71
|
+
tslib_1.__decorate([
|
|
72
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The kept recipe to keep again (its parts, title, values); none to keep a new one.' }),
|
|
73
|
+
tslib_1.__metadata("design:type", String)
|
|
74
|
+
], FigureRecipeKeep.prototype, "id", void 0);
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, type_graphql_1.Field)({ description: 'Its title, in the words of the person keeping it.' }),
|
|
77
|
+
tslib_1.__metadata("design:type", String)
|
|
78
|
+
], FigureRecipeKeep.prototype, "title", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'One line on what it is.' }),
|
|
81
|
+
tslib_1.__metadata("design:type", String)
|
|
82
|
+
], FigureRecipeKeep.prototype, "description", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The category it is listed under.' }),
|
|
85
|
+
tslib_1.__metadata("design:type", String)
|
|
86
|
+
], FigureRecipeKeep.prototype, "category", void 0);
|
|
87
|
+
tslib_1.__decorate([
|
|
88
|
+
(0, type_graphql_1.Field)(type => [String], { nullable: true, description: 'Words it is found by.' }),
|
|
89
|
+
tslib_1.__metadata("design:type", Array)
|
|
90
|
+
], FigureRecipeKeep.prototype, "tags", void 0);
|
|
91
|
+
tslib_1.__decorate([
|
|
92
|
+
(0, type_graphql_1.Field)({ description: 'The recipe JSON (figure-model FigureRecipe).' }),
|
|
93
|
+
tslib_1.__metadata("design:type", String)
|
|
94
|
+
], FigureRecipeKeep.prototype, "source", void 0);
|
|
95
|
+
tslib_1.__decorate([
|
|
96
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Its card picture, as a data URL.' }),
|
|
97
|
+
tslib_1.__metadata("design:type", String)
|
|
98
|
+
], FigureRecipeKeep.prototype, "thumbnail", void 0);
|
|
99
|
+
exports.FigureRecipeKeep = FigureRecipeKeep = tslib_1.__decorate([
|
|
100
|
+
(0, type_graphql_1.InputType)({ description: 'A recipe a person keeps from parts (ADR-0216 5b, device 2).' })
|
|
101
|
+
], FigureRecipeKeep);
|
|
48
102
|
//# sourceMappingURL=figure-recipe-type.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Domain } from '@things-factory/shell';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
/**
|
|
4
|
+
* A recipe a person kept from parts (ADR-0216 5b, device 2), on the same shelf as the product's templates (the parts
|
|
5
|
+
* catalog). It belongs to the domain that kept it and is read by the figure rule: that domain and its parent, and every
|
|
6
|
+
* domain when it is public; only its domain changes or removes it. Its parts are changed by keeping it again.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FigureShelfRecipe {
|
|
9
|
+
readonly id?: string;
|
|
10
|
+
domain?: Domain;
|
|
11
|
+
domainId?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
source?: string;
|
|
17
|
+
thumbnailHash?: string;
|
|
18
|
+
public?: boolean;
|
|
19
|
+
creator?: User;
|
|
20
|
+
creatorId?: string;
|
|
21
|
+
updater?: User;
|
|
22
|
+
updaterId?: string;
|
|
23
|
+
createdAt?: Date;
|
|
24
|
+
updatedAt?: Date;
|
|
25
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FigureShelfRecipe = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
/**
|
|
10
|
+
* A recipe a person kept from parts (ADR-0216 5b, device 2), on the same shelf as the product's templates (the parts
|
|
11
|
+
* catalog). It belongs to the domain that kept it and is read by the figure rule: that domain and its parent, and every
|
|
12
|
+
* domain when it is public; only its domain changes or removes it. Its parts are changed by keeping it again.
|
|
13
|
+
*/
|
|
14
|
+
let FigureShelfRecipe = class FigureShelfRecipe {
|
|
15
|
+
};
|
|
16
|
+
exports.FigureShelfRecipe = FigureShelfRecipe;
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
19
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the kept recipe.' }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], FigureShelfRecipe.prototype, "id", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
24
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain that kept it.' }),
|
|
25
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
26
|
+
], FigureShelfRecipe.prototype, "domain", void 0);
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
(0, typeorm_1.RelationId)((recipe) => recipe.domain),
|
|
29
|
+
tslib_1.__metadata("design:type", String)
|
|
30
|
+
], FigureShelfRecipe.prototype, "domainId", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, typeorm_1.Column)(),
|
|
33
|
+
(0, type_graphql_1.Field)({ description: 'Its title, in the words of the person who kept it.' }),
|
|
34
|
+
tslib_1.__metadata("design:type", String)
|
|
35
|
+
], FigureShelfRecipe.prototype, "title", void 0);
|
|
36
|
+
tslib_1.__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
38
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'One line on what it is.' }),
|
|
39
|
+
tslib_1.__metadata("design:type", String)
|
|
40
|
+
], FigureShelfRecipe.prototype, "description", void 0);
|
|
41
|
+
tslib_1.__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
43
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The category it is listed under (door, conveyor, …).' }),
|
|
44
|
+
tslib_1.__metadata("design:type", String)
|
|
45
|
+
], FigureShelfRecipe.prototype, "category", void 0);
|
|
46
|
+
tslib_1.__decorate([
|
|
47
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
48
|
+
(0, type_graphql_1.Field)(type => [String], { nullable: true, description: 'Words it is found by.' }),
|
|
49
|
+
tslib_1.__metadata("design:type", Array)
|
|
50
|
+
], FigureShelfRecipe.prototype, "tags", void 0);
|
|
51
|
+
tslib_1.__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ nullable: true, ...(0, shell_1.longTextColumn)() }),
|
|
53
|
+
(0, type_graphql_1.Field)({ description: 'The recipe JSON (figure-model FigureRecipe), as the modeller applies it.' }),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], FigureShelfRecipe.prototype, "source", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
58
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The hash of its card picture, kept as figures keep theirs.' }),
|
|
59
|
+
tslib_1.__metadata("design:type", String)
|
|
60
|
+
], FigureShelfRecipe.prototype, "thumbnailHash", void 0);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({ nullable: true, default: false }),
|
|
63
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Public: every domain reads it and puts it in. Only its domain changes it.' }),
|
|
64
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
65
|
+
], FigureShelfRecipe.prototype, "public", void 0);
|
|
66
|
+
tslib_1.__decorate([
|
|
67
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
68
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who first kept it.' }),
|
|
69
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
70
|
+
], FigureShelfRecipe.prototype, "creator", void 0);
|
|
71
|
+
tslib_1.__decorate([
|
|
72
|
+
(0, typeorm_1.RelationId)((recipe) => recipe.creator),
|
|
73
|
+
tslib_1.__metadata("design:type", String)
|
|
74
|
+
], FigureShelfRecipe.prototype, "creatorId", void 0);
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
77
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last kept or changed it.' }),
|
|
78
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
79
|
+
], FigureShelfRecipe.prototype, "updater", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, typeorm_1.RelationId)((recipe) => recipe.updater),
|
|
82
|
+
tslib_1.__metadata("design:type", String)
|
|
83
|
+
], FigureShelfRecipe.prototype, "updaterId", void 0);
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
86
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was first kept.' }),
|
|
87
|
+
tslib_1.__metadata("design:type", Date)
|
|
88
|
+
], FigureShelfRecipe.prototype, "createdAt", void 0);
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
91
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was last kept or changed.' }),
|
|
92
|
+
tslib_1.__metadata("design:type", Date)
|
|
93
|
+
], FigureShelfRecipe.prototype, "updatedAt", void 0);
|
|
94
|
+
exports.FigureShelfRecipe = FigureShelfRecipe = tslib_1.__decorate([
|
|
95
|
+
(0, typeorm_1.Entity)('figure_shelf_recipes'),
|
|
96
|
+
(0, typeorm_1.Index)('ix_figure_shelf_recipe_0', (recipe) => [recipe.domain]),
|
|
97
|
+
(0, type_graphql_1.ObjectType)({ description: 'A recipe a person kept from parts, on the shelf beside the templates the product ships.' })
|
|
98
|
+
], FigureShelfRecipe);
|
|
99
|
+
//# sourceMappingURL=figure-shelf-recipe.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getRepository } from '@things-factory/shell';
|
|
2
|
+
import { FigureShelfRecipe } from './figure-shelf-recipe.js';
|
|
3
|
+
type Reader = {
|
|
4
|
+
id: string;
|
|
5
|
+
parentId?: string | null;
|
|
6
|
+
};
|
|
7
|
+
type Tx = {
|
|
8
|
+
getRepository: typeof getRepository;
|
|
9
|
+
};
|
|
10
|
+
/** What a person gives when keeping a recipe. */
|
|
11
|
+
export interface ShelfRecipeInput {
|
|
12
|
+
id?: string;
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
category?: string;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
source: string;
|
|
18
|
+
thumbnail?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The kept recipes a domain reads: its own and its parent's, and any domain's public ones. */
|
|
21
|
+
export declare function readableShelfRecipes(domain: Reader, tx?: Tx): Promise<FigureShelfRecipe[]>;
|
|
22
|
+
/** One kept recipe the domain reads, or none. */
|
|
23
|
+
export declare function readableShelfRecipe(domain: Reader, id: string): Promise<FigureShelfRecipe | null>;
|
|
24
|
+
export declare function keepShelfRecipe(tx: Tx, domain: Reader, user: unknown, input: ShelfRecipeInput): Promise<FigureShelfRecipe>;
|
|
25
|
+
export declare function removeShelfRecipe(tx: Tx, domain: Reader, id: string): Promise<boolean>;
|
|
26
|
+
export declare function setShelfRecipePublic(tx: Tx, domain: Reader, id: string, isPublic: boolean): Promise<FigureShelfRecipe>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readableShelfRecipes = readableShelfRecipes;
|
|
4
|
+
exports.readableShelfRecipe = readableShelfRecipe;
|
|
5
|
+
exports.keepShelfRecipe = keepShelfRecipe;
|
|
6
|
+
exports.removeShelfRecipe = removeShelfRecipe;
|
|
7
|
+
exports.setShelfRecipePublic = setShelfRecipePublic;
|
|
8
|
+
/*
|
|
9
|
+
* A person's recipes on the shelf (ADR-0216 5b, device 2): kept, read, changed and removed by the figure rule -- its
|
|
10
|
+
* domain and that domain's parent read it, every domain when it is public, and only its domain writes it.
|
|
11
|
+
*/
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
13
|
+
const figure_model_1 = require("@hatiolab/figure-model");
|
|
14
|
+
const figure_shelf_recipe_js_1 = require("./figure-shelf-recipe.js");
|
|
15
|
+
const figure_public_js_1 = require("../figure/figure-public.js");
|
|
16
|
+
const figure_thumbnail_store_js_1 = require("../figure/figure-thumbnail-store.js");
|
|
17
|
+
/** The kept recipes a domain reads: its own and its parent's, and any domain's public ones. */
|
|
18
|
+
async function readableShelfRecipes(domain, tx = { getRepository: shell_1.getRepository }) {
|
|
19
|
+
const rows = await tx.getRepository(figure_shelf_recipe_js_1.FigureShelfRecipe).find({
|
|
20
|
+
where: [{ domain: { id: (0, figure_public_js_1.ownScope)(domain) } }, { public: true }],
|
|
21
|
+
relations: ['domain'],
|
|
22
|
+
order: { updatedAt: 'DESC' }
|
|
23
|
+
});
|
|
24
|
+
return [...new Map(rows.map(r => [r.id, r])).values()];
|
|
25
|
+
}
|
|
26
|
+
/** One kept recipe the domain reads, or none. */
|
|
27
|
+
async function readableShelfRecipe(domain, id) {
|
|
28
|
+
return (0, shell_1.getRepository)(figure_shelf_recipe_js_1.FigureShelfRecipe).findOne({ where: [{ domain: { id: (0, figure_public_js_1.ownScope)(domain) }, id }, { public: true, id }], relations: ['domain'] });
|
|
29
|
+
}
|
|
30
|
+
/** A kept recipe its own domain changes: refused for any other, the parent's included. */
|
|
31
|
+
async function ownShelfRecipe(tx, domain, id) {
|
|
32
|
+
const row = await tx.getRepository(figure_shelf_recipe_js_1.FigureShelfRecipe).findOne({ where: { id }, relations: ['domain'] });
|
|
33
|
+
if (!row)
|
|
34
|
+
throw new shell_1.Refusal('figure-recipe-absent', { id }, 'There is no kept recipe {id}.');
|
|
35
|
+
if (row.domain?.id !== domain.id)
|
|
36
|
+
throw new shell_1.Refusal('figure-recipe-not-own', { title: row.title ?? id }, '{title} is kept by another domain: only it changes or removes it.');
|
|
37
|
+
return row;
|
|
38
|
+
}
|
|
39
|
+
async function keepShelfRecipe(tx, domain, user, input) {
|
|
40
|
+
const title = input.title?.trim();
|
|
41
|
+
if (!title)
|
|
42
|
+
throw new shell_1.Refusal('figure-recipe-title', {}, 'A kept recipe has a title.');
|
|
43
|
+
let recipe;
|
|
44
|
+
try {
|
|
45
|
+
recipe = (0, figure_model_1.parseFigureRecipe)(JSON.parse(input.source));
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
throw new shell_1.Refusal('figure-recipe-source', { reason: String(e.message ?? e) }, 'The recipe cannot be read: {reason}');
|
|
49
|
+
}
|
|
50
|
+
const repository = tx.getRepository(figure_shelf_recipe_js_1.FigureShelfRecipe);
|
|
51
|
+
const row = input.id ? await ownShelfRecipe(tx, domain, input.id) : repository.create({ domain: domain, creator: user });
|
|
52
|
+
row.title = title;
|
|
53
|
+
row.description = input.description?.trim() || undefined;
|
|
54
|
+
row.category = input.category?.trim() || undefined;
|
|
55
|
+
row.tags = input.tags ?? [];
|
|
56
|
+
row.source = JSON.stringify(recipe);
|
|
57
|
+
row.updater = user;
|
|
58
|
+
if (input.thumbnail)
|
|
59
|
+
row.thumbnailHash = await (0, figure_thumbnail_store_js_1.keepThumbnail)(tx, domain, user, input.thumbnail);
|
|
60
|
+
return repository.save(row);
|
|
61
|
+
}
|
|
62
|
+
async function removeShelfRecipe(tx, domain, id) {
|
|
63
|
+
const row = await ownShelfRecipe(tx, domain, id);
|
|
64
|
+
await tx.getRepository(figure_shelf_recipe_js_1.FigureShelfRecipe).delete({ id: row.id });
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
async function setShelfRecipePublic(tx, domain, id, isPublic) {
|
|
68
|
+
const row = await ownShelfRecipe(tx, domain, id);
|
|
69
|
+
row.public = isPublic;
|
|
70
|
+
return tx.getRepository(figure_shelf_recipe_js_1.FigureShelfRecipe).save(row);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=figure-shelf.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvers = void 0;
|
|
3
|
+
exports.entities = exports.resolvers = void 0;
|
|
4
4
|
const figure_recipe_resolver_js_1 = require("./figure-recipe-resolver.js");
|
|
5
|
+
const figure_shelf_recipe_js_1 = require("./figure-shelf-recipe.js");
|
|
5
6
|
exports.resolvers = [figure_recipe_resolver_js_1.FigureRecipeTemplateQuery];
|
|
7
|
+
exports.entities = [figure_shelf_recipe_js_1.FigureShelfRecipe];
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,12 +4,14 @@ export * from './figure/figure-format.js';
|
|
|
4
4
|
export * from './figure/figure-history.js';
|
|
5
5
|
export * from './figure-recipe/figure-recipe-type.js';
|
|
6
6
|
export { recipeTemplates, inLanguage, RECIPE_DIR } from './figure-recipe/figure-recipe-templates.js';
|
|
7
|
+
export { FigureShelfRecipe } from './figure-recipe/figure-shelf-recipe.js';
|
|
8
|
+
export { readableShelfRecipe, readableShelfRecipes } from './figure-recipe/figure-shelf.js';
|
|
7
9
|
import { FigureInstallKeyResolver } from './install-key/figure-install-key.js';
|
|
8
10
|
import { FigureCapabilityUse } from './capability-module/capability-module-entity.js';
|
|
9
11
|
import { FigureCapabilityModuleResolver } from './capability-module/capability-module-resolver.js';
|
|
10
12
|
import './capability-module/capability-release-check.js';
|
|
11
13
|
export * from './install-key/figure-install-key.js';
|
|
12
|
-
export declare const entities: (typeof import("./figure/figure.js").Figure | typeof import("./figure/figure-history.js").FigureHistory | typeof FigureCapabilityUse | typeof import("./figure/figure-replaced-draft.js").FigureReplacedDraft | typeof import("./figure/figure-proposal-record.js").FigureProposalRecord | typeof import("./figure/figure-namespace-entity.js").FigureNamespace)[];
|
|
14
|
+
export declare const entities: (typeof import("./figure/figure.js").Figure | typeof import("./figure-recipe/figure-shelf-recipe.js").FigureShelfRecipe | typeof import("./figure/figure-history.js").FigureHistory | typeof FigureCapabilityUse | typeof import("./figure/figure-replaced-draft.js").FigureReplacedDraft | typeof import("./figure/figure-proposal-record.js").FigureProposalRecord | typeof import("./figure/figure-namespace-entity.js").FigureNamespace)[];
|
|
13
15
|
export declare const subscribers: typeof import("./figure/event-subscriber.js").FigureHistoryEntitySubscriber[];
|
|
14
16
|
export declare const schema: {
|
|
15
17
|
resolverClasses: (typeof import("./figure/figure-query.js").FigureQuery | typeof import("./figure/figure-mutation.js").FigureMutation | typeof import("./figure/figure-namespace-resolver.js").FigureNamespaceResolver | typeof import("./figure-recipe/figure-recipe-resolver.js").FigureRecipeTemplateQuery | typeof FigureInstallKeyResolver | typeof FigureCapabilityModuleResolver)[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capabilityFindings = exports.registerCapabilityModule = exports.prepareCapabilityModules = exports.chosenModules = exports.chosenCapabilityChoices = exports.schema = exports.subscribers = exports.entities = exports.RECIPE_DIR = exports.inLanguage = exports.recipeTemplates = void 0;
|
|
3
|
+
exports.capabilityFindings = exports.registerCapabilityModule = exports.prepareCapabilityModules = exports.chosenModules = exports.chosenCapabilityChoices = exports.schema = exports.subscribers = exports.entities = exports.readableShelfRecipes = exports.readableShelfRecipe = exports.FigureShelfRecipe = exports.RECIPE_DIR = exports.inLanguage = exports.recipeTemplates = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// Entity types
|
|
6
6
|
tslib_1.__exportStar(require("./figure/figure.js"), exports);
|
|
@@ -12,6 +12,11 @@ var figure_recipe_templates_js_1 = require("./figure-recipe/figure-recipe-templa
|
|
|
12
12
|
Object.defineProperty(exports, "recipeTemplates", { enumerable: true, get: function () { return figure_recipe_templates_js_1.recipeTemplates; } });
|
|
13
13
|
Object.defineProperty(exports, "inLanguage", { enumerable: true, get: function () { return figure_recipe_templates_js_1.inLanguage; } });
|
|
14
14
|
Object.defineProperty(exports, "RECIPE_DIR", { enumerable: true, get: function () { return figure_recipe_templates_js_1.RECIPE_DIR; } });
|
|
15
|
+
var figure_shelf_recipe_js_1 = require("./figure-recipe/figure-shelf-recipe.js");
|
|
16
|
+
Object.defineProperty(exports, "FigureShelfRecipe", { enumerable: true, get: function () { return figure_shelf_recipe_js_1.FigureShelfRecipe; } });
|
|
17
|
+
var figure_shelf_js_1 = require("./figure-recipe/figure-shelf.js");
|
|
18
|
+
Object.defineProperty(exports, "readableShelfRecipe", { enumerable: true, get: function () { return figure_shelf_js_1.readableShelfRecipe; } });
|
|
19
|
+
Object.defineProperty(exports, "readableShelfRecipes", { enumerable: true, get: function () { return figure_shelf_js_1.readableShelfRecipes; } });
|
|
15
20
|
// Entities, resolvers
|
|
16
21
|
const index_js_1 = require("./figure/index.js");
|
|
17
22
|
const index_js_2 = require("./figure-recipe/index.js");
|
|
@@ -21,7 +26,7 @@ const capability_module_resolver_js_1 = require("./capability-module/capability-
|
|
|
21
26
|
/* Registers the release door's capability check (ADR-0172 decision 9). */
|
|
22
27
|
require("./capability-module/capability-release-check.js");
|
|
23
28
|
tslib_1.__exportStar(require("./install-key/figure-install-key.js"), exports);
|
|
24
|
-
exports.entities = [...index_js_1.entities, capability_module_entity_js_1.FigureCapabilityModule, capability_module_entity_js_1.FigureCapabilityUse, capability_module_entity_js_1.FigureInstallKeyCapability, capability_module_entity_js_1.FigureCapabilityChoiceLists];
|
|
29
|
+
exports.entities = [...index_js_1.entities, ...index_js_2.entities, capability_module_entity_js_1.FigureCapabilityModule, capability_module_entity_js_1.FigureCapabilityUse, capability_module_entity_js_1.FigureInstallKeyCapability, capability_module_entity_js_1.FigureCapabilityChoiceLists];
|
|
25
30
|
/* 버전 스냅샷을 뜨는 구독자. 셸이 이 이름으로 모아 TypeORM 에 등록한다(board-service 와 같다). */
|
|
26
31
|
exports.subscribers = [...index_js_1.subscribers];
|
|
27
32
|
/*
|