@mfdaves/okf-mcp 0.3.2-rc.1
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/LICENSE +21 -0
- package/README.md +504 -0
- package/bin/okf-mcp.js +13 -0
- package/okf/bundles/okf-mcp/distribution/reference-bundle.md +42 -0
- package/okf/bundles/okf-mcp/index.md +17 -0
- package/okf/bundles/okf-mcp/interfaces/http-authoring-api.md +26 -0
- package/okf/bundles/okf-mcp/interfaces/mcp-tools.md +34 -0
- package/okf/bundles/okf-mcp/overview/okf-mcp.md +28 -0
- package/okf/bundles/okf-mcp/policies/authoring-safety.md +38 -0
- package/okf/bundles/okf-mcp/runtime/file-concept-store.md +30 -0
- package/okf/bundles/okf-mcp/runtime/indexer.md +34 -0
- package/okf/bundles/okf-mcp/runtime/mcp-server.md +32 -0
- package/okf/bundles/okf-mcp/specs/concept-format.md +32 -0
- package/okf/bundles/okf-mcp/workflows/concept-authoring.md +30 -0
- package/okf/bundles/okf-mcp/workflows/concept-update.md +30 -0
- package/okf.project.yaml +5 -0
- package/package.json +55 -0
- package/src/authoring.js +334 -0
- package/src/cli.js +427 -0
- package/src/graph.js +278 -0
- package/src/http-server.js +137 -0
- package/src/index.js +15 -0
- package/src/indexer.js +437 -0
- package/src/mcp-server.js +816 -0
- package/src/parser.js +364 -0
- package/src/plugins.js +209 -0
- package/src/project.js +235 -0
- package/src/remote.js +179 -0
- package/src/search.js +179 -0
- package/src/store.js +341 -0
- package/src/validation.js +117 -0
package/src/store.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { buildIndex } = require("./indexer");
|
|
7
|
+
const { loadProjectConfig } = require("./project");
|
|
8
|
+
const { normalizeConceptPath } = require("./authoring");
|
|
9
|
+
|
|
10
|
+
function nowIso() {
|
|
11
|
+
return new Date().toISOString();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function proposalId() {
|
|
15
|
+
if (crypto.randomUUID) {
|
|
16
|
+
return crypto.randomUUID();
|
|
17
|
+
}
|
|
18
|
+
return `${Date.now()}-${crypto.randomBytes(8).toString("hex")}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function ensureDir(dir) {
|
|
22
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function safeProposalFile(root, id) {
|
|
26
|
+
const clean = String(id || "").trim();
|
|
27
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(clean)) {
|
|
28
|
+
throw new Error(`Invalid proposal id: ${id || "<missing>"}`);
|
|
29
|
+
}
|
|
30
|
+
return path.join(root, `${clean}.json`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readJson(filePath) {
|
|
34
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function writeJson(filePath, value) {
|
|
38
|
+
ensureDir(path.dirname(filePath));
|
|
39
|
+
fs.writeFileSync(filePath, JSON.stringify(value, null, 2) + "\n", "utf8");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function revisionFor(text) {
|
|
43
|
+
return `sha256:${crypto.createHash("sha256").update(text).digest("hex")}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function writeFileAtomic(filePath, text, expectedRevision) {
|
|
47
|
+
ensureDir(path.dirname(filePath));
|
|
48
|
+
if (fs.existsSync(filePath) && fs.lstatSync(filePath).isSymbolicLink()) {
|
|
49
|
+
throw new Error("Concept files cannot be symbolic links.");
|
|
50
|
+
}
|
|
51
|
+
const mode = fs.existsSync(filePath) ? fs.statSync(filePath).mode : null;
|
|
52
|
+
const temporaryPath = path.join(
|
|
53
|
+
path.dirname(filePath),
|
|
54
|
+
`.${path.basename(filePath)}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`,
|
|
55
|
+
);
|
|
56
|
+
try {
|
|
57
|
+
fs.writeFileSync(temporaryPath, text, { encoding: "utf8", flag: "wx" });
|
|
58
|
+
if (mode !== null) {
|
|
59
|
+
fs.chmodSync(temporaryPath, mode);
|
|
60
|
+
}
|
|
61
|
+
const currentRevision = revisionFor(fs.readFileSync(filePath));
|
|
62
|
+
if (expectedRevision && currentRevision !== expectedRevision) {
|
|
63
|
+
return { written: false, currentRevision };
|
|
64
|
+
}
|
|
65
|
+
fs.renameSync(temporaryPath, filePath);
|
|
66
|
+
return { written: true, currentRevision };
|
|
67
|
+
} finally {
|
|
68
|
+
if (fs.existsSync(temporaryPath)) {
|
|
69
|
+
fs.unlinkSync(temporaryPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isInside(root, candidate) {
|
|
75
|
+
const relative = path.relative(root, candidate);
|
|
76
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function rejectSymlinkTraversal(realRoot, relativePath) {
|
|
80
|
+
const segments = relativePath.split("/");
|
|
81
|
+
let current = realRoot;
|
|
82
|
+
segments.forEach((segment, index) => {
|
|
83
|
+
current = path.join(current, segment);
|
|
84
|
+
if (!fs.existsSync(current)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const stat = fs.lstatSync(current);
|
|
88
|
+
if (stat.isSymbolicLink()) {
|
|
89
|
+
throw new Error(`Concept path cannot traverse a symbolic link: ${segments.slice(0, index + 1).join("/")}`);
|
|
90
|
+
}
|
|
91
|
+
if (index < segments.length - 1 && !stat.isDirectory()) {
|
|
92
|
+
throw new Error(`Concept path parent is not a directory: ${segments.slice(0, index + 1).join("/")}`);
|
|
93
|
+
}
|
|
94
|
+
const resolved = fs.realpathSync(current);
|
|
95
|
+
if (!isInside(realRoot, resolved)) {
|
|
96
|
+
throw new Error("Concept path resolves outside bundle root.");
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class FileConceptStore {
|
|
102
|
+
constructor(options) {
|
|
103
|
+
this.project = options.project || null;
|
|
104
|
+
this.bundles = (options.bundles || []).filter((bundle) => !bundle.remote);
|
|
105
|
+
this.relationTypes = options.relationTypes || [];
|
|
106
|
+
this.proposalRoot = options.proposalRoot || path.join((this.project && this.project.root) || process.cwd(), ".okf-proposals");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static fromProject(projectPath, options) {
|
|
110
|
+
const project = loadProjectConfig(projectPath);
|
|
111
|
+
return new FileConceptStore({
|
|
112
|
+
project,
|
|
113
|
+
bundles: project.bundles,
|
|
114
|
+
relationTypes: project.relationTypes,
|
|
115
|
+
proposalRoot: options && options.proposalRoot,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getBundles() {
|
|
120
|
+
return this.bundles.slice();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getRelationTypes() {
|
|
124
|
+
return this.relationTypes.slice();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getIndex() {
|
|
128
|
+
return buildIndex(this.bundles, { relationTypes: this.relationTypes });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getBundle(id) {
|
|
132
|
+
const bundle = this.bundles.find((entry) => entry.id === id);
|
|
133
|
+
if (!bundle) {
|
|
134
|
+
throw new Error(`Unknown writable OKF bundle: ${id || "<missing>"}`);
|
|
135
|
+
}
|
|
136
|
+
return bundle;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
resolveConceptFile(bundleId, conceptPath) {
|
|
140
|
+
const bundle = this.getBundle(bundleId);
|
|
141
|
+
const relativePath = normalizeConceptPath(conceptPath);
|
|
142
|
+
const realRoot = fs.realpathSync(bundle.root);
|
|
143
|
+
const absolutePath = path.resolve(realRoot, ...relativePath.split("/"));
|
|
144
|
+
if (!isInside(realRoot, absolutePath)) {
|
|
145
|
+
throw new Error("Concept path resolves outside bundle root.");
|
|
146
|
+
}
|
|
147
|
+
rejectSymlinkTraversal(realRoot, relativePath);
|
|
148
|
+
return { relativePath, absolutePath };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getConceptRevision(bundleId, conceptPath) {
|
|
152
|
+
const { relativePath, absolutePath } = this.resolveConceptFile(bundleId, conceptPath);
|
|
153
|
+
if (!fs.existsSync(absolutePath)) {
|
|
154
|
+
throw new Error(`Concept file does not exist: ${relativePath}`);
|
|
155
|
+
}
|
|
156
|
+
return revisionFor(fs.readFileSync(absolutePath));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getContentRevision(text) {
|
|
160
|
+
return revisionFor(text);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
listProposalFiles() {
|
|
164
|
+
if (!fs.existsSync(this.proposalRoot)) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
return fs.readdirSync(this.proposalRoot)
|
|
168
|
+
.filter((name) => name.endsWith(".json"))
|
|
169
|
+
.sort()
|
|
170
|
+
.map((name) => path.join(this.proposalRoot, name));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async saveProposal(input) {
|
|
174
|
+
const id = proposalId();
|
|
175
|
+
const timestamp = nowIso();
|
|
176
|
+
const proposal = {
|
|
177
|
+
id,
|
|
178
|
+
status: "proposed",
|
|
179
|
+
op: input.op || "create",
|
|
180
|
+
targetUri: input.targetUri || null,
|
|
181
|
+
targetPathUri: input.targetPathUri || null,
|
|
182
|
+
baseRevision: input.baseRevision || null,
|
|
183
|
+
bundle: input.bundle,
|
|
184
|
+
path: input.path,
|
|
185
|
+
uri: input.validation && input.validation.uri,
|
|
186
|
+
pathUri: input.validation && input.validation.pathUri,
|
|
187
|
+
frontmatter: input.frontmatter || {},
|
|
188
|
+
body: input.body || "",
|
|
189
|
+
markdown: input.markdown || "",
|
|
190
|
+
message: input.message || "",
|
|
191
|
+
validation: input.validation || null,
|
|
192
|
+
createdAt: timestamp,
|
|
193
|
+
updatedAt: timestamp,
|
|
194
|
+
};
|
|
195
|
+
writeJson(safeProposalFile(this.proposalRoot, id), proposal);
|
|
196
|
+
return proposal;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async listProposals(filters) {
|
|
200
|
+
const options = filters || {};
|
|
201
|
+
return this.listProposalFiles().map(readJson).filter((proposal) => {
|
|
202
|
+
if (options.bundle && proposal.bundle !== options.bundle) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (options.status && proposal.status !== options.status) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}).map((proposal) => ({
|
|
210
|
+
id: proposal.id,
|
|
211
|
+
status: proposal.status,
|
|
212
|
+
op: proposal.op || "create",
|
|
213
|
+
targetUri: proposal.targetUri || null,
|
|
214
|
+
bundle: proposal.bundle,
|
|
215
|
+
path: proposal.path,
|
|
216
|
+
uri: proposal.uri,
|
|
217
|
+
message: proposal.message,
|
|
218
|
+
createdAt: proposal.createdAt,
|
|
219
|
+
updatedAt: proposal.updatedAt,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async getProposal(id) {
|
|
224
|
+
const filePath = safeProposalFile(this.proposalRoot, id);
|
|
225
|
+
if (!fs.existsSync(filePath)) {
|
|
226
|
+
throw new Error(`Unknown OKF proposal: ${id || "<missing>"}`);
|
|
227
|
+
}
|
|
228
|
+
return readJson(filePath);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
saveExistingProposal(proposal) {
|
|
232
|
+
proposal.updatedAt = nowIso();
|
|
233
|
+
writeJson(safeProposalFile(this.proposalRoot, proposal.id), proposal);
|
|
234
|
+
return proposal;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
markProposalConflict(proposal, currentRevision) {
|
|
238
|
+
proposal.conflict = {
|
|
239
|
+
expectedRevision: proposal.baseRevision || null,
|
|
240
|
+
actualRevision: currentRevision,
|
|
241
|
+
detectedAt: nowIso(),
|
|
242
|
+
};
|
|
243
|
+
this.saveExistingProposal(proposal);
|
|
244
|
+
return {
|
|
245
|
+
accepted: false,
|
|
246
|
+
conflict: true,
|
|
247
|
+
message: "The concept changed after this update was proposed. Create a new proposal from the current concept.",
|
|
248
|
+
proposal,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async acceptProposal(id, authoringService) {
|
|
253
|
+
const proposal = await this.getProposal(id);
|
|
254
|
+
if (proposal.status !== "proposed") {
|
|
255
|
+
throw new Error(`Only proposed concepts can be accepted. Current status: ${proposal.status}`);
|
|
256
|
+
}
|
|
257
|
+
const op = proposal.op || "create";
|
|
258
|
+
if (op !== "create" && op !== "update") {
|
|
259
|
+
throw new Error(`Unsupported proposal operation: ${op}`);
|
|
260
|
+
}
|
|
261
|
+
const { relativePath, absolutePath } = this.resolveConceptFile(proposal.bundle, proposal.path);
|
|
262
|
+
const exists = fs.existsSync(absolutePath);
|
|
263
|
+
if (op === "create" && exists) {
|
|
264
|
+
throw new Error(`Concept file already exists: ${relativePath}`);
|
|
265
|
+
}
|
|
266
|
+
if (op === "update" && !exists) {
|
|
267
|
+
throw new Error(`Concept file does not exist for update: ${relativePath}`);
|
|
268
|
+
}
|
|
269
|
+
let existing = null;
|
|
270
|
+
if (op === "update") {
|
|
271
|
+
const currentRevision = this.getConceptRevision(proposal.bundle, proposal.path);
|
|
272
|
+
if (!proposal.baseRevision || currentRevision !== proposal.baseRevision) {
|
|
273
|
+
return this.markProposalConflict(proposal, currentRevision);
|
|
274
|
+
}
|
|
275
|
+
existing = authoringService.resolveConcept(proposal.targetUri);
|
|
276
|
+
if (
|
|
277
|
+
proposal.bundle !== existing.bundle
|
|
278
|
+
|| proposal.path !== existing.path
|
|
279
|
+
|| proposal.targetPathUri !== existing.pathUri
|
|
280
|
+
) {
|
|
281
|
+
throw new Error("Update proposal target does not match the current concept identity.");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const candidate = {
|
|
285
|
+
bundle: proposal.bundle,
|
|
286
|
+
path: proposal.path,
|
|
287
|
+
frontmatter: proposal.frontmatter,
|
|
288
|
+
body: proposal.body,
|
|
289
|
+
};
|
|
290
|
+
const validation = op === "update"
|
|
291
|
+
? authoringService.validateUpdateCandidate(candidate, existing)
|
|
292
|
+
: authoringService.validateConcept(candidate);
|
|
293
|
+
if (!validation.valid) {
|
|
294
|
+
proposal.validation = validation;
|
|
295
|
+
this.saveExistingProposal(proposal);
|
|
296
|
+
return { accepted: false, proposal, validation };
|
|
297
|
+
}
|
|
298
|
+
if (op === "update") {
|
|
299
|
+
const currentRevision = this.getConceptRevision(proposal.bundle, proposal.path);
|
|
300
|
+
if (currentRevision !== proposal.baseRevision) {
|
|
301
|
+
return this.markProposalConflict(proposal, currentRevision);
|
|
302
|
+
}
|
|
303
|
+
const safeTarget = this.resolveConceptFile(proposal.bundle, proposal.path);
|
|
304
|
+
const write = writeFileAtomic(safeTarget.absolutePath, validation.markdown, proposal.baseRevision);
|
|
305
|
+
if (!write.written) {
|
|
306
|
+
return this.markProposalConflict(proposal, write.currentRevision);
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
ensureDir(path.dirname(absolutePath));
|
|
310
|
+
const safeTarget = this.resolveConceptFile(proposal.bundle, proposal.path);
|
|
311
|
+
fs.writeFileSync(safeTarget.absolutePath, validation.markdown, { encoding: "utf8", flag: "wx" });
|
|
312
|
+
}
|
|
313
|
+
proposal.status = "accepted";
|
|
314
|
+
proposal.acceptedAt = nowIso();
|
|
315
|
+
proposal.validation = validation;
|
|
316
|
+
this.saveExistingProposal(proposal);
|
|
317
|
+
return {
|
|
318
|
+
accepted: true,
|
|
319
|
+
created: op === "create",
|
|
320
|
+
updated: op === "update",
|
|
321
|
+
proposal,
|
|
322
|
+
validation,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async rejectProposal(id, reason) {
|
|
327
|
+
const proposal = await this.getProposal(id);
|
|
328
|
+
if (proposal.status !== "proposed") {
|
|
329
|
+
throw new Error(`Only proposed concepts can be rejected. Current status: ${proposal.status}`);
|
|
330
|
+
}
|
|
331
|
+
proposal.status = "rejected";
|
|
332
|
+
proposal.rejectedAt = nowIso();
|
|
333
|
+
proposal.rejectionReason = reason || "";
|
|
334
|
+
this.saveExistingProposal(proposal);
|
|
335
|
+
return proposal;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
module.exports = {
|
|
340
|
+
FileConceptStore,
|
|
341
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const CONFORMANCE_WARNING_CODES = new Set([
|
|
4
|
+
"missing_frontmatter",
|
|
5
|
+
"missing_type",
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
const PROJECT_INVALID_WARNING_CODES = new Set([
|
|
9
|
+
"broken_link",
|
|
10
|
+
"invalid_id",
|
|
11
|
+
"link_outside_root",
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
function inBundle(entry, bundle) {
|
|
15
|
+
return !bundle || (entry && entry.bundle === bundle);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function diagnosticKey(entry) {
|
|
19
|
+
return [
|
|
20
|
+
entry.layer || "",
|
|
21
|
+
entry.code || "",
|
|
22
|
+
entry.bundle || "",
|
|
23
|
+
entry.path || "",
|
|
24
|
+
entry.href || "",
|
|
25
|
+
entry.target || "",
|
|
26
|
+
entry.relationType || "",
|
|
27
|
+
entry.message || "",
|
|
28
|
+
].join("\u0000");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeDiagnostic(entry, defaults) {
|
|
32
|
+
return Object.assign({
|
|
33
|
+
code: "validation_diagnostic",
|
|
34
|
+
severity: "warning",
|
|
35
|
+
layer: "project",
|
|
36
|
+
message: "",
|
|
37
|
+
}, defaults || {}, entry || {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function validateIndex(index, bundle) {
|
|
41
|
+
const source = index || {};
|
|
42
|
+
const errors = (source.errors || []).filter((entry) => inBundle(entry, bundle));
|
|
43
|
+
const warnings = (source.warnings || []).filter((entry) => inBundle(entry, bundle));
|
|
44
|
+
const documents = (source.documents || []).filter((doc) => !bundle || doc.bundle === bundle);
|
|
45
|
+
const diagnostics = [];
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
|
|
48
|
+
function add(entry, defaults) {
|
|
49
|
+
const diagnostic = normalizeDiagnostic(entry, defaults);
|
|
50
|
+
const key = diagnosticKey(diagnostic);
|
|
51
|
+
if (!seen.has(key)) {
|
|
52
|
+
seen.add(key);
|
|
53
|
+
diagnostics.push(diagnostic);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
documents.forEach((doc) => {
|
|
58
|
+
(doc.conformanceDiagnostics || doc.diagnostics || []).forEach((entry) => {
|
|
59
|
+
add(entry, {
|
|
60
|
+
bundle: doc.bundle,
|
|
61
|
+
path: doc.path,
|
|
62
|
+
severity: "error",
|
|
63
|
+
layer: "conformance",
|
|
64
|
+
invalidatesProject: true,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
errors.forEach((entry) => {
|
|
70
|
+
const conformance = entry.code === "parse_error";
|
|
71
|
+
add(entry, {
|
|
72
|
+
severity: "error",
|
|
73
|
+
layer: conformance ? "conformance" : "project",
|
|
74
|
+
invalidatesProject: true,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
warnings.forEach((entry) => {
|
|
79
|
+
if (CONFORMANCE_WARNING_CODES.has(entry.code)) {
|
|
80
|
+
add(entry, {
|
|
81
|
+
severity: "error",
|
|
82
|
+
layer: "conformance",
|
|
83
|
+
invalidatesProject: true,
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
add(entry, {
|
|
88
|
+
severity: "warning",
|
|
89
|
+
layer: "project",
|
|
90
|
+
invalidatesProject: PROJECT_INVALID_WARNING_CODES.has(entry.code),
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const conformanceErrors = diagnostics.filter((entry) => (
|
|
95
|
+
entry.layer === "conformance" && entry.severity === "error"
|
|
96
|
+
));
|
|
97
|
+
const projectDiagnostics = diagnostics.filter((entry) => entry.layer === "project");
|
|
98
|
+
const conformant = conformanceErrors.length === 0;
|
|
99
|
+
const validForProject = conformant
|
|
100
|
+
&& errors.length === 0
|
|
101
|
+
&& !diagnostics.some((entry) => entry.invalidatesProject);
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
conformant,
|
|
105
|
+
validForProject,
|
|
106
|
+
valid: validForProject,
|
|
107
|
+
diagnostics,
|
|
108
|
+
conformanceErrors,
|
|
109
|
+
projectDiagnostics,
|
|
110
|
+
errors,
|
|
111
|
+
warnings,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
validateIndex,
|
|
117
|
+
};
|