@kanonak-protocol/sdk 4.12.0 → 4.14.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/dist/auth/CredentialBackend.d.ts +15 -6
- package/dist/auth/CredentialHelperBackend.d.ts +4 -4
- package/dist/auth/DeviceCertificateStore.d.ts +52 -0
- package/dist/auth/EncryptedFileBackend.d.ts +11 -7
- package/dist/auth/KeychainBackend.d.ts +10 -6
- package/dist/auth/SecretServiceBackend.d.ts +8 -6
- package/dist/auth/WinCredBackend.d.ts +13 -9
- package/dist/auth/index.d.ts +3 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunk-2HNPPYSK.js +1 -0
- package/dist/chunk-6U26UASC.js +1 -0
- package/dist/chunk-7BHDZHJY.js +1 -0
- package/dist/{chunk-V72IVYR4.js → chunk-H37TY5AQ.js} +4 -4
- package/dist/{chunk-VWS25JH4.js → chunk-HQQ4OAZ2.js} +1 -1
- package/dist/chunk-MRNELSJF.js +63 -0
- package/dist/{chunk-RGOBWOBB.js → chunk-OR3F4WIF.js} +1 -1
- package/dist/chunk-QDSN5VM3.js +2 -0
- package/dist/chunk-R73T4RUO.js +1 -0
- package/dist/{chunk-CR55WXIN.js → chunk-VDVJJ62W.js} +1 -1
- package/dist/chunk-WGKIRLMA.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -26
- package/dist/kanonaks/DefinedKanonak.d.ts +12 -0
- package/dist/parsing/KanonakObjectParser.d.ts +14 -1
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/ResourceResolver.d.ts +0 -4
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/ValidationCache.d.ts +34 -76
- package/dist/validation/documentModel.d.ts +47 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/ClassDefinitionRule.d.ts +21 -6
- package/dist/validation/rules/repository/ClassHierarchyCycleRule.d.ts +9 -4
- package/dist/validation/rules/repository/EmbeddedKanonakTypeRule.d.ts +29 -90
- package/dist/validation/rules/repository/ObjectPropertyValueValidationRule.d.ts +20 -6
- package/dist/validation/rules/repository/PropertyDomainRule.d.ts +21 -17
- package/dist/validation/rules/repository/PropertyHierarchyCycleRule.d.ts +8 -4
- package/dist/validation/rules/repository/PropertyKindRangeConsistencyRule.d.ts +29 -0
- package/dist/validation/rules/repository/PropertyRangeReferenceRule.d.ts +14 -7
- package/dist/validation/rules/repository/PropertyRangeRequiredRule.d.ts +13 -2
- package/dist/validation/rules/repository/SubClassOfReferenceRule.d.ts +16 -13
- package/dist/validation/rules/repository/SubPropertyOfReferenceRule.d.ts +12 -5
- package/dist/validation/rules/repository/UnresolvedReferenceRule.d.ts +16 -4
- package/dist/validation/rules/repository/hierarchyCycle.d.ts +25 -0
- package/dist/validation/rules/repository/index.d.ts +1 -4
- package/package.json +2 -2
- package/dist/chunk-4UT2CLAT.js +0 -1
- package/dist/chunk-7HRKWTBB.js +0 -1
- package/dist/chunk-7TKJHKC2.js +0 -1
- package/dist/chunk-BKVPSPG4.js +0 -1
- package/dist/chunk-IEOSSSB5.js +0 -1
- package/dist/chunk-SHDHMKMJ.js +0 -1
- package/dist/chunk-U7LVFPEO.js +0 -2
- package/dist/chunk-UBBZWWRB.js +0 -86
- package/dist/validation/rules/repository/DefinitionPropertyReferenceRule.d.ts +0 -13
- package/dist/validation/rules/repository/ObjectPropertyImportRule.d.ts +0 -9
- package/dist/validation/rules/repository/PropertyValueTypeRule.d.ts +0 -11
- package/dist/validation/rules/repository/XsdImportRule.d.ts +0 -11
|
@@ -2,10 +2,17 @@ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/ty
|
|
|
2
2
|
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
3
3
|
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
4
4
|
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
5
|
+
import type { ValidationCache } from '../../ValidationCache.js';
|
|
6
|
+
/**
|
|
7
|
+
* Every `subPropertyOf` target must resolve to a defined or imported property.
|
|
8
|
+
* Reads the resolved object model: the target is a `ReferenceKanonak` resolved
|
|
9
|
+
* through the import closure (alias-agnostic), and its existence + property-ness
|
|
10
|
+
* are checked by `findSubjectByUri` + `ResourceTypeClassifier`, never by a
|
|
11
|
+
* hardcoded built-in-name list or `split('.')` alias extraction.
|
|
12
|
+
*/
|
|
5
13
|
export declare class SubPropertyOfReferenceRule implements IRepositoryValidationRule {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
private isPropertyAvailableInImportsRecursive;
|
|
14
|
+
readonly ruleName = "SubPropertyOfReference";
|
|
15
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
16
|
+
private resolvesToProperty;
|
|
17
|
+
private error;
|
|
11
18
|
}
|
|
@@ -2,10 +2,22 @@ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/documen
|
|
|
2
2
|
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
3
3
|
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
4
4
|
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
5
|
+
import type { ValidationCache } from '../../ValidationCache.js';
|
|
6
|
+
/**
|
|
7
|
+
* Reports an object-property value that references an entity which does not
|
|
8
|
+
* resolve to a defined or imported resource — a typo, a moved entity, or an
|
|
9
|
+
* unimported namespace. Reads the resolved object model recursively
|
|
10
|
+
* ({@link walkDefinedKanonaks}), so a bad reference on an embedded object at any
|
|
11
|
+
* depth is caught, not just on top-level subjects (the #65 gap).
|
|
12
|
+
*
|
|
13
|
+
* A reference value parses to a `ReferenceKanonak` whose `subject` is the
|
|
14
|
+
* resolved (or, for an unresolvable authored name, fabricated doc-local) URI;
|
|
15
|
+
* resolution succeeds iff that URI names a subject in the catalog. Identity is
|
|
16
|
+
* compared by `findSubjectByUri`, never by string/alias shape.
|
|
17
|
+
*/
|
|
5
18
|
export declare class UnresolvedReferenceRule implements IRepositoryValidationRule {
|
|
6
19
|
readonly ruleName = "UnresolvedReference";
|
|
7
|
-
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private getPropertyValue;
|
|
20
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
21
|
+
private check;
|
|
22
|
+
private unresolvedError;
|
|
11
23
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Kanonak } from '../../../kanonaks/Kanonak.js';
|
|
2
|
+
import type { KanonakUri } from '../../../resolution/KanonakUri.js';
|
|
3
|
+
import { type EntityUri } from '../../../uri-helpers/index.js';
|
|
4
|
+
export declare const URI_SUBCLASSOF: EntityUri;
|
|
5
|
+
export declare const URI_SUBPROPERTYOF: EntityUri;
|
|
6
|
+
/**
|
|
7
|
+
* Walk the `edge` (`subClassOf` / `subPropertyOf`) graph from `start`, resolving
|
|
8
|
+
* each hop to its canonical `KanonakUri` through the catalog, and return the
|
|
9
|
+
* first ILL-FOUNDED cycle reachable from `start` (the looping segment, with the
|
|
10
|
+
* repeated node appended) or `null`.
|
|
11
|
+
*
|
|
12
|
+
* Identity is VERSION-AWARE — keyed by the resolved subject's version-specific
|
|
13
|
+
* namespace, not the version-agnostic `uriKey`. With several versions of a
|
|
14
|
+
* package in the catalog (`core-rdf@1.0.0` and `@1.1.0`), a version-agnostic key
|
|
15
|
+
* would collapse them and could report a cycle that exists only by conflating
|
|
16
|
+
* two versions; the version-aware key follows the actual per-version edges and
|
|
17
|
+
* only closes a cycle when the SAME version is re-entered.
|
|
18
|
+
*
|
|
19
|
+
* A reflexive self-loop (`X subClassOf X`, the looping segment being a single
|
|
20
|
+
* node) is NOT reported: `subClassOf` is reflexive, so a class being its own
|
|
21
|
+
* superclass is valid (if redundant), not an ill-founded hierarchy. Only a cycle
|
|
22
|
+
* through ≥2 distinct classes is an error. Standard DFS with a recursion-stack
|
|
23
|
+
* set for back-edges and a done-set to prune shared subtrees.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectHierarchyCycle(catalog: Kanonak[], start: KanonakUri, edge: EntityUri): KanonakUri[] | null;
|
|
@@ -8,14 +8,11 @@ export { SubClassOfReferenceRule } from './SubClassOfReferenceRule.js';
|
|
|
8
8
|
export { SubPropertyOfReferenceRule } from './SubPropertyOfReferenceRule.js';
|
|
9
9
|
export { NamespaceImportCycleRule } from './NamespaceImportCycleRule.js';
|
|
10
10
|
export { UnresolvedPredicateRule } from './UnresolvedPredicateRule.js';
|
|
11
|
-
export { DefinitionPropertyReferenceRule } from './DefinitionPropertyReferenceRule.js';
|
|
12
|
-
export { XsdImportRule } from './XsdImportRule.js';
|
|
13
11
|
export { AmbiguousReferenceRule } from './AmbiguousReferenceRule.js';
|
|
14
12
|
export { PropertyRangeReferenceRule } from './PropertyRangeReferenceRule.js';
|
|
15
|
-
export { ObjectPropertyImportRule } from './ObjectPropertyImportRule.js';
|
|
16
13
|
export { ObjectPropertyValueValidationRule } from './ObjectPropertyValueValidationRule.js';
|
|
17
14
|
export { PropertyDomainRule } from './PropertyDomainRule.js';
|
|
18
|
-
export {
|
|
15
|
+
export { PropertyKindRangeConsistencyRule } from './PropertyKindRangeConsistencyRule.js';
|
|
19
16
|
export { ClassDefinitionRule } from './ClassDefinitionRule.js';
|
|
20
17
|
export { EmbeddedKanonakTypeRule } from './EmbeddedKanonakTypeRule.js';
|
|
21
18
|
export { MarkdownLinkRule } from './MarkdownLinkRule.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
],
|
|
127
127
|
"dependencies": {
|
|
128
128
|
"@kanonak-protocol/canonical": "^0.1.1",
|
|
129
|
-
"@kanonak-protocol/types": "^4.
|
|
129
|
+
"@kanonak-protocol/types": "^4.14.0",
|
|
130
130
|
"ignore": "^7.0.5",
|
|
131
131
|
"js-yaml": "^4.1.0",
|
|
132
132
|
"yaml": "^2.7.0"
|
package/dist/chunk-4UT2CLAT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p}from"./chunk-FUUTGGJS.js";var m=class{};var c=class extends m{statement=[];unresolvedPredicates=[]};var i=class extends c{namespace;name;icon};var a=class e extends m{subject;static parse(o){let n=new e;return n.subject=p.parse(o),n}};var r=class{predicate;object};var s=class extends r{carrier;lexical};var d=class e extends s{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=n,t}};var f=class e extends s{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=n,t}};var k=class extends s{};var l=class e extends r{static parse(o,n){let t=new e;return t.predicate=a.parse(o),t.object=a.parse(n),t}};var x=class extends r{};var b=class extends r{};export{m as a,c as b,i as c,a as d,r as e,s as f,d as g,f as h,k as i,l as j,x as k,b as l};
|
package/dist/chunk-7HRKWTBB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as w}from"./chunk-FUUTGGJS.js";function K(r){if(Array.isArray(r))return r.map(t=>t?.toString()??"").filter(t=>t.length>0);let e=r?.toString();return e?[e]:[]}var S=class{cache=new Map;repository;logger;constructor(e,t){this.repository=e,this.logger=t}async resolveEntityAsync(e,t){let a=t.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(a);if(s){let o=s.get(e);if(o)return o}let n=await this.buildEntityIndexAsyncInternal(t,new Set,"",new Map);return this.cache.set(a,n),n.get(e)??null}async resolveAllEntitiesAsync(e,t){let a=await this.buildAllEntitiesIndexAsync(t,new Set,"");if(e.includes(".")){let s=e.split("."),n=s[0],o=s[1],g=await this.findDocumentForAlias(t,n);return g?await this.resolveAllEntitiesAsync(o,g):[]}return a.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,t,a){let s=[],n=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${n}`),t.has(n))return this.logger?.debug?.(`Skipping ${n} - already visited (circular import prevention)`),s;t.add(n);let o=a.length===0?n:`${a} \u2192 ${n}`;for(let[g,u]of Object.entries(e.body))if(!g.includes(".")&&u&&typeof u=="object"&&!Array.isArray(u)){if(!e.metadata.namespace_)continue;let f=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:g,uri:new w(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,g,f),entity:u,definedInNamespace:n,isImported:a.length>0,importPath:o})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${n}`),e.metadata?.imports){let g=Object.values(e.metadata.imports).reduce((u,f)=>u+f.length,0);this.logger?.debug?.(`Processing ${g} import(s) for ${n}`);for(let[u,f]of Object.entries(e.metadata.imports))for(let d of f)try{this.logger?.debug?.(`Resolving import: ${u}/${d.packageName}`);let p=await this.repository.getHighestCompatibleVersionAsync(u,d);if(p){this.logger?.debug?.(`Successfully loaded import: ${p.metadata?.namespace_?.toString()}`);let m=await this.buildAllEntitiesIndexAsync(p,t,o);s.push(...m),this.logger?.debug?.(`Added ${m.length} entities from import ${p.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${u}/${d.packageName}`)}catch(p){let m=p;throw this.logger?.error?.(`Failed to process import ${u}/${d.packageName} for namespace ${n}. Error: ${m.message}`,m),new Error(`Failed to process import ${u}/${d.packageName} for namespace ${n}. See inner exception for details.`,{cause:p})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,t,a,s){let n=new Map,o=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${o}`),t.has(o))return this.logger?.debug?.(`Skipping ${o} - circular import in progress`),n;let g=s.get(o);if(g)return g;t.add(o);let u=a.length===0?o:`${a} \u2192 ${o}`,f=0;for(let[d,p]of Object.entries(e.body))if(!d.includes(".")&&p&&typeof p=="object"&&!Array.isArray(p)){if(!e.metadata.namespace_)continue;if(!n.has(d)){let m=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};n.set(d,{entityName:d,uri:new w(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,m),entity:p,definedInNamespace:o,isImported:a.length>0,importPath:u}),f++}}if(this.logger?.debug?.(`Indexed ${f} entities from ${o}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((p,m)=>p+m.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${o}`);for(let[p,m]of Object.entries(e.metadata.imports))for(let h of m)try{this.logger?.debug?.(`Resolving import: ${p}/${h.packageName}`);let k=await this.repository.getHighestCompatibleVersionAsync(p,h);if(k){this.logger?.debug?.(`Successfully loaded import: ${k.metadata?.namespace_?.toString()}`);let P=await this.buildEntityIndexAsyncInternal(k,t,u,s),v=0;for(let[$,R]of P.entries()){let b=n.get($);if(!b)n.set($,R),v++;else if(b.isImported&&R.isImported&&(b.uri.publisher!==R.uri.publisher||b.uri.package_!==R.uri.package_)){let A=b.isAmbiguous?b:{...b,isAmbiguous:!0,ambiguousNamespaces:[b.definedInNamespace]};A.ambiguousNamespaces.includes(R.definedInNamespace)||A.ambiguousNamespaces.push(R.definedInNamespace),n.set($,A),this.logger?.warn?.(`Ambiguous reference '${$}': defined in ${A.ambiguousNamespaces.join(", ")}`)}if(h.alias&&!$.includes(".")){let A=`${h.alias}.${$}`;n.has(A)||(n.set(A,R),v++)}}this.logger?.debug?.(`Merged ${v} entities from import ${k.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${p}/${h.packageName}`)}catch(k){let P=k;throw this.logger?.error?.(`Failed to process import ${p}/${h.packageName} for namespace ${o}. Error: ${P.message}`,P),new Error(`Failed to process import ${p}/${h.packageName} for namespace ${o}. See inner exception for details.`,{cause:k})}}return t.delete(o),s.set(o,n),n}async findDocumentForAlias(e,t){if(!e.metadata?.imports)return null;for(let[a,s]of Object.entries(e.metadata.imports))for(let n of s){if(n.alias===t)return await this.repository.getHighestCompatibleVersionAsync(a,n);if(!n.alias&&n.packageName===t)return await this.repository.getHighestCompatibleVersionAsync(a,n)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}async isSubclassOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubclassOfRecursiveAsync(e,t,a,s)}async isSubclassOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let n=await this.resolveEntityAsync(e,a);if(!n?.entity)return!1;let o=n.entity.subClassOf;if(o){let g=K(o);for(let u of g)if(u===t||await this.isSubclassOfRecursiveAsync(u,t,a,s))return!0}return!1}async isSubpropertyOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubpropertyOfRecursiveAsync(e,t,a,s)}async isSubpropertyOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let n=await this.resolveEntityAsync(e,a);if(!n?.entity)return!1;let o=n.entity.subPropertyOf;if(o){let g=K(o);for(let u of g)if(u===t||await this.isSubpropertyOfRecursiveAsync(u,t,a,s))return!0}return!1}};var D=class r{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&r.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let t=e.includes(".")?e.split(".")[1]:e;return r.KNOWN_XSD_DATATYPES.has(t.toLowerCase())}async isClassTypeAsync(e,t){if(this.isKnownXsdDatatypeName(e))return!1;let a=await this.resourceResolver.resolveEntityAsync(e,t);if(a){let s=a.entity.type;if(s){let n=String(s);return n==="Class"||n==="rdfs.Class"||n.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,t){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(t)||e==="Property"&&this.isLiteralType(t))}isEffectiveObjectProperty(e,t){return!!(e==="ObjectProperty"||e==="Property"&&t&&!this.isXsdDatatype(t)&&!this.isLiteralType(t))}};function L(r){return`${r.publisher}/${r.package_}/${r.name}`}function c(r,e,t){return`${r}/${e}/${t}`}function M(r){return`${r.s}|${r.p}|${I(r.o)}`}function I(r){switch(r.kind){case"uri":return`u:${r.key}`;case"literal":return`l:${r.datatype}:${r.lexical}`;case"blank":return`b:${r.id}`}}function F(r,e,t){return{s:r,p:e,o:{kind:"uri",key:t}}}var l="kanonak.org",i="core-rdf",y="core-owl",_="core-kanonak",x=new Map([["type",i],["subClassOf",i],["subPropertyOf",i],["domain",i],["range",i],["label",i],["comment",i],["seeAlso",i],["isDefinedBy",i],["member",i],["Resource",i],["Class",i],["Property",i],["Datatype",i],["Literal",i],["List",i],["ObjectProperty",y],["DatatypeProperty",y],["AnnotationProperty",y],["Thing",y],["Nothing",y],["Package",_]]),E=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function X(r){return x.has(r)}function B(r,e,t){if(!r||!r.name)return;let a=x.get(r.name);if(!a)return;let s=()=>{r.publisher=l,r.package_=a,t&&(r.version=t.get(a))};if(E.has(r.name)){let n=r.publisher===l&&r.package_===a;r.publisher=l,r.package_=a,!n&&t&&(r.version=t.get(a));return}r.publisher===l&&r.package_===a||r.publisher&&r.publisher.length>0&&(!e||e(r))||s()}var O=class{type=c(l,i,"type");subClassOf=c(l,i,"subClassOf");subPropertyOf=c(l,i,"subPropertyOf");domain=c(l,i,"domain");range=c(l,i,"range");label=c(l,i,"label");comment=c(l,i,"comment");resource=c(l,i,"Resource");class_=c(l,i,"Class");datatype=c(l,i,"Datatype");literal=c(l,i,"Literal");equivalentClass=c(l,y,"equivalentClass");equivalentProperty=c(l,y,"equivalentProperty");inverseOf=c(l,y,"inverseOf");sameAs=c(l,y,"sameAs");transitiveProperty=c(l,y,"TransitiveProperty");symmetricProperty=c(l,y,"SymmetricProperty");objectProperty=c(l,y,"ObjectProperty");datatypeProperty=c(l,y,"DatatypeProperty");annotationProperty=c(l,y,"AnnotationProperty");package_=c(l,_,"Package")};export{K as a,S as b,D as c,L as d,c as e,M as f,I as g,F as h,X as i,B as j,O as k};
|
package/dist/chunk-7TKJHKC2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as y,c as s,g as l,h as g,i as b,j as u,k,l as K}from"./chunk-4UT2CLAT.js";import{c as d,g as m}from"./chunk-2ACBWC7K.js";function S(t){return`${t.publisher}/${t.package_}/${t.name}`}function f(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function U(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function h(t,e){if(!(t instanceof y))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let r=n.object;if(f(r.subject,e))return!0}return!1}function j(t,e){let n=[];for(let o of t)o instanceof s&&h(o,e)&&n.push(o);return n}function E(t,e){let n=e.version,o=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let r of t){if(!(r instanceof s)||r.name!==e.name)continue;let a=r.namespace||"";if(o!==void 0){if(a===o)return r}else if(a.startsWith(`${e.publisher}/${e.package_}@`))return r}}function $(t,e){let n=[];for(let o of t){if(!(o instanceof s)||o.name!==e.name)continue;(o.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(o)}return n.sort((o,r)=>{let a=m((o.namespace||"").split("@")[1]??""),c=m((r.namespace||"").split("@")[1]??"");return a?c?d(c,a):-1:c?1:0}),n}function i(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&f(o.subject,e))return n}}function x(t,e){return i(t,e)!==void 0}function D(t,e){let n=i(t,e);if(n&&(n instanceof l||n instanceof g||n instanceof b))return n.object}function A(t,e){let n=D(t,e);return typeof n=="string"?n:void 0}function R(t,e){let n=i(t,e);if(n instanceof u)return n.object.subject}function P(t,e){let n=i(t,e);if(n instanceof k)return n.object}function v(t,e){let n=i(t,e);return n instanceof K?n.object??[]:[]}var p=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{S as a,f as b,U as c,h as d,j as e,E as f,$ as g,x as h,D as i,A as j,R as k,P as l,v as m,p as n};
|
package/dist/chunk-BKVPSPG4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as N}from"./chunk-NJ3AZYQD.js";import{b as V,c as C,i as B,j as M}from"./chunk-7HRKWTBB.js";import{a as _,b as U,c as S,d as k,g as P,h as x,i as O,j as I,k as R,l as v}from"./chunk-4UT2CLAT.js";import{j as $}from"./chunk-2ACBWC7K.js";var w=class extends U{name};var K=class extends _{value;carrier;lexical};var D=class extends P{links=[]};import{Carrier as j,carrierOf as F}from"@kanonak-protocol/canonical";function T(p){return F(`${p.publisher}/${p.package_}/${p.name}`)}var Y=/\[\[([^\[\]\n]+)\]\]/g,G=/\[\[/g,z=/```[\s\S]*?```|`[^`\n]*`/g;function q(p){let e=[];for(let t of p.matchAll(z))e.push([t.index,t.index+t[0].length]);return e}function ae(p){if(!p||!p.includes("[["))return[];let e=q(p),t=s=>e.some(([r,i])=>s>=r&&s<i),a=new Set(E(p).map(s=>s.startOffset)),n=[];for(let s of p.matchAll(G)){let r=s.index;if(t(r)||a.has(r))continue;let i=p.slice(r,r+48).replace(/\s+/g," ").trim();n.push({startOffset:r,snippet:i})}return n}function E(p){if(!p||!p.includes("[["))return[];let e=[];for(let n of p.matchAll(z))e.push([n.index,n.index+n[0].length]);let t=n=>e.some(([s,r])=>n>=s&&n<r),a=[];for(let n of p.matchAll(Y)){let s=n.index;if(t(s))continue;let r=n[1],i=r.indexOf("|"),c=(i===-1?r:r.slice(0,i)).trim();if(c.length===0)continue;let f=i===-1?"":r.slice(i+1).trim(),g={reference:c,startOffset:s,endOffset:s+n[0].length};f.length>0&&(g.displayText=f),a.push(g)}return a}var X=class{constructor(e){}async parseKanonaks(e){let t=[],a=await e.getAllDocumentsAsync(),n=new V(e),s=new C(n);for(let o of a){let m=o.metadata.namespace_?.toString()??"";for(let[u,y]of Object.entries(o.body)){let d=new S,b=this.resolveCanonicalEntity(u,o,m);d.namespace=b.namespace,d.name=b.name,d.statement=[];let h=await this.parseStatements(y,o,n,s,e);d.statement.push(...h.statements),d.unresolvedPredicates=h.unresolved,t.push(d)}}let r=new Map,i=new Map,c=[];for(let o of t)if(o instanceof S){let m=`${o.namespace}/${o.name}`,u=r.get(m);if(u){let y=i.get(m);for(let d of o.statement){let b=L(d);y.has(b)||(y.add(b),u.statement.push(d))}for(let d of o.unresolvedPredicates)u.unresolvedPredicates.some(b=>b.key===d.key&&b.sourceDoc===d.sourceDoc)||u.unresolvedPredicates.push(d)}else{let y=new Set,d=[];for(let b of o.statement){let h=L(b);y.has(h)||(y.add(h),d.push(b))}o.statement=d,i.set(m,y),r.set(m,o),c.push(o)}}else c.push(o);let f=new Set;for(let o of c)if(o instanceof S){let m=o.namespace||"",u=m.indexOf("/"),y=u>=0?m.slice(0,u):"",d=u>=0?m.slice(u+1):"",b=d.indexOf("@"),h=b>=0?d.slice(0,b):d;f.add(`${y}/${h}/${o.name}`)}let g=o=>f.has(`${o.publisher}/${o.package_}/${o.name}`),l=new Map;for(let o of["core-rdf","core-owl","core-kanonak"]){let m=await e.getDocumentsByNamespaceAsync("kanonak.org",o);l.set(o,$(m).chosen?.metadata.namespace_?.version??void 0)}for(let o of c)o instanceof S&&this.canonicalizeStatementBuiltins(o.statement,g,l);return c}canonicalizeStatementBuiltins(e,t,a){for(let n of e){let s=n.predicate?.subject;if(M(s,t,a),n instanceof I)n.object instanceof k&&M(n.object.subject,t,a);else if(n instanceof R)n.object&&this.canonicalizeStatementBuiltins(n.object.statement,t,a);else if(n instanceof v)for(let r of n.object??[])r instanceof k?M(r.subject,t,a):r instanceof w&&this.canonicalizeStatementBuiltins(r.statement,t,a)}}resolveCanonicalEntity(e,t,a){if(!e.includes(".")||!t.metadata?.imports)return{namespace:a,name:e};let n=e.indexOf("."),s=e.substring(0,n),r=e.substring(n+1);for(let[i,c]of Object.entries(t.metadata.imports))for(let f of c)if((f.alias??f.packageName)===s){let l=f.version;return{namespace:`${i}/${f.packageName}@${l.major}.${l.minor}.${l.patch}`,name:r}}return{namespace:a,name:e}}async parseStatements(e,t,a,n,s){let r=[],i=[];if(typeof e!="object"||e===null||Array.isArray(e))return{statements:r,unresolved:i};let c=t.metadata.namespace_?.toString()??"";for(let[f,g]of Object.entries(e))try{let l=await this.getPropertyMetadata(f,t,a,s,n);if(!l){let m=f.includes(".")?f.slice(f.lastIndexOf(".")+1):f;B(m)||i.push({key:f,sourceDoc:c});continue}let o=await this.parsePropertyValue(f,g,l,t,a,n,s);o&&r.push(o)}catch(l){throw new Error(`Failed to parse property '${f}': ${l.message}`,{cause:l})}return{statements:r,unresolved:i}}async getPropertyMetadata(e,t,a,n,s){let r=await a.resolveEntityAsync(e,t);if(!r)return;let i=r.entity,c=i.type?.toString()??"",f=c.includes(".")?c.substring(c.lastIndexOf(".")+1):c;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(f))return;let l=s.getPropertyTypeClassification(c),o=i.range?.toString(),m;if(l==="ObjectProperty")m="ObjectProperty";else if(l==="DatatypeProperty")m="DatatypeProperty";else{let d=o&&o.includes(".")?o.substring(o.lastIndexOf(".")+1):o??"";(o?s.isKnownXsdDatatypeName(o):!1)||d==="Literal"?m="DatatypeProperty":m="ObjectProperty"}let u;if(o){let d=t;if(r.isImported&&r.definedInNamespace){if(typeof n.getDocumentAsync!="function")throw new Error(`Cannot resolve the range of imported property '${e}': the parse repository cannot fetch defining document '${r.definedInNamespace}'. Thread the real repository through to embedded-object parsing \u2014 no stub, no fallback.`);let h=await n.getDocumentAsync(r.definedInNamespace);if(!h)throw new Error(`Cannot resolve the range of imported property '${e}': defining document '${r.definedInNamespace}' was not found in the repository.`);d=h}u=(await a.resolveEntityAsync(o,d))?.uri}return{propertyUri:r.uri.toString(),propertyType:m,range:o,rangeUri:u,isImported:r.isImported,definedInNamespace:r.definedInNamespace}}async parsePropertyValue(e,t,a,n,s,r,i){let c=a.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(c,t,a,n,s,r,i);if(a.propertyType==="DatatypeProperty")return this.parseDatatypeValue(c,t,a,n,s,r);if(a.propertyType==="ObjectProperty")return this.parseObjectValue(c,t,a,n,s,r,i)}}async parseDatatypeValue(e,t,a,n,s,r){let i;if(typeof t=="string"){if(r.isSubstitutableDatatype(a.rangeUri))return await this.parseSubstitutableValue(e,t,n,s);i=t}else if(typeof t=="number"||typeof t=="boolean")i=String(t);else return;return this.typedScalarStatement(e,i,a)}typedScalarStatement(e,t,a){let n=k.parse(e),s=a.rangeUri?T(a.rangeUri):void 0;if(s===j.Boolean){let i=new O;return i.predicate=n,i.object=t==="true"||t==="1",i.carrier=s,i.lexical=t,i}if(s===j.Integer||s===j.Decimal||s===j.Double||s===j.Float){let i=new x;return i.predicate=n,i.object=Number(t),i.carrier=s,i.lexical=t,i}let r=P.parse(e,t);return s&&(r.carrier=s,r.lexical=t),r}typedListLiteral(e,t){let a=new K,n=t.rangeUri?T(t.rangeUri):void 0;return n===j.Boolean?a.value=e==="true"||e==="1":n===j.Integer||n===j.Decimal||n===j.Double||n===j.Float?a.value=Number(e):a.value=e,n&&(a.carrier=n,a.lexical=e),a}async parseSubstitutableValue(e,t,a,n){let s=new D;s.predicate=k.parse(e),s.object=t;for(let r of E(t)){let i=await n.resolveEntityAsync(r.reference,a),c;i&&(c=new k,c.subject=i.uri);let f={reference:r.reference,startOffset:r.startOffset,endOffset:r.endOffset};r.displayText!==void 0&&(f.displayText=r.displayText),c!==void 0&&(f.target=c),s.links.push(f)}return s}async parseObjectValue(e,t,a,n,s,r,i){if(typeof t=="string"){let c=await this.resolveReference(t,n,s);if(!c)return;let f=new I;return f.predicate=k.parse(e),f.object=c,f}if(typeof t=="object"&&!Array.isArray(t)){let c=await this.parseStatements(t,n,s,r,i);if(c.statements.length>0){let l=new w;l.statement=c.statements,l.unresolvedPredicates=c.unresolved;let o=new R;return o.predicate=k.parse(e),o.object=l,o}let f=[];for(let[l,o]of Object.entries(t))if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let m=new w;m.name=l;let u=await this.parseStatements(o,n,s,r,i);m.statement=u.statements,m.unresolvedPredicates=u.unresolved,f.push(m)}else if(typeof o=="string"){let m=await this.resolveReference(o,n,s);m&&f.push(m)}if(f.length>0){let l=new v;return l.predicate=k.parse(e),l.object=f,l}let g=new R;return g.predicate=k.parse(e),g.object=new w,g}}async parseListValue(e,t,a,n,s,r,i){let c=[],f=a.propertyType==="DatatypeProperty",g=a.rangeUri?.publisher==="kanonak.org"&&a.rangeUri?.package_==="core-rdf"&&a.rangeUri?.name==="List"||!a.rangeUri&&(a.range?.includes(".")?a.range.substring(a.range.lastIndexOf(".")+1):a.range)==="List";for(let o of t){let m=typeof o=="string"||typeof o=="number"||typeof o=="boolean";if(f&&m){let u=typeof o=="string"?o:String(o);c.push(this.typedListLiteral(u,a));continue}if(g&&m){if(typeof o=="string"){let u=await s.resolveEntityAsync(o,n);if(u){let y=new k;y.subject=u.uri,c.push(y)}else{let y=new K;y.value=o,c.push(y)}}else{let u=new K;u.value=o,c.push(u)}continue}if(typeof o=="string"){let u=await this.resolveReference(o,n,s);u&&c.push(u)}else if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let u=new w,y=await this.parseStatements(o,n,s,r,i);u.statement=y.statements,u.unresolvedPredicates=y.unresolved,c.push(u)}}let l=new v;return l.predicate=k.parse(e),l.object=c,l}async resolveReference(e,t,a){let n=await a.resolveEntityAsync(e,t);if(n){let r=new k;return r.subject=n.uri,r}let s=t.metadata?.namespace_;if(s){let{KanonakUri:r}=await import("./KanonakUri-4VJGV3FN.js");if(e.includes(".")){let c=e.indexOf("."),f=e.substring(0,c),g=e.substring(c+1);if(t.metadata?.imports){for(let[l,o]of Object.entries(t.metadata.imports))for(let m of o)if((m.alias??m.packageName)===f){let y=new k;return y.subject=new r(l,m.packageName,g,m.version),y}}}let i=new k;return i.subject=new r(s.publisher,s.package_,e,s.version??void 0),i}return null}async saveKanonaks(e,t){let a=new Map;for(let n of e)n instanceof S&&n.namespace&&(a.has(n.namespace)||a.set(n.namespace,[]),a.get(n.namespace).push(n));for(let[n,s]of a){let r=await this.convertKanonaksToDocument(n,s),i=`${n.split("@")[0]}.yml`;await t.saveDocumentAsync(r,i)}}async serializeToYaml(e,t){let a=e.filter(r=>r instanceof S&&r.namespace===t);if(a.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let n=await this.convertKanonaksToDocument(t,a);return new N().save(n)}async convertKanonaksToDocument(e,t){let n={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let r=[];for(let i of Object.values(this.imports))r.push(...i);return r}},body:{}},s=new Map;for(let r of t){let i={};for(let c of r.statement){let[f,g]=this.convertStatementToProperty(c);f&&g!==null&&g!==void 0&&(i[f]=g),this.collectImportsFromStatement(c,e,s)}n.body[r.name]=i}return n}convertStatementToProperty(e){if(e instanceof P)return[e.predicate.subject.name,e.object];if(e instanceof x)return[e.predicate.subject.name,e.object];if(e instanceof O)return[e.predicate.subject.name,e.object];if(e instanceof I)return[e.predicate.subject.name,e.object.subject.name];if(e instanceof v){let t=this.convertKanonakListToValue(e.object);return[e.predicate.subject.name,t]}else if(e instanceof R){let t=this.convertEmbeddedKanonakToValue(e.object);return[e.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(e){let t=[];for(let a of e)a instanceof k?t.push(a.subject.name):a instanceof w&&t.push(this.convertEmbeddedKanonakToValue(a));return t}convertEmbeddedKanonakToValue(e){let t={};for(let a of e.statement){let[n,s]=this.convertStatementToProperty(a);n&&s!==null&&s!==void 0&&(t[n]=s)}return t}collectImportsFromStatement(e,t,a){}};function L(p){let e=p.predicate?.subject;return(e?`${e.publisher}/${e.package_}/${e.name}`:"?")+"="+H(p)}function H(p){return p instanceof D?"m:"+String(p.object):p instanceof P?"s:"+String(p.object):p instanceof x?"n:"+String(p.object):p instanceof O?"b:"+String(p.object):p instanceof I?"r:"+A(p.object):p instanceof R?"e:"+A(p.object):p instanceof v?"l:["+(p.object??[]).map(A).join("|")+"]":"x"}function A(p){if(!p)return"";if(p instanceof k){let e=p.subject;return"R("+(e?`${e.publisher}/${e.package_}/${e.name}`:"")+")"}return p instanceof w?"E("+(p.statement??[]).map(L).join(";")+")":p instanceof K?"L("+String(p.value)+")":"N"}export{w as a,K as b,D as c,j as d,T as e,ae as f,E as g,X as h};
|
package/dist/chunk-IEOSSSB5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as u,f as _,j as g,k as d,m as j}from"./chunk-7TKJHKC2.js";import{j as m}from"./chunk-7HRKWTBB.js";import{c as U,d as S}from"./chunk-4UT2CLAT.js";import{a as b}from"./chunk-FUUTGGJS.js";var $=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function i(r){let n=r;if(n.entity&&typeof n.entity=="object"){let e=n.entity.type;if(typeof e=="string"){let a={publisher:"",package_:"",name:e.includes(".")?e.substring(e.lastIndexOf(".")+1):e};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}if(n.statement&&Array.isArray(n.statement)){for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject,a={publisher:t.publisher??"",package_:t.package_??"",name:t.name};return m(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return null}function c(r,n){return $.has(`${r}/${n}`)}var y=class r{static getTypeUri(n){return i(n)}static isCoreOntologyType(n){return c(n.publisher,n.package_)}static isClassType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(n){let e=i(n);return e?c(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(n){let e=i(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(n,e){if(r.isSchemaDefinitionType(n))return!1;let t=i(n);return t?e.has(t.name):!1}};function P(r){if(!r||r.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=r.trim(),e=n.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${r}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let s=a.substring(0,o),p=a.substring(o+1);if(!s||!p)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let f=A(p);return{kind:"package",publisher:t,package_:s,version:f}}return{kind:"resource",uri:b.parse(n)}}function G(r){switch(r.kind){case"publisher":return r.publisher;case"package":return r.version?`${r.publisher}/${r.package_}@${r.version.major}.${r.version.minor}.${r.version.patch}`:`${r.publisher}/${r.package_}`;case"resource":return r.uri.toString()}}function A(r){let n=r.split(".").map(Number);return w(n[0]||0,n[1]||0,n[2]||0)}function w(r,n,e){return{major:r,minor:n,patch:e,toString:()=>`${r}.${n}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===r&&t.minor===n&&t.patch===e,getHashCode:()=>r<<20|n<<10|e,compareTo:t=>r!==t.major?r-t.major:n!==t.minor?n-t.minor:e-t.patch}}var k="kanonak.org",l="core-rdf",T={publisher:k,package_:l,name:"domain"},C={publisher:k,package_:l,name:"range"},R={publisher:k,package_:l,name:"subClassOf"},v={publisher:k,package_:l,name:"type"},x={publisher:k,package_:l,name:"label"},D={publisher:k,package_:l,name:"comment"},O=new b(k,l,"Resource"),I=r=>r;function V(r){try{let n=P(`${r.namespace}/${r.name}`);return n.kind==="resource"?n.uri:void 0}catch{return}}function h(r,n){let e=d(r,n);if(e)return[e];let t=[];for(let a of j(r,n))a instanceof S&&t.push(a.subject);return t}function N(r,n){let e=[],t=new Set,a=[new b(n.publisher,n.package_,n.name)];for(;a.length>0;){let o=a.shift(),s=u(o);if(t.has(s))continue;t.add(s),e.push(o);let p=_(r,o);p&&a.push(...h(p,R))}return e}function B(r,n){let e=new Set([u(O)]);for(let t of N(r,n))e.add(u(t));return e}function F(r,n){let e=B(r,n),t=[],a=new Set;for(let o of r){if(!(o instanceof U))continue;let s=I(o);if(!y.isAnyPropertyType(s))continue;let p=h(o,T);if(!p.some(E=>e.has(u(E))))continue;let f=V(o);if(!f)continue;let K=u(f);a.has(K)||(a.add(K),t.push({uri:f,label:g(o,x),comment:g(o,D),kind:y.isObjectPropertyType(s)?"object":y.isDatatypePropertyType(s)?"datatype":"other",range:d(o,C),domains:p}))}return t}function Z(r,n,e){let t=F(r,n).find(a=>u(a.uri)===u(e));return t?{ok:!0,descriptor:t}:{ok:!1,message:`Property ${e.publisher}/${e.package_}/${e.name} is not in scope for ${n.publisher}/${n.package_}/${n.name}.`}}function ee(r){return h(r,v)}export{y as a,P as b,G as c,V as d,N as e,F as f,Z as g,ee as h};
|
package/dist/chunk-SHDHMKMJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t="kanonak.org",a="transformations",i=3,e=r=>({publisher:t,package_:a,name:r}),n={Transformation:e("Transformation"),InstanceTransformation:e("InstanceTransformation"),SetTransformation:e("SetTransformation"),inputPattern:e("inputPattern"),rule:e("rule"),artifactName:e("artifactName"),outputs:e("outputs"),formatOverrides:e("formatOverrides"),partitionBy:e("partitionBy"),InputPattern:e("InputPattern"),matchesClass:e("matchesClass"),requires:e("requires"),sortBy:e("sortBy"),SortKey:e("SortKey"),byProperty:e("byProperty"),order:e("order"),SortOrder:e("SortOrder"),ascending:e("ascending"),descending:e("descending"),OutputFormat:e("OutputFormat"),backendUri:e("backendUri"),FormatOverride:e("FormatOverride"),formatTarget:e("formatTarget"),metadataKeys:e("metadataKeys"),metadataRenames:e("metadataRenames"),trailingNewline:e("trailingNewline"),omitWrapper:e("omitWrapper"),RenameEntry:e("RenameEntry"),fromKey:e("fromKey"),toKey:e("toKey"),FMT_MARKDOWN_FRONTMATTER:e("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:e("plain-markdown"),FMT_TOML:e("toml"),FMT_JSON:e("json"),FMT_HTML:e("html"),FMT_SVG:e("svg"),Expression:e("Expression"),ListSourcedExpression:e("ListSourcedExpression"),ListAggregate:e("ListAggregate"),IteratingExpression:e("IteratingExpression"),BuildAstNode:e("BuildAstNode"),astClass:e("astClass"),set:e("set"),AstFieldBinding:e("AstFieldBinding"),field:e("field"),bindValue:e("bindValue"),When:e("When"),condition:e("condition"),thenBuild:e("thenBuild"),elseBuild:e("elseBuild"),Concat:e("Concat"),parts:e("parts"),Fallback:e("Fallback"),primary:e("primary"),alternate:e("alternate"),StringLiteral:e("StringLiteral"),stringLiteral:e("stringLiteral"),IntegerLiteral:e("IntegerLiteral"),integerLiteral:e("integerLiteral"),DecimalLiteral:e("DecimalLiteral"),decimalLiteral:e("decimalLiteral"),BooleanLiteral:e("BooleanLiteral"),booleanLiteral:e("booleanLiteral"),VarRef:e("VarRef"),varName:e("varName"),PropertyRead:e("PropertyRead"),readSource:e("readSource"),readProp:e("readProp"),Traverse:e("Traverse"),traverseSource:e("traverseSource"),through:e("through"),step:e("step"),UriName:e("UriName"),uriNameOf:e("uriNameOf"),UriPublisher:e("UriPublisher"),uriPublisherOf:e("uriPublisherOf"),UriPackage:e("UriPackage"),uriPackageOf:e("uriPackageOf"),UriVersion:e("UriVersion"),uriVersionOf:e("uriVersionOf"),SubjectUri:e("SubjectUri"),subjectOf:e("subjectOf"),UriLiteral:e("UriLiteral"),refTo:e("refTo"),DisplayLabel:e("DisplayLabel"),labelTarget:e("labelTarget"),labelSource:e("labelSource"),ResolveRef:e("ResolveRef"),resolveSource:e("resolveSource"),Normalize:e("Normalize"),normSource:e("normSource"),normKind:e("normKind"),NormalizeKind:e("NormalizeKind"),NORM_TRIM_END:e("trim-end"),NORM_TO_UPPER:e("to-upper"),NORM_TO_LOWER:e("to-lower"),NORM_FIRST_CHAR:e("first-char"),UnescapedString:e("UnescapedString"),unescapedSource:e("unescapedSource"),IsSet:e("IsSet"),checkExpr:e("checkExpr"),ExpressionFragment:e("ExpressionFragment"),body:e("body"),CallFragment:e("CallFragment"),fragmentRef:e("fragmentRef"),source:e("source"),Join:e("Join"),separator:e("separator"),Count:e("Count"),Sum:e("Sum"),Min:e("Min"),Max:e("Max"),Average:e("Average"),loopVar:e("loopVar"),ForEach:e("ForEach"),emit:e("emit"),ListMap:e("ListMap"),mapBody:e("mapBody"),Filter:e("Filter"),predicate:e("predicate"),PartitionBy:e("PartitionBy"),partitionKey:e("partitionKey"),DistinctBy:e("DistinctBy"),distinctKey:e("distinctKey"),Partition:e("Partition"),key:e("key"),members:e("members"),AllStatements:e("AllStatements"),statementsOf:e("statementsOf"),StatementPredicate:e("StatementPredicate"),predicateOf:e("predicateOf"),StatementValue:e("StatementValue"),valueOf:e("valueOf"),DateFormat:e("DateFormat"),dateSource:e("dateSource"),dateFormat:e("dateFormat"),BinaryArithmetic:e("BinaryArithmetic"),arithLeft:e("arithLeft"),arithRight:e("arithRight"),Add:e("Add"),Subtract:e("Subtract"),Multiply:e("Multiply"),Divide:e("Divide"),Reverse:e("Reverse"),WindowedMap:e("WindowedMap"),windowSize:e("windowSize"),windowVar:e("windowVar"),windowBody:e("windowBody"),PairwiseMap:e("PairwiseMap"),firstVar:e("firstVar"),secondVar:e("secondVar"),pairBody:e("pairBody"),Scan:e("Scan"),initialState:e("initialState"),stateVar:e("stateVar"),elementVar:e("elementVar"),accumulate:e("accumulate"),ListItemAt:e("ListItemAt"),itemIndex:e("itemIndex"),BinaryComparison:e("BinaryComparison"),compareLeft:e("compareLeft"),compareRight:e("compareRight"),Equals:e("Equals"),GreaterThan:e("GreaterThan"),LessThan:e("LessThan"),GreaterThanOrEqual:e("GreaterThanOrEqual"),LessThanOrEqual:e("LessThanOrEqual"),Not:e("Not"),operand:e("operand"),BooleanLogic:e("BooleanLogic"),operands:e("operands"),And:e("And"),Or:e("Or"),Contains:e("Contains"),haystack:e("haystack"),needle:e("needle"),UnaryNumericOp:e("UnaryNumericOp"),value:e("value"),Abs:e("Abs"),Negate:e("Negate"),KindPredicate:e("KindPredicate"),IsReference:e("IsReference"),IsEmbedded:e("IsEmbedded"),IsList:e("IsList"),kindCheck:e("kindCheck"),IsString:e("IsString"),IsNumber:e("IsNumber"),IsBoolean:e("IsBoolean"),StatementObject:e("StatementObject"),statementSource:e("statementSource"),Let:e("Let"),letName:e("letName"),letValue:e("letValue"),letBody:e("letBody"),GetStatementByName:e("GetStatementByName"),inSubject:e("inSubject"),byName:e("byName"),RenderMarkdown:e("RenderMarkdown"),renderSource:e("renderSource"),renderProp:e("renderProp"),renderFormat:e("renderFormat"),RenderFormat:e("RenderFormat"),RENDER_HTML:e("render-html"),RENDER_MARKDOWN:e("render-markdown")};export{t as a,a as b,i as c,n as d};
|
package/dist/chunk-U7LVFPEO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{J as W,K as X}from"./chunk-UBBZWWRB.js";import{b as B,c as V,h as w}from"./chunk-BKVPSPG4.js";import{a as b,d as K,e as q,f as z}from"./chunk-IEOSSSB5.js";import{a as D,f as E,h as F,j as N,k as Y,m as v}from"./chunk-7TKJHKC2.js";import{c as G,d as x}from"./chunk-4UT2CLAT.js";import{a as L}from"./chunk-FUUTGGJS.js";import{d as U}from"./chunk-2ACBWC7K.js";var Q=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(Q||{}),Z=(p=>(p.InstanceOf="instanceOf",p.SubClassOf="subClassOf",p.Domain="domain",p.Range="range",p.ObjectRelationship="objectRelationship",p.SubPropertyOf="subPropertyOf",p.PropertyValue="propertyValue",p.EmbeddedLink="embeddedLink",p))(Z||{}),I=class{static async buildFromRepository(e){let a=await new w().parseKanonaks(e),o=await e.getAllDocumentsAsync(),s=[],i=[],t=new Set,p=new Set,g=new Map;for(let u of a){let l=u;l.name&&(b.isClassType(l)&&t.add(l.name),(b.isObjectPropertyType(l)||b.isGenericPropertyType(l))&&p.add(l.name))}for(let u of o)for(let[l,f]of Object.entries(u.body))p.has(l)&&f?.range&&typeof f.range=="string"&&g.set(l,f.range);let y=new Map;for(let u of a){let l=u;l.name&&y.set(l.name,l)}for(let u of o){let l=u.metadata.namespace_,f=l?`${l.publisher}/${l.package_}`:"",c=l?.version?`${l.version.major}.${l.version.minor}.${l.version.patch}`:"",d=H(u);for(let[k,m]of Object.entries(u.body)){if(!m||typeof m!="object")continue;let P=y.get(k),h="Unknown";if(P){let T=P;b.isClassType(T)?h="Class":b.isObjectPropertyType(T)?h="ObjectProperty":b.isDatatypePropertyType(T)?h="DatatypeProperty":b.isAnnotationPropertyType(T)?h="AnnotationProperty":b.isDatatypeType(T)?h="Datatype":b.isGenericPropertyType(T)?h="ObjectProperty":b.isInstanceOfKnownClass(T,t)&&(h="Instance")}let j=f&&c?`${f}/${k}@${c}`:k,A={};for(let[T,$]of Object.entries(m))T!=="type"&&(typeof $!="object"||$===null)&&(A[T]=$);s.push({id:j,label:m.label??k,type:h,namespace:f,properties:A}),J(j,m,h,t,p,i,f,c,d),_(j,m,p,g,s,i,f,c,d),ue(j,P,i)}}return{nodes:s,edges:i}}static buildFromDocument(e){let r=[],a=[],o=e.metadata.namespace_,s=o?.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"",i=o?`${o.publisher}/${o.package_}`:"",t=new Set,p=new Set,g=new Map,y=H(e);for(let[f,c]of Object.entries(e.body)){let d=c?.type;d&&(pe(d,y)&&t.add(f),ce(d,y)&&(p.add(f),c.range&&typeof c.range=="string"&&g.set(f,c.range)))}for(let[f,c]of Object.entries(e.body)){if(!c||typeof c!="object")continue;let d=c.type,k=le(d,f,t,y),m=i&&s?`${i}/${f}@${s}`:f,P={};for(let[h,j]of Object.entries(c))h!=="type"&&(typeof j!="object"||j===null)&&(P[h]=j);r.push({id:m,label:c.label??f,type:k,namespace:i,properties:P}),J(m,c,k,t,p,a,i,s,y),_(m,c,p,g,r,a,i,s,y)}let u=new Set(r.map(f=>f.id)),l=a.filter(f=>u.has(f.source)&&u.has(f.target));return{nodes:r,edges:l}}};function H(n,e){let r=new Map;if(n.metadata?.imports)for(let[a,o]of Object.entries(n.metadata.imports))for(let s of o){let i=s.alias??s.packageName,t=s.version,p=`${t.major}.${t.minor}.${t.patch}`;r.set(i,{publisher:a,package_:s.packageName,version:p})}return r}var ee={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},ie=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(n,e){if(n.includes(".")){let r=n.indexOf("."),a=n.substring(0,r),o=n.substring(r+1),s=e.get(a);if(s)return`${s.publisher}/${s.package_}/${o}`}return null}function pe(n,e){let r=M(n,e);return r?ee[r]==="Class":!1}function ce(n,e){let r=M(n,e);return r?ie.has(r):!1}function le(n,e,r,a){if(!n||n==="Package")return"Unknown";let o=M(n,a);if(o){let i=ee[o];if(i)return i;let t=o.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let s=n.split(".").pop()??n;return r.has(s)?"Instance":"Unknown"}var ne=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function J(n,e,r,a,o,s,i,t,p){let g=e.type,y=e.subClassOf;if(y){let c=Array.isArray(y)?y:[y];for(let d of c)typeof d=="string"&&s.push({source:n,target:O(d,i,t,p),type:"subClassOf",label:"subClassOf"})}let u=e.subPropertyOf;if(u){let c=Array.isArray(u)?u:[u];for(let d of c)typeof d=="string"&&s.push({source:n,target:O(d,i,t,p),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&g){let c=g.split(".").pop()??g;s.push({source:n,target:O(c,i,t,p),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[c,d]of Object.entries(e)){if(ne.has(c)||!o.has(c))continue;let k=Array.isArray(d)?d:[d];for(let m of k)typeof m=="string"&&fe(m)&&s.push({source:n,target:O(m,i,t,p),type:"propertyValue",label:c,propertyId:O(c,i,t,p)})}let l=r==="ObjectProperty"||r==="DatatypeProperty",f=e.domain&&e.range;if((l||f)&&e.domain&&e.range){let c=typeof e.domain=="string"?e.domain:null,d=typeof e.range=="string"?e.range:null;c&&d&&s.push({source:O(c,i,t,p),target:O(d,i,t,p),type:"objectRelationship",label:e.label??n.split("/").pop()??"",propertyId:n})}}function _(n,e,r,a,o,s,i,t,p){for(let[g,y]of Object.entries(e)){if(ne.has(g)||typeof y!="object"||y===null||Array.isArray(y))continue;let u=y,l=`${n}/${g}`,f=a.get(g),c=f?f.split(".").pop()??f:"Unknown",d={};for(let[m,P]of Object.entries(u))(typeof P!="object"||P===null)&&(d[m]=P);o.push({id:l,label:`${c} (embedded)`,type:"Instance",namespace:i,properties:d});let k=i&&t?`${i}/${g}@${t}`:g;s.push({source:n,target:l,type:"propertyValue",label:g,propertyId:r.has(g)?k:void 0}),f&&s.push({source:l,target:O(c,i,t,p),type:"instanceOf",label:"type (inferred)"}),_(l,u,r,a,o,s,i,t,p)}}function ue(n,e,r){let a=e?.statement;if(Array.isArray(a))for(let o of a){if(!(o instanceof V))continue;let s=o.predicate?.subject?.name??"";for(let i of o.links){let t=i.target?.subject;if(!t)continue;let p=t.version,g=p&&typeof p.major=="number"?`@${p.major}.${p.minor}.${p.patch}`:"";r.push({source:n,target:`${t.publisher}/${t.package_}/${t.name}${g}`,type:"embeddedLink",label:s})}}}function fe(n){return!(!n||n.includes(" ")||n.includes(`
|
|
2
|
-
`)||n.startsWith("http://")||n.startsWith("https://")||/^\d{4}-\d{2}/.test(n)||/^\d+(\.\d+)?$/.test(n))}function O(n,e,r,a){if(n.includes("@")&&n.includes("/"))return n;if(n.includes(".")){let o=n.indexOf("."),s=n.substring(0,o),i=n.substring(o+1);if(a){let t=a.get(s);if(t)return`${t.publisher}/${t.package_}/${i}@${t.version}`}return e&&r?`${e}/${i}@${r}`:i}return e&&r?`${e}/${n}@${r}`:n}function de(n){if(!n.expiresAt)return!1;let e=new Date(n.expiresAt),r=300*1e3;return e.getTime()<=Date.now()+r}function Re(n){return!!n.accessToken&&!de(n)}function Se(n){let e=n.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}var C="kanonak.org",S="core-rdf",re="core-xsd",te={publisher:C,package_:S,name:"subClassOf"},oe={publisher:C,package_:S,name:"label"},ye={publisher:C,package_:S,name:"comment"},se={publisher:C,package_:"core-owl",name:"oneOf"},ae=n=>n;function ge(n){let e=Y(n,te);if(e)return[e];let r=[];for(let a of v(n,te))a instanceof x&&r.push(a.subject);return r}function me(n,e,r){if(e.publisher===C&&e.package_===S&&e.name==="Literal")return{kind:"datatype",uri:e};let o=E(n,e);if(o){let s=ae(o);if(b.isDatatypeType(s))return{kind:"datatype",uri:e};if(b.isClassType(s))return{kind:"class",uri:K(o)??e,localName:o.name}}return e.publisher===C&&e.package_===re?{kind:"datatype",uri:e}:r==="datatype"?{kind:"datatype",uri:e}:{kind:"class",uri:e,localName:e.name}}function be(n,e,r){if(!e.range)throw new Error(`Property ${e.uri.publisher}/${e.uri.package_}/${e.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let a=me(n,e.range,e.kind),o=e.kind==="object"?"object":e.kind==="datatype"?"datatype":a.kind==="class"?"object":"datatype";return{uri:e.uri,localName:e.uri.name,kind:o,range:a,...e.label!==void 0?{label:e.label}:{},...e.comment!==void 0?{comment:e.comment}:{},...r??{}}}var R=n=>new L(C,re,n);function ke(n){return typeof n=="boolean"?R("boolean"):typeof n=="number"?Number.isInteger(n)?R("integer"):R("decimal"):R("string")}function he(n,e){let r=[];for(let a of v(e,se))if(a instanceof x){let o=E(n,a.subject),s=(o?K(o):void 0)??a.subject,i=o?N(o,oe):void 0;r.push({kind:"individual",uri:s,localName:s.name,...i!==void 0?{label:i}:{}})}else a instanceof B&&r.push({kind:"literal",value:a.value,datatype:ke(a.value)});return r}function Pe(n,e,r,a){let o=q(n,e),s=D(e);return z(n,e).filter(t=>r?!0:t.domains.some(p=>D(p)===s)).map(t=>be(n,t,X(a,o,t.uri)))}async function Te(n,e,r){let a=n.metadata?.namespace_;if(!a)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let o=r?.includeInherited??!1,s=await new w().parseKanonaks(e),i=W(s),t=[],p=[],g=new Set;for(let y of s){if(!(y instanceof G)||!b.isClassType(ae(y)))continue;let u=K(y);if(!u||u.publisher!==a.publisher||u.package_!==a.package_||u.version&&a.version&&!U(u.version,a.version))continue;let l=D(u);if(g.has(l))continue;g.add(l);let f=ge(y).map(k=>({uri:k,localName:k.name})),c=N(y,oe),d=N(y,ye);t.push({uri:u,localName:u.name,superClasses:f,properties:Pe(s,u,o,i),...c!==void 0?{label:c}:{},...d!==void 0?{comment:d}:{}}),F(y,se)&&p.push({uri:u,localName:u.name,members:he(s,y),...c!==void 0?{label:c}:{},...d!==void 0?{comment:d}:{}})}return{classes:t,enums:p}}export{Q as a,Z as b,I as c,de as d,Re as e,Se as f,Te as g};
|
package/dist/chunk-UBBZWWRB.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import{d as _}from"./chunk-SHDHMKMJ.js";import{a as I,b as Ne,c as Qe,f as tt,h as E}from"./chunk-BKVPSPG4.js";import{a as Ye}from"./chunk-NJ3AZYQD.js";import{a as B,d as W,e as nt,f as ot,g as x,h as rt}from"./chunk-IEOSSSB5.js";import{a as C,d as A,f as T,h as xe,i as w,j as L,k as V,l as O,m as S,n as M}from"./chunk-7TKJHKC2.js";import{a as N,b as U,c as et}from"./chunk-7HRKWTBB.js";import{c as D,d as H,k as Ze,l as Je}from"./chunk-4UT2CLAT.js";import{a as Ge}from"./chunk-FUUTGGJS.js";import{e as P}from"./chunk-2ACBWC7K.js";var q=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var b=(t=>(t.Warning="Warning",t.Error="Error",t))(b||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var Le=class m{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new m;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var Se=class{constructor(e){this.underlying=e;this.repository=new We(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new E().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let t=this.importClosureCache.get(e);return t||(t=this.computeImportClosure(e),this.importClosureCache.set(e,t),t)}async getClassDeclarations(e){let t=this.classDeclarationsCache.get(e);return t||(t=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,t),t)}async getPropertyNames(e){let t=this.propertyNamesCache.get(e);return t||(t=this.computePropertyNames(e),this.propertyNamesCache.set(e,t),t)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let t=new Set([e]),n=[e],o=await this.buildDocsByIdIndex();for(;n.length>0;){let a=n.shift(),r=o.get(a);if(r?.metadata.imports)for(let[i,s]of Object.entries(r.metadata.imports))for(let c of s){let p=await this.repository.getHighestCompatibleVersionAsync(i,c);if(!p)continue;let l=Me(p);!l||t.has(l)||(t.add(l),n.push(l))}}return t}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),t=new Map;for(let n of e){let o=Me(n);o&&t.set(o,n)}return t}async computeClassDeclarations(e){let t=await this.findDocById(e),n=new Map;if(!t)return n;for(let[o,a]of Object.entries(t.body)){if(!it(a))continue;let r=a,i=at(r,"type");if(i==="Class"||i?.endsWith(".Class")){let s=Rt(r);n.set(o,s)}}return n}async computePropertyNames(e){let t=await this.findDocById(e),n=new Set;if(!t)return n;for(let[o,a]of Object.entries(t.body)){if(!it(a))continue;let i=at(a,"type");(i==="ObjectProperty"||i?.endsWith(".ObjectProperty")||i==="DatatypeProperty"||i?.endsWith(".DatatypeProperty")||i==="AnnotationProperty"||i?.endsWith(".AnnotationProperty")||i==="Property"||i?.endsWith(".Property"))&&n.add(o)}return n}async findDocById(e){let t=await this.getAllDocuments();for(let n of t)if(Me(n)===e)return n}};function Me(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}function it(m){return typeof m=="object"&&m!==null&&!Array.isArray(m)}function at(m,e){if(e in m)return st(m[e]);for(let t of Object.keys(m))if(t.endsWith(`.${e}`))return st(m[t])}function st(m){return Array.isArray(m)?m.length>0?String(m[0]):void 0:m==null?void 0:String(m)}function Rt(m){let e=m.subClassOf;if(e===void 0){for(let t of Object.keys(m))if(t.endsWith(".subClassOf")){e=m[t];break}}return N(e)}var We=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let n=`${e}/${t}`,o=this.byNamespaceCache.get(n);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(n,o),o)}getHighestCompatibleVersionAsync(e,t){let n=t.version,o=n?`${n.major}.${n.minor}.${n.patch}`:"",a=`${e}/${t.packageName}@${t.versionOperator}:${o}`,r=this.highestVersionCache.get(a);return r||(r=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(a,r),r)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var z=class m{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[n,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(n,o,t);return t}validateEntity(e,t,n){for(let[o,a]of Object.entries(t)){let r=a?.toString()??"";if(r&&m.NAMESPACE_PREFIX_PATTERN.test(r)){let i=this.getSuggestionForPrefixedValue(r),s=e.split(".")[0],c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=o,c.expectedValue=i,c.message=`Invalid namespace prefix '${r}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",n.push(c)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validateEntity(`${e}.${o}`,a,n)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let n=e.indexOf(":");return n>=0?e.substring(n+1):e}};var Y=class m{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],n=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,a]of Object.entries(e.body)){let r=m.VALID_AUGMENTATION_PATTERN.test(o);if(!r&&!n&&m.RESERVED_WORDS.has(o.toLowerCase())){let i=new g;i.ruleType=this.ruleName,i.severity="Error",i.entityName=o,i.message=`Entity name '${o}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!r&&!m.VALID_NAME_PATTERN.test(o)){let i;/^\d/.test(o)?i="Entity names must start with a letter, not a number.":o.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new g;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.message=`Invalid entity name '${o}'. ${i}`,s.suggestion=i,t.push(s)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validatePropertyNames(o,a,t)}return t}validatePropertyNames(e,t,n){for(let o of Object.keys(t))if(!m.VALID_PROPERTIES.has(o)&&!m.VALID_PROPERTY_NAME_PATTERN.test(o)){let a=new g;a.ruleType=this.ruleName,a.severity="Warning",a.entityName=e,a.propertyName=o,a.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,a.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",n.push(a)}}};var G=class m{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let n=this.isPropertyDefinedAsClass(e);for(let[o,a]of Object.entries(e.body))if(a&&typeof a=="object"&&!Array.isArray(a)){let r=a,i=r.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let p=c?.toString();p&&p==="Property"&&!n&&s.push(p)}else{let c=i?.toString();c&&c==="Property"&&!n&&s.push(c)}for(let c of s){let p=this.getPropertyValue(r,"range"),l=this.determinePropertyType(p),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.entityName=o,u.propertyName="type",u.actualValue=c,u.expectedValue=l,u.message=`Invalid property type '${c}'. Use '${l}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":m.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let n=e[t];return n?n.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let o=t.type;if(o){let a=o.toString();return a==="Class"||a.endsWith(".Class")}}return!1}};var Z=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[n,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||n.includes("."))continue;let a=o,r="type"in a,i=a.type?.toString().trim();if(!r||!i){let s=new g;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.propertyName="type",s.message=`Subject Kanonak '${n}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
2
|
-
type: Scene
|
|
3
|
-
|
|
4
|
-
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var vt=new Set(["EphemeralPackage"]),J=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let n=[],o=this.packageKey(e,t.type_);return t.namespace_?(!vt.has(t.type_)&&!t.namespace_.version&&n.push(this.error(o,"version",`Package resource '${o}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
5
|
-
version: 1.0.0`)),n):(n.push(this.error(o,"publisher",`Package resource '${o}' requires a 'publisher' property.`,`Add a publisher, e.g.:
|
|
6
|
-
publisher: example.org`)),n)}packageKey(e,t){for(let[n,o]of Object.entries(e.body))if(o&&typeof o=="object"&&!Array.isArray(o)&&o.type===t)return n;return t}error(e,t,n,o){let a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.message=n,a.suggestion=o,a}};var Q=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,t){let n=[],o=new U(t),a=await this.buildPropertyRangeMap(e,o);for(let[r,i]of Object.entries(e.body))typeof i=="object"&&i!==null&&!Array.isArray(i)&&await this.checkEmbeddedTypes(r,i,void 0,a,o,e,n,0);return n}pickRange(e,t,n){if(e.length===0)return;if(e.length===1)return e[0].range;let o=t.indexOf(".");if(o>0){let a=t.substring(0,o),r=e.find(i=>i.declaringAlias===a);if(r)return r.range}if(n){let a=this.localName(n),r=e.find(i=>this.localName(i.domain)===a);if(r)return r.range}return e[0].range}async checkEmbeddedTypes(e,t,n,o,a,r,i,s){if(s>0){let p=t.type;if(p!=null){let l=await this.validateEmbeddedType(e,String(p),n,a,r);l&&i.push(l)}}let c=t.type!==void 0&&t.type!==null?String(t.type):void 0;for(let[p,l]of Object.entries(t)){let u=this.localName(p),y=o.get(u),d=(y!==void 0?this.pickRange(y,p,c):void 0)??n;if(typeof l=="object"&&l!==null)if(Array.isArray(l))for(let k=0;k<l.length;k++){let h=l[k];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${p}[${k}]`,h,d,o,a,r,i,s+1)}else await this.checkEmbeddedTypes(`${e}.${p}`,l,d,o,a,r,i,s+1)}}async validateEmbeddedType(e,t,n,o,a){if(t.length===0||!n)return null;let r=this.localName(t),i=this.localName(n);if(i==="Resource"||i==="Class")return null;let s=e.split(".")[0];if(r===i){let p=new g;return p.ruleType=this.ruleName,p.severity="Warning",p.entityName=s,p.propertyName=e,p.actualValue=t,p.expectedValue=n,p.message=`Embedded object at '${e}' declares 'type: ${t}', which equals the parent property's range '${n}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,p.suggestion=`Remove the 'type: ${t}' line, or keep it if explicitness is preferred over concision.`,p}if(await o.isSubclassOfAsync(t,n,a)||(r!==t||i!==n)&&await o.isSubclassOfAsync(r,i,a))return null;let c=new g;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=t,c.expectedValue=n,c.message=`Embedded object at '${e}' has 'type: ${t}', which is not a subclass of the parent property's range '${n}'.`,c.suggestion=`Either remove the 'type: ${t}' line (so the type is inferred from the property's range '${n}'), or add 'subClassOf: ${n}' to the '${t}' class definition so the relationship holds.`,c}localName(e){let t=e.lastIndexOf(".");return t<0||t===e.length-1?e:e.substring(t+1)}async buildPropertyRangeMap(e,t){let n=new Map,o=await t.buildEntityIndexAsync(e),a=new Map;for(let[r,i]of o){let s=i.entity.type;if(s==null)continue;let c=String(s),p=this.localName(c);if(!(p==="Property"||p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"))continue;let u=i.entity.range;if(u==null)continue;let y=String(u);if(y.length===0)continue;let f=i.entity.domain,d=f!=null?String(f):"",k=i.uri.toString(),h=a.get(k),v=r.includes(".");(!h||v&&!h.entityName.includes("."))&&a.set(k,{entityName:r,domain:d,range:y})}for(let r of a.values()){let i=this.localName(r.entityName),s=r.entityName.indexOf("."),c=s>0?r.entityName.substring(0,s):void 0,p=n.get(i)??[];p.push({domain:r.domain,range:r.range,declaringAlias:c}),n.set(i,p)}return n}};import{VersionOperator as Te}from"@kanonak-protocol/types/document/models/enums";var ee=class{ruleName="ImportExistence";async validateAsync(e,t){let n=[];if(!e.metadata?.imports)return n;let o=await t.getAllDocumentsAsync();for(let[a,r]of Object.entries(e.metadata.imports))for(let i of r)if(!await t.getHighestCompatibleVersionAsync(a,i)){let c=await this.determineImportErrorAsync(t,a,i,o),p=new g;p.ruleType=this.ruleName,p.severity="Error",p.message=c.message,p.suggestion=c.suggestion,p.entityName=`Import: ${a}/${i.packageName}`,p.actualValue=i.toString(),p.expectedValue=c.expectedValue,n.push(p)}return n}async determineImportErrorAsync(e,t,n,o){let a=await e.getDocumentsByNamespaceAsync(t,n.packageName);if(a.length===0){let c=o.filter(y=>y.metadata.namespace_?.publisher===t).map(y=>y.metadata.namespace_.package_).filter((y,f,d)=>d.indexOf(y)===f),p=this.findSimilarPackages(n.packageName,c),l=`Import '${t}/${n.package_}' not found - package does not exist`,u=p.length>0?`Did you mean: ${p.slice(0,3).join(", ")}?`:c.length>0?`Available packages in ${t}: ${c.slice(0,5).join(", ")}`:`No packages found for publisher '${t}'. Verify the publisher name is correct.`;return{message:l,suggestion:u,expectedValue:"Existing package"}}let i=a.filter(c=>c.metadata.namespace_?.version).map(c=>c.metadata.namespace_.version.toString()).sort().join(", "),s=this.getAcceptableVersionRange(n);return{message:`Import '${t}/${n.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${s}`,expectedValue:s}}getAcceptableVersionRange(e){switch(e.versionOperator){case Te.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Te.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Te.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Te.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,t){if(t.length===0)return[];let n=t.filter(r=>r.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(r.toLowerCase()));if(n.length>0)return n.sort((r,i)=>r.length-i.length);let o=t.map(r=>({package:r,distance:this.levenshteinDistance(e.toLowerCase(),r.toLowerCase())})).sort((r,i)=>r.distance-i.distance),a=Math.max(3,Math.floor(e.length*.4));return o.filter(r=>r.distance<=a).map(r=>r.package)}levenshteinDistance(e,t){if(!e||e.length===0)return t?.length??0;if(!t||t.length===0)return e.length;let n=e.length,o=t.length,a=Array(n+1).fill(null).map(()=>Array(o+1).fill(0));for(let r=0;r<=n;r++)a[r][0]=r;for(let r=0;r<=o;r++)a[0][r]=r;for(let r=1;r<=n;r++)for(let i=1;i<=o;i++){let s=e[r-1]===t[i-1]?0:1;a[r][i]=Math.min(Math.min(a[r-1][i]+1,a[r][i-1]+1),a[r-1][i-1]+s)}return a[n][o]}};var te=class{ruleName="UnresolvedReference";async validateAsync(e,t){let n=[],o=new U(t),a=await o.buildEntityIndexAsync(e),r=new Set;for(let[i,s]of a.entries()){let c=s.entity.type;if(c){let p=c.toString();(p==="ObjectProperty"||p.endsWith(".ObjectProperty"))&&r.add(i)}}for(let[i,s]of Object.entries(e.body)){if(!s||typeof s!="object"||Array.isArray(s))continue;let c=s,p=this.getPropertyValue(c,"type");if(!(!p||p==="Class"||p.endsWith("Property")||p==="AnnotationProperty"))for(let[l,u]of Object.entries(c))l==="type"||l==="label"||l==="comment"||!(r.has(l)||Array.from(r).some(f=>f.endsWith(`.${l}`)))||await this.validateReferenceValue(i,l,u,e,o,n)}return n}async validateReferenceValue(e,t,n,o,a,r){if(n!=null){if(typeof n=="string")await a.resolveEntityAsync(n,o)||r.push(this.createUnresolvedReferenceError(e,t,n));else if(Array.isArray(n))for(let i=0;i<n.length;i++){let s=n[i];typeof s=="string"&&(await a.resolveEntityAsync(s,o)||r.push(this.createUnresolvedReferenceError(e,`${t}[${i}]`,s)))}}}createUnresolvedReferenceError(e,t,n){let o=`The entity '${n}' cannot be found in the current document or any imported namespaces.
|
|
7
|
-
|
|
8
|
-
Possible solutions:
|
|
9
|
-
\u2022 Add import if the entity is defined in another namespace:
|
|
10
|
-
kanonak namespace add-import <publisher>/<package>@<version>
|
|
11
|
-
\u2022 Check for typos in the reference name '${n}'
|
|
12
|
-
\u2022 Define '${n}' in the current namespace or an appropriate namespace
|
|
13
|
-
\u2022 Use 'kanonak search type ${n} --include-imports' to locate the entity`,a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=n,a.message=`Reference to '${n}' could not be resolved`,a.suggestion=o,a.expectedValue="A valid entity reference that exists in the current document or imported namespaces",a}getPropertyValue(e,t){let n=e[t];return n?n.toString():null}};var ne=class{ruleName="ClassHierarchyCycle";async validateAsync(e,t){let n=[],o=new Map,a=new Set;await this.buildClassHierarchy(e,t,o,a);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let s=i,c=s.type,p=s.subClassOf;if(c?.toString()==="Class"&&p){let l=r,u=this.detectCycle(l,o);if(u){let y=u.join(" \u2192 "),f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Circular class hierarchy detected: ${y}`,f.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",f.entityName=l,f.propertyName="subClassOf",f.actualValue=y,n.push(f);break}}}return n}async buildClassHierarchy(e,t,n,o){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&o.has(a))){a&&o.add(a);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let s=i,c=s.type,p=s.subClassOf;if(c?.toString()==="Class"&&p){let l=N(p);l.length>0&&n.set(r,l)}}if(e.metadata?.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);c&&await this.buildClassHierarchy(c,t,n,o)}}}detectCycle(e,t){let n=[],o=new Set;return this.detectCycleRecursive(e,t,n,o)}detectCycleRecursive(e,t,n,o){if(n.includes(e)){let r=n.indexOf(e),i=n.slice(r);return i.push(e),i}if(o.has(e))return null;n.push(e),o.add(e);let a=t.get(e);if(a)for(let r of a){let i=this.detectCycleRecursive(r,t,n,o);if(i)return i}return n.pop(),null}};var oe=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,t){let n=[],o=new Map,a=new Set;await this.buildPropertyHierarchy(e,t,o,a);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)&&i.subPropertyOf){let p=r,l=this.detectCycle(p,o);if(l){let u=l.join(" \u2192 "),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Circular property hierarchy detected: ${u}`,y.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",y.entityName=p,y.propertyName="subPropertyOf",y.actualValue=u,n.push(y);break}}return n}async buildPropertyHierarchy(e,t,n,o){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&o.has(a))){a&&o.add(a);for(let[r,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let s=i,c=s.type;if(c){let p=c.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let l=s.subPropertyOf;if(l){let u=N(l);u.length>0&&n.set(r,u)}}}}if(e.metadata?.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);c&&await this.buildPropertyHierarchy(c,t,n,o)}}}detectCycle(e,t){let n=[],o=new Set;return this.detectCycleRecursive(e,t,n,o)}detectCycleRecursive(e,t,n,o){if(n.includes(e)){let r=n.indexOf(e),i=n.slice(r);return i.push(e),i}if(o.has(e))return null;n.push(e),o.add(e);let a=t.get(e);if(a)for(let r of a){let i=this.detectCycleRecursive(r,t,n,o);if(i)return i}return n.pop(),null}};var re=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,t){let n=[];for(let[o,a]of Object.entries(e.body)){if(typeof a!="object"||a===null||Array.isArray(a))continue;let r=a,i=r.type?.toString();if(i==="DatatypeProperty"||i==="ObjectProperty"||i?.endsWith(".DatatypeProperty")||i?.endsWith(".ObjectProperty")){let s="range"in r,c=r.range?.toString().trim();if(!s||!c){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=o,p.propertyName="range",p.message=`Property '${o}' must have a 'range' defined.`,p.suggestion=i==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=i==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",n.push(p)}}}return n}};var ie=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,t){let n=[],o=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=r.type?.toString();this.isClassLikeType(s)&&o.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=N(r.subClassOf);for(let c=0;c<s.length;c++){let p=s[c];if(this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isClassAvailableInImports(e,t,p)){let u=s.length>1?`[${c}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Class '${p}' referenced in subClassOf${u} is not defined or imported`,y.suggestion=`Define '${p}' as a Class, or import a namespace that contains it`,y.entityName=a,y.propertyName="subClassOf",y.actualValue=p,y.expectedValue="Defined or imported class",n.push(y)}}}return n}async isClassAvailableInImports(e,t,n){if(!e.metadata.imports)return!1;let o=null,a=n;if(n.includes(".")){let r=n.split(".",2);o=r[0],a=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){if(o!==null&&s.alias!==o)continue;let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=o!==null?a:n,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isClassLikeType(f))return!0}let u=new Set;if(await this.isClassAvailableInImportsRecursive(c,t,p,u))return!0}}return!1}async isClassAvailableInImportsRecursive(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=c.body[n];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isClassLikeType(u))return!0}if(await this.isClassAvailableInImportsRecursive(c,t,n,o))return!0}}return!1}};var ae=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,t){let n=[],o=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=r.type?.toString();(s==="DatatypeProperty"||s==="ObjectProperty"||s==="AnnotationProperty")&&o.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=N(r.subPropertyOf);for(let c=0;c<s.length;c++){let p=s[c];if(this.builtInProperties.has(p)||o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,t,p)){let u=s.length>1?`[${c}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Property '${p}' referenced in subPropertyOf${u} is not defined or imported`,y.suggestion=`Define '${p}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,y.entityName=a,y.propertyName="subPropertyOf",y.actualValue=p,y.expectedValue="Defined or imported property",n.push(y)}}}return n}async isPropertyAvailableInImports(e,t,n){if(!e.metadata.imports)return!1;let o=null,a=n;if(n.includes(".")){let r=n.split(".",2);o=r[0],a=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){if(o!==null&&s.alias!==o)continue;let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=o!==null?a:n,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(f==="DatatypeProperty"||f==="ObjectProperty"||f==="AnnotationProperty")return!0}let u=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,t,p,u))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=c.body[n];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(c,t,n,o))return!0}}return!1}};var se=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,t){let n=[],o=e.metadata.namespace_?.toString();if(!o)return n;let a=new Map,r=new Set;await this.buildImportGraph(e,t,a,r);let i=this.detectCycle(o,a);if(i){let s=i.join(" \u2192 "),c=new g;c.ruleType=this.ruleName,c.severity="Error",c.message=`Circular namespace import detected: ${s}`,c.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",c.entityName="imports",c.propertyName="imports",c.actualValue=s,n.push(c)}return n}async buildImportGraph(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(!(!a||o.has(a))&&(o.add(a),e.metadata.imports)){let r=[];for(let[i,s]of Object.entries(e.metadata.imports))for(let c of s){let p=`${i}/${c.packageName}@${c.version}`;r.push(p);let l=await t.getHighestCompatibleVersionAsync(i,c);l&&await this.buildImportGraph(l,t,n,o)}r.length>0&&n.set(a,r)}}detectCycle(e,t){let n=[],o=new Set;return this.detectCycleRecursive(e,t,n,o)}detectCycleRecursive(e,t,n,o){let a=n.indexOf(e);if(a>=0){let i=n.slice(a);return i.push(e),i}if(o.has(e))return null;n.push(e),o.add(e);let r=t.get(e);if(r)for(let i of r){let s=this.detectCycleRecursive(i,t,n,o);if(s)return s}return n.pop(),null}};async function Be(m,e,t){return t?t.getKanonaks():new E().parseKanonaks(new M(m,e))}async function pt(m,e,t){let n=await Be(m,e,t),o=Fe(m);return o?n.filter(a=>a instanceof D&&a.namespace===o):[]}function _e(m,e){for(let t of m)t instanceof D&&He(t,t.name,e)}function He(m,e,t){t({kanonak:m,path:e});for(let n of m.statement)if(n instanceof Ze)He(n.object,ct(e,n.object),t);else if(n instanceof Je)for(let o of n.object)o instanceof I&&He(o,ct(e,o),t)}function ct(m,e){let t=e instanceof I&&e.name?e.name:"<embedded>";return`${m}/${t}`}function Fe(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ce=class{ruleName="UnresolvedPredicate";async validateAsync(e,t,n){let o=[],a=Fe(e);if(!a)return o;let r=await Be(e,t,n);return _e(r,({kanonak:i,path:s})=>{for(let c of i.unresolvedPredicates)c.sourceDoc===a&&o.push(this.unresolvedPredicateError(s,c.key))}),o}unresolvedPredicateError(e,t){let n=t.lastIndexOf("."),o=n>0?t.slice(0,n):null,a=n>0?t.slice(n+1):t,r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=t,r.expectedValue="A defined or imported property",r.message=`Property '${t}' is not defined or imported`,r.suggestion=o?`The property '${a}' was not found in the namespace imported as '${o}'.
|
|
14
|
-
1. Check '${a}' is spelled correctly
|
|
15
|
-
2. Verify '${o}' is imported with the right alias and version
|
|
16
|
-
3. Ensure that namespace version actually defines '${a}'`:`The property '${t}' is not defined in this namespace or any imported namespace.
|
|
17
|
-
1. Define '${t}' as an ObjectProperty or DatatypeProperty here, OR
|
|
18
|
-
2. Import the namespace that defines it, OR
|
|
19
|
-
3. Alias-qualify it if it lives in an imported namespace ('alias.${t}')`,r}};var pe=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,t){let n=[],o=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=r.type?.toString();this.isPropertyType(s)&&o.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,s=i.type?.toString();if(!this.isPropertyType(s)&&!this.isClassType(s))continue;for(let[c,p]of Object.entries(i)){if(!c||this.metadataKeys.has(c))continue;let l=c,u=null;if(c.includes(".")){let f=c.lastIndexOf(".");u=c.substring(0,f),l=c.substring(f+1)}if(o.has(l))continue;if(!await this.isPropertyAvailableInImports(e,t,l,u)){let f=this.isClassType(s)?"class":"property",d=new g;d.ruleType=this.ruleName,d.severity="Error",d.message=`Property '${c}' used on ${f} '${a}' is not defined or imported`,d.suggestion=u?`The property '${l}' is not found in the imported namespace with alias '${u}'.
|
|
20
|
-
1. Verify the namespace is imported with the correct alias
|
|
21
|
-
2. Check if the property name is spelled correctly
|
|
22
|
-
3. Ensure the imported namespace version contains this property`:`The property '${c}' is not defined in this namespace or any imported namespace.
|
|
23
|
-
1. Define '${c}' as an ObjectProperty or DatatypeProperty in this namespace, OR
|
|
24
|
-
2. Import the namespace that contains '${c}', OR
|
|
25
|
-
3. Use a qualified reference like 'alias.${c}' if already imported with an alias`,d.entityName=a,d.propertyName=c,d.actualValue=p?.toString(),d.expectedValue="A defined or imported property",n.push(d)}}}return n}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,t,n,o){if(!e.metadata.imports)return!1;for(let[a,r]of Object.entries(e.metadata.imports))for(let i of r){if(o!==null&&i.alias!==o)continue;let s=await t.getHighestCompatibleVersionAsync(a,i);if(s){let c=s.body[n];if(c&&typeof c=="object"&&!Array.isArray(c)){let u=c.type?.toString();if(this.isPropertyType(u))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(s,t,n,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=c.body[n];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isPropertyType(u))return!0}if(await this.isPropertyAvailableInImportsRecursive(c,t,n,o))return!0}}return!1}};var le=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,t){let n=[],o=new Set,a=[];for(let[r,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let s=i,c=!1,p=s.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="DatatypeProperty"){c=!0;break}}else p?.toString()==="DatatypeProperty"&&(c=!0);if(c){a.push(r);let l=this.getPropertyValue(s,"range");l&&this.xsdTypes.has(l)&&o.add(l)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,t)){let i=Array.from(o).sort().join(", "),s=a.sort().join(", "),c=new g;c.ruleType=this.ruleName,c.severity="Error",c.message=`XSD namespace not imported but XSD types are used: ${i}`,c.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${s}`,c.entityName="imports",n.push(c)}return n}async checkXsdImportAsync(e,t,n=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&n.has(o))return!1;o&&n.add(o);for(let[,a]of Object.entries(e.imports))for(let r of a)if(r.packageName==="xsd"||r.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[a,r]of Object.entries(e.imports))for(let i of r){let s=await t.getHighestCompatibleVersionAsync(a,i);if(s?.metadata&&await this.checkXsdImportAsync(s.metadata,t,n))return!0}return!1}getPropertyValue(e,t){return e[t]?.toString()}};var me=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,t){let n=[],{entitySources:o,importPaths:a}=await this.buildEntitySourceMapAsync(e,t),r=await this.buildDatatypePropertyNamesAsync(e,t);for(let[i,s]of Object.entries(e.body))typeof s=="object"&&s!==null&&!Array.isArray(s)&&this.validateEntityReferences(i,s,o,a,r,e,n);return n}async buildEntitySourceMapAsync(e,t){let n=new Map,o=new Set,a=new Map;for(let r of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";n.has(r)||n.set(r,[]),n.get(r).push(`(local:${i})`)}if(e.metadata.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=c.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(c,n,o,a,[p],t)}}return{entitySources:n,importPaths:a}}async collectEntitiesRecursivelyAsync(e,t,n,o,a,r){let i=e.metadata.namespace_?.toString()??"";if(!n.has(i)){n.add(i),o.has(i)||o.set(i,a);for(let s of Object.keys(e.body)){t.has(s)||t.set(s,[]);let c=t.get(s);c.includes(i)||c.push(i)}if(e.metadata.imports)for(let[s,c]of Object.entries(e.metadata.imports))for(let p of c){let l=await r.getHighestCompatibleVersionAsync(s,p);if(l){let u=l.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(l,t,n,o,[...a,u],r)}}}}async buildDatatypePropertyNamesAsync(e,t){let n=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,n,o,t),e.metadata.imports)for(let[a,r]of Object.entries(e.metadata.imports))for(let i of r){let s=await t.getHighestCompatibleVersionAsync(a,i);s&&await this.collectDatatypePropertiesAsync(s,n,o,t)}return n}async collectDatatypePropertiesAsync(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(!n.has(a)){n.add(a);for(let[r,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let s=i.type;if(typeof s!="string")continue;(s.includes(".")?s.substring(s.lastIndexOf(".")+1):s)==="DatatypeProperty"&&t.add(r)}if(e.metadata.imports)for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await o.getHighestCompatibleVersionAsync(r,s);c&&await this.collectDatatypePropertiesAsync(c,t,n,o)}}}validateEntityReferences(e,t,n,o,a,r,i){for(let[s,c]of Object.entries(t)){let p=s;if(p&&!p.includes(".")){let l=n.get(p);if(l&&l.length>1&&!l.some(y=>y.startsWith("(local:"))){let y=l.filter(f=>!f.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,p,`Property '${p}'`,y,o,r,!0,p))}}this.validatePropertyValue(e,p,c,n,o,a,r,i)}}validatePropertyValue(e,t,n,o,a,r,i,s){if(n==null)return;let c=t&&t.includes(".")?t.substring(t.lastIndexOf(".")+1):t,p=!!c&&r.has(c);if(typeof n=="string"&&!n.includes(".")&&!p){let l=o.get(n);if(l&&l.length>1&&!l.some(y=>y.startsWith("(local:"))){let y=l.filter(f=>!f.startsWith("(local:"));y.length>1&&s.push(this.createAmbiguityError(e,t,`Reference '${n}'`,y,a,i,!1,n))}}else if(Array.isArray(n))for(let l=0;l<n.length;l++){let u=`${e}.${t}[${l}]`;this.validatePropertyValue(u,t,n[l],o,a,r,i,s)}else if(typeof n=="object"&&!Array.isArray(n)){let l=t?`${e}.${t}`:e;this.validateEntityReferences(l,n,o,a,r,i,s)}}createAmbiguityError(e,t,n,o,a,r,i,s){let c=[];for(let k of o){let h=this.findAliasForNamespace(r,k);if(h){let v=t?.split(".").pop()??t;c.push(`${h}.${v}`)}}let p=c.length>0?`Use one of: ${c.map(k=>`'${k}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${t}')`,l=o.map(k=>{let h=a.get(k);return!h||h.length===0?` \u2022 ${k}`:h.length===1?` \u2022 ${k} (direct import)`:` \u2022 ${k}
|
|
26
|
-
imported via: ${h.join(" \u2192 ")}`}).join(`
|
|
27
|
-
`),u=e.split(".")[0],y=e.includes(".")?e:t,f=new g;f.ruleType=this.ruleName,f.severity="Error",f.entityName=u,y&&(f.propertyName=y);let d=s??t;return d&&(f.actualValue=d),f.message=`${n} is ambiguous - defined in multiple imported namespaces`,f.suggestion=`${p}
|
|
28
|
-
|
|
29
|
-
Defined in:
|
|
30
|
-
${l}`,f.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",f}findAliasForNamespace(e,t){if(!e.metadata.imports)return null;for(let[n,o]of Object.entries(e.metadata.imports))for(let a of o)if(`${n}/${a.packageName}@${a.version}`===t&&a.alias)return a.alias;return null}};var ye=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","dateTime","date","time","duration","anyURI","anySimpleType","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte","base64Binary","hexBinary","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,t){let n=[],o=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let s=r.type?.toString();this.isValidRangeTargetType(s)&&o.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,s=i.type?.toString();if(s!=="DatatypeProperty"&&s!=="ObjectProperty"&&!s?.endsWith(".DatatypeProperty")&&!s?.endsWith(".ObjectProperty"))continue;let c=i.range;if(!c)continue;let p=[];if(Array.isArray(c))for(let l of c){let u=l?.toString();u&&p.push(u)}else{let l=c?.toString();l&&p.push(l)}if(p.length===0)continue;for(let l of p){if(this.primitiveTypes.has(l)||this.builtInClasses.has(l)||o.has(l))continue;if(!await this.isTypeAvailableInImports(e,t,l)){let y=s?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${a}' has range '${l}' which is not defined or imported`,f.suggestion=y==="ObjectProperty"?`For ObjectProperty:
|
|
31
|
-
1. Define '${l}' as a Class in this namespace, OR
|
|
32
|
-
2. Import the namespace that contains '${l}', OR
|
|
33
|
-
3. Use a qualified reference like 'alias.${l}' if already imported with an alias`:`For DatatypeProperty:
|
|
34
|
-
1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
|
|
35
|
-
2. If '${l}' should be a class, change property type to ObjectProperty`,f.entityName=a,f.propertyName="range",f.actualValue=l,f.expectedValue=y==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",n.push(f)}}}return n}async isTypeAvailableInImports(e,t,n){if(!e.metadata.imports)return!1;let o=null,a=n;if(n.includes(".")){let r=n.split(".",2);o=r[0],a=r[1]}for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){if(o!==null&&s.alias!==o)continue;let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=o!==null?a:n,l=c.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isValidRangeTargetType(f))return!0}let u=new Set;if(await this.isTypeAvailableInImportsRecursive(c,t,p,u))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,t,n,o){let a=e.metadata.namespace_?.toString()??"";if(a&&o.has(a)||(a&&o.add(a),!e.metadata.imports))return!1;for(let[r,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(r,s);if(c){let p=c.body[n];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isValidRangeTargetType(u))return!0}if(await this.isTypeAvailableInImportsRecursive(c,t,n,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var ue=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,t){let n=[],o=new Map,a=new U(t);await a.buildEntityIndexAsync(e);for(let[r,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let s=i,c=!1,p=s.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="ObjectProperty"){c=!0;break}}else p?.toString()==="ObjectProperty"&&(c=!0);if(c){let l=s.range,u=[];if(Array.isArray(l))for(let y of l){let f=y?.toString();f&&u.push(f)}else{let y=l?.toString();y&&u.push(y)}for(let y of u)this.xsdTypes.has(y)||(o.has(y)||o.set(y,[]),o.get(y).push(r))}}for(let[r,i]of o)if(!await a.resolveEntityAsync(r,e))for(let c of i){let p=new g;p.ruleType=this.ruleName,p.severity="Warning",p.message=`ObjectProperty references class '${r}' which may not be imported`,p.suggestion=`Ensure the namespace containing '${r}' is imported, or define '${r}' in this document`,p.entityName=c,p.propertyName="range",p.actualValue=r,n.push(p)}return n}};var fe=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,t){let n=[],o=new U(t),a=new et(o),r=await o.buildEntityIndexAsync(e),i=await this.buildPropertyMetadataAsync(e,t,o,r);for(let[s,c]of Object.entries(e.body))typeof c=="object"&&c!==null&&!Array.isArray(c)&&await this.scanEntityForObjectProperties(c,s,"",i,o,a,e,n);return n}async scanEntityForObjectProperties(e,t,n,o,a,r,i,s){for(let[c,p]of Object.entries(e)){if(this.standardProperties.has(c))continue;let l,u=await a.resolveEntityAsync(c,i);if(u?.uri){let y=`${u.uri.publisher}/${u.uri.package_}/${u.uri.name}`;l=o.get(y)}if(!l){let y=c,f=c.lastIndexOf(".");f>0&&f<c.length-1&&(y=c.substring(f+1)),l=o.get(y)}if(l&&r.isEffectiveObjectProperty(l.propertyType,l.rangeUri)){let f=n?`${n}.${c}`:c;if(typeof p=="string"&&p.trim().length>0){let d=p.trim();if(d.includes(",")){let h=d.split(",").map(v=>v.trim()).filter(v=>v.length>0);s.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
|
|
36
|
-
${c}:
|
|
37
|
-
- ${h[0]}
|
|
38
|
-
${h.slice(1).map(v=>` - ${v}`).join(`
|
|
39
|
-
`)}`,entityName:t,propertyName:c,propertyPath:f,actualValue:d,expectedValue:`A single reference to ${l.range??"an entity"} OR a YAML list`});continue}let k=await a.resolveEntityAsync(d,i);if(k)l.range&&(await this.validateRangeType(k,l.range,a,i)||s.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${c}' expects a ${l.range}, but '${d}' may not be a ${l.range}`,suggestion:`Ensure '${d}' is defined with appropriate type`,entityName:t,propertyName:c,propertyPath:f,actualValue:d,expectedValue:l.range}));else{let h=l.range??"entity";s.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' references '${d}' which is not defined or imported`,suggestion:`Define '${d}' or import a namespace that contains it. Expected range: ${h}`,entityName:t,propertyName:c,propertyPath:f,actualValue:d,expectedValue:"Defined or imported entity"})}}else if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let d=n?`${n}.${c}`:c;await this.scanEntityForObjectProperties(p,t,d,o,a,r,i,s)}else if(Array.isArray(p))for(let d=0;d<p.length;d++){let k=p[d];if(typeof k=="string"&&k.trim().length>0){let h=k.trim(),v=await a.resolveEntityAsync(h,i);if(v){if(l.range&&!await this.validateRangeType(v,l.range,a,i)){let je=n?`${n}.${c}[${d}]`:`${c}[${d}]`;s.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${c}' expects a ${l.range}, but '${h}' may not be a ${l.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:t,propertyName:`${c}[${d}]`,propertyPath:je,actualValue:h,expectedValue:l.range})}}else{let $=l.range??"entity",je=n?`${n}.${c}[${d}]`:`${c}[${d}]`;s.push({ruleType:this.ruleName,severity:"Error",message:`Property '${c}' references '${h}' which is not defined or imported`,suggestion:`Define '${h}' or import a namespace that contains it. Expected range: ${$}`,entityName:t,propertyName:`${c}[${d}]`,propertyPath:je,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof k=="object"&&k!==null&&!Array.isArray(k)){let h=n?`${n}.${c}[${d}]`:`${c}[${d}]`;await this.scanEntityForObjectProperties(k,t,h,o,a,r,i,s)}}}if(typeof p=="object"&&p!==null&&!Array.isArray(p)&&!o.has(c)){let y=n?`${n}.${c}`:c;await this.scanEntityForObjectProperties(p,t,y,o,a,r,i,s)}else if(Array.isArray(p))for(let y=0;y<p.length;y++){let f=p[y];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=n?`${n}.${c}[${y}]`:`${c}[${y}]`;await this.scanEntityForObjectProperties(f,t,d,o,a,r,i,s)}}}}async validateRangeType(e,t,n,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(t))return!0;let r=e.entity.type;if(r){let i=[];if(Array.isArray(r))for(let s of r){let c=s?.toString();c&&c.trim().length>0&&i.push(c)}else{let s=r?.toString();s&&s.trim().length>0&&i.push(s)}for(let s of i){let c=s.includes(".")?s.split(".")[1]:s;if(c===t||t==="Property"&&(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")||t==="Class"&&c==="Class"||await n.isSubclassOfAsync(s,t,o))return!0}}return!1}async buildPropertyMetadataAsync(e,t,n,o){let a=new Map;for(let[r,i]of o){let s=i.entity.type;if(s){let c=[];if(Array.isArray(s))for(let u of s){let y=u?.toString();y&&y.trim().length>0&&c.push(y)}else{let u=s?.toString();u&&u.trim().length>0&&c.push(u)}let p=!1,l="Property";for(let u of c){let y=u.includes(".")?u.split(".")[1]:u;if(y==="Property"||y==="DatatypeProperty"||y==="ObjectProperty"||y==="AnnotationProperty"){p=!0,l=u;break}}if(p){let u={propertyType:l},y=i.entity.range;if(y){let f=y?.toString();if(f&&f.trim().length>0){u.range=f;let d=await n.resolveEntityAsync(f,e);d&&(u.rangeUri=d.uri)}}if(a.set(r,u),i.uri){let f=`${i.uri.publisher}/${i.uri.package_}/${i.uri.name}`;a.set(f,u)}}}}return a}};var de=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,t,n){let o=[],a=new Map;for(let[i,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let c=s,p=this.getPropertyValue(c,"type");(p==="DatatypeProperty"||p?.endsWith(".DatatypeProperty")||p==="ObjectProperty"||p?.endsWith(".ObjectProperty")||p==="AnnotationProperty"||p?.endsWith(".AnnotationProperty"))&&a.set(i,c)}let r=n?await this.buildClassHierarchyViaCache(e,n):await this.buildCompleteClassHierarchyAsync(e,t);for(let[i,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let c=s,p=this.getPropertyValue(c,"type");if(!p||p==="Class"||p.endsWith(".Class")||p.endsWith("Property")||p==="AnnotationProperty")continue;this.validateEntityProperties(c,i,p,a,r,o)}return o}async buildClassHierarchyViaCache(e,t){let n=new Map,o=Vt(e);if(!o)return n;let a=await t.getImportClosure(o);for(let r of a){let i=await t.getClassDeclarations(r);for(let[s,c]of i)c.length>0&&n.set(s,c)}return n}async buildCompleteClassHierarchyAsync(e,t){let n=new Map,o=new Set,a=async(i,s)=>{if(!o.has(s)){o.add(s);for(let[c,p]of Object.entries(i.body))if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let l=p,u=this.getPropertyValue(l,"type");if(u==="Class"||u?.endsWith(".Class")){let y=l.subClassOf;if(y===void 0){for(let d of Object.keys(l))if(d.endsWith(".subClassOf")){y=l[d];break}}let f=N(y);f.length>0&&n.set(c,f)}}if(i.metadata.imports)for(let[c,p]of Object.entries(i.metadata.imports))for(let l of p)try{let u=await t.getHighestCompatibleVersionAsync(c,l);if(u){let y=`${c}/${l.packageName}@${l.version}`;await a(u,y)}}catch{}}},r=e.metadata.namespace_?.toString()??"unknown";return await a(e,r),n}validateEntityProperties(e,t,n,o,a,r){for(let[i,s]of Object.entries(e)){if(this.standardProperties.has(i))continue;let c=i,p=i.lastIndexOf(".");p>0&&p<i.length-1&&(c=i.substring(p+1));let l=o.get(c);if(!l)continue;let u=this.getPropertyValue(l,"domain");if(u){if(!this.isTypeCompatibleWithDomain(n,u,a)){let y=t.split(".")[0];r.push({ruleType:this.ruleName,severity:"Error",entityName:y,propertyName:t,actualValue:i,message:`Property '${i}' has domain '${u}' but is used on '${n}' at '${t}'`,suggestion:`Either:
|
|
40
|
-
1. Use this property only on '${u}' instances
|
|
41
|
-
2. Change the property domain to include '${n}'
|
|
42
|
-
3. Create a different property for '${n}'`,expectedValue:`Property used on ${u} or its subclasses`})}if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let y=s,f=this.getPropertyValue(y,"type");if(f){let d=`${t}.${i}`;this.validateEntityProperties(y,d,f,o,a,r)}else{let d=this.getPropertyValue(l,"range");if(d){let k=`${t}.${i}`;this.validateEntityProperties(y,k,d,o,a,r)}}}else if(Array.isArray(s))for(let y=0;y<s.length;y++){let f=s[y];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=f,k=this.getPropertyValue(d,"type");if(k){let h=`${t}.${i}[${y}]`;this.validateEntityProperties(d,h,k,o,a,r)}else{let h=this.getPropertyValue(l,"range");if(h){let v=`${t}.${i}[${y}]`;this.validateEntityProperties(d,v,h,o,a,r)}}}}}}}isTypeCompatibleWithDomain(e,t,n){if(e===t)return!0;let o=new Set,a=[e];for(;a.length>0;){let r=a.shift();if(o.has(r))continue;o.add(r);let i=n.get(r);if(i)for(let s of i){if(s===t)return!0;a.push(s)}}return!1}getPropertyValue(e,t){if(t in e){let n=e[t];return this.extractFirstValue(n)}for(let n of Object.keys(e))if(n.endsWith(`.${t}`)){let o=e[n];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let t=[];for(let n of e)t.push(n?.toString()??"");return t.length>0?t[0]:void 0}return e?.toString()}};function Vt(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ge=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,t){let n=[],o=new Map;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let i=r,s=this.getPropertyValue(i,"type");(s==="DatatypeProperty"||s==="ObjectProperty")&&o.set(a,i)}for(let[a,r]of Object.entries(e.body)){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r,s=this.getPropertyValue(i,"type");if(!(!s||s==="Class"||s.endsWith("Property")||s==="AnnotationProperty"))for(let[c,p]of Object.entries(i)){if(c==="type"||c==="label"||c==="comment")continue;let l=c,u=c.lastIndexOf(".");u>0&&u<c.length-1&&(l=c.substring(u+1));let y=o.get(l);if(!y)continue;let f=this.getPropertyValue(y,"type"),d=this.getPropertyValue(y,"range");if(f==="DatatypeProperty"){if(typeof p=="object"&&p!==null&&!Array.isArray(p)||Array.isArray(p))n.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:c,message:`Property '${c}' is a DatatypeProperty with range '${d}' but instance '${a}' has a complex object value`,suggestion:`Either:
|
|
43
|
-
1. Create a class for this data and change '${c}' to an ObjectProperty
|
|
44
|
-
2. Store as a JSON string to keep it as DatatypeProperty
|
|
45
|
-
3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${d}'`});else if(!this.validateDatatypeValue(d,p)){let k={ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:c,message:`Property '${c}' expects type '${d}' but instance '${a}' has value of type '${this.getValueTypeName(p)}'`,suggestion:`Provide a value of type '${d}'`,toString:()=>""};d&&(k.expectedValue=d),n.push(k)}}else if(f==="ObjectProperty")if(Array.isArray(p))for(let k=0;k<p.length;k++){let h=p[k];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&n.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:`${c}[${k}]`,message:`ObjectProperty '${c}' array item ${k} in instance '${a}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof p!="string"&&(typeof p!="object"||p===null||Array.isArray(p))&&n.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:c,message:`ObjectProperty '${c}' in instance '${a}' has invalid value type '${this.getValueTypeName(p)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${d} or embedded ${d} object`})}}return n}validateDatatypeValue(e,t){switch(e?.toLowerCase()){case"string":return typeof t=="string";case"integer":case"int":return typeof t=="number"&&Number.isInteger(t);case"decimal":return typeof t=="number";case"boolean":return typeof t=="boolean";case"float":case"double":return typeof t=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,t){if(t in e){let n=e[t];if(Array.isArray(n)){let o=[];for(let a of n)o.push(a?.toString()??"");return o.length>0?o[0]:void 0}return n?.toString()}}};var he=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,t){let n=[],o=new Map,a=new Set;for(let[i,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let p=s.type;if(p)if(Array.isArray(p))for(let l of p){let u=l?.toString();if(u==="Class"||u&&u.endsWith(".Class")){a.add(i);break}}else{let l=p?.toString();(l==="Class"||l&&l.endsWith(".Class"))&&a.add(i)}}for(let[i,s]of Object.entries(e.body))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let c=s,p=c.type;if(p)if(Array.isArray(p)){let l=!1;for(let u of p){let y=u?.toString();if(y&&this.isDefinitionType(y)){l=!0;break}}if(!l)for(let u of p){let y=u?.toString();y&&y.trim().length>0&&(o.has(y)||o.set(y,[]),o.get(y).push(i))}}else{let l=p?.toString();l&&l.trim().length>0&&(this.isDefinitionType(l)||(o.has(l)||o.set(l,[]),o.get(l).push(i)))}this.checkNestedTypes(c,i,o,i)}let r=new U(t);for(let[i,s]of o){if(this.builtInClasses.has(i)||a.has(i))continue;let c=await r.resolveEntityAsync(i,e);if(!(c&&this.isClassEntity(c.entity))){let l=Array.from(new Set(s)).sort();for(let u of l)n.push({ruleType:this.ruleName,severity:"Error",message:`Class '${i}' is not defined or imported`,suggestion:`Define '${i}' as a Class in this document, or import a namespace that contains it`,entityName:u,propertyName:"type",actualValue:i,expectedValue:"Defined or imported class"})}}return n}checkNestedTypes(e,t,n,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let a=e,r=a.type;if(r){let i=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(r))for(let s of r){let c=s?.toString();c&&c.trim().length>0&&!i.has(c)&&(n.has(c)||n.set(c,[]),n.get(c).push(o))}else{let s=r?.toString();s&&s.trim().length>0&&!i.has(s)&&(n.has(s)||n.set(s,[]),n.get(s).push(o))}}for(let[i,s]of Object.entries(a))if(i!=="type"){let c=`${o}.${i}`;this.checkNestedTypes(s,t,n,c)}}else if(Array.isArray(e))for(let a=0;a<e.length;a++){let r=`${o}[${a}]`;this.checkNestedTypes(e[a],t,n,r)}}isClassEntity(e){if(!e)return!1;let t=e.type;if(!t)return!1;if(Array.isArray(t))for(let n of t){let o=n?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let n=t?.toString();if(n==="Class"||n&&n.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var ke=class{ruleName="MarkdownLink";async validateAsync(e,t,n){let o=[],a=await pt(e,t,n);return _e(a,({kanonak:r,path:i})=>{this.checkNode(r,i,o)}),o}checkNode(e,t,n){for(let o of e.statement){if(!(o instanceof Qe))continue;let a=o.predicate.subject?.name??"(unknown)";for(let r of o.links)r.target||n.push(this.unresolvedLinkError(t,a,r.reference));for(let r of tt(o.object))n.push(this.malformedLinkError(t,a,r.snippet))}}unresolvedLinkError(e,t,n){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=t,o.actualValue=n,o.message=`Embedded link [[${n}]] in '${t}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${n}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
46
|
-
|
|
47
|
-
Possible solutions:
|
|
48
|
-
\u2022 Import the package that defines '${n}' so the link can resolve
|
|
49
|
-
\u2022 Check for typos in the reference name
|
|
50
|
-
\u2022 If the name collides across imports, alias-qualify it: [[alias.${n}]]`,o}malformedLinkError(e,t,n){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=t,o.actualValue=n,o.message=`Malformed embedded reference near '${n}' in '${t}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${t}' does not form a complete [[reference]] link.
|
|
51
|
-
|
|
52
|
-
A reference may not span a line break \u2014 the most common cause is wrapping a
|
|
53
|
-
long reference across two lines in a block scalar, e.g.:
|
|
54
|
-
... read for [[persistent-energy-
|
|
55
|
-
shock]] held ...
|
|
56
|
-
which is parsed as literal text, not a link. Keep each [[reference]] on one
|
|
57
|
-
line (let the line run long), or check for an unterminated [[.`,o}};var lt="kanonak.org",mt="look",Pt={publisher:lt,package_:mt,name:"displayLabel"},Dt={publisher:lt,package_:mt,name:"displaySummary"},be=class{ruleName="DisplayLensScope";async validateAsync(e,t,n){let o=[],a;n?a=await n.getKanonaks():a=await new E().parseKanonaks(new M(e,t));let r=It(e);if(!r)return o;for(let i of a)i instanceof D&&i.namespace===r&&(this.checkLens(a,i,Pt,"displayLabel",o),this.checkLens(a,i,Dt,"displaySummary",o));return o}checkLens(e,t,n,o,a){let r=V(t,n);if(!r)return;let i=[],s=W(t);if(s&&i.push(s),i.push(...rt(t)),i.length===0)return;i.some(p=>x(e,p,r).ok)||a.push(this.scopeError(t.name,o,r.name))}scopeError(e,t,n){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=t,o.actualValue=n,o.message=`${t} points at '${n}', which is not a property in scope for '${e}'`,o.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",o.suggestion=`'${n}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
|
|
58
|
-
|
|
59
|
-
Possible solutions:
|
|
60
|
-
\u2022 Point ${t} at a property declared on this class (or an ancestor / rdfs.Resource)
|
|
61
|
-
\u2022 Set the property's domain to this class if it should apply here
|
|
62
|
-
\u2022 Use rdfs.label / rdfs.comment for the universal default`,o}};function It(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}function F(m,e,t){let n=[];return Ke(m,t,{input:e},n),n}function Ke(m,e,t,n){if(A(e,_.VarRef)){let r=L(e,_.varName);return r?t[r]:void 0}if(A(e,_.PropertyRead)){let r=O(e,_.readSource),i=r?Ke(m,r,t,n):void 0,s=V(e,_.readProp);if(!i||!s)return;let c=x(m,i,s);if(!c.ok){n.push({contextClass:i,propertyUri:s,via:"PropertyRead"});return}return c.descriptor?.range}if(A(e,_.Traverse)){let r=O(e,_.traverseSource),i=r?Ke(m,r,t,n):void 0,s=V(e,_.through),c;if(i&&s){let l=x(m,i,s);l.ok?c=l.descriptor?.range:n.push({contextClass:i,propertyUri:s,via:"Traverse"})}let p=O(e,_.step);return p?Ke(m,p,{...t,input:c},n):void 0}let o=L(e,_.loopVar),a=o?{...t,[o]:void 0}:t;for(let r of Et(e))Ke(m,r,a,n)}function Et(m){let e=[];for(let t of m.statement){let n=t.object;if(n instanceof I)e.push(n);else if(Array.isArray(n))for(let o of n)o instanceof I&&e.push(o)}return e}var $e="kanonak.org",Ce="look",At={publisher:$e,package_:Ce,name:"semanticSvg"},Ot={publisher:$e,package_:Ce,name:"tierChip"},St={publisher:$e,package_:Ce,name:"tierIcon"},Kt={publisher:$e,package_:Ce,name:"tierCard"},$t={publisher:$e,package_:Ce,name:"tierFull"},Ct=[Ot,St,Kt,$t],Re=class{ruleName="LookSemanticSvgPath";async validateAsync(e,t,n){let o=[],a;n?a=await n.getKanonaks():a=await new E().parseKanonaks(new M(e,t));let r=wt(e);if(!r)return o;for(let i of a)i instanceof D&&i.namespace===r&&this.checkSemanticSvg(a,i,o);return o}checkSemanticSvg(e,t,n){let o=O(t,At);if(!o)return;let a=W(t);if(a)for(let r of Ct){let i=O(o,r);if(i)for(let s of F(e,a,i))n.push(this.toError(t.name,r.name,s))}}toError(e,t,n){let o=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,r=a===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${a}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${t}`,i.actualValue=o,i.message=`tx.${n.via} reads property '${n.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${r}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${a}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${o}' is not in scope for '${a}'.
|
|
63
|
-
|
|
64
|
-
Possible solutions:
|
|
65
|
-
\u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
|
|
66
|
-
\u2022 If the property should apply to '${a}', adjust its domain
|
|
67
|
-
\u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function wt(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var jt="kanonak.org",R=(m,e)=>({publisher:jt,package_:m,name:e}),Nt=R("derivation","look"),xt=R("look","bands"),Tt=R("look","Distribution"),_t=R("look","StatRow"),Ut=R("look","VersionDelta"),Lt=R("look","Timeline"),Mt=R("look","VersionDiff"),Wt=R("look","TimePlot"),Ht=R("look","ReferenceList"),Bt=R("look","Diagram"),Ft=R("look","alphaPath"),Xt=R("look","betaPath"),Xe=R("look","metricPath"),yt=R("look","lowerPath"),ut=R("look","upperPath"),ft=R("look","hueBy"),qt=R("look","statPath"),zt=R("look","laneBy"),dt=R("look","labelPath"),Yt=R("look","badgePath"),Gt=R("look","mapPath"),Zt=R("look","nodeNote"),Jt=R("look","edgeValue"),Qt=R("look","stats"),en=R("look","facets"),tn=R("look","channels"),nn=R("look","track"),on=R("look","source"),rn=R("look","relation"),an=R("look","entries"),we=class{ruleName="LookBandPath";async validateAsync(e,t,n){let o=[],a;n?a=await n.getKanonaks():a=await new E().parseKanonaks(new M(e,t));let r=cn(e);if(!r)return o;for(let i of a)i instanceof D&&i.namespace===r&&this.checkDeclaration(a,i,o);return o}checkDeclaration(e,t,n){let o=O(t,Nt);if(!o)return;let a=W(t);if(!a)return;let r=S(o,xt).filter(i=>i instanceof I);for(let i of r)for(let s of this.carriersOf(e,i,a))for(let c of F(e,s.context,s.expr))n.push(this.toError(t.name,s.slot,c))}carriersOf(e,t,n){let o=[],a=(r,i)=>{let s=O(t,r);s&&o.push({slot:`look.${r.name}`,context:i,expr:s})};if(A(t,Tt))for(let r of[Ft,Xt,Xe,yt,ut,ft])a(r,n);if(A(t,Ut)&&a(Xe,n),A(t,_t)){let r=S(t,Qt).filter(i=>i instanceof I);for(let i of r){let s=O(i,qt);s&&o.push({slot:"look.stats[].statPath",context:n,expr:s})}}if(A(t,Lt)||A(t,Mt)){let r=this.rangeOf(e,n,V(t,nn));if(r)for(let i of[Xe,yt,ut,ft])a(i,r)}if(A(t,Wt)){let r=this.rangeOf(e,n,V(t,on));if(r)for(let i of[zt,dt])a(i,r)}if(A(t,Ht))for(let r of S(t,an)){let i=r instanceof I?void 0:sn(r),s=this.rangeOf(e,n,i);if(s)for(let c of[dt,Yt])a(c,s)}if(A(t,Bt)){let r=S(t,en).filter(i=>i instanceof I);for(let i of r){let s=this.rangeOf(e,n,V(i,rn));if(!s)continue;let c=O(i,Zt);c&&o.push({slot:"look.facets[].nodeNote",context:s,expr:c});let p=O(i,Jt);p&&o.push({slot:"look.facets[].edgeValue",context:s,expr:p});let l=S(i,tn).filter(u=>u instanceof I);for(let u of l){let y=O(u,Gt);y&&o.push({slot:"look.facets[].channels[].mapPath",context:s,expr:y})}}}return o}rangeOf(e,t,n){if(!n)return;let o=x(e,t,n);return o.ok?o.descriptor?.range:void 0}toError(e,t,n){let o=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=o,r.message=`tx.${n.via} reads property '${n.propertyUri.name}', but its domain is not in scope for '${a}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,r.expectedValue=`A property whose domain is '${a}', an ancestor, or rdfs.Resource`,r.suggestion=`Property '${o}' is not in scope for '${a}'.
|
|
68
|
-
|
|
69
|
-
Possible solutions:
|
|
70
|
-
\u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
|
|
71
|
-
\u2022 If the property should apply to '${a}', adjust its domain
|
|
72
|
-
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,r}};function sn(m){let e=m.subject;return e&&typeof e.name=="string"?e:void 0}function cn(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var Ve="kanonak.org",Pe="view",pn={publisher:Ve,package_:Pe,name:"bind"},ln={publisher:Ve,package_:Pe,name:"produces"},mn={publisher:Ve,package_:Pe,name:"projections"},yn={publisher:Ve,package_:Pe,name:"where"},un={publisher:Ve,package_:Pe,name:"value"},fn={publisher:Ve,package_:Pe,name:"as"},ve=class{ruleName="TxExpressionPath";async validateAsync(e,t,n){let o=[],a;n?a=await n.getKanonaks():a=await new E().parseKanonaks(new M(e,t));let r=hn(e);if(!r)return o;for(let i of a)i instanceof D&&i.namespace===r&&this.checkView(a,i,o);return o}checkView(e,t,n){let o=V(t,pn);if(!o)return;let a=V(t,ln),r=0;for(let s of gn(e,S(t,mn))){let c=O(s,un);if(c)for(let l of F(e,o,c))n.push(this.toError(t.name,`view.projections[${r}].value`,o,l));let p=V(s,fn);p&&a&&(x(e,a,p).ok||n.push(this.asError(t.name,r,a,p))),r+=1}let i=0;for(let s of dn(t,yn)){for(let c of F(e,o,s))n.push(this.toError(t.name,`view.where[${i}]`,o,c));i+=1}}asError(e,t,n,o){let a=`${o.publisher}/${o.package_}/${o.name}`,r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=`view.projections[${t}].as`,r.actualValue=a,r.message=`Projection stores its value under property '${o.name}', but that property's domain is not in scope for the view's produces class '${n.name}'. The materialized result instance could not carry this value.`,r.expectedValue=`A property whose domain is '${n.name}', an ancestor, or rdfs.Resource`,r.suggestion=`Property '${a}' is not in scope for produces class '${n.name}'.
|
|
73
|
-
|
|
74
|
-
Possible solutions:
|
|
75
|
-
\u2022 Use an output property whose domain covers '${n.name}'
|
|
76
|
-
\u2022 Define a new property in the ViewPackage with domain '${n.name}' and the right range
|
|
77
|
-
\u2022 If the value belongs on a different output class, adjust the view's produces`,r}toError(e,t,n,o){let a=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,i=r===n.name?`the view's bound class '${n.name}'`:`'${r}', reached by traversal from the view's bound class '${n.name}'`,s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=t,s.actualValue=a,s.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for ${i}. The read would silently return undefined when the view materializes.`,s.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,s.suggestion=`Property '${a}' is not in scope for '${r}'.
|
|
78
|
-
|
|
79
|
-
Possible solutions:
|
|
80
|
-
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
81
|
-
\u2022 If the property should apply to '${r}', adjust its domain
|
|
82
|
-
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,s}};function dn(m,e){let t=O(m,e);return t?[t]:S(m,e).filter(n=>n instanceof I)}function gn(m,e){let t=[];for(let n of e)if(n instanceof I)t.push(n);else if(n instanceof H){let o=T(m,n.subject);o&&t.push(o)}return t}function hn(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var Ue="kanonak.org",kn="core-shacl",K=m=>({publisher:Ue,package_:kn,name:m}),bn=K("NodeShape"),Rn=K("PropertyShape"),vn=K("targetClass"),Vn=K("property"),Pn=K("path"),Dn=K("minCount"),In=K("maxCount"),En=K("datatype"),An=K("class"),gt=K("in"),On=K("pattern"),Sn=K("flags"),Kn=K("minLength"),$n=K("maxLength"),Cn=K("minInclusive"),wn=K("maxInclusive"),jn=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),qe=m=>m,Ie=class{ruleName="ShaclShape";async validateAsync(e,t,n){let o=[],a=n?await n.getKanonaks():await new E().parseKanonaks(t),r=Nn(e);if(!r)return o;let i=new Set;for(let s of a){if(!(s instanceof D)||s.namespace!==r||!A(s,bn))continue;let c=V(s,vn);c?this.resolvesToClass(a,c)||o.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' sh:targetClass '${c.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(c))):o.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let p of S(s,Vn)){let l;if(p instanceof I)l=p;else if(p instanceof H){let u=T(a,p.subject);u&&(l=u,i.add(C(p.subject)))}l&&this.checkPropertyShape(a,s.name,l,c??void 0,o)}}for(let s of a){if(!(s instanceof D)||s.namespace!==r||!A(s,Rn))continue;let c=W(s);c&&i.has(C(c))||this.checkPropertyShape(a,s.name,s,void 0,o)}return o}checkPropertyShape(e,t,n,o,a){let r=V(n,Pn);if(!r){a.push(this.err(t,"property.path","Error",`A PropertyShape on '${t}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=T(e,r),s=i?B.isAnyPropertyType(qe(i)):!1;s?o&&(x(e,o,r).ok||a.push(this.err(t,"property.path","Warning",`sh:path '${r.name}' is not in scope for sh:targetClass '${o.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${o.name}', an ancestor, or rdfs.Resource.`,X(r)))):a.push(this.err(t,"property.path","Error",`sh:path '${r.name}' on '${t}' does not resolve to a property.`,"Reference a defined or imported property.",X(r)));let c=V(n,En),p=V(n,An);c&&p&&a.push(this.err(t,"property","Error",`A PropertyShape on '${t}' sets both sh:datatype and sh:class; a value is a literal or a node, not both.`,"Keep sh:datatype (literal values) or sh:class (node values), not both.")),c&&!this.resolvesToDatatype(e,c)&&a.push(this.err(t,"datatype","Error",`sh:datatype '${c.name}' on '${t}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",X(c))),p&&!this.resolvesToClass(e,p)&&a.push(this.err(t,"class","Error",`sh:class '${p.name}' on '${t}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(p)));let l=De(w(n,Dn)),u=De(w(n,In));this.checkOrder(t,"minCount",l,"maxCount",u,a);let y=De(w(n,Kn)),f=De(w(n,$n));this.checkOrder(t,"minLength",y,"maxLength",f,a);let d=De(w(n,Cn)),k=De(w(n,wn));this.checkOrder(t,"minInclusive",d,"maxInclusive",k,a);let h=L(n,On);if(h!==void 0){let v=L(n,Sn);try{new RegExp(h,v)}catch{a.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(v!==void 0?` (with flags '${v}')`:"")+`: ${h}`,"Provide a valid regular expression and flags.",h))}}if(xe(n,gt)&&S(n,gt).length===0&&a.push(this.err(t,"in","Error",`sh:in on '${t}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),s&&o){let $=x(e,o,r).descriptor;$&&((h!==void 0||y!==void 0||f!==void 0)&&$.kind==="object"&&a.push(this.err(t,"pattern/minLength/maxLength","Warning",`String facets on '${t}' apply to '${r.name}', which is an object property; string facets constrain literal values.`,"Apply string facets to a datatype property, or use sh:class for node values.",X(r))),(d!==void 0||k!==void 0)&&!this.isNumericDatatypeRange($.range)&&a.push(this.err(t,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${t}' apply to '${r.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",X(r))))}}checkOrder(e,t,n,o,a,r){n!==void 0&&a!==void 0&&n>a&&r.push(this.err(e,`${t}/${o}`,"Error",`${t} (${n}) exceeds ${o} (${a}) on '${e}'.`,`Set ${t} <= ${o}.`))}resolvesToClass(e,t){let n=T(e,t);return n?B.isClassType(qe(n)):!1}resolvesToDatatype(e,t){if(t.publisher===Ue&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let n=T(e,t);return n?B.isDatatypeType(qe(n)):!1}isNumericDatatypeRange(e){return!e||e.publisher===Ue&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===Ue&&e.package_==="core-xsd"&&jn.has(e.name)}err(e,t,n,o,a,r){let i=new g;return i.ruleType=this.ruleName,i.severity=n,i.entityName=e,i.propertyName=t,i.message=o,i.suggestion=a,r!==void 0&&(i.actualValue=r),i}};function De(m){return typeof m=="number"?m:void 0}function X(m){return`${m.publisher}/${m.package_}/${m.name}`}function Nn(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ht={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},xn=m=>m,Ee=class{ruleName="OwlOneOf";async validateAsync(e,t,n){let o=[],a=n?await n.getKanonaks():await new E().parseKanonaks(t),r=Tn(e);if(!r)return o;for(let i of a){if(!(i instanceof D)||i.namespace!==r||!xe(i,ht))continue;let s=S(i,ht);if(s.length===0){o.push(this.err(i.name,"Warning",`owl:oneOf on '${i.name}' is empty; a closed enumeration must list at least one individual.`,"List the individuals that make up the enumeration, or remove owl:oneOf."));continue}for(let c of s)if(c instanceof Ne)o.push(this.err(i.name,"Error",`owl:oneOf member '${String(c.value)}' on '${i.name}' is not a named individual; a class enumeration is of individuals (a misspelled or unimported individual reads as a literal). For a closed set of literal VALUES, constrain a property with sh:in instead.`,"Reference a defined or imported individual, or move literal value sets to a property sh:in.",String(c.value)));else if(c instanceof H){let p=T(a,c.subject);p&&B.isSchemaDefinitionType(xn(p))&&o.push(this.err(i.name,"Error",`owl:oneOf member '${c.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${c.subject.publisher}/${c.subject.package_}/${c.subject.name}`))}}return o}err(e,t,n,o,a){let r=new g;return r.ruleType=this.ruleName,r.severity=t,r.entityName=e,r.propertyName="oneOf",r.message=n,r.suggestion=o,a!==void 0&&(r.actualValue=a),r}};function Tn(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var _n="kanonak.org",Un="core-shacl",j=m=>({publisher:_n,package_:Un,name:m}),Ln=j("NodeShape"),Mn=j("targetClass"),Wn=j("property"),Hn=j("path"),Bn=j("minCount"),Fn=j("maxCount"),Xn=j("in"),qn=j("pattern"),zn=j("flags"),Yn=j("minLength"),Gn=j("maxLength"),Zn=j("minInclusive"),Jn=j("maxInclusive"),Qn=j("message");function Ae(m){return typeof m=="number"?m:void 0}function eo(m){let e={},t=Ae(w(m,Bn)),n=Ae(w(m,Fn));t!==void 0&&(e.minCount=t),n!==void 0&&(e.maxCount=n);let o=Ae(w(m,Yn)),a=Ae(w(m,Gn));o!==void 0&&(e.minLength=o),a!==void 0&&(e.maxLength=a);let r=Ae(w(m,Zn)),i=Ae(w(m,Jn));r!==void 0&&(e.minInclusive=r),i!==void 0&&(e.maxInclusive=i);let s=L(m,qn);if(s!==void 0){let l=L(m,zn);e.pattern=l!==void 0?{regex:s,flags:l}:{regex:s}}let c=S(m,Xn).filter(l=>l instanceof Ne).map(l=>l.value);c.length>0&&(e.enumValues=c);let p=L(m,Qn);return p!==void 0&&(e.message=p),e}function to(m,e){let t=[];for(let n of S(e,Wn))if(n instanceof I)t.push(n);else if(n instanceof H){let o=T(m,n.subject);o&&t.push(o)}return t}function kt(m){let e=new Map;for(let t of m){if(!(t instanceof D)||!A(t,Ln))continue;let n=V(t,Mn);if(!n)continue;let o=C(n);for(let a of to(m,t)){let r=V(a,Hn);if(!r)continue;let i={pathKey:C(r),constraints:eo(a)},s=e.get(o);s?s.push(i):e.set(o,[i])}}return e}function no(m,e){e.minCount!==void 0&&(m.minCount=e.minCount),e.maxCount!==void 0&&(m.maxCount=e.maxCount),e.minLength!==void 0&&(m.minLength=e.minLength),e.maxLength!==void 0&&(m.maxLength=e.maxLength),e.minInclusive!==void 0&&(m.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(m.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(m.pattern=e.pattern),e.enumValues!==void 0&&(m.enumValues=e.enumValues),e.message!==void 0&&(m.message=e.message)}function bt(m,e,t){let n=C(t),o=!1,a={};for(let r=e.length-1;r>=0;r--){let i=m.get(C(e[r]));if(i)for(let s of i)s.pathKey===n&&(o=!0,no(a,s.constraints))}if(o)return a.cardinality=a.maxCount===1?"single":"list",a.required=(a.minCount??0)>=1,a}var oo=m=>m,ro=new Ge("kanonak.org","core-rdf","Resource"),Oe=class{ruleName="DiamondNameClash";async validateAsync(e,t,n){let o=[],a=n?await n.getKanonaks():await new E().parseKanonaks(t),r=io(e);if(!r)return o;let i=kt(a);for(let s of a){if(!(s instanceof D)||s.namespace!==r||!B.isClassType(oo(s)))continue;let c=W(s);if(!c)continue;let p=nt(a,c),l=C(c),u=new Set(p.map(f=>C(f)));u.delete(l),u.delete(C(ro));let y=new Map;for(let f of ot(a,c)){if(!f.domains.some(h=>u.has(C(h))))continue;let k=y.get(f.uri.name);k?k.push(f):y.set(f.uri.name,[f])}for(let[f,d]of y){if(d.length<2)continue;let k=$=>bt(i,p,$.uri)?.cardinality,h=new Set(d.map($=>$.range?C($.range):void 0).filter($=>$!==void 0)),v=new Set(d.map(k).filter($=>$!==void 0));h.size<=1&&v.size<=1||o.push(this.toError(s.name,f,d,k))}}return o}toError(e,t,n,o){let a=s=>{let c=`${s.uri.publisher}/${s.uri.package_}/${s.uri.name}`,p=s.range?`${s.range.publisher}/${s.range.package_}/${s.range.name}`:"no range",l=o(s);return`${c} (range ${p}${l?`, ${l}`:""})`},r=n.map(a).join("; "),i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=t,i.actualValue=r,i.message=`Class '${e}' inherits ${n.length} distinct properties named '${t}' with incompatible range or cardinality: ${r}. The generated interface would multiply-inherit '${t}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${t}':
|
|
83
|
-
\u2022 rename one of the properties, or
|
|
84
|
-
\u2022 re-domain one so it is not inherited by '${e}', or
|
|
85
|
-
\u2022 restructure the hierarchy so '${e}' inherits only one '${t}', or
|
|
86
|
-
\u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function io(m){let e=m.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var ze=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new Ye,this.documentRules=[new z,new Y,new G,new Z,new J],this.repositoryRules=[new Q,new ee,new te,new ne,new oe,new re,new ie,new ae,new se,new ce,new pe,new le,new me,new ye,new ue,new fe,new de,new ge,new he,new ke,new be,new Re,new we,new ve,new Ie,new Ee,new Oe]}async validateAsync(e,t,n){let o=new q;for(let a of this.documentRules)try{let r=a.validate(e);this.addErrorsToResult(o,r)}catch(r){let i=new g;i.ruleType=a.ruleName,i.severity="Error",i.message=`Validation rule '${a.ruleName}' failed: ${r instanceof Error?r.message:String(r)}`,o.errors.push(i)}if(t){let a=[],r=n?.repository??t;for(let i of this.repositoryRules)try{let s=await i.validateAsync(e,r,n);this.addErrorsToResult(o,s)}catch(s){let c=s instanceof Error?s.message:String(s);a.push({ruleName:i.ruleName,cause:c})}if(a.length>0){let i=new Map;for(let{ruleName:s,cause:c}of a){let p=i.get(c);p?p.push(s):i.set(c,[s])}for(let[s,c]of i){let p=new g;p.ruleType=c[0],p.severity="Error",c.length===1?p.message=`Validation rule '${c[0]}' failed: ${s}`:p.message=`${s} (affects ${c.length} rules: ${c.join(", ")})`,o.errors.push(p)}}}return o.isValid=o.errors.length===0,o}async validateDocumentsAsync(e,t){let n=new Se(t),o=[];for(let a of e){let r=await this.validateAsync(a,n.repository,n);o.push({document:a,result:r})}return o}async validateYamlAsync(e,t,n){let o=this.parser.parseWithErrors(e);if(!o.isValid){let a=new q;a.isValid=!1;for(let r of o.errors){let i=new g;i.ruleType="ParseError",i.severity="Error",i.lineNumber=r.line,i.column=r.column,i.message=r.message,r.keyName&&(i.entityName=r.keyName),r.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),a.errors.push(i)}return a}return await this.validateAsync(o.document,t,n)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let t=this.documentRules.findIndex(n=>n instanceof e);t>=0&&this.documentRules.splice(t,1)}removeRepositoryRule(e){let t=this.repositoryRules.findIndex(n=>n instanceof e);t>=0&&this.repositoryRules.splice(t,1)}addErrorsToResult(e,t){for(let n of t)n.severity==="Error"?e.errors.push(n):this.includeWarnings&&e.warnings.push(n)}};export{q as a,b,g as c,Le as d,Se as e,z as f,Y as g,G as h,Z as i,J as j,Q as k,ee as l,te as m,ne as n,oe as o,re as p,ie as q,ae as r,se as s,ce as t,pe as u,le as v,me as w,ye as x,ue as y,fe as z,de as A,ge as B,he as C,ke as D,be as E,Re as F,ve as G,Ie as H,Ee as I,kt as J,bt as K,Oe as L,ze as M};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
2
|
-
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
3
|
-
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
4
|
-
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
5
|
-
export declare class DefinitionPropertyReferenceRule implements IRepositoryValidationRule {
|
|
6
|
-
private readonly metadataKeys;
|
|
7
|
-
get ruleName(): string;
|
|
8
|
-
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
|
|
9
|
-
private isPropertyType;
|
|
10
|
-
private isClassType;
|
|
11
|
-
private isPropertyAvailableInImports;
|
|
12
|
-
private isPropertyAvailableInImportsRecursive;
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
2
|
-
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
3
|
-
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
4
|
-
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
5
|
-
export declare class ObjectPropertyImportRule implements IRepositoryValidationRule {
|
|
6
|
-
private readonly xsdTypes;
|
|
7
|
-
get ruleName(): string;
|
|
8
|
-
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
|
|
9
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
2
|
-
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
3
|
-
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
4
|
-
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
5
|
-
export declare class PropertyValueTypeRule implements IRepositoryValidationRule {
|
|
6
|
-
get ruleName(): string;
|
|
7
|
-
validateAsync(document: KanonakDocument, _repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
|
|
8
|
-
private validateDatatypeValue;
|
|
9
|
-
private getValueTypeName;
|
|
10
|
-
private getPropertyValue;
|
|
11
|
-
}
|