@kanonak-protocol/sdk 3.22.0 → 3.23.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/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-GD4SYMXW.js";import{a as Ye}from"./chunk-ROCCA4BY.js";import{a as H,b as L,c as W,d as F}from"./chunk-CNM3SY5S.js";import{a as Pe,b as we,c as he}from"./chunk-63NJ25ZX.js";import{a as ye,b as ke,e as be}from"./chunk-VRZUCZEF.js";import{a as O,b as V,c as $,d as U,e as z,f as M,g as N,h as J}from"./chunk-FQHALFRR.js";import{A as Fe,B as Ge,C as Xe,D as Qe,a as Ke,b as xe,c as Se,d as Re,e as De,f as Be,g as Ce,h as Ee,i as je,j as ve,k as _e,l as Ae,m as Ie,n as Te,o as Oe,p as Ve,q as $e,r as Ue,s as ze,t as Me,u as Ne,v as Je,w as He,x as qe,y as Le,z as We}from"./chunk-
|
|
1
|
+
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-GD4SYMXW.js";import{a as Ye}from"./chunk-ROCCA4BY.js";import{a as H,b as L,c as W,d as F}from"./chunk-CNM3SY5S.js";import{a as Pe,b as we,c as he}from"./chunk-63NJ25ZX.js";import{a as ye,b as ke,e as be}from"./chunk-VRZUCZEF.js";import{a as O,b as V,c as $,d as U,e as z,f as M,g as N,h as J}from"./chunk-FQHALFRR.js";import{A as Fe,B as Ge,C as Xe,D as Qe,a as Ke,b as xe,c as Se,d as Re,e as De,f as Be,g as Ce,h as Ee,i as je,j as ve,k as _e,l as Ae,m as Ie,n as Te,o as Oe,p as Ve,q as $e,r as Ue,s as ze,t as Me,u as Ne,v as Je,w as He,x as qe,y as Le,z as We}from"./chunk-LPUWDJMI.js";import"./chunk-FJ35VIV6.js";import{a as Y,c as le,e as pe}from"./chunk-R2V7IXWN.js";import{a as G,b as X,c as Q,d as ee,e as re,f as te,g as ne,h as oe,i as se,j as ie,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as q}from"./chunk-MYITGTGJ.js";import{b as ue,c as de}from"./chunk-IXE5THUW.js";import{a as Z}from"./chunk-FUUTGGJS.js";var j="kanonak-credentials",u="credentials",Ze=1,f=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(j,Ze);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${j}': ${e.error?.message}
|
|
2
2
|
Credential storage requires IndexedDB support in your browser.`))})}async function _(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey);return{signingKey:n.privateKey,publicKeyJwk:r}}async function k(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey),e=await crypto.subtle.exportKey("jwk",n.privateKey);return{keys:{signingKey:n.privateKey,publicKeyJwk:r},dpopKeyPair:{publicKey:r,privateKey:e}}}async function b(n){return{signingKey:await crypto.subtle.importKey("jwk",n.privateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),publicKeyJwk:n.publicKey}}async function K(n,r,e,t,o){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:n.publicKeyJwk.kty,crv:n.publicKeyJwk.crv,x:n.publicKeyJwk.x,y:n.publicKeyJwk.y}},s={jti:crypto.randomUUID(),htm:r.toUpperCase(),htu:e,iat:Math.floor(Date.now()/1e3)};return t&&(s.ath=await rr(t)),o&&(s.nonce=o),await er(a,s,n.signingKey)}function x(n){return!n||n.length===0?!1:n.some(r=>r.toUpperCase()==="ES256")}async function er(n,r,e){let t=v(JSON.stringify(n)),o=v(JSON.stringify(r)),a=new TextEncoder().encode(`${t}.${o}`),s=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,a),l=D(s);return`${t}.${o}.${l}`}async function rr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return D(e)}function v(n){let r=new TextEncoder().encode(n);return D(r.buffer)}function D(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var tr=300*1e3,S=class{credentialBackend;callbackUrl;constructor(r){this.credentialBackend=new f,this.callbackUrl=r??`${window.location.origin}/browser/callback.html`}async authorize(r){let e=d(r),t=await this.discover(e);if(!t)return{success:!1,error:`No OAuth discovery endpoint found for '${e}'.`};if(!t.authorizationEndpoint||!t.tokenEndpoint)return{success:!1,error:`OAuth metadata incomplete for '${e}'.`};let o=x(t.dpopSigningAlgValuesSupported),a=null,s=null;if(o){let g=await k();a=g.keys,s=g.dpopKeyPair}let l=await this.credentialBackend.get(e),i=l?.clientId??null,c=l?.clientSecret??null;if(!i&&t.registrationEndpoint){let g=await this.registerClient(t.registrationEndpoint);if(!g)return{success:!1,error:`Dynamic client registration failed for '${e}'.`};i=g.clientId,c=g.clientSecret??null}if(!i)return{success:!1,error:`No OAuth client credentials for '${e}'.`};let m=nr(),p=await or(m),R=sr(),I=ir(t.authorizationEndpoint,i,this.callbackUrl,R,p),y=await this.openAuthPopup(I,R);if(!y)return{success:!1,error:"Authorization timed out or was cancelled."};if(y.error)return{success:!1,error:`Authorization failed: ${y.error}`};if(!y.code)return{success:!1,error:"No authorization code received."};if(y.state!==R)return{success:!1,error:"State mismatch \u2014 possible CSRF attack."};let P=await this.exchangeCode(t.tokenEndpoint,i,c,y.code,this.callbackUrl,m,a);if(!P)return{success:!1,error:"Token exchange failed."};let T={clientId:i,clientSecret:c,accessToken:P.accessToken??null,refreshToken:P.refreshToken??null,expiresAt:P.expiresIn?new Date(Date.now()+P.expiresIn*1e3).toISOString():null,tokenEndpoint:t.tokenEndpoint,dpopKeyPair:s};return await this.credentialBackend.store(e,T),{success:!0,host:e}}async getCredentialWithKeys(r){let e=await this.credentialBackend.get(r);if(!e)return null;let t=null;return e.dpopKeyPair&&(t=await b(e.dpopKeyPair)),{credential:e,dpopKeys:t}}async logout(r){let e=d(r);return await this.credentialBackend.remove(e),{success:!0,host:e}}async listAuthenticated(){return this.credentialBackend.list()}async discover(r){for(let e of[`https://${r}/.well-known/oauth-authorization-server`,`https://${r}/.well-known/openid-configuration`])try{let t=await fetch(e);if(!t.ok)continue;let o=await t.json();return{issuer:w(o.issuer),authorizationEndpoint:w(o.authorization_endpoint),tokenEndpoint:w(o.token_endpoint),registrationEndpoint:w(o.registration_endpoint),revocationEndpoint:w(o.revocation_endpoint),dpopSigningAlgValuesSupported:A(o.dpop_signing_alg_values_supported),codeChallengeMethodsSupported:A(o.code_challenge_methods_supported)}}catch{continue}return null}async registerClient(r){try{let e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"Kanonak Browser",redirect_uris:[this.callbackUrl],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"})});if(!e.ok)return null;let t=await e.json(),o=t.client_id;return o?{clientId:o,clientSecret:t.client_secret}:null}catch{return null}}openAuthPopup(r,e){return new Promise(t=>{let o=window.open(r,"kanonak-auth","width=500,height=700,menubar=no,toolbar=no,location=yes,status=no");if(!o){t(null);return}let a=setTimeout(()=>{i(),t(null)},tr),s=c=>{c.origin===window.location.origin&&(!c.data||c.data.type!=="kanonak-auth-callback"||(i(),t({code:c.data.code??void 0,state:c.data.state??void 0,error:c.data.error??void 0})))},l=setInterval(()=>{o.closed&&(i(),t(null))},500),i=()=>{clearTimeout(a),clearInterval(l),window.removeEventListener("message",s);try{o.close()}catch{}};window.addEventListener("message",s)})}async exchangeCode(r,e,t,o,a,s,l){let i=new URLSearchParams({grant_type:"authorization_code",client_id:e,code:o,redirect_uri:a,code_verifier:s});t&&i.set("client_secret",t);let c={"Content-Type":"application/x-www-form-urlencoded"};l&&(c.DPoP=await K(l,"POST",r));try{let m=await fetch(r,{method:"POST",headers:c,body:i.toString()});if(!m.ok)return null;let p=await m.json();return{accessToken:p.access_token,refreshToken:p.refresh_token,expiresIn:typeof p.expires_in=="number"?p.expires_in:void 0}}catch{return null}}};function nr(){let n=new Uint8Array(32);return crypto.getRandomValues(n),B(n.buffer)}async function or(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return B(e)}function sr(){let n=new Uint8Array(16);return crypto.getRandomValues(n),B(n.buffer)}function ir(n,r,e,t,o){let a=new URLSearchParams({client_id:r,response_type:"code",redirect_uri:e,state:t,code_challenge:o,code_challenge_method:"S256"});return`${n}?${a}`}function B(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function w(n){return typeof n=="string"?n:null}function A(n){return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}export{Je as AmbiguousReferenceRule,se as BooleanStatement,f as BrowserCredentialBackend,S as BrowserOAuthFlow,Ge as ClassDefinitionRule,Ie as ClassHierarchyCycleRule,X as DefinedKanonak,Me as DefinitionPropertyReferenceRule,fe as EdgeType,Y as EmbeddedKanonak,je as EmbeddedKanonakTypeRule,ae as EmbeddedStatement,me as GraphBuilder,F as HttpKanonakDocumentRepository,ve as ImportExistenceRule,H as InMemoryKanonakDocumentRepository,ze as InstancePropertyReferenceRule,G as Kanonak,we as KanonakDocumentPositions,pe as KanonakObjectParser,Qe as KanonakObjectValidator,q as KanonakParser,Z as KanonakUri,ke as KanonakUriBuilder,ce as ListStatement,Xe as MarkdownLinkRule,le as MarkdownStatement,Ue as NamespaceImportCycleRule,De as NamespacePrefixRule,ge as NodeType,oe as NumberStatement,qe as ObjectPropertyImportRule,Le as ObjectPropertyValueValidationRule,Se as OntologyValidationError,Ke as OntologyValidationResult,We as PropertyDomainRule,Te as PropertyHierarchyCycleRule,Pe as PropertyMetadata,He as PropertyRangeReferenceRule,Oe as PropertyRangeRequiredRule,Ce as PropertyTypeSpecificityRule,Fe as PropertyValueTypeRule,L as PublisherConfigResolver,W as PublisherIndex,ee as ReferenceKanonak,ie as ReferenceStatement,Be as ResourceNamingRule,ue as ResourceResolver,ye as ResourceTypeClassifier,te as ScalarStatement,re as Statement,ne as StringStatement,Ve as SubClassOfReferenceRule,$e as SubPropertyOfReferenceRule,Q as SubjectKanonak,Ee as SubjectKanonakTypeRequiredRule,Ae as TypeAmbiguityRule,de as TypeResolver,_e as UnresolvedReferenceRule,Re as ValidationContext,xe as ValidationSeverity,Ne as XsdImportRule,x as browserServerSupportsDPoP,O as compareVersions,K as createBrowserDPoPProof,U as createVersion,Ye as findDerivation,be as findInstancesByType,$ as formatVersion,k as generateBrowserDPoPKeyPair,_ as generateBrowserDPoPKeys,E as hasValidToken,b as importDPoPKeys,M as isCompatibleVersion,C as isExpired,N as isMajorCompatible,d as normalizeHost,z as parseVersionString,he as parseWithPositions,J as pickHighestDocument,V as versionsEqual};
|
|
@@ -8,7 +8,7 @@ Possible solutions:
|
|
|
8
8
|
kanonak namespace add-import <publisher>/<package>@<version>
|
|
9
9
|
\u2022 Check for typos in the reference name '${t}'
|
|
10
10
|
\u2022 Define '${t}' in the current namespace or an appropriate namespace
|
|
11
|
-
\u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,a=new g;return a.ruleType=this.ruleName,a.severity="Warning",a.entityName=e,a.propertyName=i,a.actualValue=t,a.message=`Reference to '${t}' could not be resolved`,a.suggestion=s,a.expectedValue="A valid entity reference that exists in the current document or imported namespaces",a}getPropertyValue(e,i){let t=e[i];return t?t.toString():null}};var S=class{ruleName="TypeAmbiguity";async validateAsync(e,i){let t=[],s=new Map,a=[];if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){a.push({doc:o,import:l,publisher:r});let p=await this.getTransitiveImportsAsync(i,o,new Set);a.push(...p.map(c=>({doc:c,import:null,publisher:r})))}}for(let{doc:r,import:n}of a){let l=r.metadata?.namespace_?.toString()??"unknown";for(let o of Object.keys(r.body))s.has(o)||s.set(o,[]),s.get(o).push({namespace:l,import:n})}for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n;this.checkAmbiguousReference(l,"type",s,r,t),this.checkAmbiguousReference(l,"subClassOf",s,r,t),this.checkAmbiguousReference(l,"subPropertyOf",s,r,t),this.checkAmbiguousReference(l,"domain",s,r,t),this.checkAmbiguousReference(l,"range",s,r,t)}return t}checkAmbiguousReference(e,i,t,s,a){let r=e[i];if(!r)return;let n=k(r);for(let l of n){if(l.includes("."))continue;let o=t.get(l);if(o&&o.length>1){let p=o.map(u=>u.namespace).join(", "),c=[];for(let{namespace:u,import:f}of o)if(f?.alias)c.push(`${f.alias}.${l}`);else{let d=u.split("/"),V=d[d.length-1]?.split("@")[0]??"alias";c.push(`${V}.${l}`)}let m=c.length>0?`Use one of: ${c.join(", ")}`:"Consider adding namespace aliases to your imports",y=new g;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=s,y.propertyName=i,y.actualValue=l,y.message=`Type '${l}' is ambiguous. It's defined in: ${p}`,y.suggestion=m,a.push(y)}}}async getTransitiveImportsAsync(e,i,t){let s=[],a=i.metadata?.namespace_?.toString()??"";if(t.has(a))return s;if(t.add(a),i.metadata?.imports)for(let[r,n]of Object.entries(i.metadata.imports))for(let l of n){let o=await e.getHighestCompatibleVersionAsync(r,l);if(o){s.push(o);let p=await this.getTransitiveImportsAsync(e,o,t);s.push(...p)}}return s}};var $=class{ruleName="ClassHierarchyCycle";async validateAsync(e,i){let t=[],s=new Map,a=new Set;await this.buildClassHierarchy(e,i,s,a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type,p=l.subClassOf;if(o?.toString()==="Class"&&p){let c=r,m=this.detectCycle(c,s);if(m){let y=m.join(" \u2192 "),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Circular class hierarchy detected: ${y}`,u.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",u.entityName=c,u.propertyName="subClassOf",u.actualValue=y,t.push(u);break}}}return t}async buildClassHierarchy(e,i,t,s){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&s.has(a))){a&&s.add(a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type,p=l.subClassOf;if(o?.toString()==="Class"&&p){let c=k(p);c.length>0&&t.set(r,c)}}if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);o&&await this.buildClassHierarchy(o,i,t,s)}}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){if(t.includes(e)){let r=t.indexOf(e),n=t.slice(r);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let a=i.get(e);if(a)for(let r of a){let n=this.detectCycleRecursive(r,i,t,s);if(n)return n}return t.pop(),null}};var T=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,i){let t=[],s=new Map,a=new Set;await this.buildPropertyHierarchy(e,i,s,a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let p=r,c=this.detectCycle(p,s);if(c){let m=c.join(" \u2192 "),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Circular property hierarchy detected: ${m}`,y.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",y.entityName=p,y.propertyName="subPropertyOf",y.actualValue=m,t.push(y);break}}return t}async buildPropertyHierarchy(e,i,t,s){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&s.has(a))){a&&s.add(a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type;if(o){let p=o.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let c=l.subPropertyOf;if(c){let m=k(c);m.length>0&&t.set(r,m)}}}}if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);o&&await this.buildPropertyHierarchy(o,i,t,s)}}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){if(t.includes(e)){let r=t.indexOf(e),n=t.slice(r);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let a=i.get(e);if(a)for(let r of a){let n=this.detectCycleRecursive(r,i,t,s);if(n)return n}return t.pop(),null}};var C=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,i){let t=[];for(let[s,a]of Object.entries(e.body)){if(typeof a!="object"||a===null||Array.isArray(a))continue;let r=a,n=r.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let l="range"in r,o=r.range?.toString().trim();if(!l||!o){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=s,p.propertyName="range",p.message=`Property '${s}' must have a 'range' defined.`,p.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var K=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,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();this.isClassLikeType(l)&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=k(r.subClassOf);for(let o=0;o<l.length;o++){let p=l[o];if(this.builtInClasses.has(p)||s.has(p))continue;if(!await this.isClassAvailableInImports(e,i,p)){let m=l.length>1?`[${o}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Class '${p}' referenced in subClassOf${m} 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",t.push(y)}}}return t}async isClassAvailableInImports(e,i,t){if(!e.metadata.imports)return!1;let s=null,a=t;if(t.includes(".")){let r=t.split(".",2);s=r[0],a=r[1]}for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){if(s!==null&&l.alias!==s)continue;let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=s!==null?a:t,c=o.body[p];if(c&&typeof c=="object"&&!Array.isArray(c)){let u=c.type?.toString();if(this.isClassLikeType(u))return!0}let m=new Set;if(await this.isClassAvailableInImportsRecursive(o,i,p,m))return!0}}return!1}async isClassAvailableInImportsRecursive(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(a&&s.has(a)||(a&&s.add(a),!e.metadata.imports))return!1;for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=o.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isClassLikeType(m))return!0}if(await this.isClassAvailableInImportsRecursive(o,i,t,s))return!0}}return!1}};var x=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();(l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty")&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=k(r.subPropertyOf);for(let o=0;o<l.length;o++){let p=l[o];if(this.builtInProperties.has(p)||s.has(p))continue;if(!await this.isPropertyAvailableInImports(e,i,p)){let m=l.length>1?`[${o}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Property '${p}' referenced in subPropertyOf${m} 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",t.push(y)}}}return t}async isPropertyAvailableInImports(e,i,t){if(!e.metadata.imports)return!1;let s=null,a=t;if(t.includes(".")){let r=t.split(".",2);s=r[0],a=r[1]}for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){if(s!==null&&l.alias!==s)continue;let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=s!==null?a:t,c=o.body[p];if(c&&typeof c=="object"&&!Array.isArray(c)){let u=c.type?.toString();if(u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty")return!0}let m=new Set;if(await this.isPropertyAvailableInImportsRecursive(o,i,p,m))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(a&&s.has(a)||(a&&s.add(a),!e.metadata.imports))return!1;for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=o.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(o,i,t,s))return!0}}return!1}};var W=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,i){let t=[],s=e.metadata.namespace_?.toString();if(!s)return t;let a=new Map,r=new Set;await this.buildImportGraph(e,i,a,r);let n=this.detectCycle(s,a);if(n){let l=n.join(" \u2192 "),o=new g;o.ruleType=this.ruleName,o.severity="Error",o.message=`Circular namespace import detected: ${l}`,o.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",o.entityName="imports",o.propertyName="imports",o.actualValue=l,t.push(o)}return t}async buildImportGraph(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(!(!a||s.has(a))&&(s.add(a),e.metadata.imports)){let r=[];for(let[n,l]of Object.entries(e.metadata.imports))for(let o of l){let p=`${n}/${o.packageName}@${o.version}`;r.push(p);let c=await i.getHighestCompatibleVersionAsync(n,o);c&&await this.buildImportGraph(c,i,t,s)}r.length>0&&t.set(a,r)}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){let a=t.indexOf(e);if(a>=0){let n=t.slice(a);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let r=i.get(e);if(r)for(let n of r){let l=this.detectCycleRecursive(n,i,t,s);if(l)return l}return t.pop(),null}};var M=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();this.isPropertyType(l)&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let n=r,l=n.type?.toString();if(this.isPropertyType(l)||this.isClassType(l))continue;for(let[o,p]of Object.entries(n)){if(!o||this.metadataKeys.has(o))continue;let c=o,m=null;if(o.includes(".")){let u=o.lastIndexOf(".");m=o.substring(0,u),c=o.substring(u+1)}if(s.has(c))continue;if(!await this.isPropertyAvailableInImports(e,i,c,m)){let u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Property '${o}' is not defined or imported`,u.suggestion=m?`The property '${c}' is not found in the imported namespace with alias '${m}'.
|
|
11
|
+
\u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=i,a.actualValue=t,a.message=`Reference to '${t}' could not be resolved`,a.suggestion=s,a.expectedValue="A valid entity reference that exists in the current document or imported namespaces",a}getPropertyValue(e,i){let t=e[i];return t?t.toString():null}};var S=class{ruleName="TypeAmbiguity";async validateAsync(e,i){let t=[],s=new Map,a=[];if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){a.push({doc:o,import:l,publisher:r});let p=await this.getTransitiveImportsAsync(i,o,new Set);a.push(...p.map(c=>({doc:c,import:null,publisher:r})))}}for(let{doc:r,import:n}of a){let l=r.metadata?.namespace_?.toString()??"unknown";for(let o of Object.keys(r.body))s.has(o)||s.set(o,[]),s.get(o).push({namespace:l,import:n})}for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n;this.checkAmbiguousReference(l,"type",s,r,t),this.checkAmbiguousReference(l,"subClassOf",s,r,t),this.checkAmbiguousReference(l,"subPropertyOf",s,r,t),this.checkAmbiguousReference(l,"domain",s,r,t),this.checkAmbiguousReference(l,"range",s,r,t)}return t}checkAmbiguousReference(e,i,t,s,a){let r=e[i];if(!r)return;let n=k(r);for(let l of n){if(l.includes("."))continue;let o=t.get(l);if(o&&o.length>1){let p=o.map(u=>u.namespace).join(", "),c=[];for(let{namespace:u,import:f}of o)if(f?.alias)c.push(`${f.alias}.${l}`);else{let d=u.split("/"),V=d[d.length-1]?.split("@")[0]??"alias";c.push(`${V}.${l}`)}let m=c.length>0?`Use one of: ${c.join(", ")}`:"Consider adding namespace aliases to your imports",y=new g;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=s,y.propertyName=i,y.actualValue=l,y.message=`Type '${l}' is ambiguous. It's defined in: ${p}`,y.suggestion=m,a.push(y)}}}async getTransitiveImportsAsync(e,i,t){let s=[],a=i.metadata?.namespace_?.toString()??"";if(t.has(a))return s;if(t.add(a),i.metadata?.imports)for(let[r,n]of Object.entries(i.metadata.imports))for(let l of n){let o=await e.getHighestCompatibleVersionAsync(r,l);if(o){s.push(o);let p=await this.getTransitiveImportsAsync(e,o,t);s.push(...p)}}return s}};var $=class{ruleName="ClassHierarchyCycle";async validateAsync(e,i){let t=[],s=new Map,a=new Set;await this.buildClassHierarchy(e,i,s,a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type,p=l.subClassOf;if(o?.toString()==="Class"&&p){let c=r,m=this.detectCycle(c,s);if(m){let y=m.join(" \u2192 "),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Circular class hierarchy detected: ${y}`,u.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",u.entityName=c,u.propertyName="subClassOf",u.actualValue=y,t.push(u);break}}}return t}async buildClassHierarchy(e,i,t,s){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&s.has(a))){a&&s.add(a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type,p=l.subClassOf;if(o?.toString()==="Class"&&p){let c=k(p);c.length>0&&t.set(r,c)}}if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);o&&await this.buildClassHierarchy(o,i,t,s)}}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){if(t.includes(e)){let r=t.indexOf(e),n=t.slice(r);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let a=i.get(e);if(a)for(let r of a){let n=this.detectCycleRecursive(r,i,t,s);if(n)return n}return t.pop(),null}};var T=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,i){let t=[],s=new Map,a=new Set;await this.buildPropertyHierarchy(e,i,s,a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let p=r,c=this.detectCycle(p,s);if(c){let m=c.join(" \u2192 "),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Circular property hierarchy detected: ${m}`,y.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",y.entityName=p,y.propertyName="subPropertyOf",y.actualValue=m,t.push(y);break}}return t}async buildPropertyHierarchy(e,i,t,s){let a=e.metadata?.namespace_?.toString()??"";if(!(a&&s.has(a))){a&&s.add(a);for(let[r,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,o=l.type;if(o){let p=o.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let c=l.subPropertyOf;if(c){let m=k(c);m.length>0&&t.set(r,m)}}}}if(e.metadata?.imports)for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);o&&await this.buildPropertyHierarchy(o,i,t,s)}}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){if(t.includes(e)){let r=t.indexOf(e),n=t.slice(r);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let a=i.get(e);if(a)for(let r of a){let n=this.detectCycleRecursive(r,i,t,s);if(n)return n}return t.pop(),null}};var C=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,i){let t=[];for(let[s,a]of Object.entries(e.body)){if(typeof a!="object"||a===null||Array.isArray(a))continue;let r=a,n=r.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let l="range"in r,o=r.range?.toString().trim();if(!l||!o){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=s,p.propertyName="range",p.message=`Property '${s}' must have a 'range' defined.`,p.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var K=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,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();this.isClassLikeType(l)&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=k(r.subClassOf);for(let o=0;o<l.length;o++){let p=l[o];if(this.builtInClasses.has(p)||s.has(p))continue;if(!await this.isClassAvailableInImports(e,i,p)){let m=l.length>1?`[${o}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Class '${p}' referenced in subClassOf${m} 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",t.push(y)}}}return t}async isClassAvailableInImports(e,i,t){if(!e.metadata.imports)return!1;let s=null,a=t;if(t.includes(".")){let r=t.split(".",2);s=r[0],a=r[1]}for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){if(s!==null&&l.alias!==s)continue;let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=s!==null?a:t,c=o.body[p];if(c&&typeof c=="object"&&!Array.isArray(c)){let u=c.type?.toString();if(this.isClassLikeType(u))return!0}let m=new Set;if(await this.isClassAvailableInImportsRecursive(o,i,p,m))return!0}}return!1}async isClassAvailableInImportsRecursive(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(a&&s.has(a)||(a&&s.add(a),!e.metadata.imports))return!1;for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=o.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(this.isClassLikeType(m))return!0}if(await this.isClassAvailableInImportsRecursive(o,i,t,s))return!0}}return!1}};var x=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();(l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty")&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=k(r.subPropertyOf);for(let o=0;o<l.length;o++){let p=l[o];if(this.builtInProperties.has(p)||s.has(p))continue;if(!await this.isPropertyAvailableInImports(e,i,p)){let m=l.length>1?`[${o}]`:"",y=new g;y.ruleType=this.ruleName,y.severity="Error",y.message=`Property '${p}' referenced in subPropertyOf${m} 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",t.push(y)}}}return t}async isPropertyAvailableInImports(e,i,t){if(!e.metadata.imports)return!1;let s=null,a=t;if(t.includes(".")){let r=t.split(".",2);s=r[0],a=r[1]}for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){if(s!==null&&l.alias!==s)continue;let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=s!==null?a:t,c=o.body[p];if(c&&typeof c=="object"&&!Array.isArray(c)){let u=c.type?.toString();if(u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty")return!0}let m=new Set;if(await this.isPropertyAvailableInImportsRecursive(o,i,p,m))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(a&&s.has(a)||(a&&s.add(a),!e.metadata.imports))return!1;for(let[r,n]of Object.entries(e.metadata.imports))for(let l of n){let o=await i.getHighestCompatibleVersionAsync(r,l);if(o){let p=o.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let m=p.type?.toString();if(m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(o,i,t,s))return!0}}return!1}};var M=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,i){let t=[],s=e.metadata.namespace_?.toString();if(!s)return t;let a=new Map,r=new Set;await this.buildImportGraph(e,i,a,r);let n=this.detectCycle(s,a);if(n){let l=n.join(" \u2192 "),o=new g;o.ruleType=this.ruleName,o.severity="Error",o.message=`Circular namespace import detected: ${l}`,o.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",o.entityName="imports",o.propertyName="imports",o.actualValue=l,t.push(o)}return t}async buildImportGraph(e,i,t,s){let a=e.metadata.namespace_?.toString()??"";if(!(!a||s.has(a))&&(s.add(a),e.metadata.imports)){let r=[];for(let[n,l]of Object.entries(e.metadata.imports))for(let o of l){let p=`${n}/${o.packageName}@${o.version}`;r.push(p);let c=await i.getHighestCompatibleVersionAsync(n,o);c&&await this.buildImportGraph(c,i,t,s)}r.length>0&&t.set(a,r)}}detectCycle(e,i){let t=[],s=new Set;return this.detectCycleRecursive(e,i,t,s)}detectCycleRecursive(e,i,t,s){let a=t.indexOf(e);if(a>=0){let n=t.slice(a);return n.push(e),n}if(s.has(e))return null;t.push(e),s.add(e);let r=i.get(e);if(r)for(let n of r){let l=this.detectCycleRecursive(n,i,t,s);if(l)return l}return t.pop(),null}};var W=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,i){let t=[],s=new Set;for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let l=r.type?.toString();this.isPropertyType(l)&&s.add(a)}for(let[a,r]of Object.entries(e.body))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let n=r,l=n.type?.toString();if(this.isPropertyType(l)||this.isClassType(l))continue;for(let[o,p]of Object.entries(n)){if(!o||this.metadataKeys.has(o))continue;let c=o,m=null;if(o.includes(".")){let u=o.lastIndexOf(".");m=o.substring(0,u),c=o.substring(u+1)}if(s.has(c))continue;if(!await this.isPropertyAvailableInImports(e,i,c,m)){let u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Property '${o}' is not defined or imported`,u.suggestion=m?`The property '${c}' is not found in the imported namespace with alias '${m}'.
|
|
12
12
|
1. Verify the namespace is imported with the correct alias
|
|
13
13
|
2. Check if the property name is spelled correctly
|
|
14
14
|
3. Ensure the imported namespace version contains this property`:`The property '${o}' is not defined in this namespace or any imported namespace.
|
|
@@ -44,4 +44,4 @@ ${V.slice(1).map(P=>` - ${P}`).join(`
|
|
|
44
44
|
Possible solutions:
|
|
45
45
|
\u2022 Import the package that defines '${t}' so the link can resolve
|
|
46
46
|
\u2022 Check for typos in the reference name
|
|
47
|
-
\u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,s}};var J=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new ee,this.documentRules=[new D,new I,new O,new j],this.repositoryRules=[new w,new E,new N,new S,new $,new T,new C,new K,new x,new
|
|
47
|
+
\u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,s}};var J=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new ee,this.documentRules=[new D,new I,new O,new j],this.repositoryRules=[new w,new E,new N,new S,new $,new T,new C,new K,new x,new M,new W,new L,new _,new H,new U,new F,new q,new X,new z,new B,new Y]}async validateAsync(e,i){let t=new v;for(let s of this.documentRules)try{let a=s.validate(e);this.addErrorsToResult(t,a)}catch(a){let r=new g;r.ruleType=s.ruleName,r.severity="Error",r.message=`Validation rule '${s.ruleName}' failed: ${a instanceof Error?a.message:String(a)}`,t.errors.push(r)}if(i){let s=[];for(let a of this.repositoryRules)try{let r=await a.validateAsync(e,i);this.addErrorsToResult(t,r)}catch(r){let n=r instanceof Error?r.message:String(r);s.push({ruleName:a.ruleName,cause:n})}if(s.length>0){let a=new Map;for(let{ruleName:r,cause:n}of s){let l=a.get(n);l?l.push(r):a.set(n,[r])}for(let[r,n]of a){let l=new g;l.ruleType=n[0],l.severity="Error",n.length===1?l.message=`Validation rule '${n[0]}' failed: ${r}`:l.message=`${r} (affects ${n.length} rules: ${n.join(", ")})`,t.errors.push(l)}}}return t.isValid=t.errors.length===0,t}async validateYamlAsync(e,i){let t=this.parser.parseWithErrors(e);if(!t.isValid){let s=new v;s.isValid=!1;for(let a of t.errors){let r=new g;r.ruleType="ParseError",r.severity="Error",r.lineNumber=a.line,r.column=a.column,r.message=a.message,a.keyName&&(r.entityName=a.keyName),a.errorType==="DuplicateKey"&&(r.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(r)}return s}return await this.validateAsync(t.document,i)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let i=this.documentRules.findIndex(t=>t instanceof e);i>=0&&this.documentRules.splice(i,1)}removeRepositoryRule(e){let i=this.repositoryRules.findIndex(t=>t instanceof e);i>=0&&this.repositoryRules.splice(i,1)}addErrorsToResult(e,i){for(let t of i)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{v as a,R as b,g as c,G as d,D as e,I as f,O as g,j as h,w as i,E as j,N as k,S as l,$ as m,T as n,C as o,K as p,x as q,M as r,W as s,L as t,_ as u,H as v,U as w,F as x,q as y,X as z,z as A,B,Y as C,J as D};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-GD4SYMXW.js";import{a as Wt}from"./chunk-ROCCA4BY.js";import{a as Te,b as je,c as Le,d as Ne,e as Fe}from"./chunk-3JRHG2JH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-CNM3SY5S.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-63NJ25ZX.js";import{a as Je,b as mt,c as ft,d as yt,e as gt}from"./chunk-VRZUCZEF.js";import{a as Pe,b as Re,c as we,d as $e,e as xe,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{A as _t,B as Mt,C as zt,D as Gt,a as ht,b as kt,c as bt,d as St,e as Ct,f as Pt,g as Rt,h as wt,i as $t,j as xt,k as vt,l as Et,m as Kt,n as Bt,o as It,p as Tt,q as jt,r as Lt,s as Nt,t as Ft,u as Dt,v as Ot,w as At,x as Ht,y as Vt,z as Ut}from"./chunk-
|
|
1
|
+
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-GD4SYMXW.js";import{a as Wt}from"./chunk-ROCCA4BY.js";import{a as Te,b as je,c as Le,d as Ne,e as Fe}from"./chunk-3JRHG2JH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-CNM3SY5S.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-63NJ25ZX.js";import{a as Je,b as mt,c as ft,d as yt,e as gt}from"./chunk-VRZUCZEF.js";import{a as Pe,b as Re,c as we,d as $e,e as xe,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{A as _t,B as Mt,C as zt,D as Gt,a as ht,b as kt,c as bt,d as St,e as Ct,f as Pt,g as Rt,h as wt,i as $t,j as xt,k as vt,l as Et,m as Kt,n as Bt,o as It,p as Tt,q as jt,r as Lt,s as Nt,t as Ft,u as Dt,v as Ot,w as At,x as Ht,y as Vt,z as Ut}from"./chunk-LPUWDJMI.js";import"./chunk-FJ35VIV6.js";import{a as N,b as D,c as Me,e as We}from"./chunk-R2V7IXWN.js";import{a as He,b as j,c as L,d as F,e as Ue,f as _e,g as O,h as A,i as H,j as V,k as U,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.js";import{b as ze,c as Ge}from"./chunk-IXE5THUW.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as to}from"@kanonak-protocol/types/document/models/enums";import{existsSync as ur,readFileSync as pr}from"fs";import{homedir as mr}from"os";import{join as fr}from"path";import{execFile as Jt}from"child_process";import{promisify as qt}from"util";var C=qt(Jt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
|
|
2
2
|
Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
|
|
3
3
|
The Keychain may be locked or inaccessible.
|
|
4
4
|
Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-LPUWDJMI.js";import"../chunk-FJ35VIV6.js";import"../chunk-R2V7IXWN.js";import"../chunk-W6T7MOKY.js";import"../chunk-MYITGTGJ.js";import"../chunk-IXE5THUW.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,i as EmbeddedKanonakTypeRule,j as ImportExistenceRule,s as InstancePropertyReferenceRule,D as KanonakObjectValidator,C as MarkdownLinkRule,r as NamespaceImportCycleRule,e as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,g as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,f as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,h as SubjectKanonakTypeRequiredRule,l as TypeAmbiguityRule,k as UnresolvedReferenceRule,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yaml-parser"
|
|
114
114
|
],
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.
|
|
116
|
+
"@kanonak-protocol/types": "^3.23.0",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|