@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
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as He,b as Ne,c as ge,d as Rr,e as fr,f as yr,g as kr,i as Cr,j as Sr,k as _r,l as Er,m as xr,n as Or,o as Ir,p as Ar,q as Hr,r as Nr,s as gr}from"./chunk-
|
|
1
|
+
import{a as He,b as Ne,c as ge,d as Rr,e as fr,f as yr,g as kr,i as Cr,j as Sr,k as _r,l as Er,m as xr,n as Or,o as Ir,p as Ar,q as Hr,r as Nr,s as gr}from"./chunk-PXUSA72Q.js";import{a as Mr}from"./chunk-FYAZ345F.js";import{a as pr,b as lr,c as cr,d as mr,e as dr,f as ur,g as Pr,h as Kr,i as Dr,j as Tr,k as hr,l as Lr}from"./chunk-IT37WOHT.js";import{a as R,b as f,c as y,e as k,g as S,h as _,i as E,j as x,k as O,m as I,o as A,p as H,q as N,r as g,s as M,t as K,u as D}from"./chunk-X2URIXH7.js";import{a as Me,b as Ke,c as De}from"./chunk-2GV6GXRF.js";import{a as Te}from"./chunk-TR7PC72M.js";import"./chunk-SC5M74NM.js";import{A as rr,B as or,C as tr,D as nr,E as ar,O as sr,a as he,b as Le,c as Ve,d as be,i as je,j as Ue,k as ve,l as we,n as Fe,o as Be,p as Ge,q as Ye,r as qe,s as We,t as Xe,u as ze,v as Qe,w as Je,x as Ze,y as $e,z as er}from"./chunk-FCRP7KXR.js";import"./chunk-QRF7AT2M.js";import{m as ir}from"./chunk-AZFLKLPB.js";import"./chunk-QHABFCRC.js";import{a as c,b as m,c as d,d as u,e as P}from"./chunk-5FVUBF7N.js";import{a as p}from"./chunk-NYCGUDVW.js";import{a as xe,g as Oe,h as Ie,k as Ae}from"./chunk-Q2ZUKZEU.js";import{a as l}from"./chunk-6CI3HTKF.js";import"./chunk-PEJALHXK.js";import{O as oe,P as te,Q as ne,R as ae,S as ie,T as se,U as pe,V as le,W as ce,X as me,Y as de,Z as ue,a as W,b as X,ca as Pe,da as Re,ea as fe,fa as ye,ga as ke,h as J,i as Z,j as $,k as ee,l as re,ma as Ce,oa as Se}from"./chunk-TVMOJ2QS.js";import{H as _e,I as Ee,a as T,b as h,c as L,d as V,e as b,g as j,h as U,i as v,j as w,k as F,l as B,m as G,n as Y,o as q,s as z,t as Q}from"./chunk-6USORWEP.js";import"./chunk-F67UH4FD.js";import{c as e,d as r,e as o,f as t,g as n,h as a,i,k as s,l as C}from"./chunk-7IMLHHSA.js";export{S as ANY_PUBLISHER,Ze as AmbiguousReferenceRule,F as BooleanStatement,cr as CANONICAL_FORM_VERSION,Ir as CREDENTIAL_EXPIRY_SKEW_SECONDS,Sr as CREDENTIAL_HELPER_PROTOCOL_VERSION,Oe as Carrier,nr as ClassDefinitionRule,Ye as ClassHierarchyCycleRule,P as CredentialError,h as DefinedKanonak,Ne as EdgeType,V as EmbeddedKanonak,Fe as EmbeddedKanonakTypeRule,G as EmbeddedStatement,hr as EntitlementDeniedError,Lr as EntitlementProducer,ge as GraphBuilder,D as HttpKanonakDocumentRepository,A as INTEGRITY_PREFIX,ur as ImportBook,Be as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,R as KANONAK_USER_AGENT,T as Kanonak,Ke as KanonakDocumentPositions,c as KanonakHttpError,Ae as KanonakObjectParser,sr as KanonakObjectValidator,l as KanonakParser,C as KanonakUri,Te as KanonakUriBuilder,Ce as KanonakVocabulary,Y as ListStatement,ar as MarkdownLinkRule,q as MarkdownStatement,Qe as NamespaceImportCycleRule,je as NamespacePrefixRule,He as NodeType,w as NumberStatement,Cr as OAuthDiscovery,ke as OWL_HAS_KEY,er as ObjectPropertyValueValidationRule,Ve as OntologyValidationError,he as OntologyValidationResult,mr as PackageBuilder,Kr as ProducerRepository,rr as PropertyDomainRule,qe as PropertyHierarchyCycleRule,or as PropertyKindRangeConsistencyRule,Me as PropertyMetadata,$e as PropertyRangeReferenceRule,We as PropertyRangeRequiredRule,ve as PropertyTypeSpecificityRule,I as PublisherConfigResolver,K as PublisherIndex,b as ReferenceKanonak,B as ReferenceStatement,tr as ReservedNameShadowRule,Ue as ResourceNamingRule,W as ResourceResolver,Se as ResourceTypeClassifier,Z as SHACL_PACKAGE,J as SHACL_PUBLISHER,ae as SH_COMP_CLASS,ue as SH_COMP_CLOSED,ne as SH_COMP_DATATYPE,ye as SH_COMP_HAS_KEY,Pe as SH_COMP_HAS_VALUE,ie as SH_COMP_IN,te as SH_COMP_MAX_COUNT,me as SH_COMP_MAX_INCLUSIVE,le as SH_COMP_MAX_LENGTH,oe as SH_COMP_MIN_COUNT,ce as SH_COMP_MIN_INCLUSIVE,pe as SH_COMP_MIN_LENGTH,de as SH_COMP_NODE_KIND,se as SH_COMP_PATTERN,fe as SH_COMP_QUALIFIED_MAX_COUNT,Re as SH_COMP_QUALIFIED_MIN_COUNT,ee as SH_NODE_SHAPE,re as SH_PROPERTY_SHAPE,$ as SH_SHAPE,U as ScalarStatement,j as Statement,v as StringStatement,Xe as SubClassOfReferenceRule,ze as SubPropertyOfReferenceRule,L as SubjectKanonak,we as SubjectKanonakTypeRequiredRule,Hr as TOKEN_ENV,gr as TokenCredentialProvider,X as TypeResolver,Je as UnresolvedPredicateRule,Ge as UnresolvedReferenceRule,be as ValidationContext,Le as ValidationSeverity,Dr as allowAllPolicy,M as assertIntegrityAsync,ir as buildOntologyModel,pr as canonicalForm,lr as canonicalHash,Ie as carrierOf,_r as checkCredentialAnswer,Er as checkHelperAnswer,xr as checkHelperEraseAnswer,E as checkPackageUrlTemplate,_ as checkPackageUrlTemplates,e as compareVersions,g as computeIntegrityAsync,dr as contentAddressedName,Ar as createCredentialedFetch,t as createVersion,d as describeResponse,O as fillPackageUrlTemplate,Mr as findDerivation,o as formatVersion,y as getKanonakUserAgent,m as httpError,a as isCompatibleVersion,i as isMajorCompatible,k as kanonakFetch,kr as narrowestScope,Tr as noopMeter,Rr as normalizeHost,x as packageUrlTemplateFor,H as parseLockFile,fr as parseScope,n as parseVersionString,De as parseWithPositions,Or as parseWwwAuthenticate,s as pickHighestDocument,Q as referenceUris,u as retryAfterSecondsOf,Pr as sanitizeName,yr as scopeContains,N as serializeLockFile,f as setKanonakUserAgent,Ee as subjectAddress,Nr as tokenEnvKeyFor,z as typeReferenceUris,_e as valuesOf,r as versionsEqual,xe as walkDefinedKanonaks};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as A}from"./chunk-
|
|
1
|
+
import{j as A}from"./chunk-Q2ZUKZEU.js";import{a as E}from"./chunk-6CI3HTKF.js";import{pa as $}from"./chunk-TVMOJ2QS.js";import{c as V,d as I,e as N,f as x,g as U,l as W,m as J,n as _,o as B}from"./chunk-6USORWEP.js";var R=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as H,LineCounter as Q,isMap as b,isPair as f,isScalar as l,isSeq as j}from"yaml";var L=class r{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let n=new r,t=new Q,o=H(e,{lineCounter:t});if(o.errors.length>0||!b(o.contents))return n;O(o.contents,[],t,n);for(let i of o.contents.items){if(!f(i)||!l(i.key))continue;let s=String(i.key.value),u=i.key.range;if(!u)continue;n.entities.set(s,g(u,t));let a=i.value,c=a&&typeof a=="object"&&"range"in a?a.range:void 0;if(c?n.entityBlocks.set(s,g([u[0],u[1],c[2]],t)):n.entityBlocks.set(s,g(u,t)),b(i.value)){let k=new Map,d=new Map,p=new Map;for(let S of i.value.items){if(!f(S)||!l(S.key))continue;let h=String(S.key.value),m=S.key.range;m&&k.set(h,g(m,t));let P=S.value;if(P&&typeof P=="object"&&"range"in P&&Array.isArray(P.range)){let v=P.range;d.set(h,g(v,t))}if(j(P)){let v=[];for(let K of P.items)K&&typeof K=="object"&&"range"in K&&Array.isArray(K.range)&&v.push(g(K.range,t));v.length>0&&p.set(h,v)}}k.size>0&&n.properties.set(s,k),d.size>0&&n.propertyValues.set(s,d),p.size>0&&n.valueListItems.set(s,p);let y=Y(i.value,t);y.length>0&&n.importPackages.set(s,y)}}return n}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,n){for(let[t,o]of this.entityBlocks)if(C(o,e,n))return t}findPropertyAtPosition(e,n){let t=this.findEntityAtPosition(e,n);if(!t)return;let o=this.properties.get(t),i=this.propertyValues.get(t);if(!o&&!i)return{entityName:t};let s,u;if(i)for(let[a,c]of i)C(c,e,n)&&(!u||q(c,u))&&(s=a,u=c);if(o)for(let[a,c]of o)C(c,e,n)&&(!u||q(c,u))&&(s=a,u=c);return s?{entityName:t,propertyName:s}:{entityName:t}}getPropertyPosition(e,n){return this.properties.get(e)?.get(n)}getPropertyValuePosition(e,n){return this.propertyValues.get(e)?.get(n)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[n,t]of this.importPackages)for(let o of t)e.push({entityName:n,entry:o});return e}findPropertySourceName(e,n){let t=this.properties.get(e);if(t){if(t.has(n))return n;for(let o of t.keys()){let i=o.lastIndexOf(".");if((i===-1?o:o.substring(i+1))===n)return o}}}getListItemPosition(e,n,t){let o=this.valueListItems.get(e)?.get(n);if(!(!o||t<0||t>=o.length))return o[t]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,n){this.nestedKeys.set(e,n)}setNestedValuePosition(e,n){this.nestedValues.set(e,n)}getMostSpecificPosition(e,n,t){if(e){if(n!==void 0){if(t!==void 0){let s=this.getListItemPosition(e,n,t);if(s)return s}let o=this.getPropertyValuePosition(e,n);if(o)return o;let i=this.getPropertyPosition(e,n);if(i)return i}return this.getEntityPosition(e)}}};function Y(r,e){let n=[];if(!b(r))return n;let t=r.items.find(o=>f(o)&&l(o.key)&&String(o.key.value)==="imports");if(!t||!f(t)||!j(t.value))return n;for(let o of t.value.items){if(!b(o))continue;let i=o.items.find(a=>f(a)&&l(a.key)&&String(a.key.value)==="publisher");if(!i||!f(i)||!l(i.value))continue;let s=String(i.value.value),u=o.items.find(a=>f(a)&&l(a.key)&&String(a.key.value)==="packages");if(!(!u||!f(u)||!j(u.value)))for(let a of u.value.items){if(!b(a))continue;let c=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="package");if(!c||!f(c)||!l(c.value)||!c.value.range)continue;let k=String(c.value.value),d=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="version"),p=d&&f(d)&&l(d.value)?String(d.value.value):"",y=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="alias"),S=y&&f(y)&&l(y.value)?String(y.value.value):void 0,h=S!==void 0?{publisher:s,package_:k,version:p,alias:S,position:g(c.value.range,e)}:{publisher:s,package_:k,version:p,position:g(c.value.range,e)};n.push(h)}}return n}function C(r,e,n){return!(e<r.line||e>r.endLine||e===r.line&&n<r.column||e===r.endLine&&n>r.endColumn)}function q(r,e){let n=r.endLine-r.line,t=e.endLine-e.line;if(n!==t)return n<t;let o=r.endLine===r.line?r.endColumn-r.column:Number.MAX_SAFE_INTEGER,i=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return o<i}function O(r,e,n,t){if(b(r)){for(let o of r.items){if(!f(o)||!l(o.key))continue;let i=String(o.key.value),s=[...e,i],u=JSON.stringify(s);o.key.range&&t.setNestedKeyPosition(u,g(o.key.range,n));let a=o.value,c=z(a);c&&t.setNestedValuePosition(u,g(c,n)),O(a,s,n,t)}return}if(j(r)){for(let o=0;o<r.items.length;o++){let i=r.items[o],s=[...e,o],u=JSON.stringify(s),a=z(i);a&&t.setNestedValuePosition(u,g(a,n)),O(i,s,n,t)}return}}function z(r){if(!r||typeof r!="object"||!("range"in r))return;let e=r.range;return Array.isArray(e)&&e.length>=3?e:void 0}function g(r,e){let n=e.linePos(r[0]),t=e.linePos(r[2]);return{line:n.line-1,column:n.col-1,endLine:t.line-1,endColumn:t.col-1}}function Z(r,e){let t=(e??new E).parse(r),o=L.fromContent(r);return{document:t,positions:o}}function T(r,e,n,t,o){if(e<t.line||e>t.endLine||e===t.line&&n<t.column||e===t.endLine&&n>=t.endColumn)return;let i=M(o,t.line,t.column),s=M(o,t.endLine,t.endColumn);if(i<0||s<0)return;let u=o.substring(i,s),a=A(u);if(a.length!==r.links.length)return;let c=e-t.line,k=e===t.line?n-t.column:n,d=M(u,c,k);if(!(d<0))for(let p=0;p<a.length;p++){let y=a[p];if(d>=y.startOffset&&d<y.endOffset)return r.links[p]}}function G(r,e){let n=M(e,r.line,r.column),t=M(e,r.endLine,r.endColumn);if(n<0||t<0)return;let o=e.substring(n,t);return A(o).map(i=>{let s=F(e,n+i.startOffset),u=F(e,n+i.endOffset);return{line:s.line,column:s.column,endLine:u.line,endColumn:u.column}})}function F(r,e){let n=0,t=0;for(let o=0;o<e&&o<r.length;o++)r[o]===`
|
|
2
2
|
`&&(n++,t=o+1);return{line:n,column:e-t}}function M(r,e,n){let t=0,o=0;for(let i=0;i<r.length;i++){if(t===e)return Math.min(o+n,r.length);r[i]===`
|
|
3
3
|
`&&(t++,o=i+1)}return t===e?Math.min(o+n,r.length):-1}function ee(r,e,n){let t=[];for(let o of r){if(!(o instanceof V)||typeof o.sourceKey!="string")continue;let i=[o.sourceKey],s=$(o);s&&t.push({role:"subject",uri:s,range:w(e.getEntityPosition(o.sourceKey),i,"key"),path:i}),D(o.statement,i,e,n,t)}return t}function ne(r,e,n){let t;for(let o of r)te(o.range,e,n)&&(!t||oe(o.range,t.range))&&(t=o);return t}function D(r,e,n,t,o){for(let i of r){if(!(i instanceof U)||i.sourceKey===void 0)continue;let s=[...e,i.sourceKey],u=i.predicate?.subject;if(u&&o.push({role:"predicate",uri:u,range:w(n.getNodeKeyPosition(s),s,"key"),path:s}),i instanceof W)o.push({role:"reference",uri:i.object.subject,range:w(n.getNodeValuePosition(s),s,"value"),path:s});else if(i instanceof B)X(i.links,s,n,t,o);else if(i instanceof J)i.object&&D(i.object.statement,s,n,t,o);else if(i instanceof _)for(let a of i.object??[]){if(!(a instanceof N||a instanceof I||a instanceof x)||a.sourceKey===void 0)continue;let c=[...s,a.sourceKey];a instanceof N?o.push({role:"reference",uri:a.subject,range:w(n.getNodeValuePosition(c),c,"value"),path:c}):a instanceof I?D(a.statement,c,n,t,o):a.links&&X(a.links,c,n,t,o)}}}function X(r,e,n,t,o){if(t===void 0||r.length===0)return;let i=G(w(n.getNodeValuePosition(e),e,"value"),t);if(!i||i.length!==r.length)throw new Error(`sourceSymbols: the prose value at ${JSON.stringify(e)} has ${r.length} resolved [[reference]](s) but ${i?.length??0} in its source text \u2014 the source text is not the text this document was parsed from.`);r.forEach((s,u)=>{s.target&&o.push({role:"reference",uri:s.target.subject,range:i[u],path:e})})}function w(r,e,n){if(!r)throw new Error(`sourceSymbols: no source ${n} position for ${JSON.stringify(e)}. The object model has a node the position index does not \u2014 the positions were not built from the text this document was parsed from.`);return r}function te(r,e,n){return!(e<r.line||e>r.endLine||e===r.line&&n<r.column||e===r.endLine&&n>r.endColumn)}function oe(r,e){let n=r.endLine-r.line,t=e.endLine-e.line;return n!==t?n<t:r.endColumn-r.column<e.endColumn-e.column}export{R as a,L as b,Z as c,T as d,ee as e,ne as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as i,p as o,q as r}from"./chunk-
|
|
1
|
+
import{o as i,p as o,q as r}from"./chunk-X2URIXH7.js";import{readFileSync as c,writeFileSync as l,existsSync as s}from"fs";import{createHash as a}from"crypto";var n="kanonak.lock";function f(e=n){return s(e)?o(c(e,"utf-8")):null}function k(e,t=n){e.lastUpdated=new Date().toISOString(),l(t,r(e),"utf-8")}function L(e){let t=a("sha256").update(e).digest("hex");return`${i}${t}`}export{f as a,k as b,L as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-F67UH4FD.js";import{a as l,b as h}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-F67UH4FD.js";import{a as l,b as h}from"./chunk-7IMLHHSA.js";import*as c from"js-yaml";var y=new Set(["Package","EphemeralPackage"]);function f(m){return typeof m=="string"&&y.has(m)}var g=class{parse(e){let r=this.parseWithErrors(e);if(!r.isValid){let n=r.errors[0];throw new Error(`YAML parse error at line ${n.line}, column ${n.column}: ${n.message}`)}return r.document}parseWithErrors(e){let r=[],n;try{e=e.replace(/^\uFEFF/,"");let a=c.load(e,{schema:c.FAILSAFE_SCHEMA});if(!a||typeof a!="object")return n={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:n,errors:r,isValid:!0};let t=this.extractMetadata(a),o=this.extractBody(a,t);return n={metadata:t,body:o,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:n,errors:r,isValid:!0}}catch(a){let t=a,o=t.mark?t.mark.line+1:0,i=t.mark?t.mark.column+1:0,s={message:t.message||"Unknown parse error",line:o,column:i,errorType:t.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${t.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${o}: ${t.message||"Unknown parse error"}`};return r.push(s),{document:void 0,errors:r,isValid:!1}}}save(e){let r={};if(e.metadata.namespace_){let n=e.metadata.namespace_,a={type:"Package",publisher:n.publisher};n.version&&(a.version=`${n.version.major}.${n.version.minor}.${n.version.patch}`),e.metadata.imports&&(a.imports=this.serializeImports(e.metadata.imports)),r[n.package_]=a}return Object.assign(r,e.body),c.dump(r,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(e){let r=e.imports;return Object.defineProperty(e,"allImports",{get:function(){if(!r)return[];let n=[];for(let a of Object.values(r))n.push(...a);return n},enumerable:!0,configurable:!0}),e}createVersion(e,r,n){return{major:e,minor:r,patch:n,toString:()=>`${e}.${r}.${n}`,equals:t=>!t||typeof t!="object"?!1:t.major===e&&t.minor===r&&t.patch===n,getHashCode:()=>e<<20|r<<10|n,compareTo:t=>e!==t.major?e-t.major:r!==t.minor?r-t.minor:n-t.patch}}extractMetadata(e){let r=this.createEmptyMetadata();for(let[n,a]of Object.entries(e))if(a&&typeof a=="object"&&f(a.type)){r.type_=a.type;let t=n,o=a.publisher,i=a.version?this.parseVersion(a.version):void 0;return o&&t&&(r.namespace_={publisher:o,package_:t,version:i,toString:function(){return this.version?`${this.publisher}/${this.package_}@${this.version.major}.${this.version.minor}.${this.version.patch}`:`${this.publisher}/${this.package_}`},equals:s=>!s||typeof s!="object"?!1:s.publisher===o&&s.package_===t&&(!i||!s.version||i.equals(s.version)),getHashCode:()=>{let s=0;for(let p=0;p<o.length;p++)s=(s<<5)-s+o.charCodeAt(p);for(let p=0;p<t.length;p++)s=(s<<5)-s+t.charCodeAt(p);return s|0}}),a.imports&&Array.isArray(a.imports)&&(r.imports=this.parseImportsV3(a.imports)),this.addAllImportsGetter(r)}return r}extractBody(e,r){let n={};for(let[a,t]of Object.entries(e))if(t&&typeof t=="object"&&f(t.type)){let o={};for(let[i,s]of Object.entries(t))i==="publisher"||i==="version"||i==="imports"||(o[i]=s);n[a]=o}else n[a]=t;return n}parseVersion(e){if(typeof e=="string"){let r=e.split(".").map(Number);return this.createVersion(r[0]||0,r[1]||0,r[2]||0)}return this.createVersion(e.major||0,e.minor||0,e.patch||0)}parseImportsV3(e){let r={};for(let n of e)if(!(!n||typeof n!="object"))if(n.packages&&Array.isArray(n.packages)){let a=n.publisher;if(!a)throw new Error("PublisherImport requires 'publisher' property");r[a]||(r[a]=[]);for(let t of n.packages){if(!t||typeof t!="object")continue;let o=this.parseImportFromEmbeddedObject(t,a);r[a].push(o)}}else{let a=this.parseImportFromEmbeddedObject(n,n.publisher),t=a.publisher||"";r[t]||(r[t]=[]),r[t].push(a)}return r}parseImportFromEmbeddedObject(e,r){let n=e.package;if(!n)throw new Error("Import requires 'package' property");let a=e.match;if(!a)throw new Error("Import requires 'match' property");let t=e.version;if(!t)throw new Error("Import requires 'version' property");let o;if(e.mode!==void 0&&e.mode!==null){if(!d.includes(e.mode))throw new Error(`Import '${n}' has an unknown mode '${e.mode}'; expected one of: ${d.join(", ")}`);o=e.mode}return this.makeImport(n,a,t,r,e.alias,o)}makeImport(e,r,n,a,t,o){let i=this.parseVersion(n),s=this.parseVersionOperator(r),p=this.calculateMaxVersion(r,i);return{package_:`${e} ${r} ${i.toString()}`,publisher:a,packageName:e,versionOperator:s,version:i,alias:t,...o?{mode:o}:{},minVersion:i,maxVersion:p,toEmbeddedObject:()=>{let u={package:e,match:r,version:i.toString()};return t&&(u.alias=t),o&&(u.mode=o),u},toString:()=>t?`${e} ${r} ${i.toString()} as ${t}`:`${e} ${r} ${i.toString()}`}}buildImport(e,r,n,a){return this.makeImport(e,r,n,a)}parseVersionOperator(e){return l(e)}calculateMaxVersion(e,r){switch(e){case"~":return this.createVersion(r.major,r.minor+1,0);case"^":return r.major===0?this.createVersion(0,r.minor+1,0):this.createVersion(r.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(e){let r=[];for(let[n,a]of Object.entries(e)){let t={publisher:n,packages:a.map(o=>{let i=h(o.versionOperator),s={package:o.packageName,match:i,version:`${o.version.major}.${o.version.minor}.${o.version.patch}`};return o.alias&&(s.alias=o.alias),s})};r.push(t)}return r}};export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as v,g as D,l as L,m as I}from"./chunk-7IMLHHSA.js";var u=class{};var f=class extends u{statement=[];unresolvedPredicates=[];sourceDoc="";sourceKey};var p=class extends f{namespace;name;icon};var k=class extends f{name;rangeType};var s=class e extends u{subject;sourceKey;static parse(n){let t=new e;return t.subject=L.parse(n),t}};var h=class extends u{value;carrier;lexical;links;sourceKey};var c=class{predicate;object;sourceKey};var l=class extends c{carrier;lexical};var y=class e extends l{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var K=class e extends l{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var x=class extends l{};var b=class e extends c{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=s.parse(t),r}};var j=class extends c{};var S=class extends c{};var U=class extends y{links=[]};function R(e){return`${e.publisher}/${e.package_}/${e.name}`}function w(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}function T(e){let n=e.version;return n&&typeof n.major=="number"?`https://${e.publisher}/${e.package_}/${n.major}.${n.minor}.${n.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function B(e){return A(e,N)}var N={publisher:"kanonak.org",package_:"core-rdf",name:"type"};function A(e,n){let t=[];for(let r of $(e,n))r.item instanceof s&&t.push(r.item.subject);return t}function $(e,n){return M(e,n).flat()}function M(e,n){if(!(e instanceof f))return[];let t=[];for(let r of e.statement){let o=r.predicate;if(!(!o?.subject||!w(o.subject,n)))if(r instanceof b)t.push([{item:r.object,fromList:!1}]);else if(r instanceof j)t.push([{item:r.object,fromList:!1}]);else if(r instanceof U)t.push([{item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical,links:r.links},fromList:!1}]);else if(r instanceof y||r instanceof K||r instanceof x)t.push([{item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical},fromList:!1}]);else if(r instanceof S){let i=[];for(let a of r.object??[])if(a instanceof s||a instanceof k)i.push({item:a,fromList:!0});else if(a instanceof h)i.push({item:{literal:!0,value:a.value,carrier:a.carrier,lexical:a.lexical,links:a.links},fromList:!0});else throw new Error(`rawValuesOf: a list value of '${n.name}' is a ${a?.constructor?.name??typeof a}; list items are references, embedded values or literals.`);t.push(i)}else throw new Error(`rawValuesOf: '${n.name}' has a statement of unknown kind ${r?.constructor?.name??typeof r}.`)}return t}function O(e,n){if(!(e instanceof f))return!1;for(let t of e.statement)if(t.predicate?.subject?.name==="type"&&t instanceof b){let o=t.object;if(w(o.subject,n))return!0}return!1}function H(e,n){let t=[];for(let r of e)r instanceof p&&O(r,n)&&t.push(r);return t}function W(e,n){let t=n.version,r=t&&typeof t.major=="number"?`${n.publisher}/${n.package_}@${t.major}.${t.minor}.${t.patch}`:void 0;for(let o of e){if(!(o instanceof p)||o.name!==n.name)continue;let i=o.namespace||"";if(r!==void 0){if(i===r)return o}else if(i.startsWith(`${n.publisher}/${n.package_}@`))return o}}function F(e,n){let t=[];for(let r of e){if(!(r instanceof p)||r.name!==n.name)continue;(r.namespace||"").startsWith(`${n.publisher}/${n.package_}@`)&&t.push(r)}return t.sort((r,o)=>{let i=D((r.namespace||"").split("@")[1]??""),a=D((o.namespace||"").split("@")[1]??"");return i?a?v(a,i):-1:a?1:0}),t}function g(e,n){for(let t of e.statement){let r=t.predicate;if(r?.subject&&w(r.subject,n))return t}}function Y(e,n){return g(e,n)!==void 0}function _(e,n){let t=g(e,n);if(t&&(t instanceof y||t instanceof K||t instanceof x))return t.object}function q(e,n){let t=_(e,n);return typeof t=="string"?t:void 0}function z(e,n){let t=g(e,n);if(t instanceof b)return t.object.subject}function G(e,n){let t=g(e,n);if(t instanceof j)return t.object}function J(e,n){let t=g(e,n);return t instanceof S?t.object??[]:[]}function Q(e,n,t,r){let o=Z(e,n,r);if(o.length===0)return[];let i=ee(t);return o.map(({value:a,address:m})=>{let d=a.fromList;if(a.item instanceof s){let P=i.resolve(a.item.subject);return P?{kind:"subject",node:P,uri:a.item.subject,address:m,fromList:d}:{kind:"unresolved",uri:a.item.subject,address:m,fromList:d}}if(a.item instanceof k)return{kind:"embedded",node:a.item,address:m,fromList:d};let V={kind:"literal",value:a.item.value,carrier:a.item.carrier,lexical:a.item.lexical,address:m,fromList:d};return a.item.links&&(V.links=a.item.links),V})}function X(e){let n=I(`${e.namespace}/${e.name}`);if(n.kind!=="resource")throw new Error(`subjectAddress: '${e.namespace}/${e.name}' is not a resource address`);return R(n.uri)}function Z(e,n,t){let r=$(e,n);if(r.length===0)return[];let o=t.includes("#")?`${t}.${n.name}`:`${t}#${n.name}`,i=r.length>1||r.some(a=>a.fromList);return r.map((a,m)=>({value:a,address:a.item instanceof k&&a.item.name?`${o}.${a.item.name}`:i?`${o}[${m}]`:o}))}var C=new WeakMap;function ee(e){let n=C.get(e);if(n)return n;let t=new Map,r=new Map;for(let o of e){if(!(o instanceof p))continue;let i=o.namespace||"",a=`${i}\0${o.name}`;t.has(a)||t.set(a,o);let m=i.indexOf("@");if(m>=0){let d=`${i.slice(0,m)}\0${o.name}`;r.has(d)||r.set(d,o)}}return n={resolve(o){let i=o.version;return i&&typeof i.major=="number"?t.get(`${o.publisher}/${o.package_}@${i.major}.${i.minor}.${i.patch}\0${o.name}`):r.get(`${o.publisher}/${o.package_}\0${o.name}`)}},C.set(e,n),n}var E=class{constructor(n,t){this.doc=n;this.broader=t}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(n){return this.broader.getDocumentAsync(n)}async getDocumentsByNamespaceAsync(n,t){return this.broader.getDocumentsByNamespaceAsync(n,t)}async getHighestCompatibleVersionAsync(n,t){return this.broader.getHighestCompatibleVersionAsync(n,t)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(n){return this.broader.getDocumentContentAsync(n)}async getDocumentUriAsync(n){return this.broader.getDocumentUriAsync(n)}};export{u as a,f as b,p as c,k as d,s as e,h as f,c as g,l as h,y as i,K as j,x as k,b as l,j as m,S as n,U as o,R as p,w as q,T as r,B as s,A as t,$ as u,M as v,O as w,H as x,W as y,F as z,g as A,Y as B,_ as C,q as D,z as E,G as F,J as G,Q as H,X as I,Z as J,E as K};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{VersionOperator as a}from"@kanonak-protocol/types/document/models/enums";function y(e){switch(e){case"=":return a.Exact;case"~":return a.Compatible;case"^":return a.Major;case"*":return a.Any;default:return a.Compatible}}function w(e){switch(e){case a.Exact:return"=";case a.Compatible:return"~";case a.Major:return"^";case a.Any:return"*";default:return"~"}}function c(e,r){return e.major!==r.major?e.major-r.major:e.minor!==r.minor?e.minor-r.minor:e.patch-r.patch}function g(e,r){return e.major===r.major&&e.minor===r.minor&&e.patch===r.patch}function h(e){return`${e.major}.${e.minor}.${e.patch}`}function k(e,r,t){let n=`${e}.${r}.${t}`;return{major:e,minor:r,patch:t,toString:()=>n,equals:s=>s?.major===e&&s?.minor===r&&s?.patch===t,getHashCode:()=>e<<20|r<<10|t,compareTo:s=>e!==s.major?e-s.major:r!==s.minor?r-s.minor:t-s.patch}}function K(e){let r=/^(\d+)\.(\d+)\.(\d+)$/.exec(e);return r?k(Number(r[1]),Number(r[2]),Number(r[3])):null}function b(e,r){return c(e,r)>=0&&e.major===r.major&&e.minor===r.minor}function v(e,r){return r.major===0?c(e,r)>=0&&e.major===0&&e.minor===r.minor:c(e,r)>=0&&e.major===r.major}function E(e,r){switch(r.versionOperator){case a.Exact:return g(e,r.version);case a.Compatible:return b(e,r.version);case a.Major:return v(e,r.version);case a.Any:return c(e,r.minVersion)>=0;default:return!1}}function I(e,r={}){let{requestedVersion:t}=r;if(e.length===0)return{chosen:null,alternatives:[],multipleVersionsPresent:!1,exactRequestedVersionMissing:!!t};if(t){let s=e.find(i=>{let o=i.metadata.namespace_?.version;return!!o&&h(o)===t});return s?{chosen:s,alternatives:e.filter(i=>i!==s),multipleVersionsPresent:e.length>1,exactRequestedVersionMissing:!1}:{chosen:null,alternatives:e,multipleVersionsPresent:e.length>1,exactRequestedVersionMissing:!0}}if(e.length===1)return{chosen:e[0],alternatives:[],multipleVersionsPresent:!1,exactRequestedVersionMissing:!1};let n=[...e].sort((s,i)=>{let o=s.metadata.namespace_?.version,u=i.metadata.namespace_?.version;return!o&&!u?0:o?u?c(u,o):-1:1});return{chosen:n[0],alternatives:n.slice(1),multipleVersionsPresent:!0,exactRequestedVersionMissing:!1}}var p=class e{constructor(r,t,n,s){this.publisher=r;this.package_=t;this.name=n;this.version=s}publisher;package_;name;version;static parse(r){if(!r||r.trim().length===0)throw new Error("Kanonak URI string cannot be null or empty");let t=r.split("/");if(t.length!==3)throw new Error(`Invalid Kanonak URI: ${r}. Expected format: publisher/package[@version]/name`);let[n,s,i]=t;if(!n||!s||!i)throw new Error(`Invalid Kanonak URI: ${r}. Expected format: publisher/package[@version]/name`);let o=s.indexOf("@");if(o===-1)return new e(n,s,i,void 0);let u=s.substring(0,o),l=s.substring(o+1);if(!u||!l)throw new Error(`Invalid Kanonak URI: ${r}. Expected format: publisher/package[@version]/name`);let m=l.split(".").map(Number),f=V(m[0]||0,m[1]||0,m[2]||0);return new e(n,u,i,f)}toString(){return this.version?`${this.publisher}/${this.package_}@${this.version.major}.${this.version.minor}.${this.version.patch}/${this.name}`:`${this.publisher}/${this.package_}/${this.name}`}};function V(e,r,t){return{major:e,minor:r,patch:t,toString:()=>`${e}.${r}.${t}`,equals:n=>!n||typeof n!="object"?!1:n.major===e&&n.minor===r&&n.patch===t,getHashCode:()=>e<<20|r<<10|t,compareTo:n=>e!==n.major?e-n.major:r!==n.minor?r-n.minor:t-n.patch}}function R(e){if(!e||e.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let r=e.trim(),t=r.split("/");if(t.length===1){let n=t[0];if(!n)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(n.includes("@"))throw new Error(`Invalid Kanonak address: "${e}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:n}}if(t.length===2){let[n,s]=t;if(!n||!s)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let i=s.indexOf("@");if(i===-1)return{kind:"package",publisher:n,package_:s};let o=s.substring(0,i),u=s.substring(i+1);if(!o||!u)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let l=d(u);return{kind:"package",publisher:n,package_:o,version:l}}return{kind:"resource",uri:p.parse(r)}}function A(e){switch(e.kind){case"publisher":return e.publisher;case"package":return e.version?`${e.publisher}/${e.package_}@${e.version.major}.${e.version.minor}.${e.version.patch}`:`${e.publisher}/${e.package_}`;case"resource":return e.uri.toString()}}function d(e){let r=e.split(".").map(Number);return $(r[0]||0,r[1]||0,r[2]||0)}function $(e,r,t){return{major:e,minor:r,patch:t,toString:()=>`${e}.${r}.${t}`,equals:n=>!n||typeof n!="object"?!1:n.major===e&&n.minor===r&&n.patch===t,getHashCode:()=>e<<20|r<<10|t,compareTo:n=>e!==n.major?e-n.major:r!==n.minor?r-n.minor:t-n.patch}}export{y as a,w as b,c,g as d,h as e,k as f,K as g,b as h,v as i,E as j,I as k,p as l,R as m,A as n};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-WXXZOJ4O.js";import{e as he,f as u,k as Sn}from"./chunk-SBWD7EOG.js";import{a as ft}from"./chunk-5ZRVFYCP.js";import{a as $t}from"./chunk-PEJALHXK.js";import{$ as bt,_ as ht,oa as tn,pa as we,qa as an,ra as $n,va as vt}from"./chunk-6WOPXTIL.js";import{A as gt,B as un,C as Xe,D as xe,E as Oe,F as kt,G as Mn,H as vn,K as yt,b as Ue,c as Y,d as D,e as U,i as ae,j as be,k as ke,l as Q,m as le,n as ue,o as De,p as B,q as re,r as pt,s as mt,t as je,u as Ee,w as _,y as Te,z as oe}from"./chunk-LK5SHY4B.js";import{c as hn,d as lt,e as bn,g as ut}from"./chunk-GGK6A6QK.js";import{a as yn}from"./chunk-FUUTGGJS.js";import{ExpressionError as Oa,evaluates as Ia,validateMatchesPattern as Fa}from"@kanonak-protocol/expression";var q=class extends Error{constructor(n,t){super(`${n} (at ${t})`);this.path=t}path};function bi(r,e){let n=r.name,t=Ja(e),a={catalog:e,depth:0};if(_(r,u.InstanceTransformation))return Ta(r,n,a,t);if(_(r,u.SetTransformation))return Pa(r,n,a,t);throw new q("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Ta(r,e,n,t){return{kind:"instance",name:r.name,inputPattern:Et(r,e),rule:wn(r,u.rule,`${e}.rule`,n),artifactName:wn(r,u.artifactName,`${e}.artifactName`,n),outputs:xt(r,`${e}.outputs`),overrides:Lt(r,`${e}.formatOverrides`,n),fragments:t}}function Pa(r,e,n,t){let a=Pe(r,u.partitionBy);return{kind:"set",name:r.name,inputPattern:Et(r,e),rule:wn(r,u.rule,`${e}.rule`,n),artifactName:wn(r,u.artifactName,`${e}.artifactName`,n),outputs:xt(r,`${e}.outputs`),overrides:Lt(r,`${e}.formatOverrides`,n),partitionBy:a,fragments:t}}function Et(r,e){let n=Ct(r,u.inputPattern);if(!n)throw new q("inputPattern is required",e);return Va(n,`${e}.inputPattern`)}function Va(r,e){let n=Pe(r,u.matchesClass);if(!n)throw new q("matchesClass is required",e);let t=[];for(let o of Le(r,u.requires))if(o instanceof Q)t.push(Hn(o.object.subject));else if(o instanceof ue)for(let i of o.object)i instanceof U&&t.push(Hn(i.subject));let a=[],s=0;for(let o of Le(r,u.sortBy))if(o instanceof ue)for(let i of o.object)i instanceof D&&a.push(St(i,`${e}.sortBy[${s++}]`));else o instanceof le&&a.push(St(o.object,`${e}.sortBy[${s++}]`));return{matchesClass:n,requires:t,sortBy:a}}function St(r,e){let n=Pe(r,u.byProperty);if(!n)throw new q("SortKey.byProperty is required",e);let t=Pe(r,u.order);if(!t)throw new q("SortKey.order is required",e);if(re(t,u.ascending))return{byProperty:n,order:"ascending"};if(re(t,u.descending))return{byProperty:n,order:"descending"};throw new q(`SortKey.order must reference tx.ascending or tx.descending; got ${t.publisher}/${t.package_}/${t.name}`,e)}function wn(r,e,n,t){let a=Gn(r,e,n,t);if(!a)throw new q("expression is required",n);return qe(a,n,t)}function qn(r,e,n,t){return Ee(r,e).map((a,s,o)=>{let i=o.length>1||a.fromList?`${n}[${s}]`:n;if(a.item instanceof D)return a.item;if(a.item instanceof U){let c=Te(t.catalog,a.item.subject);if(!c)throw new q(`references '${B(a.item.subject)}', which does not resolve in the catalog`,i);return c}throw new q(`expects a node, not the literal ${JSON.stringify(a.item.value)}`,i)})}function Gn(r,e,n,t){let a=qn(r,e,n,t);if(a.length>1)throw new q(`expects one expression, has ${a.length}`,n);return a[0]}function qe(r,e,n){if(r instanceof Y){let t=we(r),a=t?B(t):`${r.namespace}/${r.name}`,s=n.visiting??new Set;if(s.has(a))throw new q(`named expressions form a cycle: ${[...s,a].join(" -> ")}`,e);return wt(r,a,{...n,visiting:new Set([...s,a])})}return wt(r,e,n)}function wt(r,e,n){if(_(r,u.StringLiteral))return{kind:"string-literal",value:ye(r,u.stringLiteral,e)};if(_(r,u.IntegerLiteral))return{kind:"integer-literal",value:Rt(r,u.integerLiteral,e)};if(_(r,u.DecimalLiteral))return{kind:"decimal-literal",value:Rt(r,u.decimalLiteral,e)};if(_(r,u.BooleanLiteral))return{kind:"boolean-literal",value:er(r,u.booleanLiteral,e)};if(_(r,u.VarRef))return{kind:"var-ref",varName:ye(r,u.varName,e)};if(_(r,u.PropertyRead))return{kind:"property-read",source:w(r,u.readSource,`${e}.readSource`,n),readProp:Be(r,u.readProp,e,"readProp")};if(_(r,u.Traverse))return{kind:"traverse",source:w(r,u.traverseSource,`${e}.traverseSource`,n),through:Be(r,u.through,e,"through"),step:w(r,u.step,`${e}.step`,n)};if(_(r,u.BuildAstNode))return{kind:"build-ast-node",astClass:Be(r,u.astClass,e,"astClass"),set:Ba(r,`${e}.set`,n)};if(_(r,u.When))return{kind:"when",condition:w(r,u.condition,`${e}.condition`,n),thenBuild:w(r,u.thenBuild,`${e}.thenBuild`,n),elseBuild:Da(r,u.elseBuild,`${e}.elseBuild`,n)};if(_(r,u.Concat))return{kind:"concat",parts:Nn(r,u.parts,`${e}.parts`,n)};if(_(r,u.Fallback))return{kind:"fallback",primary:w(r,u.primary,`${e}.primary`,n),alternate:w(r,u.alternate,`${e}.alternate`,n)};if(_(r,u.UriName))return{kind:"uri-name",source:w(r,u.uriNameOf,`${e}.uriNameOf`,n)};if(_(r,u.UriPublisher))return{kind:"uri-publisher",source:w(r,u.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(_(r,u.UriPackage))return{kind:"uri-package",source:w(r,u.uriPackageOf,`${e}.uriPackageOf`,n)};if(_(r,u.UriVersion))return{kind:"uri-version",source:w(r,u.uriVersionOf,`${e}.uriVersionOf`,n)};if(_(r,u.SubjectUri))return{kind:"subject-uri",source:w(r,u.subjectOf,`${e}.subjectOf`,n)};if(_(r,u.UriLiteral))return{kind:"uri-literal",refTo:Be(r,u.refTo,e,"refTo")};if(_(r,u.DisplayLabel))return{kind:"display-label",labelTarget:Be(r,u.labelTarget,e,"labelTarget"),labelSource:Be(r,u.labelSource,e,"labelSource")};if(_(r,u.ResolveRef))return{kind:"resolve-ref",source:w(r,u.resolveSource,`${e}.resolveSource`,n)};if(_(r,u.Normalize))return{kind:"normalize",source:w(r,u.normSource,`${e}.normSource`,n),normKind:qa(r,e)};if(_(r,u.UnescapedString))return{kind:"unescaped-string",source:w(r,u.unescapedSource,`${e}.unescapedSource`,n)};if(_(r,u.RenderMarkdown))return{kind:"render-markdown",source:w(r,u.renderSource,`${e}.renderSource`,n),readProp:Be(r,u.renderProp,e,"renderProp"),format:Ga(r,e)};if(_(r,u.IsSet))return{kind:"is-set",check:w(r,u.checkExpr,`${e}.checkExpr`,n)};if(_(r,u.CallFragment))return Ya(r,e,n);if(_(r,u.Join))return{kind:"join",source:w(r,u.source,`${e}.source`,n),separator:ye(r,u.separator,e)};if(_(r,u.Count))return{kind:"count",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Sum))return{kind:"sum",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Min))return{kind:"min",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Max))return{kind:"max",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Average))return{kind:"average",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.ForEach))return{kind:"for-each",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),emit:w(r,u.emit,`${e}.emit`,n)};if(_(r,u.ListMap))return{kind:"list-map",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),mapBody:w(r,u.mapBody,`${e}.mapBody`,n)};if(_(r,u.Filter))return{kind:"filter",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),predicate:w(r,u.predicate,`${e}.predicate`,n)};if(_(r,u.PartitionBy))return{kind:"partition-by",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),partitionKey:w(r,u.partitionKey,`${e}.partitionKey`,n)};if(_(r,u.DistinctBy))return{kind:"distinct-by",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),distinctKey:w(r,u.distinctKey,`${e}.distinctKey`,n)};if(_(r,u.AllStatements))return{kind:"all-statements",source:w(r,u.statementsOf,`${e}.statementsOf`,n)};if(_(r,u.StatementPredicate))return{kind:"statement-predicate",source:w(r,u.predicateOf,`${e}.predicateOf`,n)};if(_(r,u.StatementValue))return{kind:"statement-value",source:w(r,u.valueOf,`${e}.valueOf`,n)};if(_(r,u.DateFormat))return{kind:"date-format",source:w(r,u.dateSource,`${e}.dateSource`,n),format:Wa(r,e)};if(_(r,u.NumberFormat)){let a=Dn(r,u.fractionDigits);if(a!==void 0&&(!Number.isInteger(a)||a<0||a>20))throw new q(`fractionDigits must be an integer between 0 and 20; got ${a}`,e);let s=He(r,u.currencyCode);return{kind:"number-format",source:w(r,u.numberSource,`${e}.numberSource`,n),style:za(r,e),...a!==void 0?{fractionDigits:a}:{},...s!==void 0?{currencyCode:s}:{}}}let t=Na.find(a=>_(r,a.type));if(t){let a=B(t.type);if(!Ia(a))throw new q(`${a} is a numeric operator the expression runtime does not evaluate`,e);return{kind:"numeric-op",type:a,name:t.type.name,operands:t.operands.map(s=>({name:s.name,expr:w(r,s,`${e}.${s.name}`,n)}))}}if(_(r,u.Reverse))return{kind:"reverse",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.WindowedMap)){let a=Dn(r,u.windowSize);if(a===void 0||!Number.isInteger(a)||a<1)throw new q("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:w(r,u.source,`${e}.source`,n),windowSize:a,windowVar:ye(r,u.windowVar,e),windowBody:w(r,u.windowBody,`${e}.windowBody`,n)}}if(_(r,u.PairwiseMap))return{kind:"pairwise-map",source:w(r,u.source,`${e}.source`,n),firstVar:ye(r,u.firstVar,e),secondVar:ye(r,u.secondVar,e),pairBody:w(r,u.pairBody,`${e}.pairBody`,n)};if(_(r,u.Scan))return{kind:"scan",source:w(r,u.source,`${e}.source`,n),initialState:w(r,u.initialState,`${e}.initialState`,n),stateVar:ye(r,u.stateVar,e),elementVar:ye(r,u.elementVar,e),accumulate:w(r,u.accumulate,`${e}.accumulate`,n)};if(_(r,u.ListItemAt))return{kind:"list-item-at",source:w(r,u.source,`${e}.source`,n),itemIndex:w(r,u.itemIndex,`${e}.itemIndex`,n)};if(_(r,u.Equals))return{kind:"equals",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.GreaterThan))return{kind:"greater-than",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.LessThan))return{kind:"less-than",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.LessThanOrEqual))return{kind:"less-than-or-equal",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.Not))return{kind:"not",operand:w(r,u.operand,`${e}.operand`,n)};if(_(r,u.And))return{kind:"and",operands:Nn(r,u.operands,`${e}.operands`,n)};if(_(r,u.Or))return{kind:"or",operands:Nn(r,u.operands,`${e}.operands`,n)};if(_(r,u.Contains))return{kind:"contains",haystack:w(r,u.haystack,`${e}.haystack`,n),needle:w(r,u.needle,`${e}.needle`,n)};if(_(r,u.Matches)){let a=ye(r,u.pattern,e);try{Fa(a)}catch(s){throw s instanceof Oa?new q(s.message,`${e}.pattern`):s}return{kind:"matches",source:w(r,u.matchSource,`${e}.matchSource`,n),pattern:a}}if(_(r,u.IsReference))return{kind:"is-reference",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsEmbedded))return{kind:"is-embedded",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsList))return{kind:"is-list",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsString))return{kind:"is-string",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsNumber))return{kind:"is-number",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsBoolean))return{kind:"is-boolean",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.StatementObject))return{kind:"statement-object",source:w(r,u.statementSource,`${e}.statementSource`,n)};if(_(r,u.Let))return{kind:"let",bindName:ye(r,u.letName,e),bindValue:w(r,u.letValue,`${e}.letValue`,n),body:w(r,u.letBody,`${e}.letBody`,n)};if(_(r,u.GetStatementByName))return{kind:"get-statement-by-name",inSubject:w(r,u.inSubject,`${e}.inSubject`,n),byName:w(r,u.byName,`${e}.byName`,n)};throw new q("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}var Aa=[u.arithLeft,u.arithRight],Ma=[u.value],Na=[...[u.Add,u.Subtract,u.Multiply,u.Divide,he.Power,he.Modulo,he.Minimum,he.Maximum].map(r=>({type:r,operands:Aa})),...[u.Abs,u.Negate,he.Exp,he.Ln,he.Log10,he.Sqrt,he.Floor,he.Ceil,he.Round,he.Sign].map(r=>({type:r,operands:Ma})),{type:he.Clip,operands:[he.clipValue,he.clipLower,he.clipUpper]}];function w(r,e,n,t){let a=Gn(r,e,n,t);if(!a)throw new q("child expression is required",n);return qe(a,n,t)}function Da(r,e,n,t){let a=Gn(r,e,n,t);if(a)return qe(a,n,t)}function Nn(r,e,n,t){return qn(r,e,n,t).map((a,s)=>qe(a,`${n}[${s}]`,t))}function Ba(r,e,n){return qn(r,u.set,e,n).map((t,a)=>Ha(t,`${e}[${a}]`,n))}function Ha(r,e,n){return{field:Be(r,u.field,e,"field"),value:w(r,u.bindValue,`${e}.bindValue`,n)}}function qa(r,e){let n=Pe(r,u.normKind);if(!n)throw new q("normKind is required",e);if(re(n,u.NORM_TRIM_END))return"trim-end";if(re(n,u.NORM_TO_UPPER))return"to-upper";if(re(n,u.NORM_TO_LOWER))return"to-lower";if(re(n,u.NORM_FIRST_CHAR))return"first-char";throw new q(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function Ga(r,e){let n=Pe(r,u.renderFormat);if(!n)throw new q("renderFormat is required",e);if(re(n,u.RENDER_HTML))return"html";if(re(n,u.RENDER_MARKDOWN))return"markdown";throw new q(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var _t=new Set(["decimal","percent","basis-points","currency","compact"]);function za(r,e){let n=He(r,u.numberStyle);if(n===void 0)throw new q("numberStyle is required",e);if(!_t.has(n))throw new q(`Unknown numberStyle "${n}"; supported: ${[..._t].join(", ")}`,e);return n}var jt=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function Wa(r,e){let n=He(r,u.dateFormat);if(!n)throw new q("dateFormat is required",e);if(!jt.has(n))throw new q(`Unknown dateFormat "${n}"; supported: ${[...jt].join(", ")}`,e);return n}function Ya(r,e,n){let t=Pe(r,u.fragmentRef);if(!t)throw new q("fragmentRef is required",e);if(!Qa(n.catalog,t))throw new q(`ExpressionFragment not found: ${t.publisher}/${t.package_}/${t.name}`,e);return{kind:"call-fragment",fragmentKey:Xa(t)}}function Xa(r){return`${r.publisher}/${r.package_}/${r.name}`}function Ja(r){let e=new Map,n=[];for(let t of r){if(!(t instanceof Y)||!_(t,u.ExpressionFragment))continue;let a=Ct(t,u.body);if(!a)continue;let s=(t.namespace||"").split("@")[0]||"",o=s.indexOf("/");if(o<0)continue;let i=s.substring(0,o),c=s.substring(o+1),l=`${i}/${c}/${t.name}`;n.push({key:l,subject:t,bodyEmb:a,pubPkgName:`${s}/${t.name}`})}for(let t of n){let a=qe(t.bodyEmb,`fragment(${t.pubPkgName})`,{catalog:r,depth:0});e.set(t.key,a)}return e}function Qa(r,e){for(let n of r)if(!(!(n instanceof Y)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&_(n,u.ExpressionFragment))return n}function xt(r,e){let n=new Set;for(let t of Le(r,u.outputs))if(t instanceof Q)n.add(t.object.subject.name);else if(t instanceof ue)for(let a of t.object)a instanceof U&&n.add(a.subject.name);if(n.size===0)throw new q("outputs is required (at least one OutputFormat)",e);return n}function Lt(r,e,n){let t=new Map,a=0;for(let s of Le(r,u.formatOverrides))if(s instanceof ue){for(let o of s.object)if(o instanceof D){let[i,c]=Kt(o,`${e}[${a++}]`);t.set(i,c)}}else if(s instanceof le){let[o,i]=Kt(s.object,`${e}[${a++}]`);t.set(o,i)}return t}function Kt(r,e){let n=Pe(r,u.formatTarget);if(!n)throw new q("formatTarget is required",e);let t=[];for(let i of Le(r,u.metadataKeys))if(i instanceof ae)t.push(i.object);else if(i instanceof ue)for(let c of i.object){let l=c.value;typeof l=="string"&&t.push(l)}let a=new Map;for(let i of Le(r,u.metadataRenames))if(i instanceof ue){for(let c of i.object)if(c instanceof D){let l=He(c,u.fromKey),d=He(c,u.toKey);l&&d&&a.set(l,d)}}else if(i instanceof le){let c=i.object,l=He(c,u.fromKey),d=He(c,u.toKey);l&&d&&a.set(l,d)}let s=Bn(r,u.trailingNewline),o=Bn(r,u.omitWrapper);return[n.name,{metadataKeys:t.length>0?t:void 0,metadataRenames:a,trailingNewline:s,omitWrapper:o}]}function Za(r){return r.predicate?.subject}function Le(r,e){let n=[];for(let t of r.statement){let a=Za(t);a&&re(a,e)&&n.push(t)}return n}function Ct(r,e){for(let n of Le(r,e))if(n instanceof le)return n.object}function Pe(r,e){for(let n of Le(r,e))if(n instanceof Q)return Hn(n.object.subject)}function He(r,e){for(let n of Le(r,e))if(n instanceof ae)return n.object}function Dn(r,e){for(let n of Le(r,e))if(n instanceof be)return n.object}function Bn(r,e){for(let n of Le(r,e))if(n instanceof ke)return n.object}function ye(r,e,n){let t=He(r,e);if(t===void 0)throw new q(`${e.name} (string) is required`,n);return t}function Rt(r,e,n){let t=Dn(r,e);if(t===void 0)throw new q(`${e.name} (number) is required`,n);return t}function er(r,e,n){let t=Bn(r,e);if(t===void 0)throw new q(`${e.name} (boolean) is required`,n);return t}function Be(r,e,n,t){let a=Pe(r,e);if(!a)throw new q(`${t} (URI reference) is required`,n);return a}function Hn(r){return{publisher:r.publisher,package_:r.package_,name:r.name}}var Je="kanonak.org",Tt="look",dn="core-rdf",Pt={publisher:Je,package_:Tt,name:"displayLabel"},Vt={publisher:Je,package_:Tt,name:"displaySummary"},nr={publisher:Je,package_:dn,name:"subClassOf"},tr={publisher:Je,package_:dn,name:"label"},ar={publisher:Je,package_:dn,name:"comment"},Ut=new yn(Je,dn,"Resource"),rr=8;function G(r,e){return At(r,e,new Set)}function At(r,e,n){let t=Ft(r,e,Pt)??tr,a=Ft(r,e,Vt)??ar,s=Ot(r,e,t,n)??e.name,o=Ot(r,e,a,n);return{label:s,summary:o}}function Ot(r,e,n,t){for(let a of e.statement){let s=a.predicate;if(!(!s?.subject||!re(s.subject,n))){if(a instanceof ae)return a.object;if(a instanceof be||a instanceof ke)return String(a.object);if(a instanceof Q)return It(r,a.object.subject,t);if(a instanceof ue){let o=[];for(let i of a.object??[])if(i instanceof U){let c=It(r,i.subject,t);c&&o.push(c)}if(o.length>0)return o.join(", ")}return}}}function It(r,e,n){let t=B(e);if(n.has(t)||n.size>=rr)return e.name;let[a]=oe(r,e);if(!a)return e.name;let s=new Set(n);return s.add(t),At(r,a,s).label}function Ft(r,e,n){let t=Oe(e,n);if(t)return t;let a=new Set,s=je(e,sr);for(;s.length>0;){let o=s.shift(),i=B(o);if(a.has(i))continue;a.add(i);let c=oe(r,o);for(let l of c){let d=Oe(l,n);if(d)return d}for(let l of c)s.push(...je(l,nr))}if(!a.has(B(Ut)))for(let o of oe(r,Ut)){let i=Oe(o,n);if(i)return i}}var sr={publisher:Je,package_:dn,name:"type"};var or="kanonak.org",Qe=(r,e)=>({publisher:or,package_:r,name:e}),ir=Qe("look","source"),Mt=Qe("look","connectors"),cr=Qe("look","relation"),lr=Qe("look","lineStyle"),ur=Qe("look","participants"),dr=Qe("core-owl","SymmetricProperty"),fr=Qe("core-owl","inverseOf"),Nt=new Set(["solid","dotted","open","thick"]);function Dt(r){return Oe(r,ir)}function Bt(r,e){let n=kt(e,Mt),t=n?[n]:Mn(e,Mt),a=[];for(let s of t){if(!(s instanceof D))continue;let o=Oe(s,cr);if(!o)continue;let i=xe(s,lr),c=i!==void 0&&Nt.has(i);a.push({relation:o,subject:oe(r,o)[0],declaredStyle:c?i:void 0,invalidStyle:i!==void 0&&!c?i:void 0})}return a}function Ht(r,e){let n=[];for(let t of Mn(e,ur)){if(!(t instanceof U))continue;let a=oe(r,t.subject)[0];a&&n.push(a)}return n}function fn(r,e,n){for(let t of mt(e))if(re(t,n)||an(r,t).some(a=>re(a,n)))return!0;return!1}function qt(r,e,n){let t=!!e.subject&&fn(r,e.subject,dr);return e.declaredStyle?{style:e.declaredStyle,undirected:t}:e.subject&&je(e.subject,fr).some(s=>n.some(o=>re(s,o.relation)))?{style:"dotted",undirected:t}:{style:"solid",undirected:t}}function zn(r,e,n){let t=Dt(n);if(!t)return _n("the band declares no look.source");let a=Bt(r,n);if(a.length===0)return _n("the band declares no look.connectors \u2014 nothing can be a message");let s=gt(e,t);if(!s)return{..._n(),sourceAbsent:!0};if(!(s instanceof De))return _n(`look.source ${B(t)} is not a Markdown-ranged property \u2014 the order of a sequence comes from prose [[references]]`);let o=[],i=[],c=0;for(let h of s.links){if(!h.target)continue;let b=h.target.subject,m=oe(r,b)[0];m&&($n(r,m)!==void 0?a.some(y=>re(b,y.relation))?o.push({kind:"selector",relation:b}):i.push(b):(o.push({kind:"participant",subject:m}),c++))}let l=[],d=[],f,p;for(let h of o){if(h.kind==="selector"){p=h.relation;continue}let b=h.subject;if(f){let m=p?a.filter(T=>re(p,T.relation)):a,y=we(b),v=we(f),E=[],K=[];for(let T of m){let{style:L,undirected:S}=qt(r,T,a);y&&je(f,T.relation).some(W=>B(W)===B(y))?E.push({from:f,to:b,relation:T.relation,style:L,undirected:S}):v&&je(b,T.relation).some(W=>B(W)===B(v))&&K.push({from:b,to:f,relation:T.relation,style:L,undirected:S})}let O=E.length>0?E:K;l.push(...O),O.length===0&&Ve(f)!==Ve(b)&&d.push({prev:f,next:b,selected:p}),p=void 0}f=b}let g=new Map;for(let h of Ht(r,n))g.set(Ve(h),h);for(let h of l)g.has(Ve(h.from))||g.set(Ve(h.from),h.from),g.has(Ve(h.to))||g.set(Ve(h.to),h.to);return{messages:l,gaps:d,lifelines:[...g.values()],mentions:c,strayPropertyRefs:i,sourceAbsent:!1}}function Ve(r){return`${r.namespace}/${r.name}`}function _n(r){return{messages:[],gaps:[],lifelines:[],mentions:0,strayPropertyRefs:[],sourceAbsent:!1,...r?{problem:r}:{}}}var pr="kanonak.org",mr="core-shacl",_e=r=>({publisher:pr,package_:mr,name:r}),gr=_e("NodeShape"),kr=_e("targetClass"),hr=_e("property"),br=_e("path"),yr=_e("minCount"),vr=_e("maxCount"),$r=_e("in"),Sr=_e("pattern"),wr=_e("flags"),_r=_e("minLength"),jr=_e("maxLength"),Kr=_e("minInclusive"),Rr=_e("maxInclusive"),Er=_e("message");function rn(r){return typeof r=="number"?r:void 0}function xr(r){let e={},n=rn(Xe(r,yr)),t=rn(Xe(r,vr));n!==void 0&&(e.minCount=n),t!==void 0&&(e.maxCount=t);let a=rn(Xe(r,_r)),s=rn(Xe(r,jr));a!==void 0&&(e.minLength=a),s!==void 0&&(e.maxLength=s);let o=rn(Xe(r,Kr)),i=rn(Xe(r,Rr));o!==void 0&&(e.minInclusive=o),i!==void 0&&(e.maxInclusive=i);let c=xe(r,Sr);if(c!==void 0){let f=xe(r,wr);e.pattern=f!==void 0?{regex:c,flags:f}:{regex:c}}let l=Ee(r,$r).map(f=>f.item).filter(f=>"literal"in f).map(f=>f.value);l.length>0&&(e.enumValues=l);let d=xe(r,Er);return d!==void 0&&(e.message=d),e}function Lr(r,e){let n=[];for(let{item:t}of Ee(e,hr))if(t instanceof D)n.push(t);else if(t instanceof U){let a=Te(r,t.subject);a&&n.push(a)}return n}function Cr(r){let e=new Map;for(let n of r){if(!(n instanceof Y)||!_(n,gr))continue;let t=Oe(n,kr);if(!t)continue;let a=B(t);for(let s of Lr(r,n)){let o=Oe(s,br);if(!o)continue;let i=xr(s);if(Ur(s,i))continue;let c={pathKey:B(o),constraints:i},l=e.get(a);l?l.push(c):e.set(a,[c])}}return e}var Gt=new WeakMap;function pn(r){let e=Gt.get(r);return e||(e=Cr(r),Gt.set(r,e)),e}function Ur(r,e){return un(r,ht)||un(r,bt)?Object.keys(e).every(t=>t==="message"):!1}function Or(r,e){e.minCount!==void 0&&(r.minCount=e.minCount),e.maxCount!==void 0&&(r.maxCount=e.maxCount),e.minLength!==void 0&&(r.minLength=e.minLength),e.maxLength!==void 0&&(r.maxLength=e.maxLength),e.minInclusive!==void 0&&(r.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(r.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(r.pattern=e.pattern),e.enumValues!==void 0&&(r.enumValues=e.enumValues),e.message!==void 0&&(r.message=e.message)}function zt(r,e,n){let t=B(n),a=!1,s={};for(let o=e.length-1;o>=0;o--){let i=r.get(B(e[o]));if(i)for(let c of i)c.pathKey===t&&(a=!0,Or(s,c.constraints))}if(a)return s.cardinality=s.maxCount===1?"single":"list",s.required=(s.minCount??0)>=1,s}var Ze="kanonak.org",Kn="core-rdf",Wt="core-xsd",Ir={publisher:Ze,package_:Kn,name:"subClassOf"},Yt={publisher:Ze,package_:Kn,name:"label"},Xt={publisher:Ze,package_:Kn,name:"comment"},Jt={publisher:Ze,package_:"core-owl",name:"oneOf"},Qt=r=>r;function Fr(r,e,n){if(e.publisher===Ze&&e.package_===Kn&&e.name==="Literal")return{kind:"datatype",uri:e};let a=Te(r,e);if(a){let s=Qt(a);if(tn.isDatatypeType(s))return{kind:"datatype",uri:e};if(tn.isClassType(s))return{kind:"class",uri:we(a)??e,localName:a.name}}return e.publisher===Ze&&e.package_===Wt?{kind:"datatype",uri:e}:n==="datatype"?{kind:"datatype",uri:e}:{kind:"class",uri:e,localName:e.name}}function Tr(r,e,n){if(!e.range)throw new Error(`Property ${e.uri.publisher}/${e.uri.package_}/${e.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let t=Fr(r,e.range,e.kind),a=e.kind==="object"?"object":e.kind==="datatype"?"datatype":t.kind==="class"?"object":"datatype";return{uri:e.uri,localName:e.uri.name,kind:a,range:t,...e.label!==void 0?{label:e.label}:{},...e.comment!==void 0?{comment:e.comment}:{},...n??{}}}var jn=r=>new yn(Ze,Wt,r);function Pr(r){return typeof r=="boolean"?jn("boolean"):typeof r=="number"?Number.isInteger(r)?jn("integer"):jn("decimal"):jn("string")}function Vr(r,e,n){let t=[];for(let a of vn(e,Jt,r,B(n)))if(a.kind==="subject"||a.kind==="unresolved"){let s=a.kind==="subject"?a.node:void 0,o=(s?we(s):void 0)??a.uri,i=s?xe(s,Yt):void 0,c=s?xe(s,Xt):void 0;t.push({kind:"individual",uri:o,localName:o.name,...i!==void 0?{label:i}:{},...c!==void 0?{comment:c}:{}})}else a.kind==="literal"&&t.push({kind:"literal",value:a.value,datatype:Pr(a.value)});return t}function Rn(r,e,n,t){let a=an(r,e),s=B(e);return vt(r,e).filter(i=>n?!0:i.domains.some(c=>B(c)===s)).map(i=>Tr(r,i,zt(t,a,i.uri)))}async function Yi(r,e,n){let t=r.metadata?.namespace_;if(!t)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let a=n?.includeInherited??!1,s=Array.isArray(e)?e:await new Sn().parseKanonaks(e),o=pn(s),i=p=>p.publisher===t.publisher&&p.package_===t.package_&&!(p.version&&t.version&&!lt(p.version,t.version)),c=[],l=[],d=new Set,f=!1;for(let p of s){if(!(p instanceof Y))continue;let g=we(p);if(!g||!i(g)||(f=!0,!tn.isClassType(Qt(p))))continue;let h=B(g);if(d.has(h))continue;d.add(h);let b=je(p,Ir).map(v=>({uri:v,localName:v.name})),m=xe(p,Yt),y=xe(p,Xt);c.push({uri:g,localName:g.name,superClasses:b,properties:Rn(s,g,a,o),...m!==void 0?{label:m}:{},...y!==void 0?{comment:y}:{}}),un(p,Jt)&&l.push({uri:g,localName:g.name,members:Vr(s,p,g),...m!==void 0?{label:m}:{},...y!==void 0?{comment:y}:{}})}if(!f)throw new Error(`buildOntologyModel: ${t.toString()} is not in the ${Array.isArray(e)?"catalog":"repository"} \u2014 a model can only be built for a document ${Array.isArray(e)?"the catalog was parsed from":"the repository holds"}.`);return{classes:c,enums:l}}function mn(r,e={}){let n=r.replace(/\r\n/g,`
|
|
1
|
+
import{a as dt}from"./chunk-NYCGUDVW.js";import{e as he,f as u,k as Sn}from"./chunk-Q2ZUKZEU.js";import{a as ft}from"./chunk-6CI3HTKF.js";import{a as $t}from"./chunk-PEJALHXK.js";import{$ as bt,_ as ht,oa as tn,pa as we,qa as an,ra as $n,va as vt}from"./chunk-TVMOJ2QS.js";import{A as gt,B as un,C as Xe,D as xe,E as Oe,F as kt,G as Mn,H as vn,K as yt,b as Ue,c as Y,d as D,e as U,i as ae,j as be,k as ke,l as Q,m as le,n as ue,o as De,p as B,q as re,r as pt,s as mt,t as je,u as Ee,w as _,y as Te,z as oe}from"./chunk-6USORWEP.js";import{c as hn,d as lt,e as bn,g as ut,l as yn}from"./chunk-7IMLHHSA.js";import{ExpressionError as Oa,evaluates as Ia,validateMatchesPattern as Fa}from"@kanonak-protocol/expression";var q=class extends Error{constructor(n,t){super(`${n} (at ${t})`);this.path=t}path};function bi(r,e){let n=r.name,t=Ja(e),a={catalog:e,depth:0};if(_(r,u.InstanceTransformation))return Ta(r,n,a,t);if(_(r,u.SetTransformation))return Pa(r,n,a,t);throw new q("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Ta(r,e,n,t){return{kind:"instance",name:r.name,inputPattern:Et(r,e),rule:wn(r,u.rule,`${e}.rule`,n),artifactName:wn(r,u.artifactName,`${e}.artifactName`,n),outputs:xt(r,`${e}.outputs`),overrides:Lt(r,`${e}.formatOverrides`,n),fragments:t}}function Pa(r,e,n,t){let a=Pe(r,u.partitionBy);return{kind:"set",name:r.name,inputPattern:Et(r,e),rule:wn(r,u.rule,`${e}.rule`,n),artifactName:wn(r,u.artifactName,`${e}.artifactName`,n),outputs:xt(r,`${e}.outputs`),overrides:Lt(r,`${e}.formatOverrides`,n),partitionBy:a,fragments:t}}function Et(r,e){let n=Ct(r,u.inputPattern);if(!n)throw new q("inputPattern is required",e);return Va(n,`${e}.inputPattern`)}function Va(r,e){let n=Pe(r,u.matchesClass);if(!n)throw new q("matchesClass is required",e);let t=[];for(let o of Le(r,u.requires))if(o instanceof Q)t.push(Hn(o.object.subject));else if(o instanceof ue)for(let i of o.object)i instanceof U&&t.push(Hn(i.subject));let a=[],s=0;for(let o of Le(r,u.sortBy))if(o instanceof ue)for(let i of o.object)i instanceof D&&a.push(St(i,`${e}.sortBy[${s++}]`));else o instanceof le&&a.push(St(o.object,`${e}.sortBy[${s++}]`));return{matchesClass:n,requires:t,sortBy:a}}function St(r,e){let n=Pe(r,u.byProperty);if(!n)throw new q("SortKey.byProperty is required",e);let t=Pe(r,u.order);if(!t)throw new q("SortKey.order is required",e);if(re(t,u.ascending))return{byProperty:n,order:"ascending"};if(re(t,u.descending))return{byProperty:n,order:"descending"};throw new q(`SortKey.order must reference tx.ascending or tx.descending; got ${t.publisher}/${t.package_}/${t.name}`,e)}function wn(r,e,n,t){let a=Gn(r,e,n,t);if(!a)throw new q("expression is required",n);return qe(a,n,t)}function qn(r,e,n,t){return Ee(r,e).map((a,s,o)=>{let i=o.length>1||a.fromList?`${n}[${s}]`:n;if(a.item instanceof D)return a.item;if(a.item instanceof U){let c=Te(t.catalog,a.item.subject);if(!c)throw new q(`references '${B(a.item.subject)}', which does not resolve in the catalog`,i);return c}throw new q(`expects a node, not the literal ${JSON.stringify(a.item.value)}`,i)})}function Gn(r,e,n,t){let a=qn(r,e,n,t);if(a.length>1)throw new q(`expects one expression, has ${a.length}`,n);return a[0]}function qe(r,e,n){if(r instanceof Y){let t=we(r),a=t?B(t):`${r.namespace}/${r.name}`,s=n.visiting??new Set;if(s.has(a))throw new q(`named expressions form a cycle: ${[...s,a].join(" -> ")}`,e);return wt(r,a,{...n,visiting:new Set([...s,a])})}return wt(r,e,n)}function wt(r,e,n){if(_(r,u.StringLiteral))return{kind:"string-literal",value:ye(r,u.stringLiteral,e)};if(_(r,u.IntegerLiteral))return{kind:"integer-literal",value:Rt(r,u.integerLiteral,e)};if(_(r,u.DecimalLiteral))return{kind:"decimal-literal",value:Rt(r,u.decimalLiteral,e)};if(_(r,u.BooleanLiteral))return{kind:"boolean-literal",value:er(r,u.booleanLiteral,e)};if(_(r,u.VarRef))return{kind:"var-ref",varName:ye(r,u.varName,e)};if(_(r,u.PropertyRead))return{kind:"property-read",source:w(r,u.readSource,`${e}.readSource`,n),readProp:Be(r,u.readProp,e,"readProp")};if(_(r,u.Traverse))return{kind:"traverse",source:w(r,u.traverseSource,`${e}.traverseSource`,n),through:Be(r,u.through,e,"through"),step:w(r,u.step,`${e}.step`,n)};if(_(r,u.BuildAstNode))return{kind:"build-ast-node",astClass:Be(r,u.astClass,e,"astClass"),set:Ba(r,`${e}.set`,n)};if(_(r,u.When))return{kind:"when",condition:w(r,u.condition,`${e}.condition`,n),thenBuild:w(r,u.thenBuild,`${e}.thenBuild`,n),elseBuild:Da(r,u.elseBuild,`${e}.elseBuild`,n)};if(_(r,u.Concat))return{kind:"concat",parts:Nn(r,u.parts,`${e}.parts`,n)};if(_(r,u.Fallback))return{kind:"fallback",primary:w(r,u.primary,`${e}.primary`,n),alternate:w(r,u.alternate,`${e}.alternate`,n)};if(_(r,u.UriName))return{kind:"uri-name",source:w(r,u.uriNameOf,`${e}.uriNameOf`,n)};if(_(r,u.UriPublisher))return{kind:"uri-publisher",source:w(r,u.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(_(r,u.UriPackage))return{kind:"uri-package",source:w(r,u.uriPackageOf,`${e}.uriPackageOf`,n)};if(_(r,u.UriVersion))return{kind:"uri-version",source:w(r,u.uriVersionOf,`${e}.uriVersionOf`,n)};if(_(r,u.SubjectUri))return{kind:"subject-uri",source:w(r,u.subjectOf,`${e}.subjectOf`,n)};if(_(r,u.UriLiteral))return{kind:"uri-literal",refTo:Be(r,u.refTo,e,"refTo")};if(_(r,u.DisplayLabel))return{kind:"display-label",labelTarget:Be(r,u.labelTarget,e,"labelTarget"),labelSource:Be(r,u.labelSource,e,"labelSource")};if(_(r,u.ResolveRef))return{kind:"resolve-ref",source:w(r,u.resolveSource,`${e}.resolveSource`,n)};if(_(r,u.Normalize))return{kind:"normalize",source:w(r,u.normSource,`${e}.normSource`,n),normKind:qa(r,e)};if(_(r,u.UnescapedString))return{kind:"unescaped-string",source:w(r,u.unescapedSource,`${e}.unescapedSource`,n)};if(_(r,u.RenderMarkdown))return{kind:"render-markdown",source:w(r,u.renderSource,`${e}.renderSource`,n),readProp:Be(r,u.renderProp,e,"renderProp"),format:Ga(r,e)};if(_(r,u.IsSet))return{kind:"is-set",check:w(r,u.checkExpr,`${e}.checkExpr`,n)};if(_(r,u.CallFragment))return Ya(r,e,n);if(_(r,u.Join))return{kind:"join",source:w(r,u.source,`${e}.source`,n),separator:ye(r,u.separator,e)};if(_(r,u.Count))return{kind:"count",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Sum))return{kind:"sum",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Min))return{kind:"min",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Max))return{kind:"max",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.Average))return{kind:"average",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.ForEach))return{kind:"for-each",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),emit:w(r,u.emit,`${e}.emit`,n)};if(_(r,u.ListMap))return{kind:"list-map",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),mapBody:w(r,u.mapBody,`${e}.mapBody`,n)};if(_(r,u.Filter))return{kind:"filter",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),predicate:w(r,u.predicate,`${e}.predicate`,n)};if(_(r,u.PartitionBy))return{kind:"partition-by",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),partitionKey:w(r,u.partitionKey,`${e}.partitionKey`,n)};if(_(r,u.DistinctBy))return{kind:"distinct-by",source:w(r,u.source,`${e}.source`,n),loopVar:ye(r,u.loopVar,e),distinctKey:w(r,u.distinctKey,`${e}.distinctKey`,n)};if(_(r,u.AllStatements))return{kind:"all-statements",source:w(r,u.statementsOf,`${e}.statementsOf`,n)};if(_(r,u.StatementPredicate))return{kind:"statement-predicate",source:w(r,u.predicateOf,`${e}.predicateOf`,n)};if(_(r,u.StatementValue))return{kind:"statement-value",source:w(r,u.valueOf,`${e}.valueOf`,n)};if(_(r,u.DateFormat))return{kind:"date-format",source:w(r,u.dateSource,`${e}.dateSource`,n),format:Wa(r,e)};if(_(r,u.NumberFormat)){let a=Dn(r,u.fractionDigits);if(a!==void 0&&(!Number.isInteger(a)||a<0||a>20))throw new q(`fractionDigits must be an integer between 0 and 20; got ${a}`,e);let s=He(r,u.currencyCode);return{kind:"number-format",source:w(r,u.numberSource,`${e}.numberSource`,n),style:za(r,e),...a!==void 0?{fractionDigits:a}:{},...s!==void 0?{currencyCode:s}:{}}}let t=Na.find(a=>_(r,a.type));if(t){let a=B(t.type);if(!Ia(a))throw new q(`${a} is a numeric operator the expression runtime does not evaluate`,e);return{kind:"numeric-op",type:a,name:t.type.name,operands:t.operands.map(s=>({name:s.name,expr:w(r,s,`${e}.${s.name}`,n)}))}}if(_(r,u.Reverse))return{kind:"reverse",source:w(r,u.source,`${e}.source`,n)};if(_(r,u.WindowedMap)){let a=Dn(r,u.windowSize);if(a===void 0||!Number.isInteger(a)||a<1)throw new q("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:w(r,u.source,`${e}.source`,n),windowSize:a,windowVar:ye(r,u.windowVar,e),windowBody:w(r,u.windowBody,`${e}.windowBody`,n)}}if(_(r,u.PairwiseMap))return{kind:"pairwise-map",source:w(r,u.source,`${e}.source`,n),firstVar:ye(r,u.firstVar,e),secondVar:ye(r,u.secondVar,e),pairBody:w(r,u.pairBody,`${e}.pairBody`,n)};if(_(r,u.Scan))return{kind:"scan",source:w(r,u.source,`${e}.source`,n),initialState:w(r,u.initialState,`${e}.initialState`,n),stateVar:ye(r,u.stateVar,e),elementVar:ye(r,u.elementVar,e),accumulate:w(r,u.accumulate,`${e}.accumulate`,n)};if(_(r,u.ListItemAt))return{kind:"list-item-at",source:w(r,u.source,`${e}.source`,n),itemIndex:w(r,u.itemIndex,`${e}.itemIndex`,n)};if(_(r,u.Equals))return{kind:"equals",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.GreaterThan))return{kind:"greater-than",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.LessThan))return{kind:"less-than",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.LessThanOrEqual))return{kind:"less-than-or-equal",left:w(r,u.compareLeft,`${e}.compareLeft`,n),right:w(r,u.compareRight,`${e}.compareRight`,n)};if(_(r,u.Not))return{kind:"not",operand:w(r,u.operand,`${e}.operand`,n)};if(_(r,u.And))return{kind:"and",operands:Nn(r,u.operands,`${e}.operands`,n)};if(_(r,u.Or))return{kind:"or",operands:Nn(r,u.operands,`${e}.operands`,n)};if(_(r,u.Contains))return{kind:"contains",haystack:w(r,u.haystack,`${e}.haystack`,n),needle:w(r,u.needle,`${e}.needle`,n)};if(_(r,u.Matches)){let a=ye(r,u.pattern,e);try{Fa(a)}catch(s){throw s instanceof Oa?new q(s.message,`${e}.pattern`):s}return{kind:"matches",source:w(r,u.matchSource,`${e}.matchSource`,n),pattern:a}}if(_(r,u.IsReference))return{kind:"is-reference",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsEmbedded))return{kind:"is-embedded",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsList))return{kind:"is-list",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsString))return{kind:"is-string",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsNumber))return{kind:"is-number",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.IsBoolean))return{kind:"is-boolean",check:w(r,u.kindCheck,`${e}.kindCheck`,n)};if(_(r,u.StatementObject))return{kind:"statement-object",source:w(r,u.statementSource,`${e}.statementSource`,n)};if(_(r,u.Let))return{kind:"let",bindName:ye(r,u.letName,e),bindValue:w(r,u.letValue,`${e}.letValue`,n),body:w(r,u.letBody,`${e}.letBody`,n)};if(_(r,u.GetStatementByName))return{kind:"get-statement-by-name",inSubject:w(r,u.inSubject,`${e}.inSubject`,n),byName:w(r,u.byName,`${e}.byName`,n)};throw new q("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}var Aa=[u.arithLeft,u.arithRight],Ma=[u.value],Na=[...[u.Add,u.Subtract,u.Multiply,u.Divide,he.Power,he.Modulo,he.Minimum,he.Maximum].map(r=>({type:r,operands:Aa})),...[u.Abs,u.Negate,he.Exp,he.Ln,he.Log10,he.Sqrt,he.Floor,he.Ceil,he.Round,he.Sign].map(r=>({type:r,operands:Ma})),{type:he.Clip,operands:[he.clipValue,he.clipLower,he.clipUpper]}];function w(r,e,n,t){let a=Gn(r,e,n,t);if(!a)throw new q("child expression is required",n);return qe(a,n,t)}function Da(r,e,n,t){let a=Gn(r,e,n,t);if(a)return qe(a,n,t)}function Nn(r,e,n,t){return qn(r,e,n,t).map((a,s)=>qe(a,`${n}[${s}]`,t))}function Ba(r,e,n){return qn(r,u.set,e,n).map((t,a)=>Ha(t,`${e}[${a}]`,n))}function Ha(r,e,n){return{field:Be(r,u.field,e,"field"),value:w(r,u.bindValue,`${e}.bindValue`,n)}}function qa(r,e){let n=Pe(r,u.normKind);if(!n)throw new q("normKind is required",e);if(re(n,u.NORM_TRIM_END))return"trim-end";if(re(n,u.NORM_TO_UPPER))return"to-upper";if(re(n,u.NORM_TO_LOWER))return"to-lower";if(re(n,u.NORM_FIRST_CHAR))return"first-char";throw new q(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function Ga(r,e){let n=Pe(r,u.renderFormat);if(!n)throw new q("renderFormat is required",e);if(re(n,u.RENDER_HTML))return"html";if(re(n,u.RENDER_MARKDOWN))return"markdown";throw new q(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var _t=new Set(["decimal","percent","basis-points","currency","compact"]);function za(r,e){let n=He(r,u.numberStyle);if(n===void 0)throw new q("numberStyle is required",e);if(!_t.has(n))throw new q(`Unknown numberStyle "${n}"; supported: ${[..._t].join(", ")}`,e);return n}var jt=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function Wa(r,e){let n=He(r,u.dateFormat);if(!n)throw new q("dateFormat is required",e);if(!jt.has(n))throw new q(`Unknown dateFormat "${n}"; supported: ${[...jt].join(", ")}`,e);return n}function Ya(r,e,n){let t=Pe(r,u.fragmentRef);if(!t)throw new q("fragmentRef is required",e);if(!Qa(n.catalog,t))throw new q(`ExpressionFragment not found: ${t.publisher}/${t.package_}/${t.name}`,e);return{kind:"call-fragment",fragmentKey:Xa(t)}}function Xa(r){return`${r.publisher}/${r.package_}/${r.name}`}function Ja(r){let e=new Map,n=[];for(let t of r){if(!(t instanceof Y)||!_(t,u.ExpressionFragment))continue;let a=Ct(t,u.body);if(!a)continue;let s=(t.namespace||"").split("@")[0]||"",o=s.indexOf("/");if(o<0)continue;let i=s.substring(0,o),c=s.substring(o+1),l=`${i}/${c}/${t.name}`;n.push({key:l,subject:t,bodyEmb:a,pubPkgName:`${s}/${t.name}`})}for(let t of n){let a=qe(t.bodyEmb,`fragment(${t.pubPkgName})`,{catalog:r,depth:0});e.set(t.key,a)}return e}function Qa(r,e){for(let n of r)if(!(!(n instanceof Y)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&_(n,u.ExpressionFragment))return n}function xt(r,e){let n=new Set;for(let t of Le(r,u.outputs))if(t instanceof Q)n.add(t.object.subject.name);else if(t instanceof ue)for(let a of t.object)a instanceof U&&n.add(a.subject.name);if(n.size===0)throw new q("outputs is required (at least one OutputFormat)",e);return n}function Lt(r,e,n){let t=new Map,a=0;for(let s of Le(r,u.formatOverrides))if(s instanceof ue){for(let o of s.object)if(o instanceof D){let[i,c]=Kt(o,`${e}[${a++}]`);t.set(i,c)}}else if(s instanceof le){let[o,i]=Kt(s.object,`${e}[${a++}]`);t.set(o,i)}return t}function Kt(r,e){let n=Pe(r,u.formatTarget);if(!n)throw new q("formatTarget is required",e);let t=[];for(let i of Le(r,u.metadataKeys))if(i instanceof ae)t.push(i.object);else if(i instanceof ue)for(let c of i.object){let l=c.value;typeof l=="string"&&t.push(l)}let a=new Map;for(let i of Le(r,u.metadataRenames))if(i instanceof ue){for(let c of i.object)if(c instanceof D){let l=He(c,u.fromKey),d=He(c,u.toKey);l&&d&&a.set(l,d)}}else if(i instanceof le){let c=i.object,l=He(c,u.fromKey),d=He(c,u.toKey);l&&d&&a.set(l,d)}let s=Bn(r,u.trailingNewline),o=Bn(r,u.omitWrapper);return[n.name,{metadataKeys:t.length>0?t:void 0,metadataRenames:a,trailingNewline:s,omitWrapper:o}]}function Za(r){return r.predicate?.subject}function Le(r,e){let n=[];for(let t of r.statement){let a=Za(t);a&&re(a,e)&&n.push(t)}return n}function Ct(r,e){for(let n of Le(r,e))if(n instanceof le)return n.object}function Pe(r,e){for(let n of Le(r,e))if(n instanceof Q)return Hn(n.object.subject)}function He(r,e){for(let n of Le(r,e))if(n instanceof ae)return n.object}function Dn(r,e){for(let n of Le(r,e))if(n instanceof be)return n.object}function Bn(r,e){for(let n of Le(r,e))if(n instanceof ke)return n.object}function ye(r,e,n){let t=He(r,e);if(t===void 0)throw new q(`${e.name} (string) is required`,n);return t}function Rt(r,e,n){let t=Dn(r,e);if(t===void 0)throw new q(`${e.name} (number) is required`,n);return t}function er(r,e,n){let t=Bn(r,e);if(t===void 0)throw new q(`${e.name} (boolean) is required`,n);return t}function Be(r,e,n,t){let a=Pe(r,e);if(!a)throw new q(`${t} (URI reference) is required`,n);return a}function Hn(r){return{publisher:r.publisher,package_:r.package_,name:r.name}}var Je="kanonak.org",Tt="look",dn="core-rdf",Pt={publisher:Je,package_:Tt,name:"displayLabel"},Vt={publisher:Je,package_:Tt,name:"displaySummary"},nr={publisher:Je,package_:dn,name:"subClassOf"},tr={publisher:Je,package_:dn,name:"label"},ar={publisher:Je,package_:dn,name:"comment"},Ut=new yn(Je,dn,"Resource"),rr=8;function G(r,e){return At(r,e,new Set)}function At(r,e,n){let t=Ft(r,e,Pt)??tr,a=Ft(r,e,Vt)??ar,s=Ot(r,e,t,n)??e.name,o=Ot(r,e,a,n);return{label:s,summary:o}}function Ot(r,e,n,t){for(let a of e.statement){let s=a.predicate;if(!(!s?.subject||!re(s.subject,n))){if(a instanceof ae)return a.object;if(a instanceof be||a instanceof ke)return String(a.object);if(a instanceof Q)return It(r,a.object.subject,t);if(a instanceof ue){let o=[];for(let i of a.object??[])if(i instanceof U){let c=It(r,i.subject,t);c&&o.push(c)}if(o.length>0)return o.join(", ")}return}}}function It(r,e,n){let t=B(e);if(n.has(t)||n.size>=rr)return e.name;let[a]=oe(r,e);if(!a)return e.name;let s=new Set(n);return s.add(t),At(r,a,s).label}function Ft(r,e,n){let t=Oe(e,n);if(t)return t;let a=new Set,s=je(e,sr);for(;s.length>0;){let o=s.shift(),i=B(o);if(a.has(i))continue;a.add(i);let c=oe(r,o);for(let l of c){let d=Oe(l,n);if(d)return d}for(let l of c)s.push(...je(l,nr))}if(!a.has(B(Ut)))for(let o of oe(r,Ut)){let i=Oe(o,n);if(i)return i}}var sr={publisher:Je,package_:dn,name:"type"};var or="kanonak.org",Qe=(r,e)=>({publisher:or,package_:r,name:e}),ir=Qe("look","source"),Mt=Qe("look","connectors"),cr=Qe("look","relation"),lr=Qe("look","lineStyle"),ur=Qe("look","participants"),dr=Qe("core-owl","SymmetricProperty"),fr=Qe("core-owl","inverseOf"),Nt=new Set(["solid","dotted","open","thick"]);function Dt(r){return Oe(r,ir)}function Bt(r,e){let n=kt(e,Mt),t=n?[n]:Mn(e,Mt),a=[];for(let s of t){if(!(s instanceof D))continue;let o=Oe(s,cr);if(!o)continue;let i=xe(s,lr),c=i!==void 0&&Nt.has(i);a.push({relation:o,subject:oe(r,o)[0],declaredStyle:c?i:void 0,invalidStyle:i!==void 0&&!c?i:void 0})}return a}function Ht(r,e){let n=[];for(let t of Mn(e,ur)){if(!(t instanceof U))continue;let a=oe(r,t.subject)[0];a&&n.push(a)}return n}function fn(r,e,n){for(let t of mt(e))if(re(t,n)||an(r,t).some(a=>re(a,n)))return!0;return!1}function qt(r,e,n){let t=!!e.subject&&fn(r,e.subject,dr);return e.declaredStyle?{style:e.declaredStyle,undirected:t}:e.subject&&je(e.subject,fr).some(s=>n.some(o=>re(s,o.relation)))?{style:"dotted",undirected:t}:{style:"solid",undirected:t}}function zn(r,e,n){let t=Dt(n);if(!t)return _n("the band declares no look.source");let a=Bt(r,n);if(a.length===0)return _n("the band declares no look.connectors \u2014 nothing can be a message");let s=gt(e,t);if(!s)return{..._n(),sourceAbsent:!0};if(!(s instanceof De))return _n(`look.source ${B(t)} is not a Markdown-ranged property \u2014 the order of a sequence comes from prose [[references]]`);let o=[],i=[],c=0;for(let h of s.links){if(!h.target)continue;let b=h.target.subject,m=oe(r,b)[0];m&&($n(r,m)!==void 0?a.some(y=>re(b,y.relation))?o.push({kind:"selector",relation:b}):i.push(b):(o.push({kind:"participant",subject:m}),c++))}let l=[],d=[],f,p;for(let h of o){if(h.kind==="selector"){p=h.relation;continue}let b=h.subject;if(f){let m=p?a.filter(T=>re(p,T.relation)):a,y=we(b),v=we(f),E=[],K=[];for(let T of m){let{style:L,undirected:S}=qt(r,T,a);y&&je(f,T.relation).some(W=>B(W)===B(y))?E.push({from:f,to:b,relation:T.relation,style:L,undirected:S}):v&&je(b,T.relation).some(W=>B(W)===B(v))&&K.push({from:b,to:f,relation:T.relation,style:L,undirected:S})}let O=E.length>0?E:K;l.push(...O),O.length===0&&Ve(f)!==Ve(b)&&d.push({prev:f,next:b,selected:p}),p=void 0}f=b}let g=new Map;for(let h of Ht(r,n))g.set(Ve(h),h);for(let h of l)g.has(Ve(h.from))||g.set(Ve(h.from),h.from),g.has(Ve(h.to))||g.set(Ve(h.to),h.to);return{messages:l,gaps:d,lifelines:[...g.values()],mentions:c,strayPropertyRefs:i,sourceAbsent:!1}}function Ve(r){return`${r.namespace}/${r.name}`}function _n(r){return{messages:[],gaps:[],lifelines:[],mentions:0,strayPropertyRefs:[],sourceAbsent:!1,...r?{problem:r}:{}}}var pr="kanonak.org",mr="core-shacl",_e=r=>({publisher:pr,package_:mr,name:r}),gr=_e("NodeShape"),kr=_e("targetClass"),hr=_e("property"),br=_e("path"),yr=_e("minCount"),vr=_e("maxCount"),$r=_e("in"),Sr=_e("pattern"),wr=_e("flags"),_r=_e("minLength"),jr=_e("maxLength"),Kr=_e("minInclusive"),Rr=_e("maxInclusive"),Er=_e("message");function rn(r){return typeof r=="number"?r:void 0}function xr(r){let e={},n=rn(Xe(r,yr)),t=rn(Xe(r,vr));n!==void 0&&(e.minCount=n),t!==void 0&&(e.maxCount=t);let a=rn(Xe(r,_r)),s=rn(Xe(r,jr));a!==void 0&&(e.minLength=a),s!==void 0&&(e.maxLength=s);let o=rn(Xe(r,Kr)),i=rn(Xe(r,Rr));o!==void 0&&(e.minInclusive=o),i!==void 0&&(e.maxInclusive=i);let c=xe(r,Sr);if(c!==void 0){let f=xe(r,wr);e.pattern=f!==void 0?{regex:c,flags:f}:{regex:c}}let l=Ee(r,$r).map(f=>f.item).filter(f=>"literal"in f).map(f=>f.value);l.length>0&&(e.enumValues=l);let d=xe(r,Er);return d!==void 0&&(e.message=d),e}function Lr(r,e){let n=[];for(let{item:t}of Ee(e,hr))if(t instanceof D)n.push(t);else if(t instanceof U){let a=Te(r,t.subject);a&&n.push(a)}return n}function Cr(r){let e=new Map;for(let n of r){if(!(n instanceof Y)||!_(n,gr))continue;let t=Oe(n,kr);if(!t)continue;let a=B(t);for(let s of Lr(r,n)){let o=Oe(s,br);if(!o)continue;let i=xr(s);if(Ur(s,i))continue;let c={pathKey:B(o),constraints:i},l=e.get(a);l?l.push(c):e.set(a,[c])}}return e}var Gt=new WeakMap;function pn(r){let e=Gt.get(r);return e||(e=Cr(r),Gt.set(r,e)),e}function Ur(r,e){return un(r,ht)||un(r,bt)?Object.keys(e).every(t=>t==="message"):!1}function Or(r,e){e.minCount!==void 0&&(r.minCount=e.minCount),e.maxCount!==void 0&&(r.maxCount=e.maxCount),e.minLength!==void 0&&(r.minLength=e.minLength),e.maxLength!==void 0&&(r.maxLength=e.maxLength),e.minInclusive!==void 0&&(r.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(r.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(r.pattern=e.pattern),e.enumValues!==void 0&&(r.enumValues=e.enumValues),e.message!==void 0&&(r.message=e.message)}function zt(r,e,n){let t=B(n),a=!1,s={};for(let o=e.length-1;o>=0;o--){let i=r.get(B(e[o]));if(i)for(let c of i)c.pathKey===t&&(a=!0,Or(s,c.constraints))}if(a)return s.cardinality=s.maxCount===1?"single":"list",s.required=(s.minCount??0)>=1,s}var Ze="kanonak.org",Kn="core-rdf",Wt="core-xsd",Ir={publisher:Ze,package_:Kn,name:"subClassOf"},Yt={publisher:Ze,package_:Kn,name:"label"},Xt={publisher:Ze,package_:Kn,name:"comment"},Jt={publisher:Ze,package_:"core-owl",name:"oneOf"},Qt=r=>r;function Fr(r,e,n){if(e.publisher===Ze&&e.package_===Kn&&e.name==="Literal")return{kind:"datatype",uri:e};let a=Te(r,e);if(a){let s=Qt(a);if(tn.isDatatypeType(s))return{kind:"datatype",uri:e};if(tn.isClassType(s))return{kind:"class",uri:we(a)??e,localName:a.name}}return e.publisher===Ze&&e.package_===Wt?{kind:"datatype",uri:e}:n==="datatype"?{kind:"datatype",uri:e}:{kind:"class",uri:e,localName:e.name}}function Tr(r,e,n){if(!e.range)throw new Error(`Property ${e.uri.publisher}/${e.uri.package_}/${e.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let t=Fr(r,e.range,e.kind),a=e.kind==="object"?"object":e.kind==="datatype"?"datatype":t.kind==="class"?"object":"datatype";return{uri:e.uri,localName:e.uri.name,kind:a,range:t,...e.label!==void 0?{label:e.label}:{},...e.comment!==void 0?{comment:e.comment}:{},...n??{}}}var jn=r=>new yn(Ze,Wt,r);function Pr(r){return typeof r=="boolean"?jn("boolean"):typeof r=="number"?Number.isInteger(r)?jn("integer"):jn("decimal"):jn("string")}function Vr(r,e,n){let t=[];for(let a of vn(e,Jt,r,B(n)))if(a.kind==="subject"||a.kind==="unresolved"){let s=a.kind==="subject"?a.node:void 0,o=(s?we(s):void 0)??a.uri,i=s?xe(s,Yt):void 0,c=s?xe(s,Xt):void 0;t.push({kind:"individual",uri:o,localName:o.name,...i!==void 0?{label:i}:{},...c!==void 0?{comment:c}:{}})}else a.kind==="literal"&&t.push({kind:"literal",value:a.value,datatype:Pr(a.value)});return t}function Rn(r,e,n,t){let a=an(r,e),s=B(e);return vt(r,e).filter(i=>n?!0:i.domains.some(c=>B(c)===s)).map(i=>Tr(r,i,zt(t,a,i.uri)))}async function Yi(r,e,n){let t=r.metadata?.namespace_;if(!t)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let a=n?.includeInherited??!1,s=Array.isArray(e)?e:await new Sn().parseKanonaks(e),o=pn(s),i=p=>p.publisher===t.publisher&&p.package_===t.package_&&!(p.version&&t.version&&!lt(p.version,t.version)),c=[],l=[],d=new Set,f=!1;for(let p of s){if(!(p instanceof Y))continue;let g=we(p);if(!g||!i(g)||(f=!0,!tn.isClassType(Qt(p))))continue;let h=B(g);if(d.has(h))continue;d.add(h);let b=je(p,Ir).map(v=>({uri:v,localName:v.name})),m=xe(p,Yt),y=xe(p,Xt);c.push({uri:g,localName:g.name,superClasses:b,properties:Rn(s,g,a,o),...m!==void 0?{label:m}:{},...y!==void 0?{comment:y}:{}}),un(p,Jt)&&l.push({uri:g,localName:g.name,members:Vr(s,p,g),...m!==void 0?{label:m}:{},...y!==void 0?{comment:y}:{}})}if(!f)throw new Error(`buildOntologyModel: ${t.toString()} is not in the ${Array.isArray(e)?"catalog":"repository"} \u2014 a model can only be built for a document ${Array.isArray(e)?"the catalog was parsed from":"the repository holds"}.`);return{classes:c,enums:l}}function mn(r,e={}){let n=r.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),t=[],a=0;for(;a<n.length;){let s=n[a];if(s.trim()===""){a++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(s);if(o){let l=o[2],d=[];for(a++;a<n.length&&!/^(\s*)```\s*$/.test(n[a]);)d.push(n[a]),a++;a++;let f=d.join(`
|
|
4
4
|
`),p=l&&e.highlight?e.highlight(l,f):on(f),g=l?` class="language-${ea(l)}"`:"";t.push(`<pre class="kan-code"><code${g}>${p}</code></pre>`);continue}let i=/^(#{1,6})\s+(.*)$/.exec(s);if(i){let l=i[1].length,d=sn(i[2].trim());t.push(`<h${l}>${d}</h${l}>`),a++;continue}if(s.includes("|")&&a+1<n.length&&Zt(n[a+1])){let l=Wn(s),d=Ar(n[a+1]);a+=2;let f=[];for(;a<n.length&&n[a].trim()!==""&&n[a].includes("|");)f.push(Wn(n[a])),a++;t.push(Mr(l,d,f));continue}if(/^\s*[-*]\s+/.test(s)){let l=[];for(;a<n.length&&/^\s*[-*]\s+/.test(n[a]);){let d=[n[a].replace(/^\s*[-*]\s+/,"")];for(a++;a<n.length&&n[a].trim()!==""&&!/^\s*[-*]\s+/.test(n[a])&&!/^\s*\d+\.\s+/.test(n[a]);)d.push(n[a]),a++;a<n.length&&n[a].trim()===""&&a++,l.push(`<li>${sn(d.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as F,u as A}from"./chunk-Z2444SWM.js";import{a as P}from"./chunk-WXXZOJ4O.js";import{a as f}from"./chunk-5ZRVFYCP.js";import{c as K,g as I,j as R}from"./chunk-GGK6A6QK.js";import*as m from"fs/promises";import*as i from"path";import{pathToFileURL as b}from"url";var y=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(e,t=!0,n){if(!e||e.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=i.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=i.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=i.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;return R(r,t)});return s.length===0?null:(s.sort((a,r)=>{let l=a.metadata.namespace_.version,u=r.metadata.namespace_.version;return K(u,l)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let l=o.split("/"),u=l[0],h=l[1].replace("@","@")+".kan.yml";n=i.join(this.rootPath,u,h)}else n=i.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=i.dirname(n);await m.mkdir(s,{recursive:!0});let a=this.parser.save(e);await m.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=i.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await m.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=i.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=i.join(this.rootPath,e);try{let s=await m.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await m.unlink(i.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[l,u]of this.documentCache.entries())if(this.filePathsByIdentifier.get(l)===n&&u.metadata.namespace_){s=u.metadata.namespace_.toString();break}let a=s??i.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await m.access(e),t=e}catch{let n=i.join(this.rootPath,e);try{await m.access(n),t=n}catch{return null}}try{return await m.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await m.access(e),t=e}catch{let n=i.join(this.rootPath,e);try{await m.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await m.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await m.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=i.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let l=s.metadata.namespace_.toString();this.documentCache.set(l,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(l,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await m.readdir(e,{withFileTypes:!0});for(let s of o){let a=i.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as g from"fs";var S=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(S||{}),D=class{cache;workspace;constructor(e,t,n){let o=n??new f;g.existsSync(e)||g.mkdirSync(e,{recursive:!0}),g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as H}from"os";import{join as T}from"path";function d(){let c=process.env.KANONAK_PACKAGE_CACHE;return c||T(H(),".kanonak","packages")}var w=class c{static createComposite(e,t,n){let o=e??d(),s=t??".";return new D(o,s,n)}static createFromEnvironment(e){let t=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return c.createComposite(t,n,e)}};var k=class{repos;constructor(...e){this.repos=e}async firstAnswer(e,t,n){let o=[];for(let s of this.repos)try{let a=await e(s);if(t(a))return a}catch(a){o.push(a)}return x(o),n}async getHighestCompatibleVersionAsync(e,t){return this.firstAnswer(n=>n.getHighestCompatibleVersionAsync(e,t),n=>n!==null,null)}async getAllDocumentsAsync(){let e=[],t=new Set,n=[];for(let o of this.repos)try{for(let s of await o.getAllDocumentsAsync()){let a=s.metadata?.namespace_,r=a?a.version?`${a.publisher}/${a.package_}@${a.version.major}.${a.version.minor}.${a.version.patch}`:`${a.publisher}/${a.package_}`:void 0;if(r!==void 0){if(t.has(r))continue;t.add(r)}e.push(s)}}catch(s){n.push(s)}return x(n),e}async getDocumentAsync(e){return this.firstAnswer(t=>t.getDocumentAsync(e),t=>t!==null,null)}async getDocumentsByNamespaceAsync(e,t){return this.firstAnswer(n=>n.getDocumentsByNamespaceAsync(e,t),n=>n.length>0,[])}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){return this.firstAnswer(t=>t.getDocumentContentAsync(e),t=>!!t,null)}async getDocumentUriAsync(e){return this.firstAnswer(t=>t.getDocumentUriAsync(e),t=>!!t,null)}};function x(c){if(c.length===1)throw c[0];if(c.length>1)throw new Error(c.map(e=>e instanceof Error?e.message:String(e)).join("; "))}import{VersionOperator as N}from"@kanonak-protocol/types/document/models/enums";var v=class{constructor(e,t){this.base=e;this.lock=t}base;lock;pinnedVersion(e,t){return F(this.lock,e,t)}async getHighestCompatibleVersionAsync(e,t){let n=this.pinnedVersion(e,t.packageName);if(n){let o=I(n);if(o){let s={...t,versionOperator:N.Exact,version:o};return this.base.getHighestCompatibleVersionAsync(e,s)}}return this.base.getHighestCompatibleVersionAsync(e,t)}async getDocumentsByNamespaceAsync(e,t){let n=await this.base.getDocumentsByNamespaceAsync(e,t),o=this.pinnedVersion(e,t);return o?n.filter(s=>{let a=s.metadata.namespace_?.version;return a?`${a.major}.${a.minor}.${a.patch}`===o:!1}):n}getAllDocumentsAsync(){return this.base.getAllDocumentsAsync()}getDocumentAsync(e){return this.base.getDocumentAsync(e)}saveDocumentAsync(e,t){return this.base.saveDocumentAsync(e,t)}deleteDocumentAsync(e){return this.base.deleteDocumentAsync(e)}clearNamespaceAsync(e,t){return this.base.clearNamespaceAsync(e,t)}getAllDocumentReferencesAsync(){return this.base.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.base.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.base.getDocumentUriAsync(e)}};import{readFileSync as B,readdirSync as U}from"fs";import{join as _}from"path";var V=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(c,e=[]){for(let t of U(c,{withFileTypes:!0}))t.isDirectory()?V.has(t.name)||C(_(c,t.name),e):t.name.endsWith(".kan.yml")&&e.push(_(c,t.name));return e}async function $(c,e=new f,t={}){let n=new P(e);for(let l of C(c))try{let u=e.parse(B(l,"utf-8")),p=u.metadata?.namespace_,h=p?.version;p&&h&&await n.saveDocumentAsync(u,`${p.publisher}/${p.package_}@${h.major}.${h.minor}.${h.patch}`)}catch{}let o=new y(d(),!0,e);if(t.offline)return new k(n,o);let s=new Map,a=t.httpCache??{getFromCache:(l,u,p)=>s.get(`${l}|${u}|${p}`)??null,onFetch:(l,u,p,h)=>{s.set(`${l}|${u}|${p}`,h)}},r=new A({getFromCache:a.getFromCache,onFetch:a.onFetch,...t.fetchFn?{fetchFn:t.fetchFn}:{},...t.packageUrlTemplates?{packageUrlTemplates:t.packageUrlTemplates}:{}});return new k(n,o,r)}export{y as a,S as b,D as c,d,w as e,k as f,v as g,C as h,$ as i};
|
|
1
|
+
import{n as F,u as A}from"./chunk-X2URIXH7.js";import{a as P}from"./chunk-NYCGUDVW.js";import{a as f}from"./chunk-6CI3HTKF.js";import{c as K,g as I,j as R}from"./chunk-7IMLHHSA.js";import*as m from"fs/promises";import*as i from"path";import{pathToFileURL as b}from"url";var y=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(e,t=!0,n){if(!e||e.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=i.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=i.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=i.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;return R(r,t)});return s.length===0?null:(s.sort((a,r)=>{let l=a.metadata.namespace_.version,u=r.metadata.namespace_.version;return K(u,l)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let l=o.split("/"),u=l[0],h=l[1].replace("@","@")+".kan.yml";n=i.join(this.rootPath,u,h)}else n=i.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=i.dirname(n);await m.mkdir(s,{recursive:!0});let a=this.parser.save(e);await m.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=i.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await m.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=i.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=i.join(this.rootPath,e);try{let s=await m.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await m.unlink(i.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[l,u]of this.documentCache.entries())if(this.filePathsByIdentifier.get(l)===n&&u.metadata.namespace_){s=u.metadata.namespace_.toString();break}let a=s??i.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await m.access(e),t=e}catch{let n=i.join(this.rootPath,e);try{await m.access(n),t=n}catch{return null}}try{return await m.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await m.access(e),t=e}catch{let n=i.join(this.rootPath,e);try{await m.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await m.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await m.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=i.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let l=s.metadata.namespace_.toString();this.documentCache.set(l,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(l,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await m.readdir(e,{withFileTypes:!0});for(let s of o){let a=i.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as g from"fs";var S=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(S||{}),D=class{cache;workspace;constructor(e,t,n){let o=n??new f;g.existsSync(e)||g.mkdirSync(e,{recursive:!0}),g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as H}from"os";import{join as T}from"path";function d(){let c=process.env.KANONAK_PACKAGE_CACHE;return c||T(H(),".kanonak","packages")}var w=class c{static createComposite(e,t,n){let o=e??d(),s=t??".";return new D(o,s,n)}static createFromEnvironment(e){let t=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return c.createComposite(t,n,e)}};var k=class{repos;constructor(...e){this.repos=e}async firstAnswer(e,t,n){let o=[];for(let s of this.repos)try{let a=await e(s);if(t(a))return a}catch(a){o.push(a)}return x(o),n}async getHighestCompatibleVersionAsync(e,t){return this.firstAnswer(n=>n.getHighestCompatibleVersionAsync(e,t),n=>n!==null,null)}async getAllDocumentsAsync(){let e=[],t=new Set,n=[];for(let o of this.repos)try{for(let s of await o.getAllDocumentsAsync()){let a=s.metadata?.namespace_,r=a?a.version?`${a.publisher}/${a.package_}@${a.version.major}.${a.version.minor}.${a.version.patch}`:`${a.publisher}/${a.package_}`:void 0;if(r!==void 0){if(t.has(r))continue;t.add(r)}e.push(s)}}catch(s){n.push(s)}return x(n),e}async getDocumentAsync(e){return this.firstAnswer(t=>t.getDocumentAsync(e),t=>t!==null,null)}async getDocumentsByNamespaceAsync(e,t){return this.firstAnswer(n=>n.getDocumentsByNamespaceAsync(e,t),n=>n.length>0,[])}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){return this.firstAnswer(t=>t.getDocumentContentAsync(e),t=>!!t,null)}async getDocumentUriAsync(e){return this.firstAnswer(t=>t.getDocumentUriAsync(e),t=>!!t,null)}};function x(c){if(c.length===1)throw c[0];if(c.length>1)throw new Error(c.map(e=>e instanceof Error?e.message:String(e)).join("; "))}import{VersionOperator as N}from"@kanonak-protocol/types/document/models/enums";var v=class{constructor(e,t){this.base=e;this.lock=t}base;lock;pinnedVersion(e,t){return F(this.lock,e,t)}async getHighestCompatibleVersionAsync(e,t){let n=this.pinnedVersion(e,t.packageName);if(n){let o=I(n);if(o){let s={...t,versionOperator:N.Exact,version:o};return this.base.getHighestCompatibleVersionAsync(e,s)}}return this.base.getHighestCompatibleVersionAsync(e,t)}async getDocumentsByNamespaceAsync(e,t){let n=await this.base.getDocumentsByNamespaceAsync(e,t),o=this.pinnedVersion(e,t);return o?n.filter(s=>{let a=s.metadata.namespace_?.version;return a?`${a.major}.${a.minor}.${a.patch}`===o:!1}):n}getAllDocumentsAsync(){return this.base.getAllDocumentsAsync()}getDocumentAsync(e){return this.base.getDocumentAsync(e)}saveDocumentAsync(e,t){return this.base.saveDocumentAsync(e,t)}deleteDocumentAsync(e){return this.base.deleteDocumentAsync(e)}clearNamespaceAsync(e,t){return this.base.clearNamespaceAsync(e,t)}getAllDocumentReferencesAsync(){return this.base.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.base.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.base.getDocumentUriAsync(e)}};import{readFileSync as B,readdirSync as U}from"fs";import{join as _}from"path";var V=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(c,e=[]){for(let t of U(c,{withFileTypes:!0}))t.isDirectory()?V.has(t.name)||C(_(c,t.name),e):t.name.endsWith(".kan.yml")&&e.push(_(c,t.name));return e}async function $(c,e=new f,t={}){let n=new P(e);for(let l of C(c))try{let u=e.parse(B(l,"utf-8")),p=u.metadata?.namespace_,h=p?.version;p&&h&&await n.saveDocumentAsync(u,`${p.publisher}/${p.package_}@${h.major}.${h.minor}.${h.patch}`)}catch{}let o=new y(d(),!0,e);if(t.offline)return new k(n,o);let s=new Map,a=t.httpCache??{getFromCache:(l,u,p)=>s.get(`${l}|${u}|${p}`)??null,onFetch:(l,u,p,h)=>{s.set(`${l}|${u}|${p}`,h)}},r=new A({getFromCache:a.getFromCache,onFetch:a.onFetch,...t.fetchFn?{fetchFn:t.fetchFn}:{},...t.packageUrlTemplates?{packageUrlTemplates:t.packageUrlTemplates}:{}});return new k(n,o,r)}export{y as a,S as b,D as c,d,w as e,k as f,v as g,C as h,$ as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ut}from"./chunk-VJUZKHQU.js";import{c as At,g as Nt,h as pt,i as lt,j as Tt,k as xt,l as _t,t as mt,u as Lt,v as Mt}from"./chunk-CPENAANM.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as wt,k as O}from"./chunk-SBWD7EOG.js";import{a as Vt}from"./chunk-5ZRVFYCP.js";import{$ as ne,_ as ct,aa as jt,b as St,ba as Ot,ha as rt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as Pt,wa as Y,xa as pe}from"./chunk-6WOPXTIL.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as f,d as V,e as N,f as ot,l as ce,m as J,n as L,o as nt,p as k,q as Z,s as $t,t as M,u as oe,w as A,y as g,z as It}from"./chunk-LK5SHY4B.js";import{b as se,c as tt}from"./chunk-F67UH4FD.js";import{e as U}from"./chunk-GGK6A6QK.js";import{a as Dt}from"./chunk-FUUTGGJS.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(R||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ut=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new dt(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},dt=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function S(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function P(p,e,t){let o=await S(p,e,t),n=at(p);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function ue(p,e,t){let o=at(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function at(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};async function Bt(p,e,t){let o=new Map;for(let[a,i]of Object.entries(p.metadata?.imports??{}))for(let s of i){if(!se(s))continue;let c=`${a}/${s.packageName}`;o.set(c,{key:c,publisher:a,import_:s,references:[],target:null})}if(o.size===0)return[];let n=(a,i,s)=>{o.get(`${a.publisher}/${a.package_}`)?.references.push({uri:a,where:i,predicate:s})};F(e,({kanonak:a,path:i})=>{for(let s of a.statement){let c=s.predicate?.subject?.name??"(unknown)";if(s instanceof ce)n(s.object.subject,i,c);else if(s instanceof L)for(let l of s.object)l instanceof N&&n(l.subject,i,c);else if(s instanceof nt)for(let l of s.links)l.target&&n(l.target.subject,i,c)}});let r=[...o.values()].filter(a=>a.references.length>0);for(let a of r)try{a.target=await t.getHighestCompatibleVersionAsync(a.publisher,a.import_)}catch(i){a.failure=i instanceof Error?i.message:String(i)}return r}function qt(p,e){return Object.prototype.hasOwnProperty.call(p.body,e)}var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[];if(tt(e).size===0)return n;let r=await P(e,t,o);for(let{key:a,references:i,target:s,failure:c}of await Bt(e,r,t)){if(!s){let l=i[0],m=`${i.length} reference${i.length===1?"":"s"}, first at '${l.where}.${l.predicate}'`;this.options.offline?n.push(this.finding("Warning",l.where,l.predicate,a,`Link target package '${a}' could not be resolved offline (${m}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",l.where,l.predicate,a,`Link target package '${a}' could not be resolved${c?` (${c})`:""} \u2014 ${m}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:l,where:m,predicate:u}of i)qt(s,l.name)||n.push(this.finding("Error",m,u,`${a}/${l.name}`,`Link to '${l.name}' in '${u}' at '${m}' does not dereference: package '${a}' (resolved to ${s.metadata.namespace_?.toString()??a}) defines no resource named '${l.name}'.`,`Check for a typo, or a resource renamed or removed in '${a}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
1
|
+
import{a as Ut}from"./chunk-QRF7AT2M.js";import{c as At,g as Nt,h as pt,i as lt,j as Tt,k as xt,l as _t,t as mt,u as Lt,v as Mt}from"./chunk-AZFLKLPB.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as wt,k as O}from"./chunk-Q2ZUKZEU.js";import{a as Vt}from"./chunk-6CI3HTKF.js";import{$ as ne,_ as ct,aa as jt,b as St,ba as Ot,ha as rt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as Pt,wa as Y,xa as pe}from"./chunk-TVMOJ2QS.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as f,d as V,e as N,f as ot,l as ce,m as J,n as L,o as nt,p as k,q as Z,s as $t,t as M,u as oe,w as A,y as g,z as It}from"./chunk-6USORWEP.js";import{b as se,c as tt}from"./chunk-F67UH4FD.js";import{e as U,l as Dt}from"./chunk-7IMLHHSA.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(R||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ut=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new dt(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},dt=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function S(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function P(p,e,t){let o=await S(p,e,t),n=at(p);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function ue(p,e,t){let o=at(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function at(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};async function Bt(p,e,t){let o=new Map;for(let[a,i]of Object.entries(p.metadata?.imports??{}))for(let s of i){if(!se(s))continue;let c=`${a}/${s.packageName}`;o.set(c,{key:c,publisher:a,import_:s,references:[],target:null})}if(o.size===0)return[];let n=(a,i,s)=>{o.get(`${a.publisher}/${a.package_}`)?.references.push({uri:a,where:i,predicate:s})};F(e,({kanonak:a,path:i})=>{for(let s of a.statement){let c=s.predicate?.subject?.name??"(unknown)";if(s instanceof ce)n(s.object.subject,i,c);else if(s instanceof L)for(let l of s.object)l instanceof N&&n(l.subject,i,c);else if(s instanceof nt)for(let l of s.links)l.target&&n(l.target.subject,i,c)}});let r=[...o.values()].filter(a=>a.references.length>0);for(let a of r)try{a.target=await t.getHighestCompatibleVersionAsync(a.publisher,a.import_)}catch(i){a.failure=i instanceof Error?i.message:String(i)}return r}function qt(p,e){return Object.prototype.hasOwnProperty.call(p.body,e)}var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[];if(tt(e).size===0)return n;let r=await P(e,t,o);for(let{key:a,references:i,target:s,failure:c}of await Bt(e,r,t)){if(!s){let l=i[0],m=`${i.length} reference${i.length===1?"":"s"}, first at '${l.where}.${l.predicate}'`;this.options.offline?n.push(this.finding("Warning",l.where,l.predicate,a,`Link target package '${a}' could not be resolved offline (${m}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",l.where,l.predicate,a,`Link target package '${a}' could not be resolved${c?` (${c})`:""} \u2014 ${m}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:l,where:m,predicate:u}of i)qt(s,l.name)||n.push(this.finding("Error",m,u,`${a}/${l.name}`,`Link to '${l.name}' in '${u}' at '${m}' does not dereference: package '${a}' (resolved to ${s.metadata.namespace_?.toString()??a}) defines no resource named '${l.name}'.`,`Check for a typo, or a resource renamed or removed in '${a}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
2
2
|
type: Scene
|
|
3
3
|
|
|
4
4
|
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var yo=new Set(["EphemeralPackage"]),ge=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let o=[],n=this.packageKey(e,t.type_);return t.namespace_?(!yo.has(t.type_)&&!t.namespace_.version&&o.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as _}from"./chunk-
|
|
1
|
+
import{k as _}from"./chunk-Q2ZUKZEU.js";import{c as l,d as u,e as m,f as q,g as a,ma as K}from"./chunk-TVMOJ2QS.js";import{c as P,d as S,e as O,f as j,i as x,j as I,k as g,l as T,m as v,n as L}from"./chunk-6USORWEP.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let r=m(e);return this.all.has(r)?!1:(this.all.add(r),this.tripleList.push(e),U(this.byPIdx,e.p,e),U(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&U(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(m(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let r=this.byPIdx.get(e);return r?r.slice():[]}bySubjectPredicate(e,r){let t=this.bySPIdx.get(`${e}|${r}`);return t?t.slice():[]}byPredicateObject(e,r){let t=this.byPOIdx.get(`${e}|${r}`);return t?t.slice():[]}subjectsWithPredicateObject(e,r){let t=this.byPOIdx.get(`${e}|${r}`);if(!t)return[];let s=new Set;for(let n of t)s.add(n.s);return Array.from(s)}uriObjectsOf(e,r){let t=this.bySPIdx.get(`${e}|${r}`);if(!t)return[];let s=new Set;for(let n of t)n.o.kind==="uri"&&s.add(n.o.key);return Array.from(s)}hasUri(e,r,t){return this.all.has(`${e}|${r}|u:${t}`)}hasTriple(e,r,t){return this.all.has(`${e}|${r}|${q(t)}`)}};function U(o,e,r){let t=o.get(e);t?t.push(r):o.set(e,[r])}var C={name:"rdfs2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.domain)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},$={name:"rdfs3",apply(o,e){let r=!1;for(let t of o.byPredicate(e.range)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))i.o.kind==="uri"&&o.add(a(i.o.key,e.type,n))&&(r=!0)}return r}},w={name:"rdfs5",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subPropertyOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.bySubjectPredicate(n,e.subPropertyOf))i.o.kind==="uri"&&o.add(a(s,e.subPropertyOf,i.o.key))&&(r=!0)}return r}},E={name:"rdfs7",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subPropertyOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(s)){let c={s:i.s,p:n,o:i.o};o.add(c)&&(r=!0)}}return r}},A={name:"rdfs9",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subClassOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},V={name:"rdfs11",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subClassOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.bySubjectPredicate(n,e.subClassOf))i.o.kind==="uri"&&o.add(a(s,e.subClassOf,i.o.key))&&(r=!0)}return r}},b=[C,$,w,E,A,V];var W={name:"prp-trp",apply(o,e){let r=!1,t=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let s of t){let n=o.byPredicate(s);for(let i of n){if(i.o.kind!=="uri")continue;let c=i.o.key;for(let p of o.bySubjectPredicate(c,s))p.o.kind==="uri"&&i.s!==p.o.key&&o.add(a(i.s,s,p.o.key))&&(r=!0)}}return r}},F={name:"prp-symp",apply(o,e){let r=!1,t=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let s of t)for(let n of o.byPredicate(s))n.o.kind==="uri"&&o.add(a(n.o.key,s,n.s))&&(r=!0);return r}},N={name:"prp-inv1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.inverseOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))i.o.kind==="uri"&&o.add(a(i.o.key,n,i.s))&&(r=!0)}return r}},D={name:"prp-inv2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.inverseOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(a(i.o.key,s,i.s))&&(r=!0)}return r}},M={name:"prp-eqp1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentProperty)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(s))o.add({s:i.s,p:n,o:i.o})&&(r=!0)}return r}},z={name:"prp-eqp2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentProperty)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(n))o.add({s:i.s,p:s,o:i.o})&&(r=!0)}return r}},B={name:"cax-eqc1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentClass)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},H={name:"cax-eqc2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentClass)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,n))o.add(a(i.s,e.type,s))&&(r=!0)}return r}},Y={name:"eq-rep-s",apply(o,e){let r=!1;for(let t of o.byPredicate(e.sameAs)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n){for(let i of o.snapshot())i.s===s&&o.add({s:n,p:i.p,o:i.o})&&(r=!0);for(let i of o.snapshot())i.s===n&&o.add({s,p:i.p,o:i.o})&&(r=!0)}}return r}},G={name:"eq-rep-o",apply(o,e){let r=!1;for(let t of o.byPredicate(e.sameAs)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===s?o.add(a(i.s,i.p,n))&&(r=!0):i.o.key===n&&o.add(a(i.s,i.p,s))&&(r=!0))}return r}},k=[W,F,N,D,M,z,B,H,Y,G];var y=class{constructor(e,r){this.store=e;this.vocabulary=r}store;vocabulary;getInstancesOfClass(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,r)}getSubclasses(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,r).filter(s=>s!==r)}getSuperclasses(e){let r=f(e);return this.store.uriObjectsOf(r,this.vocabulary.subClassOf).filter(t=>t!==r)}getTypesOfIndividual(e){return this.store.uriObjectsOf(f(e),this.vocabulary.type)}isInstanceOf(e,r){return this.store.hasUri(f(e),this.vocabulary.type,f(r))}getPropertyClosure(e){let r=f(e),t={},s=new Map;for(let n of this.store.byPredicate(r)){if(n.o.kind!=="uri")continue;let i=s.get(n.s);i||(i=new Set,s.set(n.s,i),t[n.s]=[]),i.has(n.o.key)||(i.add(n.o.key),t[n.s].push(n.o.key))}return t}getPropertyClosures(e){let r={};for(let t of e)r[f(t)]=this.getPropertyClosure(t);return r}triples(){return this.store.snapshot()}size(){return this.store.size()}};function f(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var h=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new K,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){return this.reasonOver(await new _().parseKanonaks(e))}reasonOver(e){let r=new d,t=new R;for(let i of e)if(i instanceof P){let c=J(i);if(!c)continue;for(let p of i.statement)this.emitStatement(c,p,r,t)}let s=[...b];this.profile==="owl-rl-classification"&&s.push(...k);let n=0;for(;n<this.maxIterations;){let i=!1;for(let c of s)c.apply(r,this.vocabulary)&&(i=!0);if(!i)break;n++}return new y(r,this.vocabulary)}emitStatement(e,r,t,s){let n=Q(r);if(n){if(r instanceof x){t.add({s:e,p:n,o:{kind:"literal",lexical:r.object,datatype:"string"}});return}if(r instanceof I){t.add({s:e,p:n,o:{kind:"literal",lexical:String(r.object),datatype:"number"}});return}if(r instanceof g){t.add({s:e,p:n,o:{kind:"literal",lexical:String(r.object),datatype:"boolean"}});return}if(r instanceof T){let i=l(r.object.subject);t.add(a(e,n,i));return}if(r instanceof v){let i=s.next();t.add({s:e,p:n,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r.object,t,s);return}if(r instanceof L){for(let i of r.object??[])this.emitListItem(e,n,i,t,s);return}}}emitListItem(e,r,t,s,n){if(t instanceof O)s.add(a(e,r,l(t.subject)));else if(t instanceof S){let i=n.next();s.add({s:e,p:r,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t,s,n)}else if(t instanceof j){let i=typeof t.value=="number"?"number":typeof t.value=="boolean"?"boolean":"string";s.add({s:e,p:r,o:{kind:"literal",lexical:String(t.value),datatype:i}})}}emitEmbedded(e,r,t,s){let n=`_:${e}`;for(let i of r.statement)this.emitStatement(n,i,t,s)}},R=class{counter=0;next(){return`b${this.counter++}`}};function J(o){let e=o.namespace??"",r=e.indexOf("@"),t=r===-1?e:e.substring(0,r),s=t.indexOf("/");if(s===-1)return null;let n=t.substring(0,s),i=t.substring(s+1);return!n||!i||!o.name?null:u(n,i,o.name)}function Q(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,b,k as c,y as d,h as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-
|
|
1
|
+
import{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-6USORWEP.js";import{c as b,g as u}from"./chunk-7IMLHHSA.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as U,k as B}from"./chunk-
|
|
1
|
+
import{g as U,k as B}from"./chunk-Q2ZUKZEU.js";import{a as K}from"./chunk-6CI3HTKF.js";import{ia as _}from"./chunk-TVMOJ2QS.js";import{K as N,b as E,c as d,d as m,e as p,f as R,h as $,i as A,j as v,k as S,l as V,m as D,n as g}from"./chunk-6USORWEP.js";import{b as C,e as l,m as j}from"./chunk-7IMLHHSA.js";import*as P from"js-yaml";import{canonicalForm as Y,canonicalHash as ee}from"@kanonak-protocol/canonical";function k(n){return typeof n=="object"&&n!==null&&Array.isArray(n.subjects)}import{CANONICAL_FORM_VERSION as Pe}from"@kanonak-protocol/canonical";function ke(n){return Y(k(n)?n:F(n))}function O(n){return ee(k(n)?n:F(n))}function F(n){let e=[];for(let t of n)t instanceof d&&e.push({uri:se(t),statements:h(t.statement)});return{subjects:e}}function h(n){let e=[];for(let t of n){let r=ie(t);if(!r)continue;if(t instanceof g&&ne(t.predicate.subject)){e.push(...re(t,r));continue}let o=oe(t);o&&e.push({predicate:r,value:o})}return e}function ne(n){let e=_("type");return e!==void 0&&n.name==="type"&&n.publisher===e.publisher&&n.package_===e.package_}var H=new TextEncoder;function te(n,e){let t=H.encode(n),r=H.encode(e),o=Math.min(t.length,r.length);for(let a=0;a<o;a++)if(t[a]!==r[a])return t[a]-r[a];return t.length-r.length}function re(n,e){let t=[];for(let r of n.object){if(!(r instanceof p))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(b(r))}t.sort(te);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:e,value:{ref:r}}))}function oe(n){if(n instanceof $&&n.carrier)return{lit:n.lexical??String(n.object),datatype:z(n.carrier)};if(n instanceof A)return{raw:n.object};if(n instanceof v)return{raw:n.lexical??String(n.object)};if(n instanceof S)return{raw:n.lexical??String(n.object)};if(n instanceof V)return{ref:b(n.object)};if(n instanceof D)return M(n.object);if(n instanceof g)return{list:n.object.map(ae)}}function M(n){let e=h(n.statement);return n.name&&n.name.length>0?{embed:{name:n.name,statements:e}}:{embed:{statements:e}}}function ae(n){if(n instanceof p)return{ref:b(n)};if(n instanceof m)return M(n);if(n instanceof R){if(n.carrier)return{lit:n.lexical??String(n.value),datatype:z(n.carrier)};let e=n.value;if(typeof e=="string")return{raw:e};if(typeof e=="number")return{raw:String(e)};if(typeof e=="boolean")return{raw:String(e)}}if(n instanceof E)return{embed:{statements:h(n.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${n.constructor?.name??typeof n}); add canonicalization support before hashing data that contains it`)}function z(n){return n===U.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${n}`}function ie(n){let e=n.predicate;if(e)return L(e.subject)}function se(n){let e=n.namespace??"",t=n.name??"";return`${e}/${t}`}function b(n){return L(n.subject)}function L(n){let e=n.version;return e&&typeof e.major=="number"?`${n.publisher}/${n.package_}@${e.major}.${e.minor}.${e.patch}/${n.name}`:`${n.publisher}/${n.package_}/${n.name}`}import{VersionOperator as T}from"@kanonak-protocol/types/document/models/enums";var ce="0.0.0",w=class{constructor(e,t=new K,r){this.repository=e;this.parser=t;this.objectParser=r??new B(this.parser)}repository;parser;objectParser;imports(){return new f}serializeValue(e,t){return G(e,t)}async buildContentAddressed(e){let t=e.book.toImports(),r=await this.hashBody(e.publisher,t,e.body),o=Z(r),a={type:"EphemeralPackage",publisher:e.publisher,imports:t};e.contentHashProperty&&(a[e.contentHashProperty]=r),Object.assign(a,e.header??{}),a.imports=t;let i={[o]:a,...e.body},s=this.dump(i);return{yaml:s,byteCount:W(s),contentHash:r,packageName:o,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let t=e.book.toImports(),r={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:t},o;e.contentHashProperty&&(o=await this.hashBody(e.publisher,t,e.body),r[e.contentHashProperty]=o),Object.assign(r,e.header??{}),r.imports=t;let a={[e.name]:r,...e.body},i=this.dump(a),s={yaml:i,byteCount:W(i),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return o!==void 0&&(s.contentHash=o),s}dump(e){return P.dump(e,{lineWidth:-1})}async hashBody(e,t,r){let o={[q]:{type:"EphemeralPackage",publisher:e,imports:t},...r},a=this.parser.parse(P.dump(o,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new N(a,this.repository))).filter(u=>u instanceof d&&u.namespace===i&&u.name!==q);for(let u of c)u.namespace="ephemeral";return O(c)}},q="__pkgbuilder_probe__";function W(n){return new TextEncoder().encode(n).length}function Z(n){let e="sha256:",t=n.startsWith(e)?e.length:0;return`q-${n.slice(t,t+16)}`}var f=class{byKey=new Map;aliases=new Set;ensure(e,t,r,o,a=T.Major){let i=`${e}/${t}@${r}`,s=this.byKey.get(i);if(s)return s.alias;let c=this.uniqueAlias(o);return this.byKey.set(i,{publisher:e,package_:t,version:r,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,l(e.version),e.package_)}.${e.name}`}refLatest(e,t,r,o){return`${this.ensure(e,t,ce,o??t,T.Any)}.${r}`}toImports(){let e=new Map;for(let r of this.byKey.values()){let o=e.get(r.publisher)??[];o.push(r),e.set(r.publisher,o)}return[...e.keys()].sort().map(r=>({publisher:r,packages:e.get(r).sort((o,a)=>o.package_<a.package_?-1:1).map(o=>({package:o.package_,match:C(o.match),version:o.version,alias:o.alias}))}))}uniqueAlias(e){let t=J(e)||"pkg",r=t,o=2;for(;this.aliases.has(r);)r=`${t}${o++}`;return this.aliases.add(r),r}};function G(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof p)return e.ref(n.subject);if(Array.isArray(n)){let t=n.map(r=>G(r,e)).filter(r=>r!==void 0);return t.length>0?t:void 0}if(n instanceof m)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(ue(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function J(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function ue(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var I=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,t){return this.producers.find(r=>r.canProduce(e,t))}async produceCached(e,t,r,o){let a=`${t}/${r}@${l(o)}`,i=this.produced.get(a);if(i)return i;let{document:s}=await e.produce(t,r,o);return this.produced.set(a,s),s}async getHighestCompatibleVersionAsync(e,t){let r=this.producerFor(e,t.packageName);if(!r)return null;let o={operator:t.versionOperator,version:t.version},a=await r.resolveVersion(e,t.packageName,o);return a?this.produceCached(r,e,t.packageName,a):null}async getDocumentAsync(e){let t;try{t=j(e)}catch{return null}if(t.kind!=="package"||!t.version)return null;let r=this.producerFor(t.publisher,t.package_);return r?this.produceCached(r,t.publisher,t.package_,t.version):null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.produced.values()).filter(r=>{let o=r.metadata.namespace_;return o!=null&&o.publisher===e&&o.package_===t})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var Q={async authorize(){return{allowed:!0}}},X={async record(){}},y=class extends Error{constructor(t,r){let o=`${t.publisher}/${t.package_}${t.version?`@${t.version.major}.${t.version.minor}.${t.version.patch}`:""}`;super(`Not entitled to produce ${o}${r?`: ${r}`:""}`);this.address=t;this.reason=r;this.name="EntitlementDeniedError"}address;reason},x=class{inner;ctx;policy;meter;constructor(e,t,r=Q,o=X){this.inner=e,this.ctx=t,this.policy=r,this.meter=o}canProduce(e,t){return this.inner.canProduce(e,t)}async resolveVersion(e,t,r){return await this.assertAllowed({publisher:e,package_:t,version:r.version}),this.inner.resolveVersion(e,t,r)}async produce(e,t,r){let o={publisher:e,package_:t,version:r};await this.assertAllowed(o);let a=await this.inner.produce(e,t,r);return await this.meter.record(this.ctx,o,a),a}async assertAllowed(e){let t=await this.policy.authorize(this.ctx,e);if(!t.allowed)throw new y(e,t.reason)}};export{ke as a,O as b,Pe as c,w as d,Z as e,f,J as g,I as h,Q as i,X as j,y as k,x as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as m,j as i}from"./chunk-
|
|
1
|
+
import{c as m,j as i}from"./chunk-7IMLHHSA.js";var u=class{documents=new Map;documentContents=new Map;parser;constructor(e){this.parser=e}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(e){return this.documents.get(e)??null}async getDocumentsByNamespaceAsync(e,n){let t=[];for(let s of this.documents.values())s.metadata?.namespace_?.publisher===e&&s.metadata?.namespace_?.package_===n&&t.push(s);return t}async getHighestCompatibleVersionAsync(e,n){let t=[];for(let a of this.documents.values())a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===n.packageName&&a.metadata?.namespace_?.version!==void 0&&t.push(a);if(t.length===0)return null;let s=t.filter(a=>{let o=a.metadata.namespace_.version;return o?i(o,n):!1});return s.length===0?null:(s.sort((a,o)=>{let r=a.metadata.namespace_.version,c=o.metadata.namespace_.version;return!r&&!c?0:r?c?m(c,r):-1:1}),s[0])}async saveDocumentAsync(e,n){this.documents.set(n,e);let t=this.parser.save(e);this.documentContents.set(n,t)}async deleteDocumentAsync(e){this.documents.delete(e),this.documentContents.delete(e)}async clearNamespaceAsync(e,n){let t=[];for(let[s,a]of this.documents.entries())a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===n&&t.push(s);for(let s of t)this.documents.delete(s),this.documentContents.delete(s)}async getAllDocumentReferencesAsync(){let e=[];for(let n of this.documents.values())n.metadata?.namespace_&&e.push({identifier:n.metadata.namespace_.toString(),uri:`kanonak://${n.metadata.namespace_}`,hasParseError:!1});return e}async getDocumentContentAsync(e){let n=this.documentContents.get(e);if(n!==void 0)return n;let t=this.documents.get(e);return t!==void 0?this.parser.save(t):null}async getDocumentUriAsync(e){let n=this.documents.get(e);return n?n.metadata?.namespace_?`kanonak://${n.metadata.namespace_}`:`kanonak://${e}`:null}};export{u as a};
|