@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/model/palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,YAAY,sEAQf,CAAC;AAEX,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAErD,+EAA+E;AAC/E,eAAO,MAAM,aAAa,QAAsB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/palette
|
|
3
|
+
*
|
|
4
|
+
* The seven-hue entry color palette and its semantic-name regex. Single
|
|
5
|
+
* source of truth — both the profile manifest parser and the renderer
|
|
6
|
+
* import from here so the two layers can never drift.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the `diagram:` group in `theme/tokens.yaml`. Adding a hue is a
|
|
9
|
+
* tokens-side change followed by an entry here; the order does not matter
|
|
10
|
+
* but kept stable for diagnostic message readability.
|
|
11
|
+
*/
|
|
12
|
+
/** The seven palette hues a profile may bind a semantic color name to. */
|
|
13
|
+
export const PALETTE_HUES = [
|
|
14
|
+
"blue",
|
|
15
|
+
"cyan",
|
|
16
|
+
"teal",
|
|
17
|
+
"orange",
|
|
18
|
+
"red",
|
|
19
|
+
"purple",
|
|
20
|
+
"grey",
|
|
21
|
+
];
|
|
22
|
+
/** Regex for a valid semantic color-role name (key into `profile.colors:`). */
|
|
23
|
+
export const COLOR_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
package/esm/model/profile.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Profile data model — TypeScript types that mirror ADR-008 §4 manifest
|
|
5
5
|
* schema. Used by the profile loader, merger, and validator.
|
|
6
6
|
*/
|
|
7
|
-
import type { EntryShape } from "./mod.js";
|
|
8
7
|
/** All 14 attribute value-type keywords recognized by the core. */
|
|
9
8
|
export declare const VALUE_TYPES: readonly ["id", "id-list", "uri", "url", "path", "path-or-id", "enum", "tag-list", "text", "citation", "external-id", "integer", "date", "boolean"];
|
|
10
9
|
export type ValueType = typeof VALUE_TYPES[number];
|
|
@@ -28,21 +27,40 @@ export interface AttrDecl {
|
|
|
28
27
|
readonly cardinality: Cardinality;
|
|
29
28
|
readonly values?: readonly string[];
|
|
30
29
|
readonly inverse?: InverseDecl;
|
|
30
|
+
readonly description?: string;
|
|
31
31
|
}
|
|
32
32
|
/** Target matcher: either a type name or a shape matcher object. */
|
|
33
33
|
export type TargetMatcher = string | {
|
|
34
|
-
readonly shape: "
|
|
34
|
+
readonly shape: "Authored" | "Reference";
|
|
35
35
|
};
|
|
36
36
|
/** Traceability rule declared on a shape or type scope. */
|
|
37
37
|
export interface TraceRule {
|
|
38
38
|
readonly target: readonly TargetMatcher[];
|
|
39
39
|
readonly cardinality?: Cardinality;
|
|
40
40
|
readonly required: boolean;
|
|
41
|
+
readonly description?: string;
|
|
42
|
+
}
|
|
43
|
+
export type LabelConcernKind = "enum" | "set" | "flag";
|
|
44
|
+
export interface LabelValue {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly description?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface LabelConcern {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly kind: LabelConcernKind;
|
|
51
|
+
readonly description?: string;
|
|
52
|
+
readonly values: readonly LabelValue[];
|
|
53
|
+
}
|
|
54
|
+
export interface ProfileConvention {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
57
|
+
readonly description?: string;
|
|
41
58
|
}
|
|
42
59
|
export type EnforcementMode = "off" | "warn" | "error";
|
|
43
60
|
export interface TypeDef {
|
|
44
61
|
readonly name: string;
|
|
45
|
-
|
|
62
|
+
/** The core type this profile type extends (e.g., "Requirement", "Test"). */
|
|
63
|
+
readonly extends: string;
|
|
46
64
|
readonly displayIdPattern?: string;
|
|
47
65
|
readonly displayIdPatternEnforcement: EnforcementMode;
|
|
48
66
|
readonly required: readonly string[];
|
|
@@ -50,6 +68,7 @@ export interface TypeDef {
|
|
|
50
68
|
readonly traceability: ReadonlyMap<string, TraceRule>;
|
|
51
69
|
/** Optional semantic color-role name (key into `ProfileManifest.colors`). */
|
|
52
70
|
readonly color?: string;
|
|
71
|
+
readonly description?: string;
|
|
53
72
|
}
|
|
54
73
|
export interface DocTypeDef {
|
|
55
74
|
readonly id: string;
|
|
@@ -75,12 +94,14 @@ export type ProfileSpecifier = {
|
|
|
75
94
|
export interface ProfileManifest {
|
|
76
95
|
readonly id: string;
|
|
77
96
|
readonly version: string;
|
|
97
|
+
/** The `markspec-schema:` pin declaring the core schema version targeted. */
|
|
98
|
+
readonly markspecSchema?: string;
|
|
78
99
|
readonly description?: string;
|
|
79
100
|
readonly license?: string;
|
|
80
101
|
readonly extends?: ProfileSpecifier;
|
|
81
|
-
readonly universalRequired: readonly string[];
|
|
82
102
|
readonly universalAttributes: readonly AttrDecl[];
|
|
83
|
-
readonly labels: readonly
|
|
103
|
+
readonly labels: readonly LabelConcern[];
|
|
104
|
+
readonly conventions: readonly ProfileConvention[];
|
|
84
105
|
/**
|
|
85
106
|
* Semantic color-role bindings authored on this manifest.
|
|
86
107
|
* Maps a profile-author-chosen name (e.g. "primary") to a palette hue
|
|
@@ -88,15 +109,6 @@ export interface ProfileManifest {
|
|
|
88
109
|
* Empty when the manifest does not declare `profile.colors:`.
|
|
89
110
|
*/
|
|
90
111
|
readonly colors: ReadonlyMap<string, string>;
|
|
91
|
-
readonly identified: {
|
|
92
|
-
readonly required: readonly string[];
|
|
93
|
-
readonly attributes: readonly AttrDecl[];
|
|
94
|
-
readonly traceability: ReadonlyMap<string, TraceRule>;
|
|
95
|
-
};
|
|
96
|
-
readonly referenced: {
|
|
97
|
-
readonly required: readonly string[];
|
|
98
|
-
readonly attributes: readonly AttrDecl[];
|
|
99
|
-
};
|
|
100
112
|
readonly types: ReadonlyMap<string, TypeDef>;
|
|
101
113
|
readonly documents: {
|
|
102
114
|
readonly types: readonly DocTypeDef[];
|
|
@@ -148,18 +160,11 @@ export interface ProvenancedMapEntry<V> {
|
|
|
148
160
|
}
|
|
149
161
|
/** Map with per-entry provenance. Keys are always strings (attr/type/link names). */
|
|
150
162
|
export type ProvenancedMap<V> = ReadonlyMap<string, ProvenancedMapEntry<V>>;
|
|
151
|
-
/** Shape-scope rules after merging (identified or referenced). */
|
|
152
|
-
export interface EffectiveShapeScope {
|
|
153
|
-
readonly required: ProvenancedValue<readonly string[]>;
|
|
154
|
-
readonly attributes: ProvenancedMap<AttrDecl>;
|
|
155
|
-
/** Referenced scope's traceability is always empty (referenced entries don't originate links). */
|
|
156
|
-
readonly traceability: ProvenancedMap<TraceRule>;
|
|
157
|
-
}
|
|
158
163
|
/** Type-scope rules after merging. */
|
|
159
164
|
export interface EffectiveTypeDef {
|
|
160
165
|
readonly name: string;
|
|
161
|
-
/**
|
|
162
|
-
readonly
|
|
166
|
+
/** The core type this profile type extends — frozen at declaration, never changes across the chain. */
|
|
167
|
+
readonly extends: string;
|
|
163
168
|
readonly displayIdPattern: ProvenancedValue<string | undefined>;
|
|
164
169
|
readonly displayIdPatternEnforcement: ProvenancedValue<EnforcementMode>;
|
|
165
170
|
/** Resolved semantic color-role name, or `undefined` when unset. */
|
|
@@ -167,19 +172,20 @@ export interface EffectiveTypeDef {
|
|
|
167
172
|
readonly required: ProvenancedValue<readonly string[]>;
|
|
168
173
|
readonly attributes: ProvenancedMap<AttrDecl>;
|
|
169
174
|
readonly traceability: ProvenancedMap<TraceRule>;
|
|
175
|
+
readonly description: ProvenancedValue<string | undefined>;
|
|
176
|
+
readonly attrDescriptions: ProvenancedMap<string>;
|
|
177
|
+
readonly relationDescriptions: ProvenancedMap<string>;
|
|
170
178
|
}
|
|
171
179
|
/**
|
|
172
180
|
* The merged, validator-ready view of a profile chain. Every field carries
|
|
173
181
|
* per-rule provenance so a diagnostic can blame the right tier.
|
|
174
182
|
*/
|
|
175
183
|
export interface EffectiveProfile {
|
|
176
|
-
readonly required: ProvenancedValue<readonly string[]>;
|
|
177
184
|
readonly attributes: ProvenancedMap<AttrDecl>;
|
|
178
|
-
readonly labels:
|
|
185
|
+
readonly labels: ProvenancedMap<LabelConcern>;
|
|
186
|
+
readonly conventions: ProvenancedMap<ProfileConvention>;
|
|
179
187
|
/** Semantic color-role bindings merged across the chain. */
|
|
180
188
|
readonly colors: ProvenancedMap<string>;
|
|
181
|
-
readonly identified: EffectiveShapeScope;
|
|
182
|
-
readonly referenced: EffectiveShapeScope;
|
|
183
189
|
readonly types: ProvenancedMap<EffectiveTypeDef>;
|
|
184
190
|
readonly documents: {
|
|
185
191
|
readonly types: ProvenancedMap<DocTypeDef>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/model/profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/model/profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,mEAAmE;AACnE,eAAO,MAAM,WAAW,qJAed,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnD,0DAA0D;AAC1D,eAAO,MA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AQ,CAAC,CAAC;KAChD,CAAC;CACH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/source_introspection
|
|
3
|
+
*
|
|
4
|
+
* `Source:` → core type inference per spec §1.3.1 step 3 and
|
|
5
|
+
* ADR-003 §Part 5. Returns the inferred core type when the
|
|
6
|
+
* `Source:` value looks like a recognised manifest, source-code
|
|
7
|
+
* file, interface description, or bus description; `undefined`
|
|
8
|
+
* otherwise.
|
|
9
|
+
*
|
|
10
|
+
* Match order is significant — manifests must run before generic
|
|
11
|
+
* extension matches so `path/to/something.json` doesn't shadow
|
|
12
|
+
* `package.json`. The list is conservative: only patterns ADR-003
|
|
13
|
+
* §Part 5 lists normatively are encoded here; profiles extend the
|
|
14
|
+
* map later.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Infer a core type from a `Source:` attribute value. The value
|
|
18
|
+
* may be a filesystem path or a URI — only the filename portion
|
|
19
|
+
* is matched. Whitespace is trimmed before matching.
|
|
20
|
+
*
|
|
21
|
+
* Returns `undefined` when no pattern matches; callers should treat
|
|
22
|
+
* that as "Source: didn't classify" and fall through to step 4 of
|
|
23
|
+
* the resolution chain.
|
|
24
|
+
*/
|
|
25
|
+
export declare function inferTypeFromSource(source: string): string | undefined;
|
|
26
|
+
//# sourceMappingURL=source_introspection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source_introspection.d.ts","sourceRoot":"","sources":["../../src/model/source_introspection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwDH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMtE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/source_introspection
|
|
3
|
+
*
|
|
4
|
+
* `Source:` → core type inference per spec §1.3.1 step 3 and
|
|
5
|
+
* ADR-003 §Part 5. Returns the inferred core type when the
|
|
6
|
+
* `Source:` value looks like a recognised manifest, source-code
|
|
7
|
+
* file, interface description, or bus description; `undefined`
|
|
8
|
+
* otherwise.
|
|
9
|
+
*
|
|
10
|
+
* Match order is significant — manifests must run before generic
|
|
11
|
+
* extension matches so `path/to/something.json` doesn't shadow
|
|
12
|
+
* `package.json`. The list is conservative: only patterns ADR-003
|
|
13
|
+
* §Part 5 lists normatively are encoded here; profiles extend the
|
|
14
|
+
* map later.
|
|
15
|
+
*/
|
|
16
|
+
const SOURCE_PATTERNS = [
|
|
17
|
+
// Build manifests → SoftwareComponent. Anchored at filename
|
|
18
|
+
// boundary so `weird-Cargo.toml` doesn't match unintentionally.
|
|
19
|
+
{ pattern: /(?:^|\/)Cargo\.toml$/, type: "SoftwareComponent" },
|
|
20
|
+
{ pattern: /(?:^|\/)package\.json$/, type: "SoftwareComponent" },
|
|
21
|
+
{ pattern: /(?:^|\/)pom\.xml$/, type: "SoftwareComponent" },
|
|
22
|
+
{ pattern: /(?:^|\/)deno\.json$/, type: "SoftwareComponent" },
|
|
23
|
+
{ pattern: /(?:^|\/)go\.mod$/, type: "SoftwareComponent" },
|
|
24
|
+
{ pattern: /(?:^|\/)pyproject\.toml$/, type: "SoftwareComponent" },
|
|
25
|
+
{ pattern: /(?:^|\/)setup\.py$/, type: "SoftwareComponent" },
|
|
26
|
+
{ pattern: /(?:^|\/)pubspec\.yaml$/, type: "SoftwareComponent" },
|
|
27
|
+
{ pattern: /(?:^|\/)[^/]+\.csproj$/, type: "SoftwareComponent" },
|
|
28
|
+
// Interface description files → SoftwareInterface. Run BEFORE the
|
|
29
|
+
// generic source-code extensions so `.openapi.yaml` wins over `.yaml`.
|
|
30
|
+
{ pattern: /\.openapi\.(?:yaml|yml|json)$/, type: "SoftwareInterface" },
|
|
31
|
+
{ pattern: /\.asyncapi\.(?:yaml|yml|json)$/, type: "SoftwareInterface" },
|
|
32
|
+
{ pattern: /\.proto$/, type: "SoftwareInterface" },
|
|
33
|
+
{ pattern: /\.graphql$/, type: "SoftwareInterface" },
|
|
34
|
+
{ pattern: /\.wsdl$/, type: "SoftwareInterface" },
|
|
35
|
+
{ pattern: /\.arxml$/, type: "SoftwareInterface" },
|
|
36
|
+
{ pattern: /\.idl$/, type: "SoftwareInterface" },
|
|
37
|
+
{ pattern: /\.ridl$/, type: "SoftwareInterface" },
|
|
38
|
+
// Bus description files → HardwareInterface.
|
|
39
|
+
{ pattern: /\.dbc$/, type: "HardwareInterface" },
|
|
40
|
+
{ pattern: /\.ldf$/, type: "HardwareInterface" },
|
|
41
|
+
{ pattern: /\.fibex$/, type: "HardwareInterface" },
|
|
42
|
+
// Source-code files → SoftwareUnit.
|
|
43
|
+
{ pattern: /\.rs$/, type: "SoftwareUnit" },
|
|
44
|
+
{ pattern: /\.kt$/, type: "SoftwareUnit" },
|
|
45
|
+
{ pattern: /\.kts$/, type: "SoftwareUnit" },
|
|
46
|
+
{ pattern: /\.java$/, type: "SoftwareUnit" },
|
|
47
|
+
{ pattern: /\.py$/, type: "SoftwareUnit" },
|
|
48
|
+
{ pattern: /\.ts$/, type: "SoftwareUnit" },
|
|
49
|
+
{ pattern: /\.tsx$/, type: "SoftwareUnit" },
|
|
50
|
+
{ pattern: /\.js$/, type: "SoftwareUnit" },
|
|
51
|
+
{ pattern: /\.jsx$/, type: "SoftwareUnit" },
|
|
52
|
+
{ pattern: /\.go$/, type: "SoftwareUnit" },
|
|
53
|
+
{ pattern: /\.cpp$/, type: "SoftwareUnit" },
|
|
54
|
+
{ pattern: /\.cc$/, type: "SoftwareUnit" },
|
|
55
|
+
{ pattern: /\.cxx$/, type: "SoftwareUnit" },
|
|
56
|
+
{ pattern: /\.c$/, type: "SoftwareUnit" },
|
|
57
|
+
{ pattern: /\.h$/, type: "SoftwareUnit" },
|
|
58
|
+
{ pattern: /\.hpp$/, type: "SoftwareUnit" },
|
|
59
|
+
{ pattern: /\.hxx$/, type: "SoftwareUnit" },
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Infer a core type from a `Source:` attribute value. The value
|
|
63
|
+
* may be a filesystem path or a URI — only the filename portion
|
|
64
|
+
* is matched. Whitespace is trimmed before matching.
|
|
65
|
+
*
|
|
66
|
+
* Returns `undefined` when no pattern matches; callers should treat
|
|
67
|
+
* that as "Source: didn't classify" and fall through to step 4 of
|
|
68
|
+
* the resolution chain.
|
|
69
|
+
*/
|
|
70
|
+
export function inferTypeFromSource(source) {
|
|
71
|
+
const trimmed = source.trim();
|
|
72
|
+
for (const { pattern, type } of SOURCE_PATTERNS) {
|
|
73
|
+
if (pattern.test(trimmed))
|
|
74
|
+
return type;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/type_hierarchy
|
|
3
|
+
*
|
|
4
|
+
* Core type hierarchy from ADR-003 §Part 2. Encodes the per-type
|
|
5
|
+
* attribute catalogue for the 15 built-in concrete types and the four
|
|
6
|
+
* abstract parents. Attributes flow downward via inheritance; this
|
|
7
|
+
* module exposes lookup helpers consumed by the validator's MSL-T022
|
|
8
|
+
* check and by future profile-resolution work.
|
|
9
|
+
*/
|
|
10
|
+
/** Per-type definition: parent in the hierarchy + locally declared attrs. */
|
|
11
|
+
export interface CoreTypeDef {
|
|
12
|
+
/** Parent type name, or `null` for `Item` (the root). */
|
|
13
|
+
readonly parent: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Attributes declared by this type. Subtype attribute sets include
|
|
16
|
+
* everything declared on ancestor types, per ADR-003 §Part 2.
|
|
17
|
+
*/
|
|
18
|
+
readonly ownAttrs: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* Attributes inherited from ancestors that are "not applicable" on
|
|
21
|
+
* this subtype per ADR-003 §Part 2 (e.g., `Allocated-to` on Test).
|
|
22
|
+
* Removed during {@linkcode attributesForType} resolution.
|
|
23
|
+
*/
|
|
24
|
+
readonly excludedAttrs?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Built-in type hierarchy. Keyed by the canonical TitleCase / lower-with-
|
|
28
|
+
* hyphens name as it would appear in a `Type:` attribute value.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CORE_TYPE_HIERARCHY: Readonly<Record<string, CoreTypeDef>>;
|
|
31
|
+
/**
|
|
32
|
+
* Collect every attribute valid on `typeName` by walking the parent
|
|
33
|
+
* chain and subtracting any `excludedAttrs` declared along the way.
|
|
34
|
+
* Returns a {@linkcode Set} of attribute keys (TitleCase or
|
|
35
|
+
* lowercase-with-hyphens as declared). Returns an empty set for
|
|
36
|
+
* unknown type names — the caller treats unknown types separately.
|
|
37
|
+
*
|
|
38
|
+
* Exclusion semantics: an attribute marked `excludedAttrs` on a
|
|
39
|
+
* subtype is removed from the final set even if an ancestor declared
|
|
40
|
+
* it. The subtype cannot re-add the attribute later — only its own
|
|
41
|
+
* `ownAttrs` list contributes.
|
|
42
|
+
*/
|
|
43
|
+
export declare function attributesForType(typeName: string): Set<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Union of every type-scoped attribute name declared anywhere in the
|
|
46
|
+
* core hierarchy. Used by the validator to suppress `MSL-R010`
|
|
47
|
+
* (unknown attribute) for keys that are core-known but appear on the
|
|
48
|
+
* "wrong" type — those cases get the more specific `MSL-T022`.
|
|
49
|
+
*/
|
|
50
|
+
export declare const CORE_TYPE_SCOPED_ATTRS: ReadonlySet<string>;
|
|
51
|
+
//# sourceMappingURL=type_hierarchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_hierarchy.d.ts","sourceRoot":"","sources":["../../src/model/type_hierarchy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA0ErE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAa/D;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAMnD,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/type_hierarchy
|
|
3
|
+
*
|
|
4
|
+
* Core type hierarchy from ADR-003 §Part 2. Encodes the per-type
|
|
5
|
+
* attribute catalogue for the 15 built-in concrete types and the four
|
|
6
|
+
* abstract parents. Attributes flow downward via inheritance; this
|
|
7
|
+
* module exposes lookup helpers consumed by the validator's MSL-T022
|
|
8
|
+
* check and by future profile-resolution work.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Built-in type hierarchy. Keyed by the canonical TitleCase / lower-with-
|
|
12
|
+
* hyphens name as it would appear in a `Type:` attribute value.
|
|
13
|
+
*/
|
|
14
|
+
export const CORE_TYPE_HIERARCHY = {
|
|
15
|
+
// Root
|
|
16
|
+
Item: { parent: null, ownAttrs: [] },
|
|
17
|
+
// Specification family (ADR-003 §Part 2 — Specification)
|
|
18
|
+
Specification: {
|
|
19
|
+
parent: "Item",
|
|
20
|
+
ownAttrs: ["Derived-from", "Satisfies", "Allocated-to"],
|
|
21
|
+
},
|
|
22
|
+
Requirement: { parent: "Specification", ownAttrs: [] },
|
|
23
|
+
Test: {
|
|
24
|
+
parent: "Specification",
|
|
25
|
+
ownAttrs: ["Verifies", "Tests"],
|
|
26
|
+
// ADR-003 §Part 2 — Test: "Allocated-to: not applicable —
|
|
27
|
+
// tests are not allocated to components".
|
|
28
|
+
excludedAttrs: ["Allocated-to"],
|
|
29
|
+
},
|
|
30
|
+
Contract: { parent: "Specification", ownAttrs: ["Schema-language"] },
|
|
31
|
+
Record: { parent: "Specification", ownAttrs: ["Caused-by", "Affects"] },
|
|
32
|
+
Risk: { parent: "Specification", ownAttrs: ["Caused-by", "Mitigated-by"] },
|
|
33
|
+
// Component family (ADR-003 §Part 2 — Component)
|
|
34
|
+
Component: {
|
|
35
|
+
parent: "Item",
|
|
36
|
+
ownAttrs: [
|
|
37
|
+
"Kind",
|
|
38
|
+
"Part-of",
|
|
39
|
+
"Realizes",
|
|
40
|
+
"Depends-on",
|
|
41
|
+
"Provides",
|
|
42
|
+
"Requires",
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
SoftwareComponent: {
|
|
46
|
+
parent: "Component",
|
|
47
|
+
ownAttrs: ["License", "Build-manifest", "Package-manager"],
|
|
48
|
+
},
|
|
49
|
+
HardwareComponent: {
|
|
50
|
+
parent: "Component",
|
|
51
|
+
ownAttrs: ["Manufacturer", "Part-number", "Datasheet"],
|
|
52
|
+
},
|
|
53
|
+
SoftwareInterface: { parent: "Component", ownAttrs: [] },
|
|
54
|
+
HardwareInterface: {
|
|
55
|
+
parent: "Component",
|
|
56
|
+
ownAttrs: [
|
|
57
|
+
"Bus-protocol",
|
|
58
|
+
"Connector-type",
|
|
59
|
+
"Voltage-level",
|
|
60
|
+
"Signal-direction",
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
// Unit family (ADR-003 §Part 2 — Unit)
|
|
64
|
+
Unit: {
|
|
65
|
+
parent: "Item",
|
|
66
|
+
ownAttrs: ["Part-of", "Realizes", "Depends-on"],
|
|
67
|
+
},
|
|
68
|
+
SoftwareUnit: {
|
|
69
|
+
parent: "Unit",
|
|
70
|
+
ownAttrs: ["Source", "Symbol", "Language"],
|
|
71
|
+
},
|
|
72
|
+
HardwareUnit: {
|
|
73
|
+
parent: "Unit",
|
|
74
|
+
ownAttrs: [
|
|
75
|
+
"Manufacturer",
|
|
76
|
+
"Part-number",
|
|
77
|
+
"Datasheet",
|
|
78
|
+
"Footprint",
|
|
79
|
+
"Value",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
// Standalone subtype of Item (ADR-003 §Part 2 — Definition)
|
|
83
|
+
Definition: { parent: "Item", ownAttrs: ["Aliases", "See-also"] },
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Collect every attribute valid on `typeName` by walking the parent
|
|
87
|
+
* chain and subtracting any `excludedAttrs` declared along the way.
|
|
88
|
+
* Returns a {@linkcode Set} of attribute keys (TitleCase or
|
|
89
|
+
* lowercase-with-hyphens as declared). Returns an empty set for
|
|
90
|
+
* unknown type names — the caller treats unknown types separately.
|
|
91
|
+
*
|
|
92
|
+
* Exclusion semantics: an attribute marked `excludedAttrs` on a
|
|
93
|
+
* subtype is removed from the final set even if an ancestor declared
|
|
94
|
+
* it. The subtype cannot re-add the attribute later — only its own
|
|
95
|
+
* `ownAttrs` list contributes.
|
|
96
|
+
*/
|
|
97
|
+
export function attributesForType(typeName) {
|
|
98
|
+
const result = new Set();
|
|
99
|
+
const excluded = new Set();
|
|
100
|
+
let cursor = typeName;
|
|
101
|
+
while (cursor !== null && CORE_TYPE_HIERARCHY[cursor]) {
|
|
102
|
+
for (const a of CORE_TYPE_HIERARCHY[cursor].ownAttrs)
|
|
103
|
+
result.add(a);
|
|
104
|
+
for (const a of CORE_TYPE_HIERARCHY[cursor].excludedAttrs ?? []) {
|
|
105
|
+
excluded.add(a);
|
|
106
|
+
}
|
|
107
|
+
cursor = CORE_TYPE_HIERARCHY[cursor].parent;
|
|
108
|
+
}
|
|
109
|
+
for (const a of excluded)
|
|
110
|
+
result.delete(a);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Union of every type-scoped attribute name declared anywhere in the
|
|
115
|
+
* core hierarchy. Used by the validator to suppress `MSL-R010`
|
|
116
|
+
* (unknown attribute) for keys that are core-known but appear on the
|
|
117
|
+
* "wrong" type — those cases get the more specific `MSL-T022`.
|
|
118
|
+
*/
|
|
119
|
+
export const CORE_TYPE_SCOPED_ATTRS = (() => {
|
|
120
|
+
const set = new Set();
|
|
121
|
+
for (const def of Object.values(CORE_TYPE_HIERARCHY)) {
|
|
122
|
+
for (const a of def.ownAttrs)
|
|
123
|
+
set.add(a);
|
|
124
|
+
}
|
|
125
|
+
return set;
|
|
126
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/uri_scheme_map
|
|
3
|
+
*
|
|
4
|
+
* Reference-shape URI → core type inference per ADR-003 §Part 6.
|
|
5
|
+
* Used by spec §1.3.1 step 5 of the type-resolution chain: a Reference
|
|
6
|
+
* entry whose `Id:` is a recognised URI scheme can infer its core type
|
|
7
|
+
* without an explicit `Type:` attribute.
|
|
8
|
+
*
|
|
9
|
+
* The map is intentionally conservative: only patterns the spec lists
|
|
10
|
+
* normatively are encoded. Profile extensions to the scheme map land
|
|
11
|
+
* in the profile layer.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Infer a core type name from a Reference-shape `Id:` value (a URI).
|
|
15
|
+
* Returns `undefined` when no rule matches — the caller should leave
|
|
16
|
+
* the entry type unresolved rather than guess.
|
|
17
|
+
*
|
|
18
|
+
* @param idValue The raw `Id:` value (a scheme-qualified URI).
|
|
19
|
+
*/
|
|
20
|
+
export declare function inferTypeFromUriScheme(idValue: string): string | undefined;
|
|
21
|
+
//# sourceMappingURL=uri_scheme_map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri_scheme_map.d.ts","sourceRoot":"","sources":["../../src/model/uri_scheme_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6DH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module model/uri_scheme_map
|
|
3
|
+
*
|
|
4
|
+
* Reference-shape URI → core type inference per ADR-003 §Part 6.
|
|
5
|
+
* Used by spec §1.3.1 step 5 of the type-resolution chain: a Reference
|
|
6
|
+
* entry whose `Id:` is a recognised URI scheme can infer its core type
|
|
7
|
+
* without an explicit `Type:` attribute.
|
|
8
|
+
*
|
|
9
|
+
* The map is intentionally conservative: only patterns the spec lists
|
|
10
|
+
* normatively are encoded. Profile extensions to the scheme map land
|
|
11
|
+
* in the profile layer.
|
|
12
|
+
*/
|
|
13
|
+
const URI_SCHEME_RULES = [
|
|
14
|
+
// Package URLs (purl) — Software components
|
|
15
|
+
{ pattern: /^pkg:cargo\//, type: "SoftwareComponent" },
|
|
16
|
+
{ pattern: /^pkg:npm\//, type: "SoftwareComponent" },
|
|
17
|
+
{ pattern: /^pkg:maven\//, type: "SoftwareComponent" },
|
|
18
|
+
{ pattern: /^pkg:pypi\//, type: "SoftwareComponent" },
|
|
19
|
+
{ pattern: /^pkg:go\//, type: "SoftwareComponent" },
|
|
20
|
+
{ pattern: /^pkg:nuget\//, type: "SoftwareComponent" },
|
|
21
|
+
{ pattern: /^pkg:deno\//, type: "SoftwareComponent" },
|
|
22
|
+
{ pattern: /^pkg:swift\//, type: "SoftwareComponent" },
|
|
23
|
+
{ pattern: /^pkg:firmware\//, type: "SoftwareComponent" },
|
|
24
|
+
// Package URLs — Hardware components
|
|
25
|
+
{ pattern: /^pkg:hw\//, type: "HardwareComponent" },
|
|
26
|
+
{ pattern: /^pkg:device\//, type: "HardwareComponent" },
|
|
27
|
+
// Standards / regulations / RFCs / papers
|
|
28
|
+
{ pattern: /^urn:iso:std:iso:/, type: "Requirement" },
|
|
29
|
+
{ pattern: /^urn:iso:std:iec:/, type: "Requirement" },
|
|
30
|
+
{ pattern: /^urn:iso:std:iso:iec:ieee:/, type: "Requirement" },
|
|
31
|
+
{ pattern: /^urn:ietf:rfc:/, type: "Requirement" },
|
|
32
|
+
{ pattern: /^urn:nist:/, type: "Requirement" },
|
|
33
|
+
{ pattern: /^urn:unece:/, type: "Requirement" },
|
|
34
|
+
{ pattern: /^doi:/, type: "Requirement" },
|
|
35
|
+
// External tracker schemes — Requirement (proxy item in external system)
|
|
36
|
+
{ pattern: /^codebeamer:/, type: "Requirement" },
|
|
37
|
+
{ pattern: /^doors:/, type: "Requirement" },
|
|
38
|
+
{ pattern: /^polarion:/, type: "Requirement" },
|
|
39
|
+
// Interface description schemes
|
|
40
|
+
{ pattern: /^urn:openapi:/, type: "Contract" },
|
|
41
|
+
{ pattern: /^urn:asyncapi:/, type: "Contract" },
|
|
42
|
+
{ pattern: /^urn:protobuf:/, type: "Contract" },
|
|
43
|
+
{ pattern: /^urn:wsdl:/, type: "Contract" },
|
|
44
|
+
{ pattern: /^urn:autosar:port:/, type: "Contract" },
|
|
45
|
+
// Hardware interfaces (bus networks)
|
|
46
|
+
{ pattern: /^urn:can-bus:/, type: "HardwareInterface" },
|
|
47
|
+
// Glossary terms
|
|
48
|
+
{ pattern: /^urn:refhub:term:/, type: "Definition" },
|
|
49
|
+
{ pattern: /^urn:driftsys:refhub:term:/, type: "Definition" },
|
|
50
|
+
// PLM
|
|
51
|
+
{ pattern: /^plm:/, type: "HardwareComponent" },
|
|
52
|
+
];
|
|
53
|
+
/**
|
|
54
|
+
* Infer a core type name from a Reference-shape `Id:` value (a URI).
|
|
55
|
+
* Returns `undefined` when no rule matches — the caller should leave
|
|
56
|
+
* the entry type unresolved rather than guess.
|
|
57
|
+
*
|
|
58
|
+
* @param idValue The raw `Id:` value (a scheme-qualified URI).
|
|
59
|
+
*/
|
|
60
|
+
export function inferTypeFromUriScheme(idValue) {
|
|
61
|
+
for (const rule of URI_SCHEME_RULES) {
|
|
62
|
+
if (rule.pattern.test(idValue))
|
|
63
|
+
return rule.type;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/parser/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/parser/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAalE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,CAgBrE;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,QAA6B,CAAC;AAYvD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,eAAe,CA6BjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA+BpB"}
|
package/esm/parser/attributes.js
CHANGED
|
@@ -9,9 +9,12 @@ import { attributeSpec } from "../model/attributes.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Pattern matching a `Key: Value` attribute line.
|
|
11
11
|
* Key must start with an uppercase letter, may contain lowercase letters and hyphens.
|
|
12
|
-
* Value is everything after
|
|
12
|
+
* Value is everything after `:` (with optional space), with optional trailing
|
|
13
|
+
* backslash stripped. The value group is optional so that `Key:` and `Key: \`
|
|
14
|
+
* are recognized (and subsequently skipped as empty-value lines) rather than
|
|
15
|
+
* silently ignored.
|
|
13
16
|
*/
|
|
14
|
-
const ATTRIBUTE_RE = /^([A-Z][A-Za-z-]*)
|
|
17
|
+
const ATTRIBUTE_RE = /^([A-Z][A-Za-z-]*):\s*(.*?)\\?$/;
|
|
15
18
|
/**
|
|
16
19
|
* Parse an array of attribute lines into Attribute objects.
|
|
17
20
|
*
|
|
@@ -30,10 +33,10 @@ export function parseAttributes(lines) {
|
|
|
30
33
|
continue;
|
|
31
34
|
const match = ATTRIBUTE_RE.exec(trimmed);
|
|
32
35
|
if (match) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value:
|
|
36
|
-
});
|
|
36
|
+
const value = (match[2] ?? "").trim();
|
|
37
|
+
if (!value)
|
|
38
|
+
continue; // skip empty-value lines — `Key:` or `Key: \`
|
|
39
|
+
attributes.push({ key: match[1], value });
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
return attributes;
|