archgraph-argo-beta 0.27.0-beta.3 → 0.27.0-beta.5
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.
|
@@ -180,7 +180,10 @@ function hasExtendsConfig(dir) {
|
|
|
180
180
|
|
|
181
181
|
function resolveBaseBundleDir(ext, childDir) {
|
|
182
182
|
const value = String(ext).trim();
|
|
183
|
-
|
|
183
|
+
// Reserved, language-neutral name for the built-in default bundle. Any other
|
|
184
|
+
// value is a path to another bundle directory — the framework never hardcodes a
|
|
185
|
+
// modeling-language name (ArchiMate or otherwise) into bundle resolution.
|
|
186
|
+
if (value === 'default') {
|
|
184
187
|
return path.join(getArgoRoot(), 'schema');
|
|
185
188
|
}
|
|
186
189
|
return path.resolve(childDir, value);
|
|
@@ -209,6 +212,27 @@ function mergeMatrixInto(target, source) {
|
|
|
209
212
|
return target;
|
|
210
213
|
}
|
|
211
214
|
|
|
215
|
+
// Append added types to a JSON-Schema enum def (the element/relationship type
|
|
216
|
+
// universe), so a schema-less inheriting Profile's own added types are structurally
|
|
217
|
+
// valid — not just present at the ontology level.
|
|
218
|
+
function extendSchemaEnum(schemaDocument, enumKeys, additions) {
|
|
219
|
+
const defs = schemaDocument && typeof schemaDocument.$defs === 'object' ? schemaDocument.$defs : null;
|
|
220
|
+
if (!defs) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
for (const key of enumKeys) {
|
|
224
|
+
const node = defs[key];
|
|
225
|
+
if (node && Array.isArray(node.enum)) {
|
|
226
|
+
for (const value of additions) {
|
|
227
|
+
if (typeof value === 'string' && value !== '' && !node.enum.includes(value)) {
|
|
228
|
+
node.enum.push(value);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
212
236
|
function mergeExtendsBundle(base, child) {
|
|
213
237
|
const baseRules = base.rules || {};
|
|
214
238
|
const childRules = child.rules || {};
|
|
@@ -232,6 +256,21 @@ function mergeExtendsBundle(base, child) {
|
|
|
232
256
|
relationshipCategoryByType[type] = category;
|
|
233
257
|
}
|
|
234
258
|
|
|
259
|
+
// Guarantee base ∪ add for the element/relationship universe regardless of the
|
|
260
|
+
// base dialect (class-matrix derives types from rules metadata, type-matrix from
|
|
261
|
+
// schema enums) — an inheriting Profile must never silently drop a base type.
|
|
262
|
+
const baseOntology = buildOntology(base);
|
|
263
|
+
for (const type of baseOntology.elementTypes) {
|
|
264
|
+
if (!elementTypeMetadata[type]) {
|
|
265
|
+
elementTypeMetadata[type] = { layer: null, aspect: null };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
for (const type of baseOntology.relationshipTypes) {
|
|
269
|
+
if (!relationshipCategoryByType[type]) {
|
|
270
|
+
relationshipCategoryByType[type] = 'Custom';
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
235
274
|
const relationshipTargetMatrix = deepCloneJson(baseRules.relationshipTargetMatrix || {}) || {};
|
|
236
275
|
mergeMatrixInto(relationshipTargetMatrix, childRules.relationshipTargetMatrix || {});
|
|
237
276
|
mergeMatrixInto(relationshipTargetMatrix, config.overrideMatrix || {});
|
|
@@ -247,13 +286,34 @@ function mergeExtendsBundle(base, child) {
|
|
|
247
286
|
relationshipTargetMatrix,
|
|
248
287
|
};
|
|
249
288
|
|
|
289
|
+
// Structural schema: when the child has none, it inherits the base schema — but
|
|
290
|
+
// its added types must be valid against the base's $defs enum too, otherwise
|
|
291
|
+
// whole-graph validation (validateAgainstSchema) rejects elements of the added
|
|
292
|
+
// types. Extend the inherited schema enum in place (clone, never mutate base).
|
|
293
|
+
let schemaDocument = child.schemaDocument || base.schemaDocument;
|
|
294
|
+
if (!child.schemaDocument && base.schemaDocument) {
|
|
295
|
+
const extraElementTypes = Object.keys(addElementTypes).filter(Boolean);
|
|
296
|
+
const extraRelationshipTypes = Object.keys(addRelationships).filter(Boolean);
|
|
297
|
+
const extraFromConfigElements = Array.isArray(config.elementTypes) ? config.elementTypes : [];
|
|
298
|
+
const extraFromConfigRelationships = Array.isArray(config.relationshipTypes) ? config.relationshipTypes : [];
|
|
299
|
+
if (extraElementTypes.length || extraRelationshipTypes.length || extraFromConfigElements.length || extraFromConfigRelationships.length) {
|
|
300
|
+
schemaDocument = deepCloneJson(base.schemaDocument);
|
|
301
|
+
extendSchemaEnum(schemaDocument, ELEMENT_ENUM_KEYS, extraElementTypes.concat(extraFromConfigElements));
|
|
302
|
+
extendSchemaEnum(schemaDocument, RELATIONSHIP_ENUM_KEYS, extraRelationshipTypes.concat(extraFromConfigRelationships));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
250
306
|
return {
|
|
251
307
|
...child,
|
|
252
308
|
schema: child.schema || base.schema,
|
|
253
|
-
schemaDocument
|
|
309
|
+
schemaDocument,
|
|
254
310
|
rules,
|
|
255
311
|
config,
|
|
256
312
|
inheritedFrom: base.dir,
|
|
313
|
+
chainDirs: Array.from(new Set([
|
|
314
|
+
...(Array.isArray(base.chainDirs) && base.chainDirs.length > 0 ? base.chainDirs : [path.resolve(base.dir).toLowerCase()]),
|
|
315
|
+
path.resolve(child.dir).toLowerCase(),
|
|
316
|
+
])),
|
|
257
317
|
};
|
|
258
318
|
}
|
|
259
319
|
|
|
@@ -748,9 +808,36 @@ function buildOntology(bundle) {
|
|
|
748
808
|
return bundle.kind === 'default' ? buildClassMatrixOntology(bundle) : buildTypeMatrixOntology(bundle);
|
|
749
809
|
}
|
|
750
810
|
|
|
811
|
+
// Cheap on-disk fingerprint of a bundle (and its extends chain) so a running MCP
|
|
812
|
+
// picks up edits to the bundle files without a restart: the ontology cache key
|
|
813
|
+
// changes when any key file's mtime/size changes.
|
|
814
|
+
function bundleFingerprint(bundle) {
|
|
815
|
+
const dirs = Array.isArray(bundle.chainDirs) && bundle.chainDirs.length > 0
|
|
816
|
+
? bundle.chainDirs
|
|
817
|
+
: [path.resolve(bundle.dir).toLowerCase()];
|
|
818
|
+
const statFile = (absolutePath) => {
|
|
819
|
+
try {
|
|
820
|
+
const stat = fs.statSync(absolutePath);
|
|
821
|
+
return `${Math.round(stat.mtimeMs)}:${stat.size}`;
|
|
822
|
+
} catch {
|
|
823
|
+
return '-';
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
const parts = [];
|
|
827
|
+
for (const dir of dirs) {
|
|
828
|
+
for (const name of [SCHEMA_BASENAME, CONFIG_BASENAME, RULES_BASENAME]) {
|
|
829
|
+
parts.push(`${name}=${statFile(path.join(dir, name))}`);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (bundle.config && typeof bundle.config.rules === 'string' && bundle.config.rules.trim() !== '') {
|
|
833
|
+
parts.push(`rules=${statFile(path.resolve(bundle.dir, bundle.config.rules))}`);
|
|
834
|
+
}
|
|
835
|
+
return parts.join('|');
|
|
836
|
+
}
|
|
837
|
+
|
|
751
838
|
function loadSchemaBundleAndOntology(workspaceRoot, options = {}) {
|
|
752
839
|
const bundle = resolveSchemaBundle(workspaceRoot, options);
|
|
753
|
-
const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}`;
|
|
840
|
+
const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}:${bundleFingerprint(bundle)}`;
|
|
754
841
|
if (ontologyCache.has(cacheKey)) {
|
|
755
842
|
return { bundle, ontology: ontologyCache.get(cacheKey) };
|
|
756
843
|
}
|
package/package.json
CHANGED