@kanonak-protocol/sdk 3.23.0 → 3.25.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 (30) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{chunk-VRZUCZEF.js → chunk-4TJZIM7A.js} +1 -1
  3. package/dist/chunk-7U6IOH7G.js +165 -0
  4. package/dist/{chunk-CNM3SY5S.js → chunk-AV4AVTI6.js} +1 -1
  5. package/dist/{chunk-3JRHG2JH.js → chunk-AZSZXLEH.js} +1 -1
  6. package/dist/chunk-NIGFQYVA.js +1 -0
  7. package/dist/chunk-PB2RWBJN.js +47 -0
  8. package/dist/{chunk-GD4SYMXW.js → chunk-VLBP5CHO.js} +1 -1
  9. package/dist/index.d.ts +5 -3
  10. package/dist/index.js +17 -17
  11. package/dist/look/LookRenderer.d.ts +141 -0
  12. package/dist/look/index.d.ts +1 -0
  13. package/dist/repositories/browser.js +1 -1
  14. package/dist/repositories/index.js +1 -1
  15. package/dist/resolution/KanonakUrlResolver.d.ts +114 -0
  16. package/dist/resolution/index.d.ts +2 -0
  17. package/dist/resolution/index.js +1 -1
  18. package/dist/transformations/TransformationEngine.d.ts +33 -0
  19. package/dist/transformations/index.js +44 -44
  20. package/dist/validation/IKanonakObjectValidator.d.ts +3 -2
  21. package/dist/validation/KanonakObjectValidator.d.ts +3 -2
  22. package/dist/validation/ValidationCache.d.ts +94 -0
  23. package/dist/validation/index.d.ts +1 -0
  24. package/dist/validation/index.js +1 -1
  25. package/dist/validation/rules/repository/IRepositoryValidationRule.d.ts +2 -1
  26. package/dist/validation/rules/repository/InstancePropertyReferenceRule.d.ts +23 -1
  27. package/dist/validation/rules/repository/MarkdownLinkRule.d.ts +2 -1
  28. package/dist/validation/rules/repository/PropertyDomainRule.d.ts +11 -1
  29. package/package.json +2 -2
  30. package/dist/chunk-LPUWDJMI.js +0 -47
package/dist/index.d.ts CHANGED
@@ -8,13 +8,13 @@ export { GitIgnoreFilter } from './filtering/index.js';
8
8
  export type { IGitIgnoreFilter } from './filtering/index.js';
9
9
  export { KanonakParser, KanonakObjectParser, PropertyMetadata, KanonakDocumentPositions, parseWithPositions, findMarkdownLinkAt, } from './parsing/index.js';
10
10
  export type { IKanonakObjectParser, SourcePosition, ImportPackageEntry, ParsedDocumentWithPositions, } from './parsing/index.js';
11
- export { ResourceResolver, KanonakUri, KanonakUriBuilder, parseKanonakAddress, formatKanonakAddress, TypeResolver, ResourceTypeClassifier, findInstancesByType, compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, } from './resolution/index.js';
12
- export type { ResourceResolutionResult, ILogger, InstanceSearchResult, DocumentVersionPick, KanonakAddress, } from './resolution/index.js';
11
+ export { ResourceResolver, KanonakUri, KanonakUriBuilder, parseKanonakAddress, formatKanonakAddress, KanonakUrlResolver, TypeResolver, ResourceTypeClassifier, findInstancesByType, compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, } from './resolution/index.js';
12
+ export type { ResourceResolutionResult, ILogger, InstanceSearchResult, DocumentVersionPick, KanonakAddress, UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './resolution/index.js';
13
13
  export { Kanonak, DefinedKanonak, SubjectKanonak, EmbeddedKanonak, ReferenceKanonak, LiteralKanonak } from './kanonaks/index.js';
14
14
  export type { IStatement } from './statements/index.js';
15
15
  export type { MarkdownLink } from './statements/index.js';
16
16
  export { Statement, ScalarStatement, StringStatement, NumberStatement, BooleanStatement, ReferenceStatement, EmbeddedStatement, ListStatement, MarkdownStatement } from './statements/index.js';
17
- export { OntologyValidationResult, OntologyValidationError, ValidationSeverity, ValidationContext, KanonakObjectValidator, NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, EmbeddedKanonakTypeRule, ImportExistenceRule, UnresolvedReferenceRule, TypeAmbiguityRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, MarkdownLinkRule } from './validation/index.js';
17
+ export { OntologyValidationResult, OntologyValidationError, ValidationSeverity, ValidationContext, ValidationCache, KanonakObjectValidator, NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, EmbeddedKanonakTypeRule, ImportExistenceRule, UnresolvedReferenceRule, TypeAmbiguityRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, MarkdownLinkRule } from './validation/index.js';
18
18
  export type { IKanonakObjectValidator, IDocumentValidationRule, IRepositoryValidationRule } from './validation/index.js';
19
19
  export type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
20
20
  export type { IKanonakParser } from '@kanonak-protocol/types/document/parsing';
@@ -26,4 +26,6 @@ export { loadLockFile, saveLockFile, computeIntegrity, } from './lock/index.js';
26
26
  export type { LockFile, LockEntry } from './lock/index.js';
27
27
  export { findDerivation } from './derivation/index.js';
28
28
  export type { DerivationEntityUri, TransformationReferenceTuple, DerivationLookupResult, } from './derivation/index.js';
29
+ export { LookRenderer } from './look/index.js';
30
+ export type { ResolvedLook } from './look/index.js';
29
31
  export { canonicalForm, canonicalHash } from './canonical/index.js';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-GD4SYMXW.js";import{a as Wt}from"./chunk-ROCCA4BY.js";import{a as Te,b as je,c as Le,d as Ne,e as Fe}from"./chunk-3JRHG2JH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-CNM3SY5S.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-63NJ25ZX.js";import{a as Je,b as mt,c as ft,d as yt,e as gt}from"./chunk-VRZUCZEF.js";import{a as Pe,b as Re,c as we,d as $e,e as xe,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{A as _t,B as Mt,C as zt,D as Gt,a as ht,b as kt,c as bt,d as St,e as Ct,f as Pt,g as Rt,h as wt,i as $t,j as xt,k as vt,l as Et,m as Kt,n as Bt,o as It,p as Tt,q as jt,r as Lt,s as Nt,t as Ft,u as Dt,v as Ot,w as At,x as Ht,y as Vt,z as Ut}from"./chunk-LPUWDJMI.js";import"./chunk-FJ35VIV6.js";import{a as N,b as D,c as Me,e as We}from"./chunk-R2V7IXWN.js";import{a as He,b as j,c as L,d as F,e as Ue,f as _e,g as O,h as A,i as H,j as V,k as U,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.js";import{b as ze,c as Ge}from"./chunk-IXE5THUW.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as to}from"@kanonak-protocol/types/document/models/enums";import{existsSync as ur,readFileSync as pr}from"fs";import{homedir as mr}from"os";import{join as fr}from"path";import{execFile as Jt}from"child_process";import{promisify as qt}from"util";var C=qt(Jt),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 Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-NYXIGTTH.js";import{a as Yt}from"./chunk-7U6IOH7G.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-VLBP5CHO.js";import{a as qt}from"./chunk-ROCCA4BY.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-AZSZXLEH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-AV4AVTI6.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-63NJ25ZX.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-PB2RWBJN.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-R2V7IXWN.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.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-IXE5THUW.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),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)}
5
5
  Ensure the Keychain is unlocked and the CLI has write permission.
6
6
  On managed devices, your IT policy may block credential storage.`)}}async remove(e){let r=i(e);try{await C(R,["delete-generic-password","-s",P,"-a",r],{timeout:1e4})}catch(n){if(X(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${r}': ${w(n)}
7
7
  The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await C(R,["dump-keychain"],{timeout:1e4}),r=[],n=!1;for(let o of e.split(`
8
- `))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as Yt}from"child_process";import{promisify as Xt}from"util";var Zt=Xt(Yt),$="kanonak:",m=class{async get(e){let r=$+i(e),n=`
8
+ `))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as Qt}from"child_process";import{promisify as er}from"util";var tr=er(Qt),x="kanonak:",m=class{async get(e){let r=x+i(e),n=`
9
9
  ${v}
10
10
  $target = [Console]::In.ReadLine()
11
11
  $ptr = [IntPtr]::Zero
@@ -18,7 +18,7 @@ try {
18
18
  [System.Text.Encoding]::Unicode.GetString($bytes)
19
19
  } finally {
20
20
  [CredMan]::CredFree($ptr)
21
- }`;try{let{stdout:o}=await x(n,r),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,r){let n=$+i(e),o=JSON.stringify(r),a=`
21
+ }`;try{let{stdout:o}=await $(n,r),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,r){let n=x+i(e),o=JSON.stringify(r),a=`
22
22
  ${v}
