@kanonak-protocol/sdk 5.30.0 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y,b as X,c as J,d as je,e as De,f as Ve,g as Ae,i as ve,j as Ne,k as He,l as Te}from"./chunk-J4ZD6IF6.js";import{a as Le}from"./chunk-L2J7WD7E.js";import{a as m,b as c,c as u,e as d,h as R,i as y,j as f,k,l as x,m as P,n as S}from"./chunk-BZ3YTI3C.js";import{a as Q,b as Z,c as $}from"./chunk-BS7RRG7D.js";import{a as ee}from"./chunk-XK24CN3C.js";import"./chunk-SC5M74NM.js";import{A as he,B as Ie,C as Ee,M as Oe,a as oe,b as te,c as re,d as ne,g as ae,h as ie,i as se,j as pe,l as le,m as me,n as ce,o as ue,p as de,q as Re,r as ye,s as fe,t as ke,u as xe,v as Pe,w as Se,x as Ce,y as ge,z as Ke}from"./chunk-
|
|
1
|
+
import{a as Y,b as X,c as J,d as je,e as De,f as Ve,g as Ae,i as ve,j as Ne,k as He,l as Te}from"./chunk-J4ZD6IF6.js";import{a as Le}from"./chunk-L2J7WD7E.js";import{a as m,b as c,c as u,e as d,h as R,i as y,j as f,k,l as x,m as P,n as S}from"./chunk-BZ3YTI3C.js";import{a as Q,b as Z,c as $}from"./chunk-BS7RRG7D.js";import{a as ee}from"./chunk-XK24CN3C.js";import"./chunk-SC5M74NM.js";import{A as he,B as Ie,C as Ee,M as Oe,a as oe,b as te,c as re,d as ne,g as ae,h as ie,i as se,j as pe,l as le,m as me,n as ce,o as ue,p as de,q as Re,r as ye,s as fe,t as ke,u as xe,v as Pe,w as Se,x as Ce,y as ge,z as Ke}from"./chunk-AXQ4DBJD.js";import"./chunk-KIBR3HAT.js";import{k as be}from"./chunk-Z5Y4MCW5.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as h,c as H,i as w,j as z,m as W}from"./chunk-PVUBHIU2.js";import{a as l}from"./chunk-HF5FJBS2.js";import"./chunk-PEJALHXK.js";import{a as T,b as L,da as B,fa as q,j as _,k as F,l as M,m as U,n as G}from"./chunk-7UYXTYXC.js";import{a as C,b as g,c as K,d as E,e as b,f as O,g as j,h as D,i as V,j as A,k as v,l as N}from"./chunk-CJMVIOZX.js";import{a as I}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{c as e,d as o,e as t,f as r,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{Pe as AmbiguousReferenceRule,V as BooleanStatement,Ve as CANONICAL_FORM_VERSION,w as Carrier,Ie as ClassDefinitionRule,ue as ClassHierarchyCycleRule,g as DefinedKanonak,X as EdgeType,h as EmbeddedKanonak,le as EmbeddedKanonakTypeRule,v as EmbeddedStatement,J as GraphBuilder,S as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,me as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,m as KANONAK_USER_AGENT,C as Kanonak,Z as KanonakDocumentPositions,W as KanonakObjectParser,Oe as KanonakObjectValidator,l as KanonakParser,I as KanonakUri,ee as KanonakUriBuilder,B as KanonakVocabulary,N as ListStatement,Ee as MarkdownLinkRule,H as MarkdownStatement,ke as NamespaceImportCycleRule,ae as NamespacePrefixRule,Y as NodeType,D as NumberStatement,ve as OAuthDiscovery,Ce as ObjectPropertyValueValidationRule,re as OntologyValidationError,oe as OntologyValidationResult,ge as PropertyDomainRule,de as PropertyHierarchyCycleRule,Ke as PropertyKindRangeConsistencyRule,Q as PropertyMetadata,Se as PropertyRangeReferenceRule,Re as PropertyRangeRequiredRule,se as PropertyTypeSpecificityRule,R as PublisherConfigResolver,P as PublisherIndex,E as ReferenceKanonak,A as ReferenceStatement,he as ReservedNameShadowRule,ie as ResourceNamingRule,T as ResourceResolver,q as ResourceTypeClassifier,F as SHACL_PACKAGE,_ as SHACL_PUBLISHER,U as SH_NODE_SHAPE,G as SH_PROPERTY_SHAPE,M as SH_SHAPE,O as ScalarStatement,b as Statement,j as StringStatement,ye as SubClassOfReferenceRule,fe as SubPropertyOfReferenceRule,K as SubjectKanonak,pe as SubjectKanonakTypeRequiredRule,Te as TokenCredentialProvider,L as TypeResolver,xe as UnresolvedPredicateRule,ce as UnresolvedReferenceRule,ne as ValidationContext,te as ValidationSeverity,be as buildOntologyModel,je as canonicalForm,De as canonicalHash,z as carrierOf,e as compareVersions,x as computeIntegrityAsync,He as createCredentialedFetch,r as createVersion,Le as findDerivation,t as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Ae as normalizeHost,Ne as parseAuthChallenge,f as parseLockFile,n as parseVersionString,$ as parseWithPositions,s as pickHighestDocument,k as serializeLockFile,c as setKanonakUserAgent,o as versionsEqual};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as Do}from"./chunk-KIBR3HAT.js";import{c as So,e as Io,f as oo,g as to,h as $o,i as jo,j as Oo,q as no,r as wo,s as Co}from"./chunk-Z5Y4MCW5.js";import{a as S,b as go,c as Ge,d as L,h as F,k as vo,m as j}from"./chunk-PVUBHIU2.js";import{a as fo}from"./chunk-HF5FJBS2.js";import{aa as ze,b as ko,ba as Ko,fa as $,ga as T,ha as H,ia as B,ja as Y,ma as Eo,na as W,oa as Vo}from"./chunk-7UYXTYXC.js";import{A as P,B as v,C as _,c as g,d as O,j as ee,k as G,l as M,m as b,n as q,p as ho,q as Ro,r as A,t as V,u as bo,w as oe,x as X,y as z,z as h}from"./chunk-CJMVIOZX.js";import{a as yo}from"./chunk-FUUTGGJS.js";import{b as Q,c as uo}from"./chunk-F67UH4FD.js";import{e as C}from"./chunk-QILEJIFU.js";var te=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(t=>(t.Info="Info",t.Warning="Warning",t.Error="Error",t))(R||{});var u=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ro=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let o=new p;return o.resolvedDocuments=this.resolvedDocuments,o.currentEntityPath=e,o}};var ne=class{constructor(e){this.underlying=e;this.repository=new ao(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Do(e,this.repository);let o={};return{merged:await new j().parseKanonaks(this.underlying,o),authored:o.authored??[]}})()),this.parsePromise}},ao=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){let t=`${e}/${o}`,n=this.byNamespaceCache.get(t);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,o),this.byNamespaceCache.set(t,n),n)}getHighestCompatibleVersionAsync(e,o){let t=o.version,n=t?`${t.major}.${t.minor}.${t.patch}`:"",r=`${e}/${o.packageName}@${o.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,o),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function I(p,e,o){return o?o.getKanonaks():new j().parseKanonaks(new re(p,e))}async function w(p,e,o){let t=await I(p,e,o),n=Xe(p);return n?t.filter(r=>r instanceof g&&r.namespace===n):[]}async function ae(p,e,o){let t=Xe(p);if(!t)return[];let n;if(o)n=await o.getAuthoredKanonaks();else{let r={};await new j().parseKanonaks(new re(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof g&&r.sourceDoc===t)}function Xe(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var re=class{constructor(e,o){this.document=e;this.broader=o}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),o=(await this.broader.getAllDocumentsAsync()).filter(t=>t.metadata.namespace_?.toString()!==e);return[this.document,...o]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){return this.broader.getDocumentsByNamespaceAsync(e,o)}getHighestCompatibleVersionAsync(e,o){return this.broader.getHighestCompatibleVersionAsync(e,o)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};var ie=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,o,t){let n=[],r=new Map;for(let[s,l]of Object.entries(e.metadata?.imports??{}))for(let m of l)Q(m)&&r.set(`${s}/${m.packageName}`,{publisher:s,import_:m});if(r.size===0)return n;let a=new Map,i=(s,l,m)=>{let d=`${s.publisher}/${s.package_}`;if(!r.has(d))return;let f=a.get(d)??[];f.push({uri:s,where:l,predicate:m}),a.set(d,f)},c=await w(e,o,t);L(c,({kanonak:s,path:l})=>{for(let m of s.statement){let d=m.predicate?.subject?.name??"(unknown)";if(m instanceof ee)i(m.object.subject,l,d);else if(m instanceof M)for(let f of m.object)f instanceof O&&i(f.subject,l,d);else if(m instanceof Ge)for(let f of m.links)f.target&&i(f.target.subject,l,d)}});for(let[s,l]of a){let{publisher:m,import_:d}=r.get(s),f=null,y;try{f=await o.getHighestCompatibleVersionAsync(m,d)}catch(k){y=k instanceof Error?k.message:String(k)}if(!f){let k=l[0],K=`${l.length} reference${l.length===1?"":"s"}, first at '${k.where}.${k.predicate}'`;this.options.offline?n.push(this.finding("Warning",k.where,k.predicate,s,`Link target package '${s}' could not be resolved offline (${K}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",k.where,k.predicate,s,`Link target package '${s}' could not be resolved${y?` (${y})`:""} \u2014 ${K}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:k,where:K,predicate:E}of l)Object.prototype.hasOwnProperty.call(f.body,k.name)||n.push(this.finding("Error",K,E,`${s}/${k.name}`,`Link to '${k.name}' in '${E}' at '${K}' does not dereference: package '${s}' (resolved to ${f.metadata.namespace_?.toString()??s}) defines no resource named '${k.name}'.`,`Check for a typo, or a resource renamed or removed in '${s}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var se=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let o=[];for(let[t,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(t,n,o);return o}validateEntity(e,o,t){for(let[n,r]of Object.entries(o)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),c=e.split(".")[0],s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=n,s.expectedValue=i,s.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,t)}}getSuggestionForPrefixedValue(e){let o=e.toLowerCase();if(o==="rdfs:class"||o==="owl:class")return"Class";if(o==="rdfs:property"||o==="rdf:property")return"DatatypeProperty or ObjectProperty";if(o.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var ce=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let o=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!t&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new u;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",o.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=n,c.message=`Invalid entity name '${n}'. ${i}`,c.suggestion=i,o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,o)}return o}validatePropertyNames(e,o,t){for(let n of Object.keys(o))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new u;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(r)}}};var pe=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let o=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return o;let t=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let c=[];if(Array.isArray(i))for(let s of i){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=i?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),d=new u;d.ruleType=this.ruleName,d.severity="Error",d.entityName=n,d.propertyName="type",d.actualValue=s,d.expectedValue=m,d.message=`Invalid property type '${s}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",o.push(d)}}}return o}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,o){let t=e[o];return t?t.toString():null}isPropertyDefinedAsClass(e){let o=e.body.Property;if(o&&typeof o=="object"&&!Array.isArray(o)){let n=o.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var le=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let o=[];for(let[t,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||t.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
1
|
+
import{a as Do}from"./chunk-KIBR3HAT.js";import{c as So,e as Io,f as oo,g as to,h as $o,i as jo,j as Oo,q as no,r as wo,s as Co}from"./chunk-Z5Y4MCW5.js";import{a as S,b as go,c as Ge,d as L,h as F,k as vo,m as j}from"./chunk-PVUBHIU2.js";import{a as fo}from"./chunk-HF5FJBS2.js";import{aa as ze,b as ko,ba as Ko,fa as $,ga as T,ha as H,ia as B,ja as Y,ma as Eo,na as W,oa as Vo}from"./chunk-7UYXTYXC.js";import{A as P,B as v,C as _,c as g,d as O,j as ee,k as G,l as M,m as b,n as q,p as ho,q as Ro,r as A,t as V,u as bo,w as oe,x as Z,y as z,z as h}from"./chunk-CJMVIOZX.js";import{a as yo}from"./chunk-FUUTGGJS.js";import{b as Q,c as uo}from"./chunk-F67UH4FD.js";import{e as C}from"./chunk-QILEJIFU.js";var te=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var R=(t=>(t.Info="Info",t.Warning="Warning",t.Error="Error",t))(R||{});var u=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ro=class p{resolvedDocuments=[];currentEntityPath;withPath(e){let o=new p;return o.resolvedDocuments=this.resolvedDocuments,o.currentEntityPath=e,o}};var ne=class{constructor(e){this.underlying=e;this.repository=new ao(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await Do(e,this.repository);let o={};return{merged:await new j().parseKanonaks(this.underlying,o),authored:o.authored??[]}})()),this.parsePromise}},ao=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){let t=`${e}/${o}`,n=this.byNamespaceCache.get(t);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,o),this.byNamespaceCache.set(t,n),n)}getHighestCompatibleVersionAsync(e,o){let t=o.version,n=t?`${t.major}.${t.minor}.${t.patch}`:"",r=`${e}/${o.packageName}@${o.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,o),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function I(p,e,o){return o?o.getKanonaks():new j().parseKanonaks(new re(p,e))}async function w(p,e,o){let t=await I(p,e,o),n=Ze(p);return n?t.filter(r=>r instanceof g&&r.namespace===n):[]}async function ae(p,e,o){let t=Ze(p);if(!t)return[];let n;if(o)n=await o.getAuthoredKanonaks();else{let r={};await new j().parseKanonaks(new re(p,e),r),n=r.authored??[]}return n.filter(r=>r instanceof g&&r.sourceDoc===t)}function Ze(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var re=class{constructor(e,o){this.document=e;this.broader=o}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),o=(await this.broader.getAllDocumentsAsync()).filter(t=>t.metadata.namespace_?.toString()!==e);return[this.document,...o]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,o){return this.broader.getDocumentsByNamespaceAsync(e,o)}getHighestCompatibleVersionAsync(e,o){return this.broader.getHighestCompatibleVersionAsync(e,o)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};var ie=class{constructor(e={}){this.options=e}options;ruleName="LinkTarget";async validateAsync(e,o,t){let n=[],r=new Map;for(let[s,l]of Object.entries(e.metadata?.imports??{}))for(let m of l)Q(m)&&r.set(`${s}/${m.packageName}`,{publisher:s,import_:m});if(r.size===0)return n;let a=new Map,i=(s,l,m)=>{let d=`${s.publisher}/${s.package_}`;if(!r.has(d))return;let f=a.get(d)??[];f.push({uri:s,where:l,predicate:m}),a.set(d,f)},c=await w(e,o,t);L(c,({kanonak:s,path:l})=>{for(let m of s.statement){let d=m.predicate?.subject?.name??"(unknown)";if(m instanceof ee)i(m.object.subject,l,d);else if(m instanceof M)for(let f of m.object)f instanceof O&&i(f.subject,l,d);else if(m instanceof Ge)for(let f of m.links)f.target&&i(f.target.subject,l,d)}});for(let[s,l]of a){let{publisher:m,import_:d}=r.get(s),f=null,y;try{f=await o.getHighestCompatibleVersionAsync(m,d)}catch(k){y=k instanceof Error?k.message:String(k)}if(!f){let k=l[0],K=`${l.length} reference${l.length===1?"":"s"}, first at '${k.where}.${k.predicate}'`;this.options.offline?n.push(this.finding("Warning",k.where,k.predicate,s,`Link target package '${s}' could not be resolved offline (${K}); the link is UNVERIFIED, not known to be broken.`,"Run without --offline to verify the link over HTTP, or add the package to the workspace or cache.")):n.push(this.finding("Error",k.where,k.predicate,s,`Link target package '${s}' could not be resolved${y?` (${y})`:""} \u2014 ${K}.`,"Check the publisher and package name of the link import; a link must dereference even though it is not a dependency. Use --offline to validate without the network (the link is then reported as unverified)."));continue}for(let{uri:k,where:K,predicate:E}of l)Object.prototype.hasOwnProperty.call(f.body,k.name)||n.push(this.finding("Error",K,E,`${s}/${k.name}`,`Link to '${k.name}' in '${E}' at '${K}' does not dereference: package '${s}' (resolved to ${f.metadata.namespace_?.toString()??s}) defines no resource named '${k.name}'.`,`Check for a typo, or a resource renamed or removed in '${s}'; a link addresses a resource by name in its package's current version unless the import is pinned with '='.`))}return n}finding(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.actualValue=n,i.expectedValue="A link that dereferences to a resource its target package defines",i.message=r,i.suggestion=a,i}};var se=class p{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):[A-Za-z_][A-Za-z0-9_.-]*$/i;ruleName="NamespacePrefix";validate(e){let o=[];for(let[t,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(t,n,o);return o}validateEntity(e,o,t){for(let[n,r]of Object.entries(o)){let a=r?.toString()??"";if(a&&p.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),c=e.split(".")[0],s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=n,s.expectedValue=i,s.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,t)}}getSuggestionForPrefixedValue(e){let o=e.toLowerCase();if(o==="rdfs:class"||o==="owl:class")return"Class";if(o==="rdfs:property"||o==="rdf:property")return"DatatypeProperty or ObjectProperty";if(o.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var ce=class p{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let o=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=p.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!t&&p.RESERVED_WORDS.has(n.toLowerCase())){let i=new u;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",o.push(i);continue}if(!a&&!p.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=n,c.message=`Invalid entity name '${n}'. ${i}`,c.suggestion=i,o.push(c)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,o)}return o}validatePropertyNames(e,o,t){for(let n of Object.keys(o))if(!p.VALID_PROPERTIES.has(n)&&!p.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new u;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(r)}}};var pe=class p{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let o=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return o;let t=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let c=[];if(Array.isArray(i))for(let s of i){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=i?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),d=new u;d.ruleType=this.ruleName,d.severity="Error",d.entityName=n,d.propertyName="type",d.actualValue=s,d.expectedValue=m,d.message=`Invalid property type '${s}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",o.push(d)}}}return o}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":p.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,o){let t=e[o];return t?t.toString():null}isPropertyDefinedAsClass(e){let o=e.body.Property;if(o&&typeof o=="object"&&!Array.isArray(o)){let n=o.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var le=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let o=[];for(let[t,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||t.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let c=new u;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
2
2
|
type: Scene
|
|
3
3
|
|
|
4
4
|
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",o.push(c)}}return o}};var ot=new Set(["EphemeralPackage"]),me=class{get ruleName(){return"PackageHeader"}validate(e){let o=e.metadata;if(!o.type_)return[];let t=[],n=this.packageKey(e,o.type_);return o.namespace_?(!ot.has(o.type_)&&!o.namespace_.version&&t.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
|
|
5
5
|
version: 1.0.0`)),t):(t.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
|
|
6
|
-
publisher: example.org`)),t)}packageKey(e,o){for(let[t,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===o)return t;return o}error(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.message=t,r.suggestion=n,r}};var tt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},nt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},rt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},at={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},ue=class{ruleName="EmbeddedKanonakType";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof G){let a=r.predicate?.subject,i=`${t}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,t,i,n),this.walk(e,r.object,i,n)}else if(r instanceof M){let a=r.predicate?.subject,i=0;for(let c of r.object){if(c instanceof S){let s=`${t}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,c,t,s,n),this.walk(e,c,s,n)}i++}}}check(e,o,t,n,r,a){if(!o)return;let i=h(t,tt);if(!i)return;let c=V(e,o);if(!c)return;let s=h(c,nt);if(s&&!(q(s,rt)||q(s,at))){if(b(i)===b(s)){a.push(this.redundant(n,r,i,s));return}H(e,i).some(l=>b(l)===b(s))||a.push(this.notSubclass(n,r,i,s))}}redundant(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' declares 'type: ${t.name}', which equals the parent property's range '${n.name}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,r.suggestion=`Remove the 'type: ${t.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' has 'type: ${t.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${t.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${t.name}' class definition so the relationship holds.`,r}};import{VersionOperator as
|
|
6
|
+
publisher: example.org`)),t)}packageKey(e,o){for(let[t,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===o)return t;return o}error(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.message=t,r.suggestion=n,r}};var tt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},nt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},rt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},at={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},ue=class{ruleName="EmbeddedKanonakType";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await ae(e,o,t);for(let i of a)i instanceof g&&this.walk(r,i,i.name,n);return n}walk(e,o,t,n){for(let r of o.statement)if(r instanceof G){let a=r.predicate?.subject,i=`${t}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,t,i,n),this.walk(e,r.object,i,n)}else if(r instanceof M){let a=r.predicate?.subject,i=0;for(let c of r.object){if(c instanceof S){let s=`${t}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,c,t,s,n),this.walk(e,c,s,n)}i++}}}check(e,o,t,n,r,a){if(!o)return;let i=h(t,tt);if(!i)return;let c=V(e,o);if(!c)return;let s=h(c,nt);if(s&&!(q(s,rt)||q(s,at))){if(b(i)===b(s)){a.push(this.redundant(n,r,i,s));return}H(e,i).some(l=>b(l)===b(s))||a.push(this.notSubclass(n,r,i,s))}}redundant(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' declares 'type: ${t.name}', which equals the parent property's range '${n.name}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,r.suggestion=`Remove the 'type: ${t.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,o,t,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t.name,r.expectedValue=n.name,r.message=`Embedded object at '${o}' has 'type: ${t.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${t.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${t.name}' class definition so the relationship holds.`,r}};import{VersionOperator as Xe}from"@kanonak-protocol/types/document/models/enums";var de=class{ruleName="ImportExistence";async validateAsync(e,o){let t=[];if(!e.metadata?.imports)return t;let n=await o.getAllDocumentsAsync();for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){if(Q(i))continue;if(!await o.getHighestCompatibleVersionAsync(r,i)){let s=await this.determineImportErrorAsync(o,r,i,n),l=new u;l.ruleType=this.ruleName,l.severity="Error",l.message=s.message,l.suggestion=s.suggestion,l.entityName=`Import: ${r}/${i.packageName}`,l.actualValue=i.toString(),l.expectedValue=s.expectedValue,t.push(l)}}return t}async determineImportErrorAsync(e,o,t,n){let r=await e.getDocumentsByNamespaceAsync(o,t.packageName);if(r.length===0){let s=n.filter(f=>f.metadata.namespace_?.publisher===o).map(f=>f.metadata.namespace_.package_).filter((f,y,k)=>k.indexOf(f)===y),l=this.findSimilarPackages(t.packageName,s),m=`Import '${o}/${t.package_}' not found - package does not exist`,d=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:s.length>0?`Available packages in ${o}: ${s.slice(0,5).join(", ")}`:`No packages found for publisher '${o}'. Verify the publisher name is correct.`;return{message:m,suggestion:d,expectedValue:"Existing package"}}let i=r.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${o}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case Xe.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Xe.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Xe.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Xe.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,o){if(o.length===0)return[];let t=o.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(t.length>0)return t.sort((a,i)=>a.length-i.length);let n=o.map(a=>({package:a,distance:this.levenshteinDistance(e.toLowerCase(),a.toLowerCase())})).sort((a,i)=>a.distance-i.distance),r=Math.max(3,Math.floor(e.length*.4));return n.filter(a=>a.distance<=r).map(a=>a.package)}levenshteinDistance(e,o){if(!e||e.length===0)return o?.length??0;if(!o||o.length===0)return e.length;let t=e.length,n=o.length,r=Array(t+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=t;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=t;a++)for(let i=1;i<=n;i++){let c=e[a-1]===o[i-1]?0:1;r[a][i]=Math.min(Math.min(r[a-1][i]+1,r[a][i-1]+1),r[a-1][i-1]+c)}return r[t][n]}};var it="kanonak.org",st="core-rdf",ct=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(p=>b({publisher:it,package_:st,name:p}))),fe=class{ruleName="UnresolvedReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t),i=uo(e),c=s=>i.has(`${s.subject.publisher}/${s.subject.package_}`);return L(a,({kanonak:s,path:l})=>{for(let m of s.statement){let d=pt(m);if(!(!d||ct.has(b(d)))){if(m instanceof ee)c(m.object)||this.check(r,l,d,m.object,n);else if(m instanceof M)for(let f of m.object)f instanceof O&&!c(f)&&this.check(r,l,d,f,n)}}}),n}check(e,o,t,n,r){V(e,n.subject)||r.push(this.unresolvedError(o,t.name,n.subject))}unresolvedError(e,o,t){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${t.name}' in '${o}' could not be resolved`,r.suggestion=`The entity '${n}' is not defined in this namespace or any imported namespace.
|
|
7
7
|
\u2022 Import the package that defines it, or check for a typo in '${t.name}'
|
|
8
|
-
\u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function pt(p){return p.predicate?.subject}var Po={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Uo={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function lt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Je(p,e,o){let t=[],n=new Set,r=new Set,a=i=>{let c=V(p,i),s=c?`${c.namespace}/${c.name}`:b(i);if(n.has(s)){let l=t.findIndex(d=>d.key===s),m=t.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(s))return null;if(n.add(s),t.push({key:s,uri:i}),c)for(let l of lt(c,o)){let m=a(l);if(m)return m}return t.pop(),n.delete(s),r.add(s),null};return a(e)}var Ao=p=>p,ye=class{ruleName="ClassHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!($.isClassType(Ao(i))||$.isDatatypeType(Ao(i))))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Po);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular class hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",m.entityName=i.name,m.propertyName="subClassOf",m.actualValue=l,n.push(m);break}}return n}};var ge=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Uo);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=i.name,m.propertyName="subPropertyOf",m.actualValue=l,n.push(m);break}}return n}};var mt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ke=class{ruleName="PropertyRangeRequired";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";oe(i,mt)||n.push(this.error(i.name,s))}return n}error(e,o){let t=new u;return t.ruleType=this.ruleName,t.severity="Error",t.entityName=e,t.propertyName="range",t.message=`Property '${e}' must have a 'range' defined.`,t.suggestion=o?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",t.expectedValue=o?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",t}};var ut={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},No=p=>p,he=class{ruleName="SubClassOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!To(No(i)))continue;let c=dt(i,ut);for(let s=0;s<c.length;s++)this.resolvesToClassLike(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?To(No(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subClassOf",r.actualValue=n,r.expectedValue="Defined or imported class",r.message=`Class '${o.name}' referenced in subClassOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a Class, or import a namespace that contains it`,r}};function To(p){return $.isClassType(p)||$.isDatatypeType(p)}function dt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ft={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Re=class{ruleName="SubPropertyOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=yt(i,ft);for(let s=0;s<c.length;s++)this.resolvesToProperty(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToProperty(e,o){let t=V(e,o);return t?Y(e,t):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subPropertyOf",r.actualValue=n,r.expectedValue="Defined or imported property",r.message=`Property '${o.name}' referenced in subPropertyOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a property, or import a namespace that contains it`,r}};function yt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var be=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,o){let t=[],n=e.metadata.namespace_?.toString();if(!n)return t;let r=new Map,a=new Set;await this.buildImportGraph(e,o,r,a);let i=this.detectCycle(n,r);if(i){let c=i.join(" \u2192 "),s=new u;s.ruleType=this.ruleName,s.severity="Error",s.message=`Circular namespace import detected: ${c}`,s.suggestion="Remove one of the imports to break the circular dependency, or \u2014 if one direction is a DATA reference rather than a schema dependency (an object-property value naming a resource in the other package) \u2014 mark that import `mode: link`: links are dereferenced on demand, are not in the closure, and are exempt from this rule. Circular dependencies prevent proper package resolution.",s.entityName="imports",s.propertyName="imports",s.actualValue=c,t.push(s)}return t}async buildImportGraph(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,c]of Object.entries(e.metadata.imports))for(let s of c){if(Q(s))continue;let l=`${i}/${s.packageName}@${s.version}`;a.push(l);let m=await o.getHighestCompatibleVersionAsync(i,s);m&&await this.buildImportGraph(m,o,t,n)}a.length>0&&t.set(r,a)}}detectCycle(e,o){let t=[],n=new Set;return this.detectCycleRecursive(e,o,t,n)}detectCycleRecursive(e,o,t,n){let r=t.indexOf(e);if(r>=0){let i=t.slice(r);return i.push(e),i}if(n.has(e))return null;t.push(e),n.add(e);let a=o.get(e);if(a)for(let i of a){let c=this.detectCycleRecursive(i,o,t,n);if(c)return c}return t.pop(),null}};var Ke=class{ruleName="UnresolvedPredicate";async validateAsync(e,o,t){let n=[],r=
|
|
8
|
+
\u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function pt(p){return p.predicate?.subject}var Po={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Uo={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function lt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}function Je(p,e,o){let t=[],n=new Set,r=new Set,a=i=>{let c=V(p,i),s=c?`${c.namespace}/${c.name}`:b(i);if(n.has(s)){let l=t.findIndex(d=>d.key===s),m=t.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(s))return null;if(n.add(s),t.push({key:s,uri:i}),c)for(let l of lt(c,o)){let m=a(l);if(m)return m}return t.pop(),n.delete(s),r.add(s),null};return a(e)}var Ao=p=>p,ye=class{ruleName="ClassHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!($.isClassType(Ao(i))||$.isDatatypeType(Ao(i))))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Po);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular class hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",m.entityName=i.name,m.propertyName="subClassOf",m.actualValue=l,n.push(m);break}}return n}};var ge=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=T(i);if(!c)continue;let s=Je(r,c,Uo);if(s){let l=s.map(d=>d.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=i.name,m.propertyName="subPropertyOf",m.actualValue=l,n.push(m);break}}return n}};var mt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ke=class{ruleName="PropertyRangeRequired";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g))continue;let c=B(r,i);if(c!=="ObjectProperty"&&c!=="DatatypeProperty")continue;let s=c==="ObjectProperty";oe(i,mt)||n.push(this.error(i.name,s))}return n}error(e,o){let t=new u;return t.ruleType=this.ruleName,t.severity="Error",t.entityName=e,t.propertyName="range",t.message=`Property '${e}' must have a 'range' defined.`,t.suggestion=o?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",t.expectedValue=o?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",t}};var ut={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},No=p=>p,he=class{ruleName="SubClassOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!To(No(i)))continue;let c=dt(i,ut);for(let s=0;s<c.length;s++)this.resolvesToClassLike(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToClassLike(e,o){let t=V(e,o);return t?To(No(t)):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subClassOf",r.actualValue=n,r.expectedValue="Defined or imported class",r.message=`Class '${o.name}' referenced in subClassOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a Class, or import a namespace that contains it`,r}};function To(p){return $.isClassType(p)||$.isDatatypeType(p)}function dt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var ft={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Re=class{ruleName="SubPropertyOfReference";async validateAsync(e,o,t){let n=[],r=await I(e,o,t),a=await w(e,o,t);for(let i of a){if(!(i instanceof g)||!Y(r,i))continue;let c=yt(i,ft);for(let s=0;s<c.length;s++)this.resolvesToProperty(r,c[s])||n.push(this.error(i.name,c[s],c.length>1?`[${s}]`:""))}return n}resolvesToProperty(e,o){let t=V(e,o);return t?Y(e,t):!1}error(e,o,t){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subPropertyOf",r.actualValue=n,r.expectedValue="Defined or imported property",r.message=`Property '${o.name}' referenced in subPropertyOf${t} is not defined or imported`,r.suggestion=`Define '${o.name}' as a property, or import a namespace that contains it`,r}};function yt(p,e){let o=h(p,e);if(o)return[o];let t=[];for(let n of v(p,e))n instanceof O&&t.push(n.subject);return t}var be=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,o){let t=[],n=e.metadata.namespace_?.toString();if(!n)return t;let r=new Map,a=new Set;await this.buildImportGraph(e,o,r,a);let i=this.detectCycle(n,r);if(i){let c=i.join(" \u2192 "),s=new u;s.ruleType=this.ruleName,s.severity="Error",s.message=`Circular namespace import detected: ${c}`,s.suggestion="Remove one of the imports to break the circular dependency, or \u2014 if one direction is a DATA reference rather than a schema dependency (an object-property value naming a resource in the other package) \u2014 mark that import `mode: link`: links are dereferenced on demand, are not in the closure, and are exempt from this rule. Circular dependencies prevent proper package resolution.",s.entityName="imports",s.propertyName="imports",s.actualValue=c,t.push(s)}return t}async buildImportGraph(e,o,t,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,c]of Object.entries(e.metadata.imports))for(let s of c){if(Q(s))continue;let l=`${i}/${s.packageName}@${s.version}`;a.push(l);let m=await o.getHighestCompatibleVersionAsync(i,s);m&&await this.buildImportGraph(m,o,t,n)}a.length>0&&t.set(r,a)}}detectCycle(e,o){let t=[],n=new Set;return this.detectCycleRecursive(e,o,t,n)}detectCycleRecursive(e,o,t,n){let r=t.indexOf(e);if(r>=0){let i=t.slice(r);return i.push(e),i}if(n.has(e))return null;t.push(e),n.add(e);let a=o.get(e);if(a)for(let i of a){let c=this.detectCycleRecursive(i,o,t,n);if(c)return c}return t.pop(),null}};var Ke=class{ruleName="UnresolvedPredicate";async validateAsync(e,o,t){let n=[],r=Ze(e);if(!r)return n;let a=await I(e,o,t);return L(a,({kanonak:i,path:c})=>{for(let s of i.unresolvedPredicates)s.sourceDoc===r&&n.push(this.unresolvedPredicateError(c,s.key))}),n}unresolvedPredicateError(e,o){let t=o.lastIndexOf("."),n=t>0?o.slice(0,t):null,r=t>0?o.slice(t+1):o,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=o,a.expectedValue="A defined or imported property",a.message=`Property '${o}' is not defined or imported`,a.suggestion=n?`The property '${r}' was not found in the namespace imported as '${n}'.
|
|
9
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 '${o}' is not defined in this namespace or any imported namespace.
|
|
@@ -36,7 +36,7 @@ line (let the line run long), or check for an unterminated [[.`,n}};var Wo="kano
|
|
|
36
36
|
Possible solutions:
|
|
37
37
|
\u2022 Point ${o} 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 Ct(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}function
|
|
39
|
+
\u2022 Use rdfs.label / rdfs.comment for the universal default`,n}};function Ct(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}function X(p,e,o){let t=[];return We(p,o,{input:e},t),t}function We(p,e,o,t){if(A(e,F.VarRef)){let a=z(e,F.varName);return a?o[a]:void 0}if(A(e,F.PropertyRead)){let a=P(e,F.readSource),i=a?We(p,a,o,t):void 0,c=h(e,F.readProp);if(!i||!c)return;let s=W(p,i,c);if(!s.ok){t.push({contextClass:i,propertyUri:c,via:"PropertyRead"});return}return s.descriptor?.range}if(A(e,F.Traverse)){let a=P(e,F.traverseSource),i=a?We(p,a,o,t):void 0,c=h(e,F.through),s;if(i&&c){let m=W(p,i,c);m.ok?s=m.descriptor?.range:t.push({contextClass:i,propertyUri:c,via:"Traverse"})}let l=P(e,F.step);return l?We(p,l,{...o,input:s},t):void 0}let n=z(e,F.loopVar),r=n?{...o,[n]:void 0}:o;for(let a of Pt(e))We(p,a,r,t)}function Pt(p){let e=[];for(let o of p.statement){let t=o.object;if(t instanceof S)e.push(t);else if(Array.isArray(t))for(let n of t)n instanceof S&&e.push(n)}return e}var Fe="kanonak.org",qe="look",Ut={publisher:Fe,package_:qe,name:"semanticSvg"},At={publisher:Fe,package_:qe,name:"tierChip"},Nt={publisher:Fe,package_:qe,name:"tierIcon"},Tt={publisher:Fe,package_:qe,name:"tierCard"},xt={publisher:Fe,package_:qe,name:"tierFull"},_t=[At,Nt,Tt,xt],Ce=class{ruleName="LookSemanticSvgPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=Lt(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,o,t){let n=P(o,Ut);if(!n)return;let r=T(o);if(r)for(let a of _t){let i=P(n,a);if(i)for(let c of X(e,r,i))t.push(this.toError(o.name,a.name,c))}}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.contextClass.name,a=r===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${r}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${o}`,i.actualValue=n,i.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${a}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${n}' is not in scope for '${r}'.
|
|
40
40
|
|
|
41
41
|
Possible solutions:
|
|
42
42
|
\u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
|
|
@@ -46,12 +46,12 @@ Possible solutions:
|
|
|
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 Wt(p){let e=[];for(let o of p.statement){let t=o.predicate?.subject;if(o instanceof G)e.push({child:o.object,predicate:t});else if(o instanceof M)for(let n of o.object)n instanceof S&&e.push({child:n,predicate:t})}return e}function Ft(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qt="kanonak.org",He=(p,e)=>({publisher:qt,package_:p,name:e}),Ht=He("derivation","look"),Ho=He("look","bands"),Yo=He("look","Sequence"),Yt=He("core-rdf","range"),Gt=He("look","nodeTier"),Ue=class{ruleName="SequenceNarrative";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=zt(e);if(!a)return n;let i=r.filter(s=>s instanceof g&&s.namespace===a);if(i.length===0)return n;for(let s of i){let l=P(s,Ht);l&&v(l,Ho).forEach((m,d)=>{!(m instanceof S)||!A(m,Yo)||n.push(...this.checkBand(r,s,m,`${s.name}.look.bands[${d}]`))})}let c=new wo(r);for(let s of i){let l=c.findCascadedLook(s);if(l)for(let m of v(l.declaration,Ho))!(m instanceof S)||!A(m,Yo)||this.checkBand(r,s,m,"").length>0||n.push(...this.checkInstance(r,s,m,$o(r,s,m)))}return n}checkBand(e,o,t,n){let r=[],a=(l,m,d)=>r.push(this.toError("Error",o.name,n,l,m,d)),i=oo(t);if(!i)a("A look.Sequence band declares no look.source. The order of a sequence comes from the [[references]] in a prose property, so without one nothing can be sequenced.","Set look.source to a property of this class whose rdfs.range is prose.Markdown (or prose.SubstitutableString), and render the same property with a look.Markdown band so the narrative and the diagram cannot drift.");else{let l=bo(e,i)[0],m=l?Ro(l,Yt):[];l&&!m.some(d=>ko.isSubstitutableDatatypeUri(d))&&a(`look.source names '${i.name}', whose rdfs.range is ${m.map(d=>b(d)).join(", ")||"undeclared"} \u2014 not prose.Markdown. A Sequence orders its participants by the [[references]] in prose, so a value of this property carries no order.`,"Point look.source at a prose.Markdown-ranged property, or give this property that range if its values are narrative.",b(i))}let c=to(e,t);c.length===0&&a("A look.Sequence band declares no look.connectors, so no property counts as a message and every narrative renders empty.","List the object properties that constitute messages: look.connectors: [{ look.relation: calls }, ...]. The domain ontology declares nothing about sequences; the look layer says which of its relations are interactions.");for(let l of c)(!l.subject||B(e,l.subject)===void 0)&&a(`look.connectors names '${l.relation.name}' as a relation, but it is not a property${l.subject?"":" in the closure"}. A message is a triple, so its relation must be an object property whose values are the participants.`,"Use an owl.ObjectProperty (or a subclass such as owl.SymmetricProperty) for look.relation.",b(l.relation)),l.invalidStyle!==void 0&&a(`look.lineStyle '${l.invalidStyle}' on connector '${l.relation.name}' is not a supported value. Supported: ${[...Io].join(", ")}.`,"Use one of the supported values, or omit look.lineStyle: a reply is derived from owl.inverseOf and an undirected edge from owl.SymmetricProperty, so the overlay is only needed for what the ontology cannot say.",l.invalidStyle);let s=z(t,Gt);return s!==void 0&&no[s]===void 0&&a(`look.nodeTier '${s}' is not a tier. Supported: ${Object.keys(no).join(", ")}.`,"Use one of the semantic-zoom tiers \u2014 chip (56), icon (120, the default), card (240), full (420) \u2014 or omit look.nodeTier to take the participants' class-level look.diagramTier.",s),r}checkInstance(e,o,t,n){let r=[],a=oo(t),i=`${o.name}.${a.name}`,c=to(e,t).map(s=>s.relation.name).join(", ");if(n.problem)return r.push(this.toError("Error",o.name,i,`The look.Sequence band cannot walk this instance: ${n.problem}.`,"Check the value authored for the source property.")),r;if(n.sourceAbsent)return r.push(this.toError("Warning",o.name,i,`'${o.name}' carries no value for '${a.name}', so its look.Sequence band renders nothing.`,`Author the narrative in '${a.name}' with [[references]] to the participants, or leave it if the band is meant to be empty here.`)),r;for(let s of n.strayPropertyRefs)r.push(this.toError("Error",o.name,i,`The narrative references property '${s.name}', which is not a declared connector of the look.Sequence band (declared: ${c}). A property reference between two participants selects the edge for that pair; one the band does not declare selects nothing, and the sentence draws no message.`,`Add { look.relation: ${s.name} } to look.connectors on the band, or reference one of the declared connectors instead.`,b(s)));if(n.mentions>=2&&n.messages.length===0)return r.push(this.toError("Error",o.name,i,`The narrative mentions ${n.mentions} participant references but joins nothing: no declared connector (${c}) holds between any consecutive pair, so the look.Sequence band renders no message.`,"Either the graph is missing the triples the prose describes (declare them on the participants), the band is missing the relation the prose relies on (add it to look.connectors), or the prose orders participants no relation joins (reorder it).")),r;for(let s of n.gaps){let l=s.selected?`'${s.selected.name}' does not hold`:`no declared connector (${c}) holds`;r.push(this.toError("Warning",o.name,i,`The narrative orders '${s.prev.name}' then '${s.next.name}', but ${l} between them in the graph, so no message is drawn for that pair.`,`If the prose is right, declare the relation on '${s.prev.name}' or '${s.next.name}' (or add it to look.connectors); if the graph is right, reorder the prose so consecutive references are joined. A mention that is meant to connect to nothing is fine \u2014 it simply gets no lifeline.`,`${s.prev.name} \u2192 ${s.next.name}`))}return r}toError(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function zt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var
|
|
49
|
+
\u2022 If the node class should be supported, implement it in the runner first`,r}};function Wt(p){let e=[];for(let o of p.statement){let t=o.predicate?.subject;if(o instanceof G)e.push({child:o.object,predicate:t});else if(o instanceof M)for(let n of o.object)n instanceof S&&e.push({child:n,predicate:t})}return e}function Ft(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var qt="kanonak.org",He=(p,e)=>({publisher:qt,package_:p,name:e}),Ht=He("derivation","look"),Ho=He("look","bands"),Yo=He("look","Sequence"),Yt=He("core-rdf","range"),Gt=He("look","nodeTier"),Ue=class{ruleName="SequenceNarrative";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=zt(e);if(!a)return n;let i=r.filter(s=>s instanceof g&&s.namespace===a);if(i.length===0)return n;for(let s of i){let l=P(s,Ht);l&&v(l,Ho).forEach((m,d)=>{!(m instanceof S)||!A(m,Yo)||n.push(...this.checkBand(r,s,m,`${s.name}.look.bands[${d}]`))})}let c=new wo(r);for(let s of i){let l=c.findCascadedLook(s);if(l)for(let m of v(l.declaration,Ho))!(m instanceof S)||!A(m,Yo)||this.checkBand(r,s,m,"").length>0||n.push(...this.checkInstance(r,s,m,$o(r,s,m)))}return n}checkBand(e,o,t,n){let r=[],a=(l,m,d)=>r.push(this.toError("Error",o.name,n,l,m,d)),i=oo(t);if(!i)a("A look.Sequence band declares no look.source. The order of a sequence comes from the [[references]] in a prose property, so without one nothing can be sequenced.","Set look.source to a property of this class whose rdfs.range is prose.Markdown (or prose.SubstitutableString), and render the same property with a look.Markdown band so the narrative and the diagram cannot drift.");else{let l=bo(e,i)[0],m=l?Ro(l,Yt):[];l&&!m.some(d=>ko.isSubstitutableDatatypeUri(d))&&a(`look.source names '${i.name}', whose rdfs.range is ${m.map(d=>b(d)).join(", ")||"undeclared"} \u2014 not prose.Markdown. A Sequence orders its participants by the [[references]] in prose, so a value of this property carries no order.`,"Point look.source at a prose.Markdown-ranged property, or give this property that range if its values are narrative.",b(i))}let c=to(e,t);c.length===0&&a("A look.Sequence band declares no look.connectors, so no property counts as a message and every narrative renders empty.","List the object properties that constitute messages: look.connectors: [{ look.relation: calls }, ...]. The domain ontology declares nothing about sequences; the look layer says which of its relations are interactions.");for(let l of c)(!l.subject||B(e,l.subject)===void 0)&&a(`look.connectors names '${l.relation.name}' as a relation, but it is not a property${l.subject?"":" in the closure"}. A message is a triple, so its relation must be an object property whose values are the participants.`,"Use an owl.ObjectProperty (or a subclass such as owl.SymmetricProperty) for look.relation.",b(l.relation)),l.invalidStyle!==void 0&&a(`look.lineStyle '${l.invalidStyle}' on connector '${l.relation.name}' is not a supported value. Supported: ${[...Io].join(", ")}.`,"Use one of the supported values, or omit look.lineStyle: a reply is derived from owl.inverseOf and an undirected edge from owl.SymmetricProperty, so the overlay is only needed for what the ontology cannot say.",l.invalidStyle);let s=z(t,Gt);return s!==void 0&&no[s]===void 0&&a(`look.nodeTier '${s}' is not a tier. Supported: ${Object.keys(no).join(", ")}.`,"Use one of the semantic-zoom tiers \u2014 chip (56), icon (120, the default), card (240), full (420) \u2014 or omit look.nodeTier to take the participants' class-level look.diagramTier.",s),r}checkInstance(e,o,t,n){let r=[],a=oo(t),i=`${o.name}.${a.name}`,c=to(e,t).map(s=>s.relation.name).join(", ");if(n.problem)return r.push(this.toError("Error",o.name,i,`The look.Sequence band cannot walk this instance: ${n.problem}.`,"Check the value authored for the source property.")),r;if(n.sourceAbsent)return r.push(this.toError("Warning",o.name,i,`'${o.name}' carries no value for '${a.name}', so its look.Sequence band renders nothing.`,`Author the narrative in '${a.name}' with [[references]] to the participants, or leave it if the band is meant to be empty here.`)),r;for(let s of n.strayPropertyRefs)r.push(this.toError("Error",o.name,i,`The narrative references property '${s.name}', which is not a declared connector of the look.Sequence band (declared: ${c}). A property reference between two participants selects the edge for that pair; one the band does not declare selects nothing, and the sentence draws no message.`,`Add { look.relation: ${s.name} } to look.connectors on the band, or reference one of the declared connectors instead.`,b(s)));if(n.mentions>=2&&n.messages.length===0)return r.push(this.toError("Error",o.name,i,`The narrative mentions ${n.mentions} participant references but joins nothing: no declared connector (${c}) holds between any consecutive pair, so the look.Sequence band renders no message.`,"Either the graph is missing the triples the prose describes (declare them on the participants), the band is missing the relation the prose relies on (add it to look.connectors), or the prose orders participants no relation joins (reorder it).")),r;for(let s of n.gaps){let l=s.selected?`'${s.selected.name}' does not hold`:`no declared connector (${c}) holds`;r.push(this.toError("Warning",o.name,i,`The narrative orders '${s.prev.name}' then '${s.next.name}', but ${l} between them in the graph, so no message is drawn for that pair.`,`If the prose is right, declare the relation on '${s.prev.name}' or '${s.next.name}' (or add it to look.connectors); if the graph is right, reorder the prose so consecutive references are joined. A mention that is meant to connect to nothing is fine \u2014 it simply gets no lifeline.`,`${s.prev.name} \u2192 ${s.next.name}`))}return r}toError(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=e,i.entityName=o,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function zt(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Zt="kanonak.org",D=(p,e)=>({publisher:Zt,package_:p,name:e}),Xt=D("derivation","look"),Jt=D("look","bands"),Qt=D("look","Distribution"),en=D("look","StatRow"),on=D("look","VersionDelta"),tn=D("look","Timeline"),nn=D("look","VersionDiff"),rn=D("look","TimePlot"),an=D("look","ReferenceList"),sn=D("look","Diagram"),cn=D("look","alphaPath"),pn=D("look","betaPath"),po=D("look","metricPath"),Go=D("look","lowerPath"),zo=D("look","upperPath"),Zo=D("look","hueBy"),ln=D("look","statPath"),mn=D("look","laneBy"),Xo=D("look","labelPath"),un=D("look","badgePath"),dn=D("look","mapPath"),fn=D("look","nodeNote"),yn=D("look","edgeValue"),gn=D("look","stats"),kn=D("look","facets"),hn=D("look","channels"),Rn=D("look","track"),bn=D("look","source"),Kn=D("look","relation"),En=D("look","entries"),Ae=class{ruleName="LookBandPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=vn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,o,t){let n=P(o,Xt);if(!n)return;let r=T(o);if(!r)return;let a=v(n,Jt).filter(i=>i instanceof S);for(let i of a)for(let c of this.carriersOf(e,i,r))for(let s of X(e,c.context,c.expr))t.push(this.toError(o.name,c.slot,s))}carriersOf(e,o,t){let n=[],r=(a,i)=>{let c=P(o,a);c&&n.push({slot:`look.${a.name}`,context:i,expr:c})};if(A(o,Qt))for(let a of[cn,pn,po,Go,zo,Zo])r(a,t);if(A(o,on)&&r(po,t),A(o,en)){let a=v(o,gn).filter(i=>i instanceof S);for(let i of a){let c=P(i,ln);c&&n.push({slot:"look.stats[].statPath",context:t,expr:c})}}if(A(o,tn)||A(o,nn)){let a=this.rangeOf(e,t,h(o,Rn));if(a)for(let i of[po,Go,zo,Zo])r(i,a)}if(A(o,rn)){let a=this.rangeOf(e,t,h(o,bn));if(a)for(let i of[mn,Xo])r(i,a)}if(A(o,an))for(let a of v(o,En)){let i=a instanceof S?void 0:Vn(a),c=this.rangeOf(e,t,i);if(c)for(let s of[Xo,un])r(s,c)}if(A(o,sn)){let a=v(o,kn).filter(i=>i instanceof S);for(let i of a){let c=this.rangeOf(e,t,h(i,Kn));if(!c)continue;let s=P(i,fn);s&&n.push({slot:"look.facets[].nodeNote",context:c,expr:s});let l=P(i,yn);l&&n.push({slot:"look.facets[].edgeValue",context:c,expr:l});let m=v(i,hn).filter(d=>d instanceof S);for(let d of m){let f=P(d,dn);f&&n.push({slot:"look.facets[].channels[].mapPath",context:c,expr:f})}}}return n}rangeOf(e,o,t){if(!t)return;let n=W(e,o,t);return n.ok?n.descriptor?.range:void 0}toError(e,o,t){let n=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,r=t.contextClass.name,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=o,a.actualValue=n,a.message=`tx.${t.via} reads property '${t.propertyUri.name}', but its domain is not in scope for '${r}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,a.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${n}' is not in scope for '${r}'.
|
|
50
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 Vn(p){let e=p.subject;return e&&typeof e.name=="string"?e:void 0}function vn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Dn="kanonak.org",lo=(p,e)=>({publisher:Dn,package_:p,name:e}),Sn=lo("derivation","look"),In=lo("look","bands"),$n=lo("core-rdf","type"),Ye=class{ruleName="UnrenderableBand";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=jn(e);if(!a)return n;let i=Co();for(let c of r){if(!(c instanceof g)||c.namespace!==a)continue;let s=P(c,Sn);if(!s)continue;let l=v(s,In).filter(m=>m instanceof S);for(let m of l){let d=this.typeOf(m);if(!d)continue;let f=`${d.publisher}/${d.package_}/${d.name}`;if(i.has(f))continue;let y=new u;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=c.name,y.propertyName="derivation.look",y.actualValue=f,y.message=`Band '${d.name}' has no renderer, so this region of the page will be empty. The declaration is valid against the look vocabulary, but the renderer emits only an HTML comment for it \u2014 which a browser does not display, so the loss is silent. Use a band the renderer implements, or remove it until it is supported.`,n.push(y)}}return n}typeOf(e){let o=h(e,$n);if(o)return{publisher:o.publisher,package_:o.package_,name:o.name}}};function jn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Te="kanonak.org",xe="view",On={publisher:Te,package_:xe,name:"bind"},wn={publisher:Te,package_:xe,name:"produces"},Cn={publisher:Te,package_:xe,name:"projections"},Pn={publisher:Te,package_:xe,name:"where"},Un={publisher:Te,package_:xe,name:"value"},An={publisher:Te,package_:xe,name:"as"},Ne=class{ruleName="TxExpressionPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=xn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,o,t){let n=h(o,On);if(!n)return;let r=h(o,wn),a=0;for(let c of Tn(e,v(o,Cn))){let s=P(c,Un);if(s)for(let m of
|
|
54
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function Vn(p){let e=p.subject;return e&&typeof e.name=="string"?e:void 0}function vn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Dn="kanonak.org",lo=(p,e)=>({publisher:Dn,package_:p,name:e}),Sn=lo("derivation","look"),In=lo("look","bands"),$n=lo("core-rdf","type"),Ye=class{ruleName="UnrenderableBand";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(new _(e,o)),a=jn(e);if(!a)return n;let i=Co();for(let c of r){if(!(c instanceof g)||c.namespace!==a)continue;let s=P(c,Sn);if(!s)continue;let l=v(s,In).filter(m=>m instanceof S);for(let m of l){let d=this.typeOf(m);if(!d)continue;let f=`${d.publisher}/${d.package_}/${d.name}`;if(i.has(f))continue;let y=new u;y.ruleType=this.ruleName,y.severity="Warning",y.entityName=c.name,y.propertyName="derivation.look",y.actualValue=f,y.message=`Band '${d.name}' has no renderer, so this region of the page will be empty. The declaration is valid against the look vocabulary, but the renderer emits only an HTML comment for it \u2014 which a browser does not display, so the loss is silent. Use a band the renderer implements, or remove it until it is supported.`,n.push(y)}}return n}typeOf(e){let o=h(e,$n);if(o)return{publisher:o.publisher,package_:o.package_,name:o.name}}};function jn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Te="kanonak.org",xe="view",On={publisher:Te,package_:xe,name:"bind"},wn={publisher:Te,package_:xe,name:"produces"},Cn={publisher:Te,package_:xe,name:"projections"},Pn={publisher:Te,package_:xe,name:"where"},Un={publisher:Te,package_:xe,name:"value"},An={publisher:Te,package_:xe,name:"as"},Ne=class{ruleName="TxExpressionPath";async validateAsync(e,o,t){let n=[],r;t?r=await t.getKanonaks():r=await new j().parseKanonaks(new _(e,o));let a=xn(e);if(!a)return n;for(let i of r)i instanceof g&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,o,t){let n=h(o,On);if(!n)return;let r=h(o,wn),a=0;for(let c of Tn(e,v(o,Cn))){let s=P(c,Un);if(s)for(let m of X(e,n,s))t.push(this.toError(o.name,`view.projections[${a}].value`,n,m));let l=h(c,An);l&&r&&(W(e,r,l).ok||t.push(this.asError(o.name,a,r,l))),a+=1}let i=0;for(let c of Nn(o,Pn)){for(let s of X(e,n,c))t.push(this.toError(o.name,`view.where[${i}]`,n,s));i+=1}}asError(e,o,t,n){let r=`${n.publisher}/${n.package_}/${n.name}`,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=`view.projections[${o}].as`,a.actualValue=r,a.message=`Projection stores its value under property '${n.name}', but that property's domain is not in scope for the view's produces class '${t.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${t.name}'.
|
|
55
55
|
|
|
56
56
|
Possible solutions:
|
|
57
57
|
\u2022 Use an output property whose domain covers '${t.name}'
|
|
@@ -61,7 +61,7 @@ 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`,c}};function Nn(p,e){let o=P(p,e);return o?[o]:v(p,e).filter(t=>t instanceof S)}function Tn(p,e){let o=[];for(let t of e)if(t instanceof S)o.push(t);else if(t instanceof O){let n=V(p,t.subject);n&&o.push(n)}return o}function xn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Qe="kanonak.org",_n="core-shacl",x=p=>({publisher:Qe,package_:_n,name:p}),Ln=x("NodeShape"),Mn=x("PropertyShape"),Bn=x("targetClass"),Wn=x("property"),Fn=x("path"),qn=x("minCount"),Hn=x("maxCount"),Yn=x("datatype"),Gn=x("class"),Jo=x("in"),zn=x("pattern"),
|
|
64
|
+
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function Nn(p,e){let o=P(p,e);return o?[o]:v(p,e).filter(t=>t instanceof S)}function Tn(p,e){let o=[];for(let t of e)if(t instanceof S)o.push(t);else if(t instanceof O){let n=V(p,t.subject);n&&o.push(n)}return o}function xn(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var Qe="kanonak.org",_n="core-shacl",x=p=>({publisher:Qe,package_:_n,name:p}),Ln=x("NodeShape"),Mn=x("PropertyShape"),Bn=x("targetClass"),Wn=x("property"),Fn=x("path"),qn=x("minCount"),Hn=x("maxCount"),Yn=x("datatype"),Gn=x("class"),Jo=x("in"),zn=x("pattern"),Zn=x("flags"),Xn=x("minLength"),Jn=x("maxLength"),Qn=x("minInclusive"),er=x("maxInclusive"),or=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),Qo=p=>p,Le=class{ruleName="ShaclShape";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=tr(e);if(!a)return n;let i=new Set;for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Ln))continue;let s=h(c,Bn);s?this.resolvesToClass(r,s)||n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' sh:targetClass '${s.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(s))):n.push(this.err(c.name,"targetClass","Error",`NodeShape '${c.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let l of v(c,Wn)){let m;if(l instanceof S)m=l;else if(l instanceof O){let d=V(r,l.subject);d&&(m=d,i.add(b(l.subject)))}m&&this.checkPropertyShape(r,c.name,m,s??void 0,n)}}for(let c of r){if(!(c instanceof g)||c.namespace!==a||!A(c,Mn))continue;let s=T(c);s&&i.has(b(s))||this.checkPropertyShape(r,c.name,c,void 0,n)}return n}checkPropertyShape(e,o,t,n,r){let a=h(t,Fn);if(!a){r.push(this.err(o,"property.path","Error",`A PropertyShape on '${o}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=V(e,a),c=i?Y(e,i):!1;c?n&&(W(e,n,a).ok||r.push(this.err(o,"property.path","Warning",`sh:path '${a.name}' is not in scope for sh:targetClass '${n.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${n.name}', an ancestor, or rdfs.Resource.`,J(a)))):r.push(this.err(o,"property.path","Error",`sh:path '${a.name}' on '${o}' does not resolve to a property.`,"Reference a defined or imported property.",J(a)));let s=h(t,Yn),l=h(t,Gn);s&&l&&r.push(this.err(o,"property","Error",`A PropertyShape on '${o}' sets both sh:datatype and sh:class; a value is a literal or a node, not both.`,"Keep sh:datatype (literal values) or sh:class (node values), not both.")),s&&!this.resolvesToDatatype(e,s)&&r.push(this.err(o,"datatype","Error",`sh:datatype '${s.name}' on '${o}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",J(s))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(o,"class","Error",`sh:class '${l.name}' on '${o}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",J(l)));let m=_e(Z(t,qn)),d=_e(Z(t,Hn));this.checkOrder(o,"minCount",m,"maxCount",d,r);let f=_e(Z(t,Xn)),y=_e(Z(t,Jn));this.checkOrder(o,"minLength",f,"maxLength",y,r);let k=_e(Z(t,Qn)),K=_e(Z(t,er));this.checkOrder(o,"minInclusive",k,"maxInclusive",K,r);let E=z(t,zn);if(E!==void 0){let U=z(t,Zn);try{new RegExp(E,U)}catch{r.push(this.err(o,"pattern","Error",`sh:pattern on '${o}' is not a valid regular expression`+(U!==void 0?` (with flags '${U}')`:"")+`: ${E}`,"Provide a valid regular expression and flags.",E))}}if(oe(t,Jo)&&v(t,Jo).length===0&&r.push(this.err(o,"in","Error",`sh:in on '${o}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),c&&n){let N=W(e,n,a).descriptor;N&&((E!==void 0||f!==void 0||y!==void 0)&&N.kind==="object"&&r.push(this.err(o,"pattern/minLength/maxLength","Warning",`String facets on '${o}' apply to '${a.name}', which is an object property; string facets constrain literal values.`,"Apply string facets to a datatype property, or use sh:class for node values.",J(a))),(k!==void 0||K!==void 0)&&!this.isNumericDatatypeRange(N.range)&&r.push(this.err(o,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${o}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",J(a))))}}checkOrder(e,o,t,n,r,a){t!==void 0&&r!==void 0&&t>r&&a.push(this.err(e,`${o}/${n}`,"Error",`${o} (${t}) exceeds ${n} (${r}) on '${e}'.`,`Set ${o} <= ${n}.`))}resolvesToClass(e,o){let t=V(e,o);return t?$.isClassType(Qo(t)):!1}resolvesToDatatype(e,o){if(o.publisher===Qe&&o.package_==="core-rdf"&&o.name==="Literal")return!0;let t=V(e,o);return t?$.isDatatypeType(Qo(t)):!1}isNumericDatatypeRange(e){return!e||e.publisher===Qe&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===Qe&&e.package_==="core-xsd"&&or.has(e.name)}err(e,o,t,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=t,i.entityName=e,i.propertyName=o,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function _e(p){return typeof p=="number"?p:void 0}function J(p){return`${p.publisher}/${p.package_}/${p.name}`}function tr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var et={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},nr=p=>p,Me=class{ruleName="OwlOneOf";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=rr(e);if(!a)return n;for(let i of r){if(!(i instanceof g)||i.namespace!==a||!oe(i,et))continue;let c=v(i,et);if(c.length===0){n.push(this.err(i.name,"Warning",`owl:oneOf on '${i.name}' is empty; a closed enumeration must list at least one individual.`,"List the individuals that make up the enumeration, or remove owl:oneOf."));continue}for(let s of c)if(s instanceof go)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(s.value)}' on '${i.name}' is not a named individual; a class enumeration is of individuals (a misspelled or unimported individual reads as a literal). For a closed set of literal VALUES, constrain a property with sh:in instead.`,"Reference a defined or imported individual, or move literal value sets to a property sh:in.",String(s.value)));else if(s instanceof O){let l=V(r,s.subject);l&&$.isSchemaDefinitionType(nr(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${s.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${s.subject.publisher}/${s.subject.package_}/${s.subject.name}`))}}return n}err(e,o,t,n,r){let a=new u;return a.ruleType=this.ruleName,a.severity=o,a.entityName=e,a.propertyName="oneOf",a.message=t,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function rr(p){let e=p.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${C(e.version)}`}var ar=p=>p,ir=new yo("kanonak.org","core-rdf","Resource"),Be=class{ruleName="DiamondNameClash";async validateAsync(e,o,t){let n=[],r=t?await t.getKanonaks():await new j().parseKanonaks(o),a=sr(e);if(!a)return n;let i=jo(r);for(let c of r){if(!(c instanceof g)||c.namespace!==a||!$.isClassType(ar(c)))continue;let s=T(c);if(!s)continue;let l=H(r,s),m=b(s),d=new Set(l.map(y=>b(y)));d.delete(m),d.delete(b(ir));let f=new Map;for(let y of Eo(r,s)){if(!y.domains.some(E=>d.has(b(E))))continue;let K=f.get(y.uri.name);K?K.push(y):f.set(y.uri.name,[y])}for(let[y,k]of f){if(k.length<2)continue;let K=N=>Oo(i,l,N.uri)?.cardinality,E=new Set(k.map(N=>N.range?b(N.range):void 0).filter(N=>N!==void 0)),U=new Set(k.map(K).filter(N=>N!==void 0));E.size<=1&&U.size<=1||n.push(this.toError(c.name,y,k,K))}}return n}toError(e,o,t,n){let r=c=>{let s=`${c.uri.publisher}/${c.uri.package_}/${c.uri.name}`,l=c.range?`${c.range.publisher}/${c.range.package_}/${c.range.name}`:"no range",m=n(c);return`${s} (range ${l}${m?`, ${m}`:""})`},a=t.map(r).join("; "),i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=o,i.actualValue=a,i.message=`Class '${e}' inherits ${t.length} distinct properties named '${o}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${o}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${o}':
|
|
65
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 '${o}', or
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-EVMSO7HJ.js";import{a as Vn,b as Nn,c as On}from"./chunk-V3DH67P3.js";import{a as Xt,b as Yt,c as Jt,d as tr,e as we,f as or,g as rr,h as ar,i as ir,j as sr,k as cr,l as ur}from"./chunk-J4ZD6IF6.js";import{a as lr}from"./chunk-L2J7WD7E.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as vt,g as It,h as _t,i as Lt}from"./chunk-IS3AQKB4.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as Ct}from"./chunk-BZ3YTI3C.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-BS7RRG7D.js";import{a as so}from"./chunk-XK24CN3C.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Xo,H as Yo,I as Jo,J as Zo,K as Qo,L as er,M as nr,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as Co,s as vo,t as Io,u as _o,v as Lo,w as Ao,x as jo,y as Vo,z as No}from"./chunk-CR5QY3LJ.js";import"./chunk-KIBR3HAT.js";import{c as Ln,d as To,e as Fo,g as Bo,h as Wo,k as zo,m as xe,o as An,p as jn,r as Go,s as qo}from"./chunk-Z5Y4MCW5.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as L}from"./chunk-PVUBHIU2.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Ee,A as rn,B as an,C as sn,D as cn,E as un,F as ln,G as pn,H as dn,I as mn,J as fn,K as kn,L as yn,M as Re,N as hn,O as gn,P as Sn,Q as bn,R as Pn,S as Rn,T as En,U as Kn,V as xn,W as wn,X as Cn,Y as vn,Z as In,_ as _n,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as Y,k as J,l as We,m as Z,ma as Wt,n as ze,na as zt,o as Ge,oa as ne,p as qe,q as Xe,r as Ye,s as Je,t as Ze,u as Qe,v as Pe,w as en,x as nn,y as tn,z as on}from"./chunk-7UYXTYXC.js";import{A as be,B as _,C as Q,a as At,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as Fe,t as K,w as Be,x as I,y as X,z as y}from"./chunk-CJMVIOZX.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new L().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new L().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function pr(n){if(!n)return;let e=u(n);if(e===u(fn))return"IRI";if(e===u(kn))return"BlankNode";if(e===u(yn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(hn))return"Violation";if(e===u(gn))return"Warning";if(e===u(Sn))return"Info"}function Ce(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function dr(n,e){let o=y(n,Xe);if(!o)return;let t={path:o},r=$(I(n,Ye)),a=$(I(n,Je));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,tn)),i=$(I(n,on));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,rn)),p=$(I(n,an));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=X(n,en);if(d!==void 0){let P=X(n,nn);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(Be(n,Pe)){let P=[],N=[];for(let O of _(n,Pe))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ze);S&&(t.datatype=S);let b=y(n,Qe);b&&(t.classRef=b);let l=pr(y(n,mn));l&&(t.nodeKind=l);let m=X(n,sn);m!==void 0&&(t.message=m);let f=Mn(y(n,Re))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!Fe(o,Z))continue;let t=Mn(y(o,Re)),r={name:o.name,uri:h(o),targetClass:y(o,Ge),targetNodes:Ce(o,cn),targetSubjectsOf:Ce(o,un),targetObjectsOf:Ce(o,ln),closed:I(o,pn)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,dn))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,qe)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=dr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",C=n=>({type:`${x}/VarRef`,varName:n}),ve=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),mr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?ve(n):mr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(C(oe)),ve(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(C(oe)),ve(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(re),needle:C("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(C("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(C("v"),Hn(n.maxInclusive))}),e}import{evaluate as kr,ExpressionError as yr}from"@kanonak-protocol/expression";function Gn(n,e){let o=hr(e)?e:te(e),t=[];for(let r of o)for(let a of gr(n,r))Pr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function hr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function gr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of Sr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function Sr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function br(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function Pr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)Er(n,e,o,a,r,s,t);e.closed&&vr(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var Rr={minCount:bn,maxCount:Pn,in:Kn,pattern:xn,minLength:wn,maxLength:Cn,minInclusive:vn,maxInclusive:In};function Er(n,e,o,t,r,a,s){let i=u(a.path),c=br(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=Rr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Kr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)xr(a.nodeKind,l)||b(_n,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=wr(a.datatype,l);m&&b(Rn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Cr(n,a.classRef,l);m&&b(En,`'${d}' ${m}`,l)}}function Kr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.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 ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new yr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return kr(n.expr,void 0,o)===1}function xr(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 wr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.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 V.Decimal:case V.Double:case V.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 Cr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function vr(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Ee,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Ee,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Le from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Ir="0.0.0",A=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new L(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Ae(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Le.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Le.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Ae(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Ir,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(_r(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function _r(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var Lr="1.1.0";async function Qn(n){let e=new A(n.repository),o=e.imports(),t=o.ensure(Y,J,Lr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ji}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",v="view",et="core-kanonak",Ar={publisher:R,package_:v,name:"rootView"},jr={publisher:R,package_:v,name:"bind"},Vr={publisher:R,package_:v,name:"produces"},Nr={publisher:R,package_:v,name:"projections"},Or={publisher:R,package_:v,name:"where"},$r={publisher:R,package_:v,name:"value"},Ur={publisher:R,package_:v,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new L(this.parser),this.builder=new A(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,jr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Vr);if(!s)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=Dr(r),c=nt(t,R,et),p=nt(t,R,v),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,v,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new An(m,t),P=this.readProjections(t,r),N=Tr(r,Or),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,Ar);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,Nr)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=be(a,$r),i=y(a,Ur);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Hr(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Fr(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=Ln(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Dr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Mr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Mr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Hr(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function Tr(n,e){let o=be(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Fr(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Lo as AmbiguousReferenceRule,ye as BooleanStatement,or as CANONICAL_FORM_VERSION,V as Carrier,$o as ClassDefinitionRule,Ko as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,ar as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,er as DiamondNameClashRule,Do as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,Po as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,Ct as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Ro as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,At as Kanonak,ro as KanonakDocumentPositions,L as KanonakObjectParser,nr as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,Fo as LINE_STYLES,ko as LinkTargetRule,q as ListStatement,D as LiteralKanonak,vt as LocalFirstRepository,It as LockAwareRepository,Yo as LookBandPathRule,Go as LookRenderer,Mo as LookSemanticSvgPathRule,Uo as MarkdownLinkRule,ge as MarkdownStatement,Io as NamespaceImportCycleRule,yo as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,ir as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,jo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Qo as OwlOneOfRule,A as PackageBuilder,bo as PackageHeaderRule,se as ProducerRepository,Vo as PropertyDomainRule,xo as PropertyHierarchyCycleRule,No as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,wo as PropertyRangeRequiredRule,go as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,Oo as ReservedNameShadowRule,ho as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,J as SHACL_PACKAGE,Y as SHACL_PUBLISHER,Z as SH_NODE_SHAPE,ze as SH_PROPERTY_SHAPE,We as SH_SHAPE,Ot as ScalarStatement,Xo as SequenceNarrativeRule,Zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,Co as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,So as SubjectKanonakTypeRequiredRule,ur as TokenCredentialProvider,Zt as TripleStore,Ho as TxExpressionCompilesRule,Jo as TxExpressionPathRule,Ut as TypeResolver,_o as UnresolvedPredicateRule,Eo as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,ji as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,Lt as buildLocalFirstRepository,zo as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,tr as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Ae as contentAddressedName,ne as contextTypesOf,cr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,lr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,rr as normalizeHost,sr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,Bo as readSequenceConnectors,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,qo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual,Wo as walkSequence};
|
|
1
|
+
import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-EVMSO7HJ.js";import{a as Vn,b as Nn,c as On}from"./chunk-V3DH67P3.js";import{a as Xt,b as Yt,c as Jt,d as tr,e as we,f as or,g as rr,h as ar,i as ir,j as sr,k as cr,l as ur}from"./chunk-J4ZD6IF6.js";import{a as lr}from"./chunk-L2J7WD7E.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as vt,g as It,h as _t,i as Lt}from"./chunk-IS3AQKB4.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as Ct}from"./chunk-BZ3YTI3C.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-BS7RRG7D.js";import{a as so}from"./chunk-XK24CN3C.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Xo,H as Yo,I as Jo,J as Zo,K as Qo,L as er,M as nr,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as Co,s as vo,t as Io,u as _o,v as Lo,w as Ao,x as jo,y as Vo,z as No}from"./chunk-AXQ4DBJD.js";import"./chunk-KIBR3HAT.js";import{c as Ln,d as To,e as Fo,g as Bo,h as Wo,k as zo,m as xe,o as An,p as jn,r as Go,s as qo}from"./chunk-Z5Y4MCW5.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as L}from"./chunk-PVUBHIU2.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Ee,A as rn,B as an,C as sn,D as cn,E as un,F as ln,G as pn,H as dn,I as mn,J as fn,K as kn,L as yn,M as Re,N as hn,O as gn,P as Sn,Q as bn,R as Pn,S as Rn,T as En,U as Kn,V as xn,W as wn,X as Cn,Y as vn,Z as In,_ as _n,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as Y,k as J,l as We,m as Z,ma as Wt,n as ze,na as zt,o as Ge,oa as ne,p as qe,q as Xe,r as Ye,s as Je,t as Ze,u as Qe,v as Pe,w as en,x as nn,y as tn,z as on}from"./chunk-7UYXTYXC.js";import{A as be,B as _,C as Q,a as At,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as Fe,t as K,w as Be,x as I,y as X,z as y}from"./chunk-CJMVIOZX.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new L().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new L().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function pr(n){if(!n)return;let e=u(n);if(e===u(fn))return"IRI";if(e===u(kn))return"BlankNode";if(e===u(yn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(hn))return"Violation";if(e===u(gn))return"Warning";if(e===u(Sn))return"Info"}function Ce(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function dr(n,e){let o=y(n,Xe);if(!o)return;let t={path:o},r=$(I(n,Ye)),a=$(I(n,Je));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,tn)),i=$(I(n,on));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,rn)),p=$(I(n,an));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=X(n,en);if(d!==void 0){let P=X(n,nn);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(Be(n,Pe)){let P=[],N=[];for(let O of _(n,Pe))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ze);S&&(t.datatype=S);let b=y(n,Qe);b&&(t.classRef=b);let l=pr(y(n,mn));l&&(t.nodeKind=l);let m=X(n,sn);m!==void 0&&(t.message=m);let f=Mn(y(n,Re))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!Fe(o,Z))continue;let t=Mn(y(o,Re)),r={name:o.name,uri:h(o),targetClass:y(o,Ge),targetNodes:Ce(o,cn),targetSubjectsOf:Ce(o,un),targetObjectsOf:Ce(o,ln),closed:I(o,pn)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,dn))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,qe)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=dr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",C=n=>({type:`${x}/VarRef`,varName:n}),ve=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),mr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?ve(n):mr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(C(oe)),ve(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(C(oe)),ve(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(re),needle:C("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(C("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(C("v"),Hn(n.maxInclusive))}),e}import{evaluate as kr,ExpressionError as yr}from"@kanonak-protocol/expression";function Gn(n,e){let o=hr(e)?e:te(e),t=[];for(let r of o)for(let a of gr(n,r))Pr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function hr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function gr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of Sr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function Sr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function br(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function Pr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)Er(n,e,o,a,r,s,t);e.closed&&vr(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var Rr={minCount:bn,maxCount:Pn,in:Kn,pattern:xn,minLength:wn,maxLength:Cn,minInclusive:vn,maxInclusive:In};function Er(n,e,o,t,r,a,s){let i=u(a.path),c=br(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=Rr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Kr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)xr(a.nodeKind,l)||b(_n,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=wr(a.datatype,l);m&&b(Rn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Cr(n,a.classRef,l);m&&b(En,`'${d}' ${m}`,l)}}function Kr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.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 ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new yr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return kr(n.expr,void 0,o)===1}function xr(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 wr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.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 V.Decimal:case V.Double:case V.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 Cr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function vr(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Ee,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Ee,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Le from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Ir="0.0.0",A=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new L(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Ae(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Le.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Le.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Ae(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Ir,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(_r(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function _r(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var Lr="1.1.0";async function Qn(n){let e=new A(n.repository),o=e.imports(),t=o.ensure(Y,J,Lr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ji}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",v="view",et="core-kanonak",Ar={publisher:R,package_:v,name:"rootView"},jr={publisher:R,package_:v,name:"bind"},Vr={publisher:R,package_:v,name:"produces"},Nr={publisher:R,package_:v,name:"projections"},Or={publisher:R,package_:v,name:"where"},$r={publisher:R,package_:v,name:"value"},Ur={publisher:R,package_:v,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new L(this.parser),this.builder=new A(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,jr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Vr);if(!s)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=Dr(r),c=nt(t,R,et),p=nt(t,R,v),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,v,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new An(m,t),P=this.readProjections(t,r),N=Tr(r,Or),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,Ar);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,Nr)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=be(a,$r),i=y(a,Ur);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Hr(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Fr(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=Ln(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Dr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Mr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Mr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Hr(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function Tr(n,e){let o=be(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Fr(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Lo as AmbiguousReferenceRule,ye as BooleanStatement,or as CANONICAL_FORM_VERSION,V as Carrier,$o as ClassDefinitionRule,Ko as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,ar as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,er as DiamondNameClashRule,Do as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,Po as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,Ct as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Ro as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,At as Kanonak,ro as KanonakDocumentPositions,L as KanonakObjectParser,nr as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,Fo as LINE_STYLES,ko as LinkTargetRule,q as ListStatement,D as LiteralKanonak,vt as LocalFirstRepository,It as LockAwareRepository,Yo as LookBandPathRule,Go as LookRenderer,Mo as LookSemanticSvgPathRule,Uo as MarkdownLinkRule,ge as MarkdownStatement,Io as NamespaceImportCycleRule,yo as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,ir as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,jo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Qo as OwlOneOfRule,A as PackageBuilder,bo as PackageHeaderRule,se as ProducerRepository,Vo as PropertyDomainRule,xo as PropertyHierarchyCycleRule,No as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,wo as PropertyRangeRequiredRule,go as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,Oo as ReservedNameShadowRule,ho as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,J as SHACL_PACKAGE,Y as SHACL_PUBLISHER,Z as SH_NODE_SHAPE,ze as SH_PROPERTY_SHAPE,We as SH_SHAPE,Ot as ScalarStatement,Xo as SequenceNarrativeRule,Zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,Co as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,So as SubjectKanonakTypeRequiredRule,ur as TokenCredentialProvider,Zt as TripleStore,Ho as TxExpressionCompilesRule,Jo as TxExpressionPathRule,Ut as TypeResolver,_o as UnresolvedPredicateRule,Eo as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,ji as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,Lt as buildLocalFirstRepository,zo as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,tr as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Ae as contentAddressedName,ne as contextTypesOf,cr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,lr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,rr as normalizeHost,sr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,Bo as readSequenceConnectors,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,qo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual,Wo as walkSequence};
|
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,y,z}from"../chunk-
|
|
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,y,z}from"../chunk-AXQ4DBJD.js";import"../chunk-KIBR3HAT.js";import"../chunk-Z5Y4MCW5.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.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};
|
|
@@ -2,6 +2,14 @@ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/ty
|
|
|
2
2
|
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
3
3
|
import type { IDocumentValidationRule } from './IDocumentValidationRule.js';
|
|
4
4
|
export declare class NamespacePrefixRule implements IDocumentValidationRule {
|
|
5
|
+
/**
|
|
6
|
+
* A Turtle/SPARQL-style prefixed name used where Kanonak expects a bare or
|
|
7
|
+
* alias-dotted name: the WHOLE value is `prefix:LocalName` — one well-known
|
|
8
|
+
* prefix, one colon, one name token. Prose that merely starts with one of
|
|
9
|
+
* these words followed by a colon (a label such as `Time::ParseDate License`,
|
|
10
|
+
* a comment beginning `Schema: ...`) is not a prefixed name and must not
|
|
11
|
+
* fire; the earlier prefix-only match did.
|
|
12
|
+
*/
|
|
5
13
|
private static readonly NAMESPACE_PREFIX_PATTERN;
|
|
6
14
|
readonly ruleName = "NamespacePrefix";
|
|
7
15
|
validate(document: KanonakDocument): OntologyValidationError[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.31.0",
|
|
4
4
|
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
],
|
|
127
127
|
"dependencies": {
|
|
128
128
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
129
|
-
"@kanonak-protocol/types": "^5.
|
|
129
|
+
"@kanonak-protocol/types": "^5.31.0",
|
|
130
130
|
"ignore": "^7.0.5",
|
|
131
131
|
"js-yaml": "^4.1.0",
|
|
132
132
|
"yaml": "^2.7.0",
|