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