23
23
  $target = [Console]::In.ReadLine()
24
24
  $json = [Console]::In.ReadLine()
@@ -35,13 +35,13 @@ try {
35
35
  if (-not $result) { throw "CredWrite failed" }
36
36
  } finally {
37
37
  [System.Runtime.InteropServices.Marshal]::FreeHGlobal($cred.CredentialBlob)
38
- }`;try{await x(a,`${n}
39
- ${o}`)}catch(s){throw new Error(`Windows Credential Manager write failed: ${String(s)}`)}}async remove(e){let r=$+i(e),n=`
38
+ }`;try{await $(a,`${n}
39
+ ${o}`)}catch(s){throw new Error(`Windows Credential Manager write failed: ${String(s)}`)}}async remove(e){let r=x+i(e),n=`
40
40
  ${v}
41
41
  $target = [Console]::In.ReadLine()
42
- [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await x(n,r)}catch{}}async list(){let e=`
42
+ [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await $(n,r)}catch{}}async list(){let e=`
43
43
  ${v}
44
- ${Qt}
44
+ ${rr}
45
45
  $prefix = [Console]::In.ReadLine()
46
46
  $count = 0
47
47
  $pCreds = [IntPtr]::Zero
@@ -55,8 +55,8 @@ if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
55
55
  }
56
56
  }
57
57
  [CredMan]::CredFree($pCreds)
58
- }`;try{let{stdout:r}=await x(e,$);return r.trim().split(`
59
- `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function x(t,e){for(let r of["pwsh","powershell"])try{return await Zt(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var v=`
58
+ }`;try{let{stdout:r}=await $(e,x);return r.trim().split(`
59
+ `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function $(t,e){for(let r of["pwsh","powershell"])try{return await tr(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var v=`
60
60
  Add-Type -TypeDefinition @"
61
61
  using System;
62
62
  using System.Runtime.InteropServices;
