@kanonak-protocol/sdk 3.70.0 → 3.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{chunk-N224PFBI.js → chunk-BGQKZBNE.js} +1 -1
  3. package/dist/chunk-CRKSKIAL.js +1 -0
  4. package/dist/{chunk-W4LPC6VM.js → chunk-F5ANO7MJ.js} +1 -1
  5. package/dist/{chunk-2OXZDBHX.js → chunk-FX7JDGL6.js} +1 -1
  6. package/dist/chunk-G2DKKSZ4.js +1 -0
  7. package/dist/{chunk-6T2XFOMU.js → chunk-GN2XODVC.js} +1 -1
  8. package/dist/{chunk-U75VPNYW.js → chunk-HAR3BNTB.js} +1 -1
  9. package/dist/chunk-IOMNZBK4.js +1 -0
  10. package/dist/{chunk-C5NKFT7W.js → chunk-MCU5IAMS.js} +24 -24
  11. package/dist/{chunk-EOMKFFKU.js → chunk-OFSARZX6.js} +1 -1
  12. package/dist/chunk-RRODBYIK.js +74 -0
  13. package/dist/chunk-TJPQETHV.js +1 -0
  14. package/dist/{chunk-7ZCFYITD.js → chunk-Y7TGQ7UF.js} +1 -1
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +26 -26
  17. package/dist/parsing/index.js +1 -1
  18. package/dist/reasoning/index.js +1 -1
  19. package/dist/repositories/browser.js +1 -1
  20. package/dist/repositories/index.js +1 -1
  21. package/dist/resolution/index.js +1 -1
  22. package/dist/search/index.js +1 -1
  23. package/dist/server/index.js +1 -1
  24. package/dist/transformations/index.js +1 -1
  25. package/dist/uri-helpers/UriHelpers.d.ts +18 -0
  26. package/dist/uri-helpers/index.d.ts +1 -1
  27. package/dist/uri-helpers/index.js +1 -1
  28. package/dist/validation/TxExpressionPathChecker.d.ts +39 -0
  29. package/dist/validation/index.d.ts +1 -1
  30. package/dist/validation/index.js +1 -1
  31. package/dist/validation/rules/repository/LookSemanticSvgPathRule.d.ts +13 -23
  32. package/dist/validation/rules/repository/TxExpressionPathRule.d.ts +28 -0
  33. package/dist/validation/rules/repository/index.d.ts +1 -0
  34. package/dist/view/ViewMaterializer.d.ts +71 -0
  35. package/dist/view/index.d.ts +2 -0
  36. package/package.json +2 -2
  37. package/dist/chunk-64TVBQFR.js +0 -1
  38. package/dist/chunk-ORFSMEMM.js +0 -1
  39. package/dist/chunk-PODBS4IU.js +0 -1
  40. package/dist/chunk-Q4DKP5DO.js +0 -1
  41. package/dist/chunk-XEFBKQY5.js +0 -64
