@kanonak-protocol/sdk 3.44.1 → 3.44.2

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.
@@ -26,7 +26,7 @@ ${o}
26
26
  <g class="tier-icon">${c}</g>
27
27
  <g class="tier-card">${l}</g>
28
28
  <g class="tier-full">${d}</g>
29
- </svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,o)=>{let a=o.trim();if(n[a]!==void 0)return re(n[a]);let r=a.indexOf(":");if(r>0){let c=a.slice(0,r),l=a.slice(r+1).trim();if(c==="delta"||c==="deltaArrow"||c==="deltaColor"||c==="deltaDir"){let d=this.metricDelta(t,l);return c==="deltaColor"?d?d.dir==="up"?"#34d399":d.dir==="down"?"#f87171":"#9aa5b8":"#9aa5b8":c==="deltaDir"?d?d.dir:"new":d?c==="deltaArrow"?d.dir==="up"?"\u25B2":d.dir==="down"?"\u25BC":"\u2014":re(`${d.delta>0?"+":""}${d.delta.toFixed(2)}`):""}}let i=this.resolvePath(t,a);return i===void 0?`{{${a}}}`:re(i)})}metricDelta(e,t){let n=g=>{let h=this.resolvePath(g,t),k=h===void 0?NaN:parseFloat(h);return Number.isFinite(k)?k:void 0},s=n(e);if(s===void 0)return;let o=g=>this.parseVersion((g.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},a=(g,h)=>g.major-h.major||g.minor-h.minor||g.patch-h.patch,r={publisher:J(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name},i=o(e),c,l;for(let g of ae(this.catalog,r)){let h=o(g);a(h,i)<0&&(!l||a(h,l)>0)&&(c=g,l=h)}if(!c)return;let d=n(c);if(d===void 0)return;let f=s-d;return{delta:f,dir:Math.abs(f)<.005?"flat":f>0?"up":"down"}}resolvePath(e,t){let n=t.split("/").map(s=>s.trim()).filter(s=>s.length>0);if(n.length!==0)return this.resolvePathSteps(e,n)}resolvePathSteps(e,t){let n=Zn(t[0]),s=Xn(e,n);if(!s)return;let o=t.length===1;if(s instanceof le)return o?void 0:this.resolvePathSteps(s.object,t.slice(1));if(s instanceof V&&s.object instanceof A){let a=s.object.subject,r=ae(this.catalog,a);if(r.length===0){let c=D(this.catalog,a);c&&r.push(c)}if(o){for(let c of r){let l=$(c,N);if(l!==void 0)return l}return a.name}let i=t.slice(1);for(let c of r){let l=this.resolvePathSteps(c,i);if(l!==void 0)return l}return}if(o&&(s instanceof Z||s instanceof me||s instanceof je))return String(s.object)}collectCascadedSvgTiers(e){let t={},n=a=>{let r=se(a,Je);if(!(r instanceof le))return;let i=r.object,c=$(i,Mn),l=$(i,Vn),d=$(i,Dn),f=$(i,Hn);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&d!==void 0&&(t.tierCard=d),t.tierFull===void 0&&f!==void 0&&(t.tierFull=f)};n(e);let s=new Set,o=ue(e);for(;o.length>0;){let a=o.shift(),r=ke(a.subject);if(s.has(r))continue;s.add(r);let i=ae(this.catalog,a.subject);for(let c of i){n(c);for(let l of Se(c))o.push(l)}}if(!s.has(ke(te)))for(let a of ae(this.catalog,te))n(a);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[a,r]of t)n.push(` --kan-${a}: ${r};`);let s=n.length>0?`:root {
29
+ </svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,o)=>{let a=o.trim();if(n[a]!==void 0)return re(n[a]);let r=a.indexOf(":");if(r>0){let c=a.slice(0,r),l=a.slice(r+1).trim();if(c==="delta"||c==="deltaArrow"||c==="deltaColor"||c==="deltaDir"){let d=this.metricDelta(t,l);return c==="deltaColor"?d?d.dir==="up"?"#34d399":d.dir==="down"?"#f87171":"#9aa5b8":"#9aa5b8":c==="deltaDir"?d?d.dir:"new":d?c==="deltaArrow"?d.dir==="up"?"\u25B2":d.dir==="down"?"\u25BC":"\u2014":re(`${d.delta>0?"+":""}${d.delta.toFixed(2)}`):""}if(c==="svg")return this.resolvePath(t,l)??""}let i=this.resolvePath(t,a);return i===void 0?`{{${a}}}`:re(i)})}metricDelta(e,t){let n=g=>{let h=this.resolvePath(g,t),k=h===void 0?NaN:parseFloat(h);return Number.isFinite(k)?k:void 0},s=n(e);if(s===void 0)return;let o=g=>this.parseVersion((g.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},a=(g,h)=>g.major-h.major||g.minor-h.minor||g.patch-h.patch,r={publisher:J(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name},i=o(e),c,l;for(let g of ae(this.catalog,r)){let h=o(g);a(h,i)<0&&(!l||a(h,l)>0)&&(c=g,l=h)}if(!c)return;let d=n(c);if(d===void 0)return;let f=s-d;return{delta:f,dir:Math.abs(f)<.005?"flat":f>0?"up":"down"}}resolvePath(e,t){let n=t.split("/").map(s=>s.trim()).filter(s=>s.length>0);if(n.length!==0)return this.resolvePathSteps(e,n)}resolvePathSteps(e,t){let n=Zn(t[0]),s=Xn(e,n);if(!s)return;let o=t.length===1;if(s instanceof le)return o?void 0:this.resolvePathSteps(s.object,t.slice(1));if(s instanceof V&&s.object instanceof A){let a=s.object.subject,r=ae(this.catalog,a);if(r.length===0){let c=D(this.catalog,a);c&&r.push(c)}if(o){for(let c of r){let l=$(c,N);if(l!==void 0)return l}return a.name}let i=t.slice(1);for(let c of r){let l=this.resolvePathSteps(c,i);if(l!==void 0)return l}return}if(o&&(s instanceof Z||s instanceof me||s instanceof je))return String(s.object)}collectCascadedSvgTiers(e){let t={},n=a=>{let r=se(a,Je);if(!(r instanceof le))return;let i=r.object,c=$(i,Mn),l=$(i,Vn),d=$(i,Dn),f=$(i,Hn);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&d!==void 0&&(t.tierCard=d),t.tierFull===void 0&&f!==void 0&&(t.tierFull=f)};n(e);let s=new Set,o=ue(e);for(;o.length>0;){let a=o.shift(),r=ke(a.subject);if(s.has(r))continue;s.add(r);let i=ae(this.catalog,a.subject);for(let c of i){n(c);for(let l of Se(c))o.push(l)}}if(!s.has(ke(te)))for(let a of ae(this.catalog,te))n(a);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[a,r]of t)n.push(` --kan-${a}: ${r};`);let s=n.length>0?`:root {
30
30
  ${n.join(`
31
31
  `)}
32
32
  }`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(J(e))??"";return`${s}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as et,b as tt,c as rt,d as nt,e as ot,f as at,g as it,h as st,i as ct,j as lt}from"./chunk-IOJMTW4T.js";import{b as Xt}from"./chunk-H2ZGQOVO.js";import{a as Xe,b as Ze,c as Qe,d as b,e as S,f as i}from"./chunk-RCI34BYO.js";import{a as Yt}from"./chunk-BFZZ6YGX.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as ut,b as pt,c as mt,d as ft}from"./chunk-NIJV5UYW.js";import{a as Ye,b as yt,c as gt,d as ht,e as bt}from"./chunk-4TJZIM7A.js";import{a as kt}from"./chunk-NIGFQYVA.js";import{A as Gt,B as Wt,C as Jt,D as qt,a as St,b as Ct,c as Pt,d as Rt,e as wt,f as xt,g as $t,h as vt,i as Et,j as Kt,k as Bt,l as It,m as Tt,n as jt,o as Lt,p as Ft,q as Nt,r as Dt,s as Ot,t as At,u as Ut,v as Mt,w as Vt,x as Ht,y as _t,z as zt}from"./chunk-SKTXJV4T.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as _e,d as We,e as Je,f as qe}from"./chunk-FMYLEPMC.js";import{a as Ue,b as j,c as L,d as N,e as Ve,f as He,g as O,h as A,i as U,j as M,k as V,l as H}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-HEMBMX7T.js";import{a as Me}from"./chunk-FUUTGGJS.js";import{a as dt}from"./chunk-ODIECDN7.js";import{VersionOperator as io}from"@kanonak-protocol/types/document/models/enums";import{existsSync as yr,readFileSync as gr}from"fs";import{homedir as hr}from"os";import{join as kr}from"path";import{execFile as Zt}from"child_process";import{promisify as Qt}from"util";var C=Qt(Zt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
