@kanonak-protocol/sdk 5.34.0 → 5.35.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-BMKA5YBF.js → chunk-26SO3A4B.js} +1 -1
- package/dist/{chunk-64A7JMOY.js → chunk-2Y6R3K5A.js} +1 -1
- package/dist/chunk-54D47DLS.js +1 -0
- package/dist/chunk-AVVLDZAZ.js +68 -0
- package/dist/chunk-D7QLWVPK.js +155 -0
- package/dist/chunk-JHQPXEMA.js +1 -0
- package/dist/chunk-MQBWSCNY.js +1 -0
- package/dist/{chunk-FLITV5YI.js → chunk-O35Y6QUW.js} +1 -1
- package/dist/{chunk-JIQNO36P.js → chunk-VEGFYZXG.js} +1 -1
- package/dist/chunk-ZYDJUGIA.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +10 -5
- package/dist/parsing/index.js +1 -1
- package/dist/producer/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/PropertyValues.d.ts +74 -0
- package/dist/uri-helpers/UriHelpers.d.ts +37 -5
- package/dist/uri-helpers/index.d.ts +4 -2
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-A7N2BMMP.js +0 -1
- package/dist/chunk-CJMVIOZX.js +0 -1
- package/dist/chunk-ESABMC5L.js +0 -1
- package/dist/chunk-FL42CQAH.js +0 -155
- package/dist/chunk-LO5IH6OE.js +0 -68
- package/dist/chunk-R53WM2ZP.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as j,C as W,c as B,d as G,o as b,p as X,r as Y,s as H,w as q,x as M}from"./chunk-54D47DLS.js";import{a as _}from"./chunk-FUUTGGJS.js";import{b as I}from"./chunk-F67UH4FD.js";var Q=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",s=this.cache.get(r);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(r,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let r=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],u=await this.findDocumentForAlias(n,a);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,r){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=r.length===0?a:`${r} \u2192 ${a}`;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 g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:u,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,g),entity:c,definedInNamespace:a,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,g)=>c+g.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${a}`);for(let[c,g]of Object.entries(e.metadata.imports))for(let m of g)if(!I(m))try{this.logger?.debug?.(`Resolving import: ${c}/${m.packageName}`);let d=await this.repository.getHighestCompatibleVersionAsync(c,m);if(d){this.logger?.debug?.(`Successfully loaded import: ${d.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(d,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${d.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${m.packageName}`)}catch(d){let k=d;throw this.logger?.error?.(`Failed to process import ${c}/${m.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${m.packageName} for namespace ${a}. See inner exception for details.`,{cause:d})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,r,s){let a=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`),a;let u=s.get(i);if(u)return u;n.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,g=0;for(let[m,d]of Object.entries(e.body))if(!m.includes(".")&&d&&typeof d=="object"&&!Array.isArray(d)){if(!e.metadata.namespace_)continue;if(!a.has(m)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(m,{entityName:m,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,m,k),entity:d,definedInNamespace:i,isImported:r.length>0,importPath:c}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let m=Object.values(e.metadata.imports).reduce((d,k)=>d+k.length,0);this.logger?.debug?.(`Processing ${m} import(s) for ${i}`);for(let[d,k]of Object.entries(e.metadata.imports))for(let S of k)if(!I(S))try{this.logger?.debug?.(`Resolving import: ${d}/${S.packageName}`);let P=await this.repository.getHighestCompatibleVersionAsync(d,S);if(P){this.logger?.debug?.(`Successfully loaded import: ${P.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(P,n,c,s),v=0;for(let[x,C]of U.entries()){let h=a.get(x);if(!h)a.set(x,C),v++;else if(h.isImported&&C.isImported&&(h.uri.publisher!==C.uri.publisher||h.uri.package_!==C.uri.package_)){let E=h.isAmbiguous?h:{...h,isAmbiguous:!0,ambiguousNamespaces:[h.definedInNamespace]};E.ambiguousNamespaces.includes(C.definedInNamespace)||E.ambiguousNamespaces.push(C.definedInNamespace),a.set(x,E),this.logger?.warn?.(`Ambiguous reference '${x}': defined in ${E.ambiguousNamespaces.join(", ")}`)}if(S.alias&&!x.includes(".")){let E=`${S.alias}.${x}`;a.has(E)||(a.set(E,C),v++)}}this.logger?.debug?.(`Merged ${v} entities from import ${P.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${d}/${S.packageName}`)}catch(P){let U=P;throw this.logger?.error?.(`Failed to process import ${d}/${S.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${d}/${S.packageName} for namespace ${i}. See inner exception for details.`,{cause:P})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[r,s]of Object.entries(e.metadata.imports))for(let a of s)if(!I(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(r,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(r,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var z=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 s=r.entity.type;if(s){let a=String(s);return a==="Class"||a==="rdfs.Class"||a.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 J(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,s]=n;if(!r||!s)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let a=s.indexOf("@");if(a===-1)return{kind:"package",publisher:r,package_:s};let i=s.substring(0,a),u=s.substring(a+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let c=ae(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:_.parse(e)}}function He(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 ae(t){let e=t.split(".").map(Number);return se(e[0]||0,e[1]||0,e[2]||0)}function se(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 Ne(t){return`${t.publisher}/${t.package_}/${t.name}`}function y(t,e,n){return`${t}/${e}/${n}`}function Te(t){return`${t.s}|${t.p}|${ie(t.o)}`}function ie(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 $e(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var pe="kanonak.org",ce="core-shacl",o=t=>({publisher:pe,package_:ce,name:t}),D=o("Shape"),N=o("NodeShape"),T=o("PropertyShape"),Me=o("targetClass"),je=o("property"),we=o("path"),Le=o("minCount"),Ve=o("maxCount"),Fe=o("datatype"),Be=o("class"),Ge=o("in"),Xe=o("pattern"),Ye=o("flags"),qe=o("minLength"),We=o("maxLength"),Qe=o("minInclusive"),ze=o("maxInclusive"),Je=o("message"),Ze=o("targetNode"),et=o("targetSubjectsOf"),tt=o("targetObjectsOf"),nt=o("closed"),rt=o("ignoredProperties"),ot=o("nodeKind"),at=o("IRI"),st=o("BlankNode"),it=o("Literal"),pt=o("severity"),ct=o("Violation"),lt=o("Warning"),ut=o("Info"),yt=o("ValidationReport"),dt=o("conforms"),mt=o("result"),gt=o("ValidationResult"),ft=o("focusNode"),kt=o("resultPath"),bt=o("resultMessage"),St=o("resultSeverity"),ht=o("sourceShape"),_t=o("value"),Pt=o("sourceConstraintComponent"),Ct=o("MinCountConstraintComponent"),Et=o("MaxCountConstraintComponent"),Kt=o("DatatypeConstraintComponent"),At=o("ClassConstraintComponent"),xt=o("InConstraintComponent"),Rt=o("PatternConstraintComponent"),Ot=o("MinLengthConstraintComponent"),Ut=o("MaxLengthConstraintComponent"),It=o("MinInclusiveConstraintComponent"),Ht=o("MaxInclusiveConstraintComponent"),Dt=o("NodeKindConstraintComponent"),Nt=o("ClosedConstraintComponent"),Tt=o("hasValue"),$t=o("qualifiedValueShape"),vt=o("qualifiedMinCount"),Mt=o("qualifiedMaxCount"),jt=o("HasValueConstraintComponent"),wt=o("QualifiedMinCountConstraintComponent"),Lt=o("QualifiedMaxCountConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",ee="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",ee]]),le=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function Gt(t){return L.has(t)}function Xt(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 s=()=>{t.publisher=l,t.package_=r,n&&(t.version=n.get(r))};if(le.has(t.name)){let a=t.publisher===l&&t.package_===r;t.publisher=l,t.package_=r,!a&&n&&(t.version=n.get(r));return}t.publisher===l&&t.package_===r||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var Z=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,ee,"Package");shape=w(D);nodeShape=w(N);propertyShape=w(T)};function w(t){return y(t.publisher,t.package_,t.name)}var ue=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 s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ne(t)[0]??null}function ne(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?Y(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 ye=[D,N,T];function O(t,e){return ue.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 te=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ne(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?ye.some(r=>X(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 K="kanonak.org",A="core-rdf",me={publisher:K,package_:A,name:"domain"},ge={publisher:K,package_:A,name:"range"},fe={publisher:K,package_:A,name:"subClassOf"},ke={publisher:K,package_:A,name:"type"},be={publisher:K,package_:A,name:"label"},Se={publisher:K,package_:A,name:"comment"},he=new _(K,A,"Resource");function _e(t){try{let e=J(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function oe(t,e){let n=[],r=new Set,s="version"in e?e.version:void 0,a=[new _(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),u=b(i);if(r.has(u))continue;r.add(u),n.push(i);let c=Pe(t,i);c&&a.push(...H(c,fe))}return n}function Pe(t,e){return e.version&&typeof e.version.major=="number"?q(t,e)??M(t,e)[0]:M(t,e)[0]}function $(t,e){let n;for(let r of Ae(e)){let s=Ce(t,r);if(s){if(s!=="Property")return s;n??=s}}return n}function Ce(t,e){let n=F(e);if(n)return n;let r=re.get(t);r||(r=new Map,re.set(t,r));let s=e.version,a=s&&typeof s.major=="number"?`${b(e)}@${s.major}.${s.minor}.${s.patch}`:b(e),i=r.get(a);if(i!==void 0)return i??void 0;let u;for(let c of oe(t,e)){let g=F(c);if(g){if(g!=="Property"){u=g;break}u??="Property"}}return r.set(a,u??null),u}var re=new WeakMap;function an(t,e){return $(t,e)!==void 0}function sn(t,e){return $(t,e)==="ObjectProperty"}function pn(t,e){return $(t,e)==="DatatypeProperty"}function Ee(t,e){let n=new Set([b(he)]);for(let r of oe(t,e))n.add(b(r));return n}function Ke(t,e){let n=Ee(t,e),r=[],s=new Set;for(let a of t){if(!(a instanceof B))continue;let i=$(t,a);if(!i)continue;let u=H(a,me);if(!u.some(m=>n.has(b(m))))continue;let c=_e(a);if(!c)continue;let g=b(c);s.has(g)||(s.add(g),r.push({uri:c,label:j(a,be),comment:j(a,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:W(a,ge),domains:u}))}return r}function cn(t,e,n){let r=Ke(t,e).find(s=>b(s.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 Ae(t){let e=H(t,ke);return e.length>0?e:t instanceof G&&t.rangeType?[t.rangeType]:[]}export{Q as a,z as b,J as c,He as d,Ne as e,y as f,Te as g,ie as h,$e as i,pe as j,ce as k,D as l,N as m,T as n,Me as o,je as p,we as q,Le as r,Ve as s,Fe as t,Be as u,Ge as v,Xe as w,Ye as x,qe as y,We as z,Qe as A,ze as B,Je as C,Ze as D,et as E,tt as F,nt as G,rt as H,ot as I,at as J,st as K,it as L,pt as M,ct as N,lt as O,ut as P,Ct as Q,Et as R,Kt as S,At as T,xt as U,Rt as V,Ot as W,Ut as X,It as Y,Ht as Z,Dt as _,Nt as $,Tt as aa,$t as ba,vt as ca,Mt as da,jt as ea,wt as fa,Lt as ga,Gt as ha,Xt as ia,V as ja,Z as ka,F as la,te as ma,_e as na,oe as oa,$ as pa,an as qa,sn as ra,pn as sa,Ke as ta,cn as ua,Ae as va};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as R}from"./chunk-BZ3YTI3C.js";import{
|
|
1
|
+
import{e as R}from"./chunk-BZ3YTI3C.js";import{a as F,k as G}from"./chunk-JHQPXEMA.js";import{ma as S,pa as j}from"./chunk-MQBWSCNY.js";import{c as N}from"./chunk-54D47DLS.js";var z=(r=>(r.Class="Class",r.DatatypeProperty="DatatypeProperty",r.ObjectProperty="ObjectProperty",r.AnnotationProperty="AnnotationProperty",r.Instance="Instance",r.Datatype="Datatype",r.Shape="Shape",r.Unknown="Unknown",r))(z||{}),L=(r=>(r.InstanceOf="instanceOf",r.SubClassOf="subClassOf",r.Domain="domain",r.Range="range",r.ObjectRelationship="objectRelationship",r.SubPropertyOf="subPropertyOf",r.PropertyValue="propertyValue",r.EmbeddedLink="embeddedLink",r))(L||{}),$=class{static async buildFromRepository(e,n){let i=await new G().parseKanonaks(e),s=await e.getAllDocumentsAsync(),p=[],a=[],r=new Set,d=new Set,y=new Map;for(let f of i){let c=f;if(c.name&&(S.isClassType(c)&&r.add(c.name),f instanceof N)){let l=j(i,f);(l==="ObjectProperty"||l==="Property")&&d.add(c.name)}}for(let f of s)for(let[c,l]of Object.entries(f.body))d.has(c)&&l?.range&&typeof l.range=="string"&&y.set(c,l.range);let g=new Map;for(let f of i){let c=f;c.name&&g.set(c.name,c)}for(let f of s){let c=f.metadata.namespace_,l=c?`${c.publisher}/${c.package_}`:"",m=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",O=U(f);for(let[h,u]of Object.entries(f.body)){if(!u||typeof u!="object")continue;let b=g.get(h),k="Unknown";if(b){let T=b,A=b instanceof N?j(i,b):void 0;S.isClassType(T)?k="Class":A==="ObjectProperty"?k="ObjectProperty":A==="DatatypeProperty"?k="DatatypeProperty":A==="AnnotationProperty"?k="AnnotationProperty":S.isDatatypeType(T)?k="Datatype":A==="Property"?k="ObjectProperty":S.isShapeType(T)?k="Shape":S.isInstanceOfKnownClass(T,r)&&(k="Instance")}let P=l&&m?`${l}/${h}@${m}`:h,I={};for(let[T,A]of Object.entries(u))T!=="type"&&(typeof A!="object"||A===null)&&(I[T]=A);p.push({id:P,label:u.label??h,type:k,namespace:l,properties:I}),K(P,u,k,r,d,a,l,m,O,n),D(P,u,d,y,p,a,l,m,O),Q(P,b,a)}}return{nodes:p,edges:a}}static buildFromDocument(e,n){let o=[],i=[],s=e.metadata.namespace_,p=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",r=new Set,d=new Set,y=new Map,g=U(e);for(let[l,m]of Object.entries(e.body)){let O=m?.type;O&&(Y(O,g)&&r.add(l),J(O,g)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(e.body)){if(!m||typeof m!="object")continue;let O=m.type,h=X(O,l,r,g),u=a&&p?`${a}/${l}@${p}`:l,b={};for(let[k,P]of Object.entries(m))k!=="type"&&(typeof P!="object"||P===null)&&(b[k]=P);o.push({id:u,label:m.label??l,type:h,namespace:a,properties:b}),K(u,m,h,r,d,i,a,p,g,n),D(u,m,d,y,o,i,a,p,g)}let f=new Set(o.map(l=>l.id)),c=i.filter(l=>f.has(l.source)&&f.has(l.target));return{nodes:o,edges:c}}};function U(t,e){let n=new Map;if(t.metadata?.imports)for(let[o,i]of Object.entries(t.metadata.imports))for(let s of i){let p=s.alias??s.packageName,a=s.version,r=`${a.major}.${a.minor}.${a.patch}`;n.set(p,{publisher:o,package_:s.packageName,version:r})}return n}var B={"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"},W=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(t,e){if(t.includes(".")){let n=t.indexOf("."),o=t.substring(0,n),i=t.substring(n+1),s=e.get(o);if(s)return`${s.publisher}/${s.package_}/${i}`}return null}function Y(t,e){let n=M(t,e);return n?B[n]==="Class":!1}function J(t,e){let n=M(t,e);return n?W.has(n):!1}function X(t,e,n,o){if(!t||t==="Package")return"Unknown";let i=M(t,o);if(i){let p=B[i];if(p)return p;let a=i.split("/").pop()?.split("@")[0]??"";return n.has(a)?"Instance":"Unknown"}let s=t.split(".").pop()??t;return n.has(s)?"Instance":"Unknown"}var V=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function K(t,e,n,o,i,s,p,a,r,d){let y=e.type,g=e.subClassOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subClassOf",label:"subClassOf"})}let f=e.subPropertyOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subPropertyOf",label:"subPropertyOf"})}let c=e.domain,l=e.range;if(d?.includePropertyEdges){let h=[[c,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let P of Array.isArray(u)?u:[u])typeof P=="string"&&s.push({source:t,target:v(P,p,a,r),type:b,label:k})}if(n==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:t,target:v(h,p,a,r),type:"instanceOf",label:"type"})}if(n==="Instance")for(let[h,u]of Object.entries(e)){if(V.has(h)||!i.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Z(k)&&s.push({source:t,target:v(k,p,a,r),type:"propertyValue",label:h,propertyId:v(h,p,a,r)})}if((n==="ObjectProperty"||n==="DatatypeProperty"||c&&l)&&c&&l){let h=typeof c=="string"?c:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:v(h,p,a,r),target:v(u,p,a,r),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function D(t,e,n,o,i,s,p,a,r){for(let[d,y]of Object.entries(e)){if(V.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let g=y,f=`${t}/${d}`,c=o.get(d),l=c?c.split(".").pop()??c:"Unknown",m={};for(let[h,u]of Object.entries(g))(typeof u!="object"||u===null)&&(m[h]=u);i.push({id:f,label:`${l} (embedded)`,type:"Instance",namespace:p,properties:m});let O=p&&a?`${p}/${d}@${a}`:d;s.push({source:t,target:f,type:"propertyValue",label:d,propertyId:n.has(d)?O:void 0}),c&&s.push({source:f,target:v(l,p,a,r),type:"instanceOf",label:"type (inferred)"}),D(f,g,n,o,i,s,p,a,r)}}function Q(t,e,n){let o=e?.statement;if(Array.isArray(o))for(let i of o){if(!(i instanceof F))continue;let s=i.predicate?.subject?.name??"";for(let p of i.links){let a=p.target?.subject;if(!a)continue;let r=a.version,d=r&&typeof r.major=="number"?`@${r.major}.${r.minor}.${r.patch}`:"";n.push({source:t,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Z(t){return!(!t||t.includes(" ")||t.includes(`
|
|
2
2
|
`)||t.startsWith("http://")||t.startsWith("https://")||/^\d{4}-\d{2}/.test(t)||/^\d+(\.\d+)?$/.test(t))}function v(t,e,n,o){if(t.includes("@")&&t.includes("/"))return t;if(t.includes(".")){let i=t.indexOf("."),s=t.substring(0,i),p=t.substring(i+1);if(o){let a=o.get(s);if(a)return`${a.publisher}/${a.package_}/${p}@${a.version}`}return e&&n?`${e}/${p}@${n}`:p}return e&&n?`${e}/${t}@${n}`:t}function _(t){let e=t.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}var ee="key_thumbprint",E=class{cache=new Map;prCache=new Map;async discoverProtectedResource(e){let n=_(e);if(this.prCache.has(n))return this.prCache.get(n);let o=`https://${n}/.well-known/oauth-protected-resource`,i=await te(o),s=i&&Array.isArray(i.authorization_servers)?i.authorization_servers.filter(a=>typeof a=="string"):[],p=s.length>0?s:null;return this.prCache.set(n,p),p}async discover(e){let n=_(e);if(this.cache.has(n))return this.cache.get(n);let o=`https://${n}/.well-known/oauth-authorization-server`,i=await this.tryEndpoint(o);if(!i){let s=`https://${n}/.well-known/openid-configuration`;i=await this.tryEndpoint(s)}return this.cache.set(n,i),i}async supportsOAuth(e){return await this.discover(e)!==null}static supportsPkceS256(e){return e.codeChallengeMethodsSupported?.some(n=>n.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(e){return!!e.registrationEndpoint}static supportsAuthorizationCode(e){return e.responseTypesSupported?.some(n=>n.toLowerCase()==="code")??!1}static supportsEnrollment(e){return!!e.enrollmentEndpoint}static supportsSession(e){return!!e.sessionEndpoint}async tryEndpoint(e){let n;try{n=await fetch(e)}catch(i){let s=i instanceof Error?i.message:String(i);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${e} \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: ${e} \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: ${e} \u2014 network error: ${s}`),null}if(!n.ok)return n.status===404||(n.status===403?(console.error(` OAuth discovery: ${e} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):n.status>=500&&(console.error(` OAuth discovery: ${e} \u2014 HTTP ${n.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let o;try{o=await n.json()}catch{return console.error(` OAuth discovery: ${e} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:C(o.issuer),authorizationEndpoint:C(o.authorization_endpoint),tokenEndpoint:C(o.token_endpoint),registrationEndpoint:C(o.registration_endpoint),revocationEndpoint:C(o.revocation_endpoint),scopesSupported:w(o.scopes_supported),responseTypesSupported:w(o.response_types_supported),grantTypesSupported:w(o.grant_types_supported),codeChallengeMethodsSupported:w(o.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:w(o.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:w(o.dpop_signing_alg_values_supported),enrollmentEndpoint:C(o.enrollment_endpoint),enrollmentIssuanceProtocols:w(o.enrollment_issuance_protocols),enrollmentKeyTypes:w(o.enrollment_key_types),enrollmentScopesSupported:w(o.enrollment_scopes_supported),enrollmentConsentBindingParam:C(o.enrollment_consent_binding_param),sessionEndpoint:C(o.session_endpoint),sessionEndpointAuthMethod:C(o.session_endpoint_auth_method)}}};async function te(t){try{let e=await fetch(t);return e.ok?await e.json():null}catch{return null}}function C(t){return typeof t=="string"?t:null}function w(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):null}function H(t){let e=t.headers.get("WWW-Authenticate")??void 0,n=t.headers.get("DPoP-Nonce")??void 0;if(!e&&!n)return;let o={wwwAuthenticate:e??""};if(n&&(o.nonce=n),e){let i=e.match(/acr_values\s*=\s*"([^"]*)"/i);i&&(o.acrValues=i[1])}return o}function ne(t){try{return new URL(t).host}catch{return null}}function re(t,e={}){let n=e.discovery??new E,o=new Map,i=new Map,s=async r=>{let d=o.get(r);if(d!==void 0)return d;let y=null,g=await n.discoverProtectedResource(r).catch(()=>null);return g&&g.length>0&&(y=ne(g[0])),o.set(r,y),y},p=async(r,d)=>{if(!t)return null;if(!(d.forceRefresh||d.challenge)&&i.has(r))return i.get(r);let g=await t.resolve(r,d).catch(()=>null);return i.set(r,g),g},a=async(r,d,y,g)=>{let f=await s(d);if(!f)return{res:await R(r,{method:y,redirect:"manual"}),authed:!1};let c=await p(f,{method:y,url:r,...g}),l=c?.headers??{};return{res:await R(r,{method:y,redirect:"manual",headers:l}),authed:!!c}};return async(r,d,y="GET")=>{let g=await a(r,d,y,{});if((g.res.status===401||g.res.status===403)&&g.authed){let f=H(g.res),c={forceRefresh:f===void 0};return f&&(c.challenge=f),(await a(r,d,y,c)).res}return g.res}}var q="KANONAK_TOKEN";function oe(){return typeof process<"u"&&process.env?process.env:{}}function se(t){return`${q}_${t.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var x=class{tokens;env;constructor(e={}){this.tokens=e.tokens??{},this.env=e.env??oe()}async resolve(e,n){let o=_(e),i=this.tokens[o]??this.env[se(o)]??this.env[q];return i?{headers:{Authorization:`Bearer ${i}`}}:null}};export{z as a,L as b,$ as c,_ as d,ee as e,E as f,H as g,re as h,x as i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{j as V}from"./chunk-JHQPXEMA.js";import{a as E}from"./chunk-HF5FJBS2.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
|
|
2
2
|
`&&(n++,r=o+1)}return n===e?Math.min(r+t,i.length):-1}export{L as a,K as b,x as c,W as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-54D47DLS.js";import{c as b,g as u}from"./chunk-QILEJIFU.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};
|
package/dist/index.d.ts
CHANGED
|
@@ -42,3 +42,5 @@ export { canonicalForm, canonicalHash, CANONICAL_FORM_VERSION, Carrier, carrierO
|
|
|
42
42
|
export type { CanonicalInput, CanonicalInputSubject, CanonicalInputStatement, CanonicalInputValue, } from './canonical/index.js';
|
|
43
43
|
export { buildOntologyModel } from './introspection/index.js';
|
|
44
44
|
export type { OntologyModel, ClassDef, PropertyDef, ClassRef, TypeRef, EnumDef, EnumMember, BuildOntologyModelOptions, } from './introspection/index.js';
|
|
45
|
+
export { valuesOf, referenceUris, typeReferenceUris } from './uri-helpers/index.js';
|
|
46
|
+
export type { PropertyValue } from './uri-helpers/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as rt,b as at,c as it,d as st,e as z}from"./chunk-BMKA5YBF.js";import{a as wn,b as Un,c as An}from"./chunk-V3DH67P3.js";import{a as nt,b as ot,c as tt,d as fr,e as pr,f as mr,g as hr,h as kr,i as Sr}from"./chunk-FLITV5YI.js";import{a as gr}from"./chunk-R53WM2ZP.js";import{a as sr,b as cr,c as ur,d as Q,e as dr,f as lr,g as Ne,h as yr,i as br,j as Er,k as Rr,l as Cr}from"./chunk-64A7JMOY.js";import{a as go,b as yo,c as bo,d as Eo,e as Ro,f as Oo,g as wo,h as Uo,i as Ao}from"./chunk-IS3AQKB4.js";import{a as Co,b as Ko,c as _o,d as vo,e as xo,f as Po,h as Io,i as Fe,j as He,k as Te,l as qe,m as Lo,n as Vo}from"./chunk-BZ3YTI3C.js";import{a as ut,b as dt,c as lt,d as ft}from"./chunk-JIQNO36P.js";import{a as pt}from"./chunk-XK24CN3C.js";import{a as No}from"./chunk-SC5M74NM.js";import{A as Ft,B as Ht,C as Tt,D as qt,E as Wt,F as Bt,G as er,H as nr,I as or,J as tr,K as rr,L as ar,M as ir,a as ht,b as kt,c as St,d as gt,e as yt,f as bt,g as Et,h as Rt,i as Ct,j as Kt,k as _t,l as vt,m as xt,n as Pt,o as It,p as Lt,q as Nt,r as Vt,s as Ot,t as wt,u as Ut,v as At,w as $t,x as jt,y as Mt,z as Dt}from"./chunk-LO5IH6OE.js";import"./chunk-KIBR3HAT.js";import{c as Nn,d as Gt,e as zt,g as Qt,h as Xt,k as Yt,m as Le,o as Vn,p as On,r as Jt,s as Zt}from"./chunk-FL42CQAH.js";import"./chunk-QHABFCRC.js";import{a as Se}from"./chunk-6VIUXP4N.js";import{a as F,b as Ee,h as w,i as Ie,j as Zo,k as et,l as M}from"./chunk-A7N2BMMP.js";import{a as D}from"./chunk-HF5FJBS2.js";import{a as mt}from"./chunk-PEJALHXK.js";import{$ as Pn,A as nn,B as on,C as tn,D as rn,E as an,F as sn,G as cn,H as un,I as dn,J as ln,K as fn,L as pn,M as mn,N as Ke,O as hn,P as kn,Q as Sn,R as gn,S as yn,T as bn,U as En,V as Rn,W as Cn,X as Kn,Y as _n,Z as vn,_ as xn,a as v,aa as _e,b as Ho,ba as In,c as To,ca as ue,d as qo,da as ve,e as Wo,ea as xe,f as q,fa as de,g as Bo,ga as B,h as Go,ha as G,j as zo,k as ie,l as se,la as Qo,m as We,n as W,na as Xo,o as ce,oa as g,p as Be,pa as Pe,q as Ge,r as Re,s as ze,t as Qe,u as Xe,ua as Yo,v as Ye,va as Jo,w as Ce,wa as j,x as Je,y as Ze,z as en}from"./chunk-ESABMC5L.js";import{A as T,B as N,C as Ln,a as $o,b as jo,c as S,d as y,e as Do,f as Fo,g as ge,h as ye,i as be,j as te,k as H,l as A,m as d,r as re,t as b,w as $,x,y as ae,z as h}from"./chunk-CJMVIOZX.js";import{a as Mo}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as co,b as uo,c as oe,d as lo,e as O,f as fo,g as po,h as mo,i as ho,j as ko,k as So}from"./chunk-QILEJIFU.js";import{a as ct}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new M().parseKanonaks(n),r=await new z().reason(n);return{kind:"merged",catalog:e,reasoning:r}}function jn(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Mn(n,e){let r=e??new Se(new D);return{kind:"standalone",catalog:await new M().parseKanonaks(new Ln(n,r))}}function V(n){return typeof n=="number"?n:void 0}function Kr(n){if(!n)return;let e=d(n);if(e===d(fn))return"IRI";if(e===d(pn))return"BlankNode";if(e===d(mn))return"Literal"}function Fn(n){if(!n)return;let e=d(n);if(e===d(hn))return"Violation";if(e===d(kn))return"Warning";if(e===d(Sn))return"Info"}function Ve(n,e){let r=h(n,e);if(r)return[r];let o=[];for(let t of N(n,e))t instanceof y&&o.push(t.subject);return o}function Hn(n,e,r,o){let t=h(e,Re);if(!t)return;let a={path:t},s=V(x(e,ze)),c=V(x(e,Qe));s!==void 0&&(a.minCount=s),c!==void 0&&(a.maxCount=c);let i=V(x(e,en)),f=V(x(e,nn));i!==void 0&&(a.minLength=i),f!==void 0&&(a.maxLength=f);let l=V(x(e,on)),u=V(x(e,tn));l!==void 0&&(a.minInclusive=l),u!==void 0&&(a.maxInclusive=u);let p=ae(e,Je);if(p!==void 0){let k=ae(e,Ze);a.pattern=k!==void 0?{regex:p,flags:k}:{regex:p}}if($(e,Ce)){let k=[],L=[];for(let E of N(e,Ce))E instanceof F?k.push(E.value):E instanceof y&&L.push(E.subject);k.length>0&&(a.inValues=k),L.length>0&&(a.inRefs=L)}let m=h(e,Xe);m&&(a.datatype=m);let _=h(e,Ye);_&&(a.classRef=_);let U=Kr(h(e,ln));U&&(a.nodeKind=U);let J=h(e,In);if(J&&(a.hasValue=J),$(e,ue)||$(e,ve)||$(e,xe)){let k={},L=V(x(e,ve)),E=V(x(e,xe));L!==void 0&&(k.minCount=L),E!==void 0&&(k.maxCount=E);let P=_r(n,e,o);"problem"in P?k.problem=P.problem:k.shape=P.shape,a.qualified=k}let Z=ae(e,rn);Z!==void 0&&(a.message=Z);let ee=Fn(h(e,Ke))??r;return ee&&(a.severity=ee),a}function _r(n,e,r){let o=T(e,ue);if(o)return Dn(n,o,void 0,r);let t=h(e,ue);if(!t)return{problem:"sh:qualifiedValueShape is missing"};let a=d(t);if(r.has(a))return{problem:`sh:qualifiedValueShape '${t.name}' leads back to itself (a cycle through named shapes)`};let s=b(n,t);return s?Dn(n,s,a,r):{problem:`sh:qualifiedValueShape '${t.name}' does not resolve`}}function Dn(n,e,r,o){let t=r?new Set([...o,r]):o,a=re(e,W);if((re(e,ce)||$(e,Re))&&!a){let i=Hn(n,e,void 0,t);return i?{shape:{kind:"property",constraint:i}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof S&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:Tn(n,e,t)}}}function Tn(n,e,r){let o=Fn(h(e,Ke)),t={name:e instanceof S?e.name:"(inline shape)",uri:e instanceof S?g(e):void 0,targetClass:h(e,Be),targetNodes:Ve(e,an),targetSubjectsOf:Ve(e,sn),targetObjectsOf:Ve(e,cn),closed:x(e,un)===!0,ignoredProperties:[],severity:o,properties:[]};for(let a of N(e,dn))a instanceof y&&t.ignoredProperties.push(a.subject);for(let a of N(e,Ge)){let s;if(a instanceof v?s=a:a instanceof y&&(s=b(n,a.subject)),!s)continue;let c=Hn(n,s,o,r);c&&t.properties.push(c)}return t}function le(n){let e=[];for(let r of n){if(!(r instanceof S)||!re(r,W))continue;let o=g(r);e.push(Tn(n,r,new Set(o?[d(o)]:[])))}return e}var C="kanonak.org/transformations",X="values";var fe="allowed",we="expected",R=n=>({type:`${C}/VarRef`,varName:n}),Oe=n=>({type:`${C}/IntegerLiteral`,integerLiteral:n}),vr=n=>({type:`${C}/DecimalLiteral`,decimalLiteral:n}),qn=n=>Number.isInteger(n)?Oe(n):vr(n),Wn=n=>({type:`${C}/Count`,source:n}),Bn=(n,e)=>({type:`${C}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Gn=(n,e)=>({type:`${C}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ue(n,e){if(!e||e.length===0)return n;let r=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!r.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function pe(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Bn(Wn(R(X)),Oe(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Gn(Wn(R(X)),Oe(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${C}/Contains`,haystack:R(X),needle:R(we)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${C}/Contains`,haystack:R(fe),needle:R("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${C}/Matches`,matchSource:R("v"),pattern:Ue(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${C}/Matches`,matchSource:R("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${C}/Matches`,matchSource:R("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Bn(R("v"),qn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Gn(R("v"),qn(n.maxInclusive))}),e}import{evaluate as Pr,ExpressionError as Ir}from"@kanonak-protocol/expression";function Xn(n,e){let r=Lr(e)?e:le(e),o=[],t=n.catalog.filter(c=>c instanceof S).map(me),a=new Map;for(let c of t)Jn(c,a);let s={scope:n,membership:new Ae(n),embeddedFocus:a};for(let c of r)for(let i of Nr(s,c,t))Zn(s,c,i,o);return{conforms:!o.some(c=>c.severity==="Violation"),results:o}}function Lr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Y(n){let e=n.predicate;return e instanceof y?e:void 0}function me(n){let e=g(n);return{node:n,key:e?d(e):`${n.namespace}/${n.name}`,uri:e,label:n.name}}function Yn(n,e,r){let o=n.includes("#")?`${n}.${e.name}`:`${n}#${e.name}`;return r===void 0?o:`${o}[${r}]`}function Jn(n,e){for(let r of n.node?.statement??[]){let o=Y(r);if(!o)continue;let t=(a,s)=>{if(e.has(a))return;let c=Yn(n.key,o.subject,s),i={node:a,key:c,label:c.slice(c.indexOf("#"))};e.set(a,i),Jn(i,e)};r instanceof H?t(r.object):r instanceof A&&(r.object??[]).forEach((a,s)=>{a instanceof v&&t(a,s)})}}var Ae=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,r){let o=d(r);return e.some(t=>d(t)===o||this.ancestorsOf(t).has(o))}ancestorsOf(e){let r=e.version&&typeof e.version.major=="number"?`${d(e)}@${O(e.version)}`:d(e),o=this.ancestors.get(r);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Pe(this.scope.catalog,e).map(t=>d(t))),this.ancestors.set(r,o)),o}};function Nr(n,e,r){let{scope:o}=n,t=new Map,a=c=>{t.set(c.key,c)},s=()=>[...r,...n.embeddedFocus.values()];if(e.targetClass){let c=e.targetClass;if(o.reasoning){let i=new Set(o.reasoning.getInstancesOfClass(c));for(let f of r)f.uri&&i.has(d(f.uri))&&a(f)}else for(let i of r)n.membership.isInstance(j(i.node),c)&&a(i);for(let i of n.embeddedFocus.values())n.membership.isInstance(j(i.node),c)&&a(i)}for(let c of e.targetNodes){let i=b(o.catalog,c);i instanceof S&&a(me(i))}for(let c of e.targetSubjectsOf){let i=d(c);for(let f of s())f.node.statement.some(l=>{let u=Y(l);return u&&d(u.subject)===i})&&a(f)}for(let c of e.targetObjectsOf){let i=d(c);for(let f of s())for(let l of f.node.statement){let u=Y(l);if(!(!u||d(u.subject)!==i)){for(let p of Vr(l)){let m=b(o.catalog,p);m instanceof S&&a(me(m))}for(let p of Or(l)){let m=n.embeddedFocus.get(p);m&&a(m)}}}}return[...t.values()]}function Vr(n){return n instanceof te?[n.object.subject]:n instanceof A?(n.object??[]).filter(e=>e instanceof y).map(e=>e.subject):[]}function Or(n){return n instanceof H?[n.object]:n instanceof A?(n.object??[]).filter(e=>e instanceof v):[]}function wr(n,e,r){let o=[];for(let t of e.node?.statement??[]){let a=Y(t);!a||d(a.subject)!==r||(t instanceof ge||t instanceof Ee?o.push({kernel:t.object,kind:"string",literal:t.object}):t instanceof ye?o.push({kernel:t.object,kind:"number",literal:t.object}):t instanceof be?o.push({kernel:t.object?1:0,kind:"boolean",literal:t.object}):t instanceof te?o.push({kernel:{ref:d(t.object.subject)},kind:"reference",ref:t.object.subject}):t instanceof H?o.push(zn(n,t.object,e,a.subject)):t instanceof A&&(t.object??[]).forEach((s,c)=>{if(s instanceof y)o.push({kernel:{ref:d(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof v)o.push(zn(n,s,e,a.subject,c));else if(s instanceof F){let i=s.value;typeof i=="boolean"?o.push({kernel:i?1:0,kind:"boolean",literal:i}):o.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}))}return o}function zn(n,e,r,o,t){let a=n.embeddedFocus.get(e);if(!a){let s=Yn(r.key,o,t);a={node:e,key:s,label:s.includes("#")?s.slice(s.indexOf("#")):s}}return{kernel:{ref:a.key},kind:"embedded",embedded:a}}function Zn(n,e,r,o){for(let t of e.properties)no(n,e,r,t,o);e.closed&&Wr(e,r,o)}function $e(n,e,r,o,t={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:r,severity:a??eo(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...t}}function eo(n){return n.severity??"Violation"}var Ur={minCount:gn,maxCount:yn,hasValue:de,in:Rn,pattern:Cn,minLength:Kn,maxLength:_n,minInclusive:vn,maxInclusive:xn};function no(n,e,r,o,t){let a=d(o.path),s=wr(n,r,a),c=o.severity??eo(e),i=o.path.name,f=[...(o.inValues??[]).map(u=>typeof u=="boolean"?u?1:0:u),...(o.inRefs??[]).map(u=>({ref:d(u)}))],l=(u,p,m)=>{let _=$e(e,r,u,o.message??p,{resultPath:o.path,value:m?.literal,valueRef:m?.ref},c);return t.push(_),_};for(let u of pe(o)){let p=Ur[u.component];if(u.per==="node"){let m={[X]:s.map(_=>_.kernel),[fe]:f};o.hasValue&&(m[we]={ref:d(o.hasValue)}),Qn(u,m)||l(p,Ar(u,i,o,s.length));continue}for(let m of s){if((u.component==="pattern"||u.component==="minLength"||u.component==="maxLength")&&m.kind!=="string"){l(p,`'${i}' value is not a string; ${u.component} applies to string values.`,m);continue}Qn(u,{v:m.kernel,[fe]:f})||l(p,Fr(u,i,o,m),m)}}if(o.nodeKind)for(let u of s)Hr(o.nodeKind,u)||l(Pn,`'${i}' value is ${u.kind}; nodeKind requires ${o.nodeKind}.`,u);if(o.datatype)for(let u of s){let p=Tr(o.datatype,u);p&&l(bn,`'${i}' ${p}`,u)}if(o.classRef)for(let u of s){let p=qr(n,o.classRef,u);p&&l(En,`'${i}' ${p}`,u)}o.qualified&&$r(n,o,s,i,l)}function Ar(n,e,r,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${r.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${r.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${r.hasValue?d(r.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function $r(n,e,r,o,t){let a=e.qualified,s=a.maxCount!==void 0?G:B,c=(f,l)=>{oo.add(t(s,f,l))};if(!a.shape){c(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let i=0;for(let f of r){let l=f.ref?d(f.ref):f.embedded?f.embedded.label:JSON.stringify(f.literal),u=jr(n,f);if(!u){c(`'${o}' value ${l} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,f);continue}let p=Dr(n,a.shape,u);if(p.kind==="undecided"){c(`'${o}' value ${l}: whether it conforms to the qualified shape cannot be decided \u2014 ${p.reason}`,f);continue}p.kind==="conforms"&&i++}a.minCount!==void 0&&i<a.minCount&&t(B,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&i>a.maxCount&&t(G,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function jr(n,e){switch(e.kind){case"reference":{let r=e.ref?b(n.scope.catalog,e.ref):void 0;return r instanceof S?me(r):void 0}case"embedded":return e.embedded;default:{let r=JSON.stringify(e.literal);return{key:r,label:r}}}}var Mr={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},oo=new WeakSet;function Dr(n,e,r){let o=[];e.kind==="property"?no(n,Mr,r,e.constraint,o):Zn(n,e.shape,r,o);let t=o.find(a=>oo.has(a));return t?{kind:"undecided",reason:t.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Fr(n,e,r,o){let t=o.ref?d(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${t} is not in the permitted set.`;case"pattern":return`'${e}' value ${t} does not match pattern ${r.pattern?.regex}.`;case"minLength":return`'${e}' value ${t} is shorter than minLength ${r.minLength}.`;case"maxLength":return`'${e}' value ${t} is longer than maxLength ${r.maxLength}.`;case"minInclusive":return`'${e}' value ${t} is below minInclusive ${r.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${t} is above maxInclusive ${r.maxInclusive} (or not numeric).`;default:return`'${e}' value ${t} violates ${n.component}.`}}function Qn(n,e){let r=o=>{let t=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof t=="string"&&t in e)return e[t];throw new Ir(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Pr(n.expr,void 0,r)===1}function Hr(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Tr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let r=Ie(n);if(r!==void 0)switch(r){case w.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case w.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case w.Decimal:case w.Double:case w.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function qr(n,e,r){if(r.kind==="embedded"&&r.embedded?.node){let t=j(r.embedded.node);return t.length===0?`value ${r.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(t,e)?void 0:`value ${r.embedded.label} is not an instance of ${e.name}.`}if(r.kind!=="reference"||!r.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;if(n.scope.reasoning)return n.scope.reasoning.isInstanceOf(r.ref,e)?void 0:`value ${d(r.ref)} is not an instance of ${e.name}.`;let o=b(n.scope.catalog,r.ref);return o instanceof S?n.membership.isInstance(j(o),e)?void 0:`value ${d(r.ref)} is not an instance of ${e.name}.`:`value ${d(r.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Wr(n,e,r){if(!e.node)return;let o=new Set([...n.properties.map(a=>d(a.path)),...n.ignoredProperties.map(a=>d(a))]),t=new Set;for(let a of e.node.statement){let s=Y(a);if(!s)continue;let c=d(s.subject);o.has(c)||t.has(c)||(t.add(c),r.push($e(n,e,_e,`'${e.label}' carries undeclared property '${s.subject.name}' (closed shape).`,{resultPath:s.subject})))}for(let a of e.node.unresolvedPredicates)t.has(a.key)||(t.add(a.key),r.push($e(n,e,_e,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var Br="1.1.0",Gr=new Set([de,B,G].map(n=>n.name));async function to(n){let e=new Q(n.repository),r=e.imports(),o=n.result.results.some(i=>Gr.has(i.constraintComponent.name))?"1.2.0":Br,t=r.ensure(ie,se,o,"sh"),a=(i,f)=>i&&i.version&&typeof i.version.major=="number"?`${r.ensure(i.publisher,i.package_,O(i.version),i.package_)}.${i.name}`:f,s={},c=[];return n.result.results.forEach((i,f)=>{let l=`result-${f+1}`;c.push(l);let u={type:`${t}.ValidationResult`,[`${t}.focusNode`]:a(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(u[`${t}.resultPath`]=a(i.resultPath,d(i.resultPath))),i.sourceShapeUri&&(u[`${t}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?u[`${t}.value`]=a(i.valueRef,d(i.valueRef)):i.value!==void 0&&(u[`${t}.value`]=i.value),s[l]=u}),s.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...c.length>0?{[`${t}.result`]:c}:{}},e.buildContentAddressed({publisher:n.publisher,book:r,body:s,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Vi}from"@kanonak-protocol/types/document/models/enums";var K="kanonak.org",I="view",ro="core-kanonak",zr={publisher:K,package_:I,name:"rootView"},Qr={publisher:K,package_:I,name:"bind"},Xr={publisher:K,package_:I,name:"produces"},Yr={publisher:K,package_:I,name:"projections"},Jr={publisher:K,package_:I,name:"where"},Zr={publisher:K,package_:I,name:"value"},ea={publisher:K,package_:I,name:"as"},he=class{constructor(e,r=new D){this.repository=e;this.parser=r;this.objectParser=new M(this.parser),this.builder=new Q(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,r={}){let o=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(o,e),a=h(t,Qr);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let s=h(t,Xr);if(!s)throw new Error(`View ${t.namespace}/${t.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let c=na(t),i=ao(o,K,ro),f=ao(o,K,I),l=this.builder.imports(),u=l.ensure(K,ro,i,"ck"),p=l.ensure(K,I,f,"v"),m=l.ref(s),_=new On(this.repository,this.parser,this.objectParser),U=new Vn(_,o),J=this.readProjections(o,t),Z=ra(t,Jr),ee=this.findInstances(o,a,await this.reason(r)),k={},L=new Set;for(let ne of ee){if(!await this.passesWhere(U,o,Z,ne))continue;let ke={type:m};for(let Me of J){let so=await this.evaluateValue(U,o,Me.value,ne),De=this.builder.serializeValue(io(so),l);De!==void 0&&(ke[l.ref(Me.as)]=De)}let je=g(ne);je&&(ke[`${p}.derivedFrom`]=l.ref(je)),k[this.rowName(ne,L)]=ke}let E={};r.resolvedAt&&(E[`${u}.resolvedAt`]=r.resolvedAt),r.invocationId&&(E[`${u}.id`]=r.invocationId);let P=await this.builder.buildContentAddressed({publisher:c,book:l,body:k,contentHashProperty:`${u}.contentHash`,header:E});return{yaml:P.yaml,contentHash:P.contentHash,packageName:P.packageName,publisher:P.publisher,rowCount:P.resourceCount}}resolveView(e,r){let o=b(e,r);if(!o)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=h(o,zr);if(t){let a=b(e,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return o}readProjections(e,r){let o=[];for(let t of N(r,Yr)){let a=t instanceof v?t:t instanceof y?b(e,t.subject):void 0;if(!a)continue;let s=T(a,Zr),c=h(a,ea);s&&c&&o.push({value:s,as:c})}return o}async reason(e){return new z({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,r,o){let t=ta(e),a=[],s=new Set;for(let c of o.getInstancesOfClass(r)){if(s.has(c))continue;s.add(c);let i=t.get(c);i&&a.push(i)}return a.sort((c,i)=>{let f=q(g(c)),l=q(g(i));return f<l?-1:f>l?1:0}),a}async passesWhere(e,r,o,t){for(let a of o){let s=await this.evaluateValue(e,r,a,t);if(!aa(s))return!1}return!0}async evaluateValue(e,r,o,t){let a=Nn(o,"view-projection",{catalog:r,depth:0}),s=new Map([["input",t]]);return e.evaluate(a,s)}rowName(e,r){let o=Ne(e.name)||"row",t=o,a=2;for(;r.has(t);)t=`${o}-${a++}`;return r.add(t),t}};function io(n){return Le(n)?n.value:Array.isArray(n)?n.map(io):n}function na(n){let e=g(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function ao(n,e,r){let o=oa(n,e,r);if(!o)throw new Error(`Package ${e}/${r} is not in the catalog; it must be importable to materialize a view.`);return o}function oa(n,e,r){let o;for(let t of n){if(!(t instanceof S))continue;let a=g(t);!a||a.publisher!==e||a.package_!==r||!a.version||(!o||oe(a.version,o)>0)&&(o=a.version)}return o?O(o):void 0}function ta(n){let e=new Map,r=new Map;for(let o of n){if(!(o instanceof S))continue;let t=g(o);if(!t||!t.version)continue;let a=q(t),s=r.get(a);(!s||oe(t.version,s)>0)&&(r.set(a,t.version),e.set(a,o))}return e}function ra(n,e){let r=T(n,e);return r?[r]:N(n,e).filter(o=>o instanceof v)}function aa(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Le(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{At as AmbiguousReferenceRule,be as BooleanStatement,ur as CANONICAL_FORM_VERSION,w as Carrier,Ht as ClassDefinitionRule,It as ClassHierarchyCycleRule,bo as CompositeKanonakDocumentRepository,pr as DEFAULT_CONSENT_BINDING_PARAM,jo as DefinedKanonak,ar as DiamondNameClashRule,qt as DisplayLensScopeRule,yo as DocumentLocation,ot as EdgeType,v as EmbeddedKanonak,vt as EmbeddedKanonakTypeRule,H as EmbeddedStatement,Rr as EntitlementDeniedError,Cr as EntitlementProducer,go as FileSystemKanonakDocumentRepository,ct as GitIgnoreFilter,tt as GraphBuilder,Vo as HttpKanonakDocumentRepository,Fe as INTEGRITY_PREFIX,lr as ImportBook,xt as ImportExistenceRule,Se as InMemoryKanonakDocumentRepository,Co as KANONAK_USER_AGENT,$o as Kanonak,dt as KanonakDocumentPositions,M as KanonakObjectParser,ir as KanonakObjectValidator,D as KanonakParser,Mo as KanonakUri,pt as KanonakUriBuilder,mt as KanonakUrlResolver,Qo as KanonakVocabulary,zt as LINE_STYLES,bt as LinkTargetRule,A as ListStatement,F as LiteralKanonak,Oo as LocalFirstRepository,wo as LockAwareRepository,nr as LookBandPathRule,Jt as LookRenderer,Wt as LookSemanticSvgPathRule,Tt as MarkdownLinkRule,Ee as MarkdownStatement,wt as NamespaceImportCycleRule,Et as NamespacePrefixRule,nt as NodeType,ye as NumberStatement,mr as OAuthDiscovery,it as OWL_RL_CLASSIFICATION_RULES,jt as ObjectPropertyValueValidationRule,St as OntologyValidationError,ht as OntologyValidationResult,rr as OwlOneOfRule,Q as PackageBuilder,_t as PackageHeaderRule,yr as ProducerRepository,Mt as PropertyDomainRule,Lt as PropertyHierarchyCycleRule,Dt as PropertyKindRangeConsistencyRule,ut as PropertyMetadata,$t as PropertyRangeReferenceRule,Nt as PropertyRangeRequiredRule,Ct as PropertyTypeSpecificityRule,Io as PublisherConfigResolver,Lo as PublisherIndex,at as RDFS_RULES,z as Reasoner,st as ReasoningResult,y as ReferenceKanonak,te as ReferenceStatement,Ro as RepositoryFactory,Ft as ReservedNameShadowRule,Rt as ResourceNamingRule,Ho as ResourceResolver,Xo as ResourceTypeClassifier,se as SHACL_PACKAGE,ie as SHACL_PUBLISHER,W as SH_NODE_SHAPE,ce as SH_PROPERTY_SHAPE,We as SH_SHAPE,Fo as ScalarStatement,er as SequenceNarrativeRule,tr as ShaclShapeRule,Do as Statement,ge as StringStatement,Vt as SubClassOfReferenceRule,Ot as SubPropertyOfReferenceRule,S as SubjectKanonak,Kt as SubjectKanonakTypeRequiredRule,Sr as TokenCredentialProvider,rt as TripleStore,Bt as TxExpressionCompilesRule,or as TxExpressionPathRule,To as TypeResolver,Ut as UnresolvedPredicateRule,Pt as UnresolvedReferenceRule,yt as ValidationCache,gt as ValidationContext,kt as ValidationSeverity,Vi as VersionOperator,he as ViewMaterializer,br as allowAllPolicy,vo as assertHttpsUrl,No as assertPackageIdentity,Ao as buildLocalFirstRepository,Yt as buildOntologyModel,to as buildReportPackageAsync,le as buildShapesModel,sr as canonicalForm,cr as canonicalHash,Ie as carrierOf,Uo as collectKanonakFiles,oe as compareVersions,An as computeIntegrity,qe as computeIntegrityAsync,dr as contentAddressedName,j as contextTypesOf,kr as createCredentialedFetch,fo as createVersion,Xn as evaluateConformance,et as extractMarkdownLinks,gr as findDerivation,Zo as findMalformedReferences,ft as findMarkdownLinkAt,Ue as foldFlagsIntoPattern,Wo as formatKanonakAddress,O as formatVersion,Eo as getGlobalCachePath,_o as getKanonakUserAgent,mo as isCompatibleVersion,ho as isMajorCompatible,xo as kanonakFetch,wn as loadLockFile,pe as lowerConstraint,Bo as makeUriKey,Er as noopMeter,fr as normalizeHost,hr as parseAuthChallenge,qo as parseKanonakAddress,He as parseLockFile,po as parseVersionString,lt as parseWithPositions,So as pickHighestDocument,Yo as propertiesInScope,Qt as readSequenceConnectors,Gt as resolveDisplayValue,Jo as resolvePropertyStep,Ne as sanitizeName,ko as satisfiesVersionOperator,Un as saveLockFile,jn as scopeFromCatalog,Mn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,Te as serializeLockFile,Po as setKanonakFetchRetries,Ko as setKanonakUserAgent,g as subjectUri,Pe as superClassChain,Zt as supportedBandKeys,Go as tripleKey,q as uriKey,zo as uriTriple,co as versionOperatorFromChar,uo as versionOperatorToChar,lo as versionsEqual,Xt as walkSequence};
|
|
1
|
+
import{a as it,b as st,c as ct,d as ut,e as B}from"./chunk-26SO3A4B.js";import{a as In,b as Vn,c as Ln}from"./chunk-V3DH67P3.js";import{a as tt,b as rt,c as at,d as mr,e as hr,f as kr,g as Sr,h as yr,i as gr}from"./chunk-O35Y6QUW.js";import{a as br}from"./chunk-ZYDJUGIA.js";import{a as ur,b as dr,c as lr,d as G,e as pr,f as fr,g as xe,h as Er,i as Rr,j as Cr,k as Kr,l as xr}from"./chunk-2Y6R3K5A.js";import{a as lo,b as po,c as fo,d as mo,e as ho,f as _o,g as Po,h as vo,i as Io}from"./chunk-IS3AQKB4.js";import{a as ko,b as So,c as yo,d as go,e as bo,f as Eo,h as Ro,i as Ae,j as $e,k as Me,l as je,m as Co,n as xo}from"./chunk-BZ3YTI3C.js";import{a as lt,b as pt,c as ft,d as mt}from"./chunk-VEGFYZXG.js";import{a as ht}from"./chunk-XK24CN3C.js";import{a as Ko}from"./chunk-SC5M74NM.js";import{A as Tt,B as qt,C as Wt,D as Bt,E as Gt,F as zt,G as or,H as tr,I as rr,J as ar,K as ir,L as sr,M as cr,a as St,b as yt,c as gt,d as bt,e as Et,f as Rt,g as Ct,h as Kt,i as xt,j as _t,k as Pt,l as vt,m as It,n as Vt,o as Lt,p as Nt,q as Ot,r as wt,s as Ut,t as At,u as $t,v as Mt,w as jt,x as Dt,y as Ft,z as Ht}from"./chunk-AVVLDZAZ.js";import"./chunk-KIBR3HAT.js";import{c as _n,d as Qt,e as Xt,g as Yt,h as Jt,k as Zt,m as Ke,o as Pn,p as vn,r as er,s as nr}from"./chunk-D7QLWVPK.js";import"./chunk-QHABFCRC.js";import{a as fe}from"./chunk-6VIUXP4N.js";import{a as Ho,g as L,h as Ce,i as nt,j as ot,k as A}from"./chunk-JHQPXEMA.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as kt}from"./chunk-PEJALHXK.js";import{$ as ge,A as Ye,B as Je,C as Ze,D as en,E as nn,F as on,G as tn,H as rn,I as an,J as sn,K as cn,L as un,M as ye,N as dn,O as ln,P as pn,Q as fn,R as mn,S as hn,T as kn,U as Sn,V as yn,W as gn,X as bn,Y as En,Z as Rn,_ as Cn,a as To,aa as Kn,b as qo,ba as ae,c as Wo,ca as be,d as Bo,da as Ee,e as F,ea as ie,f as zo,fa as T,g as Qo,ga as q,i as Xo,j as oe,k as te,ka as Yo,l as De,m as H,ma as Jo,n as re,na as k,o as Fe,oa as Re,p as He,q as ke,r as Te,s as qe,t as We,ta as Zo,u as Be,ua as et,v as Se,va as U,w as Ge,x as ze,y as Qe,z as Xe}from"./chunk-MQBWSCNY.js";import{A as C,B as ne,C as h,D,E as he,F as W,G as xn,a as Vo,b as Lo,c as S,d as N,e as v,f as Oo,g as wo,h as Uo,i as Ao,j as $o,k as Mo,l as jo,m as Do,n as Fo,o as l,r as Go,s as O,t as me,u as ee,w as x,z as w}from"./chunk-54D47DLS.js";import{a as No}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as no,b as oo,c as Z,d as to,e as V,f as ro,g as ao,h as io,i as so,j as co,k as uo}from"./chunk-QILEJIFU.js";import{a as dt}from"./chunk-ODIECDN7.js";async function Nn(n){let e=await new A().parseKanonaks(n),t=await new B().reason(n);return{kind:"merged",catalog:e,reasoning:t}}function On(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function wn(n,e){let t=e??new fe(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new xn(n,t))}}function I(n){return typeof n=="number"?n:void 0}function _r(n){if(!n)return;let e=l(n);if(e===l(sn))return"IRI";if(e===l(cn))return"BlankNode";if(e===l(un))return"Literal"}function An(n){if(!n)return;let e=l(n);if(e===l(dn))return"Violation";if(e===l(ln))return"Warning";if(e===l(pn))return"Info"}function $n(n,e,t,o){let r=h(e,ke);if(!r)return;let a={path:r},u=I(C(e,Te)),s=I(C(e,qe));u!==void 0&&(a.minCount=u),s!==void 0&&(a.maxCount=s);let i=I(C(e,Qe)),d=I(C(e,Xe));i!==void 0&&(a.minLength=i),d!==void 0&&(a.maxLength=d);let c=I(C(e,Ye)),p=I(C(e,Je));c!==void 0&&(a.minInclusive=c),p!==void 0&&(a.maxInclusive=p);let f=ne(e,Ge);if(f!==void 0){let m=ne(e,ze);a.pattern=m!==void 0?{regex:f,flags:m}:{regex:f}}if(w(e,Se)){let m=[],P=[];for(let{item:y}of me(e,Se))"literal"in y?m.push(y.value):y instanceof v&&P.push(y.subject);m.length>0&&(a.inValues=m),P.length>0&&(a.inRefs=P)}let R=h(e,We);R&&(a.datatype=R);let $=h(e,Be);$&&(a.classRef=$);let M=_r(h(e,an));M&&(a.nodeKind=M);let Q=h(e,Kn);if(Q&&(a.hasValue=Q),w(e,ae)||w(e,be)||w(e,Ee)){let m={},P=I(C(e,be)),y=I(C(e,Ee));P!==void 0&&(m.minCount=P),y!==void 0&&(m.maxCount=y);let K=Pr(n,e,o);"problem"in K?m.problem=K.problem:m.shape=K.shape,a.qualified=m}let X=ne(e,Ze);X!==void 0&&(a.message=X);let Y=An(h(e,ye))??t;return Y&&(a.severity=Y),a}function Pr(n,e,t){let o=D(e,ae);if(o)return Un(n,o,void 0,t);let r=h(e,ae);if(!r)return{problem:"sh:qualifiedValueShape is missing"};let a=l(r);if(t.has(a))return{problem:`sh:qualifiedValueShape '${r.name}' leads back to itself (a cycle through named shapes)`};let u=x(n,r);return u?Un(n,u,a,t):{problem:`sh:qualifiedValueShape '${r.name}' does not resolve`}}function Un(n,e,t,o){let r=t?new Set([...o,t]):o,a=ee(e,H);if((ee(e,re)||w(e,ke))&&!a){let i=$n(n,e,void 0,r);return i?{shape:{kind:"property",constraint:i}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof S&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:Mn(n,e,r)}}}function Mn(n,e,t){let o=An(h(e,ye)),r={name:e instanceof S?e.name:"(inline shape)",uri:e instanceof S?k(e):void 0,targetClass:h(e,Fe),targetNodes:O(e,en),targetSubjectsOf:O(e,nn),targetObjectsOf:O(e,on),closed:C(e,tn)===!0,ignoredProperties:[],severity:o,properties:[]};r.ignoredProperties.push(...O(e,rn));for(let{item:a}of me(e,He)){let u;if(a instanceof N?u=a:a instanceof v&&(u=x(n,a.subject)),!u)continue;let s=$n(n,u,o,t);s&&r.properties.push(s)}return r}function se(n){let e=[];for(let t of n){if(!(t instanceof S)||!ee(t,H))continue;let o=k(t);e.push(Mn(n,t,new Set(o?[l(o)]:[])))}return e}var b="kanonak.org/transformations",z="values";var ce="allowed",Pe="expected",g=n=>({type:`${b}/VarRef`,varName:n}),_e=n=>({type:`${b}/IntegerLiteral`,integerLiteral:n}),vr=n=>({type:`${b}/DecimalLiteral`,decimalLiteral:n}),jn=n=>Number.isInteger(n)?_e(n):vr(n),Dn=n=>({type:`${b}/Count`,source:n}),Fn=(n,e)=>({type:`${b}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Hn=(n,e)=>({type:`${b}/LessThanOrEqual`,compareLeft:n,compareRight:e});function ve(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!t.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function ue(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Dn(g(z)),_e(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Hn(Dn(g(z)),_e(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${b}/Contains`,haystack:g(z),needle:g(Pe)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${b}/Contains`,haystack:g(ce),needle:g("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:ve(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(g("v"),jn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Hn(g("v"),jn(n.maxInclusive))}),e}import{evaluate as Vr,ExpressionError as Lr}from"@kanonak-protocol/expression";function qn(n,e){let t=Nr(e)?e:se(e),o=[],r=n.catalog.filter(s=>s instanceof S).map(de),a=new Map;for(let s of r)Wn(s,n.catalog,a);let u={scope:n,membership:new Ie(n),embeddedFocus:a};for(let s of t)for(let i of wr(u,s,r))Bn(u,s,i,o);return{conforms:!o.some(s=>s.severity==="Violation"),results:o}}function Nr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Le(n){let e=n.predicate;return e instanceof v?e:void 0}function de(n){let e=k(n);return{node:n,key:e?l(e):`${n.namespace}/${n.name}`,uri:e,label:n.name}}function Ne(n,e){return{node:n,key:e,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Or(n){let e=new Map;for(let t of n.statement){let o=Le(t);o&&!e.has(l(o.subject))&&e.set(l(o.subject),o.subject)}return[...e.values()]}function Wn(n,e,t){if(n.node)for(let o of Or(n.node))for(let r of W(n.node,o,e,n.key)){if(r.kind!=="embedded"||t.has(r.node))continue;let a=Ne(r.node,r.address);t.set(r.node,a),Wn(a,e,t)}}var Ie=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,t){let o=l(t);return e.some(r=>l(r)===o||this.ancestorsOf(r).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${l(e)}@${V(e.version)}`:l(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Re(this.scope.catalog,e).map(r=>l(r))),this.ancestors.set(t,o)),o}};function wr(n,e,t){let{scope:o}=n,r=new Map,a=s=>{r.set(s.key,s)},u=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let s=e.targetClass;if(o.reasoning){let i=new Set(o.reasoning.getInstancesOfClass(s));for(let d of t)d.uri&&i.has(l(d.uri))&&a(d)}else for(let i of t)n.membership.isInstance(U(i.node),s)&&a(i);for(let i of n.embeddedFocus.values())n.membership.isInstance(U(i.node),s)&&a(i)}for(let s of e.targetNodes){let i=x(o.catalog,s);i instanceof S&&a(de(i))}for(let s of e.targetSubjectsOf){let i=l(s);for(let d of u())d.node.statement.some(c=>{let p=Le(c);return p&&l(p.subject)===i})&&a(d)}for(let s of e.targetObjectsOf)for(let i of u())for(let d of W(i.node,s,o.catalog,i.key))d.kind==="subject"?a(de(d.node)):d.kind==="embedded"&&a(n.embeddedFocus.get(d.node)??Ne(d.node,d.address));return[...r.values()]}function Ur(n,e,t){return e.node?W(e.node,t,n.scope.catalog,e.key).map(o=>Ar(n,o)):[]}function Ar(n,e){switch(e.kind){case"subject":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let t=n.embeddedFocus.get(e.node)??Ne(e.node,e.address);return{kernel:{ref:t.key},kind:"embedded",embedded:t}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function Bn(n,e,t,o){for(let r of e.properties)zn(n,e,t,r,o);e.closed&&Gr(e,t,o)}function Ve(n,e,t,o,r={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:a??Gn(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...r}}function Gn(n){return n.severity??"Violation"}var $r={minCount:fn,maxCount:mn,hasValue:ie,in:Sn,pattern:yn,minLength:gn,maxLength:bn,minInclusive:En,maxInclusive:Rn};function zn(n,e,t,o,r){let a=Ur(n,t,o.path),u=o.severity??Gn(e),s=o.path.name,i=[...(o.inValues??[]).map(c=>typeof c=="boolean"?c?1:0:c),...(o.inRefs??[]).map(c=>({ref:l(c)}))],d=(c,p,f)=>{let R=Ve(e,t,c,o.message??p,{resultPath:o.path,value:f?.literal,valueRef:f?.ref},u);return r.push(R),R};for(let c of ue(o)){let p=$r[c.component];if(c.per==="node"){let f={[z]:a.map(R=>R.kernel),[ce]:i};o.hasValue&&(f[Pe]={ref:l(o.hasValue)}),Tn(c,f)||d(p,Mr(c,s,o,a.length));continue}for(let f of a){if((c.component==="pattern"||c.component==="minLength"||c.component==="maxLength")&&f.kind!=="string"){d(p,`'${s}' value is not a string; ${c.component} applies to string values.`,f);continue}Tn(c,{v:f.kernel,[ce]:i})||d(p,Tr(c,s,o,f),f)}}if(o.nodeKind)for(let c of a)qr(o.nodeKind,c)||d(Cn,`'${s}' value is ${c.kind}; nodeKind requires ${o.nodeKind}.`,c);if(o.datatype)for(let c of a){let p=Wr(o.datatype,c);p&&d(hn,`'${s}' ${p}`,c)}if(o.classRef)for(let c of a){let p=Br(n,o.classRef,c);p&&d(kn,`'${s}' ${p}`,c)}o.qualified&&jr(n,o,a,s,d)}function Mr(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?l(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function jr(n,e,t,o,r){let a=e.qualified,u=a.maxCount!==void 0?q:T,s=(d,c)=>{Qn.add(r(u,d,c))};if(!a.shape){s(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let i=0;for(let d of t){let c=d.ref?l(d.ref):d.embedded?d.embedded.label:JSON.stringify(d.literal),p=Dr(n,d);if(!p){s(`'${o}' value ${c} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,d);continue}let f=Hr(n,a.shape,p);if(f.kind==="undecided"){s(`'${o}' value ${c}: whether it conforms to the qualified shape cannot be decided \u2014 ${f.reason}`,d);continue}f.kind==="conforms"&&i++}a.minCount!==void 0&&i<a.minCount&&r(T,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&i>a.maxCount&&r(q,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function Dr(n,e){switch(e.kind){case"reference":return e.subject?de(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Fr={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},Qn=new WeakSet;function Hr(n,e,t){let o=[];e.kind==="property"?zn(n,Fr,t,e.constraint,o):Bn(n,e.shape,t,o);let r=o.find(a=>Qn.has(a));return r?{kind:"undecided",reason:r.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Tr(n,e,t,o){let r=o.ref?l(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function Tn(n,e){let t=o=>{let r=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new Lr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Vr(n.expr,void 0,t)===1}function qr(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Wr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ce(n);if(t!==void 0)switch(t){case L.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case L.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case L.Decimal:case L.Double:case L.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Br(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let r=U(t.embedded.node);return r.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(r,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;if(n.scope.reasoning)return n.scope.reasoning.isInstanceOf(t.ref,e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`;let o=t.subject;return o?n.membership.isInstance(U(o),e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`:`value ${l(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Gr(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(a=>l(a.path)),...n.ignoredProperties.map(a=>l(a))]),r=new Set;for(let a of e.node.statement){let u=Le(a);if(!u)continue;let s=l(u.subject);o.has(s)||r.has(s)||(r.add(s),t.push(Ve(n,e,ge,`'${e.label}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let a of e.node.unresolvedPredicates)r.has(a.key)||(r.add(a.key),t.push(Ve(n,e,ge,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var zr="1.1.0",Qr=new Set([ie,T,q].map(n=>n.name));async function Xn(n){let e=new G(n.repository),t=e.imports(),o=n.result.results.some(i=>Qr.has(i.constraintComponent.name))?"1.2.0":zr,r=t.ensure(oe,te,o,"sh"),a=(i,d)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:d,u={},s=[];return n.result.results.forEach((i,d)=>{let c=`result-${d+1}`;s.push(c);let p={type:`${r}.ValidationResult`,[`${r}.focusNode`]:a(i.focusUri,i.focusNode),[`${r}.resultMessage`]:i.message,[`${r}.resultSeverity`]:`${r}.${i.severity}`,[`${r}.sourceConstraintComponent`]:`${r}.${i.constraintComponent.name}`};i.resultPath&&(p[`${r}.resultPath`]=a(i.resultPath,l(i.resultPath))),i.sourceShapeUri&&(p[`${r}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${r}.value`]=a(i.valueRef,l(i.valueRef)):i.value!==void 0&&(p[`${r}.value`]=i.value),u[c]=p}),u.report={type:`${r}.ValidationReport`,[`${r}.conforms`]:n.result.conforms,...s.length>0?{[`${r}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:u,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ki}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",_="view",Yn="core-kanonak",Xr={publisher:E,package_:_,name:"rootView"},Yr={publisher:E,package_:_,name:"bind"},Jr={publisher:E,package_:_,name:"produces"},Zr={publisher:E,package_:_,name:"projections"},ea={publisher:E,package_:_,name:"where"},na={publisher:E,package_:_,name:"value"},oa={publisher:E,package_:_,name:"as"},le=class{constructor(e,t=new j){this.repository=e;this.parser=t;this.objectParser=new A(this.parser),this.builder=new G(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(o,e),a=h(r,Yr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let u=h(r,Jr);if(!u)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=ta(r),i=Jn(o,E,Yn),d=Jn(o,E,_),c=this.builder.imports(),p=c.ensure(E,Yn,i,"ck"),f=c.ensure(E,_,d,"v"),R=c.ref(u),$=new vn(this.repository,this.parser,this.objectParser),M=new Pn($,o),Q=this.readProjections(o,r),X=ia(r,ea),Y=this.findInstances(o,a,await this.reason(t)),m={},P=new Set;for(let J of Y){if(!await this.passesWhere(M,o,X,J))continue;let pe={type:R};for(let we of Q){let eo=await this.evaluateValue(M,o,we.value,J),Ue=this.builder.serializeValue(Zn(eo),c);Ue!==void 0&&(pe[c.ref(we.as)]=Ue)}let Oe=k(J);Oe&&(pe[`${f}.derivedFrom`]=c.ref(Oe)),m[this.rowName(J,P)]=pe}let y={};t.resolvedAt&&(y[`${p}.resolvedAt`]=t.resolvedAt),t.invocationId&&(y[`${p}.id`]=t.invocationId);let K=await this.builder.buildContentAddressed({publisher:s,book:c,body:m,contentHashProperty:`${p}.contentHash`,header:y});return{yaml:K.yaml,contentHash:K.contentHash,packageName:K.packageName,publisher:K.publisher,rowCount:K.resourceCount}}resolveView(e,t){let o=x(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let r=h(o,Xr);if(r){let a=x(e,r);if(!a)throw new Error(`ViewPackage ${t.name} names rootView ${r.name}, which is not in the catalog.`);return a}return o}readProjections(e,t){let o=[];for(let r of he(t,Zr)){let a=r instanceof N?r:r instanceof v?x(e,r.subject):void 0;if(!a)continue;let u=D(a,na),s=h(a,oa);u&&s&&o.push({value:u,as:s})}return o}async reason(e){return new B({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let r=aa(e),a=[],u=new Set;for(let s of o.getInstancesOfClass(t)){if(u.has(s))continue;u.add(s);let i=r.get(s);i&&a.push(i)}return a.sort((s,i)=>{let d=F(k(s)),c=F(k(i));return d<c?-1:d>c?1:0}),a}async passesWhere(e,t,o,r){for(let a of o){let u=await this.evaluateValue(e,t,a,r);if(!sa(u))return!1}return!0}async evaluateValue(e,t,o,r){let a=_n(o,"view-projection",{catalog:t,depth:0}),u=new Map([["input",r]]);return e.evaluate(a,u)}rowName(e,t){let o=xe(e.name)||"row",r=o,a=2;for(;t.has(r);)r=`${o}-${a++}`;return t.add(r),r}};function Zn(n){return Ke(n)?n.value:Array.isArray(n)?n.map(Zn):n}function ta(n){let e=k(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function Jn(n,e,t){let o=ra(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function ra(n,e,t){let o;for(let r of n){if(!(r instanceof S))continue;let a=k(r);!a||a.publisher!==e||a.package_!==t||!a.version||(!o||Z(a.version,o)>0)&&(o=a.version)}return o?V(o):void 0}function aa(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof S))continue;let r=k(o);if(!r||!r.version)continue;let a=F(r),u=t.get(a);(!u||Z(r.version,u)>0)&&(t.set(a,r.version),e.set(a,o))}return e}function ia(n,e){let t=D(n,e);return t?[t]:he(n,e).filter(o=>o instanceof N)}function sa(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Ke(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Mt as AmbiguousReferenceRule,Mo as BooleanStatement,lr as CANONICAL_FORM_VERSION,L as Carrier,qt as ClassDefinitionRule,Lt as ClassHierarchyCycleRule,fo as CompositeKanonakDocumentRepository,hr as DEFAULT_CONSENT_BINDING_PARAM,Lo as DefinedKanonak,sr as DiamondNameClashRule,Bt as DisplayLensScopeRule,po as DocumentLocation,rt as EdgeType,N as EmbeddedKanonak,vt as EmbeddedKanonakTypeRule,Do as EmbeddedStatement,Kr as EntitlementDeniedError,xr as EntitlementProducer,lo as FileSystemKanonakDocumentRepository,dt as GitIgnoreFilter,at as GraphBuilder,xo as HttpKanonakDocumentRepository,Ae as INTEGRITY_PREFIX,fr as ImportBook,It as ImportExistenceRule,fe as InMemoryKanonakDocumentRepository,ko as KANONAK_USER_AGENT,Vo as Kanonak,pt as KanonakDocumentPositions,A as KanonakObjectParser,cr as KanonakObjectValidator,j as KanonakParser,No as KanonakUri,ht as KanonakUriBuilder,kt as KanonakUrlResolver,Yo as KanonakVocabulary,Xt as LINE_STYLES,Rt as LinkTargetRule,Fo as ListStatement,Oo as LiteralKanonak,_o as LocalFirstRepository,Po as LockAwareRepository,tr as LookBandPathRule,er as LookRenderer,Gt as LookSemanticSvgPathRule,Wt as MarkdownLinkRule,Ho as MarkdownStatement,At as NamespaceImportCycleRule,Ct as NamespacePrefixRule,tt as NodeType,$o as NumberStatement,kr as OAuthDiscovery,ct as OWL_RL_CLASSIFICATION_RULES,Dt as ObjectPropertyValueValidationRule,gt as OntologyValidationError,St as OntologyValidationResult,ir as OwlOneOfRule,G as PackageBuilder,Pt as PackageHeaderRule,Er as ProducerRepository,Ft as PropertyDomainRule,Nt as PropertyHierarchyCycleRule,Ht as PropertyKindRangeConsistencyRule,lt as PropertyMetadata,jt as PropertyRangeReferenceRule,Ot as PropertyRangeRequiredRule,xt as PropertyTypeSpecificityRule,Ro as PublisherConfigResolver,Co as PublisherIndex,st as RDFS_RULES,B as Reasoner,ut as ReasoningResult,v as ReferenceKanonak,jo as ReferenceStatement,ho as RepositoryFactory,Tt as ReservedNameShadowRule,Kt as ResourceNamingRule,To as ResourceResolver,Jo as ResourceTypeClassifier,te as SHACL_PACKAGE,oe as SHACL_PUBLISHER,H as SH_NODE_SHAPE,re as SH_PROPERTY_SHAPE,De as SH_SHAPE,Uo as ScalarStatement,or as SequenceNarrativeRule,ar as ShaclShapeRule,wo as Statement,Ao as StringStatement,wt as SubClassOfReferenceRule,Ut as SubPropertyOfReferenceRule,S as SubjectKanonak,_t as SubjectKanonakTypeRequiredRule,gr as TokenCredentialProvider,it as TripleStore,zt as TxExpressionCompilesRule,rr as TxExpressionPathRule,qo as TypeResolver,$t as UnresolvedPredicateRule,Vt as UnresolvedReferenceRule,Et as ValidationCache,bt as ValidationContext,yt as ValidationSeverity,Ki as VersionOperator,le as ViewMaterializer,Rr as allowAllPolicy,go as assertHttpsUrl,Ko as assertPackageIdentity,Io as buildLocalFirstRepository,Zt as buildOntologyModel,Xn as buildReportPackageAsync,se as buildShapesModel,ur as canonicalForm,dr as canonicalHash,Ce as carrierOf,vo as collectKanonakFiles,Z as compareVersions,Ln as computeIntegrity,je as computeIntegrityAsync,pr as contentAddressedName,U as contextTypesOf,yr as createCredentialedFetch,ro as createVersion,qn as evaluateConformance,ot as extractMarkdownLinks,br as findDerivation,nt as findMalformedReferences,mt as findMarkdownLinkAt,ve as foldFlagsIntoPattern,Bo as formatKanonakAddress,V as formatVersion,mo as getGlobalCachePath,yo as getKanonakUserAgent,io as isCompatibleVersion,so as isMajorCompatible,bo as kanonakFetch,In as loadLockFile,ue as lowerConstraint,zo as makeUriKey,Cr as noopMeter,mr as normalizeHost,Sr as parseAuthChallenge,Wo as parseKanonakAddress,$e as parseLockFile,ao as parseVersionString,ft as parseWithPositions,uo as pickHighestDocument,Zo as propertiesInScope,Yt as readSequenceConnectors,O as referenceUris,Qt as resolveDisplayValue,et as resolvePropertyStep,xe as sanitizeName,co as satisfiesVersionOperator,Vn as saveLockFile,On as scopeFromCatalog,wn as scopeFromDocumentAsync,Nn as scopeFromRepositoryAsync,Me as serializeLockFile,Eo as setKanonakFetchRetries,So as setKanonakUserAgent,k as subjectUri,Re as superClassChain,nr as supportedBandKeys,Qo as tripleKey,Go as typeReferenceUris,F as uriKey,Xo as uriTriple,W as valuesOf,no as versionOperatorFromChar,oo as versionOperatorToChar,to as versionsEqual,Jt as walkSequence};
|
|
@@ -730,6 +730,7 @@ export declare class LookRenderer {
|
|
|
730
730
|
*/
|
|
731
731
|
private renderDetails;
|
|
732
732
|
private detailRows;
|
|
733
|
+
/** All of a property's values on a node, as one Details cell. */
|
|
733
734
|
private detailValue;
|
|
734
735
|
/**
|
|
735
736
|
* A relational value in the Details sheet: the target's chip-tier
|
|
@@ -1067,12 +1068,16 @@ export declare class LookRenderer {
|
|
|
1067
1068
|
*/
|
|
1068
1069
|
private readPropertyValueReferences;
|
|
1069
1070
|
/**
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1071
|
+
* Every value of a property on a node, as the items the band renderers
|
|
1072
|
+
* dispatch on: a reference or an embedded value as itself, a literal as its
|
|
1073
|
+
* value. Read across EVERY statement for the property and every authored
|
|
1074
|
+
* form (the SDK's one statement walk, `rawValuesOf` — typescript#123), so a
|
|
1075
|
+
* value asserted by a second document renders, and a literal list item
|
|
1076
|
+
* renders as its value.
|
|
1072
1077
|
*/
|
|
1073
|
-
private
|
|
1078
|
+
private valueItems;
|
|
1074
1079
|
/**
|
|
1075
|
-
* Render one item (from
|
|
1080
|
+
* Render one item (from valueItems) as inline HTML — anchor
|
|
1076
1081
|
* for references, escaped text for scalars, a nested definition list
|
|
1077
1082
|
* for embedded resources. slotUri is the look slot the item came from
|
|
1078
1083
|
* (used for urlForm). `depth` bounds recursion into nested embeddeds.
|
|
@@ -1085,7 +1090,7 @@ export declare class LookRenderer {
|
|
|
1085
1090
|
* nested definition list, lists as comma-joined items. `depth` bounds
|
|
1086
1091
|
* recursion into nested embeddeds.
|
|
1087
1092
|
*/
|
|
1088
|
-
private
|
|
1093
|
+
private renderValuesInline;
|
|
1089
1094
|
/**
|
|
1090
1095
|
* Render an embedded (anonymous) resource as a nested definition list of
|
|
1091
1096
|
* its `predicate → value` pairs. Embedded vs named is purely a
|
package/dist/parsing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f}from"../chunk-
|
|
1
|
+
import{a as c,b as d,c as e,d as f}from"../chunk-VEGFYZXG.js";import{k as b}from"../chunk-JHQPXEMA.js";import{a}from"../chunk-HF5FJBS2.js";import"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
|
package/dist/producer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-
|
|
1
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-2Y6R3K5A.js";import"../chunk-QHABFCRC.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
|
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-
|
|
1
|
+
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-26SO3A4B.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import{e as a,f as b,g as c,i as d,ja as e,ka as f}from"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
|
package/dist/resolution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{
|
|
1
|
+
import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,c as s,d as t,la as u,ma as v,na as w,oa as x,pa as y,qa as z,ra as A,sa as B,ta as C,ua as D,va as E}from"../chunk-MQBWSCNY.js";import"../chunk-54D47DLS.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-
|
|
1
|
+
import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-D7QLWVPK.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-JHQPXEMA.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{na as m,va as S}from"../chunk-MQBWSCNY.js";import{c as v,o as p,w as E}from"../chunk-54D47DLS.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
|
|
2
2
|
Install it with:
|
|
3
3
|
npm install @huggingface/transformers
|
|
4
4
|
(underlying import error: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
|
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-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,"&").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-D7QLWVPK.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{k as oe}from"../chunk-JHQPXEMA.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-MQBWSCNY.js";import{c as we,x as re}from"../chunk-54D47DLS.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-
|
|
1
|
+
import{a as pe}from"../chunk-ZYDJUGIA.js";import"../chunk-VEGFYZXG.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-D7QLWVPK.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import{a as de,c as $n,d as Tn,e as Bn,f as xn,k as fe}from"../chunk-JHQPXEMA.js";import{a as se}from"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-MQBWSCNY.js";import{b as Y,c as D,d as ce,e as E,f as ue,i as $,j as T,k as B,l as w,m as me,n as x,p as N,q as S,w as A}from"../chunk-54D47DLS.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(`
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Kanonak } from '../kanonaks/Kanonak.js';
|
|
2
|
+
import { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
|
|
3
|
+
import { EmbeddedKanonak } from '../kanonaks/EmbeddedKanonak.js';
|
|
4
|
+
import type { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
|
|
5
|
+
import type { KanonakUri } from '../resolution/KanonakUri.js';
|
|
6
|
+
import { type EntityUri } from './UriHelpers.js';
|
|
7
|
+
/**
|
|
8
|
+
* One value of a property, whatever form it was authored in (typescript#123).
|
|
9
|
+
*
|
|
10
|
+
* - `subject`: a reference, resolved to the subject it names in the catalog;
|
|
11
|
+
* - `embedded`: an inline value — a single embedded object, a list item, or a
|
|
12
|
+
* dict-keyed entry;
|
|
13
|
+
* - `unresolved`: a reference the catalog cannot resolve — returned, never
|
|
14
|
+
* dropped, so "names something absent" stays distinguishable from "names
|
|
15
|
+
* nothing";
|
|
16
|
+
* - `literal`: a literal value. Legitimate where a property's range admits
|
|
17
|
+
* literals (a datatype property, the members of an `rdf:List` such as
|
|
18
|
+
* `sh:in` or `owl:oneOf`); on an object property it is a modelling error
|
|
19
|
+
* the validator reports — returned all the same, so a consumer that wants
|
|
20
|
+
* only resources filters by kind in its own code.
|
|
21
|
+
*
|
|
22
|
+
* Every value carries its ADDRESS: the node's address plus the protocol's
|
|
23
|
+
* fragment path for this value (see {@link valuesOf}).
|
|
24
|
+
*/
|
|
25
|
+
export type PropertyValue = {
|
|
26
|
+
kind: 'subject';
|
|
27
|
+
node: SubjectKanonak;
|
|
28
|
+
uri: KanonakUri;
|
|
29
|
+
address: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'embedded';
|
|
32
|
+
node: EmbeddedKanonak;
|
|
33
|
+
address: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'unresolved';
|
|
36
|
+
uri: KanonakUri;
|
|
37
|
+
address: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'literal';
|
|
40
|
+
value: string | number | boolean;
|
|
41
|
+
/** Canonical-form datatype carrier, when the value was range-typed. */
|
|
42
|
+
carrier?: string | undefined;
|
|
43
|
+
/** The raw lexical token as authored. */
|
|
44
|
+
lexical?: string | undefined;
|
|
45
|
+
address: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Every value of a property on a node, in authored order, each resolved and
|
|
49
|
+
* addressed — THE form-agnostic read of "the values of this property".
|
|
50
|
+
*
|
|
51
|
+
* Reads every statement the property has on the node (the open-world merge
|
|
52
|
+
* can fold several documents' statements onto one subject) and every form
|
|
53
|
+
* each was written in. References resolve through `catalog` with exactly the
|
|
54
|
+
* semantics of `findSubjectByUri` (a versioned reference matches that version;
|
|
55
|
+
* a versionless one the first version in the catalog), via an index built
|
|
56
|
+
* once per catalog.
|
|
57
|
+
*
|
|
58
|
+
* Addressing follows the protocol's `uri-fragments` convention: a fragment
|
|
59
|
+
* after `#` whose segments are property names, `.`-separated, with `[N]` for
|
|
60
|
+
* a position. `nodeAddress` is the node's own address — a subject's canonical
|
|
61
|
+
* key, or an embedded value's address from an earlier call — so nested values
|
|
62
|
+
* compose (`box#parts[1].subparts[0]`). A property's value is addressed:
|
|
63
|
+
*
|
|
64
|
+
* - by its dict key when it was authored as a dict-keyed entry
|
|
65
|
+
* (`product#offers.north`) — the form the convention prefers, since a name
|
|
66
|
+
* does not shift when entries reorder;
|
|
67
|
+
* - by position `[N]` when it came from a list or the property has more than
|
|
68
|
+
* one value (`N` counts across all of the property's values, so it is
|
|
69
|
+
* unique within the catalog — though in a merged view it depends on which
|
|
70
|
+
* documents are loaded, which is why names are the stable form);
|
|
71
|
+
* - by the property name alone when it is the property's single value
|
|
72
|
+
* (`alice#address`).
|
|
73
|
+
*/
|
|
74
|
+
export declare function valuesOf(node: DefinedKanonak, property: EntityUri, catalog: Kanonak[], nodeAddress: string): PropertyValue[];
|