@kanonak-protocol/sdk 3.69.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-4NO7MHS7.js +1 -0
- package/dist/{chunk-N224PFBI.js → chunk-BGQKZBNE.js} +1 -1
- package/dist/chunk-CRKSKIAL.js +1 -0
- package/dist/chunk-F5ANO7MJ.js +1 -0
- package/dist/chunk-FX7JDGL6.js +1 -0
- package/dist/chunk-G2DKKSZ4.js +1 -0
- package/dist/{chunk-7JZUJ2K4.js → chunk-GN2XODVC.js} +1 -1
- package/dist/chunk-HAR3BNTB.js +2 -0
- package/dist/chunk-IOMNZBK4.js +1 -0
- package/dist/chunk-MCU5IAMS.js +148 -0
- package/dist/chunk-OFSARZX6.js +1 -0
- package/dist/chunk-RRODBYIK.js +74 -0
- package/dist/chunk-SHDHMKMJ.js +1 -0
- package/dist/chunk-TJPQETHV.js +1 -0
- package/dist/chunk-Y7TGQ7UF.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -26
- package/dist/look/LookRenderer.d.ts +29 -1
- 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 +2 -2
- package/dist/server/route.d.ts +1 -1
- package/dist/transformations/index.js +47 -47
- package/dist/transformations/v3/CompiledTransformationV3.d.ts +6 -2
- package/dist/transformations/v3/ExpressionEngineV3.d.ts +13 -1
- package/dist/transformations/v3/TransformationLoaderV3.d.ts +19 -2
- package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +5 -0
- 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 +26 -0
- package/dist/validation/rules/repository/TxExpressionPathRule.d.ts +28 -0
- package/dist/validation/rules/repository/index.d.ts +2 -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-767XYRNU.js +0 -1
- package/dist/chunk-CA2EATJR.js +0 -1
- package/dist/chunk-FXKT6OI4.js +0 -148
- package/dist/chunk-H2LEQLVD.js +0 -1
- package/dist/chunk-KSTGTV35.js +0 -2
- package/dist/chunk-OIVACCMQ.js +0 -59
- package/dist/chunk-ORFSMEMM.js +0 -1
- package/dist/chunk-Q4DKP5DO.js +0 -1
- package/dist/chunk-Q6QTQWR2.js +0 -1
- package/dist/chunk-QHJ6EY3Y.js +0 -1
- package/dist/chunk-RSIZQAFL.js +0 -2
- /package/dist/{chunk-3NEUHF7E.js → chunk-QHABFCRC.js} +0 -0
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{
|
|
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
|
-
`)}if(e==="/"||e==="/index.html"||e==="/index.css"){let o=t.publisherSubject(n);return e==="/index.css"?
|
|
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};
|
package/dist/server/route.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ import type { ServerModel, RouteResponse } from './types.js';
|
|
|
9
9
|
* sources are preloaded in the model. `accept` disambiguates the no-extension
|
|
10
10
|
* case (raw package YAML vs HTML).
|
|
11
11
|
*/
|
|
12
|
-
export declare function route(model: ServerModel, pathname: string, accept?: string): RouteResponse
|
|
12
|
+
export declare function route(model: ServerModel, pathname: string, accept?: string): Promise<RouteResponse>;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
`);return
|
|
3
|
-
`)||(
|
|
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-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
|
+
`);return t?.trailingNewline&&(s.endsWith(`
|
|
3
|
+
`)||(s+=`
|
|
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(`
|
|
5
5
|
`)?`|-
|
|
6
|
-
${
|
|
7
|
-
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(
|
|
6
|
+
${e.replace(/\n/g,`
|
|
7
|
+
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function Le(e){let n=[];for(let t of e){let r=J(t);r&&n.push(r)}return n.join(`
|
|
8
8
|
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function
|
|
11
|
-
`)?r.push(`${
|
|
12
|
-
${
|
|
9
|
+
`)}function J(e){switch(e.kind){case"Heading":return`${"#".repeat(e.level)} ${_(e.inlines)}`;case"Paragraph":return _(e.inlines);case"RawBlock":return e.rawContent;case"PropertyList":return de(e);case"Table":return Oe(e);default:return""}}function Oe(e){let n=e.tableColumnLabels??[],t=e.tableRows??[];if(n.length===0&&t.length===0)return"";let r=`| ${n.map(G).join(" | ")} |`,o=`| ${n.map(()=>"---").join(" | ")} |`,a=t.map(s=>`| ${(s.tableCells??[]).map(Ie).join(" | ")} |`);return[r,o,...a].join(`
|
|
10
|
+
`)}function Ie(e){let n=e;return!n||typeof n!="object"||!n.kind?"":n.kind==="Text"||n.kind==="ResourceLink"||n.kind==="Badge"?G(_([n])):G(J(n).replace(/\n+/g," "))}function G(e){return e==null?"":String(e).replace(/\|/g,"\\|")}function de(e,n=0){if(!e.propertyEntries||e.propertyEntries.length===0)return"";let t=" ".repeat(n),r=[];for(let o of e.propertyEntries){let a=`${t}**${o.propertyKey}:**`,s=_e(o.propertyValue,n+1);s.includes(`
|
|
11
|
+
`)?r.push(`${a}
|
|
12
|
+
${s}`):r.push(`${a} ${s}`)}return r.join(`
|
|
13
13
|
|
|
14
|
-
`)}function
|
|
14
|
+
`)}function _e(e,n){if(!e||e.length===0)return"";let t=[],r=[];for(let o of e){let a=o;!a||typeof a!="object"||!a.kind||(a.kind==="Text"||a.kind==="ResourceLink"||a.kind==="Badge"?t.push(_([a])):a.kind==="PropertyList"?r.push(de(a,n)):r.push(J(a)))}return r.length===0?t.join(""):t.length===0?r.join(`
|
|
15
15
|
|
|
16
|
-
`):`${
|
|
16
|
+
`):`${t.join("")}
|
|
17
17
|
|
|
18
18
|
${r.join(`
|
|
19
19
|
|
|
20
|
-
`)}`}function
|
|
21
|
-
`);return
|
|
22
|
-
`)||(
|
|
23
|
-
`)),
|
|
24
|
-
${
|
|
25
|
-
"""`}var
|
|
20
|
+
`)}`}function _(e){let n=[];for(let t of e)t.kind==="Text"?n.push(t.text):t.kind==="ResourceLink"?n.push(Re(t)):t.kind==="Badge"&&n.push(Ce(t));return n.join("")}function Re(e){let n=le(e.target);if(!n)return e.linkLabel??"[unresolved link]";let t=A(n),r=e.linkLabel&&e.linkLabel.length>0?e.linkLabel:n.name,o=e.linkTooltip?` "${fe(e.linkTooltip)}"`:"";return`[${r}](${t}${o})`}function Ce(e){if(!e.badgeTarget)return`*${e.badgeLabel}*`;let n=le(e.badgeTarget);if(!n)return`*${e.badgeLabel}*`;let t=A(n),r=e.badgeTooltip?` "${fe(e.badgeTooltip)}"`:"";return`*[${e.badgeLabel}](${t}${r})*`}function fe(e){return e==null?"":String(e).replace(/"/g,'\\"')}function le(e){if(!e||typeof e!="object")return;let n=e;if(n.subject&&n.subject.publisher&&n.subject.package_&&n.subject.name){let r={publisher:n.subject.publisher,package_:n.subject.package_,name:n.subject.name};return n.subject.version&&(r.version=n.subject.version),r}let t=e;if(typeof t.namespace=="string"&&typeof t.name=="string"&&t.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(t.namespace);if(r)return{publisher:r[1],package_:r[2],name:t.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function Ne(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var E=class{backendUri="kanonak.org/transformations/toml";render(n,t){let o=Ke(n.metadata,t).join(`
|
|
21
|
+
`);return t?.trailingNewline&&(o.endsWith(`
|
|
22
|
+
`)||(o+=`
|
|
23
|
+
`)),o}};function Ke(e,n){if(!e)return[];let t=new Map;for(let a of e.entries)t.set(a.key,a);let r=n?.metadataKeys??e.entries.map(a=>a.key),o=[];for(let a of r){let s=t.get(a);if(!s)continue;let c=n?.metadataRenames.get(a)??a,u=pe(s.value,s.escapeHint);u!==void 0&&o.push(`${c} = ${u}`)}return o}function pe(e,n){switch(e.kind){case"StringScalar":return Me(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=pe(r,n);o!==void 0&&t.push(o)}return`[${t.join(", ")}]`}case"StructuredMap":return;default:return}}function Me(e,n){return n&&Ne(n,m.ESC_TOML_MULTILINE)?Fe(e):Pe(e)}function Pe(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`}function Fe(e){return`"""
|
|
24
|
+
${e.replace(/"""/g,'\\"\\"\\"')}
|
|
25
|
+
"""`}var B=class{backendUri="kanonak.org/transformations/json";render(n,t){let r=JSON.stringify(n,null,2);return t?.trailingNewline&&!r.endsWith(`
|
|
26
26
|
`)?r+`
|
|
27
|
-
`:r}};function
|
|
27
|
+
`:r}};function z(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var T=class{backendUri="kanonak.org/transformations/html";render(n,t){let r=Ye(n.children);if(t?.omitWrapper){let c=r.endsWith(`
|
|
28
28
|
`)?r:`${r}
|
|
29
|
-
`;return
|
|
30
|
-
`)?c.slice(0,-1):c}let
|
|
29
|
+
`;return t.trailingNewline===!1&&c.endsWith(`
|
|
30
|
+
`)?c.slice(0,-1):c}let o=We(n.metadata)??"Untitled",a=He(n.metadata,t),s=`<!DOCTYPE html>
|
|
31
31
|
<html lang="en">
|
|
32
32
|
<head>
|
|
33
33
|
<meta charset="utf-8">
|
|
34
|
-
<title>${
|
|
34
|
+
<title>${y(o)}</title>
|
|
35
35
|
<style>
|
|
36
36
|
body { font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif; max-width: 860px; margin: 2rem auto; padding: 0 1rem; color: #222; line-height: 1.55; }
|
|
37
37
|
h1, h2, h3, h4 { line-height: 1.2; }
|
|
@@ -53,39 +53,39 @@ figure.svg-figure svg { max-width: 100%; height: auto; }
|
|
|
53
53
|
</style>
|
|
54
54
|
</head>
|
|
55
55
|
<body>
|
|
56
|
-
${
|
|
56
|
+
${a}${r}
|
|
57
57
|
</body>
|
|
58
58
|
</html>
|
|
59
|
-
`;return
|
|
60
|
-
`)?
|
|
61
|
-
<dd>${
|
|
62
|
-
${
|
|
59
|
+
`;return t?.trailingNewline===!1&&s.endsWith(`
|
|
60
|
+
`)?s.slice(0,-1):s}};function We(e){if(e){for(let n of e.entries)if((n.key==="title"||n.key==="name")&&n.value.kind==="StringScalar")return n.value.stringValue}}function He(e,n){if(!e||e.entries.length===0)return"";let t=n?.metadataKeys??e.entries.map(a=>a.key),r=new Map(e.entries.map(a=>[a.key,a])),o=[];for(let a of t){let s=r.get(a);if(!s)continue;let c=n?.metadataRenames.get(a)??a,u=ge(s.value);u!==void 0&&o.push(` <dt>${y(c)}</dt>
|
|
61
|
+
<dd>${u}</dd>`)}return o.length===0?"":`<dl class="metadata">
|
|
62
|
+
${o.join(`
|
|
63
63
|
`)}
|
|
64
64
|
</dl>
|
|
65
|
-
`}function
|
|
66
|
-
`)}function
|
|
67
|
-
<tr>${
|
|
65
|
+
`}function ge(e){switch(e.kind){case"StringScalar":return y(e.stringValue);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let n=[];for(let t of e.items){let r=ge(t);r!==void 0&&n.push(`<code>${r}</code>`)}return n.join(", ")}case"StructuredMap":return;default:return}}function Ye(e){let n=[];for(let t of e){let r=Q(t);r&&n.push(r)}return n.join(`
|
|
66
|
+
`)}function Q(e){switch(e.kind){case"Heading":{let n=Math.max(1,Math.min(6,e.level));return`<h${n}>${R(e.inlines)}</h${n}>`}case"Paragraph":return`<p>${R(e.inlines)}</p>`;case"RawBlock":return Qe(e);case"PropertyList":return Je(e);case"Table":return Xe(e);default:return""}}function Xe(e){let n=e.tableColumnLabels??[],t=e.tableRows??[],r=n.length>0?`<thead>
|
|
67
|
+
<tr>${n.map(a=>`<th>${y(a)}</th>`).join("")}</tr>
|
|
68
68
|
</thead>
|
|
69
|
-
`:"",
|
|
70
|
-
${
|
|
69
|
+
`:"",o=t.length>0?`<tbody>
|
|
70
|
+
${t.map(qe).join(`
|
|
71
71
|
`)}
|
|
72
72
|
</tbody>
|
|
73
73
|
`:"";return`<table class="property-table">
|
|
74
|
-
${r}${
|
|
75
|
-
${
|
|
74
|
+
${r}${o}</table>`}function qe(e){return` <tr>${(e.tableCells??[]).map(r=>`<td>${Ge(r)}</td>`).join("")}</tr>`}function Ge(e){let n=e;return!n||typeof n!="object"||!n.kind?"":n.kind==="Text"||n.kind==="ResourceLink"||n.kind==="Badge"?R([n]):Q(n)}function Je(e){if(!e.propertyEntries||e.propertyEntries.length===0)return"";let n=[];for(let t of e.propertyEntries){let o=`<dt${t.propertyTooltip?` title="${w(t.propertyTooltip)}"`:""}>${y(t.propertyKey)}</dt>`,a=`<dd>${ze(t.propertyValue)}</dd>`;n.push(o,a)}return`<dl class="property-list">
|
|
75
|
+
${n.join(`
|
|
76
76
|
`)}
|
|
77
|
-
</dl>`}function
|
|
78
|
-
${
|
|
79
|
-
</figure>`:`<pre${
|
|
80
|
-
`)&&(
|
|
81
|
-
`),
|
|
77
|
+
</dl>`}function ze(e){if(!e||e.length===0)return"";let n=[];for(let t of e){let r=t;!r||typeof r!="object"||!r.kind||(r.kind==="Text"||r.kind==="ResourceLink"||r.kind==="Badge"?n.push(R([r])):n.push(Q(r)))}return n.join("")}function Qe(e){let n=e.mediaType;return n&&z(n,m.TEXT_MARKDOWN)?Y(e.rawContent):n&&z(n,m.TEXT_HTML)?e.rawContent:n&&z(n,m.IMAGE_SVG_XML)?`<figure class="svg-figure">
|
|
78
|
+
${e.rawContent}
|
|
79
|
+
</figure>`:`<pre${n?` class="media-${w(n.name)}"`:""}><code>${y(e.rawContent)}</code></pre>`}function R(e){let n=[];for(let t of e)t.kind==="Text"?n.push(y(t.text)):t.kind==="ResourceLink"?n.push(Ze(t)):t.kind==="Badge"&&n.push(en(t));return n.join("")}function Ze(e){let n=ye(e.target);if(!n)return y(e.linkLabel??"[unresolved link]");let t=A(n),r=e.linkLabel&&e.linkLabel.length>0?e.linkLabel:n.name,o=e.linkTooltip?` title="${w(e.linkTooltip)}"`:"";return`<a class="kan-link" href="${w(t)}"${o}>${y(r)}</a>`}function en(e){let n=e.badgeTooltip?` title="${w(e.badgeTooltip)}"`:"",t=y(e.badgeLabel);if(!e.badgeTarget)return`<span class="kan-badge"${n}>${t}</span>`;let r=ye(e.badgeTarget);if(!r)return`<span class="kan-badge"${n}>${t}</span>`;let o=A(r);return`<a class="kan-badge" href="${w(o)}"${n}>${t}</a>`}function ye(e){if(!e||typeof e!="object")return;let n=e;if(n.subject&&n.subject.publisher&&n.subject.package_&&n.subject.name){let r={publisher:n.subject.publisher,package_:n.subject.package_,name:n.subject.name};return n.subject.version&&(r.version=n.subject.version),r}let t=e;if(typeof t.namespace=="string"&&typeof t.name=="string"&&t.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(t.namespace);if(r)return{publisher:r[1],package_:r[2],name:t.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function y(e){return e==null?"":String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(e){return e==null?"":String(e).replace(/"/g,""").replace(/&/g,"&")}function nn(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var $=class{backendUri="kanonak.org/transformations/svg";render(n,t){for(let r of n.children)if(r.kind==="RawBlock"&&r.mediaType&&nn(r.mediaType,m.IMAGE_SVG_XML)){let o=r.rawContent;return t?.trailingNewline&&!o.endsWith(`
|
|
80
|
+
`)&&(o+=`
|
|
81
|
+
`),o}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function tn(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var U=class{backendUri="kanonak.org/transformations/stylesheet";render(n,t){let r=[];for(let a of n.children)a.kind==="RawBlock"&&a.mediaType&&tn(a.mediaType,m.TEXT_CSS)&&r.push(a.rawContent);let o=r.join(`
|
|
82
82
|
|
|
83
|
-
`);return
|
|
84
|
-
`)&&(
|
|
85
|
-
`),
|
|
83
|
+
`);return t?.trailingNewline&&o.length>0&&!o.endsWith(`
|
|
84
|
+
`)&&(o+=`
|
|
85
|
+
`),o}};function rn(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var x=class{backendUri="kanonak.org/transformations/yaml";render(n,t){let r=[];for(let a of n.children)a.kind==="RawBlock"&&a.mediaType&&rn(a.mediaType,m.TEXT_YAML)&&r.push(a.rawContent);let o=r.join(`
|
|
86
86
|
|
|
87
|
-
`);return
|
|
88
|
-
`)&&(
|
|
89
|
-
`),
|
|
90
|
-
`)&&(
|
|
91
|
-
`),a}};function ze(t,e){let n=new Map;for(let i of t.entries)n.set(i.key,i);let r=e?.metadataKeys??t.entries.map(i=>i.key),a={};for(let i of r){let u=n.get(i);if(!u)continue;let c=e?.metadataRenames.get(i)??i;a[c]=Ge(u.value,u.escapeHint)}return{M:a}}function Ge(t,e){switch(t.kind){case"StructuredMap":return ze(t);case"StructuredList":return{L:t.items.map(n=>Ge(n,void 0))};case"StringScalar":return zt(t.stringValue,e??t.escapeHint);case"IntegerScalar":return Gt(t.integerValue,e??t.escapeHint)}}function zt(t,e){if(e&&re(e,k.ESC_DYNAMODB_BOOL)){if(t==="true")return{BOOL:!0};if(t==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(t)}.`)}if(e&&re(e,k.ESC_DYNAMODB_NULL))return{NULL:!0};if(e&&re(e,k.ESC_DYNAMODB_NUMBER)){if(t.trim()===""||Number.isNaN(Number(t)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(t)}.`);return{N:t}}return{S:t}}function Gt(t,e){if(e&&re(e,k.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${t}). Use a StringScalar "true"/"false".`);if(e&&re(e,k.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${t}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(t)}}var ie=class{constructor(e,n,r){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;cache=new Map;async resolveSubject(e,n){let r=M(n,e);if(r)return r;let a=e.version,i=a&&typeof a.major=="number"?`@${a.major}.${a.minor}.${a.patch}`:"",u=`${e.publisher}/${e.package_}${i}`,c=this.cache.get(u);if(!c){let p=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(p.length===0)return;let y=a&&typeof a.major=="number"?p.find(D=>{let $=D.metadata?.namespace_?.version;return $&&$.major===a.major&&$.minor===a.minor&&$.patch===a.patch})??p[0]:p[0],h=new Oe(y,this.repository);c=await this.objectParser.parseKanonaks(h),this.cache.set(u,c)}let l=M(c,e);if(l)return l;for(let p of c)if(p instanceof w&&p.name===e.name)return p}};var Jt="kanonak.org",Xt="transformations",Qn=3,s=t=>({publisher:Jt,package_:Xt,name:t}),o={Transformation:s("Transformation"),InstanceTransformation:s("InstanceTransformation"),SetTransformation:s("SetTransformation"),inputPattern:s("inputPattern"),rule:s("rule"),artifactName:s("artifactName"),outputs:s("outputs"),formatOverrides:s("formatOverrides"),partitionBy:s("partitionBy"),InputPattern:s("InputPattern"),matchesClass:s("matchesClass"),requires:s("requires"),sortBy:s("sortBy"),SortKey:s("SortKey"),byProperty:s("byProperty"),order:s("order"),SortOrder:s("SortOrder"),ascending:s("ascending"),descending:s("descending"),OutputFormat:s("OutputFormat"),backendUri:s("backendUri"),FormatOverride:s("FormatOverride"),formatTarget:s("formatTarget"),metadataKeys:s("metadataKeys"),metadataRenames:s("metadataRenames"),trailingNewline:s("trailingNewline"),omitWrapper:s("omitWrapper"),RenameEntry:s("RenameEntry"),fromKey:s("fromKey"),toKey:s("toKey"),FMT_MARKDOWN_FRONTMATTER:s("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:s("plain-markdown"),FMT_TOML:s("toml"),FMT_JSON:s("json"),FMT_HTML:s("html"),FMT_SVG:s("svg"),Expression:s("Expression"),ListSourcedExpression:s("ListSourcedExpression"),ListAggregate:s("ListAggregate"),IteratingExpression:s("IteratingExpression"),BuildAstNode:s("BuildAstNode"),astClass:s("astClass"),set:s("set"),AstFieldBinding:s("AstFieldBinding"),field:s("field"),bindValue:s("bindValue"),When:s("When"),condition:s("condition"),thenBuild:s("thenBuild"),elseBuild:s("elseBuild"),Concat:s("Concat"),parts:s("parts"),Fallback:s("Fallback"),primary:s("primary"),alternate:s("alternate"),StringLiteral:s("StringLiteral"),stringLiteral:s("stringLiteral"),IntegerLiteral:s("IntegerLiteral"),integerLiteral:s("integerLiteral"),DecimalLiteral:s("DecimalLiteral"),decimalLiteral:s("decimalLiteral"),BooleanLiteral:s("BooleanLiteral"),booleanLiteral:s("booleanLiteral"),VarRef:s("VarRef"),varName:s("varName"),PropertyRead:s("PropertyRead"),readSource:s("readSource"),readProp:s("readProp"),Traverse:s("Traverse"),traverseSource:s("traverseSource"),through:s("through"),step:s("step"),UriName:s("UriName"),uriNameOf:s("uriNameOf"),UriPublisher:s("UriPublisher"),uriPublisherOf:s("uriPublisherOf"),UriPackage:s("UriPackage"),uriPackageOf:s("uriPackageOf"),UriVersion:s("UriVersion"),uriVersionOf:s("uriVersionOf"),SubjectUri:s("SubjectUri"),subjectOf:s("subjectOf"),UriLiteral:s("UriLiteral"),refTo:s("refTo"),DisplayLabel:s("DisplayLabel"),labelTarget:s("labelTarget"),labelSource:s("labelSource"),ResolveRef:s("ResolveRef"),resolveSource:s("resolveSource"),Normalize:s("Normalize"),normSource:s("normSource"),normKind:s("normKind"),NormalizeKind:s("NormalizeKind"),NORM_TRIM_END:s("trim-end"),IsSet:s("IsSet"),checkExpr:s("checkExpr"),ExpressionFragment:s("ExpressionFragment"),body:s("body"),CallFragment:s("CallFragment"),fragmentRef:s("fragmentRef"),source:s("source"),Join:s("Join"),separator:s("separator"),Count:s("Count"),Sum:s("Sum"),Min:s("Min"),Max:s("Max"),Average:s("Average"),loopVar:s("loopVar"),ForEach:s("ForEach"),emit:s("emit"),ListMap:s("ListMap"),mapBody:s("mapBody"),Filter:s("Filter"),predicate:s("predicate"),PartitionBy:s("PartitionBy"),partitionKey:s("partitionKey"),DistinctBy:s("DistinctBy"),distinctKey:s("distinctKey"),Partition:s("Partition"),key:s("key"),members:s("members"),AllStatements:s("AllStatements"),statementsOf:s("statementsOf"),StatementPredicate:s("StatementPredicate"),predicateOf:s("predicateOf"),StatementValue:s("StatementValue"),valueOf:s("valueOf"),DateFormat:s("DateFormat"),dateSource:s("dateSource"),dateFormat:s("dateFormat"),BinaryArithmetic:s("BinaryArithmetic"),arithLeft:s("arithLeft"),arithRight:s("arithRight"),Add:s("Add"),Subtract:s("Subtract"),Multiply:s("Multiply"),Divide:s("Divide"),Reverse:s("Reverse"),WindowedMap:s("WindowedMap"),windowSize:s("windowSize"),windowVar:s("windowVar"),windowBody:s("windowBody"),PairwiseMap:s("PairwiseMap"),firstVar:s("firstVar"),secondVar:s("secondVar"),pairBody:s("pairBody"),Scan:s("Scan"),initialState:s("initialState"),stateVar:s("stateVar"),elementVar:s("elementVar"),accumulate:s("accumulate"),ListItemAt:s("ListItemAt"),itemIndex:s("itemIndex"),BinaryComparison:s("BinaryComparison"),compareLeft:s("compareLeft"),compareRight:s("compareRight"),Equals:s("Equals"),GreaterThan:s("GreaterThan"),LessThan:s("LessThan"),GreaterThanOrEqual:s("GreaterThanOrEqual"),LessThanOrEqual:s("LessThanOrEqual"),Not:s("Not"),operand:s("operand"),BooleanLogic:s("BooleanLogic"),operands:s("operands"),And:s("And"),Or:s("Or"),Contains:s("Contains"),haystack:s("haystack"),needle:s("needle"),UnaryNumericOp:s("UnaryNumericOp"),value:s("value"),Abs:s("Abs"),Negate:s("Negate"),KindPredicate:s("KindPredicate"),IsReference:s("IsReference"),IsEmbedded:s("IsEmbedded"),IsList:s("IsList"),kindCheck:s("kindCheck"),IsString:s("IsString"),IsNumber:s("IsNumber"),IsBoolean:s("IsBoolean"),StatementObject:s("StatementObject"),statementSource:s("statementSource"),Let:s("Let"),letName:s("letName"),letValue:s("letValue"),letBody:s("letBody"),GetStatementByName:s("GetStatementByName"),inSubject:s("inSubject"),byName:s("byName"),RenderMarkdown:s("RenderMarkdown"),renderSource:s("renderSource"),renderProp:s("renderProp"),renderFormat:s("renderFormat"),RenderFormat:s("RenderFormat"),RENDER_HTML:s("render-html"),RENDER_MARKDOWN:s("render-markdown")};var g=class extends Error{constructor(n,r){super(`${n} (at ${r})`);this.path=r}path};function fe(t,e){let n=t.name,r=sn(e),a={catalog:e,depth:0};if(f(t,o.InstanceTransformation))return Yt(t,n,a,r);if(f(t,o.SetTransformation))return Zt(t,n,a,r);throw new g("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Yt(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:xe(t,e),rule:le(t,o.rule,`${e}.rule`,n),artifactName:le(t,o.artifactName,`${e}.artifactName`,n),outputs:et(t,`${e}.outputs`),overrides:tt(t,`${e}.formatOverrides`,n),fragments:r}}function Zt(t,e,n,r){let a=_(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:xe(t,e),rule:le(t,o.rule,`${e}.rule`,n),artifactName:le(t,o.artifactName,`${e}.artifactName`,n),outputs:et(t,`${e}.outputs`),overrides:tt(t,`${e}.formatOverrides`,n),partitionBy:a,fragments:r}}function xe(t,e){let n=oe(t,o.inputPattern);if(!n)throw new g("inputPattern is required",e);return Qt(n,`${e}.inputPattern`)}function Qt(t,e){let n=_(t,o.matchesClass);if(!n)throw new g("matchesClass is required",e);let r=[];for(let u of A(t,o.requires))if(u instanceof j)r.push(ve(u.object.subject));else if(u instanceof S)for(let c of u.object)c instanceof b&&r.push(ve(c.subject));let a=[],i=0;for(let u of A(t,o.sortBy))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(Je(c,`${e}.sortBy[${i++}]`));else u instanceof T&&a.push(Je(u.object,`${e}.sortBy[${i++}]`));return{matchesClass:n,requires:r,sortBy:a}}function Je(t,e){let n=_(t,o.byProperty);if(!n)throw new g("SortKey.byProperty is required",e);let r=_(t,o.order);if(!r)throw new g("SortKey.order is required",e);if(E(r,o.ascending))return{byProperty:n,order:"ascending"};if(E(r,o.descending))return{byProperty:n,order:"descending"};throw new g(`SortKey.order must reference tx.ascending or tx.descending; got ${r.publisher}/${r.package_}/${r.name}`,e)}function le(t,e,n,r){let a=oe(t,e);if(!a)throw new g("expression is required",n);return G(a,n,r)}function G(t,e,n){if(f(t,o.StringLiteral))return{kind:"string-literal",value:V(t,o.stringLiteral,e)};if(f(t,o.IntegerLiteral))return{kind:"integer-literal",value:Qe(t,o.integerLiteral,e)};if(f(t,o.DecimalLiteral))return{kind:"decimal-literal",value:Qe(t,o.decimalLiteral,e)};if(f(t,o.BooleanLiteral))return{kind:"boolean-literal",value:dn(t,o.booleanLiteral,e)};if(f(t,o.VarRef))return{kind:"var-ref",varName:V(t,o.varName,e)};if(f(t,o.PropertyRead))return{kind:"property-read",source:d(t,o.readSource,`${e}.readSource`,n),readProp:q(t,o.readProp,e,"readProp")};if(f(t,o.Traverse))return{kind:"traverse",source:d(t,o.traverseSource,`${e}.traverseSource`,n),through:q(t,o.through,e,"through"),step:d(t,o.step,`${e}.step`,n)};if(f(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:q(t,o.astClass,e,"astClass"),set:en(t,`${e}.set`,n)};if(f(t,o.When))return{kind:"when",condition:d(t,o.condition,`${e}.condition`,n),thenBuild:d(t,o.thenBuild,`${e}.thenBuild`,n),elseBuild:xt(t,o.elseBuild,`${e}.elseBuild`,n)};if(f(t,o.Concat))return{kind:"concat",parts:Se(t,o.parts,`${e}.parts`,n)};if(f(t,o.Fallback))return{kind:"fallback",primary:d(t,o.primary,`${e}.primary`,n),alternate:d(t,o.alternate,`${e}.alternate`,n)};if(f(t,o.UriName))return{kind:"uri-name",source:d(t,o.uriNameOf,`${e}.uriNameOf`,n)};if(f(t,o.UriPublisher))return{kind:"uri-publisher",source:d(t,o.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(f(t,o.UriPackage))return{kind:"uri-package",source:d(t,o.uriPackageOf,`${e}.uriPackageOf`,n)};if(f(t,o.UriVersion))return{kind:"uri-version",source:d(t,o.uriVersionOf,`${e}.uriVersionOf`,n)};if(f(t,o.SubjectUri))return{kind:"subject-uri",source:d(t,o.subjectOf,`${e}.subjectOf`,n)};if(f(t,o.UriLiteral))return{kind:"uri-literal",refTo:q(t,o.refTo,e,"refTo")};if(f(t,o.DisplayLabel))return{kind:"display-label",labelTarget:q(t,o.labelTarget,e,"labelTarget"),labelSource:q(t,o.labelSource,e,"labelSource")};if(f(t,o.ResolveRef))return{kind:"resolve-ref",source:d(t,o.resolveSource,`${e}.resolveSource`,n)};if(f(t,o.Normalize))return{kind:"normalize",source:d(t,o.normSource,`${e}.normSource`,n),normKind:tn(t,e)};if(f(t,o.RenderMarkdown))return{kind:"render-markdown",source:d(t,o.renderSource,`${e}.renderSource`,n),readProp:q(t,o.renderProp,e,"renderProp"),format:nn(t,e)};if(f(t,o.IsSet))return{kind:"is-set",check:d(t,o.checkExpr,`${e}.checkExpr`,n)};if(f(t,o.CallFragment))return an(t,e,n);if(f(t,o.Join))return{kind:"join",source:d(t,o.source,`${e}.source`,n),separator:V(t,o.separator,e)};if(f(t,o.Count))return{kind:"count",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Sum))return{kind:"sum",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Min))return{kind:"min",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Max))return{kind:"max",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.Average))return{kind:"average",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.ForEach))return{kind:"for-each",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),emit:d(t,o.emit,`${e}.emit`,n)};if(f(t,o.ListMap))return{kind:"list-map",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),mapBody:d(t,o.mapBody,`${e}.mapBody`,n)};if(f(t,o.Filter))return{kind:"filter",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),predicate:d(t,o.predicate,`${e}.predicate`,n)};if(f(t,o.PartitionBy))return{kind:"partition-by",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),partitionKey:d(t,o.partitionKey,`${e}.partitionKey`,n)};if(f(t,o.DistinctBy))return{kind:"distinct-by",source:d(t,o.source,`${e}.source`,n),loopVar:V(t,o.loopVar,e),distinctKey:d(t,o.distinctKey,`${e}.distinctKey`,n)};if(f(t,o.AllStatements))return{kind:"all-statements",source:d(t,o.statementsOf,`${e}.statementsOf`,n)};if(f(t,o.StatementPredicate))return{kind:"statement-predicate",source:d(t,o.predicateOf,`${e}.predicateOf`,n)};if(f(t,o.StatementValue))return{kind:"statement-value",source:d(t,o.valueOf,`${e}.valueOf`,n)};if(f(t,o.DateFormat))return{kind:"date-format",source:d(t,o.dateSource,`${e}.dateSource`,n),format:rn(t,e)};if(f(t,o.Add))return{kind:"add",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Subtract))return{kind:"subtract",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Multiply))return{kind:"multiply",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Divide))return{kind:"divide",left:d(t,o.arithLeft,`${e}.arithLeft`,n),right:d(t,o.arithRight,`${e}.arithRight`,n)};if(f(t,o.Reverse))return{kind:"reverse",source:d(t,o.source,`${e}.source`,n)};if(f(t,o.WindowedMap)){let r=nt(t,o.windowSize);if(r===void 0||!Number.isInteger(r)||r<1)throw new g("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:d(t,o.source,`${e}.source`,n),windowSize:r,windowVar:V(t,o.windowVar,e),windowBody:d(t,o.windowBody,`${e}.windowBody`,n)}}if(f(t,o.PairwiseMap))return{kind:"pairwise-map",source:d(t,o.source,`${e}.source`,n),firstVar:V(t,o.firstVar,e),secondVar:V(t,o.secondVar,e),pairBody:d(t,o.pairBody,`${e}.pairBody`,n)};if(f(t,o.Scan))return{kind:"scan",source:d(t,o.source,`${e}.source`,n),initialState:d(t,o.initialState,`${e}.initialState`,n),stateVar:V(t,o.stateVar,e),elementVar:V(t,o.elementVar,e),accumulate:d(t,o.accumulate,`${e}.accumulate`,n)};if(f(t,o.ListItemAt))return{kind:"list-item-at",source:d(t,o.source,`${e}.source`,n),itemIndex:d(t,o.itemIndex,`${e}.itemIndex`,n)};if(f(t,o.Equals))return{kind:"equals",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThan))return{kind:"greater-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThan))return{kind:"less-than",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.LessThanOrEqual))return{kind:"less-than-or-equal",left:d(t,o.compareLeft,`${e}.compareLeft`,n),right:d(t,o.compareRight,`${e}.compareRight`,n)};if(f(t,o.Not))return{kind:"not",operand:d(t,o.operand,`${e}.operand`,n)};if(f(t,o.And))return{kind:"and",operands:Se(t,o.operands,`${e}.operands`,n)};if(f(t,o.Or))return{kind:"or",operands:Se(t,o.operands,`${e}.operands`,n)};if(f(t,o.Contains))return{kind:"contains",haystack:d(t,o.haystack,`${e}.haystack`,n),needle:d(t,o.needle,`${e}.needle`,n)};if(f(t,o.Abs))return{kind:"abs",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.Negate))return{kind:"negate",value:d(t,o.value,`${e}.value`,n)};if(f(t,o.IsReference))return{kind:"is-reference",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsEmbedded))return{kind:"is-embedded",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsList))return{kind:"is-list",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsString))return{kind:"is-string",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsNumber))return{kind:"is-number",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.IsBoolean))return{kind:"is-boolean",check:d(t,o.kindCheck,`${e}.kindCheck`,n)};if(f(t,o.StatementObject))return{kind:"statement-object",source:d(t,o.statementSource,`${e}.statementSource`,n)};if(f(t,o.Let))return{kind:"let",bindName:V(t,o.letName,e),bindValue:d(t,o.letValue,`${e}.letValue`,n),body:d(t,o.letBody,`${e}.letBody`,n)};if(f(t,o.GetStatementByName))return{kind:"get-statement-by-name",inSubject:d(t,o.inSubject,`${e}.inSubject`,n),byName:d(t,o.byName,`${e}.byName`,n)};throw new g("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}function d(t,e,n,r){let a=oe(t,e);if(!a)throw new g("child expression is required",n);return G(a,n,r)}function xt(t,e,n,r){let a=oe(t,e);if(a)return G(a,n,r)}function Se(t,e,n,r){let a=[],i=0;for(let u of A(t,e))if(u instanceof S)for(let c of u.object)c instanceof C&&a.push(G(c,`${n}[${i++}]`,r));else u instanceof T&&a.push(G(u.object,`${n}[${i++}]`,r));return a}function en(t,e,n){let r=[],a=0;for(let i of A(t,o.set))if(i instanceof S)for(let u of i.object)u instanceof C&&r.push(Xe(u,`${e}[${a++}]`,n));else i instanceof T&&r.push(Xe(i.object,`${e}[${a++}]`,n));return r}function Xe(t,e,n){return{field:q(t,o.field,e,"field"),value:d(t,o.bindValue,`${e}.bindValue`,n)}}function tn(t,e){let n=_(t,o.normKind);if(!n)throw new g("normKind is required",e);if(E(n,o.NORM_TRIM_END))return"trim-end";throw new g(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function nn(t,e){let n=_(t,o.renderFormat);if(!n)throw new g("renderFormat is required",e);if(E(n,o.RENDER_HTML))return"html";if(E(n,o.RENDER_MARKDOWN))return"markdown";throw new g(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var Ye=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function rn(t,e){let n=z(t,o.dateFormat);if(!n)throw new g("dateFormat is required",e);if(!Ye.has(n))throw new g(`Unknown dateFormat "${n}"; supported: ${[...Ye].join(", ")}`,e);return n}function an(t,e,n){let r=_(t,o.fragmentRef);if(!r)throw new g("fragmentRef is required",e);if(!un(n.catalog,r))throw new g(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:on(r)}}function on(t){return`${t.publisher}/${t.package_}/${t.name}`}function sn(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof w)||!f(r,o.ExpressionFragment))continue;let a=oe(r,o.body);if(!a)continue;let i=(r.namespace||"").split("@")[0]||"",u=i.indexOf("/");if(u<0)continue;let c=i.substring(0,u),l=i.substring(u+1),p=`${c}/${l}/${r.name}`;n.push({key:p,subject:r,bodyEmb:a,pubPkgName:`${i}/${r.name}`})}for(let r of n){let a=G(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,a)}return e}function un(t,e){for(let n of t)if(!(!(n instanceof w)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&f(n,o.ExpressionFragment))return n}function et(t,e){let n=new Set;for(let r of A(t,o.outputs))if(r instanceof j)n.add(r.object.subject.name);else if(r instanceof S)for(let a of r.object)a instanceof b&&n.add(a.subject.name);if(n.size===0)throw new g("outputs is required (at least one OutputFormat)",e);return n}function tt(t,e,n){let r=new Map,a=0;for(let i of A(t,o.formatOverrides))if(i instanceof S){for(let u of i.object)if(u instanceof C){let[c,l]=Ze(u,`${e}[${a++}]`);r.set(c,l)}}else if(i instanceof T){let[u,c]=Ze(i.object,`${e}[${a++}]`);r.set(u,c)}return r}function Ze(t,e){let n=_(t,o.formatTarget);if(!n)throw new g("formatTarget is required",e);let r=[];for(let c of A(t,o.metadataKeys))if(c instanceof L)r.push(c.object);else if(c instanceof S)for(let l of c.object){let p=l.value;typeof p=="string"&&r.push(p)}let a=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof S){for(let l of c.object)if(l instanceof C){let p=z(l,o.fromKey),y=z(l,o.toKey);p&&y&&a.set(p,y)}}else if(c instanceof T){let l=c.object,p=z(l,o.fromKey),y=z(l,o.toKey);p&&y&&a.set(p,y)}let i=Ee(t,o.trailingNewline),u=Ee(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:a,trailingNewline:i,omitWrapper:u}]}function cn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let a=cn(r);a&&E(a,e)&&n.push(r)}return n}function oe(t,e){for(let n of A(t,e))if(n instanceof T)return n.object}function _(t,e){for(let n of A(t,e))if(n instanceof j)return ve(n.object.subject)}function z(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function nt(t,e){for(let n of A(t,e))if(n instanceof U)return n.object}function Ee(t,e){for(let n of A(t,e))if(n instanceof O)return n.object}function V(t,e,n){let r=z(t,e);if(r===void 0)throw new g(`${e.name} (string) is required`,n);return r}function Qe(t,e,n){let r=nt(t,e);if(r===void 0)throw new g(`${e.name} (number) is required`,n);return r}function dn(t,e,n){let r=Ee(t,e);if(r===void 0)throw new g(`${e.name} (boolean) is required`,n);return r}function q(t,e,n,r){let a=_(t,e);if(!a)throw new g(`${r} (URI reference) is required`,n);return a}function ve(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var ln={publisher:"kanonak.org",package_:"core-rdf",name:"label"},I=class extends Error{},pe=class{constructor(e,n,r=new Map){this.resolver=e;this.catalog=n;this.fragments=r}resolver;catalog;fragments;async evaluate(e,n){switch(e.kind){case"string-literal":return e.value;case"integer-literal":return e.value;case"decimal-literal":return e.value;case"boolean-literal":return e.value;case"uri-literal":return{...e.refTo};case"var-ref":{if(!n.has(e.varName))throw new I(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let a of e.parts){let i=await this.evaluate(a,n);if(i!=null)if(Array.isArray(i))for(let u of i)r.push(u);else r.push(i)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return rt(r)?r:this.evaluate(e.alternate,n)}case"when":return await this.evaluate(e.condition,n)===!0?this.evaluate(e.thenBuild,n):e.elseBuild?this.evaluate(e.elseBuild,n):void 0;case"is-set":{let r=await this.evaluate(e.check,n);return rt(r)}case"property-read":{let r=await this.evaluate(e.source,n);return me(r,e.readProp)}case"traverse":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a=mn(r,e.through),i=[];for(let u of a){let c=await this.resolver.resolveSubject(u,this.catalog);if(!c)continue;let l=new Map(n);l.set("input",c);let p=await this.evaluate(e.step,l);p!=null&&i.push(se(p))}return i.join("")}case"uri-name":{let r=await this.evaluate(e.source,n);return J(r)?r.name:r instanceof b?r.subject.name:r instanceof w?r.name:r instanceof C?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return $e(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return $e(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return $e(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof w){let a=r.namespace??"",i=r.name??"";return!a||!i?void 0:`${a}/${i}`}if(r instanceof b){let a=r.subject,i=a.version;return i&&typeof i.major=="number"?`${a.publisher}/${a.package_}@${i.major}.${i.minor}.${i.patch}/${a.name}`:`${a.publisher}/${a.package_}/${a.name}`}return}case"display-label":{let r=await this.resolver.resolveSubject({...e.labelTarget},this.catalog);return r?me(r,e.labelSource):void 0}case"resolve-ref":{let r=await this.evaluate(e.source,n);return r instanceof w?r:r instanceof b?await this.resolver.resolveSubject(r.subject,this.catalog):J(r)?await this.resolver.resolveSubject(r,this.catalog):void 0}case"normalize":{let r=await this.evaluate(e.source,n),a=r==null?"":se(r);return e.normKind==="trim-end"?a.replace(/[\s\r\n]+$/u,""):a}case"render-markdown":{let r=await this.evaluate(e.source,n);if(!(r instanceof K))return;let a;for(let u of r.statement){let c=je(u);if(c&&E(c,e.readProp)){a=u;break}}if(!(a instanceof Ce)){let u=me(r,e.readProp);return u==null?void 0:se(u)}let i=await this.renderMarkdownLinks(a);return e.format==="html"?X(i):i}case"build-ast-node":{let r={kind:e.astClass.name};for(let a of e.set){let i=await this.evaluate(a.value,n);if(i==null||Array.isArray(i)&&i.length===0)continue;let u=a.field.name;gn.has(u)&&(Array.isArray(i)&&i.every(c=>at(c))?i=i.map(c=>String(c)).join(""):at(i)&&(i=String(i))),r[u]=i}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new I(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(a=>a==null?"":se(a)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),a=0;for(let i of r)a+=v(i,"Sum");return a}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Min on an empty list is undefined; guard with IsSet");let a=v(r[0],"Min");for(let i=1;i<r.length;i++){let u=v(r[i],"Min");u<a&&(a=u)}return a}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Max on an empty list is undefined; guard with IsSet");let a=v(r[0],"Max");for(let i=1;i<r.length;i++){let u=v(r[i],"Max");u>a&&(a=u)}return a}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new I("Average on an empty list is undefined; guard with IsSet");let a=0;for(let i of r)a+=v(i,"Average");return a/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"list-map":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i)),a.push(await this.evaluate(e.mapBody,u))}return a}case"filter":{let r=await this.evaluateList(e.source,n),a=[];for(let i of r){let u=new Map(n);u.set(e.loopVar,B(i)),await this.evaluate(e.predicate,u)===!0&&a.push(i)}return a}case"partition-by":{let r=await this.evaluateList(e.source,n),a=new Map,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.partitionKey,c),p=st(l),y=a.get(p);y||(y={kind:"Partition",key:l,members:[]},a.set(p,y),i.push(p)),y.members.push(u)}return i.map(u=>a.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),a=new Set,i=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,B(u));let l=await this.evaluate(e.distinctKey,c),p=st(l);a.has(p)||(a.add(p),i.push(u))}return i}case"all-statements":{let r=await this.evaluate(e.source,n);return r instanceof K?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if(Ve(r)){let a=r.predicate;if(a instanceof b)return a}return}case"statement-value":{let r=await this.evaluate(e.source,n);return Ve(r)?hn(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),a=r==null?"":se(r);return a?kn(a,e.format):""}case"add":{let r=v(await this.evaluate(e.left,n),"Add"),a=v(await this.evaluate(e.right,n),"Add");return r+a}case"subtract":{let r=v(await this.evaluate(e.left,n),"Subtract"),a=v(await this.evaluate(e.right,n),"Subtract");return r-a}case"multiply":{let r=v(await this.evaluate(e.left,n),"Multiply"),a=v(await this.evaluate(e.right,n),"Multiply");return r*a}case"divide":{let r=v(await this.evaluate(e.left,n),"Divide"),a=v(await this.evaluate(e.right,n),"Divide");if(a===0)throw new I("Divide by zero; guard with When");return r/a}case"reverse":{if(e.source.kind==="reverse")return this.evaluate(e.source.source,n);let r=await this.evaluateReverseIterator(e.source,n);return r!==void 0?r:[...await this.evaluateList(e.source,n)].reverse()}case"windowed-map":{let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=0;i+e.windowSize<=r.length;i++){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let p of l)a.push(p);else a.push(l)}return a}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=0;i+1<r.length;i++){let u=new Map(n);u.set(e.firstVar,B(r[i])),u.set(e.secondVar,B(r[i+1]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let a=await this.evaluate(e.initialState,n),i=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,a),c.set(e.elementVar,B(u));let l=await this.evaluate(e.accumulate,c);i.push(l),a=l}return i}case"list-item-at":{let r=await this.evaluateList(e.source,n),a=await this.evaluate(e.itemIndex,n);return typeof a!="number"||!Number.isInteger(a)||a<0||a>=r.length?void 0:r[a]}case"equals":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return it(r,a)}case"greater-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>a}case"less-than":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<a}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r>=a}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),a=await this.evaluate(e.right,n);return typeof r!="number"||typeof a!="number"?!1:r<=a}case"not":{let r=await this.evaluate(e.operand,n);return r===!0?!1:r===!1?!0:void 0}case"and":{for(let r of e.operands)if(await this.evaluate(r,n)!==!0)return!1;return!0}case"or":{for(let r of e.operands)if(await this.evaluate(r,n)===!0)return!0;return!1}case"contains":{let r=await this.evaluateList(e.haystack,n),a=await this.evaluate(e.needle,n);for(let i of r)if(it(i,a))return!0;return!1}case"abs":{let r=v(await this.evaluate(e.value,n),"Abs");return Math.abs(r)}case"negate":return-v(await this.evaluate(e.value,n),"Negate");case"is-reference":{let r=await this.evaluate(e.check,n);return r instanceof b||r instanceof w}case"is-embedded":return await this.evaluate(e.check,n)instanceof C;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"is-string":return typeof await this.evaluate(e.check,n)=="string";case"is-number":return typeof await this.evaluate(e.check,n)=="number";case"is-boolean":return typeof await this.evaluate(e.check,n)=="boolean";case"statement-object":{let r=await this.evaluate(e.source,n);if(!Ve(r))return;let a=r;return a instanceof L||a instanceof U||a instanceof O||a instanceof j||a instanceof T||a instanceof S?a.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),a=new Map(n);return a.set(e.bindName,r),this.evaluate(e.body,a)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),a=await this.evaluate(e.byName,n);if(!(r instanceof K)||typeof a!="string")return;for(let i of r.statement)if(i.predicate?.subject?.name===a)return i;return}default:{let r=e;throw new I("Unknown expression kind")}}}async renderMarkdownLinks(e){let n=e.object,r="",a=0;for(let i of e.links){if(r+=n.slice(a,i.startOffset),i.target){let u=i.target.subject,c=i.displayText??await this.resolveLabel(u)??u.name;r+=`[${c}](${F(u)})`}else r+=i.displayText??i.reference;a=i.endOffset}return r+=n.slice(a),r}async resolveLabel(e){let n=await this.resolver.resolveSubject(e,this.catalog);if(!n)return;let r=me(n,ln);return typeof r=="string"?r:void 0}async evaluateList(e,n){let r=await this.evaluate(e,n);return r==null?[]:Array.isArray(r)?r:[r]}async evaluateReverseIterator(e,n){if(e.kind==="pairwise-map"){let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let a=[];for(let i=r.length-1;i>=1;i--){let u=new Map(n);u.set(e.firstVar,B(r[i-1])),u.set(e.secondVar,B(r[i]));let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,B(r[i]));let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)a.push(l);else a.push(c)}return a}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),a=[];for(let i=r.length-1;i>=0;i--){let u=new Map(n);u.set(e.loopVar,B(r[i])),a.push(await this.evaluate(e.mapBody,u))}return a}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let a=[];for(let i=r.length-e.windowSize;i>=0;i--){let u=r.slice(i,i+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let p of l)a.push(p);else a.push(l)}return a}}};function me(t,e){if(t instanceof K)return fn(t,e);if(pn(t))return E(e,o.key)?t.key:E(e,o.members)?t.members:void 0}function fn(t,e){for(let n of t.statement){let r=je(n);if(!(!r||!E(r,e))&&(n instanceof L||n instanceof U||n instanceof O||n instanceof j||n instanceof T||n instanceof S))return n.object}}function mn(t,e){let n=[];for(let r of t.statement){let a=je(r);if(!(!a||!E(a,e))){if(r instanceof j)n.push(r.object.subject);else if(r instanceof S)for(let i of r.object)i instanceof b&&n.push(i.subject)}}return n}function je(t){return t.predicate?.subject}function se(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t instanceof K)return t.name??"";if(t instanceof b)return t.subject.name;if(J(t))return t.name;let e=t.value;return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function B(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof K)&&!(t instanceof b)&&!(t instanceof C)&&"value"in t?t.value:t}function rt(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:typeof t=="boolean"?t===!0:!0}function J(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}function pn(t){return typeof t=="object"&&t!==null&&t.kind==="Partition"&&Array.isArray(t.members)}function v(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;throw new I(`${e} requires numeric elements; got ${yn(t)}`)}function $e(t){if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);return n<0||r<0?void 0:{publisher:e.substring(0,n),package_:e.substring(n+1,r),version:e.substring(r+1),name:t.name??""}}if(t instanceof b){let e=t.subject,n=e.version;return{publisher:e.publisher,package_:e.package_,version:n&&typeof n.major=="number"?`${n.major}.${n.minor}.${n.patch}`:"",name:e.name}}if(J(t))return{publisher:t.publisher,package_:t.package_,version:"",name:t.name}}var gn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function at(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function yn(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function kn(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),a=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getUTCMonth()],u=n.getUTCDate(),c=(l,p=2)=>String(l).padStart(p,"0");switch(e){case"iso-date":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}`;case"iso-datetime":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}T${c(n.getUTCHours())}:${c(n.getUTCMinutes())}:${c(n.getUTCSeconds())}Z`;case"short-date":return`${i} ${u}`;case"long-date":return`${a} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${a} ${r}`}}function it(t,e){if(t==null||e===void 0||e===null)return!1;if(t===e)return!0;let n=typeof t=="object"&&"value"in t?t.value:void 0,r=typeof e=="object"&&"value"in e?e.value:void 0,a=n??t,i=r??e,u=ot(t),c=ot(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof a=="string"&&typeof i=="string"||typeof a=="number"&&typeof i=="number"||typeof a=="boolean"&&typeof i=="boolean"?a===i:!1}function ot(t){if(t instanceof b){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof w){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let a=e.substring(0,n),i=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:a,package_:i,name:t.name??""}}if(J(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function Ve(t){return t instanceof L||t instanceof U||t instanceof O||t instanceof j||t instanceof T||t instanceof S}function hn(t){return t instanceof L||t instanceof U||t instanceof O?String(t.object??""):t instanceof j?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof S?(t.object??[]).map(n=>{if(n instanceof b)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let a=n.value;return typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a):"[embedded]"}).join(", "):""}function st(t){if(t===void 0)return"\0undef";if(t===null)return"\0null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return J(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var bn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},W=class extends Error{},ge=class{backends=new Map;constructor(){this.register(new Y),this.register(new Z),this.register(new Q),this.register(new x),this.register(new ee),this.register(new te),this.register(new ne),this.register(new ae)}register(e){this.backends.set(e.backendUri,e)}async run(e){let n=e.transformationKanonaks??e.allKanonaks,r=fe(e.transformation,n);if(!r.outputs.has(e.outputFormat))throw new W(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let a=this.findBackend(e.outputFormat);if(!a)throw new W(`No backend registered for OutputFormat "${e.outputFormat}".`);let i=new ie(e.repository,e.parser,e.objectParser),u=new pe(i,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,a,u):this.runSet(r,e,a,u)}async runInstance(e,n,r,a){let i=ut(n.instances,e.inputPattern.requires),u=ct(i,e.inputPattern.sortBy),c=[];for(let l of u){let p=new Map;p.set("input",l);let y=await a.evaluate(e.rule,p);Ae(y,e.name,`input "${l.name}"`);let h=De(await a.evaluate(e.artifactName,p),e.name,`input "${l.name}"`),D=Ke(e.overrides.get(n.outputFormat),n.runtimeOverride),$=r.render(y,D);c.push({fileName:h,format:n.outputFormat,content:$,source:{kind:"instance",sourceName:l.name}})}return c}async runSet(e,n,r,a){let i=ut(n.instances,e.inputPattern.requires),u=ct(i,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,a):this.runSetSingle(e,u,n,r,a)}async runSetSingle(e,n,r,a,i){let u=new Map;u.set("inputs",n);let c=await i.evaluate(e.rule,u);Ae(c,e.name,"set");let l=De(await i.evaluate(e.artifactName,u),e.name,"set"),p=Ke(e.overrides.get(r.outputFormat),r.runtimeOverride),y=a.render(c,p);return[{fileName:l,format:r.outputFormat,content:y,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,a,i){let u=e.partitionBy,c=new Map,l=[];for(let y of n){let h=En(y,u);if(h==null)continue;let D=vn(h),$=c.get(D);$||($={keyValue:h,keyDisplay:$n(h),members:[]},c.set(D,$),l.push(D)),$.members.push(y)}let p=[];for(let y of l){let h=c.get(y),D=new Map;D.set("inputs",h.members),D.set("key",h.keyValue);let $=await i.evaluate(e.rule,D);Ae($,e.name,`partition "${h.keyDisplay}"`);let mt=De(await i.evaluate(e.artifactName,D),e.name,`partition "${h.keyDisplay}"`),pt=Ke(e.overrides.get(r.outputFormat),r.runtimeOverride),gt=a.render($,pt);p.push({fileName:mt,format:r.outputFormat,content:gt,source:{kind:"set",memberCount:h.members.length,partitionKey:h.keyDisplay}})}return p}findBackend(e){let n=bn[e];if(n)return this.backends.get(n.formatUri)}};function ut(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!Sn(n,r))return!1;return!0})}function ct(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,a)=>{for(let i of e){let u=dt(r,i.byProperty),c=dt(a,i.byProperty),l=wn(u,c,i.order);if(l!==0)return l}return 0}),n}function dt(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!E(r,e))){if(n instanceof L||n instanceof U||n instanceof O)return n.object;if(n instanceof S)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(n instanceof j)throw new W(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function wn(t,e,n){if(t===void 0&&e===void 0)return 0;if(t===void 0)return n==="ascending"?1:-1;if(e===void 0)return n==="ascending"?-1:1;let r;return typeof t=="number"&&typeof e=="number"?r=t-e:r=String(t).localeCompare(String(e)),n==="ascending"?r:-r}function Sn(t,e){for(let n of t.statement){let r=Te(n);if(!r||!E(r,e))continue;let a=n.object;if(a!=null&&!(typeof a=="string"&&a.length===0)&&!(Array.isArray(a)&&a.length===0))return!0}return!1}function En(t,e){for(let n of t.statement){let r=Te(n);if(!(!r||!E(r,e))&&(n instanceof L||n instanceof U||n instanceof O||n instanceof j||n instanceof S))return n.object}}function Te(t){return t.predicate?.subject}function vn(t){if(t===void 0)return" undef";if(t===null)return" null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof b){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof K){let e=t.name??"";return`k:${t.namespace??""}/${e}`}if(typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.publisher=="string"){let e=t;return`u:${e.publisher}/${e.package_}/${e.name}`}return`o:${JSON.stringify(t)}`}function $n(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof b?t.subject.name:t instanceof K?t.name??"":typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:""}function Ae(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new W(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${lt(t)}`)}function De(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(Vn))return t.map(r=>String(r)).join("");throw new W(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${lt(t)}`)}function Vn(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function lt(t){if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return`array(${t.length})`;if(typeof t=="object"){let e=t.kind;return e?`object(kind=${e})`:"object"}return typeof t}function Ke(t,e){if(!t&&!e)return;let n={metadataRenames:e?.metadataRenames??t?.metadataRenames??new Map},r=e?.metadataKeys??t?.metadataKeys;r!==void 0&&(n.metadataKeys=r);let a=e?.trailingNewline??t?.trailingNewline;a!==void 0&&(n.trailingNewline=a);let i=e?.omitWrapper??t?.omitWrapper;return i!==void 0&&(n.omitWrapper=i),n}var R=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},ft={publisher:"kanonak.org",package_:"derivation",name:"default"},Be=class{constructor(e,n=new Re,r=new Ue){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new ge;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))throw new R(`Resource not found: ${P(e.resource)}`);let a=new ye(n),i;if(e.format.name==="html")i=a.renderHtml(r);else if(e.format.name==="stylesheet")i=a.renderStylesheet(r);else throw new R(`LookRenderer does not support format ${P(e.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:i,format:e.format,filename:r.name}}async findDerivation(e){let n=await this.getCatalog(),r=M(n,e.resource);if(!(r instanceof w))return;let a=e.variant??ft;return Ne(r,e.format,a,n)}async render(e){if(e.format.name==="html"||e.format.name==="stylesheet"){let i=await this.getCatalog(),u=M(i,e.resource);if(u instanceof w){let l=new ye(i).findCascadedLook(u);if(l&&!An(l.sourceClass)){let p=await this.findDerivation(e);if(!p||jn(p))return this.renderViaLook({resource:e.resource,format:e.format})}}}let n=await this.findDerivation(e);if(!n)throw new R(`No derivation found for ${P(e.resource)} \u2192 format ${P(e.format)}`+(e.variant?` variant ${P(e.variant)}`:""));let r=Le(n.transformation.version),a={transformation:{publisher:n.transformation.publisher,package_:n.transformation.package_,name:n.transformation.name,...r?{version:r}:{}},input:e.resource,format:e.format};return e.omitWrapper!==void 0&&(a.omitWrapper=e.omitWrapper),this.runTransformation(a)}async runTransformation(e){let n=await this.getCatalog(),r=M(n,e.transformation);if(!(r instanceof w))throw new R(`Transformation not found: ${P(e.transformation)}`);let a=M(n,e.input);if(!(a instanceof w))throw new R(`Input resource not found: ${P(e.input)}`);let i=fe(r,n),u=Dn(i.outputs,e.format);if(!u)throw new R(`Transformation ${P(e.transformation)} declares outputs [${[...i.outputs].join(", ")}], none of which corresponds to format ${P(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[a],allKanonaks:n,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:u,...e.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:e.omitWrapper}}:{}})}catch(l){throw new R(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new R("Transformation produced no artifacts");return{content:c[0].content,format:e.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function P(t){return`${t.publisher}/${t.package_}/${t.name}`}function jn(t){return typeof t.source=="string"?!1:t.source.publisher==="kanonak.org"&&t.source.package_==="core-rdf"&&t.source.name==="Resource"}function An(t){return t.publisher==="kanonak.org"&&t.package_==="core-rdf"&&t.name==="Resource"}function Dn(t,e){let n=e.name;if(t.has(n))return n;for(let r of t)if(r.startsWith(n+"-")||r===n)return r}export{te as CssBackend,ft as DEFAULT_VARIANT,k as DOCAST,kt as DOCAST_PKG,yt as DOCAST_PUB,ae as DynamoDbBackend,pe as ExpressionEngineV3,I as ExpressionEvalErrorV3,x as HtmlBackend,Q as JsonBackend,Y as MarkdownFrontmatterBackend,ie as ReferenceResolver,R as RenderError,bn as SUPPORTED_FORMATS_V3,ee as SvgBackend,o as TX_V3,Xt as TX_V3_PKG,Jt as TX_V3_PUB,Qn as TX_V3_VERSION_MAJOR,Z as TomlBackend,Be as TransformationEngine,g as TransformationLoadErrorV3,W as TransformationRunnerErrorV3,ge as TransformationRunnerV3,ne as YamlBackend,fe as compileTransformationV3,X as renderMarkdownToHtml};
|
|
87
|
+
`);return t?.trailingNewline&&o.length>0&&!o.endsWith(`
|
|
88
|
+
`)&&(o+=`
|
|
89
|
+
`),o}};function V(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var v=class{backendUri="kanonak.org/transformations/dynamodb-json";render(n,t){if(!n.metadata)throw new Error("dynamodb-json backend: Document has no `metadata` channel. This backend serializes Document.metadata into DynamoDB attribute-value JSON \u2014 the transformation must populate that channel. (No silent empty artifact.)");let r=ke(n.metadata,t),o=JSON.stringify(r,null,2);return t?.trailingNewline&&!o.endsWith(`
|
|
90
|
+
`)&&(o+=`
|
|
91
|
+
`),o}};function ke(e,n){let t=new Map;for(let a of e.entries)t.set(a.key,a);let r=n?.metadataKeys??e.entries.map(a=>a.key),o={};for(let a of r){let s=t.get(a);if(!s)continue;let c=n?.metadataRenames.get(a)??a;o[c]=be(s.value,s.escapeHint)}return{M:o}}function be(e,n){switch(e.kind){case"StructuredMap":return ke(e);case"StructuredList":return{L:e.items.map(t=>be(t,void 0))};case"StringScalar":return on(e.stringValue,n??e.escapeHint);case"IntegerScalar":return an(e.integerValue,n??e.escapeHint)}}function on(e,n){if(n&&V(n,m.ESC_DYNAMODB_BOOL)){if(e==="true")return{BOOL:!0};if(e==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(e)}.`)}if(n&&V(n,m.ESC_DYNAMODB_NULL))return{NULL:!0};if(n&&V(n,m.ESC_DYNAMODB_NUMBER)){if(e.trim()===""||Number.isNaN(Number(e)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(e)}.`);return{N:e}}return{S:e}}function an(e,n){if(n&&V(n,m.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${e}). Use a StringScalar "true"/"false".`);if(n&&V(n,m.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${e}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(e)}}var sn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},h=class extends Error{},C=class{backends=new Map;constructor(){this.register(new j),this.register(new E),this.register(new B),this.register(new T),this.register(new $),this.register(new U),this.register(new x),this.register(new v)}register(n){this.backends.set(n.backendUri,n)}async run(n){let t=n.transformationKanonaks??n.allKanonaks,r=O(n.transformation,t);if(!r.outputs.has(n.outputFormat))throw new h(`Transformation "${r.name}" does not declare output format "${n.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let o=this.findBackend(n.outputFormat);if(!o)throw new h(`No backend registered for OutputFormat "${n.outputFormat}".`);let a=new X(n.repository,n.parser,n.objectParser),s=new ce(a,n.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,n,o,s):this.runSet(r,n,o,s)}async runInstance(n,t,r,o){let a=he(t.instances,n.inputPattern.requires),s=De(a,n.inputPattern.sortBy),c=[];for(let u of s){let f=new Map;f.set("input",u);let l=await o.evaluate(n.rule,f);Z(l,n.name,`input "${u.name}"`);let d=ee(await o.evaluate(n.artifactName,f),n.name,`input "${u.name}"`),g=ne(n.overrides.get(t.outputFormat),t.runtimeOverride),k=r.render(l,g);c.push({fileName:d,format:t.outputFormat,content:k,source:{kind:"instance",sourceName:u.name}})}return c}async runSet(n,t,r,o){let a=he(t.instances,n.inputPattern.requires),s=De(a,n.inputPattern.sortBy);return n.partitionBy?this.runSetWithPartition(n,s,t,r,o):this.runSetSingle(n,s,t,r,o)}async runSetSingle(n,t,r,o,a){let s=new Map;s.set("inputs",t);let c=await a.evaluate(n.rule,s);Z(c,n.name,"set");let u=ee(await a.evaluate(n.artifactName,s),n.name,"set"),f=ne(n.overrides.get(r.outputFormat),r.runtimeOverride),l=o.render(c,f);return[{fileName:u,format:r.outputFormat,content:l,source:{kind:"set",memberCount:t.length}}]}async runSetWithPartition(n,t,r,o,a){let s=n.partitionBy,c=new Map,u=[];for(let l of t){let d=mn(l,s);if(d==null)continue;let g=dn(d),k=c.get(g);k||(k={keyValue:d,keyDisplay:fn(d),members:[]},c.set(g,k),u.push(g)),k.members.push(l)}let f=[];for(let l of u){let d=c.get(l),g=new Map;g.set("inputs",d.members),g.set("key",d.keyValue);let k=await a.evaluate(n.rule,g);Z(k,n.name,`partition "${d.keyDisplay}"`);let je=ee(await a.evaluate(n.artifactName,g),n.name,`partition "${d.keyDisplay}"`),Ee=ne(n.overrides.get(r.outputFormat),r.runtimeOverride),Be=o.render(k,Ee);f.push({fileName:je,format:r.outputFormat,content:Be,source:{kind:"set",memberCount:d.members.length,partitionKey:d.keyDisplay}})}return f}findBackend(n){let t=sn[n];if(t)return this.backends.get(t.formatUri)}};function he(e,n){return n.length===0?e:e.filter(t=>{for(let r of n)if(!un(t,r))return!1;return!0})}function De(e,n){if(n.length===0)return e;let t=[...e];return t.sort((r,o)=>{for(let a of n){let s=Ae(r,a.byProperty),c=Ae(o,a.byProperty),u=cn(s,c,a.order);if(u!==0)return u}return 0}),t}function Ae(e,n){for(let t of e.statement){let r=te(t);if(!(!r||!L(r,n))){if(t instanceof M||t instanceof P||t instanceof F)return t.object;if(t instanceof H)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(t instanceof W)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function cn(e,n,t){if(e===void 0&&n===void 0)return 0;if(e===void 0)return t==="ascending"?1:-1;if(n===void 0)return t==="ascending"?-1:1;let r;return typeof e=="number"&&typeof n=="number"?r=e-n:r=String(e).localeCompare(String(n)),t==="ascending"?r:-r}function un(e,n){for(let t of e.statement){let r=te(t);if(!r||!L(r,n))continue;let o=t.object;if(o!=null&&!(typeof o=="string"&&o.length===0)&&!(Array.isArray(o)&&o.length===0))return!0}return!1}function mn(e,n){for(let t of e.statement){let r=te(t);if(!(!r||!L(r,n))&&(t instanceof M||t instanceof P||t instanceof F||t instanceof W||t instanceof H))return t.object}}function te(e){return e.predicate?.subject}function dn(e){if(e===void 0)return" undef";if(e===null)return" null";if(typeof e=="string")return`s:${e}`;if(typeof e=="number")return`n:${e}`;if(typeof e=="boolean")return`b:${e}`;if(e instanceof K){let n=e.subject;return`r:${n.publisher}/${n.package_}/${n.name}`}if(e instanceof N){let n=e.name??"";return`k:${e.namespace??""}/${n}`}if(typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.publisher=="string"){let n=e;return`u:${n.publisher}/${n.package_}/${n.name}`}return`o:${JSON.stringify(e)}`}function fn(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e instanceof K?e.subject.name:e instanceof N?e.name??"":typeof e=="object"&&e!==null&&typeof e.name=="string"?e.name:""}function Z(e,n,t){if(typeof e!="object"||e===null||e.kind!=="Document")throw new h(`Transformation "${n}" rule did not yield a Document for ${t}. Got: ${Se(e)}`)}function ee(e,n,t){if(typeof e=="string")return e;if(Array.isArray(e)&&e.every(ln))return e.map(r=>String(r)).join("");throw new h(`Transformation "${n}" artifactName did not yield a string for ${t}. Got: ${Se(e)}`)}function ln(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Se(e){if(e===void 0)return"undefined";if(e===null)return"null";if(Array.isArray(e))return`array(${e.length})`;if(typeof e=="object"){let n=e.kind;return n?`object(kind=${n})`:"object"}return typeof e}function ne(e,n){if(!e&&!n)return;let t={metadataRenames:n?.metadataRenames??e?.metadataRenames??new Map},r=n?.metadataKeys??e?.metadataKeys;r!==void 0&&(t.metadataKeys=r);let o=n?.trailingNewline??e?.trailingNewline;o!==void 0&&(t.trailingNewline=o);let a=n?.omitWrapper??e?.omitWrapper;return a!==void 0&&(t.omitWrapper=a),t}var p=class extends Error{constructor(t,r){super(t);this.cause=r;this.name="RenderError"}cause},we={publisher:"kanonak.org",package_:"derivation",name:"default"},re=class{constructor(n,t=new ae,r=new ie){this.repository=n;this.parser=t;this.objectParser=r}repository;parser;objectParser;runner=new C;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(n){let t=await this.getCatalog(),r=S(t,n.resource);if(!(r instanceof D))throw new p(`Resource not found: ${b(n.resource)}`);let o=new q(t),a;if(n.format.name==="html")a=o.renderHtml(r);else if(n.format.name==="stylesheet")a=o.renderStylesheet(r);else throw new p(`LookRenderer does not support format ${b(n.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:a,format:n.format,filename:r.name}}async findDerivation(n){let t=await this.getCatalog(),r=S(t,n.resource);if(!(r instanceof D))return;let o=n.variant??we;return se(r,n.format,o,t)}async render(n){if(n.format.name==="html"||n.format.name==="stylesheet"){let a=await this.getCatalog(),s=S(a,n.resource);if(s instanceof D){let u=new q(a).findCascadedLook(s);if(u&&!gn(u.sourceClass)){let f=await this.findDerivation(n);if(!f||pn(f))return this.renderViaLook({resource:n.resource,format:n.format})}}}let t=await this.findDerivation(n);if(!t)throw new p(`No derivation found for ${b(n.resource)} \u2192 format ${b(n.format)}`+(n.variant?` variant ${b(n.variant)}`:""));let r=oe(t.transformation.version),o={transformation:{publisher:t.transformation.publisher,package_:t.transformation.package_,name:t.transformation.name,...r?{version:r}:{}},input:n.resource,format:n.format};return n.omitWrapper!==void 0&&(o.omitWrapper=n.omitWrapper),this.runTransformation(o)}async runTransformation(n){let t=await this.getCatalog(),r=S(t,n.transformation);if(!(r instanceof D))throw new p(`Transformation not found: ${b(n.transformation)}`);let o=S(t,n.input);if(!(o instanceof D))throw new p(`Input resource not found: ${b(n.input)}`);let a=O(r,t),s=yn(a.outputs,n.format);if(!s)throw new p(`Transformation ${b(n.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${b(n.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[o],allKanonaks:t,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:s,...n.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:n.omitWrapper}}:{}})}catch(u){throw new p(`Transformation execution failed: ${u.message}`,u)}if(c.length===0)throw new p("Transformation produced no artifacts");return{content:c[0].content,format:n.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function b(e){return`${e.publisher}/${e.package_}/${e.name}`}function pn(e){return typeof e.source=="string"?!1:e.source.publisher==="kanonak.org"&&e.source.package_==="core-rdf"&&e.source.name==="Resource"}function gn(e){return e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Resource"}function yn(e,n){let t=n.name;if(e.has(t))return t;for(let r of e)if(r.startsWith(t+"-")||r===t)return r}export{U as CssBackend,we as DEFAULT_VARIANT,m as DOCAST,Ue as DOCAST_PKG,$e as DOCAST_PUB,v as DynamoDbBackend,ce as ExpressionEngineV3,Sn as ExpressionEvalErrorV3,T as HtmlBackend,B as JsonBackend,j as MarkdownFrontmatterBackend,X as ReferenceResolver,p as RenderError,sn as SUPPORTED_FORMATS_V3,$ as SvgBackend,Dn as TX_V3,bn as TX_V3_PKG,kn as TX_V3_PUB,hn as TX_V3_VERSION_MAJOR,E as TomlBackend,re as TransformationEngine,Te as TransformationLoadErrorV3,h as TransformationRunnerErrorV3,C as TransformationRunnerV3,x as YamlBackend,wn as compileExpression,O as compileTransformationV3,An as isRawStringV3,Y as renderMarkdownToHtml};
|
|
@@ -90,7 +90,7 @@ export interface CompiledFormatOverrideV3 {
|
|
|
90
90
|
* doctype + style + metadata <dl>; analogous in other backends). */
|
|
91
91
|
omitWrapper?: boolean | undefined;
|
|
92
92
|
}
|
|
93
|
-
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledIsStringV3 | CompiledIsNumberV3 | CompiledIsBooleanV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
|
|
93
|
+
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledUnescapedStringV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledIsStringV3 | CompiledIsNumberV3 | CompiledIsBooleanV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
|
|
94
94
|
export interface CompiledStringLiteralV3 {
|
|
95
95
|
kind: 'string-literal';
|
|
96
96
|
value: string;
|
|
@@ -352,12 +352,16 @@ export interface CompiledGetStatementByNameV3 {
|
|
|
352
352
|
inSubject: CompiledExpressionV3;
|
|
353
353
|
byName: CompiledExpressionV3;
|
|
354
354
|
}
|
|
355
|
-
export type NormalizeKindV3 = 'trim-end';
|
|
355
|
+
export type NormalizeKindV3 = 'trim-end' | 'to-upper' | 'to-lower' | 'first-char';
|
|
356
356
|
export interface CompiledNormalizeV3 {
|
|
357
357
|
kind: 'normalize';
|
|
358
358
|
source: CompiledExpressionV3;
|
|
359
359
|
normKind: NormalizeKindV3;
|
|
360
360
|
}
|
|
361
|
+
export interface CompiledUnescapedStringV3 {
|
|
362
|
+
kind: 'unescaped-string';
|
|
363
|
+
source: CompiledExpressionV3;
|
|
364
|
+
}
|
|
361
365
|
export interface CompiledIsSetV3 {
|
|
362
366
|
kind: 'is-set';
|
|
363
367
|
check: CompiledExpressionV3;
|
|
@@ -29,7 +29,19 @@ export interface RuntimePartitionV3 {
|
|
|
29
29
|
key: EnvValue;
|
|
30
30
|
members: Kanonak[];
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Discriminated marker emitted by the `unescaped-string` Expression handler.
|
|
34
|
+
* Concat preserves these wrappers through its flatten so consumers (e.g. the
|
|
35
|
+
* look renderer that converts a Concat result into an HTML/SVG fragment) can
|
|
36
|
+
* decide which items to escape and which to splice raw. Stringification at
|
|
37
|
+
* the binding boundary (BuildAstNode) unwraps `value` transparently.
|
|
38
|
+
*/
|
|
39
|
+
export interface RawStringV3 {
|
|
40
|
+
kind: 'raw-string';
|
|
41
|
+
value: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function isRawStringV3(v: unknown): v is RawStringV3;
|
|
44
|
+
export type EnvValue = string | number | boolean | Kanonak | Kanonak[] | EnvValue[] | RuntimePartitionV3 | RawStringV3 | EntityUri | unknown | undefined | null;
|
|
33
45
|
export type Env = Map<string, EnvValue>;
|
|
34
46
|
export declare class ExpressionEvalErrorV3 extends Error {
|
|
35
47
|
}
|
|
@@ -8,15 +8,32 @@
|
|
|
8
8
|
* Throws `TransformationLoadErrorV3` with a breadcrumb path on the
|
|
9
9
|
* first shape violation.
|
|
10
10
|
*/
|
|
11
|
-
import { SubjectKanonak, type Kanonak } from '../../kanonaks/index.js';
|
|
12
|
-
import type { CompiledTransformationV3 } from './CompiledTransformationV3.js';
|
|
11
|
+
import { EmbeddedKanonak, SubjectKanonak, type Kanonak } from '../../kanonaks/index.js';
|
|
12
|
+
import type { CompiledTransformationV3, CompiledExpressionV3 } from './CompiledTransformationV3.js';
|
|
13
13
|
export declare class TransformationLoadErrorV3 extends Error {
|
|
14
14
|
readonly path: string;
|
|
15
15
|
constructor(message: string, path: string);
|
|
16
16
|
}
|
|
17
|
+
export interface CompileContext {
|
|
18
|
+
readonly catalog: Kanonak[];
|
|
19
|
+
readonly depth: number;
|
|
20
|
+
}
|
|
17
21
|
/**
|
|
18
22
|
* Top-level entry point. Determines whether the SubjectKanonak is an
|
|
19
23
|
* InstanceTransformation or SetTransformation by RDF type, then
|
|
20
24
|
* dispatches to the appropriate compiler.
|
|
21
25
|
*/
|
|
22
26
|
export declare function compileTransformationV3(transformation: SubjectKanonak, catalog: Kanonak[]): CompiledTransformationV3;
|
|
27
|
+
/**
|
|
28
|
+
* Compile a single EmbeddedKanonak (a tx.Expression-typed value) into the
|
|
29
|
+
* runtime `CompiledExpressionV3` shape the engine executes. Exposed so
|
|
30
|
+
* consumers OUTSIDE the full Transformation pipeline can use the
|
|
31
|
+
* Expression vocabulary directly — the look renderer uses this to compile
|
|
32
|
+
* a `look.semanticSvg` tier fragment without wrapping it in a synthetic
|
|
33
|
+
* Transformation.
|
|
34
|
+
*
|
|
35
|
+
* `path` is a human-readable trail for error messages; `ctx.catalog`
|
|
36
|
+
* must contain every class/property the Expression references so the
|
|
37
|
+
* loader can resolve URI references.
|
|
38
|
+
*/
|
|
39
|
+
export declare function compileExpression(emb: EmbeddedKanonak, path: string, ctx: CompileContext): CompiledExpressionV3;
|
|
@@ -109,6 +109,11 @@ export declare const TX_V3: {
|
|
|
109
109
|
readonly normKind: EntityUri;
|
|
110
110
|
readonly NormalizeKind: EntityUri;
|
|
111
111
|
readonly NORM_TRIM_END: EntityUri;
|
|
112
|
+
readonly NORM_TO_UPPER: EntityUri;
|
|
113
|
+
readonly NORM_TO_LOWER: EntityUri;
|
|
114
|
+
readonly NORM_FIRST_CHAR: EntityUri;
|
|
115
|
+
readonly UnescapedString: EntityUri;
|
|
116
|
+
readonly unescapedSource: EntityUri;
|
|
112
117
|
readonly IsSet: EntityUri;
|
|
113
118
|
readonly checkExpr: EntityUri;
|
|
114
119
|
readonly ExpressionFragment: EntityUri;
|