1
+ import{a as et,b as tt,c as rt,d as nt,e as ot,f as at,g as it,h as st,i as ct,j as lt}from"./chunk-IOJMTW4T.js";import{b as Xt}from"./chunk-Y4YVFGEX.js";import{a as Xe,b as Ze,c as Qe,d as b,e as S,f as i}from"./chunk-RCI34BYO.js";import{a as Yt}from"./chunk-BFZZ6YGX.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as ut,b as pt,c as mt,d as ft}from"./chunk-NIJV5UYW.js";import{a as Ye,b as yt,c as gt,d as ht,e as bt}from"./chunk-4TJZIM7A.js";import{a as kt}from"./chunk-NIGFQYVA.js";import{A as Gt,B as Wt,C as Jt,D as qt,a as St,b as Ct,c as Pt,d as Rt,e as wt,f as xt,g as $t,h as vt,i as Et,j as Kt,k as Bt,l as It,m as Tt,n as jt,o as Lt,p as Ft,q as Nt,r as Dt,s as Ot,t as At,u as Ut,v as Mt,w as Vt,x as Ht,y as _t,z as zt}from"./chunk-SKTXJV4T.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as _e,d as We,e as Je,f as qe}from"./chunk-FMYLEPMC.js";import{a as Ue,b as j,c as L,d as N,e as Ve,f as He,g as O,h as A,i as U,j as M,k as V,l as H}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-HEMBMX7T.js";import{a as Me}from"./chunk-FUUTGGJS.js";import{a as dt}from"./chunk-ODIECDN7.js";import{VersionOperator as io}from"@kanonak-protocol/types/document/models/enums";import{existsSync as yr,readFileSync as gr}from"fs";import{homedir as hr}from"os";import{join as kr}from"path";import{execFile as Zt}from"child_process";import{promisify as Qt}from"util";var C=Qt(Zt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
2
2
  Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
