@kanonak-protocol/sdk 5.27.0 → 5.28.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/index.js CHANGED
@@ -1 +1 @@
1
- import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-4VLLX3MZ.js";import{a as Vn,b as Nn,c as On}from"./chunk-D66LUZDB.js";import{a as Xt,b as Yt,c as Jt,d as Yo,e as we,f as Jo,g as Zo,h as Qo,i as er,j as nr,k as tr,l as or,m as ar}from"./chunk-RVR25FWW.js";import{a as rr}from"./chunk-RWN5JZPU.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as Ct,g as It,h as _t,i as At}from"./chunk-JFBPQN6T.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as vt}from"./chunk-P5VQEDBS.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-KOV3AFBN.js";import{a as so}from"./chunk-PEB52US5.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Wo,H as zo,I as Go,L as qo,M as Xo,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as vo,s as Co,t as Io,u as _o,v as Ao,w as Lo,x as jo,y as Vo,z as No}from"./chunk-4C7ZMXQT.js";import"./chunk-BRCVOR7A.js";import{c as An,d as To,f as xe,h as Ln,i as jn,j as Fo,k as Bo}from"./chunk-ZZINR6NT.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as A}from"./chunk-M7LXZN47.js";import{a as j}from"./chunk-KOWDHKBN.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Re,A as tn,B as on,C as rn,D as an,E as sn,F as cn,G as un,H as ln,I as pn,J as dn,K as mn,L as fn,M as Pe,N as kn,O as yn,P as hn,Q as gn,R as Sn,S as bn,T as Pn,U as Rn,V as En,W as Kn,X as xn,Y as wn,Z as vn,_ as Cn,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as X,k as Y,l as Fe,m as J,ma as Wt,n as Be,na as zt,o as We,oa as ne,p as ze,q as Ge,r as qe,s as Xe,t as Ye,u as Je,v as be,w as Ze,x as Qe,y as en,z as nn}from"./chunk-NOPFCGB7.js";import{A as Q,a as Lt,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,q as In,s as K,u as _n,v as I,w as Z,x as y,y as Ee,z as _}from"./chunk-CZY6OOTM.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new A().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function ir(n){if(!n)return;let e=u(n);if(e===u(dn))return"IRI";if(e===u(mn))return"BlankNode";if(e===u(fn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(kn))return"Violation";if(e===u(yn))return"Warning";if(e===u(hn))return"Info"}function ve(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function sr(n,e){let o=y(n,Ge);if(!o)return;let t={path:o},r=$(I(n,qe)),a=$(I(n,Xe));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,en)),i=$(I(n,nn));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,tn)),p=$(I(n,on));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=Z(n,Ze);if(d!==void 0){let P=Z(n,Qe);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(_n(n,be)){let P=[],N=[];for(let O of _(n,be))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ye);S&&(t.datatype=S);let b=y(n,Je);b&&(t.classRef=b);let l=ir(y(n,pn));l&&(t.nodeKind=l);let m=Z(n,rn);m!==void 0&&(t.message=m);let f=Mn(y(n,Pe))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!In(o,J))continue;let t=Mn(y(o,Pe)),r={name:o.name,uri:h(o),targetClass:y(o,We),targetNodes:ve(o,an),targetSubjectsOf:ve(o,sn),targetObjectsOf:ve(o,cn),closed:I(o,un)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,ln))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,ze)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=sr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",v=n=>({type:`${x}/VarRef`,varName:n}),Ce=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),cr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?Ce(n):cr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(v(oe)),Ce(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(v(oe)),Ce(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:v(re),needle:v("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(v("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(v("v"),Hn(n.maxInclusive))}),e}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Gn(n,e){let o=dr(e)?e:te(e),t=[];for(let r of o)for(let a of mr(n,r))yr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function dr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function mr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of fr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function fr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function kr(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function yr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)gr(n,e,o,a,r,s,t);e.closed&&Er(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var hr={minCount:gn,maxCount:Sn,in:Rn,pattern:En,minLength:Kn,maxLength:xn,minInclusive:wn,maxInclusive:vn};function gr(n,e,o,t,r,a,s){let i=u(a.path),c=kr(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=hr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Sr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)br(a.nodeKind,l)||b(Cn,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=Pr(a.datatype,l);m&&b(bn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Rr(n,a.classRef,l);m&&b(Pn,`'${d}' ${m}`,l)}}function Sr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.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 ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new pr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return lr(n.expr,void 0,o)===1}function br(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 Pr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.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 V.Decimal:case V.Double:case V.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 Rr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Er(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Re,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Re,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Ae from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Kr="0.0.0",L=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new A(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Le(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Ae.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Ae.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Le(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Kr,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(xr(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function xr(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var wr="1.1.0";async function Qn(n){let e=new L(n.repository),o=e.imports(),t=o.ensure(X,Y,wr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ci}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",C="view",et="core-kanonak",vr={publisher:R,package_:C,name:"rootView"},Cr={publisher:R,package_:C,name:"bind"},Ir={publisher:R,package_:C,name:"produces"},_r={publisher:R,package_:C,name:"projections"},Ar={publisher:R,package_:C,name:"where"},Lr={publisher:R,package_:C,name:"value"},jr={publisher:R,package_:C,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new A(this.parser),this.builder=new L(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,Cr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Ir);if(!s)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 i=Vr(r),c=nt(t,R,et),p=nt(t,R,C),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,C,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new Ln(m,t),P=this.readProjections(t,r),N=$r(r,Ar),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,vr);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,_r)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=Ee(a,Lr),i=y(a,jr);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Or(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Ur(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=An(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Vr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Nr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Nr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Or(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function $r(n,e){let o=Ee(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Ur(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{_o as AmbiguousReferenceRule,ye as BooleanStatement,Jo as CANONICAL_FORM_VERSION,V as Carrier,Oo as ClassDefinitionRule,Eo as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,Qo as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,qo as DiamondNameClashRule,Uo as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,bo as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,vt as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Po as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,Lt as Kanonak,ro as KanonakDocumentPositions,A as KanonakObjectParser,Xo as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,q as ListStatement,D as LiteralKanonak,Ct as LocalFirstRepository,It as LockAwareRepository,Ho as LookBandPathRule,Fo as LookRenderer,Do as LookSemanticSvgPathRule,$o as MarkdownLinkRule,ge as MarkdownStatement,Co as NamespaceImportCycleRule,ko as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,er as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,Lo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Go as OwlOneOfRule,L as PackageBuilder,So as PackageHeaderRule,se as ProducerRepository,jo as PropertyDomainRule,Ko as PropertyHierarchyCycleRule,Vo as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,xo as PropertyRangeRequiredRule,ho as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,No as ReservedNameShadowRule,yo as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,Y as SHACL_PACKAGE,X as SHACL_PUBLISHER,J as SH_NODE_SHAPE,Be as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Ot as ScalarStatement,zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,wo as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,go as SubjectKanonakTypeRequiredRule,or as TokenCredentialProvider,Zt as TripleStore,Mo as TxExpressionCompilesRule,Wo as TxExpressionPathRule,Ut as TypeResolver,Io as UnresolvedPredicateRule,Ro as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,Ci as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,At as buildLocalFirstRepository,ar as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,Yo as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Le as contentAddressedName,ne as contextTypesOf,tr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,rr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,Zo as normalizeHost,nr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,Bo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual};
1
+ import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-GJAYU443.js";import{a as Vn,b as Nn,c as On}from"./chunk-D66LUZDB.js";import{a as Xt,b as Yt,c as Jt,d as Yo,e as we,f as Jo,g as Zo,h as Qo,i as er,j as nr,k as tr,l as or,m as ar}from"./chunk-KDMBMX3J.js";import{a as rr}from"./chunk-S2VGNHHF.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as Ct,g as It,h as _t,i as At}from"./chunk-JFBPQN6T.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as vt}from"./chunk-P5VQEDBS.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-RJK6Y4HS.js";import{a as so}from"./chunk-PEB52US5.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Wo,H as zo,I as Go,L as qo,M as Xo,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as vo,s as Co,t as Io,u as _o,v as Ao,w as Lo,x as jo,y as Vo,z as No}from"./chunk-SR6I5ZSI.js";import"./chunk-BRCVOR7A.js";import{c as An,d as To,f as xe,h as Ln,i as jn,j as Fo,k as Bo}from"./chunk-TW7NJDMW.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as A}from"./chunk-SUXSCSHO.js";import{a as j}from"./chunk-KOWDHKBN.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Re,A as tn,B as on,C as rn,D as an,E as sn,F as cn,G as un,H as ln,I as pn,J as dn,K as mn,L as fn,M as Pe,N as kn,O as yn,P as hn,Q as gn,R as Sn,S as bn,T as Pn,U as Rn,V as En,W as Kn,X as xn,Y as wn,Z as vn,_ as Cn,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as X,k as Y,l as Fe,m as J,ma as Wt,n as Be,na as zt,o as We,oa as ne,p as ze,q as Ge,r as qe,s as Xe,t as Ye,u as Je,v as be,w as Ze,x as Qe,y as en,z as nn}from"./chunk-BA4HAURJ.js";import{A as _,B as Q,a as Lt,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as In,t as K,v as _n,w as I,x as Z,y,z as Ee}from"./chunk-N3XODYH5.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new A().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function ir(n){if(!n)return;let e=u(n);if(e===u(dn))return"IRI";if(e===u(mn))return"BlankNode";if(e===u(fn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(kn))return"Violation";if(e===u(yn))return"Warning";if(e===u(hn))return"Info"}function ve(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function sr(n,e){let o=y(n,Ge);if(!o)return;let t={path:o},r=$(I(n,qe)),a=$(I(n,Xe));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,en)),i=$(I(n,nn));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,tn)),p=$(I(n,on));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=Z(n,Ze);if(d!==void 0){let P=Z(n,Qe);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(_n(n,be)){let P=[],N=[];for(let O of _(n,be))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ye);S&&(t.datatype=S);let b=y(n,Je);b&&(t.classRef=b);let l=ir(y(n,pn));l&&(t.nodeKind=l);let m=Z(n,rn);m!==void 0&&(t.message=m);let f=Mn(y(n,Pe))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!In(o,J))continue;let t=Mn(y(o,Pe)),r={name:o.name,uri:h(o),targetClass:y(o,We),targetNodes:ve(o,an),targetSubjectsOf:ve(o,sn),targetObjectsOf:ve(o,cn),closed:I(o,un)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,ln))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,ze)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=sr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",v=n=>({type:`${x}/VarRef`,varName:n}),Ce=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),cr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?Ce(n):cr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(v(oe)),Ce(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(v(oe)),Ce(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:v(re),needle:v("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(v("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(v("v"),Hn(n.maxInclusive))}),e}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Gn(n,e){let o=dr(e)?e:te(e),t=[];for(let r of o)for(let a of mr(n,r))yr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function dr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function mr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of fr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function fr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function kr(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function yr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)gr(n,e,o,a,r,s,t);e.closed&&Er(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var hr={minCount:gn,maxCount:Sn,in:Rn,pattern:En,minLength:Kn,maxLength:xn,minInclusive:wn,maxInclusive:vn};function gr(n,e,o,t,r,a,s){let i=u(a.path),c=kr(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=hr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Sr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)br(a.nodeKind,l)||b(Cn,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=Pr(a.datatype,l);m&&b(bn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Rr(n,a.classRef,l);m&&b(Pn,`'${d}' ${m}`,l)}}function Sr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.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 ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new pr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return lr(n.expr,void 0,o)===1}function br(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 Pr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.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 V.Decimal:case V.Double:case V.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 Rr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Er(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Re,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Re,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Ae from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Kr="0.0.0",L=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new A(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Le(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Ae.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Ae.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Le(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Kr,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(xr(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function xr(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var wr="1.1.0";async function Qn(n){let e=new L(n.repository),o=e.imports(),t=o.ensure(X,Y,wr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ci}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",C="view",et="core-kanonak",vr={publisher:R,package_:C,name:"rootView"},Cr={publisher:R,package_:C,name:"bind"},Ir={publisher:R,package_:C,name:"produces"},_r={publisher:R,package_:C,name:"projections"},Ar={publisher:R,package_:C,name:"where"},Lr={publisher:R,package_:C,name:"value"},jr={publisher:R,package_:C,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new A(this.parser),this.builder=new L(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,Cr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Ir);if(!s)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 i=Vr(r),c=nt(t,R,et),p=nt(t,R,C),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,C,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new Ln(m,t),P=this.readProjections(t,r),N=$r(r,Ar),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,vr);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,_r)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=Ee(a,Lr),i=y(a,jr);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Or(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Ur(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=An(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Vr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Nr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Nr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Or(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function $r(n,e){let o=Ee(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Ur(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{_o as AmbiguousReferenceRule,ye as BooleanStatement,Jo as CANONICAL_FORM_VERSION,V as Carrier,Oo as ClassDefinitionRule,Eo as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,Qo as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,qo as DiamondNameClashRule,Uo as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,bo as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,vt as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Po as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,Lt as Kanonak,ro as KanonakDocumentPositions,A as KanonakObjectParser,Xo as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,q as ListStatement,D as LiteralKanonak,Ct as LocalFirstRepository,It as LockAwareRepository,Ho as LookBandPathRule,Fo as LookRenderer,Do as LookSemanticSvgPathRule,$o as MarkdownLinkRule,ge as MarkdownStatement,Co as NamespaceImportCycleRule,ko as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,er as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,Lo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Go as OwlOneOfRule,L as PackageBuilder,So as PackageHeaderRule,se as ProducerRepository,jo as PropertyDomainRule,Ko as PropertyHierarchyCycleRule,Vo as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,xo as PropertyRangeRequiredRule,ho as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,No as ReservedNameShadowRule,yo as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,Y as SHACL_PACKAGE,X as SHACL_PUBLISHER,J as SH_NODE_SHAPE,Be as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Ot as ScalarStatement,zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,wo as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,go as SubjectKanonakTypeRequiredRule,or as TokenCredentialProvider,Zt as TripleStore,Mo as TxExpressionCompilesRule,Wo as TxExpressionPathRule,Ut as TypeResolver,Io as UnresolvedPredicateRule,Ro as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,Ci as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,At as buildLocalFirstRepository,ar as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,Yo as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Le as contentAddressedName,ne as contextTypesOf,tr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,rr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,Zo as normalizeHost,nr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,Bo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual};
@@ -18,10 +18,8 @@ export interface DisplayValue {
18
18
  * off the instance; the label falls back to the instance's local name so
19
19
  * it is never empty.
20
20
  *
21
- * Single-hop: the lens value is read directly off the instance (a
22
- * datatype property such as `rdfs.label` or a domain property like
23
- * `teamName`). Built entirely on the canonical object-model helpers in
24
- * `uri-helpers`; relies on built-in URIs already canonicalized at parse
25
- * time (see KanonakVocabulary.canonicalizeBuiltinUri).
21
+ * Built entirely on the canonical object-model helpers in `uri-helpers`;
22
+ * relies on built-in URIs already canonicalized at parse time (see
23
+ * KanonakVocabulary.canonicalizeBuiltinUri).
26
24
  */
27
25
  export declare function resolveDisplayValue(catalog: Kanonak[], instance: SubjectKanonak): DisplayValue;
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-KOV3AFBN.js";import{m as b}from"../chunk-M7LXZN47.js";import{a}from"../chunk-KOWDHKBN.js";import"../chunk-NOPFCGB7.js";import"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-RJK6Y4HS.js";import{m as b}from"../chunk-SUXSCSHO.js";import{a}from"../chunk-KOWDHKBN.js";import"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-4VLLX3MZ.js";import"../chunk-M7LXZN47.js";import"../chunk-KOWDHKBN.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-NOPFCGB7.js";import"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.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};
1
+ import{a as g,b as h,c as i,d as j,e as k}from"../chunk-GJAYU443.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.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};
@@ -1 +1 @@
1
- import{a as C}from"../chunk-PEB52US5.js";import{a as l}from"../chunk-SC5M74NM.js";import{a as D}from"../chunk-PEJALHXK.js";import{a as n,b as o,c as p,d as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B}from"../chunk-NOPFCGB7.js";import"../chunk-CZY6OOTM.js";import{a as m}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{m as KanonakUri,C as KanonakUriBuilder,D as KanonakUrlResolver,n as ResourceResolver,s as ResourceTypeClassifier,o as TypeResolver,l as assertPackageIdentity,c as compareVersions,B as contextTypesOf,r as corePropertyClassOf,f as createVersion,q as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,y as isDatatypePropertySubject,i as isMajorCompatible,x as isObjectPropertySubject,w as isPropertySubject,p as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,z as propertiesInScope,v as propertyClassOf,A as resolvePropertyStep,j as satisfiesVersionOperator,t as subjectUri,u as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
1
+ import{a as C}from"../chunk-PEB52US5.js";import{a as l}from"../chunk-SC5M74NM.js";import{a as D}from"../chunk-PEJALHXK.js";import{a as n,b as o,c as p,d as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import{a as m}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{m as KanonakUri,C as KanonakUriBuilder,D as KanonakUrlResolver,n as ResourceResolver,s as ResourceTypeClassifier,o as TypeResolver,l as assertPackageIdentity,c as compareVersions,B as contextTypesOf,r as corePropertyClassOf,f as createVersion,q as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,y as isDatatypePropertySubject,i as isMajorCompatible,x as isObjectPropertySubject,w as isPropertySubject,p as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,z as propertiesInScope,v as propertyClassOf,A as resolvePropertyStep,j as satisfiesVersionOperator,t as subjectUri,u as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -1,4 +1,4 @@
1
- import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-ZZINR6NT.js";import"../chunk-6VIUXP4N.js";import"../chunk-M7LXZN47.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-NOPFCGB7.js";import{c as v,m as p,s as E}from"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.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.
1
+ import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-BA4HAURJ.js";import{c as v,m as p,t as E}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.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+`
@@ -1,4 +1,4 @@
1
- import{c as Pe}from"../chunk-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-JFBPQN6T.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-P5VQEDBS.js";import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-BRCVOR7A.js";import{j as te}from"../chunk-ZZINR6NT.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-M7LXZN47.js";import{a as O}from"../chunk-KOWDHKBN.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-NOPFCGB7.js";import{c as we,t as re}from"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
1
+ import{c as Pe}from"../chunk-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-JFBPQN6T.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-P5VQEDBS.js";import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-BRCVOR7A.js";import{j as te}from"../chunk-TW7NJDMW.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-SUXSCSHO.js";import{a as O}from"../chunk-KOWDHKBN.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-BA4HAURJ.js";import{c as we,u as re}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
2
2
  `),t=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
3
3
  `),a=o.renderStack.packages.map(s=>{let l=s.origin!=="missing"&&!s.resolvedButNotInCatalog,f=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,p=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${l?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${f}</td><td>${p}</td></tr>`}).join(`
4
4
  `),u=o.stylesheet.baseStylesheet,d=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,k=o.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
@@ -1,4 +1,4 @@
1
- import{a as pe}from"../chunk-RWN5JZPU.js";import"../chunk-KOV3AFBN.js";import{a as ve,b as M,c as Un,e as X,f as Vn,g as Rn,h as le,i as q,j as G}from"../chunk-ZZINR6NT.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-M7LXZN47.js";import{a as se}from"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-NOPFCGB7.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,s as A}from"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
1
+ import{a as pe}from"../chunk-S2VGNHHF.js";import"../chunk-RJK6Y4HS.js";import{a as ve,b as M,c as Un,e as X,f as Vn,g as Rn,h as le,i as q,j as G}from"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-SUXSCSHO.js";import{a as se}from"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-BA4HAURJ.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.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(`
@@ -65,6 +65,15 @@ export declare function toCanonicalUrl(uri: CanonicalUriParts): string;
65
65
  * separately — new code uses this.
66
66
  */
67
67
  export declare function typeReferenceUris(kanonak: Kanonak): KanonakUri[];
68
+ /**
69
+ * The canonical URIs a reference-valued property points at, whether it was
70
+ * authored as a single reference or a list. Non-reference values are skipped.
71
+ *
72
+ * THE one way to read "which resources does this property name?" — the shape
73
+ * every cascade needs before a `subClassOf` or type walk.
74
+ * {@link typeReferenceUris} is the `rdf:type` case by name.
75
+ */
76
+ export declare function referenceUris(kanonak: Kanonak, property: EntityUri): KanonakUri[];
68
77
  export declare function hasType(kanonak: Kanonak, target: EntityUri): boolean;
69
78
  /**
70
79
  * Filter a list of parsed kanonaks down to `SubjectKanonak`s whose type
@@ -1,3 +1,3 @@
1
- export { typeReferenceUris, uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
1
+ export { typeReferenceUris, referenceUris, uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
2
2
  export type { EntityUri, CanonicalUriParts } from './UriHelpers.js';
3
3
  export { SingleDocumentRepository } from './SingleDocumentRepository.js';
@@ -1 +1 @@
1
- import{A as o,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{o as SingleDocumentRepository,h as findAllResourcesByCanonicalUri,g as findSubjectByUri,f as findSubjectsByType,j as getDatatypeValue,m as getEmbeddedValue,n as getListValues,l as getReferenceUri,k as getStringValue,i as hasProperty,e as hasType,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches};
1
+ import{A as o,B as p,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{p as SingleDocumentRepository,i as findAllResourcesByCanonicalUri,h as findSubjectByUri,g as findSubjectsByType,k as getDatatypeValue,n as getEmbeddedValue,o as getListValues,m as getReferenceUri,l as getStringValue,j as hasProperty,f as hasType,e as referenceUris,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches};
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,L as J,M as K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-4C7ZMXQT.js";import"../chunk-BRCVOR7A.js";import"../chunk-ZZINR6NT.js";import"../chunk-6VIUXP4N.js";import"../chunk-M7LXZN47.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import"../chunk-NOPFCGB7.js";import"../chunk-CZY6OOTM.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,J as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,K as KanonakObjectValidator,F as LookBandPathRule,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,I as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,H as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,E as TxExpressionCompilesRule,G as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
1
+ import{A,B,C,D,E,F,G,H,I,L as J,M as K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-SR6I5ZSI.js";import"../chunk-BRCVOR7A.js";import"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,J as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,K as KanonakObjectValidator,F as LookBandPathRule,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,I as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,H as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,E as TxExpressionCompilesRule,G as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
@@ -36,6 +36,24 @@ import type { ValidationCache } from '../../ValidationCache.js';
36
36
  * `PropertyRead` / `Traverse` step is in scope for its context type. This
37
37
  * rule is the prior question — whether the tree is a tree the runner can
38
38
  * even build.
39
+ *
40
+ * SCOPE — and why this rule is NOT "every tx.Expression must compile".
41
+ *
42
+ * `tx.Expression` is open for extension: a publisher may subclass it with
43
+ * their own node classes and evaluate them with their OWN runner. That is the
44
+ * designed pattern, stated by `kanonak.org/math` itself — "the per-language
45
+ * primitive implementations live in the runners, keyed on the node class" —
46
+ * and it is in real use (e.g. a streaming vocabulary whose `VarRef` is
47
+ * `subClassOf tx.Expression`, evaluated by a stream processor that has never
48
+ * heard of this SDK).
49
+ *
50
+ * So the v3 loader is the authority on what THIS SDK's engine implements, and
51
+ * on nothing else. An expression carried by someone else's property is not
52
+ * this validator's business, and flagging it was a closed-world assumption in
53
+ * an open-world protocol. The rule therefore checks only expressions sitting
54
+ * in a slot one of the SDK's three consumers will actually evaluate
55
+ * ({@link SDK_EVALUATED_VOCABULARIES}) — where an uncompilable tree really
56
+ * does mean a value that silently never appears.
39
57
  */
40
58
  export declare class TxExpressionCompilesRule implements IRepositoryValidationRule {
41
59
  readonly ruleName = "TxExpressionCompiles";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "5.27.0",
3
+ "version": "5.28.0",
4
4
  "description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -126,7 +126,7 @@
126
126
  ],
127
127
  "dependencies": {
128
128
  "@kanonak-protocol/canonical": "^0.1.3",
129
- "@kanonak-protocol/types": "^5.27.0",
129
+ "@kanonak-protocol/types": "^5.28.0",
130
130
  "ignore": "^7.0.5",
131
131
  "js-yaml": "^4.1.0",
132
132
  "yaml": "^2.7.0",
@@ -1 +0,0 @@
1
- import{a as U}from"./chunk-FUUTGGJS.js";import{c as h,g as j}from"./chunk-QILEJIFU.js";var m=class{};var c=class extends m{statement=[];unresolvedPredicates=[];sourceDoc=""};var p=class extends c{namespace;name;icon};var a=class t extends m{subject;static parse(e){let n=new t;return n.subject=U.parse(e),n}};var s=class{predicate;object};var i=class extends s{carrier;lexical};var y=class t extends i{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=n,r}};var k=class t extends i{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=n,r}};var b=class extends i{};var f=class t extends s{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=a.parse(n),r}};var g=class extends s{};var d=class extends s{};function E(t){return`${t.publisher}/${t.package_}/${t.name}`}function S(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function $(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function A(t){if(!(t instanceof c))return[];let e=[];for(let n of t.statement)if(n.predicate?.subject?.name==="type"){if(n instanceof f)e.push(n.object.subject);else if(n instanceof d)for(let o of n.object)o instanceof a&&e.push(o.subject)}return e}function D(t,e){if(!(t instanceof c))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof f){let o=n.object;if(S(o.subject,e))return!0}return!1}function P(t,e){let n=[];for(let r of t)r instanceof p&&D(r,e)&&n.push(r);return n}function v(t,e){let n=e.version,r=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let o of t){if(!(o instanceof p)||o.name!==e.name)continue;let u=o.namespace||"";if(r!==void 0){if(u===r)return o}else if(u.startsWith(`${e.publisher}/${e.package_}@`))return o}}function I(t,e){let n=[];for(let r of t){if(!(r instanceof p)||r.name!==e.name)continue;(r.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(r)}return n.sort((r,o)=>{let u=j((r.namespace||"").split("@")[1]??""),K=j((o.namespace||"").split("@")[1]??"");return u?K?h(K,u):-1:K?1:0}),n}function l(t,e){for(let n of t.statement){let r=n.predicate;if(r?.subject&&S(r.subject,e))return n}}function V(t,e){return l(t,e)!==void 0}function R(t,e){let n=l(t,e);if(n&&(n instanceof y||n instanceof k||n instanceof b))return n.object}function w(t,e){let n=R(t,e);return typeof n=="string"?n:void 0}function C(t,e){let n=l(t,e);if(n instanceof f)return n.object.subject}function B(t,e){let n=l(t,e);if(n instanceof g)return n.object}function T(t,e){let n=l(t,e);return n instanceof d?n.object??[]:[]}var x=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{m as a,c as b,p as c,a as d,s as e,i as f,y as g,k as h,b as i,f as j,g as k,d as l,E as m,S as n,$ as o,A as p,D as q,P as r,v as s,I as t,V as u,R as v,w,C as x,B as y,T as z,x as A};