@driftsys/markspec 0.3.0 → 0.5.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 +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +56 -6
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +372 -41
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +21 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -5
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +100 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +58 -2
- package/esm/model/palette.d.ts +18 -0
- package/esm/model/palette.d.ts.map +1 -0
- package/esm/model/palette.js +23 -0
- package/esm/model/profile.d.ts +33 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts +10 -3
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +241 -11
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +4 -3
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +4 -4
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.d.ts +26 -0
- package/esm/profile/colors.d.ts.map +1 -0
- package/esm/profile/colors.js +46 -0
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +278 -104
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +3 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +6 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +140 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +56 -6
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +375 -41
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +21 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +58 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +100 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +67 -3
- package/script/model/palette.d.ts +18 -0
- package/script/model/palette.d.ts.map +1 -0
- package/script/model/palette.js +26 -0
- package/script/model/profile.d.ts +33 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts +10 -3
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +240 -10
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +8 -4
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +4 -1
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.d.ts +26 -0
- package/script/profile/colors.d.ts.map +1 -0
- package/script/profile/colors.js +49 -0
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +280 -106
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +3 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +9 -6
- package/script/reporter/mod.js +4 -4
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +146 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -11,47 +11,25 @@ exports.parseManifest = parseManifest;
|
|
|
11
11
|
const yaml_1 = require("@std/yaml");
|
|
12
12
|
const mod_js_1 = require("../model/mod.js");
|
|
13
13
|
const VALUE_TYPE_SET = new Set(mod_js_1.VALUE_TYPES);
|
|
14
|
-
/**
|
|
15
|
-
* The seven palette hues a profile may bind a semantic name to.
|
|
16
|
-
* Mirrors the `diagram:` group in `theme/tokens.yaml`.
|
|
17
|
-
*/
|
|
18
|
-
const PALETTE_HUES = [
|
|
19
|
-
"blue",
|
|
20
|
-
"cyan",
|
|
21
|
-
"teal",
|
|
22
|
-
"orange",
|
|
23
|
-
"red",
|
|
24
|
-
"purple",
|
|
25
|
-
"grey",
|
|
26
|
-
];
|
|
27
|
-
/** Regex for valid semantic-name keys in `profile.colors:`. */
|
|
28
|
-
const COLOR_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
29
14
|
const ALLOWED_ROOT_KEYS = new Set([
|
|
30
15
|
"id",
|
|
31
16
|
"version",
|
|
17
|
+
"markspec-schema",
|
|
32
18
|
"description",
|
|
33
19
|
"license",
|
|
34
20
|
"extends",
|
|
35
21
|
"profile",
|
|
36
22
|
]);
|
|
37
23
|
const ALLOWED_PROFILE_KEYS = new Set([
|
|
38
|
-
"required",
|
|
39
24
|
"attributes",
|
|
40
25
|
"labels",
|
|
41
26
|
"colors",
|
|
42
|
-
"
|
|
43
|
-
"referenced",
|
|
27
|
+
"conventions",
|
|
44
28
|
"types",
|
|
45
29
|
"documents",
|
|
46
30
|
]);
|
|
47
|
-
const ALLOWED_IDENTIFIED_KEYS = new Set([
|
|
48
|
-
"required",
|
|
49
|
-
"attributes",
|
|
50
|
-
"traceability",
|
|
51
|
-
]);
|
|
52
|
-
const ALLOWED_REFERENCED_KEYS = new Set(["required", "attributes"]);
|
|
53
31
|
const ALLOWED_TYPE_KEYS = new Set([
|
|
54
|
-
"
|
|
32
|
+
"extends",
|
|
55
33
|
"description",
|
|
56
34
|
"display-id-pattern",
|
|
57
35
|
"display-id-pattern-enforcement",
|
|
@@ -69,34 +47,15 @@ const ALLOWED_ATTR_KEYS = new Set([
|
|
|
69
47
|
"cardinality",
|
|
70
48
|
"values",
|
|
71
49
|
"inverse",
|
|
50
|
+
"description",
|
|
72
51
|
]);
|
|
73
52
|
const ALLOWED_INVERSE_KEYS = new Set(["name", "category"]);
|
|
74
|
-
const ALLOWED_TRACE_RULE_KEYS = new Set([
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
code: "PROFILE-LOAD-003",
|
|
81
|
-
severity: "error",
|
|
82
|
-
message: `${context}: must be a mapping`,
|
|
83
|
-
location: { file: sourcePath, line: 1, column: 1 },
|
|
84
|
-
});
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
const r = raw;
|
|
88
|
-
for (const key of Object.keys(r)) {
|
|
89
|
-
if (!allowedKeys.has(key)) {
|
|
90
|
-
diagnostics.push({
|
|
91
|
-
code: "PROFILE-LOAD-003",
|
|
92
|
-
severity: "error",
|
|
93
|
-
message: `${context}: unknown key '${key}'`,
|
|
94
|
-
location: { file: sourcePath, line: 1, column: 1 },
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return r;
|
|
99
|
-
}
|
|
53
|
+
const ALLOWED_TRACE_RULE_KEYS = new Set([
|
|
54
|
+
"target",
|
|
55
|
+
"cardinality",
|
|
56
|
+
"required",
|
|
57
|
+
"description",
|
|
58
|
+
]);
|
|
100
59
|
function parseStringList(raw, key, sourcePath, diagnostics) {
|
|
101
60
|
if (raw === undefined)
|
|
102
61
|
return [];
|
|
@@ -321,7 +280,18 @@ function parseAttrDecl(raw, context, sourcePath, diagnostics) {
|
|
|
321
280
|
}
|
|
322
281
|
inverse = { name: inv.name, category: inv.category };
|
|
323
282
|
}
|
|
324
|
-
|
|
283
|
+
const description = typeof r.description === "string"
|
|
284
|
+
? r.description
|
|
285
|
+
: undefined;
|
|
286
|
+
return {
|
|
287
|
+
name,
|
|
288
|
+
type: vtype,
|
|
289
|
+
required,
|
|
290
|
+
cardinality,
|
|
291
|
+
values,
|
|
292
|
+
inverse,
|
|
293
|
+
description,
|
|
294
|
+
};
|
|
325
295
|
}
|
|
326
296
|
function parseAttrList(raw, context, sourcePath, diagnostics) {
|
|
327
297
|
if (raw === undefined)
|
|
@@ -348,9 +318,21 @@ function parseTargetMatcher(raw, context, sourcePath, diagnostics) {
|
|
|
348
318
|
return raw;
|
|
349
319
|
if (raw != null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
350
320
|
const r = raw;
|
|
351
|
-
if (typeof r.shape === "string"
|
|
352
|
-
|
|
353
|
-
|
|
321
|
+
if (typeof r.shape === "string") {
|
|
322
|
+
// The profile-manifest `shape:` vocabulary is the authored
|
|
323
|
+
// `identified`/`referenced` surface (profile-schema §1.3 marks it
|
|
324
|
+
// obsolete — its removal is the profile-schema reconciliation
|
|
325
|
+
// slice, not this one). Map it one-directionally onto the internal
|
|
326
|
+
// EntryShape. NOT a backward-compat dual-accept: the new names are
|
|
327
|
+
// deliberately not accepted in authored YAML.
|
|
328
|
+
const shape = r.shape === "identified"
|
|
329
|
+
? "Authored"
|
|
330
|
+
: r.shape === "referenced"
|
|
331
|
+
? "Reference"
|
|
332
|
+
: undefined;
|
|
333
|
+
if (shape !== undefined) {
|
|
334
|
+
return { shape };
|
|
335
|
+
}
|
|
354
336
|
}
|
|
355
337
|
}
|
|
356
338
|
diagnostics.push({
|
|
@@ -404,7 +386,10 @@ function parseTraceRule(raw, context, sourcePath, diagnostics) {
|
|
|
404
386
|
? parseCardinality(r.cardinality, { lower: 0, upper: Infinity }, `${context}.cardinality`, sourcePath, diagnostics)
|
|
405
387
|
: undefined;
|
|
406
388
|
const required = r.required === true;
|
|
407
|
-
|
|
389
|
+
const description = typeof r.description === "string"
|
|
390
|
+
? r.description
|
|
391
|
+
: undefined;
|
|
392
|
+
return { target: targets, cardinality, required, description };
|
|
408
393
|
}
|
|
409
394
|
function parseTraceabilityMap(raw, context, sourcePath, diagnostics) {
|
|
410
395
|
const out = new Map();
|
|
@@ -446,9 +431,9 @@ function parseColorsMap(raw, sourcePath, diagnostics) {
|
|
|
446
431
|
return out;
|
|
447
432
|
}
|
|
448
433
|
for (const [name, value] of Object.entries(raw)) {
|
|
449
|
-
if (!COLOR_NAME_RE.test(name)) {
|
|
434
|
+
if (!mod_js_1.COLOR_NAME_RE.test(name)) {
|
|
450
435
|
diagnostics.push({
|
|
451
|
-
code: "PROFILE-
|
|
436
|
+
code: "MSL-PROFILE-COLOR-004",
|
|
452
437
|
severity: "error",
|
|
453
438
|
message: `profile.colors: '${name}' is not a valid semantic name (lowercase letters, digits, hyphens; must start with a letter)`,
|
|
454
439
|
location: { file: sourcePath, line: 1, column: 1 },
|
|
@@ -464,11 +449,11 @@ function parseColorsMap(raw, sourcePath, diagnostics) {
|
|
|
464
449
|
});
|
|
465
450
|
continue;
|
|
466
451
|
}
|
|
467
|
-
if (!PALETTE_HUES.includes(value)) {
|
|
452
|
+
if (!mod_js_1.PALETTE_HUES.includes(value)) {
|
|
468
453
|
diagnostics.push({
|
|
469
454
|
code: "MSL-PROFILE-COLOR-002",
|
|
470
455
|
severity: "error",
|
|
471
|
-
message: `profile.colors.${name}: '${value}' is not a palette hue (allowed: ${PALETTE_HUES.join(", ")})`,
|
|
456
|
+
message: `profile.colors.${name}: '${value}' is not a palette hue (allowed: ${mod_js_1.PALETTE_HUES.join(", ")})`,
|
|
472
457
|
location: { file: sourcePath, line: 1, column: 1 },
|
|
473
458
|
});
|
|
474
459
|
continue;
|
|
@@ -477,6 +462,197 @@ function parseColorsMap(raw, sourcePath, diagnostics) {
|
|
|
477
462
|
}
|
|
478
463
|
return out;
|
|
479
464
|
}
|
|
465
|
+
const KNOWN_CONVENTIONS = new Set(["modal-keywords"]);
|
|
466
|
+
const MODAL_KEYWORDS_CASING_VALUES = new Set(["rfc2119", "iso", "preserve"]);
|
|
467
|
+
function parseLabelConcerns(raw, sourcePath, diagnostics) {
|
|
468
|
+
if (raw === undefined)
|
|
469
|
+
return [];
|
|
470
|
+
// Form A: flat sequence of strings → each becomes a flag concern.
|
|
471
|
+
if (Array.isArray(raw)) {
|
|
472
|
+
const concerns = [];
|
|
473
|
+
for (const item of raw) {
|
|
474
|
+
if (typeof item !== "string") {
|
|
475
|
+
diagnostics.push({
|
|
476
|
+
code: "PROFILE-LOAD-003",
|
|
477
|
+
severity: "error",
|
|
478
|
+
message: "profile.labels: list form requires all-string entries",
|
|
479
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
480
|
+
});
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
concerns.push({ name: item, kind: "flag", values: [] });
|
|
484
|
+
}
|
|
485
|
+
return concerns;
|
|
486
|
+
}
|
|
487
|
+
// Form B: mapping — each key is a concern name.
|
|
488
|
+
if (raw === null || typeof raw !== "object") {
|
|
489
|
+
diagnostics.push({
|
|
490
|
+
code: "PROFILE-LOAD-003",
|
|
491
|
+
severity: "error",
|
|
492
|
+
message: "profile.labels: must be a list of strings or a mapping",
|
|
493
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
494
|
+
});
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
const concerns = [];
|
|
498
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
499
|
+
const concern = parseLabelConcernEntry(name, value, sourcePath, diagnostics);
|
|
500
|
+
if (concern)
|
|
501
|
+
concerns.push(concern);
|
|
502
|
+
}
|
|
503
|
+
return concerns;
|
|
504
|
+
}
|
|
505
|
+
function parseLabelConcernEntry(name, raw, sourcePath, diagnostics) {
|
|
506
|
+
const ctx = `profile.labels.${name}`;
|
|
507
|
+
// Bare string → description shorthand, implies flag.
|
|
508
|
+
if (typeof raw === "string") {
|
|
509
|
+
return { name, kind: "flag", description: raw, values: [] };
|
|
510
|
+
}
|
|
511
|
+
// null/undefined → flag, no description.
|
|
512
|
+
if (raw === null || raw === undefined) {
|
|
513
|
+
return { name, kind: "flag", values: [] };
|
|
514
|
+
}
|
|
515
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
516
|
+
diagnostics.push({
|
|
517
|
+
code: "PROFILE-LOAD-003",
|
|
518
|
+
severity: "error",
|
|
519
|
+
message: `${ctx}: value must be null, a string, or a mapping`,
|
|
520
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
521
|
+
});
|
|
522
|
+
return undefined;
|
|
523
|
+
}
|
|
524
|
+
const r = raw;
|
|
525
|
+
const description = typeof r.description === "string"
|
|
526
|
+
? r.description
|
|
527
|
+
: undefined;
|
|
528
|
+
let kind = "flag";
|
|
529
|
+
if (r.kind !== undefined) {
|
|
530
|
+
if (r.kind !== "enum" && r.kind !== "set" && r.kind !== "flag") {
|
|
531
|
+
diagnostics.push({
|
|
532
|
+
code: "PROFILE-LOAD-003",
|
|
533
|
+
severity: "error",
|
|
534
|
+
message: `${ctx}: 'kind' must be 'enum', 'set', or 'flag'`,
|
|
535
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
536
|
+
});
|
|
537
|
+
return undefined;
|
|
538
|
+
}
|
|
539
|
+
kind = r.kind;
|
|
540
|
+
}
|
|
541
|
+
if (r.values !== undefined && kind === "flag") {
|
|
542
|
+
diagnostics.push({
|
|
543
|
+
code: "PROFILE-LOAD-003",
|
|
544
|
+
severity: "error",
|
|
545
|
+
message: `${ctx}: 'values' is not valid for kind 'flag'`,
|
|
546
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
547
|
+
});
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
550
|
+
const values = [];
|
|
551
|
+
if (r.values !== undefined) {
|
|
552
|
+
if (typeof r.values !== "object" || Array.isArray(r.values)) {
|
|
553
|
+
diagnostics.push({
|
|
554
|
+
code: "PROFILE-LOAD-003",
|
|
555
|
+
severity: "error",
|
|
556
|
+
message: `${ctx}: 'values' must be a mapping of value names`,
|
|
557
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
558
|
+
});
|
|
559
|
+
return undefined;
|
|
560
|
+
}
|
|
561
|
+
for (const [vName, vRaw] of Object.entries(r.values)) {
|
|
562
|
+
if (vRaw === null || vRaw === undefined) {
|
|
563
|
+
values.push({ name: vName });
|
|
564
|
+
}
|
|
565
|
+
else if (typeof vRaw === "string") {
|
|
566
|
+
values.push({ name: vName, description: vRaw });
|
|
567
|
+
}
|
|
568
|
+
else if (typeof vRaw === "object" && !Array.isArray(vRaw)) {
|
|
569
|
+
const vr = vRaw;
|
|
570
|
+
const vDesc = typeof vr.description === "string"
|
|
571
|
+
? vr.description
|
|
572
|
+
: undefined;
|
|
573
|
+
values.push({ name: vName, description: vDesc });
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
diagnostics.push({
|
|
577
|
+
code: "PROFILE-LOAD-003",
|
|
578
|
+
severity: "error",
|
|
579
|
+
message: `${ctx}.values.${vName}: must be null, a string, or {description: string}`,
|
|
580
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return { name, kind, description, values };
|
|
586
|
+
}
|
|
587
|
+
function parseConventions(raw, sourcePath, diagnostics) {
|
|
588
|
+
if (raw === undefined)
|
|
589
|
+
return [];
|
|
590
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
591
|
+
diagnostics.push({
|
|
592
|
+
code: "PROFILE-LOAD-003",
|
|
593
|
+
severity: "error",
|
|
594
|
+
message: "profile.conventions: must be a mapping",
|
|
595
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
596
|
+
});
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
const out = [];
|
|
600
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
601
|
+
if (!KNOWN_CONVENTIONS.has(name)) {
|
|
602
|
+
diagnostics.push({
|
|
603
|
+
code: "PROFILE-LOAD-003",
|
|
604
|
+
severity: "warning",
|
|
605
|
+
message: `profile.conventions: unknown convention '${name}' (accepted for forward compatibility)`,
|
|
606
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
610
|
+
diagnostics.push({
|
|
611
|
+
code: "PROFILE-LOAD-003",
|
|
612
|
+
severity: "error",
|
|
613
|
+
message: `profile.conventions.${name}: must be a mapping`,
|
|
614
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
615
|
+
});
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
const r = value;
|
|
619
|
+
const description = typeof r.description === "string"
|
|
620
|
+
? r.description
|
|
621
|
+
: undefined;
|
|
622
|
+
const settings = {};
|
|
623
|
+
let valid = true;
|
|
624
|
+
for (const [k, v] of Object.entries(r)) {
|
|
625
|
+
if (k === "description")
|
|
626
|
+
continue;
|
|
627
|
+
if (typeof v !== "string") {
|
|
628
|
+
diagnostics.push({
|
|
629
|
+
code: "PROFILE-LOAD-003",
|
|
630
|
+
severity: "error",
|
|
631
|
+
message: `profile.conventions.${name}.${k}: setting value must be a string`,
|
|
632
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
633
|
+
});
|
|
634
|
+
valid = false;
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
if (name === "modal-keywords" && k === "casing") {
|
|
638
|
+
if (!MODAL_KEYWORDS_CASING_VALUES.has(v)) {
|
|
639
|
+
diagnostics.push({
|
|
640
|
+
code: "PROFILE-LOAD-003",
|
|
641
|
+
severity: "error",
|
|
642
|
+
message: `profile.conventions.modal-keywords.casing: '${v}' not valid (expected: rfc2119, iso, preserve)`,
|
|
643
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
644
|
+
});
|
|
645
|
+
valid = false;
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
settings[k] = v;
|
|
650
|
+
}
|
|
651
|
+
if (valid)
|
|
652
|
+
out.push({ name, settings, description });
|
|
653
|
+
}
|
|
654
|
+
return out;
|
|
655
|
+
}
|
|
480
656
|
function parseTypeDef(name, raw, sourcePath, diagnostics) {
|
|
481
657
|
const ctx = `profile.types.${name}`;
|
|
482
658
|
if (raw == null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -492,32 +668,33 @@ function parseTypeDef(name, raw, sourcePath, diagnostics) {
|
|
|
492
668
|
for (const key of Object.keys(r)) {
|
|
493
669
|
if (!ALLOWED_TYPE_KEYS.has(key)) {
|
|
494
670
|
diagnostics.push({
|
|
495
|
-
code: "PROFILE-
|
|
671
|
+
code: "PROFILE-TYPE-005",
|
|
496
672
|
severity: "error",
|
|
497
673
|
message: `${ctx}: unknown key '${key}'`,
|
|
498
674
|
location: { file: sourcePath, line: 1, column: 1 },
|
|
499
675
|
});
|
|
500
676
|
}
|
|
501
677
|
}
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
678
|
+
const rawExtends = r.extends;
|
|
679
|
+
if (rawExtends === undefined) {
|
|
504
680
|
diagnostics.push({
|
|
505
|
-
code: "PROFILE-
|
|
681
|
+
code: "PROFILE-TYPE-001",
|
|
506
682
|
severity: "error",
|
|
507
|
-
message: `${ctx}: '
|
|
683
|
+
message: `${ctx}: missing required field 'extends' (must be a core type name)`,
|
|
508
684
|
location: { file: sourcePath, line: 1, column: 1 },
|
|
509
685
|
});
|
|
510
686
|
return undefined;
|
|
511
687
|
}
|
|
512
|
-
if (
|
|
688
|
+
if (typeof rawExtends !== "string" || !mod_js_1.CORE_TYPES.has(rawExtends)) {
|
|
513
689
|
diagnostics.push({
|
|
514
|
-
code: "PROFILE-
|
|
690
|
+
code: "PROFILE-TYPE-002",
|
|
515
691
|
severity: "error",
|
|
516
|
-
message: `${ctx}:
|
|
692
|
+
message: `${ctx}: 'extends' value '${rawExtends}' is not a recognised core type`,
|
|
517
693
|
location: { file: sourcePath, line: 1, column: 1 },
|
|
518
694
|
});
|
|
519
695
|
return undefined;
|
|
520
696
|
}
|
|
697
|
+
const extendsValue = rawExtends;
|
|
521
698
|
let displayIdPattern;
|
|
522
699
|
if (r["display-id-pattern"] !== undefined) {
|
|
523
700
|
if (typeof r["display-id-pattern"] !== "string") {
|
|
@@ -557,29 +734,23 @@ function parseTypeDef(name, raw, sourcePath, diagnostics) {
|
|
|
557
734
|
return undefined;
|
|
558
735
|
}
|
|
559
736
|
color = r.color;
|
|
560
|
-
if (shape === "referenced") {
|
|
561
|
-
diagnostics.push({
|
|
562
|
-
code: "MSL-PROFILE-COLOR-001",
|
|
563
|
-
severity: "warning",
|
|
564
|
-
message: `${ctx}: 'color' on a referenced-shape type is ignored at render time`,
|
|
565
|
-
location: { file: sourcePath, line: 1, column: 1 },
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
737
|
}
|
|
738
|
+
const description = typeof r.description === "string"
|
|
739
|
+
? r.description
|
|
740
|
+
: undefined;
|
|
569
741
|
const required = parseStringList(r.required, `${ctx}.required`, sourcePath, diagnostics);
|
|
570
742
|
const attributes = parseAttrList(r.attributes, `${ctx}.attributes`, sourcePath, diagnostics);
|
|
571
|
-
const traceability =
|
|
572
|
-
? parseTraceabilityMap(r.traceability, `${ctx}.traceability`, sourcePath, diagnostics)
|
|
573
|
-
: new Map();
|
|
743
|
+
const traceability = parseTraceabilityMap(r.traceability, `${ctx}.traceability`, sourcePath, diagnostics);
|
|
574
744
|
return {
|
|
575
745
|
name,
|
|
576
|
-
|
|
746
|
+
extends: extendsValue,
|
|
577
747
|
displayIdPattern,
|
|
578
748
|
displayIdPatternEnforcement: enforcement,
|
|
579
749
|
required,
|
|
580
750
|
attributes,
|
|
581
751
|
traceability,
|
|
582
752
|
color,
|
|
753
|
+
description,
|
|
583
754
|
};
|
|
584
755
|
}
|
|
585
756
|
function parseTypesMap(raw, sourcePath, diagnostics) {
|
|
@@ -733,6 +904,20 @@ function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
733
904
|
if (id === undefined || version === undefined) {
|
|
734
905
|
return { manifest: null, diagnostics };
|
|
735
906
|
}
|
|
907
|
+
// Parse markspec-schema: early so PROFILE-SCHEMA-001 errors out before
|
|
908
|
+
// deeper parsing. PROFILE-SCHEMA-002 (absent) is emitted later, on the
|
|
909
|
+
// completed manifest, so it doesn't clutter error-case output.
|
|
910
|
+
const rawSchema = root["markspec-schema"];
|
|
911
|
+
const markspecSchema = typeof rawSchema === "string" ? rawSchema : undefined;
|
|
912
|
+
if (rawSchema !== undefined && markspecSchema !== "1") {
|
|
913
|
+
diagnostics.push({
|
|
914
|
+
code: "PROFILE-SCHEMA-001",
|
|
915
|
+
severity: "error",
|
|
916
|
+
message: `profile targets core schema "${rawSchema}"; this MarkSpec implements "1"`,
|
|
917
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
918
|
+
});
|
|
919
|
+
return { manifest: null, diagnostics };
|
|
920
|
+
}
|
|
736
921
|
const extendsSpec = parseSpecifier(root.extends, sourcePath, diagnostics);
|
|
737
922
|
if (root.extends !== undefined && extendsSpec === undefined) {
|
|
738
923
|
return { manifest: null, diagnostics };
|
|
@@ -764,24 +949,11 @@ function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
764
949
|
}
|
|
765
950
|
}
|
|
766
951
|
const profileSection = (rawProfile ?? {});
|
|
767
|
-
const universalRequired = parseStringList(profileSection.required, "profile.required", sourcePath, diagnostics);
|
|
768
952
|
const universalAttributes = parseAttrList(profileSection.attributes, "profile.attributes", sourcePath, diagnostics);
|
|
769
|
-
const labels =
|
|
953
|
+
const labels = parseLabelConcerns(profileSection.labels, sourcePath, diagnostics);
|
|
770
954
|
const colors = parseColorsMap(profileSection.colors, sourcePath, diagnostics);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
const idRaw = parseShapeScope(profileSection.identified, ALLOWED_IDENTIFIED_KEYS, "profile.identified", sourcePath, diagnostics);
|
|
775
|
-
const refRaw = parseShapeScope(profileSection.referenced, ALLOWED_REFERENCED_KEYS, "profile.referenced", sourcePath, diagnostics);
|
|
776
|
-
if (idRaw === undefined || refRaw === undefined || diagnostics.length > 0) {
|
|
777
|
-
return { manifest: null, diagnostics };
|
|
778
|
-
}
|
|
779
|
-
const identifiedRequired = parseStringList(idRaw.required, "profile.identified.required", sourcePath, diagnostics);
|
|
780
|
-
const identifiedAttributes = parseAttrList(idRaw.attributes, "profile.identified.attributes", sourcePath, diagnostics);
|
|
781
|
-
const identifiedTraceability = parseTraceabilityMap(idRaw.traceability, "profile.identified.traceability", sourcePath, diagnostics);
|
|
782
|
-
const referencedRequired = parseStringList(refRaw.required, "profile.referenced.required", sourcePath, diagnostics);
|
|
783
|
-
const referencedAttributes = parseAttrList(refRaw.attributes, "profile.referenced.attributes", sourcePath, diagnostics);
|
|
784
|
-
if (diagnostics.length > 0) {
|
|
955
|
+
const conventions = parseConventions(profileSection.conventions, sourcePath, diagnostics);
|
|
956
|
+
if (diagnostics.some((d) => d.severity === "error")) {
|
|
785
957
|
return { manifest: null, diagnostics };
|
|
786
958
|
}
|
|
787
959
|
const types = parseTypesMap(profileSection.types, sourcePath, diagnostics);
|
|
@@ -792,27 +964,29 @@ function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
792
964
|
if (diagnostics.some((d) => d.severity === "error")) {
|
|
793
965
|
return { manifest: null, diagnostics };
|
|
794
966
|
}
|
|
967
|
+
// PROFILE-SCHEMA-002: emitted on the otherwise-complete manifest so it
|
|
968
|
+
// doesn't add noise to error-case output.
|
|
969
|
+
if (rawSchema === undefined) {
|
|
970
|
+
diagnostics.push({
|
|
971
|
+
code: "PROFILE-SCHEMA-002",
|
|
972
|
+
severity: "warning",
|
|
973
|
+
message: 'profile is missing markspec-schema pin; add `markspec-schema: "1"` to declare the core schema version this profile targets',
|
|
974
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
975
|
+
});
|
|
976
|
+
}
|
|
795
977
|
const manifest = {
|
|
796
978
|
id,
|
|
797
979
|
version,
|
|
980
|
+
markspecSchema,
|
|
798
981
|
description: typeof root.description === "string"
|
|
799
982
|
? root.description
|
|
800
983
|
: undefined,
|
|
801
984
|
license: typeof root.license === "string" ? root.license : undefined,
|
|
802
985
|
extends: extendsSpec,
|
|
803
|
-
universalRequired,
|
|
804
986
|
universalAttributes,
|
|
805
987
|
labels,
|
|
988
|
+
conventions,
|
|
806
989
|
colors,
|
|
807
|
-
identified: {
|
|
808
|
-
required: identifiedRequired,
|
|
809
|
-
attributes: identifiedAttributes,
|
|
810
|
-
traceability: identifiedTraceability,
|
|
811
|
-
},
|
|
812
|
-
referenced: {
|
|
813
|
-
required: referencedRequired,
|
|
814
|
-
attributes: referencedAttributes,
|
|
815
|
-
},
|
|
816
990
|
types: types,
|
|
817
991
|
documents: documents,
|
|
818
992
|
};
|