@kanonak-protocol/cli 3.71.0 → 3.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -117,7 +117,7 @@ Examples:
117
117
  # Write the result to a file.
118
118
  $ kanonak view run example.org/authors/AuthorView --out ./result.kan.yml
119
119
  `).action(async(e,t)=>{try{await vs(e,t)}catch(o){console.error(`Error: ${o.message}`),process.exit(1)}}),n}async function vs(n,e){let t=D(n);if(!t||!t.instanceName)throw new Error(`Invalid view URI "${n}". Expected publisher/package[@version]/name.`);let o=new ws,r=await $(process.cwd(),o),a=new bs(r,o),s={resolvedAt:new Date().toISOString()};e.id&&(s.invocationId=e.id);let i=await a.materialize({publisher:t.publisher,package_:t.packageName,name:t.instanceName},s);if(e.out){let c=ys(e.out);ks(c,i.yaml,"utf-8"),console.error(`Materialized ${i.rowCount} result(s) \u2192 ${c}
120
- ${i.publisher}/${i.packageName} (${i.contentHash})`)}else process.stdout.write(i.yaml)}import{Command as $s}from"commander";import{writeFileSync as x,mkdirSync as L}from"fs";import{join as S,resolve as zn,dirname as Ss}from"path";import{SubjectKanonak as Ps}from"@kanonak-protocol/sdk";import{loadServerModel as Cs,route as Rs}from"@kanonak-protocol/sdk/server";function Bn(){return new $s("publish").description("Generate a static Kanonak site from the local workspace \u2014 the same origin `kanonak serve` produces (it shares serve's model + renderer), frozen to disk under --out.").option("--workspace <dir>","Workspace directory containing .kan.yml package files. Defaults to current directory.",process.cwd()).option("--out <dir>","Output directory for the generated site. Defaults to _site.","_site").option("--publisher <domain>","Publisher to publish (required only if the workspace has more than one).").action(async n=>{await _s(n)})}async function _s(n){let e=zn(n.workspace),t=zn(n.out),o=await Cs(e,n.publisher?{publisher:n.publisher}:{}),{catalog:r,lookRenderer:a,localNamespaces:s,rawByNsKey:i,publisher:c}=o;L(t,{recursive:!0}),console.log(`Publishing ${c} \u2014 ${s.size} package version(s) to ${t}`);let l=r.filter(g=>g instanceof Ps&&s.has(g.namespace||""));console.log(`Rendering ${l.length} resource(s).`);let u=0,p=0;for(let g of l){let m=(g.namespace||"").split("/")[1]??"",[k,h]=m.split("@");if(!k||!h)continue;let y=S(t,k,h);L(y,{recursive:!0});try{let w=a.renderRawMarkdown(g);w!==void 0&&(x(S(y,`${g.name}.md`),w,"utf-8"),u+=1),x(S(y,`${g.name}.html`),a.renderDocument(g),"utf-8"),x(S(y,`${g.name}.css`),a.renderStylesheet(g),"utf-8"),x(S(y,`${g.name}.svg`),await a.renderSvg(g),"utf-8"),u+=3}catch(w){console.warn(` ${g.namespace}/${g.name}: ${w.message}`),p+=1}}console.log(`Done. ${u} artifact(s) written, ${p} skipped.`);let d=Is(t,l,a);console.log(`Wrote ${d} package overview page(s).`),Ks(t,l,a);let f=Ts(t,l);console.log(`Wrote ${f} version-form redirect stub(s).`),await xs(t,o)}async function xs(n,e){if(e.rawByNsKey.size===0)return;let t=async(o,r)=>{let a=S(n,r);L(Ss(a),{recursive:!0}),x(a,(await Rs(e,o)).body,"utf-8")};await t("/.well-known/kanonak.json",".well-known/kanonak.json"),await t("/index.txt","index.txt");for(let o of e.rawByNsKey.keys()){let[r,a]=o.split("@");!r||!a||await t(`/${r}/${a}.kan.yml`,`${r}/${a}.kan.yml`)}console.log(`Wrote publisher endpoints: index.txt, .well-known/kanonak.json, and ${e.rawByNsKey.size} raw package source(s).`)}function Is(n,e,t){let o=new Map,r=new Map;for(let i of e){let c=i.namespace||"",[,l]=c.split("/");if(!l)continue;let[u,p]=l.split("@");if(!u||!p||i.name!==u)continue;let d=p.split(".").map(Number);if(d.length!==3||d.some(m=>Number.isNaN(m)))continue;let f={verStr:p,major:d[0],minor:d[1],patch:d[2]};o.has(u)||o.set(u,[]),o.get(u).push({resource:i,ver:f});let g=r.get(u);(!g||f.major>g.ver.major||f.major===g.ver.major&&f.minor>g.ver.minor||f.major===g.ver.major&&f.minor===g.ver.minor&&f.patch>g.ver.patch)&&r.set(u,{resource:i,ver:f})}let a=(i,c)=>{try{return L(i,{recursive:!0}),x(S(i,"index.html"),t.renderDocument(c),"utf-8"),x(S(i,`${c.name}.css`),t.renderStylesheet(c),"utf-8"),!0}catch{return!1}},s=0;for(let[i,c]of o)for(let{resource:l,ver:u}of c)a(S(n,i,u.verStr),l)&&(s+=1);for(let[i,{resource:c}]of r){let l=S(n,i);try{if(L(l,{recursive:!0}),t.hasDeclaredView(c))x(S(l,"index.html"),t.renderDocument(c,{bareOverview:!0}),"utf-8"),x(S(l,`${c.name}.css`),t.renderStylesheet(c),"utf-8");else{let u=(o.get(i)??[]).slice().sort((p,d)=>d.ver.major-p.ver.major||d.ver.minor-p.ver.minor||d.ver.patch-p.ver.patch).map(p=>p.ver.verStr);x(S(l,"index.html"),t.renderPackageVersionList(i,u,c),"utf-8"),x(S(l,`${c.name}.css`),t.renderStylesheet(c),"utf-8")}s+=1}catch{}}return s}function Ks(n,e,t){let o="",r=new Map;for(let s of e){let c=(s.namespace||"").split("/"),[l]=(c[1]??"").split("@");if(!c[0]||!l||(o||(o=c[0]),s.name!==l))continue;let u=(c[1]??"").split("@")[1]??"",p=u.split(".").map(Number);if(p.length!==3||p.some(g=>Number.isNaN(g)))continue;let d={verStr:u,major:p[0],minor:p[1],patch:p[2]},f=r.get(l);(!f||d.major>f.ver.major||d.major===f.ver.major&&d.minor>f.ver.minor||d.major===f.ver.major&&d.minor===f.ver.minor&&d.patch>f.ver.patch)&&r.set(l,{resource:s,ver:d})}if(!o||r.size===0)return;let a=t.publisherSubject(o);x(S(n,"index.html"),t.renderDocument(a,{rootIndex:!0}),"utf-8"),x(S(n,"index.css"),t.renderStylesheet(a),"utf-8")}function Ts(n,e){let t=new Map;for(let r of e){let a=r.namespace||"",[,s]=a.split("/");if(!s)continue;let[i,c]=s.split("@");if(!i||!c)continue;let l=c.split(".").map(Number);if(l.length!==3||l.some(p=>Number.isNaN(p)))continue;let u=`${i}/${r.name}`;t.has(u)||t.set(u,[]),t.get(u).push({verStr:c,major:l[0],minor:l[1],patch:l[2]})}let o=0;for(let[r,a]of t){let[s,i]=r.split("/");a.sort((p,d)=>d.major-p.major||d.minor-p.minor||d.patch-p.patch);let c=a[0];x(S(n,s,`${i}.html`),Ee(`/${s}/${c.verStr}/${i}`),"utf-8"),o+=1;let l=new Set;for(let p of a){if(l.has(p.major))continue;l.add(p.major);let d=S(n,s,String(p.major));L(d,{recursive:!0}),x(S(d,`${i}.html`),Ee(`/${s}/${p.verStr}/${i}`),"utf-8"),o+=1}let u=new Set;for(let p of a){let d=`${p.major}.${p.minor}`;if(u.has(d))continue;u.add(d);let f=S(n,s,d);L(f,{recursive:!0}),x(S(f,`${i}.html`),Ee(`/${s}/${p.verStr}/${i}`),"utf-8"),o+=1}}return o}function Ee(n){let e=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return`<!doctype html>
120
+ ${i.publisher}/${i.packageName} (${i.contentHash})`)}else process.stdout.write(i.yaml)}import{Command as $s}from"commander";import{writeFileSync as x,mkdirSync as L}from"fs";import{join as S,resolve as zn,dirname as Ss}from"path";import{SubjectKanonak as Ps}from"@kanonak-protocol/sdk";import{loadServerModel as Cs,route as Rs}from"@kanonak-protocol/sdk/server";function Bn(){return new $s("publish").description("Generate a static Kanonak site from the local workspace \u2014 the same origin `kanonak serve` produces (it shares serve's model + renderer), frozen to disk under --out.").option("--workspace <dir>","Workspace directory containing .kan.yml package files. Defaults to current directory.",process.cwd()).option("--out <dir>","Output directory for the generated site. Defaults to _site.","_site").option("--publisher <domain>","Publisher to publish (required only if the workspace has more than one).").action(async n=>{await _s(n)})}async function _s(n){let e=zn(n.workspace),t=zn(n.out),o=await Cs(e,n.publisher?{publisher:n.publisher}:{}),{catalog:r,lookRenderer:a,localNamespaces:s,rawByNsKey:i,publisher:c}=o;L(t,{recursive:!0}),console.log(`Publishing ${c} \u2014 ${s.size} package version(s) to ${t}`);let l=r.filter(g=>g instanceof Ps&&s.has(g.namespace||""));console.log(`Rendering ${l.length} resource(s).`);let u=0,p=0;for(let g of l){let m=(g.namespace||"").split("/")[1]??"",[k,h]=m.split("@");if(!k||!h)continue;let y=S(t,k,h);L(y,{recursive:!0});try{let w=a.renderRawMarkdown(g);w!==void 0&&(x(S(y,`${g.name}.md`),w,"utf-8"),u+=1),x(S(y,`${g.name}.html`),await a.renderDocument(g),"utf-8"),x(S(y,`${g.name}.css`),a.renderStylesheet(g),"utf-8"),x(S(y,`${g.name}.svg`),await a.renderSvg(g),"utf-8"),u+=3}catch(w){console.warn(` ${g.namespace}/${g.name}: ${w.message}`),p+=1}}console.log(`Done. ${u} artifact(s) written, ${p} skipped.`);let d=await Is(t,l,a);console.log(`Wrote ${d} package overview page(s).`),await Ks(t,l,a);let f=Ts(t,l);console.log(`Wrote ${f} version-form redirect stub(s).`),await xs(t,o)}async function xs(n,e){if(e.rawByNsKey.size===0)return;let t=async(o,r)=>{let a=S(n,r);L(Ss(a),{recursive:!0}),x(a,(await Rs(e,o)).body,"utf-8")};await t("/.well-known/kanonak.json",".well-known/kanonak.json"),await t("/index.txt","index.txt");for(let o of e.rawByNsKey.keys()){let[r,a]=o.split("@");!r||!a||await t(`/${r}/${a}.kan.yml`,`${r}/${a}.kan.yml`)}console.log(`Wrote publisher endpoints: index.txt, .well-known/kanonak.json, and ${e.rawByNsKey.size} raw package source(s).`)}async function Is(n,e,t){let o=new Map,r=new Map;for(let i of e){let c=i.namespace||"",[,l]=c.split("/");if(!l)continue;let[u,p]=l.split("@");if(!u||!p||i.name!==u)continue;let d=p.split(".").map(Number);if(d.length!==3||d.some(m=>Number.isNaN(m)))continue;let f={verStr:p,major:d[0],minor:d[1],patch:d[2]};o.has(u)||o.set(u,[]),o.get(u).push({resource:i,ver:f});let g=r.get(u);(!g||f.major>g.ver.major||f.major===g.ver.major&&f.minor>g.ver.minor||f.major===g.ver.major&&f.minor===g.ver.minor&&f.patch>g.ver.patch)&&r.set(u,{resource:i,ver:f})}let a=async(i,c)=>{try{return L(i,{recursive:!0}),x(S(i,"index.html"),await t.renderDocument(c),"utf-8"),x(S(i,`${c.name}.css`),t.renderStylesheet(c),"utf-8"),!0}catch{return!1}},s=0;for(let[i,c]of o)for(let{resource:l,ver:u}of c)await a(S(n,i,u.verStr),l)&&(s+=1);for(let[i,{resource:c}]of r){let l=S(n,i);try{if(L(l,{recursive:!0}),t.hasDeclaredView(c))x(S(l,"index.html"),await t.renderDocument(c,{bareOverview:!0}),"utf-8"),x(S(l,`${c.name}.css`),t.renderStylesheet(c),"utf-8");else{let u=(o.get(i)??[]).slice().sort((p,d)=>d.ver.major-p.ver.major||d.ver.minor-p.ver.minor||d.ver.patch-p.ver.patch).map(p=>p.ver.verStr);x(S(l,"index.html"),t.renderPackageVersionList(i,u,c),"utf-8"),x(S(l,`${c.name}.css`),t.renderStylesheet(c),"utf-8")}s+=1}catch{}}return s}async function Ks(n,e,t){let o="",r=new Map;for(let s of e){let c=(s.namespace||"").split("/"),[l]=(c[1]??"").split("@");if(!c[0]||!l||(o||(o=c[0]),s.name!==l))continue;let u=(c[1]??"").split("@")[1]??"",p=u.split(".").map(Number);if(p.length!==3||p.some(g=>Number.isNaN(g)))continue;let d={verStr:u,major:p[0],minor:p[1],patch:p[2]},f=r.get(l);(!f||d.major>f.ver.major||d.major===f.ver.major&&d.minor>f.ver.minor||d.major===f.ver.major&&d.minor===f.ver.minor&&d.patch>f.ver.patch)&&r.set(l,{resource:s,ver:d})}if(!o||r.size===0)return;let a=t.publisherSubject(o);x(S(n,"index.html"),await t.renderDocument(a,{rootIndex:!0}),"utf-8"),x(S(n,"index.css"),t.renderStylesheet(a),"utf-8")}function Ts(n,e){let t=new Map;for(let r of e){let a=r.namespace||"",[,s]=a.split("/");if(!s)continue;let[i,c]=s.split("@");if(!i||!c)continue;let l=c.split(".").map(Number);if(l.length!==3||l.some(p=>Number.isNaN(p)))continue;let u=`${i}/${r.name}`;t.has(u)||t.set(u,[]),t.get(u).push({verStr:c,major:l[0],minor:l[1],patch:l[2]})}let o=0;for(let[r,a]of t){let[s,i]=r.split("/");a.sort((p,d)=>d.major-p.major||d.minor-p.minor||d.patch-p.patch);let c=a[0];x(S(n,s,`${i}.html`),Ee(`/${s}/${c.verStr}/${i}`),"utf-8"),o+=1;let l=new Set;for(let p of a){if(l.has(p.major))continue;l.add(p.major);let d=S(n,s,String(p.major));L(d,{recursive:!0}),x(S(d,`${i}.html`),Ee(`/${s}/${p.verStr}/${i}`),"utf-8"),o+=1}let u=new Set;for(let p of a){let d=`${p.major}.${p.minor}`;if(u.has(d))continue;u.add(d);let f=S(n,s,d);L(f,{recursive:!0}),x(S(f,`${i}.html`),Ee(`/${s}/${p.verStr}/${i}`),"utf-8"),o+=1}}return o}function Ee(n){let e=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return`<!doctype html>
121
121
  <meta charset="utf-8">
122
122
  <title>Redirecting\u2026</title>
123
123
  <meta http-equiv="refresh" content="0; url=${e}">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/cli",
3
- "version": "3.71.0",
3
+ "version": "3.73.0",
4
4
  "description": "Command-line tool for the Kanonak Protocol — validate, resolve, preview, and publish semantic ontology packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,8 +35,8 @@
35
35
  "semantic-web"
36
36
  ],
37
37
  "dependencies": {
38
- "@kanonak-protocol/sdk": "^3.71.0",
39
- "@kanonak-protocol/types": "^3.71.0",
38
+ "@kanonak-protocol/sdk": "^3.73.0",
39
+ "@kanonak-protocol/types": "^3.73.0",
40
40
  "commander": "^13.0.0",
41
41
  "js-yaml": "^4.1.1"
42
42
  },