@@ -1 +1 @@
1
- import{d as v}from"./chunk-U75VPNYW.js";import{a as A}from"./chunk-4NO7MHS7.js";import{a as f}from"./chunk-ORFSMEMM.js";import{c as w,d as I,h as R,i as F}from"./chunk-2ACBWC7K.js";import*as i from"fs/promises";import*as c from"path";import{pathToFileURL as b}from"url";import{VersionOperator as P}from"@kanonak-protocol/types/document/models/enums";var y=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(e,t=!0,n){if(!e||e.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=c.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=c.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=c.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;switch(t.versionOperator){case P.Exact:return I(r,t.version);case P.Compatible:return R(r,t.version);case P.Major:return F(r,t.version);case P.Any:return w(r,t.minVersion)>=0;default:return!1}});return s.length===0?null:(s.sort((a,r)=>{let m=a.metadata.namespace_.version,l=r.metadata.namespace_.version;return w(l,m)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let m=o.split("/"),l=m[0],p=m[1].replace("@","@")+".kan.yml";n=c.join(this.rootPath,l,p)}else n=c.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=c.dirname(n);await i.mkdir(s,{recursive:!0});let a=this.parser.save(e);await i.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=c.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await i.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=c.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=c.join(this.rootPath,e);try{let s=await i.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await i.unlink(c.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[m,l]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&l.metadata.namespace_){s=l.metadata.namespace_.toString();break}let a=s??c.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}try{return await i.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await i.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await i.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=c.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await i.readdir(e,{withFileTypes:!0});for(let s of o){let a=c.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as d from"fs";var S=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(S||{}),k=class{cache;workspace;constructor(e,t,n){let o=n??new f;d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.existsSync(t)||d.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as _}from"os";import{join as N}from"path";function g(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||N(_(),".kanonak","packages")}var C=class u{static createComposite(e,t,n){let o=e??g(),s=t??".";return new k(o,s,n)}static createFromEnvironment(e){let t=g(),n=process.env.KANONAK_WORKSPACE_PATH??".";return u.createComposite(t,n,e)}};var D=class{repos;constructor(...e){this.repos=e}async getHighestCompatibleVersionAsync(e,t){for(let n of this.repos)try{let o=await n.getHighestCompatibleVersionAsync(e,t);if(o)return o}catch{}return null}async getAllDocumentsAsync(){let e=[],t=new Set;for(let n of this.repos)try{for(let o of await n.getAllDocumentsAsync()){let s=o.metadata?.namespace_,a=s?s.version?`${s.publisher}/${s.package_}@${s.version.major}.${s.version.minor}.${s.version.patch}`:`${s.publisher}/${s.package_}`:void 0;if(a!==void 0){if(t.has(a))continue;t.add(a)}e.push(o)}}catch{}return e}async getDocumentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentAsync(e);if(n)return n}catch{}return null}async getDocumentsByNamespaceAsync(e,t){for(let n of this.repos)try{let o=await n.getDocumentsByNamespaceAsync(e,t);if(o.length>0)return o}catch{}return[]}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentContentAsync(e);if(n)return n}catch{}return null}async getDocumentUriAsync(e){for(let t of this.repos)try{let n=await t.getDocumentUriAsync(e);if(n)return n}catch{}return null}};import{readFileSync as B,readdirSync as H}from"fs";import{join as x}from"path";var $=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function K(u,e=[]){for(let t of H(u,{withFileTypes:!0}))t.isDirectory()?$.has(t.name)||K(x(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(x(u,t.name));return e}async function j(u,e=new f,t={}){let n=new A(e);for(let m of K(u))try{let l=e.parse(B(m,"utf-8")),h=l.metadata?.namespace_,p=h?.version;h&&p&&await n.saveDocumentAsync(l,`${h.publisher}/${h.package_}@${p.major}.${p.minor}.${p.patch}`)}catch{}let o=new y(g(),!0,e),s=new Map,a=t.httpCache??{getFromCache:(m,l,h)=>s.get(`${m}|${l}|${h}`)??null,onFetch:(m,l,h,p)=>{s.set(`${m}|${l}|${h}`,p)}},r=new v({getFromCache:a.getFromCache,onFetch:a.onFetch});return new D(n,o,r)}export{y as a,S as b,k as c,g as d,C as e,D as f,K as g,j as h};
1
+ import{d as v}from"./chunk-HAR3BNTB.js";import{a as A}from"./chunk-4NO7MHS7.js";import{a as f}from"./chunk-TJPQETHV.js";import{c as w,d as I,h as R,i as F}from"./chunk-2ACBWC7K.js";import*as i from"fs/promises";import*as c from"path";import{pathToFileURL as b}from"url";import{VersionOperator as P}from"@kanonak-protocol/types/document/models/enums";var y=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(e,t=!0,n){if(!e||e.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=c.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=c.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=c.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;switch(t.versionOperator){case P.Exact:return I(r,t.version);case P.Compatible:return R(r,t.version);case P.Major:return F(r,t.version);case P.Any:return w(r,t.minVersion)>=0;default:return!1}});return s.length===0?null:(s.sort((a,r)=>{let m=a.metadata.namespace_.version,l=r.metadata.namespace_.version;return w(l,m)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let m=o.split("/"),l=m[0],p=m[1].replace("@","@")+".kan.yml";n=c.join(this.rootPath,l,p)}else n=c.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=c.dirname(n);await i.mkdir(s,{recursive:!0});let a=this.parser.save(e);await i.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=c.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await i.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=c.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=c.join(this.rootPath,e);try{let s=await i.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await i.unlink(c.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[m,l]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&l.metadata.namespace_){s=l.metadata.namespace_.toString();break}let a=s??c.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}try{return await i.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await i.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await i.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=c.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await i.readdir(e,{withFileTypes:!0});for(let s of o){let a=c.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as d from"fs";var S=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(S||{}),k=class{cache;workspace;constructor(e,t,n){let o=n??new f;d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),d.existsSync(t)||d.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as _}from"os";import{join as N}from"path";function g(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||N(_(),".kanonak","packages")}var C=class u{static createComposite(e,t,n){let o=e??g(),s=t??".";return new k(o,s,n)}static createFromEnvironment(e){let t=g(),n=process.env.KANONAK_WORKSPACE_PATH??".";return u.createComposite(t,n,e)}};var D=class{repos;constructor(...e){this.repos=e}async getHighestCompatibleVersionAsync(e,t){for(let n of this.repos)try{let o=await n.getHighestCompatibleVersionAsync(e,t);if(o)return o}catch{}return null}async getAllDocumentsAsync(){let e=[],t=new Set;for(let n of this.repos)try{for(let o of await n.getAllDocumentsAsync()){let s=o.metadata?.namespace_,a=s?s.version?`${s.publisher}/${s.package_}@${s.version.major}.${s.version.minor}.${s.version.patch}`:`${s.publisher}/${s.package_}`:void 0;if(a!==void 0){if(t.has(a))continue;t.add(a)}e.push(o)}}catch{}return e}async getDocumentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentAsync(e);if(n)return n}catch{}return null}async getDocumentsByNamespaceAsync(e,t){for(let n of this.repos)try{let o=await n.getDocumentsByNamespaceAsync(e,t);if(o.length>0)return o}catch{}return[]}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentContentAsync(e);if(n)return n}catch{}return null}async getDocumentUriAsync(e){for(let t of this.repos)try{let n=await t.getDocumentUriAsync(e);if(n)return n}catch{}return null}};import{readFileSync as B,readdirSync as H}from"fs";import{join as x}from"path";var $=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function K(u,e=[]){for(let t of H(u,{withFileTypes:!0}))t.isDirectory()?$.has(t.name)||K(x(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(x(u,t.name));return e}async function j(u,e=new f,t={}){let n=new A(e);for(let m of K(u))try{let l=e.parse(B(m,"utf-8")),h=l.metadata?.namespace_,p=h?.version;h&&p&&await n.saveDocumentAsync(l,`${h.publisher}/${h.package_}@${p.major}.${p.minor}.${p.patch}`)}catch{}let o=new y(g(),!0,e),s=new Map,a=t.httpCache??{getFromCache:(m,l,h)=>s.get(`${m}|${l}|${h}`)??null,onFetch:(m,l,h,p)=>{s.set(`${m}|${l}|${h}`,p)}},r=new v({getFromCache:a.getFromCache,onFetch:a.onFetch});return new D(n,o,r)}export{y as a,S as b,k as c,g as d,C as e,D as f,K as g,j as h};
@@ -0,0 +1,74 @@
1
+ import{d as v}from"./chunk-SHDHMKMJ.js";import{a as w,c as Ee,d as je,f as A}from"./chunk-G2DKKSZ4.js";import{a as De}from"./chunk-TJPQETHV.js";import{d as ue,f as $,g as Se}from"./chunk-BGQKZBNE.js";import{d as me,f as $e,i as ge,j as E,k as I,l as he,m as j}from"./chunk-CRKSKIAL.js";import{a as V,b as D,c as we}from"./chunk-IOMNZBK4.js";import{c as O,d as Ae,k as Ie,l as Oe}from"./chunk-W6T7MOKY.js";import{e as k}from"./chunk-2ACBWC7K.js";var S=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var be=class u{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new u;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var ke=class{constructor(e){this.underlying=e;this.repository=new Pe(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new A().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],o=await this.buildDocsByIdIndex();for(;t.length>0;){let s=t.shift(),i=o.get(s);if(i?.metadata.imports)for(let[n,c]of Object.entries(i.metadata.imports))for(let a of c){let p=await this.repository.getHighestCompatibleVersionAsync(n,a);if(!p)continue;let l=Re(p);!l||r.has(l)||(r.add(l),t.push(l))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let o=Re(t);o&&r.set(o,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ke(s))continue;let i=s,n=Ne(i,"type");if(n==="Class"||n?.endsWith(".Class")){let c=Ue(i);t.set(o,c)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ke(s))continue;let n=Ne(s,"type");(n==="ObjectProperty"||n?.endsWith(".ObjectProperty")||n==="DatatypeProperty"||n?.endsWith(".DatatypeProperty")||n==="AnnotationProperty"||n?.endsWith(".AnnotationProperty")||n==="Property"||n?.endsWith(".Property"))&&t.add(o)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(Re(t)===e)return t}};function Re(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}function Ke(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}function Ne(u,e){if(e in u)return Ce(u[e]);for(let r of Object.keys(u))if(r.endsWith(`.${e}`))return Ce(u[r])}function Ce(u){return Array.isArray(u)?u.length>0?String(u[0]):void 0:u==null?void 0:String(u)}function Ue(u){let e=u.subClassOf;if(e===void 0){for(let r of Object.keys(u))if(r.endsWith(".subClassOf")){e=u[r];break}}return V(e)}var Pe=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){let t=`${e}/${r}`,o=this.byNamespaceCache.get(t);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,o),o)}getHighestCompatibleVersionAsync(e,r){let t=r.version,o=t?`${t.major}.${t.minor}.${t.patch}`:"",s=`${e}/${r.packageName}@${r.versionOperator}:${o}`,i=this.highestVersionCache.get(s);return i||(i=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(s,i),i)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var K=class u{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let r=[];for(let[t,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(t,o,r);return r}validateEntity(e,r,t){for(let[o,s]of Object.entries(r)){let i=s?.toString()??"";if(i&&u.NAMESPACE_PREFIX_PATTERN.test(i)){let n=this.getSuggestionForPrefixedValue(i),c=e.split(".")[0],a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=o,a.expectedValue=n,a.message=`Invalid namespace prefix '${i}'. Use '${n}' without prefix.`,a.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(a)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validateEntity(`${e}.${o}`,s,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var N=class u{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,s]of Object.entries(e.body)){let i=u.VALID_AUGMENTATION_PATTERN.test(o);if(!i&&!t&&u.RESERVED_WORDS.has(o.toLowerCase())){let n=new g;n.ruleType=this.ruleName,n.severity="Error",n.entityName=o,n.message=`Entity name '${o}' is a reserved word and cannot be used.`,n.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(n);continue}if(!i&&!u.VALID_NAME_PATTERN.test(o)){let n;/^\d/.test(o)?n="Entity names must start with a letter, not a number.":o.includes(" ")?n="Entity names cannot contain spaces. Use camelCase or underscores instead.":n="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=o,c.message=`Invalid entity name '${o}'. ${n}`,c.suggestion=n,r.push(c)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validatePropertyNames(o,s,r)}return r}validatePropertyNames(e,r,t){for(let o of Object.keys(r))if(!u.VALID_PROPERTIES.has(o)&&!u.VALID_PROPERTY_NAME_PATTERN.test(o)){let s=new g;s.ruleType=this.ruleName,s.severity="Warning",s.entityName=e,s.propertyName=o,s.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,s.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(s)}}};var C=class u{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[o,s]of Object.entries(e.body))if(s&&typeof s=="object"&&!Array.isArray(s)){let i=s,n=i.type;if(n){let c=[];if(Array.isArray(n))for(let a of n){let p=a?.toString();p&&p==="Property"&&!t&&c.push(p)}else{let a=n?.toString();a&&a==="Property"&&!t&&c.push(a)}for(let a of c){let p=this.getPropertyValue(i,"range"),l=this.determinePropertyType(p),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=o,y.propertyName="type",y.actualValue=a,y.expectedValue=l,y.message=`Invalid property type '${a}'. Use '${l}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":u.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r.type;if(o){let s=o.toString();return s==="Class"||s.endsWith(".Class")}}return!1}};var T=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||t.includes("."))continue;let s=o,i="type"in s,n=s.type?.toString().trim();if(!i||!n){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
2
+ type: Scene
3
+
4
+ Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",r.push(c)}}return r}};var x=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,r){let t=[],o=new D(r),s=await this.buildPropertyRangeMap(e,o);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&await this.checkEmbeddedTypes(i,n,void 0,s,o,e,t,0);return t}pickRange(e,r,t){if(e.length===0)return;if(e.length===1)return e[0].range;let o=r.indexOf(".");if(o>0){let s=r.substring(0,o),i=e.find(n=>n.declaringAlias===s);if(i)return i.range}if(t){let s=this.localName(t),i=e.find(n=>this.localName(n.domain)===s);if(i)return i.range}return e[0].range}async checkEmbeddedTypes(e,r,t,o,s,i,n,c){if(c>0){let p=r.type;if(p!=null){let l=await this.validateEmbeddedType(e,String(p),t,s,i);l&&n.push(l)}}let a=r.type!==void 0&&r.type!==null?String(r.type):void 0;for(let[p,l]of Object.entries(r)){let y=this.localName(p),m=o.get(y),d=(m!==void 0?this.pickRange(m,p,a):void 0)??t;if(typeof l=="object"&&l!==null)if(Array.isArray(l))for(let b=0;b<l.length;b++){let h=l[b];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${p}[${b}]`,h,d,o,s,i,n,c+1)}else await this.checkEmbeddedTypes(`${e}.${p}`,l,d,o,s,i,n,c+1)}}async validateEmbeddedType(e,r,t,o,s){if(r.length===0||!t)return null;let i=this.localName(r),n=this.localName(t);if(n==="Resource"||n==="Class")return null;let c=e.split(".")[0];if(i===n){let p=new g;return p.ruleType=this.ruleName,p.severity="Warning",p.entityName=c,p.propertyName=e,p.actualValue=r,p.expectedValue=t,p.message=`Embedded object at '${e}' declares 'type: ${r}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,p.suggestion=`Remove the 'type: ${r}' line, or keep it if explicitness is preferred over concision.`,p}if(await o.isSubclassOfAsync(r,t,s)||(i!==r||n!==t)&&await o.isSubclassOfAsync(i,n,s))return null;let a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=r,a.expectedValue=t,a.message=`Embedded object at '${e}' has 'type: ${r}', which is not a subclass of the parent property's range '${t}'.`,a.suggestion=`Either remove the 'type: ${r}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${r}' class definition so the relationship holds.`,a}localName(e){let r=e.lastIndexOf(".");return r<0||r===e.length-1?e:e.substring(r+1)}async buildPropertyRangeMap(e,r){let t=new Map,o=await r.buildEntityIndexAsync(e),s=new Map;for(let[i,n]of o){let c=n.entity.type;if(c==null)continue;let a=String(c),p=this.localName(a);if(!(p==="Property"||p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"))continue;let y=n.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let f=n.entity.domain,d=f!=null?String(f):"",b=n.uri.toString(),h=s.get(b),P=i.includes(".");(!h||P&&!h.entityName.includes("."))&&s.set(b,{entityName:i,domain:d,range:m})}for(let i of s.values()){let n=this.localName(i.entityName),c=i.entityName.indexOf("."),a=c>0?i.entityName.substring(0,c):void 0,p=t.get(n)??[];p.push({domain:i.domain,range:i.range,declaringAlias:a}),t.set(n,p)}return t}};import{VersionOperator as fe}from"@kanonak-protocol/types/document/models/enums";var _=class{ruleName="ImportExistence";async validateAsync(e,r){let t=[];if(!e.metadata?.imports)return t;let o=await r.getAllDocumentsAsync();for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i)if(!await r.getHighestCompatibleVersionAsync(s,n)){let a=await this.determineImportErrorAsync(r,s,n,o),p=new g;p.ruleType=this.ruleName,p.severity="Error",p.message=a.message,p.suggestion=a.suggestion,p.entityName=`Import: ${s}/${n.packageName}`,p.actualValue=n.toString(),p.expectedValue=a.expectedValue,t.push(p)}return t}async determineImportErrorAsync(e,r,t,o){let s=await e.getDocumentsByNamespaceAsync(r,t.packageName);if(s.length===0){let a=o.filter(m=>m.metadata.namespace_?.publisher===r).map(m=>m.metadata.namespace_.package_).filter((m,f,d)=>d.indexOf(m)===f),p=this.findSimilarPackages(t.packageName,a),l=`Import '${r}/${t.package_}' not found - package does not exist`,y=p.length>0?`Did you mean: ${p.slice(0,3).join(", ")}?`:a.length>0?`Available packages in ${r}: ${a.slice(0,5).join(", ")}`:`No packages found for publisher '${r}'. Verify the publisher name is correct.`;return{message:l,suggestion:y,expectedValue:"Existing package"}}let n=s.filter(a=>a.metadata.namespace_?.version).map(a=>a.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${r}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${n}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case fe.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case fe.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case fe.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case fe.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,r){if(r.length===0)return[];let t=r.filter(i=>i.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(i.toLowerCase()));if(t.length>0)return t.sort((i,n)=>i.length-n.length);let o=r.map(i=>({package:i,distance:this.levenshteinDistance(e.toLowerCase(),i.toLowerCase())})).sort((i,n)=>i.distance-n.distance),s=Math.max(3,Math.floor(e.length*.4));return o.filter(i=>i.distance<=s).map(i=>i.package)}levenshteinDistance(e,r){if(!e||e.length===0)return r?.length??0;if(!r||r.length===0)return e.length;let t=e.length,o=r.length,s=Array(t+1).fill(null).map(()=>Array(o+1).fill(0));for(let i=0;i<=t;i++)s[i][0]=i;for(let i=0;i<=o;i++)s[0][i]=i;for(let i=1;i<=t;i++)for(let n=1;n<=o;n++){let c=e[i-1]===r[n-1]?0:1;s[i][n]=Math.min(Math.min(s[i-1][n]+1,s[i][n-1]+1),s[i-1][n-1]+c)}return s[t][o]}};var U=class{ruleName="UnresolvedReference";async validateAsync(e,r){let t=[],o=new D(r),s=await o.buildEntityIndexAsync(e),i=new Set;for(let[n,c]of s.entries()){let a=c.entity.type;if(a){let p=a.toString();(p==="ObjectProperty"||p.endsWith(".ObjectProperty"))&&i.add(n)}}for(let[n,c]of Object.entries(e.body)){if(!c||typeof c!="object"||Array.isArray(c))continue;let a=c,p=this.getPropertyValue(a,"type");if(!(!p||p==="Class"||p.endsWith("Property")||p==="AnnotationProperty"))for(let[l,y]of Object.entries(a))l==="type"||l==="label"||l==="comment"||!(i.has(l)||Array.from(i).some(f=>f.endsWith(`.${l}`)))||await this.validateReferenceValue(n,l,y,e,o,t)}return t}async validateReferenceValue(e,r,t,o,s,i){if(t!=null){if(typeof t=="string")await s.resolveEntityAsync(t,o)||i.push(this.createUnresolvedReferenceError(e,r,t));else if(Array.isArray(t))for(let n=0;n<t.length;n++){let c=t[n];typeof c=="string"&&(await s.resolveEntityAsync(c,o)||i.push(this.createUnresolvedReferenceError(e,`${r}[${n}]`,c)))}}}createUnresolvedReferenceError(e,r,t){let o=`The entity '${t}' cannot be found in the current document or any imported namespaces.
5
+
6
+ Possible solutions:
7
+ \u2022 Add import if the entity is defined in another namespace:
8
+ kanonak namespace add-import <publisher>/<package>@<version>
9
+ \u2022 Check for typos in the reference name '${t}'
10
+ \u2022 Define '${t}' in the current namespace or an appropriate namespace
11
+ \u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=r,s.actualValue=t,s.message=`Reference to '${t}' could not be resolved`,s.suggestion=o,s.expectedValue="A valid entity reference that exists in the current document or imported namespaces",s}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}};var L=class{ruleName="ClassHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildClassHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=i,y=this.detectCycle(l,o);if(y){let m=y.join(" \u2192 "),f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Circular class hierarchy detected: ${m}`,f.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",f.entityName=l,f.propertyName="subClassOf",f.actualValue=m,t.push(f);break}}}return t}async buildClassHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=V(p);l.length>0&&t.set(i,l)}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);a&&await this.buildClassHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var M=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildPropertyHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let p=i,l=this.detectCycle(p,o);if(l){let y=l.join(" \u2192 "),m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${y}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=p,m.propertyName="subPropertyOf",m.actualValue=y,t.push(m);break}}return t}async buildPropertyHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type;if(a){let p=a.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let l=c.subPropertyOf;if(l){let y=V(l);y.length>0&&t.set(i,y)}}}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);a&&await this.buildPropertyHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var W=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,r){let t=[];for(let[o,s]of Object.entries(e.body)){if(typeof s!="object"||s===null||Array.isArray(s))continue;let i=s,n=i.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let c="range"in i,a=i.range?.toString().trim();if(!c||!a){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=o,p.propertyName="range",p.message=`Property '${o}' must have a 'range' defined.`,p.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var H=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isClassLikeType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=V(i.subClassOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isClassAvailableInImports(e,r,p)){let y=c.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Class '${p}' referenced in subClassOf${y} is not defined or imported`,m.suggestion=`Define '${p}' as a Class, or import a namespace that contains it`,m.entityName=s,m.propertyName="subClassOf",m.actualValue=p,m.expectedValue="Defined or imported class",t.push(m)}}}return t}async isClassAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isClassLikeType(f))return!0}let y=new Set;if(await this.isClassAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isClassAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isClassLikeType(y))return!0}if(await this.isClassAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var F=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=V(i.subPropertyOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInProperties.has(p)||o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,r,p)){let y=c.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Property '${p}' referenced in subPropertyOf${y} is not defined or imported`,m.suggestion=`Define '${p}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,m.entityName=s,m.propertyName="subPropertyOf",m.actualValue=p,m.expectedValue="Defined or imported property",t.push(m)}}}return t}async isPropertyAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(f==="DatatypeProperty"||f==="ObjectProperty"||f==="AnnotationProperty")return!0}let y=new Set;if(await this.isPropertyAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(y==="DatatypeProperty"||y==="ObjectProperty"||y==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var B=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,r){let t=[],o=e.metadata.namespace_?.toString();if(!o)return t;let s=new Map,i=new Set;await this.buildImportGraph(e,r,s,i);let n=this.detectCycle(o,s);if(n){let c=n.join(" \u2192 "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`Circular namespace import detected: ${c}`,a.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",a.entityName="imports",a.propertyName="imports",a.actualValue=c,t.push(a)}return t}async buildImportGraph(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!(!s||o.has(s))&&(o.add(s),e.metadata.imports)){let i=[];for(let[n,c]of Object.entries(e.metadata.imports))for(let a of c){let p=`${n}/${a.packageName}@${a.version}`;i.push(p);let l=await r.getHighestCompatibleVersionAsync(n,a);l&&await this.buildImportGraph(l,r,t,o)}i.length>0&&t.set(s,i)}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){let s=t.indexOf(e);if(s>=0){let n=t.slice(s);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let i=r.get(e);if(i)for(let n of i){let c=this.detectCycleRecursive(n,r,t,o);if(c)return c}return t.pop(),null}};var q=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,r,t){let o=[],s=new Set,i=t?await this.closurePropertyNamesViaCache(e,t):void 0,n=t?await this.aliasClosurePropertyNamesViaCache(e,t):void 0;for(let[c,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let l=a.type?.toString();this.isPropertyType(l)&&s.add(c)}for(let[c,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let p=a,l=p.type?.toString();if(this.isPropertyType(l)||this.isClassType(l))continue;for(let[y,m]of Object.entries(p)){if(!y||this.metadataKeys.has(y))continue;let f=y,d=null;if(y.includes(".")){let h=y.lastIndexOf(".");d=y.substring(0,h),f=y.substring(h+1)}if(s.has(f))continue;if(!await this.isPropertyAvailable(e,r,f,d,i,n)){let h=new g;h.ruleType=this.ruleName,h.severity="Error",h.message=`Property '${y}' is not defined or imported`,h.suggestion=d?`The property '${f}' is not found in the imported namespace with alias '${d}'.
12
+ 1. Verify the namespace is imported with the correct alias
13
+ 2. Check if the property name is spelled correctly
14
+ 3. Ensure the imported namespace version contains this property`:`The property '${y}' is not defined in this namespace or any imported namespace.
15
+ 1. Define '${y}' as an ObjectProperty or DatatypeProperty in this namespace, OR
16
+ 2. Import the namespace that contains '${y}', OR
17
+ 3. Use a qualified reference like 'alias.${y}' if already imported with an alias`,h.entityName=c,h.propertyName=y,h.actualValue=m?.toString(),h.expectedValue="A defined or imported property",o.push(h)}}}return o}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailable(e,r,t,o,s,i){if(s!==void 0&&i!==void 0){if(o===null)return s.has(t);let n=i.get(o);return n?n.has(t):!1}return await this.isPropertyAvailableInImports(e,r,t,o)}async closurePropertyNamesViaCache(e,r){let t=new Set,o=Te(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s)if(i!==o)for(let n of await r.getPropertyNames(i))t.add(n);return t}async aliasClosurePropertyNamesViaCache(e,r){let t=new Map;if(!e.metadata.imports)return t;for(let[o,s]of Object.entries(e.metadata.imports))for(let i of s){if(!i.alias)continue;let n=await r.repository.getHighestCompatibleVersionAsync(o,i);if(!n)continue;let c=Te(n);if(!c)continue;let a=await r.getImportClosure(c),p=t.get(i.alias)??new Set;for(let l of a)for(let y of await r.getPropertyNames(l))p.add(y);t.set(i.alias,p)}return t}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(s,n);if(c){let a=c.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};function Te(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var X=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isPropertyType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(!this.isPropertyType(c)&&!this.isClassType(c))continue;for(let[a,p]of Object.entries(n)){if(!a||this.metadataKeys.has(a))continue;let l=a,y=null;if(a.includes(".")){let f=a.lastIndexOf(".");y=a.substring(0,f),l=a.substring(f+1)}if(o.has(l))continue;if(!await this.isPropertyAvailableInImports(e,r,l,y)){let f=this.isClassType(c)?"class":"property",d=new g;d.ruleType=this.ruleName,d.severity="Error",d.message=`Property '${a}' used on ${f} '${s}' is not defined or imported`,d.suggestion=y?`The property '${l}' is not found in the imported namespace with alias '${y}'.
18
+ 1. Verify the namespace is imported with the correct alias
19
+ 2. Check if the property name is spelled correctly
20
+ 3. Ensure the imported namespace version contains this property`:`The property '${a}' is not defined in this namespace or any imported namespace.
21
+ 1. Define '${a}' as an ObjectProperty or DatatypeProperty in this namespace, OR
22
+ 2. Import the namespace that contains '${a}', OR
23
+ 3. Use a qualified reference like 'alias.${a}' if already imported with an alias`,d.entityName=s,d.propertyName=a,d.actualValue=p?.toString(),d.expectedValue="A defined or imported property",t.push(d)}}}return t}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(s,n);if(c){let a=c.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var z=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,r){let t=[],o=new Set,s=[];for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,a=!1,p=c.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="DatatypeProperty"){a=!0;break}}else p?.toString()==="DatatypeProperty"&&(a=!0);if(a){s.push(i);let l=this.getPropertyValue(c,"range");l&&this.xsdTypes.has(l)&&o.add(l)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,r)){let n=Array.from(o).sort().join(", "),c=s.sort().join(", "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`XSD namespace not imported but XSD types are used: ${n}`,a.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${c}`,a.entityName="imports",t.push(a)}return t}async checkXsdImportAsync(e,r,t=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&t.has(o))return!1;o&&t.add(o);for(let[,s]of Object.entries(e.imports))for(let i of s)if(i.packageName==="xsd"||i.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[s,i]of Object.entries(e.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);if(c?.metadata&&await this.checkXsdImportAsync(c.metadata,r,t))return!0}return!1}getPropertyValue(e,r){return e[r]?.toString()}};var Y=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,r){let t=[],o=await this.buildEntitySourceMapAsync(e,r),s=await this.buildDatatypePropertyNamesAsync(e,r);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&this.validateEntityReferences(i,n,o,s,e,t);return t}async buildEntitySourceMapAsync(e,r){let t=new Map,o=new Set;for(let s of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(s)||t.set(s,[]),t.get(s).push(`(local:${i})`)}if(e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);c&&await this.collectEntitiesRecursivelyAsync(c,t,o,r)}return t}async collectEntitiesRecursivelyAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let i of Object.keys(e.body)){r.has(i)||r.set(i,[]);let n=r.get(i);n.includes(s)||n.push(s)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await o.getHighestCompatibleVersionAsync(i,c);a&&await this.collectEntitiesRecursivelyAsync(a,r,t,o)}}}async buildDatatypePropertyNamesAsync(e,r){let t=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,t,o,r),e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);c&&await this.collectDatatypePropertiesAsync(c,t,o,r)}return t}async collectDatatypePropertiesAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let[i,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let c=n.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&r.add(i)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await o.getHighestCompatibleVersionAsync(i,c);a&&await this.collectDatatypePropertiesAsync(a,r,t,o)}}}validateEntityReferences(e,r,t,o,s,i){for(let[n,c]of Object.entries(r)){let a=n;if(a&&!a.includes(".")){let p=t.get(a);if(p&&p.length>1&&!p.some(y=>y.startsWith("(local:"))){let y=p.filter(m=>!m.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,a,`Property '${a}'`,y,s,!0,a))}}this.validatePropertyValue(e,a,c,t,o,s,i)}}validatePropertyValue(e,r,t,o,s,i,n){if(t==null)return;let c=r&&r.includes(".")?r.substring(r.lastIndexOf(".")+1):r,a=!!c&&s.has(c);if(typeof t=="string"&&!t.includes(".")&&!a){let p=o.get(t);if(p&&p.length>1&&!p.some(y=>y.startsWith("(local:"))){let y=p.filter(m=>!m.startsWith("(local:"));y.length>1&&n.push(this.createAmbiguityError(e,r,`Reference '${t}'`,y,i,!1,t))}}else if(Array.isArray(t))for(let p=0;p<t.length;p++){let l=`${e}.${r}[${p}]`;this.validatePropertyValue(l,r,t[p],o,s,i,n)}else if(typeof t=="object"&&!Array.isArray(t)){let p=r?`${e}.${r}`:e;this.validateEntityReferences(p,t,o,s,i,n)}}createAmbiguityError(e,r,t,o,s,i,n){let c=[];for(let d of o){let b=this.findAliasForNamespace(s,d);if(b){let h=r?.split(".").pop()??r;c.push(`${b}.${h}`)}}let a=c.length>0?`Use one of: ${c.map(d=>`'${d}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${r}')`,p=o.map(d=>` \u2022 ${d}`).join(`
24
+ `),l=e.split(".")[0],y=e.includes(".")?e:r,m=new g;m.ruleType=this.ruleName,m.severity="Error",m.entityName=l,y&&(m.propertyName=y);let f=n??r;return f&&(m.actualValue=f),m.message=`${t} is ambiguous - defined in multiple imported namespaces`,m.suggestion=`${a}
25
+
26
+ Defined in:
27
+ ${p}`,m.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",m}findAliasForNamespace(e,r){if(!e.metadata.imports)return null;for(let[t,o]of Object.entries(e.metadata.imports))for(let s of o)if(`${t}/${s.packageName}@${s.version}`===r&&s.alias)return s.alias;return null}};var Z=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","dateTime","date","time","duration","anyURI","anySimpleType","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte","base64Binary","hexBinary","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isValidRangeTargetType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(c!=="DatatypeProperty"&&c!=="ObjectProperty"&&!c?.endsWith(".DatatypeProperty")&&!c?.endsWith(".ObjectProperty"))continue;let a=n.range;if(!a)continue;let p=[];if(Array.isArray(a))for(let l of a){let y=l?.toString();y&&p.push(y)}else{let l=a?.toString();l&&p.push(l)}if(p.length===0)continue;for(let l of p){if(this.primitiveTypes.has(l)||this.builtInClasses.has(l)||o.has(l))continue;if(!await this.isTypeAvailableInImports(e,r,l)){let m=c?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${s}' has range '${l}' which is not defined or imported`,f.suggestion=m==="ObjectProperty"?`For ObjectProperty:
28
+ 1. Define '${l}' as a Class in this namespace, OR
29
+ 2. Import the namespace that contains '${l}', OR
30
+ 3. Use a qualified reference like 'alias.${l}' if already imported with an alias`:`For DatatypeProperty:
31
+ 1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
32
+ 2. If '${l}' should be a class, change property type to ObjectProperty`,f.entityName=s,f.propertyName="range",f.actualValue=l,f.expectedValue=m==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",t.push(f)}}}return t}async isTypeAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isValidRangeTargetType(f))return!0}let y=new Set;if(await this.isTypeAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isValidRangeTargetType(y))return!0}if(await this.isTypeAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var G=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,r){let t=[],o=new Map,s=new D(r);await s.buildEntityIndexAsync(e);for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,a=!1,p=c.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="ObjectProperty"){a=!0;break}}else p?.toString()==="ObjectProperty"&&(a=!0);if(a){let l=c.range,y=[];if(Array.isArray(l))for(let m of l){let f=m?.toString();f&&y.push(f)}else{let m=l?.toString();m&&y.push(m)}for(let m of y)this.xsdTypes.has(m)||(o.has(m)||o.set(m,[]),o.get(m).push(i))}}for(let[i,n]of o)if(!await s.resolveEntityAsync(i,e))for(let a of n){let p=new g;p.ruleType=this.ruleName,p.severity="Warning",p.message=`ObjectProperty references class '${i}' which may not be imported`,p.suggestion=`Ensure the namespace containing '${i}' is imported, or define '${i}' in this document`,p.entityName=a,p.propertyName="range",p.actualValue=i,t.push(p)}return t}};var J=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,r){let t=[],o=new D(r),s=new we(o),i=await o.buildEntityIndexAsync(e),n=await this.buildPropertyMetadataAsync(e,r,o,i);for(let[c,a]of Object.entries(e.body))typeof a=="object"&&a!==null&&!Array.isArray(a)&&await this.scanEntityForObjectProperties(a,c,"",n,o,s,e,t);return t}async scanEntityForObjectProperties(e,r,t,o,s,i,n,c){for(let[a,p]of Object.entries(e)){if(this.standardProperties.has(a))continue;let l,y=await s.resolveEntityAsync(a,n);if(y?.uri){let m=`${y.uri.publisher}/${y.uri.package_}/${y.uri.name}`;l=o.get(m)}if(!l){let m=a,f=a.lastIndexOf(".");f>0&&f<a.length-1&&(m=a.substring(f+1)),l=o.get(m)}if(l&&i.isEffectiveObjectProperty(l.propertyType,l.rangeUri)){let f=t?`${t}.${a}`:a;if(typeof p=="string"&&p.trim().length>0){let d=p.trim();if(d.includes(",")){let h=d.split(",").map(P=>P.trim()).filter(P=>P.length>0);c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
33
+ ${a}:
34
+ - ${h[0]}
35
+ ${h.slice(1).map(P=>` - ${P}`).join(`
36
+ `)}`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:`A single reference to ${l.range??"an entity"} OR a YAML list`});continue}let b=await s.resolveEntityAsync(d,n);if(b)l.range&&(await this.validateRangeType(b,l.range,s,n)||c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${l.range}, but '${d}' may not be a ${l.range}`,suggestion:`Ensure '${d}' is defined with appropriate type`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:l.range}));else{let h=l.range??"entity";c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' references '${d}' which is not defined or imported`,suggestion:`Define '${d}' or import a namespace that contains it. Expected range: ${h}`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:"Defined or imported entity"})}}else if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let d=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(p,r,d,o,s,i,n,c)}else if(Array.isArray(p))for(let d=0;d<p.length;d++){let b=p[d];if(typeof b=="string"&&b.trim().length>0){let h=b.trim(),P=await s.resolveEntityAsync(h,n);if(P){if(l.range&&!await this.validateRangeType(P,l.range,s,n)){let de=t?`${t}.${a}[${d}]`:`${a}[${d}]`;c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${l.range}, but '${h}' may not be a ${l.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:r,propertyName:`${a}[${d}]`,propertyPath:de,actualValue:h,expectedValue:l.range})}}else{let ve=l.range??"entity",de=t?`${t}.${a}[${d}]`:`${a}[${d}]`;c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' references '${h}' which is not defined or imported`,suggestion:`Define '${h}' or import a namespace that contains it. Expected range: ${ve}`,entityName:r,propertyName:`${a}[${d}]`,propertyPath:de,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof b=="object"&&b!==null&&!Array.isArray(b)){let h=t?`${t}.${a}[${d}]`:`${a}[${d}]`;await this.scanEntityForObjectProperties(b,r,h,o,s,i,n,c)}}}if(typeof p=="object"&&p!==null&&!Array.isArray(p)&&!o.has(a)){let m=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(p,r,m,o,s,i,n,c)}else if(Array.isArray(p))for(let m=0;m<p.length;m++){let f=p[m];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=t?`${t}.${a}[${m}]`:`${a}[${m}]`;await this.scanEntityForObjectProperties(f,r,d,o,s,i,n,c)}}}}async validateRangeType(e,r,t,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(r))return!0;let i=e.entity.type;if(i){let n=[];if(Array.isArray(i))for(let c of i){let a=c?.toString();a&&a.trim().length>0&&n.push(a)}else{let c=i?.toString();c&&c.trim().length>0&&n.push(c)}for(let c of n){let a=c.includes(".")?c.split(".")[1]:c;if(a===r||r==="Property"&&(a==="DatatypeProperty"||a==="ObjectProperty"||a==="AnnotationProperty")||r==="Class"&&a==="Class"||await t.isSubclassOfAsync(c,r,o))return!0}}return!1}async buildPropertyMetadataAsync(e,r,t,o){let s=new Map;for(let[i,n]of o){let c=n.entity.type;if(c){let a=[];if(Array.isArray(c))for(let y of c){let m=y?.toString();m&&m.trim().length>0&&a.push(m)}else{let y=c?.toString();y&&y.trim().length>0&&a.push(y)}let p=!1,l="Property";for(let y of a){let m=y.includes(".")?y.split(".")[1]:y;if(m==="Property"||m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty"){p=!0,l=y;break}}if(p){let y={propertyType:l},m=n.entity.range;if(m){let f=m?.toString();if(f&&f.trim().length>0){y.range=f;let d=await t.resolveEntityAsync(f,e);d&&(y.rangeUri=d.uri)}}if(s.set(i,y),n.uri){let f=`${n.uri.publisher}/${n.uri.package_}/${n.uri.name}`;s.set(f,y)}}}}return s}};var Q=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,r,t){let o=[],s=new Map;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=this.getPropertyValue(a,"type");(p==="DatatypeProperty"||p?.endsWith(".DatatypeProperty")||p==="ObjectProperty"||p?.endsWith(".ObjectProperty")||p==="AnnotationProperty"||p?.endsWith(".AnnotationProperty"))&&s.set(n,a)}let i=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,r);for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=this.getPropertyValue(a,"type");if(!p||p==="Class"||p.endsWith(".Class")||p.endsWith("Property")||p==="AnnotationProperty")continue;this.validateEntityProperties(a,n,p,s,i,o)}return o}async buildClassHierarchyViaCache(e,r){let t=new Map,o=Le(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s){let n=await r.getClassDeclarations(i);for(let[c,a]of n)a.length>0&&t.set(c,a)}return t}async buildCompleteClassHierarchyAsync(e,r){let t=new Map,o=new Set,s=async(n,c)=>{if(!o.has(c)){o.add(c);for(let[a,p]of Object.entries(n.body))if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let l=p,y=this.getPropertyValue(l,"type");if(y==="Class"||y?.endsWith(".Class")){let m=l.subClassOf;if(m===void 0){for(let d of Object.keys(l))if(d.endsWith(".subClassOf")){m=l[d];break}}let f=V(m);f.length>0&&t.set(a,f)}}if(n.metadata.imports)for(let[a,p]of Object.entries(n.metadata.imports))for(let l of p)try{let y=await r.getHighestCompatibleVersionAsync(a,l);if(y){let m=`${a}/${l.packageName}@${l.version}`;await s(y,m)}}catch{}}},i=e.metadata.namespace_?.toString()??"unknown";return await s(e,i),t}validateEntityProperties(e,r,t,o,s,i){for(let[n,c]of Object.entries(e)){if(this.standardProperties.has(n))continue;let a=n,p=n.lastIndexOf(".");p>0&&p<n.length-1&&(a=n.substring(p+1));let l=o.get(a);if(!l)continue;let y=this.getPropertyValue(l,"domain");if(y){if(!this.isTypeCompatibleWithDomain(t,y,s)){let m=r.split(".")[0];i.push({ruleType:this.ruleName,severity:"Error",entityName:m,propertyName:r,actualValue:n,message:`Property '${n}' has domain '${y}' but is used on '${t}' at '${r}'`,suggestion:`Either:
37
+ 1. Use this property only on '${y}' instances
38
+ 2. Change the property domain to include '${t}'
39
+ 3. Create a different property for '${t}'`,expectedValue:`Property used on ${y} or its subclasses`})}if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=c,f=this.getPropertyValue(m,"type");if(f){let d=`${r}.${n}`;this.validateEntityProperties(m,d,f,o,s,i)}else{let d=this.getPropertyValue(l,"range");if(d){let b=`${r}.${n}`;this.validateEntityProperties(m,b,d,o,s,i)}}}else if(Array.isArray(c))for(let m=0;m<c.length;m++){let f=c[m];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=f,b=this.getPropertyValue(d,"type");if(b){let h=`${r}.${n}[${m}]`;this.validateEntityProperties(d,h,b,o,s,i)}else{let h=this.getPropertyValue(l,"range");if(h){let P=`${r}.${n}[${m}]`;this.validateEntityProperties(d,P,h,o,s,i)}}}}}}}isTypeCompatibleWithDomain(e,r,t){if(e===r)return!0;let o=new Set,s=[e];for(;s.length>0;){let i=s.shift();if(o.has(i))continue;o.add(i);let n=t.get(i);if(n)for(let c of n){if(c===r)return!0;s.push(c)}}return!1}getPropertyValue(e,r){if(r in e){let t=e[r];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${r}`)){let o=e[t];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let r=[];for(let t of e)r.push(t?.toString()??"");return r.length>0?r[0]:void 0}return e?.toString()}};function Le(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var ee=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,r){let t=[],o=new Map;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=this.getPropertyValue(n,"type");(c==="DatatypeProperty"||c==="ObjectProperty")&&o.set(s,n)}for(let[s,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let n=i,c=this.getPropertyValue(n,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[a,p]of Object.entries(n)){if(a==="type"||a==="label"||a==="comment")continue;let l=a,y=a.lastIndexOf(".");y>0&&y<a.length-1&&(l=a.substring(y+1));let m=o.get(l);if(!m)continue;let f=this.getPropertyValue(m,"type"),d=this.getPropertyValue(m,"range");if(f==="DatatypeProperty"){if(typeof p=="object"&&p!==null&&!Array.isArray(p)||Array.isArray(p))t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' is a DatatypeProperty with range '${d}' but instance '${s}' has a complex object value`,suggestion:`Either:
40
+ 1. Create a class for this data and change '${a}' to an ObjectProperty
41
+ 2. Store as a JSON string to keep it as DatatypeProperty
42
+ 3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${d}'`});else if(!this.validateDatatypeValue(d,p)){let b={ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' expects type '${d}' but instance '${s}' has value of type '${this.getValueTypeName(p)}'`,suggestion:`Provide a value of type '${d}'`,toString:()=>""};d&&(b.expectedValue=d),t.push(b)}}else if(f==="ObjectProperty")if(Array.isArray(p))for(let b=0;b<p.length;b++){let h=p[b];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:`${a}[${b}]`,message:`ObjectProperty '${a}' array item ${b} in instance '${s}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof p!="string"&&(typeof p!="object"||p===null||Array.isArray(p))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`ObjectProperty '${a}' in instance '${s}' has invalid value type '${this.getValueTypeName(p)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${d} or embedded ${d} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let o=[];for(let s of t)o.push(s?.toString()??"");return o.length>0?o[0]:void 0}return t?.toString()}}};var te=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],o=new Map,s=new Set;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let p=c.type;if(p)if(Array.isArray(p))for(let l of p){let y=l?.toString();if(y==="Class"||y&&y.endsWith(".Class")){s.add(n);break}}else{let l=p?.toString();(l==="Class"||l&&l.endsWith(".Class"))&&s.add(n)}}for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=a.type;if(p)if(Array.isArray(p)){let l=!1;for(let y of p){let m=y?.toString();if(m&&this.isDefinitionType(m)){l=!0;break}}if(!l)for(let y of p){let m=y?.toString();m&&m.trim().length>0&&(o.has(m)||o.set(m,[]),o.get(m).push(n))}}else{let l=p?.toString();l&&l.trim().length>0&&(this.isDefinitionType(l)||(o.has(l)||o.set(l,[]),o.get(l).push(n)))}this.checkNestedTypes(a,n,o,n)}let i=new D(r);for(let[n,c]of o){if(this.builtInClasses.has(n)||s.has(n))continue;let a=await i.resolveEntityAsync(n,e);if(!(a&&this.isClassEntity(a.entity))){let l=Array.from(new Set(c)).sort();for(let y of l)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${n}' is not defined or imported`,suggestion:`Define '${n}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:n,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e,i=s.type;if(i){let n=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(i))for(let c of i){let a=c?.toString();a&&a.trim().length>0&&!n.has(a)&&(t.has(a)||t.set(a,[]),t.get(a).push(o))}else{let c=i?.toString();c&&c.trim().length>0&&!n.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(o))}}for(let[n,c]of Object.entries(s))if(n!=="type"){let a=`${o}.${n}`;this.checkNestedTypes(c,r,t,a)}}else if(Array.isArray(e))for(let s=0;s<e.length;s++){let i=`${o}[${s}]`;this.checkNestedTypes(e[s],r,t,i)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let o=t?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var re=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let o=[],s;if(t){let i=await t.getKanonaks(),n=Me(e);s=n?i.filter(c=>c instanceof O&&c.namespace===n):[]}else{let i=new j(e,r);s=await new A().parseKanonaks(i)}for(let i of s)i instanceof O&&this.checkDefined(i,i.name,o);return o}checkDefined(e,r,t){for(let o of e.statement)if(o instanceof Ee){let s=o.predicate.subject?.name??"(unknown)";for(let i of o.links)i.target||t.push(this.unresolvedLinkError(r,s,i.reference));for(let i of je(o.object))t.push(this.malformedLinkError(r,s,i.snippet))}else if(o instanceof Ie)this.checkDefined(o.object,r,t);else if(o instanceof Oe)for(let s of o.object)s instanceof w&&this.checkDefined(s,r,t)}unresolvedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
43
+
44
+ Possible solutions:
45
+ \u2022 Import the package that defines '${t}' so the link can resolve
46
+ \u2022 Check for typos in the reference name
47
+ \u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,o}malformedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Malformed embedded reference near '${t}' in '${r}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${r}' does not form a complete [[reference]] link.
48
+
49
+ A reference may not span a line break \u2014 the most common cause is wrapping a
50
+ long reference across two lines in a block scalar, e.g.:
51
+ ... read for [[persistent-energy-
52
+ shock]] held ...
53
+ which is parsed as literal text, not a link. Keep each [[reference]] on one
54
+ line (let the line run long), or check for an unterminated [[.`,o}};function Me(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var xe="kanonak.org",_e="look",We={publisher:xe,package_:_e,name:"displayLabel"},He={publisher:xe,package_:_e,name:"displaySummary"},oe=class{ruleName="DisplayLensScope";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=Fe(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&(this.checkLens(s,n,We,"displayLabel",o),this.checkLens(s,n,He,"displaySummary",o));return o}checkLens(e,r,t,o,s){let i=E(r,t);if(!i)return;let n=[],c=ue(r);if(c&&n.push(c),n.push(...Se(r)),n.length===0)return;n.some(p=>$(e,p,i).ok)||s.push(this.scopeError(r.name,o,i.name))}scopeError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`${r} points at '${t}', which is not a property in scope for '${e}'`,o.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",o.suggestion=`'${t}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
55
+
56
+ Possible solutions:
57
+ \u2022 Point ${r} at a property declared on this class (or an ancestor / rdfs.Resource)
58
+ \u2022 Set the property's domain to this class if it should apply here
59
+ \u2022 Use rdfs.label / rdfs.comment for the universal default`,o}};function Fe(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}function pe(u,e,r){let t=[];return ce(u,r,{input:e},t),t}function ce(u,e,r,t){if(me(e,v.VarRef)){let i=ge(e,v.varName);return i?r[i]:void 0}if(me(e,v.PropertyRead)){let i=I(e,v.readSource),n=i?ce(u,i,r,t):void 0,c=E(e,v.readProp);if(!n||!c)return;let a=$(u,n,c);if(!a.ok){t.push({contextClass:n,propertyUri:c,via:"PropertyRead"});return}return a.descriptor?.range}if(me(e,v.Traverse)){let i=I(e,v.traverseSource),n=i?ce(u,i,r,t):void 0,c=E(e,v.through),a;if(n&&c){let l=$(u,n,c);l.ok?a=l.descriptor?.range:t.push({contextClass:n,propertyUri:c,via:"Traverse"})}let p=I(e,v.step);return p?ce(u,p,{...r,input:a},t):void 0}let o=ge(e,v.loopVar),s=o?{...r,[o]:void 0}:r;for(let i of Be(e))ce(u,i,s,t)}function Be(u){let e=[];for(let r of u.statement){let t=r.object;if(t instanceof w)e.push(t);else if(Array.isArray(t))for(let o of t)o instanceof w&&e.push(o)}return e}var le="kanonak.org",ye="look",qe={publisher:le,package_:ye,name:"semanticSvg"},Xe={publisher:le,package_:ye,name:"tierChip"},ze={publisher:le,package_:ye,name:"tierIcon"},Ye={publisher:le,package_:ye,name:"tierCard"},Ze={publisher:le,package_:ye,name:"tierFull"},Ge=[Xe,ze,Ye,Ze],ne=class{ruleName="LookSemanticSvgPath";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=Je(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&this.checkSemanticSvg(s,n,o);return o}checkSemanticSvg(e,r,t){let o=I(r,qe);if(!o)return;let s=ue(r);if(s)for(let i of Ge){let n=I(o,i);if(n)for(let c of pe(e,s,n))t.push(this.toError(r.name,i.name,c))}}toError(e,r,t){let o=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,i=s===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${s}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,n=new g;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=`look.semanticSvg.${r}`,n.actualValue=o,n.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${i}. The read would silently return undefined at render time.`,n.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,n.suggestion=`Property '${o}' is not in scope for '${s}'.
60
+
61
+ Possible solutions:
62
+ \u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
63
+ \u2022 If the property should apply to '${s}', adjust its domain
64
+ \u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,n}};function Je(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var se="kanonak.org",ae="view",Qe={publisher:se,package_:ae,name:"bind"},et={publisher:se,package_:ae,name:"produces"},tt={publisher:se,package_:ae,name:"projections"},rt={publisher:se,package_:ae,name:"where"},ot={publisher:se,package_:ae,name:"value"},nt={publisher:se,package_:ae,name:"as"},ie=class{ruleName="TxExpressionPath";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=at(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&this.checkView(s,n,o);return o}checkView(e,r,t){let o=E(r,Qe);if(!o)return;let s=E(r,et),i=0;for(let c of st(e,he(r,tt))){let a=I(c,ot);if(a)for(let l of pe(e,o,a))t.push(this.toError(r.name,`view.projections[${i}].value`,o,l));let p=E(c,nt);p&&s&&($(e,s,p).ok||t.push(this.asError(r.name,i,s,p))),i+=1}let n=0;for(let c of it(r,rt)){for(let a of pe(e,o,c))t.push(this.toError(r.name,`view.where[${n}]`,o,a));n+=1}}asError(e,r,t,o){let s=`${o.publisher}/${o.package_}/${o.name}`,i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`view.projections[${r}].as`,i.actualValue=s,i.message=`Projection stores its value under property '${o.name}', but that property's domain is not in scope for the view's produces class '${t.name}'. The materialized result instance could not carry this value.`,i.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${s}' is not in scope for produces class '${t.name}'.
65
+
66
+ Possible solutions:
67
+ \u2022 Use an output property whose domain covers '${t.name}'
68
+ \u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
69
+ \u2022 If the value belongs on a different output class, adjust the view's produces`,i}toError(e,r,t,o){let s=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,i=o.contextClass.name,n=i===t.name?`the view's bound class '${t.name}'`:`'${i}', reached by traversal from the view's bound class '${t.name}'`,c=new g;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=e,c.propertyName=r,c.actualValue=s,c.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for ${n}. The read would silently return undefined when the view materializes.`,c.expectedValue=`A property whose domain is '${i}', an ancestor, or rdfs.Resource`,c.suggestion=`Property '${s}' is not in scope for '${i}'.
70
+
71
+ Possible solutions:
72
+ \u2022 Read a property declared on '${i}' (or an ancestor / rdfs.Resource)
73
+ \u2022 If the property should apply to '${i}', adjust its domain
74
+ \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function it(u,e){let r=I(u,e);return r?[r]:he(u,e).filter(t=>t instanceof w)}function st(u,e){let r=[];for(let t of e)if(t instanceof w)r.push(t);else if(t instanceof Ae){let o=$e(u,t.subject);o&&r.push(o)}return r}function at(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var Ve=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new De,this.documentRules=[new K,new N,new C,new T],this.repositoryRules=[new x,new _,new U,new L,new M,new W,new H,new F,new B,new q,new X,new z,new Y,new Z,new G,new J,new Q,new ee,new te,new re,new oe,new ne,new ie]}async validateAsync(e,r,t){let o=new S;for(let s of this.documentRules)try{let i=s.validate(e);this.addErrorsToResult(o,i)}catch(i){let n=new g;n.ruleType=s.ruleName,n.severity="Error",n.message=`Validation rule '${s.ruleName}' failed: ${i instanceof Error?i.message:String(i)}`,o.errors.push(n)}if(r){let s=[],i=t?.repository??r;for(let n of this.repositoryRules)try{let c=await n.validateAsync(e,i,t);this.addErrorsToResult(o,c)}catch(c){let a=c instanceof Error?c.message:String(c);s.push({ruleName:n.ruleName,cause:a})}if(s.length>0){let n=new Map;for(let{ruleName:c,cause:a}of s){let p=n.get(a);p?p.push(c):n.set(a,[c])}for(let[c,a]of n){let p=new g;p.ruleType=a[0],p.severity="Error",a.length===1?p.message=`Validation rule '${a[0]}' failed: ${c}`:p.message=`${c} (affects ${a.length} rules: ${a.join(", ")})`,o.errors.push(p)}}}return o.isValid=o.errors.length===0,o}async validateYamlAsync(e,r,t){let o=this.parser.parseWithErrors(e);if(!o.isValid){let s=new S;s.isValid=!1;for(let i of o.errors){let n=new g;n.ruleType="ParseError",n.severity="Error",n.lineNumber=i.line,n.column=i.column,n.message=i.message,i.keyName&&(n.entityName=i.keyName),i.errorType==="DuplicateKey"&&(n.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(n)}return s}return await this.validateAsync(o.document,r,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let r=this.documentRules.findIndex(t=>t instanceof e);r>=0&&this.documentRules.splice(r,1)}removeRepositoryRule(e){let r=this.repositoryRules.findIndex(t=>t instanceof e);r>=0&&this.repositoryRules.splice(r,1)}addErrorsToResult(e,r){for(let t of r)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{S as a,R as b,g as c,be as d,ke as e,K as f,N as g,C as h,T as i,x as j,_ as k,U as l,L as m,M as n,W as o,H as p,F as q,B as r,q as s,X as t,z as u,Y as v,Z as w,G as x,J as y,Q as z,ee as A,te as B,re as C,oe as D,ne as E,ie as F,Ve as G};
@@ -0,0 +1 @@
1
+ import{a as k,b as f}from"./chunk-2ACBWC7K.js";import*as h from"js-yaml";var b=new Set(["Package","EphemeralPackage"]);function v(d){return typeof d=="string"&&b.has(d)}var $=class{parse(r){let t=this.parseWithErrors(r);if(!t.isValid){let a=t.errors[0];throw new Error(`YAML parse error at line ${a.line}, column ${a.column}: ${a.message}`)}return t.document}parseWithErrors(r){let t=[],a;try{r=r.replace(/^\uFEFF/,"");let s=h.load(r);if(!s||typeof s!="object")return a={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:a,errors:t,isValid:!0};let e=this.extractMetadata(s),n=this.extractBody(s,e);return a={metadata:e,body:n,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:a,errors:t,isValid:!0}}catch(s){let e=s,n={message:e.message||"Unknown parse error",line:e.mark?.line??0,column:e.mark?.column??0,errorType:e.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${e.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${e.mark?.line??0}: ${e.message||"Unknown parse error"}`};return t.push(n),{document:void 0,errors:t,isValid:!1}}}save(r){let t={};if(r.metadata.namespace_){let a=r.metadata.namespace_,s={type:"Package",publisher:a.publisher};a.version&&(s.version=`${a.version.major}.${a.version.minor}.${a.version.patch}`),r.metadata.imports&&(s.imports=this.serializeImports(r.metadata.imports)),t[a.package_]=s}return Object.assign(t,r.body),h.dump(t,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(r){let t=r.imports;return Object.defineProperty(r,"allImports",{get:function(){if(!t)return[];let a=[];for(let s of Object.values(t))a.push(...s);return a},enumerable:!0,configurable:!0}),r}createVersion(r,t,a){return{major:r,minor:t,patch:a,toString:()=>`${r}.${t}.${a}`,equals:e=>!e||typeof e!="object"?!1:e.major===r&&e.minor===t&&e.patch===a,getHashCode:()=>r<<20|t<<10|a,compareTo:e=>r!==e.major?r-e.major:t!==e.minor?t-e.minor:a-e.patch}}extractMetadata(r){let t=this.createEmptyMetadata();for(let[a,s]of Object.entries(r))if(s&&typeof s=="object"&&v(s.type)){t.type_=s.type;let e=a,n=s.publisher,i=s.version?this.parseVersion(s.version):void 0;return n&&e&&(t.namespace_={publisher:n,package_:e,version:i,toString:function(){return this.version?`${this.publisher}/${this.package_}@${this.version.major}.${this.version.minor}.${this.version.patch}`:`${this.publisher}/${this.package_}`},equals:o=>!o||typeof o!="object"?!1:o.publisher===n&&o.package_===e&&(!i||!o.version||i.equals(o.version)),getHashCode:()=>{let o=0;for(let c=0;c<n.length;c++)o=(o<<5)-o+n.charCodeAt(c);for(let c=0;c<e.length;c++)o=(o<<5)-o+e.charCodeAt(c);return o|0}}),s.imports&&Array.isArray(s.imports)&&(t.imports=this.parseImportsV3(s.imports)),this.addAllImportsGetter(t)}if(r.kanonak&&typeof r.kanonak=="object"){let a=r.kanonak;return(a.publisher||a.package||a.version)&&(t.namespace_=this.parseNamespace(a)),a.imports&&typeof a.imports=="object"&&(t.imports=this.parseImportsLegacy(a.imports)),this.addAllImportsGetter(t)}return t}extractBody(r,t){let a={};for(let[s,e]of Object.entries(r))if(!(s==="kanonak"||s==="namespace"||s==="imports"))if(e&&typeof e=="object"&&v(e.type)){let n={};for(let[i,o]of Object.entries(e))i==="publisher"||i==="version"||i==="imports"||(n[i]=o);a[s]=n}else a[s]=e;return a}parseNamespace(r){if(typeof r=="string"){let e=r.match(/^([^/]+)\/([^@]+)(?:@(.+))?$/);if(e){let n=e[3]?this.parseVersion(e[3]):this.createVersion(1,0,0);return{publisher:e[1],package_:e[2],version:n,toString:()=>r,equals:i=>!i||typeof i!="object"?!1:i.publisher===e[1]&&i.package_===e[2]&&(!n||!i.version||n.equals(i.version)),getHashCode:()=>{let i=0;for(let o=0;o<e[1].length;o++)i=(i<<5)-i+e[1].charCodeAt(o);for(let o=0;o<e[2].length;o++)i=(i<<5)-i+e[2].charCodeAt(o);return i|0}}}}let t=r.publisher||"",a=r.package||"",s=r.version?this.parseVersion(r.version):this.createVersion(1,0,0);return{publisher:t,package_:a,version:s,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:e=>!e||typeof e!="object"?!1:e.publisher===t&&e.package_===a&&(!s||!e.version||s.equals(e.version)),getHashCode:()=>{let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);for(let n=0;n<a.length;n++)e=(e<<5)-e+a.charCodeAt(n);return e|0}}}parseVersion(r){if(typeof r=="string"){let t=r.split(".").map(Number);return this.createVersion(t[0]||0,t[1]||0,t[2]||0)}return this.createVersion(r.major||0,r.minor||0,r.patch||0)}parseImportsV3(r){let t={};for(let a of r)if(!(!a||typeof a!="object"))if(a.packages&&Array.isArray(a.packages)){let s=a.publisher;if(!s)throw new Error("PublisherImport requires 'publisher' property");t[s]||(t[s]=[]);for(let e of a.packages){if(!e||typeof e!="object")continue;let n=this.parseImportFromEmbeddedObject(e,s);t[s].push(n)}}else{let s=this.parseImportFromEmbeddedObject(a,a.publisher),e=s.publisher||"";t[e]||(t[e]=[]),t[e].push(s)}return t}parseImportsLegacy(r){let t={};for(let[a,s]of Object.entries(r))Array.isArray(s)&&(t[a]=s.map(e=>this.parseImport(e,a)));return t}parseImportFromEmbeddedObject(r,t){let a=r.package;if(!a)throw new Error("Import requires 'package' property");let s=r.match;if(!s)throw new Error("Import requires 'match' property");let e=r.version;if(!e)throw new Error("Import requires 'version' property");let n=this.parseVersion(e),i=this.parseVersionOperator(s),o=this.calculateMaxVersion(s,n),c=r.alias;return{package_:`${a} ${s} ${n.toString()}`,publisher:t,packageName:a,versionOperator:i,version:n,alias:c,minVersion:n,maxVersion:o,toEmbeddedObject:()=>{let m={package:a,match:s,version:n.toString()};return c&&(m.alias=c),m},toString:()=>c?`${a} ${s} ${n.toString()} as ${c}`:`${a} ${s} ${n.toString()}`}}buildImport(r,t,a,s){return this.parseImport({packageName:r,operator:t,version:a},s)}parseImport(r,t){if(typeof r=="string"){let o=r.match(/^(.+?)\s*([~^=*])\s*(\S+)\s+as\s+(\S+)$/);if(o){let m=o[1].trim(),u=o[2],p=this.parseVersion(o[3].trim()),l=o[4].trim(),g=this.parseVersionOperator(u),V=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:g,version:p,alias:l,minVersion:p,maxVersion:V,toEmbeddedObject:()=>{let y={package:m,match:u,version:p.toString()};return l&&(y.alias=l),y},toString:()=>`${m} ${u} ${p.toString()} as ${l}`}}let c=r.match(/^(.+?)\s*([~^=*])\s*(.+)$/);if(c){let m=c[1].trim(),u=c[2],p=this.parseVersion(c[3].trim()),l=this.parseVersionOperator(u),g=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:l,version:p,alias:void 0,minVersion:p,maxVersion:g,toEmbeddedObject:()=>({package:m,match:u,version:p.toString()}),toString:()=>`${m} ${u} ${p.toString()}`}}}let a=this.parseVersionOperator(r.operator||"~"),s=this.parseVersion(r.version||"1.0.0"),e=r.packageName||r.package||"",n=f(a),i=this.calculateMaxVersion(r.operator||"~",s);return{package_:r.package||"",publisher:t,packageName:e,versionOperator:a,version:s,alias:r.alias,minVersion:s,maxVersion:i,toEmbeddedObject:()=>{let o={package:e,match:n,version:s.toString()};return r.alias&&(o.alias=r.alias),o},toString:()=>`${e} ${n} ${s.toString()}`}}parseVersionOperator(r){return k(r)}calculateMaxVersion(r,t){switch(r){case"~":return this.createVersion(t.major,t.minor+1,0);case"^":return t.major===0?this.createVersion(0,t.minor+1,0):this.createVersion(t.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(r){let t=[];for(let[a,s]of Object.entries(r)){let e={publisher:a,packages:s.map(n=>{let i=f(n.versionOperator),o={package:n.packageName,match:i,version:`${n.version.major}.${n.version.minor}.${n.version.patch}`};return n.alias&&(o.alias=n.alias),o})};t.push(e)}return t}};export{$ as a};
@@ -1,2 +1,2 @@
1
- import{c as S,f as R}from"./chunk-PODBS4IU.js";import{a as h}from"./chunk-N224PFBI.js";var E=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(E||{}),A=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(A||{}),$=class{static async buildFromRepository(n){let l=await new R().parseKanonaks(n),p=await n.getAllDocumentsAsync(),a=[],s=[],t=new Set,o=new Set,d=new Map;for(let y of l){let c=y;c.name&&(h.isClassType(c)&&t.add(c.name),(h.isObjectPropertyType(c)||h.isGenericPropertyType(c))&&o.add(c.name))}for(let y of p)for(let[c,g]of Object.entries(y.body))o.has(c)&&g?.range&&typeof g.range=="string"&&d.set(c,g.range);let u=new Map;for(let y of l){let c=y;c.name&&u.set(c.name,c)}for(let y of p){let c=y.metadata.namespace_,g=c?`${c.publisher}/${c.package_}`:"",i=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",f=x(y);for(let[m,b]of Object.entries(y.body)){if(!b||typeof b!="object")continue;let P=u.get(m),k="Unknown";if(P){let T=P;h.isClassType(T)?k="Class":h.isObjectPropertyType(T)?k="ObjectProperty":h.isDatatypePropertyType(T)?k="DatatypeProperty":h.isAnnotationPropertyType(T)?k="AnnotationProperty":h.isDatatypeType(T)?k="Datatype":h.isGenericPropertyType(T)?k="ObjectProperty":h.isInstanceOfKnownClass(T,t)&&(k="Instance")}let j=g&&i?`${g}/${m}@${i}`:m,C={};for(let[T,O]of Object.entries(b))T!=="type"&&(typeof O!="object"||O===null)&&(C[T]=O);a.push({id:j,label:b.label??m,type:k,namespace:g,properties:C}),v(j,b,k,t,o,s,g,i,f),N(j,b,o,d,a,s,g,i,f),L(j,P,s)}}return{nodes:a,edges:s}}static buildFromDocument(n){let r=[],l=[],p=n.metadata.namespace_,a=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",s=p?`${p.publisher}/${p.package_}`:"",t=new Set,o=new Set,d=new Map,u=x(n);for(let[g,i]of Object.entries(n.body)){let f=i?.type;f&&(K(f,u)&&t.add(g),M(f,u)&&(o.add(g),i.range&&typeof i.range=="string"&&d.set(g,i.range)))}for(let[g,i]of Object.entries(n.body)){if(!i||typeof i!="object")continue;let f=i.type,m=U(f,g,t,u),b=s&&a?`${s}/${g}@${a}`:g,P={};for(let[k,j]of Object.entries(i))k!=="type"&&(typeof j!="object"||j===null)&&(P[k]=j);r.push({id:b,label:i.label??g,type:m,namespace:s,properties:P}),v(b,i,m,t,o,l,s,a,u),N(b,i,o,d,r,l,s,a,u)}let y=new Set(r.map(g=>g.id)),c=l.filter(g=>y.has(g.source)&&y.has(g.target));return{nodes:r,edges:c}}};function x(e,n){let r=new Map;if(e.metadata?.imports)for(let[l,p]of Object.entries(e.metadata.imports))for(let a of p){let s=a.alias??a.packageName,t=a.version,o=`${t.major}.${t.minor}.${t.patch}`;r.set(s,{publisher:l,package_:a.packageName,version:o})}return r}var _={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},G=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function D(e,n){if(e.includes(".")){let r=e.indexOf("."),l=e.substring(0,r),p=e.substring(r+1),a=n.get(l);if(a)return`${a.publisher}/${a.package_}/${p}`}return null}function K(e,n){let r=D(e,n);return r?_[r]==="Class":!1}function M(e,n){let r=D(e,n);return r?G.has(r):!1}function U(e,n,r,l){if(!e||e==="Package")return"Unknown";let p=D(e,l);if(p){let s=_[p];if(s)return s;let t=p.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let a=e.split(".").pop()??e;return r.has(a)?"Instance":"Unknown"}var I=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function v(e,n,r,l,p,a,s,t,o){let d=n.type,u=n.subClassOf;if(u){let i=Array.isArray(u)?u:[u];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subClassOf",label:"subClassOf"})}let y=n.subPropertyOf;if(y){let i=Array.isArray(y)?y:[y];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&d){let i=d.split(".").pop()??d;a.push({source:e,target:w(i,s,t,o),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[i,f]of Object.entries(n)){if(I.has(i)||!p.has(i))continue;let m=Array.isArray(f)?f:[f];for(let b of m)typeof b=="string"&&V(b)&&a.push({source:e,target:w(b,s,t,o),type:"propertyValue",label:i,propertyId:w(i,s,t,o)})}let c=r==="ObjectProperty"||r==="DatatypeProperty",g=n.domain&&n.range;if((c||g)&&n.domain&&n.range){let i=typeof n.domain=="string"?n.domain:null,f=typeof n.range=="string"?n.range:null;i&&f&&a.push({source:w(i,s,t,o),target:w(f,s,t,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function N(e,n,r,l,p,a,s,t,o){for(let[d,u]of Object.entries(n)){if(I.has(d)||typeof u!="object"||u===null||Array.isArray(u))continue;let y=u,c=`${e}/${d}`,g=l.get(d),i=g?g.split(".").pop()??g:"Unknown",f={};for(let[b,P]of Object.entries(y))(typeof P!="object"||P===null)&&(f[b]=P);p.push({id:c,label:`${i} (embedded)`,type:"Instance",namespace:s,properties:f});let m=s&&t?`${s}/${d}@${t}`:d;a.push({source:e,target:c,type:"propertyValue",label:d,propertyId:r.has(d)?m:void 0}),g&&a.push({source:c,target:w(i,s,t,o),type:"instanceOf",label:"type (inferred)"}),N(c,y,r,l,p,a,s,t,o)}}function L(e,n,r){let l=n?.statement;if(Array.isArray(l))for(let p of l){if(!(p instanceof S))continue;let a=p.predicate?.subject?.name??"";for(let s of p.links){let t=s.target?.subject;if(!t)continue;let o=t.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";r.push({source:e,target:`${t.publisher}/${t.package_}/${t.name}${d}`,type:"embeddedLink",label:a})}}}function V(e){return!(!e||e.includes(" ")||e.includes(`
1
+ import{c as S,f as R}from"./chunk-G2DKKSZ4.js";import{a as h}from"./chunk-BGQKZBNE.js";var E=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(E||{}),A=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(A||{}),$=class{static async buildFromRepository(n){let l=await new R().parseKanonaks(n),p=await n.getAllDocumentsAsync(),a=[],s=[],t=new Set,o=new Set,d=new Map;for(let y of l){let c=y;c.name&&(h.isClassType(c)&&t.add(c.name),(h.isObjectPropertyType(c)||h.isGenericPropertyType(c))&&o.add(c.name))}for(let y of p)for(let[c,g]of Object.entries(y.body))o.has(c)&&g?.range&&typeof g.range=="string"&&d.set(c,g.range);let u=new Map;for(let y of l){let c=y;c.name&&u.set(c.name,c)}for(let y of p){let c=y.metadata.namespace_,g=c?`${c.publisher}/${c.package_}`:"",i=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",f=x(y);for(let[m,b]of Object.entries(y.body)){if(!b||typeof b!="object")continue;let P=u.get(m),k="Unknown";if(P){let T=P;h.isClassType(T)?k="Class":h.isObjectPropertyType(T)?k="ObjectProperty":h.isDatatypePropertyType(T)?k="DatatypeProperty":h.isAnnotationPropertyType(T)?k="AnnotationProperty":h.isDatatypeType(T)?k="Datatype":h.isGenericPropertyType(T)?k="ObjectProperty":h.isInstanceOfKnownClass(T,t)&&(k="Instance")}let j=g&&i?`${g}/${m}@${i}`:m,C={};for(let[T,O]of Object.entries(b))T!=="type"&&(typeof O!="object"||O===null)&&(C[T]=O);a.push({id:j,label:b.label??m,type:k,namespace:g,properties:C}),v(j,b,k,t,o,s,g,i,f),N(j,b,o,d,a,s,g,i,f),L(j,P,s)}}return{nodes:a,edges:s}}static buildFromDocument(n){let r=[],l=[],p=n.metadata.namespace_,a=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",s=p?`${p.publisher}/${p.package_}`:"",t=new Set,o=new Set,d=new Map,u=x(n);for(let[g,i]of Object.entries(n.body)){let f=i?.type;f&&(K(f,u)&&t.add(g),M(f,u)&&(o.add(g),i.range&&typeof i.range=="string"&&d.set(g,i.range)))}for(let[g,i]of Object.entries(n.body)){if(!i||typeof i!="object")continue;let f=i.type,m=U(f,g,t,u),b=s&&a?`${s}/${g}@${a}`:g,P={};for(let[k,j]of Object.entries(i))k!=="type"&&(typeof j!="object"||j===null)&&(P[k]=j);r.push({id:b,label:i.label??g,type:m,namespace:s,properties:P}),v(b,i,m,t,o,l,s,a,u),N(b,i,o,d,r,l,s,a,u)}let y=new Set(r.map(g=>g.id)),c=l.filter(g=>y.has(g.source)&&y.has(g.target));return{nodes:r,edges:c}}};function x(e,n){let r=new Map;if(e.metadata?.imports)for(let[l,p]of Object.entries(e.metadata.imports))for(let a of p){let s=a.alias??a.packageName,t=a.version,o=`${t.major}.${t.minor}.${t.patch}`;r.set(s,{publisher:l,package_:a.packageName,version:o})}return r}var _={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},G=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function D(e,n){if(e.includes(".")){let r=e.indexOf("."),l=e.substring(0,r),p=e.substring(r+1),a=n.get(l);if(a)return`${a.publisher}/${a.package_}/${p}`}return null}function K(e,n){let r=D(e,n);return r?_[r]==="Class":!1}function M(e,n){let r=D(e,n);return r?G.has(r):!1}function U(e,n,r,l){if(!e||e==="Package")return"Unknown";let p=D(e,l);if(p){let s=_[p];if(s)return s;let t=p.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let a=e.split(".").pop()??e;return r.has(a)?"Instance":"Unknown"}var I=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function v(e,n,r,l,p,a,s,t,o){let d=n.type,u=n.subClassOf;if(u){let i=Array.isArray(u)?u:[u];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subClassOf",label:"subClassOf"})}let y=n.subPropertyOf;if(y){let i=Array.isArray(y)?y:[y];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&d){let i=d.split(".").pop()??d;a.push({source:e,target:w(i,s,t,o),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[i,f]of Object.entries(n)){if(I.has(i)||!p.has(i))continue;let m=Array.isArray(f)?f:[f];for(let b of m)typeof b=="string"&&V(b)&&a.push({source:e,target:w(b,s,t,o),type:"propertyValue",label:i,propertyId:w(i,s,t,o)})}let c=r==="ObjectProperty"||r==="DatatypeProperty",g=n.domain&&n.range;if((c||g)&&n.domain&&n.range){let i=typeof n.domain=="string"?n.domain:null,f=typeof n.range=="string"?n.range:null;i&&f&&a.push({source:w(i,s,t,o),target:w(f,s,t,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function N(e,n,r,l,p,a,s,t,o){for(let[d,u]of Object.entries(n)){if(I.has(d)||typeof u!="object"||u===null||Array.isArray(u))continue;let y=u,c=`${e}/${d}`,g=l.get(d),i=g?g.split(".").pop()??g:"Unknown",f={};for(let[b,P]of Object.entries(y))(typeof P!="object"||P===null)&&(f[b]=P);p.push({id:c,label:`${i} (embedded)`,type:"Instance",namespace:s,properties:f});let m=s&&t?`${s}/${d}@${t}`:d;a.push({source:e,target:c,type:"propertyValue",label:d,propertyId:r.has(d)?m:void 0}),g&&a.push({source:c,target:w(i,s,t,o),type:"instanceOf",label:"type (inferred)"}),N(c,y,r,l,p,a,s,t,o)}}function L(e,n,r){let l=n?.statement;if(Array.isArray(l))for(let p of l){if(!(p instanceof S))continue;let a=p.predicate?.subject?.name??"";for(let s of p.links){let t=s.target?.subject;if(!t)continue;let o=t.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";r.push({source:e,target:`${t.publisher}/${t.package_}/${t.name}${d}`,type:"embeddedLink",label:a})}}}function V(e){return!(!e||e.includes(" ")||e.includes(`
2
2
  `)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,r,l){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let p=e.indexOf("."),a=e.substring(0,p),s=e.substring(p+1);if(l){let t=l.get(a);if(t)return`${t.publisher}/${t.package_}/${s}@${t.version}`}return n&&r?`${n}/${s}@${r}`:s}return n&&r?`${n}/${e}@${r}`:e}function Y(e){if(!e.expiresAt)return!1;let n=new Date(e.expiresAt),r=300*1e3;return n.getTime()<=Date.now()+r}function Q(e){return!!e.accessToken&&!Y(e)}function X(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}export{E as a,A as b,$ as c,Y as d,Q as e,X as f};
package/dist/index.d.ts CHANGED
@@ -29,4 +29,6 @@ export { findDerivation } from './derivation/index.js';
29
29
  export type { DerivationEntityUri, TransformationReferenceTuple, DerivationLookupResult, } from './derivation/index.js';
30
30
  export { LookRenderer, resolveDisplayValue } from './look/index.js';
31
31
  export type { ResolvedLook, DisplayValue } from './look/index.js';
32
+ export { ViewMaterializer } from './view/index.js';
33
+ export type { MaterializeOptions, MaterializeResult } from './view/index.js';
32
34
  export { canonicalForm, canonicalHash } from './canonical/index.js';
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import{a as ut,b as pt,c as mt,d as ft,e as yt}from"./chunk-2OXZDBHX.js";import{a as sr,j as cr}from"./chunk-C5NKFT7W.js";import{a as ct,b as lt,c as dt,d as b,e as S,f as i}from"./chunk-7ZCFYITD.js";import{a as ir}from"./chunk-W4LPC6VM.js";import"./chunk-QHABFCRC.js";import{a as Le,b as Fe,c as De,d as Ne,e as Oe,f as Me,g as _e,h as ze}from"./chunk-EOMKFFKU.js";import{b as Ae,c as Ue,d as He}from"./chunk-U75VPNYW.js";import{a as Te}from"./chunk-4NO7MHS7.js";import{a as ht,b as kt,c as bt,d as St}from"./chunk-6T2XFOMU.js";import{a as Ct,b as Kt}from"./chunk-PEUTCG3B.js";import{a as wt}from"./chunk-PEJALHXK.js";import{a as Ve}from"./chunk-SC5M74NM.js";import{A as rr,B as nr,C as or,E as ar,a as It,b as Bt,c as Tt,d as jt,e as Lt,f as Ft,g as Dt,h as Nt,i as Ot,j as At,k as Ut,l as Vt,m as Ht,n as Mt,o as _t,p as zt,q as Gt,r as Wt,s as Jt,t as qt,u as Yt,v as Xt,w as Zt,x as Qt,y as er,z as tr}from"./chunk-XEFBKQY5.js";import"./chunk-SHDHMKMJ.js";import{a as F,b as N,c as Ye,d as ot,e as at,f as it}from"./chunk-PODBS4IU.js";import{a as je}from"./chunk-ORFSMEMM.js";import{a as st,b as Pt,c as Rt,d as xt,e as vt,f as $t,g as Et}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{b as Xe,c as Ze,d as Qe,e as et,f as tt,h as rt,j as nt}from"./chunk-64TVBQFR.js";import{a as Ge,b as j,c as L,d as D,e as Je,f as qe,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as We}from"./chunk-FUUTGGJS.js";import{a as Pe,b as Re,c as we,d as xe,e as ve,f as $e,g as Ee,h as Ke,i as Ie,j as Be}from"./chunk-2ACBWC7K.js";import{a as gt}from"./chunk-ODIECDN7.js";import{VersionOperator as ko}from"@kanonak-protocol/types/document/models/enums";import{existsSync as vr,readFileSync as $r}from"fs";import{homedir as Er}from"os";import{join as Kr}from"path";import{execFile as lr}from"child_process";import{promisify as dr}from"util";var C=dr(lr),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
- 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)}
1
+ import{a as Qt,b as en,c as tn,d as nn,e as le}from"./chunk-FX7JDGL6.js";import{a as Jn,c as pe,e as xe,h as Ie,i as je,j as qn}from"./chunk-MCU5IAMS.js";import{a as Yt,b as Zt,c as Xt,d as T,e as V,f as c}from"./chunk-Y7TGQ7UF.js";import{a as Gn}from"./chunk-F5ANO7MJ.js";import"./chunk-QHABFCRC.js";import{a as Et,b as Rt,c as vt,d as $t,e as Kt,f as Tt,g as Vt,h as Ut}from"./chunk-OFSARZX6.js";import{b as xt,c as It,d as Bt}from"./chunk-HAR3BNTB.js";import{a as Ct}from"./chunk-4NO7MHS7.js";import{a as on,b as an,c as sn,d as cn}from"./chunk-GN2XODVC.js";import{a as ln,b as gn}from"./chunk-PEUTCG3B.js";import{a as pn}from"./chunk-PEJALHXK.js";import{a as jt}from"./chunk-SC5M74NM.js";import{A as Mn,B as Hn,C as zn,G as Wn,a as hn,b as kn,c as bn,d as Sn,e as wn,f as Pn,g as Cn,h as En,i as Rn,j as vn,k as $n,l as Kn,m as xn,n as In,o as jn,p as Bn,q as Tn,r as Vn,s as Un,t as On,u as Ln,v as Nn,w as _n,x as An,y as Dn,z as Fn}from"./chunk-RRODBYIK.js";import"./chunk-SHDHMKMJ.js";import{a as g,b as te,c as At,d as Gt,e as Jt,f as ce}from"./chunk-G2DKKSZ4.js";import{a as Q}from"./chunk-TJPQETHV.js";import{a as qt,b as un,c as dn,d as f,e as mn,f as fn,g as yn}from"./chunk-BGQKZBNE.js";import{f as B,j as S,k as ue,l as de,m as Ke}from"./chunk-CRKSKIAL.js";import{b as Dt,c as Ft,d as b,e as Mt,f as Ht,h as zt,j as Wt}from"./chunk-IOMNZBK4.js";import{a as Ot,b as ee,c as y,d as h,e as Nt,f as _t,g as ne,h as re,i as oe,j as ae,k as ie,l as se}from"./chunk-W6T7MOKY.js";import{a as Lt}from"./chunk-FUUTGGJS.js";import{a as yt,b as gt,c as I,d as ht,e as j,f as kt,g as bt,h as St,i as wt,j as Pt}from"./chunk-2ACBWC7K.js";import{a as rn}from"./chunk-ODIECDN7.js";import{VersionOperator as Ua}from"@kanonak-protocol/types/document/models/enums";import{existsSync as mr,readFileSync as fr}from"fs";import{homedir as yr}from"os";import{join as gr}from"path";import{execFile as Yn}from"child_process";import{promisify as Zn}from"util";var U=Zn(Yn),O="kanonak",L="/usr/bin/security",w=class{async get(e){let n=c(e);try{let{stdout:r}=await U(L,["find-generic-password","-s",O,"-a",n,"-w"],{timeout:1e4});try{return JSON.parse(r.trim())}catch{throw new Error(`Stored credential for '${n}' is corrupted (not valid JSON).
2
+ Run 'kanonak logout ${n}' then 'kanonak login ${n}' to fix.`)}}catch(r){if(Be(r,44))return null;throw new Error(`macOS Keychain read failed for '${n}': ${N(r)}
3
3
  The Keychain may be locked or inaccessible.
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)}
4
+ Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,n){let r=c(e),o=JSON.stringify(n);try{await U(L,["add-generic-password","-s",O,"-a",r,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${r}': ${N(a)}
5
5
  Ensure the Keychain is unlocked and the CLI has write permission.
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
- 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 ur}from"child_process";import{promisify as pr}from"util";var mr=pr(ur),x="kanonak:",m=class{async get(e){let r=x+i(e),n=`
9
- ${$}
6
+ On managed devices, your IT policy may block credential storage.`)}}async remove(e){let n=c(e);try{await U(L,["delete-generic-password","-s",O,"-a",n],{timeout:1e4})}catch(r){if(Be(r,44))return;console.warn(` Warning: macOS Keychain delete failed for '${n}': ${N(r)}
7
+ The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await U(L,["dump-keychain"],{timeout:1e4}),n=[],r=!1;for(let o of e.split(`
8
+ `))if(o.includes(`"svce"<blob>="${O}"`)&&(r=!0),r&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&n.push(a[1]),r=!1}return n}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${N(e)}`),[]}}};function Be(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function N(t){return t instanceof Error?t.message:String(t)}import{execFile as Xn}from"child_process";import{promisify as Qn}from"util";var er=Qn(Xn),_="kanonak:",P=class{async get(e){let n=_+c(e),r=`
9
+ ${D}
10
10
  $target = [Console]::In.ReadLine()
11
11
  $ptr = [IntPtr]::Zero
12
12
  $result = [CredMan]::CredRead($target, 1, 0, [ref]$ptr)
@@ -18,8 +18,8 @@ try {
18
18
  [System.Text.Encoding]::Unicode.GetString($bytes)
19
19
  } finally {
20
20
  [CredMan]::CredFree($ptr)
21
- }`;try{let{stdout:o}=await v(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
- ${$}
21
+ }`;try{let{stdout:o}=await A(r,n),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,n){let r=_+c(e),o=JSON.stringify(n),a=`
22
+ ${D}
23
23
  $target = [Console]::In.ReadLine()
24
24
  $json = [Console]::In.ReadLine()
25
25
  $bytes = [System.Text.Encoding]::Unicode.GetBytes($json)
@@ -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 v(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
- ${$}
38
+ }`;try{await A(a,`${r}
39
+ ${o}`)}catch(i){throw new Error(`Windows Credential Manager write failed: ${String(i)}`)}}async remove(e){let n=_+c(e),r=`
40
+ ${D}
41
41
  $target = [Console]::In.ReadLine()
42
- [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await v(n,r)}catch{}}async list(){let e=`
43
- ${$}
44
- ${fr}
42
+ [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await A(r,n)}catch{}}async list(){let e=`
43
+ ${D}
44
+ ${tr}
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 v(e,x);return r.trim().split(`
59
- `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function v(t,e){for(let r of["pwsh","powershell"])try{return await mr(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 $=`
58
+ }`;try{let{stdout:n}=await A(e,_);return n.trim().split(`
59
+ `).map(r=>r.trim()).filter(Boolean)}catch{return[]}}};async function A(t,e){for(let n of["pwsh","powershell"])try{return await er(n,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(r){if(n==="powershell")throw r}throw new Error("Neither pwsh nor powershell found")}var D=`
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
- "@`,fr="";import{execFile as yr,spawn as gr}from"child_process";import{promisify as hr}from"util";var K=hr(yr),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=gr("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 _(){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 kr,createDecipheriv as br,randomBytes as re}from"crypto";import{homedir as Sr}from"os";import{join as W,dirname as ne}from"path";var ae=W(Sr(),".config","kanonak"),y=W(ae,"keyring.key"),I=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(I))return{};try{let e=this.getOrCreateKey(),r=ee(I);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=br(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=kr(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(I),{recursive:!0}),te(I,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 Cr}from"child_process";import{promisify as Pr}from"util";var Rr=Pr(Cr),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}': ${B(n)}
90
+ "@`,tr="";import{execFile as nr,spawn as rr}from"child_process";import{promisify as or}from"util";var M=or(nr),F="kanonak",C=class{async get(e){let n=c(e);try{let{stdout:r}=await M("secret-tool",["lookup","service",F,"publisher",n],{timeout:1e4}),o=r.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,n){let r=c(e),o=JSON.stringify(n);await new Promise((a,i)=>{let s=rr("secret-tool",["store","--label",`Kanonak: ${r}`,"service",F,"publisher",r],{stdio:["pipe","ignore","ignore"],timeout:1e4});s.stdin.write(o),s.stdin.end(),s.on("close",l=>{l===0?a():i(new Error(`secret-tool store exited with code ${l}`))}),s.on("error",i)})}async remove(e){let n=c(e);try{await M("secret-tool",["clear","service",F,"publisher",n],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await M("secret-tool",["search","service",F],{timeout:1e4}),n=[];for(let r of e.split(`
91
+ `)){let o=r.match(/attribute\.publisher\s*=\s*(.+)/);o&&n.push(o[1].trim())}return n}catch{return[]}}};async function me(){try{return await M("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Te,mkdirSync as Ve,readFileSync as Ue,writeFileSync as Oe}from"fs";import{createCipheriv as ar,createDecipheriv as ir,randomBytes as Le}from"crypto";import{homedir as sr}from"os";import{join as ge,dirname as Ne}from"path";var Ae=ge(sr(),".config","kanonak"),E=ge(Ae,"keyring.key"),H=ge(Ae,"credentials.enc"),_e="aes-256-gcm",fe=32,k=12,ye=16,R=class{async get(e){let n=this.loadStore(),r=c(e);return n[r]??null}async store(e,n){let r=this.loadStore(),o=c(e);r[o]=n,this.saveStore(r)}async remove(e){let n=this.loadStore(),r=c(e);delete n[r],this.saveStore(n)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Te(H))return{};try{let e=this.getOrCreateKey(),n=Ue(H);if(n.length<k+ye)return{};let r=n.subarray(0,k),o=n.subarray(k,k+ye),a=n.subarray(k+ye),i=ir(_e,e,r);i.setAuthTag(o);let s=Buffer.concat([i.update(a),i.final()]);return JSON.parse(s.toString("utf-8"))}catch{return{}}}saveStore(e){let n=this.getOrCreateKey(),r=Le(k),o=ar(_e,n,r),a=Buffer.from(JSON.stringify(e),"utf-8"),i=Buffer.concat([o.update(a),o.final()]),s=o.getAuthTag(),l=Buffer.concat([r,s,i]);Ve(Ne(H),{recursive:!0}),Oe(H,l,{mode:384})}getOrCreateKey(){if(Te(E)){let n=Ue(E);if(n.length!==fe)throw new Error(`Credential keyring key is corrupted (expected ${fe} bytes, got ${n.length}). Delete ${E} and re-authenticate.`);return n}let e=Le(fe);return Ve(Ne(E),{recursive:!0}),Oe(E,e,{mode:384}),e}};import{execFile as cr}from"child_process";import{promisify as lr}from"util";var ur=lr(cr),De=3e4,v=class{constructor(e){this.helperPath=e}helperPath;async get(e){let n=c(e);try{let o=(await this.runHelper("get",{publisher:n})).trim();return o?JSON.parse(o):null}catch(r){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${n}': ${z(r)}
92
92
  Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
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}': ${B(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}': ${B(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: ${B(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await Rr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw wr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
- Check the 'credentialHelper' path in ~/.kanonak/config.json.`):xr(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 B(t){return t instanceof Error?t.message:String(t)}function wr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function xr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=Kr(Er(),".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=Ir(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 _()?new f:new g}};function Ir(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function Br(){if(!vr(J))return{};try{return JSON.parse($r(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 Tr,createPrivateKey as jr,generateKeyPairSync as Lr,randomUUID as Fr,sign as Dr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=Lr("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:Fr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=Tr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Nr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Nr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=jr({key:r,format:"jwk"}),l=Dr("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 Or,writeFileSync as Ar,existsSync as Ur}from"fs";import{createHash as Vr}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",Hr=`# This file is generated by Kanonak CLI. Do not edit manually.
99
- `;function me(t=pe){if(!Ur(t))return null;let e=Or(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:'"'});Ar(e,Hr+n,"utf-8")}function ye(t){return`sha256:${Vr("sha256").update(t).digest("hex")}`}import{createHash as Mr}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(_r(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:${Mr("sha256").update(e,"utf8").digest("hex")}`}function _r(t){let e=Yr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=zr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function zr(t){let e=qr(t);if(!e)return;let r=Gr(t);if(r)return Jr(e,r)}function Gr(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 M)return{type:"list",items:t.object.map(Wr)}}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 Wr(t){if(t instanceof D)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof N){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 qr(t){let e=t.predicate;if(e)return be(e.subject)}function Yr(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{Xt as AmbiguousReferenceRule,U as BooleanStatement,nr as ClassDefinitionRule,Ht as ClassHierarchyCycleRule,De as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,qt as DefinitionPropertyReferenceRule,Fe as DocumentLocation,lt as EdgeType,F as EmbeddedKanonak,At as EmbeddedKanonakTypeRule,H as EmbeddedStatement,Le as FileSystemKanonakDocumentRepository,gt as GitIgnoreFilter,dt as GraphBuilder,He as HttpKanonakDocumentRepository,Ut as ImportExistenceRule,Te as InMemoryKanonakDocumentRepository,Jt as InstancePropertyReferenceRule,Ge as Kanonak,kt as KanonakDocumentPositions,it as KanonakObjectParser,ar as KanonakObjectValidator,je as KanonakParser,We as KanonakUri,Ct as KanonakUriBuilder,wt as KanonakUrlResolver,nt as KanonakVocabulary,M as ListStatement,N as LiteralKanonak,Me as LocalFirstRepository,cr as LookRenderer,or as MarkdownLinkRule,Ye as MarkdownStatement,Wt as NamespaceImportCycleRule,Ft as NamespacePrefixRule,ct as NodeType,A as NumberStatement,mt as OWL_RL_CLASSIFICATION_RULES,Qt as ObjectPropertyImportRule,er as ObjectPropertyValueValidationRule,Tt as OntologyValidationError,It as OntologyValidationResult,tr as PropertyDomainRule,Mt as PropertyHierarchyCycleRule,ht as PropertyMetadata,Zt as PropertyRangeReferenceRule,_t as PropertyRangeRequiredRule,Nt as PropertyTypeSpecificityRule,rr as PropertyValueTypeRule,Ae as PublisherConfigResolver,Ue as PublisherIndex,pt as RDFS_RULES,yt as Reasoner,ft as ReasoningResult,D as ReferenceKanonak,V as ReferenceStatement,Oe as RepositoryFactory,Dt as ResourceNamingRule,Xe as ResourceResolver,st as ResourceTypeClassifier,qe as ScalarStatement,Je as Statement,O as StringStatement,zt as SubClassOfReferenceRule,Gt as SubPropertyOfReferenceRule,L as SubjectKanonak,Ot as SubjectKanonakTypeRequiredRule,ut as TripleStore,Ze as TypeResolver,Vt as UnresolvedReferenceRule,Lt as ValidationCache,jt as ValidationContext,Bt as ValidationSeverity,ko as VersionOperator,Yt as XsdImportRule,Ve as assertPackageIdentity,ze as buildLocalFirstRepository,q as canonicalForm,ge as canonicalHash,_e as collectKanonakFiles,we as compareVersions,ye as computeIntegrity,Et as contextTypesOf,de as createAuthenticatedFetch,k as createDPoPProof,$e as createVersion,at as extractMarkdownLinks,ir as findDerivation,Kt as findInstancesByType,ot as findMalformedReferences,St as findMarkdownLinkAt,Rt as formatKanonakAddress,ve as formatVersion,ce as generateDPoPKeyPair,Ne as getGlobalCachePath,S as hasValidToken,Ke as isCompatibleVersion,b as isExpired,Ie as isMajorCompatible,me as loadLockFile,et as makeUriKey,i as normalizeHost,Pt as parseKanonakAddress,Ee as parseVersionString,bt as parseWithPositions,Be as pickHighestDocument,vt as propertiesInScope,sr as resolveDisplayValue,$t as resolvePropertyStep,fe as saveLockFile,le as serverSupportsDPoP,xt as subjectUri,tt as tripleKey,Qe as uriKey,rt as uriTriple,Pe as versionOperatorFromChar,Re as versionOperatorToChar,xe as versionsEqual};
93
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,n){let r=c(e);try{await this.runHelper("store",{publisher:r,credential:n})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${r}': ${z(o)}
94
+ Verify the helper binary supports the 'store' action.`)}}async remove(e){let n=c(e);try{await this.runHelper("erase",{publisher:n})}catch(r){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${n}': ${z(r)}`)}}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: ${z(e)}`),[]}}async runHelper(e,n){try{let{stdout:r}=await ur(this.helperPath,[e],{...n&&{input:JSON.stringify(n)},timeout:De});return r}catch(r){throw dr(r)?new Error(`Credential helper not found at '${this.helperPath}'.
95
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`):pr(r)?new Error(`Credential helper '${this.helperPath}' timed out after ${De/1e3}s on '${e}'.
96
+ The helper may be waiting for authentication to an external vault.`):r}}};function z(t){return t instanceof Error?t.message:String(t)}function dr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function pr(t){return t instanceof Error&&"killed"in t&&t.killed}var he=gr(yr(),".kanonak","config.json"),W=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 n=hr(e);if(n)return n;let o=await(await this.getBackend()).get(e);return!o||!V(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,n){return(await this.getBackend()).store(e,n)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=kr();return e.credentialHelper?new v(e.credentialHelper):process.platform==="darwin"?new w:process.platform==="win32"?new P:await me()?new C:new R}};function hr(t){let n="KANONAK_TOKEN_"+c(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[n]??null}function kr(){if(!mr(he))return{};try{return JSON.parse(fr(he,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${he}: ${e}
97
+ Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as br,createPrivateKey as Sr,generateKeyPairSync as wr,randomUUID as Pr,sign as Cr}from"crypto";function Me(){let{publicKey:t,privateKey:e}=wr("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function $(t,e,n,r,o,a){let i={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},s={jti:Pr(),htm:n.toUpperCase(),htu:r,iat:Math.floor(Date.now()/1e3)};return o&&(s.ath=br("sha256").update(o).digest("base64url")),a&&(s.nonce=a),Er(i,s,t)}function He(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Er(t,e,n){let r=Fe(JSON.stringify(t)),o=Fe(JSON.stringify(e)),a=`${r}.${o}`,i=Sr({key:n,format:"jwk"}),l=Cr("SHA256",Buffer.from(a),{key:i,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function Fe(t){return Buffer.from(t,"utf-8").toString("base64url")}function ze(t){let e=new Map;return async(n,r,o="GET")=>{if(!t)return fetch(n,{method:o});let a=await t.getCredential(r);if(!a?.accessToken)return fetch(n,{method:o});T(a)&&console.warn(` Warning: Access token for '${r}' is expired. Run 'kanonak login ${r}' to re-authenticate.`);let i={};if(a.dpopKeyPair){let l=e.get(r);try{let u=$(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,n,a.accessToken,l);i.Authorization=`DPoP ${a.accessToken}`,i.DPoP=u}catch(u){let d=u instanceof Error?u.message:String(u);console.error(` Error: Failed to create DPoP proof for '${r}': ${d}
98
+ The stored key pair may be corrupted. Run 'kanonak login ${r}' to re-authenticate.`),i.Authorization=`Bearer ${a.accessToken}`}}else i.Authorization=`Bearer ${a.accessToken}`;let s=await fetch(n,{method:o,headers:i});if(s.status===401&&a.dpopKeyPair){let l=s.headers.get("DPoP-Nonce");if(l){e.set(r,l);try{let u=$(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,n,a.accessToken,l);i.DPoP=u,s=await fetch(n,{method:o,headers:i})}catch{}}}return s}}import{readFileSync as Rr,writeFileSync as vr,existsSync as $r}from"fs";import{createHash as Kr}from"crypto";import We from"js-yaml";var Ge="kanonak.lock",xr=`# This file is generated by Kanonak CLI. Do not edit manually.
99
+ `;function Je(t=Ge){if(!$r(t))return null;let e=Rr(t,"utf-8"),n=We.load(e);return!n||typeof n!="object"||n.version!=="1"?null:{version:"1",lastUpdated:n.lastUpdated??new Date().toISOString(),packages:n.packages??{}}}function qe(t,e=Ge){t.lastUpdated=new Date().toISOString();let n={};for(let o of Object.keys(t.packages).sort())n[o]=t.packages[o];t.packages=n;let r=We.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});vr(e,xr+r,"utf-8")}function Ye(t){return`sha256:${Kr("sha256").update(t).digest("hex")}`}import*as Se from"js-yaml";import{createHash as Ir}from"crypto";function ke(t){let e=[];for(let r of t)r instanceof y&&e.push(jr(r));return e.sort((r,o)=>r.uri<o.uri?-1:r.uri>o.uri?1:0),JSON.stringify({subjects:e})}function G(t){let e=ke(t);return`sha256:${Ir("sha256").update(e,"utf8").digest("hex")}`}function jr(t){let e=Lr(t),n=be(t.statement);return{uri:e,statements:n}}function be(t){let e=[];for(let n of t){let r=Br(n);r&&e.push(r)}return e.sort((n,r)=>n.predicate<r.predicate?-1:n.predicate>r.predicate?1:0),e}function Br(t){let e=Or(t);if(!e)return;let n=Tr(t);if(n)return Ur(e,n)}function Tr(t){if(t instanceof ne)return{type:"string",value:t.object};if(t instanceof re)return{type:"number",value:et(t.object)};if(t instanceof oe)return{type:"boolean",value:t.object};if(t instanceof ae)return{type:"ref",value:Xe(t.object)};if(t instanceof ie){let e=t.object;return Ze(e)}if(t instanceof se)return{type:"list",items:t.object.map(Vr)}}function Ze(t){let e=be(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function Vr(t){if(t instanceof h)return{type:"ref",value:Xe(t)};if(t instanceof g)return Ze(t);if(t instanceof te){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:et(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof ee)return{type:"embedded",statements:be(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 Ur(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 Or(t){let e=t.predicate;if(e)return Qe(e.subject)}function Lr(t){let e=t.namespace??"",n=t.name??"";return`${e}/${n}`}function Xe(t){return Qe(t.subject)}function Qe(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 et(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)}var p="kanonak.org",m="view",tt="core-kanonak",Nr={publisher:p,package_:m,name:"rootView"},_r={publisher:p,package_:m,name:"bind"},Ar={publisher:p,package_:m,name:"produces"},Dr={publisher:p,package_:m,name:"projections"},Fr={publisher:p,package_:m,name:"where"},Mr={publisher:p,package_:m,name:"value"},Hr={publisher:p,package_:m,name:"as"},nt="__view_probe__",J=class{constructor(e,n=new Q){this.repository=e;this.parser=n;this.objectParser=new ce(this.parser)}repository;parser;objectParser;async materialize(e,n={}){let r=await this.objectParser.parseKanonaks(this.repository),o=this.resolveView(r,e),a=S(o,_r);if(!a)throw new Error(`View ${o.namespace}/${o.name} declares no view.bind; cannot materialize.`);let i=S(o,Ar);if(!i)throw new Error(`View ${o.namespace}/${o.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let s=zr(o),l=rt(r,p,tt),u=rt(r,p,m),d=new we,q=d.ensure(p,tt,l,"ck"),it=d.ensure(p,m,u,"v"),st=d.ref(i),ct=new je(this.repository,this.parser,this.objectParser),Pe=new xe(ct,r),lt=this.readProjections(r,o),ut=Jr(o,Fr),dt=this.findInstances(r,a,await this.reason(n)),K={},pt=new Set;for(let x of dt){if(!await this.passesWhere(Pe,r,ut,x))continue;let X={type:st};for(let ve of lt){let ft=await this.evaluateValue(Pe,r,ve.value,x),$e=ot(ft,d);$e!==void 0&&(X[d.ref(ve.as)]=$e)}let Re=f(x);Re&&(X[`${it}.derivedFrom`]=d.ref(Re)),K[this.rowName(x,pt)]=X}let Ce=d.toImports(),Y=await this.hashBody(s,Ce,K),Ee=`q-${Y.slice(7,23)}`,Z={type:"EphemeralPackage",publisher:s,imports:Ce,[`${q}.contentHash`]:Y};n.resolvedAt&&(Z[`${q}.resolvedAt`]=n.resolvedAt),n.invocationId&&(Z[`${q}.id`]=n.invocationId);let mt={[Ee]:Z,...K};return{yaml:Se.dump(mt,{lineWidth:-1}),contentHash:Y,packageName:Ee,publisher:s,rowCount:Object.keys(K).length}}resolveView(e,n){let r=B(e,n);if(!r)throw new Error(`View ${n.publisher}/${n.package_}/${n.name} not found in the catalog.`);let o=S(r,Nr);if(o){let a=B(e,o);if(!a)throw new Error(`ViewPackage ${n.name} names rootView ${o.name}, which is not in the catalog.`);return a}return r}readProjections(e,n){let r=[];for(let o of de(n,Dr)){let a=o instanceof g?o:o instanceof h?B(e,o.subject):void 0;if(!a)continue;let i=ue(a,Mr),s=S(a,Hr);i&&s&&r.push({value:i,as:s})}return r}async reason(e){return new le({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,n,r){let o=Gr(e),a=[],i=new Set;for(let s of r.getInstancesOfClass(n)){if(i.has(s))continue;i.add(s);let l=o.get(s);l&&a.push(l)}return a.sort((s,l)=>{let u=b(f(s)),d=b(f(l));return u<d?-1:u>d?1:0}),a}async passesWhere(e,n,r,o){for(let a of r){let i=await this.evaluateValue(e,n,a,o);if(!qr(i))return!1}return!0}async evaluateValue(e,n,r,o){let a=Ie(r,"view-projection",{catalog:n,depth:0}),i=new Map([["input",o]]);return e.evaluate(a,i)}rowName(e,n){let r=at(e.name)||"row",o=r,a=2;for(;n.has(o);)o=`${r}-${a++}`;return n.add(o),o}async hashBody(e,n,r){let o={[nt]:{type:"EphemeralPackage",publisher:e,imports:n},...r},a=this.parser.parse(Se.dump(o,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),l=(await this.objectParser.parseKanonaks(new Ke(a,this.repository))).filter(u=>u instanceof y&&u.namespace===i&&u.name!==nt);for(let u of l)u.namespace="ephemeral";return G(l)}},we=class{byKey=new Map;aliases=new Set;ensure(e,n,r,o){let a=`${e}/${n}@${r}`,i=this.byKey.get(a);if(i)return i.alias;let s=this.uniqueAlias(o);return this.byKey.set(a,{publisher:e,package_:n,version:r,alias:s}),s}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,j(e.version),e.package_)}.${e.name}`}toImports(){let e=new Map;for(let r of this.byKey.values()){let o=e.get(r.publisher)??[];o.push(r),e.set(r.publisher,o)}return[...e.keys()].sort().map(r=>({publisher:r,packages:e.get(r).sort((o,a)=>o.package_<a.package_?-1:1).map(o=>({package:o.package_,match:"^",version:o.version,alias:o.alias}))}))}uniqueAlias(e){let n=at(e)||"pkg",r=n,o=2;for(;this.aliases.has(r);)r=`${n}${o++}`;return this.aliases.add(r),r}};function ot(t,e){if(t!=null){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(pe(t))return t.value;if(t instanceof h)return e.ref(t.subject);if(Array.isArray(t)){let n=t.map(r=>ot(r,e)).filter(r=>r!==void 0);return n.length>0?n:void 0}if(t instanceof g)throw new Error("Embedded projection values are not yet supported by the in-graph materializer. Project a literal or a reference, or compose the embedded shape into the produces class.");if(Yr(t))throw new Error(`Projection produced a bare URI without a version (${t.publisher}/${t.package_}/${t.name}); cannot serialize it as a reference.`)}}function zr(t){let e=f(t);if(!e)throw new Error(`Could not derive a publisher from view ${t.namespace}/${t.name}.`);return e.publisher}function rt(t,e,n){let r=Wr(t,e,n);if(!r)throw new Error(`Package ${e}/${n} is not in the catalog; it must be importable to materialize a view.`);return r}function Wr(t,e,n){let r;for(let o of t){if(!(o instanceof y))continue;let a=f(o);!a||a.publisher!==e||a.package_!==n||!a.version||(!r||I(a.version,r)>0)&&(r=a.version)}return r?j(r):void 0}function Gr(t){let e=new Map,n=new Map;for(let r of t){if(!(r instanceof y))continue;let o=f(r);if(!o||!o.version)continue;let a=b(o),i=n.get(a);(!i||I(o.version,i)>0)&&(n.set(a,o.version),e.set(a,r))}return e}function Jr(t,e){let n=ue(t,e);return n?[n]:de(t,e).filter(r=>r instanceof g)}function at(t){return t.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function qr(t){return t===!0?!0:t===!1||t===void 0||t===null?!1:typeof t=="string"?t.length>0:typeof t=="number"?t!==0:pe(t)?t.value.length>0:Array.isArray(t)?t.length>0:!!t}function Yr(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}export{Nn as AmbiguousReferenceRule,oe as BooleanStatement,Hn as ClassDefinitionRule,xn as ClassHierarchyCycleRule,vt as CompositeKanonakDocumentRepository,W as CredentialStore,ee as DefinedKanonak,On as DefinitionPropertyReferenceRule,Rt as DocumentLocation,Zt as EdgeType,g as EmbeddedKanonak,vn as EmbeddedKanonakTypeRule,ie as EmbeddedStatement,Et as FileSystemKanonakDocumentRepository,rn as GitIgnoreFilter,Xt as GraphBuilder,Bt as HttpKanonakDocumentRepository,$n as ImportExistenceRule,Ct as InMemoryKanonakDocumentRepository,Un as InstancePropertyReferenceRule,Ot as Kanonak,an as KanonakDocumentPositions,ce as KanonakObjectParser,Wn as KanonakObjectValidator,Q as KanonakParser,Lt as KanonakUri,ln as KanonakUriBuilder,pn as KanonakUrlResolver,Wt as KanonakVocabulary,se as ListStatement,te as LiteralKanonak,Tt as LocalFirstRepository,qn as LookRenderer,zn as MarkdownLinkRule,At as MarkdownStatement,Vn as NamespaceImportCycleRule,Pn as NamespacePrefixRule,Yt as NodeType,re as NumberStatement,tn as OWL_RL_CLASSIFICATION_RULES,An as ObjectPropertyImportRule,Dn as ObjectPropertyValueValidationRule,bn as OntologyValidationError,hn as OntologyValidationResult,Fn as PropertyDomainRule,In as PropertyHierarchyCycleRule,on as PropertyMetadata,_n as PropertyRangeReferenceRule,jn as PropertyRangeRequiredRule,En as PropertyTypeSpecificityRule,Mn as PropertyValueTypeRule,xt as PublisherConfigResolver,It as PublisherIndex,en as RDFS_RULES,le as Reasoner,nn as ReasoningResult,h as ReferenceKanonak,ae as ReferenceStatement,Kt as RepositoryFactory,Cn as ResourceNamingRule,Dt as ResourceResolver,qt as ResourceTypeClassifier,_t as ScalarStatement,Nt as Statement,ne as StringStatement,Bn as SubClassOfReferenceRule,Tn as SubPropertyOfReferenceRule,y as SubjectKanonak,Rn as SubjectKanonakTypeRequiredRule,Qt as TripleStore,Ft as TypeResolver,Kn as UnresolvedReferenceRule,wn as ValidationCache,Sn as ValidationContext,kn as ValidationSeverity,Ua as VersionOperator,J as ViewMaterializer,Ln as XsdImportRule,jt as assertPackageIdentity,Ut as buildLocalFirstRepository,ke as canonicalForm,G as canonicalHash,Vt as collectKanonakFiles,I as compareVersions,Ye as computeIntegrity,yn as contextTypesOf,ze as createAuthenticatedFetch,$ as createDPoPProof,kt as createVersion,Jt as extractMarkdownLinks,Gn as findDerivation,gn as findInstancesByType,Gt as findMalformedReferences,cn as findMarkdownLinkAt,dn as formatKanonakAddress,j as formatVersion,Me as generateDPoPKeyPair,$t as getGlobalCachePath,V as hasValidToken,St as isCompatibleVersion,T as isExpired,wt as isMajorCompatible,Je as loadLockFile,Mt as makeUriKey,c as normalizeHost,un as parseKanonakAddress,bt as parseVersionString,sn as parseWithPositions,Pt as pickHighestDocument,mn as propertiesInScope,Jn as resolveDisplayValue,fn as resolvePropertyStep,qe as saveLockFile,He as serverSupportsDPoP,f as subjectUri,Ht as tripleKey,b as uriKey,zt as uriTriple,yt as versionOperatorFromChar,gt as versionOperatorToChar,ht as versionsEqual};
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-6T2XFOMU.js";import{f as b}from"../chunk-PODBS4IU.js";import{a}from"../chunk-ORFSMEMM.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-GN2XODVC.js";import{f as b}from"../chunk-G2DKKSZ4.js";import{a}from"../chunk-TJPQETHV.js";import"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};