@things-factory/figure-service 10.1.297 → 10.1.300
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.
|
@@ -53,6 +53,8 @@ export interface FigureReadRequest {
|
|
|
53
53
|
}
|
|
54
54
|
export interface FigureView {
|
|
55
55
|
whole: boolean;
|
|
56
|
+
/** Said when the joints' nodes were left out of what is shown (ADR-0215 decision 4); counted in the budget. */
|
|
57
|
+
jointNodes?: string;
|
|
56
58
|
/** Whole: the source as it is. */
|
|
57
59
|
source?: FigureAsset;
|
|
58
60
|
outline?: FigureOutline;
|
|
@@ -86,11 +88,19 @@ export declare function figurePartReadOf(asset: FigureAsset, part: string): Figu
|
|
|
86
88
|
* budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.
|
|
87
89
|
*/
|
|
88
90
|
export declare function figureOutlineOf(asset: FigureAsset, chars?: number): FigureOutline;
|
|
91
|
+
/**
|
|
92
|
+
* The figure as the model is shown it: without the nodes its joints own (figure-model ADR-0215 decision 4). The kernel
|
|
93
|
+
* writes them from the joint records on every edit, so a step never names them; left in, they were a third of a figure's
|
|
94
|
+
* text and crowded out what a change reads. Every view and every judgment of a proposal against a view is made on this,
|
|
95
|
+
* so a section's pointer means the same in both.
|
|
96
|
+
*/
|
|
97
|
+
export declare const JOINT_NODES_LEFT_OUT = "The nodes each joint writes from its record (<part>.on.*, its row, seat, chain and motion) are left out: the kernel writes them again on every edit. Change a fastening through its joint record.";
|
|
98
|
+
export declare function figureShownOf(asset: FigureAsset): FigureAsset;
|
|
89
99
|
/**
|
|
90
100
|
* The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then
|
|
91
101
|
* sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.
|
|
92
102
|
*/
|
|
93
|
-
export declare function figureViewOf(
|
|
103
|
+
export declare function figureViewOf(given: FigureAsset, request?: FigureReadRequest): FigureView;
|
|
94
104
|
/**
|
|
95
105
|
* The steps that change a part of the base not shown in full, as reasons said back to the writer. A part may still be
|
|
96
106
|
* named to fasten to or to follow -- the kernel works from it, nothing about it is guessed -- and a new part is the
|
|
@@ -102,5 +112,5 @@ export declare function unreadPartEdits(base: FigureAsset, steps: readonly Figur
|
|
|
102
112
|
* on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a
|
|
103
113
|
* record in a list, a key in a map -- is the steps' own.
|
|
104
114
|
*/
|
|
105
|
-
export declare function unreadSectionEdits(
|
|
115
|
+
export declare function unreadSectionEdits(givenBase: FigureAsset, givenAfter: FigureAsset, view: FigureView): string[];
|
|
106
116
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FIGURE_CONTEXT_BUDGET = void 0;
|
|
3
|
+
exports.JOINT_NODES_LEFT_OUT = exports.FIGURE_CONTEXT_BUDGET = void 0;
|
|
4
4
|
exports.figurePartReadOf = figurePartReadOf;
|
|
5
5
|
exports.figureOutlineOf = figureOutlineOf;
|
|
6
|
+
exports.figureShownOf = figureShownOf;
|
|
6
7
|
exports.figureViewOf = figureViewOf;
|
|
7
8
|
exports.unreadPartEdits = unreadPartEdits;
|
|
8
9
|
exports.unreadSectionEdits = unreadSectionEdits;
|
|
9
10
|
/**
|
|
10
11
|
* What of a figure the model is shown (ADR-0061 2026-10-16 decision 4).
|
|
11
12
|
*
|
|
12
|
-
* The kernel keeps a figure up to
|
|
13
|
+
* The kernel keeps a figure up to 4 MiB (`FIGURE_JSON_MAX_BYTES`); that is whether the figure is valid. How much of it the
|
|
13
14
|
* model reads at once is another question with its own number. A figure that fits is shown whole. One that does not is
|
|
14
15
|
* shown as an outline -- its sections, and every part by name, shape and what it is fastened to -- and in full only the
|
|
15
16
|
* parts and sections asked for, while they fit. A section too large for the outline is left out, named by its JSON
|
|
@@ -31,6 +32,12 @@ exports.FIGURE_CONTEXT_BUDGET = 100_000;
|
|
|
31
32
|
const OUTLINE_SHARE = exports.FIGURE_CONTEXT_BUDGET / 2;
|
|
32
33
|
/** How many entries of a section left out, or pointers in a reason, are named: the largest first. */
|
|
33
34
|
const ENTRIES_NAMED = 20;
|
|
35
|
+
/*
|
|
36
|
+
Room kept, while parts and sections are added, for saying what was not read: a view filled to the last character had
|
|
37
|
+
none left, and the parts it could not show went unsaid (2026-11-19, once a part without its joints' nodes was small
|
|
38
|
+
enough to fill it exactly).
|
|
39
|
+
*/
|
|
40
|
+
const REASON_ROOM = 400;
|
|
34
41
|
const length = (value) => JSON.stringify(value)?.length ?? 0;
|
|
35
42
|
const under = (part) => (id) => id === part || (typeof id === 'string' && id.startsWith(`${part}.`));
|
|
36
43
|
/* ── JSON Pointer (RFC 6901) ─────────────────────────────────────────────────────────── */
|
|
@@ -138,7 +145,7 @@ function place(outline, tokens, value) {
|
|
|
138
145
|
* What the view wraps the outline in, read or not: an outline that took the whole budget left the view over it by these
|
|
139
146
|
* (53 characters, a figure of 3000 long-named parts, 2026-10-19).
|
|
140
147
|
*/
|
|
141
|
-
const VIEW_ENVELOPE = () => length({ whole: false, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({});
|
|
148
|
+
const VIEW_ENVELOPE = () => length({ whole: false, jointNodes: exports.JOINT_NODES_LEFT_OUT, outline: {}, parts: {}, shown: [], sections: {}, notRead: [] }) - length({});
|
|
142
149
|
/**
|
|
143
150
|
* The outline: within OUTLINE_SHARE for its sections, the largest left out first; and, every field counted, within the
|
|
144
151
|
* budget less what the view wraps it in -- a figure of very many parts lists them by id only, then as many as fit.
|
|
@@ -195,20 +202,40 @@ function pipesOf(asset) {
|
|
|
195
202
|
return swept ? (0, figure_model_1.figurePipesOf)(asset) : {};
|
|
196
203
|
}
|
|
197
204
|
/* ── The view ────────────────────────────────────────────────────────────────────────── */
|
|
205
|
+
/**
|
|
206
|
+
* The figure as the model is shown it: without the nodes its joints own (figure-model ADR-0215 decision 4). The kernel
|
|
207
|
+
* writes them from the joint records on every edit, so a step never names them; left in, they were a third of a figure's
|
|
208
|
+
* text and crowded out what a change reads. Every view and every judgment of a proposal against a view is made on this,
|
|
209
|
+
* so a section's pointer means the same in both.
|
|
210
|
+
*/
|
|
211
|
+
exports.JOINT_NODES_LEFT_OUT = 'The nodes each joint writes from its record (<part>.on.*, its row, seat, chain and motion) are left out: the kernel writes them again on every edit. Change a fastening through its joint record.';
|
|
212
|
+
function figureShownOf(asset) {
|
|
213
|
+
const parts = (asset.joints ?? []).map((j) => j.body1?.part).filter((p) => typeof p === 'string');
|
|
214
|
+
if (!parts.length)
|
|
215
|
+
return asset;
|
|
216
|
+
const model = asset.document.model;
|
|
217
|
+
const nodes = model.nodes.filter(n => !parts.some((p) => (0, figure_model_1.figureJointNodeOf)(p, n.id)));
|
|
218
|
+
if (nodes.length === model.nodes.length)
|
|
219
|
+
return asset;
|
|
220
|
+
return { ...asset, document: { ...asset.document, model: { ...model, nodes } } };
|
|
221
|
+
}
|
|
198
222
|
/**
|
|
199
223
|
* The view of a figure the model is shown: whole when it fits, else the outline and what was asked for -- parts, then
|
|
200
224
|
* sections, each in the order asked -- while it fits beside it. Every field counted, the view is within the budget.
|
|
201
225
|
*/
|
|
202
|
-
function figureViewOf(
|
|
226
|
+
function figureViewOf(given, request = {}) {
|
|
227
|
+
const asset = figureShownOf(given);
|
|
228
|
+
const said = asset !== given ? { jointNodes: exports.JOINT_NODES_LEFT_OUT } : {};
|
|
203
229
|
const chars = length(asset);
|
|
204
|
-
|
|
230
|
+
/* Read from the figure itself: a pipe's reading compiles it, and that needs the joints' nodes. */
|
|
231
|
+
const pipes = pipesOf(given);
|
|
205
232
|
if (chars <= exports.FIGURE_CONTEXT_BUDGET) {
|
|
206
|
-
const whole = { whole: true, source: asset, ...(Object.keys(pipes).length ? { pipes } : {}), palette: { tokens: Object.keys(asset.palette ?? {}) } };
|
|
233
|
+
const whole = { whole: true, ...said, source: asset, ...(Object.keys(pipes).length ? { pipes } : {}), palette: { tokens: Object.keys(asset.palette ?? {}) } };
|
|
207
234
|
if (length(whole) <= exports.FIGURE_CONTEXT_BUDGET)
|
|
208
235
|
return whole;
|
|
209
236
|
}
|
|
210
237
|
const outline = figureOutlineOf(asset, chars);
|
|
211
|
-
const view = { whole: false, outline, parts: {}, shown: [], sections: {}, pipes: {}, notRead: [] };
|
|
238
|
+
const view = { whole: false, ...said, outline, parts: {}, shown: [], sections: {}, pipes: {}, notRead: [] };
|
|
212
239
|
const room = () => exports.FIGURE_CONTEXT_BUDGET - length(view);
|
|
213
240
|
const refuse = (one) => {
|
|
214
241
|
if (length(one) + 1 <= room())
|
|
@@ -227,7 +254,7 @@ function figureViewOf(asset, request = {}) {
|
|
|
227
254
|
view.shown.push(part);
|
|
228
255
|
if (pipe)
|
|
229
256
|
view.pipes[part] = pipe;
|
|
230
|
-
if (room() >=
|
|
257
|
+
if (room() >= REASON_ROOM)
|
|
231
258
|
continue;
|
|
232
259
|
delete view.parts[part];
|
|
233
260
|
delete view.pipes[part];
|
|
@@ -254,7 +281,7 @@ function figureViewOf(asset, request = {}) {
|
|
|
254
281
|
}
|
|
255
282
|
const cost = length(at.value) + length(section) + 2;
|
|
256
283
|
view.sections[section] = at.value;
|
|
257
|
-
if (room() >=
|
|
284
|
+
if (room() >= REASON_ROOM)
|
|
258
285
|
continue;
|
|
259
286
|
delete view.sections[section];
|
|
260
287
|
const entries = entriesOf(section, at.value);
|
|
@@ -404,7 +431,10 @@ function keyedEntries(value) {
|
|
|
404
431
|
* on what the steps made, not on what they say: nothing that was there may be changed or taken away. A new entry -- a
|
|
405
432
|
* record in a list, a key in a map -- is the steps' own.
|
|
406
433
|
*/
|
|
407
|
-
function unreadSectionEdits(
|
|
434
|
+
function unreadSectionEdits(givenBase, givenAfter, view) {
|
|
435
|
+
/* The view's pointers are into the figure as shown: so are the two judged here. */
|
|
436
|
+
const base = figureShownOf(givenBase);
|
|
437
|
+
const after = figureShownOf(givenAfter);
|
|
408
438
|
const read = Object.keys(view.sections ?? {});
|
|
409
439
|
const reasons = [];
|
|
410
440
|
const say = (pointer, what) => reasons.push(`UNREAD_SECTION: the steps ${what} ${pointer}, which was left out of the outline and not read, so it is not known here. ` +
|
|
@@ -327,6 +327,10 @@ let FigureQuery = class FigureQuery {
|
|
|
327
327
|
if (names.length > FIGURE_BLUEPRINTS_MAX) {
|
|
328
328
|
throw new shell_1.Refusal('figure-names-too-many', { count: names.length, max: FIGURE_BLUEPRINTS_MAX }, 'at most {max} figure names can be asked at once, not {count}.');
|
|
329
329
|
}
|
|
330
|
+
/*
|
|
331
|
+
`jointsChecked`: each release is parsed here, joint check and all, before it is handed over (consumablePayloadOf),
|
|
332
|
+
so the board need not write its joints again (figure-model ADR-0215 decision 3).
|
|
333
|
+
*/
|
|
330
334
|
const items = [];
|
|
331
335
|
const refused = [];
|
|
332
336
|
/* Plain text: a board draws the reason on a canvas, so a name with `/` is not escaped. */
|
|
@@ -351,7 +355,7 @@ let FigureQuery = class FigureQuery {
|
|
|
351
355
|
continue;
|
|
352
356
|
}
|
|
353
357
|
try {
|
|
354
|
-
items.push({ type, ref: (0, figure_model_1.formatFigureRef)({ ...name, version: found.version }), asset: (0, figure_format_js_1.consumablePayloadOf)(found.source).asset });
|
|
358
|
+
items.push({ type, ref: (0, figure_model_1.formatFigureRef)({ ...name, version: found.version }), asset: (0, figure_format_js_1.consumablePayloadOf)(found.source).asset, jointsChecked: true });
|
|
355
359
|
}
|
|
356
360
|
catch {
|
|
357
361
|
refuse(type, new shell_1.Refusal('figure-release-does-not-compile', { type, figureId: found.figure.id, version: found.version }, 'the released source of {type} does not compile. open it in the modeller and release it again.'));
|
|
@@ -197,7 +197,7 @@ function sourceForTool(row, host) {
|
|
|
197
197
|
if (typeof draft !== 'object' || Array.isArray(draft))
|
|
198
198
|
throw new Error('the unsaved draft is not a figure asset');
|
|
199
199
|
const serialized = JSON.stringify(draft);
|
|
200
|
-
/* Validity is the save door's (the kernel's
|
|
200
|
+
/* Validity is the save door's (the kernel's 4 MiB); how much the model is shown is `figure-context`'s. */
|
|
201
201
|
try {
|
|
202
202
|
getDeps().parseSource(serialized);
|
|
203
203
|
}
|
|
@@ -282,12 +282,13 @@ const PARTS_ARG = {
|
|
|
282
282
|
function partialRead(source, request) {
|
|
283
283
|
const view = (0, figure_context_js_1.figureViewOf)(source, request);
|
|
284
284
|
if (view.whole)
|
|
285
|
-
return { source };
|
|
285
|
+
return { source: view.source, ...(view.jointNodes ? { jointNodes: view.jointNodes } : {}) };
|
|
286
286
|
return {
|
|
287
287
|
outline: view.outline,
|
|
288
288
|
partSources: view.parts,
|
|
289
289
|
...(Object.keys(view.sections ?? {}).length ? { sectionSources: view.sections } : {}),
|
|
290
290
|
...(view.notRead ? { notRead: view.notRead } : {}),
|
|
291
|
+
...(view.jointNodes ? { jointNodes: view.jointNodes } : {}),
|
|
291
292
|
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
293
|
'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
294
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/figure-service",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.300",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"@things-factory:registry": "https://registry.npmjs.org"
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"test": "node --test test/conventions.test.mjs"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@hatiolab/figure-model": "^0.12.
|
|
45
|
+
"@hatiolab/figure-model": "^0.12.21",
|
|
46
46
|
"@operato/typeorm-history": "^10.0.0",
|
|
47
|
-
"@things-factory/ai-client-base": "^10.1.
|
|
48
|
-
"@things-factory/attachment-base": "^10.1.
|
|
49
|
-
"@things-factory/auth-base": "^10.1.
|
|
50
|
-
"@things-factory/env": "^10.1.
|
|
51
|
-
"@things-factory/setting-base": "^10.1.
|
|
52
|
-
"@things-factory/shell": "^10.1.
|
|
47
|
+
"@things-factory/ai-client-base": "^10.1.298",
|
|
48
|
+
"@things-factory/attachment-base": "^10.1.298",
|
|
49
|
+
"@things-factory/auth-base": "^10.1.298",
|
|
50
|
+
"@things-factory/env": "^10.1.298",
|
|
51
|
+
"@things-factory/setting-base": "^10.1.298",
|
|
52
|
+
"@things-factory/shell": "^10.1.298",
|
|
53
53
|
"graphql-scalars": "^1.22.4",
|
|
54
54
|
"graphql-upload": "^15.0.2",
|
|
55
55
|
"jszip": "^3.10.1",
|
|
56
56
|
"koa-router": "^7.4.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "1d8d05b52b9ae030bd4b74a3852b9e9d64f39e6e",
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=22.12"
|
|
61
61
|
},
|