@driftsys/markspec 0.2.0 → 0.3.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 +32 -8
- package/esm/compiler/inverses.d.ts +22 -0
- package/esm/compiler/inverses.d.ts.map +1 -0
- package/esm/compiler/inverses.js +147 -0
- package/esm/compiler/link_target.d.ts +19 -0
- package/esm/compiler/link_target.d.ts.map +1 -0
- package/esm/compiler/link_target.js +66 -0
- package/esm/compiler/mod.d.ts +7 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +61 -14
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +20 -1
- package/esm/config/markspec.d.ts +51 -0
- package/esm/config/markspec.d.ts.map +1 -0
- package/esm/config/markspec.js +216 -0
- package/esm/config/mod.d.ts +4 -0
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +27 -16
- package/esm/formatter/mod.d.ts +12 -2
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +130 -22
- package/esm/mod.d.ts +10 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +5 -2
- package/esm/model/attributes.d.ts +47 -0
- package/esm/model/attributes.d.ts.map +1 -0
- package/esm/model/attributes.js +97 -0
- package/esm/model/mod.d.ts +255 -26
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +27 -1
- package/esm/model/profile.d.ts +189 -0
- package/esm/model/profile.d.ts.map +1 -0
- package/esm/model/profile.js +31 -0
- package/esm/parser/attributes.d.ts +13 -1
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +47 -0
- package/esm/parser/frontmatter.d.ts +53 -0
- package/esm/parser/frontmatter.d.ts.map +1 -0
- package/esm/parser/frontmatter.js +185 -0
- package/esm/parser/grammars.js +11 -2
- package/esm/parser/markdown.d.ts +11 -4
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +85 -38
- package/esm/parser/mod.d.ts +26 -10
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +39 -9
- package/esm/parser/source.d.ts +12 -8
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +20 -13
- package/esm/profile/cache.d.ts +29 -0
- package/esm/profile/cache.d.ts.map +1 -0
- package/esm/profile/cache.js +45 -0
- package/esm/profile/chain.d.ts +42 -0
- package/esm/profile/chain.d.ts.map +1 -0
- package/esm/profile/chain.js +193 -0
- package/esm/profile/git-cache.d.ts +73 -0
- package/esm/profile/git-cache.d.ts.map +1 -0
- package/esm/profile/git-cache.js +96 -0
- package/esm/profile/load.d.ts +28 -0
- package/esm/profile/load.d.ts.map +1 -0
- package/esm/profile/load.js +50 -0
- package/esm/profile/manifest.d.ts +21 -0
- package/esm/profile/manifest.d.ts.map +1 -0
- package/esm/profile/manifest.js +830 -0
- package/esm/profile/merge.d.ts +26 -0
- package/esm/profile/merge.d.ts.map +1 -0
- package/esm/profile/merge.js +518 -0
- package/esm/profile/mod.d.ts +23 -0
- package/esm/profile/mod.d.ts.map +1 -0
- package/esm/profile/mod.js +14 -0
- package/esm/profile/npm.d.ts +51 -0
- package/esm/profile/npm.d.ts.map +1 -0
- package/esm/profile/npm.js +186 -0
- package/esm/profile/resolver.d.ts +60 -0
- package/esm/profile/resolver.d.ts.map +1 -0
- package/esm/profile/resolver.js +132 -0
- package/esm/reporter/mod.js +14 -27
- package/esm/validator/attributes.d.ts +43 -0
- package/esm/validator/attributes.d.ts.map +1 -0
- package/esm/validator/attributes.js +169 -0
- package/esm/validator/mod.d.ts +27 -6
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +132 -124
- package/esm/validator/normalize.d.ts +21 -0
- package/esm/validator/normalize.d.ts.map +1 -0
- package/esm/validator/normalize.js +58 -0
- package/esm/validator/pattern.d.ts +23 -0
- package/esm/validator/pattern.d.ts.map +1 -0
- package/esm/validator/pattern.js +44 -0
- package/esm/validator/pipeline.d.ts +30 -0
- package/esm/validator/pipeline.d.ts.map +1 -0
- package/esm/validator/pipeline.js +115 -0
- package/esm/validator/traceability.d.ts +48 -0
- package/esm/validator/traceability.d.ts.map +1 -0
- package/esm/validator/traceability.js +141 -0
- package/esm/validator/types.d.ts +48 -0
- package/esm/validator/types.d.ts.map +1 -0
- package/esm/validator/types.js +140 -0
- package/esm/validator/value_types.d.ts +20 -0
- package/esm/validator/value_types.d.ts.map +1 -0
- package/esm/validator/value_types.js +126 -0
- package/package.json +1 -1
- package/script/compiler/inverses.d.ts +22 -0
- package/script/compiler/inverses.d.ts.map +1 -0
- package/script/compiler/inverses.js +150 -0
- package/script/compiler/link_target.d.ts +19 -0
- package/script/compiler/link_target.d.ts.map +1 -0
- package/script/compiler/link_target.js +69 -0
- package/script/compiler/mod.d.ts +7 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +62 -14
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +20 -1
- package/script/config/markspec.d.ts +51 -0
- package/script/config/markspec.d.ts.map +1 -0
- package/script/config/markspec.js +222 -0
- package/script/config/mod.d.ts +4 -0
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +28 -16
- package/script/formatter/mod.d.ts +12 -2
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +131 -22
- package/script/mod.d.ts +10 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +48 -19
- package/script/model/attributes.d.ts +47 -0
- package/script/model/attributes.d.ts.map +1 -0
- package/script/model/attributes.js +101 -0
- package/script/model/mod.d.ts +255 -26
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +34 -2
- package/script/model/profile.d.ts +189 -0
- package/script/model/profile.d.ts.map +1 -0
- package/script/model/profile.js +34 -0
- package/script/parser/attributes.d.ts +13 -1
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +48 -0
- package/script/parser/frontmatter.d.ts +53 -0
- package/script/parser/frontmatter.d.ts.map +1 -0
- package/script/parser/frontmatter.js +188 -0
- package/script/parser/grammars.js +11 -2
- package/script/parser/markdown.d.ts +11 -4
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +84 -37
- package/script/parser/mod.d.ts +26 -10
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +41 -10
- package/script/parser/source.d.ts +12 -8
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +20 -13
- package/script/profile/cache.d.ts +29 -0
- package/script/profile/cache.d.ts.map +1 -0
- package/script/profile/cache.js +48 -0
- package/script/profile/chain.d.ts +42 -0
- package/script/profile/chain.d.ts.map +1 -0
- package/script/profile/chain.js +229 -0
- package/script/profile/git-cache.d.ts +73 -0
- package/script/profile/git-cache.d.ts.map +1 -0
- package/script/profile/git-cache.js +104 -0
- package/script/profile/load.d.ts +28 -0
- package/script/profile/load.d.ts.map +1 -0
- package/script/profile/load.js +53 -0
- package/script/profile/manifest.d.ts +21 -0
- package/script/profile/manifest.d.ts.map +1 -0
- package/script/profile/manifest.js +833 -0
- package/script/profile/merge.d.ts +26 -0
- package/script/profile/merge.d.ts.map +1 -0
- package/script/profile/merge.js +521 -0
- package/script/profile/mod.d.ts +23 -0
- package/script/profile/mod.d.ts.map +1 -0
- package/script/profile/mod.js +31 -0
- package/script/profile/npm.d.ts +51 -0
- package/script/profile/npm.d.ts.map +1 -0
- package/script/profile/npm.js +191 -0
- package/script/profile/resolver.d.ts +60 -0
- package/script/profile/resolver.d.ts.map +1 -0
- package/script/profile/resolver.js +136 -0
- package/script/reporter/mod.js +14 -27
- package/script/validator/attributes.d.ts +43 -0
- package/script/validator/attributes.d.ts.map +1 -0
- package/script/validator/attributes.js +173 -0
- package/script/validator/mod.d.ts +27 -6
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +145 -123
- package/script/validator/normalize.d.ts +21 -0
- package/script/validator/normalize.d.ts.map +1 -0
- package/script/validator/normalize.js +61 -0
- package/script/validator/pattern.d.ts +23 -0
- package/script/validator/pattern.d.ts.map +1 -0
- package/script/validator/pattern.js +47 -0
- package/script/validator/pipeline.d.ts +30 -0
- package/script/validator/pipeline.d.ts.map +1 -0
- package/script/validator/pipeline.js +118 -0
- package/script/validator/traceability.d.ts +48 -0
- package/script/validator/traceability.d.ts.map +1 -0
- package/script/validator/traceability.js +146 -0
- package/script/validator/types.d.ts +48 -0
- package/script/validator/types.d.ts.map +1 -0
- package/script/validator/types.js +144 -0
- package/script/validator/value_types.d.ts +20 -0
- package/script/validator/value_types.d.ts.map +1 -0
- package/script/validator/value_types.js +129 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/pattern
|
|
3
|
+
*
|
|
4
|
+
* Display-ID pattern template → anchored RegExp.
|
|
5
|
+
*
|
|
6
|
+
* Grammar (per ADR-009 §5):
|
|
7
|
+
* pattern := literal-prefix placeholder (literal-suffix)?
|
|
8
|
+
* placeholder := "{n}" | "{n:" PADDING "d}"
|
|
9
|
+
* PADDING := "0" digits
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* REQ-{n} → ^REQ-(\d+)$
|
|
13
|
+
* REQ-{n:04d} → ^REQ-(\d{4})$
|
|
14
|
+
* STAKE-REQ-{n:06d} → ^STAKE-REQ-(\d{6})$
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Compile a display-ID pattern template into an anchored RegExp.
|
|
18
|
+
*
|
|
19
|
+
* Throws if the template is missing the `{n}` placeholder or has an invalid
|
|
20
|
+
* padding specifier.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compileDisplayIdPattern(template: string): RegExp;
|
|
23
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/validator/pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA0BhE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/pattern
|
|
3
|
+
*
|
|
4
|
+
* Display-ID pattern template → anchored RegExp.
|
|
5
|
+
*
|
|
6
|
+
* Grammar (per ADR-009 §5):
|
|
7
|
+
* pattern := literal-prefix placeholder (literal-suffix)?
|
|
8
|
+
* placeholder := "{n}" | "{n:" PADDING "d}"
|
|
9
|
+
* PADDING := "0" digits
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* REQ-{n} → ^REQ-(\d+)$
|
|
13
|
+
* REQ-{n:04d} → ^REQ-(\d{4})$
|
|
14
|
+
* STAKE-REQ-{n:06d} → ^STAKE-REQ-(\d{6})$
|
|
15
|
+
*/
|
|
16
|
+
const PLACEHOLDER_RE = /\{n(?::(0\d+)d)?\}/;
|
|
17
|
+
/**
|
|
18
|
+
* Compile a display-ID pattern template into an anchored RegExp.
|
|
19
|
+
*
|
|
20
|
+
* Throws if the template is missing the `{n}` placeholder or has an invalid
|
|
21
|
+
* padding specifier.
|
|
22
|
+
*/
|
|
23
|
+
export function compileDisplayIdPattern(template) {
|
|
24
|
+
const match = PLACEHOLDER_RE.exec(template);
|
|
25
|
+
if (!match) {
|
|
26
|
+
if (/\{n:[^}]*\}/.test(template)) {
|
|
27
|
+
throw new Error(`display-id-pattern '${template}': invalid padding specifier ` +
|
|
28
|
+
`(expected {n} or {n:NNd})`);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`display-id-pattern '${template}': missing {n} placeholder`);
|
|
31
|
+
}
|
|
32
|
+
const padding = match[1];
|
|
33
|
+
const placeholderStart = match.index;
|
|
34
|
+
const placeholderEnd = match.index + match[0].length;
|
|
35
|
+
const prefix = template.slice(0, placeholderStart);
|
|
36
|
+
const suffix = template.slice(placeholderEnd);
|
|
37
|
+
const digitGroup = padding ? `\\d{${Number(padding)}}` : `\\d+`;
|
|
38
|
+
const regexSource = "^" + escapeRegex(prefix) + "(" + digitGroup + ")" +
|
|
39
|
+
escapeRegex(suffix) + "$";
|
|
40
|
+
return new RegExp(regexSource);
|
|
41
|
+
}
|
|
42
|
+
function escapeRegex(s) {
|
|
43
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/pipeline
|
|
3
|
+
*
|
|
4
|
+
* Validator pipeline. Composes Stage 1 (core hygiene — existing `validate`),
|
|
5
|
+
* Stage 2 (type classification — {@linkcode classifyEntriesStage}),
|
|
6
|
+
* Stage 2.5 (list-value normalization — {@linkcode normalizeListValues}),
|
|
7
|
+
* Stage 3 (typed attribute validation — {@linkcode validateAttributesForEntry}),
|
|
8
|
+
* and Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}).
|
|
9
|
+
*/
|
|
10
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
11
|
+
/** Result of running the full validator pipeline. */
|
|
12
|
+
export interface PipelineResult {
|
|
13
|
+
/** Entries after classification — `type` set on those that classified. */
|
|
14
|
+
readonly entries: readonly Entry[];
|
|
15
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
16
|
+
/** `true` when no error-severity diagnostics were emitted. */
|
|
17
|
+
readonly valid: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run the validator pipeline.
|
|
21
|
+
*
|
|
22
|
+
* - Stage 1 (always): core hygiene via {@linkcode validate}.
|
|
23
|
+
* - Stage 2 (when `profile` is non-null): entry classification via
|
|
24
|
+
* {@linkcode classifyEntriesStage}.
|
|
25
|
+
*
|
|
26
|
+
* When `profile` is `null`, entries pass through unchanged (no `type`
|
|
27
|
+
* assignments).
|
|
28
|
+
*/
|
|
29
|
+
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null): PipelineResult;
|
|
30
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO3E,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,cAAc,CA2DhB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/pipeline
|
|
3
|
+
*
|
|
4
|
+
* Validator pipeline. Composes Stage 1 (core hygiene — existing `validate`),
|
|
5
|
+
* Stage 2 (type classification — {@linkcode classifyEntriesStage}),
|
|
6
|
+
* Stage 2.5 (list-value normalization — {@linkcode normalizeListValues}),
|
|
7
|
+
* Stage 3 (typed attribute validation — {@linkcode validateAttributesForEntry}),
|
|
8
|
+
* and Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}).
|
|
9
|
+
*/
|
|
10
|
+
import { validate } from "./mod.js";
|
|
11
|
+
import { classifyEntriesStage } from "./types.js";
|
|
12
|
+
import { effectiveScope, validateAttributesForEntry } from "./attributes.js";
|
|
13
|
+
import { normalizeListValues } from "./normalize.js";
|
|
14
|
+
import { validateTraceabilityForEntry } from "./traceability.js";
|
|
15
|
+
/**
|
|
16
|
+
* Run the validator pipeline.
|
|
17
|
+
*
|
|
18
|
+
* - Stage 1 (always): core hygiene via {@linkcode validate}.
|
|
19
|
+
* - Stage 2 (when `profile` is non-null): entry classification via
|
|
20
|
+
* {@linkcode classifyEntriesStage}.
|
|
21
|
+
*
|
|
22
|
+
* When `profile` is `null`, entries pass through unchanged (no `type`
|
|
23
|
+
* assignments).
|
|
24
|
+
*/
|
|
25
|
+
export function runPipeline(entries, profile) {
|
|
26
|
+
const diagnostics = [];
|
|
27
|
+
// Stage 1 — core hygiene. When a profile is loaded, suppress MSL-R010
|
|
28
|
+
// warnings for attributes the profile actually declares (Stage 3's scope
|
|
29
|
+
// validates them directly — the core-only R010 check would be noise).
|
|
30
|
+
const stage1 = validate(entries);
|
|
31
|
+
const profileDeclaredAttrs = profile !== null
|
|
32
|
+
? collectAllProfileAttributes(entries, profile)
|
|
33
|
+
: null;
|
|
34
|
+
const filteredStage1 = profileDeclaredAttrs === null
|
|
35
|
+
? stage1.diagnostics
|
|
36
|
+
: stage1.diagnostics.filter((d) => {
|
|
37
|
+
if (d.code !== "MSL-R010")
|
|
38
|
+
return true;
|
|
39
|
+
const match = /attribute '([^']+)'/.exec(d.message);
|
|
40
|
+
if (!match)
|
|
41
|
+
return true;
|
|
42
|
+
return !profileDeclaredAttrs.has(match[1]);
|
|
43
|
+
});
|
|
44
|
+
diagnostics.push(...filteredStage1);
|
|
45
|
+
// Stage 2 — classification (only when a profile is loaded).
|
|
46
|
+
let finalEntries = entries;
|
|
47
|
+
if (profile !== null) {
|
|
48
|
+
const stage2 = classifyEntriesStage(entries, profile);
|
|
49
|
+
finalEntries = stage2.entries;
|
|
50
|
+
diagnostics.push(...stage2.diagnostics);
|
|
51
|
+
}
|
|
52
|
+
// Stage 2.5 — normalize profile-declared list-value attributes. Splits
|
|
53
|
+
// comma-separated values for `id-list`/`tag-list` attributes the core parser
|
|
54
|
+
// didn't see so that Stage 3 sees already-split values.
|
|
55
|
+
if (profile !== null) {
|
|
56
|
+
finalEntries = finalEntries.map((e) => normalizeListValues(e, profile));
|
|
57
|
+
}
|
|
58
|
+
// Stage 3 — typed attributes (only when a profile is loaded).
|
|
59
|
+
if (profile !== null) {
|
|
60
|
+
for (const entry of finalEntries) {
|
|
61
|
+
const stage3 = validateAttributesForEntry(entry, profile);
|
|
62
|
+
diagnostics.push(...stage3);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Stage 4 — traceability rules (only when a profile is loaded). Builds a
|
|
66
|
+
// graph index keyed by `entry.id` from the post-classification entries so
|
|
67
|
+
// trace-rule target matchers can look up the classified type/shape.
|
|
68
|
+
if (profile !== null) {
|
|
69
|
+
const graph = new Map();
|
|
70
|
+
for (const e of finalEntries) {
|
|
71
|
+
if (e.id)
|
|
72
|
+
graph.set(e.id, e);
|
|
73
|
+
}
|
|
74
|
+
for (const entry of finalEntries) {
|
|
75
|
+
const stage4 = validateTraceabilityForEntry(entry, profile, graph);
|
|
76
|
+
diagnostics.push(...stage4);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const valid = !diagnostics.some((d) => d.severity === "error");
|
|
80
|
+
return { entries: finalEntries, diagnostics, valid };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Union of all attribute names declared by the profile's effective scope
|
|
84
|
+
* across all entries. Used to suppress core Stage 1 MSL-R010 warnings for
|
|
85
|
+
* attributes that Stage 3 already validates.
|
|
86
|
+
*
|
|
87
|
+
* Computed per-entry because the effective scope for an entry depends on
|
|
88
|
+
* its shape and (when classified) type. Stage 1 runs before classification,
|
|
89
|
+
* so we pre-classify by iterating; entries without `type` still contribute
|
|
90
|
+
* their universal+shape scope.
|
|
91
|
+
*/
|
|
92
|
+
function collectAllProfileAttributes(entries, profile) {
|
|
93
|
+
const out = new Set();
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
const scope = effectiveScope(entry, profile);
|
|
96
|
+
for (const name of scope.attributes.keys())
|
|
97
|
+
out.add(name);
|
|
98
|
+
}
|
|
99
|
+
// Also include every type-scoped attribute in the profile, since an entry
|
|
100
|
+
// may have declared attributes before Stage 2 classification runs.
|
|
101
|
+
for (const [, typeEntry] of profile.types) {
|
|
102
|
+
for (const name of typeEntry.value.attributes.keys())
|
|
103
|
+
out.add(name);
|
|
104
|
+
// Trace rule link names are implicitly id-list attributes — include them
|
|
105
|
+
// so Stage 1's MSL-R010 doesn't flag them before Stage 2 classifies.
|
|
106
|
+
for (const name of typeEntry.value.traceability.keys())
|
|
107
|
+
out.add(name);
|
|
108
|
+
}
|
|
109
|
+
// Shape-level trace rule link names too.
|
|
110
|
+
for (const name of profile.identified.traceability.keys())
|
|
111
|
+
out.add(name);
|
|
112
|
+
for (const name of profile.referenced.traceability.keys())
|
|
113
|
+
out.add(name);
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/traceability
|
|
3
|
+
*
|
|
4
|
+
* Validator Stage 4 — traceability rule enforcement.
|
|
5
|
+
*
|
|
6
|
+
* Runs after Stage 3. For each classified identified entry, checks the
|
|
7
|
+
* profile's declared trace rules against the entry's outgoing link
|
|
8
|
+
* attributes:
|
|
9
|
+
* - Required (MSL-L001)
|
|
10
|
+
* - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
|
|
11
|
+
* - Target match against the rule's target matchers (MSL-L004)
|
|
12
|
+
*
|
|
13
|
+
* Referenced entries are skipped entirely — the profile manifest parser
|
|
14
|
+
* rejects `referenced.traceability` at load time, so referenced entries
|
|
15
|
+
* never have declared outgoing links.
|
|
16
|
+
*/
|
|
17
|
+
import type { Diagnostic, EffectiveProfile, Entry, TargetMatcher, TraceRule } from "../model/mod.js";
|
|
18
|
+
/**
|
|
19
|
+
* Effective trace rules for an entry: union of identified-shape-scope rules
|
|
20
|
+
* and (when classified) type-scope rules. Type-scope rules win on
|
|
21
|
+
* link-attribute-name collision.
|
|
22
|
+
*
|
|
23
|
+
* Referenced entries always return an empty map.
|
|
24
|
+
*/
|
|
25
|
+
export declare function effectiveTraceRules(entry: Entry, profile: EffectiveProfile): ReadonlyMap<string, TraceRule>;
|
|
26
|
+
/**
|
|
27
|
+
* Return true if the target entry matches any of the rule's target matchers.
|
|
28
|
+
* OR semantics across the list.
|
|
29
|
+
*
|
|
30
|
+
* - Type-name matcher (string): target's classified type equals the name.
|
|
31
|
+
* An un-classified target never matches a type-name matcher.
|
|
32
|
+
* - Shape matcher ({shape: "identified"|"referenced"}): target's shape
|
|
33
|
+
* equals the matcher's shape.
|
|
34
|
+
*/
|
|
35
|
+
export declare function matchesAnyTarget(target: Entry, matchers: readonly TargetMatcher[]): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Run Stage 4 traceability checks for one entry.
|
|
38
|
+
*
|
|
39
|
+
* Skips referenced entries entirely. For identified entries, iterates the
|
|
40
|
+
* effective trace rules and emits MSL-L001..L004 as appropriate.
|
|
41
|
+
*
|
|
42
|
+
* @param entry - The entry to validate (after Stage 2 classification +
|
|
43
|
+
* Stage 2.5 normalization)
|
|
44
|
+
* @param profile - The effective profile (null → never called)
|
|
45
|
+
* @param graph - Index keyed by entry.id for target lookup
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateTraceabilityForEntry(entry: Entry, profile: EffectiveProfile, graph: ReadonlyMap<string, Entry>): Diagnostic[];
|
|
48
|
+
//# sourceMappingURL=traceability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAoBhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAChC,UAAU,EAAE,CAuEd"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/traceability
|
|
3
|
+
*
|
|
4
|
+
* Validator Stage 4 — traceability rule enforcement.
|
|
5
|
+
*
|
|
6
|
+
* Runs after Stage 3. For each classified identified entry, checks the
|
|
7
|
+
* profile's declared trace rules against the entry's outgoing link
|
|
8
|
+
* attributes:
|
|
9
|
+
* - Required (MSL-L001)
|
|
10
|
+
* - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
|
|
11
|
+
* - Target match against the rule's target matchers (MSL-L004)
|
|
12
|
+
*
|
|
13
|
+
* Referenced entries are skipped entirely — the profile manifest parser
|
|
14
|
+
* rejects `referenced.traceability` at load time, so referenced entries
|
|
15
|
+
* never have declared outgoing links.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Effective trace rules for an entry: union of identified-shape-scope rules
|
|
19
|
+
* and (when classified) type-scope rules. Type-scope rules win on
|
|
20
|
+
* link-attribute-name collision.
|
|
21
|
+
*
|
|
22
|
+
* Referenced entries always return an empty map.
|
|
23
|
+
*/
|
|
24
|
+
export function effectiveTraceRules(entry, profile) {
|
|
25
|
+
const out = new Map();
|
|
26
|
+
if (entry.shape !== "identified")
|
|
27
|
+
return out;
|
|
28
|
+
// Shape scope.
|
|
29
|
+
for (const [name, ruleEntry] of profile.identified.traceability) {
|
|
30
|
+
out.set(name, ruleEntry.value);
|
|
31
|
+
}
|
|
32
|
+
// Type scope (only when classified AND type is declared in the profile).
|
|
33
|
+
if (entry.type !== undefined) {
|
|
34
|
+
const typeEntry = profile.types.get(entry.type);
|
|
35
|
+
if (typeEntry !== undefined) {
|
|
36
|
+
for (const [name, ruleEntry] of typeEntry.value.traceability) {
|
|
37
|
+
out.set(name, ruleEntry.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Return true if the target entry matches any of the rule's target matchers.
|
|
45
|
+
* OR semantics across the list.
|
|
46
|
+
*
|
|
47
|
+
* - Type-name matcher (string): target's classified type equals the name.
|
|
48
|
+
* An un-classified target never matches a type-name matcher.
|
|
49
|
+
* - Shape matcher ({shape: "identified"|"referenced"}): target's shape
|
|
50
|
+
* equals the matcher's shape.
|
|
51
|
+
*/
|
|
52
|
+
export function matchesAnyTarget(target, matchers) {
|
|
53
|
+
for (const m of matchers) {
|
|
54
|
+
if (typeof m === "string") {
|
|
55
|
+
if (target.type === m)
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (target.shape === m.shape)
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Run Stage 4 traceability checks for one entry.
|
|
67
|
+
*
|
|
68
|
+
* Skips referenced entries entirely. For identified entries, iterates the
|
|
69
|
+
* effective trace rules and emits MSL-L001..L004 as appropriate.
|
|
70
|
+
*
|
|
71
|
+
* @param entry - The entry to validate (after Stage 2 classification +
|
|
72
|
+
* Stage 2.5 normalization)
|
|
73
|
+
* @param profile - The effective profile (null → never called)
|
|
74
|
+
* @param graph - Index keyed by entry.id for target lookup
|
|
75
|
+
*/
|
|
76
|
+
export function validateTraceabilityForEntry(entry, profile, graph) {
|
|
77
|
+
const diagnostics = [];
|
|
78
|
+
if (entry.shape !== "identified")
|
|
79
|
+
return diagnostics;
|
|
80
|
+
const rules = effectiveTraceRules(entry, profile);
|
|
81
|
+
const present = entry.typedAttributes;
|
|
82
|
+
for (const [linkName, rule] of rules) {
|
|
83
|
+
const values = present.get(linkName);
|
|
84
|
+
const count = values?.length ?? 0;
|
|
85
|
+
const card = rule.cardinality ?? { lower: 0, upper: Infinity };
|
|
86
|
+
// MSL-L001: required link missing.
|
|
87
|
+
if (rule.required && count === 0) {
|
|
88
|
+
diagnostics.push({
|
|
89
|
+
code: "MSL-L001",
|
|
90
|
+
severity: "error",
|
|
91
|
+
message: `${entry.displayId}: required link attribute '${linkName}' is missing`,
|
|
92
|
+
location: entry.location,
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (count === 0)
|
|
97
|
+
continue;
|
|
98
|
+
// MSL-L002: upper cardinality.
|
|
99
|
+
if (count > card.upper) {
|
|
100
|
+
diagnostics.push({
|
|
101
|
+
code: "MSL-L002",
|
|
102
|
+
severity: "error",
|
|
103
|
+
message: `${entry.displayId}: link '${linkName}' has ${count} values but max is ${formatUpper(card.upper)}`,
|
|
104
|
+
location: entry.location,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// MSL-L003: lower cardinality.
|
|
108
|
+
if (count < card.lower) {
|
|
109
|
+
diagnostics.push({
|
|
110
|
+
code: "MSL-L003",
|
|
111
|
+
severity: "error",
|
|
112
|
+
message: `${entry.displayId}: link '${linkName}' has ${count} values but min is ${card.lower}`,
|
|
113
|
+
location: entry.location,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// MSL-L004: target match for each resolved value.
|
|
117
|
+
for (const v of values) {
|
|
118
|
+
const target = graph.get(v);
|
|
119
|
+
if (!target)
|
|
120
|
+
continue;
|
|
121
|
+
if (!matchesAnyTarget(target, rule.target)) {
|
|
122
|
+
diagnostics.push({
|
|
123
|
+
code: "MSL-L004",
|
|
124
|
+
severity: "error",
|
|
125
|
+
message: `${entry.displayId}: link '${linkName}' targets ${target.displayId} ` +
|
|
126
|
+
`whose type '${target.type ?? "<unclassified>"}' / shape '${target.shape}' ` +
|
|
127
|
+
`is not accepted by rule target ${stringifyMatchers(rule.target)}`,
|
|
128
|
+
location: entry.location,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return diagnostics;
|
|
134
|
+
}
|
|
135
|
+
function formatUpper(u) {
|
|
136
|
+
return u === Infinity ? "N" : String(u);
|
|
137
|
+
}
|
|
138
|
+
function stringifyMatchers(matchers) {
|
|
139
|
+
const parts = matchers.map((m) => typeof m === "string" ? m : `{shape: ${m.shape}}`);
|
|
140
|
+
return `[${parts.join(", ")}]`;
|
|
141
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/types
|
|
3
|
+
*
|
|
4
|
+
* Validator Stage 2 — entry classification.
|
|
5
|
+
*
|
|
6
|
+
* Each entry is assigned a profile-declared type either by an explicit
|
|
7
|
+
* `Type:` trailer attribute or by display-ID pattern matching. Un-classified
|
|
8
|
+
* entries in a strict profile (types declared) produce MSL-T003.
|
|
9
|
+
*/
|
|
10
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
11
|
+
/** Result of classifying a single entry. */
|
|
12
|
+
export interface ClassifyResult {
|
|
13
|
+
/** The assigned type name, or `undefined` if un-classified. */
|
|
14
|
+
readonly type: string | undefined;
|
|
15
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Classify one {@linkcode Entry} against the profile's type vocabulary.
|
|
19
|
+
*
|
|
20
|
+
* Order of precedence:
|
|
21
|
+
* 1. Explicit `Type:` trailer attribute (if present).
|
|
22
|
+
* 2. Display-ID pattern match across types whose `shape` matches
|
|
23
|
+
* `entry.shape`.
|
|
24
|
+
*
|
|
25
|
+
* Emits:
|
|
26
|
+
* - `MSL-T001` when explicit `Type:` value is not in the profile's type
|
|
27
|
+
* vocabulary.
|
|
28
|
+
* - `MSL-T002` when the display ID matches more than one type's pattern.
|
|
29
|
+
* - `MSL-T003` when strict mode (types declared) and no classification
|
|
30
|
+
* could be assigned.
|
|
31
|
+
*/
|
|
32
|
+
export declare function classifyEntry(entry: Entry, profile: EffectiveProfile): ClassifyResult;
|
|
33
|
+
/** Result of running the classification stage over a batch of entries. */
|
|
34
|
+
export interface ClassifyStageResult {
|
|
35
|
+
/** Entries with `type` set on successful classification. */
|
|
36
|
+
readonly entries: readonly Entry[];
|
|
37
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Run classification across all entries. Produces new {@linkcode Entry}
|
|
41
|
+
* objects with `type` set when classification succeeds; un-classified
|
|
42
|
+
* entries pass through with `type` unchanged.
|
|
43
|
+
*
|
|
44
|
+
* Also emits `MSL-T004` when a classified entry's display ID violates the
|
|
45
|
+
* type's `display-id-pattern-enforcement` level.
|
|
46
|
+
*/
|
|
47
|
+
export declare function classifyEntriesStage(entries: readonly Entry[], profile: EffectiveProfile): ClassifyStageResult;
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAGzB,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,cAAc,CA4DhB;AAWD,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CAuBrB"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/types
|
|
3
|
+
*
|
|
4
|
+
* Validator Stage 2 — entry classification.
|
|
5
|
+
*
|
|
6
|
+
* Each entry is assigned a profile-declared type either by an explicit
|
|
7
|
+
* `Type:` trailer attribute or by display-ID pattern matching. Un-classified
|
|
8
|
+
* entries in a strict profile (types declared) produce MSL-T003.
|
|
9
|
+
*/
|
|
10
|
+
import { compileDisplayIdPattern } from "./pattern.js";
|
|
11
|
+
/**
|
|
12
|
+
* Classify one {@linkcode Entry} against the profile's type vocabulary.
|
|
13
|
+
*
|
|
14
|
+
* Order of precedence:
|
|
15
|
+
* 1. Explicit `Type:` trailer attribute (if present).
|
|
16
|
+
* 2. Display-ID pattern match across types whose `shape` matches
|
|
17
|
+
* `entry.shape`.
|
|
18
|
+
*
|
|
19
|
+
* Emits:
|
|
20
|
+
* - `MSL-T001` when explicit `Type:` value is not in the profile's type
|
|
21
|
+
* vocabulary.
|
|
22
|
+
* - `MSL-T002` when the display ID matches more than one type's pattern.
|
|
23
|
+
* - `MSL-T003` when strict mode (types declared) and no classification
|
|
24
|
+
* could be assigned.
|
|
25
|
+
*/
|
|
26
|
+
export function classifyEntry(entry, profile) {
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
// 1. Explicit Type: trailer?
|
|
29
|
+
const explicitType = findExplicitTypeAttribute(entry);
|
|
30
|
+
if (explicitType !== undefined) {
|
|
31
|
+
if (profile.types.has(explicitType)) {
|
|
32
|
+
return { type: explicitType, diagnostics };
|
|
33
|
+
}
|
|
34
|
+
diagnostics.push({
|
|
35
|
+
code: "MSL-T001",
|
|
36
|
+
severity: "error",
|
|
37
|
+
message: `${entry.displayId}: explicit Type: '${explicitType}' is not a declared type`,
|
|
38
|
+
location: entry.location,
|
|
39
|
+
});
|
|
40
|
+
return { type: undefined, diagnostics };
|
|
41
|
+
}
|
|
42
|
+
// 2. Display-ID pattern match across same-shape types.
|
|
43
|
+
const matches = [];
|
|
44
|
+
for (const [typeName, typeEntry] of profile.types) {
|
|
45
|
+
if (typeEntry.value.shape !== entry.shape)
|
|
46
|
+
continue;
|
|
47
|
+
const pattern = typeEntry.value.displayIdPattern.value;
|
|
48
|
+
if (pattern === undefined)
|
|
49
|
+
continue;
|
|
50
|
+
const regex = compileDisplayIdPattern(pattern);
|
|
51
|
+
if (regex.test(entry.displayId)) {
|
|
52
|
+
matches.push(typeName);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (matches.length === 1) {
|
|
56
|
+
return { type: matches[0], diagnostics };
|
|
57
|
+
}
|
|
58
|
+
if (matches.length > 1) {
|
|
59
|
+
diagnostics.push({
|
|
60
|
+
code: "MSL-T002",
|
|
61
|
+
severity: "error",
|
|
62
|
+
message: `${entry.displayId}: display ID matches multiple type patterns ` +
|
|
63
|
+
`(${matches.join(", ")}); add an explicit 'Type:' trailer to disambiguate`,
|
|
64
|
+
location: entry.location,
|
|
65
|
+
});
|
|
66
|
+
return { type: undefined, diagnostics };
|
|
67
|
+
}
|
|
68
|
+
// 0 matches. Strict mode → MSL-T003; permissive → OK.
|
|
69
|
+
if (profile.types.size > 0) {
|
|
70
|
+
diagnostics.push({
|
|
71
|
+
code: "MSL-T003",
|
|
72
|
+
severity: "error",
|
|
73
|
+
message: `${entry.displayId}: un-classified entry ` +
|
|
74
|
+
`(profile declares ${profile.types.size} types; display ID matched none)`,
|
|
75
|
+
location: entry.location,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return { type: undefined, diagnostics };
|
|
79
|
+
}
|
|
80
|
+
function findExplicitTypeAttribute(entry) {
|
|
81
|
+
for (const attr of entry.rawAttributes) {
|
|
82
|
+
if (attr.key === "Type") {
|
|
83
|
+
return attr.value.trim();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Run classification across all entries. Produces new {@linkcode Entry}
|
|
90
|
+
* objects with `type` set when classification succeeds; un-classified
|
|
91
|
+
* entries pass through with `type` unchanged.
|
|
92
|
+
*
|
|
93
|
+
* Also emits `MSL-T004` when a classified entry's display ID violates the
|
|
94
|
+
* type's `display-id-pattern-enforcement` level.
|
|
95
|
+
*/
|
|
96
|
+
export function classifyEntriesStage(entries, profile) {
|
|
97
|
+
const diagnostics = [];
|
|
98
|
+
const out = [];
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
const classified = classifyEntry(entry, profile);
|
|
101
|
+
diagnostics.push(...classified.diagnostics);
|
|
102
|
+
if (classified.type !== undefined) {
|
|
103
|
+
const typeEntry = profile.types.get(classified.type);
|
|
104
|
+
if (typeEntry !== undefined) {
|
|
105
|
+
const enforceDiag = checkEnforcement(entry, typeEntry);
|
|
106
|
+
if (enforceDiag !== undefined) {
|
|
107
|
+
diagnostics.push(enforceDiag);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
out.push({ ...entry, type: classified.type });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
out.push(entry);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { entries: out, diagnostics };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* If the classified type declares a display-id-pattern and the entry's
|
|
120
|
+
* display ID doesn't match it, emit an MSL-T004 at the configured severity.
|
|
121
|
+
* Returns `undefined` when the display ID matches or enforcement is `off`.
|
|
122
|
+
*/
|
|
123
|
+
function checkEnforcement(entry, typeEntry) {
|
|
124
|
+
const pattern = typeEntry.value.displayIdPattern.value;
|
|
125
|
+
if (pattern === undefined)
|
|
126
|
+
return undefined;
|
|
127
|
+
const level = typeEntry.value.displayIdPatternEnforcement.value;
|
|
128
|
+
if (level === "off")
|
|
129
|
+
return undefined;
|
|
130
|
+
const regex = compileDisplayIdPattern(pattern);
|
|
131
|
+
if (regex.test(entry.displayId))
|
|
132
|
+
return undefined;
|
|
133
|
+
return {
|
|
134
|
+
code: "MSL-T004",
|
|
135
|
+
severity: level === "error" ? "error" : "warning",
|
|
136
|
+
message: `${entry.displayId}: display ID doesn't match pattern ` +
|
|
137
|
+
`'${pattern}' for type '${typeEntry.value.name}'`,
|
|
138
|
+
location: entry.location,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/value_types
|
|
3
|
+
*
|
|
4
|
+
* Per-type value validators for profile-declared attributes. Each validator
|
|
5
|
+
* takes a string value and the attribute's declaration, returns `null` when
|
|
6
|
+
* valid or a short error message explaining why it's invalid.
|
|
7
|
+
*
|
|
8
|
+
* The top-level {@linkcode validateValue} dispatches on the declared type.
|
|
9
|
+
*/
|
|
10
|
+
import type { AttrDecl } from "../model/mod.js";
|
|
11
|
+
/**
|
|
12
|
+
* Validate one string value against an attribute's declared value type.
|
|
13
|
+
* Returns `null` when the value is valid, or a short human-readable detail
|
|
14
|
+
* string (without the attribute name or display ID — the caller composes the
|
|
15
|
+
* full diagnostic message).
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateValue(value: string, decl: AttrDecl): string | null;
|
|
18
|
+
/** Signature for a single value-type validator. */
|
|
19
|
+
export type ValueValidator = (value: string, decl: AttrDecl) => string | null;
|
|
20
|
+
//# sourceMappingURL=value_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC"}
|