@driftsys/markspec 0.12.0 → 0.13.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/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +19 -5
- package/esm/ast/equivalence.js +14 -2
- package/esm/ast/nodes.d.ts +15 -3
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +18 -3
- package/esm/compiler/mod.d.ts +34 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +112 -48
- package/esm/compiler/schema.d.ts +3 -2
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +6 -3
- package/esm/config/markspec.d.ts +2 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +47 -5
- package/esm/criteria/scenarios.d.ts +55 -0
- package/esm/criteria/scenarios.d.ts.map +1 -0
- package/esm/criteria/scenarios.js +133 -0
- package/esm/discovery/mod.d.ts +20 -1
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +105 -17
- package/esm/discovery/projects.d.ts +6 -4
- package/esm/discovery/projects.d.ts.map +1 -1
- package/esm/discovery/projects.js +27 -17
- package/esm/formatter/entry_body.d.ts +13 -12
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +25 -17
- package/esm/formatter/feature_file.d.ts +40 -0
- package/esm/formatter/feature_file.d.ts.map +1 -0
- package/esm/formatter/feature_file.js +88 -0
- package/esm/formatter/md_equiv.d.ts +6 -5
- package/esm/formatter/md_equiv.d.ts.map +1 -1
- package/esm/formatter/md_equiv.js +6 -5
- package/esm/formatter/mod.d.ts +25 -3
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +267 -27
- package/esm/formatter/tab_markers.d.ts +15 -0
- package/esm/formatter/tab_markers.d.ts.map +1 -0
- package/esm/formatter/tab_markers.js +133 -0
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +18 -3
- package/esm/gherkin/load.d.ts +35 -0
- package/esm/gherkin/load.d.ts.map +1 -0
- package/esm/gherkin/load.js +39 -0
- package/esm/gherkin/parse.d.ts +11 -0
- package/esm/gherkin/parse.d.ts.map +1 -0
- package/esm/gherkin/parse.js +311 -0
- package/esm/gherkin/position.d.ts +23 -0
- package/esm/gherkin/position.d.ts.map +1 -0
- package/esm/gherkin/position.js +21 -0
- package/esm/gherkin/procedure.d.ts +76 -0
- package/esm/gherkin/procedure.d.ts.map +1 -0
- package/esm/gherkin/procedure.js +164 -0
- package/esm/gherkin/project.d.ts +35 -0
- package/esm/gherkin/project.d.ts.map +1 -0
- package/esm/gherkin/project.js +64 -0
- package/esm/gherkin/role.d.ts +23 -0
- package/esm/gherkin/role.d.ts.map +1 -0
- package/esm/gherkin/role.js +28 -0
- package/esm/gherkin/types.d.ts +118 -0
- package/esm/gherkin/types.d.ts.map +1 -0
- package/esm/gherkin/types.js +12 -0
- package/esm/lock/acquire_compile.d.ts +12 -4
- package/esm/lock/acquire_compile.d.ts.map +1 -1
- package/esm/lock/acquire_compile.js +15 -5
- package/esm/lock/canonical_edges.d.ts +6 -2
- package/esm/lock/canonical_edges.d.ts.map +1 -1
- package/esm/lock/canonical_edges.js +10 -3
- package/esm/lock/model.d.ts +5 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +2 -0
- package/esm/lock/resolve.d.ts +6 -2
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +36 -4
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +7 -1
- package/esm/lock/upstream_deps.js +1 -1
- package/esm/mod.d.ts +24 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +19 -5
- package/esm/model/mod.d.ts +43 -2
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -1
- package/esm/model/relations.d.ts +9 -0
- package/esm/model/relations.d.ts.map +1 -1
- package/esm/model/relations.js +16 -1
- package/esm/parser/attributes.d.ts +82 -3
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +199 -32
- package/esm/parser/body_tokens.d.ts +1 -1
- package/esm/parser/body_tokens.d.ts.map +1 -1
- package/esm/parser/body_tokens.js +49 -35
- package/esm/parser/feature_file.d.ts +116 -0
- package/esm/parser/feature_file.d.ts.map +1 -0
- package/esm/parser/feature_file.js +540 -0
- package/esm/parser/markdown.d.ts +7 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +129 -40
- package/esm/parser/mod.d.ts +18 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +51 -0
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +8 -3
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +20 -7
- package/esm/refs/split.d.ts +58 -0
- package/esm/refs/split.d.ts.map +1 -0
- package/esm/refs/split.js +137 -0
- package/esm/reporter/mod.d.ts +7 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +113 -3
- package/esm/sync/mapping.d.ts +4 -3
- package/esm/sync/mapping.d.ts.map +1 -1
- package/esm/sync/mapping.js +52 -9
- package/esm/util/display_id.d.ts +20 -0
- package/esm/util/display_id.d.ts.map +1 -0
- package/esm/util/display_id.js +19 -0
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +4 -1
- package/esm/validator/block_role.d.ts +40 -0
- package/esm/validator/block_role.d.ts.map +1 -0
- package/esm/validator/block_role.js +109 -0
- package/esm/validator/feature_ac.d.ts.map +1 -1
- package/esm/validator/feature_ac.js +6 -1
- package/esm/validator/feature_parse.d.ts +35 -0
- package/esm/validator/feature_parse.d.ts.map +1 -0
- package/esm/validator/feature_parse.js +69 -0
- package/esm/validator/locators.d.ts +36 -0
- package/esm/validator/locators.d.ts.map +1 -0
- package/esm/validator/locators.js +184 -0
- package/esm/validator/mod.d.ts +10 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +38 -14
- package/esm/validator/normalize.d.ts.map +1 -1
- package/esm/validator/normalize.js +8 -3
- package/esm/validator/per_type_attrs.d.ts +3 -3
- package/esm/validator/per_type_attrs.js +3 -3
- package/esm/validator/pipeline.d.ts +10 -16
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +37 -16
- package/esm/validator/procedure.d.ts +22 -0
- package/esm/validator/procedure.d.ts.map +1 -0
- package/esm/validator/procedure.js +58 -0
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +4 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +4 -1
- package/esm/validator/type_resolution.d.ts +5 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +14 -2
- package/esm/validator/types.d.ts +11 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +26 -4
- package/esm/validator/uxil_family.d.ts +1 -1
- package/package.json +3 -1
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +19 -5
- package/script/ast/equivalence.js +14 -2
- package/script/ast/nodes.d.ts +15 -3
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +18 -3
- package/script/compiler/mod.d.ts +34 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +110 -46
- package/script/compiler/schema.d.ts +3 -2
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +6 -3
- package/script/config/markspec.d.ts +2 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +47 -5
- package/script/criteria/scenarios.d.ts +55 -0
- package/script/criteria/scenarios.d.ts.map +1 -0
- package/script/criteria/scenarios.js +139 -0
- package/script/discovery/mod.d.ts +20 -1
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +106 -17
- package/script/discovery/projects.d.ts +6 -4
- package/script/discovery/projects.d.ts.map +1 -1
- package/script/discovery/projects.js +27 -17
- package/script/formatter/entry_body.d.ts +13 -12
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +25 -17
- package/script/formatter/feature_file.d.ts +40 -0
- package/script/formatter/feature_file.d.ts.map +1 -0
- package/script/formatter/feature_file.js +92 -0
- package/script/formatter/md_equiv.d.ts +6 -5
- package/script/formatter/md_equiv.d.ts.map +1 -1
- package/script/formatter/md_equiv.js +6 -5
- package/script/formatter/mod.d.ts +25 -3
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +266 -26
- package/script/formatter/tab_markers.d.ts +15 -0
- package/script/formatter/tab_markers.d.ts.map +1 -0
- package/script/formatter/tab_markers.js +141 -0
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +18 -3
- package/script/gherkin/load.d.ts +35 -0
- package/script/gherkin/load.d.ts.map +1 -0
- package/script/gherkin/load.js +76 -0
- package/script/gherkin/parse.d.ts +11 -0
- package/script/gherkin/parse.d.ts.map +1 -0
- package/script/gherkin/parse.js +314 -0
- package/script/gherkin/position.d.ts +23 -0
- package/script/gherkin/position.d.ts.map +1 -0
- package/script/gherkin/position.js +24 -0
- package/script/gherkin/procedure.d.ts +76 -0
- package/script/gherkin/procedure.d.ts.map +1 -0
- package/script/gherkin/procedure.js +169 -0
- package/script/gherkin/project.d.ts +35 -0
- package/script/gherkin/project.d.ts.map +1 -0
- package/script/gherkin/project.js +67 -0
- package/script/gherkin/role.d.ts +23 -0
- package/script/gherkin/role.d.ts.map +1 -0
- package/script/gherkin/role.js +31 -0
- package/script/gherkin/types.d.ts +118 -0
- package/script/gherkin/types.d.ts.map +1 -0
- package/script/gherkin/types.js +13 -0
- package/script/lock/acquire_compile.d.ts +12 -4
- package/script/lock/acquire_compile.d.ts.map +1 -1
- package/script/lock/acquire_compile.js +15 -5
- package/script/lock/canonical_edges.d.ts +6 -2
- package/script/lock/canonical_edges.d.ts.map +1 -1
- package/script/lock/canonical_edges.js +10 -3
- package/script/lock/model.d.ts +5 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +2 -0
- package/script/lock/resolve.d.ts +6 -2
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +36 -4
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +7 -1
- package/script/lock/upstream_deps.js +1 -1
- package/script/mod.d.ts +24 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +48 -6
- package/script/model/mod.d.ts +43 -2
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +2 -1
- package/script/model/relations.d.ts +9 -0
- package/script/model/relations.d.ts.map +1 -1
- package/script/model/relations.js +17 -1
- package/script/parser/attributes.d.ts +82 -3
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +205 -33
- package/script/parser/body_tokens.d.ts +1 -1
- package/script/parser/body_tokens.d.ts.map +1 -1
- package/script/parser/body_tokens.js +49 -35
- package/script/parser/feature_file.d.ts +116 -0
- package/script/parser/feature_file.d.ts.map +1 -0
- package/script/parser/feature_file.js +548 -0
- package/script/parser/markdown.d.ts +7 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +128 -39
- package/script/parser/mod.d.ts +18 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +52 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +8 -3
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +20 -7
- package/script/refs/split.d.ts +58 -0
- package/script/refs/split.d.ts.map +1 -0
- package/script/refs/split.js +145 -0
- package/script/reporter/mod.d.ts +7 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +113 -3
- package/script/sync/mapping.d.ts +4 -3
- package/script/sync/mapping.d.ts.map +1 -1
- package/script/sync/mapping.js +52 -9
- package/script/util/display_id.d.ts +20 -0
- package/script/util/display_id.d.ts.map +1 -0
- package/script/util/display_id.js +22 -0
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +4 -1
- package/script/validator/block_role.d.ts +40 -0
- package/script/validator/block_role.d.ts.map +1 -0
- package/script/validator/block_role.js +112 -0
- package/script/validator/feature_ac.d.ts.map +1 -1
- package/script/validator/feature_ac.js +6 -1
- package/script/validator/feature_parse.d.ts +35 -0
- package/script/validator/feature_parse.d.ts.map +1 -0
- package/script/validator/feature_parse.js +73 -0
- package/script/validator/locators.d.ts +36 -0
- package/script/validator/locators.d.ts.map +1 -0
- package/script/validator/locators.js +188 -0
- package/script/validator/mod.d.ts +10 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +38 -14
- package/script/validator/normalize.d.ts.map +1 -1
- package/script/validator/normalize.js +8 -3
- package/script/validator/per_type_attrs.d.ts +3 -3
- package/script/validator/per_type_attrs.js +3 -3
- package/script/validator/pipeline.d.ts +10 -16
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +36 -16
- package/script/validator/procedure.d.ts +22 -0
- package/script/validator/procedure.d.ts.map +1 -0
- package/script/validator/procedure.js +61 -0
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +4 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +4 -1
- package/script/validator/type_resolution.d.ts +5 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +14 -2
- package/script/validator/types.d.ts +11 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +27 -4
- package/script/validator/uxil_family.d.ts +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module refs/split
|
|
3
|
+
*
|
|
4
|
+
* Bracket-aware splitting of trace attribute values. A value is
|
|
5
|
+
* `target [ 1*WSP "[" locator "]" ]`. A locator can contain commas, so a
|
|
6
|
+
* plain split on commas is wrong for it. The escapes `\]` and `\\` are
|
|
7
|
+
* valid inside a locator only; any other backslash sequence (such as `\x`)
|
|
8
|
+
* is kept as written. A locator must follow whitespace after the target,
|
|
9
|
+
* so `A[x]` has no locator. A value without a closed locator is read
|
|
10
|
+
* exactly as before scenario locators existed.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Normalize locator text for comparison: Unicode NFC, trim, and collapse
|
|
14
|
+
* each whitespace run to one space.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeLocator(text) {
|
|
17
|
+
return text.normalize("NFC").trim().replace(/\s+/g, " ");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Split a trace attribute value into its parts. When at least one part has
|
|
21
|
+
* a closed bracket locator after whitespace, commas inside a locator do not
|
|
22
|
+
* split. Otherwise the value is split on every comma, exactly as before
|
|
23
|
+
* scenario locators existed, so an unterminated `[` does not change how a
|
|
24
|
+
* value is read. Parts are trimmed and empty parts are dropped.
|
|
25
|
+
*/
|
|
26
|
+
export function splitTraceValues(value) {
|
|
27
|
+
// An unclosed `[` never protects commas (see splitOutsideLocators).
|
|
28
|
+
const bracketParts = splitOutsideLocators(value);
|
|
29
|
+
if (bracketParts.some((p) => LOCATOR_VALUE_RE.test(p)))
|
|
30
|
+
return bracketParts;
|
|
31
|
+
return value.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
|
|
32
|
+
}
|
|
33
|
+
/** Split on commas outside a closed locator. A `[` opens a locator only
|
|
34
|
+
* after whitespace; an unclosed locator does not protect its commas. */
|
|
35
|
+
function splitOutsideLocators(value) {
|
|
36
|
+
const parts = [];
|
|
37
|
+
let current = "";
|
|
38
|
+
let inLocator = false;
|
|
39
|
+
for (let i = 0; i < value.length; i++) {
|
|
40
|
+
const ch = value[i];
|
|
41
|
+
if (inLocator) {
|
|
42
|
+
if (ch === "\\" && i + 1 < value.length) {
|
|
43
|
+
current += ch + value[++i];
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (ch === "]")
|
|
47
|
+
inLocator = false;
|
|
48
|
+
current += ch;
|
|
49
|
+
}
|
|
50
|
+
else if (ch === "[" && i > 0 && /\s/.test(value[i - 1])) {
|
|
51
|
+
inLocator = true;
|
|
52
|
+
current += ch;
|
|
53
|
+
}
|
|
54
|
+
else if (ch === ",") {
|
|
55
|
+
parts.push(current);
|
|
56
|
+
current = "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
current += ch;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// An unclosed `[` never swallows commas: the rest splits on each comma.
|
|
63
|
+
if (inLocator)
|
|
64
|
+
parts.push(...current.split(","));
|
|
65
|
+
else
|
|
66
|
+
parts.push(current);
|
|
67
|
+
return parts.map((p) => p.trim()).filter((p) => p.length > 0);
|
|
68
|
+
}
|
|
69
|
+
/** `target 1*WSP "[" locator "]"` with escapes inside the locator. The
|
|
70
|
+
* locator may be empty (`A []`); an empty locator names no scenario. */
|
|
71
|
+
const LOCATOR_VALUE_RE = /^(\S+)\s+\[((?:\\[\s\S]|[^\]\\])*)\]$/;
|
|
72
|
+
/**
|
|
73
|
+
* Parse one value from {@linkcode splitTraceValues} into target and
|
|
74
|
+
* optional locator. A value without a closed locator after whitespace is
|
|
75
|
+
* kept whole as the target, as before scenario locators existed.
|
|
76
|
+
*/
|
|
77
|
+
export function parseTraceValue(raw) {
|
|
78
|
+
const value = raw.trim();
|
|
79
|
+
const match = LOCATOR_VALUE_RE.exec(value);
|
|
80
|
+
if (!match)
|
|
81
|
+
return { target: value };
|
|
82
|
+
const locatorRaw = match[2];
|
|
83
|
+
return {
|
|
84
|
+
target: match[1],
|
|
85
|
+
locator: normalizeLocator(locatorRaw.replace(/\\([\]\\])/g, "$1")),
|
|
86
|
+
locatorRaw,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* `true` when a trace value has a `[` after whitespace that no unescaped
|
|
91
|
+
* `]` closes. Such a value has no locator.
|
|
92
|
+
*/
|
|
93
|
+
export function isUnterminatedLocator(raw) {
|
|
94
|
+
const value = raw.trim();
|
|
95
|
+
let inLocator = false;
|
|
96
|
+
for (let i = 0; i < value.length; i++) {
|
|
97
|
+
const ch = value[i];
|
|
98
|
+
if (inLocator) {
|
|
99
|
+
if (ch === "\\")
|
|
100
|
+
i++;
|
|
101
|
+
else if (ch === "]")
|
|
102
|
+
inLocator = false;
|
|
103
|
+
}
|
|
104
|
+
else if (ch === "[" && i > 0 && /\s/.test(value[i - 1])) {
|
|
105
|
+
inLocator = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return inLocator;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The target of a trace value for existence and value-type checks: the
|
|
112
|
+
* target before a closed bracket locator, else the trimmed value as
|
|
113
|
+
* written.
|
|
114
|
+
*/
|
|
115
|
+
export function traceTarget(raw) {
|
|
116
|
+
return parseTraceValue(raw).target;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The tokens of a trace value that can name another entry, for reference
|
|
120
|
+
* scans (find references, dependent counts). A closed locator is dropped,
|
|
121
|
+
* so an ID written inside a locator is not a reference. Any other part is
|
|
122
|
+
* split on whitespace and commas, as before scenario locators existed.
|
|
123
|
+
*/
|
|
124
|
+
export function referenceTokens(value) {
|
|
125
|
+
const out = [];
|
|
126
|
+
for (const part of splitTraceValues(value)) {
|
|
127
|
+
const parsed = parseTraceValue(part);
|
|
128
|
+
if (parsed.locator !== undefined) {
|
|
129
|
+
out.push(parsed.target);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
for (const t of part.split(/[\s,]+/))
|
|
133
|
+
if (t.length > 0)
|
|
134
|
+
out.push(t);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
package/esm/reporter/mod.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* traceability matrices and coverage reports in md, json, or csv format.
|
|
6
6
|
*/
|
|
7
7
|
import type { CompileResult } from "../compiler/mod.js";
|
|
8
|
+
import type { EffectiveProfile } from "../model/mod.js";
|
|
8
9
|
/** Supported report kinds. */
|
|
9
10
|
export type ReportKind = "traceability" | "coverage";
|
|
10
11
|
/** Supported output formats. */
|
|
@@ -30,6 +31,12 @@ export interface ReportOptions {
|
|
|
30
31
|
* reference leaf.
|
|
31
32
|
*/
|
|
32
33
|
readonly dependencyUpstreamIds?: ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The active profile. The criterion coverage section counts a verifier
|
|
36
|
+
* only when its type is, or extends, the core `Test` type; without a
|
|
37
|
+
* profile, only core types are resolved.
|
|
38
|
+
*/
|
|
39
|
+
readonly profile?: EffectiveProfile;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
35
42
|
* Generate a report from compiled traceability graph.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAa,gBAAgB,EAAS,MAAM,iBAAiB,CAAC;AAQ1E,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAErD,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;OASG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAa5E"}
|
package/esm/reporter/mod.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Output reporters. Transforms compiled traceability graph into
|
|
5
5
|
* traceability matrices and coverage reports in md, json, or csv format.
|
|
6
6
|
*/
|
|
7
|
+
import { isTestEntry } from "../criteria/scenarios.js";
|
|
7
8
|
import { formatEntryOrigin, isCorpusEntry, isUpstreamEntry, } from "../model/mod.js";
|
|
8
9
|
/**
|
|
9
10
|
* Generate a report from compiled traceability graph.
|
|
@@ -17,7 +18,7 @@ export function report(result, options) {
|
|
|
17
18
|
if (options.kind === "traceability") {
|
|
18
19
|
return formatTraceability(result, entries, options.format);
|
|
19
20
|
}
|
|
20
|
-
return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds);
|
|
21
|
+
return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds, options.profile);
|
|
21
22
|
}
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
24
|
// Filtering
|
|
@@ -143,10 +144,13 @@ function computeCoverage(result, entries, opts = {}) {
|
|
|
143
144
|
gaps: { orphans, unsatisfied },
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
|
-
function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
147
|
+
function formatCoverage(result, entries, format, dependencyUpstreamIds, profile) {
|
|
147
148
|
const stats = computeCoverage(result, entries, { dependencyUpstreamIds });
|
|
149
|
+
// Absent when no reported entry has criteria, so coverage output for a
|
|
150
|
+
// project without feature blocks stays unchanged.
|
|
151
|
+
const criteria = computeCriterionCoverage(result, entries, profile);
|
|
148
152
|
if (format === "json") {
|
|
149
|
-
return JSON.stringify(stats, null, 2);
|
|
153
|
+
return JSON.stringify(criteria ? { ...stats, criteria } : stats, null, 2);
|
|
150
154
|
}
|
|
151
155
|
if (format === "csv") {
|
|
152
156
|
const lines = [
|
|
@@ -158,6 +162,9 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
|
158
162
|
`Orphans,${stats.gaps.orphans.length}`,
|
|
159
163
|
`Unsatisfied parents,${stats.gaps.unsatisfied.length}`,
|
|
160
164
|
];
|
|
165
|
+
if (criteria) {
|
|
166
|
+
lines.push(`Criteria total,${criteria.total}`, `Criteria verified,${criteria.verified}`);
|
|
167
|
+
}
|
|
161
168
|
return lines.join("\n");
|
|
162
169
|
}
|
|
163
170
|
// Markdown
|
|
@@ -182,8 +189,111 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
|
182
189
|
if (stats.gaps.unsatisfied.length > 0) {
|
|
183
190
|
lines.push("## Unsatisfied parents (STK/SYS with no children)", "", ...stats.gaps.unsatisfied.map((id) => `- ${id}`), "");
|
|
184
191
|
}
|
|
192
|
+
if (criteria)
|
|
193
|
+
lines.push(...formatCriteriaMarkdown(criteria));
|
|
185
194
|
return lines.join("\n");
|
|
186
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Compute per-criterion verification for the reported entries that carry
|
|
198
|
+
* criteria. Returns `undefined` when none does.
|
|
199
|
+
*
|
|
200
|
+
* Only `verifies` links count, and only when the verifier's type is, or
|
|
201
|
+
* extends, the core `Test` type; an entry never verifies itself. A link
|
|
202
|
+
* without a locator verifies every criterion of its target. A link with a
|
|
203
|
+
* locator verifies the named criterion only when `locatorResolved` is
|
|
204
|
+
* `true`. A generated inverse runs from the target to the verifier; the
|
|
205
|
+
* verifier set removes the duplicate it makes of the authored link.
|
|
206
|
+
* Upstream (federated) entries are not reported.
|
|
207
|
+
*/
|
|
208
|
+
function computeCriterionCoverage(result, entries, profile) {
|
|
209
|
+
const withCriteria = entries.filter((e) => (e.criteria?.length ?? 0) > 0 && !isUpstreamEntry(e));
|
|
210
|
+
if (withCriteria.length === 0)
|
|
211
|
+
return undefined;
|
|
212
|
+
// A link end may be written as a ULID; report display IDs.
|
|
213
|
+
const byUlid = new Map();
|
|
214
|
+
for (const e of result.entries.values())
|
|
215
|
+
if (e.id)
|
|
216
|
+
byUlid.set(e.id, e);
|
|
217
|
+
const resolve = (id) => result.entries.get(id) ?? byUlid.get(id);
|
|
218
|
+
// Target display ID → criterion name ("" for whole entry) → verifiers.
|
|
219
|
+
const verifiers = new Map();
|
|
220
|
+
for (const link of result.links) {
|
|
221
|
+
if (link.kind !== "verifies")
|
|
222
|
+
continue;
|
|
223
|
+
if (link.locator !== undefined && link.locatorResolved !== true)
|
|
224
|
+
continue;
|
|
225
|
+
const generated = link.origin === "generated";
|
|
226
|
+
const targetEntry = resolve(generated ? link.from : link.to);
|
|
227
|
+
const verifierEntry = resolve(generated ? link.to : link.from);
|
|
228
|
+
if (!targetEntry || !verifierEntry)
|
|
229
|
+
continue;
|
|
230
|
+
if (targetEntry.displayId === verifierEntry.displayId)
|
|
231
|
+
continue;
|
|
232
|
+
if (!isTestEntry(verifierEntry, profile))
|
|
233
|
+
continue;
|
|
234
|
+
const target = targetEntry.displayId;
|
|
235
|
+
const verifier = verifierEntry.displayId;
|
|
236
|
+
let byName = verifiers.get(target);
|
|
237
|
+
if (!byName) {
|
|
238
|
+
byName = new Map();
|
|
239
|
+
verifiers.set(target, byName);
|
|
240
|
+
}
|
|
241
|
+
const key = link.locator ?? "";
|
|
242
|
+
let set = byName.get(key);
|
|
243
|
+
if (!set) {
|
|
244
|
+
set = new Set();
|
|
245
|
+
byName.set(key, set);
|
|
246
|
+
}
|
|
247
|
+
set.add(verifier);
|
|
248
|
+
}
|
|
249
|
+
let total = 0;
|
|
250
|
+
let verified = 0;
|
|
251
|
+
const rows = withCriteria.map((entry) => {
|
|
252
|
+
const byName = verifiers.get(entry.displayId);
|
|
253
|
+
const whole = byName?.get("") ?? new Set();
|
|
254
|
+
const criteria = entry.criteria.map((c) => {
|
|
255
|
+
const named = c.addressable ? byName?.get(c.name) : undefined;
|
|
256
|
+
const all = new Set([...whole, ...(named ?? [])]);
|
|
257
|
+
return {
|
|
258
|
+
name: c.name,
|
|
259
|
+
addressable: c.addressable,
|
|
260
|
+
verifiedBy: [...all].sort(),
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
const entryVerified = criteria.filter((c) => c.verifiedBy.length > 0)
|
|
264
|
+
.length;
|
|
265
|
+
total += criteria.length;
|
|
266
|
+
verified += entryVerified;
|
|
267
|
+
return {
|
|
268
|
+
displayId: entry.displayId,
|
|
269
|
+
title: entry.title,
|
|
270
|
+
state: entryVerified === criteria.length
|
|
271
|
+
? "full"
|
|
272
|
+
: entryVerified === 0
|
|
273
|
+
? "none"
|
|
274
|
+
: "partial",
|
|
275
|
+
verified: entryVerified,
|
|
276
|
+
total: criteria.length,
|
|
277
|
+
criteria,
|
|
278
|
+
};
|
|
279
|
+
});
|
|
280
|
+
return { total, verified, entries: rows };
|
|
281
|
+
}
|
|
282
|
+
/** Render the `## Criteria` Markdown section, one text block per entry. */
|
|
283
|
+
function formatCriteriaMarkdown(criteria) {
|
|
284
|
+
const lines = ["## Criteria", ""];
|
|
285
|
+
for (const entry of criteria.entries) {
|
|
286
|
+
const width = Math.max(...entry.criteria.map((c) => c.name.length));
|
|
287
|
+
lines.push("```text", `${entry.displayId} ${entry.title} ${entry.verified}/${entry.total} criteria verified`, ...entry.criteria.map((c) => {
|
|
288
|
+
const mark = c.verifiedBy.length > 0 ? "\u2713" : "\u2717";
|
|
289
|
+
const by = c.verifiedBy.length > 0
|
|
290
|
+
? c.verifiedBy.join(", ")
|
|
291
|
+
: "no verifier";
|
|
292
|
+
return ` ${mark} ${c.name.padEnd(width)} \u2190 ${by}`;
|
|
293
|
+
}), "```", "");
|
|
294
|
+
}
|
|
295
|
+
return lines;
|
|
296
|
+
}
|
|
187
297
|
// ---------------------------------------------------------------------------
|
|
188
298
|
// Helpers
|
|
189
299
|
// ---------------------------------------------------------------------------
|
package/esm/sync/mapping.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* cache TTL.
|
|
8
8
|
*
|
|
9
9
|
* Diagnostic family is `MSL-S###`:
|
|
10
|
-
* - MSL-S001 — malformed YAML / unsupported schema
|
|
10
|
+
* - MSL-S001 — malformed YAML / invalid structure / unsupported schema
|
|
11
11
|
* - MSL-S002 — locked + outbound contradiction
|
|
12
12
|
* - MSL-S003 — unknown conflict policy (newest-wins removed pre-1.0)
|
|
13
13
|
* - MSL-S004 — system ≠ identity.external-id-scheme
|
|
@@ -52,8 +52,9 @@ export interface ParseMappingResult {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Parse and validate one mapping.yaml. Returns the model when valid, or
|
|
55
|
-
* an MSL-S### diagnostic when not.
|
|
56
|
-
*
|
|
55
|
+
* an MSL-S### diagnostic when not. Never throws on invalid YAML or invalid
|
|
56
|
+
* field shapes. Single-shot — stops at the first integrity failure to keep
|
|
57
|
+
* the repair signal clear.
|
|
57
58
|
*/
|
|
58
59
|
export declare function parseMapping(yaml: string, sourcePath: string): ParseMappingResult;
|
|
59
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/sync/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjE,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAErE,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;KAAE,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AASD
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/sync/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjE,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAErE,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;KAAE,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AASD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,kBAAkB,CAoLpB;AASD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,UAAU,EAAE,CA2B3E"}
|
package/esm/sync/mapping.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* cache TTL.
|
|
8
8
|
*
|
|
9
9
|
* Diagnostic family is `MSL-S###`:
|
|
10
|
-
* - MSL-S001 — malformed YAML / unsupported schema
|
|
10
|
+
* - MSL-S001 — malformed YAML / invalid structure / unsupported schema
|
|
11
11
|
* - MSL-S002 — locked + outbound contradiction
|
|
12
12
|
* - MSL-S003 — unknown conflict policy (newest-wins removed pre-1.0)
|
|
13
13
|
* - MSL-S004 — system ≠ identity.external-id-scheme
|
|
@@ -23,8 +23,9 @@ const ALLOWED_POLICIES = new Set([
|
|
|
23
23
|
]);
|
|
24
24
|
/**
|
|
25
25
|
* Parse and validate one mapping.yaml. Returns the model when valid, or
|
|
26
|
-
* an MSL-S### diagnostic when not.
|
|
27
|
-
*
|
|
26
|
+
* an MSL-S### diagnostic when not. Never throws on invalid YAML or invalid
|
|
27
|
+
* field shapes. Single-shot — stops at the first integrity failure to keep
|
|
28
|
+
* the repair signal clear.
|
|
28
29
|
*/
|
|
29
30
|
export function parseMapping(yaml, sourcePath) {
|
|
30
31
|
let raw;
|
|
@@ -34,7 +35,16 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
34
35
|
catch (e) {
|
|
35
36
|
return fail("MSL-S001", `Malformed mapping.yaml: ${e.message}`, sourcePath);
|
|
36
37
|
}
|
|
38
|
+
if (raw === null || raw === undefined) {
|
|
39
|
+
return fail("MSL-S001", "Mapping YAML is empty or null", sourcePath);
|
|
40
|
+
}
|
|
41
|
+
if (!isRecord(raw)) {
|
|
42
|
+
return fail("MSL-S001", "Mapping YAML must be an object", sourcePath);
|
|
43
|
+
}
|
|
37
44
|
const schema = raw.schema;
|
|
45
|
+
if (typeof schema !== "number") {
|
|
46
|
+
return fail("MSL-S001", "Missing or non-number `schema` field", sourcePath);
|
|
47
|
+
}
|
|
38
48
|
if (schema !== SUPPORTED_SCHEMA) {
|
|
39
49
|
return fail("MSL-S001", `Unsupported mapping schema: ${schema} (expected ${SUPPORTED_SCHEMA})`, sourcePath);
|
|
40
50
|
}
|
|
@@ -43,12 +53,18 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
43
53
|
return fail("MSL-S001", "Missing or non-string `system` field", sourcePath);
|
|
44
54
|
}
|
|
45
55
|
const direction = raw.direction;
|
|
56
|
+
if (typeof direction !== "string") {
|
|
57
|
+
return fail("MSL-S001", "Missing or non-string `direction` field", sourcePath);
|
|
58
|
+
}
|
|
46
59
|
if (direction !== "outbound" && direction !== "inbound" &&
|
|
47
60
|
direction !== "bidirectional") {
|
|
48
61
|
return fail("MSL-S001", `Invalid top-level direction '${direction}' (expected outbound/inbound/bidirectional)`, sourcePath);
|
|
49
62
|
}
|
|
50
63
|
const identity = raw.identity;
|
|
51
|
-
|
|
64
|
+
if (!isRecord(identity)) {
|
|
65
|
+
return fail("MSL-S001", "Missing or non-object `identity` field", sourcePath);
|
|
66
|
+
}
|
|
67
|
+
const scheme = identity["external-id-scheme"];
|
|
52
68
|
if (typeof scheme !== "string") {
|
|
53
69
|
return fail("MSL-S001", "Missing identity.external-id-scheme", sourcePath);
|
|
54
70
|
}
|
|
@@ -56,19 +72,42 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
56
72
|
return fail("MSL-S004", `system '${system}' does not match identity.external-id-scheme '${scheme}'`, sourcePath);
|
|
57
73
|
}
|
|
58
74
|
const conflict = raw.conflict;
|
|
75
|
+
if (conflict !== undefined && !isRecord(conflict)) {
|
|
76
|
+
return fail("MSL-S001", "Non-object `conflict` field", sourcePath);
|
|
77
|
+
}
|
|
59
78
|
const policy = conflict?.default;
|
|
79
|
+
if (policy !== undefined && typeof policy !== "string") {
|
|
80
|
+
return fail("MSL-S001", "Non-string conflict.default", sourcePath);
|
|
81
|
+
}
|
|
60
82
|
if (policy !== undefined && !ALLOWED_POLICIES.has(policy)) {
|
|
61
83
|
return fail("MSL-S003", `Unknown conflict policy '${policy}' (allowed: manual, local-wins, remote-wins; newest-wins removed pre-1.0)`, sourcePath);
|
|
62
84
|
}
|
|
63
85
|
const cacheRaw = raw.cache;
|
|
64
|
-
|
|
86
|
+
if (cacheRaw !== undefined && !isRecord(cacheRaw)) {
|
|
87
|
+
return fail("MSL-S001", "Non-object `cache` field", sourcePath);
|
|
88
|
+
}
|
|
89
|
+
const ttlStr = cacheRaw?.ttl === undefined ? "15m" : cacheRaw.ttl;
|
|
90
|
+
if (typeof ttlStr !== "string") {
|
|
91
|
+
return fail("MSL-S001", "Non-string cache.ttl", sourcePath);
|
|
92
|
+
}
|
|
65
93
|
const ttlMs = parseDurationMs(ttlStr);
|
|
66
94
|
if (ttlMs === null) {
|
|
67
95
|
return fail("MSL-S005", `Unparseable cache.ttl '${ttlStr}' (expected: 15m, 1h, 7d etc.)`, sourcePath);
|
|
68
96
|
}
|
|
69
|
-
const attrsRaw = raw.attributes
|
|
97
|
+
const attrsRaw = raw.attributes === undefined ? [] : raw.attributes;
|
|
98
|
+
if (!Array.isArray(attrsRaw)) {
|
|
99
|
+
return fail("MSL-S001", "Non-array `attributes` field", sourcePath);
|
|
100
|
+
}
|
|
70
101
|
const attributes = [];
|
|
71
102
|
for (const a of attrsRaw) {
|
|
103
|
+
if (!isRecord(a) || typeof a.markspec !== "string" ||
|
|
104
|
+
typeof a.external !== "string") {
|
|
105
|
+
return fail("MSL-S001", "Each attribute mapping requires an object with string 'markspec' and 'external' fields", sourcePath);
|
|
106
|
+
}
|
|
107
|
+
if ((a.direction !== undefined && typeof a.direction !== "string") ||
|
|
108
|
+
(a.locked !== undefined && typeof a.locked !== "boolean")) {
|
|
109
|
+
return fail("MSL-S001", "Attribute mapping requires a string 'direction' and boolean 'locked' when present", sourcePath);
|
|
110
|
+
}
|
|
72
111
|
const attrDir = (a.direction === "outbound" || a.direction === "inbound" ||
|
|
73
112
|
a.direction === "bidirectional")
|
|
74
113
|
? a.direction
|
|
@@ -77,9 +116,6 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
77
116
|
if (locked && attrDir === "outbound") {
|
|
78
117
|
return fail("MSL-S002", `Attribute '${a.markspec}': locked: true contradicts direction: outbound`, sourcePath);
|
|
79
118
|
}
|
|
80
|
-
if (typeof a.markspec !== "string" || typeof a.external !== "string") {
|
|
81
|
-
return fail("MSL-S001", "Each attribute mapping requires string 'markspec' and 'external' fields", sourcePath);
|
|
82
|
-
}
|
|
83
119
|
attributes.push({
|
|
84
120
|
markspec: a.markspec,
|
|
85
121
|
external: a.external,
|
|
@@ -99,6 +135,13 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
99
135
|
};
|
|
100
136
|
return { mapping, diagnostics: [] };
|
|
101
137
|
}
|
|
138
|
+
/** Whether a YAML value is a plain mapping rather than a scalar or sequence. */
|
|
139
|
+
function isRecord(value) {
|
|
140
|
+
if (typeof value !== "object" || value === null)
|
|
141
|
+
return false;
|
|
142
|
+
const prototype = Object.getPrototypeOf(value);
|
|
143
|
+
return prototype === Object.prototype || prototype === null;
|
|
144
|
+
}
|
|
102
145
|
/**
|
|
103
146
|
* Cross-system validation: at most one system writes locally per attribute.
|
|
104
147
|
* "Writes locally" = direction is `inbound` or `bidirectional`. Multiple
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DISPLAY_ID_CHAR_RE: RegExp;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DISPLAY_ID_TOKEN_RE: RegExp;
|
|
20
|
+
//# sourceMappingURL=display_id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display_id.d.ts","sourceRoot":"","sources":["../../src/util/display_id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,QAAoB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAEjC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export const DISPLAY_ID_CHAR_RE = /[A-Za-z0-9._/-]/;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export const DISPLAY_ID_TOKEN_RE = new RegExp(`^[A-Za-z0-9]${DISPLAY_ID_CHAR_RE.source}{2,}$`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/validator/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/validator/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAYzB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,kBAAkB,CAoCpB;AAqBD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,UAAU,EAAE,CA8Ed"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { UNIVERSAL_ATTRIBUTE_KEYS } from "../model/mod.js";
|
|
14
14
|
import { validateValue } from "./value_types.js";
|
|
15
|
+
import { traceTarget } from "../refs/split.js";
|
|
15
16
|
/** Core-reserved attribute keys that are always permitted regardless of profile. */
|
|
16
17
|
const CORE_RESERVED_KEYS = new Set([
|
|
17
18
|
"Id",
|
|
@@ -132,8 +133,10 @@ export function validateAttributesForEntry(entry, profile) {
|
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
// MSL-A004: value-type conformance.
|
|
136
|
+
// A bracket locator (`A [x]`) is not part of an id value.
|
|
137
|
+
const isIdType = decl.type === "id" || decl.type === "id-list";
|
|
135
138
|
for (const v of values) {
|
|
136
|
-
const detail = validateValue(v, decl);
|
|
139
|
+
const detail = validateValue(isIdType ? traceTarget(v) : v, decl);
|
|
137
140
|
if (detail !== null) {
|
|
138
141
|
diagnostics.push({
|
|
139
142
|
code: "MSL-A004",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/block_role
|
|
3
|
+
*
|
|
4
|
+
* Diagnostics for the role of a Gherkin block (epic #915, ADR-038).
|
|
5
|
+
*
|
|
6
|
+
* `MSL-B064` (warning): a scenario of a criteria block has no outcome step.
|
|
7
|
+
* A criteria block belongs to an entry that is, or extends, a Requirement
|
|
8
|
+
* or a Contract (see `blockRole`). The scenario has no `Then` step (or the
|
|
9
|
+
* keyword of the block language that means `Then`, including `And` and `But`
|
|
10
|
+
* after it), or no step at all. A scenario with `Given` and `Then` and no
|
|
11
|
+
* action is valid. `Scenario Outline` Examples are not considered.
|
|
12
|
+
*
|
|
13
|
+
* Each `feature` or `gherkin` block is checked in a top-level block or in a
|
|
14
|
+
* list item at any depth, as for `MSL-B062`. A block that has a `parseError`
|
|
15
|
+
* or no `feature` is skipped. Upstream entries are not checked
|
|
16
|
+
* (`emittableEntries`). An entry without a type after classification with
|
|
17
|
+
* the profile is not checked.
|
|
18
|
+
*
|
|
19
|
+
* The warning is reported at the file line of the `Scenario` keyword, in
|
|
20
|
+
* column 1.
|
|
21
|
+
*
|
|
22
|
+
* Four information diagnostics (severity `info`) complete the checks:
|
|
23
|
+
*
|
|
24
|
+
* - `MSL-B065`: in a procedure block (an entry that is, or extends, a Test),
|
|
25
|
+
* a step has an expected result and no action. Reported at the line of the
|
|
26
|
+
* first expected-result step.
|
|
27
|
+
* - `MSL-B066`: a scenario starts with `And` or `But`, which is read as an
|
|
28
|
+
* action. Reported at the line of that step. It applies to every role
|
|
29
|
+
* except an illustration.
|
|
30
|
+
* - `MSL-B067`: in a procedure block, a `# Step` label comment labels no
|
|
31
|
+
* step. Reported at the line of the comment.
|
|
32
|
+
* - `MSL-B068`: a feature block in a typed entry whose type has no role (an
|
|
33
|
+
* illustration). Reported at the first line of the block.
|
|
34
|
+
*
|
|
35
|
+
* The diagnostics of one entry are sorted by file line.
|
|
36
|
+
*/
|
|
37
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
38
|
+
/** Report the block-role diagnostics for `entries`. */
|
|
39
|
+
export declare function checkBlockRoles(entries: readonly Entry[], profile: EffectiveProfile | null): Diagnostic[];
|
|
40
|
+
//# sourceMappingURL=block_role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_role.d.ts","sourceRoot":"","sources":["../../src/validator/block_role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAY3E,uDAAuD;AACvD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,UAAU,EAAE,CAmGd"}
|