3
3
  The Keychain may be locked or inaccessible.
4
4
  Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
@@ -1,4 +1,4 @@
1
- import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-H2ZGQOVO.js";import{a as Oe}from"../chunk-BFZZ6YGX.js";import"../chunk-NIJV5UYW.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,f as Ce}from"../chunk-FMYLEPMC.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-7CUTGGH3.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-Y4YVFGEX.js";import{a as Oe}from"../chunk-BFZZ6YGX.js";import"../chunk-NIJV5UYW.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,f as Ce}from"../chunk-FMYLEPMC.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-7CUTGGH3.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
2
2
  `);return n?.trailingNewline&&(u.endsWith(`
3
3
  `)||(u+=`
4
4
  `)),u}};function kt(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Ie(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Ie(t,e){switch(t.kind){case"StringScalar":return ht(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Ie(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function ht(t,e){return!e||Ne(e,k.ESC_RAW)?t:Ne(e,k.ESC_YAML_SAFE)?bt(t):t}function bt(t){return t.includes(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "3.44.1",
3
+ "version": "3.44.2",
4
4
  "description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -113,7 +113,7 @@
113
113
  "yaml-parser"
114
114
  ],
115
115
  "dependencies": {
116
- "@kanonak-protocol/types": "^3.44.1",
116
+ "@kanonak-protocol/types": "^3.44.2",
117
117
  "ignore": "^7.0.5",
118
118
  "js-yaml": "^4.1.0",
119
119
  "yaml": "^2.7.0"