@kanonak-protocol/sdk 5.36.0 → 5.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-22DSABP6.js +1 -0
  3. package/dist/chunk-7JBKOJB4.js +1 -0
  4. package/dist/{chunk-4QXD6HKI.js → chunk-A3HRXFVX.js} +1 -1
  5. package/dist/{chunk-VENZTHCC.js → chunk-ADSDFJUO.js} +1 -1
  6. package/dist/chunk-D2X6J77P.js +1 -0
  7. package/dist/chunk-D4QGPMRW.js +1 -0
  8. package/dist/chunk-DONOB6RA.js +1 -0
  9. package/dist/{chunk-IN5VVPYH.js → chunk-ED35OFGD.js} +1 -1
  10. package/dist/chunk-GKIX3OD6.js +3 -0
  11. package/dist/chunk-HKX27KBZ.js +1 -0
  12. package/dist/{chunk-H7SX57L7.js → chunk-LBVHWFFL.js} +1 -1
  13. package/dist/chunk-NUTHBBDZ.js +1 -0
  14. package/dist/{chunk-6TEJENCD.js → chunk-O6SOU5Y2.js} +10 -10
  15. package/dist/{chunk-BZ3YTI3C.js → chunk-OOYGILH4.js} +2 -2
  16. package/dist/chunk-TYVZXABI.js +155 -0
  17. package/dist/chunk-VORVR5BZ.js +1 -0
  18. package/dist/index.d.ts +7 -7
  19. package/dist/index.js +1 -1
  20. package/dist/kanonaks/DefinedKanonak.d.ts +11 -0
  21. package/dist/kanonaks/LiteralKanonak.d.ts +2 -0
  22. package/dist/kanonaks/ReferenceKanonak.d.ts +2 -0
  23. package/dist/lock/LockFile.d.ts +6 -0
  24. package/dist/lock/index.d.ts +1 -1
  25. package/dist/look/displayValue.d.ts +3 -0
  26. package/dist/look/index.d.ts +1 -1
  27. package/dist/parsing/findMarkdownLinkAt.d.ts +8 -0
  28. package/dist/parsing/index.d.ts +2 -0
  29. package/dist/parsing/index.js +1 -1
  30. package/dist/parsing/sourceSymbols.d.ts +54 -0
  31. package/dist/producer/index.js +1 -1
  32. package/dist/reasoning/KanonakVocabulary.d.ts +21 -0
  33. package/dist/reasoning/index.d.ts +1 -1
  34. package/dist/reasoning/index.js +1 -1
  35. package/dist/repositories/LockAwareRepository.d.ts +1 -1
  36. package/dist/repositories/browser.js +1 -1
  37. package/dist/repositories/index.js +1 -1
  38. package/dist/resolution/ResourceTypeClassifier.d.ts +8 -1
  39. package/dist/resolution/index.d.ts +1 -0
  40. package/dist/resolution/index.js +1 -1
  41. package/dist/resolution/referenceSpelling.d.ts +14 -0
  42. package/dist/search/index.js +1 -1
  43. package/dist/server/closure.d.ts +8 -0
  44. package/dist/server/index.d.ts +1 -1
  45. package/dist/server/index.js +16 -16
  46. package/dist/server/requestRouter.d.ts +16 -0
  47. package/dist/statements/Statement.d.ts +9 -0
  48. package/dist/transformations/index.js +2 -2
  49. package/dist/transformations/v3/CompiledTransformationV3.d.ts +28 -27
  50. package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +27 -0
  51. package/dist/uri-helpers/index.js +1 -1
  52. package/dist/validation/KanonakObjectValidator.d.ts +7 -1
  53. package/dist/validation/index.js +1 -1
  54. package/package.json +3 -3
  55. package/dist/chunk-7TU55KLO.js +0 -1
  56. package/dist/chunk-HF5FJBS2.js +0 -1
  57. package/dist/chunk-IS3AQKB4.js +0 -1
  58. package/dist/chunk-KIBR3HAT.js +0 -1
  59. package/dist/chunk-Q2FG7DME.js +0 -1
  60. package/dist/chunk-ROKDCCJN.js +0 -155
  61. package/dist/chunk-V3DH67P3.js +0 -1
  62. package/dist/chunk-XK24CN3C.js +0 -1
  63. package/dist/chunk-XNEWQEB6.js +0 -1
  64. package/dist/chunk-YBHIELES.js +0 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as st,b as ct,c as ut,d as dt,e as W}from"./chunk-4QXD6HKI.js";import{a as Vn,b as Ln,c as Nn}from"./chunk-V3DH67P3.js";import{a as rt,b as at,c as it,d as hr,e as kr,f as Sr,g as yr,h as gr,i as br}from"./chunk-H7SX57L7.js";import{a as Er}from"./chunk-IN5VVPYH.js";import{a as dr,b as lr,c as pr,d as B,e as fr,f as mr,g as Pe,h as Rr,i as Cr,j as Kr,k as xr,l as _r}from"./chunk-VENZTHCC.js";import{a as po,b as fo,c as mo,d as ho,e as ko,f as Po,g as vo,h as Io,i as Vo}from"./chunk-IS3AQKB4.js";import{a as So,b as yo,c as go,d as bo,e as Eo,f as Ro,h as Co,i as $e,j as Me,k as je,l as De,m as Ko,n as _o}from"./chunk-BZ3YTI3C.js";import{a as pt,b as ft,c as mt,d as ht}from"./chunk-YBHIELES.js";import{a as kt}from"./chunk-XK24CN3C.js";import{a as xo}from"./chunk-SC5M74NM.js";import{A as qt,B as Wt,C as Bt,D as Gt,E as zt,F as Qt,G as tr,H as rr,I as ar,J as ir,K as sr,L as cr,M as ur,a as yt,b as gt,c as bt,d as Et,e as Rt,f as Ct,g as Kt,h as xt,i as _t,j as Pt,k as vt,l as It,m as Vt,n as Lt,o as Nt,p as Ot,q as wt,r as At,s as Ut,t as $t,u as Mt,v as jt,w as Dt,x as Ft,y as Ht,z as Tt}from"./chunk-6TEJENCD.js";import"./chunk-KIBR3HAT.js";import{c as Pn,d as Xt,e as Yt,g as Jt,h as Zt,k as er,m as _e,o as vn,p as In,r as nr,s as or}from"./chunk-ROKDCCJN.js";import"./chunk-QHABFCRC.js";import{a as fe}from"./chunk-6VIUXP4N.js";import{a as Ke,f as N,g as xe,h as ot,i as tt,j as U}from"./chunk-Q2FG7DME.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as St}from"./chunk-PEJALHXK.js";import{$ as re,A as en,B as nn,C as on,D as tn,E as rn,F as an,G as sn,H as cn,I as un,J as dn,K as ye,L as ln,M as pn,N as fn,O as mn,P as hn,Q as kn,R as Sn,S as yn,T as gn,U as bn,V as En,W as Rn,X as Cn,Y as Kn,Z as ge,_ as xn,a as qo,aa as be,b as Wo,ba as Ee,c as F,ca as ae,d as Qo,da as T,e as Xo,ea as q,g as Yo,h as ne,i as oe,ia as Jo,j as Fe,k as H,ka as Zo,l as te,la as k,m as He,ma as Ce,n as Te,o as ke,p as qe,q as We,r as Be,ra as et,s as Ge,sa as nt,t as Se,ta as A,u as ze,v as Qe,w as Xe,x as Ye,y as Je,z as Ze}from"./chunk-7TU55KLO.js";import{C as w,D as C,E as ee,F as h,G as D,H as he,I as ie,J as Re,L as _n,a as Lo,b as No,c as S,d as v,e as I,f as wo,g as Ao,h as Uo,i as $o,j as Mo,k as jo,l as Do,m as Fo,n as Ho,o as To,p as Bo,q as Go,r as l,u as zo,v as O,w as me,x as Z,z as x}from"./chunk-XNEWQEB6.js";import{a as Oo}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as oo,b as to,c as J,d as ro,e as L,f as ao,g as io,h as so,i as co,j as uo,k as lo}from"./chunk-QILEJIFU.js";import{a as lt}from"./chunk-ODIECDN7.js";async function On(n){let e=await new U().parseKanonaks(n),t=await new W().reason(n);return{kind:"merged",catalog:e,reasoning:t}}function wn(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function An(n,e){let t=e??new fe(new j);return{kind:"standalone",catalog:await new U().parseKanonaks(new _n(n,t))}}function V(n){return typeof n=="number"?n:void 0}function Pr(n){if(!n)return;let e=l(n);if(e===l(cn))return"IRI";if(e===l(un))return"BlankNode";if(e===l(dn))return"Literal"}function $n(n){if(!n)return;let e=l(n);if(e===l(ln))return"Violation";if(e===l(pn))return"Warning";if(e===l(fn))return"Info"}function Mn(n,e,t,o){let r=h(e,ke);if(!r)return;let a={path:r},u=V(C(e,qe)),s=V(C(e,We));u!==void 0&&(a.minCount=u),s!==void 0&&(a.maxCount=s);let i=V(C(e,Xe)),d=V(C(e,Ye));i!==void 0&&(a.minLength=i),d!==void 0&&(a.maxLength=d);let c=V(C(e,Je)),p=V(C(e,Ze));c!==void 0&&(a.minInclusive=c),p!==void 0&&(a.maxInclusive=p);let f=ee(e,ze);if(f!==void 0){let m=ee(e,Qe);a.pattern=m!==void 0?{regex:f,flags:m}:{regex:f}}if(w(e,Se)){let m=[],P=[];for(let{item:y}of me(e,Se))"literal"in y?m.push(y.value):y instanceof I&&P.push(y.subject);m.length>0&&(a.inValues=m),P.length>0&&(a.inRefs=P)}let R=h(e,Be);R&&(a.datatype=R);let $=h(e,Ge);$&&(a.classRef=$);let M=Pr(h(e,sn));M&&(a.nodeKind=M);let z=h(e,xn);if(z&&(a.hasValue=z),w(e,re)||w(e,be)||w(e,Ee)){let m={},P=V(C(e,be)),y=V(C(e,Ee));P!==void 0&&(m.minCount=P),y!==void 0&&(m.maxCount=y);let K=vr(n,e,o);"problem"in K?m.problem=K.problem:m.shape=K.shape,a.qualified=m}let Q=ee(e,en);Q!==void 0&&(a.message=Q);let X=$n(h(e,ye))??t;return X&&(a.severity=X),a}function vr(n,e,t){let o=D(e,re);if(o)return Un(n,o,void 0,t);let r=h(e,re);if(!r)return{problem:"sh:qualifiedValueShape is missing"};let a=l(r);if(t.has(a))return{problem:`sh:qualifiedValueShape '${r.name}' leads back to itself (a cycle through named shapes)`};let u=x(n,r);return u?Un(n,u,a,t):{problem:`sh:qualifiedValueShape '${r.name}' does not resolve`}}function Un(n,e,t,o){let r=t?new Set([...o,t]):o,a=Z(e,H);if((Z(e,te)||w(e,ke))&&!a){let i=Mn(n,e,void 0,r);return i?{shape:{kind:"property",constraint:i}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof S&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:jn(n,e,r)}}}function jn(n,e,t){let o=$n(h(e,ye)),r={name:e instanceof S?e.name:"(inline shape)",uri:e instanceof S?k(e):void 0,targetClass:h(e,He),targetNodes:O(e,nn),targetSubjectsOf:O(e,on),targetObjectsOf:O(e,tn),closed:C(e,rn)===!0,ignoredProperties:[],severity:o,properties:[]};r.ignoredProperties.push(...O(e,an));for(let{item:a}of me(e,Te)){let u;if(a instanceof v?u=a:a instanceof I&&(u=x(n,a.subject)),!u)continue;let s=Mn(n,u,o,t);s&&r.properties.push(s)}return r}function se(n){let e=[];for(let t of n){if(!(t instanceof S)||!Z(t,H))continue;let o=k(t);e.push(jn(n,t,new Set(o?[l(o)]:[])))}return e}var b="kanonak.org/transformations",G="values";var ce="allowed",Ie="expected",g=n=>({type:`${b}/VarRef`,varName:n}),ve=n=>({type:`${b}/IntegerLiteral`,integerLiteral:n}),Ir=n=>({type:`${b}/DecimalLiteral`,decimalLiteral:n}),Dn=n=>Number.isInteger(n)?ve(n):Ir(n),Fn=n=>({type:`${b}/Count`,source:n}),Hn=(n,e)=>({type:`${b}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Tn=(n,e)=>({type:`${b}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ve(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!t.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function ue(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Hn(Fn(g(G)),ve(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Tn(Fn(g(G)),ve(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${b}/Contains`,haystack:g(G),needle:g(Ie)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${b}/Contains`,haystack:g(ce),needle:g("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:Ve(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Hn(g("v"),Dn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Tn(g("v"),Dn(n.maxInclusive))}),e}import{evaluate as Lr,ExpressionError as Nr}from"@kanonak-protocol/expression";function Wn(n,e){let t=Or(e)?e:se(e),o=[],r=n.catalog.filter(s=>s instanceof S).map(de),a=new Map;wr(r,a);let u={scope:n,membership:new Le(n),embeddedFocus:a};for(let s of t)for(let i of Ar(u,s,r))Gn(u,s,i,o);return{conforms:!o.some(s=>s.severity==="Violation"),results:o}}function Or(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Bn(n){let e=n.predicate;return e instanceof I?e:void 0}function de(n){return{node:n,key:Re(n),uri:k(n),label:n.name}}function Oe(n,e){return{node:n,key:e,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function wr(n,e){Ke(n.map(t=>t.node),({kanonak:t,address:o})=>{t instanceof v&&!e.has(t)&&e.set(t,Oe(t,o))})}var Le=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,t){let o=l(t);return e.some(r=>l(r)===o||this.ancestorsOf(r).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${l(e)}@${L(e.version)}`:l(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ce(this.scope.catalog,e).map(r=>l(r))),this.ancestors.set(t,o)),o}};function Ar(n,e,t){let{scope:o}=n,r=new Map,a=s=>{r.set(s.key,s)},u=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let s=e.targetClass;if(o.reasoning){let i=new Set(o.reasoning.getInstancesOfClass(s));for(let d of t)d.uri&&i.has(l(d.uri))&&a(d)}else for(let i of t)n.membership.isInstance(A(i.node),s)&&a(i);for(let i of n.embeddedFocus.values())n.membership.isInstance(A(i.node),s)&&a(i)}for(let s of e.targetNodes){let i=x(o.catalog,s);i instanceof S&&a(de(i))}for(let s of e.targetSubjectsOf){let i=l(s);for(let d of u())d.node.statement.some(c=>{let p=Bn(c);return p&&l(p.subject)===i})&&a(d)}for(let s of e.targetObjectsOf)for(let i of u())for(let d of ie(i.node,s,o.catalog,i.key))d.kind==="subject"?a(de(d.node)):d.kind==="embedded"&&a(n.embeddedFocus.get(d.node)??Oe(d.node,d.address));return[...r.values()]}function Ur(n,e,t){return e.node?ie(e.node,t,n.scope.catalog,e.key).map(o=>$r(n,o)):[]}function $r(n,e){switch(e.kind){case"subject":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let t=n.embeddedFocus.get(e.node)??Oe(e.node,e.address);return{kernel:{ref:t.key},kind:"embedded",embedded:t}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function Gn(n,e,t,o){for(let r of e.properties)Qn(n,e,t,r,o);e.closed&&zr(e,t,o)}function Ne(n,e,t,o,r={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:a??zn(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...r}}function zn(n){return n.severity??"Violation"}var Mr={minCount:mn,maxCount:hn,hasValue:ae,in:yn,pattern:gn,minLength:bn,maxLength:En,minInclusive:Rn,maxInclusive:Cn};function Qn(n,e,t,o,r){let a=Ur(n,t,o.path),u=o.severity??zn(e),s=o.path.name,i=[...(o.inValues??[]).map(c=>typeof c=="boolean"?c?1:0:c),...(o.inRefs??[]).map(c=>({ref:l(c)}))],d=(c,p,f)=>{let R=Ne(e,t,c,o.message??p,{resultPath:o.path,value:f?.literal,valueRef:f?.ref},u);return r.push(R),R};for(let c of ue(o)){let p=Mr[c.component];if(c.per==="node"){let f={[G]:a.map(R=>R.kernel),[ce]:i};o.hasValue&&(f[Ie]={ref:l(o.hasValue)}),qn(c,f)||d(p,jr(c,s,o,a.length));continue}for(let f of a){if((c.component==="pattern"||c.component==="minLength"||c.component==="maxLength")&&f.kind!=="string"){d(p,`'${s}' value is not a string; ${c.component} applies to string values.`,f);continue}qn(c,{v:f.kernel,[ce]:i})||d(p,qr(c,s,o,f),f)}}if(o.nodeKind)for(let c of a)Wr(o.nodeKind,c)||d(Kn,`'${s}' value is ${c.kind}; nodeKind requires ${o.nodeKind}.`,c);if(o.datatype)for(let c of a){let p=Br(o.datatype,c);p&&d(kn,`'${s}' ${p}`,c)}if(o.classRef)for(let c of a){let p=Gr(n,o.classRef,c);p&&d(Sn,`'${s}' ${p}`,c)}o.qualified&&Dr(n,o,a,s,d)}function jr(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?l(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Dr(n,e,t,o,r){let a=e.qualified,u=a.maxCount!==void 0?q:T,s=(d,c)=>{Xn.add(r(u,d,c))};if(!a.shape){s(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let i=0;for(let d of t){let c=d.ref?l(d.ref):d.embedded?d.embedded.label:JSON.stringify(d.literal),p=Fr(n,d);if(!p){s(`'${o}' value ${c} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,d);continue}let f=Tr(n,a.shape,p);if(f.kind==="undecided"){s(`'${o}' value ${c}: whether it conforms to the qualified shape cannot be decided \u2014 ${f.reason}`,d);continue}f.kind==="conforms"&&i++}a.minCount!==void 0&&i<a.minCount&&r(T,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&i>a.maxCount&&r(q,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function Fr(n,e){switch(e.kind){case"reference":return e.subject?de(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Hr={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},Xn=new WeakSet;function Tr(n,e,t){let o=[];e.kind==="property"?Qn(n,Hr,t,e.constraint,o):Gn(n,e.shape,t,o);let r=o.find(a=>Xn.has(a));return r?{kind:"undecided",reason:r.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function qr(n,e,t,o){let r=o.ref?l(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function qn(n,e){let t=o=>{let r=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new Nr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Lr(n.expr,void 0,t)===1}function Wr(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 Br(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=xe(n);if(t!==void 0)switch(t){case N.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case N.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 N.Decimal:case N.Double:case N.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 Gr(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let r=A(t.embedded.node);return r.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(r,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;if(n.scope.reasoning)return n.scope.reasoning.isInstanceOf(t.ref,e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`;let o=t.subject;return o?n.membership.isInstance(A(o),e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`:`value ${l(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}function zr(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(a=>l(a.path)),...n.ignoredProperties.map(a=>l(a))]),r=new Set;for(let a of e.node.statement){let u=Bn(a);if(!u)continue;let s=l(u.subject);o.has(s)||r.has(s)||(r.add(s),t.push(Ne(n,e,ge,`'${e.label}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let a of e.node.unresolvedPredicates)r.has(a.key)||(r.add(a.key),t.push(Ne(n,e,ge,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var Qr="1.1.0",Xr=new Set([ae,T,q].map(n=>n.name));async function Yn(n){let e=new B(n.repository),t=e.imports(),o=n.result.results.some(i=>Xr.has(i.constraintComponent.name))?"1.2.0":Qr,r=t.ensure(ne,oe,o,"sh"),a=(i,d)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,L(i.version),i.package_)}.${i.name}`:d,u={},s=[];return n.result.results.forEach((i,d)=>{let c=`result-${d+1}`;s.push(c);let p={type:`${r}.ValidationResult`,[`${r}.focusNode`]:a(i.focusUri,i.focusNode),[`${r}.resultMessage`]:i.message,[`${r}.resultSeverity`]:`${r}.${i.severity}`,[`${r}.sourceConstraintComponent`]:`${r}.${i.constraintComponent.name}`};i.resultPath&&(p[`${r}.resultPath`]=a(i.resultPath,l(i.resultPath))),i.sourceShapeUri&&(p[`${r}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${r}.value`]=a(i.valueRef,l(i.valueRef)):i.value!==void 0&&(p[`${r}.value`]=i.value),u[c]=p}),u.report={type:`${r}.ValidationReport`,[`${r}.conforms`]:n.result.conforms,...s.length>0?{[`${r}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:u,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Pi}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",_="view",Jn="core-kanonak",Yr={publisher:E,package_:_,name:"rootView"},Jr={publisher:E,package_:_,name:"bind"},Zr={publisher:E,package_:_,name:"produces"},ea={publisher:E,package_:_,name:"projections"},na={publisher:E,package_:_,name:"where"},oa={publisher:E,package_:_,name:"value"},ta={publisher:E,package_:_,name:"as"},le=class{constructor(e,t=new j){this.repository=e;this.parser=t;this.objectParser=new U(this.parser),this.builder=new B(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(o,e),a=h(r,Jr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let u=h(r,Zr);if(!u)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=ra(r),i=Zn(o,E,Jn),d=Zn(o,E,_),c=this.builder.imports(),p=c.ensure(E,Jn,i,"ck"),f=c.ensure(E,_,d,"v"),R=c.ref(u),$=new In(this.repository,this.parser,this.objectParser),M=new vn($,o),z=this.readProjections(o,r),Q=sa(r,na),X=this.findInstances(o,a,await this.reason(t)),m={},P=new Set;for(let Y of X){if(!await this.passesWhere(M,o,Q,Y))continue;let pe={type:R};for(let Ae of z){let no=await this.evaluateValue(M,o,Ae.value,Y),Ue=this.builder.serializeValue(eo(no),c);Ue!==void 0&&(pe[c.ref(Ae.as)]=Ue)}let we=k(Y);we&&(pe[`${f}.derivedFrom`]=c.ref(we)),m[this.rowName(Y,P)]=pe}let y={};t.resolvedAt&&(y[`${p}.resolvedAt`]=t.resolvedAt),t.invocationId&&(y[`${p}.id`]=t.invocationId);let K=await this.builder.buildContentAddressed({publisher:s,book:c,body:m,contentHashProperty:`${p}.contentHash`,header:y});return{yaml:K.yaml,contentHash:K.contentHash,packageName:K.packageName,publisher:K.publisher,rowCount:K.resourceCount}}resolveView(e,t){let o=x(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let r=h(o,Yr);if(r){let a=x(e,r);if(!a)throw new Error(`ViewPackage ${t.name} names rootView ${r.name}, which is not in the catalog.`);return a}return o}readProjections(e,t){let o=[];for(let r of he(t,ea)){let a=r instanceof v?r:r instanceof I?x(e,r.subject):void 0;if(!a)continue;let u=D(a,oa),s=h(a,ta);u&&s&&o.push({value:u,as:s})}return o}async reason(e){return new W({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let r=ia(e),a=[],u=new Set;for(let s of o.getInstancesOfClass(t)){if(u.has(s))continue;u.add(s);let i=r.get(s);i&&a.push(i)}return a.sort((s,i)=>{let d=F(k(s)),c=F(k(i));return d<c?-1:d>c?1:0}),a}async passesWhere(e,t,o,r){for(let a of o){let u=await this.evaluateValue(e,t,a,r);if(!ca(u))return!1}return!0}async evaluateValue(e,t,o,r){let a=Pn(o,"view-projection",{catalog:t,depth:0}),u=new Map([["input",r]]);return e.evaluate(a,u)}rowName(e,t){let o=Pe(e.name)||"row",r=o,a=2;for(;t.has(r);)r=`${o}-${a++}`;return t.add(r),r}};function eo(n){return _e(n)?n.value:Array.isArray(n)?n.map(eo):n}function ra(n){let e=k(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function Zn(n,e,t){let o=aa(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function aa(n,e,t){let o;for(let r of n){if(!(r instanceof S))continue;let a=k(r);!a||a.publisher!==e||a.package_!==t||!a.version||(!o||J(a.version,o)>0)&&(o=a.version)}return o?L(o):void 0}function ia(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof S))continue;let r=k(o);if(!r||!r.version)continue;let a=F(r),u=t.get(a);(!u||J(r.version,u)>0)&&(t.set(a,r.version),e.set(a,o))}return e}function sa(n,e){let t=D(n,e);return t?[t]:he(n,e).filter(o=>o instanceof v)}function ca(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:_e(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{jt as AmbiguousReferenceRule,jo as BooleanStatement,pr as CANONICAL_FORM_VERSION,N as Carrier,Wt as ClassDefinitionRule,Nt as ClassHierarchyCycleRule,mo as CompositeKanonakDocumentRepository,kr as DEFAULT_CONSENT_BINDING_PARAM,No as DefinedKanonak,cr as DiamondNameClashRule,Gt as DisplayLensScopeRule,fo as DocumentLocation,at as EdgeType,v as EmbeddedKanonak,It as EmbeddedKanonakTypeRule,Fo as EmbeddedStatement,xr as EntitlementDeniedError,_r as EntitlementProducer,po as FileSystemKanonakDocumentRepository,lt as GitIgnoreFilter,it as GraphBuilder,_o as HttpKanonakDocumentRepository,$e as INTEGRITY_PREFIX,mr as ImportBook,Vt as ImportExistenceRule,fe as InMemoryKanonakDocumentRepository,So as KANONAK_USER_AGENT,Lo as Kanonak,ft as KanonakDocumentPositions,U as KanonakObjectParser,ur as KanonakObjectValidator,j as KanonakParser,Oo as KanonakUri,kt as KanonakUriBuilder,St as KanonakUrlResolver,Jo as KanonakVocabulary,Yt as LINE_STYLES,Ct as LinkTargetRule,Ho as ListStatement,wo as LiteralKanonak,Po as LocalFirstRepository,vo as LockAwareRepository,rr as LookBandPathRule,nr as LookRenderer,zt as LookSemanticSvgPathRule,Bt as MarkdownLinkRule,To as MarkdownStatement,$t as NamespaceImportCycleRule,Kt as NamespacePrefixRule,rt as NodeType,Mo as NumberStatement,Sr as OAuthDiscovery,ut as OWL_RL_CLASSIFICATION_RULES,Ft as ObjectPropertyValueValidationRule,bt as OntologyValidationError,yt as OntologyValidationResult,sr as OwlOneOfRule,B as PackageBuilder,vt as PackageHeaderRule,Rr as ProducerRepository,Ht as PropertyDomainRule,Ot as PropertyHierarchyCycleRule,Tt as PropertyKindRangeConsistencyRule,pt as PropertyMetadata,Dt as PropertyRangeReferenceRule,wt as PropertyRangeRequiredRule,_t as PropertyTypeSpecificityRule,Co as PublisherConfigResolver,Ko as PublisherIndex,ct as RDFS_RULES,W as Reasoner,dt as ReasoningResult,I as ReferenceKanonak,Do as ReferenceStatement,ko as RepositoryFactory,qt as ReservedNameShadowRule,xt as ResourceNamingRule,qo as ResourceResolver,Zo as ResourceTypeClassifier,oe as SHACL_PACKAGE,ne as SHACL_PUBLISHER,H as SH_NODE_SHAPE,te as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Uo as ScalarStatement,tr as SequenceNarrativeRule,ir as ShaclShapeRule,Ao as Statement,$o as StringStatement,At as SubClassOfReferenceRule,Ut as SubPropertyOfReferenceRule,S as SubjectKanonak,Pt as SubjectKanonakTypeRequiredRule,br as TokenCredentialProvider,st as TripleStore,Qt as TxExpressionCompilesRule,ar as TxExpressionPathRule,Wo as TypeResolver,Mt as UnresolvedPredicateRule,Lt as UnresolvedReferenceRule,Rt as ValidationCache,Et as ValidationContext,gt as ValidationSeverity,Pi as VersionOperator,le as ViewMaterializer,Cr as allowAllPolicy,bo as assertHttpsUrl,xo as assertPackageIdentity,Vo as buildLocalFirstRepository,er as buildOntologyModel,Yn as buildReportPackageAsync,se as buildShapesModel,dr as canonicalForm,lr as canonicalHash,xe as carrierOf,Io as collectKanonakFiles,J as compareVersions,Nn as computeIntegrity,De as computeIntegrityAsync,fr as contentAddressedName,A as contextTypesOf,gr as createCredentialedFetch,ao as createVersion,Wn as evaluateConformance,tt as extractMarkdownLinks,Er as findDerivation,ot as findMalformedReferences,ht as findMarkdownLinkAt,Ve as foldFlagsIntoPattern,Go as formatKanonakAddress,L as formatVersion,ho as getGlobalCachePath,go as getKanonakUserAgent,so as isCompatibleVersion,co as isMajorCompatible,Eo as kanonakFetch,Vn as loadLockFile,ue as lowerConstraint,Qo as makeUriKey,Kr as noopMeter,hr as normalizeHost,yr as parseAuthChallenge,Bo as parseKanonakAddress,Me as parseLockFile,io as parseVersionString,mt as parseWithPositions,lo as pickHighestDocument,et as propertiesInScope,Jt as readSequenceConnectors,O as referenceUris,Xt as resolveDisplayValue,nt as resolvePropertyStep,Pe as sanitizeName,uo as satisfiesVersionOperator,Ln as saveLockFile,wn as scopeFromCatalog,An as scopeFromDocumentAsync,On as scopeFromRepositoryAsync,je as serializeLockFile,Ro as setKanonakFetchRetries,yo as setKanonakUserAgent,Re as subjectAddress,k as subjectUri,Ce as superClassChain,or as supportedBandKeys,Xo as tripleKey,zo as typeReferenceUris,F as uriKey,Yo as uriTriple,ie as valuesOf,oo as versionOperatorFromChar,to as versionOperatorToChar,ro as versionsEqual,Ke as walkDefinedKanonaks,Zt as walkSequence};
1
+ import{a as pt,b as ft,c as mt,d as ht,e as W}from"./chunk-A3HRXFVX.js";import{a as Vn,b as Nn,c as On}from"./chunk-DONOB6RA.js";import{a as ut,b as dt,c as lt,d as _r,e as xr,f as Pr,g as vr,h as Ir,i as Lr}from"./chunk-LBVHWFFL.js";import{a as Vr}from"./chunk-ED35OFGD.js";import{a as br,b as Er,c as Rr,d as B,e as Cr,f as Kr,g as Pe,h as Nr,i as Or,j as wr,k as Ar,l as Ur}from"./chunk-ADSDFJUO.js";import{a as fo,b as mo,c as ho,d as So,e as ko,f as vo,g as Io,h as Lo,i as Vo}from"./chunk-HKX27KBZ.js";import{a as yo,b as go,c as bo,d as Eo,e as Ro,f as Co,h as Ko,i as $e,j as Me,k as je,l as De,m as Fe,n as _o,o as Po}from"./chunk-OOYGILH4.js";import{a as kt,b as yt,c as gt,d as bt,e as Et,f as Rt}from"./chunk-GKIX3OD6.js";import{a as Ct,b as _t}from"./chunk-D2X6J77P.js";import{a as xo}from"./chunk-SC5M74NM.js";import{A as Jt,B as Zt,C as er,D as nr,E as or,F as tr,G as fr,H as mr,I as hr,J as Sr,K as kr,L as yr,M as gr,a as xt,b as Pt,c as vt,d as It,e as Lt,f as Vt,g as Nt,h as Ot,i as wt,j as At,k as Ut,l as $t,m as Mt,n as jt,o as Dt,p as Ft,q as Ht,r as Tt,s as qt,t as Wt,u as Bt,v as Gt,w as zt,x as Qt,y as Xt,z as Yt}from"./chunk-O6SOU5Y2.js";import"./chunk-VORVR5BZ.js";import{c as vn,d as rr,e as ar,f as ir,g as sr,i as cr,j as ur,m as dr,o as xe,q as In,r as Ln,t as lr,u as pr}from"./chunk-TYVZXABI.js";import"./chunk-QHABFCRC.js";import{a as fe}from"./chunk-6VIUXP4N.js";import{a as Ke,g as N,h as _e,i as st,j as ct,k as U}from"./chunk-22DSABP6.js";import{a as j}from"./chunk-7JBKOJB4.js";import{a as Kt}from"./chunk-PEJALHXK.js";import{$ as re,A as nn,B as on,C as tn,D as rn,E as an,F as sn,G as cn,H as un,I as dn,J as ln,K as ye,L as pn,M as fn,N as mn,O as hn,P as Sn,Q as kn,R as yn,S as gn,T as bn,U as En,V as Rn,W as Cn,X as Kn,Y as _n,Z as ge,_ as xn,a as Wo,aa as be,b as Bo,ba as Ee,c as F,ca as ae,d as Xo,da as T,e as Yo,ea as q,g as Jo,h as ne,ha as Zo,i as oe,ia as et,j as He,k as H,ka as nt,l as te,m as Te,ma as ot,n as qe,na as S,o as Se,oa as Ce,p as We,pa as tt,q as Be,qa as rt,r as Ge,s as ze,t as ke,ta as at,u as Qe,ua as it,v as Xe,va as A,w as Ye,x as Je,y as Ze,z as en}from"./chunk-NUTHBBDZ.js";import{C as w,D as C,E as ee,F as h,G as D,H as he,I as ie,J as Re,L as Pn,a as No,b as Oo,c as k,d as v,e as I,f as Ao,g as Uo,h as $o,i as Mo,j as jo,k as Do,l as Fo,m as Ho,n as To,o as qo,p as Go,q as zo,r as l,u as Qo,v as O,w as me,x as Z,z as _}from"./chunk-D4QGPMRW.js";import{a as wo}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as to,b as ro,c as J,d as ao,e as V,f as io,g as so,h as co,i as uo,j as lo,k as po}from"./chunk-QILEJIFU.js";import{a as St}from"./chunk-ODIECDN7.js";async function wn(n){let e=await new U().parseKanonaks(n),t=await new W().reason(n);return{kind:"merged",catalog:e,reasoning:t}}function An(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Un(n,e){let t=e??new fe(new j);return{kind:"standalone",catalog:await new U().parseKanonaks(new Pn(n,t))}}function L(n){return typeof n=="number"?n:void 0}function $r(n){if(!n)return;let e=l(n);if(e===l(un))return"IRI";if(e===l(dn))return"BlankNode";if(e===l(ln))return"Literal"}function Mn(n){if(!n)return;let e=l(n);if(e===l(pn))return"Violation";if(e===l(fn))return"Warning";if(e===l(mn))return"Info"}function jn(n,e,t,o){let r=h(e,Se);if(!r)return;let a={path:r},u=L(C(e,We)),s=L(C(e,Be));u!==void 0&&(a.minCount=u),s!==void 0&&(a.maxCount=s);let i=L(C(e,Ye)),d=L(C(e,Je));i!==void 0&&(a.minLength=i),d!==void 0&&(a.maxLength=d);let c=L(C(e,Ze)),p=L(C(e,en));c!==void 0&&(a.minInclusive=c),p!==void 0&&(a.maxInclusive=p);let f=ee(e,Qe);if(f!==void 0){let m=ee(e,Xe);a.pattern=m!==void 0?{regex:f,flags:m}:{regex:f}}if(w(e,ke)){let m=[],P=[];for(let{item:y}of me(e,ke))"literal"in y?m.push(y.value):y instanceof I&&P.push(y.subject);m.length>0&&(a.inValues=m),P.length>0&&(a.inRefs=P)}let R=h(e,Ge);R&&(a.datatype=R);let $=h(e,ze);$&&(a.classRef=$);let M=$r(h(e,cn));M&&(a.nodeKind=M);let z=h(e,xn);if(z&&(a.hasValue=z),w(e,re)||w(e,be)||w(e,Ee)){let m={},P=L(C(e,be)),y=L(C(e,Ee));P!==void 0&&(m.minCount=P),y!==void 0&&(m.maxCount=y);let K=Mr(n,e,o);"problem"in K?m.problem=K.problem:m.shape=K.shape,a.qualified=m}let Q=ee(e,nn);Q!==void 0&&(a.message=Q);let X=Mn(h(e,ye))??t;return X&&(a.severity=X),a}function Mr(n,e,t){let o=D(e,re);if(o)return $n(n,o,void 0,t);let r=h(e,re);if(!r)return{problem:"sh:qualifiedValueShape is missing"};let a=l(r);if(t.has(a))return{problem:`sh:qualifiedValueShape '${r.name}' leads back to itself (a cycle through named shapes)`};let u=_(n,r);return u?$n(n,u,a,t):{problem:`sh:qualifiedValueShape '${r.name}' does not resolve`}}function $n(n,e,t,o){let r=t?new Set([...o,t]):o,a=Z(e,H);if((Z(e,te)||w(e,Se))&&!a){let i=jn(n,e,void 0,r);return i?{shape:{kind:"property",constraint:i}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof k&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:Dn(n,e,r)}}}function Dn(n,e,t){let o=Mn(h(e,ye)),r={name:e instanceof k?e.name:"(inline shape)",uri:e instanceof k?S(e):void 0,targetClass:h(e,Te),targetNodes:O(e,on),targetSubjectsOf:O(e,tn),targetObjectsOf:O(e,rn),closed:C(e,an)===!0,ignoredProperties:[],severity:o,properties:[]};r.ignoredProperties.push(...O(e,sn));for(let{item:a}of me(e,qe)){let u;if(a instanceof v?u=a:a instanceof I&&(u=_(n,a.subject)),!u)continue;let s=jn(n,u,o,t);s&&r.properties.push(s)}return r}function se(n){let e=[];for(let t of n){if(!(t instanceof k)||!Z(t,H))continue;let o=S(t);e.push(Dn(n,t,new Set(o?[l(o)]:[])))}return e}var b="kanonak.org/transformations",G="values";var ce="allowed",Ie="expected",g=n=>({type:`${b}/VarRef`,varName:n}),ve=n=>({type:`${b}/IntegerLiteral`,integerLiteral:n}),jr=n=>({type:`${b}/DecimalLiteral`,decimalLiteral:n}),Fn=n=>Number.isInteger(n)?ve(n):jr(n),Hn=n=>({type:`${b}/Count`,source:n}),Tn=(n,e)=>({type:`${b}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),qn=(n,e)=>({type:`${b}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Le(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!t.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function ue(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Tn(Hn(g(G)),ve(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:qn(Hn(g(G)),ve(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${b}/Contains`,haystack:g(G),needle:g(Ie)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${b}/Contains`,haystack:g(ce),needle:g("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:Le(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${b}/Matches`,matchSource:g("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Tn(g("v"),Fn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:qn(g("v"),Fn(n.maxInclusive))}),e}import{evaluate as Fr,ExpressionError as Hr}from"@kanonak-protocol/expression";function Bn(n,e){let t=Tr(e)?e:se(e),o=[],r=n.catalog.filter(s=>s instanceof k).map(de),a=new Map;qr(r,a);let u={scope:n,membership:new Ve(n),embeddedFocus:a};for(let s of t)for(let i of Wr(u,s,r))zn(u,s,i,o);return{conforms:!o.some(s=>s.severity==="Violation"),results:o}}function Tr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Gn(n){let e=n.predicate;return e instanceof I?e:void 0}function de(n){return{node:n,key:Re(n),uri:S(n),label:n.name}}function Oe(n,e){return{node:n,key:e,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function qr(n,e){Ke(n.map(t=>t.node),({kanonak:t,address:o})=>{t instanceof v&&!e.has(t)&&e.set(t,Oe(t,o))})}var Ve=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,t){let o=l(t);return e.some(r=>l(r)===o||this.ancestorsOf(r).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${l(e)}@${V(e.version)}`:l(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ce(this.scope.catalog,e).map(r=>l(r))),this.ancestors.set(t,o)),o}};function Wr(n,e,t){let{scope:o}=n,r=new Map,a=s=>{r.set(s.key,s)},u=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let s=e.targetClass;if(o.reasoning){let i=new Set(o.reasoning.getInstancesOfClass(s));for(let d of t)d.uri&&i.has(l(d.uri))&&a(d)}else for(let i of t)n.membership.isInstance(A(i.node),s)&&a(i);for(let i of n.embeddedFocus.values())n.membership.isInstance(A(i.node),s)&&a(i)}for(let s of e.targetNodes){let i=_(o.catalog,s);i instanceof k&&a(de(i))}for(let s of e.targetSubjectsOf){let i=l(s);for(let d of u())d.node.statement.some(c=>{let p=Gn(c);return p&&l(p.subject)===i})&&a(d)}for(let s of e.targetObjectsOf)for(let i of u())for(let d of ie(i.node,s,o.catalog,i.key))d.kind==="subject"?a(de(d.node)):d.kind==="embedded"&&a(n.embeddedFocus.get(d.node)??Oe(d.node,d.address));return[...r.values()]}function Br(n,e,t){return e.node?ie(e.node,t,n.scope.catalog,e.key).map(o=>Gr(n,o)):[]}function Gr(n,e){switch(e.kind){case"subject":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:l(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let t=n.embeddedFocus.get(e.node)??Oe(e.node,e.address);return{kernel:{ref:t.key},kind:"embedded",embedded:t}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function zn(n,e,t,o){for(let r of e.properties)Xn(n,e,t,r,o);e.closed&&ra(e,t,o)}function Ne(n,e,t,o,r={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:a??Qn(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...r}}function Qn(n){return n.severity??"Violation"}var zr={minCount:hn,maxCount:Sn,hasValue:ae,in:gn,pattern:bn,minLength:En,maxLength:Rn,minInclusive:Cn,maxInclusive:Kn};function Xn(n,e,t,o,r){let a=Br(n,t,o.path),u=o.severity??Qn(e),s=o.path.name,i=[...(o.inValues??[]).map(c=>typeof c=="boolean"?c?1:0:c),...(o.inRefs??[]).map(c=>({ref:l(c)}))],d=(c,p,f)=>{let R=Ne(e,t,c,o.message??p,{resultPath:o.path,value:f?.literal,valueRef:f?.ref},u);return r.push(R),R};for(let c of ue(o)){let p=zr[c.component];if(c.per==="node"){let f={[G]:a.map(R=>R.kernel),[ce]:i};o.hasValue&&(f[Ie]={ref:l(o.hasValue)}),Wn(c,f)||d(p,Qr(c,s,o,a.length));continue}for(let f of a){if((c.component==="pattern"||c.component==="minLength"||c.component==="maxLength")&&f.kind!=="string"){d(p,`'${s}' value is not a string; ${c.component} applies to string values.`,f);continue}Wn(c,{v:f.kernel,[ce]:i})||d(p,ea(c,s,o,f),f)}}if(o.nodeKind)for(let c of a)na(o.nodeKind,c)||d(_n,`'${s}' value is ${c.kind}; nodeKind requires ${o.nodeKind}.`,c);if(o.datatype)for(let c of a){let p=oa(o.datatype,c);p&&d(kn,`'${s}' ${p}`,c)}if(o.classRef)for(let c of a){let p=ta(n,o.classRef,c);p&&d(yn,`'${s}' ${p}`,c)}o.qualified&&Xr(n,o,a,s,d)}function Qr(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?l(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Xr(n,e,t,o,r){let a=e.qualified,u=a.maxCount!==void 0?q:T,s=(d,c)=>{Yn.add(r(u,d,c))};if(!a.shape){s(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let i=0;for(let d of t){let c=d.ref?l(d.ref):d.embedded?d.embedded.label:JSON.stringify(d.literal),p=Yr(n,d);if(!p){s(`'${o}' value ${c} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,d);continue}let f=Zr(n,a.shape,p);if(f.kind==="undecided"){s(`'${o}' value ${c}: whether it conforms to the qualified shape cannot be decided \u2014 ${f.reason}`,d);continue}f.kind==="conforms"&&i++}a.minCount!==void 0&&i<a.minCount&&r(T,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&i>a.maxCount&&r(q,`'${o}' has ${i} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function Yr(n,e){switch(e.kind){case"reference":return e.subject?de(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Jr={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},Yn=new WeakSet;function Zr(n,e,t){let o=[];e.kind==="property"?Xn(n,Jr,t,e.constraint,o):zn(n,e.shape,t,o);let r=o.find(a=>Yn.has(a));return r?{kind:"undecided",reason:r.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function ea(n,e,t,o){let r=o.ref?l(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function Wn(n,e){let t=o=>{let r=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new Hr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Fr(n.expr,void 0,t)===1}function na(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 oa(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=_e(n);if(t!==void 0)switch(t){case N.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case N.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 N.Decimal:case N.Double:case N.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 ta(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let r=A(t.embedded.node);return r.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(r,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;if(n.scope.reasoning)return n.scope.reasoning.isInstanceOf(t.ref,e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`;let o=t.subject;return o?n.membership.isInstance(A(o),e)?void 0:`value ${l(t.ref)} is not an instance of ${e.name}.`:`value ${l(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}function ra(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(a=>l(a.path)),...n.ignoredProperties.map(a=>l(a))]),r=new Set;for(let a of e.node.statement){let u=Gn(a);if(!u)continue;let s=l(u.subject);o.has(s)||r.has(s)||(r.add(s),t.push(Ne(n,e,ge,`'${e.label}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let a of e.node.unresolvedPredicates)r.has(a.key)||(r.add(a.key),t.push(Ne(n,e,ge,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var aa="1.1.0",ia=new Set([ae,T,q].map(n=>n.name));async function Jn(n){let e=new B(n.repository),t=e.imports(),o=n.result.results.some(i=>ia.has(i.constraintComponent.name))?"1.2.0":aa,r=t.ensure(ne,oe,o,"sh"),a=(i,d)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:d,u={},s=[];return n.result.results.forEach((i,d)=>{let c=`result-${d+1}`;s.push(c);let p={type:`${r}.ValidationResult`,[`${r}.focusNode`]:a(i.focusUri,i.focusNode),[`${r}.resultMessage`]:i.message,[`${r}.resultSeverity`]:`${r}.${i.severity}`,[`${r}.sourceConstraintComponent`]:`${r}.${i.constraintComponent.name}`};i.resultPath&&(p[`${r}.resultPath`]=a(i.resultPath,l(i.resultPath))),i.sourceShapeUri&&(p[`${r}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${r}.value`]=a(i.valueRef,l(i.valueRef)):i.value!==void 0&&(p[`${r}.value`]=i.value),u[c]=p}),u.report={type:`${r}.ValidationReport`,[`${r}.conforms`]:n.result.conforms,...s.length>0?{[`${r}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:u,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as $i}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",x="view",Zn="core-kanonak",sa={publisher:E,package_:x,name:"rootView"},ca={publisher:E,package_:x,name:"bind"},ua={publisher:E,package_:x,name:"produces"},da={publisher:E,package_:x,name:"projections"},la={publisher:E,package_:x,name:"where"},pa={publisher:E,package_:x,name:"value"},fa={publisher:E,package_:x,name:"as"},le=class{constructor(e,t=new j){this.repository=e;this.parser=t;this.objectParser=new U(this.parser),this.builder=new B(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(o,e),a=h(r,ca);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let u=h(r,ua);if(!u)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=ma(r),i=eo(o,E,Zn),d=eo(o,E,x),c=this.builder.imports(),p=c.ensure(E,Zn,i,"ck"),f=c.ensure(E,x,d,"v"),R=c.ref(u),$=new Ln(this.repository,this.parser,this.objectParser),M=new In($,o),z=this.readProjections(o,r),Q=ka(r,la),X=this.findInstances(o,a,await this.reason(t)),m={},P=new Set;for(let Y of X){if(!await this.passesWhere(M,o,Q,Y))continue;let pe={type:R};for(let Ae of z){let oo=await this.evaluateValue(M,o,Ae.value,Y),Ue=this.builder.serializeValue(no(oo),c);Ue!==void 0&&(pe[c.ref(Ae.as)]=Ue)}let we=S(Y);we&&(pe[`${f}.derivedFrom`]=c.ref(we)),m[this.rowName(Y,P)]=pe}let y={};t.resolvedAt&&(y[`${p}.resolvedAt`]=t.resolvedAt),t.invocationId&&(y[`${p}.id`]=t.invocationId);let K=await this.builder.buildContentAddressed({publisher:s,book:c,body:m,contentHashProperty:`${p}.contentHash`,header:y});return{yaml:K.yaml,contentHash:K.contentHash,packageName:K.packageName,publisher:K.publisher,rowCount:K.resourceCount}}resolveView(e,t){let o=_(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let r=h(o,sa);if(r){let a=_(e,r);if(!a)throw new Error(`ViewPackage ${t.name} names rootView ${r.name}, which is not in the catalog.`);return a}return o}readProjections(e,t){let o=[];for(let r of he(t,da)){let a=r instanceof v?r:r instanceof I?_(e,r.subject):void 0;if(!a)continue;let u=D(a,pa),s=h(a,fa);u&&s&&o.push({value:u,as:s})}return o}async reason(e){return new W({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let r=Sa(e),a=[],u=new Set;for(let s of o.getInstancesOfClass(t)){if(u.has(s))continue;u.add(s);let i=r.get(s);i&&a.push(i)}return a.sort((s,i)=>{let d=F(S(s)),c=F(S(i));return d<c?-1:d>c?1:0}),a}async passesWhere(e,t,o,r){for(let a of o){let u=await this.evaluateValue(e,t,a,r);if(!ya(u))return!1}return!0}async evaluateValue(e,t,o,r){let a=vn(o,"view-projection",{catalog:t,depth:0}),u=new Map([["input",r]]);return e.evaluate(a,u)}rowName(e,t){let o=Pe(e.name)||"row",r=o,a=2;for(;t.has(r);)r=`${o}-${a++}`;return t.add(r),r}};function no(n){return xe(n)?n.value:Array.isArray(n)?n.map(no):n}function ma(n){let e=S(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function eo(n,e,t){let o=ha(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function ha(n,e,t){let o;for(let r of n){if(!(r instanceof k))continue;let a=S(r);!a||a.publisher!==e||a.package_!==t||!a.version||(!o||J(a.version,o)>0)&&(o=a.version)}return o?V(o):void 0}function Sa(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof k))continue;let r=S(o);if(!r||!r.version)continue;let a=F(r),u=t.get(a);(!u||J(r.version,u)>0)&&(t.set(a,r.version),e.set(a,o))}return e}function ka(n,e){let t=D(n,e);return t?[t]:he(n,e).filter(o=>o instanceof v)}function ya(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{Gt as AmbiguousReferenceRule,Do as BooleanStatement,Rr as CANONICAL_FORM_VERSION,N as Carrier,Zt as ClassDefinitionRule,Dt as ClassHierarchyCycleRule,ho as CompositeKanonakDocumentRepository,xr as DEFAULT_CONSENT_BINDING_PARAM,Oo as DefinedKanonak,yr as DiamondNameClashRule,nr as DisplayLensScopeRule,mo as DocumentLocation,dt as EdgeType,v as EmbeddedKanonak,$t as EmbeddedKanonakTypeRule,Ho as EmbeddedStatement,Ar as EntitlementDeniedError,Ur as EntitlementProducer,fo as FileSystemKanonakDocumentRepository,St as GitIgnoreFilter,lt as GraphBuilder,Po as HttpKanonakDocumentRepository,Me as INTEGRITY_PREFIX,Kr as ImportBook,Mt as ImportExistenceRule,fe as InMemoryKanonakDocumentRepository,yo as KANONAK_USER_AGENT,No as Kanonak,yt as KanonakDocumentPositions,U as KanonakObjectParser,gr as KanonakObjectValidator,j as KanonakParser,wo as KanonakUri,Ct as KanonakUriBuilder,Kt as KanonakUrlResolver,nt as KanonakVocabulary,sr as LINE_STYLES,Vt as LinkTargetRule,To as ListStatement,Ao as LiteralKanonak,vo as LocalFirstRepository,Io as LockAwareRepository,mr as LookBandPathRule,lr as LookRenderer,or as LookSemanticSvgPathRule,er as MarkdownLinkRule,qo as MarkdownStatement,Wt as NamespaceImportCycleRule,Nt as NamespacePrefixRule,ut as NodeType,jo as NumberStatement,Pr as OAuthDiscovery,mt as OWL_RL_CLASSIFICATION_RULES,Qt as ObjectPropertyValueValidationRule,vt as OntologyValidationError,xt as OntologyValidationResult,kr as OwlOneOfRule,B as PackageBuilder,Ut as PackageHeaderRule,Nr as ProducerRepository,Xt as PropertyDomainRule,Ft as PropertyHierarchyCycleRule,Yt as PropertyKindRangeConsistencyRule,kt as PropertyMetadata,zt as PropertyRangeReferenceRule,Ht as PropertyRangeRequiredRule,wt as PropertyTypeSpecificityRule,Ko as PublisherConfigResolver,_o as PublisherIndex,ft as RDFS_RULES,W as Reasoner,ht as ReasoningResult,I as ReferenceKanonak,Fo as ReferenceStatement,ko as RepositoryFactory,Jt as ReservedNameShadowRule,Ot as ResourceNamingRule,Wo as ResourceResolver,ot as ResourceTypeClassifier,oe as SHACL_PACKAGE,ne as SHACL_PUBLISHER,H as SH_NODE_SHAPE,te as SH_PROPERTY_SHAPE,He as SH_SHAPE,$o as ScalarStatement,fr as SequenceNarrativeRule,Sr as ShaclShapeRule,Uo as Statement,Mo as StringStatement,Tt as SubClassOfReferenceRule,qt as SubPropertyOfReferenceRule,k as SubjectKanonak,At as SubjectKanonakTypeRequiredRule,Lr as TokenCredentialProvider,pt as TripleStore,tr as TxExpressionCompilesRule,hr as TxExpressionPathRule,Bo as TypeResolver,rr as URI_DISPLAY_LABEL,ar as URI_DISPLAY_SUMMARY,Bt as UnresolvedPredicateRule,jt as UnresolvedReferenceRule,Lt as ValidationCache,It as ValidationContext,Pt as ValidationSeverity,$i as VersionOperator,le as ViewMaterializer,Or as allowAllPolicy,Eo as assertHttpsUrl,xo as assertPackageIdentity,Vo as buildLocalFirstRepository,dr as buildOntologyModel,Jn as buildReportPackageAsync,se as buildShapesModel,Zo as builtinHomePackages,et as builtinUri,br as canonicalForm,Er as canonicalHash,_e as carrierOf,Lo as collectKanonakFiles,J as compareVersions,On as computeIntegrity,Fe as computeIntegrityAsync,Cr as contentAddressedName,A as contextTypesOf,Ir as createCredentialedFetch,io as createVersion,Bn as evaluateConformance,ct as extractMarkdownLinks,Vr as findDerivation,st as findMalformedReferences,bt as findMarkdownLinkAt,Le as foldFlagsIntoPattern,zo as formatKanonakAddress,V as formatVersion,So as getGlobalCachePath,bo as getKanonakUserAgent,co as isCompatibleVersion,uo as isMajorCompatible,rt as isPropertySubject,Ro as kanonakFetch,Vn as loadLockFile,$e as lockedVersion,ue as lowerConstraint,Xo as makeUriKey,wr as noopMeter,_r as normalizeHost,vr as parseAuthChallenge,Go as parseKanonakAddress,je as parseLockFile,so as parseVersionString,gt as parseWithPositions,po as pickHighestDocument,at as propertiesInScope,tt as propertyClassOf,cr as readSequenceConnectors,_t as referenceSpelling,O as referenceUris,ir as resolveDisplayValue,it as resolvePropertyStep,Pe as sanitizeName,lo as satisfiesVersionOperator,Nn as saveLockFile,An as scopeFromCatalog,Un as scopeFromDocumentAsync,wn as scopeFromRepositoryAsync,De as serializeLockFile,Co as setKanonakFetchRetries,go as setKanonakUserAgent,Rt as sourceSymbolAt,Et as sourceSymbols,Re as subjectAddress,S as subjectUri,Ce as superClassChain,pr as supportedBandKeys,Yo as tripleKey,Qo as typeReferenceUris,F as uriKey,Jo as uriTriple,ie as valuesOf,to as versionOperatorFromChar,ro as versionOperatorToChar,ao as versionsEqual,Ke as walkDefinedKanonaks,ur as walkSequence};
@@ -39,4 +39,15 @@ export declare abstract class DefinedKanonak extends Kanonak {
39
39
  * hand-built kanonak the parser never stamped.
40
40
  */
41
41
  sourceDoc: string;
42
+ /**
43
+ * The segment of the authored YAML path at which this node sits: a subject's
44
+ * entity key exactly as authored (`Agent`, or `rdfs.Resource` for an
45
+ * open-world augmentation), or a list item's index / a dict-keyed entry's key.
46
+ * Set by the parser on every node it builds from source; absent on a node it
47
+ * synthesized, and on a single embedded value, which sits at its statement's
48
+ * own key. A parse-time fact, not part of the graph: it changes no content
49
+ * hash or serialization. Read by `sourceSymbols` to tie the object model back
50
+ * to source positions.
51
+ */
52
+ sourceKey?: string | number;
42
53
  }
@@ -35,4 +35,6 @@ export declare class LiteralKanonak extends Kanonak {
35
35
  * part of the value's canonical identity.
36
36
  */
37
37
  links?: MarkdownLink[];
38
+ /** Its authored index in the list (see `DefinedKanonak.sourceKey`). */
39
+ sourceKey?: string | number;
38
40
  }
@@ -2,5 +2,7 @@ import { Kanonak } from './Kanonak.js';
2
2
  import { KanonakUri } from '../resolution/KanonakUri.js';
3
3
  export declare class ReferenceKanonak extends Kanonak {
4
4
  subject: KanonakUri;
5
+ /** As a list item: its authored index or dict key (see `DefinedKanonak.sourceKey`). */
6
+ sourceKey?: string | number;
5
7
  static parse(subjectKanonakUri: string): ReferenceKanonak;
6
8
  }
@@ -9,6 +9,12 @@ export interface LockFile {
9
9
  lastUpdated: string;
10
10
  packages: Record<string, LockEntry>;
11
11
  }
12
+ /**
13
+ * The version a lock pins for a package, or undefined when the lock has no
14
+ * entry for it — THE lookup of a package's lock entry, so no consumer spells
15
+ * the lock's key format out.
16
+ */
17
+ export declare function lockedVersion(lock: LockFile, publisher: string, packageName: string): string | undefined;
12
18
  /**
13
19
  * The one integrity format every lock producer and consumer shares:
14
20
  * `sha256:<lowercase hex digest>` of the resource's UTF-8 bytes. Both
@@ -1,3 +1,3 @@
1
1
  export { loadLockFile, saveLockFile, computeIntegrity, } from './LockFileIO.js';
2
- export { parseLockFile, serializeLockFile, computeIntegrityAsync, INTEGRITY_PREFIX, } from './LockFile.js';
2
+ export { parseLockFile, serializeLockFile, computeIntegrityAsync, lockedVersion, INTEGRITY_PREFIX, } from './LockFile.js';
3
3
  export type { LockFile, LockEntry } from './LockFile.js';
@@ -1,5 +1,8 @@
1
1
  import type { Kanonak } from '../kanonaks/Kanonak.js';
2
2
  import type { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
3
+ import { type EntityUri } from '../uri-helpers/index.js';
4
+ export declare const URI_DISPLAY_LABEL: EntityUri;
5
+ export declare const URI_DISPLAY_SUMMARY: EntityUri;
3
6
  export interface DisplayValue {
4
7
  /** The resource's display name. Never empty — falls back to the local name. */
5
8
  label: string;
@@ -1,3 +1,3 @@
1
1
  export { LookRenderer, supportedBandKeys, type ResolvedLook, type TokenProvenance, type BaseStylesheetStatus, type StylesheetExplanation, } from './LookRenderer.js';
2
- export { resolveDisplayValue, type DisplayValue } from './displayValue.js';
2
+ export { resolveDisplayValue, URI_DISPLAY_LABEL, URI_DISPLAY_SUMMARY, type DisplayValue } from './displayValue.js';
3
3
  export { walkSequence, readSequenceSource, readSequenceConnectors, readSequenceParticipants, edgeStyleFor, hasPropertyCharacteristic, LINE_STYLES, type LineStyle, type SequenceWalk, type SequenceMessage, type SequenceGap, type SequenceConnector, } from './sequenceWalk.js';
@@ -27,3 +27,11 @@
27
27
  import type { MarkdownLink, MarkdownStatement } from '../statements/MarkdownStatement.js';
28
28
  import type { SourcePosition } from './KanonakDocumentPositions.js';
29
29
  export declare function findMarkdownLinkAt(stmt: MarkdownStatement, cursorLine: number, cursorColumn: number, valuePosition: SourcePosition, sourceText: string): MarkdownLink | undefined;
30
+ /**
31
+ * The source span of every `[[reference]]` in a prose value, in source order —
32
+ * the order the parser populated the value's resolved `links` in, so the i-th
33
+ * span belongs to the i-th link. Same source-slice approach as
34
+ * {@link findMarkdownLinkAt}. Undefined when the value's range falls outside
35
+ * `sourceText`.
36
+ */
37
+ export declare function markdownLinkSourceSpans(valuePosition: SourcePosition, sourceText: string): SourcePosition[] | undefined;
@@ -7,5 +7,7 @@ export type { SourcePosition, ImportPackageEntry } from './KanonakDocumentPositi
7
7
  export { parseWithPositions } from './parseWithPositions.js';
8
8
  export type { ParsedDocumentWithPositions } from './parseWithPositions.js';
9
9
  export { findMarkdownLinkAt } from './findMarkdownLinkAt.js';
10
+ export { sourceSymbols, sourceSymbolAt } from './sourceSymbols.js';
11
+ export type { SourceSymbol, SourceSymbolRole } from './sourceSymbols.js';
10
12
  export type { IKanonakParser } from '@kanonak-protocol/types/document/parsing';
11
13
  export type { KanonakDocument, KanonakMetadata, Namespace, Import, Version, ParseResult, ParseError } from '@kanonak-protocol/types/document/models/types';
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-YBHIELES.js";import{j as b}from"../chunk-Q2FG7DME.js";import{a}from"../chunk-HF5FJBS2.js";import"../chunk-7TU55KLO.js";import"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f,e as g,f as h}from"../chunk-GKIX3OD6.js";import{k as b}from"../chunk-22DSABP6.js";import{a}from"../chunk-7JBKOJB4.js";import"../chunk-NUTHBBDZ.js";import"../chunk-D4QGPMRW.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions,h as sourceSymbolAt,g as sourceSymbols};
@@ -0,0 +1,54 @@
1
+ import type { Kanonak } from '../kanonaks/Kanonak.js';
2
+ import type { KanonakUri } from '../resolution/KanonakUri.js';
3
+ import type { KanonakDocumentPositions, SourcePosition } from './KanonakDocumentPositions.js';
4
+ /**
5
+ * What an authored token names:
6
+ * - `subject`: an entity key — the resource the block defines, or for an
7
+ * open-world augmentation (`rdfs.Resource:`) the imported resource it
8
+ * asserts about;
9
+ * - `predicate`: a property key, at any depth;
10
+ * - `reference`: a value that references a resource — a single value, a list
11
+ * item, a dict-keyed entry, or a `[[reference]]` inside a prose value.
12
+ */
13
+ export type SourceSymbolRole = 'subject' | 'predicate' | 'reference';
14
+ /** One token of a document's source that names a resource, as the parser resolved it. */
15
+ export interface SourceSymbol {
16
+ readonly role: SourceSymbolRole;
17
+ /**
18
+ * The resource the token names: the subject's canonical URI, the property's
19
+ * URI, or the reference's target — exactly what the object model holds, so
20
+ * an alias, an open-world augmentation and a built-in all arrive resolved,
21
+ * versioned wherever the import resolved a version.
22
+ */
23
+ readonly uri: KanonakUri;
24
+ /** The token's span in the source. */
25
+ readonly range: SourcePosition;
26
+ /** The authored YAML path of the node the token belongs to. */
27
+ readonly path: ReadonlyArray<string | number>;
28
+ }
29
+ /**
30
+ * Every token in one document that names a resource, each tied to its source
31
+ * span — THE bridge from the object model to source positions, for editor
32
+ * navigation (definition, hover, references) and anything else that must
33
+ * answer "what does the text at this position name?".
34
+ *
35
+ * `authored` is the document's own pre-merge subjects: the `authored` view of
36
+ * the parse (`KanonakObjectParser.parseKanonaks(repo, out)`, or
37
+ * `ValidationCache.getAuthoredKanonaks()`) filtered by `sourceDoc` to this
38
+ * document. The merged catalog will not do — the open-world merge folds other
39
+ * documents' statements onto the same subjects. `positions` must come from
40
+ * the same source text the document was parsed from. Pass `sourceText` to
41
+ * include the `[[references]]` inside prose values.
42
+ *
43
+ * Nothing is matched by name: each node carries the key or index it was
44
+ * authored at (`sourceKey`), so a token's URI is the one the parser resolved
45
+ * for that exact node. A node the parser built from source that has no
46
+ * position is a disagreement between the two parsers, and throws.
47
+ */
48
+ export declare function sourceSymbols(authored: Kanonak[], positions: KanonakDocumentPositions, sourceText?: string): SourceSymbol[];
49
+ /**
50
+ * The symbol whose span contains the position (0-based, end-inclusive so a
51
+ * cursor just past a token still names it), the tightest when spans nest;
52
+ * undefined when the position names no resource.
53
+ */
54
+ export declare function sourceSymbolAt(symbols: readonly SourceSymbol[], line: number, column: number): SourceSymbol | undefined;
@@ -1 +1 @@
1
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-VENZTHCC.js";import"../chunk-QHABFCRC.js";import"../chunk-Q2FG7DME.js";import"../chunk-HF5FJBS2.js";import"../chunk-7TU55KLO.js";import"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
1
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-ADSDFJUO.js";import"../chunk-QHABFCRC.js";import"../chunk-22DSABP6.js";import"../chunk-7JBKOJB4.js";import"../chunk-NUTHBBDZ.js";import"../chunk-D4QGPMRW.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
@@ -1,6 +1,7 @@
1
1
  import type { KanonakUri } from '../resolution/KanonakUri.js';
2
2
  import type { Version } from '@kanonak-protocol/types/document/models/types';
3
3
  import type { Vocabulary } from './Vocabulary.js';
4
+ import type { EntityUri } from '../uri-helpers/UriHelpers.js';
4
5
  /**
5
6
  * True when `name` is a reserved built-in term (an RDF/RDFS/OWL/Kanonak
6
7
  * structural predicate, annotation, class, or datatype — see
@@ -20,6 +21,26 @@ export declare function builtinHome(name: string): {
20
21
  publisher: string;
21
22
  package_: string;
22
23
  } | undefined;
24
+ /**
25
+ * The packages that home the reserved built-in terms (core-rdf, core-owl,
26
+ * core-kanonak) — the implicit foundation every document can name without
27
+ * importing it. A consumer that must hold the documents a built-in reference
28
+ * resolves to (an editor scoping its catalog to an import closure, the
29
+ * parser stamping built-in versions) takes the list from here.
30
+ */
31
+ export declare function builtinHomePackages(): {
32
+ publisher: string;
33
+ package_: string;
34
+ }[];
35
+ /**
36
+ * The canonical URI of a reserved built-in term — `subClassOf` →
37
+ * `kanonak.org/core-rdf/subClassOf`, `ObjectProperty` →
38
+ * `kanonak.org/core-owl/ObjectProperty` — from the one table of built-in
39
+ * homes, for a consumer that reads a built-in property by identity
40
+ * (`referenceUris(subject, builtinUri('subClassOf'))`) instead of spelling
41
+ * its coordinates out. Throws for a name that is not a built-in term.
42
+ */
43
+ export declare function builtinUri(name: string): EntityUri;
23
44
  /**
24
45
  * Canonicalize a built-in URI in place against {@link BUILTIN_HOMES}.
25
46
  *
@@ -22,7 +22,7 @@ export { Reasoner } from './Reasoner.js';
22
22
  export type { ReasonerOptions, ReasoningProfile } from './Reasoner.js';
23
23
  export { ReasoningResult } from './ReasoningResult.js';
24
24
  export { TripleStore } from './TripleStore.js';
25
- export { KanonakVocabulary, canonicalizeBuiltinUri } from './KanonakVocabulary.js';
25
+ export { KanonakVocabulary, canonicalizeBuiltinUri, builtinUri, builtinHomePackages } from './KanonakVocabulary.js';
26
26
  export type { Vocabulary } from './Vocabulary.js';
27
27
  export type { Triple, TripleObject, UriKey } from './Triple.js';
28
28
  export { uriKey, makeUriKey, tripleKey, uriTriple } from './Triple.js';
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-4QXD6HKI.js";import"../chunk-Q2FG7DME.js";import"../chunk-HF5FJBS2.js";import{c as a,d as b,e as c,g as d,ha as e,ia as f}from"../chunk-7TU55KLO.js";import"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
1
+ import{a as i,b as j,c as k,d as l,e as m}from"../chunk-A3HRXFVX.js";import"../chunk-22DSABP6.js";import"../chunk-7JBKOJB4.js";import{c as a,d as b,e as c,g as d,ha as e,ia as f,ja as g,ka as h}from"../chunk-NUTHBBDZ.js";import"../chunk-D4QGPMRW.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{h as KanonakVocabulary,k as OWL_RL_CLASSIFICATION_RULES,j as RDFS_RULES,m as Reasoner,l as ReasoningResult,i as TripleStore,e as builtinHomePackages,f as builtinUri,g as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
@@ -1,6 +1,6 @@
1
1
  import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
2
  import type { KanonakDocument, Import, DocumentReference } from '@kanonak-protocol/types/document/models/types';
3
- import type { LockFile } from '../lock/LockFile.js';
3
+ import { type LockFile } from '../lock/LockFile.js';
4
4
  /**
5
5
  * A repository decorator that resolves versions through a `kanonak.lock`, so a
6
6
  * package's identity is computed over its LOCKED closure rather than a freshly
@@ -1 +1 @@
1
- import{h as e,m as r,n}from"../chunk-BZ3YTI3C.js";import"../chunk-SC5M74NM.js";import{a as o}from"../chunk-6VIUXP4N.js";import"../chunk-HF5FJBS2.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
1
+ import{h as e,n as r,o as n}from"../chunk-OOYGILH4.js";import"../chunk-SC5M74NM.js";import{a as o}from"../chunk-6VIUXP4N.js";import"../chunk-7JBKOJB4.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m,i as n}from"../chunk-IS3AQKB4.js";import{g,h,m as i,n as j}from"../chunk-BZ3YTI3C.js";import"../chunk-SC5M74NM.js";import{a}from"../chunk-6VIUXP4N.js";import"../chunk-HF5FJBS2.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,l as LockAwareRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,n as buildLocalFirstRepository,m as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m,i as n}from"../chunk-HKX27KBZ.js";import{g,h,n as i,o as j}from"../chunk-OOYGILH4.js";import"../chunk-SC5M74NM.js";import{a}from"../chunk-6VIUXP4N.js";import"../chunk-7JBKOJB4.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,l as LockAwareRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,n as buildLocalFirstRepository,m as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
@@ -1,4 +1,10 @@
1
- import type { SubjectKanonak } from '@kanonak-protocol/types/object/kanonaks/types';
1
+ import type { SubjectKanonak as SubjectKanonakShape } from '@kanonak-protocol/types/object/kanonaks/types';
2
+ import type { SubjectKanonak as ParsedSubjectKanonak } from '../kanonaks/SubjectKanonak.js';
3
+ /**
4
+ * A subject the classifier reads: the SDK's parsed `SubjectKanonak` or the
5
+ * types-package shape. Both are read the same way (their `type` statements).
6
+ */
7
+ type SubjectKanonak = SubjectKanonakShape | ParsedSubjectKanonak;
2
8
  /**
3
9
  * The canonical RDF/OWL property classes — the roots of the property
4
10
  * tree. A type is a property type when it IS one of these or descends
@@ -60,3 +66,4 @@ export declare class ResourceTypeClassifier {
60
66
  static isSchemaDefinitionType(resource: SubjectKanonak): boolean;
61
67
  static isInstanceOfKnownClass(resource: SubjectKanonak, knownClassNames: Set<string>): boolean;
62
68
  }
69
+ export {};
@@ -10,6 +10,7 @@ export { KanonakUrlResolver } from './KanonakUrlResolver.js';
10
10
  export type { UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './KanonakUrlResolver.js';
11
11
  export type { ResourceResolutionResult } from './ResourceResolutionResult.js';
12
12
  export { TypeResolver } from './TypeResolver.js';
13
+ export { referenceSpelling } from './referenceSpelling.js';
13
14
  export { propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, superClassChain, propertyClassOf, isPropertySubject, isObjectPropertySubject, isDatatypePropertySubject, } from './TypeDirectedResolver.js';
14
15
  export type { PropertyDescriptor, PropertyKind, StepResolution } from './TypeDirectedResolver.js';
15
16
  export { ResourceTypeClassifier, corePropertyClassOf } from './ResourceTypeClassifier.js';
@@ -1 +1 @@
1
- import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,ja as u,ka as v,la as w,ma as x,na as y,oa as z,pa as A,qa as B,ra as C,sa as D,ta as E}from"../chunk-7TU55KLO.js";import{p as s,q as t}from"../chunk-XNEWQEB6.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
1
+ import{a as F,b as H}from"../chunk-D2X6J77P.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,la as u,ma as v,na as w,oa as x,pa as y,qa as z,ra as A,sa as B,ta as C,ua as D,va as E}from"../chunk-NUTHBBDZ.js";import{p as s,q as t}from"../chunk-D4QGPMRW.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,H as referenceSpelling,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -0,0 +1,14 @@
1
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
2
+ import type { ResourceResolver } from './ResourceResolver.js';
3
+ import { type EntityUri } from '../uri-helpers/UriHelpers.js';
4
+ /**
5
+ * How `document` names the resource `uri` — the inverse of resolution, for a
6
+ * tool that WRITES a reference (completion, quick fixes, generators): the bare
7
+ * name for the document's own resources, `alias.name` through the import that
8
+ * brings `uri`'s package in. Every candidate is resolved back through
9
+ * `resolver` in `document`'s scope and kept only if it names exactly `uri`
10
+ * (and not ambiguously), so the result is a spelling the parser resolves to
11
+ * `uri` — never a guess. Undefined when no spelling reaches `uri` from this
12
+ * document (its package is neither the document's own nor imported).
13
+ */
14
+ export declare function referenceSpelling(uri: EntityUri, document: KanonakDocument, resolver: ResourceResolver): Promise<string | undefined>;
@@ -1,4 +1,4 @@
1
- import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-ROKDCCJN.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-Q2FG7DME.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{la as m,ta as S}from"../chunk-7TU55KLO.js";import{c as v,r as p,z as E}from"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import"../chunk-D2X6J77P.js";import"../chunk-SC5M74NM.js";import{f as g}from"../chunk-TYVZXABI.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-22DSABP6.js";import"../chunk-7JBKOJB4.js";import"../chunk-PEJALHXK.js";import{na as m,va as S}from"../chunk-NUTHBBDZ.js";import{c as v,r as p,z as E}from"../chunk-D4QGPMRW.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
2
2
  Install it with:
3
3
  npm install @huggingface/transformers
4
4
  (underlying import error: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
@@ -27,6 +27,14 @@ export interface DeriveImportClosureOptions {
27
27
  * `RenderStackReport.warnings`; silence is how typescript#91 shipped.
28
28
  */
29
29
  onUnresolvedEdge?: (edge: UnresolvedImportEdge) => void;
30
+ /**
31
+ * Called once per document the walk visits — each seed, then each resolved
32
+ * version of an import, in walk order. A caller that needs the closure's
33
+ * DOCUMENTS rather than its package keys (an editor holding exactly the
34
+ * resolved versions in memory) collects them here instead of walking the
35
+ * imports a second time.
36
+ */
37
+ onDocument?: (doc: KanonakDocument) => void;
30
38
  }
31
39
  /**
32
40
  * The transitive import closure of `seedDocs`, as a set of `publisher/package`
@@ -2,7 +2,7 @@ export { loadServerModel } from './loadServerModel.js';
2
2
  export { loadResourceModel } from './loadResourceModel.js';
3
3
  export type { LoadResourceModelOptions } from './loadResourceModel.js';
4
4
  export { route } from './route.js';
5
- export { RequestRouter, landingPage } from './requestRouter.js';
5
+ export { RequestRouter, landingPage, requestPathFor, addressForRequestPath } from './requestRouter.js';
6
6
  export type { RequestRouterOptions } from './requestRouter.js';
7
7
  export { deriveImportClosure, ClosureScopedRepository } from './closure.js';
8
8
  export type { UnresolvedImportEdge, DeriveImportClosureOptions } from './closure.js';