@driftsys/markspec 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -8
- package/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +127 -0
- package/esm/compiler/inverses.d.ts +22 -0
- package/esm/compiler/inverses.d.ts.map +1 -0
- package/esm/compiler/inverses.js +147 -0
- package/esm/compiler/link_target.d.ts +19 -0
- package/esm/compiler/link_target.d.ts.map +1 -0
- package/esm/compiler/link_target.js +66 -0
- package/esm/compiler/mod.d.ts +43 -0
- package/esm/compiler/mod.d.ts.map +1 -0
- package/esm/compiler/mod.js +163 -0
- package/esm/compiler/schema.d.ts +38 -0
- package/esm/compiler/schema.d.ts.map +1 -0
- package/esm/compiler/schema.js +44 -0
- package/esm/config/markspec.d.ts +51 -0
- package/esm/config/markspec.d.ts.map +1 -0
- package/esm/config/markspec.js +216 -0
- package/esm/config/mod.d.ts +48 -0
- package/esm/config/mod.d.ts.map +1 -0
- package/esm/config/mod.js +243 -0
- package/esm/formatter/mod.d.ts +65 -0
- package/esm/formatter/mod.d.ts.map +1 -0
- package/esm/formatter/mod.js +306 -0
- package/esm/mod.d.ts +19 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +18 -0
- package/esm/model/attributes.d.ts +47 -0
- package/esm/model/attributes.d.ts.map +1 -0
- package/esm/model/attributes.js +97 -0
- package/esm/model/mod.d.ts +381 -0
- package/esm/model/mod.d.ts.map +1 -0
- package/esm/model/mod.js +73 -0
- package/esm/model/profile.d.ts +189 -0
- package/esm/model/profile.d.ts.map +1 -0
- package/esm/model/profile.js +31 -0
- package/esm/parser/attributes.d.ts +48 -0
- package/esm/parser/attributes.d.ts.map +1 -0
- package/esm/parser/attributes.js +131 -0
- package/esm/parser/captions.d.ts +25 -0
- package/esm/parser/captions.d.ts.map +1 -0
- package/esm/parser/captions.js +148 -0
- package/esm/parser/directives.d.ts +29 -0
- package/esm/parser/directives.d.ts.map +1 -0
- package/esm/parser/directives.js +88 -0
- package/esm/parser/frontmatter.d.ts +53 -0
- package/esm/parser/frontmatter.d.ts.map +1 -0
- package/esm/parser/frontmatter.js +185 -0
- package/esm/parser/grammars.d.ts +22 -0
- package/esm/parser/grammars.d.ts.map +1 -0
- package/esm/parser/grammars.js +70 -0
- package/esm/parser/markdown.d.ts +32 -0
- package/esm/parser/markdown.d.ts.map +1 -0
- package/esm/parser/markdown.js +225 -0
- package/esm/parser/mod.d.ts +73 -0
- package/esm/parser/mod.d.ts.map +1 -0
- package/esm/parser/mod.js +89 -0
- package/esm/parser/references.d.ts +24 -0
- package/esm/parser/references.d.ts.map +1 -0
- package/esm/parser/references.js +71 -0
- package/esm/parser/remark.d.ts +9 -0
- package/esm/parser/remark.d.ts.map +1 -0
- package/esm/parser/remark.js +11 -0
- package/esm/parser/source.d.ts +33 -0
- package/esm/parser/source.d.ts.map +1 -0
- package/esm/parser/source.js +192 -0
- package/esm/profile/cache.d.ts +29 -0
- package/esm/profile/cache.d.ts.map +1 -0
- package/esm/profile/cache.js +45 -0
- package/esm/profile/chain.d.ts +42 -0
- package/esm/profile/chain.d.ts.map +1 -0
- package/esm/profile/chain.js +193 -0
- package/esm/profile/git-cache.d.ts +73 -0
- package/esm/profile/git-cache.d.ts.map +1 -0
- package/esm/profile/git-cache.js +96 -0
- package/esm/profile/load.d.ts +28 -0
- package/esm/profile/load.d.ts.map +1 -0
- package/esm/profile/load.js +50 -0
- package/esm/profile/manifest.d.ts +21 -0
- package/esm/profile/manifest.d.ts.map +1 -0
- package/esm/profile/manifest.js +830 -0
- package/esm/profile/merge.d.ts +26 -0
- package/esm/profile/merge.d.ts.map +1 -0
- package/esm/profile/merge.js +518 -0
- package/esm/profile/mod.d.ts +23 -0
- package/esm/profile/mod.d.ts.map +1 -0
- package/esm/profile/mod.js +14 -0
- package/esm/profile/npm.d.ts +51 -0
- package/esm/profile/npm.d.ts.map +1 -0
- package/esm/profile/npm.js +186 -0
- package/esm/profile/resolver.d.ts +60 -0
- package/esm/profile/resolver.d.ts.map +1 -0
- package/esm/profile/resolver.js +132 -0
- package/esm/reporter/mod.d.ts +31 -0
- package/esm/reporter/mod.d.ts.map +1 -0
- package/esm/reporter/mod.js +173 -0
- package/esm/validator/attributes.d.ts +43 -0
- package/esm/validator/attributes.d.ts.map +1 -0
- package/esm/validator/attributes.js +169 -0
- package/esm/validator/mod.d.ts +44 -0
- package/esm/validator/mod.d.ts.map +1 -0
- package/esm/validator/mod.js +214 -0
- package/esm/validator/normalize.d.ts +21 -0
- package/esm/validator/normalize.d.ts.map +1 -0
- package/esm/validator/normalize.js +58 -0
- package/esm/validator/pattern.d.ts +23 -0
- package/esm/validator/pattern.d.ts.map +1 -0
- package/esm/validator/pattern.js +44 -0
- package/esm/validator/pipeline.d.ts +30 -0
- package/esm/validator/pipeline.d.ts.map +1 -0
- package/esm/validator/pipeline.js +115 -0
- package/esm/validator/traceability.d.ts +48 -0
- package/esm/validator/traceability.d.ts.map +1 -0
- package/esm/validator/traceability.js +141 -0
- package/esm/validator/types.d.ts +48 -0
- package/esm/validator/types.d.ts.map +1 -0
- package/esm/validator/types.js +140 -0
- package/esm/validator/value_types.d.ts +20 -0
- package/esm/validator/value_types.d.ts.map +1 -0
- package/esm/validator/value_types.js +126 -0
- package/package.json +8 -1
- package/script/_dnt.polyfills.d.ts +101 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +130 -0
- package/script/compiler/inverses.d.ts +22 -0
- package/script/compiler/inverses.d.ts.map +1 -0
- package/script/compiler/inverses.js +150 -0
- package/script/compiler/link_target.d.ts +19 -0
- package/script/compiler/link_target.d.ts.map +1 -0
- package/script/compiler/link_target.js +69 -0
- package/script/compiler/mod.d.ts +43 -0
- package/script/compiler/mod.d.ts.map +1 -0
- package/script/compiler/mod.js +169 -0
- package/script/compiler/schema.d.ts +38 -0
- package/script/compiler/schema.d.ts.map +1 -0
- package/script/compiler/schema.js +47 -0
- package/script/config/markspec.d.ts +51 -0
- package/script/config/markspec.d.ts.map +1 -0
- package/script/config/markspec.js +222 -0
- package/script/config/mod.d.ts +48 -0
- package/script/config/mod.d.ts.map +1 -0
- package/script/config/mod.js +250 -0
- package/script/formatter/mod.d.ts +65 -0
- package/script/formatter/mod.d.ts.map +1 -0
- package/script/formatter/mod.js +313 -0
- package/script/mod.d.ts +19 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +65 -2
- package/script/model/attributes.d.ts +47 -0
- package/script/model/attributes.d.ts.map +1 -0
- package/script/model/attributes.js +101 -0
- package/script/model/mod.d.ts +381 -0
- package/script/model/mod.d.ts.map +1 -0
- package/script/model/mod.js +83 -0
- package/script/model/profile.d.ts +189 -0
- package/script/model/profile.d.ts.map +1 -0
- package/script/model/profile.js +34 -0
- package/script/parser/attributes.d.ts +48 -0
- package/script/parser/attributes.d.ts.map +1 -0
- package/script/parser/attributes.js +137 -0
- package/script/parser/captions.d.ts +25 -0
- package/script/parser/captions.d.ts.map +1 -0
- package/script/parser/captions.js +151 -0
- package/script/parser/directives.d.ts +29 -0
- package/script/parser/directives.d.ts.map +1 -0
- package/script/parser/directives.js +91 -0
- package/script/parser/frontmatter.d.ts +53 -0
- package/script/parser/frontmatter.d.ts.map +1 -0
- package/script/parser/frontmatter.js +188 -0
- package/script/parser/grammars.d.ts +22 -0
- package/script/parser/grammars.d.ts.map +1 -0
- package/script/parser/grammars.js +77 -0
- package/script/parser/markdown.d.ts +32 -0
- package/script/parser/markdown.d.ts.map +1 -0
- package/script/parser/markdown.js +228 -0
- package/script/parser/mod.d.ts +73 -0
- package/script/parser/mod.d.ts.map +1 -0
- package/script/parser/mod.js +101 -0
- package/script/parser/references.d.ts +24 -0
- package/script/parser/references.d.ts.map +1 -0
- package/script/parser/references.js +74 -0
- package/script/parser/remark.d.ts +9 -0
- package/script/parser/remark.d.ts.map +1 -0
- package/script/parser/remark.js +17 -0
- package/script/parser/source.d.ts +33 -0
- package/script/parser/source.d.ts.map +1 -0
- package/script/parser/source.js +198 -0
- package/script/profile/cache.d.ts +29 -0
- package/script/profile/cache.d.ts.map +1 -0
- package/script/profile/cache.js +48 -0
- package/script/profile/chain.d.ts +42 -0
- package/script/profile/chain.d.ts.map +1 -0
- package/script/profile/chain.js +229 -0
- package/script/profile/git-cache.d.ts +73 -0
- package/script/profile/git-cache.d.ts.map +1 -0
- package/script/profile/git-cache.js +104 -0
- package/script/profile/load.d.ts +28 -0
- package/script/profile/load.d.ts.map +1 -0
- package/script/profile/load.js +53 -0
- package/script/profile/manifest.d.ts +21 -0
- package/script/profile/manifest.d.ts.map +1 -0
- package/script/profile/manifest.js +833 -0
- package/script/profile/merge.d.ts +26 -0
- package/script/profile/merge.d.ts.map +1 -0
- package/script/profile/merge.js +521 -0
- package/script/profile/mod.d.ts +23 -0
- package/script/profile/mod.d.ts.map +1 -0
- package/script/profile/mod.js +31 -0
- package/script/profile/npm.d.ts +51 -0
- package/script/profile/npm.d.ts.map +1 -0
- package/script/profile/npm.js +191 -0
- package/script/profile/resolver.d.ts +60 -0
- package/script/profile/resolver.d.ts.map +1 -0
- package/script/profile/resolver.js +136 -0
- package/script/reporter/mod.d.ts +31 -0
- package/script/reporter/mod.d.ts.map +1 -0
- package/script/reporter/mod.js +176 -0
- package/script/validator/attributes.d.ts +43 -0
- package/script/validator/attributes.d.ts.map +1 -0
- package/script/validator/attributes.js +173 -0
- package/script/validator/mod.d.ts +44 -0
- package/script/validator/mod.d.ts.map +1 -0
- package/script/validator/mod.js +231 -0
- package/script/validator/normalize.d.ts +21 -0
- package/script/validator/normalize.d.ts.map +1 -0
- package/script/validator/normalize.js +61 -0
- package/script/validator/pattern.d.ts +23 -0
- package/script/validator/pattern.d.ts.map +1 -0
- package/script/validator/pattern.js +47 -0
- package/script/validator/pipeline.d.ts +30 -0
- package/script/validator/pipeline.d.ts.map +1 -0
- package/script/validator/pipeline.js +118 -0
- package/script/validator/traceability.d.ts +48 -0
- package/script/validator/traceability.d.ts.map +1 -0
- package/script/validator/traceability.js +146 -0
- package/script/validator/types.d.ts +48 -0
- package/script/validator/types.d.ts.map +1 -0
- package/script/validator/types.js +144 -0
- package/script/validator/value_types.d.ts +20 -0
- package/script/validator/value_types.d.ts.map +1 -0
- package/script/validator/value_types.js +129 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module config
|
|
3
|
+
*
|
|
4
|
+
* Project discovery and configuration loading. Walks up from CWD to
|
|
5
|
+
* find `project.yaml`, parses the YAML, and validates the schema.
|
|
6
|
+
*/
|
|
7
|
+
import { parse as parseYaml } from "@std/yaml";
|
|
8
|
+
import { dirname, join, resolve } from "@std/path";
|
|
9
|
+
import { ConfigError, DEFAULT_PROJECT_CONFIG, } from "../model/mod.js";
|
|
10
|
+
/** The config file name used as the project root marker. */
|
|
11
|
+
export const CONFIG_FILE_NAME = "project.yaml";
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Discovery
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Walk up from `startDir` to the filesystem root looking for `project.yaml`.
|
|
17
|
+
*
|
|
18
|
+
* @returns Absolute path to the directory containing `project.yaml`,
|
|
19
|
+
* or `undefined` if not found.
|
|
20
|
+
*/
|
|
21
|
+
export async function discoverProjectRoot(startDir, readFile) {
|
|
22
|
+
let current = resolve(startDir);
|
|
23
|
+
for (;;) {
|
|
24
|
+
const candidate = join(current, CONFIG_FILE_NAME);
|
|
25
|
+
const content = await readFile(candidate);
|
|
26
|
+
if (content !== undefined)
|
|
27
|
+
return current;
|
|
28
|
+
const parent = dirname(current);
|
|
29
|
+
if (parent === current)
|
|
30
|
+
return undefined;
|
|
31
|
+
current = parent;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Parsing and validation
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
/** Escape special regex characters for safe interpolation into RegExp. */
|
|
38
|
+
function escapeRegex(s) {
|
|
39
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
40
|
+
}
|
|
41
|
+
/** Find the 1-based line number where `^fieldName:` appears in raw YAML. */
|
|
42
|
+
function findLineNumber(rawYaml, fieldName) {
|
|
43
|
+
const pattern = new RegExp(`^${escapeRegex(fieldName)}\\s*:`, "m");
|
|
44
|
+
const match = pattern.exec(rawYaml);
|
|
45
|
+
if (!match)
|
|
46
|
+
return undefined;
|
|
47
|
+
return rawYaml.slice(0, match.index).split("\n").length;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse a YAML string and validate it as a MarkSpec project configuration.
|
|
51
|
+
*
|
|
52
|
+
* @param yaml - Raw YAML content
|
|
53
|
+
* @param filePath - Path to the file (for error messages)
|
|
54
|
+
* @returns Validated `ProjectConfig`
|
|
55
|
+
* @throws {ConfigError} on invalid content
|
|
56
|
+
*/
|
|
57
|
+
export function parseProjectConfig(yaml, filePath) {
|
|
58
|
+
// Parse YAML
|
|
59
|
+
let raw;
|
|
60
|
+
try {
|
|
61
|
+
raw = parseYaml(yaml);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
throw new ConfigError(filePath, [
|
|
65
|
+
{
|
|
66
|
+
field: "(syntax)",
|
|
67
|
+
message: err instanceof Error ? err.message : String(err),
|
|
68
|
+
line: undefined,
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
// Must be a plain object
|
|
73
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
74
|
+
throw new ConfigError(filePath, [
|
|
75
|
+
{
|
|
76
|
+
field: "(root)",
|
|
77
|
+
message: "expected a YAML mapping, got " +
|
|
78
|
+
(raw === null ? "null" : Array.isArray(raw) ? "array" : typeof raw),
|
|
79
|
+
line: undefined,
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
const obj = raw;
|
|
84
|
+
const errors = [];
|
|
85
|
+
// name: required string
|
|
86
|
+
if (obj.name === undefined || obj.name === null || obj.name === "") {
|
|
87
|
+
errors.push({
|
|
88
|
+
field: "name",
|
|
89
|
+
message: "required, must be a non-empty string",
|
|
90
|
+
line: obj.name === undefined ? undefined : findLineNumber(yaml, "name"),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else if (typeof obj.name !== "string") {
|
|
94
|
+
errors.push({
|
|
95
|
+
field: "name",
|
|
96
|
+
message: `expected string, got ${typeof obj.name}`,
|
|
97
|
+
line: findLineNumber(yaml, "name"),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// version: optional string
|
|
101
|
+
// version: optional string
|
|
102
|
+
let version = DEFAULT_PROJECT_CONFIG.version;
|
|
103
|
+
if (obj.version !== undefined && obj.version !== null) {
|
|
104
|
+
if (typeof obj.version === "number") {
|
|
105
|
+
console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
|
|
106
|
+
`coerced to "${String(obj.version)}". ` +
|
|
107
|
+
`Quote it in YAML: version: "${obj.version}"`);
|
|
108
|
+
}
|
|
109
|
+
version = String(obj.version);
|
|
110
|
+
}
|
|
111
|
+
// labels: optional string[]
|
|
112
|
+
let labels = DEFAULT_PROJECT_CONFIG.labels;
|
|
113
|
+
if (obj.labels !== undefined && obj.labels !== null) {
|
|
114
|
+
if (!Array.isArray(obj.labels)) {
|
|
115
|
+
errors.push({
|
|
116
|
+
field: "labels",
|
|
117
|
+
message: `expected array, got ${typeof obj.labels}`,
|
|
118
|
+
line: findLineNumber(yaml, "labels"),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const bad = obj.labels.findIndex((v) => typeof v !== "string" || v === "");
|
|
123
|
+
if (bad !== -1) {
|
|
124
|
+
errors.push({
|
|
125
|
+
field: `labels[${bad}]`,
|
|
126
|
+
message: "each label must be a non-empty string",
|
|
127
|
+
line: findLineNumber(yaml, "labels"),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
labels = obj.labels;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// parents: optional string[] of URLs
|
|
136
|
+
let parents = DEFAULT_PROJECT_CONFIG.parents;
|
|
137
|
+
if (obj.parents !== undefined && obj.parents !== null) {
|
|
138
|
+
if (!Array.isArray(obj.parents)) {
|
|
139
|
+
errors.push({
|
|
140
|
+
field: "parents",
|
|
141
|
+
message: `expected array, got ${typeof obj.parents}`,
|
|
142
|
+
line: findLineNumber(yaml, "parents"),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const bad = obj.parents.findIndex((v) => typeof v !== "string" || !isValidUrl(v));
|
|
147
|
+
if (bad !== -1) {
|
|
148
|
+
errors.push({
|
|
149
|
+
field: `parents[${bad}]`,
|
|
150
|
+
message: "each parent must be a valid URL",
|
|
151
|
+
line: findLineNumber(yaml, "parents"),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
parents = obj.parents;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// parent-fallback: optional URL string
|
|
160
|
+
let parentFallback = DEFAULT_PROJECT_CONFIG.parentFallback;
|
|
161
|
+
const fallbackKey = "parent-fallback";
|
|
162
|
+
if (obj[fallbackKey] !== undefined && obj[fallbackKey] !== null) {
|
|
163
|
+
const val = obj[fallbackKey];
|
|
164
|
+
if (typeof val !== "string" || !isValidUrl(val)) {
|
|
165
|
+
errors.push({
|
|
166
|
+
field: "parent-fallback",
|
|
167
|
+
message: "must be a valid URL",
|
|
168
|
+
line: findLineNumber(yaml, "parent-fallback"),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
parentFallback = val;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (errors.length > 0) {
|
|
176
|
+
throw new ConfigError(filePath, errors);
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
name: obj.name,
|
|
180
|
+
version,
|
|
181
|
+
labels,
|
|
182
|
+
parents,
|
|
183
|
+
parentFallback,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
// Domain derivation
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
/**
|
|
190
|
+
* Derive a 3-6 letter project domain abbreviation from the project name.
|
|
191
|
+
*/
|
|
192
|
+
export function deriveDomain(projectName) {
|
|
193
|
+
const lastSegment = projectName.split(".").pop() ?? projectName;
|
|
194
|
+
const words = lastSegment.split(/[-_]+/).filter((w) => w.length > 0);
|
|
195
|
+
if (words.length === 0) {
|
|
196
|
+
return "XXXXX";
|
|
197
|
+
}
|
|
198
|
+
const charsPerWord = Math.ceil(6 / words.length);
|
|
199
|
+
const abbrev = words
|
|
200
|
+
.map((word) => word.slice(0, charsPerWord).toUpperCase())
|
|
201
|
+
.join("");
|
|
202
|
+
if (abbrev.length >= 3 && abbrev.length <= 6) {
|
|
203
|
+
return abbrev;
|
|
204
|
+
}
|
|
205
|
+
else if (abbrev.length > 6) {
|
|
206
|
+
return abbrev.slice(0, 6);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
return (abbrev + "XXXXXX").slice(0, 6);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
// Combined load
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
/**
|
|
216
|
+
* Discover `project.yaml` by walking up from `startDir`, load, and validate.
|
|
217
|
+
*
|
|
218
|
+
* @returns `LoadConfigResult` if found and valid, `undefined` if not found.
|
|
219
|
+
* @throws {ConfigError} if `project.yaml` exists but is invalid.
|
|
220
|
+
*/
|
|
221
|
+
export async function loadConfig(startDir, readFile) {
|
|
222
|
+
const root = await discoverProjectRoot(startDir, readFile);
|
|
223
|
+
if (root === undefined)
|
|
224
|
+
return undefined;
|
|
225
|
+
const configPath = join(root, CONFIG_FILE_NAME);
|
|
226
|
+
const content = await readFile(configPath);
|
|
227
|
+
if (content === undefined)
|
|
228
|
+
return undefined;
|
|
229
|
+
const config = parseProjectConfig(content, configPath);
|
|
230
|
+
return { config, projectRoot: root, configPath };
|
|
231
|
+
}
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
// Helpers
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
function isValidUrl(value) {
|
|
236
|
+
try {
|
|
237
|
+
new URL(value);
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter
|
|
3
|
+
*
|
|
4
|
+
* Markdown formatter and ULID assigner. Handles write-back operations:
|
|
5
|
+
* ULID stamping, indentation normalization, trailing backslash enforcement,
|
|
6
|
+
* and requirement block insertion.
|
|
7
|
+
*/
|
|
8
|
+
import type { Attribute, Diagnostic } from "../model/mod.js";
|
|
9
|
+
/** Options for {@linkcode format}. */
|
|
10
|
+
export interface FormatOptions {
|
|
11
|
+
/** File path for diagnostic messages. */
|
|
12
|
+
readonly file?: string;
|
|
13
|
+
/** ULID generator override (for testing). */
|
|
14
|
+
readonly generateUlid?: () => string;
|
|
15
|
+
}
|
|
16
|
+
/** Result of a format operation. */
|
|
17
|
+
export interface FormatResult {
|
|
18
|
+
/** The formatted Markdown text. */
|
|
19
|
+
readonly output: string;
|
|
20
|
+
/** Diagnostics emitted during formatting (e.g., ULID assignments). */
|
|
21
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
22
|
+
/** Whether any changes were made. */
|
|
23
|
+
readonly changed: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format a Markdown string — normalize attribute blocks,
|
|
27
|
+
* fix indentation, enforce canonical ordering.
|
|
28
|
+
*
|
|
29
|
+
* @param markdown - Markdown source text
|
|
30
|
+
* @param options - Format options
|
|
31
|
+
* @returns Format result with output text and diagnostics
|
|
32
|
+
*/
|
|
33
|
+
export declare function format(markdown: string, options?: FormatOptions): FormatResult;
|
|
34
|
+
/**
|
|
35
|
+
* Expand CSV values on repeatable-type attributes into one entry per value
|
|
36
|
+
* per ADR-002 §2.6. `id-list` / `tag-list` / `external-id` accept CSV input
|
|
37
|
+
* but must round-trip as multi-line output; `citation` is left alone
|
|
38
|
+
* because locators may contain commas.
|
|
39
|
+
*/
|
|
40
|
+
export declare function expandCsvValues(attrs: Attribute[]): Attribute[];
|
|
41
|
+
/**
|
|
42
|
+
* Sort attributes to canonical order per the language spec.
|
|
43
|
+
*
|
|
44
|
+
* `Id:` first, then profile-declared/unknown keys in source order, then
|
|
45
|
+
* universal attributes (References / Labels / External-id / Supersedes /
|
|
46
|
+
* Superseded-by / Deprecated).
|
|
47
|
+
*/
|
|
48
|
+
export declare function sortAttributes(attributes: Attribute[]): Attribute[];
|
|
49
|
+
/**
|
|
50
|
+
* Render attributes as indented `Key: Value\` lines.
|
|
51
|
+
* Trailing backslash on all lines except the last.
|
|
52
|
+
*/
|
|
53
|
+
export declare function renderAttributeBlock(attributes: Attribute[], indent: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* Find the 0-based line range [start, end) of the attribute block
|
|
56
|
+
* for an entry starting at the given line.
|
|
57
|
+
*
|
|
58
|
+
* Scans forward from the entry start to find the list item boundary,
|
|
59
|
+
* then walks backwards to find the contiguous trailing attribute block.
|
|
60
|
+
*/
|
|
61
|
+
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number): {
|
|
62
|
+
start: number;
|
|
63
|
+
end: number;
|
|
64
|
+
} | undefined;
|
|
65
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AAyDzB,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CACtC;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA8Ed;AA8BD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAmB/D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CAmCb;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAQR;AA2BD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2B5C"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter
|
|
3
|
+
*
|
|
4
|
+
* Markdown formatter and ULID assigner. Handles write-back operations:
|
|
5
|
+
* ULID stamping, indentation normalization, trailing backslash enforcement,
|
|
6
|
+
* and requirement block insertion.
|
|
7
|
+
*/
|
|
8
|
+
import { ulid as defaultUlid } from "@std/ulid";
|
|
9
|
+
import { stringify as stringifyYaml } from "@std/yaml";
|
|
10
|
+
import { attributeSpec, IDENTITY_KEY } from "../model/mod.js";
|
|
11
|
+
import { ATTR_LINE_RE } from "../parser/attributes.js";
|
|
12
|
+
import { extractFrontMatter } from "../parser/frontmatter.js";
|
|
13
|
+
import { parseMarkdown } from "../parser/markdown.js";
|
|
14
|
+
/**
|
|
15
|
+
* Value types that accept CSV on input but must be emitted as multi-line
|
|
16
|
+
* per ADR-002 §2.6. `citation` is deliberately excluded because locators
|
|
17
|
+
* may contain commas.
|
|
18
|
+
*/
|
|
19
|
+
const CSV_SPLITTABLE_TYPES = new Set([
|
|
20
|
+
"id-list",
|
|
21
|
+
"tag-list",
|
|
22
|
+
"external-id",
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Canonical front-matter key order per ADR-007. Core keys first, then
|
|
26
|
+
* `metadata` (reserved free-form map), then `extra` (allowlisted ecosystem
|
|
27
|
+
* keys / profile keys) are emitted verbatim at the end.
|
|
28
|
+
*/
|
|
29
|
+
const FRONT_MATTER_CORE_ORDER = [
|
|
30
|
+
"document-id",
|
|
31
|
+
"document-type",
|
|
32
|
+
"labels",
|
|
33
|
+
"deprecated",
|
|
34
|
+
"external-id",
|
|
35
|
+
"supersedes",
|
|
36
|
+
"references",
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Canonical attribute ordering per the language spec.
|
|
40
|
+
*
|
|
41
|
+
* Identity (`Id:`) comes first, then profile-declared attributes appear in
|
|
42
|
+
* the order the author wrote them (or in the order a profile-aware pass
|
|
43
|
+
* may rewrite them), then the universal set
|
|
44
|
+
* (References / Labels / External-id / Supersedes / Deprecated). Unknown
|
|
45
|
+
* keys are placed just before `Labels:`, preserving their relative order.
|
|
46
|
+
*
|
|
47
|
+
* A profile-aware formatter may extend this with profile-declared canonical
|
|
48
|
+
* positions; the core formatter only knows about `Id:` and the universal
|
|
49
|
+
* set.
|
|
50
|
+
*/
|
|
51
|
+
const CANONICAL_ORDER = [
|
|
52
|
+
"Id",
|
|
53
|
+
// Profile-declared attributes land here in whatever order the source has
|
|
54
|
+
// them; the filler slot keeps them between Id and the universal set.
|
|
55
|
+
"References",
|
|
56
|
+
"Labels",
|
|
57
|
+
"External-id",
|
|
58
|
+
"Supersedes",
|
|
59
|
+
"Superseded-by",
|
|
60
|
+
"Deprecated",
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* Format a Markdown string — normalize attribute blocks,
|
|
64
|
+
* fix indentation, enforce canonical ordering.
|
|
65
|
+
*
|
|
66
|
+
* @param markdown - Markdown source text
|
|
67
|
+
* @param options - Format options
|
|
68
|
+
* @returns Format result with output text and diagnostics
|
|
69
|
+
*/
|
|
70
|
+
export function format(markdown, options) {
|
|
71
|
+
const file = options?.file ?? "<unknown>";
|
|
72
|
+
// Extract any YAML front matter first so entries are parsed against the
|
|
73
|
+
// body only (front-matter `---` could be confused with horizontal rules).
|
|
74
|
+
const fm = extractFrontMatter(markdown, { file });
|
|
75
|
+
const body = fm.hadFrontMatter ? fm.markdown : markdown;
|
|
76
|
+
const entries = parseMarkdown(body, { file });
|
|
77
|
+
const diagnostics = [...fm.diagnostics];
|
|
78
|
+
if (entries.length === 0 && !fm.hadFrontMatter) {
|
|
79
|
+
return { output: markdown, diagnostics, changed: false };
|
|
80
|
+
}
|
|
81
|
+
const lines = body.split("\n");
|
|
82
|
+
let changed = false;
|
|
83
|
+
// Process bottom-to-top so line splicing doesn't shift earlier entries.
|
|
84
|
+
const sorted = [...entries].sort((a, b) => b.location.line - a.location.line);
|
|
85
|
+
const genUlid = options?.generateUlid ?? defaultUlid;
|
|
86
|
+
for (const entry of sorted) {
|
|
87
|
+
const indent = (entry.location.column - 1) + 2;
|
|
88
|
+
let attrs = [...entry.rawAttributes];
|
|
89
|
+
// Assign a bare ULID `Id:` to identified entries that carry no
|
|
90
|
+
// identity yet. Referenced entries are left alone — their `Id:` is a
|
|
91
|
+
// URI that must be author-provided.
|
|
92
|
+
const hasIdentity = attrs.some((a) => a.key === IDENTITY_KEY);
|
|
93
|
+
if (!hasIdentity && entry.shape === "identified") {
|
|
94
|
+
const newId = genUlid();
|
|
95
|
+
attrs = [{ key: IDENTITY_KEY, value: newId }, ...attrs];
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
code: "MSL-F001",
|
|
98
|
+
severity: "info",
|
|
99
|
+
message: `assigned Id: ${newId} to ${entry.displayId}`,
|
|
100
|
+
location: entry.location,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (attrs.length === 0)
|
|
104
|
+
continue;
|
|
105
|
+
const normalized = sortAttributes(expandCsvValues(attrs));
|
|
106
|
+
const range = findAttributeBlockRange(lines, entry.location.line, indent);
|
|
107
|
+
if (range) {
|
|
108
|
+
// Replace existing attribute block.
|
|
109
|
+
const newBlock = renderAttributeBlock(normalized, indent);
|
|
110
|
+
const oldBlock = lines.slice(range.start, range.end).join("\n");
|
|
111
|
+
if (newBlock !== oldBlock) {
|
|
112
|
+
lines.splice(range.start, range.end - range.start, ...newBlock.split("\n"));
|
|
113
|
+
changed = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// No attribute block — insert one after the entry body.
|
|
118
|
+
const insertLine = findEntryBodyEnd(lines, entry, indent);
|
|
119
|
+
const newBlock = renderAttributeBlock(normalized, indent);
|
|
120
|
+
lines.splice(insertLine, 0, "", ...newBlock.split("\n"));
|
|
121
|
+
changed = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const formattedBody = lines.join("\n");
|
|
125
|
+
if (fm.hadFrontMatter) {
|
|
126
|
+
const canonicalFm = renderFrontMatter(fm.attributes);
|
|
127
|
+
const output = canonicalFm + formattedBody;
|
|
128
|
+
if (output !== markdown)
|
|
129
|
+
changed = true;
|
|
130
|
+
return { output, diagnostics, changed };
|
|
131
|
+
}
|
|
132
|
+
return { output: formattedBody, diagnostics, changed };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Render {@linkcode DocumentAttributes} as a canonical YAML front matter
|
|
136
|
+
* block. Keys are emitted in canonical order (core → metadata → extra);
|
|
137
|
+
* an `extra` subtree is flattened to top-level keys per ADR-007
|
|
138
|
+
* allowlist conventions.
|
|
139
|
+
*/
|
|
140
|
+
function renderFrontMatter(attrs) {
|
|
141
|
+
const ordered = {};
|
|
142
|
+
const a = attrs;
|
|
143
|
+
for (const key of FRONT_MATTER_CORE_ORDER) {
|
|
144
|
+
if (a[key] !== undefined)
|
|
145
|
+
ordered[key] = a[key];
|
|
146
|
+
}
|
|
147
|
+
if (a.metadata !== undefined)
|
|
148
|
+
ordered.metadata = a.metadata;
|
|
149
|
+
if (a.extra && typeof a.extra === "object") {
|
|
150
|
+
for (const [key, value] of Object.entries(a.extra)) {
|
|
151
|
+
ordered[key] = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (Object.keys(ordered).length === 0) {
|
|
155
|
+
return "---\n---\n\n";
|
|
156
|
+
}
|
|
157
|
+
const yaml = stringifyYaml(ordered).trimEnd();
|
|
158
|
+
return `---\n${yaml}\n---\n\n`;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Expand CSV values on repeatable-type attributes into one entry per value
|
|
162
|
+
* per ADR-002 §2.6. `id-list` / `tag-list` / `external-id` accept CSV input
|
|
163
|
+
* but must round-trip as multi-line output; `citation` is left alone
|
|
164
|
+
* because locators may contain commas.
|
|
165
|
+
*/
|
|
166
|
+
export function expandCsvValues(attrs) {
|
|
167
|
+
const result = [];
|
|
168
|
+
for (const attr of attrs) {
|
|
169
|
+
const spec = attributeSpec(attr.key);
|
|
170
|
+
if (spec && CSV_SPLITTABLE_TYPES.has(spec.type) && attr.value.includes(",")) {
|
|
171
|
+
const values = attr.value
|
|
172
|
+
.split(",")
|
|
173
|
+
.map((s) => s.trim())
|
|
174
|
+
.filter((s) => s.length > 0);
|
|
175
|
+
for (const value of values) {
|
|
176
|
+
result.push({ key: attr.key, value });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
result.push(attr);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sort attributes to canonical order per the language spec.
|
|
187
|
+
*
|
|
188
|
+
* `Id:` first, then profile-declared/unknown keys in source order, then
|
|
189
|
+
* universal attributes (References / Labels / External-id / Supersedes /
|
|
190
|
+
* Superseded-by / Deprecated).
|
|
191
|
+
*/
|
|
192
|
+
export function sortAttributes(attributes) {
|
|
193
|
+
const known = new Array(CANONICAL_ORDER.length);
|
|
194
|
+
const unknown = [];
|
|
195
|
+
for (const attr of attributes) {
|
|
196
|
+
const idx = CANONICAL_ORDER.indexOf(attr.key);
|
|
197
|
+
if (idx >= 0) {
|
|
198
|
+
// Preserve duplicates — keep all occurrences of the same key.
|
|
199
|
+
if (!known[idx])
|
|
200
|
+
known[idx] = [];
|
|
201
|
+
known[idx].push(attr);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
unknown.push(attr);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const result = [];
|
|
208
|
+
const labelsIdx = CANONICAL_ORDER.indexOf("Labels");
|
|
209
|
+
const hasLabels = known[labelsIdx] != null;
|
|
210
|
+
for (let i = 0; i < known.length; i++) {
|
|
211
|
+
// Insert unknown attributes just before Labels (or at end if no Labels).
|
|
212
|
+
if (i === labelsIdx && hasLabels) {
|
|
213
|
+
result.push(...unknown);
|
|
214
|
+
}
|
|
215
|
+
if (known[i] != null) {
|
|
216
|
+
result.push(...known[i]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// If Labels was not present, unknown attrs go at the end.
|
|
220
|
+
if (!hasLabels) {
|
|
221
|
+
result.push(...unknown);
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Render attributes as indented `Key: Value\` lines.
|
|
227
|
+
* Trailing backslash on all lines except the last.
|
|
228
|
+
*/
|
|
229
|
+
export function renderAttributeBlock(attributes, indent) {
|
|
230
|
+
const prefix = " ".repeat(indent);
|
|
231
|
+
return attributes
|
|
232
|
+
.map((attr, i) => {
|
|
233
|
+
const sep = i < attributes.length - 1 ? "\\" : "";
|
|
234
|
+
return `${prefix}${attr.key}: ${attr.value}${sep}`;
|
|
235
|
+
})
|
|
236
|
+
.join("\n");
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Find the 0-based line index where a list item's content ends.
|
|
240
|
+
* Scans forward from the entry start, stopping at: a sibling list item
|
|
241
|
+
* (`- ` at the entry's marker column), a line with less indent, or EOF.
|
|
242
|
+
*/
|
|
243
|
+
function findItemEnd(lines, startIdx, indent) {
|
|
244
|
+
const indentStr = " ".repeat(indent);
|
|
245
|
+
// The marker column is indent - 2 (e.g., indent 2 → marker at column 0).
|
|
246
|
+
const markerPrefix = " ".repeat(Math.max(0, indent - 2)) + "- ";
|
|
247
|
+
for (let i = startIdx + 1; i < lines.length; i++) {
|
|
248
|
+
const line = lines[i];
|
|
249
|
+
if (line.trim() === "")
|
|
250
|
+
continue;
|
|
251
|
+
// Sibling list item at same level
|
|
252
|
+
if (line.startsWith(markerPrefix))
|
|
253
|
+
return i;
|
|
254
|
+
// Line with less indent than continuation
|
|
255
|
+
if (!line.startsWith(indentStr))
|
|
256
|
+
return i;
|
|
257
|
+
}
|
|
258
|
+
return lines.length;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Find the 0-based line range [start, end) of the attribute block
|
|
262
|
+
* for an entry starting at the given line.
|
|
263
|
+
*
|
|
264
|
+
* Scans forward from the entry start to find the list item boundary,
|
|
265
|
+
* then walks backwards to find the contiguous trailing attribute block.
|
|
266
|
+
*/
|
|
267
|
+
export function findAttributeBlockRange(lines, entryStartLine, indent) {
|
|
268
|
+
const startIdx = entryStartLine - 1;
|
|
269
|
+
const itemEnd = findItemEnd(lines, startIdx, indent);
|
|
270
|
+
// Walk backwards from itemEnd, skip trailing blank lines.
|
|
271
|
+
let scanEnd = itemEnd;
|
|
272
|
+
while (scanEnd > startIdx && lines[scanEnd - 1].trim() === "") {
|
|
273
|
+
scanEnd--;
|
|
274
|
+
}
|
|
275
|
+
if (scanEnd <= startIdx)
|
|
276
|
+
return undefined;
|
|
277
|
+
// Walk backwards collecting attribute lines.
|
|
278
|
+
let attrStart = scanEnd;
|
|
279
|
+
for (let i = scanEnd - 1; i > startIdx; i--) {
|
|
280
|
+
const trimmed = lines[i].trim();
|
|
281
|
+
if (trimmed === "")
|
|
282
|
+
break;
|
|
283
|
+
if (ATTR_LINE_RE.test(trimmed)) {
|
|
284
|
+
attrStart = i;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (attrStart >= scanEnd)
|
|
291
|
+
return undefined;
|
|
292
|
+
return { start: attrStart, end: scanEnd };
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Find the 0-based line index where a new attribute block should be inserted
|
|
296
|
+
* (after the last non-blank body line of the entry).
|
|
297
|
+
*/
|
|
298
|
+
function findEntryBodyEnd(lines, entry, indent) {
|
|
299
|
+
const startIdx = entry.location.line - 1;
|
|
300
|
+
const itemEnd = findItemEnd(lines, startIdx, indent);
|
|
301
|
+
let insertAt = itemEnd;
|
|
302
|
+
while (insertAt > startIdx && lines[insertAt - 1].trim() === "") {
|
|
303
|
+
insertAt--;
|
|
304
|
+
}
|
|
305
|
+
return insertAt;
|
|
306
|
+
}
|
package/esm/mod.d.ts
CHANGED
|
@@ -7,5 +7,24 @@
|
|
|
7
7
|
* This is the library boundary. Everything outside core/ imports
|
|
8
8
|
* from core/mod.ts, never from internal paths.
|
|
9
9
|
*/
|
|
10
|
+
import "./_dnt.polyfills.js";
|
|
10
11
|
export declare const VERSION = "0.0.1";
|
|
12
|
+
export { ConfigError, DEFAULT_PROJECT_CONFIG, REFHUB_URL, } from "./model/mod.js";
|
|
13
|
+
export type { Attribute, Caption, ConfigFieldError, Diagnostic, Directive, DisplayId, EffectiveProfile, Entry, EntryShape, EntrySource, InlineRef, Link, LinkKind, ProfileChain, ProjectConfig, Severity, SourceLocation, Ulid, } from "./model/mod.js";
|
|
14
|
+
export { discoverProjectRoot, loadConfig, parseProjectConfig, } from "./config/mod.js";
|
|
15
|
+
export type { LoadConfigResult, ReadFile } from "./config/mod.js";
|
|
16
|
+
export { MARKSPEC_YAML_FILENAME, parseMarkspecYaml, readMarkspecYaml, } from "./config/markspec.js";
|
|
17
|
+
export type { MarkspecYaml, ParseMarkspecYamlResult, } from "./config/markspec.js";
|
|
18
|
+
export { computeCacheKey, computeCacheLocation, defaultAppendFile, defaultRunGit, ensureCacheGitignored, loadChain, loadProfileForCommand, mergeChain, parseManifest, resolveGitSpecifier, resolveLocalSpecifier, } from "./profile/mod.js";
|
|
19
|
+
export type { AppendFile, CacheLocation, GitCacheKeyInput, LoadChainOptions, LoadChainResult, LoadProfileForCommandResult, MergeResult, ParseManifestResult, ResolvedProfileSource, ResolveGitOptions, RunGit, RunGitResult, } from "./profile/mod.js";
|
|
20
|
+
export { detectCaptions, detectDirectives, detectInlineRefs, isSupportedExtension, loadGrammar, parse, parseFile, parseSource, } from "./parser/mod.js";
|
|
21
|
+
export type { DetectCaptionsOptions, DetectDirectivesOptions, DetectInlineRefsOptions, ParseFileResult, ParseOptions, ParseSourceOptions, ParseSourceResult, } from "./parser/mod.js";
|
|
22
|
+
export { format } from "./formatter/mod.js";
|
|
23
|
+
export type { FormatOptions, FormatResult } from "./formatter/mod.js";
|
|
24
|
+
export { classifyEntriesStage, classifyEntry, compileDisplayIdPattern, effectiveScope, effectiveTraceRules, matchesAnyTarget, normalizeListValues, runPipeline, validate, validateAttributesForEntry, validateTraceabilityForEntry, validateValue, } from "./validator/mod.js";
|
|
25
|
+
export type { ClassifyResult, ClassifyStageResult, EffectiveAttrScope, PipelineResult, ValidateResult, ValueValidator, } from "./validator/mod.js";
|
|
26
|
+
export { compile, generateInverses, serializeCompileResult, } from "./compiler/mod.js";
|
|
27
|
+
export type { CompileOptions, CompileResult, GenerateInversesResult, SerializedCompileResult, } from "./compiler/mod.js";
|
|
28
|
+
export { report } from "./reporter/mod.js";
|
|
29
|
+
export type { ReportFormat, ReportKind, ReportOptions, } from "./reporter/mod.js";
|
|
11
30
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,qBAAqB,CAAC;AAG7B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,IAAI,GACL,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,EACN,YAAY,GACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,KAAK,EACL,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,0BAA0B,EAC1B,4BAA4B,EAC5B,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,mBAAmB,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -7,4 +7,22 @@
|
|
|
7
7
|
* This is the library boundary. Everything outside core/ imports
|
|
8
8
|
* from core/mod.ts, never from internal paths.
|
|
9
9
|
*/
|
|
10
|
+
import "./_dnt.polyfills.js";
|
|
10
11
|
export const VERSION = "0.0.1";
|
|
12
|
+
// Model types
|
|
13
|
+
export { ConfigError, DEFAULT_PROJECT_CONFIG, REFHUB_URL, } from "./model/mod.js";
|
|
14
|
+
// Config
|
|
15
|
+
export { discoverProjectRoot, loadConfig, parseProjectConfig, } from "./config/mod.js";
|
|
16
|
+
export { MARKSPEC_YAML_FILENAME, parseMarkspecYaml, readMarkspecYaml, } from "./config/markspec.js";
|
|
17
|
+
// Profile system (ADR-008)
|
|
18
|
+
export { computeCacheKey, computeCacheLocation, defaultAppendFile, defaultRunGit, ensureCacheGitignored, loadChain, loadProfileForCommand, mergeChain, parseManifest, resolveGitSpecifier, resolveLocalSpecifier, } from "./profile/mod.js";
|
|
19
|
+
// Parser
|
|
20
|
+
export { detectCaptions, detectDirectives, detectInlineRefs, isSupportedExtension, loadGrammar, parse, parseFile, parseSource, } from "./parser/mod.js";
|
|
21
|
+
// Formatter
|
|
22
|
+
export { format } from "./formatter/mod.js";
|
|
23
|
+
// Validator
|
|
24
|
+
export { classifyEntriesStage, classifyEntry, compileDisplayIdPattern, effectiveScope, effectiveTraceRules, matchesAnyTarget, normalizeListValues, runPipeline, validate, validateAttributesForEntry, validateTraceabilityForEntry, validateValue, } from "./validator/mod.js";
|
|
25
|
+
// Compiler
|
|
26
|
+
export { compile, generateInverses, serializeCompileResult, } from "./compiler/mod.js";
|
|
27
|
+
// Reporter
|
|
28
|
+
export { report } from "./reporter/mod.js";
|