@kanonak-protocol/sdk 3.47.0 → 3.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/chunk-3NEUHF7E.js +0 -0
- package/dist/chunk-EIOMVL5H.js +1 -0
- package/dist/chunk-MOFATNEC.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -12
- package/dist/repositories/LocalFirstRepository.d.ts +28 -0
- package/dist/repositories/buildLocalFirstRepository.d.ts +29 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/server/loadServerModel.d.ts +16 -0
- package/dist/server/route.d.ts +12 -0
- package/dist/server/types.d.ts +62 -0
- package/dist/transformations/index.js +1 -1
- package/package.json +6 -2
- package/dist/chunk-5AH6GIPO.js +0 -1
- package/dist/chunk-JGVDV6PM.js +0 -1
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-RCI34BYO.js";import{a as Qe}from"./chunk-
|
|
1
|
+
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-RCI34BYO.js";import{a as Qe}from"./chunk-EIOMVL5H.js";import"./chunk-3NEUHF7E.js";import{a as H,b as L,c as W,d as F}from"./chunk-VHUJSHH7.js";import{a as Pe,b as we,c as he}from"./chunk-NIJV5UYW.js";import{a as ye,b as ke,e as be}from"./chunk-4TJZIM7A.js";import"./chunk-NIGFQYVA.js";import{A as We,B as Fe,C as Ge,D as Xe,a as Ke,b as xe,c as Se,d as Re,f as De,g as Be,h as Ce,i as Ee,j as je,k as ve,l as _e,m as Ie,n as Ae,o as Te,p as Oe,q as Ve,r as $e,s as Ue,t as ze,u as Me,v as Ne,w as Je,x as He,y as qe,z as Le}from"./chunk-SKTXJV4T.js";import"./chunk-FJ35VIV6.js";import{a as Y,c as le,f as pe}from"./chunk-FMYLEPMC.js";import{a as G,b as X,c as Q,d as ee,e as re,f as te,g as ne,h as oe,i as se,j as ie,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as q}from"./chunk-7CUTGGH3.js";import{a as O,b as V,c as $,d as U,e as z,f as M,g as N,h as J}from"./chunk-FQHALFRR.js";import{b as ue,c as de}from"./chunk-HEMBMX7T.js";import{a as Z}from"./chunk-FUUTGGJS.js";var j="kanonak-credentials",u="credentials",Ye=1,f=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(j,Ye);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${j}': ${e.error?.message}
|
|
2
2
|
Credential storage requires IndexedDB support in your browser.`))})}async function _(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey);return{signingKey:n.privateKey,publicKeyJwk:r}}async function k(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey),e=await crypto.subtle.exportKey("jwk",n.privateKey);return{keys:{signingKey:n.privateKey,publicKeyJwk:r},dpopKeyPair:{publicKey:r,privateKey:e}}}async function b(n){return{signingKey:await crypto.subtle.importKey("jwk",n.privateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),publicKeyJwk:n.publicKey}}async function K(n,r,e,t,o){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:n.publicKeyJwk.kty,crv:n.publicKeyJwk.crv,x:n.publicKeyJwk.x,y:n.publicKeyJwk.y}},s={jti:crypto.randomUUID(),htm:r.toUpperCase(),htu:e,iat:Math.floor(Date.now()/1e3)};return t&&(s.ath=await er(t)),o&&(s.nonce=o),await Ze(a,s,n.signingKey)}function x(n){return!n||n.length===0?!1:n.some(r=>r.toUpperCase()==="ES256")}async function Ze(n,r,e){let t=v(JSON.stringify(n)),o=v(JSON.stringify(r)),a=new TextEncoder().encode(`${t}.${o}`),s=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,a),l=D(s);return`${t}.${o}.${l}`}async function er(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return D(e)}function v(n){let r=new TextEncoder().encode(n);return D(r.buffer)}function D(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var rr=300*1e3,S=class{credentialBackend;callbackUrl;constructor(r){this.credentialBackend=new f,this.callbackUrl=r??`${window.location.origin}/browser/callback.html`}async authorize(r){let e=d(r),t=await this.discover(e);if(!t)return{success:!1,error:`No OAuth discovery endpoint found for '${e}'.`};if(!t.authorizationEndpoint||!t.tokenEndpoint)return{success:!1,error:`OAuth metadata incomplete for '${e}'.`};let o=x(t.dpopSigningAlgValuesSupported),a=null,s=null;if(o){let g=await k();a=g.keys,s=g.dpopKeyPair}let l=await this.credentialBackend.get(e),i=l?.clientId??null,c=l?.clientSecret??null;if(!i&&t.registrationEndpoint){let g=await this.registerClient(t.registrationEndpoint);if(!g)return{success:!1,error:`Dynamic client registration failed for '${e}'.`};i=g.clientId,c=g.clientSecret??null}if(!i)return{success:!1,error:`No OAuth client credentials for '${e}'.`};let m=tr(),p=await nr(m),R=or(),A=sr(t.authorizationEndpoint,i,this.callbackUrl,R,p),y=await this.openAuthPopup(A,R);if(!y)return{success:!1,error:"Authorization timed out or was cancelled."};if(y.error)return{success:!1,error:`Authorization failed: ${y.error}`};if(!y.code)return{success:!1,error:"No authorization code received."};if(y.state!==R)return{success:!1,error:"State mismatch \u2014 possible CSRF attack."};let P=await this.exchangeCode(t.tokenEndpoint,i,c,y.code,this.callbackUrl,m,a);if(!P)return{success:!1,error:"Token exchange failed."};let T={clientId:i,clientSecret:c,accessToken:P.accessToken??null,refreshToken:P.refreshToken??null,expiresAt:P.expiresIn?new Date(Date.now()+P.expiresIn*1e3).toISOString():null,tokenEndpoint:t.tokenEndpoint,dpopKeyPair:s};return await this.credentialBackend.store(e,T),{success:!0,host:e}}async getCredentialWithKeys(r){let e=await this.credentialBackend.get(r);if(!e)return null;let t=null;return e.dpopKeyPair&&(t=await b(e.dpopKeyPair)),{credential:e,dpopKeys:t}}async logout(r){let e=d(r);return await this.credentialBackend.remove(e),{success:!0,host:e}}async listAuthenticated(){return this.credentialBackend.list()}async discover(r){for(let e of[`https://${r}/.well-known/oauth-authorization-server`,`https://${r}/.well-known/openid-configuration`])try{let t=await fetch(e);if(!t.ok)continue;let o=await t.json();return{issuer:w(o.issuer),authorizationEndpoint:w(o.authorization_endpoint),tokenEndpoint:w(o.token_endpoint),registrationEndpoint:w(o.registration_endpoint),revocationEndpoint:w(o.revocation_endpoint),dpopSigningAlgValuesSupported:I(o.dpop_signing_alg_values_supported),codeChallengeMethodsSupported:I(o.code_challenge_methods_supported)}}catch{continue}return null}async registerClient(r){try{let e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"Kanonak Browser",redirect_uris:[this.callbackUrl],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"})});if(!e.ok)return null;let t=await e.json(),o=t.client_id;return o?{clientId:o,clientSecret:t.client_secret}:null}catch{return null}}openAuthPopup(r,e){return new Promise(t=>{let o=window.open(r,"kanonak-auth","width=500,height=700,menubar=no,toolbar=no,location=yes,status=no");if(!o){t(null);return}let a=setTimeout(()=>{i(),t(null)},rr),s=c=>{c.origin===window.location.origin&&(!c.data||c.data.type!=="kanonak-auth-callback"||(i(),t({code:c.data.code??void 0,state:c.data.state??void 0,error:c.data.error??void 0})))},l=setInterval(()=>{o.closed&&(i(),t(null))},500),i=()=>{clearTimeout(a),clearInterval(l),window.removeEventListener("message",s);try{o.close()}catch{}};window.addEventListener("message",s)})}async exchangeCode(r,e,t,o,a,s,l){let i=new URLSearchParams({grant_type:"authorization_code",client_id:e,code:o,redirect_uri:a,code_verifier:s});t&&i.set("client_secret",t);let c={"Content-Type":"application/x-www-form-urlencoded"};l&&(c.DPoP=await K(l,"POST",r));try{let m=await fetch(r,{method:"POST",headers:c,body:i.toString()});if(!m.ok)return null;let p=await m.json();return{accessToken:p.access_token,refreshToken:p.refresh_token,expiresIn:typeof p.expires_in=="number"?p.expires_in:void 0}}catch{return null}}};function tr(){let n=new Uint8Array(32);return crypto.getRandomValues(n),B(n.buffer)}async function nr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return B(e)}function or(){let n=new Uint8Array(16);return crypto.getRandomValues(n),B(n.buffer)}function sr(n,r,e,t,o){let a=new URLSearchParams({client_id:r,response_type:"code",redirect_uri:e,state:t,code_challenge:o,code_challenge_method:"S256"});return`${n}?${a}`}function B(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function w(n){return typeof n=="string"?n:null}function I(n){return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}export{Ne as AmbiguousReferenceRule,se as BooleanStatement,f as BrowserCredentialBackend,S as BrowserOAuthFlow,Fe as ClassDefinitionRule,Ie as ClassHierarchyCycleRule,X as DefinedKanonak,ze as DefinitionPropertyReferenceRule,fe as EdgeType,Y as EmbeddedKanonak,je as EmbeddedKanonakTypeRule,ae as EmbeddedStatement,me as GraphBuilder,F as HttpKanonakDocumentRepository,ve as ImportExistenceRule,H as InMemoryKanonakDocumentRepository,Ue as InstancePropertyReferenceRule,G as Kanonak,we as KanonakDocumentPositions,pe as KanonakObjectParser,Xe as KanonakObjectValidator,q as KanonakParser,Z as KanonakUri,ke as KanonakUriBuilder,ce as ListStatement,Ge as MarkdownLinkRule,le as MarkdownStatement,$e as NamespaceImportCycleRule,De as NamespacePrefixRule,ge as NodeType,oe as NumberStatement,He as ObjectPropertyImportRule,qe as ObjectPropertyValueValidationRule,Se as OntologyValidationError,Ke as OntologyValidationResult,Le as PropertyDomainRule,Ae as PropertyHierarchyCycleRule,Pe as PropertyMetadata,Je as PropertyRangeReferenceRule,Te as PropertyRangeRequiredRule,Ce as PropertyTypeSpecificityRule,We as PropertyValueTypeRule,L as PublisherConfigResolver,W as PublisherIndex,ee as ReferenceKanonak,ie as ReferenceStatement,Be as ResourceNamingRule,ue as ResourceResolver,ye as ResourceTypeClassifier,te as ScalarStatement,re as Statement,ne as StringStatement,Oe as SubClassOfReferenceRule,Ve as SubPropertyOfReferenceRule,Q as SubjectKanonak,Ee as SubjectKanonakTypeRequiredRule,de as TypeResolver,_e as UnresolvedReferenceRule,Re as ValidationContext,xe as ValidationSeverity,Me as XsdImportRule,x as browserServerSupportsDPoP,O as compareVersions,K as createBrowserDPoPProof,U as createVersion,Qe as findDerivation,be as findInstancesByType,$ as formatVersion,k as generateBrowserDPoPKeyPair,_ as generateBrowserDPoPKeys,E as hasValidToken,b as importDPoPKeys,M as isCompatibleVersion,C as isExpired,N as isMajorCompatible,d as normalizeHost,z as parseVersionString,he as parseWithPositions,J as pickHighestDocument,V as versionsEqual};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R}from"./chunk-FMYLEPMC.js";import{c as D,d as p,g as l,j as m,k as g,l as d}from"./chunk-W6T7MOKY.js";import{a as j,e as b}from"./chunk-FQHALFRR.js";function te(t,n,e,r){let i=v(t);if(i.length>0){let s=h(i,n,e);return s?{transformation:s.transformation,source:"instance"}:void 0}let a=new Set,o=I(t);for(;o.length>0;){let s=o.shift(),c=_(s.subject);if(a.has(c))continue;a.add(c);let u=y(r,s.subject);if(!u)continue;let U=v(u),S=h(U,n,e);if(S)return{transformation:S.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let x of w(u))o.push(x)}let f={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!a.has(_(f))){let s=y(r,f);if(s){let c=v(s),u=h(c,n,e);if(u)return{transformation:u.transformation,source:f}}}}function v(t){let n=[];for(let e of t.statement)if(e instanceof d&&k(e,"kanonak.org","derivation","derivations"))for(let r of e.object??[]){if(!(r instanceof R))continue;let i=T(r);i&&n.push(i)}return n}function h(t,n,e){let r=t.filter(o=>K(o.format,n)&&K(o.variant,e));if(r.length<=1)return r[0];let i=r[0].transformation,a=r[0];for(let o of r){let f=o.transformation;if(f.publisher!==i.publisher||f.package_!==i.package_||f.name!==i.name)continue;let s=b(a.transformation.version),c=b(f.version);s&&c&&j(c,s)>0&&(a=o)}return a}function T(t){let n,e,r;for(let i of t.statement)i instanceof m?k(i,"kanonak.org","derivation","format")?n=E(i):k(i,"kanonak.org","derivation","variant")&&(e=E(i)):i instanceof g&&k(i,"kanonak.org","derivation","transformation")&&(r=P(i.object));if(!(!n||!r))return e||(e={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:n,variant:e,transformation:r}}function P(t){let n,e,r,i;for(let a of t.statement){if(!(a instanceof l))continue;let o=a.predicate?.subject?.name;o==="publisher"?n=a.object:o==="package"?e=a.object:o==="version"?r=a.object:o==="name"&&(i=a.object)}if(!(!n||!e||!r||!i))return{publisher:n,package_:e,version:r,name:i}}function I(t){let n=[];for(let e of t.statement)e instanceof m&&e.predicate?.subject?.name==="type"&&e.object instanceof p&&n.push(e.object);return n}function w(t){let n=[];for(let e of t.statement)if(e instanceof m){if(e.predicate?.subject?.name!=="subClassOf")continue;e.object instanceof p&&n.push(e.object)}else if(e instanceof d){if(e.predicate?.subject?.name!=="subClassOf")continue;for(let r of e.object??[])r instanceof p&&n.push(r)}return n}function y(t,n){for(let e of t){if(!(e instanceof D)||e.name!==n.name)continue;if((e.namespace||"").startsWith(`${n.publisher}/${n.package_}@`))return e}}function k(t,n,e,r){let i=t.predicate?.subject;return i?i.publisher===n&&i.package_===e&&i.name===r:!1}function E(t){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}function K(t,n){return t.publisher===n.publisher&&t.package_===n.package_&&t.name===n.name}function _(t){return`${t.publisher}/${t.package_}/${t.name}`}export{te as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w,d as A}from"./chunk-VHUJSHH7.js";import{a as f}from"./chunk-7CUTGGH3.js";import{a as P,b as K,f as I,g as R}from"./chunk-FQHALFRR.js";import*as i from"fs/promises";import*as c from"path";import{pathToFileURL as F}from"url";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 0:return K(r,t.version);case 1:return I(r,t.version);case 2:return R(r,t.version);case 3:return P(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 P(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=F(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 F(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 g from"fs";var b=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(b||{}),k=class{cache;workspace;constructor(e,t,n){let o=n??new f;g.existsSync(e)||g.mkdirSync(e,{recursive:!0}),g.existsSync(t)||g.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 x}from"os";import{join as _}from"path";function d(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||_(x(),".kanonak","packages")}var v=class u{static createComposite(e,t,n){let o=e??d(),s=t??".";return new k(o,s,n)}static createFromEnvironment(e){let t=d(),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=[];for(let t of this.repos)try{e.push(...await t.getAllDocumentsAsync())}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 N,readdirSync as B}from"fs";import{join as S}from"path";var H=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(u,e=[]){for(let t of B(u,{withFileTypes:!0}))t.isDirectory()?H.has(t.name)||C(S(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(S(u,t.name));return e}async function j(u,e=new f,t={}){let n=new w(e);for(let m of C(u))try{let l=e.parse(N(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(d(),!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 A({getFromCache:a.getFromCache,onFetch:a.onFetch});return new D(n,o,r)}export{y as a,b,k as c,d,v as e,D as f,C as g,j as h};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { InMemoryKanonakDocumentRepository, FileSystemKanonakDocumentRepository, CompositeKanonakDocumentRepository, RepositoryFactory, DocumentLocation, HttpKanonakDocumentRepository, PublisherIndex, PublisherConfigResolver, getGlobalCachePath } from './repositories/index.js';
|
|
2
|
-
export type { PublisherConfig } from './repositories/index.js';
|
|
1
|
+
export { InMemoryKanonakDocumentRepository, FileSystemKanonakDocumentRepository, CompositeKanonakDocumentRepository, RepositoryFactory, DocumentLocation, HttpKanonakDocumentRepository, LocalFirstRepository, buildLocalFirstRepository, collectKanonakFiles, PublisherIndex, PublisherConfigResolver, getGlobalCachePath } from './repositories/index.js';
|
|
2
|
+
export type { PublisherConfig, HttpCacheHooks } from './repositories/index.js';
|
|
3
3
|
export { GraphBuilder, NodeType, EdgeType } from './graph/index.js';
|
|
4
4
|
export type { GraphNode, GraphEdge, GraphData } from './graph/index.js';
|
|
5
5
|
export { Reasoner, ReasoningResult, TripleStore, KanonakVocabulary, uriKey, makeUriKey, tripleKey, uriTriple, RDFS_RULES, OWL_RL_CLASSIFICATION_RULES, } from './reasoning/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as nt,b as ot,c as at,d as it,e as st,f as ct,g as lt,h as dt,i as ut,j as pt}from"./chunk-IOJMTW4T.js";import{b as er}from"./chunk-KPLFNUIL.js";import{a as et,b as tt,c as rt,d as b,e as S,f as i}from"./chunk-RCI34BYO.js";import{a as Qt}from"./chunk-EIOMVL5H.js";import"./chunk-3NEUHF7E.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne,f as Ue,g as He,h as Me}from"./chunk-MOFATNEC.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VHUJSHH7.js";import{a as ft,b as yt,c as gt,d as ht}from"./chunk-NIJV5UYW.js";import{a as Qe,b as kt,c as bt,d as St,e as Pt}from"./chunk-4TJZIM7A.js";import{a as Ct}from"./chunk-NIGFQYVA.js";import{A as qt,B as Yt,C as Xt,D as Zt,a as Rt,b as wt,c as xt,d as $t,e as vt,f as Et,g as Kt,h as Bt,i as It,j as Tt,k as jt,l as Lt,m as Ft,n as Nt,o as Dt,p as Ot,q as At,r as Ut,s as Ht,t as Mt,u as Vt,v as _t,w as zt,x as Gt,y as Wt,z as Jt}from"./chunk-SKTXJV4T.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as We,d as Ye,e as Xe,f as Ze}from"./chunk-FMYLEPMC.js";import{a as Ve,b as j,c as L,d as N,e as ze,f as Ge,g as O,h as A,i as U,j as H,k as M,l as V}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as Je,c as qe}from"./chunk-HEMBMX7T.js";import{a as _e}from"./chunk-FUUTGGJS.js";import{a as mt}from"./chunk-ODIECDN7.js";import{VersionOperator as lo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as kr,readFileSync as br}from"fs";import{homedir as Sr}from"os";import{join as Cr}from"path";import{execFile as tr}from"child_process";import{promisify as rr}from"util";var C=rr(tr),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
|
|
2
2
|
Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
|
|
3
3
|
The Keychain may be locked or inaccessible.
|
|
4
4
|
Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
|
|
5
5
|
Ensure the Keychain is unlocked and the CLI has write permission.
|
|
6
6
|
On managed devices, your IT policy may block credential storage.`)}}async remove(e){let r=i(e);try{await C(R,["delete-generic-password","-s",P,"-a",r],{timeout:1e4})}catch(n){if(X(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${r}': ${w(n)}
|
|
7
7
|
The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await C(R,["dump-keychain"],{timeout:1e4}),r=[],n=!1;for(let o of e.split(`
|
|
8
|
-
`))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as
|
|
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 nr}from"child_process";import{promisify as or}from"util";var ar=or(nr),x="kanonak:",m=class{async get(e){let r=x+i(e),n=`
|
|
9
9
|
${v}
|
|
10
10
|
$target = [Console]::In.ReadLine()
|
|
11
11
|
$ptr = [IntPtr]::Zero
|
|
@@ -41,7 +41,7 @@ ${v}
|
|
|
41
41
|
$target = [Console]::In.ReadLine()
|
|
42
42
|
[CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await $(n,r)}catch{}}async list(){let e=`
|
|
43
43
|
${v}
|
|
44
|
-
${
|
|
44
|
+
${ir}
|
|
45
45
|
$prefix = [Console]::In.ReadLine()
|
|
46
46
|
$count = 0
|
|
47
47
|
$pCreds = [IntPtr]::Zero
|
|
@@ -56,7 +56,7 @@ if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
|
|
|
56
56
|
}
|
|
57
57
|
[CredMan]::CredFree($pCreds)
|
|
58
58
|
}`;try{let{stdout:r}=await $(e,x);return r.trim().split(`
|
|
59
|
-
`).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function $(t,e){for(let r of["pwsh","powershell"])try{return await
|
|
59
|
+
`).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function $(t,e){for(let r of["pwsh","powershell"])try{return await ar(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var v=`
|
|
60
60
|
Add-Type -TypeDefinition @"
|
|
61
61
|
using System;
|
|
62
62
|
using System.Runtime.InteropServices;
|
|
@@ -87,13 +87,13 @@ public class CredMan {
|
|
|
87
87
|
[DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
88
88
|
public static extern bool CredEnumerate(string filter, int flags, out int count, out IntPtr credentials);
|
|
89
89
|
}
|
|
90
|
-
"@`,
|
|
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
|
|
90
|
+
"@`,ir="";import{execFile as sr,spawn as cr}from"child_process";import{promisify as lr}from"util";var K=lr(sr),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=cr("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 dr,createDecipheriv as ur,randomBytes as re}from"crypto";import{homedir as pr}from"os";import{join as W,dirname as ne}from"path";var ae=W(pr(),".config","kanonak"),y=W(ae,"keyring.key"),B=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(B))return{};try{let e=this.getOrCreateKey(),r=ee(B);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=ur(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=dr(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(B),{recursive:!0}),te(B,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as mr}from"child_process";import{promisify as fr}from"util";var yr=fr(mr),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${I(n)}
|
|
92
92
|
Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
|
|
93
93
|
Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,r){let n=i(e);try{await this.runHelper("store",{publisher:n,credential:r})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${I(o)}
|
|
94
|
-
Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${I(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${I(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await
|
|
95
|
-
Check the 'credentialHelper' path in ~/.kanonak/config.json.`):
|
|
96
|
-
The helper may be waiting for authentication to an external vault.`):n}}};function I(t){return t instanceof Error?t.message:String(t)}function
|
|
97
|
-
Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as
|
|
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
|
|
99
|
-
`;function me(t=pe){if(!
|
|
94
|
+
Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${I(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${I(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await yr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw gr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
|
|
95
|
+
Check the 'credentialHelper' path in ~/.kanonak/config.json.`):hr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
|
|
96
|
+
The helper may be waiting for authentication to an external vault.`):n}}};function I(t){return t instanceof Error?t.message:String(t)}function gr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function hr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=Cr(Sr(),".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=Pr(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=Rr();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await _()?new f:new g}};function Pr(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function Rr(){if(!kr(J))return{};try{return JSON.parse(br(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 wr,createPrivateKey as xr,generateKeyPairSync as $r,randomUUID as vr,sign as Er}from"crypto";function ce(){let{publicKey:t,privateKey:e}=$r("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:vr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=wr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Kr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Kr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=xr({key:r,format:"jwk"}),l=Er("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 Br,writeFileSync as Ir,existsSync as Tr}from"fs";import{createHash as jr}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",Lr=`# This file is generated by Kanonak CLI. Do not edit manually.
|
|
99
|
+
`;function me(t=pe){if(!Tr(t))return null;let e=Br(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:'"'});Ir(e,Lr+n,"utf-8")}function ye(t){return`sha256:${jr("sha256").update(t).digest("hex")}`}import{createHash as Fr}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(Nr(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:${Fr("sha256").update(e,"utf8").digest("hex")}`}function Nr(t){let e=Mr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=Dr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function Dr(t){let e=Hr(t);if(!e)return;let r=Or(t);if(r)return Ur(e,r)}function Or(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 H)return{type:"ref",value:ke(t.object)};if(t instanceof M){let e=t.object;return he(e)}if(t instanceof V)return{type:"list",items:t.object.map(Ar)}}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 Ar(t){if(t instanceof N)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof D){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function 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 Hr(t){let e=t.predicate;if(e)return be(e.subject)}function Mr(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{_t as AmbiguousReferenceRule,U as BooleanStatement,Yt as ClassDefinitionRule,Ft as ClassHierarchyCycleRule,Le as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,Mt as DefinitionPropertyReferenceRule,je as DocumentLocation,tt as EdgeType,F as EmbeddedKanonak,Tt as EmbeddedKanonakTypeRule,M as EmbeddedStatement,Te as FileSystemKanonakDocumentRepository,mt as GitIgnoreFilter,rt as GraphBuilder,Ae as HttpKanonakDocumentRepository,jt as ImportExistenceRule,Be as InMemoryKanonakDocumentRepository,Ht as InstancePropertyReferenceRule,Ve as Kanonak,yt as KanonakDocumentPositions,Ze as KanonakObjectParser,Zt as KanonakObjectValidator,Ie as KanonakParser,_e as KanonakUri,kt as KanonakUriBuilder,Ct as KanonakUrlResolver,ct as KanonakVocabulary,V as ListStatement,D as LiteralKanonak,Ue as LocalFirstRepository,er as LookRenderer,Xt as MarkdownLinkRule,We as MarkdownStatement,Ut as NamespaceImportCycleRule,Et as NamespacePrefixRule,et as NodeType,A as NumberStatement,dt as OWL_RL_CLASSIFICATION_RULES,Gt as ObjectPropertyImportRule,Wt as ObjectPropertyValueValidationRule,xt as OntologyValidationError,Rt as OntologyValidationResult,Jt as PropertyDomainRule,Nt as PropertyHierarchyCycleRule,ft as PropertyMetadata,zt as PropertyRangeReferenceRule,Dt as PropertyRangeRequiredRule,Bt as PropertyTypeSpecificityRule,qt as PropertyValueTypeRule,De as PublisherConfigResolver,Oe as PublisherIndex,lt as RDFS_RULES,pt as Reasoner,ut as ReasoningResult,N as ReferenceKanonak,H as ReferenceStatement,Ne as RepositoryFactory,Kt as ResourceNamingRule,Je as ResourceResolver,Qe as ResourceTypeClassifier,Ge as ScalarStatement,ze as Statement,O as StringStatement,Ot as SubClassOfReferenceRule,At as SubPropertyOfReferenceRule,L as SubjectKanonak,It as SubjectKanonakTypeRequiredRule,st as TripleStore,qe as TypeResolver,Lt as UnresolvedReferenceRule,vt as ValidationCache,$t as ValidationContext,wt as ValidationSeverity,lo as VersionOperator,Vt as XsdImportRule,Me as buildLocalFirstRepository,q as canonicalForm,ge as canonicalHash,He as collectKanonakFiles,Pe as compareVersions,ye as computeIntegrity,de as createAuthenticatedFetch,k as createDPoPProof,xe as createVersion,Xe as extractMarkdownLinks,Qt as findDerivation,Pt as findInstancesByType,Ye as findMalformedReferences,ht as findMarkdownLinkAt,St as formatKanonakAddress,we as formatVersion,ce as generateDPoPKeyPair,Fe as getGlobalCachePath,S as hasValidToken,ve as isCompatibleVersion,b as isExpired,Ee as isMajorCompatible,me as loadLockFile,ot as makeUriKey,i as normalizeHost,bt as parseKanonakAddress,$e as parseVersionString,gt as parseWithPositions,Ke as pickHighestDocument,fe as saveLockFile,le as serverSupportsDPoP,at as tripleKey,nt as uriKey,it as uriTriple,Re as versionsEqual};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import type { KanonakDocument, Import, DocumentReference } from '@kanonak-protocol/types/document/models/types';
|
|
3
|
+
/**
|
|
4
|
+
* A repository that tries several backends in order. For read operations the
|
|
5
|
+
* first backend to return a value wins; writes go to the first backend.
|
|
6
|
+
*
|
|
7
|
+
* The canonical stack is workspace → global cache → HTTP (see
|
|
8
|
+
* `buildLocalFirstRepository`). Document ORDER is significant: open-world
|
|
9
|
+
* augmentations (e.g. a publisher look re-opening `rdfs.Resource`) merge in
|
|
10
|
+
* the order documents are returned, so the workspace must precede the cache
|
|
11
|
+
* for renders to match what the workspace authored. Use this rather than
|
|
12
|
+
* `CompositeKanonakDocumentRepository` (cache-first, no HTTP tier) when that
|
|
13
|
+
* ordering matters — notably anything that renders via `LookRenderer`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class LocalFirstRepository implements IKanonakDocumentRepository {
|
|
16
|
+
private readonly repos;
|
|
17
|
+
constructor(...repos: IKanonakDocumentRepository[]);
|
|
18
|
+
getHighestCompatibleVersionAsync(publisher: string, import_: Import): Promise<KanonakDocument | null>;
|
|
19
|
+
getAllDocumentsAsync(): Promise<KanonakDocument[]>;
|
|
20
|
+
getDocumentAsync(identifier: string): Promise<KanonakDocument | null>;
|
|
21
|
+
getDocumentsByNamespaceAsync(publisher: string, package_: string): Promise<KanonakDocument[]>;
|
|
22
|
+
saveDocumentAsync(document: KanonakDocument, identifier: string): Promise<void>;
|
|
23
|
+
deleteDocumentAsync(identifier: string): Promise<void>;
|
|
24
|
+
clearNamespaceAsync(publisher: string, package_: string): Promise<void>;
|
|
25
|
+
getAllDocumentReferencesAsync(): Promise<DocumentReference[]>;
|
|
26
|
+
getDocumentContentAsync(identifier: string): Promise<string | null>;
|
|
27
|
+
getDocumentUriAsync(identifier: string): Promise<string | null>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import { KanonakParser } from '../parsing/KanonakParser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively collect every `.kan.yml` file under `dir`, skipping build/output
|
|
5
|
+
* and dependency directories. Pure filesystem walk — no YAML parsing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function collectKanonakFiles(dir: string, files?: string[]): string[];
|
|
8
|
+
/** Hook for persisting / reading HTTP-fetched documents (e.g. a disk cache). */
|
|
9
|
+
export interface HttpCacheHooks {
|
|
10
|
+
getFromCache(publisher: string, packageName: string, version: string): string | null;
|
|
11
|
+
onFetch(publisher: string, packageName: string, version: string, content: string): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build the canonical three-tier resolution repository, workspace-first:
|
|
15
|
+
*
|
|
16
|
+
* 1. **Workspace** — every `.kan.yml` under `workspaceRoot`, parsed into an
|
|
17
|
+
* in-memory repo (loaded first → returned first, so open-world
|
|
18
|
+
* augmentations merge in workspace order).
|
|
19
|
+
* 2. **Global cache** — `~/.kanonak/packages/` (`getGlobalCachePath()`).
|
|
20
|
+
* 3. **HTTP** — on-demand fetch from publisher origins, write-through to the
|
|
21
|
+
* caller-supplied `httpCache` (defaults to an in-memory map).
|
|
22
|
+
*
|
|
23
|
+
* This is the stack every Kanonak-aware tool should resolve through; it is the
|
|
24
|
+
* order that makes `LookRenderer` output deterministic. The CLI's
|
|
25
|
+
* `buildRepository` and the server core both build on this.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildLocalFirstRepository(workspaceRoot: string, parser?: KanonakParser, options?: {
|
|
28
|
+
httpCache?: HttpCacheHooks;
|
|
29
|
+
}): Promise<IKanonakDocumentRepository>;
|
|
@@ -3,6 +3,8 @@ export { FileSystemKanonakDocumentRepository } from './FileSystemKanonakDocument
|
|
|
3
3
|
export { CompositeKanonakDocumentRepository, DocumentLocation } from './CompositeKanonakDocumentRepository.js';
|
|
4
4
|
export { RepositoryFactory } from './RepositoryFactory.js';
|
|
5
5
|
export { HttpKanonakDocumentRepository } from './HttpKanonakDocumentRepository.js';
|
|
6
|
+
export { LocalFirstRepository } from './LocalFirstRepository.js';
|
|
7
|
+
export { buildLocalFirstRepository, collectKanonakFiles, type HttpCacheHooks, } from './buildLocalFirstRepository.js';
|
|
6
8
|
export { PublisherIndex } from './PublisherIndex.js';
|
|
7
9
|
export { PublisherConfigResolver } from './PublisherConfig.js';
|
|
8
10
|
export type { PublisherConfig } from './PublisherConfig.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f}from"../chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as j,g as k,h as l}from"../chunk-MOFATNEC.js";import{a,b as g,c as h,d as i}from"../chunk-VHUJSHH7.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,i as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,j as LocalFirstRepository,g as PublisherConfigResolver,h as PublisherIndex,f as RepositoryFactory,l as buildLocalFirstRepository,k as collectKanonakFiles,e as getGlobalCachePath};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{b as O}from"../chunk-KPLFNUIL.js";import"../chunk-3NEUHF7E.js";import{a as P,d as _,f as F,g as N}from"../chunk-MOFATNEC.js";import{a as V,d as K}from"../chunk-VHUJSHH7.js";import{a as L}from"../chunk-NIGFQYVA.js";import{f as D}from"../chunk-FMYLEPMC.js";import{c as C}from"../chunk-W6T7MOKY.js";import{a as M}from"../chunk-7CUTGGH3.js";import{a as x,e as R}from"../chunk-FQHALFRR.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";import{readFileSync as B}from"fs";async function A(n,e={}){let a=new M,r=new V(a),c=[];for(let o of N(n)){let h;try{h=B(o,"utf-8")}catch{continue}let u;try{u=a.parse(h).metadata?.namespace_}catch{continue}if(!u?.version)continue;let v=u.version,w=`${v.major}.${v.minor}.${v.patch}`;await r.saveDocumentAsync(a.parse(h),`${u.publisher}/${u.package_}@${w}`),c.push({publisher:u.publisher,package_:u.package_,verStr:w,source:h})}let g=[...new Set(c.map(o=>o.publisher))].sort(),m=e.publisher;if(m){if(!g.includes(m))throw new Error(`Publisher "${m}" not found in workspace. Available: ${g.join(", ")||"(none)"}`)}else if(g.length===1)m=g[0];else throw g.length===0?new Error(`No Kanonak packages found under ${n}`):new Error(`Workspace has multiple publishers (${g.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let d=new Set,b=new Map;for(let o of c)o.publisher===m&&(d.add(`${o.publisher}/${o.package_}@${o.verStr}`),b.set(`${o.package_}@${o.verStr}`,o.source));let $=e.repository??new F(r,new P(_(),!0,a),new K(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),i=await new D(a).parseKanonaks($),s=new O(i),t=new Map,l=new Map,k=new Map,y=new Set;for(let o of i){if(!(o instanceof C))continue;let h=o.namespace||"";if(!d.has(h))continue;t.set(`${h}/${o.name}`,o);let u=h.split("/")[1]??"",[v,w]=u.split("@");if(!v||!w)continue;let j=R(w);j&&(y.has(u)||(y.add(u),l.has(v)||l.set(v,[]),l.get(v).push({verStr:w,version:j})),o.name===v&&k.set(u,o))}for(let o of l.values())o.sort((h,u)=>x(u.version,h.version));return{publisher:m,availablePublishers:g,catalog:i,lookRenderer:s,localNamespaces:d,rawByNsKey:b,bySubject:t,pkgVersions:l,pkgSelfByVer:k}}var p={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},f=(n,e,a,r)=>({status:n,headers:{"Content-Type":e,...r||{}},body:a}),S=n=>f(404,p[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${n}</p>`),I=n=>({status:301,headers:{Location:n},body:""});function E(n,e,a){let r=n.pkgVersions.get(e);if(!r||r.length===0)return null;switch(a.kind){case"any":return r[0].verStr;case"major-pin":return r.find(c=>c.version.major===a.major)?.verStr??null;case"minor-pin":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor)?.verStr??null;case"exact":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor&&c.version.patch===a.patch)?.verStr??null;default:return null}}function T(n,e,a=""){let{lookRenderer:r,publisher:c}=n;if(e==="/.well-known/kanonak.json")return f(200,p[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(e==="/index.txt"){let s=[...n.localNamespaces].map(t=>t.split("/")[1].replace("@","/")).sort();return f(200,p[".txt"],s.join(`
|
|
2
|
+
`)+`
|
|
3
|
+
`)}if(e==="/"||e==="/index.html"||e==="/index.css"){let s=r.findPublisherRootView(c),t=[...n.pkgVersions.keys()].sort(),l=s??(t.length?n.pkgSelfByVer.get(`${t[0]}@${n.pkgVersions.get(t[0])[0].verStr}`):void 0);if(e==="/index.css")return f(200,p[".css"],s?r.renderStylesheet(s):r.renderPublisherIndexStylesheet(l));if(s)return f(200,p[".html"],r.renderDocument(s,{rootIndex:!0}));let k=t.map(y=>({label:y,href:`/${y}`}));return f(200,p[".html"],r.renderPublisherIndex(c,k,l))}let g=".html",m=!1,d=e;for(let s of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(s)){g=s,m=!0,d=e.slice(0,-s.length);break}let b=!m&&/application\/yaml|text\/yaml/i.test(a),$=d.endsWith("/");$&&d!=="/"&&(d=d.slice(0,-1));let i=L.parse(d,c);if(!i)return S(e);if(i.kind==="package"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);if(g===".kan.yml"||b){let k=n.rawByNsKey.get(`${i.package_}@${s}`);return k!==void 0?f(200,p[".kan.yml"],k):S(e)}let t=n.pkgSelfByVer.get(`${i.package_}@${s}`);if(!t)return S(e);if(g===".css")return f(200,p[".css"],r.renderStylesheet(t));if(!$)return I(d+"/");let l=i.versionSpec.kind==="any";if(l&&!r.hasDeclaredView(t)){let k=(n.pkgVersions.get(i.package_)||[]).map(y=>y.verStr);return f(200,p[".html"],r.renderPackageVersionList(i.package_,k,t))}return f(200,p[".html"],r.renderDocument(t,l?{bareOverview:!0}:void 0))}if(i.kind==="resource"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);let t=n.bySubject.get(`${c}/${i.package_}@${s}/${i.name}`);if(!t)return S(e);switch(g){case".css":return f(200,p[".css"],r.renderStylesheet(t));case".svg":return f(200,p[".svg"],r.renderSvg(t));case".md":{let l=r.renderRawMarkdown(t);return l===void 0?S(e):f(200,p[".md"],l)}default:return f(200,p[".html"],r.renderDocument(t))}}return S(e)}export{A as loadServerModel,T as route};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ServerModel, LoadServerModelOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load a workspace into an in-memory {@link ServerModel} for {@link route}.
|
|
4
|
+
*
|
|
5
|
+
* A publisher origin serves exactly ONE publisher. With several publishers in
|
|
6
|
+
* the workspace, pass `{ publisher }`; a single-publisher workspace infers it,
|
|
7
|
+
* an empty one throws, and an ambiguous one throws with the candidate list.
|
|
8
|
+
* ALL local files are still loaded into the resolution repository regardless,
|
|
9
|
+
* so cross-publisher imports between local packages keep resolving — only the
|
|
10
|
+
* SERVED set (routing, `index.txt`, package list, raw source) is scoped to the
|
|
11
|
+
* chosen publisher.
|
|
12
|
+
*
|
|
13
|
+
* Raw `.kan.yml` source is read here and held in the model so `route` performs
|
|
14
|
+
* no filesystem I/O.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadServerModel(workspaceRoot: string, options?: LoadServerModelOptions): Promise<ServerModel>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ServerModel, RouteResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map one request to a response, using the same `LookRenderer` calls
|
|
4
|
+
* `kanonak publish` makes — so a live response is byte-equivalent to the
|
|
5
|
+
* static page `publish` would write — plus the machine-facing endpoints
|
|
6
|
+
* `publish` omits (`/.well-known/kanonak.json`, `/index.txt`, raw `.kan.yml`).
|
|
7
|
+
*
|
|
8
|
+
* Pure: `pathname` in, response out. No filesystem or network I/O — raw
|
|
9
|
+
* sources are preloaded in the model. `accept` disambiguates the no-extension
|
|
10
|
+
* case (raw package YAML vs HTML).
|
|
11
|
+
*/
|
|
12
|
+
export declare function route(model: ServerModel, pathname: string, accept?: string): RouteResponse;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Version } from '@kanonak-protocol/types/document/models/types';
|
|
2
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
3
|
+
import type { Kanonak } from '../kanonaks/index.js';
|
|
4
|
+
import { SubjectKanonak } from '../kanonaks/index.js';
|
|
5
|
+
import type { LookRenderer } from '../look/index.js';
|
|
6
|
+
import type { HttpCacheHooks } from '../repositories/index.js';
|
|
7
|
+
/** A package version present in the served workspace. */
|
|
8
|
+
export interface PackageVersion {
|
|
9
|
+
/** "major.minor.patch" string form. */
|
|
10
|
+
readonly verStr: string;
|
|
11
|
+
/** Parsed Version (for comparison against a URL `VersionSpec`). */
|
|
12
|
+
readonly version: Version;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The in-memory render model for one served publisher: the parsed catalog, a
|
|
16
|
+
* `LookRenderer` over it, and the indexes `route` needs to map a path to a
|
|
17
|
+
* response without touching the filesystem. Built once by `loadServerModel`
|
|
18
|
+
* and held in memory; rebuilt on workspace change (the CLI's `--watch`).
|
|
19
|
+
*/
|
|
20
|
+
export interface ServerModel {
|
|
21
|
+
/** The publisher this model serves. */
|
|
22
|
+
readonly publisher: string;
|
|
23
|
+
/** Every publisher found in the workspace (for the ambiguity message). */
|
|
24
|
+
readonly availablePublishers: string[];
|
|
25
|
+
/** Parsed kanonaks across the full resolution closure. */
|
|
26
|
+
readonly catalog: Kanonak[];
|
|
27
|
+
/** Renderer over `catalog` — the same one `kanonak publish` uses. */
|
|
28
|
+
readonly lookRenderer: LookRenderer;
|
|
29
|
+
/** Namespaces (`publisher/pkg@ver`) of the SERVED publisher's local packages. */
|
|
30
|
+
readonly localNamespaces: Set<string>;
|
|
31
|
+
/** `pkg@ver` → raw `.kan.yml` source (preloaded so `route` stays fs-free). */
|
|
32
|
+
readonly rawByNsKey: Map<string, string>;
|
|
33
|
+
/** `publisher/pkg@ver/name` → subject, for resource lookup. */
|
|
34
|
+
readonly bySubject: Map<string, SubjectKanonak>;
|
|
35
|
+
/** package → versions present, sorted highest-first. */
|
|
36
|
+
readonly pkgVersions: Map<string, PackageVersion[]>;
|
|
37
|
+
/** `pkg@ver` → the package self-resource subject. */
|
|
38
|
+
readonly pkgSelfByVer: Map<string, SubjectKanonak>;
|
|
39
|
+
}
|
|
40
|
+
/** A routed response. `body` is always a string (HTML/CSS/SVG/MD/YAML/JSON). */
|
|
41
|
+
export interface RouteResponse {
|
|
42
|
+
status: number;
|
|
43
|
+
headers: Record<string, string>;
|
|
44
|
+
body: string;
|
|
45
|
+
}
|
|
46
|
+
export interface LoadServerModelOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Which publisher to serve. Required only when the workspace contains more
|
|
49
|
+
* than one publisher; a single-publisher workspace infers it.
|
|
50
|
+
*/
|
|
51
|
+
publisher?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Override the resolution repository. When omitted, the canonical
|
|
54
|
+
* workspace → cache → HTTP stack is built. A provided repository MUST cover
|
|
55
|
+
* the workspace's documents (it supplies the parsed catalog); raw-source
|
|
56
|
+
* serving and publisher scoping still come from the workspace scan.
|
|
57
|
+
*/
|
|
58
|
+
repository?: IKanonakDocumentRepository;
|
|
59
|
+
/** HTTP write-through cache hook for the default stack (e.g. a disk cache). */
|
|
60
|
+
httpCache?: HttpCacheHooks;
|
|
61
|
+
}
|
|
62
|
+
export { SubjectKanonak };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-KPLFNUIL.js";import{a as Ne}from"../chunk-
|
|
1
|
+
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-KPLFNUIL.js";import{a as Ne}from"../chunk-EIOMVL5H.js";import"../chunk-3NEUHF7E.js";import"../chunk-NIJV5UYW.js";import"../chunk-NIGFQYVA.js";import{a as Oe}from"../chunk-FJ35VIV6.js";import{a as C,c as Ce,f as Ue}from"../chunk-FMYLEPMC.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-HEMBMX7T.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
4
|
`)),u}};function ht(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Me(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.48.0",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -78,6 +78,10 @@
|
|
|
78
78
|
"types": "./dist/transformations/index.d.ts",
|
|
79
79
|
"default": "./dist/transformations/index.js"
|
|
80
80
|
},
|
|
81
|
+
"./server": {
|
|
82
|
+
"types": "./dist/server/index.d.ts",
|
|
83
|
+
"default": "./dist/server/index.js"
|
|
84
|
+
},
|
|
81
85
|
"./browser": {
|
|
82
86
|
"types": "./dist/browser.d.ts",
|
|
83
87
|
"default": "./dist/browser.js"
|
|
@@ -113,7 +117,7 @@
|
|
|
113
117
|
"yaml-parser"
|
|
114
118
|
],
|
|
115
119
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.
|
|
120
|
+
"@kanonak-protocol/types": "^3.48.0",
|
|
117
121
|
"ignore": "^7.0.5",
|
|
118
122
|
"js-yaml": "^4.1.0",
|
|
119
123
|
"yaml": "^2.7.0"
|
package/dist/chunk-5AH6GIPO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as f}from"./chunk-7CUTGGH3.js";import{a as g,b as D,f as P,g as w}from"./chunk-FQHALFRR.js";import*as c from"fs/promises";import*as i from"path";import{pathToFileURL as v}from"url";var l=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(t,e=!0,n){if(!t||t.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=i.resolve(t),this.recursive=e,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let t=new Set(this.documentCache.values());return Array.from(t)}async getDocumentAsync(t){await this.ensureCacheInitialized();let e=this.documentCache.get(t);if(e)return e;let n=i.join(this.rootPath,t);if(e=this.documentCache.get(n),e)return e;for(let a of[".kan.yml",".yml",".yaml"])if(!t.endsWith(a)){let s=t+a;if(e=this.documentCache.get(s),e)return e;let o=i.join(this.rootPath,s);if(e=this.documentCache.get(o),e)return e}return null}async getDocumentsByNamespaceAsync(t,e){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(a=>a.metadata.namespace_?.publisher===t&&a.metadata.namespace_?.package_===e)}async getHighestCompatibleVersionAsync(t,e){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),a=Array.from(n).filter(o=>o.metadata?.namespace_?.publisher===t&&o.metadata?.namespace_?.package_===e.packageName&&o.metadata?.namespace_?.version!==void 0);if(a.length===0)return null;let s=a.filter(o=>{let r=o.metadata.namespace_.version;switch(e.versionOperator){case 0:return D(r,e.version);case 1:return P(r,e.version);case 2:return w(r,e.version);case 3:return g(r,e.minVersion)>=0;default:return!1}});return s.length===0?null:(s.sort((o,r)=>{let m=o.metadata.namespace_.version,u=r.metadata.namespace_.version;return g(u,m)}),s[0])}async saveDocumentAsync(t,e){let n,a=t.metadata.namespace_?.toString();if(a&&a.includes("@")&&a.includes("/")){let m=a.split("/"),u=m[0],I=m[1].replace("@","@")+".kan.yml";n=i.join(this.rootPath,u,I)}else n=i.join(this.rootPath,e),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=i.dirname(n);await c.mkdir(s,{recursive:!0});let o=this.parser.save(t);await c.writeFile(n,o,"utf8"),a&&this.documentCache.set(a,t),this.documentCache.set(n,t);let r=i.relative(this.rootPath,n);this.documentCache.set(r,t)}async deleteDocumentAsync(t){let e=await this.getDocumentAsync(t);if(!e)return;let n=this.filePathsByIdentifier.get(t);if(!n)return;try{await c.unlink(n)}catch{}let a=e.metadata.namespace_?.toString();a&&this.documentCache.delete(a),this.documentCache.delete(t),this.documentCache.delete(n);let s=i.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(t,e){await this.ensureCacheInitialized();let n=[];for(let[s,o]of this.documentCache.entries()){let r=o.metadata.namespace_?.toString()||"";r.includes(t)&&r.includes(e)&&n.push([s,o])}let a=i.join(this.rootPath,t);try{let s=await c.readdir(a);for(let o of s)o.includes(e)&&o.endsWith(".kan.yml")&&await c.unlink(i.join(a,o))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let t=new Set(this.filePathsByIdentifier.values()),e=[];for(let n of t){let a=v(n).toString(),s;for(let[m,u]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&u.metadata.namespace_){s=u.metadata.namespace_.toString();break}let o=s??i.relative(this.rootPath,n),r=this.parsingErrors.has(n);e.push({identifier:o,uri:a,hasParseError:r})}return e}async getDocumentContentAsync(t){await this.ensureCacheInitialized();let e=this.filePathsByIdentifier.get(t);if(!e)try{await c.access(t),e=t}catch{let n=i.join(this.rootPath,t);try{await c.access(n),e=n}catch{return null}}try{return await c.readFile(e,"utf8")}catch{return null}}async getDocumentUriAsync(t){await this.ensureCacheInitialized();let e=this.filePathsByIdentifier.get(t);if(!e)try{await c.access(t),e=t}catch{let n=i.join(this.rootPath,t);try{await c.access(n),e=n}catch{return null}}return v(e).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 c.mkdir(this.rootPath,{recursive:!0})}catch{}let e=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async a=>{try{let s=await c.readFile(a,"utf8"),o=this.parser.parse(s);return{filePath:a,document:o,error:null}}catch(s){return{filePath:a,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(e);for(let{filePath:a,document:s,error:o}of n){let r=i.relative(this.rootPath,a);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(a,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,a),this.filePathsByIdentifier.set(a,a),this.filePathsByIdentifier.set(r,a)}else this.filePathsByIdentifier.set(a,a),this.filePathsByIdentifier.set(r,a);o&&this.parsingErrors.set(a,o)}}async findYamlFiles(t,e){let n=[];try{let a=await c.readdir(t,{withFileTypes:!0});for(let s of a){let o=i.join(t,s.name);if(s.isDirectory()&&e){let r=await this.findYamlFiles(o,e);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(o)}}catch{}return n}};import*as p from"fs";var A=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(A||{}),y=class{cache;workspace;constructor(t,e,n){let a=n??new f;p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),p.existsSync(e)||p.mkdirSync(e,{recursive:!0}),this.cache=new l(t,!0,a),this.workspace=new l(e,!0,a)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let t=await this.workspace.getAllDocumentsAsync(),e=await this.cache.getAllDocumentsAsync(),n=new Map;for(let a of e)if(a.metadata.namespace_){let s=a.metadata.namespace_.toString();n.set(s,a)}for(let a of t)if(a.metadata.namespace_){let s=a.metadata.namespace_.toString();n.set(s,a)}return Array.from(n.values())}async getDocumentAsync(t){let e=await this.workspace.getDocumentAsync(t);return e||await this.cache.getDocumentAsync(t)}async getDocumentsByNamespaceAsync(t,e){let n=await this.workspace.getDocumentsByNamespaceAsync(t,e),a=await this.cache.getDocumentsByNamespaceAsync(t,e),s=new Map;for(let o of a)if(o.metadata.namespace_?.version){let r=o.metadata.namespace_.version.toString();s.set(r,o)}for(let o of n)if(o.metadata.namespace_?.version){let r=o.metadata.namespace_.version.toString();s.set(r,o)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(t,e){let n=await this.workspace.getHighestCompatibleVersionAsync(t,e);return n||await this.cache.getHighestCompatibleVersionAsync(t,e)}async saveDocumentAsync(t,e){await this.workspace.saveDocumentAsync(t,e)}async saveToCacheAsync(t,e){await this.cache.saveDocumentAsync(t,e)}async deleteDocumentAsync(t){await this.workspace.deleteDocumentAsync(t)}async clearNamespaceAsync(t,e){await this.workspace.clearNamespaceAsync(t,e)}async getAllDocumentReferencesAsync(){let t=await this.workspace.getAllDocumentReferencesAsync(),e=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...t),n.push(...e),n}async getDocumentContentAsync(t){let e=await this.workspace.getDocumentContentAsync(t);return e||await this.cache.getDocumentContentAsync(t)}async getDocumentUriAsync(t){let e=await this.workspace.getDocumentUriAsync(t);return e||await this.cache.getDocumentUriAsync(t)}async getDocumentLocationAsync(t){return await this.workspace.getDocumentAsync(t)?"Workspace":await this.cache.getDocumentAsync(t)?"Cache":"NotFound"}};import{homedir as K}from"os";import{join as R}from"path";function d(){let h=process.env.KANONAK_PACKAGE_CACHE;return h||R(K(),".kanonak","packages")}var k=class h{static createComposite(t,e,n){let a=t??d(),s=e??".";return new y(a,s,n)}static createFromEnvironment(t){let e=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return h.createComposite(e,n,t)}};export{l as a,A as b,y as c,d,k as e};
|
package/dist/chunk-JGVDV6PM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as g}from"./chunk-FMYLEPMC.js";import{c as l,d as u,g as v,j as p,k as h,l as d}from"./chunk-W6T7MOKY.js";import{a as K,e as b}from"./chunk-FQHALFRR.js";function pe(t,n,e,i){let r=S(t);if(r.length>0){let s=j(r,n,e);return s?{transformation:s.transformation,source:"instance"}:void 0}let a=new Set,o=I(t);for(;o.length>0;){let s=o.shift(),c=x(s.subject);if(a.has(c))continue;a.add(c);let m=R(i,s.subject);if(!m)continue;let _=S(m),D=j(_,n,e);if(D)return{transformation:D.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let U of L(m))o.push(U)}let f={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!a.has(x(f))){let s=R(i,f);if(s){let c=S(s),m=j(c,n,e);if(m)return{transformation:m.transformation,source:f}}}}function S(t){let n=[];for(let e of t.statement)if(e instanceof d&&k(e,"kanonak.org","derivation","derivations"))for(let i of e.object??[]){if(!(i instanceof g))continue;let r=T(i);r&&n.push(r)}return n}function j(t,n,e){let i=t.filter(o=>E(o.format,n)&&E(o.variant,e));if(i.length<=1)return i[0];let r=i[0].transformation,a=i[0];for(let o of i){let f=o.transformation;if(f.publisher!==r.publisher||f.package_!==r.package_||f.name!==r.name)continue;let s=b(a.transformation.version),c=b(f.version);s&&c&&K(c,s)>0&&(a=o)}return a}function T(t){let n,e,i;for(let r of t.statement)r instanceof p?k(r,"kanonak.org","derivation","format")?n=y(r):k(r,"kanonak.org","derivation","variant")&&(e=y(r)):r instanceof h&&k(r,"kanonak.org","derivation","transformation")&&(i=P(r.object));if(!(!n||!i))return e||(e={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:n,variant:e,transformation:i}}function P(t){let n,e,i,r;for(let a of t.statement){if(!(a instanceof v))continue;let o=a.predicate?.subject?.name;o==="publisher"?n=a.object:o==="package"?e=a.object:o==="version"?i=a.object:o==="name"&&(r=a.object)}if(!(!n||!e||!i||!r))return{publisher:n,package_:e,version:i,name:r}}function I(t){let n=[];for(let e of t.statement)e instanceof p&&e.predicate?.subject?.name==="type"&&e.object instanceof u&&n.push(e.object);return n}function L(t){let n=[];for(let e of t.statement)if(e instanceof p){if(e.predicate?.subject?.name!=="subClassOf")continue;e.object instanceof u&&n.push(e.object)}else if(e instanceof d){if(e.predicate?.subject?.name!=="subClassOf")continue;for(let i of e.object??[])i instanceof u&&n.push(i)}return n}function R(t,n){for(let e of t){if(!(e instanceof l)||e.name!==n.name)continue;if((e.namespace||"").startsWith(`${n.publisher}/${n.package_}@`))return e}}function k(t,n,e,i){let r=t.predicate?.subject;return r?r.publisher===n&&r.package_===e&&r.name===i:!1}function y(t){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}function E(t,n){return t.publisher===n.publisher&&t.package_===n.package_&&t.name===n.name}function x(t){return`${t.publisher}/${t.package_}/${t.name}`}export{pe as a};
|