@@ -87,13 +87,13 @@ public class CredMan {
87
87
  [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
88
88
  public static extern bool CredEnumerate(string filter, int flags, out int count, out IntPtr credentials);
89
89
  }
90
- "@`,Qt="";import{execFile as er,spawn as tr}from"child_process";import{promisify as rr}from"util";var K=rr(er),E="kanonak",f=class{async get(e){let r=i(e);try{let{stdout:n}=await K("secret-tool",["lookup","service",E,"publisher",r],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,r){let n=i(e),o=JSON.stringify(r);await new Promise((a,s)=>{let c=tr("secret-tool",["store","--label",`Kanonak: ${n}`,"service",E,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});c.stdin.write(o),c.stdin.end(),c.on("close",l=>{l===0?a():s(new Error(`secret-tool store exited with code ${l}`))}),c.on("error",s)})}async remove(e){let r=i(e);try{await K("secret-tool",["clear","service",E,"publisher",r],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await K("secret-tool",["search","service",E],{timeout:1e4}),r=[];for(let n of e.split(`
91
- `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&r.push(o[1].trim())}return r}catch{return[]}}};async function M(){try{return await K("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Z,mkdirSync as Q,readFileSync as ee,writeFileSync as te}from"fs";import{createCipheriv as nr,createDecipheriv as or,randomBytes as re}from"crypto";import{homedir as ar}from"os";import{join as W,dirname as ne}from"path";var ae=W(ar(),".config","kanonak"),y=W(ae,"keyring.key"),B=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(B))return{};try{let e=this.getOrCreateKey(),r=ee(B);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=or(oe,e,n);s.setAuthTag(o);let c=Buffer.concat([s.update(a),s.final()]);return JSON.parse(c.toString("utf-8"))}catch{return{}}}saveStore(e){let r=this.getOrCreateKey(),n=re(u),o=nr(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(B),{recursive:!0}),te(B,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as ir}from"child_process";import{promisify as sr}from"util";var cr=sr(ir),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${I(n)}
90
+ "@`,rr="";import{execFile as nr,spawn as or}from"child_process";import{promisify as ar}from"util";var K=ar(nr),E="kanonak",f=class{async get(e){let r=i(e);try{let{stdout:n}=await K("secret-tool",["lookup","service",E,"publisher",r],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,r){let n=i(e),o=JSON.stringify(r);await new Promise((a,s)=>{let c=or("secret-tool",["store","--label",`Kanonak: ${n}`,"service",E,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});c.stdin.write(o),c.stdin.end(),c.on("close",l=>{l===0?a():s(new Error(`secret-tool store exited with code ${l}`))}),c.on("error",s)})}async remove(e){let r=i(e);try{await K("secret-tool",["clear","service",E,"publisher",r],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await K("secret-tool",["search","service",E],{timeout:1e4}),r=[];for(let n of e.split(`
91
+ `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&r.push(o[1].trim())}return r}catch{return[]}}};async function M(){try{return await K("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Z,mkdirSync as Q,readFileSync as ee,writeFileSync as te}from"fs";import{createCipheriv as ir,createDecipheriv as sr,randomBytes as re}from"crypto";import{homedir as cr}from"os";import{join as W,dirname as ne}from"path";var ae=W(cr(),".config","kanonak"),y=W(ae,"keyring.key"),B=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(B))return{};try{let e=this.getOrCreateKey(),r=ee(B);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=sr(oe,e,n);s.setAuthTag(o);let c=Buffer.concat([s.update(a),s.final()]);return JSON.parse(c.toString("utf-8"))}catch{return{}}}saveStore(e){let r=this.getOrCreateKey(),n=re(u),o=ir(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(B),{recursive:!0}),te(B,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as lr}from"child_process";import{promisify as dr}from"util";var ur=dr(lr),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${I(n)}
92
92
  Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
93
93
  Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,r){let n=i(e);try{await this.runHelper("store",{publisher:n,credential:r})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${I(o)}
94
- Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${I(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${I(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await cr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw lr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
- Check the 'credentialHelper' path in ~/.kanonak/config.json.`):dr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
96
- The helper may be waiting for authentication to an external vault.`):n}}};function I(t){return t instanceof Error?t.message:String(t)}function lr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function dr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=fr(mr(),".kanonak","config.json"),T=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let r=yr(e);if(r)return r;let o=await(await this.getBackend()).get(e);return!o||!S(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,r){return(await this.getBackend()).store(e,r)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=gr();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await M()?new f:new g}};function yr(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function gr(){if(!ur(J))return{};try{return JSON.parse(pr(J,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${J}: ${e}
97
- Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as hr,createPrivateKey as kr,generateKeyPairSync as br,randomUUID as Sr,sign as Cr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=br("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function k(t,e,r,n,o,a){let s={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},c={jti:Sr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=hr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Pr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Pr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=kr({key:r,format:"jwk"}),l=Cr("SHA256",Buffer.from(a),{key:s,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function se(t){return Buffer.from(t,"utf-8").toString("base64url")}function de(t){let e=new Map;return async(r,n,o="GET")=>{if(!t)return fetch(r,{method:o});let a=await t.getCredential(n);if(!a?.accessToken)return fetch(r,{method:o});b(a)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let s={};if(a.dpopKeyPair){let l=e.get(n);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.Authorization=`DPoP ${a.accessToken}`,s.DPoP=d}catch(d){let Ce=d instanceof Error?d.message:String(d);console.error(` Error: Failed to create DPoP proof for '${n}': ${Ce}
98
- The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),s.Authorization=`Bearer ${a.accessToken}`}}else s.Authorization=`Bearer ${a.accessToken}`;let c=await fetch(r,{method:o,headers:s});if(c.status===401&&a.dpopKeyPair){let l=c.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.DPoP=d,c=await fetch(r,{method:o,headers:s})}catch{}}}return c}}import{readFileSync as Rr,writeFileSync as wr,existsSync as $r}from"fs";import{createHash as xr}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",vr=`# This file is generated by Kanonak CLI. Do not edit manually.
99
- `;function me(t=pe){if(!$r(t))return null;let e=Rr(t,"utf-8"),r=ue.load(e);return!r||typeof r!="object"||r.version!=="1"?null:{version:"1",lastUpdated:r.lastUpdated??new Date().toISOString(),packages:r.packages??{}}}function fe(t,e=pe){t.lastUpdated=new Date().toISOString();let r={};for(let o of Object.keys(t.packages).sort())r[o]=t.packages[o];t.packages=r;let n=ue.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});wr(e,vr+n,"utf-8")}function ye(t){return`sha256:${xr("sha256").update(t).digest("hex")}`}import{createHash as Er}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(Kr(n));return e.sort((n,o)=>n.uri<o.uri?-1:n.uri>o.uri?1:0),JSON.stringify({subjects:e})}function ge(t){let e=q(t);return`sha256:${Er("sha256").update(e,"utf8").digest("hex")}`}function Kr(t){let e=Nr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=Br(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function Br(t){let e=Lr(t);if(!e)return;let r=Ir(t);if(r)return jr(e,r)}function Ir(t){if(t instanceof O)return{type:"string",value:t.object};if(t instanceof A)return{type:"number",value:Se(t.object)};if(t instanceof H)return{type:"boolean",value:t.object};if(t instanceof V)return{type:"ref",value:ke(t.object)};if(t instanceof U){let e=t.object;return he(e)}if(t instanceof _)return{type:"list",items:t.object.map(Tr)}}function he(t){let e=Y(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function Tr(t){if(t instanceof F)return{type:"ref",value:ke(t)};if(t instanceof N)return he(t);if(t instanceof D){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function jr(t,e){switch(e.type){case"string":return{predicate:t,type:"string",value:e.value};case"number":return{predicate:t,type:"number",value:e.value};case"boolean":return{predicate:t,type:"boolean",value:e.value};case"ref":return{predicate:t,type:"ref",value:e.value};case"embedded":return e.name!==void 0?{predicate:t,type:"embedded",name:e.name,statements:e.statements}:{predicate:t,type:"embedded",statements:e.statements};case"list":return{predicate:t,type:"list",items:e.items}}}function Lr(t){let e=t.predicate;if(e)return be(e.subject)}function Nr(t){let e=t.namespace??"",r=t.name??"";return`${e}/${r}`}function ke(t){return be(t.subject)}function be(t){let e=t.version;return e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}/${t.name}`:`${t.publisher}/${t.package_}/${t.name}`}function Se(t){if(Number.isNaN(t))throw new Error("canonicalForm: NaN cannot be canonicalized");if(!Number.isFinite(t))throw new Error("canonicalForm: \xB1Infinity cannot be canonicalized");return Object.is(t,-0)?"0":String(t)}export{Ot as AmbiguousReferenceRule,H as BooleanStatement,Mt as ClassDefinitionRule,Kt as ClassHierarchyCycleRule,Le as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,Ft as DefinitionPropertyReferenceRule,je as DocumentLocation,Ye as EdgeType,N as EmbeddedKanonak,$t as EmbeddedKanonakTypeRule,U as EmbeddedStatement,Te as FileSystemKanonakDocumentRepository,ct as GitIgnoreFilter,Xe as GraphBuilder,Ae as HttpKanonakDocumentRepository,xt as ImportExistenceRule,Be as InMemoryKanonakDocumentRepository,Nt as InstancePropertyReferenceRule,He as Kanonak,dt as KanonakDocumentPositions,We as KanonakObjectParser,Gt as KanonakObjectValidator,Ie as KanonakParser,Ve as KanonakUri,mt as KanonakUriBuilder,nt as KanonakVocabulary,_ as ListStatement,D as LiteralKanonak,zt as MarkdownLinkRule,Me as MarkdownStatement,Lt as NamespaceImportCycleRule,Ct as NamespacePrefixRule,qe as NodeType,A as NumberStatement,at as OWL_RL_CLASSIFICATION_RULES,Ht as ObjectPropertyImportRule,Vt as ObjectPropertyValueValidationRule,bt as OntologyValidationError,ht as OntologyValidationResult,Ut as PropertyDomainRule,Bt as PropertyHierarchyCycleRule,lt as PropertyMetadata,At as PropertyRangeReferenceRule,It as PropertyRangeRequiredRule,Rt as PropertyTypeSpecificityRule,_t as PropertyValueTypeRule,De as PublisherConfigResolver,Oe as PublisherIndex,ot as RDFS_RULES,st as Reasoner,it as ReasoningResult,F as ReferenceKanonak,V as ReferenceStatement,Fe as RepositoryFactory,Pt as ResourceNamingRule,ze as ResourceResolver,Je as ResourceTypeClassifier,_e as ScalarStatement,Ue as Statement,O as StringStatement,Tt as SubClassOfReferenceRule,jt as SubPropertyOfReferenceRule,L as SubjectKanonak,wt as SubjectKanonakTypeRequiredRule,rt as TripleStore,Et as TypeAmbiguityRule,Ge as TypeResolver,vt as UnresolvedReferenceRule,St as ValidationContext,kt as ValidationSeverity,to as VersionOperator,Dt as XsdImportRule,q as canonicalForm,ge as canonicalHash,Pe as compareVersions,ye as computeIntegrity,de as createAuthenticatedFetch,k as createDPoPProof,$e as createVersion,Wt as findDerivation,gt as findInstancesByType,pt as findMarkdownLinkAt,yt as formatKanonakAddress,we as formatVersion,ce as generateDPoPKeyPair,Ne as getGlobalCachePath,S as hasValidToken,ve as isCompatibleVersion,b as isExpired,Ee as isMajorCompatible,me as loadLockFile,Qe as makeUriKey,i as normalizeHost,ft as parseKanonakAddress,xe as parseVersionString,ut as parseWithPositions,Ke as pickHighestDocument,fe as saveLockFile,le as serverSupportsDPoP,et as tripleKey,Ze as uriKey,tt as uriTriple,Re as versionsEqual};
94
+ Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${I(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${I(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await ur(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw pr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`):mr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
96
+ The helper may be waiting for authentication to an external vault.`):n}}};function I(t){return t instanceof Error?t.message:String(t)}function pr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function mr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=hr(gr(),".kanonak","config.json"),T=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let r=kr(e);if(r)return r;let o=await(await this.getBackend()).get(e);return!o||!S(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,r){return(await this.getBackend()).store(e,r)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=br();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await M()?new f:new g}};function kr(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function br(){if(!fr(J))return{};try{return JSON.parse(yr(J,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${J}: ${e}
97
+ Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as Sr,createPrivateKey as Cr,generateKeyPairSync as Pr,randomUUID as Rr,sign as wr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=Pr("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function k(t,e,r,n,o,a){let s={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},c={jti:Rr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=Sr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),xr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function xr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=Cr({key:r,format:"jwk"}),l=wr("SHA256",Buffer.from(a),{key:s,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function se(t){return Buffer.from(t,"utf-8").toString("base64url")}function de(t){let e=new Map;return async(r,n,o="GET")=>{if(!t)return fetch(r,{method:o});let a=await t.getCredential(n);if(!a?.accessToken)return fetch(r,{method:o});b(a)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let s={};if(a.dpopKeyPair){let l=e.get(n);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.Authorization=`DPoP ${a.accessToken}`,s.DPoP=d}catch(d){let Ce=d instanceof Error?d.message:String(d);console.error(` Error: Failed to create DPoP proof for '${n}': ${Ce}
98
+ The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),s.Authorization=`Bearer ${a.accessToken}`}}else s.Authorization=`Bearer ${a.accessToken}`;let c=await fetch(r,{method:o,headers:s});if(c.status===401&&a.dpopKeyPair){let l=c.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.DPoP=d,c=await fetch(r,{method:o,headers:s})}catch{}}}return c}}import{readFileSync as $r,writeFileSync as vr,existsSync as Er}from"fs";import{createHash as Kr}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",Br=`# This file is generated by Kanonak CLI. Do not edit manually.
99
+ `;function me(t=pe){if(!Er(t))return null;let e=$r(t,"utf-8"),r=ue.load(e);return!r||typeof r!="object"||r.version!=="1"?null:{version:"1",lastUpdated:r.lastUpdated??new Date().toISOString(),packages:r.packages??{}}}function fe(t,e=pe){t.lastUpdated=new Date().toISOString();let r={};for(let o of Object.keys(t.packages).sort())r[o]=t.packages[o];t.packages=r;let n=ue.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});vr(e,Br+n,"utf-8")}function ye(t){return`sha256:${Kr("sha256").update(t).digest("hex")}`}import{createHash as Ir}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(Tr(n));return e.sort((n,o)=>n.uri<o.uri?-1:n.uri>o.uri?1:0),JSON.stringify({subjects:e})}function ge(t){let e=q(t);return`sha256:${Ir("sha256").update(e,"utf8").digest("hex")}`}function Tr(t){let e=Or(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=jr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function jr(t){let e=Dr(t);if(!e)return;let r=Lr(t);if(r)return Nr(e,r)}function Lr(t){if(t instanceof O)return{type:"string",value:t.object};if(t instanceof A)return{type:"number",value:Se(t.object)};if(t instanceof U)return{type:"boolean",value:t.object};if(t instanceof V)return{type:"ref",value:ke(t.object)};if(t instanceof H){let e=t.object;return he(e)}if(t instanceof _)return{type:"list",items:t.object.map(Fr)}}function he(t){let e=Y(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function Fr(t){if(t instanceof N)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof D){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function Nr(t,e){switch(e.type){case"string":return{predicate:t,type:"string",value:e.value};case"number":return{predicate:t,type:"number",value:e.value};case"boolean":return{predicate:t,type:"boolean",value:e.value};case"ref":return{predicate:t,type:"ref",value:e.value};case"embedded":return e.name!==void 0?{predicate:t,type:"embedded",name:e.name,statements:e.statements}:{predicate:t,type:"embedded",statements:e.statements};case"list":return{predicate:t,type:"list",items:e.items}}}function Dr(t){let e=t.predicate;if(e)return be(e.subject)}function Or(t){let e=t.namespace??"",r=t.name??"";return`${e}/${r}`}function ke(t){return be(t.subject)}function be(t){let e=t.version;return e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}/${t.name}`:`${t.publisher}/${t.package_}/${t.name}`}function Se(t){if(Number.isNaN(t))throw new Error("canonicalForm: NaN cannot be canonicalized");if(!Number.isFinite(t))throw new Error("canonicalForm: \xB1Infinity cannot be canonicalized");return Object.is(t,-0)?"0":String(t)}export{Ut as AmbiguousReferenceRule,U as BooleanStatement,Gt as ClassDefinitionRule,It as ClassHierarchyCycleRule,Le as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,Ot as DefinitionPropertyReferenceRule,je as DocumentLocation,Ye as EdgeType,F as EmbeddedKanonak,vt as EmbeddedKanonakTypeRule,H as EmbeddedStatement,Te as FileSystemKanonakDocumentRepository,ct as GitIgnoreFilter,Xe as GraphBuilder,Ae as HttpKanonakDocumentRepository,Et as ImportExistenceRule,Be as InMemoryKanonakDocumentRepository,Dt as InstancePropertyReferenceRule,Ue as Kanonak,dt as KanonakDocumentPositions,We as KanonakObjectParser,Jt as KanonakObjectValidator,Ie as KanonakParser,Ve as KanonakUri,mt as KanonakUriBuilder,gt as KanonakUrlResolver,nt as KanonakVocabulary,_ as ListStatement,D as LiteralKanonak,Yt as LookRenderer,Wt as MarkdownLinkRule,Me as MarkdownStatement,Nt as NamespaceImportCycleRule,Rt as NamespacePrefixRule,qe as NodeType,A as NumberStatement,at as OWL_RL_CLASSIFICATION_RULES,Ht as ObjectPropertyImportRule,_t as ObjectPropertyValueValidationRule,St as OntologyValidationError,kt as OntologyValidationResult,Mt as PropertyDomainRule,Tt as PropertyHierarchyCycleRule,lt as PropertyMetadata,Vt as PropertyRangeReferenceRule,jt as PropertyRangeRequiredRule,xt as PropertyTypeSpecificityRule,zt as PropertyValueTypeRule,De as PublisherConfigResolver,Oe as PublisherIndex,ot as RDFS_RULES,st as Reasoner,it as ReasoningResult,N as ReferenceKanonak,V as ReferenceStatement,Ne as RepositoryFactory,wt as ResourceNamingRule,ze as ResourceResolver,Je as ResourceTypeClassifier,_e as ScalarStatement,He as Statement,O as StringStatement,Lt as SubClassOfReferenceRule,Ft as SubPropertyOfReferenceRule,L as SubjectKanonak,$t as SubjectKanonakTypeRequiredRule,rt as TripleStore,Bt as TypeAmbiguityRule,Ge as TypeResolver,Kt as UnresolvedReferenceRule,Pt as ValidationCache,Ct as ValidationContext,bt as ValidationSeverity,oo as VersionOperator,At as XsdImportRule,q as canonicalForm,ge as canonicalHash,Pe as compareVersions,ye as computeIntegrity,de as createAuthenticatedFetch,k as createDPoPProof,xe as createVersion,qt as findDerivation,ht as findInstancesByType,pt as findMarkdownLinkAt,yt as formatKanonakAddress,we as formatVersion,ce as generateDPoPKeyPair,Fe as getGlobalCachePath,S as hasValidToken,ve as isCompatibleVersion,b as isExpired,Ee as isMajorCompatible,me as loadLockFile,Qe as makeUriKey,i as normalizeHost,ft as parseKanonakAddress,$e as parseVersionString,ut as parseWithPositions,Ke as pickHighestDocument,fe as saveLockFile,le as serverSupportsDPoP,et as tripleKey,Ze as uriKey,tt as uriTriple,Re as versionsEqual};
@@ -0,0 +1,141 @@
1
+ /**
2
+ * LookRenderer — declarative visual rendering for Kanonak resources.
3
+ *
4
+ * Consumes `derivation.look` declarations on classes/packages/publishers
5
+ * and produces HTML without requiring publishers to author per-class
6
+ * `tx.InstanceTransformation` packages.
7
+ *
8
+ * Walks the instance's type chain to find the closest class declaring
9
+ * `derivation.look`, falls through to `rdfs.Resource` at the root, then
10
+ * walks the declaration's bands and emits HTML.
11
+ *
12
+ * v0.1 band coverage:
13
+ * - look.Hero : page header with title, eyebrow, subtitle, badges
14
+ * - look.PropertyList : labeled section listing one property's values
15
+ * - look.BadgeRow : clickable type badges from a property holding refs
16
+ * - look.ChipRow : inline labeled chips from a list of properties
17
+ * - look.ReferenceList : labeled definition list of cross-reference groups
18
+ *
19
+ * Still ahead: PropertyTable, Markdown, ResourceGrid, ResourceCount,
20
+ * FeaturedResource bands; token cascade resolution; CSS output via the
21
+ * stylesheet format; TransformationEngine integration.
22
+ */
23
+ import { SubjectKanonak, EmbeddedKanonak, type Kanonak } from '../kanonaks/index.js';
24
+ type Uri = {
25
+ publisher: string;
26
+ package_: string;
27
+ name: string;
28
+ };
29
+ /**
30
+ * The result of walking the cascade to find the look declaration that
31
+ * applies to a given instance. Carries the declaration plus provenance
32
+ * (the class the declaration was sourced from).
33
+ */
34
+ export interface ResolvedLook {
35
+ /** The look declaration — an EmbeddedKanonak with bands and metadata. */
36
+ declaration: EmbeddedKanonak;
37
+ /** The class in the hierarchy where the declaration was found. */
38
+ sourceClass: Uri;
39
+ }
40
+ export declare class LookRenderer {
41
+ private readonly catalog;
42
+ constructor(catalog: Kanonak[]);
43
+ /**
44
+ * Walk the instance's type chain (BFS) looking for the first class
45
+ * that declares `derivation.look`. Falls through to `rdfs.Resource`
46
+ * at the root.
47
+ */
48
+ findCascadedLook(instance: SubjectKanonak): ResolvedLook | undefined;
49
+ /**
50
+ * Walk the instance's type chain merging token declarations by key.
51
+ * Closer-to-instance wins; tokens from different keys merge cleanly.
52
+ *
53
+ * Resolution order:
54
+ * 1. Instance direct (`derivation.tokens` on the instance itself)
55
+ * 2. First-declared type's chain (BFS through subClassOf)
56
+ * 3. Subsequent declared types' chains (already-visited classes skipped)
57
+ * 4. Universal floor (`rdfs.Resource` defaults from look-tokens)
58
+ *
59
+ * Tokens are keyed by their local name (e.g. `"accent"`, not the
60
+ * full URI), assumed globally unique by convention.
61
+ */
62
+ findCascadedTokens(instance: SubjectKanonak): Map<string, string>;
63
+ /**
64
+ * Render the stylesheet for an instance — a CSS string with the
65
+ * cascaded tokens as `--kan-*` custom properties on `:root`, plus
66
+ * the base CSS rules that style the look vocabulary's HTML output
67
+ * (`.kan-hero`, `.kan-property-list`, `.kan-badge`, etc.).
68
+ *
69
+ * The :root variables are derived per-resource (different classes
70
+ * may resolve different accent colors etc.); the base rules are
71
+ * shared across the universal-look layer.
72
+ */
73
+ renderStylesheet(instance: SubjectKanonak): string;
74
+ /**
75
+ * Render the instance as body-only HTML using its cascaded look.
76
+ */
77
+ renderHtml(instance: SubjectKanonak): string;
78
+ private renderBand;
79
+ private renderHero;
80
+ private renderPropertyList;
81
+ private renderBadgeRow;
82
+ private renderChipRow;
83
+ private renderReferenceList;
84
+ /**
85
+ * Read a property's value off an instance and return it as a single
86
+ * piece of text. Strings render verbatim. References resolve to the
87
+ * target's rdfs.label or local name. Lists render as comma-joined.
88
+ * Embeddeds render as their UriName.
89
+ */
90
+ private readPropertyValueText;
91
+ /**
92
+ * Read a property's value off an instance and return any references
93
+ * within. Used by Hero badges, BadgeRow source, ReferenceList entries.
94
+ */
95
+ private readPropertyValueReferences;
96
+ /**
97
+ * Gather the items from a statement value for list-style rendering.
98
+ * Returns the raw IStatement objects (callers dispatch per item).
99
+ */
100
+ private gatherValueItems;
101
+ /**
102
+ * Render one item (from gatherValueItems) as inline HTML — anchor
103
+ * for references, escaped text for strings, UriName for embeddeds.
104
+ * slotUri is the look slot the item came from (used for urlForm).
105
+ */
106
+ private renderInlineValue;
107
+ /**
108
+ * Render a Statement's value as inline HTML — single-line, suitable
109
+ * for a chip's `chip-val` slot. Strings/refs render as expected;
110
+ * lists render as comma-joined items.
111
+ */
112
+ private renderStatementInlineValue;
113
+ /**
114
+ * Render a Kanonak resource reference as a clickable anchor. Label
115
+ * is the target's rdfs.label (fall back to local name). URL form
116
+ * comes from the slot property's `look.urlForm` annotation (defaults
117
+ * to `=` for unannotated properties). Same-publisher refs render as
118
+ * path-only URLs; cross-publisher refs render as full `https://...`.
119
+ */
120
+ private renderReferenceLink;
121
+ /**
122
+ * Render a Kanonak resource reference as a styled type badge with a
123
+ * tooltip from the target's rdfs.comment. Same URL-form rules as
124
+ * renderReferenceLink.
125
+ */
126
+ private renderBadge;
127
+ /**
128
+ * Build a URL string for a reference, applying the slot property's
129
+ * urlForm annotation. The slot property is the look property that
130
+ * "owns" the reference (e.g., look.target on NavLink, look.badges
131
+ * on Hero). Unannotated properties default to `=` (exact pin).
132
+ */
133
+ private urlForReference;
134
+ /** Look up the `look.urlForm` annotation on a property, defaulting to `=`. */
135
+ private getUrlFormForProperty;
136
+ /** Look up rdfs.label of a resource by URI. */
137
+ private readLabelForUri;
138
+ /** Look up rdfs.comment of a resource by URI. */
139
+ private readCommentForUri;
140
+ }
141
+ export {};
@@ -0,0 +1 @@
1
+ export { LookRenderer, type ResolvedLook } from './LookRenderer.js';
@@ -1 +1 @@
1
- import{a as o,b as e,c as r,d as n}from"../chunk-CNM3SY5S.js";import"../chunk-FQHALFRR.js";import"../chunk-MYITGTGJ.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
1
+ import{a as o,b as e,c as r,d as n}from"../chunk-AV4AVTI6.js";import"../chunk-MYITGTGJ.js";import"../chunk-FQHALFRR.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f}from"../chunk-3JRHG2JH.js";import{a,b as g,c as h,d as i}from"../chunk-CNM3SY5S.js";import"../chunk-FQHALFRR.js";import"../chunk-MYITGTGJ.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,i as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,g as PublisherConfigResolver,h as PublisherIndex,f as RepositoryFactory,e as getGlobalCachePath};
1
+ import{a as b,b as c,c as d,d as e,e as f}from"../chunk-AZSZXLEH.js";import{a,b as g,c as h,d as i}from"../chunk-AV4AVTI6.js";import"../chunk-MYITGTGJ.js";import"../chunk-FQHALFRR.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,i as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,g as PublisherConfigResolver,h as PublisherIndex,f as RepositoryFactory,e as getGlobalCachePath};
@@ -0,0 +1,114 @@
1
+ /**
2
+ * KanonakUrlResolver — parse and format Kanonak's HTTP URL hierarchy.
3
+ *
4
+ * The five URL forms:
5
+ *
6
+ * / → publisher view
7
+ * /{package} → package, any version (operator *)
8
+ * /{package}/{version-or-range} → package, version-pinned by operator
9
+ * /{package}/{name} → resource, any version (operator *)
10
+ * /{package}/{version-or-range}/{name} → resource, version-pinned
11
+ *
12
+ * The second path segment encodes the version-compatibility operator
13
+ * via its shape — same operators as Kanonak's `imports.match`:
14
+ *
15
+ * shape `2` → operator `^` (major-pinned: latest 2.x.y)
16
+ * shape `2.4` → operator `~` (minor-pinned: latest 2.4.x)
17
+ * shape `2.4.6` → operator `=` (exact pin)
18
+ * absent → operator `*` (any version, resolve to latest)
19
+ *
20
+ * Disambiguation between `/snapshot/2` (package major-pin) and
21
+ * `/snapshot/view` (resource at latest): the second segment is a
22
+ * version iff it matches `^\d+(\.\d+){0,2}$`. Resource names cannot
23
+ * contain periods (existing rule) nor be purely numeric (new v1 rule),
24
+ * so collisions are impossible.
25
+ *
26
+ * The resolver is stateless — it does NOT consult a repository to
27
+ * resolve `*` / `^` / `~` to a concrete version. That's a separate
28
+ * concern handled by the caller against its catalog. The resolver's
29
+ * job is parsing and formatting.
30
+ */
31
+ import type { Version } from '@kanonak-protocol/types/document/models/types';
32
+ export type VersionSpec = {
33
+ readonly kind: 'any';
34
+ } | {
35
+ readonly kind: 'major-pin';
36
+ readonly major: number;
37
+ } | {
38
+ readonly kind: 'minor-pin';
39
+ readonly major: number;
40
+ readonly minor: number;
41
+ } | {
42
+ readonly kind: 'exact';
43
+ readonly major: number;
44
+ readonly minor: number;
45
+ readonly patch: number;
46
+ };
47
+ /** The operator character corresponding to a VersionSpec. */
48
+ export type UrlForm = '*' | '^' | '~' | '=';
49
+ export type UrlAddress = PublisherUrlAddress | PackageUrlAddress | ResourceUrlAddress;
50
+ export interface PublisherUrlAddress {
51
+ readonly kind: 'publisher';
52
+ readonly publisher: string;
53
+ }
54
+ export interface PackageUrlAddress {
55
+ readonly kind: 'package';
56
+ readonly publisher: string;
57
+ readonly package_: string;
58
+ readonly versionSpec: VersionSpec;
59
+ }
60
+ export interface ResourceUrlAddress {
61
+ readonly kind: 'resource';
62
+ readonly publisher: string;
63
+ readonly package_: string;
64
+ readonly versionSpec: VersionSpec;
65
+ readonly name: string;
66
+ }
67
+ export declare class KanonakUrlResolver {
68
+ /**
69
+ * Parse an HTTP URL or path into a UrlAddress.
70
+ *
71
+ * Accepts:
72
+ * - Full URLs: `https://worldview.genval.ai/snapshot/2.1/view`
73
+ * - Path-only: `/snapshot/2.1/view` — requires `contextPublisher`
74
+ *
75
+ * Returns `null` for unrecognized shapes (4+ path segments, missing
76
+ * publisher when path-only, etc.). The caller treats null as "not a
77
+ * Kanonak URL".
78
+ */
79
+ static parse(urlOrPath: string, contextPublisher?: string): UrlAddress | null;
80
+ /**
81
+ * Format a UrlAddress back into a URL string.
82
+ *
83
+ * Default: full URL with `https://` scheme. Pass `pathOnly: true` to
84
+ * get the path component only — useful for same-publisher links.
85
+ */
86
+ static format(address: UrlAddress, opts?: {
87
+ scheme?: 'https' | 'http';
88
+ pathOnly?: boolean;
89
+ }): string;
90
+ /**
91
+ * Format a pinned resource reference as a URL with a specific
92
+ * version-form operator. This is the rendering-time helper used by
93
+ * the look renderer when emitting `<a href="...">` for cross-resource
94
+ * references — given the pinned target and the property's
95
+ * `look.urlForm` annotation, produce the appropriately-shaped URL.
96
+ *
97
+ * If `target.version` is absent and operator requires a version
98
+ * (`^`, `~`, `=`), the resolver falls back to `*` (any).
99
+ *
100
+ * When `opts.contextPublisher` matches `target.publisher`, the
101
+ * result is a path-only URL (e.g. `/snapshot/2/view`) — natural for
102
+ * same-publisher links. Otherwise the full `https://...` form is
103
+ * emitted.
104
+ */
105
+ static formatResourceUrl(target: {
106
+ publisher: string;
107
+ package_: string;
108
+ version?: Version;
109
+ name: string;
110
+ }, urlForm: UrlForm, opts?: {
111
+ scheme?: 'https' | 'http';
112
+ contextPublisher?: string;
113
+ }): string;
114
+ }
@@ -4,6 +4,8 @@ export { KanonakUri } from './KanonakUri.js';
4
4
  export { KanonakUriBuilder } from './KanonakUriBuilder.js';
5
5
  export { parseKanonakAddress, formatKanonakAddress, } from './KanonakAddress.js';
6
6
  export type { KanonakAddress } from './KanonakAddress.js';
7
+ export { KanonakUrlResolver } from './KanonakUrlResolver.js';
8
+ export type { UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './KanonakUrlResolver.js';
7
9
  export type { ResourceResolutionResult } from './ResourceResolutionResult.js';
8
10
  export { TypeResolver } from './TypeResolver.js';
9
11
  export { ResourceTypeClassifier } from './ResourceTypeClassifier.js';
@@ -1 +1 @@
1
- import{a as l,b as m,c as n,d as o,e as p}from"../chunk-VRZUCZEF.js";import{a,b,c,d,e,f,g,h}from"../chunk-FQHALFRR.js";import{b as j,c as k}from"../chunk-IXE5THUW.js";import{a as i}from"../chunk-FUUTGGJS.js";export{i as KanonakUri,m as KanonakUriBuilder,j as ResourceResolver,l as ResourceTypeClassifier,k as TypeResolver,a as compareVersions,d as createVersion,p as findInstancesByType,o as formatKanonakAddress,c as formatVersion,f as isCompatibleVersion,g as isMajorCompatible,n as parseKanonakAddress,e as parseVersionString,h as pickHighestDocument,b as versionsEqual};
1
+ import{a as l,b as m,c as n,d as o,e as q}from"../chunk-4TJZIM7A.js";import{a as p}from"../chunk-NIGFQYVA.js";import{a,b,c,d,e,f,g,h}from"../chunk-FQHALFRR.js";import{b as j,c as k}from"../chunk-IXE5THUW.js";import{a as i}from"../chunk-FUUTGGJS.js";export{i as KanonakUri,m as KanonakUriBuilder,p as KanonakUrlResolver,j as ResourceResolver,l as ResourceTypeClassifier,k as TypeResolver,a as compareVersions,d as createVersion,q as findInstancesByType,o as formatKanonakAddress,c as formatVersion,f as isCompatibleVersion,g as isMajorCompatible,n as parseKanonakAddress,e as parseVersionString,h as pickHighestDocument,b as versionsEqual};
@@ -39,6 +39,25 @@ export declare class TransformationEngine {
39
39
  constructor(repository: IKanonakDocumentRepository, parser?: KanonakParser, objectParser?: KanonakObjectParser);
40
40
  /** Discard the cached catalog; the next call will re-parse the repository. */
41
41
  invalidate(): void;
42
+ /**
43
+ * Render the given resource through the declarative look layer
44
+ * (`derivation.look` cascade). Returns body-only HTML or a CSS
45
+ * stylesheet depending on the requested format.
46
+ *
47
+ * This is the integration point for the look vocabulary
48
+ * (`kanonak.org/look@1.0.0`): publishers declaring `derivation.look`
49
+ * on their classes get rendered output via this path without
50
+ * needing to author a `tx.InstanceTransformation`.
51
+ *
52
+ * Supported formats: `formats.html`, `formats.stylesheet`. Other
53
+ * formats throw RenderError. Callers select this path explicitly
54
+ * (vs `render()` which routes through `findDerivation` for the
55
+ * legacy transformation-based path).
56
+ */
57
+ renderViaLook(opts: {
58
+ resource: EntityUri;
59
+ format: EntityUri;
60
+ }): Promise<RenderedArtifact>;
42
61
  /**
43
62
  * Walk derivation discovery to find the transformation that should
44
63
  * render the given resource as the given format/variant. Returns
@@ -52,6 +71,20 @@ export declare class TransformationEngine {
52
71
  /**
53
72
  * Discover + run: render the given resource as the given format.
54
73
  * Throws RenderError if no derivation is found or the run fails.
74
+ *
75
+ * Dispatch order:
76
+ * 1. If the resource's class hierarchy declares a custom
77
+ * `derivation.derivations` binding for this (format, variant),
78
+ * run that transformation. Publishers' explicit overrides win.
79
+ * 2. Otherwise, if the resource has a cascaded `derivation.look`
80
+ * AND the format is supported by the look layer (html,
81
+ * stylesheet), route through LookRenderer.
82
+ * 3. Otherwise, fall back to the universal-derivations baseline
83
+ * transformation (also found via findDerivation).
84
+ *
85
+ * This auto-dispatch means callers (Kanonak Browser, CLI, dynamic
86
+ * servers) only need to call `render` — the engine picks the right
87
+ * path based on what the resource's class declares.
55
88
  */
56
89
  render(opts: {
57
90
  resource: EntityUri;