@kanonak-protocol/sdk 5.30.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +1 -1
- package/dist/chunk-DD3TCFBT.js +155 -0
- package/dist/{chunk-CR5QY3LJ.js → chunk-LRVOGQI5.js} +7 -7
- package/dist/chunk-PRXC2HZ3.js +1 -0
- package/dist/chunk-PXS6XZ3V.js +2 -0
- package/dist/chunk-QHABFCRC.js +0 -0
- package/dist/index.js +1 -1
- package/dist/producer/index.js +1 -0
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/document/NamespacePrefixRule.d.ts +8 -0
- package/package.json +10 -2
- package/dist/chunk-J4ZD6IF6.js +0 -2
- package/dist/chunk-Z5Y4MCW5.js +0 -155
package/dist/server/index.js
CHANGED
|
@@ -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-Z5Y4MCW5.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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-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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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(`
|
|
@@ -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-
|
|
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(`
|
|
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(`
|
package/dist/validation/index.js
CHANGED
|
@@ -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-
|
|
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};
|
|
@@ -2,6 +2,14 @@ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/ty
|
|
|
2
2
|
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
3
3
|
import type { IDocumentValidationRule } from './IDocumentValidationRule.js';
|
|
4
4
|
export declare class NamespacePrefixRule implements IDocumentValidationRule {
|
|
5
|
+
/**
|
|
6
|
+
* A Turtle/SPARQL-style prefixed name used where Kanonak expects a bare or
|
|
7
|
+
* alias-dotted name: the WHOLE value is `prefix:LocalName` — one well-known
|
|
8
|
+
* prefix, one colon, one name token. Prose that merely starts with one of
|
|
9
|
+
* these words followed by a colon (a label such as `Time::ParseDate License`,
|
|
10
|
+
* a comment beginning `Schema: ...`) is not a prefixed name and must not
|
|
11
|
+
* fire; the earlier prefix-only match did.
|
|
12
|
+
*/
|
|
5
13
|
private static readonly NAMESPACE_PREFIX_PATTERN;
|
|
6
14
|
readonly ruleName = "NamespacePrefix";
|
|
7
15
|
validate(document: KanonakDocument): OntologyValidationError[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.32.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",
|
|
@@ -78,6 +78,14 @@
|
|
|
78
78
|
"types": "./dist/transformations/index.d.ts",
|
|
79
79
|
"default": "./dist/transformations/index.js"
|
|
80
80
|
},
|
|
81
|
+
"./producer": {
|
|
82
|
+
"browser": {
|
|
83
|
+
"types": "./dist/producer/index.d.ts",
|
|
84
|
+
"default": "./dist/producer/index.js"
|
|
85
|
+
},
|
|
86
|
+
"types": "./dist/producer/index.d.ts",
|
|
87
|
+
"default": "./dist/producer/index.js"
|
|
88
|
+
},
|
|
81
89
|
"./server": {
|
|
82
90
|
"types": "./dist/server/index.d.ts",
|
|
83
91
|
"default": "./dist/server/index.js"
|
|
@@ -126,7 +134,7 @@
|
|
|
126
134
|
],
|
|
127
135
|
"dependencies": {
|
|
128
136
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
129
|
-
"@kanonak-protocol/types": "^5.
|
|
137
|
+
"@kanonak-protocol/types": "^5.32.0",
|
|
130
138
|
"ignore": "^7.0.5",
|
|
131
139
|
"js-yaml": "^4.1.0",
|
|
132
140
|
"yaml": "^2.7.0",
|
package/dist/chunk-J4ZD6IF6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{e as R}from"./chunk-BZ3YTI3C.js";import{a as H,b as B,c as Z,i as x,m as ne}from"./chunk-PVUBHIU2.js";import{ba as ee,fa as T,ia as N}from"./chunk-7UYXTYXC.js";import{b as z,c as _,d as $,f as q,g as W,h as Y,i as J,j as X,k as Q,l as I}from"./chunk-CJMVIOZX.js";var oe=(o=>(o.Class="Class",o.DatatypeProperty="DatatypeProperty",o.ObjectProperty="ObjectProperty",o.AnnotationProperty="AnnotationProperty",o.Instance="Instance",o.Datatype="Datatype",o.Shape="Shape",o.Unknown="Unknown",o))(oe||{}),se=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(se||{}),D=class{static async buildFromRepository(n,t){let a=await new ne().parseKanonaks(n),s=await n.getAllDocumentsAsync(),c=[],i=[],o=new Set,d=new Set,y=new Map;for(let g of a){let p=g;if(p.name&&(T.isClassType(p)&&o.add(p.name),g instanceof _)){let l=N(a,g);(l==="ObjectProperty"||l==="Property")&&d.add(p.name)}}for(let g of s)for(let[p,l]of Object.entries(g.body))d.has(p)&&l?.range&&typeof l.range=="string"&&y.set(p,l.range);let f=new Map;for(let g of a){let p=g;p.name&&f.set(p.name,p)}for(let g of s){let p=g.metadata.namespace_,l=p?`${p.publisher}/${p.package_}`:"",m=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",C=te(g);for(let[h,u]of Object.entries(g.body)){if(!u||typeof u!="object")continue;let b=f.get(h),k="Unknown";if(b){let A=b,P=b instanceof _?N(a,b):void 0;T.isClassType(A)?k="Class":P==="ObjectProperty"?k="ObjectProperty":P==="DatatypeProperty"?k="DatatypeProperty":P==="AnnotationProperty"?k="AnnotationProperty":T.isDatatypeType(A)?k="Datatype":P==="Property"?k="ObjectProperty":T.isShapeType(A)?k="Shape":T.isInstanceOfKnownClass(A,o)&&(k="Instance")}let S=l&&m?`${l}/${h}@${m}`:h,L={};for(let[A,P]of Object.entries(u))A!=="type"&&(typeof P!="object"||P===null)&&(L[A]=P);c.push({id:S,label:u.label??h,type:k,namespace:l,properties:L}),re(S,u,k,o,d,i,l,m,C,t),M(S,u,d,y,c,i,l,m,C),be(S,b,i)}}return{nodes:c,edges:i}}static buildFromDocument(n,t){let r=[],a=[],s=n.metadata.namespace_,c=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",i=s?`${s.publisher}/${s.package_}`:"",o=new Set,d=new Set,y=new Map,f=te(n);for(let[l,m]of Object.entries(n.body)){let C=m?.type;C&&(he(C,f)&&o.add(l),me(C,f)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(n.body)){if(!m||typeof m!="object")continue;let C=m.type,h=ke(C,l,o,f),u=i&&c?`${i}/${l}@${c}`:l,b={};for(let[k,S]of Object.entries(m))k!=="type"&&(typeof S!="object"||S===null)&&(b[k]=S);r.push({id:u,label:m.label??l,type:h,namespace:i,properties:b}),re(u,m,h,o,d,a,i,c,f,t),M(u,m,d,y,r,a,i,c,f)}let g=new Set(r.map(l=>l.id)),p=a.filter(l=>g.has(l.source)&&g.has(l.target));return{nodes:r,edges:p}}};function te(e,n){let t=new Map;if(e.metadata?.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let s of a){let c=s.alias??s.packageName,i=s.version,o=`${i.major}.${i.minor}.${i.patch}`;t.set(c,{publisher:r,package_:s.packageName,version:o})}return t}var ae={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},ye=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function K(e,n){if(e.includes(".")){let t=e.indexOf("."),r=e.substring(0,t),a=e.substring(t+1),s=n.get(r);if(s)return`${s.publisher}/${s.package_}/${a}`}return null}function he(e,n){let t=K(e,n);return t?ae[t]==="Class":!1}function me(e,n){let t=K(e,n);return t?ye.has(t):!1}function ke(e,n,t,r){if(!e||e==="Package")return"Unknown";let a=K(e,r);if(a){let c=ae[a];if(c)return c;let i=a.split("/").pop()?.split("@")[0]??"";return t.has(i)?"Instance":"Unknown"}let s=e.split(".").pop()??e;return t.has(s)?"Instance":"Unknown"}var ie=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function re(e,n,t,r,a,s,c,i,o,d){let y=n.type,f=n.subClassOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:e,target:w(u,c,i,o),type:"subClassOf",label:"subClassOf"})}let g=n.subPropertyOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:e,target:w(u,c,i,o),type:"subPropertyOf",label:"subPropertyOf"})}let p=n.domain,l=n.range;if(d?.includePropertyEdges){let h=[[p,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let S of Array.isArray(u)?u:[u])typeof S=="string"&&s.push({source:e,target:w(S,c,i,o),type:b,label:k})}if(t==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:e,target:w(h,c,i,o),type:"instanceOf",label:"type"})}if(t==="Instance")for(let[h,u]of Object.entries(n)){if(ie.has(h)||!a.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Ce(k)&&s.push({source:e,target:w(k,c,i,o),type:"propertyValue",label:h,propertyId:w(h,c,i,o)})}if((t==="ObjectProperty"||t==="DatatypeProperty"||p&&l)&&p&&l){let h=typeof p=="string"?p:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:w(h,c,i,o),target:w(u,c,i,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function M(e,n,t,r,a,s,c,i,o){for(let[d,y]of Object.entries(n)){if(ie.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let f=y,g=`${e}/${d}`,p=r.get(d),l=p?p.split(".").pop()??p:"Unknown",m={};for(let[h,u]of Object.entries(f))(typeof u!="object"||u===null)&&(m[h]=u);a.push({id:g,label:`${l} (embedded)`,type:"Instance",namespace:c,properties:m});let C=c&&i?`${c}/${d}@${i}`:d;s.push({source:e,target:g,type:"propertyValue",label:d,propertyId:t.has(d)?C:void 0}),p&&s.push({source:g,target:w(l,c,i,o),type:"instanceOf",label:"type (inferred)"}),M(g,f,t,r,a,s,c,i,o)}}function be(e,n,t){let r=n?.statement;if(Array.isArray(r))for(let a of r){if(!(a instanceof Z))continue;let s=a.predicate?.subject?.name??"";for(let c of a.links){let i=c.target?.subject;if(!i)continue;let o=i.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";t.push({source:e,target:`${i.publisher}/${i.package_}/${i.name}${d}`,type:"embeddedLink",label:s})}}}function Ce(e){return!(!e||e.includes(" ")||e.includes(`
|
|
2
|
-
`)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let a=e.indexOf("."),s=e.substring(0,a),c=e.substring(a+1);if(r){let i=r.get(s);if(i)return`${i.publisher}/${i.package_}/${c}@${i.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}import{canonicalForm as Se,canonicalHash as we}from"@kanonak-protocol/canonical";function F(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as $e}from"@kanonak-protocol/canonical";function Oe(e){return Se(F(e)?e:pe(e))}function ve(e){return we(F(e)?e:pe(e))}function pe(e){let n=[];for(let t of e)t instanceof _&&n.push({uri:Re(t),statements:U(t.statement)});return{subjects:n}}function U(e){let n=[];for(let t of e){let r=Ee(t);if(!r)continue;if(t instanceof I&&Pe(t.predicate.subject)){n.push(...Te(t,r));continue}let a=je(t);a&&n.push({predicate:r,value:a})}return n}function Pe(e){let n=ee("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var ce=new TextEncoder;function Ae(e,n){let t=ce.encode(e),r=ce.encode(n),a=Math.min(t.length,r.length);for(let s=0;s<a;s++)if(t[s]!==r[s])return t[s]-r[s];return t.length-r.length}function Te(e,n){let t=[];for(let r of e.object){if(!(r instanceof $))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(G(r))}t.sort(Ae);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:n,value:{ref:r}}))}function je(e){if(e instanceof q&&e.carrier)return{lit:e.lexical??String(e.object),datatype:ue(e.carrier)};if(e instanceof W)return{raw:e.object};if(e instanceof Y)return{raw:e.lexical??String(e.object)};if(e instanceof J)return{raw:e.lexical??String(e.object)};if(e instanceof X)return{ref:G(e.object)};if(e instanceof Q)return le(e.object);if(e instanceof I)return{list:e.object.map(_e)}}function le(e){let n=U(e.statement);return e.name&&e.name.length>0?{embed:{name:e.name,statements:n}}:{embed:{statements:n}}}function _e(e){if(e instanceof $)return{ref:G(e)};if(e instanceof H)return le(e);if(e instanceof B){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:ue(e.carrier)};let n=e.value;if(typeof n=="string")return{raw:n};if(typeof n=="number")return{raw:String(n)};if(typeof n=="boolean")return{raw:String(n)}}if(e instanceof z)return{embed:{statements:U(e.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${e.constructor?.name??typeof e}); add canonicalization support before hashing data that contains it`)}function ue(e){return e===x.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function Ee(e){let n=e.predicate;if(n)return de(n.subject)}function Re(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function G(e){return de(e.subject)}function de(e){let n=e.version;return n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}/${e.name}`:`${e.publisher}/${e.package_}/${e.name}`}function j(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var Ie="key_thumbprint",E=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=j(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,a=await Ne(r),s=a&&Array.isArray(a.authorization_servers)?a.authorization_servers.filter(i=>typeof i=="string"):[],c=s.length>0?s:null;return this.prCache.set(t,c),c}async discover(n){let t=j(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,a=await this.tryEndpoint(r);if(!a){let s=`https://${t}/.well-known/openid-configuration`;a=await this.tryEndpoint(s)}return this.cache.set(t,a),a}async supportsOAuth(n){return await this.discover(n)!==null}static supportsPkceS256(n){return n.codeChallengeMethodsSupported?.some(t=>t.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(n){return!!n.registrationEndpoint}static supportsAuthorizationCode(n){return n.responseTypesSupported?.some(t=>t.toLowerCase()==="code")??!1}static supportsEnrollment(n){return!!n.enrollmentEndpoint}static supportsSession(n){return!!n.sessionEndpoint}async tryEndpoint(n){let t;try{t=await fetch(n)}catch(a){let s=a instanceof Error?a.message:String(a);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${s})`),console.error(" If the server is behind a VPN, ensure you are connected.")):s.includes("CERT")||s.includes("SSL")||s.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${s})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${n} \u2014 network error: ${s}`),null}if(!t.ok)return t.status===404||(t.status===403?(console.error(` OAuth discovery: ${n} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):t.status>=500&&(console.error(` OAuth discovery: ${n} \u2014 HTTP ${t.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let r;try{r=await t.json()}catch{return console.error(` OAuth discovery: ${n} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:O(r.issuer),authorizationEndpoint:O(r.authorization_endpoint),tokenEndpoint:O(r.token_endpoint),registrationEndpoint:O(r.registration_endpoint),revocationEndpoint:O(r.revocation_endpoint),scopesSupported:v(r.scopes_supported),responseTypesSupported:v(r.response_types_supported),grantTypesSupported:v(r.grant_types_supported),codeChallengeMethodsSupported:v(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:v(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:v(r.dpop_signing_alg_values_supported),enrollmentEndpoint:O(r.enrollment_endpoint),enrollmentIssuanceProtocols:v(r.enrollment_issuance_protocols),enrollmentKeyTypes:v(r.enrollment_key_types),enrollmentScopesSupported:v(r.enrollment_scopes_supported),enrollmentConsentBindingParam:O(r.enrollment_consent_binding_param),sessionEndpoint:O(r.session_endpoint),sessionEndpointAuthMethod:O(r.session_endpoint_auth_method)}}};async function Ne(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function O(e){return typeof e=="string"?e:null}function v(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function fe(e){let n=e.headers.get("WWW-Authenticate")??void 0,t=e.headers.get("DPoP-Nonce")??void 0;if(!n&&!t)return;let r={wwwAuthenticate:n??""};if(t&&(r.nonce=t),n){let a=n.match(/acr_values\s*=\s*"([^"]*)"/i);a&&(r.acrValues=a[1])}return r}function xe(e){try{return new URL(e).host}catch{return null}}function De(e,n={}){let t=n.discovery??new E,r=new Map,a=new Map,s=async o=>{let d=r.get(o);if(d!==void 0)return d;let y=null,f=await t.discoverProtectedResource(o).catch(()=>null);return f&&f.length>0&&(y=xe(f[0])),r.set(o,y),y},c=async(o,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&a.has(o))return a.get(o);let f=await e.resolve(o,d).catch(()=>null);return a.set(o,f),f},i=async(o,d,y,f)=>{let g=await s(d);if(!g)return{res:await R(o,{method:y,redirect:"manual"}),authed:!1};let p=await c(g,{method:y,url:o,...f}),l=p?.headers??{};return{res:await R(o,{method:y,redirect:"manual",headers:l}),authed:!!p}};return async(o,d,y="GET")=>{let f=await i(o,d,y,{});if((f.res.status===401||f.res.status===403)&&f.authed){let g=fe(f.res),p={forceRefresh:g===void 0};return g&&(p.challenge=g),(await i(o,d,y,p)).res}return f.res}}var ge="KANONAK_TOKEN";function Me(){return typeof process<"u"&&process.env?process.env:{}}function Ke(e){return`${ge}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var V=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??Me()}async resolve(n,t){let r=j(n),a=this.tokens[r]??this.env[Ke(r)]??this.env[ge];return a?{headers:{Authorization:`Bearer ${a}`}}:null}};export{oe as a,se as b,D as c,Oe as d,ve as e,$e as f,j as g,Ie as h,E as i,fe as j,De as k,V as l};
|