@kanonak-protocol/sdk 6.7.0 → 6.8.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-OHF4RIKS.js → chunk-2GV6GXRF.js} +1 -1
- package/dist/{chunk-BDTJIUS4.js → chunk-3ABGZHKM.js} +1 -1
- package/dist/{chunk-5ZRVFYCP.js → chunk-6CI3HTKF.js} +1 -1
- package/dist/chunk-6USORWEP.js +1 -0
- package/dist/chunk-7IMLHHSA.js +1 -0
- package/dist/{chunk-CPENAANM.js → chunk-AZFLKLPB.js} +1 -1
- package/dist/{chunk-K76UUREI.js → chunk-F4UHQVGA.js} +1 -1
- package/dist/{chunk-426MUUGB.js → chunk-FCRP7KXR.js} +1 -1
- package/dist/{chunk-DQGXJDQU.js → chunk-FKLZDYWF.js} +1 -1
- package/dist/{chunk-IWPCPQQY.js → chunk-FYAZ345F.js} +1 -1
- package/dist/{chunk-FS7UGDEX.js → chunk-IT37WOHT.js} +1 -1
- package/dist/{chunk-WXXZOJ4O.js → chunk-NYCGUDVW.js} +1 -1
- package/dist/{chunk-TF23WBSZ.js → chunk-PXUSA72Q.js} +1 -1
- package/dist/chunk-Q2ZUKZEU.js +1 -0
- package/dist/{chunk-VJUZKHQU.js → chunk-QRF7AT2M.js} +1 -1
- package/dist/{chunk-LIN5SG5I.js → chunk-TR7PC72M.js} +1 -1
- package/dist/chunk-TVMOJ2QS.js +1 -0
- package/dist/{chunk-Z2444SWM.js → chunk-X2URIXH7.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/parsing/KanonakObjectParser.d.ts +22 -2
- package/dist/parsing/index.js +1 -1
- package/dist/producer/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/KanonakUri-4VJGV3FN.js +0 -1
- package/dist/chunk-6WOPXTIL.js +0 -1
- package/dist/chunk-FUUTGGJS.js +0 -1
- package/dist/chunk-GGK6A6QK.js +0 -1
- package/dist/chunk-LK5SHY4B.js +0 -1
- package/dist/chunk-SBWD7EOG.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as j}from"./chunk-
|
|
1
|
+
import{e as j}from"./chunk-X2URIXH7.js";import{a as I,b as K,c as ee,e as T}from"./chunk-5FVUBF7N.js";import{k as re}from"./chunk-Q2ZUKZEU.js";import{oa as _,ra as z}from"./chunk-TVMOJ2QS.js";import{c as G,o as te}from"./chunk-6USORWEP.js";var se=(i=>(i.Class="Class",i.DatatypeProperty="DatatypeProperty",i.ObjectProperty="ObjectProperty",i.AnnotationProperty="AnnotationProperty",i.Instance="Instance",i.Datatype="Datatype",i.Shape="Shape",i.Unknown="Unknown",i))(se||{}),ae=(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))(ae||{}),H=class{static async buildFromRepository(e,r){let s=await new re().parseKanonaks(e),o=await e.getAllDocumentsAsync(),c=[],p=[],i=new Set,h=new Set,b=new Map;for(let g of s){let a=g;if(a.name&&(_.isClassType(a)&&i.add(a.name),g instanceof G)){let d=z(s,g);(d==="ObjectProperty"||d==="Property")&&h.add(a.name)}}for(let g of o)for(let[a,d]of Object.entries(g.body))h.has(a)&&d?.range&&typeof d.range=="string"&&b.set(a,d.range);let w=new Map;for(let g of s){let a=g;a.name&&w.set(a.name,a)}for(let g of o){let a=g.metadata.namespace_,d=a?`${a.publisher}/${a.package_}`:"",u=a?.version?`${a.version.major}.${a.version.minor}.${a.version.patch}`:"",y=ne(g);for(let[f,l]of Object.entries(g.body)){if(!l||typeof l!="object")continue;let A=w.get(f),m="Unknown";if(A){let E=A,k=A instanceof G?z(s,A):void 0;_.isClassType(E)?m="Class":k==="ObjectProperty"?m="ObjectProperty":k==="DatatypeProperty"?m="DatatypeProperty":k==="AnnotationProperty"?m="AnnotationProperty":_.isDatatypeType(E)?m="Datatype":k==="Property"?m="ObjectProperty":_.isShapeType(E)?m="Shape":_.isInstanceOfKnownClass(E,i)&&(m="Instance")}let C=d&&u?`${d}/${f}@${u}`:f,R={};for(let[E,k]of Object.entries(l))E!=="type"&&(typeof k!="object"||k===null)&&(R[E]=k);c.push({id:C,label:l.label??f,type:m,namespace:d,properties:R}),oe(C,l,m,i,h,p,d,u,y,r),q(C,l,h,b,c,p,d,u,y),Ce(C,A,p)}}return{nodes:c,edges:p}}static buildFromDocument(e,r){let n=[],s=[],o=e.metadata.namespace_,c=o?.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"",p=o?`${o.publisher}/${o.package_}`:"",i=new Set,h=new Set,b=new Map,w=ne(e);for(let[d,u]of Object.entries(e.body)){let y=u?.type;y&&(be(y,w)&&i.add(d),Pe(y,w)&&(h.add(d),u.range&&typeof u.range=="string"&&b.set(d,u.range)))}for(let[d,u]of Object.entries(e.body)){if(!u||typeof u!="object")continue;let y=u.type,f=Ae(y,d,i,w),l=p&&c?`${p}/${d}@${c}`:d,A={};for(let[m,C]of Object.entries(u))m!=="type"&&(typeof C!="object"||C===null)&&(A[m]=C);n.push({id:l,label:u.label??d,type:f,namespace:p,properties:A}),oe(l,u,f,i,h,s,p,c,w,r),q(l,u,h,b,n,s,p,c,w)}let g=new Set(n.map(d=>d.id)),a=s.filter(d=>g.has(d.source)&&g.has(d.target));return{nodes:n,edges:a}}};function ne(t,e){let r=new Map;if(t.metadata?.imports)for(let[n,s]of Object.entries(t.metadata.imports))for(let o of s){let c=o.alias??o.packageName,p=o.version,i=`${p.major}.${p.minor}.${p.patch}`;r.set(c,{publisher:n,package_:o.packageName,version:i})}return r}var ie={"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"},ke=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function W(t,e){if(t.includes(".")){let r=t.indexOf("."),n=t.substring(0,r),s=t.substring(r+1),o=e.get(n);if(o)return`${o.publisher}/${o.package_}/${s}`}return null}function be(t,e){let r=W(t,e);return r?ie[r]==="Class":!1}function Pe(t,e){let r=W(t,e);return r?ke.has(r):!1}function Ae(t,e,r,n){if(!t||t==="Package")return"Unknown";let s=W(t,n);if(s){let c=ie[s];if(c)return c;let p=s.split("/").pop()?.split("@")[0]??"";return r.has(p)?"Instance":"Unknown"}let o=t.split(".").pop()??t;return r.has(o)?"Instance":"Unknown"}var ce=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function oe(t,e,r,n,s,o,c,p,i,h){let b=e.type,w=e.subClassOf;if(w){let f=Array.isArray(w)?w:[w];for(let l of f)typeof l=="string"&&o.push({source:t,target:O(l,c,p,i),type:"subClassOf",label:"subClassOf"})}let g=e.subPropertyOf;if(g){let f=Array.isArray(g)?g:[g];for(let l of f)typeof l=="string"&&o.push({source:t,target:O(l,c,p,i),type:"subPropertyOf",label:"subPropertyOf"})}let a=e.domain,d=e.range;if(h?.includePropertyEdges){let f=[[a,"domain","domain"],[d,"range","range"]];for(let[l,A,m]of f)if(l!=null)for(let C of Array.isArray(l)?l:[l])typeof C=="string"&&o.push({source:t,target:O(C,c,p,i),type:A,label:m})}if(r==="Instance"&&b){let f=b.split(".").pop()??b;o.push({source:t,target:O(f,c,p,i),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[f,l]of Object.entries(e)){if(ce.has(f)||!s.has(f))continue;let A=Array.isArray(l)?l:[l];for(let m of A)typeof m=="string"&&Ee(m)&&o.push({source:t,target:O(m,c,p,i),type:"propertyValue",label:f,propertyId:O(f,c,p,i)})}if((r==="ObjectProperty"||r==="DatatypeProperty"||a&&d)&&a&&d){let f=typeof a=="string"?a:null,l=typeof d=="string"?d:null;f&&l&&o.push({source:O(f,c,p,i),target:O(l,c,p,i),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function q(t,e,r,n,s,o,c,p,i){for(let[h,b]of Object.entries(e)){if(ce.has(h)||typeof b!="object"||b===null||Array.isArray(b))continue;let w=b,g=`${t}/${h}`,a=n.get(h),d=a?a.split(".").pop()??a:"Unknown",u={};for(let[f,l]of Object.entries(w))(typeof l!="object"||l===null)&&(u[f]=l);s.push({id:g,label:`${d} (embedded)`,type:"Instance",namespace:c,properties:u});let y=c&&p?`${c}/${h}@${p}`:h;o.push({source:t,target:g,type:"propertyValue",label:h,propertyId:r.has(h)?y:void 0}),a&&o.push({source:g,target:O(d,c,p,i),type:"instanceOf",label:"type (inferred)"}),q(g,w,r,n,s,o,c,p,i)}}function Ce(t,e,r){let n=e?.statement;if(Array.isArray(n))for(let s of n){if(!(s instanceof te))continue;let o=s.predicate?.subject?.name??"";for(let c of s.links){let p=c.target?.subject;if(!p)continue;let i=p.version,h=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"";r.push({source:t,target:`${p.publisher}/${p.package_}/${p.name}${h}`,type:"embeddedLink",label:o})}}}function Ee(t){return!(!t||t.includes(" ")||t.includes(`
|
|
2
2
|
`)||t.startsWith("http://")||t.startsWith("https://")||/^\d{4}-\d{2}/.test(t)||/^\d+(\.\d+)?$/.test(t))}function O(t,e,r,n){if(t.includes("@")&&t.includes("/"))return t;if(t.includes(".")){let s=t.indexOf("."),o=t.substring(0,s),c=t.substring(s+1);if(n){let p=n.get(o);if(p)return`${p.publisher}/${p.package_}/${c}@${p.version}`}return e&&r?`${e}/${c}@${r}`:c}return e&&r?`${e}/${t}@${r}`:t}function M(t){let e=t.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}function v(t){let e;try{e=new URL(t)}catch{throw new Error(`credential scope '${t}' is not an absolute URL`)}if(e.protocol!=="https:")throw new Error(`credential scope '${t}' is not https`);if(e.username||e.password)throw new Error(`credential scope '${t}' carries userinfo`);if(e.search||t.includes("?"))throw new Error(`credential scope '${t}' has a query`);if(e.hash||t.includes("#"))throw new Error(`credential scope '${t}' has a fragment`);let r=e.pathname;return{origin:e.origin,prefix:r.endsWith("/")?r:`${r}/`}}function N(t,e){let r=typeof t=="string"?v(t):t,n;try{n=new URL(e)}catch{return!1}if(n.protocol!=="https:"||n.origin!==r.origin)return!1;let s=n.pathname;return s.startsWith(r.prefix)||`${s}/`===r.prefix}function V(t,e){let r,n=-1;for(let s of t){let o=v(s.scope);N(o,e)&&o.prefix.length>n&&(r=s,n=o.prefix.length)}return r}var Oe="key_thumbprint",x=class{cache=new Map;wellKnownCache=new Map;metadataUrlCache=new Map;async protectedResourceMetadata(e){let r=new URL(e).href,n=this.wellKnownCache.get(r);return n||(n=this.fetchWellKnown(r),this.wellKnownCache.set(r,n)),n}async protectedResourceMetadataAt(e,r){let n=new URL(e).href,s=this.metadataUrlCache.get(n);s||(s=this.fetchMetadataAt(n),this.metadataUrlCache.set(n,s));let o=await s,c;try{c=N(v(o.resource),r)}catch(p){throw new Error(`Protected resource metadata at ${n} names an unusable resource '${o.resource}': ${p.message}`)}if(!c)throw new Error(`Protected resource metadata at ${n} names the resource '${o.resource}', which does not contain the requested ${r}. RFC 9728 \xA73.3 forbids using it.`);return o}async fetchWellKnown(e){let r=new URL(e),n=r.pathname==="/"?"":r.pathname,s=`${r.origin}/.well-known/oauth-protected-resource${n}`,o=await j(s,{redirect:"manual"});if(o.status===404||o.status===410||o.status>=300&&o.status<400)return null;if(!o.ok)throw await K("protected resource metadata",s,o);if(!pe(o.headers.get("content-type")))return null;let c=de(s,await o.text());if(!URL.canParse(c.resource)||new URL(c.resource).href!==e)throw new Error(`Protected resource metadata at ${s} names the resource '${c.resource}', not '${e}'. RFC 9728 \xA73.3 forbids using it.`);return c}async fetchMetadataAt(e){let r=await j(e,{redirect:"manual"});if(!r.ok)throw await K("protected resource metadata",e,r);if(!pe(r.headers.get("content-type")))throw new Error(`Protected resource metadata at ${e} is not a JSON document (${r.headers.get("content-type")??"no content type"})`);return de(e,await r.text())}async discover(e){let r=M(e);if(this.cache.has(r))return this.cache.get(r);let n=`https://${r}/.well-known/oauth-authorization-server`,s=await this.tryEndpoint(n);if(!s){let o=`https://${r}/.well-known/openid-configuration`;s=await this.tryEndpoint(o)}return this.cache.set(r,s),s}async supportsOAuth(e){return await this.discover(e)!==null}static supportsPkceS256(e){return e.codeChallengeMethodsSupported?.some(r=>r.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(e){return!!e.registrationEndpoint}static supportsAuthorizationCode(e){return e.responseTypesSupported?.some(r=>r.toLowerCase()==="code")??!1}static supportsEnrollment(e){return!!e.enrollmentEndpoint}static supportsSession(e){return!!e.sessionEndpoint}async tryEndpoint(e){let r;try{r=await fetch(e)}catch(s){let o=s instanceof Error?s.message:String(s);return o.includes("ENOTFOUND")||o.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${e} \u2014 host unreachable (${o})`),console.error(" If the server is behind a VPN, ensure you are connected.")):o.includes("CERT")||o.includes("SSL")||o.includes("TLS")?(console.error(` OAuth discovery: ${e} \u2014 TLS error (${o})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${e} \u2014 network error: ${o}`),null}if(!r.ok)return r.status===404||(r.status===403?(console.error(` OAuth discovery: ${e} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):r.status>=500&&(console.error(` OAuth discovery: ${e} \u2014 HTTP ${r.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let n;try{n=await r.json()}catch{return console.error(` OAuth discovery: ${e} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:$(n.issuer),authorizationEndpoint:$(n.authorization_endpoint),tokenEndpoint:$(n.token_endpoint),registrationEndpoint:$(n.registration_endpoint),revocationEndpoint:$(n.revocation_endpoint),scopesSupported:S(n.scopes_supported),responseTypesSupported:S(n.response_types_supported),grantTypesSupported:S(n.grant_types_supported),codeChallengeMethodsSupported:S(n.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:S(n.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:S(n.dpop_signing_alg_values_supported),enrollmentEndpoint:$(n.enrollment_endpoint),enrollmentIssuanceProtocols:S(n.enrollment_issuance_protocols),enrollmentKeyTypes:S(n.enrollment_key_types),enrollmentScopesSupported:S(n.enrollment_scopes_supported),enrollmentConsentBindingParam:$(n.enrollment_consent_binding_param),sessionEndpoint:$(n.session_endpoint),sessionEndpointAuthMethod:$(n.session_endpoint_auth_method)}}};function pe(t){let e=(t??"").split(";")[0].trim().toLowerCase();return e==="application/json"||e.endsWith("+json")}function de(t,e){let r;try{r=JSON.parse(e)}catch{throw new Error(`Protected resource metadata at ${t} is not valid JSON`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Protected resource metadata at ${t} is not a JSON object`);let n=r;if(typeof n.resource!="string")throw new Error(`Protected resource metadata at ${t} has no "resource"`);let s=n.authorization_servers;if(s!==void 0&&!(Array.isArray(s)&&s.every(o=>typeof o=="string")))throw new Error(`Protected resource metadata at ${t} has an "authorization_servers" that is not a list of strings`);return{resource:n.resource,authorizationServers:s??[]}}function $(t){return typeof t=="string"?t:null}function S(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):null}var D=1,$e=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Se=/[\r\n\0]/;function P(t,e){return{ok:!1,problem:t,message:e}}function L(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function U(t,e,r){if(!L(e))return P("malformed","the answer is not a JSON object");if(e.status==="declined")return e.reason!==void 0&&typeof e.reason!="string"?P("reason",`a decline's "reason" must be a string`):{ok:!0,answer:e.reason===void 0?{status:"declined"}:{status:"declined",reason:e.reason}};if(e.status!=="credential")return P("status",`"status" must be "credential" or "declined", not ${JSON.stringify(e.status)}`);let n=e.headers;if(!L(n)||Object.keys(n).length===0)return P("headers",'a credential needs "headers": an object with at least one header');let s={};for(let[i,h]of Object.entries(n)){if(!$e.test(i))return P("headers",`header name ${JSON.stringify(i)} is not a valid field name`);if(typeof h!="string"||Se.test(h))return P("headers",`header '${i}' must be a string without CR, LF or NUL`);s[i]=h}if(typeof e.scope!="string")return P("scope",'a credential needs a "scope" string');let o;try{o=v(e.scope)}catch(i){return P("scope",i.message)}if(!N(o,t.resource))return P("scope-excludes-resource",`scope '${e.scope}' does not contain the requested resource ${t.resource}`);let c;if(e.expiresAt!==void 0){if(typeof e.expiresAt!="number"||!Number.isFinite(e.expiresAt))return P("expires-at",'"expiresAt" must be a number of Unix seconds');if(e.expiresAt<=r)return P("expired",`the credential expired at ${e.expiresAt} (now ${Math.floor(r)})`);c=e.expiresAt}let p={status:"credential",headers:s,scope:e.scope};return c!==void 0&&(p.expiresAt=c),{ok:!0,answer:p}}function Re(t,e,r){return L(e)?e.version!==D?P("version",`"version" must be ${D}, not ${JSON.stringify(e.version)}`):U(t,e,r):P("malformed","the answer is not a JSON object")}function Te(t){return L(t)?t.version!==D?P("version",`"version" must be ${D}, not ${JSON.stringify(t.version)}`):t.status!=="erased"?P("status",`"status" must be "erased", not ${JSON.stringify(t.status)}`):{ok:!0,answer:{status:"erased"}}:P("malformed","the answer is not a JSON object")}function B(t){let e=new J(t),r=[];for(e.skipListSeparators();!e.atEnd();){let n=e.token();if(!n)throw e.error("expected an auth-scheme");let s={scheme:n,params:{}};r.push(s);let o=e.skipSpaces();if(e.atEnd()||e.peek()===","){e.skipListSeparators();continue}if(!o)throw e.error(`expected a space after the auth-scheme '${n}'`);let c=e.tryParam();if(c)for(ue(s,c,e);e.skipOws(),!e.atEnd();){if(e.peek()!==",")throw e.error('expected "," between auth-params');if(e.skipListSeparators(),e.atEnd())break;let p=e.pos,i=e.tryParam();if(!i){e.pos=p;break}ue(s,i,e)}else{let p=e.token68();if(!p)throw e.error(`expected a token68 or auth-params after '${n}'`);if(s.token68=p,e.skipOws(),!e.atEnd()&&e.peek()!==",")throw e.error("unexpected text after token68")}e.skipListSeparators()}return r}function ue(t,[e,r],n){if(Object.prototype.hasOwnProperty.call(t.params,e))throw n.error(`auth-param '${e}' appears twice in the '${t.scheme}' challenge`);t.params[e]=r}var ve=/[!#$%&'*+\-.^_`|~0-9A-Za-z]/,xe=/[A-Za-z0-9\-._~+/]/,J=class{constructor(e){this.s=e}s;pos=0;atEnd(){return this.pos>=this.s.length}peek(){return this.s[this.pos]}error(e){return new Error(`Malformed WWW-Authenticate (${e} at offset ${this.pos}): ${this.s}`)}skipSpaces(){let e=this.pos;for(;!this.atEnd()&&(this.peek()===" "||this.peek()===" ");)this.pos++;return this.pos>e}skipOws(){this.skipSpaces()}skipListSeparators(){for(;;){if(this.skipOws(),this.peek()!==",")return;this.pos++}}token(){let e=this.pos;for(;!this.atEnd()&&ve.test(this.peek());)this.pos++;return this.s.slice(e,this.pos)}token68(){let e=this.pos;for(;!this.atEnd()&&xe.test(this.peek());)this.pos++;if(this.pos===e)return"";for(;!this.atEnd()&&this.peek()==="=";)this.pos++;return this.s.slice(e,this.pos)}tryParam(){let e=this.pos,r=this.token();if(!r)return null;if(this.skipOws(),this.peek()!=="=")return this.pos=e,null;this.pos++,this.skipOws();let n;if(this.peek()==='"')n=this.quotedString();else if(n=this.token(),!n)return this.pos=e,null;return[r.toLowerCase(),n]}quotedString(){this.pos++;let e="";for(;;){if(this.atEnd())throw this.error("unterminated quoted-string");let r=this.s[this.pos++];if(r==='"')return e;if(r==="\\"){if(this.atEnd())throw this.error("unterminated quoted-pair");e+=this.s[this.pos++]}else e+=r}}};var ye=30;function _e(t,e={}){let r=e.discovery??new x,n=e.nowSeconds??(()=>Date.now()/1e3),s=[],o=new WeakSet,c=new Map,p=new Map,i=a=>{let d=n();return s=s.filter(u=>u.expiresAt===void 0||u.expiresAt-ye>d),V(s,a)},h=(a,d)=>{let u=(p.get(a)??Promise.resolve()).then(d);return p.set(a,u.then(()=>{},()=>{})),u},b=a=>{let d=c.get(a);return d||(d=r.protectedResourceMetadata(a).then(u=>u!==null,u=>{if(u instanceof I&&(u.status===401||u.status===403))return!0;throw new T(`Could not learn whether ${a} requires a credential: ${me(u)}`)}),c.set(a,d)),d},w=async(a,d)=>{let u=U(d,await le(()=>a.get(d),d.resource),n());if(!u.ok)throw new T(`The credential provider answered for ${d.resource} outside the protocol (${u.problem}): ${u.message}`);let y=u.answer;if(y.status==="declined")return y.reason===void 0?{}:{declined:y.reason};let f={headers:y.headers,scope:y.scope};return y.expiresAt!==void 0&&(f.expiresAt=y.expiresAt),s=s.filter(l=>l.scope!==f.scope),s.push(f),f},g=(a,d,u)=>j(a,{method:d,redirect:"manual",headers:u?.headers??{}});return async(a,d,u="GET")=>{let y=new URL(a).origin,f=i(a);if(!f&&t&&await b(y)){let k=await h(y,async()=>i(a)??w(t,{resource:a,method:u}));fe(k)&&(f=k)}let l=await g(a,u,f);if(l.status!==401&&l.status!==403)return l;let A=ge(l,a),m=l.status===401;if(!m&&!he(A))return l;if(c.set(y,Promise.resolve(!0)),!t)throw await Y(`${a} requires a credential, and no credential provider is configured`,l);let C={resource:a,method:u,challenges:A},R=await h(y,async()=>{let k=i(a);if(k&&k!==f)return k;if(m&&f&&!o.has(f)){o.add(f);let Q=f;s=s.filter(we=>we!==Q),await le(()=>t.erase({...C,scope:Q.scope}),a)}return w(t,C)});if(!fe(R)){let k=R.declined?`: ${R.declined}`:"";throw await Y(`${a} requires a credential, and the credential provider declined${k}`,l)}let E=await g(a,u,R);if(E.status===401||E.status===403&&he(ge(E,a)))throw await Y(`${a} rejected the credential for ${R.scope} after asking the provider again`,E);return E}}async function le(t,e){try{return await t()}catch(r){throw r instanceof T?r:new T(`The credential provider failed for ${e}: ${me(r)}`)}}function me(t){return t instanceof Error?t.message:String(t)}function fe(t){return"scope"in t}function he(t){return t.some(e=>e.params.error==="insufficient_scope")}function ge(t,e){let r=t.headers.get("www-authenticate");if(!r)return[];try{return B(r)}catch(n){throw new T(`${e} answered ${t.status} with a challenge that cannot be read: ${n.message}`)}}async function Y(t,e){return new T(`${t}. The server answered ${await ee(e)}`)}var F="KANONAK_TOKEN";function Ne(){return typeof process<"u"&&process.env?process.env:{}}function Z(t){return`${F}_${M(t).toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var X=class{tokens;env;discovery;constructor(e={}){this.tokens=e.tokens??{},this.env=e.env??Ne(),this.discovery=e.discovery??new x}async get(e){let r=await this.metadataFor(e);if("declined"in r)return{status:"declined",reason:r.declined};let n=r.metadata;if(n.authorizationServers.length===0)return{status:"declined",reason:`the protected-resource metadata for ${n.resource} names no authorization server`};let s=n.authorizationServers.map(o=>new URL(o).host);for(let o of s){let c=this.tokens[o]??this.env[Z(o)]??this.env[F];if(c)return{status:"credential",headers:{Authorization:`Bearer ${c}`},scope:n.resource}}return{status:"declined",reason:`no token is configured for ${s.join(" or ")}: set ${s.map(Z).join(" or ")}, or ${F}`}}async erase(){}async metadataFor(e){let r=e.challenges?.find(o=>o.params.resource_metadata!==void 0)?.params.resource_metadata;if(r!==void 0)return{metadata:await this.discovery.protectedResourceMetadataAt(r,e.resource)};let n=new URL(e.resource).origin,s;try{s=await this.discovery.protectedResourceMetadata(n)}catch(o){if(o instanceof I&&(o.status===401||o.status===403))return{declined:`${n} requires a credential even for its protected-resource metadata, and its challenge names no resource_metadata`};throw o}return s?{metadata:s}:{declined:`${n} publishes no RFC 9728 protected-resource metadata naming its authorization server, so no token is presented to it`}}};export{se as a,ae as b,H as c,M as d,v as e,N as f,V as g,Oe as h,x as i,D as j,U as k,Re as l,Te as m,B as n,ye as o,_e as p,F as q,Z as r,X as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as X}from"./chunk-6CI3HTKF.js";import{a as H,b as J,ha as Q,ia as _,ja as Z,la as E,ra as te}from"./chunk-TVMOJ2QS.js";import{I as ee,J as ne,c as P,d as S,e as k,f as L,g as q,i as M,j as I,k as T,l as v,m as R,n as O,o as N,p as x,q as U,y as Y}from"./chunk-6USORWEP.js";import{b as G}from"./chunk-F67UH4FD.js";import{k as W,l as j}from"./chunk-7IMLHHSA.js";function re(u,n){for(let t of u)t instanceof P&&ae(t,ee(t),t.name,n)}function ae(u,n,t,r){let a=n.indexOf("#");r({kanonak:u,address:n,path:a<0?t:`${t}.${n.slice(a+1)}`});for(let i of ce(u))for(let{value:o,address:s}of ne(u,i,n))o.item instanceof S&&ae(o.item,s,t,r)}function ce(u){let n=new Map;for(let t of u.statement){let r=t.predicate?.subject;if(!r)continue;let a=`${r.publisher}/${r.package_}/${r.name}`;n.has(a)||n.set(a,r)}return[...n.values()]}var oe="kanonak.org",pe="transformations",je=3,e=u=>({publisher:oe,package_:pe,name:u}),h=u=>({publisher:oe,package_:"math",name:u}),ve={Power:h("Power"),Modulo:h("Modulo"),Minimum:h("Minimum"),Maximum:h("Maximum"),Exp:h("Exp"),Ln:h("Ln"),Log10:h("Log10"),Sqrt:h("Sqrt"),Floor:h("Floor"),Ceil:h("Ceil"),Round:h("Round"),Sign:h("Sign"),Clip:h("Clip"),clipValue:h("clipValue"),clipLower:h("clipLower"),clipUpper:h("clipUpper")},A={Transformation:e("Transformation"),InstanceTransformation:e("InstanceTransformation"),SetTransformation:e("SetTransformation"),inputPattern:e("inputPattern"),rule:e("rule"),artifactName:e("artifactName"),outputs:e("outputs"),formatOverrides:e("formatOverrides"),partitionBy:e("partitionBy"),InputPattern:e("InputPattern"),matchesClass:e("matchesClass"),requires:e("requires"),sortBy:e("sortBy"),SortKey:e("SortKey"),byProperty:e("byProperty"),order:e("order"),SortOrder:e("SortOrder"),ascending:e("ascending"),descending:e("descending"),OutputFormat:e("OutputFormat"),backendUri:e("backendUri"),FormatOverride:e("FormatOverride"),formatTarget:e("formatTarget"),metadataKeys:e("metadataKeys"),metadataRenames:e("metadataRenames"),trailingNewline:e("trailingNewline"),omitWrapper:e("omitWrapper"),RenameEntry:e("RenameEntry"),fromKey:e("fromKey"),toKey:e("toKey"),FMT_MARKDOWN_FRONTMATTER:e("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:e("plain-markdown"),FMT_TOML:e("toml"),FMT_JSON:e("json"),FMT_HTML:e("html"),FMT_SVG:e("svg"),Expression:e("Expression"),ListSourcedExpression:e("ListSourcedExpression"),ListAggregate:e("ListAggregate"),IteratingExpression:e("IteratingExpression"),BuildAstNode:e("BuildAstNode"),astClass:e("astClass"),set:e("set"),AstFieldBinding:e("AstFieldBinding"),field:e("field"),bindValue:e("bindValue"),When:e("When"),condition:e("condition"),thenBuild:e("thenBuild"),elseBuild:e("elseBuild"),Concat:e("Concat"),parts:e("parts"),Fallback:e("Fallback"),primary:e("primary"),alternate:e("alternate"),StringLiteral:e("StringLiteral"),stringLiteral:e("stringLiteral"),IntegerLiteral:e("IntegerLiteral"),integerLiteral:e("integerLiteral"),DecimalLiteral:e("DecimalLiteral"),decimalLiteral:e("decimalLiteral"),BooleanLiteral:e("BooleanLiteral"),booleanLiteral:e("booleanLiteral"),VarRef:e("VarRef"),varName:e("varName"),PropertyRead:e("PropertyRead"),readSource:e("readSource"),readProp:e("readProp"),Traverse:e("Traverse"),traverseSource:e("traverseSource"),through:e("through"),step:e("step"),UriName:e("UriName"),uriNameOf:e("uriNameOf"),UriPublisher:e("UriPublisher"),uriPublisherOf:e("uriPublisherOf"),UriPackage:e("UriPackage"),uriPackageOf:e("uriPackageOf"),UriVersion:e("UriVersion"),uriVersionOf:e("uriVersionOf"),SubjectUri:e("SubjectUri"),subjectOf:e("subjectOf"),UriLiteral:e("UriLiteral"),refTo:e("refTo"),DisplayLabel:e("DisplayLabel"),labelTarget:e("labelTarget"),labelSource:e("labelSource"),ResolveRef:e("ResolveRef"),resolveSource:e("resolveSource"),Normalize:e("Normalize"),normSource:e("normSource"),normKind:e("normKind"),NormalizeKind:e("NormalizeKind"),NORM_TRIM_END:e("trim-end"),NORM_TO_UPPER:e("to-upper"),NORM_TO_LOWER:e("to-lower"),NORM_FIRST_CHAR:e("first-char"),UnescapedString:e("UnescapedString"),unescapedSource:e("unescapedSource"),IsSet:e("IsSet"),checkExpr:e("checkExpr"),ExpressionFragment:e("ExpressionFragment"),body:e("body"),CallFragment:e("CallFragment"),fragmentRef:e("fragmentRef"),source:e("source"),Join:e("Join"),separator:e("separator"),Count:e("Count"),Sum:e("Sum"),Min:e("Min"),Max:e("Max"),Average:e("Average"),loopVar:e("loopVar"),ForEach:e("ForEach"),emit:e("emit"),ListMap:e("ListMap"),mapBody:e("mapBody"),Filter:e("Filter"),predicate:e("predicate"),PartitionBy:e("PartitionBy"),partitionKey:e("partitionKey"),DistinctBy:e("DistinctBy"),distinctKey:e("distinctKey"),Partition:e("Partition"),key:e("key"),members:e("members"),AllStatements:e("AllStatements"),statementsOf:e("statementsOf"),StatementPredicate:e("StatementPredicate"),predicateOf:e("predicateOf"),StatementValue:e("StatementValue"),valueOf:e("valueOf"),DateFormat:e("DateFormat"),dateSource:e("dateSource"),dateFormat:e("dateFormat"),NumberFormat:e("NumberFormat"),numberSource:e("numberSource"),numberStyle:e("numberStyle"),fractionDigits:e("fractionDigits"),currencyCode:e("currencyCode"),BinaryArithmetic:e("BinaryArithmetic"),arithLeft:e("arithLeft"),arithRight:e("arithRight"),Add:e("Add"),Subtract:e("Subtract"),Multiply:e("Multiply"),Divide:e("Divide"),Reverse:e("Reverse"),WindowedMap:e("WindowedMap"),windowSize:e("windowSize"),windowVar:e("windowVar"),windowBody:e("windowBody"),PairwiseMap:e("PairwiseMap"),firstVar:e("firstVar"),secondVar:e("secondVar"),pairBody:e("pairBody"),Scan:e("Scan"),initialState:e("initialState"),stateVar:e("stateVar"),elementVar:e("elementVar"),accumulate:e("accumulate"),ListItemAt:e("ListItemAt"),itemIndex:e("itemIndex"),BinaryComparison:e("BinaryComparison"),compareLeft:e("compareLeft"),compareRight:e("compareRight"),Equals:e("Equals"),GreaterThan:e("GreaterThan"),LessThan:e("LessThan"),GreaterThanOrEqual:e("GreaterThanOrEqual"),LessThanOrEqual:e("LessThanOrEqual"),Not:e("Not"),operand:e("operand"),BooleanLogic:e("BooleanLogic"),operands:e("operands"),And:e("And"),Or:e("Or"),Contains:e("Contains"),haystack:e("haystack"),needle:e("needle"),Matches:e("Matches"),matchSource:e("matchSource"),pattern:e("pattern"),UnaryNumericOp:e("UnaryNumericOp"),value:e("value"),Abs:e("Abs"),Negate:e("Negate"),KindPredicate:e("KindPredicate"),IsReference:e("IsReference"),IsEmbedded:e("IsEmbedded"),IsList:e("IsList"),kindCheck:e("kindCheck"),IsString:e("IsString"),IsNumber:e("IsNumber"),IsBoolean:e("IsBoolean"),StatementObject:e("StatementObject"),statementSource:e("statementSource"),Let:e("Let"),letName:e("letName"),letValue:e("letValue"),letBody:e("letBody"),GetStatementByName:e("GetStatementByName"),inSubject:e("inSubject"),byName:e("byName"),RenderMarkdown:e("RenderMarkdown"),renderSource:e("renderSource"),renderProp:e("renderProp"),renderFormat:e("renderFormat"),RenderFormat:e("RenderFormat"),RENDER_HTML:e("render-html"),RENDER_MARKDOWN:e("render-markdown")};import{Carrier as K,carrierOf as ue}from"@kanonak-protocol/canonical";function V(u){return ue(`${u.publisher}/${u.package_}/${u.name}`)}var fe=/\[\[([^\[\]\n]+)\]\]/g,me=/\[\[/g,ie=/```[\s\S]*?```|`[^`\n]*`/g;function le(u){let n=[];for(let t of u.matchAll(ie))n.push([t.index,t.index+t[0].length]);return n}function Me(u){if(!u||!u.includes("[["))return[];let n=le(u),t=i=>n.some(([o,s])=>i>=o&&i<s),r=new Set(C(u).map(i=>i.startOffset)),a=[];for(let i of u.matchAll(me)){let o=i.index;if(t(o)||r.has(o))continue;let s=u.slice(o,o+48).replace(/\s+/g," ").trim();a.push({startOffset:o,snippet:s})}return a}function C(u){if(!u||!u.includes("[["))return[];let n=[];for(let a of u.matchAll(ie))n.push([a.index,a.index+a[0].length]);let t=a=>n.some(([i,o])=>a>=i&&a<o),r=[];for(let a of u.matchAll(fe)){let i=a.index;if(t(i))continue;let o=a[1],s=o.indexOf("|"),p=(s===-1?o:o.slice(0,s)).trim();if(p.length===0)continue;let c=s===-1?"":o.slice(s+1).trim(),f={reference:p,startOffset:i,endOffset:i+a[0].length};c.length>0&&(f.displayText=c),r.push(f)}return r}import{VersionOperator as de}from"@kanonak-protocol/types/document/models/enums";var ye={..._("range"),name:"range"};function ge(u){let n=u.lastIndexOf(".");return n===-1?u:u.slice(n+1)}var se=class{constructor(n){}async parseKanonaks(n,t){let r=await n.getAllDocumentsAsync(),a=new H(n),i=new J(a);this.knownPropertyClasses.clear();let o=await this.parseAllDocumentsAsync(r,a,i,n),s=await this.mergeAndCanonicalizeAsync(o,n);return await this.learnPropertyClassesAsync(s,r,a)&&(o=await this.parseAllDocumentsAsync(r,a,i,n),s=await this.mergeAndCanonicalizeAsync(o,n)),t&&(t.authored=o),s}knownPropertyClasses=new Map;async learnPropertyClassesAsync(n,t,r){let a=new Map;for(let p of t){let c=p.metadata.namespace_?.toString();c&&a.set(c,p)}let i=[],o=new Set;re(n,({kanonak:p})=>{for(let c of p.unresolvedPredicates){let f=`${c.sourceDoc}::${c.key}`;o.has(f)||(o.add(f),i.push(c))}});let s=!1;for(let p of i){let c=a.get(p.sourceDoc);if(!c)continue;let f=await r.resolveEntityAsync(p.key,c);if(!f)continue;let l=x(f.uri);if(this.knownPropertyClasses.has(l))continue;let d=Y(n,f.uri);if(!d)continue;let m=te(n,d);m&&(this.knownPropertyClasses.set(l,m),s=!0)}return s}async parseAllDocumentsAsync(n,t,r,a){let i=[];for(let o of n){let s=o.metadata.namespace_?.toString()??"";for(let[p,c]of Object.entries(o.body)){let f=new P,l=this.resolveCanonicalEntity(p,o,s);f.namespace=l.namespace,f.name=l.name,f.sourceKey=p,f.statement=[];let d=await this.parseStatements(c,o,t,r,a);f.statement.push(...d.statements),f.unresolvedPredicates=d.unresolved,F(f,s),i.push(f)}}return i}async mergeAndCanonicalizeAsync(n,t){let r=new Map,a=new Map,i=[];for(let c of n)if(c instanceof P){let f=`${c.namespace}/${c.name}`,l=r.get(f);if(l){let d=a.get(f);for(let m of c.statement){let g=$(m);d.has(g)||(d.add(g),l.statement.push(m))}for(let m of c.unresolvedPredicates)l.unresolvedPredicates.some(g=>g.key===m.key&&g.sourceDoc===m.sourceDoc)||l.unresolvedPredicates.push(m)}else{let d=new P;d.namespace=c.namespace,d.name=c.name,d.sourceDoc=c.sourceDoc,c.sourceKey!==void 0&&(d.sourceKey=c.sourceKey);let m=new Set;for(let g of c.statement){let w=$(g);m.has(w)||(m.add(w),d.statement.push(g))}d.unresolvedPredicates=[...c.unresolvedPredicates],a.set(f,m),r.set(f,d),i.push(d)}}else i.push(c);let o=new Set;for(let c of i)if(c instanceof P){let f=c.namespace||"",l=f.indexOf("/"),d=l>=0?f.slice(0,l):"",m=l>=0?f.slice(l+1):"",g=m.indexOf("@"),w=g>=0?m.slice(0,g):m;o.add(`${d}/${w}/${c.name}`)}let s=c=>o.has(`${c.publisher}/${c.package_}/${c.name}`),p=new Map;for(let c of Z()){let f=await t.getDocumentsByNamespaceAsync(c.publisher,c.package_);p.set(c.package_,W(f).chosen?.metadata.namespace_?.version??void 0)}for(let c of n)c instanceof P&&this.canonicalizeStatementBuiltins(c.statement,s,p);return i}canonicalizeStatementBuiltins(n,t,r){for(let a of n){let i=a.predicate?.subject;if(E(i,t,r),a instanceof v)a.object instanceof k&&E(a.object.subject,t,r);else if(a instanceof R)a.object&&this.canonicalizeStatementBuiltins(a.object.statement,t,r);else if(a instanceof O)for(let o of a.object??[])o instanceof k?E(o.subject,t,r):o instanceof S&&this.canonicalizeStatementBuiltins(o.statement,t,r)}}resolveCanonicalEntity(n,t,r){if(!n.includes(".")||!t.metadata?.imports)return{namespace:r,name:n};let a=n.indexOf("."),i=n.substring(0,a),o=n.substring(a+1);for(let[s,p]of Object.entries(t.metadata.imports))for(let c of p)if((c.alias??c.packageName)===i){let l=c.version;return{namespace:`${s}/${c.packageName}@${l.major}.${l.minor}.${l.patch}`,name:o}}return{namespace:r,name:n}}async parseStatements(n,t,r,a,i){let o=[],s=[];if(typeof n!="object"||n===null||Array.isArray(n))return{statements:o,unresolved:s};let p=t.metadata.namespace_?.toString()??"";for(let[c,f]of Object.entries(n))try{let l=await this.getPropertyMetadata(c,t,r,i,a);if(!l){let m=c.includes(".")?c.slice(c.lastIndexOf(".")+1):c;Q(m)||s.push({key:c,sourceDoc:p});continue}let d=await this.parsePropertyValue(c,f,l,t,r,a,i);d&&(d instanceof q&&(d.sourceKey=c),o.push(d))}catch(l){throw new Error(`Failed to parse property '${c}': ${l.message}`,{cause:l})}return{statements:o,unresolved:s}}async getPropertyMetadata(n,t,r,a,i){let o=await r.resolveEntityAsync(n,t);if(!o)return;let s=o.entity,p=s.type?.toString()??"",c=p.includes(".")?p.substring(p.lastIndexOf(".")+1):p,f=new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]),l=this.knownPropertyClasses.get(x(o.uri));if(!f.has(c)&&!l)return;let d=l??i.getPropertyTypeClassification(p),m,g=async()=>{if(m)return m;if(!(o.isImported&&o.definedInNamespace))return m=t,t;if(typeof a.getDocumentAsync!="function")throw new Error(`Cannot resolve the range of imported property '${n}': the parse repository cannot fetch defining document '${o.definedInNamespace}'. Thread the real repository through to embedded-object parsing \u2014 no stub, no fallback.`);let D=await a.getDocumentAsync(o.definedInNamespace);if(!D)throw new Error(`Cannot resolve the range of imported property '${n}': defining document '${o.definedInNamespace}' was not found in the repository.`);return m=D,D},w=await this.readDefinitionSlot(s,ye,g,r),y=w==null?void 0:String(w),b;if(d==="ObjectProperty")b="ObjectProperty";else if(d==="DatatypeProperty")b="DatatypeProperty";else{let D=y&&y.includes(".")?y.substring(y.lastIndexOf(".")+1):y??"";(y?i.isKnownXsdDatatypeName(y):!1)||D==="Literal"?b="DatatypeProperty":b="ObjectProperty"}let z;return y&&(z=(await r.resolveEntityAsync(y,await g()))?.uri),{propertyUri:o.uri.toString(),propertyType:b,range:y,rangeUri:z,isImported:o.isImported,definedInNamespace:o.definedInNamespace}}async readDefinitionSlot(n,t,r,a){let i=Object.keys(n).filter(c=>ge(c)===t.name);if(i.length===0)return;let o=await r(),s=_(t.name),p=s!==void 0&&s.publisher===t.publisher&&s.package_===t.package_;for(let c of i){let f=await a.resolveEntityAsync(c,o);if(f){if(U(f.uri,t))return n[c];continue}if(!c.includes(".")&&p)return n[c]}}async parsePropertyValue(n,t,r,a,i,o,s){let p=r.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(p,t,r,a,i,o,s);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(p,t,r,a,i,o);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(p,t,r,a,i,o,s)}}async parseDatatypeValue(n,t,r,a,i,o){let s;if(typeof t=="string"){if(o.isSubstitutableDatatype(r.rangeUri))return await this.parseSubstitutableValue(n,t,a,i);s=t}else if(typeof t=="number"||typeof t=="boolean")s=String(t);else return;return this.typedScalarStatement(n,s,r)}typedScalarStatement(n,t,r){let a=k.parse(n),i=r.rangeUri?V(r.rangeUri):void 0;if(i===K.Boolean){let s=new T;return s.predicate=a,s.object=t==="true"||t==="1",s.carrier=i,s.lexical=t,s}if(i===K.Integer||i===K.Decimal||i===K.Double||i===K.Float){let s=new I;return s.predicate=a,s.object=Number(t),s.carrier=i,s.lexical=t,s}let o=M.parse(n,t);return i&&(o.carrier=i,o.lexical=t),o}typedListLiteral(n,t){let r=new L,a=t.rangeUri?V(t.rangeUri):void 0;return a===K.Boolean?r.value=n==="true"||n==="1":a===K.Integer||a===K.Decimal||a===K.Double||a===K.Float?r.value=Number(n):r.value=n,a&&(r.carrier=a,r.lexical=n),r}async parseSubstitutableValue(n,t,r,a){let i=new N;return i.predicate=k.parse(n),i.object=t,i.links=await this.resolveMarkdownLinks(t,r,a),i}async resolveMarkdownLinks(n,t,r){let a=[];for(let i of C(n)){let o=this.linkReference(i.reference,t);if(!o){let p=await r.resolveEntityAsync(i.reference,t);p&&(o=new k,o.subject=p.uri)}let s={reference:i.reference,startOffset:i.startOffset,endOffset:i.endOffset};i.displayText!==void 0&&(s.displayText=i.displayText),o!==void 0&&(s.target=o),a.push(s)}return a}async parseObjectValue(n,t,r,a,i,o,s){if(typeof t=="string"){if(r.rangeUri&&U(r.rangeUri,A.Expression)){let f=await this.expressionValue(t,r.rangeUri,a,i);if(f instanceof S){let d=new R;return d.predicate=k.parse(n),d.object=f,d}let l=new v;return l.predicate=k.parse(n),l.object=f,l}let p=await this.resolveReference(t,a,i);if(!p)return;let c=new v;return c.predicate=k.parse(n),c.object=p,c}if(typeof t=="object"&&!Array.isArray(t)){let p=await this.parseStatements(t,a,i,o,s);if(p.statements.length>0){let l=new S;l.statement=p.statements,l.unresolvedPredicates=p.unresolved,r.rangeUri&&(l.rangeType=r.rangeUri);let d=new R;return d.predicate=k.parse(n),d.object=l,d}let c=[];for(let[l,d]of Object.entries(t))if(typeof d=="object"&&d!==null&&!Array.isArray(d)){let m=new S;m.name=l,m.sourceKey=l,r.rangeUri&&(m.rangeType=r.rangeUri);let g=await this.parseStatements(d,a,i,o,s);m.statement=g.statements,m.unresolvedPredicates=g.unresolved,c.push(m)}else if(typeof d=="string"){let m=await this.resolveReference(d,a,i);m&&(m.sourceKey=l,c.push(m))}if(c.length>0){let l=new O;return l.predicate=k.parse(n),l.object=c,l}let f=new R;return f.predicate=k.parse(n),f.object=new S,r.rangeUri&&(f.object.rangeType=r.rangeUri),f}}expressionLiteral(n,t){let r=new S,a=new v,i=new k;i.subject=new j("kanonak.org","core-rdf","type"),a.predicate=i;let o=new k;o.subject=new j(t.publisher,t.package_,A.StringLiteral.name,t.version),a.object=o;let s=new M,p=new k;return p.subject=new j(t.publisher,t.package_,A.stringLiteral.name,t.version),s.predicate=p,s.object=n,r.statement=[a,s],r}async parseListValue(n,t,r,a,i,o,s){let p=[],c=r.propertyType==="DatatypeProperty",f=r.rangeUri?.publisher==="kanonak.org"&&r.rangeUri?.package_==="core-rdf"&&r.rangeUri?.name==="List"||!r.rangeUri&&(r.range?.includes(".")?r.range.substring(r.range.lastIndexOf(".")+1):r.range)==="List";for(let d=0;d<t.length;d++){let m=t[d],g=y=>{y.sourceKey=d,p.push(y)},w=typeof m=="string"||typeof m=="number"||typeof m=="boolean";if(c&&w){let y=typeof m=="string"?m:String(m),b=this.typedListLiteral(y,r);o.isSubstitutableDatatype(r.rangeUri)&&(b.links=await this.resolveMarkdownLinks(y,a,i)),g(b);continue}if(f&&w){if(typeof m=="string"){let y=await i.resolveEntityAsync(m,a);if(y){let b=new k;b.subject=y.uri,g(b)}else{let b=new L;b.value=m,g(b)}}else{let y=new L;y.value=m,g(y)}continue}if(typeof m=="string"){let y=await this.resolveReference(m,a,i);y&&g(y)}else if(typeof m=="object"&&m!==null&&!Array.isArray(m)){let y=new S;r.rangeUri&&(y.rangeType=r.rangeUri);let b=await this.parseStatements(m,a,i,o,s);y.statement=b.statements,y.unresolvedPredicates=b.unresolved,g(y)}}let l=new O;return l.predicate=k.parse(n),l.object=p,l}linkReference(n,t){let r=n.indexOf(".");if(r<=0||!t.metadata?.imports)return;let a=n.substring(0,r),i=n.substring(r+1);for(let[o,s]of Object.entries(t.metadata.imports))for(let p of s){if(!G(p)||(p.alias??p.packageName)!==a)continue;let c=new k,f=p.versionOperator===de.Exact?p.version:void 0;return c.subject=new j(o,p.packageName,i,f),c}}importedReference(n,t){let r=n.indexOf(".");if(r<=0||!t.metadata?.imports)return;let a=n.substring(0,r),i=n.substring(r+1);for(let[o,s]of Object.entries(t.metadata.imports))for(let p of s){if((p.alias??p.packageName)!==a)continue;let c=new k;return c.subject=new j(o,p.packageName,i,p.version),c}}async expressionValue(n,t,r,a){let i=this.linkReference(n,r);if(i)return i;let o=await a.resolveEntityAsync(n,r);if(o){let s=new k;return s.subject=o.uri,s}return this.importedReference(n,r)??this.expressionLiteral(n,t)}async resolveReference(n,t,r){let a=this.linkReference(n,t);if(a)return a;let i=await r.resolveEntityAsync(n,t);if(i){let s=new k;return s.subject=i.uri,s}let o=t.metadata?.namespace_;if(o){let s=this.importedReference(n,t);if(s)return s;let p=new k;return p.subject=new j(o.publisher,o.package_,n,o.version??void 0),p}return null}async saveKanonaks(n,t){let r=new Map;for(let a of n)a instanceof P&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,i]of r){let o=await this.convertKanonaksToDocument(a,i),s=`${a.split("@")[0]}.yml`;await t.saveDocumentAsync(o,s)}}async serializeToYaml(n,t){let r=n.filter(o=>o instanceof P&&o.namespace===t);if(r.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let a=await this.convertKanonaksToDocument(t,r);return new X().save(a)}async convertKanonaksToDocument(n,t){let a={metadata:{namespace_:n,get allImports(){if(!this.imports)return[];let o=[];for(let s of Object.values(this.imports))o.push(...s);return o}},body:{}},i=new Map;for(let o of t){let s={};for(let p of o.statement){let[c,f]=this.convertStatementToProperty(p);c&&f!==null&&f!==void 0&&(s[c]=f),this.collectImportsFromStatement(p,n,i)}a.body[o.name]=s}return a}convertStatementToProperty(n){if(n instanceof M)return[n.predicate.subject.name,n.object];if(n instanceof I)return[n.predicate.subject.name,n.object];if(n instanceof T)return[n.predicate.subject.name,n.object];if(n instanceof v)return[n.predicate.subject.name,n.object.subject.name];if(n instanceof O){let t=this.convertKanonakListToValue(n.object);return[n.predicate.subject.name,t]}else if(n instanceof R){let t=this.convertEmbeddedKanonakToValue(n.object);return[n.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(n){let t=[];for(let r of n)r instanceof k?t.push(r.subject.name):r instanceof S&&t.push(this.convertEmbeddedKanonakToValue(r));return t}convertEmbeddedKanonakToValue(n){let t={};for(let r of n.statement){let[a,i]=this.convertStatementToProperty(r);a&&i!==null&&i!==void 0&&(t[a]=i)}return t}collectImportsFromStatement(n,t,r){}};function F(u,n){u.sourceDoc=n;for(let t of u.statement)if(t instanceof R)F(t.object,n);else if(t instanceof O)for(let r of t.object)r instanceof S&&F(r,n)}function $(u){let n=u.predicate?.subject;return(n?`${n.publisher}/${n.package_}/${n.name}`:"?")+"="+ke(u)}function ke(u){return u instanceof N?"m:"+String(u.object):u instanceof M?"s:"+String(u.object):u instanceof I?"n:"+String(u.object):u instanceof T?"b:"+String(u.object):u instanceof v?"r:"+B(u.object):u instanceof R?"e:"+B(u.object):u instanceof O?"l:["+(u.object??[]).map(B).join("|")+"]":"x"}function B(u){if(!u)return"";if(u instanceof k){let n=u.subject;return"R("+(n?`${n.publisher}/${n.package_}/${n.name}`:"")+")"}return u instanceof S?"E("+(u.statement??[]).map($).join(";")+")":u instanceof L?"L("+String(u.value)+")":"N"}export{re as a,oe as b,pe as c,je as d,ve as e,A as f,K as g,V as h,Me as i,C as j,se as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as D}from"./chunk-F67UH4FD.js";import{b as y,e as u}from"./chunk-
|
|
1
|
+
import{b as D}from"./chunk-F67UH4FD.js";import{b as y,e as u}from"./chunk-7IMLHHSA.js";function h(t){let e=t.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}function k(t){let e=t.metadata?.namespace_;if(e)return e.version?`${e.publisher}/${e.package_}@${u(e.version)}`:`${e.publisher}/${e.package_}`}async function I(t,e,n={}){let o=new Set,r=new Set,c=[...t];for(;c.length>0;){let i=c.shift(),l=h(i),a=k(i);if(!l||!a||r.has(a))continue;r.add(a),o.add(l),n.onDocument?.(i);let p=i.metadata?.imports;if(p)for(let[g,v]of Object.entries(p))for(let s of v){if(D(s))continue;let m=null,d="no-compatible-version";try{m=await e.getHighestCompatibleVersionAsync(g,s)}catch{d="resolution-error"}m?c.push(m):n.onUnresolvedEdge?.({fromNamespace:a,publisher:g,packageName:s.packageName,constraint:`${y(s.versionOperator)}${u(s.version)}`,reason:d})}}return o}var f=class{constructor(e,n){this.inner=e;this.scope=n}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(n=>{let o=h(n),r=k(n);return o!==void 0&&(this.scope.has(o)||r!==void 0&&this.scope.has(r))})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,n){return this.inner.getDocumentsByNamespaceAsync(e,n)}getHighestCompatibleVersionAsync(e,n){return this.inner.getHighestCompatibleVersionAsync(e,n)}saveDocumentAsync(e,n){return this.inner.saveDocumentAsync(e,n)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,n){return this.inner.clearNamespaceAsync(e,n)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};export{I as a,f as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as f}from"./chunk-
|
|
1
|
+
import{p as f}from"./chunk-6USORWEP.js";import{b as u}from"./chunk-F67UH4FD.js";import{l as m}from"./chunk-7IMLHHSA.js";var R=class{resourceResolver;constructor(e){this.resourceResolver=e}async buildFromNameAsync(e,o){return(await this.resourceResolver.resolveEntityAsync(e,o))?.uri??null}buildFromName(e,o,t){if(e.includes(".")){let r=e.split("."),c=r[0],l=r[1],i=this.findPackageNameForAlias(t,c);if(i){for(let n of o.values())if(n.entityName===l&&n.uri.package_===i)return n.uri}return null}let a=o.get(e);return a?a.uri:null}create(e,o,t,a){return new m(e,o,t,a)}findPackageNameForAlias(e,o){if(!e.metadata.imports)return null;for(let[t,a]of Object.entries(e.metadata.imports))for(let r of a)if(r.alias===o||!r.alias&&r.packageName===o)return r.packageName;return null}};async function y(s,e,o){let t=e.metadata?.namespace_,a=!!t&&t.publisher===s.publisher&&t.package_===s.package_,r=[];for(let[i,n]of Object.entries(e.metadata?.imports??{}))if(i===s.publisher)for(let p of n)p.packageName!==s.package_||u(p)||r.push(`${p.alias??p.packageName}.${s.name}`);let c=a?[s.name,...r]:[...r,s.name],l=f(s);for(let i of c){let n=await o.resolveEntityAsync(i,e);if(n&&!n.isAmbiguous&&f(n.uri)===l)return i}}export{R as a,y as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as w,E as Q,c as G,d as X,p as S,q as Y,s as q,t as I,y as W,z as L}from"./chunk-6USORWEP.js";import{b as H}from"./chunk-F67UH4FD.js";import{l as x,m as B}from"./chunk-7IMLHHSA.js";var z=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let o=n.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(o);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(o,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let o=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],y=await this.findDocumentForAlias(n,a);return y?await this.resolveAllEntitiesAsync(i,y):[]}return o.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,o){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=o.length===0?a:`${o} \u2192 ${a}`;for(let[y,l]of Object.entries(e.body))if(!y.includes(".")&&l&&typeof l=="object"&&!Array.isArray(l)){if(!e.metadata.namespace_)continue;let g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:y,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,y,g),entity:l,definedInNamespace:a,isImported:o.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let y=Object.values(e.metadata.imports).reduce((l,g)=>l+g.length,0);this.logger?.debug?.(`Processing ${y} import(s) for ${a}`);for(let[l,g]of Object.entries(e.metadata.imports))for(let d of g)if(!H(d))try{this.logger?.debug?.(`Resolving import: ${l}/${d.packageName}`);let m=await this.repository.getHighestCompatibleVersionAsync(l,d);if(m){this.logger?.debug?.(`Successfully loaded import: ${m.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(m,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${m.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${l}/${d.packageName}`)}catch(m){let k=m;throw this.logger?.error?.(`Failed to process import ${l}/${d.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${l}/${d.packageName} for namespace ${a}. See inner exception for details.`,{cause:m})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,o,s){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let y=s.get(i);if(y)return y;n.add(i);let l=o.length===0?i:`${o} \u2192 ${i}`,g=0;for(let[d,m]of Object.entries(e.body))if(!d.includes(".")&&m&&typeof m=="object"&&!Array.isArray(m)){if(!e.metadata.namespace_)continue;if(!a.has(d)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(d,{entityName:d,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,k),entity:m,definedInNamespace:i,isImported:o.length>0,importPath:l}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((m,k)=>m+k.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${i}`);for(let[m,k]of Object.entries(e.metadata.imports))for(let b of k)if(!H(b))try{this.logger?.debug?.(`Resolving import: ${m}/${b.packageName}`);let h=await this.repository.getHighestCompatibleVersionAsync(m,b);if(h){this.logger?.debug?.(`Successfully loaded import: ${h.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(h,n,l,s),v=0;for(let[A,P]of U.entries()){if(A.includes("."))continue;let _=a.get(A);if(!_)a.set(A,P),v++;else if(_.isImported&&P.isImported&&(_.uri.publisher!==P.uri.publisher||_.uri.package_!==P.uri.package_)){let C=_.isAmbiguous?_:{..._,isAmbiguous:!0,ambiguousNamespaces:[_.definedInNamespace]};C.ambiguousNamespaces.includes(P.definedInNamespace)||C.ambiguousNamespaces.push(P.definedInNamespace),a.set(A,C),this.logger?.warn?.(`Ambiguous reference '${A}': defined in ${C.ambiguousNamespaces.join(", ")}`)}if(b.alias){let C=`${b.alias}.${A}`;a.has(C)||(a.set(C,P),v++)}}this.logger?.debug?.(`Merged ${v} entities from import ${h.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${m}/${b.packageName}`)}catch(h){let U=h;throw this.logger?.error?.(`Failed to process import ${m}/${b.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${m}/${b.packageName} for namespace ${i}. See inner exception for details.`,{cause:h})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[o,s]of Object.entries(e.metadata.imports))for(let a of s)if(!H(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(o,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(o,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var J=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let o=await this.resourceResolver.resolveEntityAsync(e,n);if(o){let s=o.entity.type;if(s){let a=String(s);return a==="Class"||a==="rdfs.Class"||a.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function He(t){return`${t.publisher}/${t.package_}/${t.name}`}function u(t,e,n){return`${t}/${e}/${n}`}function Ie(t){return`${t.s}|${t.p}|${ae(t.o)}`}function ae(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function De(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var se="kanonak.org",ie="core-shacl",r=t=>({publisher:se,package_:ie,name:t}),D=r("Shape"),N=r("NodeShape"),T=r("PropertyShape"),Te=r("targetClass"),je=r("property"),$e=r("path"),Me=r("minCount"),ve=r("maxCount"),Le=r("datatype"),we=r("class"),Ve=r("in"),Fe=r("pattern"),Be=r("flags"),Ge=r("minLength"),Xe=r("maxLength"),Ye=r("minInclusive"),qe=r("maxInclusive"),We=r("message"),Qe=r("targetNode"),ze=r("targetSubjectsOf"),Je=r("targetObjectsOf"),Ze=r("closed"),et=r("ignoredProperties"),tt=r("nodeKind"),nt=r("IRI"),rt=r("BlankNode"),ot=r("Literal"),at=r("severity"),st=r("Violation"),it=r("Warning"),pt=r("Info"),ct=r("ValidationReport"),lt=r("conforms"),ut=r("result"),yt=r("ValidationResult"),mt=r("focusNode"),dt=r("resultPath"),gt=r("resultMessage"),ft=r("resultSeverity"),kt=r("sourceShape"),St=r("value"),bt=r("sourceConstraintComponent"),_t=r("MinCountConstraintComponent"),ht=r("MaxCountConstraintComponent"),Pt=r("DatatypeConstraintComponent"),Ct=r("ClassConstraintComponent"),Kt=r("InConstraintComponent"),Et=r("PatternConstraintComponent"),At=r("MinLengthConstraintComponent"),xt=r("MaxLengthConstraintComponent"),Rt=r("MinInclusiveConstraintComponent"),Ot=r("MaxInclusiveConstraintComponent"),Ut=r("NodeKindConstraintComponent"),Ht=r("ClosedConstraintComponent"),It=r("hasValue"),Dt=r("qualifiedValueShape"),Nt=r("qualifiedMinCount"),Tt=r("qualifiedMaxCount"),jt=r("HasValueConstraintComponent"),$t=r("QualifiedMinCountConstraintComponent"),Mt=r("QualifiedMaxCountConstraintComponent"),vt=r("HasKeyConstraintComponent");var p="kanonak.org",c="core-rdf",f="core-owl",ee="core-kanonak",pe={publisher:p,package_:f,name:"hasKey"},$=new Map([["type",c],["subClassOf",c],["subPropertyOf",c],["domain",c],["range",c],["label",c],["comment",c],["seeAlso",c],["isDefinedBy",c],["member",c],["Resource",c],["Class",c],["Property",c],["Datatype",c],["Literal",c],["List",c],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",ee]]),ce=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function Ft(t){return $.has(t)}function le(t){let e=$.get(t);return e?{publisher:p,package_:e}:void 0}function Bt(){return[...new Set($.values())].map(t=>({publisher:p,package_:t}))}function Gt(t){let e=le(t);if(!e)throw new Error(`builtinUri: '${t}' is not a reserved built-in term.`);return{...e,name:t}}function V(t,e,n){if(!t||!t.name)return;let o=$.get(t.name);if(!o)return;let s=()=>{t.publisher=p,t.package_=o,n&&(t.version=n.get(o))};if(ce.has(t.name)){let a=t.publisher===p&&t.package_===o;t.publisher=p,t.package_=o,!a&&n&&(t.version=n.get(o));return}t.publisher===p&&t.package_===o||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var Z=class{type=u(p,c,"type");subClassOf=u(p,c,"subClassOf");subPropertyOf=u(p,c,"subPropertyOf");domain=u(p,c,"domain");range=u(p,c,"range");label=u(p,c,"label");comment=u(p,c,"comment");resource=u(p,c,"Resource");class_=u(p,c,"Class");datatype=u(p,c,"Datatype");literal=u(p,c,"Literal");equivalentClass=u(p,f,"equivalentClass");equivalentProperty=u(p,f,"equivalentProperty");inverseOf=u(p,f,"inverseOf");sameAs=u(p,f,"sameAs");transitiveProperty=u(p,f,"TransitiveProperty");symmetricProperty=u(p,f,"SymmetricProperty");objectProperty=u(p,f,"ObjectProperty");datatypeProperty=u(p,f,"DatatypeProperty");annotationProperty=u(p,f,"AnnotationProperty");hasKey=j(pe);package_=u(p,ee,"Package");shape=j(D);nodeShape=j(N);propertyShape=j(T)};function j(t){return u(t.publisher,t.package_,t.name)}var ue=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ne(t)[0]??null}function ne(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?q(t).map(n=>{let o={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(o),{publisher:o.publisher,package_:o.package_,name:o.name}}):[]}var ye=[D,N,T];function O(t,e){return ue.has(`${t}/${e}`)}var me=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return me.has(t.name)?t.name:void 0}var te=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ne(e).some(o=>O(o.publisher,o.package_)&&o.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ye.some(o=>Y(n,o)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let o=R(e);return o?n.has(o.name):!1}};var K="kanonak.org",E="core-rdf",de={publisher:K,package_:E,name:"domain"},ge={publisher:K,package_:E,name:"range"},fe={publisher:K,package_:E,name:"subClassOf"},ke={publisher:K,package_:E,name:"type"},Se={publisher:K,package_:E,name:"label"},be={publisher:K,package_:E,name:"comment"},_e=new x(K,E,"Resource");function he(t){try{let e=B(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function oe(t,e){let n=[],o=new Set,s="version"in e?e.version:void 0,a=[new x(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),y=S(i);if(o.has(y))continue;o.add(y),n.push(i);let l=Pe(t,i);l&&a.push(...I(l,fe))}return n}function Pe(t,e){return e.version&&typeof e.version.major=="number"?W(t,e)??L(t,e)[0]:L(t,e)[0]}function M(t,e){let n;for(let o of Ae(e)){let s=Ce(t,o);if(s){if(s!=="Property")return s;n??=s}}return n}function Ce(t,e){let n=F(e);if(n)return n;let o=re.get(t);o||(o=new Map,re.set(t,o));let s=e.version,a=s&&typeof s.major=="number"?`${S(e)}@${s.major}.${s.minor}.${s.patch}`:S(e),i=o.get(a);if(i!==void 0)return i??void 0;let y;for(let l of oe(t,e)){let g=F(l);if(g){if(g!=="Property"){y=g;break}y??="Property"}}return o.set(a,y??null),y}var re=new WeakMap;function on(t,e){return M(t,e)!==void 0}function an(t,e){return M(t,e)==="ObjectProperty"}function sn(t,e){return M(t,e)==="DatatypeProperty"}function Ke(t,e){let n=new Set([S(_e)]);for(let o of oe(t,e))n.add(S(o));return n}function Ee(t,e){let n=Ke(t,e),o=[],s=new Set;for(let a of t){if(!(a instanceof G))continue;let i=M(t,a);if(!i)continue;let y=I(a,de);if(!y.some(d=>n.has(S(d))))continue;let l=he(a);if(!l)continue;let g=S(l);s.has(g)||(s.add(g),o.push({uri:l,label:w(a,Se),comment:w(a,be),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:Q(a,ge),domains:y}))}return o}function pn(t,e,n){let o=Ee(t,e).find(s=>S(s.uri)===S(n));return o?{ok:!0,descriptor:o}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Ae(t){let e=I(t,ke);return e.length>0?e:t instanceof X&&t.rangeType?[t.rangeType]:[]}export{z as a,J as b,He as c,u as d,Ie as e,ae as f,De as g,se as h,ie as i,D as j,N as k,T as l,Te as m,je as n,$e as o,Me as p,ve as q,Le as r,we as s,Ve as t,Fe as u,Be as v,Ge as w,Xe as x,Ye as y,qe as z,We as A,Qe as B,ze as C,Je as D,Ze as E,et as F,tt as G,nt as H,rt as I,ot as J,at as K,st as L,it as M,pt as N,_t as O,ht as P,Pt as Q,Ct as R,Kt as S,Et as T,At as U,xt as V,Rt as W,Ot as X,Ut as Y,Ht as Z,It as _,Dt as $,Nt as aa,Tt as ba,jt as ca,$t as da,Mt as ea,vt as fa,pe as ga,Ft as ha,le as ia,Bt as ja,Gt as ka,V as la,Z as ma,F as na,te as oa,he as pa,oe as qa,M as ra,on as sa,an as ta,sn as ua,Ee as va,pn as wa,Ae as xa};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-SC5M74NM.js";import{b as l,d as A,e as p}from"./chunk-5FVUBF7N.js";import{a as E}from"./chunk-
|
|
1
|
+
import{a as m}from"./chunk-SC5M74NM.js";import{b as l,d as A,e as p}from"./chunk-5FVUBF7N.js";import{a as E}from"./chunk-6CI3HTKF.js";import{e as f,g as R,j as C,m as x}from"./chunk-7IMLHHSA.js";var j="@kanonak-protocol/sdk (+https://kanonak.org)",F=j;function ee(o){F=o}function te(){return F}function g(o){let e;try{e=typeof o=="string"?new URL(o):o}catch{throw new Error(`Kanonak requires an absolute https:// URL \u2014 got an unparseable or relative URL: ${String(o)}`)}if(e.protocol!=="https:")throw new Error(`Kanonak requires HTTPS \u2014 refusing to fetch ${e.href} (only https:// is supported).`)}var M=new Set([429,502,503,504]),B=4,q=500,_=2e4;function h(o,e){g(o);let t=new Headers(e?.headers);return t.has("User-Agent")||t.set("User-Agent",F),W(o,{...e,headers:t})}var d=B;function ne(o){d=Math.max(0,o)}async function W(o,e){let t;for(let r=0;r<=d;r++){let n;try{n=await fetch(o,e)}catch(a){if(t=a,r>=d)throw a;await b(T(r,void 0));continue}if(!M.has(n.status)||r>=d)return n;let s=A(n.headers.get("retry-after"));if(s!==void 0&&s*1e3>_)return n;await b(T(r,s))}throw t??new Error("kanonakFetch: exhausted retries")}function T(o,e){if(e!==void 0)return e*1e3;let t=Math.min(_,q*2**o);return Math.floor(t/2+Math.random()*(t/2))}function b(o){return new Promise(e=>setTimeout(e,o))}var k="*",P=["publisher","package","version"];function D(o,e,t){let r=t?` in ${t}`:"";if(typeof o!="object"||o===null||Array.isArray(o))throw new Error(`${e}${r} must be an object mapping a publisher, or "${k}", to a package URL template`);let n={};for(let[s,a]of Object.entries(o)){let i=s===k;if(!i&&!V(s))throw new Error(`${e}${r} names "${s}", which is not a publisher (a publisher is a bare domain, e.g. example.org)`);n[s]=N(a,`${e}["${s}"]${r}`,i)}return Object.freeze(n)}function N(o,e,t){if(typeof o!="string"||o.trim()==="")throw new Error(`${e} must be a package URL template string`);if(!o.startsWith("https://"))throw new Error(`${e} must be an absolute https:// URL template (got "${o}")`);let r=(o.match(/\{[^{}]*\}/g)??[]).filter(a=>!P.includes(a.slice(1,-1)));if(r.length>0)throw new Error(`${e} has the unknown placeholder ${r[0]}; a package URL template takes {publisher}, {package} and {version}`);let s=(t?P:P.filter(a=>a!=="publisher")).filter(a=>!o.includes(`{${a}}`)).map(a=>`{${a}}`);if(s.length>0)throw new Error(`${e} must contain ${s.join(", ")}`+(t?", so that one template addresses every publisher's packages":"")+` (got "${o}")`);return o}function U(o,e){if(o)return Object.hasOwn(o,e)?o[e]:Object.hasOwn(o,k)?o[k]:void 0}function u(o,e,t,r){let n={publisher:e,package:t,version:r},s=o;for(let[i,c]of Object.entries(n))s=s.replaceAll(`{${i}}`,c);let a=s.match(/\{[a-z]+\}/);if(a)throw new Error(`Unresolved variable ${a[0]} in URL template: ${o}`);return g(s),s}function V(o){if(o.trim()!==o)return!1;try{let e=x(o);return e.kind==="publisher"&&e.publisher===o}catch{return!1}}var G="https://{publisher}/{package}/{version}.kan.yml",I={version:1};function he(){return{version:1}}var y=class{constructor(e){this.fetchFn=e}fetchFn;cache=new Map;getConfig(e){let t=this.cache.get(e);return t||(t=this.fetchConfig(e),this.cache.set(e,t),t.catch(()=>{this.cache.get(e)===t&&this.cache.delete(e)})),t}async fetchConfig(e){let t=`https://${e}/.well-known/kanonak.json`,r;try{r=await(this.fetchFn?this.fetchFn(t,e):h(t))}catch(a){if(a instanceof p)throw a;return I}if(r.status===404)return I;if(!r.ok)throw await l("publisher config",t,r);let n=await r.json();if(typeof n.version!="number")throw new Error(`Invalid publisher config at ${t}: missing or invalid "version" field`);let s={version:n.version};return typeof n.package_url_template=="string"&&(z(t,"package_url_template",n.package_url_template),s.package_url_template=n.package_url_template),Array.isArray(n.featured_packages)&&n.featured_packages.every(a=>typeof a=="string")&&(s.featured_packages=n.featured_packages),s}resolvePackageUrl(e,t,r,n){let s=n.package_url_template??G;return u(s,e,t,r)}};function z(o,e,t){if(!t.startsWith("https://"))throw new Error(`Invalid publisher config at ${o}: ${e} must be an absolute https:// URL template (got "${t}").`)}import K from"js-yaml";function pe(o,e,t){return o.packages[`${e}/${t}`]?.version}var Y=`# This file is generated by Kanonak CLI. Do not edit manually.
|
|
2
2
|
`,X="sha256:";function O(o){let e=K.load(o);return!e||typeof e!="object"||e.version!=="1"?null:{version:"1",lastUpdated:e.lastUpdated??"",packages:e.packages??{}}}function me(o){let e={};for(let r of Object.keys(o.packages).sort())e[r]=o.packages[r];let t=K.dump({...o,packages:e},{lineWidth:-1,sortKeys:!1,quotingType:'"'});return Y+t}async function J(o){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(o)),t=Array.from(new Uint8Array(e),r=>r.toString(16).padStart(2,"0")).join("");return`${X}${t}`}async function S(o,e,t,r){let n=await J(e);if(n!==t)throw new Error(`Integrity mismatch for ${o}: the lock declares ${t||"(no integrity)"} but the bytes from ${r} hash to ${n}.`)}var w=class{configResolver;fetchFn;packageUrlTemplates;lockCache=new Map;packageLockCache=new Map;constructor(e){this.configResolver=e?.configResolver??new y(e?.fetchFn),this.fetchFn=e?.fetchFn,this.packageUrlTemplates=e?.packageUrlTemplates?D(e.packageUrlTemplates,"packageUrlTemplates"):void 0}getConfig(e){return this.configResolver.getConfig(e)}async getPackageUrl(e,t,r){let n=U(this.packageUrlTemplates,e);if(n)return u(n,e,t,r);let s=await this.configResolver.getConfig(e);return this.configResolver.resolvePackageUrl(e,t,r,s)}lockedSourceUrl(e,t,r){let n=U(this.packageUrlTemplates,e);return n?u(n,e,t,r.version):r.resolved}async fetchLockedSource(e,t,r){let n=`${e}/${t}@${r.version}`,s=this.lockedSourceUrl(e,t,r);g(s);let a=this.fetchFn?await this.fetchFn(s,e):await h(s);if(!a.ok)throw await l(n,s,a);let i=await a.text();return await S(n,i,r.integrity,s),{url:s,content:i}}getLock(e){let t=this.lockCache.get(e);return t||(t=this.fetchLock(e),this.lockCache.set(e,t),t.catch(()=>{this.lockCache.get(e)===t&&this.lockCache.delete(e)})),t}async getPackageLockEntry(e,t){let r=`${e}/${t}`,n=this.packageLockCache.get(r);return n||(n=this.fetchLock(e,t),this.packageLockCache.set(r,n),n.catch(()=>{this.packageLockCache.get(r)===n&&this.packageLockCache.delete(r)})),(await n)?.packages[r]??null}async fetchLock(e,t){let r=t?`https://${e}/${t}/kanonak.lock`:`https://${e}/kanonak.lock`,n;try{n=this.fetchFn?await this.fetchFn(r,e):await h(r)}catch(s){if(s instanceof p)throw s;return null}if(n.status===404)return null;if(!n.ok)throw await l("publisher lock",r,n);return O(await n.text())}};import{VersionOperator as $}from"@kanonak-protocol/types/document/models/enums";function Q(o,e){let t=R(o);return t?C(t,e):!1}var H=class{parser=new E;publisherIndex;documents=new Map;contentCache=new Map;fetchFn;onFetch;getFromCache;constructor(e){this.onFetch=e?.onFetch,this.getFromCache=e?.getFromCache,this.fetchFn=e?.fetchFn,this.publisherIndex=new w({...e?.fetchFn?{fetchFn:e.fetchFn}:{},...e?.packageUrlTemplates?{packageUrlTemplates:e.packageUrlTemplates}:{}})}async getHighestCompatibleVersionAsync(e,t){if(t.versionOperator===$.Exact){let s=await this.fromMemoOrCache(e,t.packageName,f(t.version));if(s)return s}let n=(await this.publisherIndex.getLock(e))?.packages[`${e}/${t.packageName}`]??await this.publisherIndex.getPackageLockEntry(e,t.packageName)??void 0;return n&&Q(n.version,t)?this.fetchPinned(e,t.packageName,n):n&&t.versionOperator!==$.Exact?null:this.resolveByDirectFetch(e,t)}async fetchPinned(e,t,r){let n=r.version,s=`${e}/${t}@${n}`,a=await this.fromMemoOrCache(e,t,n);if(a)return a;let{content:i}=await this.publisherIndex.fetchLockedSource(e,t,r),c=this.parser.parse(i);return m(c,e,t,n),this.onFetch&&await this.onFetch(e,t,n,i),this.documents.set(s,c),this.contentCache.set(s,i),c}async fromMemoOrCache(e,t,r){let n=`${e}/${t}@${r}`,s=this.documents.get(n);if(s)return s;if(!this.getFromCache)return null;let a=await this.getFromCache(e,t,r);if(a==null)return null;let i;try{i=this.parser.parse(a),m(i,e,t,r)}catch(c){throw new Error(`Cached content for ${n} is not a usable copy of that package \u2014 refusing to fall through to a fetch that would hide it. ${c.message}`,{cause:c})}return this.documents.set(n,i),this.contentCache.set(n,a),i}async resolveByDirectFetch(e,t){let r=t.packageName,s=t.versionOperator===$.Exact?await this.publisherIndex.getPackageUrl(e,r,f(t.version)):`https://${e}/${r}.kan.yml`,a=await this.fetchFollowing(s,e);if(!a)return null;let i=this.parser.parse(a.content),c=i.metadata.namespace_;if(!c||!c.version)throw new Error(`Producer origin returned a package with no namespace/version for ${e}/${r}`);let v=f(c.version);m(i,e,r,v);let L=`${e}/${r}@${v}`;return this.onFetch&&await this.onFetch(e,r,v,a.content),this.documents.set(L,i),this.contentCache.set(L,a.content),i}async fetchFollowing(e,t,r=4){let n=e;for(let s=0;s<r;s++){g(n);let a=this.fetchFn?await this.fetchFn(n,t):await h(n,{redirect:"manual"});if(a.status===301||a.status===302){let i=a.headers.get("location");if(!i)throw new Error(`Redirect with no Location header from ${n}`);n=new URL(i,n).toString();continue}if(a.status===404)return null;if(!a.ok)throw await l("Kanonak package",n,a);return{url:n,content:await a.text()}}throw new Error(`Too many redirects resolving ${e}`)}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(e){return this.documents.get(e)??null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.documents.values()).filter(r=>{let n=r.metadata.namespace_;return n&&n.publisher===e&&n.package_===t})}async saveDocumentAsync(e,t){throw new Error("HttpKanonakDocumentRepository is read-only")}async deleteDocumentAsync(e){throw new Error("HttpKanonakDocumentRepository is read-only")}async clearNamespaceAsync(e,t){throw new Error("HttpKanonakDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.contentCache.get(e)??null}async getDocumentUriAsync(e){let t=e.match(/^(.+?)\/(.+?)@(.+)$/);if(!t)return null;let[,r,n,s]=t;return this.publisherIndex.getPackageUrl(r,n,s)}};export{j as a,ee as b,te as c,g as d,h as e,ne as f,k as g,D as h,N as i,U as j,u as k,he as l,y as m,pe as n,X as o,O as p,me as q,J as r,S as s,w as t,H as u};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as zt,b as Xt,c as Yt,d as Qt,e as z}from"./chunk-
|
|
1
|
+
import{a as zt,b as Xt,c as Yt,d as Qt,e as z}from"./chunk-FKLZDYWF.js";import{a as to,b as ro,c as ao}from"./chunk-3ABGZHKM.js";import{a as qt,b as Bt,c as Gt,d as sa,e as ca,f as da,g as ua,h as la,i as pa,j as Ze,k as fa,l as en,m as nn,n as ma,o as ha,p as Sa,q as ve,r as ga,s as on}from"./chunk-PXUSA72Q.js";import{a as ka}from"./chunk-FYAZ345F.js";import{a as oa,b as ta,c as ra,d as ne,e as aa,f as ia,g as Je,h as ya,i as Ea,j as Ca,k as ba,l as _a}from"./chunk-IT37WOHT.js";import{a as Wo,b as qo,c as Bo,d as Go,e as zo,f as mt,g as ht,h as St,i as gt}from"./chunk-F4UHQVGA.js";import{a as Zo,b as et,c as nt,d as ot,e as tt,f as rt,g as Me,h as Ue,i as $e,j as ct,k as dt,m as ut,n as Sn,o as gn,p as kn,q as yn,r as En,s as Cn,t as lt,u as ft}from"./chunk-X2URIXH7.js";import{a as Zt,b as er,c as nr,d as or,e as tr,f as rr}from"./chunk-2GV6GXRF.js";import{a as ar,b as sr}from"./chunk-TR7PC72M.js";import{a as pt}from"./chunk-SC5M74NM.js";import{A as xr,B as Ir,C as Lr,D as Mr,E as Ur,F as $r,G as Vr,H as Hr,I as Xr,J as Yr,K as Qr,L as Jr,M as Zr,N as ea,O as na,a as cr,b as dr,c as ur,d as lr,e as pr,f as Jn,g as Zn,h as fr,i as mr,j as hr,k as Sr,l as gr,m as kr,n as yr,o as Er,p as Cr,q as br,r as _r,s as Pr,t as Rr,u as vr,v as wr,w as Kr,x as Or,y as Nr,z as Ar}from"./chunk-FCRP7KXR.js";import{a as Yn,b as Qn}from"./chunk-QRF7AT2M.js";import{c as eo,d as jr,e as Tr,f as Dr,g as Fr,i as Wr,j as qr,m as Br,o as Qe,q as no,s as oo,u as Gr,v as zr}from"./chunk-AZFLKLPB.js";import"./chunk-QHABFCRC.js";import{a as Xo,b as Yo,c as Qo,d as Jo,e as L}from"./chunk-5FVUBF7N.js";import{a as Le}from"./chunk-NYCGUDVW.js";import{a as Xe,g as T,h as Ye,i as Ft,j as Wt,k as U}from"./chunk-Q2ZUKZEU.js";import{a as X}from"./chunk-6CI3HTKF.js";import{a as ir}from"./chunk-PEJALHXK.js";import{$ as Re,A as Un,B as $n,C as Vn,D as Hn,E as jn,F as Tn,G as Dn,H as Fn,I as Wn,J as qn,K as De,L as Bn,M as Gn,N as zn,O as me,P as he,Q as Se,R as ge,S as ke,T as ye,U as Ee,V as Ce,W as be,X as _e,Y as Pe,Z,_ as Xn,a as Nt,aa as Fe,b as At,ba as We,c as Q,ca as W,d as It,da as H,e as Lt,ea as j,fa as q,g as Mt,ga as qe,h as le,i as pe,j as _n,ja as Ut,k as J,ka as $t,l as fe,m as Pn,ma as Vt,n as Rn,o as je,oa as Ht,p as vn,pa as E,q as wn,qa as Ge,r as Kn,ra as jt,s as On,sa as ze,t as Te,u as Nn,v as An,va as Tt,w as xn,wa as Dt,x as In,xa as G,y as Ln,z as Mn}from"./chunk-TVMOJ2QS.js";import{B as F,C as A,D as ue,E as k,F as Y,G as He,H as ee,I as B,K as Be,a as kt,b as yt,c as g,d as M,e as O,f as Et,g as Ct,h as bt,i as _t,j as Pt,k as Rt,l as vt,m as wt,n as Kt,o as Ot,p,s as xt,t as D,u as Ve,v as bn,w as de,y as N}from"./chunk-6USORWEP.js";import"./chunk-F67UH4FD.js";import{a as Mo,b as Uo,c as ce,d as $o,e as V,f as Vo,g as Ho,h as jo,i as To,j as Do,k as Fo,l as at,m as it,n as st}from"./chunk-7IMLHHSA.js";import{a as Jt}from"./chunk-ODIECDN7.js";async function io(n){let e=await new U().parseKanonaks(n);return{kind:"merged",catalog:e,reasoning:new z().reasonOver(e)}}async function so(n,e){let t=new Set(n.map(oe)),o=new Set,a=[];if(await Yn(n,e,{onDocument:l=>o.add(oe(l)),onUnresolvedEdge:l=>a.push(l)}),a.length>0){let l=a.map(h=>`${h.fromNamespace} imports ${h.publisher}/${h.packageName} ${h.constraint} (${h.reason})`);throw new Error(`Cannot build the conformance scope: ${a.length} import(s) did not resolve:
|
|
2
2
|
${l.join(`
|
|
3
3
|
`)}`)}let r=new Qn(e,o),d=new Set((await r.getAllDocumentsAsync()).map(oe)),i=[...t].filter(l=>!d.has(l));if(i.length>0)throw new Error(`scopeFromClosureAsync: ${i.join(", ")} is not a document of the repository the closure is resolved through.`);let c={},u=await new U().parseKanonaks(r,c),s=c.authored.filter(l=>l instanceof g&&t.has(l.sourceDoc)),f=new Set(s.map(B)),m=await Pa(n,s,e);return{kind:"merged",catalog:u,reasoning:new z().reasonOver(u),focus:f,links:m}}async function Pa(n,e,t){let o=[],a=new Map,r=new Map;for(let d of n){let i=oe(d),c=e.filter(u=>u.sourceDoc===i);for(let{key:u,references:s,target:f,failure:m}of await Jn(d,c,t)){let l=f?oe(f):void 0;if(r.has(u)&&r.get(u)!==l)throw new Error(`scopeFromClosureAsync: the seeds link ${u} at different versions (${r.get(u)??"unresolved"} and ${l??"unresolved"}); judge them in separate scopes.`);r.has(u)||(r.set(u,l),f&&o.push(...await new U().parseKanonaks(new Be(f,t))));for(let{uri:h}of s)f?Zn(f,h.name)||a.set(p(h),`${l} defines no resource named '${h.name}'`):a.set(p(h),`its package ${u} could not be resolved${m?` (${m})`:""}`)}}return r.size>0?{subjects:o,unresolved:a}:void 0}function oe(n){let e=n.metadata?.namespace_;if(!e)throw new Error("scopeFromClosureAsync: a document has no namespace, so it cannot be identified.");return e.toString()}function co(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function uo(n,e){let t=e??new Le(new X);return{kind:"standalone",catalog:await new U().parseKanonaks(new Be(n,t))}}function $(n){return typeof n=="number"?n:void 0}function Ra(n){if(!n)return;let e=p(n);if(e===p(Fn))return"IRI";if(e===p(Wn))return"BlankNode";if(e===p(qn))return"Literal"}function po(n){if(!n)return;let e=p(n);if(e===p(Bn))return"Violation";if(e===p(Gn))return"Warning";if(e===p(zn))return"Info"}function fo(n,e,t,o){let a=k(e,je);if(!a)return;let r={path:a},d=$(A(e,vn)),i=$(A(e,wn));d!==void 0&&(r.minCount=d),i!==void 0&&(r.maxCount=i);let c=$(A(e,xn)),u=$(A(e,In));c!==void 0&&(r.minLength=c),u!==void 0&&(r.maxLength=u);let s=$(A(e,Ln)),f=$(A(e,Mn));s!==void 0&&(r.minInclusive=s),f!==void 0&&(r.maxInclusive=f);let m=ue(e,Nn);if(m!==void 0){let S=ue(e,An);r.pattern=S!==void 0?{regex:m,flags:S}:{regex:m}}if(F(e,Te)){let S=[],K=[];for(let{item:C}of Ve(e,Te))"literal"in C?S.push(C.value):C instanceof O&&K.push(C.subject);S.length>0&&(r.inValues=S),K.length>0&&(r.inRefs=K)}let l=k(e,Kn);l&&(r.datatype=l);let h=k(e,On);h&&(r.classRef=h);let y=Ra(k(e,Dn));y&&(r.nodeKind=y);let R=k(e,Xn);if(R&&(r.hasValue=R),F(e,Re)||F(e,Fe)||F(e,We)){let S={},K=$(A(e,Fe)),C=$(A(e,We));K!==void 0&&(S.minCount=K),C!==void 0&&(S.maxCount=C);let x=va(n,e,o);"problem"in x?S.problem=x.problem:S.shape=x.shape,r.qualified=S}let v=ue(e,Un);v!==void 0&&(r.message=v);let w=po(k(e,De))??t;return w&&(r.severity=w),r}function va(n,e,t){let o=Y(e,Re);if(o)return lo(n,o,void 0,t);let a=k(e,Re);if(!a)return{problem:"sh:qualifiedValueShape is missing"};let r=p(a);if(t.has(r))return{problem:`sh:qualifiedValueShape '${a.name}' leads back to itself (a cycle through named shapes)`};let d=N(n,a);return d?lo(n,d,r,t):{problem:`sh:qualifiedValueShape '${a.name}' does not resolve`}}function lo(n,e,t,o){let a=t?new Set([...o,t]):o,r=de(e,J);if((de(e,fe)||F(e,je))&&!r){let c=fo(n,e,void 0,a);return c?{shape:{kind:"property",constraint:c}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof g&&!r?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:mo(n,e,a)}}}function mo(n,e,t){let o=po(k(e,De)),a={name:e instanceof g?e.name:"(inline shape)",uri:e instanceof g?E(e):void 0,targetClass:k(e,Pn),targetNodes:D(e,$n),targetSubjectsOf:D(e,Vn),targetObjectsOf:D(e,Hn),closed:A(e,jn)===!0,ignoredProperties:[],severity:o,properties:[]};a.ignoredProperties.push(...D(e,Tn));for(let{item:r}of Ve(e,Rn)){let d;if(r instanceof M?d=r:r instanceof O&&(d=N(n,r.subject)),!d)continue;let i=fo(n,d,o,t);i&&a.properties.push(i)}return a}function we(n){let e=[];for(let t of n){if(!(t instanceof g)||!de(t,J))continue;let o=E(t);e.push(mo(n,t,new Set(o?[p(o)]:[])))}return e}function Ke(n){let e=new Map;for(let t of n)if(t instanceof g)for(let o of bn(t,qe)){let a=E(t);if(!a)throw new Error(`owl.hasKey on '${t.namespace}/${t.name}': the class has no resolvable URI.`);if(o.length===0)throw new Error(`owl.hasKey on '${t.name}' lists no properties; a key needs at least one.`);let r=o.map(({item:d})=>{let i=d instanceof O?N(n,d.subject):void 0;if(!i||!ze(n,i)){let c=d instanceof O?`'${p(d.subject)}'`:"a value that is not a reference";throw new Error(`owl.hasKey on '${t.name}' lists ${c}, which is not a property defined in scope; a key lists properties.`)}return d.subject});e.set(`${p(a)}|${r.map(p).join(",")}`,{classUri:a,className:t.name,properties:r})}return[...e.values()]}var _="kanonak.org/transformations",te="values";var Oe="allowed",rn="expected",b=n=>({type:`${_}/VarRef`,varName:n}),tn=n=>({type:`${_}/IntegerLiteral`,integerLiteral:n}),wa=n=>({type:`${_}/DecimalLiteral`,decimalLiteral:n}),ho=n=>Number.isInteger(n)?tn(n):wa(n),So=n=>({type:`${_}/Count`,source:n}),go=(n,e)=>({type:`${_}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),ko=(n,e)=>({type:`${_}/LessThanOrEqual`,compareLeft:n,compareRight:e});function an(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(r=>!t.has(r)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function Ne(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:go(So(b(te)),tn(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:ko(So(b(te)),tn(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${_}/Contains`,haystack:b(te),needle:b(rn)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${_}/Contains`,haystack:b(Oe),needle:b("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:an(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:go(b("v"),ho(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:ko(b("v"),ho(n.maxInclusive))}),e}import{evaluate as Oa,ExpressionError as Na}from"@kanonak-protocol/expression";function Co(n,e){let t=yo(e)?e:we(e),o=[],a=n.catalog.filter(c=>c instanceof g).map(Ae),r=new Map;Aa(a,r);let d=n.links?[...n.catalog,...n.links.subjects]:n.catalog,i={scope:n,membership:new cn(n),values:d,embeddedFocus:r};for(let c of t)for(let u of xa(i,c,a))sn(n,u)&&_o(i,c,u,o);if(!yo(e))for(let c of Ke(e))Ia(i,c,a,o);return{conforms:!o.some(c=>c.severity==="Violation"),results:o}}function yo(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function bo(n){let e=n.predicate;return e instanceof O?e:void 0}function sn(n,e){return!n.focus||e.subject!==void 0&&n.focus.has(e.subject)}function Ae(n){let e=B(n);return{node:n,key:e,uri:E(n),subject:e,label:n.name}}function un(n,e,t){return{node:n,key:e,subject:t,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Aa(n,e){for(let t of n)Xe([t.node],({kanonak:o,address:a})=>{o instanceof M&&!e.has(o)&&e.set(o,un(o,a,t.subject))})}var cn=class{constructor(e){this.scope=e}scope;ancestors=new Map;defined;defines(e){return this.defined??=new Set(this.scope.catalog.filter(t=>t instanceof g).map(B)),this.defined.has(p(e))}isInstance(e,t){let o=p(t);return e.some(a=>p(a)===o||this.ancestorsOf(a).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${p(e)}@${V(e.version)}`:p(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ge(this.scope.catalog,e).map(a=>p(a))),this.ancestors.set(t,o)),o}};function xa(n,e,t){let{scope:o}=n,a=new Map,r=i=>{a.set(i.key,i)},d=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let i=e.targetClass;for(let c of d())n.membership.isInstance(G(c.node),i)&&r(c)}for(let i of e.targetNodes){let c=N(o.catalog,i);c instanceof g&&r(Ae(c))}for(let i of e.targetSubjectsOf){let c=p(i);for(let u of d())u.node.statement.some(s=>{let f=bo(s);return f&&p(f.subject)===c})&&r(u)}for(let i of e.targetObjectsOf)for(let c of d())for(let u of ee(c.node,i,o.catalog,c.key))u.kind==="subject"?r(Ae(u.node)):u.kind==="embedded"&&r(n.embeddedFocus.get(u.node)??un(u.node,u.address,c.subject));return[...a.values()]}function Ia(n,e,t,o){let a=new Map;for(let c of t)n.membership.isInstance(G(c.node),e.classUri)&&a.set(c.key,c);let r=[];for(let c of[...a.values()].sort((u,s)=>u.key<s.key?-1:u.key>s.key?1:0)){let u=e.properties.map(s=>La(n,c,s));u.every(s=>s.size>0)&&r.push({focus:c,values:u})}let d=new Map;r.forEach(({values:c},u)=>{for(let s of c[0].keys()){let f=d.get(s);f?f.push(u):d.set(s,[u])}});let i=new Set;for(let c of d.values())for(let u=0;u<c.length;u++)for(let s=u+1;s<c.length;s++){let f=`${c[u]}:${c[s]}`;if(i.has(f))continue;let m=r[c[u]],l=r[c[s]],h=m.values.map((w,S)=>[...w.keys()].find(K=>l.values[S].has(K)));if(h.some(w=>w===void 0))continue;i.add(f);let[y,R]=sn(n.scope,m.focus)?[m.focus,l.focus]:sn(n.scope,l.focus)?[l.focus,m.focus]:[void 0,void 0];if(!y||!R)continue;let v=e.properties.map((w,S)=>`${w.name} = ${m.values[S].get(h[S])}`).join(", ");o.push({focusNode:y.key,focusUri:y.uri,valueRef:R.uri,constraintComponent:q,severity:"Violation",message:`'${y.label}' and '${R.label}' are distinct instances of ${e.className} with the same key (${v}); its owl.hasKey makes the key unique.`})}}function La(n,e,t){let o=new Map;for(let a of ee(e.node,t,n.scope.catalog,e.key))switch(a.kind){case"subject":case"unresolved":o.set(`ref:${p(a.uri)}`,a.uri.name);break;case"literal":o.set(`${typeof a.value}:${String(a.value)}`,JSON.stringify(a.value));break;case"embedded":break}return o}function Ma(n,e,t){return e.node?ee(e.node,t,n.values,e.key).map(o=>Ua(n,o,e.subject)):[]}function Ua(n,e,t){switch(e.kind){case"subject":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let o=n.embeddedFocus.get(e.node)??un(e.node,e.address,t);return{kernel:{ref:o.key},kind:"embedded",embedded:o}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function _o(n,e,t,o){for(let a of e.properties)Ro(n,e,t,a,o);e.closed&&Ga(e,t,o)}function dn(n,e,t,o,a={},r){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:r??Po(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function Po(n){return n.severity??"Violation"}var $a={minCount:me,maxCount:he,hasValue:W,in:ke,pattern:ye,minLength:Ee,maxLength:Ce,minInclusive:be,maxInclusive:_e};function Ro(n,e,t,o,a){let r=Ma(n,t,o.path),d=o.severity??Po(e),i=o.path.name,c=[...(o.inValues??[]).map(s=>typeof s=="boolean"?s?1:0:s),...(o.inRefs??[]).map(s=>({ref:p(s)}))],u=(s,f,m)=>{let l=dn(e,t,s,o.message??f,{resultPath:o.path,value:m?.literal,valueRef:m?.ref},d);return a.push(l),l};for(let s of Ne(o)){let f=$a[s.component];if(s.per==="node"){let m={[te]:r.map(l=>l.kernel),[Oe]:c};o.hasValue&&(m[rn]={ref:p(o.hasValue)}),Eo(s,m)||u(f,Va(s,i,o,r.length));continue}for(let m of r){if((s.component==="pattern"||s.component==="minLength"||s.component==="maxLength")&&m.kind!=="string"){u(f,`'${i}' value is not a string; ${s.component} applies to string values.`,m);continue}Eo(s,{v:m.kernel,[Oe]:c})||u(f,Fa(s,i,o,m),m)}}if(o.nodeKind)for(let s of r)Wa(o.nodeKind,s)||u(Pe,`'${i}' value is ${s.kind}; nodeKind requires ${o.nodeKind}.`,s);if(o.datatype)for(let s of r){let f=qa(o.datatype,s);f&&u(Se,`'${i}' ${f}`,s)}if(o.classRef)for(let s of r){let f=Ba(n,o.classRef,s);f&&u(ge,`'${i}' ${f}`,s)}o.qualified&&Ha(n,o,r,i,u)}function Va(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?p(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Ha(n,e,t,o,a){let r=e.qualified,d=r.maxCount!==void 0?j:H,i=(u,s)=>{vo.add(a(d,u,s))};if(!r.shape){i(`'${o}' qualified value shape cannot be evaluated: ${r.problem??"it could not be built"}.`);return}let c=0;for(let u of t){let s=u.ref?p(u.ref):u.embedded?u.embedded.label:JSON.stringify(u.literal),f=ja(n,u);if(!f){i(`'${o}' value ${s} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,u);continue}let m=Da(n,r.shape,f);if(m.kind==="undecided"){i(`'${o}' value ${s}: whether it conforms to the qualified shape cannot be decided \u2014 ${m.reason}`,u);continue}m.kind==="conforms"&&c++}r.minCount!==void 0&&c<r.minCount&&a(H,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMinCount is ${r.minCount}.`),r.maxCount!==void 0&&c>r.maxCount&&a(j,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMaxCount is ${r.maxCount}.`)}function ja(n,e){switch(e.kind){case"reference":return e.subject?Ae(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Ta={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},vo=new WeakSet;function Da(n,e,t){let o=[];e.kind==="property"?Ro(n,Ta,t,e.constraint,o):_o(n,e.shape,t,o);let a=o.find(r=>vo.has(r));return a?{kind:"undecided",reason:a.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Fa(n,e,t,o){let a=o.ref?p(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${a} is not in the permitted set.`;case"pattern":return`'${e}' value ${a} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${a} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${a} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${a} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${a} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${a} violates ${n.component}.`}}function Eo(n,e){let t=o=>{let a=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof a=="string"&&a in e)return e[a];throw new Na(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Oa(n.expr,void 0,t)===1}function Wa(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function qa(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ye(n);if(t!==void 0)switch(t){case T.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case T.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case T.Decimal:case T.Double:case T.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Ba(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let d=G(t.embedded.node);return d.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(d,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let o=t.subject;if(!o){let d=n.scope.links?.unresolved.get(p(t.ref));return d?`value ${p(t.ref)} is a link that does not dereference: ${d} (sh:class ${e.name}).`:`value ${p(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}let a=G(o);if(n.membership.isInstance(a,e))return;let r=a.filter(d=>!n.membership.defines(d));return r.length>0?`value ${p(t.ref)} is typed ${r.map(p).join(", ")}, which this scope does not define, so it cannot be shown to be an instance of ${e.name}. A class is in scope when the judged document imports the package that defines it.`:`value ${p(t.ref)} is not an instance of ${e.name}.`}function Ga(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(r=>p(r.path)),...n.ignoredProperties.map(r=>p(r))]),a=new Set;for(let r of e.node.statement){let d=bo(r);if(!d)continue;let i=p(d.subject);o.has(i)||a.has(i)||(a.add(i),t.push(dn(n,e,Z,`'${e.label}' carries undeclared property '${d.subject.name}' (closed shape).`,{resultPath:d.subject})))}for(let r of e.node.unresolvedPredicates)a.has(r.key)||(a.add(r.key),t.push(dn(n,e,Z,`'${e.label}' carries unresolvable property '${r.key}' (closed shape).`,{value:r.key})))}var za="1.1.0",Xa=new Set([W,H,j].map(n=>n.name)),Ya=new Set([q].map(n=>n.name));function Qa(n){let e=new Set(n.results.map(t=>t.constraintComponent.name));return[...e].some(t=>Ya.has(t))?"1.3.0":[...e].some(t=>Xa.has(t))?"1.2.0":za}async function wo(n){let e=new ne(n.repository),t=e.imports(),o=t.ensure(le,pe,Qa(n.result),"sh"),a=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:c,r={},d=[];return n.result.results.forEach((i,c)=>{let u=`result-${c+1}`;d.push(u);let s={type:`${o}.ValidationResult`,[`${o}.focusNode`]:a(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(s[`${o}.resultPath`]=a(i.resultPath,p(i.resultPath))),i.sourceShapeUri&&i.sourceShape!==void 0&&(s[`${o}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?s[`${o}.value`]=a(i.valueRef,p(i.valueRef)):i.value!==void 0&&(s[`${o}.value`]=i.value),r[u]=s}),r.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:n.result.conforms,...d.length>0?{[`${o}.result`]:d}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:r,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as tc}from"@kanonak-protocol/types/document/models/enums";import{spawn as Ja}from"child_process";var Oo=12e4,Za=4096,re=class{argv;interactive;timeoutMs;stderr;now;constructor(e){this.argv=No(e.command),this.interactive=e.interactive??!1,this.timeoutMs=e.timeoutMs??Oo,this.stderr=e.stderr??process.stderr,this.now=e.nowSeconds??(()=>Date.now()/1e3)}get command(){return this.argv.join(" ")}async get(e){let t=await this.run("get",this.wireRequest("get",e)),o=en(e,t,this.now());if(!o.ok)throw new L(`credential helper '${this.command}' answered get for ${e.resource} outside the protocol (${o.problem}): ${o.message}`);return o.answer}async erase(e){let t=await this.run("erase",{...this.wireRequest("erase",e),scope:e.scope}),o=nn(t);if(!o.ok)throw new L(`credential helper '${this.command}' answered erase for ${e.resource} outside the protocol (${o.problem}): ${o.message}`)}wireRequest(e,t){let o={version:Ze,operation:e,resource:t.resource,method:t.method};return t.challenges&&(o.challenges=t.challenges),o.interactive=this.interactive,o}run(e,t){let o=`credential helper '${this.command}' ${e}`;return new Promise((a,r)=>{let d=!1,i=l=>{d||(d=!0,l())},c;try{c=Ja(this.argv[0],[...this.argv.slice(1),e],{stdio:["pipe","pipe","pipe"],shell:!1,windowsHide:!0})}catch(l){r(Ko(o,l));return}let u=[],s="",f=!1,m=setTimeout(()=>{f=!0,c.kill()},this.timeoutMs);c.stdout.on("data",l=>u.push(l)),c.stderr.on("data",l=>{this.stderr.write(l),s=(s+l.toString("utf8")).slice(-Za)}),c.on("error",l=>{clearTimeout(m),i(()=>r(Ko(o,l)))}),c.on("close",(l,h)=>{clearTimeout(m);let y=s.trim()?`: ${s.trim()}`:"";if(f){i(()=>r(new L(`${o} did not finish within ${Math.round(this.timeoutMs/1e3)}s${y}`)));return}if(l!==0){let v=l!==null?`exit ${l}`:`signal ${h}`;i(()=>r(new L(`${o} failed (${v})${y}`)));return}let R=Buffer.concat(u).toString("utf8").trim();try{let v=JSON.parse(R);i(()=>a(v))}catch{i(()=>r(new L(`${o} exited 0 without printing one JSON answer${y}`)))}}),c.stdin.on("error",()=>{}),c.stdin.end(`${JSON.stringify(t)}
|
|
4
4
|
`)})}};function No(n){let e=n.trim().split(/\s+/).filter(t=>t!=="");if(e.length===0)throw new Error("the credential helper command is empty");return e}function Ko(n,e){let t=e.code,o="";return t==="ENOENT"&&(o=" (not found: give its path, or put it on PATH)"),t==="EINVAL"&&process.platform==="win32"&&(o=" (a .cmd or .bat file cannot run without a shell: configure an executable, e.g. `node path/to/helper.js`)"),new L(`${n} could not be started: ${e.message}${o}`)}import{existsSync as ei,readFileSync as ni}from"fs";import{homedir as oi}from"os";import{join as ti}from"path";function ae(){return ti(oi(),".kanonak","config.json")}function ie(n){if(!ei(n))return;let e;try{e=JSON.parse(ni(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must hold a JSON object`);return e}var ln="KANONAK_CREDENTIAL_HELPER";function ri(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ai(e,t);if(o){let r=Object.keys(e).filter(d=>(d===ve||d.startsWith(`${ve}_`))&&(e[d]??"").trim()!=="").sort();if(r.length>0)throw new Error(`A credential helper is configured (${o.source}: ${o.command}) and so is ${r.join(", ")}. Configure one or the other.`);return new re({command:o.command,interactive:n.interactive??!1})}let a={env:e};return n.discovery&&(a.discovery=n.discovery),new on(a)}function ai(n,e){let t=(n[ln]??"").trim();if(t)return{command:t,source:ln};let o=ie(e)?.credentialHelper;if(o!==void 0){if(typeof o!="string"||o.trim()==="")throw new Error(`"credentialHelper" in ${e} must be a non-empty command line`);return{command:o.trim(),source:e}}}var pn="KANONAK_PACKAGE_URL_TEMPLATE";function ii(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ie(t)?.packageUrlTemplates,a=o===void 0?{}:{...Ue(o,"packageUrlTemplates",t)},r=(e[pn]??"").trim();return r&&(a[Me]=$e(r,pn,!0)),Object.keys(a).length>0?Object.freeze(a):void 0}var P="kanonak.org",I="view",Ao="core-kanonak",si={publisher:P,package_:I,name:"rootView"},ci={publisher:P,package_:I,name:"bind"},di={publisher:P,package_:I,name:"produces"},ui={publisher:P,package_:I,name:"projections"},li={publisher:P,package_:I,name:"where"},pi={publisher:P,package_:I,name:"value"},fi={publisher:P,package_:I,name:"as"},xe=class{constructor(e,t=new X){this.repository=e;this.parser=t;this.objectParser=new U(this.parser),this.builder=new ne(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),a=this.resolveView(o,e),r=k(a,ci);if(!r)throw new Error(`View ${a.namespace}/${a.name} declares no view.bind; cannot materialize.`);let d=k(a,di);if(!d)throw new Error(`View ${a.namespace}/${a.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 i=mi(a),c=xo(o,P,Ao),u=xo(o,P,I),s=this.builder.imports(),f=s.ensure(P,Ao,c,"ck"),m=s.ensure(P,I,u,"v"),l=s.ref(d),h=new oo(this.repository,this.parser,this.objectParser),y=new no(h,o),R=this.readProjections(o,a),v=gi(a,li),w=this.findInstances(o,r,await this.reason(t)),S={},K=new Set;for(let se of w){if(!await this.passesWhere(y,o,v,se))continue;let Ie={type:l};for(let mn of R){let Lo=await this.evaluateValue(y,o,mn.value,se),hn=this.builder.serializeValue(Io(Lo),s);hn!==void 0&&(Ie[s.ref(mn.as)]=hn)}let fn=E(se);fn&&(Ie[`${m}.derivedFrom`]=s.ref(fn)),S[this.rowName(se,K)]=Ie}let C={};t.resolvedAt&&(C[`${f}.resolvedAt`]=t.resolvedAt),t.invocationId&&(C[`${f}.id`]=t.invocationId);let x=await this.builder.buildContentAddressed({publisher:i,book:s,body:S,contentHashProperty:`${f}.contentHash`,header:C});return{yaml:x.yaml,contentHash:x.contentHash,packageName:x.packageName,publisher:x.publisher,rowCount:x.resourceCount}}resolveView(e,t){let o=N(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let a=k(o,si);if(a){let r=N(e,a);if(!r)throw new Error(`ViewPackage ${t.name} names rootView ${a.name}, which is not in the catalog.`);return r}return o}readProjections(e,t){let o=[];for(let a of He(t,ui)){let r=a instanceof M?a:a instanceof O?N(e,a.subject):void 0;if(!r)continue;let d=Y(r,pi),i=k(r,fi);d&&i&&o.push({value:d,as:i})}return o}async reason(e){return new z({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let a=Si(e),r=[],d=new Set;for(let i of o.getInstancesOfClass(t)){if(d.has(i))continue;d.add(i);let c=a.get(i);c&&r.push(c)}return r.sort((i,c)=>{let u=Q(E(i)),s=Q(E(c));return u<s?-1:u>s?1:0}),r}async passesWhere(e,t,o,a){for(let r of o){let d=await this.evaluateValue(e,t,r,a);if(!ki(d))return!1}return!0}async evaluateValue(e,t,o,a){let r=eo(o,"view-projection",{catalog:t,depth:0}),d=new Map([["input",a]]);return e.evaluate(r,d)}rowName(e,t){let o=Je(e.name)||"row",a=o,r=2;for(;t.has(a);)a=`${o}-${r++}`;return t.add(a),a}};function Io(n){return Qe(n)?n.value:Array.isArray(n)?n.map(Io):n}function mi(n){let e=E(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function xo(n,e,t){let o=hi(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function hi(n,e,t){let o;for(let a of n){if(!(a instanceof g))continue;let r=E(a);!r||r.publisher!==e||r.package_!==t||!r.version||(!o||ce(r.version,o)>0)&&(o=r.version)}return o?V(o):void 0}function Si(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof g))continue;let a=E(o);if(!a||!a.version)continue;let r=Q(a),d=t.get(r);(!d||ce(a.version,d)>0)&&(t.set(r,a.version),e.set(r,o))}return e}function gi(n,e){let t=Y(n,e);return t?[t]:He(n,e).filter(o=>o instanceof M)}function ki(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Qe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Me as ANY_PUBLISHER,Or as AmbiguousReferenceRule,Rt as BooleanStatement,ra as CANONICAL_FORM_VERSION,ha as CREDENTIAL_EXPIRY_SKEW_SECONDS,ln as CREDENTIAL_HELPER_ENV,Ze as CREDENTIAL_HELPER_PROTOCOL_VERSION,Oo as CREDENTIAL_HELPER_TIMEOUT_MS,T as Carrier,Mr as ClassDefinitionRule,br as ClassHierarchyCycleRule,Bo as CompositeKanonakDocumentRepository,L as CredentialError,la as DEFAULT_CONSENT_BINDING_PARAM,yt as DefinedKanonak,ea as DiamondNameClashRule,$r as DisplayLensScopeRule,qo as DocumentLocation,Bt as EdgeType,M as EmbeddedKanonak,yr as EmbeddedKanonakTypeRule,wt as EmbeddedStatement,ba as EntitlementDeniedError,_a as EntitlementProducer,re as ExecCredentialProvider,Wo as FileSystemKanonakDocumentRepository,Jt as GitIgnoreFilter,Gt as GraphBuilder,ft as HttpKanonakDocumentRepository,gn as INTEGRITY_PREFIX,ia as ImportBook,Er as ImportExistenceRule,Le as InMemoryKanonakDocumentRepository,Zo as KANONAK_USER_AGENT,kt as Kanonak,er as KanonakDocumentPositions,Xo as KanonakHttpError,U as KanonakObjectParser,na as KanonakObjectValidator,X as KanonakParser,at as KanonakUri,ar as KanonakUriBuilder,ir as KanonakUrlResolver,Vt as KanonakVocabulary,Fr as LINE_STYLES,fr as LinkTargetRule,Kt as ListStatement,Et as LiteralKanonak,mt as LocalFirstRepository,ht as LockAwareRepository,Yr as LookBandPathRule,Gr as LookRenderer,Vr as LookSemanticSvgPathRule,Ur as MarkdownLinkRule,Ot as MarkdownStatement,wr as NamespaceImportCycleRule,mr as NamespacePrefixRule,qt as NodeType,Pt as NumberStatement,pa as OAuthDiscovery,qe as OWL_HAS_KEY,Yt as OWL_RL_CLASSIFICATION_RULES,Ar as ObjectPropertyValueValidationRule,ur as OntologyValidationError,cr as OntologyValidationResult,Zr as OwlOneOfRule,pn as PACKAGE_URL_TEMPLATE_ENV,ne as PackageBuilder,kr as PackageHeaderRule,ya as ProducerRepository,xr as PropertyDomainRule,_r as PropertyHierarchyCycleRule,Ir as PropertyKindRangeConsistencyRule,Zt as PropertyMetadata,Nr as PropertyRangeReferenceRule,Pr as PropertyRangeRequiredRule,Sr as PropertyTypeSpecificityRule,ut as PublisherConfigResolver,lt as PublisherIndex,Xt as RDFS_RULES,z as Reasoner,Qt as ReasoningResult,O as ReferenceKanonak,vt as ReferenceStatement,zo as RepositoryFactory,Lr as ReservedNameShadowRule,hr as ResourceNamingRule,Nt as ResourceResolver,Ht as ResourceTypeClassifier,pe as SHACL_PACKAGE,le as SHACL_PUBLISHER,ge as SH_COMP_CLASS,Z as SH_COMP_CLOSED,Se as SH_COMP_DATATYPE,q as SH_COMP_HAS_KEY,W as SH_COMP_HAS_VALUE,ke as SH_COMP_IN,he as SH_COMP_MAX_COUNT,_e as SH_COMP_MAX_INCLUSIVE,Ce as SH_COMP_MAX_LENGTH,me as SH_COMP_MIN_COUNT,be as SH_COMP_MIN_INCLUSIVE,Ee as SH_COMP_MIN_LENGTH,Pe as SH_COMP_NODE_KIND,ye as SH_COMP_PATTERN,j as SH_COMP_QUALIFIED_MAX_COUNT,H as SH_COMP_QUALIFIED_MIN_COUNT,J as SH_NODE_SHAPE,fe as SH_PROPERTY_SHAPE,_n as SH_SHAPE,bt as ScalarStatement,Xr as SequenceNarrativeRule,Jr as ShaclShapeRule,Ct as Statement,_t as StringStatement,Rr as SubClassOfReferenceRule,vr as SubPropertyOfReferenceRule,g as SubjectKanonak,gr as SubjectKanonakTypeRequiredRule,ve as TOKEN_ENV,on as TokenCredentialProvider,zt as TripleStore,Hr as TxExpressionCompilesRule,Qr as TxExpressionPathRule,At as TypeResolver,jr as URI_DISPLAY_LABEL,Tr as URI_DISPLAY_SUMMARY,Kr as UnresolvedPredicateRule,Cr as UnresolvedReferenceRule,pr as ValidationCache,lr as ValidationContext,dr as ValidationSeverity,tc as VersionOperator,xe as ViewMaterializer,Ea as allowAllPolicy,ot as assertHttpsUrl,Cn as assertIntegrityAsync,pt as assertPackageIdentity,Ke as buildKeysModel,gt as buildLocalFirstRepository,Br as buildOntologyModel,wo as buildReportPackageAsync,we as buildShapesModel,Ut as builtinHomePackages,$t as builtinUri,oa as canonicalForm,ta as canonicalHash,Ye as carrierOf,fa as checkCredentialAnswer,en as checkHelperAnswer,nn as checkHelperEraseAnswer,$e as checkPackageUrlTemplate,Ue as checkPackageUrlTemplates,St as collectKanonakFiles,ce as compareVersions,ao as computeIntegrity,En as computeIntegrityAsync,aa as contentAddressedName,G as contextTypesOf,Sa as createCredentialedFetch,Vo as createVersion,ri as credentialProviderFromConfig,Qo as describeResponse,Co as evaluateConformance,Wt as extractMarkdownLinks,dt as fillPackageUrlTemplate,ka as findDerivation,Ft as findMalformedReferences,or as findMarkdownLinkAt,an as foldFlagsIntoPattern,st as formatKanonakAddress,V as formatVersion,Go as getGlobalCachePath,nt as getKanonakUserAgent,Yo as httpError,jo as isCompatibleVersion,To as isMajorCompatible,ze as isPropertySubject,tt as kanonakFetch,to as loadLockFile,Sn as lockedVersion,Ne as lowerConstraint,It as makeUriKey,ua as narrowestScope,Ca as noopMeter,sa as normalizeHost,ct as packageUrlTemplateFor,ii as packageUrlTemplatesFromConfig,it as parseKanonakAddress,kn as parseLockFile,ca as parseScope,Ho as parseVersionString,nr as parseWithPositions,ma as parseWwwAuthenticate,Fo as pickHighestDocument,Tt as propertiesInScope,jt as propertyClassOf,Wr as readSequenceConnectors,ie as readUserConfig,sr as referenceSpelling,D as referenceUris,Dr as resolveDisplayValue,Dt as resolvePropertyStep,Jo as retryAfterSecondsOf,Je as sanitizeName,Do as satisfiesVersionOperator,ro as saveLockFile,da as scopeContains,co as scopeFromCatalog,so as scopeFromClosureAsync,uo as scopeFromDocumentAsync,io as scopeFromRepositoryAsync,yn as serializeLockFile,rt as setKanonakFetchRetries,et as setKanonakUserAgent,rr as sourceSymbolAt,tr as sourceSymbols,No as splitCommandLine,B as subjectAddress,E as subjectUri,Ge as superClassChain,zr as supportedBandKeys,ga as tokenEnvKeyFor,Lt as tripleKey,xt as typeReferenceUris,Q as uriKey,Mt as uriTriple,ae as userConfigPath,ee as valuesOf,Mo as versionOperatorFromChar,Uo as versionOperatorToChar,$o as versionsEqual,Xe as walkDefinedKanonaks,qr as walkSequence};
|
|
@@ -122,7 +122,7 @@ export declare class KanonakObjectParser implements IKanonakObjectParser {
|
|
|
122
122
|
private parseObjectValue;
|
|
123
123
|
/**
|
|
124
124
|
* Build the embedded `tx.StringLiteral` that a `tx.Expression`-ranged object
|
|
125
|
-
* property's string
|
|
125
|
+
* property's literal string coerces to: `{ type: tx.StringLiteral,
|
|
126
126
|
* tx.stringLiteral: <value> }`. The `tx` URIs are stamped from the resolved
|
|
127
127
|
* range's coordinates (publisher/package/version) so they match the
|
|
128
128
|
* transformations version the property's range resolved to; the `type`
|
|
@@ -130,7 +130,7 @@ export declare class KanonakObjectParser implements IKanonakObjectParser {
|
|
|
130
130
|
* every other built-in. Downstream (`TransformationLoaderV3`, `LookRenderer`)
|
|
131
131
|
* already reads this exact shape via `hasType(emb, TX_V3.StringLiteral)`.
|
|
132
132
|
*/
|
|
133
|
-
private
|
|
133
|
+
private expressionLiteral;
|
|
134
134
|
private parseListValue;
|
|
135
135
|
/**
|
|
136
136
|
* Resolve a bare name or aliased reference to a full ReferenceKanonak.
|
|
@@ -146,6 +146,26 @@ export declare class KanonakObjectParser implements IKanonakObjectParser {
|
|
|
146
146
|
* validate time. Returns undefined when the reference is not a link.
|
|
147
147
|
*/
|
|
148
148
|
private linkReference;
|
|
149
|
+
/**
|
|
150
|
+
* An `alias.name` reference whose alias names one of the document's imports,
|
|
151
|
+
* built from the import declaration when the name did not resolve through
|
|
152
|
+
* it (e.g. `rdfs.Clas`). It stays a reference, so validation reports the
|
|
153
|
+
* name the import does not define. Returns undefined when the reference is
|
|
154
|
+
* not qualified by a declared alias.
|
|
155
|
+
*/
|
|
156
|
+
private importedReference;
|
|
157
|
+
/**
|
|
158
|
+
* A single string value under a `tx.Expression`-ranged object property
|
|
159
|
+
* (typescript#140). A name in scope, through an import or a link, is a
|
|
160
|
+
* reference to it, as the same name is in a list: a named expression is
|
|
161
|
+
* the same fact however it is used (#124). So is a name qualified by a
|
|
162
|
+
* declared alias that does not resolve, which validation then reports.
|
|
163
|
+
* Any other string is an expression LITERAL, an embedded `tx.StringLiteral`
|
|
164
|
+
* (#65), since a single expression slot carries template text, never a
|
|
165
|
+
* reference fabricated to a name that does not exist. (A list item that
|
|
166
|
+
* names nothing is a reference, which validation reports as unresolved.)
|
|
167
|
+
*/
|
|
168
|
+
private expressionValue;
|
|
149
169
|
private resolveReference;
|
|
150
170
|
saveKanonaks(kanonaks: Kanonak[], documentRepository: IKanonakDocumentRepository): Promise<void>;
|
|
151
171
|
serializeToYaml(kanonaks: Kanonak[], namespaceString: string): Promise<string>;
|
package/dist/parsing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f,e as g,f as h}from"../chunk-
|
|
1
|
+
import{a as c,b as d,c as e,d as f,e as g,f as h}from"../chunk-2GV6GXRF.js";import{k as b}from"../chunk-Q2ZUKZEU.js";import{a}from"../chunk-6CI3HTKF.js";import"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions,h as sourceSymbolAt,g as sourceSymbols};
|
package/dist/producer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-
|
|
1
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"../chunk-IT37WOHT.js";import"../chunk-QHABFCRC.js";import"../chunk-Q2ZUKZEU.js";import"../chunk-6CI3HTKF.js";import"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{h as EntitlementDeniedError,i as EntitlementProducer,c as ImportBook,a as PackageBuilder,e as ProducerRepository,f as allowAllPolicy,b as contentAddressedName,g as noopMeter,d as sanitizeName};
|
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,b as k,c as l,d as m,e as n}from"../chunk-
|
|
1
|
+
import{a as j,b as k,c as l,d as m,e as n}from"../chunk-FKLZDYWF.js";import"../chunk-Q2ZUKZEU.js";import"../chunk-6CI3HTKF.js";import{c as a,d as b,e as c,g as d,ga as e,ja as f,ka as g,la as h,ma as i}from"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{i as KanonakVocabulary,e as OWL_HAS_KEY,l as OWL_RL_CLASSIFICATION_RULES,k as RDFS_RULES,n as Reasoner,m as ReasoningResult,j as TripleStore,f as builtinHomePackages,g as builtinUri,h as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e,t as r,u as n}from"../chunk-
|
|
1
|
+
import{m as e,t as r,u as n}from"../chunk-X2URIXH7.js";import"../chunk-SC5M74NM.js";import"../chunk-5FVUBF7N.js";import{a as o}from"../chunk-NYCGUDVW.js";import"../chunk-6CI3HTKF.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f,f as p,g as q,h as r,i as s}from"../chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as p,g as q,h as r,i as s}from"../chunk-F4UHQVGA.js";import{g,h,i,j,k,l,m,t as n,u as o}from"../chunk-X2URIXH7.js";import"../chunk-SC5M74NM.js";import"../chunk-5FVUBF7N.js";import{a}from"../chunk-NYCGUDVW.js";import"../chunk-6CI3HTKF.js";import"../chunk-F67UH4FD.js";import"../chunk-7IMLHHSA.js";export{g as ANY_PUBLISHER,d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,o as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,p as LocalFirstRepository,q as LockAwareRepository,m as PublisherConfigResolver,n as PublisherIndex,f as RepositoryFactory,s as buildLocalFirstRepository,i as checkPackageUrlTemplate,h as checkPackageUrlTemplates,r as collectKanonakFiles,l as defaultPublisherConfig,k as fillPackageUrlTemplate,e as getGlobalCachePath,j as packageUrlTemplateFor};
|
package/dist/resolution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F,b as H}from"../chunk-
|
|
1
|
+
import{a as F,b as H}from"../chunk-TR7PC72M.js";import{a as r}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as s,b as t,na as u,oa as v,pa as w,qa as x,ra as y,sa as z,ta as A,ua as B,va as C,wa as D,xa as E}from"../chunk-TVMOJ2QS.js";import"../chunk-6USORWEP.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k,l as o,m as p,n as q}from"../chunk-7IMLHHSA.js";export{l as IMPORT_MODES,o as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,s as ResourceResolver,v as ResourceTypeClassifier,t as TypeResolver,r as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,q as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,p as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,H as referenceSpelling,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-TR7PC72M.js";import"../chunk-SC5M74NM.js";import{f as g}from"../chunk-AZFLKLPB.js";import"../chunk-QHABFCRC.js";import"../chunk-NYCGUDVW.js";import"../chunk-Q2ZUKZEU.js";import"../chunk-6CI3HTKF.js";import"../chunk-PEJALHXK.js";import{pa as m,xa as S}from"../chunk-TVMOJ2QS.js";import{c as v,p,y as E}from"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-7IMLHHSA.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
|
|
2
2
|
Install it with:
|
|
3
3
|
npm install @huggingface/transformers
|
|
4
4
|
(underlying import error: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as xe}from"../chunk-BDTJIUS4.js";import{a as ye,d as J,f as Se,h as Z}from"../chunk-K76UUREI.js";import{l as $e,t as X,u as Q}from"../chunk-Z2444SWM.js";import"../chunk-LIN5SG5I.js";import"../chunk-SC5M74NM.js";import{a as O,b as W}from"../chunk-VJUZKHQU.js";import{u as te}from"../chunk-CPENAANM.js";import"../chunk-QHABFCRC.js";import"../chunk-5FVUBF7N.js";import{a as fe}from"../chunk-WXXZOJ4O.js";import{k as re}from"../chunk-SBWD7EOG.js";import{a as B}from"../chunk-5ZRVFYCP.js";import{a as Re}from"../chunk-PEJALHXK.js";import"../chunk-6WOPXTIL.js";import{c as we,z as ee}from"../chunk-LK5SHY4B.js";import"../chunk-F67UH4FD.js";import{c as V,e as j,f as L,g as Y,l as ve}from"../chunk-GGK6A6QK.js";import{a as be}from"../chunk-FUUTGGJS.js";import{readFileSync as le,writeFileSync as Ie,mkdirSync as Fe}from"fs";import{join as ne}from"path";import Me from"js-yaml";var Pe=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(r){return Pe}function C(r){return`${r.publisher}/${r.package_}`}function H(r,e=[]){let i={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},t=[];for(let o of r)if(o.origin==="missing"){let a=C(o),u=i[a]??"whatever this package contributes to rendering is lost";t.push(`Render-stack package ${a} is MISSING (${o.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${o.publisher}.`)}else o.resolvedButNotInCatalog&&t.push(`Render-stack package ${C(o)} resolved (${o.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let o of e)t.push(`Import edge ${o.fromNamespace} \u2192 ${o.publisher}/${o.packageName} ${o.constraint} did NOT resolve (${o.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${o.fromNamespace} authors against ${o.publisher}/${o.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${o.constraint}-compatible version of ${o.publisher}/${o.packageName} to the workspace or cache (kanonak install ${o.publisher}/${o.packageName}), or bump the import in ${o.fromNamespace}.`);return t}function oe(r){let{publisher:e,availablePublishers:i,catalog:t,lookRenderer:o,localNamespaces:a,rawByNsKey:u,renderStack:p,producers:f,lockSource:y,configSource:s}=r,d=new Map,k=new Map,l=new Map,h=new Set;for(let S of t){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;d.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,M]=P.split("@");if(!_||!M)continue;let E=Y(M);E&&(h.has(P)||(h.add(P),k.has(_)||k.set(_,[]),k.get(_).push({verStr:M,version:E})),S.name===_&&l.set(P,S))}for(let S of k.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:i,catalog:t,lookRenderer:o,localNamespaces:a,rawByNsKey:u,bySubject:d,pkgVersions:k,pkgSelfByVer:l,renderStack:p,...f?{producers:f}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function de(r,e={}){let i=new B,t=new fe(i),o=[],a=[];for(let c of Z(r)){let m;try{m=le(c,"utf-8")}catch{continue}let n;try{n=i.parse(m).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:j(g),version:g,source:m})}a.sort((c,m)=>V(m.version,c.version));for(let c of a)await t.saveDocumentAsync(i.parse(c.source),`${c.publisher}/${c.package_}@${c.verStr}`),o.push({publisher:c.publisher,package_:c.package_,verStr:c.verStr,source:c.source});let u=[...new Set(o.map(c=>c.publisher))].sort(),p=e.publisher;if(p){if(!u.includes(p))throw new Error(`Publisher "${p}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)p=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${r}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let f=new Set,y=new Map;for(let c of o)c.publisher===p&&(f.add(`${c.publisher}/${c.package_}@${c.verStr}`),y.set(`${c.package_}@${c.verStr}`,c.source));let s=J(),d=new ye(s,!0,i),k={};e.httpCache&&(k.getFromCache=e.httpCache.getFromCache,k.onFetch=e.httpCache.onFetch),e.fetchFn&&(k.fetchFn=e.fetchFn),e.packageUrlTemplates&&(k.packageUrlTemplates=e.packageUrlTemplates);let l=e.repository??new Se(t,d,new Q(k)),h=e.log??(()=>{}),S=q(void 0),w=[],P=c=>c.map(m=>m.metadata.namespace_?.version).filter(m=>m!==void 0).sort((m,n)=>V(n,m)).map(j);if(!e.repository){h(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let c=new X({...e.fetchFn?{fetchFn:e.fetchFn}:{},...e.packageUrlTemplates?{packageUrlTemplates:e.packageUrlTemplates}:{}});for(let m of S){let n=C(m),g=await t.getDocumentsByNamespaceAsync(m.publisher,m.package_);if(g.length>0){let v=P(g);w.push({...m,origin:"workspace",versions:v}),h(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await d.getDocumentsByNamespaceAsync(m.publisher,m.package_);if(b.length>0){let v=P(b);w.push({...m,origin:"cache",versions:v}),h(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await c.getLock(m.publisher))?.packages[`${m.publisher}/${m.package_}`];if(!$){let K=`publisher ${m.publisher} reachable but its lock does not pin ${m.package_}`;w.push({...m,origin:"missing",reason:K}),h(`[render-stack] ${n} \u2014 MISSING: ${K}`);continue}let I=$.version,{url:he,content:ke}=await c.fetchLockedSource(m.publisher,m.package_,$);await t.saveDocumentAsync(i.parse(ke),`${m.publisher}/${m.package_}@${I}`);try{let K=ne(s,m.publisher);Fe(K,{recursive:!0}),Ie(ne(K,`${m.package_}@${I}.kan.yml`),ke,"utf-8"),w.push({...m,origin:"fetched",versions:[I]}),h(`[render-stack] ${n}@${I} \u2014 fetched from ${he}, installed to cache`)}catch(K){w.push({...m,origin:"fetched",versions:[I]}),h(`[render-stack] ${n}@${I} \u2014 fetched from ${he}, but cache ${s} is NOT WRITABLE (${K.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...m,origin:"missing",reason:$}),h(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await t.getAllDocumentsAsync()).filter(c=>c.metadata.namespace_?.publisher===p);for(let c of S)_.push(...await l.getDocumentsByNamespaceAsync(c.publisher,c.package_));let M=[],E=await O(_,l,{onUnresolvedEdge:c=>M.push(c)}),A=l;if(!e.repository){for(let c of S)E.add(C(c));A=new W(l,E)}let T=await new re(i).parseKanonaks(A),ie=new te(T),ce=(c,m)=>ee(T,{publisher:c,package_:m,name:m}).length>0,N;if(e.repository){N=[];for(let c of S){let m=await l.getDocumentsByNamespaceAsync(c.publisher,c.package_);N.push(m.length>0?{...c,origin:"repository",versions:P(m)}:{...c,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(c=>c.origin==="missing"||ce(c.publisher,c.package_)?c:{...c,resolvedButNotInCatalog:!0});let G=H(N,M);for(let c of G)h(`[render-stack] WARNING: ${c}`);let z={contractSource:"universal-default",cachePath:s,packages:N,warnings:G},D;try{D=le(ne(r,"kanonak.lock"),"utf-8")}catch{D=Ee(p,o,i)}let U;try{U=le(ne(r,".well-known","kanonak.json"),"utf-8")}catch{U=void 0}return oe({publisher:p,availablePublishers:u,catalog:T,lookRenderer:ie,localNamespaces:f,rawByNsKey:y,renderStack:z,...D?{lockSource:D}:{},...U?{configSource:U}:{}})}function Ee(r,e,i){let t=new Map;for(let a of e)a.publisher===r&&(t.has(a.package_)||t.set(a.package_,{verStr:a.verStr,source:a.source}));if(t.size===0)return;let o={};for(let a of[...t.keys()].sort()){let{verStr:u,source:p}=t.get(a),f={},y;try{y=i.parse(p).metadata?.imports}catch{y=void 0}for(let d of y?.[r]??[]){let k=t.get(d.packageName);k&&(f[`${r}/${d.packageName}`]=k.verStr)}let s={};for(let d of Object.keys(f).sort())s[d]=f[d];o[`${r}/${a}`]={version:u,resolved:`https://${r}/${a}/${u}.kan.yml`,integrity:xe(p),dependencies:s}}return Me.dump({version:"1",lastUpdated:"",packages:o},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as De,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as _e}from"path";async function pe(r,e={}){let i=new B,t=ve(r),o=t.kind==="resource"?t.uri.publisher:t.publisher,a=e.log??(()=>{}),u=e.cacheRoot??J(),p=(n,g,b)=>_e(u,n,`${g}@${b}.kan.yml`),f=new Set,y=new Set,s=new Map,d=new Q({getFromCache:(n,g,b)=>{let v=p(n,g,b),$=De(v)?Ke(v,"utf-8"):null;return $!==null&&f.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=_e(u,n);Ae($,{recursive:!0}),Ve(p(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{},...e.packageUrlTemplates?{packageUrlTemplates:e.packageUrlTemplates}:{}}),k=new X(e.fetchFn?{fetchFn:e.fetchFn}:void 0),l;if(t.kind==="resource"){let n=t.uri.version;l=[n?{package_:t.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:t.uri.package_}]}else if(t.kind==="package"){let n=t.version;l=[n?{package_:t.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:t.package_}]}else l=((await k.getConfig(o)).featured_packages??[]).map(g=>({package_:g}));let h=async(n,g,b)=>{try{let v=b?i.buildImport(g,"=",b,n):i.buildImport(g,"*","0.0.0",n),$=await d.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of l){let{doc:g,error:b}=await h(o,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${r}" from publisher "${o}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",M=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(j);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let E=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await h(n.publisher,n.package_,void 0);if(b){E.push(b);let $=M([b]),I=y.has(g)?"fetched":f.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let T=[],ie=await O([...S,...E],d,{onUnresolvedEdge:n=>T.push(n)}),ce=new W(d,ie),N=await new re(i).parseKanonaks(ce),G=new te(N),z=A.map(n=>n.origin==="missing"||ee(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),D=H(z,T);for(let n of D)a(`[render-stack] WARNING: ${n}`);let U={contractSource:_,cachePath:u,packages:z,warnings:D},c=new Set,m=new Map;for(let n of await d.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==o)continue;let b=j(g.version),v=`${g.publisher}/${g.package_}@${b}`;c.add(v);let $=await d.getDocumentContentAsync(v);$!==null&&m.set(`${g.package_}@${b}`,$)}return oe({publisher:o,availablePublishers:[o],catalog:N,lookRenderer:G,localNamespaces:c,rawByNsKey:m,renderStack:U})}import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";function se(r){let{lookRenderer:e,publisher:i,renderStack:t,catalog:o}=r,a=e.explainStylesheet(e.publisherSubject(i)),u=[...a.tokens.entries()].map(([l,h])=>({name:l,value:h.value,source:`${h.sourceNamespace}/${h.sourceName}`,level:h.level})),p=a.baseStylesheet,f={present:p.css!==void 0,...p.sourceNamespace!==void 0?{source:p.sourceNamespace}:{},...p.scope!==void 0?{scope:p.scope}:{},...p.css!==void 0?{bytes:p.css.length}:{},...p.problem!==void 0?{problem:p.problem}:{},candidates:p.candidates},y=new Map;for(let l of o){let h=l.namespace;h&&y.set(h,(y.get(h)??0)+1)}let s=[...y.entries()].map(([l,h])=>({namespace:l,resources:h})).sort((l,h)=>l.namespace.localeCompare(h.namespace)),d=e.expressionFailures().map(l=>({carrier:l.carrier,stage:l.stage,reason:l.reason})),k=d.map(l=>l.stage==="compile"?`Expression carrier "${l.carrier}" did not compile: ${l.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`:`Expression carrier "${l.carrier}" failed to evaluate: ${l.reason} Consequence: that value renders as nothing. Fix: correct the expression, or make a value that may be absent explicitly optional.`);return{publisher:i,renderStack:{contractSource:t.contractSource,cachePath:t.cachePath,packages:t.packages.map(l=>({package_:C(l),origin:l.origin,...l.versions!==void 0?{versions:l.versions}:{},...l.reason!==void 0?{reason:l.reason}:{},...l.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:l.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:f,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:d,catalog:s,warnings:[...t.warnings,...a.warnings.filter(l=>!t.warnings.includes(l)),...k]}}function Te(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(r){let e=Te,i=r.warnings.length===0,t=r.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
|
|
1
|
+
import{c as xe}from"../chunk-3ABGZHKM.js";import{a as ye,d as J,f as Se,h as Z}from"../chunk-F4UHQVGA.js";import{l as $e,t as X,u as Q}from"../chunk-X2URIXH7.js";import"../chunk-TR7PC72M.js";import"../chunk-SC5M74NM.js";import{a as O,b as W}from"../chunk-QRF7AT2M.js";import{u as te}from"../chunk-AZFLKLPB.js";import"../chunk-QHABFCRC.js";import"../chunk-5FVUBF7N.js";import{a as fe}from"../chunk-NYCGUDVW.js";import{k as re}from"../chunk-Q2ZUKZEU.js";import{a as B}from"../chunk-6CI3HTKF.js";import{a as Re}from"../chunk-PEJALHXK.js";import"../chunk-TVMOJ2QS.js";import{c as we,z as ee}from"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import{c as V,e as j,f as L,g as Y,l as be,m as ve}from"../chunk-7IMLHHSA.js";import{readFileSync as le,writeFileSync as Ie,mkdirSync as Fe}from"fs";import{join as ne}from"path";import Me from"js-yaml";var Pe=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function q(r){return Pe}function C(r){return`${r.publisher}/${r.package_}`}function H(r,e=[]){let i={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},t=[];for(let o of r)if(o.origin==="missing"){let a=C(o),u=i[a]??"whatever this package contributes to rendering is lost";t.push(`Render-stack package ${a} is MISSING (${o.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${o.publisher}.`)}else o.resolvedButNotInCatalog&&t.push(`Render-stack package ${C(o)} resolved (${o.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let o of e)t.push(`Import edge ${o.fromNamespace} \u2192 ${o.publisher}/${o.packageName} ${o.constraint} did NOT resolve (${o.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${o.fromNamespace} authors against ${o.publisher}/${o.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${o.constraint}-compatible version of ${o.publisher}/${o.packageName} to the workspace or cache (kanonak install ${o.publisher}/${o.packageName}), or bump the import in ${o.fromNamespace}.`);return t}function oe(r){let{publisher:e,availablePublishers:i,catalog:t,lookRenderer:o,localNamespaces:a,rawByNsKey:u,renderStack:p,producers:f,lockSource:y,configSource:s}=r,d=new Map,k=new Map,l=new Map,h=new Set;for(let S of t){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;d.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,M]=P.split("@");if(!_||!M)continue;let E=Y(M);E&&(h.has(P)||(h.add(P),k.has(_)||k.set(_,[]),k.get(_).push({verStr:M,version:E})),S.name===_&&l.set(P,S))}for(let S of k.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:i,catalog:t,lookRenderer:o,localNamespaces:a,rawByNsKey:u,bySubject:d,pkgVersions:k,pkgSelfByVer:l,renderStack:p,...f?{producers:f}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function de(r,e={}){let i=new B,t=new fe(i),o=[],a=[];for(let c of Z(r)){let m;try{m=le(c,"utf-8")}catch{continue}let n;try{n=i.parse(m).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:j(g),version:g,source:m})}a.sort((c,m)=>V(m.version,c.version));for(let c of a)await t.saveDocumentAsync(i.parse(c.source),`${c.publisher}/${c.package_}@${c.verStr}`),o.push({publisher:c.publisher,package_:c.package_,verStr:c.verStr,source:c.source});let u=[...new Set(o.map(c=>c.publisher))].sort(),p=e.publisher;if(p){if(!u.includes(p))throw new Error(`Publisher "${p}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)p=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${r}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let f=new Set,y=new Map;for(let c of o)c.publisher===p&&(f.add(`${c.publisher}/${c.package_}@${c.verStr}`),y.set(`${c.package_}@${c.verStr}`,c.source));let s=J(),d=new ye(s,!0,i),k={};e.httpCache&&(k.getFromCache=e.httpCache.getFromCache,k.onFetch=e.httpCache.onFetch),e.fetchFn&&(k.fetchFn=e.fetchFn),e.packageUrlTemplates&&(k.packageUrlTemplates=e.packageUrlTemplates);let l=e.repository??new Se(t,d,new Q(k)),h=e.log??(()=>{}),S=q(void 0),w=[],P=c=>c.map(m=>m.metadata.namespace_?.version).filter(m=>m!==void 0).sort((m,n)=>V(n,m)).map(j);if(!e.repository){h(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let c=new X({...e.fetchFn?{fetchFn:e.fetchFn}:{},...e.packageUrlTemplates?{packageUrlTemplates:e.packageUrlTemplates}:{}});for(let m of S){let n=C(m),g=await t.getDocumentsByNamespaceAsync(m.publisher,m.package_);if(g.length>0){let v=P(g);w.push({...m,origin:"workspace",versions:v}),h(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await d.getDocumentsByNamespaceAsync(m.publisher,m.package_);if(b.length>0){let v=P(b);w.push({...m,origin:"cache",versions:v}),h(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await c.getLock(m.publisher))?.packages[`${m.publisher}/${m.package_}`];if(!$){let K=`publisher ${m.publisher} reachable but its lock does not pin ${m.package_}`;w.push({...m,origin:"missing",reason:K}),h(`[render-stack] ${n} \u2014 MISSING: ${K}`);continue}let I=$.version,{url:he,content:ke}=await c.fetchLockedSource(m.publisher,m.package_,$);await t.saveDocumentAsync(i.parse(ke),`${m.publisher}/${m.package_}@${I}`);try{let K=ne(s,m.publisher);Fe(K,{recursive:!0}),Ie(ne(K,`${m.package_}@${I}.kan.yml`),ke,"utf-8"),w.push({...m,origin:"fetched",versions:[I]}),h(`[render-stack] ${n}@${I} \u2014 fetched from ${he}, installed to cache`)}catch(K){w.push({...m,origin:"fetched",versions:[I]}),h(`[render-stack] ${n}@${I} \u2014 fetched from ${he}, but cache ${s} is NOT WRITABLE (${K.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...m,origin:"missing",reason:$}),h(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await t.getAllDocumentsAsync()).filter(c=>c.metadata.namespace_?.publisher===p);for(let c of S)_.push(...await l.getDocumentsByNamespaceAsync(c.publisher,c.package_));let M=[],E=await O(_,l,{onUnresolvedEdge:c=>M.push(c)}),A=l;if(!e.repository){for(let c of S)E.add(C(c));A=new W(l,E)}let T=await new re(i).parseKanonaks(A),ie=new te(T),ce=(c,m)=>ee(T,{publisher:c,package_:m,name:m}).length>0,N;if(e.repository){N=[];for(let c of S){let m=await l.getDocumentsByNamespaceAsync(c.publisher,c.package_);N.push(m.length>0?{...c,origin:"repository",versions:P(m)}:{...c,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(c=>c.origin==="missing"||ce(c.publisher,c.package_)?c:{...c,resolvedButNotInCatalog:!0});let G=H(N,M);for(let c of G)h(`[render-stack] WARNING: ${c}`);let z={contractSource:"universal-default",cachePath:s,packages:N,warnings:G},D;try{D=le(ne(r,"kanonak.lock"),"utf-8")}catch{D=Ee(p,o,i)}let U;try{U=le(ne(r,".well-known","kanonak.json"),"utf-8")}catch{U=void 0}return oe({publisher:p,availablePublishers:u,catalog:T,lookRenderer:ie,localNamespaces:f,rawByNsKey:y,renderStack:z,...D?{lockSource:D}:{},...U?{configSource:U}:{}})}function Ee(r,e,i){let t=new Map;for(let a of e)a.publisher===r&&(t.has(a.package_)||t.set(a.package_,{verStr:a.verStr,source:a.source}));if(t.size===0)return;let o={};for(let a of[...t.keys()].sort()){let{verStr:u,source:p}=t.get(a),f={},y;try{y=i.parse(p).metadata?.imports}catch{y=void 0}for(let d of y?.[r]??[]){let k=t.get(d.packageName);k&&(f[`${r}/${d.packageName}`]=k.verStr)}let s={};for(let d of Object.keys(f).sort())s[d]=f[d];o[`${r}/${a}`]={version:u,resolved:`https://${r}/${a}/${u}.kan.yml`,integrity:xe(p),dependencies:s}}return Me.dump({version:"1",lastUpdated:"",packages:o},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as De,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as _e}from"path";async function pe(r,e={}){let i=new B,t=ve(r),o=t.kind==="resource"?t.uri.publisher:t.publisher,a=e.log??(()=>{}),u=e.cacheRoot??J(),p=(n,g,b)=>_e(u,n,`${g}@${b}.kan.yml`),f=new Set,y=new Set,s=new Map,d=new Q({getFromCache:(n,g,b)=>{let v=p(n,g,b),$=De(v)?Ke(v,"utf-8"):null;return $!==null&&f.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=_e(u,n);Ae($,{recursive:!0}),Ve(p(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{},...e.packageUrlTemplates?{packageUrlTemplates:e.packageUrlTemplates}:{}}),k=new X(e.fetchFn?{fetchFn:e.fetchFn}:void 0),l;if(t.kind==="resource"){let n=t.uri.version;l=[n?{package_:t.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:t.uri.package_}]}else if(t.kind==="package"){let n=t.version;l=[n?{package_:t.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:t.package_}]}else l=((await k.getConfig(o)).featured_packages??[]).map(g=>({package_:g}));let h=async(n,g,b)=>{try{let v=b?i.buildImport(g,"=",b,n):i.buildImport(g,"*","0.0.0",n),$=await d.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of l){let{doc:g,error:b}=await h(o,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${r}" from publisher "${o}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",M=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(j);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let E=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await h(n.publisher,n.package_,void 0);if(b){E.push(b);let $=M([b]),I=y.has(g)?"fetched":f.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let T=[],ie=await O([...S,...E],d,{onUnresolvedEdge:n=>T.push(n)}),ce=new W(d,ie),N=await new re(i).parseKanonaks(ce),G=new te(N),z=A.map(n=>n.origin==="missing"||ee(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),D=H(z,T);for(let n of D)a(`[render-stack] WARNING: ${n}`);let U={contractSource:_,cachePath:u,packages:z,warnings:D},c=new Set,m=new Map;for(let n of await d.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==o)continue;let b=j(g.version),v=`${g.publisher}/${g.package_}@${b}`;c.add(v);let $=await d.getDocumentContentAsync(v);$!==null&&m.set(`${g.package_}@${b}`,$)}return oe({publisher:o,availablePublishers:[o],catalog:N,lookRenderer:G,localNamespaces:c,rawByNsKey:m,renderStack:U})}import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";function se(r){let{lookRenderer:e,publisher:i,renderStack:t,catalog:o}=r,a=e.explainStylesheet(e.publisherSubject(i)),u=[...a.tokens.entries()].map(([l,h])=>({name:l,value:h.value,source:`${h.sourceNamespace}/${h.sourceName}`,level:h.level})),p=a.baseStylesheet,f={present:p.css!==void 0,...p.sourceNamespace!==void 0?{source:p.sourceNamespace}:{},...p.scope!==void 0?{scope:p.scope}:{},...p.css!==void 0?{bytes:p.css.length}:{},...p.problem!==void 0?{problem:p.problem}:{},candidates:p.candidates},y=new Map;for(let l of o){let h=l.namespace;h&&y.set(h,(y.get(h)??0)+1)}let s=[...y.entries()].map(([l,h])=>({namespace:l,resources:h})).sort((l,h)=>l.namespace.localeCompare(h.namespace)),d=e.expressionFailures().map(l=>({carrier:l.carrier,stage:l.stage,reason:l.reason})),k=d.map(l=>l.stage==="compile"?`Expression carrier "${l.carrier}" did not compile: ${l.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`:`Expression carrier "${l.carrier}" failed to evaluate: ${l.reason} Consequence: that value renders as nothing. Fix: correct the expression, or make a value that may be absent explicitly optional.`);return{publisher:i,renderStack:{contractSource:t.contractSource,cachePath:t.cachePath,packages:t.packages.map(l=>({package_:C(l),origin:l.origin,...l.versions!==void 0?{versions:l.versions}:{},...l.reason!==void 0?{reason:l.reason}:{},...l.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:l.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:f,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:d,catalog:s,warnings:[...t.warnings,...a.warnings.filter(l=>!t.warnings.includes(l)),...k]}}function Te(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(r){let e=Te,i=r.warnings.length===0,t=r.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
|
|
2
2
|
`),o=r.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':r.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
|
|
3
3
|
`),a=r.renderStack.packages.map(s=>{let d=s.origin!=="missing"&&!s.resolvedButNotInCatalog,k=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,l=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${d?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${k}</td><td>${l}</td></tr>`}).join(`
|
|
4
4
|
`),u=r.stylesheet.baseStylesheet,p=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,f=r.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pe}from"../chunk-
|
|
1
|
+
import{a as pe}from"../chunk-FYAZ345F.js";import"../chunk-2GV6GXRF.js";import{a as ve,b as M,c as Vn,n as X,o as Rn,p as vn,q as le,r as Ln,s as q,u as G}from"../chunk-AZFLKLPB.js";import"../chunk-QHABFCRC.js";import"../chunk-NYCGUDVW.js";import{b as $n,c as Tn,d as Bn,e as xn,f as Un,k as fe}from"../chunk-Q2ZUKZEU.js";import{a as se}from"../chunk-6CI3HTKF.js";import"../chunk-PEJALHXK.js";import{c as U}from"../chunk-TVMOJ2QS.js";import{b as Y,c as D,d as ce,e as E,f as ue,i as $,j as T,k as B,l as w,m as me,n as x,o as de,q as N,r as S,y as A}from"../chunk-6USORWEP.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-7IMLHHSA.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
|
|
2
2
|
`);return t?.trailingNewline&&(s.endsWith(`
|
|
3
3
|
`)||(s+=`
|
|
4
4
|
`)),s}};function Ie(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(P(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(P(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(P),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=P(f??c),d=ye(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function P(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function ye(e,n){switch(e.kind){case"StringScalar":return _e(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=ye(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function _e(e,n){return!n||ge(n,m.ESC_RAW)?e:ge(n,m.ESC_YAML_SAFE)?Ce(e):e}function Ce(e){return e.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as l,B as m,C as n,D as o,E as p,F as q,G as r,H as s,I as t,K as u,p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h,x as i,y as j,z as k}from"../chunk-
|
|
1
|
+
import{A as l,B as m,C as n,D as o,E as p,F as q,G as r,H as s,I as t,K as u,p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h,x as i,y as j,z as k}from"../chunk-6USORWEP.js";import"../chunk-7IMLHHSA.js";export{u as SingleDocumentRepository,k as findAllResourcesByCanonicalUri,l as findStatement,j as findSubjectByUri,i as findSubjectsByType,n as getDatatypeValue,q as getEmbeddedValue,r as getListValues,p as getReferenceUri,o as getStringValue,m as hasProperty,h as hasType,g as rawValuesByStatementOf,f as rawValuesOf,e as referenceUris,t as subjectAddress,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches,s as valuesOf};
|