@kanonak-protocol/sdk 5.32.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.
Files changed (34) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{chunk-PRXC2HZ3.js → chunk-64A7JMOY.js} +1 -1
  3. package/dist/chunk-A7N2BMMP.js +1 -0
  4. package/dist/{chunk-EVMSO7HJ.js → chunk-BMKA5YBF.js} +1 -1
  5. package/dist/chunk-ESABMC5L.js +1 -0
  6. package/dist/chunk-FL42CQAH.js +155 -0
  7. package/dist/{chunk-PXS6XZ3V.js → chunk-FLITV5YI.js} +1 -1
  8. package/dist/{chunk-BS7RRG7D.js → chunk-JIQNO36P.js} +1 -1
  9. package/dist/chunk-LO5IH6OE.js +68 -0
  10. package/dist/{chunk-L2J7WD7E.js → chunk-R53WM2ZP.js} +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/introspection/OntologyModel.d.ts +13 -1
  13. package/dist/introspection/ShaclConstraints.d.ts +13 -0
  14. package/dist/kanonaks/EmbeddedKanonak.d.ts +13 -0
  15. package/dist/parsing/index.js +1 -1
  16. package/dist/producer/index.js +1 -1
  17. package/dist/reasoning/index.js +1 -1
  18. package/dist/resolution/TypeDirectedResolver.d.ts +12 -2
  19. package/dist/resolution/index.js +1 -1
  20. package/dist/search/index.js +1 -1
  21. package/dist/server/index.js +1 -1
  22. package/dist/shacl/ConformanceEvaluator.d.ts +13 -3
  23. package/dist/shacl/ShapesModel.d.ts +28 -0
  24. package/dist/shacl/lowering.d.ts +3 -2
  25. package/dist/shacl/uris.d.ts +7 -0
  26. package/dist/transformations/index.js +1 -1
  27. package/dist/validation/index.js +1 -1
  28. package/dist/validation/rules/repository/PropertyDomainRule.d.ts +6 -0
  29. package/dist/validation/rules/repository/ShaclShapeRule.d.ts +13 -0
  30. package/package.json +2 -2
  31. package/dist/chunk-7UYXTYXC.js +0 -1
  32. package/dist/chunk-DD3TCFBT.js +0 -155
  33. package/dist/chunk-LRVOGQI5.js +0 -68
  34. package/dist/chunk-PVUBHIU2.js +0 -1
@@ -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-DD3TCFBT.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-DD3TCFBT.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-LRVOGQI5.js";import"../chunk-KIBR3HAT.js";import"../chunk-DD3TCFBT.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.32.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.32.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};