@kanonak-protocol/sdk 5.20.0 → 5.22.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.
@@ -1,63 +0,0 @@
1
- import{a as lt}from"./chunk-M443OYKT.js";import{a as I,b as Fe,c as at,d as G,h as M,k as pt,m as S}from"./chunk-V6KIDED2.js";import{a as nt}from"./chunk-NJ3AZYQD.js";import{j as We,k as it,o as v,p as w,q as z,r as H,s as W,v as st,w as L,x as ct}from"./chunk-SVUMCLK5.js";import{c as f,d as D,j as He,k as Q,l as Y,m as R,n as X,p as P,r as k,t as ee,u as x,v as F,w as y,x as $,y as b,z as q}from"./chunk-YW6P24RF.js";import{a as rt}from"./chunk-FUUTGGJS.js";import{e as U}from"./chunk-2ACBWC7K.js";var te=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var g=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(g||{});var u=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 Xe=class c{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new c;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var oe=class{constructor(e){this.underlying=e;this.repository=new Ze(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await lt(e,this.repository);let t={};return{merged:await new S().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},Ze=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 o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}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)}};async function E(c,e,t){return t?t.getKanonaks():new S().parseKanonaks(new ne(c,e))}async function C(c,e,t){let o=await E(c,e,t),n=Ge(c);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function re(c,e,t){let o=Ge(c);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new S().parseKanonaks(new ne(c,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function Ge(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var ne=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};var ae=class c{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[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&c.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],p=new u;p.ruleType=this.ruleName,p.severity="Error",p.entityName=s,p.propertyName=e,p.actualValue=n,p.expectedValue=i,p.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,p.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(p)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}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 o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ie=class c{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=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=c.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&c.RESERVED_WORDS.has(n.toLowerCase())){let i=new u;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' 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(!a&&!c.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.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 u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!c.VALID_PROPERTIES.has(n)&&!c.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new u;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var se=class c{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 o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let p of i){let l=p?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let p=i?.toString();p&&p==="Property"&&!o&&s.push(p)}for(let p of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),d=new u;d.ruleType=this.ruleName,d.severity="Error",d.entityName=n,d.propertyName="type",d.actualValue=p,d.expectedValue=m,d.message=`Invalid property type '${p}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(d)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":c.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ce=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' 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 $t=new Set(["EphemeralPackage"]),pe=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let o=[],n=this.packageKey(e,t.type_);return t.namespace_?(!$t.has(t.type_)&&!t.namespace_.version&&o.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
5
- version: 1.0.0`)),o):(o.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
6
- publisher: example.org`)),o)}packageKey(e,t){for(let[o,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===t)return o;return t}error(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.message=o,r.suggestion=n,r}};var Ut={publisher:"kanonak.org",package_:"core-rdf",name:"type"},wt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},At={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},xt={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},le=class{ruleName="EmbeddedKanonakType";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await re(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof Q){let a=r.predicate?.subject,i=`${o}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,o,i,n),this.walk(e,r.object,i,n)}else if(r instanceof Y){let a=r.predicate?.subject,i=0;for(let s of r.object){if(s instanceof I){let p=`${o}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,s,o,p,n),this.walk(e,s,p,n)}i++}}}check(e,t,o,n,r,a){if(!t)return;let i=y(o,Ut);if(!i)return;let s=k(e,t);if(!s)return;let p=y(s,wt);if(p&&!(X(p,At)||X(p,xt))){if(R(i)===R(p)){a.push(this.redundant(n,r,i,p));return}z(e,i).some(l=>R(l)===R(p))||a.push(this.notSubclass(n,r,i,p))}}redundant(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' declares 'type: ${o.name}', which equals the parent property's range '${n.name}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,r.suggestion=`Remove the 'type: ${o.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' has 'type: ${o.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${o.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${o.name}' class definition so the relationship holds.`,r}};import{VersionOperator as Ye}from"@kanonak-protocol/types/document/models/enums";var me=class{ruleName="ImportExistence";async validateAsync(e,t){let o=[];if(!e.metadata?.imports)return o;let n=await t.getAllDocumentsAsync();for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a)if(!await t.getHighestCompatibleVersionAsync(r,i)){let p=await this.determineImportErrorAsync(t,r,i,n),l=new u;l.ruleType=this.ruleName,l.severity="Error",l.message=p.message,l.suggestion=p.suggestion,l.entityName=`Import: ${r}/${i.packageName}`,l.actualValue=i.toString(),l.expectedValue=p.expectedValue,o.push(l)}return o}async determineImportErrorAsync(e,t,o,n){let r=await e.getDocumentsByNamespaceAsync(t,o.packageName);if(r.length===0){let p=n.filter(h=>h.metadata.namespace_?.publisher===t).map(h=>h.metadata.namespace_.package_).filter((h,V,T)=>T.indexOf(h)===V),l=this.findSimilarPackages(o.packageName,p),m=`Import '${t}/${o.package_}' not found - package does not exist`,d=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:p.length>0?`Available packages in ${t}: ${p.slice(0,5).join(", ")}`:`No packages found for publisher '${t}'. Verify the publisher name is correct.`;return{message:m,suggestion:d,expectedValue:"Existing package"}}let i=r.filter(p=>p.metadata.namespace_?.version).map(p=>p.metadata.namespace_.version.toString()).sort().join(", "),s=this.getAcceptableVersionRange(o);return{message:`Import '${t}/${o.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${s}`,expectedValue:s}}getAcceptableVersionRange(e){switch(e.versionOperator){case Ye.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Ye.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Ye.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Ye.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 o=t.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(o.length>0)return o.sort((a,i)=>a.length-i.length);let n=t.map(a=>({package:a,distance:this.levenshteinDistance(e.toLowerCase(),a.toLowerCase())})).sort((a,i)=>a.distance-i.distance),r=Math.max(3,Math.floor(e.length*.4));return n.filter(a=>a.distance<=r).map(a=>a.package)}levenshteinDistance(e,t){if(!e||e.length===0)return t?.length??0;if(!t||t.length===0)return e.length;let o=e.length,n=t.length,r=Array(o+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=o;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=o;a++)for(let i=1;i<=n;i++){let s=e[a-1]===t[i-1]?0:1;r[a][i]=Math.min(Math.min(r[a-1][i]+1,r[a][i-1]+1),r[a-1][i-1]+s)}return r[o][n]}};var Nt="kanonak.org",Tt="core-rdf",_t=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(c=>R({publisher:Nt,package_:Tt,name:c}))),ue=class{ruleName="UnresolvedReference";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);return G(a,({kanonak:i,path:s})=>{for(let p of i.statement){let l=Lt(p);if(!(!l||_t.has(R(l)))){if(p instanceof He)this.check(r,s,l,p.object,n);else if(p instanceof Y)for(let m of p.object)m instanceof D&&this.check(r,s,l,m,n)}}}),n}check(e,t,o,n,r){k(e,n.subject)||r.push(this.unresolvedError(t,o.name,n.subject))}unresolvedError(e,t,o){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${o.name}' in '${t}' could not be resolved`,r.suggestion=`The entity '${n}' is not defined in this namespace or any imported namespace.
7
- \u2022 Import the package that defines it, or check for a typo in '${o.name}'
8
- \u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function Lt(c){return c.predicate?.subject}var mt={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},ut={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function Mt(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}function qe(c,e,t){let o=[],n=new Set,r=new Set,a=i=>{let s=k(c,i),p=s?`${s.namespace}/${s.name}`:R(i);if(n.has(p)){let l=o.findIndex(d=>d.key===p),m=o.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(p))return null;if(n.add(p),o.push({key:p,uri:i}),s)for(let l of Mt(s,t)){let m=a(l);if(m)return m}return o.pop(),n.delete(p),r.add(p),null};return a(e)}var dt=c=>c,de=class{ruleName="ClassHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f)||!(v.isClassType(dt(i))||v.isDatatypeType(dt(i))))continue;let s=w(i);if(!s)continue;let p=qe(r,s,mt);if(p){let l=p.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular class hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",m.entityName=i.name,m.propertyName="subClassOf",m.actualValue=l,n.push(m);break}}return n}};var fe=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f)||!W(r,i))continue;let s=w(i);if(!s)continue;let p=qe(r,s,ut);if(p){let l=p.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=i.name,m.propertyName="subPropertyOf",m.actualValue=l,n.push(m);break}}return n}};var Bt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ye=class{ruleName="PropertyRangeRequired";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=H(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty";ee(i,Bt)||n.push(this.error(i.name,p))}return n}error(e,t){let o=new u;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName="range",o.message=`Property '${e}' must have a 'range' defined.`,o.suggestion=t?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",o.expectedValue=t?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",o}};var Ft={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},ft=c=>c,ge=class{ruleName="SubClassOfReference";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f)||!yt(ft(i)))continue;let s=Ht(i,Ft);for(let p=0;p<s.length;p++)this.resolvesToClassLike(r,s[p])||n.push(this.error(i.name,s[p],s.length>1?`[${p}]`:""))}return n}resolvesToClassLike(e,t){let o=k(e,t);return o?yt(ft(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subClassOf",r.actualValue=n,r.expectedValue="Defined or imported class",r.message=`Class '${t.name}' referenced in subClassOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a Class, or import a namespace that contains it`,r}};function yt(c){return v.isClassType(c)||v.isDatatypeType(c)}function Ht(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}var Wt={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},ke=class{ruleName="SubPropertyOfReference";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f)||!W(r,i))continue;let s=Gt(i,Wt);for(let p=0;p<s.length;p++)this.resolvesToProperty(r,s[p])||n.push(this.error(i.name,s[p],s.length>1?`[${p}]`:""))}return n}resolvesToProperty(e,t){let o=k(e,t);return o?W(e,o):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subPropertyOf",r.actualValue=n,r.expectedValue="Defined or imported property",r.message=`Property '${t.name}' referenced in subPropertyOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a property, or import a namespace that contains it`,r}};function Gt(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}var he=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,t){let o=[],n=e.metadata.namespace_?.toString();if(!n)return o;let r=new Map,a=new Set;await this.buildImportGraph(e,t,r,a);let i=this.detectCycle(n,r);if(i){let s=i.join(" \u2192 "),p=new u;p.ruleType=this.ruleName,p.severity="Error",p.message=`Circular namespace import detected: ${s}`,p.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",p.entityName="imports",p.propertyName="imports",p.actualValue=s,o.push(p)}return o}async buildImportGraph(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,s]of Object.entries(e.metadata.imports))for(let p of s){let l=`${i}/${p.packageName}@${p.version}`;a.push(l);let m=await t.getHighestCompatibleVersionAsync(i,p);m&&await this.buildImportGraph(m,t,o,n)}a.length>0&&o.set(r,a)}}detectCycle(e,t){let o=[],n=new Set;return this.detectCycleRecursive(e,t,o,n)}detectCycleRecursive(e,t,o,n){let r=o.indexOf(e);if(r>=0){let i=o.slice(r);return i.push(e),i}if(n.has(e))return null;o.push(e),n.add(e);let a=t.get(e);if(a)for(let i of a){let s=this.detectCycleRecursive(i,t,o,n);if(s)return s}return o.pop(),null}};var Re=class{ruleName="UnresolvedPredicate";async validateAsync(e,t,o){let n=[],r=Ge(e);if(!r)return n;let a=await E(e,t,o);return G(a,({kanonak:i,path:s})=>{for(let p of i.unresolvedPredicates)p.sourceDoc===r&&n.push(this.unresolvedPredicateError(s,p.key))}),n}unresolvedPredicateError(e,t){let o=t.lastIndexOf("."),n=o>0?t.slice(0,o):null,r=o>0?t.slice(o+1):t,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=t,a.expectedValue="A defined or imported property",a.message=`Property '${t}' is not defined or imported`,a.suggestion=n?`The property '${r}' was not found in the namespace imported as '${n}'.
9
- 1. Check '${r}' is spelled correctly
10
- 2. Verify '${n}' is imported with the right alias and version
11
- 3. Ensure that namespace version actually defines '${r}'`:`The property '${t}' is not defined in this namespace or any imported namespace.
12
- 1. Define '${t}' as an ObjectProperty or DatatypeProperty here, OR
13
- 2. Import the namespace that defines it, OR
14
- 3. Alias-qualify it if it lives in an imported namespace ('alias.${t}')`,a}};var Ke=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,t){let o=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,t),a=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,n,r,a,e,o);return o}async buildEntitySourceMapAsync(e,t){let o=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";o.has(a)||o.set(a,[]),o.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let p=await t.getHighestCompatibleVersionAsync(a,s);if(p){let l=p.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(p,o,n,r,[l],t)}}return{entitySources:o,importPaths:r}}async collectEntitiesRecursivelyAsync(e,t,o,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!o.has(i)){o.add(i),n.has(i)||n.set(i,r);for(let s of Object.keys(e.body)){t.has(s)||t.set(s,[]);let p=t.get(s);p.includes(i)||p.push(i)}if(e.metadata.imports)for(let[s,p]of Object.entries(e.metadata.imports))for(let l of p){let m=await a.getHighestCompatibleVersionAsync(s,l);if(m){let d=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,t,o,n,[...r,d],a)}}}}async buildDatatypePropertyNamesAsync(e,t){let o=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,o,n,t),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let s=await t.getHighestCompatibleVersionAsync(r,i);s&&await this.collectDatatypePropertiesAsync(s,o,n,t)}return o}async collectDatatypePropertiesAsync(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!o.has(r)){o.add(r);for(let[a,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(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let p=await n.getHighestCompatibleVersionAsync(a,s);p&&await this.collectDatatypePropertiesAsync(p,t,o,n)}}}validateEntityReferences(e,t,o,n,r,a,i){for(let[s,p]of Object.entries(t)){let l=s;if(l&&!l.includes(".")){let m=o.get(l);if(m&&m.length>1&&!m.some(h=>h.startsWith("(local:"))){let h=m.filter(V=>!V.startsWith("(local:"));h.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,h,n,a,!0,l))}}this.validatePropertyValue(e,l,p,o,n,r,a,i)}}validatePropertyValue(e,t,o,n,r,a,i,s){if(o==null)return;let p=t&&t.includes(".")?t.substring(t.lastIndexOf(".")+1):t,l=!!p&&a.has(p);if(typeof o=="string"&&!o.includes(".")&&!l){let m=n.get(o);if(m&&m.length>1&&!m.some(h=>h.startsWith("(local:"))){let h=m.filter(V=>!V.startsWith("(local:"));h.length>1&&s.push(this.createAmbiguityError(e,t,`Reference '${o}'`,h,r,i,!1,o))}}else if(Array.isArray(o))for(let m=0;m<o.length;m++){let d=`${e}.${t}[${m}]`;this.validatePropertyValue(d,t,o[m],n,r,a,i,s)}else if(typeof o=="object"&&!Array.isArray(o)){let m=t?`${e}.${t}`:e;this.validateEntityReferences(m,o,n,r,a,i,s)}}createAmbiguityError(e,t,o,n,r,a,i,s){let p=[];for(let j of n){let O=this.findAliasForNamespace(a,j);if(O){let B=t?.split(".").pop()??t;p.push(`${O}.${B}`)}}let l=p.length>0?`Use one of: ${p.map(j=>`'${j}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${t}')`,m=n.map(j=>{let O=r.get(j);return!O||O.length===0?` \u2022 ${j}`:O.length===1?` \u2022 ${j} (direct import)`:` \u2022 ${j}
15
- imported via: ${O.join(" \u2192 ")}`}).join(`
16
- `),d=e.split(".")[0],h=e.includes(".")?e:t,V=new u;V.ruleType=this.ruleName,V.severity="Error",V.entityName=d,h&&(V.propertyName=h);let T=s??t;return T&&(V.actualValue=T),V.message=`${o} is ambiguous - defined in multiple imported namespaces`,V.suggestion=`${l}
17
-
18
- Defined in:
19
- ${m}`,V.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",V}findAliasForNamespace(e,t){if(!e.metadata.imports)return null;for(let[o,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${o}/${r.packageName}@${r.version}`===t&&r.alias)return r.alias;return null}};var Yt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},gt=c=>c,be=class{ruleName="PropertyRangeReference";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=H(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty";for(let l of qt(i,Yt))this.resolvesToClassLike(r,l)||n.push(this.error(i.name,l,p))}return n}resolvesToClassLike(e,t){let o=k(e,t);return o?v.isClassType(gt(o))||v.isDatatypeType(gt(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="range",r.actualValue=n,r.expectedValue=o?"A defined or imported class":"A datatype or defined class",r.message=`Property '${e}' has range '${t.name}' which is not defined or imported`,r.suggestion=o?`Define '${t.name}' as a Class here, or import the namespace that contains it (alias-qualify it if imported under an alias).`:`Use a datatype (xsd type, rdfs.Literal, or a datatype-derived type), or \u2014 if '${t.name}' is a class \u2014 make this an ObjectProperty.`,r}};function qt(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}var zt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Ve="kanonak.org",Je="core-rdf",Qe="core-owl",et=c=>c,Xt=[{uri:{publisher:Ve,package_:Je,name:"Class"},ok:(c,e)=>v.isClassType(et(e))||v.isDatatypeType(et(e))},{uri:{publisher:Ve,package_:Je,name:"Datatype"},ok:(c,e)=>v.isDatatypeType(et(e))},{uri:{publisher:Ve,package_:Je,name:"Property"},ok:(c,e)=>W(c,e)},{uri:{publisher:Ve,package_:Qe,name:"ObjectProperty"},ok:(c,e)=>H(c,e)==="ObjectProperty"},{uri:{publisher:Ve,package_:Qe,name:"DatatypeProperty"},ok:(c,e)=>H(c,e)==="DatatypeProperty"},{uri:{publisher:Ve,package_:Qe,name:"AnnotationProperty"},ok:(c,e)=>H(c,e)==="AnnotationProperty"}],Ee=class{ruleName="ObjectPropertyValue";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await re(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof He)this.check(e,r.predicate?.subject,r.object.subject,o,n);else if(r instanceof Q)this.walk(e,r.object,kt(o,r.predicate?.subject),n);else if(r instanceof Y){let a=r.predicate?.subject;for(let i of r.object)i instanceof D?this.check(e,a,i.subject,o,n):i instanceof I&&this.walk(e,i,kt(o,a),n)}}check(e,t,o,n,r){if(!t)return;let a=k(e,t);if(!a)return;let i=y(a,zt);if(!i)return;let s=Xt.find(l=>X(i,l.uri));if(!s)return;let p=k(e,o);p&&(s.ok(e,p)||r.push(this.warn(n,t,i,o)))}warn(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e.split(".")[0],r.propertyName=e,r.actualValue=n.name,r.expectedValue=o.name,r.message=`Property '${t.name}' expects a ${o.name}, but '${n.name}' is not a ${o.name}`,r.suggestion=`Reference a resource that is a ${o.name}, or correct the type of '${n.name}'.`,r}};function kt(c,e){return`${c}.${e?.name??"<embedded>"}`}var Zt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Jt={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},Qt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},ve=class{ruleName="PropertyDomain";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await re(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){this.checkNode(e,t,o,n);for(let r of t.statement)if(r instanceof Q)this.walk(e,r.object,Rt(o,r.predicate?.subject),n);else if(r instanceof Y)for(let a of r.object)a instanceof I&&this.walk(e,a,Rt(o,r.predicate?.subject),n)}checkNode(e,t,o,n){let r=ht(t,Zt);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([R(Qt)]);for(let p of r)for(let l of z(e,p))a.add(R(l))}return a},s=new Set;for(let p of t.statement){let l=eo(p);if(!l||We(l.name)||s.has(R(l)))continue;s.add(R(l));let m=k(e,l);if(!m)continue;let d=ht(m,Jt);d.length!==0&&(d.some(h=>i().has(R(h)))||n.push(this.error(o,l,d,r[0])))}}error(e,t,o,n){let r=o.map(i=>i.name).join(" | "),a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e.split(".")[0],a.propertyName=e,a.actualValue=t.name,a.expectedValue=`Property used on ${r} or its subclasses`,a.message=`Property '${t.name}' has domain '${r}' but is used on '${n.name}' at '${e}'`,a.suggestion=`Either:
20
- 1. Use '${t.name}' only on '${r}' (or a subclass) instances
21
- 2. Widen the property's domain to include '${n.name}'
22
- 3. Use a different property for '${n.name}'`,a}};function eo(c){return c.predicate?.subject}function ht(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}function Rt(c,e){return`${c}.${e?.name??"<embedded>"}`}var to={publisher:"kanonak.org",package_:"core-rdf",name:"range"},oo={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},no=c=>c,De=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=H(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty",l=s==="DatatypeProperty",m=y(i,to);if(!m||!k(r,m))continue;let d=ro(r,m);l&&!d?n.push(this.error(i.name,m,"datatype")):p&&d&&n.push(this.error(i.name,m,"object"))}return n}error(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="range",n.actualValue=t.name,o==="datatype"?(n.expectedValue="A datatype (xsd type, rdfs.Literal, or a datatype-derived class)",n.message=`DatatypeProperty '${e}' has range '${t.name}', which is a class, not a datatype. A datatype property's values are literals.`,n.suggestion=`Use a datatype range (e.g. xsd.string, rdfs.Literal, or a datatype-derived class), or \u2014 if '${t.name}' is the intended target \u2014 declare '${e}' an ObjectProperty.`):(n.expectedValue="A plain class (not datatype-derived)",n.message=`ObjectProperty '${e}' has range '${t.name}', which is a datatype, not a class. An object property's values are references to resources.`,n.suggestion=`Declare '${e}' a DatatypeProperty (its values are literals of '${t.name}'), or change the range to a plain class.`),n}};function ro(c,e){for(let t of z(c,e)){if(X(t,oo))return!0;let o=k(c,t);if(o&&v.isDatatypeType(no(o)))return!0}return!1}var Ie=class{ruleName="ReservedNameShadow";async validateAsync(e,t,o){let n=[],r=await C(e,t,o);for(let a of r){if(!(a instanceof f))continue;let i=it(a.name);if(!i)continue;let s=w(a);s&&(i.publisher===s.publisher&&i.package_===s.package_||n.push(this.info(a.name,s,i)))}return n}info(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Info",n.entityName=e,n.propertyName=e,n.actualValue=`${t.publisher}/${t.package_}/${e}`,n.expectedValue=`${o.publisher}/${o.package_}/${e}`,n.message=`'${e}' is also the reserved built-in '${o.publisher}/${o.package_}/${e}'. This local definition shadows it \u2014 a bare '${e}' reference in this package resolves to the local entity, not the built-in.`,n.suggestion=`If this is intentional, qualify bare references to '${e}' explicitly (this local one vs. the built-in '${o.publisher}/${o.package_}/${e}') so the choice is unambiguous to readers and tools \u2014 e.g. a self-referential 'subClassOf: ${e}' silently resolves to this local entity.`,n}};var ao={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Kt=c=>c,Ce=class{ruleName="ClassDefinition";async validateAsync(e,t,o){let n=[],r=await E(e,t,o),a=await C(e,t,o);return G(a,({kanonak:i,path:s})=>{for(let p of io(i,ao))this.resolvesToClassLike(r,p)||n.push(this.error(s,p))}),n}resolvesToClassLike(e,t){if(We(t.name))return!0;let o=k(e,t);return o?v.isClassType(Kt(o))||v.isDatatypeType(Kt(o)):!1}error(e,t){let o=`${t.publisher}/${t.package_}/${t.name}`,n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="type",n.actualValue=o,n.expectedValue="Defined or imported class",n.message=`Class '${t.name}' is not defined or imported`,n.suggestion=`Define '${t.name}' as a Class in this document, or import a namespace that contains it`,n}};function io(c,e){let t=y(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof D&&o.push(n.subject);return o}var Se=class{ruleName="MarkdownLink";async validateAsync(e,t,o){let n=[],r=await C(e,t,o);return G(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,t,o){for(let n of e.statement){if(!(n instanceof at))continue;let r=n.predicate.subject?.name??"(unknown)";for(let a of n.links)a.target||o.push(this.unresolvedLinkError(t,r,a.reference));for(let a of pt(n.object))o.push(this.malformedLinkError(t,r,a.snippet))}}unresolvedLinkError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`Embedded link [[${o}]] in '${t}' could not be resolved`,n.expectedValue="A reference resolvable through the document's import closure",n.suggestion=`The reference '${o}' inside a markdown value cannot be found in the current document or any imported namespace.
23
-
24
- Possible solutions:
25
- \u2022 Import the package that defines '${o}' so the link can resolve
26
- \u2022 Check for typos in the reference name
27
- \u2022 If the name collides across imports, alias-qualify it: [[alias.${o}]]`,n}malformedLinkError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`Malformed embedded reference near '${o}' in '${t}'`,n.expectedValue="A single-line [[reference]] with no internal line break",n.suggestion=`A '[[' in '${t}' does not form a complete [[reference]] link.
28
-
29
- A reference may not span a line break \u2014 the most common cause is wrapping a
30
- long reference across two lines in a block scalar, e.g.:
31
- ... read for [[persistent-energy-
32
- shock]] held ...
33
- which is parsed as literal text, not a link. Keep each [[reference]] on one
34
- line (let the line run long), or check for an unterminated [[.`,n}};var bt="kanonak.org",Vt="look",so={publisher:bt,package_:Vt,name:"displayLabel"},co={publisher:bt,package_:Vt,name:"displaySummary"},Pe=class{ruleName="DisplayLensScope";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new q(e,t));let a=po(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&(this.checkLens(r,i,so,"displayLabel",n),this.checkLens(r,i,co,"displaySummary",n));return n}checkLens(e,t,o,n,r){let a=y(t,o);if(!a)return;let i=[],s=w(t);if(s&&i.push(s),i.push(...ct(t)),i.length===0)return;i.some(l=>L(e,l,a).ok)||r.push(this.scopeError(t.name,n,a.name))}scopeError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`${t} points at '${o}', which is not a property in scope for '${e}'`,n.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",n.suggestion=`'${o}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
35
-
36
- Possible solutions:
37
- \u2022 Point ${t} at a property declared on this class (or an ancestor / rdfs.Resource)
38
- \u2022 Set the property's domain to this class if it should apply here
39
- \u2022 Use rdfs.label / rdfs.comment for the universal default`,n}};function po(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}function Z(c,e,t){let o=[];return Le(c,t,{input:e},o),o}function Le(c,e,t,o){if(P(e,M.VarRef)){let a=F(e,M.varName);return a?t[a]:void 0}if(P(e,M.PropertyRead)){let a=$(e,M.readSource),i=a?Le(c,a,t,o):void 0,s=y(e,M.readProp);if(!i||!s)return;let p=L(c,i,s);if(!p.ok){o.push({contextClass:i,propertyUri:s,via:"PropertyRead"});return}return p.descriptor?.range}if(P(e,M.Traverse)){let a=$(e,M.traverseSource),i=a?Le(c,a,t,o):void 0,s=y(e,M.through),p;if(i&&s){let m=L(c,i,s);m.ok?p=m.descriptor?.range:o.push({contextClass:i,propertyUri:s,via:"Traverse"})}let l=$(e,M.step);return l?Le(c,l,{...t,input:p},o):void 0}let n=F(e,M.loopVar),r=n?{...t,[n]:void 0}:t;for(let a of lo(e))Le(c,a,r,o)}function lo(c){let e=[];for(let t of c.statement){let o=t.object;if(o instanceof I)e.push(o);else if(Array.isArray(o))for(let n of o)n instanceof I&&e.push(n)}return e}var Me="kanonak.org",Be="look",mo={publisher:Me,package_:Be,name:"semanticSvg"},uo={publisher:Me,package_:Be,name:"tierChip"},fo={publisher:Me,package_:Be,name:"tierIcon"},yo={publisher:Me,package_:Be,name:"tierCard"},go={publisher:Me,package_:Be,name:"tierFull"},ko=[uo,fo,yo,go],je=class{ruleName="LookSemanticSvgPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new q(e,t));let a=ho(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,t,o){let n=$(t,mo);if(!n)return;let r=w(t);if(r)for(let a of ko){let i=$(n,a);if(i)for(let s of Z(e,r,i))o.push(this.toError(t.name,a.name,s))}}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,a=r===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${r}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${t}`,i.actualValue=n,i.message=`tx.${o.via} reads property '${o.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${a}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${n}' is not in scope for '${r}'.
40
-
41
- Possible solutions:
42
- \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
43
- \u2022 If the property should apply to '${r}', adjust its domain
44
- \u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function ho(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Ro="kanonak.org",K=(c,e)=>({publisher:Ro,package_:c,name:e}),Ko=K("derivation","look"),bo=K("look","bands"),Vo=K("look","Distribution"),Eo=K("look","StatRow"),vo=K("look","VersionDelta"),Do=K("look","Timeline"),Io=K("look","VersionDiff"),Co=K("look","TimePlot"),So=K("look","ReferenceList"),Po=K("look","Diagram"),jo=K("look","alphaPath"),Oo=K("look","betaPath"),tt=K("look","metricPath"),Et=K("look","lowerPath"),vt=K("look","upperPath"),Dt=K("look","hueBy"),$o=K("look","statPath"),Uo=K("look","laneBy"),It=K("look","labelPath"),wo=K("look","badgePath"),Ao=K("look","mapPath"),xo=K("look","nodeNote"),No=K("look","edgeValue"),To=K("look","stats"),_o=K("look","facets"),Lo=K("look","channels"),Mo=K("look","track"),Bo=K("look","source"),Fo=K("look","relation"),Ho=K("look","entries"),Oe=class{ruleName="LookBandPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new q(e,t));let a=Go(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,t,o){let n=$(t,Ko);if(!n)return;let r=w(t);if(!r)return;let a=b(n,bo).filter(i=>i instanceof I);for(let i of a)for(let s of this.carriersOf(e,i,r))for(let p of Z(e,s.context,s.expr))o.push(this.toError(t.name,s.slot,p))}carriersOf(e,t,o){let n=[],r=(a,i)=>{let s=$(t,a);s&&n.push({slot:`look.${a.name}`,context:i,expr:s})};if(P(t,Vo))for(let a of[jo,Oo,tt,Et,vt,Dt])r(a,o);if(P(t,vo)&&r(tt,o),P(t,Eo)){let a=b(t,To).filter(i=>i instanceof I);for(let i of a){let s=$(i,$o);s&&n.push({slot:"look.stats[].statPath",context:o,expr:s})}}if(P(t,Do)||P(t,Io)){let a=this.rangeOf(e,o,y(t,Mo));if(a)for(let i of[tt,Et,vt,Dt])r(i,a)}if(P(t,Co)){let a=this.rangeOf(e,o,y(t,Bo));if(a)for(let i of[Uo,It])r(i,a)}if(P(t,So))for(let a of b(t,Ho)){let i=a instanceof I?void 0:Wo(a),s=this.rangeOf(e,o,i);if(s)for(let p of[It,wo])r(p,s)}if(P(t,Po)){let a=b(t,_o).filter(i=>i instanceof I);for(let i of a){let s=this.rangeOf(e,o,y(i,Fo));if(!s)continue;let p=$(i,xo);p&&n.push({slot:"look.facets[].nodeNote",context:s,expr:p});let l=$(i,No);l&&n.push({slot:"look.facets[].edgeValue",context:s,expr:l});let m=b(i,Lo).filter(d=>d instanceof I);for(let d of m){let h=$(d,Ao);h&&n.push({slot:"look.facets[].channels[].mapPath",context:s,expr:h})}}}return n}rangeOf(e,t,o){if(!o)return;let n=L(e,t,o);return n.ok?n.descriptor?.range:void 0}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=n,a.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for '${r}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,a.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${n}' is not in scope for '${r}'.
45
-
46
- Possible solutions:
47
- \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
48
- \u2022 If the property should apply to '${r}', adjust its domain
49
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function Wo(c){let e=c.subject;return e&&typeof e.name=="string"?e:void 0}function Go(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Ue="kanonak.org",we="view",Yo={publisher:Ue,package_:we,name:"bind"},qo={publisher:Ue,package_:we,name:"produces"},zo={publisher:Ue,package_:we,name:"projections"},Xo={publisher:Ue,package_:we,name:"where"},Zo={publisher:Ue,package_:we,name:"value"},Jo={publisher:Ue,package_:we,name:"as"},$e=class{ruleName="TxExpressionPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new q(e,t));let a=tn(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,t,o){let n=y(t,Yo);if(!n)return;let r=y(t,qo),a=0;for(let s of en(e,b(t,zo))){let p=$(s,Zo);if(p)for(let m of Z(e,n,p))o.push(this.toError(t.name,`view.projections[${a}].value`,n,m));let l=y(s,Jo);l&&r&&(L(e,r,l).ok||o.push(this.asError(t.name,a,r,l))),a+=1}let i=0;for(let s of Qo(t,Xo)){for(let p of Z(e,n,s))o.push(this.toError(t.name,`view.where[${i}]`,n,p));i+=1}}asError(e,t,o,n){let r=`${n.publisher}/${n.package_}/${n.name}`,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=`view.projections[${t}].as`,a.actualValue=r,a.message=`Projection stores its value under property '${n.name}', but that property's domain is not in scope for the view's produces class '${o.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${o.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${o.name}'.
50
-
51
- Possible solutions:
52
- \u2022 Use an output property whose domain covers '${o.name}'
53
- \u2022 Define a new property in the ViewPackage with domain '${o.name}' and the right range
54
- \u2022 If the value belongs on a different output class, adjust the view's produces`,a}toError(e,t,o,n){let r=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,i=a===o.name?`the view's bound class '${o.name}'`:`'${a}', reached by traversal from the view's bound class '${o.name}'`,s=new u;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=t,s.actualValue=r,s.message=`tx.${n.via} reads property '${n.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 '${a}', an ancestor, or rdfs.Resource`,s.suggestion=`Property '${r}' is not in scope for '${a}'.
55
-
56
- Possible solutions:
57
- \u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
58
- \u2022 If the property should apply to '${a}', adjust its domain
59
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,s}};function Qo(c,e){let t=$(c,e);return t?[t]:b(c,e).filter(o=>o instanceof I)}function en(c,e){let t=[];for(let o of e)if(o instanceof I)t.push(o);else if(o instanceof D){let n=k(c,o.subject);n&&t.push(n)}return t}function tn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var ze="kanonak.org",on="core-shacl",A=c=>({publisher:ze,package_:on,name:c}),nn=A("NodeShape"),rn=A("PropertyShape"),an=A("targetClass"),sn=A("property"),cn=A("path"),pn=A("minCount"),ln=A("maxCount"),mn=A("datatype"),un=A("class"),Ct=A("in"),dn=A("pattern"),fn=A("flags"),yn=A("minLength"),gn=A("maxLength"),kn=A("minInclusive"),hn=A("maxInclusive"),Rn=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),St=c=>c,xe=class{ruleName="ShaclShape";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=Kn(e);if(!a)return n;let i=new Set;for(let s of r){if(!(s instanceof f)||s.namespace!==a||!P(s,nn))continue;let p=y(s,an);p?this.resolvesToClass(r,p)||n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' sh:targetClass '${p.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(p))):n.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 l of b(s,sn)){let m;if(l instanceof I)m=l;else if(l instanceof D){let d=k(r,l.subject);d&&(m=d,i.add(R(l.subject)))}m&&this.checkPropertyShape(r,s.name,m,p??void 0,n)}}for(let s of r){if(!(s instanceof f)||s.namespace!==a||!P(s,rn))continue;let p=w(s);p&&i.has(R(p))||this.checkPropertyShape(r,s.name,s,void 0,n)}return n}checkPropertyShape(e,t,o,n,r){let a=y(o,cn);if(!a){r.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=k(e,a),s=i?W(e,i):!1;s?n&&(L(e,n,a).ok||r.push(this.err(t,"property.path","Warning",`sh:path '${a.name}' is not in scope for sh:targetClass '${n.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${n.name}', an ancestor, or rdfs.Resource.`,J(a)))):r.push(this.err(t,"property.path","Error",`sh:path '${a.name}' on '${t}' does not resolve to a property.`,"Reference a defined or imported property.",J(a)));let p=y(o,mn),l=y(o,un);p&&l&&r.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.")),p&&!this.resolvesToDatatype(e,p)&&r.push(this.err(t,"datatype","Error",`sh:datatype '${p.name}' on '${t}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",J(p))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(t,"class","Error",`sh:class '${l.name}' on '${t}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(l)));let m=Ae(x(o,pn)),d=Ae(x(o,ln));this.checkOrder(t,"minCount",m,"maxCount",d,r);let h=Ae(x(o,yn)),V=Ae(x(o,gn));this.checkOrder(t,"minLength",h,"maxLength",V,r);let T=Ae(x(o,kn)),j=Ae(x(o,hn));this.checkOrder(t,"minInclusive",T,"maxInclusive",j,r);let O=F(o,dn);if(O!==void 0){let B=F(o,fn);try{new RegExp(O,B)}catch{r.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(B!==void 0?` (with flags '${B}')`:"")+`: ${O}`,"Provide a valid regular expression and flags.",O))}}if(ee(o,Ct)&&b(o,Ct).length===0&&r.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&&n){let _=L(e,n,a).descriptor;_&&((O!==void 0||h!==void 0||V!==void 0)&&_.kind==="object"&&r.push(this.err(t,"pattern/minLength/maxLength","Warning",`String facets on '${t}' apply to '${a.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.",J(a))),(T!==void 0||j!==void 0)&&!this.isNumericDatatypeRange(_.range)&&r.push(this.err(t,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${t}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",J(a))))}}checkOrder(e,t,o,n,r,a){o!==void 0&&r!==void 0&&o>r&&a.push(this.err(e,`${t}/${n}`,"Error",`${t} (${o}) exceeds ${n} (${r}) on '${e}'.`,`Set ${t} <= ${n}.`))}resolvesToClass(e,t){let o=k(e,t);return o?v.isClassType(St(o)):!1}resolvesToDatatype(e,t){if(t.publisher===ze&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let o=k(e,t);return o?v.isDatatypeType(St(o)):!1}isNumericDatatypeRange(e){return!e||e.publisher===ze&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===ze&&e.package_==="core-xsd"&&Rn.has(e.name)}err(e,t,o,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=o,i.entityName=e,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function Ae(c){return typeof c=="number"?c:void 0}function J(c){return`${c.publisher}/${c.package_}/${c.name}`}function Kn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Pt={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},bn=c=>c,Ne=class{ruleName="OwlOneOf";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=Vn(e);if(!a)return n;for(let i of r){if(!(i instanceof f)||i.namespace!==a||!ee(i,Pt))continue;let s=b(i,Pt);if(s.length===0){n.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 p of s)if(p instanceof Fe)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(p.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(p.value)));else if(p instanceof D){let l=k(r,p.subject);l&&v.isSchemaDefinitionType(bn(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${p.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${p.subject.publisher}/${p.subject.package_}/${p.subject.name}`))}}return n}err(e,t,o,n,r){let a=new u;return a.ruleType=this.ruleName,a.severity=t,a.entityName=e,a.propertyName="oneOf",a.message=o,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function Vn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var En="kanonak.org",vn="core-shacl",N=c=>({publisher:En,package_:vn,name:c}),Dn=N("NodeShape"),In=N("targetClass"),Cn=N("property"),Sn=N("path"),Pn=N("minCount"),jn=N("maxCount"),On=N("in"),$n=N("pattern"),Un=N("flags"),wn=N("minLength"),An=N("maxLength"),xn=N("minInclusive"),Nn=N("maxInclusive"),Tn=N("message");function Te(c){return typeof c=="number"?c:void 0}function _n(c){let e={},t=Te(x(c,Pn)),o=Te(x(c,jn));t!==void 0&&(e.minCount=t),o!==void 0&&(e.maxCount=o);let n=Te(x(c,wn)),r=Te(x(c,An));n!==void 0&&(e.minLength=n),r!==void 0&&(e.maxLength=r);let a=Te(x(c,xn)),i=Te(x(c,Nn));a!==void 0&&(e.minInclusive=a),i!==void 0&&(e.maxInclusive=i);let s=F(c,$n);if(s!==void 0){let m=F(c,Un);e.pattern=m!==void 0?{regex:s,flags:m}:{regex:s}}let p=b(c,On).filter(m=>m instanceof Fe).map(m=>m.value);p.length>0&&(e.enumValues=p);let l=F(c,Tn);return l!==void 0&&(e.message=l),e}function Ln(c,e){let t=[];for(let o of b(e,Cn))if(o instanceof I)t.push(o);else if(o instanceof D){let n=k(c,o.subject);n&&t.push(n)}return t}function jt(c){let e=new Map;for(let t of c){if(!(t instanceof f)||!P(t,Dn))continue;let o=y(t,In);if(!o)continue;let n=R(o);for(let r of Ln(c,t)){let a=y(r,Sn);if(!a)continue;let i={pathKey:R(a),constraints:_n(r)},s=e.get(n);s?s.push(i):e.set(n,[i])}}return e}function Mn(c,e){e.minCount!==void 0&&(c.minCount=e.minCount),e.maxCount!==void 0&&(c.maxCount=e.maxCount),e.minLength!==void 0&&(c.minLength=e.minLength),e.maxLength!==void 0&&(c.maxLength=e.maxLength),e.minInclusive!==void 0&&(c.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(c.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(c.pattern=e.pattern),e.enumValues!==void 0&&(c.enumValues=e.enumValues),e.message!==void 0&&(c.message=e.message)}function Ot(c,e,t){let o=R(t),n=!1,r={};for(let a=e.length-1;a>=0;a--){let i=c.get(R(e[a]));if(i)for(let s of i)s.pathKey===o&&(n=!0,Mn(r,s.constraints))}if(n)return r.cardinality=r.maxCount===1?"single":"list",r.required=(r.minCount??0)>=1,r}var Bn=c=>c,Fn=new rt("kanonak.org","core-rdf","Resource"),_e=class{ruleName="DiamondNameClash";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=Hn(e);if(!a)return n;let i=jt(r);for(let s of r){if(!(s instanceof f)||s.namespace!==a||!v.isClassType(Bn(s)))continue;let p=w(s);if(!p)continue;let l=z(r,p),m=R(p),d=new Set(l.map(V=>R(V)));d.delete(m),d.delete(R(Fn));let h=new Map;for(let V of st(r,p)){if(!V.domains.some(O=>d.has(R(O))))continue;let j=h.get(V.uri.name);j?j.push(V):h.set(V.uri.name,[V])}for(let[V,T]of h){if(T.length<2)continue;let j=_=>Ot(i,l,_.uri)?.cardinality,O=new Set(T.map(_=>_.range?R(_.range):void 0).filter(_=>_!==void 0)),B=new Set(T.map(j).filter(_=>_!==void 0));O.size<=1&&B.size<=1||n.push(this.toError(s.name,V,T,j))}}return n}toError(e,t,o,n){let r=s=>{let p=`${s.uri.publisher}/${s.uri.package_}/${s.uri.name}`,l=s.range?`${s.range.publisher}/${s.range.package_}/${s.range.name}`:"no range",m=n(s);return`${p} (range ${l}${m?`, ${m}`:""})`},a=o.map(r).join("; "),i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=t,i.actualValue=a,i.message=`Class '${e}' inherits ${o.length} distinct properties named '${t}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${t}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${t}':
60
- \u2022 rename one of the properties, or
61
- \u2022 re-domain one so it is not inherited by '${e}', or
62
- \u2022 restructure the hierarchy so '${e}' inherits only one '${t}', or
63
- \u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function Hn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var ot=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new nt,this.documentRules=[new ae,new ie,new se,new ce,new pe],this.repositoryRules=[new le,new me,new ue,new de,new fe,new ye,new ge,new ke,new he,new Re,new Ke,new be,new Ee,new ve,new De,new Ie,new Ce,new Se,new Pe,new je,new Oe,new $e,new xe,new Ne,new _e]}async validateAsync(e,t,o){let n=new te;for(let r of this.documentRules)try{let a=r.validate(e);this.addErrorsToResult(n,a)}catch(a){let i=new u;i.ruleType=r.ruleName,i.severity="Error",i.message=`Validation rule '${r.ruleName}' failed: ${a instanceof Error?a.message:String(a)}`,n.errors.push(i)}if(t){let r=[],a=o??new oe(new ne(e,t)),i=a.repository;for(let s of this.repositoryRules)try{let p=await s.validateAsync(e,i,a);this.addErrorsToResult(n,p)}catch(p){let l=p instanceof Error?p.message:String(p);r.push({ruleName:s.ruleName,cause:l})}if(r.length>0){let s=new Map;for(let{ruleName:p,cause:l}of r){let m=s.get(l);m?m.push(p):s.set(l,[p])}for(let[p,l]of s){let m=new u;m.ruleType=l[0],m.severity="Error",l.length===1?m.message=`Validation rule '${l[0]}' failed: ${p}`:m.message=`${p} (affects ${l.length} rules: ${l.join(", ")})`,n.errors.push(m)}}}return n.isValid=n.errors.length===0,n}async validateDocumentsAsync(e,t){let o=new oe(t),n=[];for(let r of e){let a=await this.validateAsync(r,o.repository,o);n.push({document:r,result:a})}return n}async validateYamlAsync(e,t,o){let n=this.parser.parseWithErrors(e);if(!n.isValid){let r=new te;r.isValid=!1;for(let a of n.errors){let i=new u;i.ruleType="ParseError",i.severity="Error",i.lineNumber=a.line,i.column=a.column,i.message=a.message,a.keyName&&(i.entityName=a.keyName),a.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),r.errors.push(i)}return r}return await this.validateAsync(n.document,t,o)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let t=this.documentRules.findIndex(o=>o instanceof e);t>=0&&this.documentRules.splice(t,1)}removeRepositoryRule(e){let t=this.repositoryRules.findIndex(o=>o instanceof e);t>=0&&this.repositoryRules.splice(t,1)}addErrorsToResult(e,t){for(let o of t)o.severity==="Error"?e.errors.push(o):o.severity==="Info"?this.includeWarnings&&e.infos.push(o):this.includeWarnings&&e.warnings.push(o)}};export{te as a,g as b,u as c,Xe as d,oe as e,ae as f,ie as g,se as h,ce as i,pe as j,le as k,me as l,ue as m,de as n,fe as o,ye as p,ge as q,ke as r,he as s,Re as t,Ke as u,be as v,Ee as w,ve as x,De as y,Ie as z,Ce as A,Se as B,Pe as C,je as D,Oe as E,$e as F,xe as G,Ne as H,jt as I,Ot as J,_e as K,ot as L};
@@ -1,32 +0,0 @@
1
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
- /**
3
- * Result from searching for instances of a specific type across a repository.
4
- */
5
- export interface InstanceSearchResult {
6
- /** The entity name (key in doc.body) */
7
- entityName: string;
8
- /** The raw entity object */
9
- entity: Record<string, any>;
10
- /** The full namespace string of the document containing this instance */
11
- documentNamespace: string;
12
- /** Publisher domain */
13
- publisher: string;
14
- /** Package name */
15
- package_: string;
16
- /** Version string */
17
- version: string;
18
- }
19
- /**
20
- * Find all instances of a given type across all documents in a repository.
21
- *
22
- * Searches each document's body for entities whose `type` field matches
23
- * the given type name. Handles both bare type names ("Skill") and
24
- * alias-prefixed references ("skills.Skill").
25
- *
26
- * Uses the SDK's existing IKanonakDocumentRepository — no custom YAML parsing.
27
- *
28
- * @param repository - The repository to search (InMemory, FileSystem, or Composite)
29
- * @param typeName - The type name to search for (e.g., "Skill", "Capability")
30
- * @returns Array of matching instances with their document context
31
- */
32
- export declare function findInstancesByType(repository: IKanonakDocumentRepository, typeName: string): Promise<InstanceSearchResult[]>;