@kanonak-protocol/sdk 6.6.0 → 6.7.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.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/{chunk-I2T6ORSG.js → chunk-426MUUGB.js} +16 -16
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/resolution/linkTargets.d.ts +45 -0
- package/dist/shacl/ConformanceScope.d.ts +34 -6
- package/dist/shacl/index.d.ts +2 -2
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
package/dist/browser.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { InMemoryKanonakDocumentRepository } from './repositories/InMemoryKanona
|
|
|
24
24
|
export { HttpKanonakDocumentRepository } from './repositories/HttpKanonakDocumentRepository.js';
|
|
25
25
|
export { PublisherIndex } from './repositories/PublisherIndex.js';
|
|
26
26
|
export { KanonakVocabulary, OWL_HAS_KEY } from './reasoning/KanonakVocabulary.js';
|
|
27
|
-
export { SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, } from './shacl/uris.js';
|
|
27
|
+
export { SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, SH_COMP_MIN_COUNT, SH_COMP_MAX_COUNT, SH_COMP_DATATYPE, SH_COMP_CLASS, SH_COMP_IN, SH_COMP_PATTERN, SH_COMP_MIN_LENGTH, SH_COMP_MAX_LENGTH, SH_COMP_MIN_INCLUSIVE, SH_COMP_MAX_INCLUSIVE, SH_COMP_NODE_KIND, SH_COMP_CLOSED, SH_COMP_HAS_VALUE, SH_COMP_QUALIFIED_MIN_COUNT, SH_COMP_QUALIFIED_MAX_COUNT, SH_COMP_HAS_KEY, } from './shacl/uris.js';
|
|
28
28
|
export { PublisherConfigResolver } from './repositories/PublisherConfig.js';
|
|
29
29
|
export type { PublisherConfig } from './repositories/PublisherConfig.js';
|
|
30
30
|
export { ANY_PUBLISHER, checkPackageUrlTemplates, checkPackageUrlTemplate, packageUrlTemplateFor, fillPackageUrlTemplate, } from './repositories/PackageUrlTemplates.js';
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as He,b as Ne,c as ge,d as Rr,e as fr,f as yr,g as kr,i as Cr,j as Sr,k as _r,l as Er,m as xr,n as Or,o as Ir,p as Ar,q as Hr,r as Nr,s as gr}from"./chunk-TF23WBSZ.js";import{a as Mr}from"./chunk-IWPCPQQY.js";import{a as pr,b as lr,c as cr,d as mr,e as dr,f as ur,g as Pr,h as Kr,i as Dr,j as Tr,k as hr,l as Lr}from"./chunk-FS7UGDEX.js";import{a as R,b as f,c as y,e as k,g as S,h as _,i as E,j as x,k as O,m as I,o as A,p as H,q as N,r as g,s as M,t as K,u as D}from"./chunk-Z2444SWM.js";import{a as Me,b as Ke,c as De}from"./chunk-OHF4RIKS.js";import{a as Te}from"./chunk-LIN5SG5I.js";import"./chunk-SC5M74NM.js";import{A as rr,B as or,C as tr,D as nr,E as ar,O as sr,a as he,b as Le,c as Ve,d as be,i as je,j as Ue,k as ve,l as we,n as Fe,o as Be,p as Ge,q as Ye,r as qe,s as We,t as Xe,u as ze,v as Qe,w as Je,x as Ze,y as $e,z as er}from"./chunk-426MUUGB.js";import"./chunk-VJUZKHQU.js";import{m as ir}from"./chunk-CPENAANM.js";import"./chunk-QHABFCRC.js";import{a as c,b as m,c as d,d as u,e as P}from"./chunk-5FVUBF7N.js";import{a as p}from"./chunk-WXXZOJ4O.js";import{a as xe,g as Oe,h as Ie,k as Ae}from"./chunk-SBWD7EOG.js";import{a as l}from"./chunk-5ZRVFYCP.js";import"./chunk-PEJALHXK.js";import{O as oe,P as te,Q as ne,R as ae,S as ie,T as se,U as pe,V as le,W as ce,X as me,Y as de,Z as ue,a as W,b as X,ca as Pe,da as Re,ea as fe,fa as ye,ga as ke,h as J,i as Z,j as $,k as ee,l as re,ma as Ce,oa as Se}from"./chunk-6WOPXTIL.js";import{H as _e,I as Ee,a as T,b as h,c as L,d as V,e as b,g as j,h as U,i as v,j as w,k as F,l as B,m as G,n as Y,o as q,s as z,t as Q}from"./chunk-LK5SHY4B.js";import"./chunk-F67UH4FD.js";import{c as e,d as r,e as o,f as t,g as n,h as a,i,k as s}from"./chunk-GGK6A6QK.js";import{a as C}from"./chunk-FUUTGGJS.js";export{S as ANY_PUBLISHER,Ze as AmbiguousReferenceRule,F as BooleanStatement,cr as CANONICAL_FORM_VERSION,Ir as CREDENTIAL_EXPIRY_SKEW_SECONDS,Sr as CREDENTIAL_HELPER_PROTOCOL_VERSION,Oe as Carrier,nr as ClassDefinitionRule,Ye as ClassHierarchyCycleRule,P as CredentialError,h as DefinedKanonak,Ne as EdgeType,V as EmbeddedKanonak,Fe as EmbeddedKanonakTypeRule,G as EmbeddedStatement,hr as EntitlementDeniedError,Lr as EntitlementProducer,ge as GraphBuilder,D as HttpKanonakDocumentRepository,A as INTEGRITY_PREFIX,ur as ImportBook,Be as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,R as KANONAK_USER_AGENT,T as Kanonak,Ke as KanonakDocumentPositions,c as KanonakHttpError,Ae as KanonakObjectParser,sr as KanonakObjectValidator,l as KanonakParser,C as KanonakUri,Te as KanonakUriBuilder,Ce as KanonakVocabulary,Y as ListStatement,ar as MarkdownLinkRule,q as MarkdownStatement,Qe as NamespaceImportCycleRule,je as NamespacePrefixRule,He as NodeType,w as NumberStatement,Cr as OAuthDiscovery,ke as OWL_HAS_KEY,er as ObjectPropertyValueValidationRule,Ve as OntologyValidationError,he as OntologyValidationResult,mr as PackageBuilder,Kr as ProducerRepository,rr as PropertyDomainRule,qe as PropertyHierarchyCycleRule,or as PropertyKindRangeConsistencyRule,Me as PropertyMetadata,$e as PropertyRangeReferenceRule,We as PropertyRangeRequiredRule,ve as PropertyTypeSpecificityRule,I as PublisherConfigResolver,K as PublisherIndex,b as ReferenceKanonak,B as ReferenceStatement,tr as ReservedNameShadowRule,Ue as ResourceNamingRule,W as ResourceResolver,Se as ResourceTypeClassifier,Z as SHACL_PACKAGE,J as SHACL_PUBLISHER,ae as SH_COMP_CLASS,ue as SH_COMP_CLOSED,ne as SH_COMP_DATATYPE,ye as SH_COMP_HAS_KEY,Pe as SH_COMP_HAS_VALUE,ie as SH_COMP_IN,te as SH_COMP_MAX_COUNT,me as SH_COMP_MAX_INCLUSIVE,le as SH_COMP_MAX_LENGTH,oe as SH_COMP_MIN_COUNT,ce as SH_COMP_MIN_INCLUSIVE,pe as SH_COMP_MIN_LENGTH,de as SH_COMP_NODE_KIND,se as SH_COMP_PATTERN,fe as SH_COMP_QUALIFIED_MAX_COUNT,Re as SH_COMP_QUALIFIED_MIN_COUNT,ee as SH_NODE_SHAPE,re as SH_PROPERTY_SHAPE,$ as SH_SHAPE,U as ScalarStatement,j as Statement,v as StringStatement,Xe as SubClassOfReferenceRule,ze as SubPropertyOfReferenceRule,L as SubjectKanonak,we as SubjectKanonakTypeRequiredRule,Hr as TOKEN_ENV,gr as TokenCredentialProvider,X as TypeResolver,Je as UnresolvedPredicateRule,Ge as UnresolvedReferenceRule,be as ValidationContext,Le as ValidationSeverity,Dr as allowAllPolicy,M as assertIntegrityAsync,ir as buildOntologyModel,pr as canonicalForm,lr as canonicalHash,Ie as carrierOf,_r as checkCredentialAnswer,Er as checkHelperAnswer,xr as checkHelperEraseAnswer,E as checkPackageUrlTemplate,_ as checkPackageUrlTemplates,e as compareVersions,g as computeIntegrityAsync,dr as contentAddressedName,Ar as createCredentialedFetch,t as createVersion,d as describeResponse,O as fillPackageUrlTemplate,Mr as findDerivation,o as formatVersion,y as getKanonakUserAgent,m as httpError,a as isCompatibleVersion,i as isMajorCompatible,k as kanonakFetch,kr as narrowestScope,Tr as noopMeter,Rr as normalizeHost,x as packageUrlTemplateFor,H as parseLockFile,fr as parseScope,n as parseVersionString,De as parseWithPositions,Or as parseWwwAuthenticate,s as pickHighestDocument,Q as referenceUris,u as retryAfterSecondsOf,Pr as sanitizeName,yr as scopeContains,N as serializeLockFile,f as setKanonakUserAgent,Ee as subjectAddress,Nr as tokenEnvKeyFor,z as typeReferenceUris,_e as valuesOf,r as versionsEqual,xe as walkDefinedKanonaks};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{a as Ut}from"./chunk-VJUZKHQU.js";import{c as At,g as Nt,h as ct,i as pt,j as Tt,k as xt,l as _t,t as lt,u as Lt,v as Mt}from"./chunk-CPENAANM.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as Pt,k as O}from"./chunk-SBWD7EOG.js";import{a as Vt}from"./chunk-5ZRVFYCP.js";import{$ as ne,_ as st,aa as jt,b as St,ba as Ot,ha as nt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as wt,wa as Y,xa as pe}from"./chunk-6WOPXTIL.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as k,d as V,e as N,f as tt,l as ce,m as J,n as L,o as ot,p as R,q as Z,s as $t,t as M,u as oe,w as A,y as b,z as It}from"./chunk-LK5SHY4B.js";import{b as se,c as Kt}from"./chunk-F67UH4FD.js";import{e as U}from"./chunk-GGK6A6QK.js";import{a as Dt}from"./chunk-FUUTGGJS.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var K=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(K||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var mt=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new ut(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},ut=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function $(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function w(p,e,t){let o=await $(p,e,t),n=rt(p);return n?o.filter(r=>r instanceof k&&r.namespace===n):[]}async function ue(p,e,t){let o=rt(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof k&&r.sourceDoc===o)}function rt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[],r=new Map;for(let[c,l]of Object.entries(e.metadata?.imports??{}))for(let m of l)se(m)&&r.set(`${c}/${m.packageName}`,{publisher:c,import_:m});if(r.size===0)return n;let a=new Map,i=(c,l,m)=>{let u=`${c.publisher}/${c.package_}`;if(!r.has(u))return;let f=a.get(u)??[];f.push({uri:c,where:l,predicate:m}),a.set(u,f)},s=await w(e,t,o);F(s,({kanonak:c,path:l})=>{for(let m of c.statement){let u=m.predicate?.subject?.name??"(unknown)";if(m instanceof ce)i(m.object.subject,l,u);else if(m instanceof L)for(let f of m.object)f instanceof N&&i(f.subject,l,u);else if(m instanceof ot)for(let f of m.links)f.target&&i(f.target.subject,l,u)}});for(let[c,l]of a){let{publisher:m,import_:u}=r.get(c),f=null,h;try{f=await t.getHighestCompatibleVersionAsync(m,u)}catch(y){h=y instanceof Error?y.message:String(y)}if(!f){let y=l[0],g=`${l.length} reference${l.length===1?"":"s"}, first at '${y.where}.${y.predicate}'`;this.options.offline?n.push(this.finding("Warning",y.where,y.predicate,c,`Link target package '${c}' could not be resolved offline (${g}); 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",y.where,y.predicate,c,`Link target package '${c}' could not be resolved${h?` (${h})`:""} \u2014 ${g}.`,"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:y,where:g,predicate:D}of l)Object.prototype.hasOwnProperty.call(f.body,y.name)||n.push(this.finding("Error",g,D,`${c}/${y.name}`,`Link to '${y.name}' in '${D}' at '${g}' does not dereference: package '${c}' (resolved to ${f.metadata.namespace_?.toString()??c}) defines no resource named '${y.name}'.`,`Check for a typo, or a resource renamed or removed in '${c}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
1
|
+
import{a as Ut}from"./chunk-VJUZKHQU.js";import{c as At,g as Nt,h as pt,i as lt,j as Tt,k as xt,l as _t,t as mt,u as Lt,v as Mt}from"./chunk-CPENAANM.js";import{a as Et,e as vt}from"./chunk-5FVUBF7N.js";import{a as F,f as z,i as wt,k as O}from"./chunk-SBWD7EOG.js";import{a as Vt}from"./chunk-5ZRVFYCP.js";import{$ as ne,_ as ct,aa as jt,b as St,ba as Ot,ha as rt,ia as Ct,oa as j,pa as x,qa as W,ra as q,sa as Q,va as Pt,wa as Y,xa as pe}from"./chunk-6WOPXTIL.js";import{B as H,C as ee,D as te,E,F as C,G as T,K as B,c as f,d as V,e as N,f as ot,l as ce,m as J,n as L,o as nt,p as k,q as Z,s as $t,t as M,u as oe,w as A,y as g,z as It}from"./chunk-LK5SHY4B.js";import{b as se,c as tt}from"./chunk-F67UH4FD.js";import{e as U}from"./chunk-GGK6A6QK.js";import{a as Dt}from"./chunk-FUUTGGJS.js";var le=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(R||{});var d=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ut=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new p;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var re=class{constructor(e){this.underlying=e;this.repository=new dt(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Ut(e,this.repository);let t={};return{merged:await new O().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},dt=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function S(p,e,t){return t?t.getKanonaks():new O().parseKanonaks(new me(p,e))}async function P(p,e,t){let o=await S(p,e,t),n=at(p);return n?o.filter(r=>r instanceof f&&r.namespace===n):[]}async function ue(p,e,t){let o=at(p);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new O().parseKanonaks(new me(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof f&&r.sourceDoc===o)}function at(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var me=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};async function Bt(p,e,t){let o=new Map;for(let[a,i]of Object.entries(p.metadata?.imports??{}))for(let s of i){if(!se(s))continue;let c=`${a}/${s.packageName}`;o.set(c,{key:c,publisher:a,import_:s,references:[],target:null})}if(o.size===0)return[];let n=(a,i,s)=>{o.get(`${a.publisher}/${a.package_}`)?.references.push({uri:a,where:i,predicate:s})};F(e,({kanonak:a,path:i})=>{for(let s of a.statement){let c=s.predicate?.subject?.name??"(unknown)";if(s instanceof ce)n(s.object.subject,i,c);else if(s instanceof L)for(let l of s.object)l instanceof N&&n(l.subject,i,c);else if(s instanceof nt)for(let l of s.links)l.target&&n(l.target.subject,i,c)}});let r=[...o.values()].filter(a=>a.references.length>0);for(let a of r)try{a.target=await t.getHighestCompatibleVersionAsync(a.publisher,a.import_)}catch(i){a.failure=i instanceof Error?i.message:String(i)}return r}function qt(p,e){return Object.prototype.hasOwnProperty.call(p.body,e)}var de=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,t,o){let n=[];if(tt(e).size===0)return n;let r=await P(e,t,o);for(let{key:a,references:i,target:s,failure:c}of await Bt(e,r,t)){if(!s){let l=i[0],m=`${i.length} reference${i.length===1?"":"s"}, first at '${l.where}.${l.predicate}'`;this.options.offline?n.push(this.finding("Warning",l.where,l.predicate,a,`Link target package '${a}' could not be resolved offline (${m}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",l.where,l.predicate,a,`Link target package '${a}' could not be resolved${c?` (${c})`:""} \u2014 ${m}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:l,where:m,predicate:u}of i)qt(s,l.name)||n.push(this.finding("Error",m,u,`${a}/${l.name}`,`Link to '${l.name}' in '${u}' at '${m}' does not dereference: package '${a}' (resolved to ${s.metadata.namespace_?.toString()??a}) defines no resource named '${l.name}'.`,`Check for a typo, or a resource renamed or removed in '${a}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var fe=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],c=new d;c.ruleType=this.ruleName,c.severity="Error",c.entityName=s,c.propertyName=e,c.actualValue=n,c.expectedValue=i,c.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,c.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var ye=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new d;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new d;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var he=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let c of i){let l=c?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let c=i?.toString();c&&c==="Property"&&!o&&s.push(c)}for(let c of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),u=new d;u.ruleType=this.ruleName,u.severity="Error",u.entityName=n,u.propertyName="type",u.actualValue=c,u.expectedValue=m,u.message=`Invalid property type '${c}'. Use '${m}' instead.`,u.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(u)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ke=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new d;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
|
|
2
2
|
type: Scene
|
|
3
3
|
|
|
4
|
-
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var
|
|
4
|
+
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var yo=new Set(["EphemeralPackage"]),ge=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let o=[],n=this.packageKey(e,t.type_);return t.namespace_?(!yo.has(t.type_)&&!t.namespace_.version&&o.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
5
5
|
version: 1.0.0`)),o):(o.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
|
|
6
|
-
publisher: example.org`)),o)}packageKey(e,t){for(let[o,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===t)return o;return t}error(e,t,o,n){let r=new d;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.message=o,r.suggestion=n,r}};var
|
|
6
|
+
publisher: example.org`)),o)}packageKey(e,t){for(let[o,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===t)return o;return t}error(e,t,o,n){let r=new d;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.message=o,r.suggestion=n,r}};var ho={publisher:"kanonak.org",package_:"core-rdf",name:"type"},ko={publisher:"kanonak.org",package_:"core-rdf",name:"range"},go={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Ro={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},Re=class{ruleName="EmbeddedKanonakType";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await ue(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof J){let a=r.predicate?.subject,i=`${o}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,o,i,n),this.walk(e,r.object,i,n)}else if(r instanceof L){let a=r.predicate?.subject,i=0;for(let s of r.object){if(s instanceof V){let c=`${o}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,s,o,c,n),this.walk(e,s,c,n)}i++}}}check(e,t,o,n,r,a){if(!t)return;let i=E(o,ho);if(!i)return;let s=g(e,t);if(!s)return;let c=E(s,ko);if(c&&!(Z(c,go)||Z(c,Ro))){if(k(i)===k(c)){a.push(this.redundant(n,r,i,c));return}W(e,i).some(l=>k(l)===k(c))||a.push(this.notSubclass(n,r,i,c))}}redundant(e,t,o,n){let r=new d;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' declares 'type: ${o.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: ${o.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,t,o,n){let r=new d;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' has 'type: ${o.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${o.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${o.name}' class definition so the relationship holds.`,r}};import{VersionOperator as it}from"@kanonak-protocol/types/document/models/enums";var be=class{ruleName="ImportExistence";async validateAsync(e,t){let o=[];if(!e.metadata?.imports)return o;for(let[n,r]of Object.entries(e.metadata.imports))for(let a of r){if(se(a))continue;let i;try{i=await t.getHighestCompatibleVersionAsync(n,a)}catch(s){o.push(this.unresolvable(n,a,s));continue}if(!i){let s=await this.determineImportErrorAsync(t,n,a),c=new d;c.ruleType=this.ruleName,c.severity="Error",c.message=s.message,c.suggestion=s.suggestion,c.entityName=`Import: ${n}/${a.packageName}`,c.actualValue=a.toString(),c.expectedValue=s.expectedValue,o.push(c)}}return o}unresolvable(e,t,o){let n=new d;return n.ruleType=this.ruleName,n.severity="Error",n.message=`Import '${e}/${t.toString()}' could not be resolved: ${o instanceof Error?o.message:String(o)}`,n.suggestion=this.suggestionFor(o),n.entityName=`Import: ${e}/${t.packageName}`,n.actualValue=t.toString(),n.expectedValue="A resolvable package",n}suggestionFor(e){return e instanceof vt?"The publisher requires a credential. Configure a credential helper or a token for it; the message says what the provider or the server answered.":e instanceof Et?e.status===429||e.retryAfterSeconds!==void 0?`The publisher is limiting requests${e.retryAfterSeconds!==void 0?`; retry after ${e.retryAfterSeconds}s`:""}.`:`The publisher answered HTTP ${e.status}; the message carries its explanation.`:"Check the network and the publisher name, or validate with --offline to use only the workspace and cache."}async determineImportErrorAsync(e,t,o){let n=await e.getDocumentsByNamespaceAsync(t,o.packageName);if(n.length===0){let s=(await e.getAllDocumentsAsync()).filter(u=>u.metadata.namespace_?.publisher===t).map(u=>u.metadata.namespace_.package_).filter((u,y,h)=>h.indexOf(u)===y),c=this.findSimilarPackages(o.packageName,s),l=`Import '${t}/${o.package_}' not found - package does not exist`,m=c.length>0?`Did you mean: ${c.slice(0,3).join(", ")}?`:s.length>0?`Packages from ${t} known to this validation (workspace, cache, fetched): ${s.slice(0,5).join(", ")}`:`No packages from '${t}' are known to this validation. Verify the publisher name is correct.`;return{message:l,suggestion:m,expectedValue:"Existing package"}}let a=n.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),i=this.getAcceptableVersionRange(o);return{message:`Import '${t}/${o.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${a}. Required: ${i}`,expectedValue:i}}getAcceptableVersionRange(e){switch(e.versionOperator){case it.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case it.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case it.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case it.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,t){if(t.length===0)return[];let o=t.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(o.length>0)return o.sort((a,i)=>a.length-i.length);let n=t.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,t){if(!e||e.length===0)return t?.length??0;if(!t||t.length===0)return e.length;let o=e.length,n=t.length,r=Array(o+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=o;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=o;a++)for(let i=1;i<=n;i++){let s=e[a-1]===t[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]+s)}return r[o][n]}};var bo="kanonak.org",Ko="core-rdf",Vo=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(p=>k({publisher:bo,package_:Ko,name:p}))),Ke=class{ruleName="UnresolvedReference";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o),i=tt(e),s=c=>i.has(`${c.subject.publisher}/${c.subject.package_}`);return F(a,({kanonak:c,path:l})=>{for(let m of c.statement){let u=Eo(m);if(!(!u||Vo.has(k(u)))){if(m instanceof ce)s(m.object)||this.check(r,l,u,m.object,n);else if(m instanceof L)for(let y of m.object)y instanceof N&&!s(y)&&this.check(r,l,u,y,n)}}}),n}check(e,t,o,n,r){g(e,n.subject)||r.push(this.unresolvedError(t,o.name,n.subject))}unresolvedError(e,t,o){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new d;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${o.name}' in '${t}' could not be resolved`,r.suggestion=`The entity '${n}' is not defined in this namespace or any imported namespace.
|
|
7
7
|
\u2022 Import the package that defines it, or check for a typo in '${o.name}'
|
|
8
|
-
\u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function
|
|
8
|
+
\u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function Eo(p){return p.predicate?.subject}var Ft={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Ht={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function st(p,e,t){let o=[],n=new Set,r=new Set,a=i=>{let s=g(p,i),c=s?`${s.namespace}/${s.name}`:k(i);if(n.has(c)){let l=o.findIndex(u=>u.key===c),m=o.slice(l);return m.length<=1?null:[...m.map(u=>u.uri),i]}if(r.has(c))return null;if(n.add(c),o.push({key:c,uri:i}),s)for(let l of M(s,t)){let m=a(l);if(m)return m}return o.pop(),n.delete(c),r.add(c),null};return a(e)}var Wt=p=>p,Ve=class{ruleName="ClassHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f)||!(j.isClassType(Wt(i))||j.isDatatypeType(Wt(i))))continue;let s=x(i);if(!s)continue;let c=st(r,s,Ft);if(c){let l=c.map(u=>u.name).join(" \u2192 "),m=new d;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 Ee=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f)||!Q(r,i))continue;let s=x(i);if(!s)continue;let c=st(r,s,Ht);if(c){let l=c.map(u=>u.name).join(" \u2192 "),m=new d;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 vo={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ve=class{ruleName="PropertyRangeRequired";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=q(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let c=s==="ObjectProperty";H(i,vo)||n.push(this.error(i.name,c))}return n}error(e,t){let o=new d;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName="range",o.message=`Property '${e}' must have a 'range' defined.`,o.suggestion=t?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",o.expectedValue=t?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",o}};var Do={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Yt=p=>p,De=class{ruleName="SubClassOfReference";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f)||!Gt(Yt(i)))continue;let s=M(i,Do);for(let c=0;c<s.length;c++)this.resolvesToClassLike(r,s[c])||n.push(this.error(i.name,s[c],s.length>1?`[${c}]`:""))}return n}resolvesToClassLike(e,t){let o=g(e,t);return o?Gt(Yt(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new d;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 '${t.name}' referenced in subClassOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a Class, or import a namespace that contains it`,r}};function Gt(p){return j.isClassType(p)||j.isDatatypeType(p)}var So={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Se=class{ruleName="SubPropertyOfReference";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f)||!Q(r,i))continue;let s=M(i,So);for(let c=0;c<s.length;c++)this.resolvesToProperty(r,s[c])||n.push(this.error(i.name,s[c],s.length>1?`[${c}]`:""))}return n}resolvesToProperty(e,t){let o=g(e,t);return o?Q(e,o):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new d;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 '${t.name}' referenced in subPropertyOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a property, or import a namespace that contains it`,r}};var $e=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,t){let o=[],n=e.metadata.namespace_?.toString();if(!n)return o;let r=new Map,a=new Set;await this.buildImportGraph(e,t,r,a);let i=this.detectCycle(n,r);if(i){let s=i.join(" \u2192 "),c=new d;c.ruleType=this.ruleName,c.severity="Error",c.message=`Circular namespace import detected: ${s}`,c.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.",c.entityName="imports",c.propertyName="imports",c.actualValue=s,o.push(c)}return o}async buildImportGraph(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,s]of Object.entries(e.metadata.imports))for(let c of s){if(se(c))continue;let l=`${i}/${c.packageName}@${c.version}`;a.push(l);let m=await t.getHighestCompatibleVersionAsync(i,c);m&&await this.buildImportGraph(m,t,o,n)}a.length>0&&o.set(r,a)}}detectCycle(e,t){let o=[],n=new Set;return this.detectCycleRecursive(e,t,o,n)}detectCycleRecursive(e,t,o,n){let r=o.indexOf(e);if(r>=0){let i=o.slice(r);return i.push(e),i}if(n.has(e))return null;o.push(e),n.add(e);let a=t.get(e);if(a)for(let i of a){let s=this.detectCycleRecursive(i,t,o,n);if(s)return s}return o.pop(),null}};var Ie=class{ruleName="UnresolvedPredicate";async validateAsync(e,t,o){let n=[],r=at(e);if(!r)return n;let a=await S(e,t,o);return F(a,({kanonak:i,path:s})=>{for(let c of i.unresolvedPredicates)c.sourceDoc===r&&n.push(this.unresolvedPredicateError(s,c.key))}),n}unresolvedPredicateError(e,t){let o=t.lastIndexOf("."),n=o>0?t.slice(0,o):null,r=o>0?t.slice(o+1):t,a=new d;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=t,a.expectedValue="A defined or imported property",a.message=`Property '${t}' is not defined or imported`,a.suggestion=n?`The property '${r}' was not found in the namespace imported as '${n}'.
|
|
9
9
|
1. Check '${r}' is spelled correctly
|
|
10
10
|
2. Verify '${n}' is imported with the right alias and version
|
|
11
11
|
3. Ensure that namespace version actually defines '${r}'`:`The property '${t}' is not defined in this namespace or any imported namespace.
|
|
12
12
|
1. Define '${t}' as an ObjectProperty or DatatypeProperty here, OR
|
|
13
13
|
2. Import the namespace that defines it, OR
|
|
14
|
-
3. Alias-qualify it if it lives in an imported namespace ('alias.${t}')`,a}};var je=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,t){let o=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,t),a=await this.buildDatatypePropertyNamesAsync(e,t);for(let[i,s]of Object.entries(e.body))typeof s=="object"&&s!==null&&!Array.isArray(s)&&this.validateEntityReferences(i,s,n,r,a,e,o);return o}async buildEntitySourceMapAsync(e,t){let o=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";o.has(a)||o.set(a,[]),o.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(a,s);if(c){let l=c.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(c,o,n,r,[l],t)}}return{entitySources:o,importPaths:r}}async collectEntitiesRecursivelyAsync(e,t,o,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!o.has(i)){o.add(i),n.has(i)||n.set(i,r);for(let s of Object.keys(e.body)){t.has(s)||t.set(s,[]);let c=t.get(s);c.includes(i)||c.push(i)}if(e.metadata.imports)for(let[s,c]of Object.entries(e.metadata.imports))for(let l of c){let m=await a.getHighestCompatibleVersionAsync(s,l);if(m){let u=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,t,o,n,[...r,u],a)}}}}async buildDatatypePropertyNamesAsync(e,t){let o=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,o,n,t),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let s=await t.getHighestCompatibleVersionAsync(r,i);s&&await this.collectDatatypePropertiesAsync(s,o,n,t)}return o}async collectDatatypePropertiesAsync(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!o.has(r)){o.add(r);for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let s=i.type;if(typeof s!="string")continue;(s.includes(".")?s.substring(s.lastIndexOf(".")+1):s)==="DatatypeProperty"&&t.add(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await n.getHighestCompatibleVersionAsync(a,s);c&&await this.collectDatatypePropertiesAsync(c,t,o,n)}}}validateEntityReferences(e,t,o,n,r,a,i){for(let[s,c]of Object.entries(t)){let l=s;if(l&&!l.includes(".")){let m=o.get(l);if(m&&m.length>1&&!m.some(
|
|
15
|
-
imported via: ${
|
|
16
|
-
`),u=e.split(".")[0],
|
|
14
|
+
3. Alias-qualify it if it lives in an imported namespace ('alias.${t}')`,a}};var je=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,t){let o=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,t),a=await this.buildDatatypePropertyNamesAsync(e,t);for(let[i,s]of Object.entries(e.body))typeof s=="object"&&s!==null&&!Array.isArray(s)&&this.validateEntityReferences(i,s,n,r,a,e,o);return o}async buildEntitySourceMapAsync(e,t){let o=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";o.has(a)||o.set(a,[]),o.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await t.getHighestCompatibleVersionAsync(a,s);if(c){let l=c.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(c,o,n,r,[l],t)}}return{entitySources:o,importPaths:r}}async collectEntitiesRecursivelyAsync(e,t,o,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!o.has(i)){o.add(i),n.has(i)||n.set(i,r);for(let s of Object.keys(e.body)){t.has(s)||t.set(s,[]);let c=t.get(s);c.includes(i)||c.push(i)}if(e.metadata.imports)for(let[s,c]of Object.entries(e.metadata.imports))for(let l of c){let m=await a.getHighestCompatibleVersionAsync(s,l);if(m){let u=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,t,o,n,[...r,u],a)}}}}async buildDatatypePropertyNamesAsync(e,t){let o=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,o,n,t),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let s=await t.getHighestCompatibleVersionAsync(r,i);s&&await this.collectDatatypePropertiesAsync(s,o,n,t)}return o}async collectDatatypePropertiesAsync(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!o.has(r)){o.add(r);for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let s=i.type;if(typeof s!="string")continue;(s.includes(".")?s.substring(s.lastIndexOf(".")+1):s)==="DatatypeProperty"&&t.add(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let c=await n.getHighestCompatibleVersionAsync(a,s);c&&await this.collectDatatypePropertiesAsync(c,t,o,n)}}}validateEntityReferences(e,t,o,n,r,a,i){for(let[s,c]of Object.entries(t)){let l=s;if(l&&!l.includes(".")){let m=o.get(l);if(m&&m.length>1&&!m.some(y=>y.startsWith("(local:"))){let y=m.filter(h=>!h.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,y,n,a,!0,l))}}this.validatePropertyValue(e,l,c,o,n,r,a,i)}}validatePropertyValue(e,t,o,n,r,a,i,s){if(o==null)return;let c=t&&t.includes(".")?t.substring(t.lastIndexOf(".")+1):t,l=!!c&&a.has(c);if(typeof o=="string"&&!o.includes(".")&&!l){let m=n.get(o);if(m&&m.length>1&&!m.some(y=>y.startsWith("(local:"))){let y=m.filter(h=>!h.startsWith("(local:"));y.length>1&&s.push(this.createAmbiguityError(e,t,`Reference '${o}'`,y,r,i,!1,o))}}else if(Array.isArray(o))for(let m=0;m<o.length;m++){let u=`${e}.${t}[${m}]`;this.validatePropertyValue(u,t,o[m],n,r,a,i,s)}else if(typeof o=="object"&&!Array.isArray(o)){let m=t?`${e}.${t}`:e;this.validateEntityReferences(m,o,n,r,a,i,s)}}createAmbiguityError(e,t,o,n,r,a,i,s){let c=[];for(let K of n){let $=this.findAliasForNamespace(a,K);if($){let w=t?.split(".").pop()??t;c.push(`${$}.${w}`)}}let l=c.length>0?`Use one of: ${c.map(K=>`'${K}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${t}')`,m=n.map(K=>{let $=r.get(K);return!$||$.length===0?` \u2022 ${K}`:$.length===1?` \u2022 ${K} (direct import)`:` \u2022 ${K}
|
|
15
|
+
imported via: ${$.join(" \u2192 ")}`}).join(`
|
|
16
|
+
`),u=e.split(".")[0],y=e.includes(".")?e:t,h=new d;h.ruleType=this.ruleName,h.severity="Error",h.entityName=u,y&&(h.propertyName=y);let b=s??t;return b&&(h.actualValue=b),h.message=`${o} is ambiguous - defined in multiple imported namespaces`,h.suggestion=`${l}
|
|
17
17
|
|
|
18
18
|
Defined in:
|
|
19
|
-
${m}`,h.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",h}findAliasForNamespace(e,t){if(!e.metadata.imports)return null;for(let[o,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${o}/${r.packageName}@${r.version}`===t&&r.alias)return r.alias;return null}};var
|
|
19
|
+
${m}`,h.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",h}findAliasForNamespace(e,t){if(!e.metadata.imports)return null;for(let[o,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${o}/${r.packageName}@${r.version}`===t&&r.alias)return r.alias;return null}};var $o={publisher:"kanonak.org",package_:"core-rdf",name:"range"},zt=p=>p,Oe=class{ruleName="PropertyRangeReference";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=q(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let c=s==="ObjectProperty";for(let l of M(i,$o))this.resolvesToClassLike(r,l)||n.push(this.error(i.name,l,c))}return n}resolvesToClassLike(e,t){let o=g(e,t);return o?j.isClassType(zt(o))||j.isDatatypeType(zt(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new d;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="range",r.actualValue=n,r.expectedValue=o?"A defined or imported class":"A datatype or defined class",r.message=`Property '${e}' has range '${t.name}' which is not defined or imported`,r.suggestion=o?`Define '${t.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 '${t.name}' is a class \u2014 make this an ObjectProperty.`,r}};var Io={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Ce="kanonak.org",ft="core-rdf",yt="core-owl",ht=p=>p,jo=[{uri:{publisher:Ce,package_:ft,name:"Class"},ok:(p,e)=>j.isClassType(ht(e))||j.isDatatypeType(ht(e))},{uri:{publisher:Ce,package_:ft,name:"Datatype"},ok:(p,e)=>j.isDatatypeType(ht(e))},{uri:{publisher:Ce,package_:ft,name:"Property"},ok:(p,e)=>Q(p,e)},{uri:{publisher:Ce,package_:yt,name:"ObjectProperty"},ok:(p,e)=>q(p,e)==="ObjectProperty"},{uri:{publisher:Ce,package_:yt,name:"DatatypeProperty"},ok:(p,e)=>q(p,e)==="DatatypeProperty"},{uri:{publisher:Ce,package_:yt,name:"AnnotationProperty"},ok:(p,e)=>q(p,e)==="AnnotationProperty"}],Pe=class{ruleName="ObjectPropertyValue";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await ue(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof ce)this.check(e,r.predicate?.subject,r.object.subject,o,n);else if(r instanceof J)this.walk(e,r.object,Xt(o,r.predicate?.subject),n);else if(r instanceof L){let a=r.predicate?.subject;for(let i of r.object)i instanceof N?this.check(e,a,i.subject,o,n):i instanceof V&&this.walk(e,i,Xt(o,a),n)}}check(e,t,o,n,r){if(!t)return;let a=g(e,t);if(!a)return;let i=E(a,Io);if(!i)return;let s=jo.find(l=>Z(i,l.uri));if(!s)return;let c=g(e,o);c&&(s.ok(e,c)||r.push(this.warn(n,t,i,o)))}warn(e,t,o,n){let r=new d;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e.split(".")[0],r.propertyName=e,r.actualValue=n.name,r.expectedValue=o.name,r.message=`Property '${t.name}' expects a ${o.name}, but '${n.name}' is not a ${o.name}`,r.suggestion=`Reference a resource that is a ${o.name}, or correct the type of '${n.name}'.`,r}};function Xt(p,e){return`${p}.${e?.name??"<embedded>"}`}var Oo={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},Co={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},we=class{ruleName="PropertyDomain";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await ue(e,t,o);for(let i of a)i instanceof f&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){this.checkNode(e,t,o,n);for(let r of t.statement)if(r instanceof J)this.walk(e,r.object,Zt(o,r.predicate?.subject),n);else if(r instanceof L)for(let a of r.object)a instanceof V&&this.walk(e,a,Zt(o,r.predicate?.subject),n)}checkNode(e,t,o,n){let r=pe(t);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([k(Co)]);for(let c of r)for(let l of W(e,c))a.add(k(l))}return a},s=new Set;for(let c of t.statement){let l=Po(c);if(!l||rt(l.name)||s.has(k(l)))continue;s.add(k(l));let m=g(e,l);if(!m)continue;let u=M(m,Oo);u.length!==0&&(u.some(y=>i().has(k(y)))||n.push(this.error(o,l,u,r[0])))}}error(e,t,o,n){let r=o.map(i=>i.name).join(" | "),a=new d;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e.split(".")[0],a.propertyName=e,a.actualValue=t.name,a.expectedValue=`Property used on ${r} or its subclasses`,a.message=`Property '${t.name}' has domain '${r}' but is used on '${n.name}' at '${e}'`,a.suggestion=`Either:
|
|
20
20
|
1. Use '${t.name}' only on '${r}' (or a subclass) instances
|
|
21
21
|
2. Widen the property's domain to include '${n.name}'
|
|
22
|
-
3. Use a different property for '${n.name}'`,a}};function
|
|
22
|
+
3. Use a different property for '${n.name}'`,a}};function Po(p){return p.predicate?.subject}function Zt(p,e){return`${p}.${e?.name??"<embedded>"}`}var wo={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Uo={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},Ao=p=>p,Ue=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);for(let i of a){if(!(i instanceof f))continue;let s=q(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let c=s==="ObjectProperty",l=s==="DatatypeProperty",m=E(i,wo);if(!m||!g(r,m))continue;let u=No(r,m);l&&!u?n.push(this.error(i.name,m,"datatype")):c&&u&&n.push(this.error(i.name,m,"object"))}return n}error(e,t,o){let n=new d;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="range",n.actualValue=t.name,o==="datatype"?(n.expectedValue="A datatype (xsd type, rdfs.Literal, or a datatype-derived class)",n.message=`DatatypeProperty '${e}' has range '${t.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 '${t.name}' is the intended target \u2014 declare '${e}' an ObjectProperty.`):(n.expectedValue="A plain class (not datatype-derived)",n.message=`ObjectProperty '${e}' has range '${t.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 '${t.name}'), or change the range to a plain class.`),n}};function No(p,e){for(let t of W(p,e)){if(Z(t,Uo))return!0;let o=g(p,t);if(o&&j.isDatatypeType(Ao(o)))return!0}return!1}var Ae=class{ruleName="ReservedNameShadow";async validateAsync(e,t,o){let n=[],r=await P(e,t,o);for(let a of r){if(!(a instanceof f))continue;let i=Ct(a.name);if(!i)continue;let s=x(a);s&&(i.publisher===s.publisher&&i.package_===s.package_||n.push(this.info(a.name,s,i)))}return n}info(e,t,o){let n=new d;return n.ruleType=this.ruleName,n.severity="Info",n.entityName=e,n.propertyName=e,n.actualValue=`${t.publisher}/${t.package_}/${e}`,n.expectedValue=`${o.publisher}/${o.package_}/${e}`,n.message=`'${e}' is also the reserved built-in '${o.publisher}/${o.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 '${o.publisher}/${o.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 To={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Qt=p=>p,Ne=class{ruleName="ClassDefinition";async validateAsync(e,t,o){let n=[],r=await S(e,t,o),a=await P(e,t,o);return F(a,({kanonak:i,path:s})=>{for(let c of M(i,To))this.resolvesToClassLike(r,c)||n.push(this.error(s,c))}),n}resolvesToClassLike(e,t){if(rt(t.name))return!0;let o=g(e,t);return o?j.isClassType(Qt(o))||j.isDatatypeType(Qt(o)):!1}error(e,t){let o=`${t.publisher}/${t.package_}/${t.name}`,n=new d;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="type",n.actualValue=o,n.expectedValue="Defined or imported class",n.message=`Class '${t.name}' is not defined or imported`,n.suggestion=`Define '${t.name}' as a Class in this document, or import a namespace that contains it`,n}};var Te=class{ruleName="MarkdownLink";async validateAsync(e,t,o){let n=[],r=await P(e,t,o);return F(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,t,o){for(let n of e.statement)if(n instanceof nt)this.checkProse(n.object,n.links,t,n.predicate.subject?.name??"(unknown)",o);else if(n instanceof L){let r=n.predicate.subject?.name??"(unknown)";(n.object??[]).forEach((a,i)=>{a instanceof ot&&a.links&&this.checkProse(String(a.value),a.links,t,`${r}[${i}]`,o)})}}checkProse(e,t,o,n,r){for(let a of t)a.target||r.push(this.unresolvedLinkError(o,n,a.reference));for(let a of wt(e))r.push(this.malformedLinkError(o,n,a.snippet))}unresolvedLinkError(e,t,o){let n=new d;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`Embedded link [[${o}]] in '${t}' could not be resolved`,n.expectedValue="A reference resolvable through the document's import closure",n.suggestion=`The reference '${o}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
23
23
|
|
|
24
24
|
Possible solutions:
|
|
25
25
|
\u2022 Import the package that defines '${o}' so the link can resolve
|
|
@@ -31,27 +31,27 @@ long reference across two lines in a block scalar, e.g.:
|
|
|
31
31
|
... read for [[persistent-energy-
|
|
32
32
|
shock]] held ...
|
|
33
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
|
|
34
|
+
line (let the line run long), or check for an unterminated [[.`,n}};var Jt="kanonak.org",eo="look",xo={publisher:Jt,package_:eo,name:"displayLabel"},_o={publisher:Jt,package_:eo,name:"displaySummary"},xe=class{ruleName="DisplayLensScope";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new O().parseKanonaks(new B(e,t));let a=Lo(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&(this.checkLens(r,i,xo,"displayLabel",n),this.checkLens(r,i,_o,"displaySummary",n));return n}checkLens(e,t,o,n,r){let a=E(t,o);if(!a)return;let i=[],s=x(t);if(s&&i.push(s),i.push(...pe(t)),i.length===0)return;i.some(l=>Y(e,l,a).ok)||r.push(this.scopeError(t.name,n,a.name))}scopeError(e,t,o){let n=new d;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`${t} points at '${o}', 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=`'${o}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
|
|
35
35
|
|
|
36
36
|
Possible solutions:
|
|
37
37
|
\u2022 Point ${t} at a property declared on this class (or an ancestor / rdfs.Resource)
|
|
38
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
|
|
39
|
+
\u2022 Use rdfs.label / rdfs.comment for the universal default`,n}};function Lo(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}function ae(p,e,t){let o=[];return ze(p,t,{input:e},o),o}function ze(p,e,t,o){if(A(e,z.VarRef)){let a=te(e,z.varName);return a?t[a]:void 0}if(A(e,z.PropertyRead)){let a=C(e,z.readSource),i=a?ze(p,a,t,o):void 0,s=E(e,z.readProp);if(!i||!s)return;let c=Y(p,i,s);if(!c.ok){o.push({contextClass:i,propertyUri:s,via:"PropertyRead"});return}return c.descriptor?.range}if(A(e,z.Traverse)){let a=C(e,z.traverseSource),i=a?ze(p,a,t,o):void 0,s=E(e,z.through),c;if(i&&s){let m=Y(p,i,s);m.ok?c=m.descriptor?.range:o.push({contextClass:i,propertyUri:s,via:"Traverse"})}let l=C(e,z.step);return l?ze(p,l,{...t,input:c},o):void 0}let n=te(e,z.loopVar),r=n?{...t,[n]:void 0}:t;for(let a of Mo(e))ze(p,a,r,o)}function Mo(p){let e=[];for(let t of p.statement){let o=t.object;if(o instanceof V)e.push(o);else if(Array.isArray(o))for(let n of o)n instanceof V&&e.push(n)}return e}var Xe="kanonak.org",Ze="look",Bo={publisher:Xe,package_:Ze,name:"semanticSvg"},qo={publisher:Xe,package_:Ze,name:"tierChip"},Fo={publisher:Xe,package_:Ze,name:"tierIcon"},Ho={publisher:Xe,package_:Ze,name:"tierCard"},Wo={publisher:Xe,package_:Ze,name:"tierFull"},Yo=[qo,Fo,Ho,Wo],_e=class{ruleName="LookSemanticSvgPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new O().parseKanonaks(new B(e,t));let a=Go(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,t,o){let n=C(t,Bo);if(!n)return;let r=x(t);if(r)for(let a of Yo){let i=C(n,a);if(i)for(let s of ae(e,r,i))o.push(this.toError(t.name,a.name,s))}}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.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 d;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${t}`,i.actualValue=n,i.message=`tx.${o.via} reads property '${o.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
40
|
|
|
41
41
|
Possible solutions:
|
|
42
42
|
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
43
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
|
|
44
|
+
\u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function Go(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var to={publisher:"kanonak.org",package_:"transformations",name:"Expression"},zo=new Map([["look","the look renderer"],["view","the view materializer"],["transformations","the transformation runner"]]);function oo(p){if(!(!p||p.publisher!=="kanonak.org"))return zo.get(p.package_)}var Le=class{ruleName="TxExpressionCompiles";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(new B(e,t)),a=Qo(e);if(!a)return n;let i=r.filter(b=>b instanceof f&&b.namespace===a);if(i.length===0)return n;let s=new Map,c=b=>{for(let K of $t(b)){let $=k(K),w=s.get($);if(w===void 0&&(w=Z(K,to)||W(r,K).some(I=>Z(I,to)),s.set($,w)),w)return!0}return!1},l=[],m=new Map,u=new Map,y=new Set;for(let b of i)F([b],({kanonak:K,path:$})=>{let w=K instanceof V&&c(K);w&&l.push({node:K,path:$,subject:b.name});for(let{child:I,predicate:D}of Zo(K))c(I)&&(D&&m.set(I,D),w&&y.add(I));if(!w){for(let I of Xo(K))if(oo(I))for(let D of oe(K,I)){if(!(D.item instanceof N))continue;let G=g(r,D.item.subject);G&&c(G)&&(l.push({node:G,path:`${$}.${I.name}`,subject:b.name}),u.set(G,I))}}});let h=new Set;for(let{node:b,path:K,subject:$}of l){if(b instanceof V&&y.has(b))continue;let w=oo(b instanceof V?m.get(b):u.get(b));if(w)try{At(b,K,{catalog:r,depth:0})}catch(I){let D=I instanceof Error?I.message:String(I),G=`${$} ${K} ${D}`;if(h.has(G))continue;h.add(G),n.push(this.toError($,K,D,w))}}return n}toError(e,t,o,n){let r=new d;r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=o;let a=/[.!?]$/.test(o)?o:`${o}.`;return r.message=`A tx.Expression at '${t}' 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
45
|
|
|
46
46
|
Possible solutions:
|
|
47
47
|
\u2022 Rebuild the expression from tx primitives this SDK supports
|
|
48
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
|
|
49
|
+
\u2022 If the node class should be supported, implement it in the runner first`,r}};function Xo(p){let e=new Map;for(let t of p.statement){let o=t.predicate?.subject;o&&!e.has(k(o))&&e.set(k(o),o)}return[...e.values()]}function Zo(p){let e=[];for(let t of p.statement){let o=t.predicate?.subject;if(t instanceof J)e.push({child:t.object,predicate:o});else if(t instanceof L)for(let n of t.object)n instanceof V&&e.push({child:n,predicate:o})}return e}function Qo(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Jo="kanonak.org",Qe=(p,e)=>({publisher:Jo,package_:p,name:e}),en=Qe("derivation","look"),no=Qe("look","bands"),ro=Qe("look","Sequence"),tn=Qe("core-rdf","range"),on=Qe("look","nodeTier"),Me=class{ruleName="SequenceNarrative";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(new B(e,t)),a=nn(e);if(!a)return n;let i=r.filter(c=>c instanceof f&&c.namespace===a);if(i.length===0)return n;for(let c of i){let l=C(c,en);l&&T(l,no).forEach((m,u)=>{!(m instanceof V)||!A(m,ro)||n.push(...this.checkBand(r,c,m,`${c.name}.look.bands[${u}]`))})}let s=new Lt(r);for(let c of i){let l=s.findCascadedLook(c);if(l)for(let m of T(l.declaration,no))!(m instanceof V)||!A(m,ro)||this.checkBand(r,c,m,"").length>0||n.push(...this.checkInstance(r,c,m,Tt(r,c,m)))}return n}checkBand(e,t,o,n){let r=[],a=(l,m,u)=>r.push(this.toError("Error",t.name,n,l,m,u)),i=pt(o);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=It(e,i)[0],m=l?M(l,tn):[];l&&!m.some(u=>St.isSubstitutableDatatypeUri(u))&&a(`look.source names '${i.name}', whose rdfs.range is ${m.map(u=>k(u)).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.",k(i))}let s=lt(e,o);s.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 s)(!l.subject||q(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.",k(l.relation)),l.invalidStyle!==void 0&&a(`look.lineStyle '${l.invalidStyle}' on connector '${l.relation.name}' is not a supported value. Supported: ${[...Nt].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 c=te(o,on);return c!==void 0&&mt[c]===void 0&&a(`look.nodeTier '${c}' is not a tier. Supported: ${Object.keys(mt).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.",c),r}checkInstance(e,t,o,n){let r=[],a=pt(o),i=`${t.name}.${a.name}`,s=lt(e,o).map(c=>c.relation.name).join(", ");if(n.problem)return r.push(this.toError("Error",t.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",t.name,i,`'${t.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 c of n.strayPropertyRefs)r.push(this.toError("Error",t.name,i,`The narrative references property '${c.name}', which is not a declared connector of the look.Sequence band (declared: ${s}). 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: ${c.name} } to look.connectors on the band, or reference one of the declared connectors instead.`,k(c)));if(n.mentions>=2&&n.messages.length===0)return r.push(this.toError("Error",t.name,i,`The narrative mentions ${n.mentions} participant references but joins nothing: no declared connector (${s}) 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 c of n.gaps){let l=c.selected?`'${c.selected.name}' does not hold`:`no declared connector (${s}) holds`;r.push(this.toError("Warning",t.name,i,`The narrative orders '${c.prev.name}' then '${c.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 '${c.prev.name}' or '${c.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.`,`${c.prev.name} \u2192 ${c.next.name}`))}return r}toError(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=e,i.entityName=t,i.propertyName=o,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function nn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var rn="kanonak.org",v=(p,e)=>({publisher:rn,package_:p,name:e}),an=v("derivation","look"),sn=v("look","bands"),cn=v("look","Distribution"),pn=v("look","StatRow"),ln=v("look","VersionDelta"),mn=v("look","Timeline"),un=v("look","VersionDiff"),dn=v("look","TimePlot"),fn=v("look","ReferenceList"),yn=v("look","Diagram"),hn=v("look","alphaPath"),kn=v("look","betaPath"),kt=v("look","metricPath"),ao=v("look","lowerPath"),io=v("look","upperPath"),so=v("look","hueBy"),gn=v("look","statPath"),Rn=v("look","laneBy"),co=v("look","labelPath"),bn=v("look","badgePath"),Kn=v("look","mapPath"),Vn=v("look","nodeNote"),En=v("look","edgeValue"),vn=v("look","stats"),Dn=v("look","facets"),Sn=v("look","channels"),$n=v("look","track"),In=v("look","source"),jn=v("look","relation"),On=v("look","entries"),Be=class{ruleName="LookBandPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new O().parseKanonaks(new B(e,t));let a=Pn(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,t,o){let n=C(t,an);if(!n)return;let r=x(t);if(!r)return;let a=T(n,sn).filter(i=>i instanceof V);for(let i of a)for(let s of this.carriersOf(e,i,r))for(let c of ae(e,s.context,s.expr))o.push(this.toError(t.name,s.slot,c))}carriersOf(e,t,o){let n=[],r=(a,i)=>{let s=C(t,a);s&&n.push({slot:`look.${a.name}`,context:i,expr:s})};if(A(t,cn))for(let a of[hn,kn,kt,ao,io,so])r(a,o);if(A(t,ln)&&r(kt,o),A(t,pn)){let a=T(t,vn).filter(i=>i instanceof V);for(let i of a){let s=C(i,gn);s&&n.push({slot:"look.stats[].statPath",context:o,expr:s})}}if(A(t,mn)||A(t,un)){let a=this.rangeOf(e,o,E(t,$n));if(a)for(let i of[kt,ao,io,so])r(i,a)}if(A(t,dn)){let a=this.rangeOf(e,o,E(t,In));if(a)for(let i of[Rn,co])r(i,a)}if(A(t,fn))for(let a of T(t,On)){let i=a instanceof V?void 0:Cn(a),s=this.rangeOf(e,o,i);if(s)for(let c of[co,bn])r(c,s)}if(A(t,yn)){let a=T(t,Dn).filter(i=>i instanceof V);for(let i of a){let s=this.rangeOf(e,o,E(i,jn));if(!s)continue;let c=C(i,Vn);c&&n.push({slot:"look.facets[].nodeNote",context:s,expr:c});let l=C(i,En);l&&n.push({slot:"look.facets[].edgeValue",context:s,expr:l});let m=T(i,Sn).filter(u=>u instanceof V);for(let u of m){let y=C(u,Kn);y&&n.push({slot:"look.facets[].channels[].mapPath",context:s,expr:y})}}}return n}rangeOf(e,t,o){if(!o)return;let n=Y(e,t,o);return n.ok?n.descriptor?.range:void 0}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,a=new d;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=n,a.message=`tx.${o.via} reads property '${o.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
50
|
|
|
51
51
|
Possible solutions:
|
|
52
52
|
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
53
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
|
|
54
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function Cn(p){let e=p.subject;return e&&typeof e.name=="string"?e:void 0}function Pn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var wn="kanonak.org",gt=(p,e)=>({publisher:wn,package_:p,name:e}),Un=gt("derivation","look"),An=gt("look","bands"),Nn=gt("core-rdf","type"),Je=class{ruleName="UnrenderableBand";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(new B(e,t)),a=Tn(e);if(!a)return n;let i=Mt();for(let s of r){if(!(s instanceof f)||s.namespace!==a)continue;let c=C(s,Un);if(!c)continue;let l=T(c,An).filter(m=>m instanceof V);for(let m of l){let u=this.typeOf(m);if(!u)continue;let y=`${u.publisher}/${u.package_}/${u.name}`;if(i.has(y))continue;let h=new d;h.ruleType=this.ruleName,h.severity="Warning",h.entityName=s.name,h.propertyName="derivation.look",h.actualValue=y,h.message=`Band '${u.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(h)}}return n}typeOf(e){let t=E(e,Nn);if(t)return{publisher:t.publisher,package_:t.package_,name:t.name}}};function Tn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Fe="kanonak.org",He="view",xn={publisher:Fe,package_:He,name:"bind"},_n={publisher:Fe,package_:He,name:"produces"},Ln={publisher:Fe,package_:He,name:"projections"},Mn={publisher:Fe,package_:He,name:"where"},Bn={publisher:Fe,package_:He,name:"value"},qn={publisher:Fe,package_:He,name:"as"},qe=class{ruleName="TxExpressionPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new O().parseKanonaks(new B(e,t));let a=Wn(e);if(!a)return n;for(let i of r)i instanceof f&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,t,o){let n=E(t,xn);if(!n)return;let r=E(t,_n),a=0;for(let s of Hn(e,T(t,Ln))){let c=C(s,Bn);if(c)for(let m of ae(e,n,c))o.push(this.toError(t.name,`view.projections[${a}].value`,n,m));let l=E(s,qn);l&&r&&(Y(e,r,l).ok||o.push(this.asError(t.name,a,r,l))),a+=1}let i=0;for(let s of Fn(t,Mn)){for(let c of ae(e,n,s))o.push(this.toError(t.name,`view.where[${i}]`,n,c));i+=1}}asError(e,t,o,n){let r=`${n.publisher}/${n.package_}/${n.name}`,a=new d;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=`view.projections[${t}].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 '${o.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${o.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${o.name}'.
|
|
55
55
|
|
|
56
56
|
Possible solutions:
|
|
57
57
|
\u2022 Use an output property whose domain covers '${o.name}'
|
|
@@ -61,8 +61,8 @@ Possible solutions:
|
|
|
61
61
|
Possible solutions:
|
|
62
62
|
\u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
|
|
63
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`,s}};function Bn(p,e){let t=C(p,e);return t?[t]:T(p,e).filter(o=>o instanceof V)}function qn(p,e){let t=[];for(let o of e)if(o instanceof V)t.push(o);else if(o instanceof N){let n=b(p,o.subject);n&&t.push(n)}return t}function Fn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var et="kanonak.org",Hn="core-shacl",_=p=>({publisher:et,package_:Hn,name:p}),so=_("NodeShape"),co=_("PropertyShape"),Wn=_("targetClass"),gt=_("property"),Rt=_("path"),Yn=_("minCount"),Gn=_("maxCount"),zn=_("datatype"),Xn=_("class"),po=_("in"),Zn=_("pattern"),Qn=_("flags"),Jn=_("minLength"),er=_("maxLength"),tr=_("minInclusive"),or=_("maxInclusive"),nr={publisher:et,package_:"core-rdf",name:"range"},rr=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),lo=p=>p,We=class{ruleName="ShaclShape";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=ar(e);if(!a)return n;let i=new Set;for(let s of r){if(!(s instanceof k)||s.namespace!==a||!A(s,so))continue;let c=E(s,Wn);c?this.resolvesToClass(r,c)||n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' sh:targetClass '${c.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(c))):n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let{item:l}of oe(s,gt)){let m;if(l instanceof V)m=l;else if(l instanceof N){let u=b(r,l.subject);u&&(m=u,i.add(R(l.subject)))}m&&this.checkPropertyShape(r,s.name,m,c??void 0,n)}}for(let s of r){if(!(s instanceof k)||s.namespace!==a||!A(s,co))continue;let c=x(s);c&&i.has(R(c))||this.checkPropertyShape(r,s.name,s,void 0,n)}return n}checkPropertyShape(e,t,o,n,r){let a=E(o,Rt);if(!a){r.push(this.err(t,"property.path","Error",`A PropertyShape on '${t}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=b(e,a),s=i?Q(e,i):!1;s?n&&(Y(e,n,a).ok||r.push(this.err(t,"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.`,X(a)))):r.push(this.err(t,"property.path","Error",`sh:path '${a.name}' on '${t}' does not resolve to a property.`,"Reference a defined or imported property.",X(a)));let c=E(o,zn),l=E(o,Xn);c&&l&&r.push(this.err(t,"property","Error",`A PropertyShape on '${t}' 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.")),c&&!this.resolvesToDatatype(e,c)&&r.push(this.err(t,"datatype","Error",`sh:datatype '${c.name}' on '${t}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",X(c))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(t,"class","Error",`sh:class '${l.name}' on '${t}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(l)));let m=ie(ee(o,Yn)),u=ie(ee(o,Gn));this.checkOrder(t,"minCount",m,"maxCount",u,r);let f=ie(ee(o,Jn)),h=ie(ee(o,er));this.checkOrder(t,"minLength",f,"maxLength",h,r);let y=ie(ee(o,tr)),g=ie(ee(o,or));this.checkOrder(t,"minInclusive",y,"maxInclusive",g,r);let D=te(o,Zn);if(D!==void 0){let S=te(o,Qn);try{new RegExp(D,S)}catch{r.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(S!==void 0?` (with flags '${S}')`:"")+`: ${D}`,"Provide a valid regular expression and flags.",D))}}if(H(o,po)&&oe(o,po).length===0&&r.push(this.err(t,"in","Error",`sh:in on '${t}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),s&&n){let G=Y(e,n,a).descriptor;G&&((D!==void 0||f!==void 0||h!==void 0)&&G.kind==="object"&&r.push(this.err(t,"pattern/minLength/maxLength","Warning",`String facets on '${t}' 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.",X(a))),(y!==void 0||g!==void 0)&&!this.isNumericDatatypeRange(G.range)&&r.push(this.err(t,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${t}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",X(a))))}let P=i&&s?E(i,nr):void 0,I=i&&s?this.isDatatypeProperty(e,i,P):!1;if(H(o,st)){let S=E(o,st);I?r.push(this.err(t,"hasValue","Error",`sh:hasValue on '${t}' constrains '${a.name}', a datatype property; a literal hasValue is not supported yet.`,"Use sh:hasValue on an object property, naming an individual; literal values arrive with structured literals (typescript#115).",S?X(S):void 0)):!S||!b(e,S)?r.push(this.err(t,"hasValue","Error",`sh:hasValue${S?` '${S.name}'`:""} on '${t}' does not resolve to an individual.`,"Name a defined or imported individual.",S?X(S):void 0)):P&&this.resolvesToClass(e,P)&&!this.isInstanceOf(e,S,P)&&r.push(this.err(t,"hasValue","Warning",`sh:hasValue '${S.name}' on '${t}' is not an instance of '${P.name}', the range of '${a.name}'; no well-typed value can equal it.`,`Name an instance of '${P.name}'.`,X(S)))}this.checkQualified(e,t,o,P,r)}checkQualified(e,t,o,n,r){let a=H(o,ne),i=[{name:"qualifiedMinCount",uri:jt,value:void 0},{name:"qualifiedMaxCount",uri:Ot,value:void 0}],s=!1;for(let y of i){if(!H(o,y.uri))continue;s=!0;let g=ie(ee(o,y.uri));g===void 0||!Number.isInteger(g)||g<0?r.push(this.err(t,y.name,"Error",`sh:${y.name} on '${t}' must be a non-negative integer.`,`Set sh:${y.name} to 0 or more.`)):y.value=g}if(!a&&!s)return;if(!a){r.push(this.err(t,"qualifiedValueShape","Error",`A qualified count on '${t}' has no sh:qualifiedValueShape; it counts values conforming to nothing.`,"Add sh:qualifiedValueShape naming the shape the counted values conform to."));return}s||r.push(this.err(t,"qualifiedValueShape","Error",`sh:qualifiedValueShape on '${t}' has no sh:qualifiedMinCount or sh:qualifiedMaxCount; it bounds nothing.`,"Add sh:qualifiedMinCount and/or sh:qualifiedMaxCount.")),this.checkOrder(t,"qualifiedMinCount",i[0].value,"qualifiedMaxCount",i[1].value,r);let c=n&&this.resolvesToClass(e,n)?n:void 0,l=`${t} (qualified shape)`,m=C(o,ne);if(m){this.checkNestedShape(e,l,m,c,r);let y=this.qualifiedCycle(e,m,new Set);y&&this.pushCycle(t,y,r);return}let u=E(o,ne),f=u?b(e,u):void 0;if(!u||!f||!(A(f,so)||A(f,co)||H(f,Rt))){r.push(this.err(t,"qualifiedValueShape","Error",`sh:qualifiedValueShape${u?` '${u.name}'`:""} on '${t}' does not resolve to a shape.`,"Reference a NodeShape or PropertyShape, or write the shape inline.",u?X(u):void 0));return}let h=this.qualifiedCycle(e,f,new Set([R(u)]));h&&this.pushCycle(t,[u.name,...h],r)}checkNestedShape(e,t,o,n,r){if(H(o,Rt)){this.checkPropertyShape(e,t,o,n,r);return}for(let{item:a}of oe(o,gt)){let i=a instanceof V?a:a instanceof N?b(e,a.subject):void 0;i&&this.checkPropertyShape(e,t,i,n,r)}}qualifiedCycle(e,t,o){let n=(r,a)=>{if(a){let i=R(a);if(o.has(i))return[a.name];let s=b(e,a);if(!s)return;let c=this.qualifiedCycle(e,s,new Set([...o,i]));return c?[a.name,...c]:void 0}return r?this.qualifiedCycle(e,r,o):void 0};if(H(t,ne)){let r=n(C(t,ne),E(t,ne));if(r)return r}for(let{item:r}of oe(t,gt)){let a=r instanceof V?n(r,void 0):r instanceof N?n(void 0,r.subject):void 0;if(a)return a}}pushCycle(e,t,o){o.push(this.err(e,"qualifiedValueShape","Error",`sh:qualifiedValueShape on '${e}' leads back to a shape already being checked (${t.join(" -> ")}); recursive shapes are not evaluated.`,"Break the cycle: a qualified value shape must not reference, directly or through other shapes, a shape that contains it."))}isDatatypeProperty(e,t,o){let n=q(e,t);return n==="DatatypeProperty"?!0:n==="ObjectProperty"?!1:o?this.resolvesToDatatype(e,o):!1}isInstanceOf(e,t,o){let n=b(e,t);if(!n)return!1;let r=R(o);return pe(n).some(a=>R(a)===r||W(e,a).some(i=>R(i)===r))}checkOrder(e,t,o,n,r,a){o!==void 0&&r!==void 0&&o>r&&a.push(this.err(e,`${t}/${n}`,"Error",`${t} (${o}) exceeds ${n} (${r}) on '${e}'.`,`Set ${t} <= ${n}.`))}resolvesToClass(e,t){let o=b(e,t);return o?j.isClassType(lo(o)):!1}resolvesToDatatype(e,t){if(t.publisher===et&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let o=b(e,t);return o?j.isDatatypeType(lo(o)):!1}isNumericDatatypeRange(e){return!e||e.publisher===et&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===et&&e.package_==="core-xsd"&&rr.has(e.name)}err(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=o,i.entityName=e,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function ie(p){return typeof p=="number"?p:void 0}function X(p){return`${p.publisher}/${p.package_}/${p.name}`}function ar(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var mo={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},ir=p=>p,Ye=class{ruleName="OwlOneOf";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=sr(e);if(!a)return n;for(let i of r){if(!(i instanceof k)||i.namespace!==a||!H(i,mo))continue;let s=T(i,mo);if(s.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 c of s)if(c instanceof tt)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(c.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(c.value)));else if(c instanceof N){let l=b(r,c.subject);l&&j.isSchemaDefinitionType(ir(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${c.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${c.subject.publisher}/${c.subject.package_}/${c.subject.name}`))}}return n}err(e,t,o,n,r){let a=new d;return a.ruleType=this.ruleName,a.severity=t,a.entityName=e,a.propertyName="oneOf",a.message=o,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function sr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var cr=p=>p,pr=new Dt("kanonak.org","core-rdf","Resource"),Ge=class{ruleName="DiamondNameClash";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=lr(e);if(!a)return n;let i=xt(r);for(let s of r){if(!(s instanceof k)||s.namespace!==a||!j.isClassType(cr(s)))continue;let c=x(s);if(!c)continue;let l=W(r,c),m=R(c),u=new Set(l.map(h=>R(h)));u.delete(m),u.delete(R(pr));let f=new Map;for(let h of wt(r,c)){if(!h.domains.some(D=>u.has(R(D))))continue;let g=f.get(h.uri.name);g?g.push(h):f.set(h.uri.name,[h])}for(let[h,y]of f){if(y.length<2)continue;let g=I=>_t(i,l,I.uri)?.cardinality,D=new Set(y.map(I=>I.range?R(I.range):void 0).filter(I=>I!==void 0)),P=new Set(y.map(g).filter(I=>I!==void 0));D.size<=1&&P.size<=1||n.push(this.toError(s.name,h,y,g))}}return n}toError(e,t,o,n){let r=s=>{let c=`${s.uri.publisher}/${s.uri.package_}/${s.uri.name}`,l=s.range?`${s.range.publisher}/${s.range.package_}/${s.range.name}`:"no range",m=n(s);return`${c} (range ${l}${m?`, ${m}`:""})`},a=o.map(r).join("; "),i=new d;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=t,i.actualValue=a,i.message=`Class '${e}' inherits ${o.length} distinct properties named '${t}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${t}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${t}':
|
|
64
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,s}};function Fn(p,e){let t=C(p,e);return t?[t]:T(p,e).filter(o=>o instanceof V)}function Hn(p,e){let t=[];for(let o of e)if(o instanceof V)t.push(o);else if(o instanceof N){let n=g(p,o.subject);n&&t.push(n)}return t}function Wn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var et="kanonak.org",Yn="core-shacl",_=p=>({publisher:et,package_:Yn,name:p}),po=_("NodeShape"),lo=_("PropertyShape"),Gn=_("targetClass"),Rt=_("property"),bt=_("path"),zn=_("minCount"),Xn=_("maxCount"),Zn=_("datatype"),Qn=_("class"),mo=_("in"),Jn=_("pattern"),er=_("flags"),tr=_("minLength"),or=_("maxLength"),nr=_("minInclusive"),rr=_("maxInclusive"),ar={publisher:et,package_:"core-rdf",name:"range"},ir=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),uo=p=>p,We=class{ruleName="ShaclShape";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=sr(e);if(!a)return n;let i=new Set;for(let s of r){if(!(s instanceof f)||s.namespace!==a||!A(s,po))continue;let c=E(s,Gn);c?this.resolvesToClass(r,c)||n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' sh:targetClass '${c.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(c))):n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let{item:l}of oe(s,Rt)){let m;if(l instanceof V)m=l;else if(l instanceof N){let u=g(r,l.subject);u&&(m=u,i.add(k(l.subject)))}m&&this.checkPropertyShape(r,s.name,m,c??void 0,n)}}for(let s of r){if(!(s instanceof f)||s.namespace!==a||!A(s,lo))continue;let c=x(s);c&&i.has(k(c))||this.checkPropertyShape(r,s.name,s,void 0,n)}return n}checkPropertyShape(e,t,o,n,r){let a=E(o,bt);if(!a){r.push(this.err(t,"property.path","Error",`A PropertyShape on '${t}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=g(e,a),s=i?Q(e,i):!1;s?n&&(Y(e,n,a).ok||r.push(this.err(t,"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.`,X(a)))):r.push(this.err(t,"property.path","Error",`sh:path '${a.name}' on '${t}' does not resolve to a property.`,"Reference a defined or imported property.",X(a)));let c=E(o,Zn),l=E(o,Qn);c&&l&&r.push(this.err(t,"property","Error",`A PropertyShape on '${t}' 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.")),c&&!this.resolvesToDatatype(e,c)&&r.push(this.err(t,"datatype","Error",`sh:datatype '${c.name}' on '${t}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",X(c))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(t,"class","Error",`sh:class '${l.name}' on '${t}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",X(l)));let m=ie(ee(o,zn)),u=ie(ee(o,Xn));this.checkOrder(t,"minCount",m,"maxCount",u,r);let y=ie(ee(o,tr)),h=ie(ee(o,or));this.checkOrder(t,"minLength",y,"maxLength",h,r);let b=ie(ee(o,nr)),K=ie(ee(o,rr));this.checkOrder(t,"minInclusive",b,"maxInclusive",K,r);let $=te(o,Jn);if($!==void 0){let D=te(o,er);try{new RegExp($,D)}catch{r.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(D!==void 0?` (with flags '${D}')`:"")+`: ${$}`,"Provide a valid regular expression and flags.",$))}}if(H(o,mo)&&oe(o,mo).length===0&&r.push(this.err(t,"in","Error",`sh:in on '${t}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),s&&n){let G=Y(e,n,a).descriptor;G&&(($!==void 0||y!==void 0||h!==void 0)&&G.kind==="object"&&r.push(this.err(t,"pattern/minLength/maxLength","Warning",`String facets on '${t}' 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.",X(a))),(b!==void 0||K!==void 0)&&!this.isNumericDatatypeRange(G.range)&&r.push(this.err(t,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${t}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",X(a))))}let w=i&&s?E(i,ar):void 0,I=i&&s?this.isDatatypeProperty(e,i,w):!1;if(H(o,ct)){let D=E(o,ct);I?r.push(this.err(t,"hasValue","Error",`sh:hasValue on '${t}' constrains '${a.name}', a datatype property; a literal hasValue is not supported yet.`,"Use sh:hasValue on an object property, naming an individual; literal values arrive with structured literals (typescript#115).",D?X(D):void 0)):!D||!g(e,D)?r.push(this.err(t,"hasValue","Error",`sh:hasValue${D?` '${D.name}'`:""} on '${t}' does not resolve to an individual.`,"Name a defined or imported individual.",D?X(D):void 0)):w&&this.resolvesToClass(e,w)&&!this.isInstanceOf(e,D,w)&&r.push(this.err(t,"hasValue","Warning",`sh:hasValue '${D.name}' on '${t}' is not an instance of '${w.name}', the range of '${a.name}'; no well-typed value can equal it.`,`Name an instance of '${w.name}'.`,X(D)))}this.checkQualified(e,t,o,w,r)}checkQualified(e,t,o,n,r){let a=H(o,ne),i=[{name:"qualifiedMinCount",uri:jt,value:void 0},{name:"qualifiedMaxCount",uri:Ot,value:void 0}],s=!1;for(let b of i){if(!H(o,b.uri))continue;s=!0;let K=ie(ee(o,b.uri));K===void 0||!Number.isInteger(K)||K<0?r.push(this.err(t,b.name,"Error",`sh:${b.name} on '${t}' must be a non-negative integer.`,`Set sh:${b.name} to 0 or more.`)):b.value=K}if(!a&&!s)return;if(!a){r.push(this.err(t,"qualifiedValueShape","Error",`A qualified count on '${t}' has no sh:qualifiedValueShape; it counts values conforming to nothing.`,"Add sh:qualifiedValueShape naming the shape the counted values conform to."));return}s||r.push(this.err(t,"qualifiedValueShape","Error",`sh:qualifiedValueShape on '${t}' has no sh:qualifiedMinCount or sh:qualifiedMaxCount; it bounds nothing.`,"Add sh:qualifiedMinCount and/or sh:qualifiedMaxCount.")),this.checkOrder(t,"qualifiedMinCount",i[0].value,"qualifiedMaxCount",i[1].value,r);let c=n&&this.resolvesToClass(e,n)?n:void 0,l=`${t} (qualified shape)`,m=C(o,ne);if(m){this.checkNestedShape(e,l,m,c,r);let b=this.qualifiedCycle(e,m,new Set);b&&this.pushCycle(t,b,r);return}let u=E(o,ne),y=u?g(e,u):void 0;if(!u||!y||!(A(y,po)||A(y,lo)||H(y,bt))){r.push(this.err(t,"qualifiedValueShape","Error",`sh:qualifiedValueShape${u?` '${u.name}'`:""} on '${t}' does not resolve to a shape.`,"Reference a NodeShape or PropertyShape, or write the shape inline.",u?X(u):void 0));return}let h=this.qualifiedCycle(e,y,new Set([k(u)]));h&&this.pushCycle(t,[u.name,...h],r)}checkNestedShape(e,t,o,n,r){if(H(o,bt)){this.checkPropertyShape(e,t,o,n,r);return}for(let{item:a}of oe(o,Rt)){let i=a instanceof V?a:a instanceof N?g(e,a.subject):void 0;i&&this.checkPropertyShape(e,t,i,n,r)}}qualifiedCycle(e,t,o){let n=(r,a)=>{if(a){let i=k(a);if(o.has(i))return[a.name];let s=g(e,a);if(!s)return;let c=this.qualifiedCycle(e,s,new Set([...o,i]));return c?[a.name,...c]:void 0}return r?this.qualifiedCycle(e,r,o):void 0};if(H(t,ne)){let r=n(C(t,ne),E(t,ne));if(r)return r}for(let{item:r}of oe(t,Rt)){let a=r instanceof V?n(r,void 0):r instanceof N?n(void 0,r.subject):void 0;if(a)return a}}pushCycle(e,t,o){o.push(this.err(e,"qualifiedValueShape","Error",`sh:qualifiedValueShape on '${e}' leads back to a shape already being checked (${t.join(" -> ")}); recursive shapes are not evaluated.`,"Break the cycle: a qualified value shape must not reference, directly or through other shapes, a shape that contains it."))}isDatatypeProperty(e,t,o){let n=q(e,t);return n==="DatatypeProperty"?!0:n==="ObjectProperty"?!1:o?this.resolvesToDatatype(e,o):!1}isInstanceOf(e,t,o){let n=g(e,t);if(!n)return!1;let r=k(o);return pe(n).some(a=>k(a)===r||W(e,a).some(i=>k(i)===r))}checkOrder(e,t,o,n,r,a){o!==void 0&&r!==void 0&&o>r&&a.push(this.err(e,`${t}/${n}`,"Error",`${t} (${o}) exceeds ${n} (${r}) on '${e}'.`,`Set ${t} <= ${n}.`))}resolvesToClass(e,t){let o=g(e,t);return o?j.isClassType(uo(o)):!1}resolvesToDatatype(e,t){if(t.publisher===et&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let o=g(e,t);return o?j.isDatatypeType(uo(o)):!1}isNumericDatatypeRange(e){return!e||e.publisher===et&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===et&&e.package_==="core-xsd"&&ir.has(e.name)}err(e,t,o,n,r,a){let i=new d;return i.ruleType=this.ruleName,i.severity=o,i.entityName=e,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function ie(p){return typeof p=="number"?p:void 0}function X(p){return`${p.publisher}/${p.package_}/${p.name}`}function sr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var fo={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},cr=p=>p,Ye=class{ruleName="OwlOneOf";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=pr(e);if(!a)return n;for(let i of r){if(!(i instanceof f)||i.namespace!==a||!H(i,fo))continue;let s=T(i,fo);if(s.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 c of s)if(c instanceof ot)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(c.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(c.value)));else if(c instanceof N){let l=g(r,c.subject);l&&j.isSchemaDefinitionType(cr(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${c.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${c.subject.publisher}/${c.subject.package_}/${c.subject.name}`))}}return n}err(e,t,o,n,r){let a=new d;return a.ruleType=this.ruleName,a.severity=t,a.entityName=e,a.propertyName="oneOf",a.message=o,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function pr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var lr=p=>p,mr=new Dt("kanonak.org","core-rdf","Resource"),Ge=class{ruleName="DiamondNameClash";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new O().parseKanonaks(t),a=ur(e);if(!a)return n;let i=xt(r);for(let s of r){if(!(s instanceof f)||s.namespace!==a||!j.isClassType(lr(s)))continue;let c=x(s);if(!c)continue;let l=W(r,c),m=k(c),u=new Set(l.map(h=>k(h)));u.delete(m),u.delete(k(mr));let y=new Map;for(let h of Pt(r,c)){if(!h.domains.some($=>u.has(k($))))continue;let K=y.get(h.uri.name);K?K.push(h):y.set(h.uri.name,[h])}for(let[h,b]of y){if(b.length<2)continue;let K=I=>_t(i,l,I.uri)?.cardinality,$=new Set(b.map(I=>I.range?k(I.range):void 0).filter(I=>I!==void 0)),w=new Set(b.map(K).filter(I=>I!==void 0));$.size<=1&&w.size<=1||n.push(this.toError(s.name,h,b,K))}}return n}toError(e,t,o,n){let r=s=>{let c=`${s.uri.publisher}/${s.uri.package_}/${s.uri.name}`,l=s.range?`${s.range.publisher}/${s.range.package_}/${s.range.name}`:"no range",m=n(s);return`${c} (range ${l}${m?`, ${m}`:""})`},a=o.map(r).join("; "),i=new d;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=t,i.actualValue=a,i.message=`Class '${e}' inherits ${o.length} distinct properties named '${t}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${t}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${t}':
|
|
65
65
|
\u2022 rename one of the properties, or
|
|
66
66
|
\u2022 re-domain one so it is not inherited by '${e}', or
|
|
67
67
|
\u2022 restructure the hierarchy so '${e}' inherits only one '${t}', or
|
|
68
|
-
\u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function
|
|
68
|
+
\u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function ur(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Kt=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e,t={}){this.parser=e??new Vt,this.documentRules=[new fe,new ye,new he,new ke,new ge],this.repositoryRules=[new Re,new be,new Ke,new de({offline:t.offline}),new Ve,new Ee,new ve,new De,new Se,new $e,new Ie,new je,new Oe,new Pe,new we,new Ue,new Ae,new Ne,new Te,new xe,new _e,new Be,new Je,new Me,new Le,new qe,new We,new Ye,new Ge]}async validateAsync(e,t,o){let n=new le;for(let r of this.documentRules)try{let a=r.validate(e);this.addErrorsToResult(n,a)}catch(a){let i=new d;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(t){let r=[],a=o??new re(new me(e,t)),i=a.repository;for(let s of this.repositoryRules)try{let c=await s.validateAsync(e,i,a);this.addErrorsToResult(n,c)}catch(c){let l=c instanceof Error?c.message:String(c);r.push({ruleName:s.ruleName,cause:l})}if(r.length>0){let s=new Map;for(let{ruleName:c,cause:l}of r){let m=s.get(l);m?m.push(c):s.set(l,[c])}for(let[c,l]of s){let m=new d;m.ruleType=l[0],m.severity="Error",l.length===1?m.message=`Validation rule '${l[0]}' failed: ${c}`:m.message=`${c} (affects ${l.length} rules: ${l.join(", ")})`,n.errors.push(m)}}}return n.isValid=n.errors.length===0,n}async validateDocumentsAsync(e,t){let o=t instanceof re?t:new re(t),n=[];for(let r of e){let a=await this.validateAsync(r,o.repository,o);n.push({document:r,result:a})}return n}async validateYamlAsync(e,t,o){let n=this.parser.parseWithErrors(e);if(!n.isValid){let r=new le;r.isValid=!1;for(let a of n.errors){let i=new d;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,t,o)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let t=this.documentRules.findIndex(o=>o instanceof e);t>=0&&this.documentRules.splice(t,1)}removeRepositoryRule(e){let t=this.repositoryRules.findIndex(o=>o instanceof e);t>=0&&this.repositoryRules.splice(t,1)}addErrorsToResult(e,t){for(let o of t)o.severity==="Error"?e.errors.push(o):o.severity==="Info"?this.includeWarnings&&e.infos.push(o):this.includeWarnings&&e.warnings.push(o)}};export{le as a,R as b,d as c,ut as d,re as e,Bt as f,qt as g,de as h,fe as i,ye as j,he as k,ke as l,ge as m,Re as n,be as o,Ke as p,Ve as q,Ee as r,ve as s,De as t,Se as u,$e as v,Ie as w,je as x,Oe as y,Pe as z,we as A,Ue as B,Ae as C,Ne as D,Te as E,xe as F,_e as G,Le as H,Me as I,Be as J,qe as K,We as L,Ye as M,Ge as N,Kt as O};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export type { MarkdownLink } from './statements/index.js';
|
|
|
16
16
|
export { Statement, ScalarStatement, StringStatement, NumberStatement, BooleanStatement, ReferenceStatement, EmbeddedStatement, ListStatement, MarkdownStatement } from './statements/index.js';
|
|
17
17
|
export { extractMarkdownLinks, findMalformedReferences, type RawMarkdownLink, type MalformedMarkdownLink, } from './parsing/extractMarkdownLinks.js';
|
|
18
18
|
export { OntologyValidationResult, OntologyValidationError, ValidationSeverity, ValidationContext, ValidationCache, KanonakObjectValidator, NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, PackageHeaderRule, EmbeddedKanonakTypeRule, ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, UnresolvedPredicateRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyKindRangeConsistencyRule, ReservedNameShadowRule, ClassDefinitionRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, TxExpressionCompilesRule, SequenceNarrativeRule, LinkTargetRule, LookBandPathRule, TxExpressionPathRule, ShaclShapeRule, OwlOneOfRule, DiamondNameClashRule } from './validation/index.js';
|
|
19
|
-
export { scopeFromRepositoryAsync, scopeFromClosureAsync, scopeFromCatalog, scopeFromDocumentAsync, buildShapesModel, buildKeysModel, lowerConstraint, foldFlagsIntoPattern, evaluateConformance, buildReportPackageAsync, SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, } from './shacl/index.js';
|
|
20
|
-
export type { ConformanceScope, ShaclNodeShapeModel, ShaclClassKeyModel, ShaclPropertyConstraint, ShaclNodeKind, ShaclSeverity, LoweredCheck, LoweredExprNode, ShaclConformanceResult, ShaclFinding, } from './shacl/index.js';
|
|
19
|
+
export { scopeFromRepositoryAsync, scopeFromClosureAsync, scopeFromCatalog, scopeFromDocumentAsync, buildShapesModel, buildKeysModel, lowerConstraint, foldFlagsIntoPattern, evaluateConformance, buildReportPackageAsync, SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, SH_COMP_MIN_COUNT, SH_COMP_MAX_COUNT, SH_COMP_DATATYPE, SH_COMP_CLASS, SH_COMP_IN, SH_COMP_PATTERN, SH_COMP_MIN_LENGTH, SH_COMP_MAX_LENGTH, SH_COMP_MIN_INCLUSIVE, SH_COMP_MAX_INCLUSIVE, SH_COMP_NODE_KIND, SH_COMP_CLOSED, SH_COMP_HAS_VALUE, SH_COMP_QUALIFIED_MIN_COUNT, SH_COMP_QUALIFIED_MAX_COUNT, SH_COMP_HAS_KEY, } from './shacl/index.js';
|
|
20
|
+
export type { ConformanceScope, ScopeLinks, ShaclNodeShapeModel, ShaclClassKeyModel, ShaclPropertyConstraint, ShaclNodeKind, ShaclSeverity, LoweredCheck, LoweredExprNode, ShaclConformanceResult, ShaclFinding, } from './shacl/index.js';
|
|
21
21
|
export type { IKanonakObjectValidator, DocumentValidationResult, IDocumentValidationRule, IRepositoryValidationRule } from './validation/index.js';
|
|
22
22
|
export type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
23
23
|
export type { IKanonakParser } from '@kanonak-protocol/types/document/parsing';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as zt,b as Xt,c as Yt,d as Qt,e as z}from"./chunk-DQGXJDQU.js";import{a as to,b as ro,c as ao}from"./chunk-BDTJIUS4.js";import{a as qt,b as Bt,c as Gt,d as sa,e as ca,f as da,g as ua,h as la,i as pa,j as Ze,k as fa,l as en,m as nn,n as ma,o as ha,p as Sa,q as ve,r as ga,s as on}from"./chunk-TF23WBSZ.js";import{a as ka}from"./chunk-IWPCPQQY.js";import{a as oa,b as ta,c as ra,d as ne,e as aa,f as ia,g as Je,h as ya,i as Ea,j as Ca,k as ba,l as _a}from"./chunk-FS7UGDEX.js";import{a as Wo,b as qo,c as Bo,d as Go,e as zo,f as mt,g as ht,h as St,i as gt}from"./chunk-K76UUREI.js";import{a as Zo,b as et,c as nt,d as ot,e as tt,f as rt,g as Me,h as Ue,i as $e,j as ct,k as dt,m as ut,n as Sn,o as gn,p as kn,q as yn,r as En,s as Cn,t as lt,u as ft}from"./chunk-Z2444SWM.js";import{a as Zt,b as er,c as nr,d as or,e as tr,f as rr}from"./chunk-OHF4RIKS.js";import{a as ar,b as sr}from"./chunk-LIN5SG5I.js";import{a as pt}from"./chunk-SC5M74NM.js";import{A as xr,B as Ir,C as Lr,D as Mr,E as Ur,F as $r,G as Vr,H as Hr,I as Xr,J as Yr,K as Qr,L as Jr,M as Zr,N as ea,O as na,a as cr,b as dr,c as ur,d as lr,e as pr,f as Jn,g as Zn,h as fr,i as mr,j as hr,k as Sr,l as gr,m as kr,n as yr,o as Er,p as Cr,q as br,r as _r,s as Pr,t as Rr,u as vr,v as wr,w as Kr,x as Or,y as Nr,z as Ar}from"./chunk-426MUUGB.js";import{a as Yn,b as Qn}from"./chunk-VJUZKHQU.js";import{c as eo,d as jr,e as Tr,f as Dr,g as Fr,i as Wr,j as qr,m as Br,o as Qe,q as no,s as oo,u as Gr,v as zr}from"./chunk-CPENAANM.js";import"./chunk-QHABFCRC.js";import{a as Xo,b as Yo,c as Qo,d as Jo,e as L}from"./chunk-5FVUBF7N.js";import{a as Le}from"./chunk-WXXZOJ4O.js";import{a as Xe,g as T,h as Ye,i as Ft,j as Wt,k as U}from"./chunk-SBWD7EOG.js";import{a as X}from"./chunk-5ZRVFYCP.js";import{a as ir}from"./chunk-PEJALHXK.js";import{$ as Re,A as Un,B as $n,C as Vn,D as Hn,E as jn,F as Tn,G as Dn,H as Fn,I as Wn,J as qn,K as De,L as Bn,M as Gn,N as zn,O as me,P as he,Q as Se,R as ge,S as ke,T as ye,U as Ee,V as Ce,W as be,X as _e,Y as Pe,Z,_ as Xn,a as Nt,aa as Fe,b as At,ba as We,c as Q,ca as W,d as It,da as H,e as Lt,ea as j,fa as q,g as Mt,ga as qe,h as le,i as pe,j as _n,ja as Ut,k as J,ka as $t,l as fe,m as Pn,ma as Vt,n as Rn,o as je,oa as Ht,p as vn,pa as E,q as wn,qa as Ge,r as Kn,ra as jt,s as On,sa as ze,t as Te,u as Nn,v as An,va as Tt,w as xn,wa as Dt,x as In,xa as G,y as Ln,z as Mn}from"./chunk-6WOPXTIL.js";import{B as F,C as A,D as ue,E as k,F as Y,G as He,H as ee,I as B,K as Be,a as kt,b as yt,c as g,d as M,e as O,f as Et,g as Ct,h as bt,i as _t,j as Pt,k as Rt,l as vt,m as wt,n as Kt,o as Ot,p,s as xt,t as D,u as Ve,v as bn,w as de,y as N}from"./chunk-LK5SHY4B.js";import"./chunk-F67UH4FD.js";import{a as Mo,b as Uo,c as ce,d as $o,e as V,f as Vo,g as Ho,h as jo,i as To,j as Do,k as Fo,l as it,m as st}from"./chunk-GGK6A6QK.js";import{a as at}from"./chunk-FUUTGGJS.js";import{a as Jt}from"./chunk-ODIECDN7.js";async function io(n){let e=await new U().parseKanonaks(n);return{kind:"merged",catalog:e,reasoning:new z().reasonOver(e)}}async function so(n,e){let t=new Set(n.map(oe)),o=new Set,a=[];if(await Yn(n,e,{onDocument:l=>o.add(oe(l)),onUnresolvedEdge:l=>a.push(l)}),a.length>0){let l=a.map(h=>`${h.fromNamespace} imports ${h.publisher}/${h.packageName} ${h.constraint} (${h.reason})`);throw new Error(`Cannot build the conformance scope: ${a.length} import(s) did not resolve:
|
|
2
2
|
${l.join(`
|
|
3
|
-
`)}`)}let a=new Xn(e,o),d=new Set((await a.getAllDocumentsAsync()).map(We)),i=[...t].filter(l=>!d.has(l));if(i.length>0)throw new Error(`scopeFromClosureAsync: ${i.join(", ")} is not a document of the repository the closure is resolved through.`);let c={},u=await new j().parseKanonaks(a,c),s=new Set(c.authored.filter(l=>l instanceof g&&t.has(l.sourceDoc)).map(X));return{kind:"merged",catalog:u,reasoning:new F().reasonOver(u),focus:s}}function We(n){let e=n.metadata?.namespace_;if(!e)throw new Error("scopeFromClosureAsync: a document has no namespace, so it cannot be identified.");return e.toString()}function io(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function so(n,e){let t=e??new be(new W);return{kind:"standalone",catalog:await new j().parseKanonaks(new Yn(n,t))}}function V(n){return typeof n=="number"?n:void 0}function Ca(n){if(!n)return;let e=p(n);if(e===p(An))return"IRI";if(e===p(On))return"BlankNode";if(e===p(Ln))return"Literal"}function uo(n){if(!n)return;let e=p(n);if(e===p(In))return"Violation";if(e===p(Un))return"Warning";if(e===p(Vn))return"Info"}function lo(n,e,t,o){let r=k(e,_e);if(!r)return;let a={path:r},d=V(A(e,mn)),i=V(A(e,hn));d!==void 0&&(a.minCount=d),i!==void 0&&(a.maxCount=i);let c=V(A(e,En)),u=V(A(e,bn));c!==void 0&&(a.minLength=c),u!==void 0&&(a.maxLength=u);let s=V(A(e,Cn)),l=V(A(e,Rn));s!==void 0&&(a.minInclusive=s),l!==void 0&&(a.maxInclusive=l);let f=ie(e,yn);if(f!==void 0){let h=ie(e,Sn);a.pattern=h!==void 0?{regex:f,flags:h}:{regex:f}}if(T(e,Ke)){let h=[],K=[];for(let{item:E}of Pe(e,Ke))"literal"in E?h.push(E.value):E instanceof x&&K.push(E.subject);h.length>0&&(a.inValues=h),K.length>0&&(a.inRefs=K)}let m=k(e,gn);m&&(a.datatype=m);let v=k(e,kn);v&&(a.classRef=v);let y=Ca(k(e,Nn));y&&(a.nodeKind=y);let P=k(e,zn);if(P&&(a.hasValue=P),T(e,ue)||T(e,Ae)||T(e,Oe)){let h={},K=V(A(e,Ae)),E=V(A(e,Oe));K!==void 0&&(h.minCount=K),E!==void 0&&(h.maxCount=E);let O=Ra(n,e,o);"problem"in O?h.problem=O.problem:h.shape=O.shape,a.qualified=h}let w=ie(e,vn);w!==void 0&&(a.message=w);let _=uo(k(e,xe))??t;return _&&(a.severity=_),a}function Ra(n,e,t){let o=q(e,ue);if(o)return co(n,o,void 0,t);let r=k(e,ue);if(!r)return{problem:"sh:qualifiedValueShape is missing"};let a=p(r);if(t.has(a))return{problem:`sh:qualifiedValueShape '${r.name}' leads back to itself (a cycle through named shapes)`};let d=N(n,r);return d?co(n,d,a,t):{problem:`sh:qualifiedValueShape '${r.name}' does not resolve`}}function co(n,e,t,o){let r=t?new Set([...o,t]):o,a=ae(e,G);if((ae(e,de)||T(e,_e))&&!a){let c=lo(n,e,void 0,r);return c?{shape:{kind:"property",constraint:c}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof g&&!a?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:po(n,e,r)}}}function po(n,e,t){let o=uo(k(e,xe)),r={name:e instanceof g?e.name:"(inline shape)",uri:e instanceof g?S(e):void 0,targetClass:k(e,pn),targetNodes:D(e,Pn),targetSubjectsOf:D(e,wn),targetObjectsOf:D(e,_n),closed:A(e,Kn)===!0,ignoredProperties:[],severity:o,properties:[]};r.ignoredProperties.push(...D(e,xn));for(let{item:a}of Pe(e,fn)){let d;if(a instanceof U?d=a:a instanceof x&&(d=N(n,a.subject)),!d)continue;let i=lo(n,d,o,t);i&&r.properties.push(i)}return r}function me(n){let e=[];for(let t of n){if(!(t instanceof g)||!ae(t,G))continue;let o=S(t);e.push(po(n,t,new Set(o?[p(o)]:[])))}return e}function he(n){let e=new Map;for(let t of n)if(t instanceof g)for(let o of un(t,Le)){let r=S(t);if(!r)throw new Error(`owl.hasKey on '${t.namespace}/${t.name}': the class has no resolvable URI.`);if(o.length===0)throw new Error(`owl.hasKey on '${t.name}' lists no properties; a key needs at least one.`);let a=o.map(({item:d})=>{let i=d instanceof x?N(n,d.subject):void 0;if(!i||!Ue(n,i)){let c=d instanceof x?`'${p(d.subject)}'`:"a value that is not a reference";throw new Error(`owl.hasKey on '${t.name}' lists ${c}, which is not a property defined in scope; a key lists properties.`)}return d.subject});e.set(`${p(r)}|${a.map(p).join(",")}`,{classUri:r,className:t.name,properties:a})}return[...e.values()]}var C="kanonak.org/transformations",Z="values";var ge="allowed",Be="expected",b=n=>({type:`${C}/VarRef`,varName:n}),qe=n=>({type:`${C}/IntegerLiteral`,integerLiteral:n}),va=n=>({type:`${C}/DecimalLiteral`,decimalLiteral:n}),fo=n=>Number.isInteger(n)?qe(n):va(n),mo=n=>({type:`${C}/Count`,source:n}),ho=(n,e)=>({type:`${C}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),go=(n,e)=>({type:`${C}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ge(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(a=>!t.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function ke(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:ho(mo(b(Z)),qe(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:go(mo(b(Z)),qe(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${C}/Contains`,haystack:b(Z),needle:b(Be)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${C}/Contains`,haystack:b(ge),needle:b("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${C}/Matches`,matchSource:b("v"),pattern:Ge(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${C}/Matches`,matchSource:b("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${C}/Matches`,matchSource:b("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:ho(b("v"),fo(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:go(b("v"),fo(n.maxInclusive))}),e}import{evaluate as wa,ExpressionError as _a}from"@kanonak-protocol/expression";function So(n,e){let t=ko(e)?e:me(e),o=[],r=n.catalog.filter(i=>i instanceof g).map(ye),a=new Map;Ka(r,a);let d={scope:n,membership:new Ye(n),embeddedFocus:a};for(let i of t)for(let c of xa(d,i,r))ze(n,c)&&bo(d,i,c,o);if(!ko(e))for(let i of he(e))Na(d,i,r,o);return{conforms:!o.some(i=>i.severity==="Violation"),results:o}}function ko(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function Eo(n){let e=n.predicate;return e instanceof x?e:void 0}function ze(n,e){return!n.focus||e.subject!==void 0&&n.focus.has(e.subject)}function ye(n){let e=X(n);return{node:n,key:e,uri:S(n),subject:e,label:n.name}}function Xe(n,e,t){return{node:n,key:e,subject:t,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Ka(n,e){for(let t of n)Ve([t.node],({kanonak:o,address:r})=>{o instanceof U&&!e.has(o)&&e.set(o,Xe(o,r,t.subject))})}var Ye=class{constructor(e){this.scope=e}scope;ancestors=new Map;isInstance(e,t){let o=p(t);return e.some(r=>p(r)===o||this.ancestorsOf(r).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${p(e)}@${$(e.version)}`:p(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ie(this.scope.catalog,e).map(r=>p(r))),this.ancestors.set(t,o)),o}};function xa(n,e,t){let{scope:o}=n,r=new Map,a=i=>{r.set(i.key,i)},d=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let i=e.targetClass;for(let c of d())n.membership.isInstance(H(c.node),i)&&a(c)}for(let i of e.targetNodes){let c=N(o.catalog,i);c instanceof g&&a(ye(c))}for(let i of e.targetSubjectsOf){let c=p(i);for(let u of d())u.node.statement.some(s=>{let l=Eo(s);return l&&p(l.subject)===c})&&a(u)}for(let i of e.targetObjectsOf)for(let c of d())for(let u of Q(c.node,i,o.catalog,c.key))u.kind==="subject"?a(ye(u.node)):u.kind==="embedded"&&a(n.embeddedFocus.get(u.node)??Xe(u.node,u.address,c.subject));return[...r.values()]}function Na(n,e,t,o){let r=new Map;for(let c of t)n.membership.isInstance(H(c.node),e.classUri)&&r.set(c.key,c);let a=[];for(let c of[...r.values()].sort((u,s)=>u.key<s.key?-1:u.key>s.key?1:0)){let u=e.properties.map(s=>Aa(n,c,s));u.every(s=>s.size>0)&&a.push({focus:c,values:u})}let d=new Map;a.forEach(({values:c},u)=>{for(let s of c[0].keys()){let l=d.get(s);l?l.push(u):d.set(s,[u])}});let i=new Set;for(let c of d.values())for(let u=0;u<c.length;u++)for(let s=u+1;s<c.length;s++){let l=`${c[u]}:${c[s]}`;if(i.has(l))continue;let f=a[c[u]],m=a[c[s]],v=f.values.map((_,h)=>[..._.keys()].find(K=>m.values[h].has(K)));if(v.some(_=>_===void 0))continue;i.add(l);let[y,P]=ze(n.scope,f.focus)?[f.focus,m.focus]:ze(n.scope,m.focus)?[m.focus,f.focus]:[void 0,void 0];if(!y||!P)continue;let w=e.properties.map((_,h)=>`${_.name} = ${f.values[h].get(v[h])}`).join(", ");o.push({focusNode:y.key,focusUri:y.uri,valueRef:P.uri,constraintComponent:pe,severity:"Violation",message:`'${y.label}' and '${P.label}' are distinct instances of ${e.className} with the same key (${w}); its owl.hasKey makes the key unique.`})}}function Aa(n,e,t){let o=new Map;for(let r of Q(e.node,t,n.scope.catalog,e.key))switch(r.kind){case"subject":case"unresolved":o.set(`ref:${p(r.uri)}`,r.uri.name);break;case"literal":o.set(`${typeof r.value}:${String(r.value)}`,JSON.stringify(r.value));break;case"embedded":break}return o}function Oa(n,e,t){return e.node?Q(e.node,t,n.scope.catalog,e.key).map(o=>La(n,o,e.subject)):[]}function La(n,e,t){switch(e.kind){case"subject":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let o=n.embeddedFocus.get(e.node)??Xe(e.node,e.address,t);return{kernel:{ref:o.key},kind:"embedded",embedded:o}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function bo(n,e,t,o){for(let r of e.properties)Ro(n,e,t,r,o);e.closed&&Wa(e,t,o)}function Qe(n,e,t,o,r={},a){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:a??Co(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...r}}function Co(n){return n.severity??"Violation"}var Ia={minCount:$n,maxCount:Mn,hasValue:le,in:Tn,pattern:Hn,minLength:Fn,maxLength:Wn,minInclusive:qn,maxInclusive:Bn};function Ro(n,e,t,o,r){let a=Oa(n,t,o.path),d=o.severity??Co(e),i=o.path.name,c=[...(o.inValues??[]).map(s=>typeof s=="boolean"?s?1:0:s),...(o.inRefs??[]).map(s=>({ref:p(s)}))],u=(s,l,f)=>{let m=Qe(e,t,s,o.message??l,{resultPath:o.path,value:f?.literal,valueRef:f?.ref},d);return r.push(m),m};for(let s of ke(o)){let l=Ia[s.component];if(s.per==="node"){let f={[Z]:a.map(m=>m.kernel),[ge]:c};o.hasValue&&(f[Be]={ref:p(o.hasValue)}),yo(s,f)||u(l,Ua(s,i,o,a.length));continue}for(let f of a){if((s.component==="pattern"||s.component==="minLength"||s.component==="maxLength")&&f.kind!=="string"){u(l,`'${i}' value is not a string; ${s.component} applies to string values.`,f);continue}yo(s,{v:f.kernel,[ge]:c})||u(l,Da(s,i,o,f),f)}}if(o.nodeKind)for(let s of a)Ta(o.nodeKind,s)||u(Gn,`'${i}' value is ${s.kind}; nodeKind requires ${o.nodeKind}.`,s);if(o.datatype)for(let s of a){let l=Ha(o.datatype,s);l&&u(jn,`'${i}' ${l}`,s)}if(o.classRef)for(let s of a){let l=Fa(n,o.classRef,s);l&&u(Dn,`'${i}' ${l}`,s)}o.qualified&&Va(n,o,a,i,u)}function Ua(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?p(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Va(n,e,t,o,r){let a=e.qualified,d=a.maxCount!==void 0?Y:z,i=(u,s)=>{vo.add(r(d,u,s))};if(!a.shape){i(`'${o}' qualified value shape cannot be evaluated: ${a.problem??"it could not be built"}.`);return}let c=0;for(let u of t){let s=u.ref?p(u.ref):u.embedded?u.embedded.label:JSON.stringify(u.literal),l=$a(n,u);if(!l){i(`'${o}' value ${s} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,u);continue}let f=ja(n,a.shape,l);if(f.kind==="undecided"){i(`'${o}' value ${s}: whether it conforms to the qualified shape cannot be decided \u2014 ${f.reason}`,u);continue}f.kind==="conforms"&&c++}a.minCount!==void 0&&c<a.minCount&&r(z,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMinCount is ${a.minCount}.`),a.maxCount!==void 0&&c>a.maxCount&&r(Y,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMaxCount is ${a.maxCount}.`)}function $a(n,e){switch(e.kind){case"reference":return e.subject?ye(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Ma={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},vo=new WeakSet;function ja(n,e,t){let o=[];e.kind==="property"?Ro(n,Ma,t,e.constraint,o):bo(n,e.shape,t,o);let r=o.find(a=>vo.has(a));return r?{kind:"undecided",reason:r.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Da(n,e,t,o){let r=o.ref?p(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function yo(n,e){let t=o=>{let r=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new _a(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return wa(n.expr,void 0,t)===1}function Ta(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Ha(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=$e(n);if(t!==void 0)switch(t){case M.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case M.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case M.Decimal:case M.Double:case M.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Fa(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let r=H(t.embedded.node);return r.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(r,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let o=t.subject;return o?n.membership.isInstance(H(o),e)?void 0:`value ${p(t.ref)} is not an instance of ${e.name}.`:`value ${p(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Wa(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(a=>p(a.path)),...n.ignoredProperties.map(a=>p(a))]),r=new Set;for(let a of e.node.statement){let d=Eo(a);if(!d)continue;let i=p(d.subject);o.has(i)||r.has(i)||(r.add(i),t.push(Qe(n,e,Ne,`'${e.label}' carries undeclared property '${d.subject.name}' (closed shape).`,{resultPath:d.subject})))}for(let a of e.node.unresolvedPredicates)r.has(a.key)||(r.add(a.key),t.push(Qe(n,e,Ne,`'${e.label}' carries unresolvable property '${a.key}' (closed shape).`,{value:a.key})))}var qa="1.1.0",Ba=new Set([le,z,Y].map(n=>n.name)),Ga=new Set([pe].map(n=>n.name));function za(n){let e=new Set(n.results.map(t=>t.constraintComponent.name));return[...e].some(t=>Ga.has(t))?"1.3.0":[...e].some(t=>Ba.has(t))?"1.2.0":qa}async function Po(n){let e=new J(n.repository),t=e.imports(),o=t.ensure(se,ce,za(n.result),"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,$(i.version),i.package_)}.${i.name}`:c,a={},d=[];return n.result.results.forEach((i,c)=>{let u=`result-${c+1}`;d.push(u);let s={type:`${o}.ValidationResult`,[`${o}.focusNode`]:r(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(s[`${o}.resultPath`]=r(i.resultPath,p(i.resultPath))),i.sourceShapeUri&&i.sourceShape!==void 0&&(s[`${o}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?s[`${o}.value`]=r(i.valueRef,p(i.valueRef)):i.value!==void 0&&(s[`${o}.value`]=i.value),a[u]=s}),a.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:n.result.conforms,...d.length>0?{[`${o}.result`]:d}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Zs}from"@kanonak-protocol/types/document/models/enums";import{spawn as Ya}from"child_process";var _o=12e4,Qa=4096,ee=class{argv;interactive;timeoutMs;stderr;now;constructor(e){this.argv=Ko(e.command),this.interactive=e.interactive??!1,this.timeoutMs=e.timeoutMs??_o,this.stderr=e.stderr??process.stderr,this.now=e.nowSeconds??(()=>Date.now()/1e3)}get command(){return this.argv.join(" ")}async get(e){let t=await this.run("get",this.wireRequest("get",e)),o=Te(e,t,this.now());if(!o.ok)throw new I(`credential helper '${this.command}' answered get for ${e.resource} outside the protocol (${o.problem}): ${o.message}`);return o.answer}async erase(e){let t=await this.run("erase",{...this.wireRequest("erase",e),scope:e.scope}),o=He(t);if(!o.ok)throw new I(`credential helper '${this.command}' answered erase for ${e.resource} outside the protocol (${o.problem}): ${o.message}`)}wireRequest(e,t){let o={version:De,operation:e,resource:t.resource,method:t.method};return t.challenges&&(o.challenges=t.challenges),o.interactive=this.interactive,o}run(e,t){let o=`credential helper '${this.command}' ${e}`;return new Promise((r,a)=>{let d=!1,i=m=>{d||(d=!0,m())},c;try{c=Ya(this.argv[0],[...this.argv.slice(1),e],{stdio:["pipe","pipe","pipe"],shell:!1,windowsHide:!0})}catch(m){a(wo(o,m));return}let u=[],s="",l=!1,f=setTimeout(()=>{l=!0,c.kill()},this.timeoutMs);c.stdout.on("data",m=>u.push(m)),c.stderr.on("data",m=>{this.stderr.write(m),s=(s+m.toString("utf8")).slice(-Qa)}),c.on("error",m=>{clearTimeout(f),i(()=>a(wo(o,m)))}),c.on("close",(m,v)=>{clearTimeout(f);let y=s.trim()?`: ${s.trim()}`:"";if(l){i(()=>a(new I(`${o} did not finish within ${Math.round(this.timeoutMs/1e3)}s${y}`)));return}if(m!==0){let w=m!==null?`exit ${m}`:`signal ${v}`;i(()=>a(new I(`${o} failed (${w})${y}`)));return}let P=Buffer.concat(u).toString("utf8").trim();try{let w=JSON.parse(P);i(()=>r(w))}catch{i(()=>a(new I(`${o} exited 0 without printing one JSON answer${y}`)))}}),c.stdin.on("error",()=>{}),c.stdin.end(`${JSON.stringify(t)}
|
|
4
|
-
`)})}};function Ko(n){let e=n.trim().split(/\s+/).filter(t=>t!=="");if(e.length===0)throw new Error("the credential helper command is empty");return e}function wo(n,e){let t=e.code,o="";return t==="ENOENT"&&(o=" (not found: give its path, or put it on PATH)"),t==="EINVAL"&&process.platform==="win32"&&(o=" (a .cmd or .bat file cannot run without a shell: configure an executable, e.g. `node path/to/helper.js`)"),new I(`${n} could not be started: ${e.message}${o}`)}import{existsSync as Xa,readFileSync as Ja}from"fs";import{homedir as Za}from"os";import{join as ei}from"path";function ne(){return ei(Za(),".kanonak","config.json")}function oe(n){if(!Xa(n))return;let e;try{e=JSON.parse(Ja(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must hold a JSON object`);return e}var Je="KANONAK_CREDENTIAL_HELPER";function ni(n={}){let e=n.env??process.env,t=n.configPath??ne(),o=oi(e,t);if(o){let a=Object.keys(e).filter(d=>(d===fe||d.startsWith(`${fe}_`))&&(e[d]??"").trim()!=="").sort();if(a.length>0)throw new Error(`A credential helper is configured (${o.source}: ${o.command}) and so is ${a.join(", ")}. Configure one or the other.`);return new ee({command:o.command,interactive:n.interactive??!1})}let r={env:e};return n.discovery&&(r.discovery=n.discovery),new Fe(r)}function oi(n,e){let t=(n[Je]??"").trim();if(t)return{command:t,source:Je};let o=oe(e)?.credentialHelper;if(o!==void 0){if(typeof o!="string"||o.trim()==="")throw new Error(`"credentialHelper" in ${e} must be a non-empty command line`);return{command:o.trim(),source:e}}}var Ze="KANONAK_PACKAGE_URL_TEMPLATE";function ti(n={}){let e=n.env??process.env,t=n.configPath??ne(),o=oe(t)?.packageUrlTemplates,r=o===void 0?{}:{...Re(o,"packageUrlTemplates",t)},a=(e[Ze]??"").trim();return a&&(r[Ce]=ve(a,Ze,!0)),Object.keys(r).length>0?Object.freeze(r):void 0}var R="kanonak.org",L="view",xo="core-kanonak",ri={publisher:R,package_:L,name:"rootView"},ai={publisher:R,package_:L,name:"bind"},ii={publisher:R,package_:L,name:"produces"},si={publisher:R,package_:L,name:"projections"},ci={publisher:R,package_:L,name:"where"},di={publisher:R,package_:L,name:"value"},ui={publisher:R,package_:L,name:"as"},Se=class{constructor(e,t=new W){this.repository=e;this.parser=t;this.objectParser=new j(this.parser),this.builder=new J(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(o,e),a=k(r,ai);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let d=k(r,ii);if(!d)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=li(r),c=No(o,R,xo),u=No(o,R,L),s=this.builder.imports(),l=s.ensure(R,xo,c,"ck"),f=s.ensure(R,L,u,"v"),m=s.ref(d),v=new eo(this.repository,this.parser,this.objectParser),y=new Zn(v,o),P=this.readProjections(o,r),w=mi(r,ci),_=this.findInstances(o,a,await this.reason(t)),h={},K=new Set;for(let te of _){if(!await this.passesWhere(y,o,w,te))continue;let Ee={type:m};for(let nn of P){let Oo=await this.evaluateValue(y,o,nn.value,te),on=this.builder.serializeValue(Ao(Oo),s);on!==void 0&&(Ee[s.ref(nn.as)]=on)}let en=S(te);en&&(Ee[`${f}.derivedFrom`]=s.ref(en)),h[this.rowName(te,K)]=Ee}let E={};t.resolvedAt&&(E[`${l}.resolvedAt`]=t.resolvedAt),t.invocationId&&(E[`${l}.id`]=t.invocationId);let O=await this.builder.buildContentAddressed({publisher:i,book:s,body:h,contentHashProperty:`${l}.contentHash`,header:E});return{yaml:O.yaml,contentHash:O.contentHash,packageName:O.packageName,publisher:O.publisher,rowCount:O.resourceCount}}resolveView(e,t){let o=N(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let r=k(o,ri);if(r){let a=N(e,r);if(!a)throw new Error(`ViewPackage ${t.name} names rootView ${r.name}, which is not in the catalog.`);return a}return o}readProjections(e,t){let o=[];for(let r of we(t,si)){let a=r instanceof U?r:r instanceof x?N(e,r.subject):void 0;if(!a)continue;let d=q(a,di),i=k(a,ui);d&&i&&o.push({value:d,as:i})}return o}async reason(e){return new F({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let r=fi(e),a=[],d=new Set;for(let i of o.getInstancesOfClass(t)){if(d.has(i))continue;d.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let u=B(S(i)),s=B(S(c));return u<s?-1:u>s?1:0}),a}async passesWhere(e,t,o,r){for(let a of o){let d=await this.evaluateValue(e,t,a,r);if(!hi(d))return!1}return!0}async evaluateValue(e,t,o,r){let a=Jn(o,"view-projection",{catalog:t,depth:0}),d=new Map([["input",r]]);return e.evaluate(a,d)}rowName(e,t){let o=je(e.name)||"row",r=o,a=2;for(;t.has(r);)r=`${o}-${a++}`;return t.add(r),r}};function Ao(n){return Me(n)?n.value:Array.isArray(n)?n.map(Ao):n}function li(n){let e=S(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function No(n,e,t){let o=pi(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function pi(n,e,t){let o;for(let r of n){if(!(r instanceof g))continue;let a=S(r);!a||a.publisher!==e||a.package_!==t||!a.version||(!o||re(a.version,o)>0)&&(o=a.version)}return o?$(o):void 0}function fi(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof g))continue;let r=S(o);if(!r||!r.version)continue;let a=B(r),d=t.get(a);(!d||re(r.version,d)>0)&&(t.set(a,r.version),e.set(a,o))}return e}function mi(n,e){let t=q(n,e);return t?[t]:we(n,e).filter(o=>o instanceof U)}function hi(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Me(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Ce as ANY_PUBLISHER,_r as AmbiguousReferenceRule,Rt as BooleanStatement,oa as CANONICAL_FORM_VERSION,fa as CREDENTIAL_EXPIRY_SKEW_SECONDS,Je as CREDENTIAL_HELPER_ENV,De as CREDENTIAL_HELPER_PROTOCOL_VERSION,_o as CREDENTIAL_HELPER_TIMEOUT_MS,M as Carrier,Lr as ClassDefinitionRule,Er as ClassHierarchyCycleRule,Wo as CompositeKanonakDocumentRepository,I as CredentialError,da as DEFAULT_CONSENT_BINDING_PARAM,kt as DefinedKanonak,Jr as DiamondNameClashRule,Ur as DisplayLensScopeRule,Fo as DocumentLocation,Wt as EdgeType,U as EmbeddedKanonak,kr as EmbeddedKanonakTypeRule,Pt as EmbeddedStatement,Ea as EntitlementDeniedError,ba as EntitlementProducer,ee as ExecCredentialProvider,Ho as FileSystemKanonakDocumentRepository,Qt as GitIgnoreFilter,qt as GraphBuilder,lt as HttpKanonakDocumentRepository,rn as INTEGRITY_PREFIX,ra as ImportBook,yr as ImportExistenceRule,be as InMemoryKanonakDocumentRepository,Xo as KANONAK_USER_AGENT,gt as Kanonak,Jt as KanonakDocumentPositions,Go as KanonakHttpError,j as KanonakObjectParser,Zr as KanonakObjectValidator,W as KanonakParser,tt as KanonakUri,tr as KanonakUriBuilder,rr as KanonakUrlResolver,Vt as KanonakVocabulary,Tr as LINE_STYLES,lr as LinkTargetRule,wt as ListStatement,yt as LiteralKanonak,pt as LocalFirstRepository,ft as LockAwareRepository,zr as LookBandPathRule,qr as LookRenderer,Vr as LookSemanticSvgPathRule,Ir as MarkdownLinkRule,_t as MarkdownStatement,Pr as NamespaceImportCycleRule,pr as NamespacePrefixRule,Ft as NodeType,Ct as NumberStatement,ua as OAuthDiscovery,Le as OWL_HAS_KEY,zt as OWL_RL_CLASSIFICATION_RULES,xr as ObjectPropertyValueValidationRule,cr as OntologyValidationError,ir as OntologyValidationResult,Xr as OwlOneOfRule,Ze as PACKAGE_URL_TEMPLATE_ENV,J as PackageBuilder,gr as PackageHeaderRule,ka as ProducerRepository,Nr as PropertyDomainRule,br as PropertyHierarchyCycleRule,Ar as PropertyKindRangeConsistencyRule,Xt as PropertyMetadata,Kr as PropertyRangeReferenceRule,Cr as PropertyRangeRequiredRule,mr as PropertyTypeSpecificityRule,ct as PublisherConfigResolver,dt as PublisherIndex,Gt as RDFS_RULES,F as Reasoner,Yt as ReasoningResult,x as ReferenceKanonak,vt as ReferenceStatement,Bo as RepositoryFactory,Or as ReservedNameShadowRule,fr as ResourceNamingRule,Kt as ResourceResolver,$t as ResourceTypeClassifier,ce as SHACL_PACKAGE,se as SHACL_PUBLISHER,G as SH_NODE_SHAPE,de as SH_PROPERTY_SHAPE,ln as SH_SHAPE,Et as ScalarStatement,Gr as SequenceNarrativeRule,Qr as ShaclShapeRule,St as Statement,bt as StringStatement,Rr as SubClassOfReferenceRule,vr as SubPropertyOfReferenceRule,g as SubjectKanonak,hr as SubjectKanonakTypeRequiredRule,fe as TOKEN_ENV,Fe as TokenCredentialProvider,Bt as TripleStore,$r as TxExpressionCompilesRule,Yr as TxExpressionPathRule,xt as TypeResolver,Mr as URI_DISPLAY_LABEL,jr as URI_DISPLAY_SUMMARY,wr as UnresolvedPredicateRule,Sr as UnresolvedReferenceRule,ur as ValidationCache,dr as ValidationContext,sr as ValidationSeverity,Zs as VersionOperator,Se as ViewMaterializer,ya as allowAllPolicy,et as assertHttpsUrl,dn as assertIntegrityAsync,ut as assertPackageIdentity,he as buildKeysModel,ht as buildLocalFirstRepository,Wr as buildOntologyModel,Po as buildReportPackageAsync,me as buildShapesModel,It as builtinHomePackages,Ut as builtinUri,ea as canonicalForm,na as canonicalHash,$e as carrierOf,la as checkCredentialAnswer,Te as checkHelperAnswer,He as checkHelperEraseAnswer,ve as checkPackageUrlTemplate,Re as checkPackageUrlTemplates,mt as collectKanonakFiles,re as compareVersions,to as computeIntegrity,cn as computeIntegrityAsync,ta as contentAddressedName,H as contextTypesOf,ma as createCredentialedFetch,Vo as createVersion,ni as credentialProviderFromConfig,Yo as describeResponse,So as evaluateConformance,Ht as extractMarkdownLinks,st as fillPackageUrlTemplate,ga as findDerivation,Tt as findMalformedReferences,er as findMarkdownLinkAt,Ge as foldFlagsIntoPattern,at as formatKanonakAddress,$ as formatVersion,qo as getGlobalCachePath,Zo as getKanonakUserAgent,zo as httpError,Mo as isCompatibleVersion,jo as isMajorCompatible,Ue as isPropertySubject,nt as kanonakFetch,no as loadLockFile,tn as lockedVersion,ke as lowerConstraint,At as makeUriKey,ca as narrowestScope,Sa as noopMeter,aa as normalizeHost,it as packageUrlTemplateFor,ti as packageUrlTemplatesFromConfig,rt as parseKanonakAddress,an as parseLockFile,ia as parseScope,$o as parseVersionString,Zt as parseWithPositions,pa as parseWwwAuthenticate,To as pickHighestDocument,jt as propertiesInScope,Mt as propertyClassOf,Hr as readSequenceConnectors,oe as readUserConfig,ar as referenceSpelling,D as referenceUris,Dr as resolveDisplayValue,Dt as resolvePropertyStep,Qo as retryAfterSecondsOf,je as sanitizeName,Do as satisfiesVersionOperator,oo as saveLockFile,sa as scopeContains,io as scopeFromCatalog,ao as scopeFromClosureAsync,so as scopeFromDocumentAsync,ro as scopeFromRepositoryAsync,sn as serializeLockFile,ot as setKanonakFetchRetries,Jo as setKanonakUserAgent,or as sourceSymbolAt,nr as sourceSymbols,Ko as splitCommandLine,X as subjectAddress,S as subjectUri,Ie as superClassChain,Br as supportedBandKeys,ha as tokenEnvKeyFor,Ot as tripleKey,Nt as typeReferenceUris,B as uriKey,Lt as uriTriple,ne as userConfigPath,Q as valuesOf,Lo as versionOperatorFromChar,Io as versionOperatorToChar,Uo as versionsEqual,Ve as walkDefinedKanonaks,Fr as walkSequence};
|
|
3
|
+
`)}`)}let r=new Qn(e,o),d=new Set((await r.getAllDocumentsAsync()).map(oe)),i=[...t].filter(l=>!d.has(l));if(i.length>0)throw new Error(`scopeFromClosureAsync: ${i.join(", ")} is not a document of the repository the closure is resolved through.`);let c={},u=await new U().parseKanonaks(r,c),s=c.authored.filter(l=>l instanceof g&&t.has(l.sourceDoc)),f=new Set(s.map(B)),m=await Pa(n,s,e);return{kind:"merged",catalog:u,reasoning:new z().reasonOver(u),focus:f,links:m}}async function Pa(n,e,t){let o=[],a=new Map,r=new Map;for(let d of n){let i=oe(d),c=e.filter(u=>u.sourceDoc===i);for(let{key:u,references:s,target:f,failure:m}of await Jn(d,c,t)){let l=f?oe(f):void 0;if(r.has(u)&&r.get(u)!==l)throw new Error(`scopeFromClosureAsync: the seeds link ${u} at different versions (${r.get(u)??"unresolved"} and ${l??"unresolved"}); judge them in separate scopes.`);r.has(u)||(r.set(u,l),f&&o.push(...await new U().parseKanonaks(new Be(f,t))));for(let{uri:h}of s)f?Zn(f,h.name)||a.set(p(h),`${l} defines no resource named '${h.name}'`):a.set(p(h),`its package ${u} could not be resolved${m?` (${m})`:""}`)}}return r.size>0?{subjects:o,unresolved:a}:void 0}function oe(n){let e=n.metadata?.namespace_;if(!e)throw new Error("scopeFromClosureAsync: a document has no namespace, so it cannot be identified.");return e.toString()}function co(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function uo(n,e){let t=e??new Le(new X);return{kind:"standalone",catalog:await new U().parseKanonaks(new Be(n,t))}}function $(n){return typeof n=="number"?n:void 0}function Ra(n){if(!n)return;let e=p(n);if(e===p(Fn))return"IRI";if(e===p(Wn))return"BlankNode";if(e===p(qn))return"Literal"}function po(n){if(!n)return;let e=p(n);if(e===p(Bn))return"Violation";if(e===p(Gn))return"Warning";if(e===p(zn))return"Info"}function fo(n,e,t,o){let a=k(e,je);if(!a)return;let r={path:a},d=$(A(e,vn)),i=$(A(e,wn));d!==void 0&&(r.minCount=d),i!==void 0&&(r.maxCount=i);let c=$(A(e,xn)),u=$(A(e,In));c!==void 0&&(r.minLength=c),u!==void 0&&(r.maxLength=u);let s=$(A(e,Ln)),f=$(A(e,Mn));s!==void 0&&(r.minInclusive=s),f!==void 0&&(r.maxInclusive=f);let m=ue(e,Nn);if(m!==void 0){let S=ue(e,An);r.pattern=S!==void 0?{regex:m,flags:S}:{regex:m}}if(F(e,Te)){let S=[],K=[];for(let{item:C}of Ve(e,Te))"literal"in C?S.push(C.value):C instanceof O&&K.push(C.subject);S.length>0&&(r.inValues=S),K.length>0&&(r.inRefs=K)}let l=k(e,Kn);l&&(r.datatype=l);let h=k(e,On);h&&(r.classRef=h);let y=Ra(k(e,Dn));y&&(r.nodeKind=y);let R=k(e,Xn);if(R&&(r.hasValue=R),F(e,Re)||F(e,Fe)||F(e,We)){let S={},K=$(A(e,Fe)),C=$(A(e,We));K!==void 0&&(S.minCount=K),C!==void 0&&(S.maxCount=C);let x=va(n,e,o);"problem"in x?S.problem=x.problem:S.shape=x.shape,r.qualified=S}let v=ue(e,Un);v!==void 0&&(r.message=v);let w=po(k(e,De))??t;return w&&(r.severity=w),r}function va(n,e,t){let o=Y(e,Re);if(o)return lo(n,o,void 0,t);let a=k(e,Re);if(!a)return{problem:"sh:qualifiedValueShape is missing"};let r=p(a);if(t.has(r))return{problem:`sh:qualifiedValueShape '${a.name}' leads back to itself (a cycle through named shapes)`};let d=N(n,a);return d?lo(n,d,r,t):{problem:`sh:qualifiedValueShape '${a.name}' does not resolve`}}function lo(n,e,t,o){let a=t?new Set([...o,t]):o,r=de(e,J);if((de(e,fe)||F(e,je))&&!r){let c=fo(n,e,void 0,a);return c?{shape:{kind:"property",constraint:c}}:{problem:"the qualified property shape has no sh:path"}}return e instanceof g&&!r?{problem:`sh:qualifiedValueShape '${e.name}' is not a shape`}:{shape:{kind:"node",shape:mo(n,e,a)}}}function mo(n,e,t){let o=po(k(e,De)),a={name:e instanceof g?e.name:"(inline shape)",uri:e instanceof g?E(e):void 0,targetClass:k(e,Pn),targetNodes:D(e,$n),targetSubjectsOf:D(e,Vn),targetObjectsOf:D(e,Hn),closed:A(e,jn)===!0,ignoredProperties:[],severity:o,properties:[]};a.ignoredProperties.push(...D(e,Tn));for(let{item:r}of Ve(e,Rn)){let d;if(r instanceof M?d=r:r instanceof O&&(d=N(n,r.subject)),!d)continue;let i=fo(n,d,o,t);i&&a.properties.push(i)}return a}function we(n){let e=[];for(let t of n){if(!(t instanceof g)||!de(t,J))continue;let o=E(t);e.push(mo(n,t,new Set(o?[p(o)]:[])))}return e}function Ke(n){let e=new Map;for(let t of n)if(t instanceof g)for(let o of bn(t,qe)){let a=E(t);if(!a)throw new Error(`owl.hasKey on '${t.namespace}/${t.name}': the class has no resolvable URI.`);if(o.length===0)throw new Error(`owl.hasKey on '${t.name}' lists no properties; a key needs at least one.`);let r=o.map(({item:d})=>{let i=d instanceof O?N(n,d.subject):void 0;if(!i||!ze(n,i)){let c=d instanceof O?`'${p(d.subject)}'`:"a value that is not a reference";throw new Error(`owl.hasKey on '${t.name}' lists ${c}, which is not a property defined in scope; a key lists properties.`)}return d.subject});e.set(`${p(a)}|${r.map(p).join(",")}`,{classUri:a,className:t.name,properties:r})}return[...e.values()]}var _="kanonak.org/transformations",te="values";var Oe="allowed",rn="expected",b=n=>({type:`${_}/VarRef`,varName:n}),tn=n=>({type:`${_}/IntegerLiteral`,integerLiteral:n}),wa=n=>({type:`${_}/DecimalLiteral`,decimalLiteral:n}),ho=n=>Number.isInteger(n)?tn(n):wa(n),So=n=>({type:`${_}/Count`,source:n}),go=(n,e)=>({type:`${_}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),ko=(n,e)=>({type:`${_}/LessThanOrEqual`,compareLeft:n,compareRight:e});function an(n,e){if(!e||e.length===0)return n;let t=new Set(["i","m","s"]),o=[...new Set(e.split(""))];if(o.filter(r=>!t.has(r)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${n}`}function Ne(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:go(So(b(te)),tn(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:ko(So(b(te)),tn(n.maxCount))}),n.hasValue!==void 0&&e.push({component:"hasValue",per:"node",expr:{type:`${_}/Contains`,haystack:b(te),needle:b(rn)}}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${_}/Contains`,haystack:b(Oe),needle:b("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:an(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${_}/Matches`,matchSource:b("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:go(b("v"),ho(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:ko(b("v"),ho(n.maxInclusive))}),e}import{evaluate as Oa,ExpressionError as Na}from"@kanonak-protocol/expression";function Co(n,e){let t=yo(e)?e:we(e),o=[],a=n.catalog.filter(c=>c instanceof g).map(Ae),r=new Map;Aa(a,r);let d=n.links?[...n.catalog,...n.links.subjects]:n.catalog,i={scope:n,membership:new cn(n),values:d,embeddedFocus:r};for(let c of t)for(let u of xa(i,c,a))sn(n,u)&&_o(i,c,u,o);if(!yo(e))for(let c of Ke(e))Ia(i,c,a,o);return{conforms:!o.some(c=>c.severity==="Violation"),results:o}}function yo(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function bo(n){let e=n.predicate;return e instanceof O?e:void 0}function sn(n,e){return!n.focus||e.subject!==void 0&&n.focus.has(e.subject)}function Ae(n){let e=B(n);return{node:n,key:e,uri:E(n),subject:e,label:n.name}}function un(n,e,t){return{node:n,key:e,subject:t,label:e.includes("#")?e.slice(e.indexOf("#")):e}}function Aa(n,e){for(let t of n)Xe([t.node],({kanonak:o,address:a})=>{o instanceof M&&!e.has(o)&&e.set(o,un(o,a,t.subject))})}var cn=class{constructor(e){this.scope=e}scope;ancestors=new Map;defined;defines(e){return this.defined??=new Set(this.scope.catalog.filter(t=>t instanceof g).map(B)),this.defined.has(p(e))}isInstance(e,t){let o=p(t);return e.some(a=>p(a)===o||this.ancestorsOf(a).has(o))}ancestorsOf(e){let t=e.version&&typeof e.version.major=="number"?`${p(e)}@${V(e.version)}`:p(e),o=this.ancestors.get(t);return o||(o=this.scope.reasoning?new Set(this.scope.reasoning.getSuperclasses(e)):new Set(Ge(this.scope.catalog,e).map(a=>p(a))),this.ancestors.set(t,o)),o}};function xa(n,e,t){let{scope:o}=n,a=new Map,r=i=>{a.set(i.key,i)},d=()=>[...t,...n.embeddedFocus.values()];if(e.targetClass){let i=e.targetClass;for(let c of d())n.membership.isInstance(G(c.node),i)&&r(c)}for(let i of e.targetNodes){let c=N(o.catalog,i);c instanceof g&&r(Ae(c))}for(let i of e.targetSubjectsOf){let c=p(i);for(let u of d())u.node.statement.some(s=>{let f=bo(s);return f&&p(f.subject)===c})&&r(u)}for(let i of e.targetObjectsOf)for(let c of d())for(let u of ee(c.node,i,o.catalog,c.key))u.kind==="subject"?r(Ae(u.node)):u.kind==="embedded"&&r(n.embeddedFocus.get(u.node)??un(u.node,u.address,c.subject));return[...a.values()]}function Ia(n,e,t,o){let a=new Map;for(let c of t)n.membership.isInstance(G(c.node),e.classUri)&&a.set(c.key,c);let r=[];for(let c of[...a.values()].sort((u,s)=>u.key<s.key?-1:u.key>s.key?1:0)){let u=e.properties.map(s=>La(n,c,s));u.every(s=>s.size>0)&&r.push({focus:c,values:u})}let d=new Map;r.forEach(({values:c},u)=>{for(let s of c[0].keys()){let f=d.get(s);f?f.push(u):d.set(s,[u])}});let i=new Set;for(let c of d.values())for(let u=0;u<c.length;u++)for(let s=u+1;s<c.length;s++){let f=`${c[u]}:${c[s]}`;if(i.has(f))continue;let m=r[c[u]],l=r[c[s]],h=m.values.map((w,S)=>[...w.keys()].find(K=>l.values[S].has(K)));if(h.some(w=>w===void 0))continue;i.add(f);let[y,R]=sn(n.scope,m.focus)?[m.focus,l.focus]:sn(n.scope,l.focus)?[l.focus,m.focus]:[void 0,void 0];if(!y||!R)continue;let v=e.properties.map((w,S)=>`${w.name} = ${m.values[S].get(h[S])}`).join(", ");o.push({focusNode:y.key,focusUri:y.uri,valueRef:R.uri,constraintComponent:q,severity:"Violation",message:`'${y.label}' and '${R.label}' are distinct instances of ${e.className} with the same key (${v}); its owl.hasKey makes the key unique.`})}}function La(n,e,t){let o=new Map;for(let a of ee(e.node,t,n.scope.catalog,e.key))switch(a.kind){case"subject":case"unresolved":o.set(`ref:${p(a.uri)}`,a.uri.name);break;case"literal":o.set(`${typeof a.value}:${String(a.value)}`,JSON.stringify(a.value));break;case"embedded":break}return o}function Ma(n,e,t){return e.node?ee(e.node,t,n.values,e.key).map(o=>Ua(n,o,e.subject)):[]}function Ua(n,e,t){switch(e.kind){case"subject":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri,subject:e.node};case"unresolved":return{kernel:{ref:p(e.uri)},kind:"reference",ref:e.uri};case"embedded":{let o=n.embeddedFocus.get(e.node)??un(e.node,e.address,t);return{kernel:{ref:o.key},kind:"embedded",embedded:o}}case"literal":return typeof e.value=="boolean"?{kernel:e.value?1:0,kind:"boolean",literal:e.value}:{kernel:e.value,kind:typeof e.value=="number"?"number":"string",literal:e.value}}}function _o(n,e,t,o){for(let a of e.properties)Ro(n,e,t,a,o);e.closed&&Ga(e,t,o)}function dn(n,e,t,o,a={},r){return{focusNode:e.key,focusUri:e.uri,constraintComponent:t,severity:r??Po(n),message:o,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function Po(n){return n.severity??"Violation"}var $a={minCount:me,maxCount:he,hasValue:W,in:ke,pattern:ye,minLength:Ee,maxLength:Ce,minInclusive:be,maxInclusive:_e};function Ro(n,e,t,o,a){let r=Ma(n,t,o.path),d=o.severity??Po(e),i=o.path.name,c=[...(o.inValues??[]).map(s=>typeof s=="boolean"?s?1:0:s),...(o.inRefs??[]).map(s=>({ref:p(s)}))],u=(s,f,m)=>{let l=dn(e,t,s,o.message??f,{resultPath:o.path,value:m?.literal,valueRef:m?.ref},d);return a.push(l),l};for(let s of Ne(o)){let f=$a[s.component];if(s.per==="node"){let m={[te]:r.map(l=>l.kernel),[Oe]:c};o.hasValue&&(m[rn]={ref:p(o.hasValue)}),Eo(s,m)||u(f,Va(s,i,o,r.length));continue}for(let m of r){if((s.component==="pattern"||s.component==="minLength"||s.component==="maxLength")&&m.kind!=="string"){u(f,`'${i}' value is not a string; ${s.component} applies to string values.`,m);continue}Eo(s,{v:m.kernel,[Oe]:c})||u(f,Fa(s,i,o,m),m)}}if(o.nodeKind)for(let s of r)Wa(o.nodeKind,s)||u(Pe,`'${i}' value is ${s.kind}; nodeKind requires ${o.nodeKind}.`,s);if(o.datatype)for(let s of r){let f=qa(o.datatype,s);f&&u(Se,`'${i}' ${f}`,s)}if(o.classRef)for(let s of r){let f=Ba(n,o.classRef,s);f&&u(ge,`'${i}' ${f}`,s)}o.qualified&&Ha(n,o,r,i,u)}function Va(n,e,t,o){switch(n.component){case"minCount":return`'${e}' has ${o} value(s); minCount is ${t.minCount}.`;case"maxCount":return`'${e}' has ${o} value(s); maxCount is ${t.maxCount}.`;case"hasValue":return`'${e}' has no value equal to ${t.hasValue?p(t.hasValue):"(unset)"}.`;default:return`'${e}' violates ${n.component}.`}}function Ha(n,e,t,o,a){let r=e.qualified,d=r.maxCount!==void 0?j:H,i=(u,s)=>{vo.add(a(d,u,s))};if(!r.shape){i(`'${o}' qualified value shape cannot be evaluated: ${r.problem??"it could not be built"}.`);return}let c=0;for(let u of t){let s=u.ref?p(u.ref):u.embedded?u.embedded.label:JSON.stringify(u.literal),f=ja(n,u);if(!f){i(`'${o}' value ${s} does not resolve in this scope; whether it conforms to the qualified shape cannot be decided.`,u);continue}let m=Da(n,r.shape,f);if(m.kind==="undecided"){i(`'${o}' value ${s}: whether it conforms to the qualified shape cannot be decided \u2014 ${m.reason}`,u);continue}m.kind==="conforms"&&c++}r.minCount!==void 0&&c<r.minCount&&a(H,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMinCount is ${r.minCount}.`),r.maxCount!==void 0&&c>r.maxCount&&a(j,`'${o}' has ${c} value(s) that conform to the qualified shape; qualifiedMaxCount is ${r.maxCount}.`)}function ja(n,e){switch(e.kind){case"reference":return e.subject?Ae(e.subject):void 0;case"embedded":return e.embedded;default:{let t=JSON.stringify(e.literal);return{key:t,label:t}}}}var Ta={name:"(qualified value shape)",targetNodes:[],targetSubjectsOf:[],targetObjectsOf:[],closed:!1,ignoredProperties:[],properties:[]},vo=new WeakSet;function Da(n,e,t){let o=[];e.kind==="property"?Ro(n,Ta,t,e.constraint,o):_o(n,e.shape,t,o);let a=o.find(r=>vo.has(r));return a?{kind:"undecided",reason:a.message}:o.length===0?{kind:"conforms"}:{kind:"fails"}}function Fa(n,e,t,o){let a=o.ref?p(o.ref):o.embedded?o.embedded.label:JSON.stringify(o.literal);switch(n.component){case"in":return`'${e}' value ${a} is not in the permitted set.`;case"pattern":return`'${e}' value ${a} does not match pattern ${t.pattern?.regex}.`;case"minLength":return`'${e}' value ${a} is shorter than minLength ${t.minLength}.`;case"maxLength":return`'${e}' value ${a} is longer than maxLength ${t.maxLength}.`;case"minInclusive":return`'${e}' value ${a} is below minInclusive ${t.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${a} is above maxInclusive ${t.maxInclusive} (or not numeric).`;default:return`'${e}' value ${a} violates ${n.component}.`}}function Eo(n,e){let t=o=>{let a=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof a=="string"&&a in e)return e[a];throw new Na(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return Oa(n.expr,void 0,t)===1}function Wa(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function qa(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let t=Ye(n);if(t!==void 0)switch(t){case T.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case T.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case T.Decimal:case T.Double:case T.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Ba(n,e,t){if(t.kind==="embedded"&&t.embedded?.node){let d=G(t.embedded.node);return d.length===0?`value ${t.embedded.label} has no type; sh:class requires an instance of ${e.name}.`:n.membership.isInstance(d,e)?void 0:`value ${t.embedded.label} is not an instance of ${e.name}.`}if(t.kind!=="reference"||!t.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let o=t.subject;if(!o){let d=n.scope.links?.unresolved.get(p(t.ref));return d?`value ${p(t.ref)} is a link that does not dereference: ${d} (sh:class ${e.name}).`:`value ${p(t.ref)} does not resolve in this scope (sh:class ${e.name}).`}let a=G(o);if(n.membership.isInstance(a,e))return;let r=a.filter(d=>!n.membership.defines(d));return r.length>0?`value ${p(t.ref)} is typed ${r.map(p).join(", ")}, which this scope does not define, so it cannot be shown to be an instance of ${e.name}. A class is in scope when the judged document imports the package that defines it.`:`value ${p(t.ref)} is not an instance of ${e.name}.`}function Ga(n,e,t){if(!e.node)return;let o=new Set([...n.properties.map(r=>p(r.path)),...n.ignoredProperties.map(r=>p(r))]),a=new Set;for(let r of e.node.statement){let d=bo(r);if(!d)continue;let i=p(d.subject);o.has(i)||a.has(i)||(a.add(i),t.push(dn(n,e,Z,`'${e.label}' carries undeclared property '${d.subject.name}' (closed shape).`,{resultPath:d.subject})))}for(let r of e.node.unresolvedPredicates)a.has(r.key)||(a.add(r.key),t.push(dn(n,e,Z,`'${e.label}' carries unresolvable property '${r.key}' (closed shape).`,{value:r.key})))}var za="1.1.0",Xa=new Set([W,H,j].map(n=>n.name)),Ya=new Set([q].map(n=>n.name));function Qa(n){let e=new Set(n.results.map(t=>t.constraintComponent.name));return[...e].some(t=>Ya.has(t))?"1.3.0":[...e].some(t=>Xa.has(t))?"1.2.0":za}async function wo(n){let e=new ne(n.repository),t=e.imports(),o=t.ensure(le,pe,Qa(n.result),"sh"),a=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${t.ensure(i.publisher,i.package_,V(i.version),i.package_)}.${i.name}`:c,r={},d=[];return n.result.results.forEach((i,c)=>{let u=`result-${c+1}`;d.push(u);let s={type:`${o}.ValidationResult`,[`${o}.focusNode`]:a(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(s[`${o}.resultPath`]=a(i.resultPath,p(i.resultPath))),i.sourceShapeUri&&i.sourceShape!==void 0&&(s[`${o}.sourceShape`]=a(i.sourceShapeUri,i.sourceShape)),i.valueRef?s[`${o}.value`]=a(i.valueRef,p(i.valueRef)):i.value!==void 0&&(s[`${o}.value`]=i.value),r[u]=s}),r.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:n.result.conforms,...d.length>0?{[`${o}.result`]:d}:{}},e.buildContentAddressed({publisher:n.publisher,book:t,body:r,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as tc}from"@kanonak-protocol/types/document/models/enums";import{spawn as Ja}from"child_process";var Oo=12e4,Za=4096,re=class{argv;interactive;timeoutMs;stderr;now;constructor(e){this.argv=No(e.command),this.interactive=e.interactive??!1,this.timeoutMs=e.timeoutMs??Oo,this.stderr=e.stderr??process.stderr,this.now=e.nowSeconds??(()=>Date.now()/1e3)}get command(){return this.argv.join(" ")}async get(e){let t=await this.run("get",this.wireRequest("get",e)),o=en(e,t,this.now());if(!o.ok)throw new L(`credential helper '${this.command}' answered get for ${e.resource} outside the protocol (${o.problem}): ${o.message}`);return o.answer}async erase(e){let t=await this.run("erase",{...this.wireRequest("erase",e),scope:e.scope}),o=nn(t);if(!o.ok)throw new L(`credential helper '${this.command}' answered erase for ${e.resource} outside the protocol (${o.problem}): ${o.message}`)}wireRequest(e,t){let o={version:Ze,operation:e,resource:t.resource,method:t.method};return t.challenges&&(o.challenges=t.challenges),o.interactive=this.interactive,o}run(e,t){let o=`credential helper '${this.command}' ${e}`;return new Promise((a,r)=>{let d=!1,i=l=>{d||(d=!0,l())},c;try{c=Ja(this.argv[0],[...this.argv.slice(1),e],{stdio:["pipe","pipe","pipe"],shell:!1,windowsHide:!0})}catch(l){r(Ko(o,l));return}let u=[],s="",f=!1,m=setTimeout(()=>{f=!0,c.kill()},this.timeoutMs);c.stdout.on("data",l=>u.push(l)),c.stderr.on("data",l=>{this.stderr.write(l),s=(s+l.toString("utf8")).slice(-Za)}),c.on("error",l=>{clearTimeout(m),i(()=>r(Ko(o,l)))}),c.on("close",(l,h)=>{clearTimeout(m);let y=s.trim()?`: ${s.trim()}`:"";if(f){i(()=>r(new L(`${o} did not finish within ${Math.round(this.timeoutMs/1e3)}s${y}`)));return}if(l!==0){let v=l!==null?`exit ${l}`:`signal ${h}`;i(()=>r(new L(`${o} failed (${v})${y}`)));return}let R=Buffer.concat(u).toString("utf8").trim();try{let v=JSON.parse(R);i(()=>a(v))}catch{i(()=>r(new L(`${o} exited 0 without printing one JSON answer${y}`)))}}),c.stdin.on("error",()=>{}),c.stdin.end(`${JSON.stringify(t)}
|
|
4
|
+
`)})}};function No(n){let e=n.trim().split(/\s+/).filter(t=>t!=="");if(e.length===0)throw new Error("the credential helper command is empty");return e}function Ko(n,e){let t=e.code,o="";return t==="ENOENT"&&(o=" (not found: give its path, or put it on PATH)"),t==="EINVAL"&&process.platform==="win32"&&(o=" (a .cmd or .bat file cannot run without a shell: configure an executable, e.g. `node path/to/helper.js`)"),new L(`${n} could not be started: ${e.message}${o}`)}import{existsSync as ei,readFileSync as ni}from"fs";import{homedir as oi}from"os";import{join as ti}from"path";function ae(){return ti(oi(),".kanonak","config.json")}function ie(n){if(!ei(n))return;let e;try{e=JSON.parse(ni(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must hold a JSON object`);return e}var ln="KANONAK_CREDENTIAL_HELPER";function ri(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ai(e,t);if(o){let r=Object.keys(e).filter(d=>(d===ve||d.startsWith(`${ve}_`))&&(e[d]??"").trim()!=="").sort();if(r.length>0)throw new Error(`A credential helper is configured (${o.source}: ${o.command}) and so is ${r.join(", ")}. Configure one or the other.`);return new re({command:o.command,interactive:n.interactive??!1})}let a={env:e};return n.discovery&&(a.discovery=n.discovery),new on(a)}function ai(n,e){let t=(n[ln]??"").trim();if(t)return{command:t,source:ln};let o=ie(e)?.credentialHelper;if(o!==void 0){if(typeof o!="string"||o.trim()==="")throw new Error(`"credentialHelper" in ${e} must be a non-empty command line`);return{command:o.trim(),source:e}}}var pn="KANONAK_PACKAGE_URL_TEMPLATE";function ii(n={}){let e=n.env??process.env,t=n.configPath??ae(),o=ie(t)?.packageUrlTemplates,a=o===void 0?{}:{...Ue(o,"packageUrlTemplates",t)},r=(e[pn]??"").trim();return r&&(a[Me]=$e(r,pn,!0)),Object.keys(a).length>0?Object.freeze(a):void 0}var P="kanonak.org",I="view",Ao="core-kanonak",si={publisher:P,package_:I,name:"rootView"},ci={publisher:P,package_:I,name:"bind"},di={publisher:P,package_:I,name:"produces"},ui={publisher:P,package_:I,name:"projections"},li={publisher:P,package_:I,name:"where"},pi={publisher:P,package_:I,name:"value"},fi={publisher:P,package_:I,name:"as"},xe=class{constructor(e,t=new X){this.repository=e;this.parser=t;this.objectParser=new U(this.parser),this.builder=new ne(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,t={}){let o=await this.objectParser.parseKanonaks(this.repository),a=this.resolveView(o,e),r=k(a,ci);if(!r)throw new Error(`View ${a.namespace}/${a.name} declares no view.bind; cannot materialize.`);let d=k(a,di);if(!d)throw new Error(`View ${a.namespace}/${a.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=mi(a),c=xo(o,P,Ao),u=xo(o,P,I),s=this.builder.imports(),f=s.ensure(P,Ao,c,"ck"),m=s.ensure(P,I,u,"v"),l=s.ref(d),h=new oo(this.repository,this.parser,this.objectParser),y=new no(h,o),R=this.readProjections(o,a),v=gi(a,li),w=this.findInstances(o,r,await this.reason(t)),S={},K=new Set;for(let se of w){if(!await this.passesWhere(y,o,v,se))continue;let Ie={type:l};for(let mn of R){let Lo=await this.evaluateValue(y,o,mn.value,se),hn=this.builder.serializeValue(Io(Lo),s);hn!==void 0&&(Ie[s.ref(mn.as)]=hn)}let fn=E(se);fn&&(Ie[`${m}.derivedFrom`]=s.ref(fn)),S[this.rowName(se,K)]=Ie}let C={};t.resolvedAt&&(C[`${f}.resolvedAt`]=t.resolvedAt),t.invocationId&&(C[`${f}.id`]=t.invocationId);let x=await this.builder.buildContentAddressed({publisher:i,book:s,body:S,contentHashProperty:`${f}.contentHash`,header:C});return{yaml:x.yaml,contentHash:x.contentHash,packageName:x.packageName,publisher:x.publisher,rowCount:x.resourceCount}}resolveView(e,t){let o=N(e,t);if(!o)throw new Error(`View ${t.publisher}/${t.package_}/${t.name} not found in the catalog.`);let a=k(o,si);if(a){let r=N(e,a);if(!r)throw new Error(`ViewPackage ${t.name} names rootView ${a.name}, which is not in the catalog.`);return r}return o}readProjections(e,t){let o=[];for(let a of He(t,ui)){let r=a instanceof M?a:a instanceof O?N(e,a.subject):void 0;if(!r)continue;let d=Y(r,pi),i=k(r,fi);d&&i&&o.push({value:d,as:i})}return o}async reason(e){return new z({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,t,o){let a=Si(e),r=[],d=new Set;for(let i of o.getInstancesOfClass(t)){if(d.has(i))continue;d.add(i);let c=a.get(i);c&&r.push(c)}return r.sort((i,c)=>{let u=Q(E(i)),s=Q(E(c));return u<s?-1:u>s?1:0}),r}async passesWhere(e,t,o,a){for(let r of o){let d=await this.evaluateValue(e,t,r,a);if(!ki(d))return!1}return!0}async evaluateValue(e,t,o,a){let r=eo(o,"view-projection",{catalog:t,depth:0}),d=new Map([["input",a]]);return e.evaluate(r,d)}rowName(e,t){let o=Je(e.name)||"row",a=o,r=2;for(;t.has(a);)a=`${o}-${r++}`;return t.add(a),a}};function Io(n){return Qe(n)?n.value:Array.isArray(n)?n.map(Io):n}function mi(n){let e=E(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function xo(n,e,t){let o=hi(n,e,t);if(!o)throw new Error(`Package ${e}/${t} is not in the catalog; it must be importable to materialize a view.`);return o}function hi(n,e,t){let o;for(let a of n){if(!(a instanceof g))continue;let r=E(a);!r||r.publisher!==e||r.package_!==t||!r.version||(!o||ce(r.version,o)>0)&&(o=r.version)}return o?V(o):void 0}function Si(n){let e=new Map,t=new Map;for(let o of n){if(!(o instanceof g))continue;let a=E(o);if(!a||!a.version)continue;let r=Q(a),d=t.get(r);(!d||ce(a.version,d)>0)&&(t.set(r,a.version),e.set(r,o))}return e}function gi(n,e){let t=Y(n,e);return t?[t]:He(n,e).filter(o=>o instanceof M)}function ki(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:Qe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Me as ANY_PUBLISHER,Or as AmbiguousReferenceRule,Rt as BooleanStatement,ra as CANONICAL_FORM_VERSION,ha as CREDENTIAL_EXPIRY_SKEW_SECONDS,ln as CREDENTIAL_HELPER_ENV,Ze as CREDENTIAL_HELPER_PROTOCOL_VERSION,Oo as CREDENTIAL_HELPER_TIMEOUT_MS,T as Carrier,Mr as ClassDefinitionRule,br as ClassHierarchyCycleRule,Bo as CompositeKanonakDocumentRepository,L as CredentialError,la as DEFAULT_CONSENT_BINDING_PARAM,yt as DefinedKanonak,ea as DiamondNameClashRule,$r as DisplayLensScopeRule,qo as DocumentLocation,Bt as EdgeType,M as EmbeddedKanonak,yr as EmbeddedKanonakTypeRule,wt as EmbeddedStatement,ba as EntitlementDeniedError,_a as EntitlementProducer,re as ExecCredentialProvider,Wo as FileSystemKanonakDocumentRepository,Jt as GitIgnoreFilter,Gt as GraphBuilder,ft as HttpKanonakDocumentRepository,gn as INTEGRITY_PREFIX,ia as ImportBook,Er as ImportExistenceRule,Le as InMemoryKanonakDocumentRepository,Zo as KANONAK_USER_AGENT,kt as Kanonak,er as KanonakDocumentPositions,Xo as KanonakHttpError,U as KanonakObjectParser,na as KanonakObjectValidator,X as KanonakParser,at as KanonakUri,ar as KanonakUriBuilder,ir as KanonakUrlResolver,Vt as KanonakVocabulary,Fr as LINE_STYLES,fr as LinkTargetRule,Kt as ListStatement,Et as LiteralKanonak,mt as LocalFirstRepository,ht as LockAwareRepository,Yr as LookBandPathRule,Gr as LookRenderer,Vr as LookSemanticSvgPathRule,Ur as MarkdownLinkRule,Ot as MarkdownStatement,wr as NamespaceImportCycleRule,mr as NamespacePrefixRule,qt as NodeType,Pt as NumberStatement,pa as OAuthDiscovery,qe as OWL_HAS_KEY,Yt as OWL_RL_CLASSIFICATION_RULES,Ar as ObjectPropertyValueValidationRule,ur as OntologyValidationError,cr as OntologyValidationResult,Zr as OwlOneOfRule,pn as PACKAGE_URL_TEMPLATE_ENV,ne as PackageBuilder,kr as PackageHeaderRule,ya as ProducerRepository,xr as PropertyDomainRule,_r as PropertyHierarchyCycleRule,Ir as PropertyKindRangeConsistencyRule,Zt as PropertyMetadata,Nr as PropertyRangeReferenceRule,Pr as PropertyRangeRequiredRule,Sr as PropertyTypeSpecificityRule,ut as PublisherConfigResolver,lt as PublisherIndex,Xt as RDFS_RULES,z as Reasoner,Qt as ReasoningResult,O as ReferenceKanonak,vt as ReferenceStatement,zo as RepositoryFactory,Lr as ReservedNameShadowRule,hr as ResourceNamingRule,Nt as ResourceResolver,Ht as ResourceTypeClassifier,pe as SHACL_PACKAGE,le as SHACL_PUBLISHER,ge as SH_COMP_CLASS,Z as SH_COMP_CLOSED,Se as SH_COMP_DATATYPE,q as SH_COMP_HAS_KEY,W as SH_COMP_HAS_VALUE,ke as SH_COMP_IN,he as SH_COMP_MAX_COUNT,_e as SH_COMP_MAX_INCLUSIVE,Ce as SH_COMP_MAX_LENGTH,me as SH_COMP_MIN_COUNT,be as SH_COMP_MIN_INCLUSIVE,Ee as SH_COMP_MIN_LENGTH,Pe as SH_COMP_NODE_KIND,ye as SH_COMP_PATTERN,j as SH_COMP_QUALIFIED_MAX_COUNT,H as SH_COMP_QUALIFIED_MIN_COUNT,J as SH_NODE_SHAPE,fe as SH_PROPERTY_SHAPE,_n as SH_SHAPE,bt as ScalarStatement,Xr as SequenceNarrativeRule,Jr as ShaclShapeRule,Ct as Statement,_t as StringStatement,Rr as SubClassOfReferenceRule,vr as SubPropertyOfReferenceRule,g as SubjectKanonak,gr as SubjectKanonakTypeRequiredRule,ve as TOKEN_ENV,on as TokenCredentialProvider,zt as TripleStore,Hr as TxExpressionCompilesRule,Qr as TxExpressionPathRule,At as TypeResolver,jr as URI_DISPLAY_LABEL,Tr as URI_DISPLAY_SUMMARY,Kr as UnresolvedPredicateRule,Cr as UnresolvedReferenceRule,pr as ValidationCache,lr as ValidationContext,dr as ValidationSeverity,tc as VersionOperator,xe as ViewMaterializer,Ea as allowAllPolicy,ot as assertHttpsUrl,Cn as assertIntegrityAsync,pt as assertPackageIdentity,Ke as buildKeysModel,gt as buildLocalFirstRepository,Br as buildOntologyModel,wo as buildReportPackageAsync,we as buildShapesModel,Ut as builtinHomePackages,$t as builtinUri,oa as canonicalForm,ta as canonicalHash,Ye as carrierOf,fa as checkCredentialAnswer,en as checkHelperAnswer,nn as checkHelperEraseAnswer,$e as checkPackageUrlTemplate,Ue as checkPackageUrlTemplates,St as collectKanonakFiles,ce as compareVersions,ao as computeIntegrity,En as computeIntegrityAsync,aa as contentAddressedName,G as contextTypesOf,Sa as createCredentialedFetch,Vo as createVersion,ri as credentialProviderFromConfig,Qo as describeResponse,Co as evaluateConformance,Wt as extractMarkdownLinks,dt as fillPackageUrlTemplate,ka as findDerivation,Ft as findMalformedReferences,or as findMarkdownLinkAt,an as foldFlagsIntoPattern,st as formatKanonakAddress,V as formatVersion,Go as getGlobalCachePath,nt as getKanonakUserAgent,Yo as httpError,jo as isCompatibleVersion,To as isMajorCompatible,ze as isPropertySubject,tt as kanonakFetch,to as loadLockFile,Sn as lockedVersion,Ne as lowerConstraint,It as makeUriKey,ua as narrowestScope,Ca as noopMeter,sa as normalizeHost,ct as packageUrlTemplateFor,ii as packageUrlTemplatesFromConfig,it as parseKanonakAddress,kn as parseLockFile,ca as parseScope,Ho as parseVersionString,nr as parseWithPositions,ma as parseWwwAuthenticate,Fo as pickHighestDocument,Tt as propertiesInScope,jt as propertyClassOf,Wr as readSequenceConnectors,ie as readUserConfig,sr as referenceSpelling,D as referenceUris,Dr as resolveDisplayValue,Dt as resolvePropertyStep,Jo as retryAfterSecondsOf,Je as sanitizeName,Do as satisfiesVersionOperator,ro as saveLockFile,da as scopeContains,co as scopeFromCatalog,so as scopeFromClosureAsync,uo as scopeFromDocumentAsync,io as scopeFromRepositoryAsync,yn as serializeLockFile,rt as setKanonakFetchRetries,et as setKanonakUserAgent,rr as sourceSymbolAt,tr as sourceSymbols,No as splitCommandLine,B as subjectAddress,E as subjectUri,Ge as superClassChain,zr as supportedBandKeys,ga as tokenEnvKeyFor,Lt as tripleKey,xt as typeReferenceUris,Q as uriKey,Mt as uriTriple,ae as userConfigPath,ee as valuesOf,Mo as versionOperatorFromChar,Uo as versionOperatorToChar,$o as versionsEqual,Xe as walkDefinedKanonaks,qr as walkSequence};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import type { KanonakDocument, Import } from '@kanonak-protocol/types/document/models/types';
|
|
3
|
+
import type { Kanonak } from '../kanonaks/Kanonak.js';
|
|
4
|
+
import type { KanonakUri } from './KanonakUri.js';
|
|
5
|
+
/** One reference through a link import, and where it was written. */
|
|
6
|
+
export interface LinkReference {
|
|
7
|
+
uri: KanonakUri;
|
|
8
|
+
/** The locator of the node it was written on (`walkDefinedKanonaks`' path). */
|
|
9
|
+
where: string;
|
|
10
|
+
/** The local name of the property it is a value of. */
|
|
11
|
+
predicate: string;
|
|
12
|
+
}
|
|
13
|
+
/** A package a document references through a link import, resolved one hop out. */
|
|
14
|
+
export interface LinkedPackage {
|
|
15
|
+
/** `publisher/package`, as the URI of a reference through the link carries it. */
|
|
16
|
+
key: string;
|
|
17
|
+
publisher: string;
|
|
18
|
+
import_: Import;
|
|
19
|
+
/** Every reference through this link, in walk order. */
|
|
20
|
+
references: LinkReference[];
|
|
21
|
+
/** The version the link import resolves to; null when it did not resolve. */
|
|
22
|
+
target: KanonakDocument | null;
|
|
23
|
+
/** The repository's error, when resolving threw. */
|
|
24
|
+
failure?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The packages `roots` reference through `document`'s `mode: link` imports,
|
|
28
|
+
* each resolved ONE HOP out through `repository` (typescript#111): the target
|
|
29
|
+
* package at the version its link import resolves to (workspace, cache, then
|
|
30
|
+
* HTTP, as the repository tiers them), never its own imports. A link import
|
|
31
|
+
* no reference uses is not resolved: declaring a link is harmless, and only
|
|
32
|
+
* following it costs.
|
|
33
|
+
*
|
|
34
|
+
* THE dereference of a link. `LinkTargetRule` verifies links with it, and a
|
|
35
|
+
* conformance scope reads link values through it (typescript#138), so the two
|
|
36
|
+
* passes cannot disagree about where a link points. References are object
|
|
37
|
+
* property values, list items and prose links.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveLinkedPackagesAsync(document: KanonakDocument, roots: Kanonak[], repository: IKanonakDocumentRepository): Promise<LinkedPackage[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a link's target package defines a resource with this name: its
|
|
42
|
+
* body, the dictionary the entity index is built from. The package's own
|
|
43
|
+
* imports are never consulted, which is what keeps a link one hop.
|
|
44
|
+
*/
|
|
45
|
+
export declare function linkTargetDefines(target: KanonakDocument, name: string): boolean;
|
|
@@ -44,6 +44,27 @@ export interface ConformanceScope {
|
|
|
44
44
|
* node in the catalog is judged.
|
|
45
45
|
*/
|
|
46
46
|
focus?: ReadonlySet<string> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* What the judged documents' `mode: link` references point at, read one hop
|
|
49
|
+
* out (typescript#138). A link is data, not a dependency (#111): its target
|
|
50
|
+
* package is not in the catalog, so nothing in it is judged, its shapes and
|
|
51
|
+
* keys bind nothing, and its classes are not the scope's. A value that is a
|
|
52
|
+
* link is checked against the subject it names, as `LinkTargetRule`
|
|
53
|
+
* dereferences it. Absent: the scope reads no links.
|
|
54
|
+
*/
|
|
55
|
+
links?: ScopeLinks | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** The targets of a scope's link references; see {@link ConformanceScope.links}. */
|
|
58
|
+
export interface ScopeLinks {
|
|
59
|
+
/**
|
|
60
|
+
* The subjects of each linked package the judged documents reference, at
|
|
61
|
+
* the version its link import resolves to: the package's own statements,
|
|
62
|
+
* with its names resolved through the repository. A reference value the
|
|
63
|
+
* catalog does not resolve is looked up here, as `findSubjectByUri` matches.
|
|
64
|
+
*/
|
|
65
|
+
subjects: Kanonak[];
|
|
66
|
+
/** Why a link reference does not dereference, by the referenced subject's key (`uriKey`). */
|
|
67
|
+
unresolved: ReadonlyMap<string, string>;
|
|
47
68
|
}
|
|
48
69
|
/**
|
|
49
70
|
* Build a merged scope from a repository — the pinned load-set. One parse
|
|
@@ -61,15 +82,22 @@ export declare function scopeFromRepositoryAsync(repository: IKanonakDocumentRep
|
|
|
61
82
|
*
|
|
62
83
|
* The catalog is the closure and nothing else: a version of a package that no
|
|
63
84
|
* import resolved to does not enter it, wherever it is stored (the workspace,
|
|
64
|
-
* the global cache), so its shapes cannot bind the seeds' nodes.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
85
|
+
* the global cache), so its shapes cannot bind the seeds' nodes. Only the
|
|
86
|
+
* seeds' own nodes are judged ({@link ConformanceScope.focus}), including
|
|
87
|
+
* subjects of other packages that a seed augments; the rest of the closure
|
|
88
|
+
* supplies their contracts.
|
|
89
|
+
*
|
|
90
|
+
* A seed's `mode: link` references are read one hop out
|
|
91
|
+
* ({@link ConformanceScope.links}): each linked package a seed references is
|
|
92
|
+
* resolved by its link import and parsed on its own, without joining the
|
|
93
|
+
* catalog. A link that does not dereference is not an error here: a check on
|
|
94
|
+
* that value fails, and says why.
|
|
69
95
|
*
|
|
70
96
|
* Every seed must be a document of `repository`, and every import in the
|
|
71
97
|
* closure must resolve. A partial closure would judge the seeds against fewer
|
|
72
|
-
* contracts than they declare, so an unresolved import is an error.
|
|
98
|
+
* contracts than they declare, so an unresolved import is an error. So is a
|
|
99
|
+
* package that two seeds link at different versions, since a link value
|
|
100
|
+
* names one subject: judge such seeds in separate scopes.
|
|
73
101
|
*/
|
|
74
102
|
export declare function scopeFromClosureAsync(seeds: KanonakDocument[], repository: IKanonakDocumentRepository): Promise<ConformanceScope>;
|
|
75
103
|
/**
|
package/dist/shacl/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { scopeFromRepositoryAsync, scopeFromClosureAsync, scopeFromCatalog, scopeFromDocumentAsync, } from './ConformanceScope.js';
|
|
2
|
-
export type { ConformanceScope } from './ConformanceScope.js';
|
|
2
|
+
export type { ConformanceScope, ScopeLinks } from './ConformanceScope.js';
|
|
3
3
|
export { buildShapesModel, buildKeysModel } from './ShapesModel.js';
|
|
4
4
|
export type { ShaclNodeShapeModel, ShaclClassKeyModel, ShaclPropertyConstraint, ShaclNodeKind, ShaclSeverity, } from './ShapesModel.js';
|
|
5
5
|
export { lowerConstraint, foldFlagsIntoPattern } from './lowering.js';
|
|
@@ -7,4 +7,4 @@ export type { LoweredCheck, LoweredExprNode } from './lowering.js';
|
|
|
7
7
|
export { evaluateConformance } from './ConformanceEvaluator.js';
|
|
8
8
|
export type { ShaclConformanceResult, ShaclFinding } from './ConformanceEvaluator.js';
|
|
9
9
|
export { buildReportPackageAsync } from './ReportBuilder.js';
|
|
10
|
-
export { SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, } from './uris.js';
|
|
10
|
+
export { SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, SH_COMP_MIN_COUNT, SH_COMP_MAX_COUNT, SH_COMP_DATATYPE, SH_COMP_CLASS, SH_COMP_IN, SH_COMP_PATTERN, SH_COMP_MIN_LENGTH, SH_COMP_MAX_LENGTH, SH_COMP_MIN_INCLUSIVE, SH_COMP_MAX_INCLUSIVE, SH_COMP_NODE_KIND, SH_COMP_CLOSED, SH_COMP_HAS_VALUE, SH_COMP_QUALIFIED_MIN_COUNT, SH_COMP_QUALIFIED_MAX_COUNT, SH_COMP_HAS_KEY, } from './uris.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x
|
|
1
|
+
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,a,b,c,d,e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"../chunk-426MUUGB.js";import"../chunk-VJUZKHQU.js";import"../chunk-CPENAANM.js";import"../chunk-QHABFCRC.js";import"../chunk-5FVUBF7N.js";import"../chunk-WXXZOJ4O.js";import"../chunk-SBWD7EOG.js";import"../chunk-5ZRVFYCP.js";import"../chunk-PEJALHXK.js";import"../chunk-6WOPXTIL.js";import"../chunk-LK5SHY4B.js";import"../chunk-F67UH4FD.js";import"../chunk-GGK6A6QK.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
138
|
-
"@kanonak-protocol/types": "^6.
|
|
138
|
+
"@kanonak-protocol/types": "^6.7.0",
|
|
139
139
|
"ignore": "^7.0.5",
|
|
140
140
|
"js-yaml": "^4.1.0",
|
|
141
141
|
"yaml": "^2.7.0",
|