@kanonak-protocol/sdk 3.70.0 → 3.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/{chunk-N224PFBI.js → chunk-BGQKZBNE.js} +1 -1
- package/dist/chunk-CRKSKIAL.js +1 -0
- package/dist/{chunk-W4LPC6VM.js → chunk-F5ANO7MJ.js} +1 -1
- package/dist/{chunk-2OXZDBHX.js → chunk-FX7JDGL6.js} +1 -1
- package/dist/chunk-G2DKKSZ4.js +1 -0
- package/dist/{chunk-6T2XFOMU.js → chunk-GN2XODVC.js} +1 -1
- package/dist/{chunk-U75VPNYW.js → chunk-HAR3BNTB.js} +1 -1
- package/dist/chunk-IOMNZBK4.js +1 -0
- package/dist/{chunk-C5NKFT7W.js → chunk-MCU5IAMS.js} +24 -24
- package/dist/{chunk-EOMKFFKU.js → chunk-OFSARZX6.js} +1 -1
- package/dist/chunk-RRODBYIK.js +74 -0
- package/dist/chunk-TJPQETHV.js +1 -0
- package/dist/{chunk-7ZCFYITD.js → chunk-Y7TGQ7UF.js} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -26
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/UriHelpers.d.ts +18 -0
- package/dist/uri-helpers/index.d.ts +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/TxExpressionPathChecker.d.ts +39 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/LookSemanticSvgPathRule.d.ts +13 -23
- package/dist/validation/rules/repository/TxExpressionPathRule.d.ts +28 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/dist/view/ViewMaterializer.d.ts +71 -0
- package/dist/view/index.d.ts +2 -0
- package/package.json +2 -2
- package/dist/chunk-64TVBQFR.js +0 -1
- package/dist/chunk-ORFSMEMM.js +0 -1
- package/dist/chunk-PODBS4IU.js +0 -1
- package/dist/chunk-Q4DKP5DO.js +0 -1
- package/dist/chunk-XEFBKQY5.js +0 -64
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-
|
|
1
|
+
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-FX7JDGL6.js";import"../chunk-G2DKKSZ4.js";import"../chunk-TJPQETHV.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.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{b as e,c as r,d as n}from"../chunk-
|
|
1
|
+
import{b as e,c as r,d as n}from"../chunk-HAR3BNTB.js";import{a as o}from"../chunk-4NO7MHS7.js";import"../chunk-SC5M74NM.js";import"../chunk-TJPQETHV.js";import"../chunk-2ACBWC7K.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}from"../chunk-
|
|
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}from"../chunk-OFSARZX6.js";import{a as g,b as h,c as i,d as j}from"../chunk-HAR3BNTB.js";import{a}from"../chunk-4NO7MHS7.js";import"../chunk-SC5M74NM.js";import"../chunk-TJPQETHV.js";import"../chunk-2ACBWC7K.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,m as buildLocalFirstRepository,l as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
|
package/dist/resolution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p,b as x}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-PEJALHXK.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as o,b as q,c as r,d as t,e as u,f as v,g as w}from"../chunk-
|
|
1
|
+
import{a as p,b as x}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-PEJALHXK.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as o,b as q,c as r,d as t,e as u,f as v,g as w}from"../chunk-BGQKZBNE.js";import"../chunk-CRKSKIAL.js";import{b as m,c as n}from"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import{a as l}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2ACBWC7K.js";export{l as KanonakUri,p as KanonakUriBuilder,s as KanonakUrlResolver,m as ResourceResolver,o as ResourceTypeClassifier,n as TypeResolver,k as assertPackageIdentity,c as compareVersions,w as contextTypesOf,f as createVersion,x as findInstancesByType,r as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,i as isMajorCompatible,q as parseKanonakAddress,g as parseVersionString,j as pickHighestDocument,u as propertiesInScope,v as resolvePropertyStep,t as subjectUri,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g}from"../chunk-
|
|
1
|
+
import{a as g}from"../chunk-MCU5IAMS.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-SHDHMKMJ.js";import"../chunk-G2DKKSZ4.js";import"../chunk-TJPQETHV.js";import{d as m,g as S}from"../chunk-BGQKZBNE.js";import{a as p,f as E}from"../chunk-CRKSKIAL.js";import"../chunk-IOMNZBK4.js";import{c as v}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as x}from"../chunk-2ACBWC7K.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
|
|
2
2
|
Install it with:
|
|
3
3
|
npm install @huggingface/transformers
|
|
4
4
|
(underlying import error: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as O}from"../chunk-
|
|
1
|
+
import{j as O}from"../chunk-MCU5IAMS.js";import"../chunk-QHABFCRC.js";import{a as z,d as j,f as Z,g as V}from"../chunk-OFSARZX6.js";import{a as Q,b as X,c as F,d as I}from"../chunk-HAR3BNTB.js";import{a as J}from"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import{a as te}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-SHDHMKMJ.js";import{f as N}from"../chunk-G2DKKSZ4.js";import{a as K}from"../chunk-TJPQETHV.js";import{b as L}from"../chunk-BGQKZBNE.js";import"../chunk-CRKSKIAL.js";import"../chunk-IOMNZBK4.js";import{c as ee}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as C,g as Y}from"../chunk-2ACBWC7K.js";import{readFileSync as ce,existsSync as le,readdirSync as pe,writeFileSync as ue,mkdirSync as de}from"fs";import{join as W}from"path";function re(a){let e=a.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function A(a,e){let r=new Set,t=[...a];for(;t.length>0;){let n=t.shift(),u=re(n);if(!u||r.has(u))continue;r.add(u);let d=n.metadata?.imports;if(d)for(let[i,g]of Object.entries(d))for(let f of g)try{let p=await e.getHighestCompatibleVersionAsync(i,f);p&&t.push(p)}catch{}}return r}var D=class{constructor(e,r){this.inner=e;this.scope=r}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(r=>{let t=re(r);return t!==void 0&&this.scope.has(t)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){return this.inner.getDocumentsByNamespaceAsync(e,r)}getHighestCompatibleVersionAsync(e,r){return this.inner.getHighestCompatibleVersionAsync(e,r)}saveDocumentAsync(e,r){return this.inner.saveDocumentAsync(e,r)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,r){return this.inner.clearNamespaceAsync(e,r)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var ne=[{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 M(a){let e=a?.render;if(e&&e.length>0){let r=[];for(let t of e)try{let n=L(t);n.kind==="package"?r.push({publisher:n.publisher,package_:n.package_}):n.kind==="resource"&&r.push({publisher:n.uri.publisher,package_:n.uri.package_})}catch{}if(r.length>0)return r}return ne}function B(a){return`${a.publisher}/${a.package_}`}function E(a){let{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d}=a,i=new Map,g=new Map,f=new Map,p=new Set;for(let o of t){if(!(o instanceof ee))continue;let m=o.namespace||"";if(!u.has(m))continue;i.set(`${m}/${o.name}`,o);let k=m.split("/")[1]??"",[v,$]=k.split("@");if(!v||!$)continue;let c=Y($);c&&(p.has(k)||(p.add(k),g.has(v)||g.set(v,[]),g.get(v).push({verStr:$,version:c})),o.name===v&&f.set(k,o))}for(let o of g.values())o.sort((m,k)=>C(k.version,m.version));return{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d,bySubject:i,pkgVersions:g,pkgSelfByVer:f}}async function H(a,e={}){let r=new K,t=new J(r),n=[],u=[];for(let c of V(a)){let R;try{R=ce(c,"utf-8")}catch{continue}let b;try{b=r.parse(R).metadata?.namespace_}catch{continue}if(!b?.version)continue;let x=b.version;u.push({publisher:b.publisher,package_:b.package_,verStr:`${x.major}.${x.minor}.${x.patch}`,version:x,source:R})}u.sort((c,R)=>C(R.version,c.version));for(let c of u)await t.saveDocumentAsync(r.parse(c.source),`${c.publisher}/${c.package_}@${c.verStr}`),n.push({publisher:c.publisher,package_:c.package_,verStr:c.verStr,source:c.source});let d=[...new Set(n.map(c=>c.publisher))].sort(),i=e.publisher;if(i){if(!d.includes(i))throw new Error(`Publisher "${i}" not found in workspace. Available: ${d.join(", ")||"(none)"}`)}else if(d.length===1)i=d[0];else throw d.length===0?new Error(`No Kanonak packages found under ${a}`):new Error(`Workspace has multiple publishers (${d.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let g=new Set,f=new Map;for(let c of n)c.publisher===i&&(g.add(`${c.publisher}/${c.package_}@${c.verStr}`),f.set(`${c.package_}@${c.verStr}`,c.source));let p=new z(j(),!0,r),o=e.repository??new Z(t,p,new I(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),m=M(void 0);if(!e.repository){let c=j(),R=s=>{let h=W(c,s);return le(h)?new Set(pe(h).filter(y=>y.endsWith(".kan.yml")).map(y=>y.split("@")[0])):new Set},b=(s,h)=>n.some(y=>y.publisher===s&&y.package_===h),x=new F,l=new Map;for(let s of m)if(l.has(s.publisher)||l.set(s.publisher,R(s.publisher)),!(l.get(s.publisher).has(s.package_)||b(s.publisher,s.package_)))try{let h=await x.getHighestVersion(s.publisher,s.package_);if(!h)continue;let y=await x.getPackageUrl(s.publisher,s.package_,h),P=await fetch(y);if(!P.ok)continue;let ie=await P.text(),G=W(c,s.publisher);de(G,{recursive:!0}),ue(W(G,`${s.package_}@${h}.kan.yml`),ie,"utf-8")}catch{}}let k=o;if(!e.repository){let c=(await t.getAllDocumentsAsync()).filter(b=>b.metadata.namespace_?.publisher===i),R=await A(c,o);for(let b of m)R.add(B(b));k=new D(o,R)}let v=await new N(r).parseKanonaks(k),$=new O(v);return E({publisher:i,availablePublishers:d,catalog:v,lookRenderer:$,localNamespaces:g,rawByNsKey:f})}import{existsSync as me,readFileSync as ge,writeFileSync as fe,mkdirSync as he}from"fs";import{join as oe}from"path";async function q(a,e={}){let r=new K,t=L(a),n=t.kind==="resource"?t.uri.publisher:t.publisher,u=e.cacheRoot??j(),d=(l,s,h)=>oe(u,l,`${s}@${h}.kan.yml`),i=new I({getFromCache:(l,s,h)=>{let y=d(l,s,h);return me(y)?ge(y,"utf-8"):null},onFetch:(l,s,h,y)=>{let P=oe(u,l);he(P,{recursive:!0}),fe(d(l,s,h),y,"utf-8")},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new F(e.fetchFn?{fetchFn:e.fetchFn}:void 0),f;if(t.kind==="resource"){let l=t.uri.version;f=[l?{package_:t.uri.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.uri.package_}]}else if(t.kind==="package"){let l=t.version;f=[l?{package_:t.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.package_}]}else f=(await g.listLatestPackages(n)).map(s=>({package_:s.packageName}));let p=async(l,s,h)=>{try{let y=h?r.buildImport(s,"=",h,l):r.buildImport(s,"*","0.0.0",l);return await i.getHighestCompatibleVersionAsync(l,y)}catch{return null}},o=[];for(let l of f){let s=await p(n,l.package_,l.version);s&&o.push(s)}if(o.length===0)throw new Error(`Could not fetch any package for address "${a}" from publisher "${n}".`);let m=await new X().getConfig(n).catch(()=>{}),k=[];for(let l of M(m)){let s=await p(l.publisher,l.package_,void 0);s&&k.push(s)}let v=await A([...o,...k],i),$=new D(i,v),c=await new N(r).parseKanonaks($),R=new O(c),b=new Set,x=new Map;for(let l of await i.getAllDocumentsAsync()){let s=l.metadata.namespace_;if(!s||s.publisher!==n)continue;let h=`${s.version.major}.${s.version.minor}.${s.version.patch}`,y=`${s.publisher}/${s.package_}@${h}`;b.add(y);let P=await i.getDocumentContentAsync(y);P!==null&&x.set(`${s.package_}@${h}`,P)}return E({publisher:n,availablePublishers:[n],catalog:c,lookRenderer:R,localNamespaces:b,rawByNsKey:x})}var w={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},S=(a,e,r,t)=>({status:a,headers:{"Content-Type":e,...t||{}},body:r}),_=a=>S(404,w[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${a}</p>`),ke=a=>({status:301,headers:{Location:a},body:""});function se(a,e,r){let t=a.pkgVersions.get(e);if(!t||t.length===0)return null;switch(r.kind){case"any":return t[0].verStr;case"major-pin":return t.find(n=>n.version.major===r.major)?.verStr??null;case"minor-pin":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor)?.verStr??null;case"exact":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor&&n.version.patch===r.patch)?.verStr??null;default:return null}}async function T(a,e,r=""){let{lookRenderer:t,publisher:n}=a;if(e==="/.well-known/kanonak.json")return S(200,w[".json"],JSON.stringify(Q(n),null,2));if(e==="/index.txt"){let o=[...a.localNamespaces].map(m=>m.split("/")[1].replace("@","/")).sort();return S(200,w[".txt"],o.join(`
|
|
2
2
|
`)+`
|
|
3
3
|
`)}if(e==="/"||e==="/index.html"||e==="/index.css"){let o=t.publisherSubject(n);return e==="/index.css"?S(200,w[".css"],t.renderStylesheet(o)):S(200,w[".html"],t.renderDocument(o,{rootIndex:!0}))}let u=".html",d=!1,i=e;for(let o of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(o)){u=o,d=!0,i=e.slice(0,-o.length);break}let g=!d&&/application\/yaml|text\/yaml/i.test(r),f=i.endsWith("/");f&&i!=="/"&&(i=i.slice(0,-1));let p=te.parse(i,n);if(!p)return _(e);if(p.kind==="package"){let o=se(a,p.package_,p.versionSpec);if(!o)return _(e);if(u===".kan.yml"||g){let v=a.rawByNsKey.get(`${p.package_}@${o}`);return v!==void 0?S(200,w[".kan.yml"],v):_(e)}let m=a.pkgSelfByVer.get(`${p.package_}@${o}`);if(!m)return _(e);if(u===".css")return S(200,w[".css"],t.renderStylesheet(m));if(!f)return ke(i+"/");let k=p.versionSpec.kind==="any";if(k&&!t.hasDeclaredView(m)){let v=(a.pkgVersions.get(p.package_)||[]).map($=>$.verStr);return S(200,w[".html"],t.renderPackageVersionList(p.package_,v,m))}return S(200,w[".html"],t.renderDocument(m,k?{bareOverview:!0}:void 0))}if(p.kind==="resource"){let o=se(a,p.package_,p.versionSpec);if(!o)return _(e);let m=a.bySubject.get(`${n}/${p.package_}@${o}/${p.name}`);if(!m)return _(e);switch(u){case".css":return S(200,w[".css"],t.renderStylesheet(m));case".svg":return S(200,w[".svg"],await t.renderSvg(m));case".md":{let k=t.renderRawMarkdown(m);return k===void 0?_(e):S(200,w[".md"],k)}default:return S(200,w[".html"],t.renderDocument(m))}}return _(e)}import{readFileSync as ye}from"fs";var U=class{constructor(e={}){this.options=e}options;models=new Map;workspaceIndex;clearCache(){this.models.clear(),this.workspaceIndex=void 0}getWorkspaceIndex(){if(this.workspaceIndex)return this.workspaceIndex;let e=new Set,r=new Set;if(this.options.root!==void 0){let t=new K;for(let n of V(this.options.root))try{let u=t.parse(ye(n,"utf-8")).metadata?.namespace_;if(!u?.version)continue;let d=u.version;e.add(`${u.publisher}/${u.package_}@${d.major}.${d.minor}.${d.patch}`),r.add(`${u.publisher}/${u.package_}`)}catch{}}return this.workspaceIndex={exact:e,pkgs:r},this.workspaceIndex}async modelFor(e,r,t){let n=this.getWorkspaceIndex(),u=this.options.fetchFn?{fetchFn:this.options.fetchFn}:{},d=r?t?n.exact.has(`${e}/${r}@${t}`):n.pkgs.has(`${e}/${r}`):[...n.pkgs].some(o=>o.startsWith(`${e}/`)),i,g;if(d&&this.options.root!==void 0){let o=this.options.root;i=`ws:${e}`,g=()=>H(o,{publisher:e})}else{let o=r?t?`${e}/${r}@${t}`:`${e}/${r}`:e;i=`rm:${o}`,g=()=>q(o,u)}let f=this.models.get(i);if(f)return f;let p=await g();return p.lookRenderer.setLinkMode("open-world"),this.models.set(i,p),p}async handle(e,r=""){let t=e.split("/").filter(Boolean);if(t.length===0)return{status:200,headers:{"Content-Type":"text/html; charset=utf-8"},body:ae()};let n=t[0];if(!n.includes("."))return{status:404,headers:{"Content-Type":"text/html; charset=utf-8"},body:"<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Expected a publisher domain as the first path segment: <code>/{publisher}/{package}/{version}/{resource}</code></p>"};let u=t.length>=2&&(t[1]==="index.html"||t[1]==="index.css"||t[1]==="index.txt"||t[1]===".well-known"),d=!u&&t.length>=2?t[1]:void 0,i=!u&&t.length>=3&&/^\d+\.\d+\.\d+$/.test(t[2])?t[2]:void 0,g=await this.modelFor(n,d,i),f=e.endsWith("/")&&t.length>1?"/":"",p="/"+t.slice(1).join("/")+f,o=await T(g,p,r);return o.headers.Location?{...o,headers:{...o.headers,Location:`/${n}${o.headers.Location}`}}:o}};function ae(){return'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Kanonak origin</title></head><body style="font-family:system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem"><h1>Kanonak request-driven origin</h1><p>Open a resource by its address:</p><p><code>/{publisher}/{package}/{version}/{resource}</code></p><p>e.g. <code>/kanonak.org/capabilities/2.0.0/Capability</code></p></body></html>'}export{D as ClosureScopedRepository,U as RequestRouter,ne as UNIVERSAL_RENDER_BASE,A as deriveImportClosure,ae as landingPage,q as loadResourceModel,H as loadServerModel,B as renderRefKey,M as resolveRenderContract,T as route};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as Y,c as An,d as Sn,e as ce,f as Te,g as O,h as wn,i as X,j as q}from"../chunk-
|
|
1
|
+
import{b as Y,c as An,d as Sn,e as ce,f as Te,g as O,h as wn,i as X,j as q}from"../chunk-MCU5IAMS.js";import{a as se}from"../chunk-F5ANO7MJ.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-GN2XODVC.js";import"../chunk-PEJALHXK.js";import{a as kn,b as bn,c as hn,d as Dn}from"../chunk-SHDHMKMJ.js";import{f as ie}from"../chunk-G2DKKSZ4.js";import{a as ae}from"../chunk-TJPQETHV.js";import{b as L,c as A,f as S}from"../chunk-CRKSKIAL.js";import"../chunk-IOMNZBK4.js";import{b as N,c as D,d as K,g as M,h as P,i as F,j as W,l as H}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{g as oe}from"../chunk-2ACBWC7K.js";var $e="kanonak.org",Ue="document-ast",i=e=>({publisher:$e,package_:Ue,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 ue(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var j=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=xe(n.metadata,t),o=Le(n.children),s=["---",...r,"---","",o].join(`
|
|
2
2
|
`);return t?.trailingNewline&&(s.endsWith(`
|
|
3
3
|
`)||(s+=`
|
|
4
4
|
`)),s}};function xe(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(I(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(I(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(I),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=I(f??c),d=me(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function I(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function me(e,n){switch(e.kind){case"StringScalar":return Ve(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=me(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function Ve(e,n){return!n||ue(n,m.ESC_RAW)?e:ue(n,m.ESC_YAML_SAFE)?ve(e):e}function ve(e){return e.includes(`
|
|
@@ -86,6 +86,24 @@ export declare function findSubjectsByType(kanonaks: Kanonak[], target: EntityUr
|
|
|
86
86
|
* bare-name references in single-version workspaces, etc).
|
|
87
87
|
*/
|
|
88
88
|
export declare function findSubjectByUri(kanonaks: Kanonak[], uri: KanonakUri): SubjectKanonak | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Every version of a subject present in the catalog, matched by canonical
|
|
91
|
+
* URI (publisher/package/name, version-agnostic), HIGHEST VERSION FIRST.
|
|
92
|
+
*
|
|
93
|
+
* This is THE single place the "newest wins" multi-version rule lives, so
|
|
94
|
+
* every cascade that takes the first match (semanticSvg, tokens, the type
|
|
95
|
+
* chain, path/traversal resolution) resolves to the newest version's
|
|
96
|
+
* open-world augmentation — an archived older version can never shadow the
|
|
97
|
+
* current one — and all environments (serve, publish, validate, the VS Code
|
|
98
|
+
* server, the transformation engine) render identically without each
|
|
99
|
+
* reimplementing (or forgetting) the load-order sort. Do not duplicate this:
|
|
100
|
+
* import it.
|
|
101
|
+
*/
|
|
102
|
+
export declare function findAllResourcesByCanonicalUri(catalog: Kanonak[], uri: {
|
|
103
|
+
publisher: string;
|
|
104
|
+
package_: string;
|
|
105
|
+
name: string;
|
|
106
|
+
}): SubjectKanonak[];
|
|
89
107
|
/**
|
|
90
108
|
* Read a datatype property value (string, number, boolean) off a defined
|
|
91
109
|
* kanonak, by property URI. Returns `undefined` when the property is not
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { uriKey, uriMatches, toCanonicalUrl, hasType, findSubjectsByType, findSubjectByUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
|
|
1
|
+
export { uriKey, uriMatches, toCanonicalUrl, hasType, 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,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../chunk-CRKSKIAL.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{m as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,h as getDatatypeValue,k as getEmbeddedValue,l as getListValues,j as getReferenceUri,i as getStringValue,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Kanonak } from '../kanonaks/Kanonak.js';
|
|
2
|
+
import { EmbeddedKanonak } from '../kanonaks/EmbeddedKanonak.js';
|
|
3
|
+
import { type EntityUri } from '../uri-helpers/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* One out-of-scope path step found while walking a `tx.Expression` tree.
|
|
6
|
+
* `contextClass` is the type the step was read against (the View's bound
|
|
7
|
+
* class for a top-level read, or an intermediate type reached after one
|
|
8
|
+
* or more traversals); `propertyUri` is the offending property; `via`
|
|
9
|
+
* records which step kind referenced it.
|
|
10
|
+
*/
|
|
11
|
+
export interface TxPathFailure {
|
|
12
|
+
contextClass: EntityUri;
|
|
13
|
+
propertyUri: EntityUri;
|
|
14
|
+
via: 'PropertyRead' | 'Traverse';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Walk a `tx.Expression` tree and report every `tx.PropertyRead` /
|
|
18
|
+
* `tx.Traverse` step whose property is not in scope for the type it is
|
|
19
|
+
* read against. The bound instance is available as the `input` binding,
|
|
20
|
+
* typed `rootContext`. Context advances through each resolved property's
|
|
21
|
+
* declared `range`, so multi-step paths (a `tx.Traverse` whose `step`
|
|
22
|
+
* reads a property off the traversed-to subject, or a `tx.PropertyRead`
|
|
23
|
+
* whose `readSource` is itself a read) are validated step-by-step.
|
|
24
|
+
*
|
|
25
|
+
* This is the canonical path-chain checker behind both
|
|
26
|
+
* `LookSemanticSvgPathRule` (context = the class a `look.semanticSvg` is
|
|
27
|
+
* declared on) and `TxExpressionPathRule` (context = a `view.View`'s
|
|
28
|
+
* `view.bind`). It resolves every property through the object model via
|
|
29
|
+
* `resolvePropertyStep`, never by local name.
|
|
30
|
+
*
|
|
31
|
+
* Scope notes: a `VarRef` to any name other than a known class-typed
|
|
32
|
+
* binding (e.g. the pre-computed `label`/`uri` env strings, or an
|
|
33
|
+
* iterator's element variable) yields an unknown type, so reads rooted at
|
|
34
|
+
* it are left unchecked rather than falsely flagged — the same
|
|
35
|
+
* conservative stance the engine takes at render time. Traversing a step
|
|
36
|
+
* whose range is a datatype is not yet rejected here (the "can't traverse
|
|
37
|
+
* past a literal" refinement); only out-of-scope properties are reported.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkTxExpressionPaths(catalog: Kanonak[], rootContext: EntityUri, expr: EmbeddedKanonak): TxPathFailure[];
|
|
@@ -8,4 +8,4 @@ export { KanonakObjectValidator } from './KanonakObjectValidator.js';
|
|
|
8
8
|
export type { IDocumentValidationRule } from './rules/document/IDocumentValidationRule.js';
|
|
9
9
|
export type { IRepositoryValidationRule } from './rules/repository/IRepositoryValidationRule.js';
|
|
10
10
|
export { NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule } from './rules/document/index.js';
|
|
11
|
-
export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule } from './rules/repository/index.js';
|
|
11
|
+
export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, TxExpressionPathRule } from './rules/repository/index.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,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-RRODBYIK.js";import"../chunk-SHDHMKMJ.js";import"../chunk-G2DKKSZ4.js";import"../chunk-TJPQETHV.js";import"../chunk-BGQKZBNE.js";import"../chunk-CRKSKIAL.js";import"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,D as DisplayLensScopeRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,G as KanonakObjectValidator,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,F as TxExpressionPathRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
|
|
@@ -4,33 +4,23 @@ import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
|
4
4
|
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
5
5
|
import type { ValidationCache } from '../../ValidationCache.js';
|
|
6
6
|
/**
|
|
7
|
-
* Validates that `tx.PropertyRead`
|
|
8
|
-
* tier fragments reference properties in scope for the
|
|
9
|
-
* the SemanticSvg is declared. When a tier authored on
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
* Validates that `tx.PropertyRead` / `tx.Traverse` steps inside
|
|
8
|
+
* `look.semanticSvg` tier fragments reference properties in scope for the
|
|
9
|
+
* class on which the SemanticSvg is declared. When a tier authored on
|
|
10
|
+
* class C reads property P off the rendered instance, P's domain must
|
|
11
|
+
* cover C (the class itself, an ancestor, or rdfs.Resource); otherwise
|
|
12
|
+
* the read silently returns undefined at render time and the tier's
|
|
13
|
+
* substitution leaks empty.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* PropertyReads in other `tx.Expression`-ranged contexts (e.g.
|
|
21
|
-
* `tx.Transformation.rule`) are out of scope here; the generalized
|
|
22
|
-
* chain walker will cover them.
|
|
15
|
+
* The path walk is the shared, context-advancing
|
|
16
|
+
* `checkTxExpressionPaths` — the same engine `TxExpressionPathRule` uses
|
|
17
|
+
* for `view.View` projections. This rule only supplies the look-specific
|
|
18
|
+
* root context (the declaring class) and the look-specific diagnostic
|
|
19
|
+
* wording.
|
|
23
20
|
*/
|
|
24
21
|
export declare class LookSemanticSvgPathRule implements IRepositoryValidationRule {
|
|
25
22
|
readonly ruleName = "LookSemanticSvgPath";
|
|
26
23
|
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
27
24
|
private checkSemanticSvg;
|
|
28
|
-
|
|
29
|
-
* Recursively walk an Expression embed, checking PropertyReads and
|
|
30
|
-
* descending into known nesting properties. Unknown Expression kinds
|
|
31
|
-
* are still recursed via every embedded child so we don't miss reads
|
|
32
|
-
* inside future Expression subclasses.
|
|
33
|
-
*/
|
|
34
|
-
private walkExpression;
|
|
35
|
-
private checkPropertyRead;
|
|
25
|
+
private toError;
|
|
36
26
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
3
|
+
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
4
|
+
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
5
|
+
import type { ValidationCache } from '../../ValidationCache.js';
|
|
6
|
+
/**
|
|
7
|
+
* Validates the projection paths of a `view.View` against its bound
|
|
8
|
+
* class. A View declares `view.bind` (its context class) and a list of
|
|
9
|
+
* `view.Projection`s whose `view.value` is a `tx.Expression` computed
|
|
10
|
+
* against each bound instance, plus optional `view.where` predicate
|
|
11
|
+
* expressions. Every `tx.PropertyRead` / `tx.Traverse` step inside those
|
|
12
|
+
* expressions must reference a property in scope for the type it is read
|
|
13
|
+
* against (the bound class, or an intermediate type reached by an earlier
|
|
14
|
+
* traversal) — otherwise the read silently returns undefined when the
|
|
15
|
+
* View materializes.
|
|
16
|
+
*
|
|
17
|
+
* Shares the context-advancing path walker with `LookSemanticSvgPathRule`
|
|
18
|
+
* (`checkTxExpressionPaths`); the only difference is the root context —
|
|
19
|
+
* here the View's `view.bind`, there the class a `look.semanticSvg` is
|
|
20
|
+
* declared on. The generalized form tracked in typescript#48.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TxExpressionPathRule implements IRepositoryValidationRule {
|
|
23
|
+
readonly ruleName = "TxExpressionPath";
|
|
24
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
25
|
+
private checkView;
|
|
26
|
+
private asError;
|
|
27
|
+
private toError;
|
|
28
|
+
}
|
|
@@ -21,3 +21,4 @@ export { EmbeddedKanonakTypeRule } from './EmbeddedKanonakTypeRule.js';
|
|
|
21
21
|
export { MarkdownLinkRule } from './MarkdownLinkRule.js';
|
|
22
22
|
export { DisplayLensScopeRule } from './DisplayLensScopeRule.js';
|
|
23
23
|
export { LookSemanticSvgPathRule } from './LookSemanticSvgPathRule.js';
|
|
24
|
+
export { TxExpressionPathRule } from './TxExpressionPathRule.js';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import { KanonakParser } from '../parsing/KanonakParser.js';
|
|
3
|
+
import { type EntityUri } from '../uri-helpers/index.js';
|
|
4
|
+
export interface MaterializeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* ISO-8601 timestamp recorded as the EphemeralPackage's `resolvedAt`.
|
|
7
|
+
* The SDK never reads the clock itself (it would make results
|
|
8
|
+
* non-deterministic and untestable); the caller supplies it. Omitted →
|
|
9
|
+
* no `resolvedAt` is written. It lives on the header, outside the hashed
|
|
10
|
+
* body, so two identical runs still share a content hash.
|
|
11
|
+
*/
|
|
12
|
+
resolvedAt?: string;
|
|
13
|
+
/** Optional per-invocation id recorded as `id` (also header-only). */
|
|
14
|
+
invocationId?: string;
|
|
15
|
+
/** Reasoning profile used to find instances of `bind`. */
|
|
16
|
+
reasoningProfile?: 'rdfs' | 'owl-rl-classification';
|
|
17
|
+
}
|
|
18
|
+
export interface MaterializeResult {
|
|
19
|
+
/** The EphemeralPackage as `.kan.yml` text. */
|
|
20
|
+
yaml: string;
|
|
21
|
+
/** `sha256:` content hash of the body (the `ck.contentHash` value). */
|
|
22
|
+
contentHash: string;
|
|
23
|
+
/** Address-safe package name (`q-<hex16>`), derived from the hash. */
|
|
24
|
+
packageName: string;
|
|
25
|
+
/** Publisher the EphemeralPackage is minted under (the View's publisher). */
|
|
26
|
+
publisher: string;
|
|
27
|
+
/** Number of result instances produced. */
|
|
28
|
+
rowCount: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The in-graph producer for the View Language. Given a `view.View` (or a
|
|
32
|
+
* `view.ViewPackage` whose `rootView` is one), it resolves the View
|
|
33
|
+
* against the local catalog and materializes the result as a versionless
|
|
34
|
+
* `EphemeralPackage`:
|
|
35
|
+
*
|
|
36
|
+
* 1. find every instance of the View's `bind` class (subclass-aware,
|
|
37
|
+
* via the reasoner);
|
|
38
|
+
* 2. keep those for which every `where` predicate holds;
|
|
39
|
+
* 3. for each, mint one `produces` instance whose properties are the
|
|
40
|
+
* projections (`value` evaluated against the instance, stored under
|
|
41
|
+
* `as`), plus a `view.derivedFrom` reference back to the stable
|
|
42
|
+
* source — a reference, never a copy;
|
|
43
|
+
* 4. wrap the instances in an EphemeralPackage whose import closure makes
|
|
44
|
+
* the shape self-describing, with a content-hash identity.
|
|
45
|
+
*
|
|
46
|
+
* This is one producer behind a producer-agnostic contract: a backend
|
|
47
|
+
* binding (Polygon, DynamoDB, …) fulfils the same View by emitting the
|
|
48
|
+
* same EphemeralPackage shape. Selection views (no `produces`) are not yet
|
|
49
|
+
* materialized here and fail visibly rather than guessing a shape.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ViewMaterializer {
|
|
52
|
+
private readonly repository;
|
|
53
|
+
private readonly parser;
|
|
54
|
+
private readonly objectParser;
|
|
55
|
+
constructor(repository: IKanonakDocumentRepository, parser?: KanonakParser);
|
|
56
|
+
materialize(viewRef: EntityUri, opts?: MaterializeOptions): Promise<MaterializeResult>;
|
|
57
|
+
private resolveView;
|
|
58
|
+
private readProjections;
|
|
59
|
+
private reason;
|
|
60
|
+
private findInstances;
|
|
61
|
+
private passesWhere;
|
|
62
|
+
private evaluateValue;
|
|
63
|
+
private rowName;
|
|
64
|
+
/**
|
|
65
|
+
* Content hash of the body, independent of the EphemeralPackage's own
|
|
66
|
+
* (not-yet-assigned) name. Parses the rows under a fixed probe header,
|
|
67
|
+
* neutralizes each body subject's namespace to a constant, and hashes —
|
|
68
|
+
* so the same projected data always yields the same `sha256:`.
|
|
69
|
+
*/
|
|
70
|
+
private hashBody;
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.71.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",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"yaml-parser"
|
|
123
123
|
],
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"@kanonak-protocol/types": "^3.
|
|
125
|
+
"@kanonak-protocol/types": "^3.71.0",
|
|
126
126
|
"ignore": "^7.0.5",
|
|
127
127
|
"js-yaml": "^4.1.0",
|
|
128
128
|
"yaml": "^2.7.0"
|
package/dist/chunk-64TVBQFR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-FUUTGGJS.js";function K(n){if(Array.isArray(n))return n.map(t=>t?.toString()??"").filter(t=>t.length>0);let e=n?.toString();return e?[e]:[]}var S=class{cache=new Map;repository;logger;constructor(e,t){this.repository=e,this.logger=t}async resolveEntityAsync(e,t){let a=t.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(a);if(s){let p=s.get(e);if(p)return p}let r=await this.buildEntityIndexAsyncInternal(t,new Set,"");return this.cache.set(a,r),r.get(e)??null}async resolveAllEntitiesAsync(e,t){let a=await this.buildAllEntitiesIndexAsync(t,new Set,"");if(e.includes(".")){let s=e.split("."),r=s[0],p=s[1],g=await this.findDocumentForAlias(t,r);return g?await this.resolveAllEntitiesAsync(p,g):[]}return a.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,t,a){let s=[],r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),s;t.add(r);let p=a.length===0?r:`${a} \u2192 ${r}`;for(let[g,i]of Object.entries(e.body))if(!g.includes(".")&&i&&typeof i=="object"&&!Array.isArray(i)){let u=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:g,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,g,u),entity:i,definedInNamespace:r,isImported:a.length>0,importPath:p})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${r}`),e.metadata?.imports){let g=Object.values(e.metadata.imports).reduce((i,u)=>i+u.length,0);this.logger?.debug?.(`Processing ${g} import(s) for ${r}`);for(let[i,u]of Object.entries(e.metadata.imports))for(let f of u)try{this.logger?.debug?.(`Resolving import: ${i}/${f.packageName}`);let y=await this.repository.getHighestCompatibleVersionAsync(i,f);if(y){this.logger?.debug?.(`Successfully loaded import: ${y.metadata?.namespace_?.toString()}`);let m=await this.buildAllEntitiesIndexAsync(y,t,p);s.push(...m),this.logger?.debug?.(`Added ${m.length} entities from import ${y.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${i}/${f.packageName}`)}catch(y){let m=y;throw this.logger?.error?.(`Failed to process import ${i}/${f.packageName} for namespace ${r}. Error: ${m.message}`,m),new Error(`Failed to process import ${i}/${f.packageName} for namespace ${r}. See inner exception for details.`,{cause:y})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"")}async buildEntityIndexAsyncInternal(e,t,a){let s=new Map,r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),s;t.add(r);let p=a.length===0?r:`${a} \u2192 ${r}`,g=0;for(let[i,u]of Object.entries(e.body))if(!i.includes(".")&&u&&typeof u=="object"&&!Array.isArray(u)&&!s.has(i)){let f=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.set(i,{entityName:i,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,i,f),entity:u,definedInNamespace:r,isImported:a.length>0,importPath:p}),g++}if(this.logger?.debug?.(`Indexed ${g} entities from ${r}`),e.metadata?.imports){let i=Object.values(e.metadata.imports).reduce((u,f)=>u+f.length,0);this.logger?.debug?.(`Processing ${i} import(s) for ${r}`);for(let[u,f]of Object.entries(e.metadata.imports))for(let y of f)try{this.logger?.debug?.(`Resolving import: ${u}/${y.packageName}`);let m=await this.repository.getHighestCompatibleVersionAsync(u,y);if(m){this.logger?.debug?.(`Successfully loaded import: ${m.metadata?.namespace_?.toString()}`);let A=await this.buildEntityIndexAsyncInternal(m,t,p),$=0;for(let[R,h]of A.entries()){let b=s.get(R);if(!b)s.set(R,h),$++;else if(b.isImported&&h.isImported&&(b.uri.publisher!==h.uri.publisher||b.uri.package_!==h.uri.package_)){let k=b.isAmbiguous?b:{...b,isAmbiguous:!0,ambiguousNamespaces:[b.definedInNamespace]};k.ambiguousNamespaces.includes(h.definedInNamespace)||k.ambiguousNamespaces.push(h.definedInNamespace),s.set(R,k),this.logger?.warn?.(`Ambiguous reference '${R}': defined in ${k.ambiguousNamespaces.join(", ")}`)}if(y.alias&&!R.includes(".")){let k=`${y.alias}.${R}`;s.has(k)||(s.set(k,h),$++)}}this.logger?.debug?.(`Merged ${$} entities from import ${m.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${u}/${y.packageName}`)}catch(m){let A=m;throw this.logger?.error?.(`Failed to process import ${u}/${y.packageName} for namespace ${r}. Error: ${A.message}`,A),new Error(`Failed to process import ${u}/${y.packageName} for namespace ${r}. See inner exception for details.`,{cause:m})}}return s}async findDocumentForAlias(e,t){if(!e.metadata?.imports)return null;for(let[a,s]of Object.entries(e.metadata.imports))for(let r of s){if(r.alias===t)return await this.repository.getHighestCompatibleVersionAsync(a,r);if(!r.alias&&r.packageName===t)return await this.repository.getHighestCompatibleVersionAsync(a,r)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}async isSubclassOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubclassOfRecursiveAsync(e,t,a,s)}async isSubclassOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let r=await this.resolveEntityAsync(e,a);if(!r?.entity)return!1;let p=r.entity.subClassOf;if(p){let g=K(p);for(let i of g)if(i===t||await this.isSubclassOfRecursiveAsync(i,t,a,s))return!0}return!1}async isSubpropertyOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubpropertyOfRecursiveAsync(e,t,a,s)}async isSubpropertyOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let r=await this.resolveEntityAsync(e,a);if(!r?.entity)return!1;let p=r.entity.subPropertyOf;if(p){let g=K(p);for(let i of g)if(i===t||await this.isSubpropertyOfRecursiveAsync(i,t,a,s))return!0}return!1}};var v=class n{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","bool","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&n.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let t=e.includes(".")?e.split(".")[1]:e;return n.KNOWN_XSD_DATATYPES.has(t.toLowerCase())}async isClassTypeAsync(e,t){if(this.isKnownXsdDatatypeName(e))return!1;let a=await this.resourceResolver.resolveEntityAsync(e,t);if(a){let s=a.entity.type;if(s){let r=String(s);return r==="Class"||r==="rdfs.Class"||r.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,t){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(t)||e==="Property"&&this.isLiteralType(t))}isEffectiveObjectProperty(e,t){return!!(e==="ObjectProperty"||e==="Property"&&t&&!this.isXsdDatatype(t)&&!this.isLiteralType(t))}};function T(n){return`${n.publisher}/${n.package_}/${n.name}`}function c(n,e,t){return`${n}/${e}/${t}`}function L(n){return`${n.s}|${n.p}|${O(n.o)}`}function O(n){switch(n.kind){case"uri":return`u:${n.key}`;case"literal":return`l:${n.datatype}:${n.lexical}`;case"blank":return`b:${n.id}`}}function N(n,e,t){return{s:n,p:e,o:{kind:"uri",key:t}}}var l="kanonak.org",o="core-rdf",d="core-owl",D="core-kanonak",_=new Map([["type",o],["subClassOf",o],["subPropertyOf",o],["domain",o],["range",o],["label",o],["comment",o],["seeAlso",o],["isDefinedBy",o],["member",o],["Resource",o],["Class",o],["Property",o],["Datatype",o],["Literal",o],["List",o],["ObjectProperty",d],["DatatypeProperty",d],["AnnotationProperty",d],["Thing",d],["Nothing",d],["Package",D]]),x=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function F(n,e){if(!n||!n.name)return;let t=_.get(n.name);if(t){if(x.has(n.name)){n.publisher=l,n.package_=t;return}n.publisher===l&&n.package_===t||n.publisher&&n.publisher.length>0&&(!e||e(n))||(n.publisher=l,n.package_=t)}}var w=class{type=c(l,o,"type");subClassOf=c(l,o,"subClassOf");subPropertyOf=c(l,o,"subPropertyOf");domain=c(l,o,"domain");range=c(l,o,"range");label=c(l,o,"label");comment=c(l,o,"comment");resource=c(l,o,"Resource");class_=c(l,o,"Class");datatype=c(l,o,"Datatype");literal=c(l,o,"Literal");equivalentClass=c(l,d,"equivalentClass");equivalentProperty=c(l,d,"equivalentProperty");inverseOf=c(l,d,"inverseOf");sameAs=c(l,d,"sameAs");transitiveProperty=c(l,d,"TransitiveProperty");symmetricProperty=c(l,d,"SymmetricProperty");objectProperty=c(l,d,"ObjectProperty");datatypeProperty=c(l,d,"DatatypeProperty");annotationProperty=c(l,d,"AnnotationProperty");package_=c(l,D,"Package")};export{K as a,S as b,v as c,T as d,c as e,L as f,O as g,N as h,F as i,w as j};
|
package/dist/chunk-ORFSMEMM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as y,b as g}from"./chunk-2ACBWC7K.js";import*as h from"js-yaml";var k=class{parse(e){let t=this.parseWithErrors(e);if(!t.isValid){let a=t.errors[0];throw new Error(`YAML parse error at line ${a.line}, column ${a.column}: ${a.message}`)}return t.document}parseWithErrors(e){let t=[],a;try{e=e.replace(/^\uFEFF/,"");let s=h.load(e);if(!s||typeof s!="object")return a={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:a,errors:t,isValid:!0};let r=this.extractMetadata(s),n=this.extractBody(s,r);return a={metadata:r,body:n,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:a,errors:t,isValid:!0}}catch(s){let r=s,n={message:r.message||"Unknown parse error",line:r.mark?.line??0,column:r.mark?.column??0,errorType:r.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${r.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${r.mark?.line??0}: ${r.message||"Unknown parse error"}`};return t.push(n),{document:void 0,errors:t,isValid:!1}}}save(e){let t={};if(e.metadata.namespace_){let a=e.metadata.namespace_,s={type:"Package",publisher:a.publisher};a.version&&(s.version=`${a.version.major}.${a.version.minor}.${a.version.patch}`),e.metadata.imports&&(s.imports=this.serializeImports(e.metadata.imports)),t[a.package_]=s}return Object.assign(t,e.body),h.dump(t,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(e){let t=e.imports;return Object.defineProperty(e,"allImports",{get:function(){if(!t)return[];let a=[];for(let s of Object.values(t))a.push(...s);return a},enumerable:!0,configurable:!0}),e}createVersion(e,t,a){return{major:e,minor:t,patch:a,toString:()=>`${e}.${t}.${a}`,equals:r=>!r||typeof r!="object"?!1:r.major===e&&r.minor===t&&r.patch===a,getHashCode:()=>e<<20|t<<10|a,compareTo:r=>e!==r.major?e-r.major:t!==r.minor?t-r.minor:a-r.patch}}extractMetadata(e){let t=this.createEmptyMetadata();for(let[a,s]of Object.entries(e))if(s&&typeof s=="object"&&s.type==="Package"){t.type_="Package";let r=a,n=s.publisher,i=s.version?this.parseVersion(s.version):void 0;return n&&r&&(t.namespace_={publisher:n,package_:r,version:i,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:o=>!o||typeof o!="object"?!1:o.publisher===n&&o.package_===r&&(!i||!o.version||i.equals(o.version)),getHashCode:()=>{let o=0;for(let c=0;c<n.length;c++)o=(o<<5)-o+n.charCodeAt(c);for(let c=0;c<r.length;c++)o=(o<<5)-o+r.charCodeAt(c);return o|0}}),s.imports&&Array.isArray(s.imports)&&(t.imports=this.parseImportsV3(s.imports)),this.addAllImportsGetter(t)}if(e.kanonak&&typeof e.kanonak=="object"){let a=e.kanonak;return(a.publisher||a.package||a.version)&&(t.namespace_=this.parseNamespace(a)),a.imports&&typeof a.imports=="object"&&(t.imports=this.parseImportsLegacy(a.imports)),this.addAllImportsGetter(t)}return t}extractBody(e,t){let a={};for(let[s,r]of Object.entries(e))if(!(s==="kanonak"||s==="namespace"||s==="imports"))if(r&&typeof r=="object"&&r.type==="Package"){let n={};for(let[i,o]of Object.entries(r))i==="publisher"||i==="version"||i==="imports"||(n[i]=o);a[s]=n}else a[s]=r;return a}parseNamespace(e){if(typeof e=="string"){let r=e.match(/^([^/]+)\/([^@]+)(?:@(.+))?$/);if(r){let n=r[3]?this.parseVersion(r[3]):this.createVersion(1,0,0);return{publisher:r[1],package_:r[2],version:n,toString:()=>e,equals:i=>!i||typeof i!="object"?!1:i.publisher===r[1]&&i.package_===r[2]&&(!n||!i.version||n.equals(i.version)),getHashCode:()=>{let i=0;for(let o=0;o<r[1].length;o++)i=(i<<5)-i+r[1].charCodeAt(o);for(let o=0;o<r[2].length;o++)i=(i<<5)-i+r[2].charCodeAt(o);return i|0}}}}let t=e.publisher||"",a=e.package||"",s=e.version?this.parseVersion(e.version):this.createVersion(1,0,0);return{publisher:t,package_:a,version:s,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:r=>!r||typeof r!="object"?!1:r.publisher===t&&r.package_===a&&(!s||!r.version||s.equals(r.version)),getHashCode:()=>{let r=0;for(let n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n);for(let n=0;n<a.length;n++)r=(r<<5)-r+a.charCodeAt(n);return r|0}}}parseVersion(e){if(typeof e=="string"){let t=e.split(".").map(Number);return this.createVersion(t[0]||0,t[1]||0,t[2]||0)}return this.createVersion(e.major||0,e.minor||0,e.patch||0)}parseImportsV3(e){let t={};for(let a of e)if(!(!a||typeof a!="object"))if(a.packages&&Array.isArray(a.packages)){let s=a.publisher;if(!s)throw new Error("PublisherImport requires 'publisher' property");t[s]||(t[s]=[]);for(let r of a.packages){if(!r||typeof r!="object")continue;let n=this.parseImportFromEmbeddedObject(r,s);t[s].push(n)}}else{let s=this.parseImportFromEmbeddedObject(a,a.publisher),r=s.publisher||"";t[r]||(t[r]=[]),t[r].push(s)}return t}parseImportsLegacy(e){let t={};for(let[a,s]of Object.entries(e))Array.isArray(s)&&(t[a]=s.map(r=>this.parseImport(r,a)));return t}parseImportFromEmbeddedObject(e,t){let a=e.package;if(!a)throw new Error("Import requires 'package' property");let s=e.match;if(!s)throw new Error("Import requires 'match' property");let r=e.version;if(!r)throw new Error("Import requires 'version' property");let n=this.parseVersion(r),i=this.parseVersionOperator(s),o=this.calculateMaxVersion(s,n),c=e.alias;return{package_:`${a} ${s} ${n.toString()}`,publisher:t,packageName:a,versionOperator:i,version:n,alias:c,minVersion:n,maxVersion:o,toEmbeddedObject:()=>{let m={package:a,match:s,version:n.toString()};return c&&(m.alias=c),m},toString:()=>c?`${a} ${s} ${n.toString()} as ${c}`:`${a} ${s} ${n.toString()}`}}buildImport(e,t,a,s){return this.parseImport({packageName:e,operator:t,version:a},s)}parseImport(e,t){if(typeof e=="string"){let o=e.match(/^(.+?)\s*([~^=*])\s*(\S+)\s+as\s+(\S+)$/);if(o){let m=o[1].trim(),u=o[2],p=this.parseVersion(o[3].trim()),l=o[4].trim(),d=this.parseVersionOperator(u),v=this.calculateMaxVersion(u,p);return{package_:e,publisher:t,packageName:m,versionOperator:d,version:p,alias:l,minVersion:p,maxVersion:v,toEmbeddedObject:()=>{let f={package:m,match:u,version:p.toString()};return l&&(f.alias=l),f},toString:()=>`${m} ${u} ${p.toString()} as ${l}`}}let c=e.match(/^(.+?)\s*([~^=*])\s*(.+)$/);if(c){let m=c[1].trim(),u=c[2],p=this.parseVersion(c[3].trim()),l=this.parseVersionOperator(u),d=this.calculateMaxVersion(u,p);return{package_:e,publisher:t,packageName:m,versionOperator:l,version:p,alias:void 0,minVersion:p,maxVersion:d,toEmbeddedObject:()=>({package:m,match:u,version:p.toString()}),toString:()=>`${m} ${u} ${p.toString()}`}}}let a=this.parseVersionOperator(e.operator||"~"),s=this.parseVersion(e.version||"1.0.0"),r=e.packageName||e.package||"",n=g(a),i=this.calculateMaxVersion(e.operator||"~",s);return{package_:e.package||"",publisher:t,packageName:r,versionOperator:a,version:s,alias:e.alias,minVersion:s,maxVersion:i,toEmbeddedObject:()=>{let o={package:r,match:n,version:s.toString()};return e.alias&&(o.alias=e.alias),o},toString:()=>`${r} ${n} ${s.toString()}`}}parseVersionOperator(e){return y(e)}calculateMaxVersion(e,t){switch(e){case"~":return this.createVersion(t.major,t.minor+1,0);case"^":return t.major===0?this.createVersion(0,t.minor+1,0):this.createVersion(t.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(e){let t=[];for(let[a,s]of Object.entries(e)){let r={publisher:a,packages:s.map(n=>{let i=g(n.versionOperator),o={package:n.packageName,match:i,version:`${n.version.major}.${n.version.minor}.${n.version.patch}`};return n.alias&&(o.alias=n.alias),o})};t.push(r)}return t}};export{k as a};
|
package/dist/chunk-PODBS4IU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E}from"./chunk-ORFSMEMM.js";import{b as $,c as _,i as M}from"./chunk-64TVBQFR.js";import{a as L,b as N,c as j,d as g,g as S,h as D,i as O,j as P,k as w,l as K}from"./chunk-W6T7MOKY.js";var b=class extends N{name};var R=class extends L{value};var I=class extends S{links=[]};var B=/\[\[([^\[\]\n]+)\]\]/g,z=/\[\[/g,V=/```[\s\S]*?```|`[^`\n]*`/g;function U(c){let e=[];for(let t of c.matchAll(V))e.push([t.index,t.index+t[0].length]);return e}function Q(c){if(!c||!c.includes("[["))return[];let e=U(c),t=o=>e.some(([n,s])=>o>=n&&o<s),r=new Set(T(c).map(o=>o.startOffset)),a=[];for(let o of c.matchAll(z)){let n=o.index;if(t(n)||r.has(n))continue;let s=c.slice(n,n+48).replace(/\s+/g," ").trim();a.push({startOffset:n,snippet:s})}return a}function T(c){if(!c||!c.includes("[["))return[];let e=[];for(let a of c.matchAll(V))e.push([a.index,a.index+a[0].length]);let t=a=>e.some(([o,n])=>a>=o&&a<n),r=[];for(let a of c.matchAll(B)){let o=a.index;if(t(o))continue;let n=a[1],s=n.indexOf("|"),p=(s===-1?n:n.slice(0,s)).trim();if(p.length===0)continue;let m=s===-1?"":n.slice(s+1).trim(),f={reference:p,startOffset:o,endOffset:o+a[0].length};m.length>0&&(f.displayText=m),r.push(f)}return r}var C=class{constructor(e){}async parseKanonaks(e){let t=[],r=await e.getAllDocumentsAsync(),a=new $(e),o=new _(a);for(let i of r){let u=i.metadata.namespace_?.toString()??"";for(let[y,l]of Object.entries(i.body)){let k=new j,d=this.resolveCanonicalEntity(y,i,u);k.namespace=d.namespace,k.name=d.name,k.statement=[];let h=await this.parseStatements(l,i,a,o,e);k.statement.push(...h),t.push(k)}}let n=new Map,s=new Map,p=[];for(let i of t)if(i instanceof j){let u=`${i.namespace}/${i.name}`,y=n.get(u);if(y){let l=s.get(u);for(let k of i.statement){let d=v(k);l.has(d)||(l.add(d),y.statement.push(k))}}else{let l=new Set,k=[];for(let d of i.statement){let h=v(d);l.has(h)||(l.add(h),k.push(d))}i.statement=k,s.set(u,l),n.set(u,i),p.push(i)}}else p.push(i);let m=new Set;for(let i of p)if(i instanceof j){let u=i.namespace||"",y=u.indexOf("/"),l=y>=0?u.slice(0,y):"",k=y>=0?u.slice(y+1):"",d=k.indexOf("@"),h=d>=0?k.slice(0,d):k;m.add(`${l}/${h}/${i.name}`)}let f=i=>m.has(`${i.publisher}/${i.package_}/${i.name}`);for(let i of p)i instanceof j&&this.canonicalizeStatementBuiltins(i.statement,f);return p}canonicalizeStatementBuiltins(e,t){for(let r of e){let a=r.predicate?.subject;if(M(a,t),r instanceof P)r.object instanceof g&&M(r.object.subject,t);else if(r instanceof w)r.object&&this.canonicalizeStatementBuiltins(r.object.statement,t);else if(r instanceof K)for(let o of r.object??[])o instanceof g?M(o.subject,t):o instanceof b&&this.canonicalizeStatementBuiltins(o.statement,t)}}resolveCanonicalEntity(e,t,r){if(!e.includes(".")||!t.metadata?.imports)return{namespace:r,name:e};let a=e.indexOf("."),o=e.substring(0,a),n=e.substring(a+1);for(let[s,p]of Object.entries(t.metadata.imports))for(let m of p)if((m.alias??m.packageName)===o){let i=m.version;return{namespace:`${s}/${m.packageName}@${i.major}.${i.minor}.${i.patch}`,name:n}}return{namespace:r,name:e}}async parseStatements(e,t,r,a,o){let n=[];if(typeof e!="object"||e===null||Array.isArray(e))return n;for(let[s,p]of Object.entries(e))try{let m=await this.getPropertyMetadata(s,t,r,o,a);if(!m)continue;let f=await this.parsePropertyValue(s,p,m,t,r,a);f&&n.push(f)}catch(m){console.error(`Error parsing property ${s}:`,m)}return n}async getPropertyMetadata(e,t,r,a,o){let n=await r.resolveEntityAsync(e,t);if(!n)return;let s=n.entity,p=s.type?.toString()??"",m=p.includes(".")?p.substring(p.lastIndexOf(".")+1):p;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(m))return;let i=o.getPropertyTypeClassification(p),u=s.range?.toString(),y;if(i==="ObjectProperty")y="ObjectProperty";else if(i==="DatatypeProperty")y="DatatypeProperty";else{let d=u&&u.includes(".")?u.substring(u.lastIndexOf(".")+1):u??"";(u?o.isKnownXsdDatatypeName(u):!1)||d==="Literal"?y="DatatypeProperty":y="ObjectProperty"}let l;if(u){let d=t;if(n.isImported&&n.definedInNamespace&&typeof a.getDocumentAsync=="function"){let x=await a.getDocumentAsync(n.definedInNamespace);x&&(d=x)}l=(await r.resolveEntityAsync(u,d))?.uri}return{propertyUri:n.uri.toString(),propertyType:y,range:u,rangeUri:l,isImported:n.isImported,definedInNamespace:n.definedInNamespace}}async parsePropertyValue(e,t,r,a,o,n){let s=r.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(s,t,r,a,o,n);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(s,t,r,a,o,n);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(s,t,r,a,o,n)}}async parseDatatypeValue(e,t,r,a,o,n){if(t instanceof Date)return S.parse(e,t.toISOString());if(typeof t=="string")return n.isSubstitutableDatatype(r.rangeUri)?await this.parseSubstitutableValue(e,t,a,o):S.parse(e,t);if(typeof t=="number")return D.parse(e,t);if(typeof t=="boolean"){let s=new O;return s.predicate=g.parse(e),s.object=t,s}}async parseSubstitutableValue(e,t,r,a){let o=new I;o.predicate=g.parse(e),o.object=t;for(let n of T(t)){let s=await a.resolveEntityAsync(n.reference,r),p;s&&(p=new g,p.subject=s.uri);let m={reference:n.reference,startOffset:n.startOffset,endOffset:n.endOffset};n.displayText!==void 0&&(m.displayText=n.displayText),p!==void 0&&(m.target=p),o.links.push(m)}return o}async parseObjectValue(e,t,r,a,o,n){if(typeof t=="string"){let s=await this.resolveReference(t,a,o);if(!s)return;let p=new P;return p.predicate=g.parse(e),p.object=s,p}if(typeof t=="object"&&!Array.isArray(t)){let s=new b;if(s.statement=await this.parseStatements(t,a,o,n,{}),s.statement.length>0){let f=new w;return f.predicate=g.parse(e),f.object=s,f}let p=[];for(let[f,i]of Object.entries(t))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let u=new b;u.name=f,u.statement=await this.parseStatements(i,a,o,n,{}),p.push(u)}else if(typeof i=="string"){let u=await this.resolveReference(i,a,o);u&&p.push(u)}if(p.length>0){let f=new K;return f.predicate=g.parse(e),f.object=p,f}let m=new w;return m.predicate=g.parse(e),m.object=s,m}}async parseListValue(e,t,r,a,o,n){let s=[],p=r.propertyType==="DatatypeProperty";for(let f of t){if(p&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean")){let i=new R;i.value=f,s.push(i);continue}if(p&&f instanceof Date){let i=new R;i.value=f.toISOString(),s.push(i);continue}if(typeof f=="string"){let i=await this.resolveReference(f,a,o);i&&s.push(i)}else if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let i=new b;i.statement=await this.parseStatements(f,a,o,n,{}),s.push(i)}}let m=new K;return m.predicate=g.parse(e),m.object=s,m}async resolveReference(e,t,r){let a=await r.resolveEntityAsync(e,t);if(a){let n=new g;return n.subject=a.uri,n}let o=t.metadata?.namespace_;if(o){let{KanonakUri:n}=await import("./KanonakUri-4VJGV3FN.js"),s=o.version??{major:0,minor:0,patch:0,toString:()=>"0.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};if(e.includes(".")){let m=e.indexOf("."),f=e.substring(0,m),i=e.substring(m+1);if(t.metadata?.imports){for(let[u,y]of Object.entries(t.metadata.imports))for(let l of y)if((l.alias??l.packageName)===f){let d=new g;return d.subject=new n(u,l.packageName,i,l.version),d}}}let p=new g;return p.subject=new n(o.publisher,o.package_,e,s),p}return null}async saveKanonaks(e,t){let r=new Map;for(let a of e)a instanceof j&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,o]of r){let n=await this.convertKanonaksToDocument(a,o),s=`${a.split("@")[0]}.yml`;await t.saveDocumentAsync(n,s)}}async serializeToYaml(e,t){let r=e.filter(n=>n instanceof j&&n.namespace===t);if(r.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let a=await this.convertKanonaksToDocument(t,r);return new E().save(a)}async convertKanonaksToDocument(e,t){let a={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let n=[];for(let s of Object.values(this.imports))n.push(...s);return n}},body:{}},o=new Map;for(let n of t){let s={};for(let p of n.statement){let[m,f]=this.convertStatementToProperty(p);m&&f!==null&&f!==void 0&&(s[m]=f),this.collectImportsFromStatement(p,e,o)}a.body[n.name]=s}return a}convertStatementToProperty(e){if(e instanceof S)return[e.predicate.subject.name,e.object];if(e instanceof D)return[e.predicate.subject.name,e.object];if(e instanceof O)return[e.predicate.subject.name,e.object];if(e instanceof P)return[e.predicate.subject.name,e.object.subject.name];if(e instanceof K){let t=this.convertKanonakListToValue(e.object);return[e.predicate.subject.name,t]}else if(e instanceof w){let t=this.convertEmbeddedKanonakToValue(e.object);return[e.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(e){let t=[];for(let r of e)r instanceof g?t.push(r.subject.name):r instanceof b&&t.push(this.convertEmbeddedKanonakToValue(r));return t}convertEmbeddedKanonakToValue(e){let t={};for(let r of e.statement){let[a,o]=this.convertStatementToProperty(r);a&&o!==null&&o!==void 0&&(t[a]=o)}return t}collectImportsFromStatement(e,t,r){}};function v(c){let e=c.predicate?.subject;return(e?`${e.publisher}/${e.package_}/${e.name}`:"?")+"="+X(c)}function X(c){return c instanceof I?"m:"+String(c.object):c instanceof S?"s:"+String(c.object):c instanceof D?"n:"+String(c.object):c instanceof O?"b:"+String(c.object):c instanceof P?"r:"+A(c.object):c instanceof w?"e:"+A(c.object):c instanceof K?"l:["+(c.object??[]).map(A).join("|")+"]":"x"}function A(c){if(!c)return"";if(c instanceof g){let e=c.subject;return"R("+(e?`${e.publisher}/${e.package_}/${e.name}`:"")+")"}return c instanceof b?"E("+(c.statement??[]).map(v).join(";")+")":c instanceof R?"L("+String(c.value)+")":"N"}export{b as a,R as b,I as c,Q as d,T as e,C as f};
|
package/dist/chunk-Q4DKP5DO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as f,c as i,g as p,h as d,i as y,j as s,k as l,l as g}from"./chunk-W6T7MOKY.js";function K(t){return`${t.publisher}/${t.package_}/${t.name}`}function c(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function D(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 b(t,e){if(!(t instanceof f))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof s){let r=n.object;if(c(r.subject,e))return!0}return!1}function h(t,e){let n=[];for(let o of t)o instanceof i&&b(o,e)&&n.push(o);return n}function S(t,e){let n=e.version,o=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let r of t){if(!(r instanceof i)||r.name!==e.name)continue;let u=r.namespace||"";if(o!==void 0){if(u===o)return r}else if(u.startsWith(`${e.publisher}/${e.package_}@`))return r}}function a(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&c(o.subject,e))return n}}function k(t,e){let n=a(t,e);if(n&&(n instanceof p||n instanceof d||n instanceof y))return n.object}function j(t,e){let n=k(t,e);return typeof n=="string"?n:void 0}function U(t,e){let n=a(t,e);if(n instanceof s)return n.object.subject}function E(t,e){let n=a(t,e);if(n instanceof l)return n.object}function $(t,e){let n=a(t,e);return n instanceof g?n.object??[]:[]}var m=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{K as a,c as b,D as c,b as d,h as e,S as f,k as g,j as h,U as i,E as j,$ as k,m as l};
|