@kanonak-protocol/sdk 5.15.0 → 5.16.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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F,b as H,c as L,d as Pe,f as ge,g as Ce,h as he,i as Ke,j as be,k as Ie,l as Oe,m as je}from"./chunk-
|
|
1
|
+
import{a as F,b as H,c as L,d as Pe,f as ge,g as Ce,h as he,i as Ke,j as be,k as Ie,l as Oe,m as je}from"./chunk-TXVVQPAO.js";import{a as Se}from"./chunk-LYSCTQC2.js";import"./chunk-QHABFCRC.js";import{a as m,b as u,c,e as d,h as R,j as y,k as f}from"./chunk-UXYCUGSF.js";import{a as p}from"./chunk-4NO7MHS7.js";import{a as B,b as G,c as q}from"./chunk-5NH5XDGO.js";import{a as w,b as _}from"./chunk-PEUTCG3B.js";import"./chunk-PEJALHXK.js";import"./chunk-SC5M74NM.js";import{A as fe,B as xe,K as ke,a as W,b as z,c as J,d as Q,f as X,g as Y,h as Z,i as $,k as ee,l as oe,m as te,n as re,o as ne,p as ae,q as ie,r as se,s as pe,t as le,u as me,v as ue,w as ce,x as de,y as Re,z as ye}from"./chunk-Q6XQ5IXW.js";import"./chunk-ITKOKDBG.js";import{a as g,c as v,i as A,j as M,m as U}from"./chunk-V6KIDED2.js";import{a as l}from"./chunk-NJ3AZYQD.js";import{a as E,b as N,o as T}from"./chunk-SVUMCLK5.js";import{a as x,b as k,c as P,d as h,e as K,f as S,g as b,h as I,i as O,j,k as D,l as V}from"./chunk-YW6P24RF.js";import{a as C}from"./chunk-FUUTGGJS.js";import{c as e,d as o,e as t,f as r,g as n,h as a,i,j as s}from"./chunk-2ACBWC7K.js";export{me as AmbiguousReferenceRule,O as BooleanStatement,Oe as CANONICAL_FORM_VERSION,A as Carrier,fe as ClassDefinitionRule,re as ClassHierarchyCycleRule,k as DefinedKanonak,H as EdgeType,g as EmbeddedKanonak,ee as EmbeddedKanonakTypeRule,D as EmbeddedStatement,L as GraphBuilder,f as HttpKanonakDocumentRepository,oe as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,m as KANONAK_USER_AGENT,x as Kanonak,G as KanonakDocumentPositions,U as KanonakObjectParser,ke as KanonakObjectValidator,l as KanonakParser,C as KanonakUri,w as KanonakUriBuilder,V as ListStatement,xe as MarkdownLinkRule,v as MarkdownStatement,pe as NamespaceImportCycleRule,X as NamespacePrefixRule,F as NodeType,I as NumberStatement,ge as OAuthDiscovery,ce as ObjectPropertyValueValidationRule,J as OntologyValidationError,W as OntologyValidationResult,de as PropertyDomainRule,ne as PropertyHierarchyCycleRule,Re as PropertyKindRangeConsistencyRule,B as PropertyMetadata,ue as PropertyRangeReferenceRule,ae as PropertyRangeRequiredRule,Z as PropertyTypeSpecificityRule,R as PublisherConfigResolver,y as PublisherIndex,h as ReferenceKanonak,j as ReferenceStatement,ye as ReservedNameShadowRule,Y as ResourceNamingRule,E as ResourceResolver,T as ResourceTypeClassifier,S as ScalarStatement,K as Statement,b as StringStatement,ie as SubClassOfReferenceRule,se as SubPropertyOfReferenceRule,P as SubjectKanonak,$ as SubjectKanonakTypeRequiredRule,Ke as TokenCredentialProvider,N as TypeResolver,le as UnresolvedPredicateRule,te as UnresolvedReferenceRule,Q as ValidationContext,z as ValidationSeverity,je as buildOntologyModel,be as canonicalForm,Ie as canonicalHash,M as carrierOf,e as compareVersions,he as createCredentialedFetch,r as createVersion,Se as findDerivation,_ as findInstancesByType,t as formatVersion,c as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Pe as normalizeHost,Ce as parseAuthChallenge,n as parseVersionString,q as parseWithPositions,s as pickHighestDocument,u as setKanonakUserAgent,o as versionsEqual};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as F}from"./chunk-UXYCUGSF.js";import{H as me,I as he}from"./chunk-Q6XQ5IXW.js";import{a as te,b as
|
|
2
|
-
`)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function v(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let o=e.indexOf("."),a=e.substring(0,o),c=e.substring(o+1);if(r){let s=r.get(a);if(s)return`${s.publisher}/${s.package_}/${c}@${s.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}function A(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var Ge="key_thumbprint",I=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=A(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,o=await Ve(r),a=o&&Array.isArray(o.authorization_servers)?o.authorization_servers.filter(s=>typeof s=="string"):[],c=a.length>0?a:null;return this.prCache.set(t,c),c}async discover(n){let t=A(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,o=await this.tryEndpoint(r);if(!o){let a=`https://${t}/.well-known/openid-configuration`;o=await this.tryEndpoint(a)}return this.cache.set(t,o),o}async supportsOAuth(n){return await this.discover(n)!==null}static supportsPkceS256(n){return n.codeChallengeMethodsSupported?.some(t=>t.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(n){return!!n.registrationEndpoint}static supportsAuthorizationCode(n){return n.responseTypesSupported?.some(t=>t.toLowerCase()==="code")??!1}static supportsEnrollment(n){return!!n.enrollmentEndpoint}static supportsSession(n){return!!n.sessionEndpoint}async tryEndpoint(n){let t;try{t=await fetch(n)}catch(o){let a=o instanceof Error?o.message:String(o);return a.includes("ENOTFOUND")||a.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${a})`),console.error(" If the server is behind a VPN, ensure you are connected.")):a.includes("CERT")||a.includes("SSL")||a.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${a})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${n} \u2014 network error: ${a}`),null}if(!t.ok)return t.status===404||(t.status===403?(console.error(` OAuth discovery: ${n} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):t.status>=500&&(console.error(` OAuth discovery: ${n} \u2014 HTTP ${t.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let r;try{r=await t.json()}catch{return console.error(` OAuth discovery: ${n} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:w(r.issuer),authorizationEndpoint:w(r.authorization_endpoint),tokenEndpoint:w(r.token_endpoint),registrationEndpoint:w(r.registration_endpoint),revocationEndpoint:w(r.revocation_endpoint),scopesSupported:P(r.scopes_supported),responseTypesSupported:P(r.response_types_supported),grantTypesSupported:P(r.grant_types_supported),codeChallengeMethodsSupported:P(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:P(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:P(r.dpop_signing_alg_values_supported),enrollmentEndpoint:w(r.enrollment_endpoint),enrollmentIssuanceProtocols:P(r.enrollment_issuance_protocols),enrollmentKeyTypes:P(r.enrollment_key_types),enrollmentScopesSupported:P(r.enrollment_scopes_supported),enrollmentConsentBindingParam:w(r.enrollment_consent_binding_param),sessionEndpoint:w(r.session_endpoint),sessionEndpointAuthMethod:w(r.session_endpoint_auth_method)}}};async function Ve(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function w(e){return typeof e=="string"?e:null}function P(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function we(e){let n=e.headers.get("WWW-Authenticate")??void 0,t=e.headers.get("DPoP-Nonce")??void 0;if(!n&&!t)return;let r={wwwAuthenticate:n??""};if(t&&(r.nonce=t),n){let o=n.match(/acr_values\s*=\s*"([^"]*)"/i);o&&(r.acrValues=o[1])}return r}function Be(e){try{return new URL(e).host}catch{return null}}function ze(e,n={}){let t=n.discovery??new I,r=new Map,o=new Map,a=async i=>{let d=r.get(i);if(d!==void 0)return d;let f=null,p=await t.discoverProtectedResource(i).catch(()=>null);return p&&p.length>0&&(f=Be(p[0])),r.set(i,f),f},c=async(i,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&o.has(i))return o.get(i);let p=await e.resolve(i,d).catch(()=>null);return o.set(i,p),p},s=async(i,d,f,p)=>{let g=await a(d);if(!g)return{res:await F(i,{method:f,redirect:"manual"}),authed:!1};let u=await c(g,{method:f,url:i,...p}),l=u?.headers??{};return{res:await F(i,{method:f,redirect:"manual",headers:l}),authed:!!u}};return async(i,d,f="GET")=>{let p=await s(i,d,f,{});if((p.res.status===401||p.res.status===403)&&p.authed){let g=we(p.res),u={forceRefresh:g===void 0};return g&&(u.challenge=g),(await s(i,d,f,u)).res}return p.res}}var Pe="KANONAK_TOKEN";function He(){return typeof process<"u"&&process.env?process.env:{}}function qe(e){return`${Pe}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var X=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??He()}async resolve(n,t){let r=A(n),o=this.tokens[r]??this.env[qe(r)]??this.env[Pe];return o?{headers:{Authorization:`Bearer ${o}`}}:null}};import{canonicalForm as We,canonicalHash as Xe}from"@kanonak-protocol/canonical";function Y(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as an}from"@kanonak-protocol/canonical";function Ye(e){return We(Y(e)?e:Te(e))}function Je(e){return Xe(Y(e)?e:Te(e))}function Te(e){let n=[];for(let t of e)t instanceof T&&n.push({uri:on(t),statements:J(t.statement)});return{subjects:n}}function J(e){let n=[];for(let t of e){let r=rn(t);if(!r)continue;if(t instanceof L&&Qe(t.predicate.subject)){n.push(...en(t,r));continue}let o=nn(t);o&&n.push({predicate:r,value:o})}return n}function Qe(e){let n=ue("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var je=new TextEncoder;function Ze(e,n){let t=je.encode(e),r=je.encode(n),o=Math.min(t.length,r.length);for(let a=0;a<o;a++)if(t[a]!==r[a])return t[a]-r[a];return t.length-r.length}function en(e,n){let t=[];for(let r of e.object){if(!(r instanceof _))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(Q(r))}t.sort(Ze);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:n,value:{ref:r}}))}function nn(e){if(e instanceof oe&&e.carrier)return{lit:e.lexical??String(e.object),datatype:Re(e.carrier)};if(e instanceof ae)return{raw:e.object};if(e instanceof se)return{raw:e.lexical??String(e.object)};if(e instanceof ie)return{raw:e.lexical??String(e.object)};if(e instanceof ce)return{ref:Q(e.object)};if(e instanceof pe)return Ee(e.object);if(e instanceof L)return{list:e.object.map(tn)}}function Ee(e){let n=J(e.statement);return e.name&&e.name.length>0?{embed:{name:e.name,statements:n}}:{embed:{statements:n}}}function tn(e){if(e instanceof _)return{ref:Q(e)};if(e instanceof te)return Ee(e);if(e instanceof N){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:Re(e.carrier)};let n=e.value;if(typeof n=="string")return{raw:n};if(typeof n=="number")return{raw:String(n)};if(typeof n=="boolean")return{raw:String(n)}}if(e instanceof ne)return{embed:{statements:J(e.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${e.constructor?.name??typeof e}); add canonicalization support before hashing data that contains it`)}function Re(e){return e===z.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function rn(e){let n=e.predicate;if(n)return _e(n.subject)}function on(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function Q(e){return _e(e.subject)}function _e(e){let n=e.version;return n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}/${e.name}`:`${e.publisher}/${e.package_}/${e.name}`}var E="kanonak.org",U="core-rdf",Ie="core-xsd",Ae={publisher:E,package_:U,name:"subClassOf"},Ne={publisher:E,package_:U,name:"label"},sn={publisher:E,package_:U,name:"comment"},$e={publisher:E,package_:"core-owl",name:"oneOf"},Ke=e=>e;function cn(e){let n=fe(e,Ae);if(n)return[n];let t=[];for(let r of V(e,Ae))r instanceof _&&t.push(r.subject);return t}function pn(e,n,t){if(n.publisher===E&&n.package_===U&&n.name==="Literal")return{kind:"datatype",uri:n};let o=G(e,n);if(o){let a=Ke(o);if(O.isDatatypeType(a))return{kind:"datatype",uri:n};if(O.isClassType(a))return{kind:"class",uri:x(o)??n,localName:o.name}}return n.publisher===E&&n.package_===Ie?{kind:"datatype",uri:n}:t==="datatype"?{kind:"datatype",uri:n}:{kind:"class",uri:n,localName:n.name}}function ln(e,n,t){if(!n.range)throw new Error(`Property ${n.uri.publisher}/${n.uri.package_}/${n.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let r=pn(e,n.range,n.kind),o=n.kind==="object"?"object":n.kind==="datatype"?"datatype":r.kind==="class"?"object":"datatype";return{uri:n.uri,localName:n.uri.name,kind:o,range:r,...n.label!==void 0?{label:n.label}:{},...n.comment!==void 0?{comment:n.comment}:{},...t??{}}}var M=e=>new re(E,Ie,e);function un(e){return typeof e=="boolean"?M("boolean"):typeof e=="number"?Number.isInteger(e)?M("integer"):M("decimal"):M("string")}function dn(e,n){let t=[];for(let r of V(n,$e))if(r instanceof _){let o=G(e,r.subject),a=(o?x(o):void 0)??r.subject,c=o?K(o,Ne):void 0;t.push({kind:"individual",uri:a,localName:a.name,...c!==void 0?{label:c}:{}})}else r instanceof N&&t.push({kind:"literal",value:r.value,datatype:un(r.value)});return t}function fn(e,n,t,r){let o=ge(e,n),a=$(n);return ye(e,n).filter(s=>t?!0:s.domains.some(i=>$(i)===a)).map(s=>ln(e,s,he(r,o,s.uri)))}async function gn(e,n,t){let r=e.metadata?.namespace_;if(!r)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let o=t?.includeInherited??!1,a=await new D().parseKanonaks(n),c=me(a),s=[],i=[],d=new Set;for(let f of a){if(!(f instanceof T)||!O.isClassType(Ke(f)))continue;let p=x(f);if(!p||p.publisher!==r.publisher||p.package_!==r.package_||p.version&&r.version&&!ee(p.version,r.version))continue;let g=$(p);if(d.has(g))continue;d.add(g);let u=cn(f).map(b=>({uri:b,localName:b.name})),l=K(f,Ne),m=K(f,sn);s.push({uri:p,localName:p.name,superClasses:u,properties:fn(a,p,o,c),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}}),de(f,$e)&&i.push({uri:p,localName:p.name,members:dn(a,f),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}})}return{classes:s,enums:i}}export{Ce as a,Se as b,H as c,A as d,Ge as e,I as f,we as g,ze as h,X as i,Ye as j,Je as k,an as l,gn as m};
|
|
1
|
+
import{e as F}from"./chunk-UXYCUGSF.js";import{H as me,I as he}from"./chunk-Q6XQ5IXW.js";import{a as te,b as $,c as le,i as z,m as D}from"./chunk-V6KIDED2.js";import{k as ue,o as O,p as x,q as ge,r as B,v as ye}from"./chunk-SVUMCLK5.js";import{b as ne,c as T,d as _,f as oe,g as se,h as ae,i as ie,j as ce,k as pe,l as L,m as K,r as G,t as de,v as I,w as fe,y as V}from"./chunk-YW6P24RF.js";import{a as re}from"./chunk-FUUTGGJS.js";import{d as ee}from"./chunk-2ACBWC7K.js";var Ce=(a=>(a.Class="Class",a.DatatypeProperty="DatatypeProperty",a.ObjectProperty="ObjectProperty",a.AnnotationProperty="AnnotationProperty",a.Instance="Instance",a.Datatype="Datatype",a.Unknown="Unknown",a))(Ce||{}),Se=(i=>(i.InstanceOf="instanceOf",i.SubClassOf="subClassOf",i.Domain="domain",i.Range="range",i.ObjectRelationship="objectRelationship",i.SubPropertyOf="subPropertyOf",i.PropertyValue="propertyValue",i.EmbeddedLink="embeddedLink",i))(Se||{}),H=class{static async buildFromRepository(n,t){let o=await new D().parseKanonaks(n),s=await n.getAllDocumentsAsync(),c=[],a=[],i=new Set,d=new Set,f=new Map;for(let g of o){let u=g;if(u.name&&(O.isClassType(u)&&i.add(u.name),g instanceof T)){let l=B(o,g);(l==="ObjectProperty"||l==="Property")&&d.add(u.name)}}for(let g of s)for(let[u,l]of Object.entries(g.body))d.has(u)&&l?.range&&typeof l.range=="string"&&f.set(u,l.range);let p=new Map;for(let g of o){let u=g;u.name&&p.set(u.name,u)}for(let g of s){let u=g.metadata.namespace_,l=u?`${u.publisher}/${u.package_}`:"",m=u?.version?`${u.version.major}.${u.version.minor}.${u.version.patch}`:"",b=ke(g);for(let[h,y]of Object.entries(g.body)){if(!y||typeof y!="object")continue;let C=p.get(h),k="Unknown";if(C){let R=C,j=C instanceof T?B(o,C):void 0;O.isClassType(R)?k="Class":j==="ObjectProperty"?k="ObjectProperty":j==="DatatypeProperty"?k="DatatypeProperty":j==="AnnotationProperty"?k="AnnotationProperty":O.isDatatypeType(R)?k="Datatype":j==="Property"?k="ObjectProperty":O.isInstanceOfKnownClass(R,i)&&(k="Instance")}let S=l&&m?`${l}/${h}@${m}`:h,Z={};for(let[R,j]of Object.entries(y))R!=="type"&&(typeof j!="object"||j===null)&&(Z[R]=j);c.push({id:S,label:y.label??h,type:k,namespace:l,properties:Z}),be(S,y,k,i,d,a,l,m,b,t),q(S,y,d,f,c,a,l,m,b),Le(S,C,a)}}return{nodes:c,edges:a}}static buildFromDocument(n,t){let r=[],o=[],s=n.metadata.namespace_,c=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",i=new Set,d=new Set,f=new Map,p=ke(n);for(let[l,m]of Object.entries(n.body)){let b=m?.type;b&&(Me(b,p)&&i.add(l),Ue(b,p)&&(d.add(l),m.range&&typeof m.range=="string"&&f.set(l,m.range)))}for(let[l,m]of Object.entries(n.body)){if(!m||typeof m!="object")continue;let b=m.type,h=Fe(b,l,i,p),y=a&&c?`${a}/${l}@${c}`:l,C={};for(let[k,S]of Object.entries(m))k!=="type"&&(typeof S!="object"||S===null)&&(C[k]=S);r.push({id:y,label:m.label??l,type:h,namespace:a,properties:C}),be(y,m,h,i,d,o,a,c,p,t),q(y,m,d,f,r,o,a,c,p)}let g=new Set(r.map(l=>l.id)),u=o.filter(l=>g.has(l.source)&&g.has(l.target));return{nodes:r,edges:u}}};function ke(e,n){let t=new Map;if(e.metadata?.imports)for(let[r,o]of Object.entries(e.metadata.imports))for(let s of o){let c=s.alias??s.packageName,a=s.version,i=`${a.major}.${a.minor}.${a.patch}`;t.set(c,{publisher:r,package_:s.packageName,version:i})}return t}var Oe={"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"},De=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function W(e,n){if(e.includes(".")){let t=e.indexOf("."),r=e.substring(0,t),o=e.substring(t+1),s=n.get(r);if(s)return`${s.publisher}/${s.package_}/${o}`}return null}function Me(e,n){let t=W(e,n);return t?Oe[t]==="Class":!1}function Ue(e,n){let t=W(e,n);return t?De.has(t):!1}function Fe(e,n,t,r){if(!e||e==="Package")return"Unknown";let o=W(e,r);if(o){let c=Oe[o];if(c)return c;let a=o.split("/").pop()?.split("@")[0]??"";return t.has(a)?"Instance":"Unknown"}let s=e.split(".").pop()??e;return t.has(s)?"Instance":"Unknown"}var ve=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function be(e,n,t,r,o,s,c,a,i,d){let f=n.type,p=n.subClassOf;if(p){let h=Array.isArray(p)?p:[p];for(let y of h)typeof y=="string"&&s.push({source:e,target:v(y,c,a,i),type:"subClassOf",label:"subClassOf"})}let g=n.subPropertyOf;if(g){let h=Array.isArray(g)?g:[g];for(let y of h)typeof y=="string"&&s.push({source:e,target:v(y,c,a,i),type:"subPropertyOf",label:"subPropertyOf"})}let u=n.domain,l=n.range;if(d?.includePropertyEdges){let h=[[u,"domain","domain"],[l,"range","range"]];for(let[y,C,k]of h)if(y!=null)for(let S of Array.isArray(y)?y:[y])typeof S=="string"&&s.push({source:e,target:v(S,c,a,i),type:C,label:k})}if(t==="Instance"&&f){let h=f.split(".").pop()??f;s.push({source:e,target:v(h,c,a,i),type:"instanceOf",label:"type"})}if(t==="Instance")for(let[h,y]of Object.entries(n)){if(ve.has(h)||!o.has(h))continue;let C=Array.isArray(y)?y:[y];for(let k of C)typeof k=="string"&&Ge(k)&&s.push({source:e,target:v(k,c,a,i),type:"propertyValue",label:h,propertyId:v(h,c,a,i)})}if((t==="ObjectProperty"||t==="DatatypeProperty"||u&&l)&&u&&l){let h=typeof u=="string"?u:null,y=typeof l=="string"?l:null;h&&y&&s.push({source:v(h,c,a,i),target:v(y,c,a,i),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function q(e,n,t,r,o,s,c,a,i){for(let[d,f]of Object.entries(n)){if(ve.has(d)||typeof f!="object"||f===null||Array.isArray(f))continue;let p=f,g=`${e}/${d}`,u=r.get(d),l=u?u.split(".").pop()??u:"Unknown",m={};for(let[h,y]of Object.entries(p))(typeof y!="object"||y===null)&&(m[h]=y);o.push({id:g,label:`${l} (embedded)`,type:"Instance",namespace:c,properties:m});let b=c&&a?`${c}/${d}@${a}`:d;s.push({source:e,target:g,type:"propertyValue",label:d,propertyId:t.has(d)?b:void 0}),u&&s.push({source:g,target:v(l,c,a,i),type:"instanceOf",label:"type (inferred)"}),q(g,p,t,r,o,s,c,a,i)}}function Le(e,n,t){let r=n?.statement;if(Array.isArray(r))for(let o of r){if(!(o instanceof le))continue;let s=o.predicate?.subject?.name??"";for(let c of o.links){let a=c.target?.subject;if(!a)continue;let i=a.version,d=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"";t.push({source:e,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Ge(e){return!(!e||e.includes(" ")||e.includes(`
|
|
2
|
+
`)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function v(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let o=e.indexOf("."),s=e.substring(0,o),c=e.substring(o+1);if(r){let a=r.get(s);if(a)return`${a.publisher}/${a.package_}/${c}@${a.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}function A(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var Ve="key_thumbprint",N=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=A(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,o=await Be(r),s=o&&Array.isArray(o.authorization_servers)?o.authorization_servers.filter(a=>typeof a=="string"):[],c=s.length>0?s:null;return this.prCache.set(t,c),c}async discover(n){let t=A(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,o=await this.tryEndpoint(r);if(!o){let s=`https://${t}/.well-known/openid-configuration`;o=await this.tryEndpoint(s)}return this.cache.set(t,o),o}async supportsOAuth(n){return await this.discover(n)!==null}static supportsPkceS256(n){return n.codeChallengeMethodsSupported?.some(t=>t.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(n){return!!n.registrationEndpoint}static supportsAuthorizationCode(n){return n.responseTypesSupported?.some(t=>t.toLowerCase()==="code")??!1}static supportsEnrollment(n){return!!n.enrollmentEndpoint}static supportsSession(n){return!!n.sessionEndpoint}async tryEndpoint(n){let t;try{t=await fetch(n)}catch(o){let s=o instanceof Error?o.message:String(o);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${s})`),console.error(" If the server is behind a VPN, ensure you are connected.")):s.includes("CERT")||s.includes("SSL")||s.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${s})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${n} \u2014 network error: ${s}`),null}if(!t.ok)return t.status===404||(t.status===403?(console.error(` OAuth discovery: ${n} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):t.status>=500&&(console.error(` OAuth discovery: ${n} \u2014 HTTP ${t.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let r;try{r=await t.json()}catch{return console.error(` OAuth discovery: ${n} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:w(r.issuer),authorizationEndpoint:w(r.authorization_endpoint),tokenEndpoint:w(r.token_endpoint),registrationEndpoint:w(r.registration_endpoint),revocationEndpoint:w(r.revocation_endpoint),scopesSupported:P(r.scopes_supported),responseTypesSupported:P(r.response_types_supported),grantTypesSupported:P(r.grant_types_supported),codeChallengeMethodsSupported:P(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:P(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:P(r.dpop_signing_alg_values_supported),enrollmentEndpoint:w(r.enrollment_endpoint),enrollmentIssuanceProtocols:P(r.enrollment_issuance_protocols),enrollmentKeyTypes:P(r.enrollment_key_types),enrollmentScopesSupported:P(r.enrollment_scopes_supported),enrollmentConsentBindingParam:w(r.enrollment_consent_binding_param),sessionEndpoint:w(r.session_endpoint),sessionEndpointAuthMethod:w(r.session_endpoint_auth_method)}}};async function Be(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function w(e){return typeof e=="string"?e:null}function P(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function we(e){let n=e.headers.get("WWW-Authenticate")??void 0,t=e.headers.get("DPoP-Nonce")??void 0;if(!n&&!t)return;let r={wwwAuthenticate:n??""};if(t&&(r.nonce=t),n){let o=n.match(/acr_values\s*=\s*"([^"]*)"/i);o&&(r.acrValues=o[1])}return r}function ze(e){try{return new URL(e).host}catch{return null}}function He(e,n={}){let t=n.discovery??new N,r=new Map,o=new Map,s=async i=>{let d=r.get(i);if(d!==void 0)return d;let f=null,p=await t.discoverProtectedResource(i).catch(()=>null);return p&&p.length>0&&(f=ze(p[0])),r.set(i,f),f},c=async(i,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&o.has(i))return o.get(i);let p=await e.resolve(i,d).catch(()=>null);return o.set(i,p),p},a=async(i,d,f,p)=>{let g=await s(d);if(!g)return{res:await F(i,{method:f,redirect:"manual"}),authed:!1};let u=await c(g,{method:f,url:i,...p}),l=u?.headers??{};return{res:await F(i,{method:f,redirect:"manual",headers:l}),authed:!!u}};return async(i,d,f="GET")=>{let p=await a(i,d,f,{});if((p.res.status===401||p.res.status===403)&&p.authed){let g=we(p.res),u={forceRefresh:g===void 0};return g&&(u.challenge=g),(await a(i,d,f,u)).res}return p.res}}var Pe="KANONAK_TOKEN";function qe(){return typeof process<"u"&&process.env?process.env:{}}function We(e){return`${Pe}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var X=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??qe()}async resolve(n,t){let r=A(n),o=this.tokens[r]??this.env[We(r)]??this.env[Pe];return o?{headers:{Authorization:`Bearer ${o}`}}:null}};import{canonicalForm as Xe,canonicalHash as Ye}from"@kanonak-protocol/canonical";function Y(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as an}from"@kanonak-protocol/canonical";function Je(e){return Xe(Y(e)?e:Te(e))}function Qe(e){return Ye(Y(e)?e:Te(e))}function Te(e){let n=[];for(let t of e)t instanceof T&&n.push({uri:sn(t),statements:J(t.statement)});return{subjects:n}}function J(e){let n=[];for(let t of e){let r=on(t);if(!r)continue;if(t instanceof L&&Ze(t.predicate.subject)){n.push(...nn(t,r));continue}let o=tn(t);o&&n.push({predicate:r,value:o})}return n}function Ze(e){let n=ue("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var je=new TextEncoder;function en(e,n){let t=je.encode(e),r=je.encode(n),o=Math.min(t.length,r.length);for(let s=0;s<o;s++)if(t[s]!==r[s])return t[s]-r[s];return t.length-r.length}function nn(e,n){let t=[];for(let r of e.object){if(!(r instanceof _))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(Q(r))}t.sort(en);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:n,value:{ref:r}}))}function tn(e){if(e instanceof oe&&e.carrier)return{lit:e.lexical??String(e.object),datatype:Re(e.carrier)};if(e instanceof se)return{raw:e.object};if(e instanceof ae)return{raw:e.lexical??String(e.object)};if(e instanceof ie)return{raw:e.lexical??String(e.object)};if(e instanceof ce)return{ref:Q(e.object)};if(e instanceof pe)return Ee(e.object);if(e instanceof L)return{list:e.object.map(rn)}}function Ee(e){let n=J(e.statement);return e.name&&e.name.length>0?{embed:{name:e.name,statements:n}}:{embed:{statements:n}}}function rn(e){if(e instanceof _)return{ref:Q(e)};if(e instanceof te)return Ee(e);if(e instanceof $){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:Re(e.carrier)};let n=e.value;if(typeof n=="string")return{raw:n};if(typeof n=="number")return{raw:String(n)};if(typeof n=="boolean")return{raw:String(n)}}if(e instanceof ne)return{embed:{statements:J(e.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${e.constructor?.name??typeof e}); add canonicalization support before hashing data that contains it`)}function Re(e){return e===z.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function on(e){let n=e.predicate;if(n)return _e(n.subject)}function sn(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function Q(e){return _e(e.subject)}function _e(e){let n=e.version;return n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}/${e.name}`:`${e.publisher}/${e.package_}/${e.name}`}var E="kanonak.org",U="core-rdf",Ie="core-xsd",Ae={publisher:E,package_:U,name:"subClassOf"},Ne={publisher:E,package_:U,name:"label"},$e={publisher:E,package_:U,name:"comment"},Ke={publisher:E,package_:"core-owl",name:"oneOf"},xe=e=>e;function cn(e){let n=fe(e,Ae);if(n)return[n];let t=[];for(let r of V(e,Ae))r instanceof _&&t.push(r.subject);return t}function pn(e,n,t){if(n.publisher===E&&n.package_===U&&n.name==="Literal")return{kind:"datatype",uri:n};let o=G(e,n);if(o){let s=xe(o);if(O.isDatatypeType(s))return{kind:"datatype",uri:n};if(O.isClassType(s))return{kind:"class",uri:x(o)??n,localName:o.name}}return n.publisher===E&&n.package_===Ie?{kind:"datatype",uri:n}:t==="datatype"?{kind:"datatype",uri:n}:{kind:"class",uri:n,localName:n.name}}function ln(e,n,t){if(!n.range)throw new Error(`Property ${n.uri.publisher}/${n.uri.package_}/${n.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let r=pn(e,n.range,n.kind),o=n.kind==="object"?"object":n.kind==="datatype"?"datatype":r.kind==="class"?"object":"datatype";return{uri:n.uri,localName:n.uri.name,kind:o,range:r,...n.label!==void 0?{label:n.label}:{},...n.comment!==void 0?{comment:n.comment}:{},...t??{}}}var M=e=>new re(E,Ie,e);function un(e){return typeof e=="boolean"?M("boolean"):typeof e=="number"?Number.isInteger(e)?M("integer"):M("decimal"):M("string")}function dn(e,n){let t=[];for(let r of V(n,Ke))if(r instanceof _){let o=G(e,r.subject),s=(o?x(o):void 0)??r.subject,c=o?I(o,Ne):void 0,a=o?I(o,$e):void 0;t.push({kind:"individual",uri:s,localName:s.name,...c!==void 0?{label:c}:{},...a!==void 0?{comment:a}:{}})}else r instanceof $&&t.push({kind:"literal",value:r.value,datatype:un(r.value)});return t}function fn(e,n,t,r){let o=ge(e,n),s=K(n);return ye(e,n).filter(a=>t?!0:a.domains.some(i=>K(i)===s)).map(a=>ln(e,a,he(r,o,a.uri)))}async function gn(e,n,t){let r=e.metadata?.namespace_;if(!r)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let o=t?.includeInherited??!1,s=await new D().parseKanonaks(n),c=me(s),a=[],i=[],d=new Set;for(let f of s){if(!(f instanceof T)||!O.isClassType(xe(f)))continue;let p=x(f);if(!p||p.publisher!==r.publisher||p.package_!==r.package_||p.version&&r.version&&!ee(p.version,r.version))continue;let g=K(p);if(d.has(g))continue;d.add(g);let u=cn(f).map(b=>({uri:b,localName:b.name})),l=I(f,Ne),m=I(f,$e);a.push({uri:p,localName:p.name,superClasses:u,properties:fn(s,p,o,c),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}}),de(f,Ke)&&i.push({uri:p,localName:p.name,members:dn(s,f),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}})}return{classes:a,enums:i}}export{Ce as a,Se as b,H as c,A as d,Ve as e,N as f,we as g,He as h,X as i,Je as j,Qe as k,an as l,gn as m};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Kr,b as Ir,c as vr,d as Vr,e as L}from"./chunk-V3IPBWWU.js";import{a as Y,b as ee,c as re}from"./chunk-L2KE7B3K.js";import{a as bn,c as B,e as ne,h as te,i as oe,j as Rn}from"./chunk-4PY3JJH3.js";import{a as wr,b as Er,c as xr,d as mn,e as yn,f as fn,g as kn,h as gn,i as hn,j as wn,k as F,l as En,m as xn}from"./chunk-MK6UVFOJ.js";import{a as Pn}from"./chunk-LYSCTQC2.js";import"./chunk-QHABFCRC.js";import{a as Ve,b as je,c as Ae,d as Ce,e as Se,f as Te,g as ze,h as He,i as We}from"./chunk-CC44JAOT.js";import{a as De,b as Ue,c as Oe,d as _e,e as Me,f as $e,h as Ne,j as Le,k as Fe}from"./chunk-UXYCUGSF.js";import{a as ve}from"./chunk-4NO7MHS7.js";import{a as Ar,b as Cr,c as Sr,d as Dr}from"./chunk-5NH5XDGO.js";import{a as Ur,b as _r}from"./chunk-PEUTCG3B.js";import{a as Or}from"./chunk-PEJALHXK.js";import{a as Be}from"./chunk-SC5M74NM.js";import{A as un,B as ln,K as dn,a as Mr,b as $r,c as Nr,d as Lr,e as Br,f as Fr,g as Tr,h as zr,i as Hr,j as Wr,k as qr,l as Gr,m as Jr,n as Zr,o as Qr,p as Xr,q as Yr,r as en,s as rn,t as nn,u as tn,v as on,w as an,x as sn,y as cn,z as pn}from"./chunk-Q6XQ5IXW.js";import"./chunk-ITKOKDBG.js";import{a as k,b as Ze,c as ar,i as hr,j as Pr,k as br,l as Rr,m as E}from"./chunk-V6KIDED2.js";import{a as P}from"./chunk-NJ3AZYQD.js";import{a as ir,b as sr,c as M,d as cr,e as R,f as pr,g as ur,i as lr,m as dr,o as mr,p as m,q as yr,v as fr,w as kr,x as gr}from"./chunk-SVUMCLK5.js";import{a as qe,b as Ge,c as f,d as b,e as Qe,f as Xe,g as Ye,h as er,i as rr,j as nr,k as tr,l as or,r as j,w,x as $,y as N,z as X}from"./chunk-YW6P24RF.js";import{a as Je}from"./chunk-FUUTGGJS.js";import{a as be,b as _,c as V,d as Re,e as y,f as we,g as Ee,h as xe,i as Ke,j as Ie}from"./chunk-2ACBWC7K.js";import{a as jr}from"./chunk-ODIECDN7.js";import{VersionOperator as _t}from"@kanonak-protocol/types/document/models/enums";import*as T from"js-yaml";import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";var Kn="0.0.0",g=class{constructor(e,r=new P,n){this.repository=e;this.parser=r;this.objectParser=n??new E(this.parser)}repository;parser;objectParser;imports(){return new x}serializeValue(e,r){return ce(e,r)}async buildContentAddressed(e){let r=e.book.toImports(),n=await this.hashBody(e.publisher,r,e.body),t=z(n),a={type:"EphemeralPackage",publisher:e.publisher,imports:r};e.contentHashProperty&&(a[e.contentHashProperty]=n),Object.assign(a,e.header??{}),a.imports=r;let i={[t]:a,...e.body},s=this.dump(i);return{yaml:s,byteCount:se(s),contentHash:n,packageName:t,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let r=e.book.toImports(),n={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:r},t;e.contentHashProperty&&(t=await this.hashBody(e.publisher,r,e.body),n[e.contentHashProperty]=t),Object.assign(n,e.header??{}),n.imports=r;let a={[e.name]:n,...e.body},i=this.dump(a),s={yaml:i,byteCount:se(i),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return t!==void 0&&(s.contentHash=t),s}dump(e){return T.dump(e,{lineWidth:-1})}async hashBody(e,r,n){let t={[ie]:{type:"EphemeralPackage",publisher:e,imports:r},...n},a=this.parser.parse(T.dump(t,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new X(a,this.repository))).filter(u=>u instanceof f&&u.namespace===i&&u.name!==ie);for(let u of c)u.namespace="ephemeral";return F(c)}},ie="__pkgbuilder_probe__";function se(o){return new TextEncoder().encode(o).length}function z(o){let e="sha256:",r=o.startsWith(e)?e.length:0;return`q-${o.slice(r,r+16)}`}var x=class{byKey=new Map;aliases=new Set;ensure(e,r,n,t,a=ae.Major){let i=`${e}/${r}@${n}`,s=this.byKey.get(i);if(s)return s.alias;let c=this.uniqueAlias(t);return this.byKey.set(i,{publisher:e,package_:r,version:n,alias:c,match:a}),c}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_,y(e.version),e.package_)}.${e.name}`}refLatest(e,r,n,t){return`${this.ensure(e,r,Kn,t??r,ae.Any)}.${n}`}toImports(){let e=new Map;for(let n of this.byKey.values()){let t=e.get(n.publisher)??[];t.push(n),e.set(n.publisher,t)}return[...e.keys()].sort().map(n=>({publisher:n,packages:e.get(n).sort((t,a)=>t.package_<a.package_?-1:1).map(t=>({package:t.package_,match:_(t.match),version:t.version,alias:t.alias}))}))}uniqueAlias(e){let r=K(e)||"pkg",n=r,t=2;for(;this.aliases.has(n);)n=`${r}${t++}`;return this.aliases.add(n),n}};function ce(o,e){if(o!=null){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o;if(o instanceof b)return e.ref(o.subject);if(Array.isArray(o)){let r=o.map(n=>ce(n,e)).filter(n=>n!==void 0);return r.length>0?r:void 0}if(o instanceof k)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(In(o))throw new Error(`Value produced a bare URI without a version (${o.publisher}/${o.package_}/${o.name}); cannot serialize it as a reference.`)}}function K(o){return o.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function In(o){return typeof o=="object"&&o!==null&&typeof o.publisher=="string"&&typeof o.package_=="string"&&typeof o.name=="string"}var A=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,r){return this.producers.find(n=>n.canProduce(e,r))}async produceCached(e,r,n,t){let a=`${r}/${n}@${y(t)}`,i=this.produced.get(a);if(i)return i;let{document:s}=await e.produce(r,n,t);return this.produced.set(a,s),s}async getHighestCompatibleVersionAsync(e,r){let n=this.producerFor(e,r.packageName);if(!n)return null;let t={operator:r.versionOperator,version:r.version},a=await n.resolveVersion(e,r.packageName,t);return a?this.produceCached(n,e,r.packageName,a):null}async getDocumentAsync(e){let r;try{r=M(e)}catch{return null}if(r.kind!=="package"||!r.version)return null;let n=this.producerFor(r.publisher,r.package_);return n?this.produceCached(n,r.publisher,r.package_,r.version):null}async getDocumentsByNamespaceAsync(e,r){return Array.from(this.produced.values()).filter(n=>{let t=n.metadata.namespace_;return t!=null&&t.publisher===e&&t.package_===r})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,r){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,r){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var H={async authorize(){return{allowed:!0}}},W={async record(){}},I=class extends Error{constructor(r,n){let t=`${r.publisher}/${r.package_}${r.version?`@${r.version.major}.${r.version.minor}.${r.version.patch}`:""}`;super(`Not entitled to produce ${t}${n?`: ${n}`:""}`);this.address=r;this.reason=n;this.name="EntitlementDeniedError"}address;reason},C=class{inner;ctx;policy;meter;constructor(e,r,n=H,t=W){this.inner=e,this.ctx=r,this.policy=n,this.meter=t}canProduce(e,r){return this.inner.canProduce(e,r)}async resolveVersion(e,r,n){return await this.assertAllowed({publisher:e,package_:r,version:n.version}),this.inner.resolveVersion(e,r,n)}async produce(e,r,n){let t={publisher:e,package_:r,version:n};await this.assertAllowed(t);let a=await this.inner.produce(e,r,n);return await this.meter.record(this.ctx,t,a),a}async assertAllowed(e){let r=await this.policy.authorize(this.ctx,e);if(!r.allowed)throw new I(e,r.reason)}};var p="kanonak.org",d="view",pe="core-kanonak",vn={publisher:p,package_:d,name:"rootView"},Vn={publisher:p,package_:d,name:"bind"},jn={publisher:p,package_:d,name:"produces"},An={publisher:p,package_:d,name:"projections"},Cn={publisher:p,package_:d,name:"where"},Sn={publisher:p,package_:d,name:"value"},Dn={publisher:p,package_:d,name:"as"},S=class{constructor(e,r=new P){this.repository=e;this.parser=r;this.objectParser=new E(this.parser),this.builder=new g(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,r={}){let n=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(n,e),a=w(t,Vn);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let i=w(t,jn);if(!i)throw new Error(`View ${t.namespace}/${t.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=Un(t),c=ue(n,p,pe),u=ue(n,p,d),l=this.builder.imports(),D=l.ensure(p,pe,c,"ck"),de=l.ensure(p,d,u,"v"),me=l.ref(i),ye=new oe(this.repository,this.parser,this.objectParser),q=new ne(ye,n),fe=this.readProjections(n,t),ke=Mn(t,Cn),ge=this.findInstances(n,a,await this.reason(r)),G={},he=new Set;for(let v of ge){if(!await this.passesWhere(q,n,ke,v))continue;let O={type:me};for(let Z of fe){let Pe=await this.evaluateValue(q,n,Z.value,v),Q=this.builder.serializeValue(le(Pe),l);Q!==void 0&&(O[l.ref(Z.as)]=Q)}let J=m(v);J&&(O[`${de}.derivedFrom`]=l.ref(J)),G[this.rowName(v,he)]=O}let U={};r.resolvedAt&&(U[`${D}.resolvedAt`]=r.resolvedAt),r.invocationId&&(U[`${D}.id`]=r.invocationId);let h=await this.builder.buildContentAddressed({publisher:s,book:l,body:G,contentHashProperty:`${D}.contentHash`,header:U});return{yaml:h.yaml,contentHash:h.contentHash,packageName:h.packageName,publisher:h.publisher,rowCount:h.resourceCount}}resolveView(e,r){let n=j(e,r);if(!n)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=w(n,vn);if(t){let a=j(e,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return n}readProjections(e,r){let n=[];for(let t of N(r,An)){let a=t instanceof k?t:t instanceof b?j(e,t.subject):void 0;if(!a)continue;let i=$(a,Sn),s=w(a,Dn);i&&s&&n.push({value:i,as:s})}return n}async reason(e){return new L({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,r,n){let t=_n(e),a=[],i=new Set;for(let s of n.getInstancesOfClass(r)){if(i.has(s))continue;i.add(s);let c=t.get(s);c&&a.push(c)}return a.sort((s,c)=>{let u=R(m(s)),l=R(m(c));return u<l?-1:u>l?1:0}),a}async passesWhere(e,r,n,t){for(let a of n){let i=await this.evaluateValue(e,r,a,t);if(!$n(i))return!1}return!0}async evaluateValue(e,r,n,t){let a=te(n,"view-projection",{catalog:r,depth:0}),i=new Map([["input",t]]);return e.evaluate(a,i)}rowName(e,r){let n=K(e.name)||"row",t=n,a=2;for(;r.has(t);)t=`${n}-${a++}`;return r.add(t),t}};function le(o){return B(o)?o.value:Array.isArray(o)?o.map(le):o}function Un(o){let e=m(o);if(!e)throw new Error(`Could not derive a publisher from view ${o.namespace}/${o.name}.`);return e.publisher}function ue(o,e,r){let n=On(o,e,r);if(!n)throw new Error(`Package ${e}/${r} is not in the catalog; it must be importable to materialize a view.`);return n}function On(o,e,r){let n;for(let t of o){if(!(t instanceof f))continue;let a=m(t);!a||a.publisher!==e||a.package_!==r||!a.version||(!n||V(a.version,n)>0)&&(n=a.version)}return n?y(n):void 0}function _n(o){let e=new Map,r=new Map;for(let n of o){if(!(n instanceof f))continue;let t=m(n);if(!t||!t.version)continue;let a=R(t),i=r.get(a);(!i||V(t.version,i)>0)&&(r.set(a,t.version),e.set(a,n))}return e}function Mn(o,e){let r=$(o,e);return r?[r]:N(o,e).filter(n=>n instanceof k)}function $n(o){return o===!0?!0:o===!1||o===void 0||o===null?!1:typeof o=="string"?o.length>0:typeof o=="number"?o!==0:B(o)?o.value.length>0:Array.isArray(o)?o.length>0:!!o}export{tn as AmbiguousReferenceRule,rr as BooleanStatement,En as CANONICAL_FORM_VERSION,hr as Carrier,un as ClassDefinitionRule,Zr as ClassHierarchyCycleRule,Ae as CompositeKanonakDocumentRepository,yn as DEFAULT_CONSENT_BINDING_PARAM,Ge as DefinedKanonak,je as DocumentLocation,Er as EdgeType,k as EmbeddedKanonak,qr as EmbeddedKanonakTypeRule,tr as EmbeddedStatement,I as EntitlementDeniedError,C as EntitlementProducer,Ve as FileSystemKanonakDocumentRepository,jr as GitIgnoreFilter,xr as GraphBuilder,Fe as HttpKanonakDocumentRepository,x as ImportBook,Gr as ImportExistenceRule,ve as InMemoryKanonakDocumentRepository,De as KANONAK_USER_AGENT,qe as Kanonak,Cr as KanonakDocumentPositions,E as KanonakObjectParser,dn as KanonakObjectValidator,P as KanonakParser,Je as KanonakUri,Ur as KanonakUriBuilder,Or as KanonakUrlResolver,dr as KanonakVocabulary,or as ListStatement,Ze as LiteralKanonak,Te as LocalFirstRepository,ze as LockAwareRepository,Rn as LookRenderer,ln as MarkdownLinkRule,ar as MarkdownStatement,rn as NamespaceImportCycleRule,Fr as NamespacePrefixRule,wr as NodeType,er as NumberStatement,fn as OAuthDiscovery,vr as OWL_RL_CLASSIFICATION_RULES,an as ObjectPropertyValueValidationRule,Nr as OntologyValidationError,Mr as OntologyValidationResult,g as PackageBuilder,Wr as PackageHeaderRule,A as ProducerRepository,sn as PropertyDomainRule,Qr as PropertyHierarchyCycleRule,cn as PropertyKindRangeConsistencyRule,Ar as PropertyMetadata,on as PropertyRangeReferenceRule,Xr as PropertyRangeRequiredRule,zr as PropertyTypeSpecificityRule,Ne as PublisherConfigResolver,Le as PublisherIndex,Ir as RDFS_RULES,L as Reasoner,Vr as ReasoningResult,b as ReferenceKanonak,nr as ReferenceStatement,Se as RepositoryFactory,pn as ReservedNameShadowRule,Tr as ResourceNamingRule,ir as ResourceResolver,mr as ResourceTypeClassifier,Xe as ScalarStatement,Qe as Statement,Ye as StringStatement,Yr as SubClassOfReferenceRule,en as SubPropertyOfReferenceRule,f as SubjectKanonak,Hr as SubjectKanonakTypeRequiredRule,hn as TokenCredentialProvider,Kr as TripleStore,sr as TypeResolver,nn as UnresolvedPredicateRule,Jr as UnresolvedReferenceRule,Br as ValidationCache,Lr as ValidationContext,$r as ValidationSeverity,_t as VersionOperator,S as ViewMaterializer,H as allowAllPolicy,_e as assertHttpsUrl,Be as assertPackageIdentity,We as buildLocalFirstRepository,xn as buildOntologyModel,wn as canonicalForm,F as canonicalHash,Pr as carrierOf,He as collectKanonakFiles,V as compareVersions,re as computeIntegrity,z as contentAddressedName,gr as contextTypesOf,gn as createCredentialedFetch,we as createVersion,Rr as extractMarkdownLinks,Pn as findDerivation,_r as findInstancesByType,br as findMalformedReferences,Dr as findMarkdownLinkAt,cr as formatKanonakAddress,y as formatVersion,Ce as getGlobalCachePath,Oe as getKanonakUserAgent,xe as isCompatibleVersion,Ke as isMajorCompatible,Me as kanonakFetch,Y as loadLockFile,pr as makeUriKey,W as noopMeter,mn as normalizeHost,kn as parseAuthChallenge,M as parseKanonakAddress,Ee as parseVersionString,Sr as parseWithPositions,Ie as pickHighestDocument,fr as propertiesInScope,bn as resolveDisplayValue,kr as resolvePropertyStep,K as sanitizeName,ee as saveLockFile,$e as setKanonakFetchRetries,Ue as setKanonakUserAgent,m as subjectUri,yr as superClassChain,ur as tripleKey,R as uriKey,lr as uriTriple,be as versionOperatorFromChar,_ as versionOperatorToChar,Re as versionsEqual};
|
|
1
|
+
import{a as Kr,b as Ir,c as vr,d as Vr,e as L}from"./chunk-V3IPBWWU.js";import{a as Y,b as ee,c as re}from"./chunk-L2KE7B3K.js";import{a as bn,c as B,e as ne,h as te,i as oe,j as Rn}from"./chunk-4PY3JJH3.js";import{a as wr,b as Er,c as xr,d as mn,e as yn,f as fn,g as kn,h as gn,i as hn,j as wn,k as F,l as En,m as xn}from"./chunk-TXVVQPAO.js";import{a as Pn}from"./chunk-LYSCTQC2.js";import"./chunk-QHABFCRC.js";import{a as Ve,b as je,c as Ae,d as Ce,e as Se,f as Te,g as ze,h as He,i as We}from"./chunk-CC44JAOT.js";import{a as De,b as Ue,c as Oe,d as _e,e as Me,f as $e,h as Ne,j as Le,k as Fe}from"./chunk-UXYCUGSF.js";import{a as ve}from"./chunk-4NO7MHS7.js";import{a as Ar,b as Cr,c as Sr,d as Dr}from"./chunk-5NH5XDGO.js";import{a as Ur,b as _r}from"./chunk-PEUTCG3B.js";import{a as Or}from"./chunk-PEJALHXK.js";import{a as Be}from"./chunk-SC5M74NM.js";import{A as un,B as ln,K as dn,a as Mr,b as $r,c as Nr,d as Lr,e as Br,f as Fr,g as Tr,h as zr,i as Hr,j as Wr,k as qr,l as Gr,m as Jr,n as Zr,o as Qr,p as Xr,q as Yr,r as en,s as rn,t as nn,u as tn,v as on,w as an,x as sn,y as cn,z as pn}from"./chunk-Q6XQ5IXW.js";import"./chunk-ITKOKDBG.js";import{a as k,b as Ze,c as ar,i as hr,j as Pr,k as br,l as Rr,m as E}from"./chunk-V6KIDED2.js";import{a as P}from"./chunk-NJ3AZYQD.js";import{a as ir,b as sr,c as M,d as cr,e as R,f as pr,g as ur,i as lr,m as dr,o as mr,p as m,q as yr,v as fr,w as kr,x as gr}from"./chunk-SVUMCLK5.js";import{a as qe,b as Ge,c as f,d as b,e as Qe,f as Xe,g as Ye,h as er,i as rr,j as nr,k as tr,l as or,r as j,w,x as $,y as N,z as X}from"./chunk-YW6P24RF.js";import{a as Je}from"./chunk-FUUTGGJS.js";import{a as be,b as _,c as V,d as Re,e as y,f as we,g as Ee,h as xe,i as Ke,j as Ie}from"./chunk-2ACBWC7K.js";import{a as jr}from"./chunk-ODIECDN7.js";import{VersionOperator as _t}from"@kanonak-protocol/types/document/models/enums";import*as T from"js-yaml";import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";var Kn="0.0.0",g=class{constructor(e,r=new P,n){this.repository=e;this.parser=r;this.objectParser=n??new E(this.parser)}repository;parser;objectParser;imports(){return new x}serializeValue(e,r){return ce(e,r)}async buildContentAddressed(e){let r=e.book.toImports(),n=await this.hashBody(e.publisher,r,e.body),t=z(n),a={type:"EphemeralPackage",publisher:e.publisher,imports:r};e.contentHashProperty&&(a[e.contentHashProperty]=n),Object.assign(a,e.header??{}),a.imports=r;let i={[t]:a,...e.body},s=this.dump(i);return{yaml:s,byteCount:se(s),contentHash:n,packageName:t,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let r=e.book.toImports(),n={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:r},t;e.contentHashProperty&&(t=await this.hashBody(e.publisher,r,e.body),n[e.contentHashProperty]=t),Object.assign(n,e.header??{}),n.imports=r;let a={[e.name]:n,...e.body},i=this.dump(a),s={yaml:i,byteCount:se(i),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return t!==void 0&&(s.contentHash=t),s}dump(e){return T.dump(e,{lineWidth:-1})}async hashBody(e,r,n){let t={[ie]:{type:"EphemeralPackage",publisher:e,imports:r},...n},a=this.parser.parse(T.dump(t,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new X(a,this.repository))).filter(u=>u instanceof f&&u.namespace===i&&u.name!==ie);for(let u of c)u.namespace="ephemeral";return F(c)}},ie="__pkgbuilder_probe__";function se(o){return new TextEncoder().encode(o).length}function z(o){let e="sha256:",r=o.startsWith(e)?e.length:0;return`q-${o.slice(r,r+16)}`}var x=class{byKey=new Map;aliases=new Set;ensure(e,r,n,t,a=ae.Major){let i=`${e}/${r}@${n}`,s=this.byKey.get(i);if(s)return s.alias;let c=this.uniqueAlias(t);return this.byKey.set(i,{publisher:e,package_:r,version:n,alias:c,match:a}),c}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_,y(e.version),e.package_)}.${e.name}`}refLatest(e,r,n,t){return`${this.ensure(e,r,Kn,t??r,ae.Any)}.${n}`}toImports(){let e=new Map;for(let n of this.byKey.values()){let t=e.get(n.publisher)??[];t.push(n),e.set(n.publisher,t)}return[...e.keys()].sort().map(n=>({publisher:n,packages:e.get(n).sort((t,a)=>t.package_<a.package_?-1:1).map(t=>({package:t.package_,match:_(t.match),version:t.version,alias:t.alias}))}))}uniqueAlias(e){let r=K(e)||"pkg",n=r,t=2;for(;this.aliases.has(n);)n=`${r}${t++}`;return this.aliases.add(n),n}};function ce(o,e){if(o!=null){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o;if(o instanceof b)return e.ref(o.subject);if(Array.isArray(o)){let r=o.map(n=>ce(n,e)).filter(n=>n!==void 0);return r.length>0?r:void 0}if(o instanceof k)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(In(o))throw new Error(`Value produced a bare URI without a version (${o.publisher}/${o.package_}/${o.name}); cannot serialize it as a reference.`)}}function K(o){return o.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function In(o){return typeof o=="object"&&o!==null&&typeof o.publisher=="string"&&typeof o.package_=="string"&&typeof o.name=="string"}var A=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,r){return this.producers.find(n=>n.canProduce(e,r))}async produceCached(e,r,n,t){let a=`${r}/${n}@${y(t)}`,i=this.produced.get(a);if(i)return i;let{document:s}=await e.produce(r,n,t);return this.produced.set(a,s),s}async getHighestCompatibleVersionAsync(e,r){let n=this.producerFor(e,r.packageName);if(!n)return null;let t={operator:r.versionOperator,version:r.version},a=await n.resolveVersion(e,r.packageName,t);return a?this.produceCached(n,e,r.packageName,a):null}async getDocumentAsync(e){let r;try{r=M(e)}catch{return null}if(r.kind!=="package"||!r.version)return null;let n=this.producerFor(r.publisher,r.package_);return n?this.produceCached(n,r.publisher,r.package_,r.version):null}async getDocumentsByNamespaceAsync(e,r){return Array.from(this.produced.values()).filter(n=>{let t=n.metadata.namespace_;return t!=null&&t.publisher===e&&t.package_===r})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,r){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,r){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var H={async authorize(){return{allowed:!0}}},W={async record(){}},I=class extends Error{constructor(r,n){let t=`${r.publisher}/${r.package_}${r.version?`@${r.version.major}.${r.version.minor}.${r.version.patch}`:""}`;super(`Not entitled to produce ${t}${n?`: ${n}`:""}`);this.address=r;this.reason=n;this.name="EntitlementDeniedError"}address;reason},C=class{inner;ctx;policy;meter;constructor(e,r,n=H,t=W){this.inner=e,this.ctx=r,this.policy=n,this.meter=t}canProduce(e,r){return this.inner.canProduce(e,r)}async resolveVersion(e,r,n){return await this.assertAllowed({publisher:e,package_:r,version:n.version}),this.inner.resolveVersion(e,r,n)}async produce(e,r,n){let t={publisher:e,package_:r,version:n};await this.assertAllowed(t);let a=await this.inner.produce(e,r,n);return await this.meter.record(this.ctx,t,a),a}async assertAllowed(e){let r=await this.policy.authorize(this.ctx,e);if(!r.allowed)throw new I(e,r.reason)}};var p="kanonak.org",d="view",pe="core-kanonak",vn={publisher:p,package_:d,name:"rootView"},Vn={publisher:p,package_:d,name:"bind"},jn={publisher:p,package_:d,name:"produces"},An={publisher:p,package_:d,name:"projections"},Cn={publisher:p,package_:d,name:"where"},Sn={publisher:p,package_:d,name:"value"},Dn={publisher:p,package_:d,name:"as"},S=class{constructor(e,r=new P){this.repository=e;this.parser=r;this.objectParser=new E(this.parser),this.builder=new g(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,r={}){let n=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(n,e),a=w(t,Vn);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let i=w(t,jn);if(!i)throw new Error(`View ${t.namespace}/${t.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=Un(t),c=ue(n,p,pe),u=ue(n,p,d),l=this.builder.imports(),D=l.ensure(p,pe,c,"ck"),de=l.ensure(p,d,u,"v"),me=l.ref(i),ye=new oe(this.repository,this.parser,this.objectParser),q=new ne(ye,n),fe=this.readProjections(n,t),ke=Mn(t,Cn),ge=this.findInstances(n,a,await this.reason(r)),G={},he=new Set;for(let v of ge){if(!await this.passesWhere(q,n,ke,v))continue;let O={type:me};for(let Z of fe){let Pe=await this.evaluateValue(q,n,Z.value,v),Q=this.builder.serializeValue(le(Pe),l);Q!==void 0&&(O[l.ref(Z.as)]=Q)}let J=m(v);J&&(O[`${de}.derivedFrom`]=l.ref(J)),G[this.rowName(v,he)]=O}let U={};r.resolvedAt&&(U[`${D}.resolvedAt`]=r.resolvedAt),r.invocationId&&(U[`${D}.id`]=r.invocationId);let h=await this.builder.buildContentAddressed({publisher:s,book:l,body:G,contentHashProperty:`${D}.contentHash`,header:U});return{yaml:h.yaml,contentHash:h.contentHash,packageName:h.packageName,publisher:h.publisher,rowCount:h.resourceCount}}resolveView(e,r){let n=j(e,r);if(!n)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=w(n,vn);if(t){let a=j(e,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return n}readProjections(e,r){let n=[];for(let t of N(r,An)){let a=t instanceof k?t:t instanceof b?j(e,t.subject):void 0;if(!a)continue;let i=$(a,Sn),s=w(a,Dn);i&&s&&n.push({value:i,as:s})}return n}async reason(e){return new L({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,r,n){let t=_n(e),a=[],i=new Set;for(let s of n.getInstancesOfClass(r)){if(i.has(s))continue;i.add(s);let c=t.get(s);c&&a.push(c)}return a.sort((s,c)=>{let u=R(m(s)),l=R(m(c));return u<l?-1:u>l?1:0}),a}async passesWhere(e,r,n,t){for(let a of n){let i=await this.evaluateValue(e,r,a,t);if(!$n(i))return!1}return!0}async evaluateValue(e,r,n,t){let a=te(n,"view-projection",{catalog:r,depth:0}),i=new Map([["input",t]]);return e.evaluate(a,i)}rowName(e,r){let n=K(e.name)||"row",t=n,a=2;for(;r.has(t);)t=`${n}-${a++}`;return r.add(t),t}};function le(o){return B(o)?o.value:Array.isArray(o)?o.map(le):o}function Un(o){let e=m(o);if(!e)throw new Error(`Could not derive a publisher from view ${o.namespace}/${o.name}.`);return e.publisher}function ue(o,e,r){let n=On(o,e,r);if(!n)throw new Error(`Package ${e}/${r} is not in the catalog; it must be importable to materialize a view.`);return n}function On(o,e,r){let n;for(let t of o){if(!(t instanceof f))continue;let a=m(t);!a||a.publisher!==e||a.package_!==r||!a.version||(!n||V(a.version,n)>0)&&(n=a.version)}return n?y(n):void 0}function _n(o){let e=new Map,r=new Map;for(let n of o){if(!(n instanceof f))continue;let t=m(n);if(!t||!t.version)continue;let a=R(t),i=r.get(a);(!i||V(t.version,i)>0)&&(r.set(a,t.version),e.set(a,n))}return e}function Mn(o,e){let r=$(o,e);return r?[r]:N(o,e).filter(n=>n instanceof k)}function $n(o){return o===!0?!0:o===!1||o===void 0||o===null?!1:typeof o=="string"?o.length>0:typeof o=="number"?o!==0:B(o)?o.value.length>0:Array.isArray(o)?o.length>0:!!o}export{tn as AmbiguousReferenceRule,rr as BooleanStatement,En as CANONICAL_FORM_VERSION,hr as Carrier,un as ClassDefinitionRule,Zr as ClassHierarchyCycleRule,Ae as CompositeKanonakDocumentRepository,yn as DEFAULT_CONSENT_BINDING_PARAM,Ge as DefinedKanonak,je as DocumentLocation,Er as EdgeType,k as EmbeddedKanonak,qr as EmbeddedKanonakTypeRule,tr as EmbeddedStatement,I as EntitlementDeniedError,C as EntitlementProducer,Ve as FileSystemKanonakDocumentRepository,jr as GitIgnoreFilter,xr as GraphBuilder,Fe as HttpKanonakDocumentRepository,x as ImportBook,Gr as ImportExistenceRule,ve as InMemoryKanonakDocumentRepository,De as KANONAK_USER_AGENT,qe as Kanonak,Cr as KanonakDocumentPositions,E as KanonakObjectParser,dn as KanonakObjectValidator,P as KanonakParser,Je as KanonakUri,Ur as KanonakUriBuilder,Or as KanonakUrlResolver,dr as KanonakVocabulary,or as ListStatement,Ze as LiteralKanonak,Te as LocalFirstRepository,ze as LockAwareRepository,Rn as LookRenderer,ln as MarkdownLinkRule,ar as MarkdownStatement,rn as NamespaceImportCycleRule,Fr as NamespacePrefixRule,wr as NodeType,er as NumberStatement,fn as OAuthDiscovery,vr as OWL_RL_CLASSIFICATION_RULES,an as ObjectPropertyValueValidationRule,Nr as OntologyValidationError,Mr as OntologyValidationResult,g as PackageBuilder,Wr as PackageHeaderRule,A as ProducerRepository,sn as PropertyDomainRule,Qr as PropertyHierarchyCycleRule,cn as PropertyKindRangeConsistencyRule,Ar as PropertyMetadata,on as PropertyRangeReferenceRule,Xr as PropertyRangeRequiredRule,zr as PropertyTypeSpecificityRule,Ne as PublisherConfigResolver,Le as PublisherIndex,Ir as RDFS_RULES,L as Reasoner,Vr as ReasoningResult,b as ReferenceKanonak,nr as ReferenceStatement,Se as RepositoryFactory,pn as ReservedNameShadowRule,Tr as ResourceNamingRule,ir as ResourceResolver,mr as ResourceTypeClassifier,Xe as ScalarStatement,Qe as Statement,Ye as StringStatement,Yr as SubClassOfReferenceRule,en as SubPropertyOfReferenceRule,f as SubjectKanonak,Hr as SubjectKanonakTypeRequiredRule,hn as TokenCredentialProvider,Kr as TripleStore,sr as TypeResolver,nn as UnresolvedPredicateRule,Jr as UnresolvedReferenceRule,Br as ValidationCache,Lr as ValidationContext,$r as ValidationSeverity,_t as VersionOperator,S as ViewMaterializer,H as allowAllPolicy,_e as assertHttpsUrl,Be as assertPackageIdentity,We as buildLocalFirstRepository,xn as buildOntologyModel,wn as canonicalForm,F as canonicalHash,Pr as carrierOf,He as collectKanonakFiles,V as compareVersions,re as computeIntegrity,z as contentAddressedName,gr as contextTypesOf,gn as createCredentialedFetch,we as createVersion,Rr as extractMarkdownLinks,Pn as findDerivation,_r as findInstancesByType,br as findMalformedReferences,Dr as findMarkdownLinkAt,cr as formatKanonakAddress,y as formatVersion,Ce as getGlobalCachePath,Oe as getKanonakUserAgent,xe as isCompatibleVersion,Ke as isMajorCompatible,Me as kanonakFetch,Y as loadLockFile,pr as makeUriKey,W as noopMeter,mn as normalizeHost,kn as parseAuthChallenge,M as parseKanonakAddress,Ee as parseVersionString,Sr as parseWithPositions,Ie as pickHighestDocument,fr as propertiesInScope,bn as resolveDisplayValue,kr as resolvePropertyStep,K as sanitizeName,ee as saveLockFile,$e as setKanonakFetchRetries,Ue as setKanonakUserAgent,m as subjectUri,yr as superClassChain,ur as tripleKey,R as uriKey,lr as uriTriple,be as versionOperatorFromChar,_ as versionOperatorToChar,Re as versionsEqual};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
],
|
|
127
127
|
"dependencies": {
|
|
128
128
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
129
|
-
"@kanonak-protocol/types": "^5.
|
|
129
|
+
"@kanonak-protocol/types": "^5.16.0",
|
|
130
130
|
"ignore": "^7.0.5",
|
|
131
131
|
"js-yaml": "^4.1.0",
|
|
132
132
|
"yaml": "^2.7.0"
|