@kanonak-protocol/sdk 5.29.0 → 5.30.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-7UYXTYXC.js +1 -0
- package/dist/{chunk-HBG6SC5L.js → chunk-BS7RRG7D.js} +1 -1
- package/dist/chunk-BZ3YTI3C.js +2 -0
- package/dist/chunk-CR5QY3LJ.js +68 -0
- package/dist/{chunk-4SMQ7G23.js → chunk-EVMSO7HJ.js} +1 -1
- package/dist/chunk-F67UH4FD.js +1 -0
- package/dist/chunk-HF5FJBS2.js +1 -0
- package/dist/{chunk-JFBPQN6T.js → chunk-IS3AQKB4.js} +1 -1
- package/dist/{chunk-ZRCJGTEV.js → chunk-J4ZD6IF6.js} +1 -1
- package/dist/chunk-KIBR3HAT.js +1 -0
- package/dist/{chunk-GMK4YL3X.js → chunk-L2J7WD7E.js} +1 -1
- package/dist/chunk-PVUBHIU2.js +1 -0
- package/dist/{chunk-D66LUZDB.js → chunk-V3DH67P3.js} +1 -1
- package/dist/{chunk-ANJAHB4N.js → chunk-Z5Y4MCW5.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parsing/KanonakObjectParser.d.ts +9 -0
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/PublisherIndex.d.ts +13 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/buildLocalFirstRepository.d.ts +1 -0
- package/dist/repositories/index.js +1 -1
- package/dist/resolution/ResourceTypeClassifier.d.ts +9 -0
- package/dist/resolution/importMode.d.ts +26 -0
- package/dist/resolution/index.d.ts +1 -0
- 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/validation/KanonakObjectValidator.d.ts +5 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/LinkTargetRule.d.ts +42 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/chunk-3DWEBQSD.js +0 -68
- package/dist/chunk-BRCVOR7A.js +0 -1
- package/dist/chunk-F3SGXIDP.js +0 -1
- package/dist/chunk-G3GKOJ5E.js +0 -1
- package/dist/chunk-KOWDHKBN.js +0 -1
- package/dist/chunk-P5VQEDBS.js +0 -2
- /package/dist/{chunk-PEB52US5.js → chunk-XK24CN3C.js} +0 -0
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y,b as X,c as J,d as je,e as De,f as Ve,g as Ae,i as ve,j as Ne,k as He,l as Te}from"./chunk-
|
|
1
|
+
import{a as Y,b as X,c as J,d as je,e as De,f as Ve,g as Ae,i as ve,j as Ne,k as He,l as Te}from"./chunk-J4ZD6IF6.js";import{a as Le}from"./chunk-L2J7WD7E.js";import{a as m,b as c,c as u,e as d,h as R,i as y,j as f,k,l as x,m as P,n as S}from"./chunk-BZ3YTI3C.js";import{a as Q,b as Z,c as $}from"./chunk-BS7RRG7D.js";import{a as ee}from"./chunk-XK24CN3C.js";import"./chunk-SC5M74NM.js";import{A as he,B as Ie,C as Ee,M as Oe,a as oe,b as te,c as re,d as ne,g as ae,h as ie,i as se,j as pe,l as le,m as me,n as ce,o as ue,p as de,q as Re,r as ye,s as fe,t as ke,u as xe,v as Pe,w as Se,x as Ce,y as ge,z as Ke}from"./chunk-CR5QY3LJ.js";import"./chunk-KIBR3HAT.js";import{k as be}from"./chunk-Z5Y4MCW5.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as h,c as H,i as w,j as z,m as W}from"./chunk-PVUBHIU2.js";import{a as l}from"./chunk-HF5FJBS2.js";import"./chunk-PEJALHXK.js";import{a as T,b as L,da as B,fa as q,j as _,k as F,l as M,m as U,n as G}from"./chunk-7UYXTYXC.js";import{a as C,b as g,c as K,d as E,e as b,f as O,g as j,h as D,i as V,j as A,k as v,l as N}from"./chunk-CJMVIOZX.js";import{a as I}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{c as e,d as o,e as t,f as r,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{Pe as AmbiguousReferenceRule,V as BooleanStatement,Ve as CANONICAL_FORM_VERSION,w as Carrier,Ie as ClassDefinitionRule,ue as ClassHierarchyCycleRule,g as DefinedKanonak,X as EdgeType,h as EmbeddedKanonak,le as EmbeddedKanonakTypeRule,v as EmbeddedStatement,J as GraphBuilder,S as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,me as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,m as KANONAK_USER_AGENT,C as Kanonak,Z as KanonakDocumentPositions,W as KanonakObjectParser,Oe as KanonakObjectValidator,l as KanonakParser,I as KanonakUri,ee as KanonakUriBuilder,B as KanonakVocabulary,N as ListStatement,Ee as MarkdownLinkRule,H as MarkdownStatement,ke as NamespaceImportCycleRule,ae as NamespacePrefixRule,Y as NodeType,D as NumberStatement,ve as OAuthDiscovery,Ce as ObjectPropertyValueValidationRule,re as OntologyValidationError,oe as OntologyValidationResult,ge as PropertyDomainRule,de as PropertyHierarchyCycleRule,Ke as PropertyKindRangeConsistencyRule,Q as PropertyMetadata,Se as PropertyRangeReferenceRule,Re as PropertyRangeRequiredRule,se as PropertyTypeSpecificityRule,R as PublisherConfigResolver,P as PublisherIndex,E as ReferenceKanonak,A as ReferenceStatement,he as ReservedNameShadowRule,ie as ResourceNamingRule,T as ResourceResolver,q as ResourceTypeClassifier,F as SHACL_PACKAGE,_ as SHACL_PUBLISHER,U as SH_NODE_SHAPE,G as SH_PROPERTY_SHAPE,M as SH_SHAPE,O as ScalarStatement,b as Statement,j as StringStatement,ye as SubClassOfReferenceRule,fe as SubPropertyOfReferenceRule,K as SubjectKanonak,pe as SubjectKanonakTypeRequiredRule,Te as TokenCredentialProvider,L as TypeResolver,xe as UnresolvedPredicateRule,ce as UnresolvedReferenceRule,ne as ValidationContext,te as ValidationSeverity,be as buildOntologyModel,je as canonicalForm,De as canonicalHash,z as carrierOf,e as compareVersions,x as computeIntegrityAsync,He as createCredentialedFetch,r as createVersion,Le as findDerivation,t as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Ae as normalizeHost,Ne as parseAuthChallenge,f as parseLockFile,n as parseVersionString,$ as parseWithPositions,s as pickHighestDocument,k as serializeLockFile,c as setKanonakUserAgent,o as versionsEqual};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as z,c as G,d as X,m as b,n as Y,p as q,t as W,u as v,y as j,z as w}from"./chunk-CJMVIOZX.js";import{a as _}from"./chunk-FUUTGGJS.js";import{b as I}from"./chunk-F67UH4FD.js";var J=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let r=n.metadata?.namespace_?.toString()??"unknown",a=this.cache.get(r);if(a){let i=a.get(e);if(i)return i}let o=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(r,o),o.get(e)??null}async resolveAllEntitiesAsync(e,n){let r=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let a=e.split("."),o=a[0],i=a[1],u=await this.findDocumentForAlias(n,o);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(a=>a.entityName===e)}async buildAllEntitiesIndexAsync(e,n,r){let a=[],o=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${o}`),n.has(o))return this.logger?.debug?.(`Skipping ${o} - already visited (circular import prevention)`),a;n.add(o);let i=r.length===0?o:`${r} \u2192 ${o}`;for(let[u,c]of Object.entries(e.body))if(!u.includes(".")&&c&&typeof c=="object"&&!Array.isArray(c)){if(!e.metadata.namespace_)continue;let m=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.push({entityName:u,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,m),entity:c,definedInNamespace:o,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${a.length} entities from ${o}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,m)=>c+m.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${o}`);for(let[c,m]of Object.entries(e.metadata.imports))for(let d of m)if(!I(d))try{this.logger?.debug?.(`Resolving import: ${c}/${d.packageName}`);let g=await this.repository.getHighestCompatibleVersionAsync(c,d);if(g){this.logger?.debug?.(`Successfully loaded import: ${g.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(g,n,i);a.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${g.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${d.packageName}`)}catch(g){let k=g;throw this.logger?.error?.(`Failed to process import ${c}/${d.packageName} for namespace ${o}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${d.packageName} for namespace ${o}. See inner exception for details.`,{cause:g})}}return a}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,r,a){let o=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),o;let u=a.get(i);if(u)return u;n.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,m=0;for(let[d,g]of Object.entries(e.body))if(!d.includes(".")&&g&&typeof g=="object"&&!Array.isArray(g)){if(!e.metadata.namespace_)continue;if(!o.has(d)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};o.set(d,{entityName:d,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,k),entity:g,definedInNamespace:i,isImported:r.length>0,importPath:c}),m++}}if(this.logger?.debug?.(`Indexed ${m} entities from ${i}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((g,k)=>g+k.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${i}`);for(let[g,k]of Object.entries(e.metadata.imports))for(let h of k)if(!I(h))try{this.logger?.debug?.(`Resolving import: ${g}/${h.packageName}`);let P=await this.repository.getHighestCompatibleVersionAsync(g,h);if(P){this.logger?.debug?.(`Successfully loaded import: ${P.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(P,n,c,a),$=0;for(let[x,K]of U.entries()){let S=o.get(x);if(!S)o.set(x,K),$++;else if(S.isImported&&K.isImported&&(S.uri.publisher!==K.uri.publisher||S.uri.package_!==K.uri.package_)){let C=S.isAmbiguous?S:{...S,isAmbiguous:!0,ambiguousNamespaces:[S.definedInNamespace]};C.ambiguousNamespaces.includes(K.definedInNamespace)||C.ambiguousNamespaces.push(K.definedInNamespace),o.set(x,C),this.logger?.warn?.(`Ambiguous reference '${x}': defined in ${C.ambiguousNamespaces.join(", ")}`)}if(h.alias&&!x.includes(".")){let C=`${h.alias}.${x}`;o.has(C)||(o.set(C,K),$++)}}this.logger?.debug?.(`Merged ${$} entities from import ${P.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${g}/${h.packageName}`)}catch(P){let U=P;throw this.logger?.error?.(`Failed to process import ${g}/${h.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${g}/${h.packageName} for namespace ${i}. See inner exception for details.`,{cause:P})}}return n.delete(i),a.set(i,o),o}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[r,a]of Object.entries(e.metadata.imports))for(let o of a)if(!I(o)){if(o.alias===n)return await this.repository.getHighestCompatibleVersionAsync(r,o);if(!o.alias&&o.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(r,o)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var Q=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let r=await this.resourceResolver.resolveEntityAsync(e,n);if(r){let a=r.entity.type;if(a){let o=String(a);return o==="Class"||o==="rdfs.Class"||o.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function Z(t){if(!t||t.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let e=t.trim(),n=e.split("/");if(n.length===1){let r=n[0];if(!r)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${t}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(n.length===2){let[r,a]=n;if(!r||!a)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:r,package_:a};let i=a.substring(0,o),u=a.substring(o+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let c=se(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:_.parse(e)}}function Te(t){switch(t.kind){case"publisher":return t.publisher;case"package":return t.version?`${t.publisher}/${t.package_}@${t.version.major}.${t.version.minor}.${t.version.patch}`:`${t.publisher}/${t.package_}`;case"resource":return t.uri.toString()}}function se(t){let e=t.split(".").map(Number);return ie(e[0]||0,e[1]||0,e[2]||0)}function ie(t,e,n){return{major:t,minor:e,patch:n,toString:()=>`${t}.${e}.${n}`,equals:r=>!r||typeof r!="object"?!1:r.major===t&&r.minor===e&&r.patch===n,getHashCode:()=>t<<20|e<<10|n,compareTo:r=>t!==r.major?t-r.major:e!==r.minor?e-r.minor:n-r.patch}}function De(t){return`${t.publisher}/${t.package_}/${t.name}`}function y(t,e,n){return`${t}/${e}/${n}`}function $e(t){return`${t.s}|${t.p}|${pe(t.o)}`}function pe(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function ve(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var ce="kanonak.org",le="core-shacl",s=t=>({publisher:ce,package_:le,name:t}),N=s("Shape"),T=s("NodeShape"),H=s("PropertyShape"),we=s("targetClass"),Me=s("property"),Le=s("path"),Ve=s("minCount"),Fe=s("maxCount"),Be=s("datatype"),Ge=s("class"),Xe=s("in"),Ye=s("pattern"),qe=s("flags"),We=s("minLength"),ze=s("maxLength"),Je=s("minInclusive"),Qe=s("maxInclusive"),Ze=s("message"),et=s("targetNode"),tt=s("targetSubjectsOf"),nt=s("targetObjectsOf"),rt=s("closed"),ot=s("ignoredProperties"),at=s("nodeKind"),st=s("IRI"),it=s("BlankNode"),pt=s("Literal"),ct=s("severity"),lt=s("Violation"),ut=s("Warning"),yt=s("Info"),gt=s("ValidationReport"),dt=s("conforms"),mt=s("result"),ft=s("ValidationResult"),kt=s("focusNode"),bt=s("resultPath"),ht=s("resultMessage"),St=s("resultSeverity"),_t=s("sourceShape"),Pt=s("value"),Kt=s("sourceConstraintComponent"),Ct=s("MinCountConstraintComponent"),Et=s("MaxCountConstraintComponent"),At=s("DatatypeConstraintComponent"),xt=s("ClassConstraintComponent"),Rt=s("InConstraintComponent"),Ot=s("PatternConstraintComponent"),Ut=s("MinLengthConstraintComponent"),It=s("MaxLengthConstraintComponent"),Nt=s("MinInclusiveConstraintComponent"),Tt=s("MaxInclusiveConstraintComponent"),Ht=s("NodeKindConstraintComponent"),Dt=s("ClosedConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",te="core-kanonak",L=new Map([["type",p],["subClassOf",p],["subPropertyOf",p],["domain",p],["range",p],["label",p],["comment",p],["seeAlso",p],["isDefinedBy",p],["member",p],["Resource",p],["Class",p],["Property",p],["Datatype",p],["Literal",p],["List",p],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",te]]),ue=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function wt(t){return L.has(t)}function Mt(t){let e=L.get(t);return e?{publisher:l,package_:e}:void 0}function V(t,e,n){if(!t||!t.name)return;let r=L.get(t.name);if(!r)return;let a=()=>{t.publisher=l,t.package_=r,n&&(t.version=n.get(r))};if(ue.has(t.name)){let o=t.publisher===l&&t.package_===r;t.publisher=l,t.package_=r,!o&&n&&(t.version=n.get(r));return}t.publisher===l&&t.package_===r||t.publisher&&t.publisher.length>0&&(!e||e(t))||a()}var ee=class{type=y(l,p,"type");subClassOf=y(l,p,"subClassOf");subPropertyOf=y(l,p,"subPropertyOf");domain=y(l,p,"domain");range=y(l,p,"range");label=y(l,p,"label");comment=y(l,p,"comment");resource=y(l,p,"Resource");class_=y(l,p,"Class");datatype=y(l,p,"Datatype");literal=y(l,p,"Literal");equivalentClass=y(l,f,"equivalentClass");equivalentProperty=y(l,f,"equivalentProperty");inverseOf=y(l,f,"inverseOf");sameAs=y(l,f,"sameAs");transitiveProperty=y(l,f,"TransitiveProperty");symmetricProperty=y(l,f,"SymmetricProperty");objectProperty=y(l,f,"ObjectProperty");datatypeProperty=y(l,f,"DatatypeProperty");annotationProperty=y(l,f,"AnnotationProperty");package_=y(l,te,"Package");shape=M(N);nodeShape=M(T);propertyShape=M(H)};function M(t){return y(t.publisher,t.package_,t.name)}var ye=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let a={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return re(t)[0]??null}function re(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?q(t).map(n=>{let r={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(r),{publisher:r.publisher,package_:r.package_,name:r.name}}):[]}var ge=[N,T,H];function O(t,e){return ye.has(`${t}/${e}`)}var de=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return de.has(t.name)?t.name:void 0}var ne=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return re(e).some(r=>O(r.publisher,r.package_)&&r.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ge.some(r=>Y(n,r)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let r=R(e);return r?n.has(r.name):!1}};var E="kanonak.org",A="core-rdf",me={publisher:E,package_:A,name:"domain"},fe={publisher:E,package_:A,name:"range"},ke={publisher:E,package_:A,name:"subClassOf"},be={publisher:E,package_:A,name:"type"},he={publisher:E,package_:A,name:"label"},Se={publisher:E,package_:A,name:"comment"},_e=new _(E,A,"Resource");function Pe(t){try{let e=Z(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function B(t,e){let n=w(t,e);if(n)return[n];let r=[];for(let a of z(t,e))a instanceof X&&r.push(a.subject);return r}function ae(t,e){let n=[],r=new Set,a="version"in e?e.version:void 0,o=[new _(e.publisher,e.package_,e.name,a??void 0)];for(;o.length>0;){let i=o.shift(),u=b(i);if(r.has(u))continue;r.add(u),n.push(i);let c=Ke(t,i);c&&o.push(...B(c,ke))}return n}function Ke(t,e){return e.version&&typeof e.version.major=="number"?W(t,e)??v(t,e)[0]:v(t,e)[0]}function D(t,e){let n;for(let r of xe(e)){let a=Ce(t,r);if(a){if(a!=="Property")return a;n??=a}}return n}function Ce(t,e){let n=F(e);if(n)return n;let r=oe.get(t);r||(r=new Map,oe.set(t,r));let a=e.version,o=a&&typeof a.major=="number"?`${b(e)}@${a.major}.${a.minor}.${a.patch}`:b(e),i=r.get(o);if(i!==void 0)return i??void 0;let u;for(let c of ae(t,e)){let m=F(c);if(m){if(m!=="Property"){u=m;break}u??="Property"}}return r.set(o,u??null),u}var oe=new WeakMap;function Zt(t,e){return D(t,e)!==void 0}function en(t,e){return D(t,e)==="ObjectProperty"}function tn(t,e){return D(t,e)==="DatatypeProperty"}function Ee(t,e){let n=new Set([b(_e)]);for(let r of ae(t,e))n.add(b(r));return n}function Ae(t,e){let n=Ee(t,e),r=[],a=new Set;for(let o of t){if(!(o instanceof G))continue;let i=D(t,o);if(!i)continue;let u=B(o,me);if(!u.some(d=>n.has(b(d))))continue;let c=Pe(o);if(!c)continue;let m=b(c);a.has(m)||(a.add(m),r.push({uri:c,label:j(o,he),comment:j(o,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:w(o,fe),domains:u}))}return r}function nn(t,e,n){let r=Ae(t,e).find(a=>b(a.uri)===b(n));return r?{ok:!0,descriptor:r}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function xe(t){return B(t,be)}export{J as a,Q as b,Z as c,Te as d,De as e,y as f,$e as g,pe as h,ve as i,ce as j,le as k,N as l,T as m,H as n,we as o,Me as p,Le as q,Ve as r,Fe as s,Be as t,Ge as u,Xe as v,Ye as w,qe as x,We as y,ze as z,Je as A,Qe as B,Ze as C,et as D,tt as E,nt as F,rt as G,ot as H,at as I,st as J,it as K,pt as L,ct as M,lt as N,ut as O,yt as P,Ct as Q,Et as R,At as S,xt as T,Rt as U,Ot as V,Ut as W,It as X,Nt as Y,Tt as Z,Ht as _,Dt as $,wt as aa,Mt as ba,V as ca,ee as da,F as ea,ne as fa,Pe as ga,ae as ha,D as ia,Zt as ja,en as ka,tn as la,Ae as ma,nn as na,xe as oa};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as V}from"./chunk-
|
|
1
|
+
import{l as V}from"./chunk-PVUBHIU2.js";import{a as E}from"./chunk-HF5FJBS2.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{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 t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
|
|
2
2
|
`&&(n++,r=o+1)}return n===e?Math.min(r+t,i.length):-1}export{L as a,K as b,x as c,W as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m}from"./chunk-SC5M74NM.js";import{a as P}from"./chunk-HF5FJBS2.js";import{e as p,g as F,j as v}from"./chunk-QILEJIFU.js";var D="@kanonak-protocol/sdk (+https://kanonak.org)",y=D;function j(o){y=o}function B(){return y}function g(o){let t;try{t=typeof o=="string"?new URL(o):o}catch{throw new Error(`Kanonak requires an absolute https:// URL \u2014 got an unparseable or relative URL: ${String(o)}`)}if(t.protocol!=="https:")throw new Error(`Kanonak requires HTTPS \u2014 refusing to fetch ${t.href} (only https:// is supported).`)}var U=new Set([429,502,503,504]),_=4,K=500,C=2e4;function h(o,t){g(o);let e=new Headers(t?.headers);return e.has("User-Agent")||e.set("User-Agent",y),I(o,{...t,headers:e})}var d=_;function W(o){d=Math.max(0,o)}async function I(o,t){let e;for(let r=0;r<=d;r++){let n;try{n=await fetch(o,t)}catch(s){if(e=s,r>=d)throw s;await A(R(r,null));continue}if(!U.has(n.status)||r>=d)return n;await A(R(r,n.headers.get("retry-after")))}throw e??new Error("kanonakFetch: exhausted retries")}function R(o,t){let e=b(t);if(e!=null)return Math.min(e,C);let r=Math.min(C,K*2**o);return Math.floor(r/2+Math.random()*(r/2))}function b(o){if(!o)return null;let t=Number(o);if(Number.isFinite(t))return Math.max(0,t*1e3);let e=Date.parse(o);return Number.isNaN(e)?null:Math.max(0,e-Date.now())}function A(o){return new Promise(t=>setTimeout(t,o))}var T="https://{publisher}/{package}/{version}.kan.yml",L={version:1};function G(){return{version:1}}var k=class{constructor(t){this.fetchFn=t}fetchFn;cache=new Map;getConfig(t){let e=this.cache.get(t);return e||(e=this.fetchConfig(t),this.cache.set(t,e),e.catch(()=>{this.cache.get(t)===e&&this.cache.delete(t)})),e}async fetchConfig(t){let e=`https://${t}/.well-known/kanonak.json`,r;try{r=await(this.fetchFn?this.fetchFn(e,t):h(e))}catch{return L}if(r.status===404)return L;if(!r.ok)throw new Error(`Failed to fetch publisher config: ${e} (${r.status} ${r.statusText})`);let n=await r.json();if(typeof n.version!="number")throw new Error(`Invalid publisher config at ${e}: missing or invalid "version" field`);let s={version:n.version};return typeof n.package_url_template=="string"&&(M(e,"package_url_template",n.package_url_template),s.package_url_template=n.package_url_template),Array.isArray(n.featured_packages)&&n.featured_packages.every(a=>typeof a=="string")&&(s.featured_packages=n.featured_packages),s}resolvePackageUrl(t,e,r,n){let s=n.package_url_template??T,a=H(s,{publisher:t,package:e,version:r});return g(a),a}};function M(o,t,e){if(!e.startsWith("https://"))throw new Error(`Invalid publisher config at ${o}: ${t} must be an absolute https:// URL template (got "${e}").`)}function H(o,t){let e=o;for(let[n,s]of Object.entries(t))e=e.replaceAll(`{${n}}`,s);let r=e.match(/\{[a-z]+\}/);if(r)throw new Error(`Unresolved variable ${r[0]} in URL template: ${o}`);return e}import x from"js-yaml";var S=`# This file is generated by Kanonak CLI. Do not edit manually.
|
|
2
|
+
`,O="sha256:";function E(o){let t=x.load(o);return!t||typeof t!="object"||t.version!=="1"?null:{version:"1",lastUpdated:t.lastUpdated??"",packages:t.packages??{}}}function Y(o){let t={};for(let r of Object.keys(o.packages).sort())t[r]=o.packages[r];let e=x.dump({...o,packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'});return S+e}async function J(o){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(o)),e=Array.from(new Uint8Array(t),r=>r.toString(16).padStart(2,"0")).join("");return`${O}${e}`}var f=class{configResolver;fetchFn;lockCache=new Map;packageLockCache=new Map;constructor(t){this.configResolver=t?.configResolver??new k(t?.fetchFn),this.fetchFn=t?.fetchFn}getConfig(t){return this.configResolver.getConfig(t)}async getPackageUrl(t,e,r){let n=await this.configResolver.getConfig(t);return this.configResolver.resolvePackageUrl(t,e,r,n)}getLock(t){let e=this.lockCache.get(t);return e||(e=this.fetchLock(t),this.lockCache.set(t,e),e.catch(()=>{this.lockCache.get(t)===e&&this.lockCache.delete(t)})),e}async getPackageLockEntry(t,e){let r=`${t}/${e}`,n=this.packageLockCache.get(r);return n||(n=this.fetchLock(t,e),this.packageLockCache.set(r,n),n.catch(()=>{this.packageLockCache.get(r)===n&&this.packageLockCache.delete(r)})),(await n)?.packages[r]??null}async fetchLock(t,e){let r=e?`https://${t}/${e}/kanonak.lock`:`https://${t}/kanonak.lock`,n;try{n=this.fetchFn?await this.fetchFn(r,t):await h(r)}catch{return null}if(n.status===404)return null;if(!n.ok)throw new Error(`Failed to fetch publisher lock: ${r} (${n.status} ${n.statusText})`);return E(await n.text())}};import{VersionOperator as w}from"@kanonak-protocol/types/document/models/enums";function N(o,t){let e=F(o);return e?v(e,t):!1}var $=class{parser=new P;publisherIndex;documents=new Map;contentCache=new Map;fetchFn;onFetch;getFromCache;constructor(t){this.onFetch=t?.onFetch,this.getFromCache=t?.getFromCache,this.fetchFn=t?.fetchFn,this.publisherIndex=t?.fetchFn?new f({fetchFn:t.fetchFn}):new f}async getHighestCompatibleVersionAsync(t,e){if(e.versionOperator===w.Exact){let s=await this.fromMemoOrCache(t,e.packageName,p(e.version));if(s)return s}let n=(await this.publisherIndex.getLock(t))?.packages[`${t}/${e.packageName}`]??await this.publisherIndex.getPackageLockEntry(t,e.packageName)??void 0;return n&&N(n.version,e)?this.fetchPinned(t,e.packageName,n):n&&e.versionOperator!==w.Exact?null:this.resolveByDirectFetch(t,e)}async fetchPinned(t,e,r){let n=r.version,s=`${t}/${e}@${n}`,a=await this.fromMemoOrCache(t,e,n);if(a)return a;let i=r.resolved,c=this.fetchFn?await this.fetchFn(i,t):await h(i);if(!c.ok)throw new Error(`Failed to fetch Kanonak package: ${i} (${c.status} ${c.statusText})`);let l=await c.text(),u=this.parser.parse(l);return m(u,t,e,n),this.onFetch&&await this.onFetch(t,e,n,l),this.documents.set(s,u),this.contentCache.set(s,l),u}async fromMemoOrCache(t,e,r){let n=`${t}/${e}@${r}`,s=this.documents.get(n);if(s)return s;if(!this.getFromCache)return null;let a=await this.getFromCache(t,e,r);if(a==null)return null;let i;try{i=this.parser.parse(a),m(i,t,e,r)}catch(c){throw new Error(`Cached content for ${n} is not a usable copy of that package \u2014 refusing to fall through to a fetch that would hide it. ${c.message}`,{cause:c})}return this.documents.set(n,i),this.contentCache.set(n,a),i}async resolveByDirectFetch(t,e){let r=e.packageName,s=e.versionOperator===w.Exact?await this.publisherIndex.getPackageUrl(t,r,p(e.version)):`https://${t}/${r}.kan.yml`,a=await this.fetchFollowing(s,t);if(!a)return null;let i=this.parser.parse(a.content),c=i.metadata.namespace_;if(!c||!c.version)throw new Error(`Producer origin returned a package with no namespace/version for ${t}/${r}`);let l=p(c.version);m(i,t,r,l);let u=`${t}/${r}@${l}`;return this.onFetch&&await this.onFetch(t,r,l,a.content),this.documents.set(u,i),this.contentCache.set(u,a.content),i}async fetchFollowing(t,e,r=4){let n=t;for(let s=0;s<r;s++){g(n);let a=this.fetchFn?await this.fetchFn(n,e):await h(n,{redirect:"manual"});if(a.status===301||a.status===302){let i=a.headers.get("location");if(!i)throw new Error(`Redirect with no Location header from ${n}`);n=new URL(i,n).toString();continue}if(a.status===404)return null;if(!a.ok)throw new Error(`Failed to fetch Kanonak package: ${n} (${a.status} ${a.statusText})`);return{url:n,content:await a.text()}}throw new Error(`Too many redirects resolving ${t}`)}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(t){return this.documents.get(t)??null}async getDocumentsByNamespaceAsync(t,e){return Array.from(this.documents.values()).filter(r=>{let n=r.metadata.namespace_;return n&&n.publisher===t&&n.package_===e})}async saveDocumentAsync(t,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async deleteDocumentAsync(t){throw new Error("HttpKanonakDocumentRepository is read-only")}async clearNamespaceAsync(t,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(t){return this.contentCache.get(t)??null}async getDocumentUriAsync(t){let e=t.match(/^(.+?)\/(.+?)@(.+)$/);if(!e)return null;let[,r,n,s]=e;return this.publisherIndex.getPackageUrl(r,n,s)}};export{D as a,j as b,B as c,g as d,h as e,W as f,G as g,k as h,O as i,E as j,Y as k,J as l,f as m,$ as n};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import{a as Do}from"./chunk-KIBR3HAT.js";import{c as So,e as Io,f as oo,g as to,h as $o,i as jo,j as Oo,q as no,r as wo,s as Co}from"./chunk-Z5Y4MCW5.js";import{a as S,b as go,c as Ge,d as L,h as F,k as vo,m as j}from"./chunk-PVUBHIU2.js";import{a as fo}from"./chunk-HF5FJBS2.js";import{aa as ze,b as ko,ba as Ko,fa as $,ga as T,ha as H,ia as B,ja as Y,ma as Eo,na as W,oa as Vo}from"./chunk-7UYXTYXC.js";import{A as P,B as v,C as _,c as g,d as O,j as ee,k as G,l as M,m as b,n as q,p as ho,q as Ro,r as A,t as V,u as bo,w as oe,x as X,y as z,z as h}from"./chunk-CJMVIOZX.js";import{a as yo}from"./chunk-FUUTGGJS.js";import{b as Q,c as uo}from"./chunk-F67UH4FD.js";import{e as C}from"./chunk-QILEJIFU.js";var te=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=(t=>(t.Info="Info",t.Warning="Warning",t.Error="Error",t))(R||{});var u=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 ro=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let o=new p;return o.resolvedDocuments=this.resolvedDocuments,o.currentEntityPath=e,o}};var ne=class{constructor(e){this.underlying=e;this.repository=new ao(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 Do(e,this.repository);let o={};return{merged:await new j().parseKanonaks(this.underlying,o),authored:o.authored??[]}})()),this.parsePromise}},ao=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,o){let t=`${e}/${o}`,n=this.byNamespaceCache.get(t);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,o),this.byNamespaceCache.set(t,n),n)}getHighestCompatibleVersionAsync(e,o){let t=o.version,n=t?`${t.major}.${t.minor}.${t.patch}`:"",r=`${e}/${o.packageName}@${o.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,o),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 I(p,e,o){return o?o.getKanonaks():new j().parseKanonaks(new re(p,e))}async function w(p,e,o){let t=await I(p,e,o),n=Xe(p);return n?t.filter(r=>r instanceof g&&r.namespace===n):[]}async function ae(p,e,o){let t=Xe(p);if(!t)return[];let n;if(o)n=await o.getAuthoredKanonaks();else{let r={};await new j().parseKanonaks(new re(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof g&&r.sourceDoc===t)}function Xe(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var re=class{constructor(e,o){this.document=e;this.broader=o}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),o=(await this.broader.getAllDocumentsAsync()).filter(t=>t.metadata.namespace_?.toString()!==e);return[this.document,...o]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){return this.broader.getDocumentsByNamespaceAsync(e,o)}getHighestCompatibleVersionAsync(e,o){return this.broader.getHighestCompatibleVersionAsync(e,o)}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")}};var ie=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,o,t){let n=[],r=new Map;for(let[s,l]of Object.entries(e.metadata?.imports??{}))for(let m of l)Q(m)&&r.set(`${s}/${m.packageName}`,{publisher:s,import_:m});if(r.size===0)return n;let a=new Map,i=(s,l,m)=>{let d=`${s.publisher}/${s.package_}`;if(!r.has(d))return;let f=a.get(d)??[];f.push({uri:s,where:l,predicate:m}),a.set(d,f)},c=await w(e,o,t);L(c,({kanonak:s,path:l})=>{for(let m of s.statement){let d=m.predicate?.subject?.name??"(unknown)";if(m instanceof ee)i(m.object.subject,l,d);else if(m instanceof M)for(let f of m.object)f instanceof O&&i(f.subject,l,d);else if(m instanceof Ge)for(let f of m.links)f.target&&i(f.target.subject,l,d)}});for(let[s,l]of a){let{publisher:m,import_:d}=r.get(s),f=null,y;try{f=await o.getHighestCompatibleVersionAsync(m,d)}catch(k){y=k instanceof Error?k.message:String(k)}if(!f){let k=l[0],K=`${l.length} reference${l.length===1?"":"s"}, first at '${k.where}.${k.predicate}'`;this.options.offline?n.push(this.finding("Warning",k.where,k.predicate,s,`Link target package '${s}' could not be resolved offline (${K}); 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",k.where,k.predicate,s,`Link target package '${s}' could not be resolved${y?` (${y})`:""} \u2014 ${K}.`,"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:k,where:K,predicate:E}of l)Object.prototype.hasOwnProperty.call(f.body,k.name)||n.push(this.finding("Error",K,E,`${s}/${k.name}`,`Link to '${k.name}' in '${E}' at '${K}' does not dereference: package '${s}' (resolved to ${f.metadata.namespace_?.toString()??s}) defines no resource named '${k.name}'.`,`Check for a typo, or a resource renamed or removed in '${s}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var se=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let o=[];for(let[t,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(t,n,o);return o}validateEntity(e,o,t){for(let[n,r]of Object.entries(o)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),c=e.split(".")[0],s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=n,s.expectedValue=i,s.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,t)}}getSuggestionForPrefixedValue(e){let o=e.toLowerCase();if(o==="rdfs:class"||o==="owl:class")return"Class";if(o==="rdfs:property"||o==="rdf:property")return"DatatypeProperty or ObjectProperty";if(o.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var ce=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 o=[],t=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&&!t&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new u;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.",o.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 c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=n,c.message=`Invalid entity name '${n}'. ${i}`,c.suggestion=i,o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,o)}return o}validatePropertyNames(e,o,t){for(let n of Object.keys(o))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new u;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.",t.push(r)}}};var pe=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 o=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return o;let t=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 c=[];if(Array.isArray(i))for(let s of i){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=i?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),d=new u;d.ruleType=this.ruleName,d.severity="Error",d.entityName=n,d.propertyName="type",d.actualValue=s,d.expectedValue=m,d.message=`Invalid property type '${s}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",o.push(d)}}}return o}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,o){let t=e[o];return t?t.toString():null}isPropertyDefinedAsClass(e){let o=e.body.Property;if(o&&typeof o=="object"&&!Array.isArray(o)){let n=o.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var le=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let o=[];for(let[t,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||t.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
2
|
+
type: Scene
|
|
3
|
+
|
|
4
|
+
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",o.push(c)}}return o}};var ot=new Set(["EphemeralPackage"]),me=class{get ruleName(){return"PackageHeader"}validate(e){let o=e.metadata;if(!o.type_)return[];let t=[],n=this.packageKey(e,o.type_);return o.namespace_?(!ot.has(o.type_)&&!o.namespace_.version&&t.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
5
|
+
version: 1.0.0`)),t):(t.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
|
|
6
|
+
publisher: example.org`)),t)}packageKey(e,o){for(let[t,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===o)return t;return o}error(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.message=t,r.suggestion=n,r}};var tt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},nt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},rt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},at={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},ue=class{ruleName="EmbeddedKanonakType";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof G){let a=r.predicate?.subject,i=`${t}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,t,i,n),this.walk(e,r.object,i,n)}else if(r instanceof M){let a=r.predicate?.subject,i=0;for(let c of r.object){if(c instanceof S){let s=`${t}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,c,t,s,n),this.walk(e,c,s,n)}i++}}}check(e,o,t,n,r,a){if(!o)return;let i=h(t,tt);if(!i)return;let c=V(e,o);if(!c)return;let s=h(c,nt);if(s&&!(q(s,rt)||q(s,at))){if(b(i)===b(s)){a.push(this.redundant(n,r,i,s));return}H(e,i).some(l=>b(l)===b(s))||a.push(this.notSubclass(n,r,i,s))}}redundant(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' declares 'type: ${t.name}', which equals the parent property's range '${n.name}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,r.suggestion=`Remove the 'type: ${t.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' has 'type: ${t.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${t.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${t.name}' class definition so the relationship holds.`,r}};import{VersionOperator as Ze}from"@kanonak-protocol/types/document/models/enums";var de=class{ruleName="ImportExistence";async validateAsync(e,o){let t=[];if(!e.metadata?.imports)return t;let n=await o.getAllDocumentsAsync();for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){if(Q(i))continue;if(!await o.getHighestCompatibleVersionAsync(r,i)){let s=await this.determineImportErrorAsync(o,r,i,n),l=new u;l.ruleType=this.ruleName,l.severity="Error",l.message=s.message,l.suggestion=s.suggestion,l.entityName=`Import: ${r}/${i.packageName}`,l.actualValue=i.toString(),l.expectedValue=s.expectedValue,t.push(l)}}return t}async determineImportErrorAsync(e,o,t,n){let r=await e.getDocumentsByNamespaceAsync(o,t.packageName);if(r.length===0){let s=n.filter(f=>f.metadata.namespace_?.publisher===o).map(f=>f.metadata.namespace_.package_).filter((f,y,k)=>k.indexOf(f)===y),l=this.findSimilarPackages(t.packageName,s),m=`Import '${o}/${t.package_}' not found - package does not exist`,d=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:s.length>0?`Available packages in ${o}: ${s.slice(0,5).join(", ")}`:`No packages found for publisher '${o}'. Verify the publisher name is correct.`;return{message:m,suggestion:d,expectedValue:"Existing package"}}let i=r.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${o}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case Ze.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Ze.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Ze.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Ze.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,o){if(o.length===0)return[];let t=o.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(t.length>0)return t.sort((a,i)=>a.length-i.length);let n=o.map(a=>({package:a,distance:this.levenshteinDistance(e.toLowerCase(),a.toLowerCase())})).sort((a,i)=>a.distance-i.distance),r=Math.max(3,Math.floor(e.length*.4));return n.filter(a=>a.distance<=r).map(a=>a.package)}levenshteinDistance(e,o){if(!e||e.length===0)return o?.length??0;if(!o||o.length===0)return e.length;let t=e.length,n=o.length,r=Array(t+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=t;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=t;a++)for(let i=1;i<=n;i++){let c=e[a-1]===o[i-1]?0:1;r[a][i]=Math.min(Math.min(r[a-1][i]+1,r[a][i-1]+1),r[a-1][i-1]+c)}return r[t][n]}};var it="kanonak.org",st="core-rdf",ct=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(p=>b({publisher:it,package_:st,name:p}))),fe=class{ruleName="UnresolvedReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t),i=uo(e),c=s=>i.has(`${s.subject.publisher}/${s.subject.package_}`);return L(a,({kanonak:s,path:l})=>{for(let m of s.statement){let d=pt(m);if(!(!d||ct.has(b(d)))){if(m instanceof ee)c(m.object)||this.check(r,l,d,m.object,n);else if(m instanceof M)for(let f of m.object)f instanceof O&&!c(f)&&this.check(r,l,d,f,n)}}}),n}check(e,o,t,n,r){V(e,n.subject)||r.push(this.unresolvedError(o,t.name,n.subject))}unresolvedError(e,o,t){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${t.name}' in '${o}' could not be resolved`,r.suggestion=`The entity '${n}' is not defined in this namespace or any imported namespace.
|
|
7
|
+
\u2022 Import the package that defines it, or check for a typo in '${t.name}'
|
|
8
|
+
\u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function pt(p){return p.predicate?.subject}var Po={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Uo={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function lt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Je(p,e,o){let t=[],n=new Set,r=new Set,a=i=>{let c=V(p,i),s=c?`${c.namespace}/${c.name}`:b(i);if(n.has(s)){let l=t.findIndex(d=>d.key===s),m=t.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(s))return null;if(n.add(s),t.push({key:s,uri:i}),c)for(let l of lt(c,o)){let m=a(l);if(m)return m}return t.pop(),n.delete(s),r.add(s),null};return a(e)}var Ao=p=>p,ye=class{ruleName="ClassHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!($.isClassType(Ao(i))||$.isDatatypeType(Ao(i))))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Po);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular class hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",m.entityName=i.name,m.propertyName="subClassOf",m.actualValue=l,n.push(m);break}}return n}};var ge=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Uo);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=i.name,m.propertyName="subPropertyOf",m.actualValue=l,n.push(m);break}}return n}};var mt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ke=class{ruleName="PropertyRangeRequired";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";oe(i,mt)||n.push(this.error(i.name,s))}return n}error(e,o){let t=new u;return t.ruleType=this.ruleName,t.severity="Error",t.entityName=e,t.propertyName="range",t.message=`Property '${e}' must have a 'range' defined.`,t.suggestion=o?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",t.expectedValue=o?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",t}};var ut={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},No=p=>p,he=class{ruleName="SubClassOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!To(No(i)))continue;let c=dt(i,ut);for(let s=0;s<c.length;s++)this.resolvesToClassLike(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?To(No(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subClassOf",r.actualValue=n,r.expectedValue="Defined or imported class",r.message=`Class '${o.name}' referenced in subClassOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a Class, or import a namespace that contains it`,r}};function To(p){return $.isClassType(p)||$.isDatatypeType(p)}function dt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ft={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Re=class{ruleName="SubPropertyOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=yt(i,ft);for(let s=0;s<c.length;s++)this.resolvesToProperty(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToProperty(e,o){let t=V(e,o);return t?Y(e,t):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subPropertyOf",r.actualValue=n,r.expectedValue="Defined or imported property",r.message=`Property '${o.name}' referenced in subPropertyOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a property, or import a namespace that contains it`,r}};function yt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var be=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,o){let t=[],n=e.metadata.namespace_?.toString();if(!n)return t;let r=new Map,a=new Set;await this.buildImportGraph(e,o,r,a);let i=this.detectCycle(n,r);if(i){let c=i.join(" \u2192 "),s=new u;s.ruleType=this.ruleName,s.severity="Error",s.message=`Circular namespace import detected: ${c}`,s.suggestion="Remove one of the imports to break the circular dependency, or \u2014 if one direction is a DATA reference rather than a schema dependency (an object-property value naming a resource in the other package) \u2014 mark that import `mode: link`: links are dereferenced on demand, are not in the closure, and are exempt from this rule. Circular dependencies prevent proper package resolution.",s.entityName="imports",s.propertyName="imports",s.actualValue=c,t.push(s)}return t}async buildImportGraph(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,c]of Object.entries(e.metadata.imports))for(let s of c){if(Q(s))continue;let l=`${i}/${s.packageName}@${s.version}`;a.push(l);let m=await o.getHighestCompatibleVersionAsync(i,s);m&&await this.buildImportGraph(m,o,t,n)}a.length>0&&t.set(r,a)}}detectCycle(e,o){let t=[],n=new Set;return this.detectCycleRecursive(e,o,t,n)}detectCycleRecursive(e,o,t,n){let r=t.indexOf(e);if(r>=0){let i=t.slice(r);return i.push(e),i}if(n.has(e))return null;t.push(e),n.add(e);let a=o.get(e);if(a)for(let i of a){let c=this.detectCycleRecursive(i,o,t,n);if(c)return c}return t.pop(),null}};var Ke=class{ruleName="UnresolvedPredicate";async validateAsync(e,o,t){let n=[],r=Xe(e);if(!r)return n;let a=await I(e,o,t);return L(a,({kanonak:i,path:c})=>{for(let s of i.unresolvedPredicates)s.sourceDoc===r&&n.push(this.unresolvedPredicateError(c,s.key))}),n}unresolvedPredicateError(e,o){let t=o.lastIndexOf("."),n=t>0?o.slice(0,t):null,r=t>0?o.slice(t+1):o,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=o,a.expectedValue="A defined or imported property",a.message=`Property '${o}' is not defined or imported`,a.suggestion=n?`The property '${r}' was not found in the namespace imported as '${n}'.
|
|
9
|
+
1. Check '${r}' is spelled correctly
|
|
10
|
+
2. Verify '${n}' is imported with the right alias and version
|
|
11
|
+
3. Ensure that namespace version actually defines '${r}'`:`The property '${o}' is not defined in this namespace or any imported namespace.
|
|
12
|
+
1. Define '${o}' as an ObjectProperty or DatatypeProperty here, OR
|
|
13
|
+
2. Import the namespace that defines it, OR
|
|
14
|
+
3. Alias-qualify it if it lives in an imported namespace ('alias.${o}')`,a}};var Ee=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,o){let t=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,o),a=await this.buildDatatypePropertyNamesAsync(e,o);for(let[i,c]of Object.entries(e.body))typeof c=="object"&&c!==null&&!Array.isArray(c)&&this.validateEntityReferences(i,c,n,r,a,e,t);return t}async buildEntitySourceMapAsync(e,o){let t=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(a)||t.set(a,[]),t.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let c of i){let s=await o.getHighestCompatibleVersionAsync(a,c);if(s){let l=s.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(s,t,n,r,[l],o)}}return{entitySources:t,importPaths:r}}async collectEntitiesRecursivelyAsync(e,o,t,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!t.has(i)){t.add(i),n.has(i)||n.set(i,r);for(let c of Object.keys(e.body)){o.has(c)||o.set(c,[]);let s=o.get(c);s.includes(i)||s.push(i)}if(e.metadata.imports)for(let[c,s]of Object.entries(e.metadata.imports))for(let l of s){let m=await a.getHighestCompatibleVersionAsync(c,l);if(m){let d=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,o,t,n,[...r,d],a)}}}}async buildDatatypePropertyNamesAsync(e,o){let t=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,t,n,o),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let c=await o.getHighestCompatibleVersionAsync(r,i);c&&await this.collectDatatypePropertiesAsync(c,t,n,o)}return t}async collectDatatypePropertiesAsync(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!t.has(r)){t.add(r);for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let c=i.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&o.add(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let c of i){let s=await n.getHighestCompatibleVersionAsync(a,c);s&&await this.collectDatatypePropertiesAsync(s,o,t,n)}}}validateEntityReferences(e,o,t,n,r,a,i){for(let[c,s]of Object.entries(o)){let l=c;if(l&&!l.includes(".")){let m=t.get(l);if(m&&m.length>1&&!m.some(f=>f.startsWith("(local:"))){let f=m.filter(y=>!y.startsWith("(local:"));f.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,f,n,a,!0,l))}}this.validatePropertyValue(e,l,s,t,n,r,a,i)}}validatePropertyValue(e,o,t,n,r,a,i,c){if(t==null)return;let s=o&&o.includes(".")?o.substring(o.lastIndexOf(".")+1):o,l=!!s&&a.has(s);if(typeof t=="string"&&!t.includes(".")&&!l){let m=n.get(t);if(m&&m.length>1&&!m.some(f=>f.startsWith("(local:"))){let f=m.filter(y=>!y.startsWith("(local:"));f.length>1&&c.push(this.createAmbiguityError(e,o,`Reference '${t}'`,f,r,i,!1,t))}}else if(Array.isArray(t))for(let m=0;m<t.length;m++){let d=`${e}.${o}[${m}]`;this.validatePropertyValue(d,o,t[m],n,r,a,i,c)}else if(typeof t=="object"&&!Array.isArray(t)){let m=o?`${e}.${o}`:e;this.validateEntityReferences(m,t,n,r,a,i,c)}}createAmbiguityError(e,o,t,n,r,a,i,c){let s=[];for(let K of n){let E=this.findAliasForNamespace(a,K);if(E){let U=o?.split(".").pop()??o;s.push(`${E}.${U}`)}}let l=s.length>0?`Use one of: ${s.map(K=>`'${K}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${o}')`,m=n.map(K=>{let E=r.get(K);return!E||E.length===0?` \u2022 ${K}`:E.length===1?` \u2022 ${K} (direct import)`:` \u2022 ${K}
|
|
15
|
+
imported via: ${E.join(" \u2192 ")}`}).join(`
|
|
16
|
+
`),d=e.split(".")[0],f=e.includes(".")?e:o,y=new u;y.ruleType=this.ruleName,y.severity="Error",y.entityName=d,f&&(y.propertyName=f);let k=c??o;return k&&(y.actualValue=k),y.message=`${t} is ambiguous - defined in multiple imported namespaces`,y.suggestion=`${l}
|
|
17
|
+
|
|
18
|
+
Defined in:
|
|
19
|
+
${m}`,y.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",y}findAliasForNamespace(e,o){if(!e.metadata.imports)return null;for(let[t,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${t}/${r.packageName}@${r.version}`===o&&r.alias)return r.alias;return null}};var gt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},xo=p=>p,Ve=class{ruleName="PropertyRangeReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";for(let l of kt(i,gt))this.resolvesToClassLike(r,l)||n.push(this.error(i.name,l,s))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?$.isClassType(xo(t))||$.isDatatypeType(xo(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="range",r.actualValue=n,r.expectedValue=t?"A defined or imported class":"A datatype or defined class",r.message=`Property '${e}' has range '${o.name}' which is not defined or imported`,r.suggestion=t?`Define '${o.name}' as a Class here, or import the namespace that contains it (alias-qualify it if imported under an alias).`:`Use a datatype (xsd type, rdfs.Literal, or a datatype-derived type), or \u2014 if '${o.name}' is a class \u2014 make this an ObjectProperty.`,r}};function kt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ht={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ve="kanonak.org",io="core-rdf",so="core-owl",co=p=>p,Rt=[{uri:{publisher:ve,package_:io,name:"Class"},ok:(p,e)=>$.isClassType(co(e))||$.isDatatypeType(co(e))},{uri:{publisher:ve,package_:io,name:"Datatype"},ok:(p,e)=>$.isDatatypeType(co(e))},{uri:{publisher:ve,package_:io,name:"Property"},ok:(p,e)=>Y(p,e)},{uri:{publisher:ve,package_:so,name:"ObjectProperty"},ok:(p,e)=>B(p,e)==="ObjectProperty"},{uri:{publisher:ve,package_:so,name:"DatatypeProperty"},ok:(p,e)=>B(p,e)==="DatatypeProperty"},{uri:{publisher:ve,package_:so,name:"AnnotationProperty"},ok:(p,e)=>B(p,e)==="AnnotationProperty"}],De=class{ruleName="ObjectPropertyValue";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof ee)this.check(e,r.predicate?.subject,r.object.subject,t,n);else if(r instanceof G)this.walk(e,r.object,_o(t,r.predicate?.subject),n);else if(r instanceof M){let a=r.predicate?.subject;for(let i of r.object)i instanceof O?this.check(e,a,i.subject,t,n):i instanceof S&&this.walk(e,i,_o(t,a),n)}}check(e,o,t,n,r){if(!o)return;let a=V(e,o);if(!a)return;let i=h(a,ht);if(!i)return;let c=Rt.find(l=>q(i,l.uri));if(!c)return;let s=V(e,t);s&&(c.ok(e,s)||r.push(this.warn(n,o,i,t)))}warn(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e.split(".")[0],r.propertyName=e,r.actualValue=n.name,r.expectedValue=t.name,r.message=`Property '${o.name}' expects a ${t.name}, but '${n.name}' is not a ${t.name}`,r.suggestion=`Reference a resource that is a ${t.name}, or correct the type of '${n.name}'.`,r}};function _o(p,e){return`${p}.${e?.name??"<embedded>"}`}var bt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Kt={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},Et={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Se=class{ruleName="PropertyDomain";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){this.checkNode(e,o,t,n);for(let r of o.statement)if(r instanceof G)this.walk(e,r.object,Mo(t,r.predicate?.subject),n);else if(r instanceof M)for(let a of r.object)a instanceof S&&this.walk(e,a,Mo(t,r.predicate?.subject),n)}checkNode(e,o,t,n){let r=Lo(o,bt);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([b(Et)]);for(let s of r)for(let l of H(e,s))a.add(b(l))}return a},c=new Set;for(let s of o.statement){let l=Vt(s);if(!l||ze(l.name)||c.has(b(l)))continue;c.add(b(l));let m=V(e,l);if(!m)continue;let d=Lo(m,Kt);d.length!==0&&(d.some(f=>i().has(b(f)))||n.push(this.error(t,l,d,r[0])))}}error(e,o,t,n){let r=t.map(i=>i.name).join(" | "),a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e.split(".")[0],a.propertyName=e,a.actualValue=o.name,a.expectedValue=`Property used on ${r} or its subclasses`,a.message=`Property '${o.name}' has domain '${r}' but is used on '${n.name}' at '${e}'`,a.suggestion=`Either:
|
|
20
|
+
1. Use '${o.name}' only on '${r}' (or a subclass) instances
|
|
21
|
+
2. Widen the property's domain to include '${n.name}'
|
|
22
|
+
3. Use a different property for '${n.name}'`,a}};function Vt(p){return p.predicate?.subject}function Lo(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Mo(p,e){return`${p}.${e?.name??"<embedded>"}`}var vt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Dt={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},St=p=>p,Ie=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty",l=c==="DatatypeProperty",m=h(i,vt);if(!m||!V(r,m))continue;let d=It(r,m);l&&!d?n.push(this.error(i.name,m,"datatype")):s&&d&&n.push(this.error(i.name,m,"object"))}return n}error(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="range",n.actualValue=o.name,t==="datatype"?(n.expectedValue="A datatype (xsd type, rdfs.Literal, or a datatype-derived class)",n.message=`DatatypeProperty '${e}' has range '${o.name}', which is a class, not a datatype. A datatype property's values are literals.`,n.suggestion=`Use a datatype range (e.g. xsd.string, rdfs.Literal, or a datatype-derived class), or \u2014 if '${o.name}' is the intended target \u2014 declare '${e}' an ObjectProperty.`):(n.expectedValue="A plain class (not datatype-derived)",n.message=`ObjectProperty '${e}' has range '${o.name}', which is a datatype, not a class. An object property's values are references to resources.`,n.suggestion=`Declare '${e}' a DatatypeProperty (its values are literals of '${o.name}'), or change the range to a plain class.`),n}};function It(p,e){for(let o of H(p,e)){if(q(o,Dt))return!0;let t=V(p,o);if(t&&$.isDatatypeType(St(t)))return!0}return!1}var $e=class{ruleName="ReservedNameShadow";async validateAsync(e,o,t){let n=[],r=await w(e,o,t);for(let a of r){if(!(a instanceof g))continue;let i=Ko(a.name);if(!i)continue;let c=T(a);c&&(i.publisher===c.publisher&&i.package_===c.package_||n.push(this.info(a.name,c,i)))}return n}info(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Info",n.entityName=e,n.propertyName=e,n.actualValue=`${o.publisher}/${o.package_}/${e}`,n.expectedValue=`${t.publisher}/${t.package_}/${e}`,n.message=`'${e}' is also the reserved built-in '${t.publisher}/${t.package_}/${e}'. This local definition shadows it \u2014 a bare '${e}' reference in this package resolves to the local entity, not the built-in.`,n.suggestion=`If this is intentional, qualify bare references to '${e}' explicitly (this local one vs. the built-in '${t.publisher}/${t.package_}/${e}') so the choice is unambiguous to readers and tools \u2014 e.g. a self-referential 'subClassOf: ${e}' silently resolves to this local entity.`,n}};var $t={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Bo=p=>p,je=class{ruleName="ClassDefinition";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);return L(a,({kanonak:i,path:c})=>{for(let s of jt(i,$t))this.resolvesToClassLike(r,s)||n.push(this.error(c,s))}),n}resolvesToClassLike(e,o){if(ze(o.name))return!0;let t=V(e,o);return t?$.isClassType(Bo(t))||$.isDatatypeType(Bo(t)):!1}error(e,o){let t=`${o.publisher}/${o.package_}/${o.name}`,n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="type",n.actualValue=t,n.expectedValue="Defined or imported class",n.message=`Class '${o.name}' is not defined or imported`,n.suggestion=`Define '${o.name}' as a Class in this document, or import a namespace that contains it`,n}};function jt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var Oe=class{ruleName="MarkdownLink";async validateAsync(e,o,t){let n=[],r=await w(e,o,t);return L(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,o,t){for(let n of e.statement){if(!(n instanceof Ge))continue;let r=n.predicate.subject?.name??"(unknown)";for(let a of n.links)a.target||t.push(this.unresolvedLinkError(o,r,a.reference));for(let a of vo(n.object))t.push(this.malformedLinkError(o,r,a.snippet))}}unresolvedLinkError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`Embedded link [[${t}]] in '${o}' could not be resolved`,n.expectedValue="A reference resolvable through the document's import closure",n.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
23
|
+
|
|
24
|
+
Possible solutions:
|
|
25
|
+
\u2022 Import the package that defines '${t}' so the link can resolve
|
|
26
|
+
\u2022 Check for typos in the reference name
|
|
27
|
+
\u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,n}malformedLinkError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`Malformed embedded reference near '${t}' in '${o}'`,n.expectedValue="A single-line [[reference]] with no internal line break",n.suggestion=`A '[[' in '${o}' does not form a complete [[reference]] link.
|
|
28
|
+
|
|
29
|
+
A reference may not span a line break \u2014 the most common cause is wrapping a
|
|
30
|
+
long reference across two lines in a block scalar, e.g.:
|
|
31
|
+
... read for [[persistent-energy-
|
|
32
|
+
shock]] held ...
|
|
33
|
+
which is parsed as literal text, not a link. Keep each [[reference]] on one
|
|
34
|
+
line (let the line run long), or check for an unterminated [[.`,n}};var Wo="kanonak.org",Fo="look",Ot={publisher:Wo,package_:Fo,name:"displayLabel"},wt={publisher:Wo,package_:Fo,name:"displaySummary"},we=class{ruleName="DisplayLensScope";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=Ct(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&(this.checkLens(r,i,Ot,"displayLabel",n),this.checkLens(r,i,wt,"displaySummary",n));return n}checkLens(e,o,t,n,r){let a=h(o,t);if(!a)return;let i=[],c=T(o);if(c&&i.push(c),i.push(...Vo(o)),i.length===0)return;i.some(l=>W(e,l,a).ok)||r.push(this.scopeError(o.name,n,a.name))}scopeError(e,o,t){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=t,n.message=`${o} points at '${t}', which is not a property in scope for '${e}'`,n.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",n.suggestion=`'${t}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
|
|
35
|
+
|
|
36
|
+
Possible solutions:
|
|
37
|
+
\u2022 Point ${o} at a property declared on this class (or an ancestor / rdfs.Resource)
|
|
38
|
+
\u2022 Set the property's domain to this class if it should apply here
|
|
39
|
+
\u2022 Use rdfs.label / rdfs.comment for the universal default`,n}};function Ct(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}function Z(p,e,o){let t=[];return We(p,o,{input:e},t),t}function We(p,e,o,t){if(A(e,F.VarRef)){let a=z(e,F.varName);return a?o[a]:void 0}if(A(e,F.PropertyRead)){let a=P(e,F.readSource),i=a?We(p,a,o,t):void 0,c=h(e,F.readProp);if(!i||!c)return;let s=W(p,i,c);if(!s.ok){t.push({contextClass:i,propertyUri:c,via:"PropertyRead"});return}return s.descriptor?.range}if(A(e,F.Traverse)){let a=P(e,F.traverseSource),i=a?We(p,a,o,t):void 0,c=h(e,F.through),s;if(i&&c){let m=W(p,i,c);m.ok?s=m.descriptor?.range:t.push({contextClass:i,propertyUri:c,via:"Traverse"})}let l=P(e,F.step);return l?We(p,l,{...o,input:s},t):void 0}let n=z(e,F.loopVar),r=n?{...o,[n]:void 0}:o;for(let a of Pt(e))We(p,a,r,t)}function Pt(p){let e=[];for(let o of p.statement){let t=o.object;if(t instanceof S)e.push(t);else if(Array.isArray(t))for(let n of t)n instanceof S&&e.push(n)}return e}var Fe="kanonak.org",qe="look",Ut={publisher:Fe,package_:qe,name:"semanticSvg"},At={publisher:Fe,package_:qe,name:"tierChip"},Nt={publisher:Fe,package_:qe,name:"tierIcon"},Tt={publisher:Fe,package_:qe,name:"tierCard"},xt={publisher:Fe,package_:qe,name:"tierFull"},_t=[At,Nt,Tt,xt],Ce=class{ruleName="LookSemanticSvgPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=Lt(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,o,t){let n=P(o,Ut);if(!n)return;let r=T(o);if(r)for(let a of _t){let i=P(n,a);if(i)for(let c of Z(e,r,i))t.push(this.toError(o.name,a.name,c))}}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.contextClass.name,a=r===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${r}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${o}`,i.actualValue=n,i.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${a}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${n}' is not in scope for '${r}'.
|
|
40
|
+
|
|
41
|
+
Possible solutions:
|
|
42
|
+
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
43
|
+
\u2022 If the property should apply to '${r}', adjust its domain
|
|
44
|
+
\u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function Lt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qo={publisher:"kanonak.org",package_:"transformations",name:"Expression"},Mt=new Map([["look","the look renderer"],["view","the view materializer"],["transformations","the transformation runner"]]);function Bt(p){if(!(!p||p.publisher!=="kanonak.org"))return Mt.get(p.package_)}var Pe=class{ruleName="TxExpressionCompiles";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=Ft(e);if(!a)return n;let i=r.filter(y=>y instanceof g&&y.namespace===a);if(i.length===0)return n;let c=new Map,s=y=>{for(let k of ho(y)){let K=b(k),E=c.get(K);if(E===void 0&&(E=q(k,qo)||H(r,k).some(U=>q(U,qo)),c.set(K,E)),E)return!0}return!1},l=[],m=new Map,d=new Set;for(let y of i)L([y],({kanonak:k,path:K})=>{let E=k instanceof S&&s(k);E&&l.push({node:k,path:K,subject:y.name});for(let{child:U,predicate:N}of Wt(k))s(U)&&(N&&m.set(U,N),E&&d.add(U))});let f=new Set;for(let{node:y,path:k,subject:K}of l){if(d.has(y))continue;let E=Bt(m.get(y));if(E)try{So(y,k,{catalog:r,depth:0})}catch(U){let N=U instanceof Error?U.message:String(U),eo=`${K} ${k} ${N}`;if(f.has(eo))continue;f.add(eo),n.push(this.toError(K,k,N,E))}}return n}toError(e,o,t,n){let r=new u;r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t;let a=/[.!?]$/.test(t)?t:`${t}.`;return r.message=`A tx.Expression at '${o}' is in a slot ${n} evaluates, but it cannot be compiled: ${a} The value would be silently absent wherever this slot is used.`,r.expectedValue=`A tx.Expression built from node classes ${n} implements`,r.suggestion=`This slot is evaluated by ${n}, which is part of this SDK, so its node classes are the ones available here. (An Expression subclass meant for a DIFFERENT runner is fine in that runner's own slots \u2014 this rule does not look at those.)
|
|
45
|
+
|
|
46
|
+
Possible solutions:
|
|
47
|
+
\u2022 Rebuild the expression from tx primitives this SDK supports
|
|
48
|
+
\u2022 For numeric presentation (rounding, percentages, fixed precision), use tx.NumberFormat \u2014 it scales internally, so no arithmetic is needed
|
|
49
|
+
\u2022 If the node class should be supported, implement it in the runner first`,r}};function Wt(p){let e=[];for(let o of p.statement){let t=o.predicate?.subject;if(o instanceof G)e.push({child:o.object,predicate:t});else if(o instanceof M)for(let n of o.object)n instanceof S&&e.push({child:n,predicate:t})}return e}function Ft(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qt="kanonak.org",He=(p,e)=>({publisher:qt,package_:p,name:e}),Ht=He("derivation","look"),Ho=He("look","bands"),Yo=He("look","Sequence"),Yt=He("core-rdf","range"),Gt=He("look","nodeTier"),Ue=class{ruleName="SequenceNarrative";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=zt(e);if(!a)return n;let i=r.filter(s=>s instanceof g&&s.namespace===a);if(i.length===0)return n;for(let s of i){let l=P(s,Ht);l&&v(l,Ho).forEach((m,d)=>{!(m instanceof S)||!A(m,Yo)||n.push(...this.checkBand(r,s,m,`${s.name}.look.bands[${d}]`))})}let c=new wo(r);for(let s of i){let l=c.findCascadedLook(s);if(l)for(let m of v(l.declaration,Ho))!(m instanceof S)||!A(m,Yo)||this.checkBand(r,s,m,"").length>0||n.push(...this.checkInstance(r,s,m,$o(r,s,m)))}return n}checkBand(e,o,t,n){let r=[],a=(l,m,d)=>r.push(this.toError("Error",o.name,n,l,m,d)),i=oo(t);if(!i)a("A look.Sequence band declares no look.source. The order of a sequence comes from the [[references]] in a prose property, so without one nothing can be sequenced.","Set look.source to a property of this class whose rdfs.range is prose.Markdown (or prose.SubstitutableString), and render the same property with a look.Markdown band so the narrative and the diagram cannot drift.");else{let l=bo(e,i)[0],m=l?Ro(l,Yt):[];l&&!m.some(d=>ko.isSubstitutableDatatypeUri(d))&&a(`look.source names '${i.name}', whose rdfs.range is ${m.map(d=>b(d)).join(", ")||"undeclared"} \u2014 not prose.Markdown. A Sequence orders its participants by the [[references]] in prose, so a value of this property carries no order.`,"Point look.source at a prose.Markdown-ranged property, or give this property that range if its values are narrative.",b(i))}let c=to(e,t);c.length===0&&a("A look.Sequence band declares no look.connectors, so no property counts as a message and every narrative renders empty.","List the object properties that constitute messages: look.connectors: [{ look.relation: calls }, ...]. The domain ontology declares nothing about sequences; the look layer says which of its relations are interactions.");for(let l of c)(!l.subject||B(e,l.subject)===void 0)&&a(`look.connectors names '${l.relation.name}' as a relation, but it is not a property${l.subject?"":" in the closure"}. A message is a triple, so its relation must be an object property whose values are the participants.`,"Use an owl.ObjectProperty (or a subclass such as owl.SymmetricProperty) for look.relation.",b(l.relation)),l.invalidStyle!==void 0&&a(`look.lineStyle '${l.invalidStyle}' on connector '${l.relation.name}' is not a supported value. Supported: ${[...Io].join(", ")}.`,"Use one of the supported values, or omit look.lineStyle: a reply is derived from owl.inverseOf and an undirected edge from owl.SymmetricProperty, so the overlay is only needed for what the ontology cannot say.",l.invalidStyle);let s=z(t,Gt);return s!==void 0&&no[s]===void 0&&a(`look.nodeTier '${s}' is not a tier. Supported: ${Object.keys(no).join(", ")}.`,"Use one of the semantic-zoom tiers \u2014 chip (56), icon (120, the default), card (240), full (420) \u2014 or omit look.nodeTier to take the participants' class-level look.diagramTier.",s),r}checkInstance(e,o,t,n){let r=[],a=oo(t),i=`${o.name}.${a.name}`,c=to(e,t).map(s=>s.relation.name).join(", ");if(n.problem)return r.push(this.toError("Error",o.name,i,`The look.Sequence band cannot walk this instance: ${n.problem}.`,"Check the value authored for the source property.")),r;if(n.sourceAbsent)return r.push(this.toError("Warning",o.name,i,`'${o.name}' carries no value for '${a.name}', so its look.Sequence band renders nothing.`,`Author the narrative in '${a.name}' with [[references]] to the participants, or leave it if the band is meant to be empty here.`)),r;for(let s of n.strayPropertyRefs)r.push(this.toError("Error",o.name,i,`The narrative references property '${s.name}', which is not a declared connector of the look.Sequence band (declared: ${c}). A property reference between two participants selects the edge for that pair; one the band does not declare selects nothing, and the sentence draws no message.`,`Add { look.relation: ${s.name} } to look.connectors on the band, or reference one of the declared connectors instead.`,b(s)));if(n.mentions>=2&&n.messages.length===0)return r.push(this.toError("Error",o.name,i,`The narrative mentions ${n.mentions} participant references but joins nothing: no declared connector (${c}) holds between any consecutive pair, so the look.Sequence band renders no message.`,"Either the graph is missing the triples the prose describes (declare them on the participants), the band is missing the relation the prose relies on (add it to look.connectors), or the prose orders participants no relation joins (reorder it).")),r;for(let s of n.gaps){let l=s.selected?`'${s.selected.name}' does not hold`:`no declared connector (${c}) holds`;r.push(this.toError("Warning",o.name,i,`The narrative orders '${s.prev.name}' then '${s.next.name}', but ${l} between them in the graph, so no message is drawn for that pair.`,`If the prose is right, declare the relation on '${s.prev.name}' or '${s.next.name}' (or add it to look.connectors); if the graph is right, reorder the prose so consecutive references are joined. A mention that is meant to connect to nothing is fine \u2014 it simply gets no lifeline.`,`${s.prev.name} \u2192 ${s.next.name}`))}return r}toError(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function zt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Xt="kanonak.org",D=(p,e)=>({publisher:Xt,package_:p,name:e}),Zt=D("derivation","look"),Jt=D("look","bands"),Qt=D("look","Distribution"),en=D("look","StatRow"),on=D("look","VersionDelta"),tn=D("look","Timeline"),nn=D("look","VersionDiff"),rn=D("look","TimePlot"),an=D("look","ReferenceList"),sn=D("look","Diagram"),cn=D("look","alphaPath"),pn=D("look","betaPath"),po=D("look","metricPath"),Go=D("look","lowerPath"),zo=D("look","upperPath"),Xo=D("look","hueBy"),ln=D("look","statPath"),mn=D("look","laneBy"),Zo=D("look","labelPath"),un=D("look","badgePath"),dn=D("look","mapPath"),fn=D("look","nodeNote"),yn=D("look","edgeValue"),gn=D("look","stats"),kn=D("look","facets"),hn=D("look","channels"),Rn=D("look","track"),bn=D("look","source"),Kn=D("look","relation"),En=D("look","entries"),Ae=class{ruleName="LookBandPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=vn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,o,t){let n=P(o,Zt);if(!n)return;let r=T(o);if(!r)return;let a=v(n,Jt).filter(i=>i instanceof S);for(let i of a)for(let c of this.carriersOf(e,i,r))for(let s of Z(e,c.context,c.expr))t.push(this.toError(o.name,c.slot,s))}carriersOf(e,o,t){let n=[],r=(a,i)=>{let c=P(o,a);c&&n.push({slot:`look.${a.name}`,context:i,expr:c})};if(A(o,Qt))for(let a of[cn,pn,po,Go,zo,Xo])r(a,t);if(A(o,on)&&r(po,t),A(o,en)){let a=v(o,gn).filter(i=>i instanceof S);for(let i of a){let c=P(i,ln);c&&n.push({slot:"look.stats[].statPath",context:t,expr:c})}}if(A(o,tn)||A(o,nn)){let a=this.rangeOf(e,t,h(o,Rn));if(a)for(let i of[po,Go,zo,Xo])r(i,a)}if(A(o,rn)){let a=this.rangeOf(e,t,h(o,bn));if(a)for(let i of[mn,Zo])r(i,a)}if(A(o,an))for(let a of v(o,En)){let i=a instanceof S?void 0:Vn(a),c=this.rangeOf(e,t,i);if(c)for(let s of[Zo,un])r(s,c)}if(A(o,sn)){let a=v(o,kn).filter(i=>i instanceof S);for(let i of a){let c=this.rangeOf(e,t,h(i,Kn));if(!c)continue;let s=P(i,fn);s&&n.push({slot:"look.facets[].nodeNote",context:c,expr:s});let l=P(i,yn);l&&n.push({slot:"look.facets[].edgeValue",context:c,expr:l});let m=v(i,hn).filter(d=>d instanceof S);for(let d of m){let f=P(d,dn);f&&n.push({slot:"look.facets[].channels[].mapPath",context:c,expr:f})}}}return n}rangeOf(e,o,t){if(!t)return;let n=W(e,o,t);return n.ok?n.descriptor?.range:void 0}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.contextClass.name,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=n,a.message=`tx.${t.via} reads property '${t.propertyUri.name}', but its domain is not in scope for '${r}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,a.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${n}' is not in scope for '${r}'.
|
|
50
|
+
|
|
51
|
+
Possible solutions:
|
|
52
|
+
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
53
|
+
\u2022 If the property should apply to '${r}', adjust its domain
|
|
54
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function Vn(p){let e=p.subject;return e&&typeof e.name=="string"?e:void 0}function vn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Dn="kanonak.org",lo=(p,e)=>({publisher:Dn,package_:p,name:e}),Sn=lo("derivation","look"),In=lo("look","bands"),$n=lo("core-rdf","type"),Ye=class{ruleName="UnrenderableBand";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=jn(e);if(!a)return n;let i=Co();for(let c of r){if(!(c instanceof g)||c.namespace!==a)continue;let s=P(c,Sn);if(!s)continue;let l=v(s,In).filter(m=>m instanceof S);for(let m of l){let d=this.typeOf(m);if(!d)continue;let f=`${d.publisher}/${d.package_}/${d.name}`;if(i.has(f))continue;let y=new u;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=c.name,y.propertyName="derivation.look",y.actualValue=f,y.message=`Band '${d.name}' has no renderer, so this region of the page will be empty. The declaration is valid against the look vocabulary, but the renderer emits only an HTML comment for it \u2014 which a browser does not display, so the loss is silent. Use a band the renderer implements, or remove it until it is supported.`,n.push(y)}}return n}typeOf(e){let o=h(e,$n);if(o)return{publisher:o.publisher,package_:o.package_,name:o.name}}};function jn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Te="kanonak.org",xe="view",On={publisher:Te,package_:xe,name:"bind"},wn={publisher:Te,package_:xe,name:"produces"},Cn={publisher:Te,package_:xe,name:"projections"},Pn={publisher:Te,package_:xe,name:"where"},Un={publisher:Te,package_:xe,name:"value"},An={publisher:Te,package_:xe,name:"as"},Ne=class{ruleName="TxExpressionPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=xn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,o,t){let n=h(o,On);if(!n)return;let r=h(o,wn),a=0;for(let c of Tn(e,v(o,Cn))){let s=P(c,Un);if(s)for(let m of Z(e,n,s))t.push(this.toError(o.name,`view.projections[${a}].value`,n,m));let l=h(c,An);l&&r&&(W(e,r,l).ok||t.push(this.asError(o.name,a,r,l))),a+=1}let i=0;for(let c of Nn(o,Pn)){for(let s of Z(e,n,c))t.push(this.toError(o.name,`view.where[${i}]`,n,s));i+=1}}asError(e,o,t,n){let r=`${n.publisher}/${n.package_}/${n.name}`,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=`view.projections[${o}].as`,a.actualValue=r,a.message=`Projection stores its value under property '${n.name}', but that property's domain is not in scope for the view's produces class '${t.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${t.name}'.
|
|
55
|
+
|
|
56
|
+
Possible solutions:
|
|
57
|
+
\u2022 Use an output property whose domain covers '${t.name}'
|
|
58
|
+
\u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
|
|
59
|
+
\u2022 If the value belongs on a different output class, adjust the view's produces`,a}toError(e,o,t,n){let r=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,i=a===t.name?`the view's bound class '${t.name}'`:`'${a}', reached by traversal from the view's bound class '${t.name}'`,c=new u;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=e,c.propertyName=o,c.actualValue=r,c.message=`tx.${n.via} reads property '${n.propertyUri.name}', but its domain is not in scope for ${i}. The read would silently return undefined when the view materializes.`,c.expectedValue=`A property whose domain is '${a}', an ancestor, or rdfs.Resource`,c.suggestion=`Property '${r}' is not in scope for '${a}'.
|
|
60
|
+
|
|
61
|
+
Possible solutions:
|
|
62
|
+
\u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
|
|
63
|
+
\u2022 If the property should apply to '${a}', adjust its domain
|
|
64
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function Nn(p,e){let o=P(p,e);return o?[o]:v(p,e).filter(t=>t instanceof S)}function Tn(p,e){let o=[];for(let t of e)if(t instanceof S)o.push(t);else if(t instanceof O){let n=V(p,t.subject);n&&o.push(n)}return o}function xn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Qe="kanonak.org",_n="core-shacl",x=p=>({publisher:Qe,package_:_n,name:p}),Ln=x("NodeShape"),Mn=x("PropertyShape"),Bn=x("targetClass"),Wn=x("property"),Fn=x("path"),qn=x("minCount"),Hn=x("maxCount"),Yn=x("datatype"),Gn=x("class"),Jo=x("in"),zn=x("pattern"),Xn=x("flags"),Zn=x("minLength"),Jn=x("maxLength"),Qn=x("minInclusive"),er=x("maxInclusive"),or=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),Qo=p=>p,Le=class{ruleName="ShaclShape";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=tr(e);if(!a)return n;let i=new Set;for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Ln))continue;let s=h(c,Bn);s?this.resolvesToClass(r,s)||n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' sh:targetClass '${s.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(s))):n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let l of v(c,Wn)){let m;if(l instanceof S)m=l;else if(l instanceof O){let d=V(r,l.subject);d&&(m=d,i.add(b(l.subject)))}m&&this.checkPropertyShape(r,c.name,m,s??void 0,n)}}for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Mn))continue;let s=T(c);s&&i.has(b(s))||this.checkPropertyShape(r,c.name,c,void 0,n)}return n}checkPropertyShape(e,o,t,n,r){let a=h(t,Fn);if(!a){r.push(this.err(o,"property.path","Error",`A PropertyShape on '${o}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=V(e,a),c=i?Y(e,i):!1;c?n&&(W(e,n,a).ok||r.push(this.err(o,"property.path","Warning",`sh:path '${a.name}' is not in scope for sh:targetClass '${n.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${n.name}', an ancestor, or rdfs.Resource.`,J(a)))):r.push(this.err(o,"property.path","Error",`sh:path '${a.name}' on '${o}' does not resolve to a property.`,"Reference a defined or imported property.",J(a)));let s=h(t,Yn),l=h(t,Gn);s&&l&&r.push(this.err(o,"property","Error",`A PropertyShape on '${o}' sets both sh:datatype and sh:class; a value is a literal or a node, not both.`,"Keep sh:datatype (literal values) or sh:class (node values), not both.")),s&&!this.resolvesToDatatype(e,s)&&r.push(this.err(o,"datatype","Error",`sh:datatype '${s.name}' on '${o}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",J(s))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(o,"class","Error",`sh:class '${l.name}' on '${o}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(l)));let m=_e(X(t,qn)),d=_e(X(t,Hn));this.checkOrder(o,"minCount",m,"maxCount",d,r);let f=_e(X(t,Zn)),y=_e(X(t,Jn));this.checkOrder(o,"minLength",f,"maxLength",y,r);let k=_e(X(t,Qn)),K=_e(X(t,er));this.checkOrder(o,"minInclusive",k,"maxInclusive",K,r);let E=z(t,zn);if(E!==void 0){let U=z(t,Xn);try{new RegExp(E,U)}catch{r.push(this.err(o,"pattern","Error",`sh:pattern on '${o}' is not a valid regular expression`+(U!==void 0?` (with flags '${U}')`:"")+`: ${E}`,"Provide a valid regular expression and flags.",E))}}if(oe(t,Jo)&&v(t,Jo).length===0&&r.push(this.err(o,"in","Error",`sh:in on '${o}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),c&&n){let N=W(e,n,a).descriptor;N&&((E!==void 0||f!==void 0||y!==void 0)&&N.kind==="object"&&r.push(this.err(o,"pattern/minLength/maxLength","Warning",`String facets on '${o}' apply to '${a.name}', which is an object property; string facets constrain literal values.`,"Apply string facets to a datatype property, or use sh:class for node values.",J(a))),(k!==void 0||K!==void 0)&&!this.isNumericDatatypeRange(N.range)&&r.push(this.err(o,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${o}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",J(a))))}}checkOrder(e,o,t,n,r,a){t!==void 0&&r!==void 0&&t>r&&a.push(this.err(e,`${o}/${n}`,"Error",`${o} (${t}) exceeds ${n} (${r}) on '${e}'.`,`Set ${o} <= ${n}.`))}resolvesToClass(e,o){let t=V(e,o);return t?$.isClassType(Qo(t)):!1}resolvesToDatatype(e,o){if(o.publisher===Qe&&o.package_==="core-rdf"&&o.name==="Literal")return!0;let t=V(e,o);return t?$.isDatatypeType(Qo(t)):!1}isNumericDatatypeRange(e){return!e||e.publisher===Qe&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===Qe&&e.package_==="core-xsd"&&or.has(e.name)}err(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=t,i.entityName=e,i.propertyName=o,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function _e(p){return typeof p=="number"?p:void 0}function J(p){return`${p.publisher}/${p.package_}/${p.name}`}function tr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var et={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},nr=p=>p,Me=class{ruleName="OwlOneOf";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=rr(e);if(!a)return n;for(let i of r){if(!(i instanceof g)||i.namespace!==a||!oe(i,et))continue;let c=v(i,et);if(c.length===0){n.push(this.err(i.name,"Warning",`owl:oneOf on '${i.name}' is empty; a closed enumeration must list at least one individual.`,"List the individuals that make up the enumeration, or remove owl:oneOf."));continue}for(let s of c)if(s instanceof go)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(s.value)}' on '${i.name}' is not a named individual; a class enumeration is of individuals (a misspelled or unimported individual reads as a literal). For a closed set of literal VALUES, constrain a property with sh:in instead.`,"Reference a defined or imported individual, or move literal value sets to a property sh:in.",String(s.value)));else if(s instanceof O){let l=V(r,s.subject);l&&$.isSchemaDefinitionType(nr(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${s.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${s.subject.publisher}/${s.subject.package_}/${s.subject.name}`))}}return n}err(e,o,t,n,r){let a=new u;return a.ruleType=this.ruleName,a.severity=o,a.entityName=e,a.propertyName="oneOf",a.message=t,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function rr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var ar=p=>p,ir=new yo("kanonak.org","core-rdf","Resource"),Be=class{ruleName="DiamondNameClash";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=sr(e);if(!a)return n;let i=jo(r);for(let c of r){if(!(c instanceof g)||c.namespace!==a||!$.isClassType(ar(c)))continue;let s=T(c);if(!s)continue;let l=H(r,s),m=b(s),d=new Set(l.map(y=>b(y)));d.delete(m),d.delete(b(ir));let f=new Map;for(let y of Eo(r,s)){if(!y.domains.some(E=>d.has(b(E))))continue;let K=f.get(y.uri.name);K?K.push(y):f.set(y.uri.name,[y])}for(let[y,k]of f){if(k.length<2)continue;let K=N=>Oo(i,l,N.uri)?.cardinality,E=new Set(k.map(N=>N.range?b(N.range):void 0).filter(N=>N!==void 0)),U=new Set(k.map(K).filter(N=>N!==void 0));E.size<=1&&U.size<=1||n.push(this.toError(c.name,y,k,K))}}return n}toError(e,o,t,n){let r=c=>{let s=`${c.uri.publisher}/${c.uri.package_}/${c.uri.name}`,l=c.range?`${c.range.publisher}/${c.range.package_}/${c.range.name}`:"no range",m=n(c);return`${s} (range ${l}${m?`, ${m}`:""})`},a=t.map(r).join("; "),i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=o,i.actualValue=a,i.message=`Class '${e}' inherits ${t.length} distinct properties named '${o}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${o}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${o}':
|
|
65
|
+
\u2022 rename one of the properties, or
|
|
66
|
+
\u2022 re-domain one so it is not inherited by '${e}', or
|
|
67
|
+
\u2022 restructure the hierarchy so '${e}' inherits only one '${o}', or
|
|
68
|
+
\u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function sr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var mo=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e,o={}){this.parser=e??new fo,this.documentRules=[new se,new ce,new pe,new le,new me],this.repositoryRules=[new ue,new de,new fe,new ie({offline:o.offline}),new ye,new ge,new ke,new he,new Re,new be,new Ke,new Ee,new Ve,new De,new Se,new Ie,new $e,new je,new Oe,new we,new Ce,new Ae,new Ye,new Ue,new Pe,new Ne,new Le,new Me,new Be]}async validateAsync(e,o,t){let n=new te;for(let r of this.documentRules)try{let a=r.validate(e);this.addErrorsToResult(n,a)}catch(a){let i=new u;i.ruleType=r.ruleName,i.severity="Error",i.message=`Validation rule '${r.ruleName}' failed: ${a instanceof Error?a.message:String(a)}`,n.errors.push(i)}if(o){let r=[],a=t??new ne(new re(e,o)),i=a.repository;for(let c of this.repositoryRules)try{let s=await c.validateAsync(e,i,a);this.addErrorsToResult(n,s)}catch(s){let l=s instanceof Error?s.message:String(s);r.push({ruleName:c.ruleName,cause:l})}if(r.length>0){let c=new Map;for(let{ruleName:s,cause:l}of r){let m=c.get(l);m?m.push(s):c.set(l,[s])}for(let[s,l]of c){let m=new u;m.ruleType=l[0],m.severity="Error",l.length===1?m.message=`Validation rule '${l[0]}' failed: ${s}`:m.message=`${s} (affects ${l.length} rules: ${l.join(", ")})`,n.errors.push(m)}}}return n.isValid=n.errors.length===0,n}async validateDocumentsAsync(e,o){let t=new ne(o),n=[];for(let r of e){let a=await this.validateAsync(r,t.repository,t);n.push({document:r,result:a})}return n}async validateYamlAsync(e,o,t){let n=this.parser.parseWithErrors(e);if(!n.isValid){let r=new te;r.isValid=!1;for(let a of n.errors){let i=new u;i.ruleType="ParseError",i.severity="Error",i.lineNumber=a.line,i.column=a.column,i.message=a.message,a.keyName&&(i.entityName=a.keyName),a.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),r.errors.push(i)}return r}return await this.validateAsync(n.document,o,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let o=this.documentRules.findIndex(t=>t instanceof e);o>=0&&this.documentRules.splice(o,1)}removeRepositoryRule(e){let o=this.repositoryRules.findIndex(t=>t instanceof e);o>=0&&this.repositoryRules.splice(o,1)}addErrorsToResult(e,o){for(let t of o)t.severity==="Error"?e.errors.push(t):t.severity==="Info"?this.includeWarnings&&e.infos.push(t):this.includeWarnings&&e.warnings.push(t)}};export{te as a,R as b,u as c,ro as d,ne as e,ie as f,se as g,ce as h,pe as i,le as j,me as k,ue as l,de as m,fe as n,ye as o,ge as p,ke as q,he as r,Re as s,be as t,Ke as u,Ee as v,Ve as w,De as x,Se as y,Ie as z,$e as A,je as B,Oe as C,we as D,Ce as E,Pe as F,Ue as G,Ae as H,Ne as I,Le as J,Me as K,Be as L,mo as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,b as x,m as $}from"./chunk-
|
|
1
|
+
import{a as j,b as x,m as $}from"./chunk-PVUBHIU2.js";import{da as U,e as l,f as u,g as b,h as C,i as a}from"./chunk-7UYXTYXC.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-CJMVIOZX.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let r=b(e);return this.all.has(r)?!1:(this.all.add(r),this.tripleList.push(e),h(this.byPIdx,e.p,e),h(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&h(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(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}|${C(t)}`)}};function h(o,e,r){let t=o.get(e);t?t.push(r):o.set(e,[r])}var _={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}},E={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}},A={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}},V={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 p={s:i.s,p:n,o:i.o};o.add(p)&&(r=!0)}}return r}},W={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}},F={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}},k=[_,E,A,V,W,F];var N={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 p=i.o.key;for(let c of o.bySubjectPredicate(p,s))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(a(i.s,s,c.o.key))&&(r=!0)}}return r}},D={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}},M={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}},z={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}},B={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}},G={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}},H={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}},J={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}},Q={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}},X={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=[N,D,M,z,B,G,H,J,Q,X];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 R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new U,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let r=new d,s=await new $().parseKanonaks(e),n=new P;for(let c of s)if(c instanceof S){let m=Y(c);if(!m)continue;for(let w of c.statement)this.emitStatement(m,w,r,n)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let p=0;for(;p<this.maxIterations;){let c=!1;for(let m of i)m.apply(r,this.vocabulary)&&(c=!0);if(!c)break;p++}return new y(r,this.vocabulary)}emitStatement(e,r,t,s){let n=Z(r);if(n){if(r instanceof I){t.add({s:e,p:n,o:{kind:"literal",lexical:r.object,datatype:"string"}});return}if(r instanceof T){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 v){let i=l(r.object.subject);t.add(a(e,n,i));return}if(r instanceof L){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 q){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 j){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 x){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)}},P=class{counter=0;next(){return`b${this.counter++}`}};function Y(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 Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=["dependency","link"];function p(o){return o.mode==="link"}function m(o){let t=new Set;for(let[n,r]of Object.entries(o.metadata?.imports??{}))for(let e of r)p(e)&&t.add(`${n}/${e.packageName}`);return t}export{a,p as b,m as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-F67UH4FD.js";import{a as l,b as h}from"./chunk-QILEJIFU.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={message:t.message||"Unknown parse error",line:t.mark?.line??0,column:t.mark?.column??0,errorType:t.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${t.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${t.mark?.line??0}: ${t.message||"Unknown parse error"}`};return r.push(o),{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as A}from"./chunk-P5VQEDBS.js";import{a as P}from"./chunk-6VIUXP4N.js";import{a as f}from"./chunk-KOWDHKBN.js";import{c as K,g as I,j as R}from"./chunk-QILEJIFU.js";import*as i from"fs/promises";import*as c 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=c.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=c.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=c.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;return R(r,t)});return s.length===0?null:(s.sort((a,r)=>{let m=a.metadata.namespace_.version,p=r.metadata.namespace_.version;return K(p,m)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let m=o.split("/"),p=m[0],h=m[1].replace("@","@")+".kan.yml";n=c.join(this.rootPath,p,h)}else n=c.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=c.dirname(n);await i.mkdir(s,{recursive:!0});let a=this.parser.save(e);await i.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=c.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await i.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=c.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=c.join(this.rootPath,e);try{let s=await i.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await i.unlink(c.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[m,p]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&p.metadata.namespace_){s=p.metadata.namespace_.toString();break}let a=s??c.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}try{return await i.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await i.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await i.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=c.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await i.readdir(e,{withFileTypes:!0});for(let s of o){let a=c.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as g from"fs";var F=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(F||{}),k=class{cache;workspace;constructor(e,t,n){let o=n??new f;g.existsSync(e)||g.mkdirSync(e,{recursive:!0}),g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as x}from"os";import{join as _}from"path";function d(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||_(x(),".kanonak","packages")}var w=class u{static createComposite(e,t,n){let o=e??d(),s=t??".";return new k(o,s,n)}static createFromEnvironment(e){let t=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return u.createComposite(t,n,e)}};var D=class{repos;constructor(...e){this.repos=e}async getHighestCompatibleVersionAsync(e,t){for(let n of this.repos)try{let o=await n.getHighestCompatibleVersionAsync(e,t);if(o)return o}catch{}return null}async getAllDocumentsAsync(){let e=[],t=new Set;for(let n of this.repos)try{for(let o of await n.getAllDocumentsAsync()){let s=o.metadata?.namespace_,a=s?s.version?`${s.publisher}/${s.package_}@${s.version.major}.${s.version.minor}.${s.version.patch}`:`${s.publisher}/${s.package_}`:void 0;if(a!==void 0){if(t.has(a))continue;t.add(a)}e.push(o)}}catch{}return e}async getDocumentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentAsync(e);if(n)return n}catch{}return null}async getDocumentsByNamespaceAsync(e,t){for(let n of this.repos)try{let o=await n.getDocumentsByNamespaceAsync(e,t);if(o.length>0)return o}catch{}return[]}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentContentAsync(e);if(n)return n}catch{}return null}async getDocumentUriAsync(e){for(let t of this.repos)try{let n=await t.getDocumentUriAsync(e);if(n)return n}catch{}return null}};import{VersionOperator as H}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 this.lock.packages[`${e}/${t}`]?.version}async getHighestCompatibleVersionAsync(e,t){let n=this.pinnedVersion(e,t.packageName);if(n){let o=I(n);if(o){let s={...t,versionOperator:H.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 N,readdirSync as $}from"fs";import{join as S}from"path";var B=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(u,e=[]){for(let t of $(u,{withFileTypes:!0}))t.isDirectory()?B.has(t.name)||C(S(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(S(u,t.name));return e}async function V(u,e=new f,t={}){let n=new P(e);for(let m of C(u))try{let p=e.parse(N(m,"utf-8")),l=p.metadata?.namespace_,h=l?.version;l&&h&&await n.saveDocumentAsync(p,`${l.publisher}/${l.package_}@${h.major}.${h.minor}.${h.patch}`)}catch{}let o=new y(d(),!0,e),s=new Map,a=t.httpCache??{getFromCache:(m,p,l)=>s.get(`${m}|${p}|${l}`)??null,onFetch:(m,p,l,h)=>{s.set(`${m}|${p}|${l}`,h)}},r=new A({getFromCache:a.getFromCache,onFetch:a.onFetch});return new D(n,o,r)}export{y as a,F as b,k as c,d,w as e,D as f,v as g,C as h,V as i};
|
|
1
|
+
import{n as A}from"./chunk-BZ3YTI3C.js";import{a as P}from"./chunk-6VIUXP4N.js";import{a as f}from"./chunk-HF5FJBS2.js";import{c as K,g as I,j as R}from"./chunk-QILEJIFU.js";import*as i from"fs/promises";import*as c 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=c.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=c.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=c.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;return R(r,t)});return s.length===0?null:(s.sort((a,r)=>{let m=a.metadata.namespace_.version,p=r.metadata.namespace_.version;return K(p,m)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let m=o.split("/"),p=m[0],h=m[1].replace("@","@")+".kan.yml";n=c.join(this.rootPath,p,h)}else n=c.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=c.dirname(n);await i.mkdir(s,{recursive:!0});let a=this.parser.save(e);await i.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=c.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await i.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=c.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=c.join(this.rootPath,e);try{let s=await i.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await i.unlink(c.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=b(n).toString(),s;for(let[m,p]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&p.metadata.namespace_){s=p.metadata.namespace_.toString();break}let a=s??c.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}try{return await i.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}return b(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await i.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await i.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=c.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await i.readdir(e,{withFileTypes:!0});for(let s of o){let a=c.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as g from"fs";var F=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(F||{}),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 x}from"os";import{join as _}from"path";function d(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||_(x(),".kanonak","packages")}var w=class u{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 u.createComposite(t,n,e)}};var k=class{repos;constructor(...e){this.repos=e}async getHighestCompatibleVersionAsync(e,t){for(let n of this.repos)try{let o=await n.getHighestCompatibleVersionAsync(e,t);if(o)return o}catch{}return null}async getAllDocumentsAsync(){let e=[],t=new Set;for(let n of this.repos)try{for(let o of await n.getAllDocumentsAsync()){let s=o.metadata?.namespace_,a=s?s.version?`${s.publisher}/${s.package_}@${s.version.major}.${s.version.minor}.${s.version.patch}`:`${s.publisher}/${s.package_}`:void 0;if(a!==void 0){if(t.has(a))continue;t.add(a)}e.push(o)}}catch{}return e}async getDocumentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentAsync(e);if(n)return n}catch{}return null}async getDocumentsByNamespaceAsync(e,t){for(let n of this.repos)try{let o=await n.getDocumentsByNamespaceAsync(e,t);if(o.length>0)return o}catch{}return[]}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentContentAsync(e);if(n)return n}catch{}return null}async getDocumentUriAsync(e){for(let t of this.repos)try{let n=await t.getDocumentUriAsync(e);if(n)return n}catch{}return null}};import{VersionOperator as H}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 this.lock.packages[`${e}/${t}`]?.version}async getHighestCompatibleVersionAsync(e,t){let n=this.pinnedVersion(e,t.packageName);if(n){let o=I(n);if(o){let s={...t,versionOperator:H.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 N,readdirSync as $}from"fs";import{join as S}from"path";var B=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(u,e=[]){for(let t of $(u,{withFileTypes:!0}))t.isDirectory()?B.has(t.name)||C(S(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(S(u,t.name));return e}async function V(u,e=new f,t={}){let n=new P(e);for(let m of C(u))try{let p=e.parse(N(m,"utf-8")),l=p.metadata?.namespace_,h=l?.version;l&&h&&await n.saveDocumentAsync(p,`${l.publisher}/${l.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:(m,p,l)=>s.get(`${m}|${p}|${l}`)??null,onFetch:(m,p,l,h)=>{s.set(`${m}|${p}|${l}`,h)}},r=new A({getFromCache:a.getFromCache,onFetch:a.onFetch});return new k(n,o,r)}export{y as a,F as b,D as c,d,w as e,k as f,v as g,C as h,V as i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as R}from"./chunk-
|
|
1
|
+
import{e as R}from"./chunk-BZ3YTI3C.js";import{a as H,b as B,c as Z,i as x,m as ne}from"./chunk-PVUBHIU2.js";import{ba as ee,fa as T,ia as N}from"./chunk-7UYXTYXC.js";import{b as z,c as _,d as $,f as q,g as W,h as Y,i as J,j as X,k as Q,l as I}from"./chunk-CJMVIOZX.js";var oe=(o=>(o.Class="Class",o.DatatypeProperty="DatatypeProperty",o.ObjectProperty="ObjectProperty",o.AnnotationProperty="AnnotationProperty",o.Instance="Instance",o.Datatype="Datatype",o.Shape="Shape",o.Unknown="Unknown",o))(oe||{}),se=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(se||{}),D=class{static async buildFromRepository(n,t){let a=await new ne().parseKanonaks(n),s=await n.getAllDocumentsAsync(),c=[],i=[],o=new Set,d=new Set,y=new Map;for(let g of a){let p=g;if(p.name&&(T.isClassType(p)&&o.add(p.name),g instanceof _)){let l=N(a,g);(l==="ObjectProperty"||l==="Property")&&d.add(p.name)}}for(let g of s)for(let[p,l]of Object.entries(g.body))d.has(p)&&l?.range&&typeof l.range=="string"&&y.set(p,l.range);let f=new Map;for(let g of a){let p=g;p.name&&f.set(p.name,p)}for(let g of s){let p=g.metadata.namespace_,l=p?`${p.publisher}/${p.package_}`:"",m=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",C=te(g);for(let[h,u]of Object.entries(g.body)){if(!u||typeof u!="object")continue;let b=f.get(h),k="Unknown";if(b){let A=b,P=b instanceof _?N(a,b):void 0;T.isClassType(A)?k="Class":P==="ObjectProperty"?k="ObjectProperty":P==="DatatypeProperty"?k="DatatypeProperty":P==="AnnotationProperty"?k="AnnotationProperty":T.isDatatypeType(A)?k="Datatype":P==="Property"?k="ObjectProperty":T.isShapeType(A)?k="Shape":T.isInstanceOfKnownClass(A,o)&&(k="Instance")}let S=l&&m?`${l}/${h}@${m}`:h,L={};for(let[A,P]of Object.entries(u))A!=="type"&&(typeof P!="object"||P===null)&&(L[A]=P);c.push({id:S,label:u.label??h,type:k,namespace:l,properties:L}),re(S,u,k,o,d,i,l,m,C,t),M(S,u,d,y,c,i,l,m,C),be(S,b,i)}}return{nodes:c,edges:i}}static buildFromDocument(n,t){let r=[],a=[],s=n.metadata.namespace_,c=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",i=s?`${s.publisher}/${s.package_}`:"",o=new Set,d=new Set,y=new Map,f=te(n);for(let[l,m]of Object.entries(n.body)){let C=m?.type;C&&(he(C,f)&&o.add(l),me(C,f)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(n.body)){if(!m||typeof m!="object")continue;let C=m.type,h=ke(C,l,o,f),u=i&&c?`${i}/${l}@${c}`:l,b={};for(let[k,S]of Object.entries(m))k!=="type"&&(typeof S!="object"||S===null)&&(b[k]=S);r.push({id:u,label:m.label??l,type:h,namespace:i,properties:b}),re(u,m,h,o,d,a,i,c,f,t),M(u,m,d,y,r,a,i,c,f)}let g=new Set(r.map(l=>l.id)),p=a.filter(l=>g.has(l.source)&&g.has(l.target));return{nodes:r,edges:p}}};function te(e,n){let t=new Map;if(e.metadata?.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let s of a){let c=s.alias??s.packageName,i=s.version,o=`${i.major}.${i.minor}.${i.patch}`;t.set(c,{publisher:r,package_:s.packageName,version:o})}return t}var ae={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},ye=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function K(e,n){if(e.includes(".")){let t=e.indexOf("."),r=e.substring(0,t),a=e.substring(t+1),s=n.get(r);if(s)return`${s.publisher}/${s.package_}/${a}`}return null}function he(e,n){let t=K(e,n);return t?ae[t]==="Class":!1}function me(e,n){let t=K(e,n);return t?ye.has(t):!1}function ke(e,n,t,r){if(!e||e==="Package")return"Unknown";let a=K(e,r);if(a){let c=ae[a];if(c)return c;let i=a.split("/").pop()?.split("@")[0]??"";return t.has(i)?"Instance":"Unknown"}let s=e.split(".").pop()??e;return t.has(s)?"Instance":"Unknown"}var ie=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function re(e,n,t,r,a,s,c,i,o,d){let y=n.type,f=n.subClassOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:e,target:w(u,c,i,o),type:"subClassOf",label:"subClassOf"})}let g=n.subPropertyOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:e,target:w(u,c,i,o),type:"subPropertyOf",label:"subPropertyOf"})}let p=n.domain,l=n.range;if(d?.includePropertyEdges){let h=[[p,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let S of Array.isArray(u)?u:[u])typeof S=="string"&&s.push({source:e,target:w(S,c,i,o),type:b,label:k})}if(t==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:e,target:w(h,c,i,o),type:"instanceOf",label:"type"})}if(t==="Instance")for(let[h,u]of Object.entries(n)){if(ie.has(h)||!a.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Ce(k)&&s.push({source:e,target:w(k,c,i,o),type:"propertyValue",label:h,propertyId:w(h,c,i,o)})}if((t==="ObjectProperty"||t==="DatatypeProperty"||p&&l)&&p&&l){let h=typeof p=="string"?p:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:w(h,c,i,o),target:w(u,c,i,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function M(e,n,t,r,a,s,c,i,o){for(let[d,y]of Object.entries(n)){if(ie.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let f=y,g=`${e}/${d}`,p=r.get(d),l=p?p.split(".").pop()??p:"Unknown",m={};for(let[h,u]of Object.entries(f))(typeof u!="object"||u===null)&&(m[h]=u);a.push({id:g,label:`${l} (embedded)`,type:"Instance",namespace:c,properties:m});let C=c&&i?`${c}/${d}@${i}`:d;s.push({source:e,target:g,type:"propertyValue",label:d,propertyId:t.has(d)?C:void 0}),p&&s.push({source:g,target:w(l,c,i,o),type:"instanceOf",label:"type (inferred)"}),M(g,f,t,r,a,s,c,i,o)}}function be(e,n,t){let r=n?.statement;if(Array.isArray(r))for(let a of r){if(!(a instanceof Z))continue;let s=a.predicate?.subject?.name??"";for(let c of a.links){let i=c.target?.subject;if(!i)continue;let o=i.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";t.push({source:e,target:`${i.publisher}/${i.package_}/${i.name}${d}`,type:"embeddedLink",label:s})}}}function Ce(e){return!(!e||e.includes(" ")||e.includes(`
|
|
2
2
|
`)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let a=e.indexOf("."),s=e.substring(0,a),c=e.substring(a+1);if(r){let i=r.get(s);if(i)return`${i.publisher}/${i.package_}/${c}@${i.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}import{canonicalForm as Se,canonicalHash as we}from"@kanonak-protocol/canonical";function F(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as $e}from"@kanonak-protocol/canonical";function Oe(e){return Se(F(e)?e:pe(e))}function ve(e){return we(F(e)?e:pe(e))}function pe(e){let n=[];for(let t of e)t instanceof _&&n.push({uri:Re(t),statements:U(t.statement)});return{subjects:n}}function U(e){let n=[];for(let t of e){let r=Ee(t);if(!r)continue;if(t instanceof I&&Pe(t.predicate.subject)){n.push(...Te(t,r));continue}let a=je(t);a&&n.push({predicate:r,value:a})}return n}function Pe(e){let n=ee("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var ce=new TextEncoder;function Ae(e,n){let t=ce.encode(e),r=ce.encode(n),a=Math.min(t.length,r.length);for(let s=0;s<a;s++)if(t[s]!==r[s])return t[s]-r[s];return t.length-r.length}function Te(e,n){let t=[];for(let r of e.object){if(!(r instanceof $))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(G(r))}t.sort(Ae);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:n,value:{ref:r}}))}function je(e){if(e instanceof q&&e.carrier)return{lit:e.lexical??String(e.object),datatype:ue(e.carrier)};if(e instanceof W)return{raw:e.object};if(e instanceof Y)return{raw:e.lexical??String(e.object)};if(e instanceof J)return{raw:e.lexical??String(e.object)};if(e instanceof X)return{ref:G(e.object)};if(e instanceof Q)return le(e.object);if(e instanceof I)return{list:e.object.map(_e)}}function le(e){let n=U(e.statement);return e.name&&e.name.length>0?{embed:{name:e.name,statements:n}}:{embed:{statements:n}}}function _e(e){if(e instanceof $)return{ref:G(e)};if(e instanceof H)return le(e);if(e instanceof B){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:ue(e.carrier)};let n=e.value;if(typeof n=="string")return{raw:n};if(typeof n=="number")return{raw:String(n)};if(typeof n=="boolean")return{raw:String(n)}}if(e instanceof z)return{embed:{statements:U(e.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${e.constructor?.name??typeof e}); add canonicalization support before hashing data that contains it`)}function ue(e){return e===x.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function Ee(e){let n=e.predicate;if(n)return de(n.subject)}function Re(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function G(e){return de(e.subject)}function de(e){let n=e.version;return n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}/${e.name}`:`${e.publisher}/${e.package_}/${e.name}`}function j(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var Ie="key_thumbprint",E=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=j(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,a=await Ne(r),s=a&&Array.isArray(a.authorization_servers)?a.authorization_servers.filter(i=>typeof i=="string"):[],c=s.length>0?s:null;return this.prCache.set(t,c),c}async discover(n){let t=j(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,a=await this.tryEndpoint(r);if(!a){let s=`https://${t}/.well-known/openid-configuration`;a=await this.tryEndpoint(s)}return this.cache.set(t,a),a}async supportsOAuth(n){return await this.discover(n)!==null}static supportsPkceS256(n){return n.codeChallengeMethodsSupported?.some(t=>t.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(n){return!!n.registrationEndpoint}static supportsAuthorizationCode(n){return n.responseTypesSupported?.some(t=>t.toLowerCase()==="code")??!1}static supportsEnrollment(n){return!!n.enrollmentEndpoint}static supportsSession(n){return!!n.sessionEndpoint}async tryEndpoint(n){let t;try{t=await fetch(n)}catch(a){let s=a instanceof Error?a.message:String(a);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${s})`),console.error(" If the server is behind a VPN, ensure you are connected.")):s.includes("CERT")||s.includes("SSL")||s.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${s})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${n} \u2014 network error: ${s}`),null}if(!t.ok)return t.status===404||(t.status===403?(console.error(` OAuth discovery: ${n} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):t.status>=500&&(console.error(` OAuth discovery: ${n} \u2014 HTTP ${t.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let r;try{r=await t.json()}catch{return console.error(` OAuth discovery: ${n} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:O(r.issuer),authorizationEndpoint:O(r.authorization_endpoint),tokenEndpoint:O(r.token_endpoint),registrationEndpoint:O(r.registration_endpoint),revocationEndpoint:O(r.revocation_endpoint),scopesSupported:v(r.scopes_supported),responseTypesSupported:v(r.response_types_supported),grantTypesSupported:v(r.grant_types_supported),codeChallengeMethodsSupported:v(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:v(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:v(r.dpop_signing_alg_values_supported),enrollmentEndpoint:O(r.enrollment_endpoint),enrollmentIssuanceProtocols:v(r.enrollment_issuance_protocols),enrollmentKeyTypes:v(r.enrollment_key_types),enrollmentScopesSupported:v(r.enrollment_scopes_supported),enrollmentConsentBindingParam:O(r.enrollment_consent_binding_param),sessionEndpoint:O(r.session_endpoint),sessionEndpointAuthMethod:O(r.session_endpoint_auth_method)}}};async function Ne(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function O(e){return typeof e=="string"?e:null}function v(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function fe(e){let n=e.headers.get("WWW-Authenticate")??void 0,t=e.headers.get("DPoP-Nonce")??void 0;if(!n&&!t)return;let r={wwwAuthenticate:n??""};if(t&&(r.nonce=t),n){let a=n.match(/acr_values\s*=\s*"([^"]*)"/i);a&&(r.acrValues=a[1])}return r}function xe(e){try{return new URL(e).host}catch{return null}}function De(e,n={}){let t=n.discovery??new E,r=new Map,a=new Map,s=async o=>{let d=r.get(o);if(d!==void 0)return d;let y=null,f=await t.discoverProtectedResource(o).catch(()=>null);return f&&f.length>0&&(y=xe(f[0])),r.set(o,y),y},c=async(o,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&a.has(o))return a.get(o);let f=await e.resolve(o,d).catch(()=>null);return a.set(o,f),f},i=async(o,d,y,f)=>{let g=await s(d);if(!g)return{res:await R(o,{method:y,redirect:"manual"}),authed:!1};let p=await c(g,{method:y,url:o,...f}),l=p?.headers??{};return{res:await R(o,{method:y,redirect:"manual",headers:l}),authed:!!p}};return async(o,d,y="GET")=>{let f=await i(o,d,y,{});if((f.res.status===401||f.res.status===403)&&f.authed){let g=fe(f.res),p={forceRefresh:g===void 0};return g&&(p.challenge=g),(await i(o,d,y,p)).res}return f.res}}var ge="KANONAK_TOKEN";function Me(){return typeof process<"u"&&process.env?process.env:{}}function Ke(e){return`${ge}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var V=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??Me()}async resolve(n,t){let r=j(n),a=this.tokens[r]??this.env[Ke(r)]??this.env[ge];return a?{headers:{Authorization:`Bearer ${a}`}}:null}};export{oe as a,se as b,D as c,Oe as d,ve as e,$e as f,j as g,Ie as h,E as i,fe as j,De as k,V as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as D}from"./chunk-F67UH4FD.js";import{b as y,e as m}from"./chunk-QILEJIFU.js";function h(t){let e=t.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}function v(t){let e=t.metadata?.namespace_;if(e)return e.version?`${e.publisher}/${e.package_}@${m(e.version)}`:`${e.publisher}/${e.package_}`}async function I(t,e,n={}){let o=new Set,u=new Set,i=[...t];for(;i.length>0;){let a=i.shift(),l=h(a),s=v(a);if(!l||!s||u.has(s))continue;u.add(s),o.add(l);let p=a.metadata?.imports;if(p)for(let[g,k]of Object.entries(p))for(let r of k){if(D(r))continue;let c=null,d="no-compatible-version";try{c=await e.getHighestCompatibleVersionAsync(g,r)}catch{d="resolution-error"}c?i.push(c):n.onUnresolvedEdge?.({fromNamespace:s,publisher:g,packageName:r.packageName,constraint:`${y(r.versionOperator)}${m(r.version)}`,reason:d})}}return o}var f=class{constructor(e,n){this.inner=e;this.scope=n}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(n=>{let o=h(n);return o!==void 0&&this.scope.has(o)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,n){return this.inner.getDocumentsByNamespaceAsync(e,n)}getHighestCompatibleVersionAsync(e,n){return this.inner.getHighestCompatibleVersionAsync(e,n)}saveDocumentAsync(e,n){return this.inner.saveDocumentAsync(e,n)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,n){return this.inner.clearNamespaceAsync(e,n)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};export{I as a,f as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-PVUBHIU2.js";import{c as j,d as m,g as R,j as p,k as K,l as k}from"./chunk-CJMVIOZX.js";import{c as b,g as u}from"./chunk-QILEJIFU.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};
|