@rse/specbook 1.2.4 → 1.2.6
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 +21 -3
- package/dst/specbook-cmd-lint.js +25 -1
- package/dst/specbook-config.js +18 -17
- package/dst/specbook-coverage.d.ts +17 -0
- package/dst/specbook-coverage.js +106 -0
- package/dst/specbook-diagram.js +163 -21
- package/dst/specbook-export-ast.js +11 -1
- package/dst/specbook-export-html.css +236 -5
- package/dst/specbook-export-html.js +312 -7
- package/dst/specbook-export-pdf.js +30 -6
- package/dst/specbook-format-schema.d.ts +12 -0
- package/dst/specbook-format-schema.js +13 -1
- package/dst/specbook-format.md +110 -10
- package/dst/specbook-format.yaml +354 -173
- package/dst/specbook-parse-semantic.js +6 -42
- package/dst/specbook-parse.d.ts +1 -1
- package/dst/specbook-parse.js +1 -1
- package/package.json +5 -5
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { referenceRegex, resolveUnique, resolveSet, chainOf, plainText, assignId } from "./specbook-link.js";
|
|
7
7
|
import { compileValueExpr, splitItems, anchored } from "./specbook-parse-value.js";
|
|
8
|
+
import { referencedCoverage } from "./specbook-coverage.js";
|
|
8
9
|
/* the syntax of a value consisting of exactly one Wiki-style reference */
|
|
9
10
|
const singleReferenceRegex = /^\[\[([^[\]]+)\]\]$/;
|
|
10
11
|
/* match a full property value directly against a value expression
|
|
@@ -431,50 +432,13 @@ const checkRelations = (ctx, schemas) => {
|
|
|
431
432
|
of the flag's reference patterns, itself or through an ancestor, while
|
|
432
433
|
the references from within the subtree of the object itself do not
|
|
433
434
|
count (a lapse is a warning only, as the specification stays valid) */
|
|
434
|
-
const checkReferenced = (ctx,
|
|
435
|
-
|
|
436
|
-
(
|
|
437
|
-
const referrers = new Map();
|
|
438
|
-
const walk = (object) => {
|
|
439
|
-
const chain = chainOf(ctx.linkIndex, object);
|
|
440
|
-
const texts = [object.name, ...object.properties.map((p) => p.value)];
|
|
441
|
-
if (object.description !== undefined)
|
|
442
|
-
texts.push(object.description.description, object.description.rationale ?? "");
|
|
443
|
-
for (const text of texts)
|
|
444
|
-
for (const m of plainText(text).matchAll(referenceRegex)) {
|
|
445
|
-
const target = resolveUnique(ctx.linkIndex, m[1].trim(), object).target;
|
|
446
|
-
if (target !== undefined && !chain.includes(target))
|
|
447
|
-
referrers.set(target, (referrers.get(target) ?? new Set()).add(object));
|
|
448
|
-
}
|
|
449
|
-
object.children.forEach(walk);
|
|
450
|
-
};
|
|
451
|
-
for (const artifact of specification.artifacts)
|
|
452
|
-
artifact.objects.forEach(walk);
|
|
453
|
-
/* resolve the reference patterns of every flagged kind into the
|
|
454
|
-
admissible referencing objects (once per shared schema node) */
|
|
455
|
-
const sources = new Map();
|
|
456
|
-
for (const [object, schema] of schemas) {
|
|
457
|
-
if (schema.referenced === undefined)
|
|
458
|
-
continue;
|
|
459
|
-
let admissible = sources.get(schema);
|
|
460
|
-
if (admissible === undefined) {
|
|
461
|
-
admissible = new Set();
|
|
462
|
-
for (const entry of schema.referenced) {
|
|
463
|
-
const expr = compileValueExpr(entry);
|
|
464
|
-
if (expr.kind === "reference")
|
|
465
|
-
for (const source of resolveSet(ctx.linkIndex, expr.pattern))
|
|
466
|
-
admissible.add(source);
|
|
467
|
-
}
|
|
468
|
-
sources.set(schema, admissible);
|
|
469
|
-
}
|
|
470
|
-
const covered = Array.from(referrers.get(object) ?? [])
|
|
471
|
-
.some((referrer) => chainOf(ctx.linkIndex, referrer).some((o) => admissible.has(o)));
|
|
472
|
-
if (!covered) {
|
|
435
|
+
const checkReferenced = (ctx, schemas) => {
|
|
436
|
+
for (const { schema, uncovered } of referencedCoverage(ctx.linkIndex, schemas))
|
|
437
|
+
for (const object of uncovered) {
|
|
473
438
|
const meta = ctx.metaOf(object);
|
|
474
439
|
ctx.diagnose(meta.file, meta.line, `${object.kind} "${object.name}" is not referenced from any object matching ` +
|
|
475
|
-
schema.referenced.map((entry) => `"${entry}"`).join(" or "), "warning");
|
|
440
|
+
(schema.referenced ?? []).map((entry) => `"${entry}"`).join(" or "), "warning");
|
|
476
441
|
}
|
|
477
|
-
}
|
|
478
442
|
};
|
|
479
443
|
/* validate the parsed specification against the configuration */
|
|
480
444
|
export const validate = (ctx, specification, config) => {
|
|
@@ -527,7 +491,7 @@ export const validate = (ctx, specification, config) => {
|
|
|
527
491
|
been validated on its own */
|
|
528
492
|
checkRelations(ctx, schemas);
|
|
529
493
|
checkAutomata(ctx, schemas);
|
|
530
|
-
checkReferenced(ctx,
|
|
494
|
+
checkReferenced(ctx, schemas);
|
|
531
495
|
/* order the artifacts exactly along the schema definition */
|
|
532
496
|
specification.artifacts.sort((a, b) => (position.get(a) ?? config.length) - (position.get(b) ?? config.length));
|
|
533
497
|
};
|
package/dst/specbook-parse.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Spec } from "./specbook-format-spec.js";
|
|
|
2
2
|
import { type Schema } from "./specbook-format-schema.js";
|
|
3
3
|
import { type SourceFile, type ParseResult } from "./specbook-parse-common.js";
|
|
4
4
|
export { type SourceFile, type ParseResult } from "./specbook-parse-common.js";
|
|
5
|
-
export { resolveArtifact } from "./specbook-parse-semantic.js";
|
|
5
|
+
export { resolveArtifact, collectSchemas } from "./specbook-parse-semantic.js";
|
|
6
6
|
export declare const parseSpecification: (sources: SourceFile[], config?: Schema) => ParseResult;
|
|
7
7
|
export declare const specStatistics: (specification: Spec) => {
|
|
8
8
|
objects: number;
|
package/dst/specbook-parse.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ParseContext } from "./specbook-parse-common.js";
|
|
|
10
10
|
import { parseFile } from "./specbook-parse-syntax.js";
|
|
11
11
|
import { validate, validateReferences } from "./specbook-parse-semantic.js";
|
|
12
12
|
import { validateDiagrams } from "./specbook-diagram.js";
|
|
13
|
-
export { resolveArtifact } from "./specbook-parse-semantic.js";
|
|
13
|
+
export { resolveArtifact, collectSchemas } from "./specbook-parse-semantic.js";
|
|
14
14
|
/* parse a set of specification Markdown files into the specification
|
|
15
15
|
AST and optionally validate the result against a configuration */
|
|
16
16
|
export const parseSpecification = (sources, config) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rse/specbook",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"publishConfig": { "access": "public" },
|
|
5
5
|
"description": "Markdown-based Specification Format (API, CLI and MCP service)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"pdf-lib": "1.17.1",
|
|
25
25
|
"subset-font": "2.7.0",
|
|
26
26
|
"@rse/mrcs": "0.9.2",
|
|
27
|
-
"@rse/gradia": "1.1
|
|
27
|
+
"@rse/gradia": "1.2.1",
|
|
28
28
|
"@toon-format/toon": "4.1.1",
|
|
29
29
|
"valibot": "1.4.2",
|
|
30
30
|
"nunjucks": "3.2.4",
|
|
31
31
|
"@rse/nunjucks-addons": "2.2.0",
|
|
32
32
|
"textframe": "1.2.1",
|
|
33
|
-
"@swc/html": "1.16.
|
|
33
|
+
"@swc/html": "1.16.2",
|
|
34
34
|
"tokenizr": "2.2.1",
|
|
35
|
-
"playwright": "1.
|
|
35
|
+
"playwright": "1.63.0",
|
|
36
36
|
"source-code-error": "1.2.0",
|
|
37
37
|
"commander": "15.0.0",
|
|
38
38
|
"chalk": "6.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"source-code-pro": "2.42.0",
|
|
65
65
|
"@fontsource/noto-sans-symbols": "5.3.0",
|
|
66
66
|
"postcss": "8.5.28",
|
|
67
|
-
"postcss-cli": "
|
|
67
|
+
"postcss-cli": "12.0.0",
|
|
68
68
|
"postcss-url": "10.1.4",
|
|
69
69
|
"stylus": "0.64.0",
|
|
70
70
|
"@rse/stx": "1.1.6",
|