@enspirit/opspicy 0.3.2 → 0.6.0
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/README.md +56 -34
- package/bin/help.js +8 -2
- package/dist/configuration.d.ts +8 -2
- package/dist/explorer/api.js +162 -12
- package/dist/explorer/asking.js +51 -0
- package/dist/explorer/dependencies.js +117 -0
- package/dist/explorer/depending.js +139 -0
- package/dist/explorer/diagrams.js +176 -0
- package/dist/explorer/document.js +1 -0
- package/dist/explorer/elo-refs.js +6 -3
- package/dist/explorer/elo.js +18 -0
- package/dist/explorer/index.js +1 -2
- package/dist/explorer/operation.js +2 -4
- package/dist/explorer/pages.js +14 -16
- package/dist/explorer/script/depending.js +41 -0
- package/dist/explorer/script/main.js +1 -0
- package/dist/explorer/script/ranking.js +2 -2
- package/dist/explorer/script/review.js +1 -1
- package/dist/explorer/script/run.js +4 -1
- package/dist/explorer/script/runner.js +420 -0
- package/dist/explorer/script/running.js +111 -0
- package/dist/explorer/script/sending.js +1 -1
- package/dist/explorer/script/served.js +4 -2
- package/dist/explorer/serve.js +1 -1
- package/dist/explorer/server.js +28 -6
- package/dist/explorer/site.js +1 -1
- package/dist/explorer/style.css +91 -1
- package/dist/explorer/telling.js +2 -0
- package/dist/explorer/tests.js +51 -18
- package/dist/explorer/wiki.js +5 -3
- package/dist/files.js +27 -16
- package/dist/judging.js +2 -34
- package/dist/main.js +1 -1
- package/dist/meaning.js +2 -2
- package/dist/modelling.js +99 -25
- package/dist/naming.js +44 -15
- package/dist/notation.js +18 -3
- package/dist/observing.js +112 -0
- package/dist/planning.js +3 -3
- package/dist/reach.js +244 -140
- package/dist/reading.js +14 -18
- package/dist/running.js +18 -8
- package/dist/starting.js +4 -3
- package/dist/suite.js +8 -1
- package/dist/upgrade.js +3 -9
- package/dist/upgrading-state.js +197 -0
- package/dist/upgrading.js +13 -2
- package/dist/variables.js +62 -0
- package/dist/world.js +8 -39
- package/package.json +3 -2
|
@@ -64,3 +64,114 @@ function bodyText(body) {
|
|
|
64
64
|
|
|
65
65
|
/** The mode a run takes: the one asked when the server runs it, else the one it takes when none is asked. */
|
|
66
66
|
const modeOfRun = (health, asked) => (health.modes && health.modes.includes(asked) ? asked : health.mode);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The command that runs every case, of the suite or of one area: the area is asked by its
|
|
70
|
+
* directory, as the runner narrows a run, and the fast run when it was the last, or when there
|
|
71
|
+
* has been none.
|
|
72
|
+
*/
|
|
73
|
+
function runsCommand(area, runner, lastMode) {
|
|
74
|
+
const fast = lastMode === undefined || lastMode === null || lastMode === 'fast';
|
|
75
|
+
return [...(area ? [`O=${plainWord(`${area}/`)}`] : []), ...(fast ? ['FAST=yes'] : []), runner].join(' ');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What a run of many cases has told, before it told anything. */
|
|
79
|
+
const runsStart = () => ({ mode: '', total: 0, done: 0, passed: 0, failed: 0, errors: 0, now: '', failures: [], ended: null, broken: '' });
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* What a run of many cases has told, once it told one thing more: what is to be run, the case
|
|
83
|
+
* that is being run, a case that was, with what did not hold when something did not, and the end.
|
|
84
|
+
* What is no message of a run is the server saying it failed: the run is broken, and says so.
|
|
85
|
+
*/
|
|
86
|
+
function runsTold(told, message) {
|
|
87
|
+
if (!isRecord(message)) return told;
|
|
88
|
+
if (message.is === 'started') return { ...told, mode: String(message.mode || ''), total: Number(message.cases) || 0 };
|
|
89
|
+
if (message.is === 'running') return { ...told, now: String(message.ref || '') };
|
|
90
|
+
if (message.is === 'ran') {
|
|
91
|
+
const result = message.result === 'passed' ? 'passed' : message.result === 'failed' ? 'failed' : 'errors';
|
|
92
|
+
const failures = result === 'passed' ? told.failures : [...told.failures, { ref: String(message.ref || ''), result: message.result, failed: Array.isArray(message.failed) ? message.failed : [] }];
|
|
93
|
+
return { ...told, done: told.done + 1, [result]: told[result] + 1, now: '', failures };
|
|
94
|
+
}
|
|
95
|
+
if (message.is === 'ended') return { ...told, now: '', ended: message };
|
|
96
|
+
return typeof message.refused === 'string' ? { ...told, now: '', broken: message.refused } : told;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The messages a server sent, a line of JSON each, as they come in pieces that end anywhere: the
|
|
101
|
+
* lines that are whole, and what is kept for the piece that ends the last one. A line that is no
|
|
102
|
+
* JSON is not a message, and is left out.
|
|
103
|
+
*/
|
|
104
|
+
function runsLines(kept, piece) {
|
|
105
|
+
const lines = (kept + piece).split('\n');
|
|
106
|
+
const rest = lines.pop();
|
|
107
|
+
const messages = [];
|
|
108
|
+
for (const line of lines) {
|
|
109
|
+
try {
|
|
110
|
+
if (line.trim()) messages.push(JSON.parse(line));
|
|
111
|
+
} catch {
|
|
112
|
+
/* not a message */
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { messages, kept: rest };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** How far a run of many cases is, in words: how many of how many, and how they went. */
|
|
119
|
+
function runsWords(told) {
|
|
120
|
+
const went = [`${told.passed} passed`, `${told.failed} failed`, ...(told.errors ? [`${told.errors} could not be run`] : [])];
|
|
121
|
+
return `${told.done} of ${told.total} run · ${went.join(' · ')}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The result of a run of many cases, in a glyph and words: what failed first, since it is what is looked for. */
|
|
125
|
+
function runsVerdict(told) {
|
|
126
|
+
const bad = told.failed + told.errors;
|
|
127
|
+
const words = [...(told.failed ? [`${told.failed} failed`] : []), ...(told.errors ? [`${told.errors} could not be run`] : []), `${told.passed} passed`].join(', ');
|
|
128
|
+
return { glyph: bad ? '✗' : '✓', words, cls: bad ? 'ko' : 'ok' };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** What is asked of the server so that it runs what a row names: an area, an operation or a case, by its anchor; the whole suite, by none. */
|
|
132
|
+
function runsScope(ref) {
|
|
133
|
+
if (ref.startsWith('area-')) return { area: ref };
|
|
134
|
+
if (ref.startsWith('op-')) return { operation: ref };
|
|
135
|
+
return ref.startsWith('case-') ? { case: ref } : {};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The cases a run is about to run, by their anchors, as its first message names them under their operations. */
|
|
139
|
+
const runsQueued = (message) => (isRecord(message) && Array.isArray(message.operations) ? message.operations.flatMap((one) => (isRecord(one) && Array.isArray(one.cases) ? one.cases.map(String) : [])) : []);
|
|
140
|
+
|
|
141
|
+
/** How a case stands, in a glyph and a word: what the last run decided of it, or where a run that is under way is with it. */
|
|
142
|
+
function caseStanding(state) {
|
|
143
|
+
if (state === 'queued') return { glyph: '·', word: 'queued', cls: 'nr' };
|
|
144
|
+
if (state === 'running') return { glyph: '◌', word: 'running…', cls: 'on' };
|
|
145
|
+
return state === 'passed' || state === 'failed' || state === 'error' ? verdictOf(state) : { glyph: '○', word: 'not run', cls: 'nr' };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* How the cases of a row stand together, from how each does: how many passed and how many did
|
|
150
|
+
* not, of how many, as counts, as shares of a bar and in words. A case that waits for a run, or
|
|
151
|
+
* is being run, is not counted as run: the bar of its row grows again as the run gets to it.
|
|
152
|
+
*/
|
|
153
|
+
function rowStanding(states) {
|
|
154
|
+
const count = (what) => states.filter((one) => one === what).length;
|
|
155
|
+
const [total, passed, failed, errors] = [states.length, count('passed'), count('failed'), count('error')];
|
|
156
|
+
const ran = passed + failed + errors;
|
|
157
|
+
const share = (of) => (total ? `${Math.round((of / total) * 1000) / 10}%` : '0%');
|
|
158
|
+
const words = [...(failed ? [`${failed} failed`] : []), ...(errors ? [`${errors} could not be run`] : []), `${ran} / ${total}`].join(' · ');
|
|
159
|
+
return { total, passed, bad: failed + errors, ran, busy: states.some((one) => one === 'queued' || one === 'running'), passedShare: share(passed), badShare: share(failed + errors), words };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** What did not hold, as a list of what each says and the clause it is said of: a run tells it so, and the document keeps the sentences alone. */
|
|
163
|
+
function failedOf(text) {
|
|
164
|
+
try {
|
|
165
|
+
const kept = JSON.parse(text || '[]');
|
|
166
|
+
return Array.isArray(kept) ? kept.map((one) => (typeof one === 'string' ? { says: one } : one)).filter((one) => isRecord(one) && typeof one.says === 'string') : [];
|
|
167
|
+
} catch {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The time of a case, or of several together, as a column of them reads: in milliseconds under a second, in seconds from there. */
|
|
173
|
+
function timeText(ms) {
|
|
174
|
+
const value = Number(ms);
|
|
175
|
+
if (!Number.isFinite(value)) return '';
|
|
176
|
+
return value < 1000 ? `${Math.round(value)} ms` : secondsText(value / 1000);
|
|
177
|
+
}
|
|
@@ -60,5 +60,5 @@ async function sendThrough(panel, input, result) {
|
|
|
60
60
|
const actor = $('[data-actor]', panel.body);
|
|
61
61
|
const body = { operation: panel.page, input: input === null || input === undefined ? {} : input, ...(actor ? { actor: actor.value } : {}) };
|
|
62
62
|
result.innerHTML = '<p class="m">Calling…</p>';
|
|
63
|
-
result.innerHTML = servedAnswerHtml(await serverFetch('
|
|
63
|
+
result.innerHTML = servedAnswerHtml(await serverFetch('api/call', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }, WAITS.call));
|
|
64
64
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Whether the page is served: by the server of the explorer, which answers a few calls from the
|
|
2
2
|
// same origin (running a case, calling an operation, saving the review). The page finds out by
|
|
3
|
-
// asking
|
|
3
|
+
// asking `api/health` once, when it came over http(s); a file asks nothing. The API is asked
|
|
4
|
+
// beside the page, `api/…` from where it is, so that an explorer served under a path of a larger
|
|
5
|
+
// site (`/spec/`) asks its own server there, and not whatever is at the root. What it answers
|
|
4
6
|
// (`name`, `target`, `protected`, `modes`, `mode`) is kept, and `opspicy:served` tells when it is
|
|
5
7
|
// known. A page that is not served says so with nothing, and reads as it always did.
|
|
6
8
|
|
|
@@ -35,7 +37,7 @@ async function serverFetch(path, init, within) {
|
|
|
35
37
|
/** Asked once; settled when it is known whether the page is served, with the answer or with nothing. */
|
|
36
38
|
const servedKnown = (async () => {
|
|
37
39
|
if (!/^https?:$/.test(location.protocol)) return null;
|
|
38
|
-
const answer = await serverFetch('
|
|
40
|
+
const answer = await serverFetch('api/health', {}, WAITS.health);
|
|
39
41
|
health = healthOf(answer, META.name);
|
|
40
42
|
document.dispatchEvent(new Event('opspicy:served'));
|
|
41
43
|
return health;
|
package/dist/explorer/serve.js
CHANGED
|
@@ -27,7 +27,7 @@ async function benchOf(options) {
|
|
|
27
27
|
const report = reportAt(options.report);
|
|
28
28
|
return report ? (report.fast ? 'fast' : 'complete') : null;
|
|
29
29
|
};
|
|
30
|
-
return { root, config, name: options.name ?? nameOf(options.suite), version: options.version, lastMode };
|
|
30
|
+
return { root, config, name: options.name ?? nameOf(options.suite), version: options.version, lastMode, ...(options.report ? { report: resolve(options.report) } : {}) };
|
|
31
31
|
}
|
|
32
32
|
const options = optionsOf(process.argv.slice(2));
|
|
33
33
|
if (!Number.isInteger(options.port) || options.port < 0 || options.port > 65535)
|
package/dist/explorer/server.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// refused, and so is a body that is not what the page sends (machine.ts). The page itself is
|
|
9
9
|
// refused to a host that is not this machine, wherever the server is offered on this machine only.
|
|
10
10
|
import { createServer } from 'node:http';
|
|
11
|
-
import { call, health, review, run } from './api.js';
|
|
11
|
+
import { call, health, isStreamed, ran, review, run, runs } from './api.js';
|
|
12
12
|
import { isLoopback, ownPage } from './machine.js';
|
|
13
13
|
import { documentKept } from './site.js';
|
|
14
14
|
// Nothing served is shown inside another page: a page that frames this one could have its
|
|
@@ -68,11 +68,18 @@ function oneAtATime() {
|
|
|
68
68
|
if (busy)
|
|
69
69
|
return refused(409, 'A case is being run, or an operation called: one at a time.');
|
|
70
70
|
busy = true;
|
|
71
|
+
let telling = false;
|
|
71
72
|
try {
|
|
72
|
-
|
|
73
|
+
const answer = await work();
|
|
74
|
+
if (!isStreamed(answer))
|
|
75
|
+
return answer;
|
|
76
|
+
// What is told as it comes is under way until its last word: the next is refused until then.
|
|
77
|
+
telling = true;
|
|
78
|
+
return { ...answer, stream: (say, gone) => answer.stream(say, gone).finally(() => (busy = false)) };
|
|
73
79
|
}
|
|
74
80
|
finally {
|
|
75
|
-
|
|
81
|
+
if (!telling)
|
|
82
|
+
busy = false;
|
|
76
83
|
}
|
|
77
84
|
};
|
|
78
85
|
}
|
|
@@ -85,17 +92,32 @@ function apiOf(bench) {
|
|
|
85
92
|
const asked = `${request.method} ${path}`;
|
|
86
93
|
if (asked === 'GET /api/health')
|
|
87
94
|
return health(bench);
|
|
95
|
+
if (asked === 'GET /api/ran')
|
|
96
|
+
return ran(bench, new URL(request.url ?? '/', 'http://x').searchParams.get('case'));
|
|
88
97
|
if (asked === 'PUT /api/review')
|
|
89
98
|
return written(bench, await bodyOf(request));
|
|
90
|
-
|
|
99
|
+
const work = { 'POST /api/run': run, 'POST /api/runs': runs, 'POST /api/call': call }[asked];
|
|
100
|
+
if (!work)
|
|
91
101
|
return refused(404, `The API has no ${asked}.`);
|
|
92
102
|
const body = await jsonOf(request);
|
|
93
103
|
if (!('asked' in body))
|
|
94
104
|
return body;
|
|
95
|
-
return alone(() => (
|
|
105
|
+
return alone(() => work(bench, body.asked));
|
|
96
106
|
};
|
|
97
107
|
}
|
|
98
108
|
const ELSEWHERE = 'This explorer is served on this machine, and read there by a name of it: localhost, 127.0.0.1, [::1].\n';
|
|
109
|
+
/**
|
|
110
|
+
* What is told as it comes, over HTTP: a line of JSON for each message, sent as it is said. Who
|
|
111
|
+
* asked may leave before the end, which the connection says: nothing more is written, and what
|
|
112
|
+
* tells is told so.
|
|
113
|
+
*/
|
|
114
|
+
function streamed(response, answer, failed) {
|
|
115
|
+
let gone = false;
|
|
116
|
+
response.on('close', () => (gone = true));
|
|
117
|
+
response.writeHead(200, { ...SECURED, 'content-type': 'application/x-ndjson; charset=utf-8', 'x-accel-buffering': 'no' });
|
|
118
|
+
const say = (message) => void (gone || response.write(`${JSON.stringify(message)}\n`));
|
|
119
|
+
answer.stream(say, () => gone).then(() => response.end(), failed);
|
|
120
|
+
}
|
|
99
121
|
const READ_ONLY = async () => refused(404, 'This explorer is served to be read: it runs nothing. Serve it with --api, on this machine.');
|
|
100
122
|
function page(request, response, path, written) {
|
|
101
123
|
if (request.method !== 'GET' && request.method !== 'HEAD')
|
|
@@ -129,7 +151,7 @@ export function serverOf(options, bench) {
|
|
|
129
151
|
const path = (request.url ?? '/').split('?')[0] ?? '/';
|
|
130
152
|
if (path.startsWith('/api/')) {
|
|
131
153
|
const failed = failing(response, 'application/json', JSON.stringify({ refused: 'The server failed: see its log.' }));
|
|
132
|
-
return void api(request, path).then((
|
|
154
|
+
return void api(request, path).then((answer) => (isStreamed(answer) ? streamed(response, answer, failed) : response.writeHead(answer.status, { ...SECURED, 'content-type': 'application/json' }).end(JSON.stringify(answer.body))), failed);
|
|
133
155
|
}
|
|
134
156
|
if (here && !isLoopback(request.headers.host ?? ''))
|
|
135
157
|
return void response.writeHead(403, TEXT).end(ELSEWHERE);
|
package/dist/explorer/site.js
CHANGED
|
@@ -11,7 +11,7 @@ import { documentOf } from './document.js';
|
|
|
11
11
|
import { wikiOf } from './wiki.js';
|
|
12
12
|
const here = (path) => new URL(path, import.meta.url);
|
|
13
13
|
/** The parts of the page's script, in the order they are read: a part names what those before it declare. The buttons of a row are in the order of the parts that add them: ƒ (rows), ▶ (run), ✎ (notes). */
|
|
14
|
-
const PARTS = ['base', 'formaldef', 'ranking', 'search', 'rows', 'filter', 'peeking', 'peek', 'markdown', 'noting', 'calling', 'copying', 'served', 'running', 'run', 'notes', 'review', 'connection', 'sending', 'call', 'main'];
|
|
14
|
+
const PARTS = ['base', 'formaldef', 'ranking', 'search', 'rows', 'filter', 'peeking', 'peek', 'markdown', 'noting', 'calling', 'copying', 'served', 'running', 'run', 'runner', 'notes', 'review', 'connection', 'sending', 'call', 'depending', 'main'];
|
|
15
15
|
/** The style, with its one font inside it: the page fetches nothing. */
|
|
16
16
|
const styleHere = () => {
|
|
17
17
|
const font = readFileSync(here('./fonts/dm-sans-latin.woff2')).toString('base64');
|
package/dist/explorer/style.css
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
--ok:light-dark(#0b7a62,#18bf97);--ko:light-dark(#c2391e,#ff9b85);
|
|
13
13
|
--yellow:#ffee7f;--green:#18bf97;--orange:#f7a336;--blue:#728dee;--light-blue:#b4c7fd;--melon:#f5cab2;--on-accent:#110e25;
|
|
14
14
|
--shade:rgba(17,14,37,.26);--veil:rgba(17,14,37,.45);
|
|
15
|
-
--note:light-dark(#fff3a8,#3a3413);--run:light-dark(#e6ecff,#1d2347);--bad:light-dark(#fbe3d6,#3b1f1a);
|
|
15
|
+
--note:light-dark(#fff3a8,#3a3413);--run:light-dark(#e6ecff,#1d2347);--bad:light-dark(#fbe3d6,#3b1f1a);--log:light-dark(#110e25,#0b091b);--on-log:#fff6e5;
|
|
16
16
|
--t-key:light-dark(#6a45c9,#c9b6ff);--t-type:light-dark(#0b7a62,#5fd9bb);--t-str:light-dark(#9a5200,#f7c27a);--t-num:light-dark(#9a5200,#f7c27a);
|
|
17
17
|
--sans:"DM Sans",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--opsz:"opsz" 14;--mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;--sign:Georgia,"Times New Roman",serif}
|
|
18
18
|
:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
|
|
@@ -224,6 +224,44 @@ dialog .bar{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
|
|
|
224
224
|
#peek .k{font-size:11.5px;color:var(--muted);letter-spacing:.08em;text-transform:uppercase}
|
|
225
225
|
#peek p{margin:4px 0 0}
|
|
226
226
|
#peek pre.elo{margin-top:8px;font-size:12.5px;max-height:220px;overflow:hidden}
|
|
227
|
+
/* The runner: every case under its operation, every operation under its area, in one table that folds, says how a run goes on its own rows, and opens a case on what its run told. */
|
|
228
|
+
.runner{margin:26px 0 0}
|
|
229
|
+
.rn-bar{background:var(--run);border-radius:10px;padding:12px 14px;font-size:14px;display:grid;gap:8px;margin:0 0 16px}
|
|
230
|
+
.rn-bar .line{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.rn-bar .sp{flex:1}
|
|
231
|
+
.rn-bar p{margin:0}.rn-bar :is(p,.outcome):empty{display:none}
|
|
232
|
+
.rn-bar pre{flex:1 1 20ch;margin:0;padding:8px 12px;border-radius:8px;background:var(--panel);white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px}
|
|
233
|
+
.rn-bar .prog{font-variant-numeric:tabular-nums;font-weight:600}
|
|
234
|
+
.rn-bar select{height:32px;border:1px solid var(--rule);border-radius:8px;background:var(--panel);padding:0 6px;font-size:14px}
|
|
235
|
+
.rn-only{display:inline-flex;align-items:center;gap:6px;min-height:32px;cursor:pointer}.rn-only input{width:16px;height:16px;margin:0;accent-color:var(--ink)}
|
|
236
|
+
.rn-whole{flex:0 1 200px}.rn-whole .rn-meter{height:8px}
|
|
237
|
+
.rn-meter{display:flex;height:6px;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--ink) 14%,transparent)}
|
|
238
|
+
.rn-meter .ok{background:var(--ok)}.rn-meter .ko{background:var(--ko)}
|
|
239
|
+
table.rn{width:100%;min-width:640px;font-size:14.5px;line-height:1.45;border-collapse:collapse}
|
|
240
|
+
table.rn thead th{font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding:0 12px 8px 0;border-bottom:2px solid var(--ink);text-align:left;white-space:nowrap}
|
|
241
|
+
table.rn tbody :is(th,td){padding:7px 12px 7px 0;border-bottom:1px solid var(--rule);vertical-align:middle;text-align:left;font-weight:400}
|
|
242
|
+
table.rn tr>:first-child{padding-left:var(--bleed)}table.rn tr>:last-child{padding-right:var(--bleed)}
|
|
243
|
+
table.rn .rn-time{width:1%;text-align:right;white-space:nowrap;color:var(--muted);font-size:13px;font-variant-numeric:tabular-nums}
|
|
244
|
+
table.rn .rn-res{width:1%;white-space:nowrap}
|
|
245
|
+
table.rn .rn-run{width:1%;text-align:right}.runner:not(.runs) .rn-run{display:none}
|
|
246
|
+
table.rn tr.rn-op>.rn-name{padding-left:calc(var(--bleed) + 24px)}table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 48px)}
|
|
247
|
+
.runner[data-scope] table.rn tr.rn-op>.rn-name{padding-left:var(--bleed)}.runner[data-scope] table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 24px)}
|
|
248
|
+
tr.rn-area>*{background:var(--code)}tr.rn-area .rn-what{font-weight:700;font-size:16px}tr.rn-op .rn-what{font-weight:700}
|
|
249
|
+
tr:is(.rn-area,.rn-op) .rn-what{margin-right:8px}
|
|
250
|
+
.runner[data-filled] tr:is(.rn-area,.rn-op,.rn-case){cursor:pointer}.runner[data-filled] tr:is(.rn-op,.rn-case):hover>*{background:var(--hover)}
|
|
251
|
+
.rn-tw{display:inline-grid;place-items:center;width:24px;height:24px;margin:0 6px 0 -4px;padding:0;border:0;border-radius:50%;background:none;color:var(--muted);vertical-align:middle;cursor:pointer}
|
|
252
|
+
.rn-tw:hover{background:var(--hover);color:var(--ink)}.rn-tw[aria-expanded=true]{color:var(--ink)}.rn-tw[aria-expanded=true] svg{transform:rotate(90deg)}
|
|
253
|
+
.rn-kind{display:inline-block;margin-right:6px;padding:0 8px;border:1px solid color-mix(in srgb,var(--ink) 30%,transparent);border-radius:999px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);white-space:nowrap;vertical-align:middle}
|
|
254
|
+
.rn-res .rn-meter{display:inline-flex;width:84px;margin-right:10px;vertical-align:middle}
|
|
255
|
+
.rn-count{font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}tr.bad .rn-count{color:var(--ko)}tr.busy .rn-count::after{content:" …"}
|
|
256
|
+
.res.on{color:var(--link);font-weight:600}
|
|
257
|
+
.rn-go{display:inline-grid;place-items:center;width:36px;height:30px;padding:0;border:1px solid var(--rule);border-radius:999px;background:var(--panel);color:var(--ink);cursor:pointer}
|
|
258
|
+
.rn-go:hover{border-color:var(--ink)}.rn-go[disabled]{opacity:.45;cursor:not-allowed}
|
|
259
|
+
table.rn tr.rn-more>td{padding:12px var(--bleed) 18px calc(var(--bleed) + 48px);background:var(--code)}.runner[data-scope] table.rn tr.rn-more>td{padding-left:calc(var(--bleed) + 24px)}
|
|
260
|
+
.rn-told{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:14px 22px;align-items:start}
|
|
261
|
+
.rn-detail h4{margin:12px 0 4px;font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}.rn-detail :is(.rn-told>div,.fail)>h4:first-child{margin-top:0}
|
|
262
|
+
.rn-detail p{margin:0 0 4px}.rn-detail .fail{margin:0 0 12px}.rn-detail .line{display:flex;margin-top:6px}
|
|
263
|
+
.rn-detail pre{margin:0 0 8px;padding:8px 12px;border-radius:8px;background:var(--panel);white-space:pre-wrap;overflow-wrap:anywhere;font-size:12.5px;line-height:1.5;max-height:320px;overflow:auto}
|
|
264
|
+
.rn-detail pre.rn-log{background:var(--log);color:var(--on-log);white-space:pre;overflow-wrap:normal;max-height:520px}
|
|
227
265
|
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:26px 0 0}
|
|
228
266
|
.tile{background:var(--code);border-radius:12px;padding:16px 18px;color:var(--ink)}
|
|
229
267
|
.tile b{display:block;font:700 34px/1.15 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.03em;font-variant-numeric:tabular-nums}
|
|
@@ -244,4 +282,56 @@ dialog .bar{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
|
|
|
244
282
|
.io,.try .grid{grid-template-columns:minmax(0,1fr)}.io .arrow{display:none}
|
|
245
283
|
.filter{width:160px}
|
|
246
284
|
tr.run-row .runbox{position:sticky;left:0;width:calc(100vw - 40px)}
|
|
285
|
+
table.rn{min-width:0}.rn-res .rn-meter,table.rn .rn-time{display:none}
|
|
286
|
+
table.rn tr.rn-op>.rn-name{padding-left:calc(var(--bleed) + 10px)}table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 20px)}
|
|
287
|
+
.runner[data-scope] table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 10px)}
|
|
288
|
+
table.rn tr.rn-more>td,.runner[data-scope] table.rn tr.rn-more>td{padding-left:var(--bleed)}
|
|
289
|
+
.rn-told{grid-template-columns:minmax(0,1fr)}
|
|
247
290
|
}
|
|
291
|
+
|
|
292
|
+
/* Dependencies: two drawings, of the tokens above alone. An arc is ink, dashed where it only reads a state, and warm where it goes against the order. */
|
|
293
|
+
.dep-scroll{margin-top:14px;padding:6px var(--bleed)}
|
|
294
|
+
svg.dep{display:block;max-width:none;height:auto}
|
|
295
|
+
.dep-box{fill:var(--panel);stroke:var(--ink);stroke-width:1.1}
|
|
296
|
+
.dep-name{font:600 14px var(--sans);font-variation-settings:var(--opsz);fill:var(--ink)}
|
|
297
|
+
.dep-sub,.dep-count{font:12px var(--sans);font-variation-settings:var(--opsz);fill:var(--muted)}
|
|
298
|
+
.dep-word{font:12.5px var(--mono);fill:var(--ink)}
|
|
299
|
+
.dep-n{font:600 11.5px var(--mono);fill:var(--ink);paint-order:stroke;stroke:var(--bg);stroke-width:5px;stroke-linejoin:round}
|
|
300
|
+
.dep-hit{fill:transparent}
|
|
301
|
+
.dep a:hover{text-decoration:none}
|
|
302
|
+
.dep-row:hover .dep-hit,.dep-row:focus-visible .dep-hit,.dep-row.lit .dep-hit{fill:var(--hover)}
|
|
303
|
+
.dep-node.here .dep-box{stroke-width:2.4}
|
|
304
|
+
.dep-node:hover .dep-box,.dep-node:focus-visible .dep-box,.dep-node.lit .dep-box{fill:var(--run)}
|
|
305
|
+
.dep .wire{fill:none;stroke:var(--ink);stroke-width:1.2}
|
|
306
|
+
.dep .tip{fill:var(--ink)}
|
|
307
|
+
.dep-wire{opacity:.45}
|
|
308
|
+
.dep-arc.state .wire{stroke-dasharray:5 4}
|
|
309
|
+
.dep-arc.against .wire{stroke:var(--ko);stroke-width:1.8}
|
|
310
|
+
.dep-arc.against .tip,.dep-arc.against .dep-n{fill:var(--ko)}
|
|
311
|
+
.dep-arc:hover .wire,.dep-wire:hover .wire{stroke-width:2.2}
|
|
312
|
+
.dep-wire:hover{opacity:1}
|
|
313
|
+
.dep.lighting :is(.dep-arc,.dep-wire):not(.lit){opacity:.08}
|
|
314
|
+
.dep.lighting :is(.dep-arc,.dep-wire).lit{opacity:1}
|
|
315
|
+
.dep.lighting :is(.dep-node,.dep-row):not(.lit) text{opacity:.35}
|
|
316
|
+
.dep-legend{margin-top:10px;flex-direction:row;flex-wrap:wrap;gap:4px 22px}.dep-legend b{color:var(--ink);font-family:var(--mono);font-size:11.5px}
|
|
317
|
+
.dep-key{display:inline-block;width:26px;border-top:1.5px solid var(--ink);vertical-align:middle;margin-right:4px}
|
|
318
|
+
.dep-key.state{border-top-style:dashed}
|
|
319
|
+
.dep-key.against{border-top:2px solid var(--ko)}
|
|
320
|
+
.dep-box.here{stroke-width:2.4}
|
|
321
|
+
.dep-rule{stroke:var(--ink);stroke-width:1.1}
|
|
322
|
+
.dep-part{font:600 10.5px var(--sans);font-variation-settings:var(--opsz);letter-spacing:.08em;text-transform:uppercase;fill:var(--muted)}
|
|
323
|
+
.dep-wire.state .wire{stroke-dasharray:5 4}
|
|
324
|
+
.dep-wire.against .wire{stroke:var(--ko)}
|
|
325
|
+
.dep-wire.against .tip{fill:var(--ko)}
|
|
326
|
+
.dep-word.condition{font-family:var(--sans);font-variation-settings:var(--opsz);font-size:13px}
|
|
327
|
+
.dep-word.type{fill:var(--t-type)}
|
|
328
|
+
.dep-word.state{fill:var(--t-key)}
|
|
329
|
+
/* The one switch of the drawing of an area: which of the two is shown is decided here, with no script. */
|
|
330
|
+
.dep-switch{display:inline-flex;align-items:center;gap:10px;margin:14px 0 0;font-size:14px;cursor:pointer;user-select:none}
|
|
331
|
+
.dep-switch input{position:absolute;opacity:0;width:1px;height:1px}
|
|
332
|
+
.dep-knob{flex:none;position:relative;width:34px;height:20px;border-radius:999px;background:var(--rule)}
|
|
333
|
+
.dep-knob::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--panel);box-shadow:0 0 0 1px var(--rule)}
|
|
334
|
+
.dep-switch input:checked+.dep-knob{background:var(--ink)}
|
|
335
|
+
.dep-switch input:checked+.dep-knob::after{transform:translateX(14px)}
|
|
336
|
+
.dep-switch input:focus-visible+.dep-knob{outline:2px solid var(--link);outline-offset:2px}
|
|
337
|
+
.dep-mode:has(.dep-detail-on:checked) .dep-plain,.dep-mode:not(:has(.dep-detail-on:checked)) .dep-detailed{display:none}
|
package/dist/explorer/telling.js
CHANGED
|
@@ -28,3 +28,5 @@ export function ranOf(operation, outcome, mode, secrets) {
|
|
|
28
28
|
const log = operationLines({ operation, outcomes: [told], gaps: [] }, 'trace').map((line) => hidden(plain(line), secrets)).filter((line, at) => at > 0 || line !== '');
|
|
29
29
|
return { result: resultOf(kept), mode, seconds: outcome.ms / 1000, background: outcome.kase.given.seed, request, answer: call ? { status: call.status, body: call.body } : null, failed: failures([...operation.clauses, ...outcome.kase.and], kept), log };
|
|
30
30
|
}
|
|
31
|
+
/** What a run decided of one case among many, as the page is told it while the others run: of the whole telling of that case, what says how it went. */
|
|
32
|
+
export const amongOf = (operation, kase, told) => ({ ref: idOf('case', kase.name), operation: operation.name, result: told.result, seconds: told.seconds, failed: told.failed });
|
package/dist/explorer/tests.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RESULT, citizens, esc, link, list, plural, table } from './html.js';
|
|
2
2
|
import { answeredOf, areaTitle, callerOf, crumbs, sentOf } from './operation.js';
|
|
3
3
|
import { idOf } from './wiki.js';
|
|
4
|
-
|
|
4
|
+
/** A count of the run, in large: named for the script, which counts again as cases are run. */
|
|
5
|
+
const tile = (value, label, key, cls = '') => `<div class="tile ${cls}" data-tile="${key}"><b>${esc(value)}</b><span>${esc(label)}</span></div>`;
|
|
5
6
|
const seconds = (ms) => (ms === undefined ? '' : `<span class="m s">${(ms / 1000).toFixed(1)} s</span>`);
|
|
6
7
|
/** Of the cases of an operation, how many ran, passed, failed. */
|
|
7
8
|
function ledger(cases) {
|
|
@@ -15,27 +16,63 @@ export function resultOfAll(results) {
|
|
|
15
16
|
return 'failed';
|
|
16
17
|
return results.includes('passed') ? 'passed' : 'notrun';
|
|
17
18
|
}
|
|
19
|
+
/** How the cases of a row went, in words: what passed, what failed, what was not run. */
|
|
20
|
+
function wentOf(cases) {
|
|
21
|
+
const of = ledger(cases);
|
|
22
|
+
if (!of.ran)
|
|
23
|
+
return `${plural(of.notRun, 'case')}, not run`;
|
|
24
|
+
return [`${of.passed} passed`, ...(of.failed ? [`${of.failed} failed`] : []), ...(of.notRun ? [`${of.notRun} not run`] : [])].join(', ');
|
|
25
|
+
}
|
|
26
|
+
const timeOf = (cases) => seconds(cases.some((one) => one.ms !== undefined) ? cases.reduce((sum, one) => sum + (one.ms ?? 0), 0) : undefined);
|
|
27
|
+
const kindOf = (kase) => (kase.generated ? 'from a condition' : kase.kind);
|
|
28
|
+
/** A row that holds others: an area, or an operation, with how its cases went. What is said beside its name ends with the way to its page of the tests. */
|
|
29
|
+
function groupRow(cls, ref, within, name, sub, cases) {
|
|
30
|
+
return `<tr class="${cls}" data-ref="${esc(ref)}"${within ? ` data-in="${esc(within)}"` : ''}><th scope="row" class="rn-name"><span class="rn-what">${name}</span> <span class="m s">${sub}</span></th><td class="rn-res">${esc(wentOf(cases))}</td><td class="rn-time">${timeOf(cases)}</td></tr>`;
|
|
31
|
+
}
|
|
32
|
+
/** A case, as the last run left it; and under it, when it failed, what did not hold. */
|
|
33
|
+
function caseRow(kase, within) {
|
|
34
|
+
const ref = idOf('case', kase.name);
|
|
35
|
+
const failed = kase.findings.length ? ` data-failed="${esc(JSON.stringify(kase.findings))}"` : '';
|
|
36
|
+
const row = `<tr class="rn-case" data-ref="${esc(ref)}" data-in="${esc(within)}" data-result="${kase.result}"${kase.ms === undefined ? '' : ` data-ms="${kase.ms}"`}${failed}><td class="rn-name"><span class="rn-kind">${kindOf(kase)}</span> <span class="rn-what">${link(`#${ref}`, kase.description)}</span>${kase.for ? ` <span class="m s">for: ${esc(kase.for)}</span>` : ''}</td><td class="rn-res">${RESULT[kase.result]}</td><td class="rn-time">${seconds(kase.ms)}</td></tr>`;
|
|
37
|
+
const more = kase.findings.length ? `<tr class="rn-more" data-of="${esc(ref)}"><td colspan="3"><div class="fail">${list(kase.findings.map(esc))}</div></td></tr>` : '';
|
|
38
|
+
return row + more;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The runner: every case of some areas, by area and by operation, a row each, with what the last
|
|
42
|
+
* run decided of it. Of one area alone, its operations are the first level, and `scope` names the
|
|
43
|
+
* area as a run is asked of it. The script adds what runs and what folds; without it every row is
|
|
44
|
+
* there to read, and what did not hold is under its case.
|
|
45
|
+
*/
|
|
46
|
+
function runner(areas, scope) {
|
|
47
|
+
const rows = areas.map((area) => {
|
|
48
|
+
const within = idOf('area', area.name);
|
|
49
|
+
const head = scope === undefined ? groupRow('rn-area', within, undefined, esc(areaTitle(area.name)), `${plural(area.operations.length, 'operation')} · ${plural(area.operations.flatMap((one) => one.cases).length, 'case')} · ${link(`#${idOf('test-area', area.name)}`, 'its page')}`, area.operations.flatMap((one) => one.cases)) : '';
|
|
50
|
+
const operations = area.operations.map((operation) => {
|
|
51
|
+
const ref = idOf('op', operation.name);
|
|
52
|
+
const sub = `${esc(operation.agent)} · ${esc(`${operation.entry.method} ${operation.entry.path}`)}${operation.observes ? ' · an observation' : ''} · ${link(`#${idOf('test', operation.name)}`, 'its page')}`;
|
|
53
|
+
return groupRow('rn-op', ref, scope === undefined ? within : undefined, `<span class="mono">${esc(operation.name)}</span>`, sub, operation.cases) + operation.cases.map((kase) => caseRow(kase, ref)).join('');
|
|
54
|
+
});
|
|
55
|
+
return head + operations.join('');
|
|
56
|
+
});
|
|
57
|
+
const place = scope === undefined ? '' : ` data-scope="${esc(idOf('area', scope))}" data-area="${esc(scope)}"`;
|
|
58
|
+
return `<div class="runner"${place}><div class="rn-bar work"></div><div class="scroll"><table class="rn"><thead><tr><th>${scope === undefined ? 'Area, operation, case' : 'Operation, case'}</th><th>Result</th><th class="rn-time">Time</th></tr></thead><tbody>${rows.join('')}</tbody></table></div></div>`;
|
|
59
|
+
}
|
|
18
60
|
function overviewPage(wiki) {
|
|
19
61
|
const run = wiki.run;
|
|
62
|
+
const all = wiki.operations.flatMap((one) => one.cases);
|
|
63
|
+
const of = ledger(all);
|
|
64
|
+
const tiles = `<div class="tiles">${tile(of.ran, 'cases run', 'ran')}${tile(of.passed, 'passing', 'passed', 'ok')}${tile(of.failed, 'failing', 'failed', of.failed ? 'ko' : 'ok')}${tile(of.notRun, 'not run', 'notrun')}</div>`;
|
|
65
|
+
const table = runner(performing(wiki));
|
|
20
66
|
if (!run) {
|
|
21
|
-
const body = `<h1>Tests</h1><p class="lead">No run of this specification is known. A run writes its report beside the console (<span class="mono">--report=</span>), and the explorer shows its results here.</p
|
|
67
|
+
const body = `<h1>Tests</h1><p class="lead">No run of this specification is known. A run writes its report beside the console (<span class="mono">--report=</span>), and the explorer shows its results here.</p>${tiles}${table}`;
|
|
22
68
|
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
23
69
|
}
|
|
24
|
-
const failing = wiki.operations.filter((one) => one.cases.some((kase) => kase.result === 'failed'));
|
|
25
|
-
const failures = failing
|
|
26
|
-
.map((one) => `<h3>${link(`#${idOf('test', one.name)}`, one.name)}</h3>${list(one.cases.filter((kase) => kase.result === 'failed').map((kase) => `${esc(kase.description)}${kase.findings.length ? `<div class="fail">${list(kase.findings.map(esc))}</div>` : ''}`))}`)
|
|
27
|
-
.join('');
|
|
28
|
-
const rows = performing(wiki).map((area) => {
|
|
29
|
-
const of = ledger(area.operations.flatMap((one) => one.cases));
|
|
30
|
-
return [link(`#${idOf('test-area', area.name)}`, areaTitle(area.name)), String(of.passed), String(of.failed), String(of.notRun), RESULT[resultOfAll(area.operations.map((one) => one.result))]];
|
|
31
|
-
});
|
|
32
70
|
const narrowed = run.narrowed.length ? `Asked: <span class="mono">${esc(run.narrowed.join(' '))}</span>. The rest was not run.` : 'The whole suite.';
|
|
33
71
|
const body = `<h1>Tests</h1>
|
|
34
72
|
<p class="lead">Run ${esc(new Date(run.when).toLocaleString('en-GB'))}${run.fast ? ', the fast run' : ''}${run.stopped ? ', stopped at the first failure' : ''}.</p>
|
|
35
|
-
|
|
73
|
+
${tiles}
|
|
36
74
|
<p class="sub">${narrowed}</p>
|
|
37
|
-
|
|
38
|
-
<h2>By area</h2>${table(['Area', 'Passed', 'Failed', 'Not run', 'Result'], rows)}`;
|
|
75
|
+
${table}`;
|
|
39
76
|
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
40
77
|
}
|
|
41
78
|
/**
|
|
@@ -62,12 +99,8 @@ function operationPage(operation, refs) {
|
|
|
62
99
|
return { id: idOf('test', operation.name), kind: 'Tests', title: `${operation.name} · tests`, nav: 'tests', body };
|
|
63
100
|
}
|
|
64
101
|
function areaPage(area) {
|
|
65
|
-
const rows = area.operations.map((one) => {
|
|
66
|
-
const of = ledger(one.cases);
|
|
67
|
-
return [link(`#${idOf('test', one.name)}`, one.name), String(of.passed), String(of.failed), String(of.notRun), RESULT[one.result]];
|
|
68
|
-
});
|
|
69
102
|
const body = `${crumbs(link('#tests', 'Tests'))}<h1>${esc(areaTitle(area.name))}</h1>
|
|
70
|
-
${
|
|
103
|
+
${runner([area], area.name)}`;
|
|
71
104
|
return { id: idOf('test-area', area.name), kind: 'Tests', title: `${areaTitle(area.name)} · tests`, nav: 'tests', body };
|
|
72
105
|
}
|
|
73
106
|
/** The areas that have something to run: one that holds words only has no test. */
|
package/dist/explorer/wiki.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { addressOf } from '../addresses.js';
|
|
7
7
|
import { casesOf, gapsOf } from '../planning.js';
|
|
8
8
|
import { named, sameSentence } from '../suite.js';
|
|
9
|
+
import { dependenciesOf } from './depending.js';
|
|
9
10
|
import { refsOf } from './elo.js';
|
|
10
11
|
/** A name, made safe for an anchor, as the suite is read to have no two at one (addresses.ts); and the anchor of a citizen of a kind: `predicate-seesBoard`. */
|
|
11
12
|
export const slug = addressOf;
|
|
@@ -60,7 +61,7 @@ function areasOf(suite, operations) {
|
|
|
60
61
|
*/
|
|
61
62
|
function typeKindsOf(model, operations) {
|
|
62
63
|
const itemOf = (name) => /^\[\s*(\w+)\s*\]$/.exec(model.types.find((one) => one.name === name)?.formaldef.trim() ?? '')?.[1];
|
|
63
|
-
const told = new Set(model.state.flatMap((one) =>
|
|
64
|
+
const told = new Set(model.state.flatMap((one) => [one.web?.type, one.web?.one?.type]).flatMap((type) => (type ? [type, itemOf(type) ?? type] : [])));
|
|
64
65
|
const exchanged = new Set(operations.flatMap((one) => [one.input, one.output]).filter((one) => Boolean(one)));
|
|
65
66
|
return new Map(model.types.map((one) => [one.name, told.has(one.name) ? 'state' : exchanged.has(one.name) ? 'message' : 'data']));
|
|
66
67
|
}
|
|
@@ -68,6 +69,7 @@ function typeKindsOf(model, operations) {
|
|
|
68
69
|
export function wikiOf(suite, report) {
|
|
69
70
|
const { model } = suite;
|
|
70
71
|
const operations = suite.operations.map((operation) => operationView(operation, suite, report)).sort((a, b) => a.area.localeCompare(b.area) || a.name.localeCompare(b.name));
|
|
72
|
+
const refs = refsOf(model);
|
|
71
73
|
return {
|
|
72
74
|
system: model.system,
|
|
73
75
|
descriptions: model.descriptions,
|
|
@@ -78,12 +80,12 @@ export function wikiOf(suite, report) {
|
|
|
78
80
|
actors: model.actors.map(({ name, description, source, is, with: held }) => ({ name, description, source, is, signsIn: held !== null })),
|
|
79
81
|
backgrounds: model.backgrounds,
|
|
80
82
|
state: model.state,
|
|
81
|
-
relations: model.relations,
|
|
82
83
|
types: model.types,
|
|
83
84
|
worldKeys: Object.keys(model.world),
|
|
84
|
-
refs
|
|
85
|
+
refs,
|
|
85
86
|
run: report ? runOf(report, operations) : null,
|
|
86
87
|
typeKinds: typeKindsOf(model, suite.operations),
|
|
88
|
+
dependencies: dependenciesOf(model, suite.operations, refs),
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
/** The counterexamples that violate a precondition: those that are "for" its sentence. */
|
package/dist/files.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// specification/
|
|
8
8
|
// system.yml what the specified system is called, and is (optional)
|
|
9
9
|
// areas.yml, agents.yml, backgrounds.yml the areas, who performs operations, where a case starts
|
|
10
|
-
// state.yml what
|
|
10
|
+
// state.yml the state variables, and what observes each: a route, a table
|
|
11
11
|
// world.yml what the runner knows: who calls, and what they hold
|
|
12
12
|
// _shared/predicates.yml, functions.yml, conditions.yml, types.elo what every area says
|
|
13
13
|
// <area>/predicates.yml, functions.yml, conditions.yml, types.elo what one area says
|
|
@@ -23,7 +23,7 @@ import { modelOf } from './modelling.js';
|
|
|
23
23
|
import { misnamed } from './naming.js';
|
|
24
24
|
import { crowded } from './notation.js';
|
|
25
25
|
import { operationOf } from './reading.js';
|
|
26
|
-
import { NOTHING_SAID,
|
|
26
|
+
import { NOTHING_SAID, isBefore, observedBy } from './suite.js';
|
|
27
27
|
/**
|
|
28
28
|
* A YAML file as it was written, and where each thing is in it. What cannot be read is told, and
|
|
29
29
|
* is nothing: under the name the file is told by, which of an operation is its file from the
|
|
@@ -41,14 +41,20 @@ function written(path, problems, as = path) {
|
|
|
41
41
|
}
|
|
42
42
|
const named = (directory, extension) => (existsSync(directory) ? readdirSync(directory, { recursive: true, encoding: 'utf8' }).filter((file) => file.endsWith(extension)).sort() : []);
|
|
43
43
|
/** What a suite names, that its formaldefs may read. */
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
export function namesOf(model) {
|
|
45
|
+
const told = observedBy(model, 'web');
|
|
46
|
+
const kept = observedBy(model, 'db');
|
|
47
|
+
return {
|
|
48
|
+
states: told.map((one) => one.name),
|
|
49
|
+
relations: kept.map((one) => one.name),
|
|
50
|
+
items: model.state.flatMap((one) => (one.item ? [{ name: one.item.name, of: one.name, key: one.item.key, web: Boolean(one.web), ...(one.db ? { db: one.db.key } : {}) }] : [])),
|
|
51
|
+
actors: model.actors.map((one) => one.name),
|
|
52
|
+
definitions: model.definitions,
|
|
53
|
+
types: Object.fromEntries(told.flatMap((one) => (one.web?.type ? [[one.name, one.web.type]] : []))),
|
|
54
|
+
members: Object.fromEntries(told.flatMap((one) => (one.web?.member ? [[one.name, one.web.member]] : []))),
|
|
55
|
+
columns: Object.fromEntries(kept.map((one) => [one.name, [...one.db.key, ...one.db.attributes]])),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
52
58
|
/** Where a suite says what it specifies. */
|
|
53
59
|
export const SPECIFICATION = 'specification';
|
|
54
60
|
/** Where every area's words are. */
|
|
@@ -120,7 +126,7 @@ function unreadable(operation, meaning, types) {
|
|
|
120
126
|
const clauses = [...operation.clauses, ...operation.cases.flatMap((kase) => kase.and)].filter((clause) => clause.formaldef);
|
|
121
127
|
const declared = (type) => (type && types.includes(type) ? type : undefined);
|
|
122
128
|
const exchanged = { input: declared(operation.input), output: declared(operation.output) };
|
|
123
|
-
const said = clauses.map((clause) => [clause.description, meaning.unreadable(clause.formaldef ?? '',
|
|
129
|
+
const said = clauses.map((clause) => [clause.description, meaning.unreadable(clause.formaldef ?? '', isBefore(clause) ? 'pre' : 'post', exchanged)]);
|
|
124
130
|
const given = operation.cases.filter((kase) => typeof kase.input === 'string').map((kase) => [`the input of "${kase.description}"`, meaning.unreadable(kase.input, 'given')]);
|
|
125
131
|
const unknown = [operation.input, operation.output].filter((type) => type && !types.includes(type)).map((type) => `"${type}" is not a type of the suite`);
|
|
126
132
|
return [...unknown, ...[...said, ...given].flatMap(([says, problem]) => (problem ? [`"${says}": ${problem}`] : []))].map((problem) => `${operation.file}: ${problem}`);
|
|
@@ -143,12 +149,17 @@ function duplicates(operations) {
|
|
|
143
149
|
const names = operations.map((operation) => operation.name);
|
|
144
150
|
return [...new Set(names.filter((name, at) => names.indexOf(name) !== at))].map((name) => `two files specify the operation "${name}"`);
|
|
145
151
|
}
|
|
146
|
-
/** The states whose type no area declares: told, and read as states of no type. */
|
|
152
|
+
/** The states whose type no area declares, of what tells them whole or of one item: told, and read as states of no type. */
|
|
147
153
|
function untyped(model, declared) {
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
const problems = [];
|
|
155
|
+
for (const one of model.state) {
|
|
156
|
+
for (const told of [one.web, one.web?.one]) {
|
|
157
|
+
if (!told?.type || declared.includes(told.type))
|
|
158
|
+
continue;
|
|
159
|
+
problems.push(`${STATE}: state "${one.name}": "${told.type}" is not a type of the suite`);
|
|
160
|
+
told.type = undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
152
163
|
return problems;
|
|
153
164
|
}
|
|
154
165
|
/** Reads the suite of a directory. */
|