@kanonak-protocol/sdk 5.33.0 → 5.34.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,4 +1,4 @@
1
- import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-PVUBHIU2.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-7UYXTYXC.js";import{c as we,u as re}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
1
+ import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-FL42CQAH.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{l as oe}from"../chunk-A7N2BMMP.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{d as Re}from"../chunk-ESABMC5L.js";import{c as we,u as re}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
2
2
  `),t=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
3
3
  `),a=o.renderStack.packages.map(s=>{let l=s.origin!=="missing"&&!s.resolvedButNotInCatalog,f=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,p=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${l?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${f}</td><td>${p}</td></tr>`}).join(`
4
4
  `),u=o.stylesheet.baseStylesheet,d=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,k=o.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
@@ -16,15 +16,25 @@ import { type ShaclNodeShapeModel, type ShaclSeverity } from './ShapesModel.js';
16
16
  * HOST PROJECTIONS: `sh:datatype` (the typed statement + the canonical
17
17
  * layer's carrier routing), `sh:class` (resolution + type closure),
18
18
  * `sh:nodeKind` (statement kind), `sh:closed` (the focus node's predicate
19
- * set vs. the shape's declared paths, over the scope).
19
+ * set vs. the shape's declared paths, over the scope), and the qualified
20
+ * value shape (nested shape evaluation per value node, then a count).
21
+ *
22
+ * A focus node is any node in the scope: a top-level subject, or an embedded
23
+ * value — an instance of its declared type or, when it declares none, of the
24
+ * range of the property it is a value of (typescript#119). An embedded focus
25
+ * node is addressed under its subject with the protocol's fragment path
26
+ * (`…/box#parts[0]`).
20
27
  *
21
28
  * Every finding names its focus node, path, offending value, and constraint
22
29
  * component — the material a ValidationReport is assembled from.
23
30
  */
24
31
  export interface ShaclFinding {
25
- /** Canonical URI key of the focus node (`publisher/package/name`). */
32
+ /**
33
+ * Canonical key of the focus node: `publisher/package/name` for a subject,
34
+ * `<subject key>#<property path>` for an embedded value.
35
+ */
26
36
  focusNode: string;
27
- /** The focus node's full URI when it carries a resolvable version. */
37
+ /** The focus node's full URI when it is a subject carrying a resolvable version. */
28
38
  focusUri?: KanonakUri | undefined;
29
39
  /** The constrained property, for property-level findings. */
30
40
  resultPath?: KanonakUri | undefined;
@@ -32,9 +32,37 @@ export interface ShaclPropertyConstraint {
32
32
  datatype?: KanonakUri | undefined;
33
33
  classRef?: KanonakUri | undefined;
34
34
  nodeKind?: ShaclNodeKind | undefined;
35
+ /** `sh:hasValue` — a named individual at least one value must equal. */
36
+ hasValue?: KanonakUri | undefined;
37
+ /** `sh:qualifiedValueShape` with its `sh:qualifiedMinCount` / `sh:qualifiedMaxCount` bounds. */
38
+ qualified?: ShaclQualifiedConstraint | undefined;
35
39
  message?: string | undefined;
36
40
  severity?: ShaclSeverity | undefined;
37
41
  }
42
+ /**
43
+ * The shape a qualified constraint checks each value against: a property
44
+ * shape (it has a path; the value is its focus node) or a node shape (its
45
+ * property constraints and closedness; its targets play no part).
46
+ */
47
+ export type ShaclQualifiedShape = {
48
+ kind: 'property';
49
+ constraint: ShaclPropertyConstraint;
50
+ } | {
51
+ kind: 'node';
52
+ shape: ShaclNodeShapeModel;
53
+ };
54
+ export interface ShaclQualifiedConstraint {
55
+ /**
56
+ * The shape each value is checked against. Absent when it could not be
57
+ * built — a reference that names no shape, or a cycle through named shapes —
58
+ * and then `problem` says why and evaluation fails closed: a count the
59
+ * evaluator cannot compute is never reported as satisfied.
60
+ */
61
+ shape?: ShaclQualifiedShape | undefined;
62
+ problem?: string | undefined;
63
+ minCount?: number | undefined;
64
+ maxCount?: number | undefined;
65
+ }
38
66
  export interface ShaclNodeShapeModel {
39
67
  /** The shape's local name (diagnostics + `sh:sourceShape`). */
40
68
  name: string;
@@ -8,10 +8,11 @@ export interface LoweredExprNode {
8
8
  export declare const LOWERED_VALUES_VAR = "values";
9
9
  export declare const LOWERED_VALUE_VAR = "v";
10
10
  export declare const LOWERED_ALLOWED_VAR = "allowed";
11
+ export declare const LOWERED_EXPECTED_VAR = "expected";
11
12
  export interface LoweredCheck {
12
13
  /** Which constraint this check enforces (the report's discriminant). */
13
- component: 'minCount' | 'maxCount' | 'in' | 'pattern' | 'minLength' | 'maxLength' | 'minInclusive' | 'maxInclusive';
14
- /** `node` = once per focus node (binds `values`); `value` = once per value (binds `v`, and `allowed` for `in`). */
14
+ component: 'minCount' | 'maxCount' | 'hasValue' | 'in' | 'pattern' | 'minLength' | 'maxLength' | 'minInclusive' | 'maxInclusive';
15
+ /** `node` = once per focus node (binds `values`, and `expected` for `hasValue`); `value` = once per value (binds `v`, and `allowed` for `in`). */
15
16
  per: 'node' | 'value';
16
17
  expr: LoweredExprNode;
17
18
  }
@@ -63,3 +63,10 @@ export declare const SH_COMP_MIN_INCLUSIVE: EntityUri;
63
63
  export declare const SH_COMP_MAX_INCLUSIVE: EntityUri;
64
64
  export declare const SH_COMP_NODE_KIND: EntityUri;
65
65
  export declare const SH_COMP_CLOSED: EntityUri;
66
+ export declare const SH_HAS_VALUE: EntityUri;
67
+ export declare const SH_QUALIFIED_VALUE_SHAPE: EntityUri;
68
+ export declare const SH_QUALIFIED_MIN_COUNT: EntityUri;
69
+ export declare const SH_QUALIFIED_MAX_COUNT: EntityUri;
70
+ export declare const SH_COMP_HAS_VALUE: EntityUri;
71
+ export declare const SH_COMP_QUALIFIED_MIN_COUNT: EntityUri;
72
+ export declare const SH_COMP_QUALIFIED_MAX_COUNT: EntityUri;
@@ -1,4 +1,4 @@
1
- import{a as pe}from"../chunk-L2J7WD7E.js";import"../chunk-BS7RRG7D.js";import{a as ve,b as M,c as Un,l as X,m as Vn,n as Rn,o as le,p as q,r as G}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-PVUBHIU2.js";import{a as se}from"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-7UYXTYXC.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
1
+ import{a as pe}from"../chunk-R53WM2ZP.js";import"../chunk-JIQNO36P.js";import{a as ve,b as M,c as Un,l as X,m as Vn,n as Rn,o as le,p as q,r as G}from"../chunk-FL42CQAH.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import{a as ue,b as de,d as $n,e as Tn,f as Bn,g as xn,l as fe}from"../chunk-A7N2BMMP.js";import{a as se}from"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{a as ce,f as U}from"../chunk-ESABMC5L.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
2
2
  `);return t?.trailingNewline&&(s.endsWith(`
3
3
  `)||(s+=`
4
4
  `)),s}};function Ie(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(P(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(P(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(P),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=P(f??c),d=ye(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function P(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function ye(e,n){switch(e.kind){case"StringScalar":return _e(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=ye(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function _e(e,n){return!n||ge(n,m.ESC_RAW)?e:ge(n,m.ESC_YAML_SAFE)?Ce(e):e}function Ce(e){return e.includes(`
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,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-C63WFML4.js";import"../chunk-KIBR3HAT.js";import"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,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-LO5IH6OE.js";import"../chunk-KIBR3HAT.js";import"../chunk-FL42CQAH.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-A7N2BMMP.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-ESABMC5L.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
@@ -10,6 +10,12 @@ import type { ValidationCache } from '../../ValidationCache.js';
10
10
  * `rdfs.label` apply universally). A property with no declared `domain` imposes
11
11
  * no constraint.
12
12
  *
13
+ * An instance's type is what `contextTypesOf` says: its declared `type`, or —
14
+ * for an embedded value that declares none — the range of the property it is a
15
+ * value of. An untyped embedded value is therefore checked too, against the
16
+ * range it takes its type from; a property that belongs to a narrower class
17
+ * needs that class declared on the embedded value, as it would on a subject.
18
+ *
13
19
  * Reads the resolved object model (recursively, on embeddeds at any depth), NOT
14
20
  * raw `document.body`: the predicate is the property's canonical URI, scope is
15
21
  * the single canonical `superClassChain` walk, and domain membership is compared
@@ -24,6 +24,19 @@ export declare class ShaclShapeRule implements IRepositoryValidationRule {
24
24
  readonly ruleName = "ShaclShape";
25
25
  validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
26
26
  private checkPropertyShape;
27
+ private checkQualified;
28
+ /** An inline qualified shape — a property shape (it has a path) or a node shape. */
29
+ private checkNestedShape;
30
+ /**
31
+ * The chain of named shapes by which a shape's qualified value shapes lead
32
+ * back to a shape already on the path, or undefined. Walks inline shapes,
33
+ * node shapes' property shapes, and named references.
34
+ */
35
+ private qualifiedCycle;
36
+ private pushCycle;
37
+ /** A path whose values are literals — a DatatypeProperty, or a generic property whose range is a datatype. */
38
+ private isDatatypeProperty;
39
+ private isInstanceOf;
27
40
  private checkOrder;
28
41
  private resolvesToClass;
29
42
  private resolvesToDatatype;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "5.33.0",
3
+ "version": "5.34.0",
4
4
  "description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -134,7 +134,7 @@
134
134
  ],
135
135
  "dependencies": {
136
136
  "@kanonak-protocol/canonical": "^0.1.3",
137
- "@kanonak-protocol/types": "^5.33.0",
137
+ "@kanonak-protocol/types": "^5.34.0",
138
138
  "ignore": "^7.0.5",
139
139
  "js-yaml": "^4.1.0",
140
140
  "yaml": "^2.7.0",
@@ -1 +0,0 @@
1
- import{B as z,c as G,d as X,m as b,n as Y,p as q,t as W,u as v,y as j,z as w}from"./chunk-CJMVIOZX.js";import{a as _}from"./chunk-FUUTGGJS.js";import{b as I}from"./chunk-F67UH4FD.js";var J=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let r=n.metadata?.namespace_?.toString()??"unknown",a=this.cache.get(r);if(a){let i=a.get(e);if(i)return i}let o=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(r,o),o.get(e)??null}async resolveAllEntitiesAsync(e,n){let r=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let a=e.split("."),o=a[0],i=a[1],u=await this.findDocumentForAlias(n,o);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(a=>a.entityName===e)}async buildAllEntitiesIndexAsync(e,n,r){let a=[],o=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${o}`),n.has(o))return this.logger?.debug?.(`Skipping ${o} - already visited (circular import prevention)`),a;n.add(o);let i=r.length===0?o:`${r} \u2192 ${o}`;for(let[u,c]of Object.entries(e.body))if(!u.includes(".")&&c&&typeof c=="object"&&!Array.isArray(c)){if(!e.metadata.namespace_)continue;let m=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.push({entityName:u,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,m),entity:c,definedInNamespace:o,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${a.length} entities from ${o}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,m)=>c+m.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${o}`);for(let[c,m]of Object.entries(e.metadata.imports))for(let d of m)if(!I(d))try{this.logger?.debug?.(`Resolving import: ${c}/${d.packageName}`);let g=await this.repository.getHighestCompatibleVersionAsync(c,d);if(g){this.logger?.debug?.(`Successfully loaded import: ${g.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(g,n,i);a.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${g.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${d.packageName}`)}catch(g){let k=g;throw this.logger?.error?.(`Failed to process import ${c}/${d.packageName} for namespace ${o}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${d.packageName} for namespace ${o}. See inner exception for details.`,{cause:g})}}return a}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,r,a){let o=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),o;let u=a.get(i);if(u)return u;n.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,m=0;for(let[d,g]of Object.entries(e.body))if(!d.includes(".")&&g&&typeof g=="object"&&!Array.isArray(g)){if(!e.metadata.namespace_)continue;if(!o.has(d)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};o.set(d,{entityName:d,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,k),entity:g,definedInNamespace:i,isImported:r.length>0,importPath:c}),m++}}if(this.logger?.debug?.(`Indexed ${m} entities from ${i}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((g,k)=>g+k.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${i}`);for(let[g,k]of Object.entries(e.metadata.imports))for(let h of k)if(!I(h))try{this.logger?.debug?.(`Resolving import: ${g}/${h.packageName}`);let P=await this.repository.getHighestCompatibleVersionAsync(g,h);if(P){this.logger?.debug?.(`Successfully loaded import: ${P.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(P,n,c,a),$=0;for(let[x,K]of U.entries()){let S=o.get(x);if(!S)o.set(x,K),$++;else if(S.isImported&&K.isImported&&(S.uri.publisher!==K.uri.publisher||S.uri.package_!==K.uri.package_)){let C=S.isAmbiguous?S:{...S,isAmbiguous:!0,ambiguousNamespaces:[S.definedInNamespace]};C.ambiguousNamespaces.includes(K.definedInNamespace)||C.ambiguousNamespaces.push(K.definedInNamespace),o.set(x,C),this.logger?.warn?.(`Ambiguous reference '${x}': defined in ${C.ambiguousNamespaces.join(", ")}`)}if(h.alias&&!x.includes(".")){let C=`${h.alias}.${x}`;o.has(C)||(o.set(C,K),$++)}}this.logger?.debug?.(`Merged ${$} entities from import ${P.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${g}/${h.packageName}`)}catch(P){let U=P;throw this.logger?.error?.(`Failed to process import ${g}/${h.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${g}/${h.packageName} for namespace ${i}. See inner exception for details.`,{cause:P})}}return n.delete(i),a.set(i,o),o}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[r,a]of Object.entries(e.metadata.imports))for(let o of a)if(!I(o)){if(o.alias===n)return await this.repository.getHighestCompatibleVersionAsync(r,o);if(!o.alias&&o.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(r,o)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var Q=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let r=await this.resourceResolver.resolveEntityAsync(e,n);if(r){let a=r.entity.type;if(a){let o=String(a);return o==="Class"||o==="rdfs.Class"||o.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function Z(t){if(!t||t.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let e=t.trim(),n=e.split("/");if(n.length===1){let r=n[0];if(!r)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${t}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(n.length===2){let[r,a]=n;if(!r||!a)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:r,package_:a};let i=a.substring(0,o),u=a.substring(o+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let c=se(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:_.parse(e)}}function Te(t){switch(t.kind){case"publisher":return t.publisher;case"package":return t.version?`${t.publisher}/${t.package_}@${t.version.major}.${t.version.minor}.${t.version.patch}`:`${t.publisher}/${t.package_}`;case"resource":return t.uri.toString()}}function se(t){let e=t.split(".").map(Number);return ie(e[0]||0,e[1]||0,e[2]||0)}function ie(t,e,n){return{major:t,minor:e,patch:n,toString:()=>`${t}.${e}.${n}`,equals:r=>!r||typeof r!="object"?!1:r.major===t&&r.minor===e&&r.patch===n,getHashCode:()=>t<<20|e<<10|n,compareTo:r=>t!==r.major?t-r.major:e!==r.minor?e-r.minor:n-r.patch}}function De(t){return`${t.publisher}/${t.package_}/${t.name}`}function y(t,e,n){return`${t}/${e}/${n}`}function $e(t){return`${t.s}|${t.p}|${pe(t.o)}`}function pe(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function ve(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var ce="kanonak.org",le="core-shacl",s=t=>({publisher:ce,package_:le,name:t}),N=s("Shape"),T=s("NodeShape"),H=s("PropertyShape"),we=s("targetClass"),Me=s("property"),Le=s("path"),Ve=s("minCount"),Fe=s("maxCount"),Be=s("datatype"),Ge=s("class"),Xe=s("in"),Ye=s("pattern"),qe=s("flags"),We=s("minLength"),ze=s("maxLength"),Je=s("minInclusive"),Qe=s("maxInclusive"),Ze=s("message"),et=s("targetNode"),tt=s("targetSubjectsOf"),nt=s("targetObjectsOf"),rt=s("closed"),ot=s("ignoredProperties"),at=s("nodeKind"),st=s("IRI"),it=s("BlankNode"),pt=s("Literal"),ct=s("severity"),lt=s("Violation"),ut=s("Warning"),yt=s("Info"),gt=s("ValidationReport"),dt=s("conforms"),mt=s("result"),ft=s("ValidationResult"),kt=s("focusNode"),bt=s("resultPath"),ht=s("resultMessage"),St=s("resultSeverity"),_t=s("sourceShape"),Pt=s("value"),Kt=s("sourceConstraintComponent"),Ct=s("MinCountConstraintComponent"),Et=s("MaxCountConstraintComponent"),At=s("DatatypeConstraintComponent"),xt=s("ClassConstraintComponent"),Rt=s("InConstraintComponent"),Ot=s("PatternConstraintComponent"),Ut=s("MinLengthConstraintComponent"),It=s("MaxLengthConstraintComponent"),Nt=s("MinInclusiveConstraintComponent"),Tt=s("MaxInclusiveConstraintComponent"),Ht=s("NodeKindConstraintComponent"),Dt=s("ClosedConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",te="core-kanonak",L=new Map([["type",p],["subClassOf",p],["subPropertyOf",p],["domain",p],["range",p],["label",p],["comment",p],["seeAlso",p],["isDefinedBy",p],["member",p],["Resource",p],["Class",p],["Property",p],["Datatype",p],["Literal",p],["List",p],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",te]]),ue=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function wt(t){return L.has(t)}function Mt(t){let e=L.get(t);return e?{publisher:l,package_:e}:void 0}function V(t,e,n){if(!t||!t.name)return;let r=L.get(t.name);if(!r)return;let a=()=>{t.publisher=l,t.package_=r,n&&(t.version=n.get(r))};if(ue.has(t.name)){let o=t.publisher===l&&t.package_===r;t.publisher=l,t.package_=r,!o&&n&&(t.version=n.get(r));return}t.publisher===l&&t.package_===r||t.publisher&&t.publisher.length>0&&(!e||e(t))||a()}var ee=class{type=y(l,p,"type");subClassOf=y(l,p,"subClassOf");subPropertyOf=y(l,p,"subPropertyOf");domain=y(l,p,"domain");range=y(l,p,"range");label=y(l,p,"label");comment=y(l,p,"comment");resource=y(l,p,"Resource");class_=y(l,p,"Class");datatype=y(l,p,"Datatype");literal=y(l,p,"Literal");equivalentClass=y(l,f,"equivalentClass");equivalentProperty=y(l,f,"equivalentProperty");inverseOf=y(l,f,"inverseOf");sameAs=y(l,f,"sameAs");transitiveProperty=y(l,f,"TransitiveProperty");symmetricProperty=y(l,f,"SymmetricProperty");objectProperty=y(l,f,"ObjectProperty");datatypeProperty=y(l,f,"DatatypeProperty");annotationProperty=y(l,f,"AnnotationProperty");package_=y(l,te,"Package");shape=M(N);nodeShape=M(T);propertyShape=M(H)};function M(t){return y(t.publisher,t.package_,t.name)}var ye=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let a={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return re(t)[0]??null}function re(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?q(t).map(n=>{let r={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(r),{publisher:r.publisher,package_:r.package_,name:r.name}}):[]}var ge=[N,T,H];function O(t,e){return ye.has(`${t}/${e}`)}var de=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return de.has(t.name)?t.name:void 0}var ne=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return re(e).some(r=>O(r.publisher,r.package_)&&r.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ge.some(r=>Y(n,r)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let r=R(e);return r?n.has(r.name):!1}};var E="kanonak.org",A="core-rdf",me={publisher:E,package_:A,name:"domain"},fe={publisher:E,package_:A,name:"range"},ke={publisher:E,package_:A,name:"subClassOf"},be={publisher:E,package_:A,name:"type"},he={publisher:E,package_:A,name:"label"},Se={publisher:E,package_:A,name:"comment"},_e=new _(E,A,"Resource");function Pe(t){try{let e=Z(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function B(t,e){let n=w(t,e);if(n)return[n];let r=[];for(let a of z(t,e))a instanceof X&&r.push(a.subject);return r}function ae(t,e){let n=[],r=new Set,a="version"in e?e.version:void 0,o=[new _(e.publisher,e.package_,e.name,a??void 0)];for(;o.length>0;){let i=o.shift(),u=b(i);if(r.has(u))continue;r.add(u),n.push(i);let c=Ke(t,i);c&&o.push(...B(c,ke))}return n}function Ke(t,e){return e.version&&typeof e.version.major=="number"?W(t,e)??v(t,e)[0]:v(t,e)[0]}function D(t,e){let n;for(let r of xe(e)){let a=Ce(t,r);if(a){if(a!=="Property")return a;n??=a}}return n}function Ce(t,e){let n=F(e);if(n)return n;let r=oe.get(t);r||(r=new Map,oe.set(t,r));let a=e.version,o=a&&typeof a.major=="number"?`${b(e)}@${a.major}.${a.minor}.${a.patch}`:b(e),i=r.get(o);if(i!==void 0)return i??void 0;let u;for(let c of ae(t,e)){let m=F(c);if(m){if(m!=="Property"){u=m;break}u??="Property"}}return r.set(o,u??null),u}var oe=new WeakMap;function Zt(t,e){return D(t,e)!==void 0}function en(t,e){return D(t,e)==="ObjectProperty"}function tn(t,e){return D(t,e)==="DatatypeProperty"}function Ee(t,e){let n=new Set([b(_e)]);for(let r of ae(t,e))n.add(b(r));return n}function Ae(t,e){let n=Ee(t,e),r=[],a=new Set;for(let o of t){if(!(o instanceof G))continue;let i=D(t,o);if(!i)continue;let u=B(o,me);if(!u.some(d=>n.has(b(d))))continue;let c=Pe(o);if(!c)continue;let m=b(c);a.has(m)||(a.add(m),r.push({uri:c,label:j(o,he),comment:j(o,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:w(o,fe),domains:u}))}return r}function nn(t,e,n){let r=Ae(t,e).find(a=>b(a.uri)===b(n));return r?{ok:!0,descriptor:r}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function xe(t){return B(t,be)}export{J as a,Q as b,Z as c,Te as d,De as e,y as f,$e as g,pe as h,ve as i,ce as j,le as k,N as l,T as m,H as n,we as o,Me as p,Le as q,Ve as r,Fe as s,Be as t,Ge as u,Xe as v,Ye as w,qe as x,We as y,ze as z,Je as A,Qe as B,Ze as C,et as D,tt as E,nt as F,rt as G,ot as H,at as I,st as J,it as K,pt as L,ct as M,lt as N,ut as O,yt as P,Ct as Q,Et as R,At as S,xt as T,Rt as U,Ot as V,Ut as W,It as X,Nt as Y,Tt as Z,Ht as _,Dt as $,wt as aa,Mt as ba,V as ca,ee as da,F as ea,ne as fa,Pe as ga,ae as ha,D as ia,Zt as ja,en as ka,tn as la,Ae as ma,nn as na,xe as oa};
@@ -1,68 +0,0 @@
1
- import{a as Do}from"./chunk-KIBR3HAT.js";import{c as So,e as Io,f as oo,g as to,h as $o,i as jo,j as Oo,q as no,r as wo,s as Co}from"./chunk-HENE47QG.js";import{a as S,b as go,c as Ge,d as L,h as W,k as vo,m as j}from"./chunk-PVUBHIU2.js";import{a as fo}from"./chunk-HF5FJBS2.js";import{aa as ze,b as ko,ba as Ko,fa as $,ga as T,ha as H,ia as B,ja as Y,ma as Eo,na as F,oa as Vo}from"./chunk-7UYXTYXC.js";import{A as P,B as v,C as _,c as g,d as O,j as ee,k as G,l as M,m as b,n as q,p as ho,q as Ro,r as A,t as V,u as bo,w as oe,x as Z,y as z,z as h}from"./chunk-CJMVIOZX.js";import{a as yo}from"./chunk-FUUTGGJS.js";import{b as Q,c as uo}from"./chunk-F67UH4FD.js";import{e as C}from"./chunk-QILEJIFU.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 R=(t=>(t.Info="Info",t.Warning="Warning",t.Error="Error",t))(R||{});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 ro=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let o=new p;return o.resolvedDocuments=this.resolvedDocuments,o.currentEntityPath=e,o}};var ne=class{constructor(e){this.underlying=e;this.repository=new ao(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 Do(e,this.repository);let o={};return{merged:await new j().parseKanonaks(this.underlying,o),authored:o.authored??[]}})()),this.parsePromise}},ao=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,o){let t=`${e}/${o}`,n=this.byNamespaceCache.get(t);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,o),this.byNamespaceCache.set(t,n),n)}getHighestCompatibleVersionAsync(e,o){let t=o.version,n=t?`${t.major}.${t.minor}.${t.patch}`:"",r=`${e}/${o.packageName}@${o.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,o),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 I(p,e,o){return o?o.getKanonaks():new j().parseKanonaks(new re(p,e))}async function w(p,e,o){let t=await I(p,e,o),n=Ze(p);return n?t.filter(r=>r instanceof g&&r.namespace===n):[]}async function ae(p,e,o){let t=Ze(p);if(!t)return[];let n;if(o)n=await o.getAuthoredKanonaks();else{let r={};await new j().parseKanonaks(new re(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof g&&r.sourceDoc===t)}function Ze(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var re=class{constructor(e,o){this.document=e;this.broader=o}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),o=(await this.broader.getAllDocumentsAsync()).filter(t=>t.metadata.namespace_?.toString()!==e);return[this.document,...o]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){return this.broader.getDocumentsByNamespaceAsync(e,o)}getHighestCompatibleVersionAsync(e,o){return this.broader.getHighestCompatibleVersionAsync(e,o)}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 ie=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,o,t){let n=[],r=new Map;for(let[s,l]of Object.entries(e.metadata?.imports??{}))for(let m of l)Q(m)&&r.set(`${s}/${m.packageName}`,{publisher:s,import_:m});if(r.size===0)return n;let a=new Map,i=(s,l,m)=>{let d=`${s.publisher}/${s.package_}`;if(!r.has(d))return;let f=a.get(d)??[];f.push({uri:s,where:l,predicate:m}),a.set(d,f)},c=await w(e,o,t);L(c,({kanonak:s,path:l})=>{for(let m of s.statement){let d=m.predicate?.subject?.name??"(unknown)";if(m instanceof ee)i(m.object.subject,l,d);else if(m instanceof M)for(let f of m.object)f instanceof O&&i(f.subject,l,d);else if(m instanceof Ge)for(let f of m.links)f.target&&i(f.target.subject,l,d)}});for(let[s,l]of a){let{publisher:m,import_:d}=r.get(s),f=null,y;try{f=await o.getHighestCompatibleVersionAsync(m,d)}catch(k){y=k instanceof Error?k.message:String(k)}if(!f){let k=l[0],K=`${l.length} reference${l.length===1?"":"s"}, first at '${k.where}.${k.predicate}'`;this.options.offline?n.push(this.finding("Warning",k.where,k.predicate,s,`Link target package '${s}' could not be resolved offline (${K}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",k.where,k.predicate,s,`Link target package '${s}' could not be resolved${y?` (${y})`:""} \u2014 ${K}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:k,where:K,predicate:E}of l)Object.prototype.hasOwnProperty.call(f.body,k.name)||n.push(this.finding("Error",K,E,`${s}/${k.name}`,`Link to '${k.name}' in '${E}' at '${K}' does not dereference: package '${s}' (resolved to ${f.metadata.namespace_?.toString()??s}) defines no resource named '${k.name}'.`,`Check for a typo, or a resource renamed or removed in '${s}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var se=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let o=[];for(let[t,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(t,n,o);return o}validateEntity(e,o,t){for(let[n,r]of Object.entries(o)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),c=e.split(".")[0],s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=n,s.expectedValue=i,s.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,t)}}getSuggestionForPrefixedValue(e){let o=e.toLowerCase();if(o==="rdfs:class"||o==="owl:class")return"Class";if(o==="rdfs:property"||o==="rdf:property")return"DatatypeProperty or ObjectProperty";if(o.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var ce=class p{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 o=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!t&&p.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.",o.push(i);continue}if(!a&&!p.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 c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=n,c.message=`Invalid entity name '${n}'. ${i}`,c.suggestion=i,o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,o)}return o}validatePropertyNames(e,o,t){for(let n of Object.keys(o))if(!p.VALID_PROPERTIES.has(n)&&!p.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.",t.push(r)}}};var pe=class p{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 o=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return o;let t=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 c=[];if(Array.isArray(i))for(let s of i){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=i?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){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=s,d.expectedValue=m,d.message=`Invalid property type '${s}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",o.push(d)}}}return o}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,o){let t=e[o];return t?t.toString():null}isPropertyDefinedAsClass(e){let o=e.body.Property;if(o&&typeof o=="object"&&!Array.isArray(o)){let n=o.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var le=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let o=[];for(let[t,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||t.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.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.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",o.push(c)}}return o}};var ot=new Set(["EphemeralPackage"]),me=class{get ruleName(){return"PackageHeader"}validate(e){let o=e.metadata;if(!o.type_)return[];let t=[],n=this.packageKey(e,o.type_);return o.namespace_?(!ot.has(o.type_)&&!o.namespace_.version&&t.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`)),t):(t.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
6
- publisher: example.org`)),t)}packageKey(e,o){for(let[t,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===o)return t;return o}error(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.message=t,r.suggestion=n,r}};var tt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},nt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},rt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},at={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},ue=class{ruleName="EmbeddedKanonakType";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof G){let a=r.predicate?.subject,i=`${t}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,t,i,n),this.walk(e,r.object,i,n)}else if(r instanceof M){let a=r.predicate?.subject,i=0;for(let c of r.object){if(c instanceof S){let s=`${t}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,c,t,s,n),this.walk(e,c,s,n)}i++}}}check(e,o,t,n,r,a){if(!o)return;let i=h(t,tt);if(!i)return;let c=V(e,o);if(!c)return;let s=h(c,nt);if(s&&!(q(s,rt)||q(s,at))){if(b(i)===b(s)){a.push(this.redundant(n,r,i,s));return}H(e,i).some(l=>b(l)===b(s))||a.push(this.notSubclass(n,r,i,s))}}redundant(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' declares 'type: ${t.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: ${t.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' has 'type: ${t.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${t.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${t.name}' class definition so the relationship holds.`,r}};import{VersionOperator as Xe}from"@kanonak-protocol/types/document/models/enums";var de=class{ruleName="ImportExistence";async validateAsync(e,o){let t=[];if(!e.metadata?.imports)return t;let n=await o.getAllDocumentsAsync();for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){if(Q(i))continue;if(!await o.getHighestCompatibleVersionAsync(r,i)){let s=await this.determineImportErrorAsync(o,r,i,n),l=new u;l.ruleType=this.ruleName,l.severity="Error",l.message=s.message,l.suggestion=s.suggestion,l.entityName=`Import: ${r}/${i.packageName}`,l.actualValue=i.toString(),l.expectedValue=s.expectedValue,t.push(l)}}return t}async determineImportErrorAsync(e,o,t,n){let r=await e.getDocumentsByNamespaceAsync(o,t.packageName);if(r.length===0){let s=n.filter(f=>f.metadata.namespace_?.publisher===o).map(f=>f.metadata.namespace_.package_).filter((f,y,k)=>k.indexOf(f)===y),l=this.findSimilarPackages(t.packageName,s),m=`Import '${o}/${t.package_}' not found - package does not exist`,d=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:s.length>0?`Available packages in ${o}: ${s.slice(0,5).join(", ")}`:`No packages found for publisher '${o}'. Verify the publisher name is correct.`;return{message:m,suggestion:d,expectedValue:"Existing package"}}let i=r.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${o}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case Xe.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Xe.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Xe.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Xe.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,o){if(o.length===0)return[];let t=o.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(t.length>0)return t.sort((a,i)=>a.length-i.length);let n=o.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,o){if(!e||e.length===0)return o?.length??0;if(!o||o.length===0)return e.length;let t=e.length,n=o.length,r=Array(t+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=t;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=t;a++)for(let i=1;i<=n;i++){let c=e[a-1]===o[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]+c)}return r[t][n]}};var it="kanonak.org",st="core-rdf",ct=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(p=>b({publisher:it,package_:st,name:p}))),fe=class{ruleName="UnresolvedReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t),i=uo(e),c=s=>i.has(`${s.subject.publisher}/${s.subject.package_}`);return L(a,({kanonak:s,path:l})=>{for(let m of s.statement){let d=pt(m);if(!(!d||ct.has(b(d)))){if(m instanceof ee)c(m.object)||this.check(r,l,d,m.object,n);else if(m instanceof M)for(let f of m.object)f instanceof O&&!c(f)&&this.check(r,l,d,f,n)}}}),n}check(e,o,t,n,r){V(e,n.subject)||r.push(this.unresolvedError(o,t.name,n.subject))}unresolvedError(e,o,t){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${t.name}' in '${o}' 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 '${t.name}'
8
- \u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function pt(p){return p.predicate?.subject}var Po={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Uo={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function lt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Je(p,e,o){let t=[],n=new Set,r=new Set,a=i=>{let c=V(p,i),s=c?`${c.namespace}/${c.name}`:b(i);if(n.has(s)){let l=t.findIndex(d=>d.key===s),m=t.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(s))return null;if(n.add(s),t.push({key:s,uri:i}),c)for(let l of lt(c,o)){let m=a(l);if(m)return m}return t.pop(),n.delete(s),r.add(s),null};return a(e)}var Ao=p=>p,ye=class{ruleName="ClassHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!($.isClassType(Ao(i))||$.isDatatypeType(Ao(i))))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Po);if(s){let l=s.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 ge=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Uo);if(s){let l=s.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 mt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ke=class{ruleName="PropertyRangeRequired";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";oe(i,mt)||n.push(this.error(i.name,s))}return n}error(e,o){let t=new u;return t.ruleType=this.ruleName,t.severity="Error",t.entityName=e,t.propertyName="range",t.message=`Property '${e}' must have a 'range' defined.`,t.suggestion=o?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",t.expectedValue=o?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",t}};var ut={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},No=p=>p,he=class{ruleName="SubClassOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!To(No(i)))continue;let c=dt(i,ut);for(let s=0;s<c.length;s++)this.resolvesToClassLike(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?To(No(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.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 '${o.name}' referenced in subClassOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a Class, or import a namespace that contains it`,r}};function To(p){return $.isClassType(p)||$.isDatatypeType(p)}function dt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ft={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Re=class{ruleName="SubPropertyOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=yt(i,ft);for(let s=0;s<c.length;s++)this.resolvesToProperty(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToProperty(e,o){let t=V(e,o);return t?Y(e,t):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.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 '${o.name}' referenced in subPropertyOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a property, or import a namespace that contains it`,r}};function yt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var be=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,o){let t=[],n=e.metadata.namespace_?.toString();if(!n)return t;let r=new Map,a=new Set;await this.buildImportGraph(e,o,r,a);let i=this.detectCycle(n,r);if(i){let c=i.join(" \u2192 "),s=new u;s.ruleType=this.ruleName,s.severity="Error",s.message=`Circular namespace import detected: ${c}`,s.suggestion="Remove one of the imports to break the circular dependency, or \u2014 if one direction is a DATA reference rather than a schema dependency (an object-property value naming a resource in the other package) \u2014 mark that import `mode: link`: links are dereferenced on demand, are not in the closure, and are exempt from this rule. Circular dependencies prevent proper package resolution.",s.entityName="imports",s.propertyName="imports",s.actualValue=c,t.push(s)}return t}async buildImportGraph(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,c]of Object.entries(e.metadata.imports))for(let s of c){if(Q(s))continue;let l=`${i}/${s.packageName}@${s.version}`;a.push(l);let m=await o.getHighestCompatibleVersionAsync(i,s);m&&await this.buildImportGraph(m,o,t,n)}a.length>0&&t.set(r,a)}}detectCycle(e,o){let t=[],n=new Set;return this.detectCycleRecursive(e,o,t,n)}detectCycleRecursive(e,o,t,n){let r=t.indexOf(e);if(r>=0){let i=t.slice(r);return i.push(e),i}if(n.has(e))return null;t.push(e),n.add(e);let a=o.get(e);if(a)for(let i of a){let c=this.detectCycleRecursive(i,o,t,n);if(c)return c}return t.pop(),null}};var Ke=class{ruleName="UnresolvedPredicate";async validateAsync(e,o,t){let n=[],r=Ze(e);if(!r)return n;let a=await I(e,o,t);return L(a,({kanonak:i,path:c})=>{for(let s of i.unresolvedPredicates)s.sourceDoc===r&&n.push(this.unresolvedPredicateError(c,s.key))}),n}unresolvedPredicateError(e,o){let t=o.lastIndexOf("."),n=t>0?o.slice(0,t):null,r=t>0?o.slice(t+1):o,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=o,a.expectedValue="A defined or imported property",a.message=`Property '${o}' 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 '${o}' is not defined in this namespace or any imported namespace.
12
- 1. Define '${o}' 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.${o}')`,a}};var Ee=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,o){let t=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,o),a=await this.buildDatatypePropertyNamesAsync(e,o);for(let[i,c]of Object.entries(e.body))typeof c=="object"&&c!==null&&!Array.isArray(c)&&this.validateEntityReferences(i,c,n,r,a,e,t);return t}async buildEntitySourceMapAsync(e,o){let t=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(a)||t.set(a,[]),t.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let c of i){let s=await o.getHighestCompatibleVersionAsync(a,c);if(s){let l=s.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(s,t,n,r,[l],o)}}return{entitySources:t,importPaths:r}}async collectEntitiesRecursivelyAsync(e,o,t,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!t.has(i)){t.add(i),n.has(i)||n.set(i,r);for(let c of Object.keys(e.body)){o.has(c)||o.set(c,[]);let s=o.get(c);s.includes(i)||s.push(i)}if(e.metadata.imports)for(let[c,s]of Object.entries(e.metadata.imports))for(let l of s){let m=await a.getHighestCompatibleVersionAsync(c,l);if(m){let d=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,o,t,n,[...r,d],a)}}}}async buildDatatypePropertyNamesAsync(e,o){let t=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,t,n,o),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let c=await o.getHighestCompatibleVersionAsync(r,i);c&&await this.collectDatatypePropertiesAsync(c,t,n,o)}return t}async collectDatatypePropertiesAsync(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!t.has(r)){t.add(r);for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let c=i.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&o.add(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let c of i){let s=await n.getHighestCompatibleVersionAsync(a,c);s&&await this.collectDatatypePropertiesAsync(s,o,t,n)}}}validateEntityReferences(e,o,t,n,r,a,i){for(let[c,s]of Object.entries(o)){let l=c;if(l&&!l.includes(".")){let m=t.get(l);if(m&&m.length>1&&!m.some(f=>f.startsWith("(local:"))){let f=m.filter(y=>!y.startsWith("(local:"));f.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,f,n,a,!0,l))}}this.validatePropertyValue(e,l,s,t,n,r,a,i)}}validatePropertyValue(e,o,t,n,r,a,i,c){if(t==null)return;let s=o&&o.includes(".")?o.substring(o.lastIndexOf(".")+1):o,l=!!s&&a.has(s);if(typeof t=="string"&&!t.includes(".")&&!l){let m=n.get(t);if(m&&m.length>1&&!m.some(f=>f.startsWith("(local:"))){let f=m.filter(y=>!y.startsWith("(local:"));f.length>1&&c.push(this.createAmbiguityError(e,o,`Reference '${t}'`,f,r,i,!1,t))}}else if(Array.isArray(t))for(let m=0;m<t.length;m++){let d=`${e}.${o}[${m}]`;this.validatePropertyValue(d,o,t[m],n,r,a,i,c)}else if(typeof t=="object"&&!Array.isArray(t)){let m=o?`${e}.${o}`:e;this.validateEntityReferences(m,t,n,r,a,i,c)}}createAmbiguityError(e,o,t,n,r,a,i,c){let s=[];for(let K of n){let E=this.findAliasForNamespace(a,K);if(E){let U=o?.split(".").pop()??o;s.push(`${E}.${U}`)}}let l=s.length>0?`Use one of: ${s.map(K=>`'${K}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${o}')`,m=n.map(K=>{let E=r.get(K);return!E||E.length===0?` \u2022 ${K}`:E.length===1?` \u2022 ${K} (direct import)`:` \u2022 ${K}
15
- imported via: ${E.join(" \u2192 ")}`}).join(`
16
- `),d=e.split(".")[0],f=e.includes(".")?e:o,y=new u;y.ruleType=this.ruleName,y.severity="Error",y.entityName=d,f&&(y.propertyName=f);let k=c??o;return k&&(y.actualValue=k),y.message=`${t} is ambiguous - defined in multiple imported namespaces`,y.suggestion=`${l}
17
-
18
- Defined in:
19
- ${m}`,y.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",y}findAliasForNamespace(e,o){if(!e.metadata.imports)return null;for(let[t,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${t}/${r.packageName}@${r.version}`===o&&r.alias)return r.alias;return null}};var gt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},xo=p=>p,Ve=class{ruleName="PropertyRangeReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";for(let l of kt(i,gt))this.resolvesToClassLike(r,l)||n.push(this.error(i.name,l,s))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?$.isClassType(xo(t))||$.isDatatypeType(xo(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="range",r.actualValue=n,r.expectedValue=t?"A defined or imported class":"A datatype or defined class",r.message=`Property '${e}' has range '${o.name}' which is not defined or imported`,r.suggestion=t?`Define '${o.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 '${o.name}' is a class \u2014 make this an ObjectProperty.`,r}};function kt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ht={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ve="kanonak.org",io="core-rdf",so="core-owl",co=p=>p,Rt=[{uri:{publisher:ve,package_:io,name:"Class"},ok:(p,e)=>$.isClassType(co(e))||$.isDatatypeType(co(e))},{uri:{publisher:ve,package_:io,name:"Datatype"},ok:(p,e)=>$.isDatatypeType(co(e))},{uri:{publisher:ve,package_:io,name:"Property"},ok:(p,e)=>Y(p,e)},{uri:{publisher:ve,package_:so,name:"ObjectProperty"},ok:(p,e)=>B(p,e)==="ObjectProperty"},{uri:{publisher:ve,package_:so,name:"DatatypeProperty"},ok:(p,e)=>B(p,e)==="DatatypeProperty"},{uri:{publisher:ve,package_:so,name:"AnnotationProperty"},ok:(p,e)=>B(p,e)==="AnnotationProperty"}],De=class{ruleName="ObjectPropertyValue";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof ee)this.check(e,r.predicate?.subject,r.object.subject,t,n);else if(r instanceof G)this.walk(e,r.object,_o(t,r.predicate?.subject),n);else if(r instanceof M){let a=r.predicate?.subject;for(let i of r.object)i instanceof O?this.check(e,a,i.subject,t,n):i instanceof S&&this.walk(e,i,_o(t,a),n)}}check(e,o,t,n,r){if(!o)return;let a=V(e,o);if(!a)return;let i=h(a,ht);if(!i)return;let c=Rt.find(l=>q(i,l.uri));if(!c)return;let s=V(e,t);s&&(c.ok(e,s)||r.push(this.warn(n,o,i,t)))}warn(e,o,t,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=t.name,r.message=`Property '${o.name}' expects a ${t.name}, but '${n.name}' is not a ${t.name}`,r.suggestion=`Reference a resource that is a ${t.name}, or correct the type of '${n.name}'.`,r}};function _o(p,e){return`${p}.${e?.name??"<embedded>"}`}var bt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Kt={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},Et={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Se=class{ruleName="PropertyDomain";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){this.checkNode(e,o,t,n);for(let r of o.statement)if(r instanceof G)this.walk(e,r.object,Mo(t,r.predicate?.subject),n);else if(r instanceof M)for(let a of r.object)a instanceof S&&this.walk(e,a,Mo(t,r.predicate?.subject),n)}checkNode(e,o,t,n){let r=Lo(o,bt);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([b(Et)]);for(let s of r)for(let l of H(e,s))a.add(b(l))}return a},c=new Set;for(let s of o.statement){let l=Vt(s);if(!l||ze(l.name)||c.has(b(l)))continue;c.add(b(l));let m=V(e,l);if(!m)continue;let d=Lo(m,Kt);d.length!==0&&(d.some(f=>i().has(b(f)))||n.push(this.error(t,l,d,r[0])))}}error(e,o,t,n){let r=t.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=o.name,a.expectedValue=`Property used on ${r} or its subclasses`,a.message=`Property '${o.name}' has domain '${r}' but is used on '${n.name}' at '${e}'`,a.suggestion=`Either:
20
- 1. Use '${o.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 Vt(p){return p.predicate?.subject}function Lo(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Mo(p,e){return`${p}.${e?.name??"<embedded>"}`}var vt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Dt={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},St=p=>p,Ie=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty",l=c==="DatatypeProperty",m=h(i,vt);if(!m||!V(r,m))continue;let d=It(r,m);l&&!d?n.push(this.error(i.name,m,"datatype")):s&&d&&n.push(this.error(i.name,m,"object"))}return n}error(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="range",n.actualValue=o.name,t==="datatype"?(n.expectedValue="A datatype (xsd type, rdfs.Literal, or a datatype-derived class)",n.message=`DatatypeProperty '${e}' has range '${o.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 '${o.name}' is the intended target \u2014 declare '${e}' an ObjectProperty.`):(n.expectedValue="A plain class (not datatype-derived)",n.message=`ObjectProperty '${e}' has range '${o.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 '${o.name}'), or change the range to a plain class.`),n}};function It(p,e){for(let o of H(p,e)){if(q(o,Dt))return!0;let t=V(p,o);if(t&&$.isDatatypeType(St(t)))return!0}return!1}var $e=class{ruleName="ReservedNameShadow";async validateAsync(e,o,t){let n=[],r=await w(e,o,t);for(let a of r){if(!(a instanceof g))continue;let i=Ko(a.name);if(!i)continue;let c=T(a);c&&(i.publisher===c.publisher&&i.package_===c.package_||n.push(this.info(a.name,c,i)))}return n}info(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Info",n.entityName=e,n.propertyName=e,n.actualValue=`${o.publisher}/${o.package_}/${e}`,n.expectedValue=`${t.publisher}/${t.package_}/${e}`,n.message=`'${e}' is also the reserved built-in '${t.publisher}/${t.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 '${t.publisher}/${t.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 $t={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Bo=p=>p,je=class{ruleName="ClassDefinition";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);return L(a,({kanonak:i,path:c})=>{for(let s of jt(i,$t))this.resolvesToClassLike(r,s)||n.push(this.error(c,s))}),n}resolvesToClassLike(e,o){if(ze(o.name))return!0;let t=V(e,o);return t?$.isClassType(Bo(t))||$.isDatatypeType(Bo(t)):!1}error(e,o){let t=`${o.publisher}/${o.package_}/${o.name}`,n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="type",n.actualValue=t,n.expectedValue="Defined or imported class",n.message=`Class '${o.name}' is not defined or imported`,n.suggestion=`Define '${o.name}' as a Class in this document, or import a namespace that contains it`,n}};function jt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var Oe=class{ruleName="MarkdownLink";async validateAsync(e,o,t){let n=[],r=await w(e,o,t);return L(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,o,t){for(let n of e.statement){if(!(n instanceof Ge))continue;let r=n.predicate.subject?.name??"(unknown)";for(let a of n.links)a.target||t.push(this.unresolvedLinkError(o,r,a.reference));for(let a of vo(n.object))t.push(this.malformedLinkError(o,r,a.snippet))}}unresolvedLinkError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`Embedded link [[${t}]] in '${o}' could not be resolved`,n.expectedValue="A reference resolvable through the document's import closure",n.suggestion=`The reference '${t}' 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 '${t}' 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.${t}]]`,n}malformedLinkError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`Malformed embedded reference near '${t}' in '${o}'`,n.expectedValue="A single-line [[reference]] with no internal line break",n.suggestion=`A '[[' in '${o}' 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 Fo="kanonak.org",Wo="look",Ot={publisher:Fo,package_:Wo,name:"displayLabel"},wt={publisher:Fo,package_:Wo,name:"displaySummary"},we=class{ruleName="DisplayLensScope";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=Ct(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&(this.checkLens(r,i,Ot,"displayLabel",n),this.checkLens(r,i,wt,"displaySummary",n));return n}checkLens(e,o,t,n,r){let a=h(o,t);if(!a)return;let i=[],c=T(o);if(c&&i.push(c),i.push(...Vo(o)),i.length===0)return;i.some(l=>F(e,l,a).ok)||r.push(this.scopeError(o.name,n,a.name))}scopeError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`${o} points at '${t}', 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=`'${t}' 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 ${o} 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 Ct(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}function X(p,e,o){let t=[];return Fe(p,o,{input:e},t),t}function Fe(p,e,o,t){if(A(e,W.VarRef)){let a=z(e,W.varName);return a?o[a]:void 0}if(A(e,W.PropertyRead)){let a=P(e,W.readSource),i=a?Fe(p,a,o,t):void 0,c=h(e,W.readProp);if(!i||!c)return;let s=F(p,i,c);if(!s.ok){t.push({contextClass:i,propertyUri:c,via:"PropertyRead"});return}return s.descriptor?.range}if(A(e,W.Traverse)){let a=P(e,W.traverseSource),i=a?Fe(p,a,o,t):void 0,c=h(e,W.through),s;if(i&&c){let m=F(p,i,c);m.ok?s=m.descriptor?.range:t.push({contextClass:i,propertyUri:c,via:"Traverse"})}let l=P(e,W.step);return l?Fe(p,l,{...o,input:s},t):void 0}let n=z(e,W.loopVar),r=n?{...o,[n]:void 0}:o;for(let a of Pt(e))Fe(p,a,r,t)}function Pt(p){let e=[];for(let o of p.statement){let t=o.object;if(t instanceof S)e.push(t);else if(Array.isArray(t))for(let n of t)n instanceof S&&e.push(n)}return e}var We="kanonak.org",qe="look",Ut={publisher:We,package_:qe,name:"semanticSvg"},At={publisher:We,package_:qe,name:"tierChip"},Nt={publisher:We,package_:qe,name:"tierIcon"},Tt={publisher:We,package_:qe,name:"tierCard"},xt={publisher:We,package_:qe,name:"tierFull"},_t=[At,Nt,Tt,xt],Ce=class{ruleName="LookSemanticSvgPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=Lt(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,o,t){let n=P(o,Ut);if(!n)return;let r=T(o);if(r)for(let a of _t){let i=P(n,a);if(i)for(let c of X(e,r,i))t.push(this.toError(o.name,a.name,c))}}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.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.${o}`,i.actualValue=n,i.message=`tx.${t.via} reads property '${t.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 Lt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qo={publisher:"kanonak.org",package_:"transformations",name:"Expression"},Mt=new Map([["look","the look renderer"],["view","the view materializer"],["transformations","the transformation runner"]]);function Bt(p){if(!(!p||p.publisher!=="kanonak.org"))return Mt.get(p.package_)}var Pe=class{ruleName="TxExpressionCompiles";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=Wt(e);if(!a)return n;let i=r.filter(y=>y instanceof g&&y.namespace===a);if(i.length===0)return n;let c=new Map,s=y=>{for(let k of ho(y)){let K=b(k),E=c.get(K);if(E===void 0&&(E=q(k,qo)||H(r,k).some(U=>q(U,qo)),c.set(K,E)),E)return!0}return!1},l=[],m=new Map,d=new Set;for(let y of i)L([y],({kanonak:k,path:K})=>{let E=k instanceof S&&s(k);E&&l.push({node:k,path:K,subject:y.name});for(let{child:U,predicate:N}of Ft(k))s(U)&&(N&&m.set(U,N),E&&d.add(U))});let f=new Set;for(let{node:y,path:k,subject:K}of l){if(d.has(y))continue;let E=Bt(m.get(y));if(E)try{So(y,k,{catalog:r,depth:0})}catch(U){let N=U instanceof Error?U.message:String(U),eo=`${K} ${k} ${N}`;if(f.has(eo))continue;f.add(eo),n.push(this.toError(K,k,N,E))}}return n}toError(e,o,t,n){let r=new u;r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t;let a=/[.!?]$/.test(t)?t:`${t}.`;return r.message=`A tx.Expression at '${o}' is in a slot ${n} evaluates, but it cannot be compiled: ${a} The value would be silently absent wherever this slot is used.`,r.expectedValue=`A tx.Expression built from node classes ${n} implements`,r.suggestion=`This slot is evaluated by ${n}, which is part of this SDK, so its node classes are the ones available here. (An Expression subclass meant for a DIFFERENT runner is fine in that runner's own slots \u2014 this rule does not look at those.)
45
-
46
- Possible solutions:
47
- \u2022 Rebuild the expression from tx primitives this SDK supports
48
- \u2022 For numeric presentation (rounding, percentages, fixed precision), use tx.NumberFormat \u2014 it scales internally, so no arithmetic is needed
49
- \u2022 If the node class should be supported, implement it in the runner first`,r}};function Ft(p){let e=[];for(let o of p.statement){let t=o.predicate?.subject;if(o instanceof G)e.push({child:o.object,predicate:t});else if(o instanceof M)for(let n of o.object)n instanceof S&&e.push({child:n,predicate:t})}return e}function Wt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qt="kanonak.org",He=(p,e)=>({publisher:qt,package_:p,name:e}),Ht=He("derivation","look"),Ho=He("look","bands"),Yo=He("look","Sequence"),Yt=He("core-rdf","range"),Gt=He("look","nodeTier"),Ue=class{ruleName="SequenceNarrative";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=zt(e);if(!a)return n;let i=r.filter(s=>s instanceof g&&s.namespace===a);if(i.length===0)return n;for(let s of i){let l=P(s,Ht);l&&v(l,Ho).forEach((m,d)=>{!(m instanceof S)||!A(m,Yo)||n.push(...this.checkBand(r,s,m,`${s.name}.look.bands[${d}]`))})}let c=new wo(r);for(let s of i){let l=c.findCascadedLook(s);if(l)for(let m of v(l.declaration,Ho))!(m instanceof S)||!A(m,Yo)||this.checkBand(r,s,m,"").length>0||n.push(...this.checkInstance(r,s,m,$o(r,s,m)))}return n}checkBand(e,o,t,n){let r=[],a=(l,m,d)=>r.push(this.toError("Error",o.name,n,l,m,d)),i=oo(t);if(!i)a("A look.Sequence band declares no look.source. The order of a sequence comes from the [[references]] in a prose property, so without one nothing can be sequenced.","Set look.source to a property of this class whose rdfs.range is prose.Markdown (or prose.SubstitutableString), and render the same property with a look.Markdown band so the narrative and the diagram cannot drift.");else{let l=bo(e,i)[0],m=l?Ro(l,Yt):[];l&&!m.some(d=>ko.isSubstitutableDatatypeUri(d))&&a(`look.source names '${i.name}', whose rdfs.range is ${m.map(d=>b(d)).join(", ")||"undeclared"} \u2014 not prose.Markdown. A Sequence orders its participants by the [[references]] in prose, so a value of this property carries no order.`,"Point look.source at a prose.Markdown-ranged property, or give this property that range if its values are narrative.",b(i))}let c=to(e,t);c.length===0&&a("A look.Sequence band declares no look.connectors, so no property counts as a message and every narrative renders empty.","List the object properties that constitute messages: look.connectors: [{ look.relation: calls }, ...]. The domain ontology declares nothing about sequences; the look layer says which of its relations are interactions.");for(let l of c)(!l.subject||B(e,l.subject)===void 0)&&a(`look.connectors names '${l.relation.name}' as a relation, but it is not a property${l.subject?"":" in the closure"}. A message is a triple, so its relation must be an object property whose values are the participants.`,"Use an owl.ObjectProperty (or a subclass such as owl.SymmetricProperty) for look.relation.",b(l.relation)),l.invalidStyle!==void 0&&a(`look.lineStyle '${l.invalidStyle}' on connector '${l.relation.name}' is not a supported value. Supported: ${[...Io].join(", ")}.`,"Use one of the supported values, or omit look.lineStyle: a reply is derived from owl.inverseOf and an undirected edge from owl.SymmetricProperty, so the overlay is only needed for what the ontology cannot say.",l.invalidStyle);let s=z(t,Gt);return s!==void 0&&no[s]===void 0&&a(`look.nodeTier '${s}' is not a tier. Supported: ${Object.keys(no).join(", ")}.`,"Use one of the semantic-zoom tiers \u2014 chip (56), icon (120, the default), card (240), full (420) \u2014 or omit look.nodeTier to take the participants' class-level look.diagramTier.",s),r}checkInstance(e,o,t,n){let r=[],a=oo(t),i=`${o.name}.${a.name}`,c=to(e,t).map(s=>s.relation.name).join(", ");if(n.problem)return r.push(this.toError("Error",o.name,i,`The look.Sequence band cannot walk this instance: ${n.problem}.`,"Check the value authored for the source property.")),r;if(n.sourceAbsent)return r.push(this.toError("Warning",o.name,i,`'${o.name}' carries no value for '${a.name}', so its look.Sequence band renders nothing.`,`Author the narrative in '${a.name}' with [[references]] to the participants, or leave it if the band is meant to be empty here.`)),r;for(let s of n.strayPropertyRefs)r.push(this.toError("Error",o.name,i,`The narrative references property '${s.name}', which is not a declared connector of the look.Sequence band (declared: ${c}). A property reference between two participants selects the edge for that pair; one the band does not declare selects nothing, and the sentence draws no message.`,`Add { look.relation: ${s.name} } to look.connectors on the band, or reference one of the declared connectors instead.`,b(s)));if(n.mentions>=2&&n.messages.length===0)return r.push(this.toError("Error",o.name,i,`The narrative mentions ${n.mentions} participant references but joins nothing: no declared connector (${c}) holds between any consecutive pair, so the look.Sequence band renders no message.`,"Either the graph is missing the triples the prose describes (declare them on the participants), the band is missing the relation the prose relies on (add it to look.connectors), or the prose orders participants no relation joins (reorder it).")),r;for(let s of n.gaps){let l=s.selected?`'${s.selected.name}' does not hold`:`no declared connector (${c}) holds`;r.push(this.toError("Warning",o.name,i,`The narrative orders '${s.prev.name}' then '${s.next.name}', but ${l} between them in the graph, so no message is drawn for that pair.`,`If the prose is right, declare the relation on '${s.prev.name}' or '${s.next.name}' (or add it to look.connectors); if the graph is right, reorder the prose so consecutive references are joined. A mention that is meant to connect to nothing is fine \u2014 it simply gets no lifeline.`,`${s.prev.name} \u2192 ${s.next.name}`))}return r}toError(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function zt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Zt="kanonak.org",D=(p,e)=>({publisher:Zt,package_:p,name:e}),Xt=D("derivation","look"),Jt=D("look","bands"),Qt=D("look","Distribution"),en=D("look","StatRow"),on=D("look","VersionDelta"),tn=D("look","Timeline"),nn=D("look","VersionDiff"),rn=D("look","TimePlot"),an=D("look","ReferenceList"),sn=D("look","Diagram"),cn=D("look","alphaPath"),pn=D("look","betaPath"),po=D("look","metricPath"),Go=D("look","lowerPath"),zo=D("look","upperPath"),Zo=D("look","hueBy"),ln=D("look","statPath"),mn=D("look","laneBy"),Xo=D("look","labelPath"),un=D("look","badgePath"),dn=D("look","mapPath"),fn=D("look","nodeNote"),yn=D("look","edgeValue"),gn=D("look","stats"),kn=D("look","facets"),hn=D("look","channels"),Rn=D("look","track"),bn=D("look","source"),Kn=D("look","relation"),En=D("look","entries"),Ae=class{ruleName="LookBandPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=vn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,o,t){let n=P(o,Xt);if(!n)return;let r=T(o);if(!r)return;let a=v(n,Jt).filter(i=>i instanceof S);for(let i of a)for(let c of this.carriersOf(e,i,r))for(let s of X(e,c.context,c.expr))t.push(this.toError(o.name,c.slot,s))}carriersOf(e,o,t){let n=[],r=(a,i)=>{let c=P(o,a);c&&n.push({slot:`look.${a.name}`,context:i,expr:c})};if(A(o,Qt))for(let a of[cn,pn,po,Go,zo,Zo])r(a,t);if(A(o,on)&&r(po,t),A(o,en)){let a=v(o,gn).filter(i=>i instanceof S);for(let i of a){let c=P(i,ln);c&&n.push({slot:"look.stats[].statPath",context:t,expr:c})}}if(A(o,tn)||A(o,nn)){let a=this.rangeOf(e,t,h(o,Rn));if(a)for(let i of[po,Go,zo,Zo])r(i,a)}if(A(o,rn)){let a=this.rangeOf(e,t,h(o,bn));if(a)for(let i of[mn,Xo])r(i,a)}if(A(o,an))for(let a of v(o,En)){let i=a instanceof S?void 0:Vn(a),c=this.rangeOf(e,t,i);if(c)for(let s of[Xo,un])r(s,c)}if(A(o,sn)){let a=v(o,kn).filter(i=>i instanceof S);for(let i of a){let c=this.rangeOf(e,t,h(i,Kn));if(!c)continue;let s=P(i,fn);s&&n.push({slot:"look.facets[].nodeNote",context:c,expr:s});let l=P(i,yn);l&&n.push({slot:"look.facets[].edgeValue",context:c,expr:l});let m=v(i,hn).filter(d=>d instanceof S);for(let d of m){let f=P(d,dn);f&&n.push({slot:"look.facets[].channels[].mapPath",context:c,expr:f})}}}return n}rangeOf(e,o,t){if(!t)return;let n=F(e,o,t);return n.ok?n.descriptor?.range:void 0}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.contextClass.name,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=n,a.message=`tx.${t.via} reads property '${t.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}'.
50
-
51
- Possible solutions:
52
- \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
53
- \u2022 If the property should apply to '${r}', adjust its domain
54
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function Vn(p){let e=p.subject;return e&&typeof e.name=="string"?e:void 0}function vn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Dn="kanonak.org",lo=(p,e)=>({publisher:Dn,package_:p,name:e}),Sn=lo("derivation","look"),In=lo("look","bands"),$n=lo("core-rdf","type"),Ye=class{ruleName="UnrenderableBand";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=jn(e);if(!a)return n;let i=Co();for(let c of r){if(!(c instanceof g)||c.namespace!==a)continue;let s=P(c,Sn);if(!s)continue;let l=v(s,In).filter(m=>m instanceof S);for(let m of l){let d=this.typeOf(m);if(!d)continue;let f=`${d.publisher}/${d.package_}/${d.name}`;if(i.has(f))continue;let y=new u;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=c.name,y.propertyName="derivation.look",y.actualValue=f,y.message=`Band '${d.name}' has no renderer, so this region of the page will be empty. The declaration is valid against the look vocabulary, but the renderer emits only an HTML comment for it \u2014 which a browser does not display, so the loss is silent. Use a band the renderer implements, or remove it until it is supported.`,n.push(y)}}return n}typeOf(e){let o=h(e,$n);if(o)return{publisher:o.publisher,package_:o.package_,name:o.name}}};function jn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Te="kanonak.org",xe="view",On={publisher:Te,package_:xe,name:"bind"},wn={publisher:Te,package_:xe,name:"produces"},Cn={publisher:Te,package_:xe,name:"projections"},Pn={publisher:Te,package_:xe,name:"where"},Un={publisher:Te,package_:xe,name:"value"},An={publisher:Te,package_:xe,name:"as"},Ne=class{ruleName="TxExpressionPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=xn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,o,t){let n=h(o,On);if(!n)return;let r=h(o,wn),a=0;for(let c of Tn(e,v(o,Cn))){let s=P(c,Un);if(s)for(let m of X(e,n,s))t.push(this.toError(o.name,`view.projections[${a}].value`,n,m));let l=h(c,An);l&&r&&(F(e,r,l).ok||t.push(this.asError(o.name,a,r,l))),a+=1}let i=0;for(let c of Nn(o,Pn)){for(let s of X(e,n,c))t.push(this.toError(o.name,`view.where[${i}]`,n,s));i+=1}}asError(e,o,t,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[${o}].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 '${t.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${t.name}'.
55
-
56
- Possible solutions:
57
- \u2022 Use an output property whose domain covers '${t.name}'
58
- \u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
59
- \u2022 If the value belongs on a different output class, adjust the view's produces`,a}toError(e,o,t,n){let r=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,i=a===t.name?`the view's bound class '${t.name}'`:`'${a}', reached by traversal from the view's bound class '${t.name}'`,c=new u;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=e,c.propertyName=o,c.actualValue=r,c.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.`,c.expectedValue=`A property whose domain is '${a}', an ancestor, or rdfs.Resource`,c.suggestion=`Property '${r}' is not in scope for '${a}'.
60
-
61
- Possible solutions:
62
- \u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
63
- \u2022 If the property should apply to '${a}', adjust its domain
64
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function Nn(p,e){let o=P(p,e);return o?[o]:v(p,e).filter(t=>t instanceof S)}function Tn(p,e){let o=[];for(let t of e)if(t instanceof S)o.push(t);else if(t instanceof O){let n=V(p,t.subject);n&&o.push(n)}return o}function xn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Qe="kanonak.org",_n="core-shacl",x=p=>({publisher:Qe,package_:_n,name:p}),Ln=x("NodeShape"),Mn=x("PropertyShape"),Bn=x("targetClass"),Fn=x("property"),Wn=x("path"),qn=x("minCount"),Hn=x("maxCount"),Yn=x("datatype"),Gn=x("class"),Jo=x("in"),zn=x("pattern"),Zn=x("flags"),Xn=x("minLength"),Jn=x("maxLength"),Qn=x("minInclusive"),er=x("maxInclusive"),or=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),Qo=p=>p,Le=class{ruleName="ShaclShape";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=tr(e);if(!a)return n;let i=new Set;for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Ln))continue;let s=h(c,Bn);s?this.resolvesToClass(r,s)||n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' sh:targetClass '${s.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(s))):n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let l of v(c,Fn)){let m;if(l instanceof S)m=l;else if(l instanceof O){let d=V(r,l.subject);d&&(m=d,i.add(b(l.subject)))}m&&this.checkPropertyShape(r,c.name,m,s??void 0,n)}}for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Mn))continue;let s=T(c);s&&i.has(b(s))||this.checkPropertyShape(r,c.name,c,void 0,n)}return n}checkPropertyShape(e,o,t,n,r){let a=h(t,Wn);if(!a){r.push(this.err(o,"property.path","Error",`A PropertyShape on '${o}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=V(e,a),c=i?Y(e,i):!1;c?n&&(F(e,n,a).ok||r.push(this.err(o,"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(o,"property.path","Error",`sh:path '${a.name}' on '${o}' does not resolve to a property.`,"Reference a defined or imported property.",J(a)));let s=h(t,Yn),l=h(t,Gn);s&&l&&r.push(this.err(o,"property","Error",`A PropertyShape on '${o}' 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.")),s&&!this.resolvesToDatatype(e,s)&&r.push(this.err(o,"datatype","Error",`sh:datatype '${s.name}' on '${o}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",J(s))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(o,"class","Error",`sh:class '${l.name}' on '${o}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(l)));let m=_e(Z(t,qn)),d=_e(Z(t,Hn));this.checkOrder(o,"minCount",m,"maxCount",d,r);let f=_e(Z(t,Xn)),y=_e(Z(t,Jn));this.checkOrder(o,"minLength",f,"maxLength",y,r);let k=_e(Z(t,Qn)),K=_e(Z(t,er));this.checkOrder(o,"minInclusive",k,"maxInclusive",K,r);let E=z(t,zn);if(E!==void 0){let U=z(t,Zn);try{new RegExp(E,U)}catch{r.push(this.err(o,"pattern","Error",`sh:pattern on '${o}' is not a valid regular expression`+(U!==void 0?` (with flags '${U}')`:"")+`: ${E}`,"Provide a valid regular expression and flags.",E))}}if(oe(t,Jo)&&v(t,Jo).length===0&&r.push(this.err(o,"in","Error",`sh:in on '${o}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),c&&n){let N=F(e,n,a).descriptor;N&&((E!==void 0||f!==void 0||y!==void 0)&&N.kind==="object"&&r.push(this.err(o,"pattern/minLength/maxLength","Warning",`String facets on '${o}' 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))),(k!==void 0||K!==void 0)&&!this.isNumericDatatypeRange(N.range)&&r.push(this.err(o,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${o}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",J(a))))}}checkOrder(e,o,t,n,r,a){t!==void 0&&r!==void 0&&t>r&&a.push(this.err(e,`${o}/${n}`,"Error",`${o} (${t}) exceeds ${n} (${r}) on '${e}'.`,`Set ${o} <= ${n}.`))}resolvesToClass(e,o){let t=V(e,o);return t?$.isClassType(Qo(t)):!1}resolvesToDatatype(e,o){if(o.publisher===Qe&&o.package_==="core-rdf"&&o.name==="Literal")return!0;let t=V(e,o);return t?$.isDatatypeType(Qo(t)):!1}isNumericDatatypeRange(e){return!e||e.publisher===Qe&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===Qe&&e.package_==="core-xsd"&&or.has(e.name)}err(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=t,i.entityName=e,i.propertyName=o,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function _e(p){return typeof p=="number"?p:void 0}function J(p){return`${p.publisher}/${p.package_}/${p.name}`}function tr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var et={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},nr=p=>p,Me=class{ruleName="OwlOneOf";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=rr(e);if(!a)return n;for(let i of r){if(!(i instanceof g)||i.namespace!==a||!oe(i,et))continue;let c=v(i,et);if(c.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 s of c)if(s instanceof go)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(s.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(s.value)));else if(s instanceof O){let l=V(r,s.subject);l&&$.isSchemaDefinitionType(nr(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${s.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${s.subject.publisher}/${s.subject.package_}/${s.subject.name}`))}}return n}err(e,o,t,n,r){let a=new u;return a.ruleType=this.ruleName,a.severity=o,a.entityName=e,a.propertyName="oneOf",a.message=t,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function rr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var ar=p=>p,ir=new yo("kanonak.org","core-rdf","Resource"),Be=class{ruleName="DiamondNameClash";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=sr(e);if(!a)return n;let i=jo(r);for(let c of r){if(!(c instanceof g)||c.namespace!==a||!$.isClassType(ar(c)))continue;let s=T(c);if(!s)continue;let l=H(r,s),m=b(s),d=new Set(l.map(y=>b(y)));d.delete(m),d.delete(b(ir));let f=new Map;for(let y of Eo(r,s)){if(!y.domains.some(E=>d.has(b(E))))continue;let K=f.get(y.uri.name);K?K.push(y):f.set(y.uri.name,[y])}for(let[y,k]of f){if(k.length<2)continue;let K=N=>Oo(i,l,N.uri)?.cardinality,E=new Set(k.map(N=>N.range?b(N.range):void 0).filter(N=>N!==void 0)),U=new Set(k.map(K).filter(N=>N!==void 0));E.size<=1&&U.size<=1||n.push(this.toError(c.name,y,k,K))}}return n}toError(e,o,t,n){let r=c=>{let s=`${c.uri.publisher}/${c.uri.package_}/${c.uri.name}`,l=c.range?`${c.range.publisher}/${c.range.package_}/${c.range.name}`:"no range",m=n(c);return`${s} (range ${l}${m?`, ${m}`:""})`},a=t.map(r).join("; "),i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=o,i.actualValue=a,i.message=`Class '${e}' inherits ${t.length} distinct properties named '${o}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${o}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${o}':
65
- \u2022 rename one of the properties, or
66
- \u2022 re-domain one so it is not inherited by '${e}', or
67
- \u2022 restructure the hierarchy so '${e}' inherits only one '${o}', or
68
- \u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function sr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var mo=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e,o={}){this.parser=e??new fo,this.documentRules=[new se,new ce,new pe,new le,new me],this.repositoryRules=[new ue,new de,new fe,new ie({offline:o.offline}),new ye,new ge,new ke,new he,new Re,new be,new Ke,new Ee,new Ve,new De,new Se,new Ie,new $e,new je,new Oe,new we,new Ce,new Ae,new Ye,new Ue,new Pe,new Ne,new Le,new Me,new Be]}async validateAsync(e,o,t){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(o){let r=[],a=t??new ne(new re(e,o)),i=a.repository;for(let c of this.repositoryRules)try{let s=await c.validateAsync(e,i,a);this.addErrorsToResult(n,s)}catch(s){let l=s instanceof Error?s.message:String(s);r.push({ruleName:c.ruleName,cause:l})}if(r.length>0){let c=new Map;for(let{ruleName:s,cause:l}of r){let m=c.get(l);m?m.push(s):c.set(l,[s])}for(let[s,l]of c){let m=new u;m.ruleType=l[0],m.severity="Error",l.length===1?m.message=`Validation rule '${l[0]}' failed: ${s}`:m.message=`${s} (affects ${l.length} rules: ${l.join(", ")})`,n.errors.push(m)}}}return n.isValid=n.errors.length===0,n}async validateDocumentsAsync(e,o){let t=new ne(o),n=[];for(let r of e){let a=await this.validateAsync(r,t.repository,t);n.push({document:r,result:a})}return n}async validateYamlAsync(e,o,t){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,o,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let o=this.documentRules.findIndex(t=>t instanceof e);o>=0&&this.documentRules.splice(o,1)}removeRepositoryRule(e){let o=this.repositoryRules.findIndex(t=>t instanceof e);o>=0&&this.repositoryRules.splice(o,1)}addErrorsToResult(e,o){for(let t of o)t.severity==="Error"?e.errors.push(t):t.severity==="Info"?this.includeWarnings&&e.infos.push(t):this.includeWarnings&&e.warnings.push(t)}};export{te as a,R as b,u as c,ro as d,ne as e,ie as f,se as g,ce as h,pe as i,le as j,me as k,ue as l,de as m,fe as n,ye as o,ge as p,ke as q,he as r,Re as s,be as t,Ke as u,Ee as v,Ve as w,De as x,Se as y,Ie as z,$e as A,je as B,Oe as C,we as D,Ce as E,Pe as F,Ue as G,Ae as H,Ne as I,Le as J,Me as K,Be as L,mo as M};