@kanonak-protocol/sdk 3.71.0 → 3.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/{chunk-OFSARZX6.js → chunk-ATH6636H.js} +1 -1
- package/dist/chunk-C7RZIMEH.js +80 -0
- package/dist/chunk-LKBG2MK6.js +2 -0
- package/dist/chunk-X5TYWQRA.js +148 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -26
- package/dist/look/LookRenderer.d.ts +21 -50
- package/dist/producer/Entitlement.d.ts +75 -0
- package/dist/producer/IPackageProducer.d.ts +59 -0
- package/dist/producer/PackageBuilder.d.ts +130 -0
- package/dist/producer/ProducerRepository.d.ts +44 -0
- package/dist/producer/index.d.ts +6 -0
- package/dist/repositories/HttpKanonakDocumentRepository.d.ts +20 -0
- package/dist/repositories/PublisherConfig.d.ts +10 -0
- package/dist/repositories/PublisherIndex.d.ts +3 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/assembleModel.d.ts +2 -0
- package/dist/server/index.js +2 -2
- package/dist/server/types.d.ts +9 -0
- package/dist/transformations/index.js +2 -2
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/LookBandPathRule.d.ts +38 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/dist/view/ViewMaterializer.d.ts +1 -7
- package/package.json +2 -2
- package/dist/chunk-HAR3BNTB.js +0 -2
- package/dist/chunk-MCU5IAMS.js +0 -148
- package/dist/chunk-RRODBYIK.js +0 -74
package/dist/chunk-RRODBYIK.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import{d as v}from"./chunk-SHDHMKMJ.js";import{a as w,c as Ee,d as je,f as A}from"./chunk-G2DKKSZ4.js";import{a as De}from"./chunk-TJPQETHV.js";import{d as ue,f as $,g as Se}from"./chunk-BGQKZBNE.js";import{d as me,f as $e,i as ge,j as E,k as I,l as he,m as j}from"./chunk-CRKSKIAL.js";import{a as V,b as D,c as we}from"./chunk-IOMNZBK4.js";import{c as O,d as Ae,k as Ie,l as Oe}from"./chunk-W6T7MOKY.js";import{e as k}from"./chunk-2ACBWC7K.js";var S=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=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 be=class u{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new u;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var ke=class{constructor(e){this.underlying=e;this.repository=new Pe(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new A().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],o=await this.buildDocsByIdIndex();for(;t.length>0;){let s=t.shift(),i=o.get(s);if(i?.metadata.imports)for(let[n,c]of Object.entries(i.metadata.imports))for(let a of c){let p=await this.repository.getHighestCompatibleVersionAsync(n,a);if(!p)continue;let l=Re(p);!l||r.has(l)||(r.add(l),t.push(l))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let o=Re(t);o&&r.set(o,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ke(s))continue;let i=s,n=Ne(i,"type");if(n==="Class"||n?.endsWith(".Class")){let c=Ue(i);t.set(o,c)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ke(s))continue;let n=Ne(s,"type");(n==="ObjectProperty"||n?.endsWith(".ObjectProperty")||n==="DatatypeProperty"||n?.endsWith(".DatatypeProperty")||n==="AnnotationProperty"||n?.endsWith(".AnnotationProperty")||n==="Property"||n?.endsWith(".Property"))&&t.add(o)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(Re(t)===e)return t}};function Re(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}function Ke(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}function Ne(u,e){if(e in u)return Ce(u[e]);for(let r of Object.keys(u))if(r.endsWith(`.${e}`))return Ce(u[r])}function Ce(u){return Array.isArray(u)?u.length>0?String(u[0]):void 0:u==null?void 0:String(u)}function Ue(u){let e=u.subClassOf;if(e===void 0){for(let r of Object.keys(u))if(r.endsWith(".subClassOf")){e=u[r];break}}return V(e)}var Pe=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,r){let t=`${e}/${r}`,o=this.byNamespaceCache.get(t);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,o),o)}getHighestCompatibleVersionAsync(e,r){let t=r.version,o=t?`${t.major}.${t.minor}.${t.patch}`:"",s=`${e}/${r.packageName}@${r.versionOperator}:${o}`,i=this.highestVersionCache.get(s);return i||(i=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(s,i),i)}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)}};var K=class u{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 r=[];for(let[t,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(t,o,r);return r}validateEntity(e,r,t){for(let[o,s]of Object.entries(r)){let i=s?.toString()??"";if(i&&u.NAMESPACE_PREFIX_PATTERN.test(i)){let n=this.getSuggestionForPrefixedValue(i),c=e.split(".")[0],a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=o,a.expectedValue=n,a.message=`Invalid namespace prefix '${i}'. Use '${n}' without prefix.`,a.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(a)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validateEntity(`${e}.${o}`,s,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var N=class u{static RESERVED_WORDS=new Set(["kanonak","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 r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,s]of Object.entries(e.body)){let i=u.VALID_AUGMENTATION_PATTERN.test(o);if(!i&&!t&&u.RESERVED_WORDS.has(o.toLowerCase())){let n=new g;n.ruleType=this.ruleName,n.severity="Error",n.entityName=o,n.message=`Entity name '${o}' is a reserved word and cannot be used.`,n.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(n);continue}if(!i&&!u.VALID_NAME_PATTERN.test(o)){let n;/^\d/.test(o)?n="Entity names must start with a letter, not a number.":o.includes(" ")?n="Entity names cannot contain spaces. Use camelCase or underscores instead.":n="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=o,c.message=`Invalid entity name '${o}'. ${n}`,c.suggestion=n,r.push(c)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validatePropertyNames(o,s,r)}return r}validatePropertyNames(e,r,t){for(let o of Object.keys(r))if(!u.VALID_PROPERTIES.has(o)&&!u.VALID_PROPERTY_NAME_PATTERN.test(o)){let s=new g;s.ruleType=this.ruleName,s.severity="Warning",s.entityName=e,s.propertyName=o,s.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,s.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(s)}}};var C=class u{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 r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[o,s]of Object.entries(e.body))if(s&&typeof s=="object"&&!Array.isArray(s)){let i=s,n=i.type;if(n){let c=[];if(Array.isArray(n))for(let a of n){let p=a?.toString();p&&p==="Property"&&!t&&c.push(p)}else{let a=n?.toString();a&&a==="Property"&&!t&&c.push(a)}for(let a of c){let p=this.getPropertyValue(i,"range"),l=this.determinePropertyType(p),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=o,y.propertyName="type",y.actualValue=a,y.expectedValue=l,y.message=`Invalid property type '${a}'. Use '${l}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":u.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r.type;if(o){let s=o.toString();return s==="Class"||s.endsWith(".Class")}}return!1}};var T=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||t.includes("."))continue;let s=o,i="type"in s,n=s.type?.toString().trim();if(!i||!n){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
2
|
-
type: Scene
|
|
3
|
-
|
|
4
|
-
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",r.push(c)}}return r}};var x=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,r){let t=[],o=new D(r),s=await this.buildPropertyRangeMap(e,o);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&await this.checkEmbeddedTypes(i,n,void 0,s,o,e,t,0);return t}pickRange(e,r,t){if(e.length===0)return;if(e.length===1)return e[0].range;let o=r.indexOf(".");if(o>0){let s=r.substring(0,o),i=e.find(n=>n.declaringAlias===s);if(i)return i.range}if(t){let s=this.localName(t),i=e.find(n=>this.localName(n.domain)===s);if(i)return i.range}return e[0].range}async checkEmbeddedTypes(e,r,t,o,s,i,n,c){if(c>0){let p=r.type;if(p!=null){let l=await this.validateEmbeddedType(e,String(p),t,s,i);l&&n.push(l)}}let a=r.type!==void 0&&r.type!==null?String(r.type):void 0;for(let[p,l]of Object.entries(r)){let y=this.localName(p),m=o.get(y),d=(m!==void 0?this.pickRange(m,p,a):void 0)??t;if(typeof l=="object"&&l!==null)if(Array.isArray(l))for(let b=0;b<l.length;b++){let h=l[b];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${p}[${b}]`,h,d,o,s,i,n,c+1)}else await this.checkEmbeddedTypes(`${e}.${p}`,l,d,o,s,i,n,c+1)}}async validateEmbeddedType(e,r,t,o,s){if(r.length===0||!t)return null;let i=this.localName(r),n=this.localName(t);if(n==="Resource"||n==="Class")return null;let c=e.split(".")[0];if(i===n){let p=new g;return p.ruleType=this.ruleName,p.severity="Warning",p.entityName=c,p.propertyName=e,p.actualValue=r,p.expectedValue=t,p.message=`Embedded object at '${e}' declares 'type: ${r}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,p.suggestion=`Remove the 'type: ${r}' line, or keep it if explicitness is preferred over concision.`,p}if(await o.isSubclassOfAsync(r,t,s)||(i!==r||n!==t)&&await o.isSubclassOfAsync(i,n,s))return null;let a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=r,a.expectedValue=t,a.message=`Embedded object at '${e}' has 'type: ${r}', which is not a subclass of the parent property's range '${t}'.`,a.suggestion=`Either remove the 'type: ${r}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${r}' class definition so the relationship holds.`,a}localName(e){let r=e.lastIndexOf(".");return r<0||r===e.length-1?e:e.substring(r+1)}async buildPropertyRangeMap(e,r){let t=new Map,o=await r.buildEntityIndexAsync(e),s=new Map;for(let[i,n]of o){let c=n.entity.type;if(c==null)continue;let a=String(c),p=this.localName(a);if(!(p==="Property"||p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"))continue;let y=n.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let f=n.entity.domain,d=f!=null?String(f):"",b=n.uri.toString(),h=s.get(b),P=i.includes(".");(!h||P&&!h.entityName.includes("."))&&s.set(b,{entityName:i,domain:d,range:m})}for(let i of s.values()){let n=this.localName(i.entityName),c=i.entityName.indexOf("."),a=c>0?i.entityName.substring(0,c):void 0,p=t.get(n)??[];p.push({domain:i.domain,range:i.range,declaringAlias:a}),t.set(n,p)}return t}};import{VersionOperator as fe}from"@kanonak-protocol/types/document/models/enums";var _=class{ruleName="ImportExistence";async validateAsync(e,r){let t=[];if(!e.metadata?.imports)return t;let o=await r.getAllDocumentsAsync();for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i)if(!await r.getHighestCompatibleVersionAsync(s,n)){let a=await this.determineImportErrorAsync(r,s,n,o),p=new g;p.ruleType=this.ruleName,p.severity="Error",p.message=a.message,p.suggestion=a.suggestion,p.entityName=`Import: ${s}/${n.packageName}`,p.actualValue=n.toString(),p.expectedValue=a.expectedValue,t.push(p)}return t}async determineImportErrorAsync(e,r,t,o){let s=await e.getDocumentsByNamespaceAsync(r,t.packageName);if(s.length===0){let a=o.filter(m=>m.metadata.namespace_?.publisher===r).map(m=>m.metadata.namespace_.package_).filter((m,f,d)=>d.indexOf(m)===f),p=this.findSimilarPackages(t.packageName,a),l=`Import '${r}/${t.package_}' not found - package does not exist`,y=p.length>0?`Did you mean: ${p.slice(0,3).join(", ")}?`:a.length>0?`Available packages in ${r}: ${a.slice(0,5).join(", ")}`:`No packages found for publisher '${r}'. Verify the publisher name is correct.`;return{message:l,suggestion:y,expectedValue:"Existing package"}}let n=s.filter(a=>a.metadata.namespace_?.version).map(a=>a.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${r}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${n}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case fe.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case fe.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case fe.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case fe.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,r){if(r.length===0)return[];let t=r.filter(i=>i.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(i.toLowerCase()));if(t.length>0)return t.sort((i,n)=>i.length-n.length);let o=r.map(i=>({package:i,distance:this.levenshteinDistance(e.toLowerCase(),i.toLowerCase())})).sort((i,n)=>i.distance-n.distance),s=Math.max(3,Math.floor(e.length*.4));return o.filter(i=>i.distance<=s).map(i=>i.package)}levenshteinDistance(e,r){if(!e||e.length===0)return r?.length??0;if(!r||r.length===0)return e.length;let t=e.length,o=r.length,s=Array(t+1).fill(null).map(()=>Array(o+1).fill(0));for(let i=0;i<=t;i++)s[i][0]=i;for(let i=0;i<=o;i++)s[0][i]=i;for(let i=1;i<=t;i++)for(let n=1;n<=o;n++){let c=e[i-1]===r[n-1]?0:1;s[i][n]=Math.min(Math.min(s[i-1][n]+1,s[i][n-1]+1),s[i-1][n-1]+c)}return s[t][o]}};var U=class{ruleName="UnresolvedReference";async validateAsync(e,r){let t=[],o=new D(r),s=await o.buildEntityIndexAsync(e),i=new Set;for(let[n,c]of s.entries()){let a=c.entity.type;if(a){let p=a.toString();(p==="ObjectProperty"||p.endsWith(".ObjectProperty"))&&i.add(n)}}for(let[n,c]of Object.entries(e.body)){if(!c||typeof c!="object"||Array.isArray(c))continue;let a=c,p=this.getPropertyValue(a,"type");if(!(!p||p==="Class"||p.endsWith("Property")||p==="AnnotationProperty"))for(let[l,y]of Object.entries(a))l==="type"||l==="label"||l==="comment"||!(i.has(l)||Array.from(i).some(f=>f.endsWith(`.${l}`)))||await this.validateReferenceValue(n,l,y,e,o,t)}return t}async validateReferenceValue(e,r,t,o,s,i){if(t!=null){if(typeof t=="string")await s.resolveEntityAsync(t,o)||i.push(this.createUnresolvedReferenceError(e,r,t));else if(Array.isArray(t))for(let n=0;n<t.length;n++){let c=t[n];typeof c=="string"&&(await s.resolveEntityAsync(c,o)||i.push(this.createUnresolvedReferenceError(e,`${r}[${n}]`,c)))}}}createUnresolvedReferenceError(e,r,t){let o=`The entity '${t}' cannot be found in the current document or any imported namespaces.
|
|
5
|
-
|
|
6
|
-
Possible solutions:
|
|
7
|
-
\u2022 Add import if the entity is defined in another namespace:
|
|
8
|
-
kanonak namespace add-import <publisher>/<package>@<version>
|
|
9
|
-
\u2022 Check for typos in the reference name '${t}'
|
|
10
|
-
\u2022 Define '${t}' in the current namespace or an appropriate namespace
|
|
11
|
-
\u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=r,s.actualValue=t,s.message=`Reference to '${t}' could not be resolved`,s.suggestion=o,s.expectedValue="A valid entity reference that exists in the current document or imported namespaces",s}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}};var L=class{ruleName="ClassHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildClassHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=i,y=this.detectCycle(l,o);if(y){let m=y.join(" \u2192 "),f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Circular class hierarchy detected: ${m}`,f.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",f.entityName=l,f.propertyName="subClassOf",f.actualValue=m,t.push(f);break}}}return t}async buildClassHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=V(p);l.length>0&&t.set(i,l)}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);a&&await this.buildClassHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var M=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildPropertyHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let p=i,l=this.detectCycle(p,o);if(l){let y=l.join(" \u2192 "),m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${y}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=p,m.propertyName="subPropertyOf",m.actualValue=y,t.push(m);break}}return t}async buildPropertyHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let c=n,a=c.type;if(a){let p=a.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let l=c.subPropertyOf;if(l){let y=V(l);y.length>0&&t.set(i,y)}}}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);a&&await this.buildPropertyHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var W=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,r){let t=[];for(let[o,s]of Object.entries(e.body)){if(typeof s!="object"||s===null||Array.isArray(s))continue;let i=s,n=i.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let c="range"in i,a=i.range?.toString().trim();if(!c||!a){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=o,p.propertyName="range",p.message=`Property '${o}' must have a 'range' defined.`,p.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var H=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isClassLikeType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=V(i.subClassOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isClassAvailableInImports(e,r,p)){let y=c.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Class '${p}' referenced in subClassOf${y} is not defined or imported`,m.suggestion=`Define '${p}' as a Class, or import a namespace that contains it`,m.entityName=s,m.propertyName="subClassOf",m.actualValue=p,m.expectedValue="Defined or imported class",t.push(m)}}}return t}async isClassAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isClassLikeType(f))return!0}let y=new Set;if(await this.isClassAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isClassAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isClassLikeType(y))return!0}if(await this.isClassAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var F=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=V(i.subPropertyOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInProperties.has(p)||o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,r,p)){let y=c.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Property '${p}' referenced in subPropertyOf${y} is not defined or imported`,m.suggestion=`Define '${p}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,m.entityName=s,m.propertyName="subPropertyOf",m.actualValue=p,m.expectedValue="Defined or imported property",t.push(m)}}}return t}async isPropertyAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(f==="DatatypeProperty"||f==="ObjectProperty"||f==="AnnotationProperty")return!0}let y=new Set;if(await this.isPropertyAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(y==="DatatypeProperty"||y==="ObjectProperty"||y==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var B=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,r){let t=[],o=e.metadata.namespace_?.toString();if(!o)return t;let s=new Map,i=new Set;await this.buildImportGraph(e,r,s,i);let n=this.detectCycle(o,s);if(n){let c=n.join(" \u2192 "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`Circular namespace import detected: ${c}`,a.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",a.entityName="imports",a.propertyName="imports",a.actualValue=c,t.push(a)}return t}async buildImportGraph(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!(!s||o.has(s))&&(o.add(s),e.metadata.imports)){let i=[];for(let[n,c]of Object.entries(e.metadata.imports))for(let a of c){let p=`${n}/${a.packageName}@${a.version}`;i.push(p);let l=await r.getHighestCompatibleVersionAsync(n,a);l&&await this.buildImportGraph(l,r,t,o)}i.length>0&&t.set(s,i)}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){let s=t.indexOf(e);if(s>=0){let n=t.slice(s);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let i=r.get(e);if(i)for(let n of i){let c=this.detectCycleRecursive(n,r,t,o);if(c)return c}return t.pop(),null}};var q=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,r,t){let o=[],s=new Set,i=t?await this.closurePropertyNamesViaCache(e,t):void 0,n=t?await this.aliasClosurePropertyNamesViaCache(e,t):void 0;for(let[c,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let l=a.type?.toString();this.isPropertyType(l)&&s.add(c)}for(let[c,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let p=a,l=p.type?.toString();if(this.isPropertyType(l)||this.isClassType(l))continue;for(let[y,m]of Object.entries(p)){if(!y||this.metadataKeys.has(y))continue;let f=y,d=null;if(y.includes(".")){let h=y.lastIndexOf(".");d=y.substring(0,h),f=y.substring(h+1)}if(s.has(f))continue;if(!await this.isPropertyAvailable(e,r,f,d,i,n)){let h=new g;h.ruleType=this.ruleName,h.severity="Error",h.message=`Property '${y}' is not defined or imported`,h.suggestion=d?`The property '${f}' is not found in the imported namespace with alias '${d}'.
|
|
12
|
-
1. Verify the namespace is imported with the correct alias
|
|
13
|
-
2. Check if the property name is spelled correctly
|
|
14
|
-
3. Ensure the imported namespace version contains this property`:`The property '${y}' is not defined in this namespace or any imported namespace.
|
|
15
|
-
1. Define '${y}' as an ObjectProperty or DatatypeProperty in this namespace, OR
|
|
16
|
-
2. Import the namespace that contains '${y}', OR
|
|
17
|
-
3. Use a qualified reference like 'alias.${y}' if already imported with an alias`,h.entityName=c,h.propertyName=y,h.actualValue=m?.toString(),h.expectedValue="A defined or imported property",o.push(h)}}}return o}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailable(e,r,t,o,s,i){if(s!==void 0&&i!==void 0){if(o===null)return s.has(t);let n=i.get(o);return n?n.has(t):!1}return await this.isPropertyAvailableInImports(e,r,t,o)}async closurePropertyNamesViaCache(e,r){let t=new Set,o=Te(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s)if(i!==o)for(let n of await r.getPropertyNames(i))t.add(n);return t}async aliasClosurePropertyNamesViaCache(e,r){let t=new Map;if(!e.metadata.imports)return t;for(let[o,s]of Object.entries(e.metadata.imports))for(let i of s){if(!i.alias)continue;let n=await r.repository.getHighestCompatibleVersionAsync(o,i);if(!n)continue;let c=Te(n);if(!c)continue;let a=await r.getImportClosure(c),p=t.get(i.alias)??new Set;for(let l of a)for(let y of await r.getPropertyNames(l))p.add(y);t.set(i.alias,p)}return t}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(s,n);if(c){let a=c.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};function Te(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var X=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isPropertyType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(!this.isPropertyType(c)&&!this.isClassType(c))continue;for(let[a,p]of Object.entries(n)){if(!a||this.metadataKeys.has(a))continue;let l=a,y=null;if(a.includes(".")){let f=a.lastIndexOf(".");y=a.substring(0,f),l=a.substring(f+1)}if(o.has(l))continue;if(!await this.isPropertyAvailableInImports(e,r,l,y)){let f=this.isClassType(c)?"class":"property",d=new g;d.ruleType=this.ruleName,d.severity="Error",d.message=`Property '${a}' used on ${f} '${s}' is not defined or imported`,d.suggestion=y?`The property '${l}' is not found in the imported namespace with alias '${y}'.
|
|
18
|
-
1. Verify the namespace is imported with the correct alias
|
|
19
|
-
2. Check if the property name is spelled correctly
|
|
20
|
-
3. Ensure the imported namespace version contains this property`:`The property '${a}' is not defined in this namespace or any imported namespace.
|
|
21
|
-
1. Define '${a}' as an ObjectProperty or DatatypeProperty in this namespace, OR
|
|
22
|
-
2. Import the namespace that contains '${a}', OR
|
|
23
|
-
3. Use a qualified reference like 'alias.${a}' if already imported with an alias`,d.entityName=s,d.propertyName=a,d.actualValue=p?.toString(),d.expectedValue="A defined or imported property",t.push(d)}}}return t}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let c=await r.getHighestCompatibleVersionAsync(s,n);if(c){let a=c.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let p=new Set;if(await this.isPropertyAvailableInImportsRecursive(c,r,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var z=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,r){let t=[],o=new Set,s=[];for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,a=!1,p=c.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="DatatypeProperty"){a=!0;break}}else p?.toString()==="DatatypeProperty"&&(a=!0);if(a){s.push(i);let l=this.getPropertyValue(c,"range");l&&this.xsdTypes.has(l)&&o.add(l)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,r)){let n=Array.from(o).sort().join(", "),c=s.sort().join(", "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`XSD namespace not imported but XSD types are used: ${n}`,a.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${c}`,a.entityName="imports",t.push(a)}return t}async checkXsdImportAsync(e,r,t=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&t.has(o))return!1;o&&t.add(o);for(let[,s]of Object.entries(e.imports))for(let i of s)if(i.packageName==="xsd"||i.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[s,i]of Object.entries(e.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);if(c?.metadata&&await this.checkXsdImportAsync(c.metadata,r,t))return!0}return!1}getPropertyValue(e,r){return e[r]?.toString()}};var Y=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,r){let t=[],o=await this.buildEntitySourceMapAsync(e,r),s=await this.buildDatatypePropertyNamesAsync(e,r);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&this.validateEntityReferences(i,n,o,s,e,t);return t}async buildEntitySourceMapAsync(e,r){let t=new Map,o=new Set;for(let s of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(s)||t.set(s,[]),t.get(s).push(`(local:${i})`)}if(e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);c&&await this.collectEntitiesRecursivelyAsync(c,t,o,r)}return t}async collectEntitiesRecursivelyAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let i of Object.keys(e.body)){r.has(i)||r.set(i,[]);let n=r.get(i);n.includes(s)||n.push(s)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await o.getHighestCompatibleVersionAsync(i,c);a&&await this.collectEntitiesRecursivelyAsync(a,r,t,o)}}}async buildDatatypePropertyNamesAsync(e,r){let t=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,t,o,r),e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let c=await r.getHighestCompatibleVersionAsync(s,n);c&&await this.collectDatatypePropertiesAsync(c,t,o,r)}return t}async collectDatatypePropertiesAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let[i,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let c=n.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&r.add(i)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await o.getHighestCompatibleVersionAsync(i,c);a&&await this.collectDatatypePropertiesAsync(a,r,t,o)}}}validateEntityReferences(e,r,t,o,s,i){for(let[n,c]of Object.entries(r)){let a=n;if(a&&!a.includes(".")){let p=t.get(a);if(p&&p.length>1&&!p.some(y=>y.startsWith("(local:"))){let y=p.filter(m=>!m.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,a,`Property '${a}'`,y,s,!0,a))}}this.validatePropertyValue(e,a,c,t,o,s,i)}}validatePropertyValue(e,r,t,o,s,i,n){if(t==null)return;let c=r&&r.includes(".")?r.substring(r.lastIndexOf(".")+1):r,a=!!c&&s.has(c);if(typeof t=="string"&&!t.includes(".")&&!a){let p=o.get(t);if(p&&p.length>1&&!p.some(y=>y.startsWith("(local:"))){let y=p.filter(m=>!m.startsWith("(local:"));y.length>1&&n.push(this.createAmbiguityError(e,r,`Reference '${t}'`,y,i,!1,t))}}else if(Array.isArray(t))for(let p=0;p<t.length;p++){let l=`${e}.${r}[${p}]`;this.validatePropertyValue(l,r,t[p],o,s,i,n)}else if(typeof t=="object"&&!Array.isArray(t)){let p=r?`${e}.${r}`:e;this.validateEntityReferences(p,t,o,s,i,n)}}createAmbiguityError(e,r,t,o,s,i,n){let c=[];for(let d of o){let b=this.findAliasForNamespace(s,d);if(b){let h=r?.split(".").pop()??r;c.push(`${b}.${h}`)}}let a=c.length>0?`Use one of: ${c.map(d=>`'${d}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${r}')`,p=o.map(d=>` \u2022 ${d}`).join(`
|
|
24
|
-
`),l=e.split(".")[0],y=e.includes(".")?e:r,m=new g;m.ruleType=this.ruleName,m.severity="Error",m.entityName=l,y&&(m.propertyName=y);let f=n??r;return f&&(m.actualValue=f),m.message=`${t} is ambiguous - defined in multiple imported namespaces`,m.suggestion=`${a}
|
|
25
|
-
|
|
26
|
-
Defined in:
|
|
27
|
-
${p}`,m.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",m}findAliasForNamespace(e,r){if(!e.metadata.imports)return null;for(let[t,o]of Object.entries(e.metadata.imports))for(let s of o)if(`${t}/${s.packageName}@${s.version}`===r&&s.alias)return s.alias;return null}};var Z=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=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","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i.type?.toString();this.isValidRangeTargetType(c)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=n.type?.toString();if(c!=="DatatypeProperty"&&c!=="ObjectProperty"&&!c?.endsWith(".DatatypeProperty")&&!c?.endsWith(".ObjectProperty"))continue;let a=n.range;if(!a)continue;let p=[];if(Array.isArray(a))for(let l of a){let y=l?.toString();y&&p.push(y)}else{let l=a?.toString();l&&p.push(l)}if(p.length===0)continue;for(let l of p){if(this.primitiveTypes.has(l)||this.builtInClasses.has(l)||o.has(l))continue;if(!await this.isTypeAvailableInImports(e,r,l)){let m=c?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${s}' has range '${l}' which is not defined or imported`,f.suggestion=m==="ObjectProperty"?`For ObjectProperty:
|
|
28
|
-
1. Define '${l}' as a Class in this namespace, OR
|
|
29
|
-
2. Import the namespace that contains '${l}', OR
|
|
30
|
-
3. Use a qualified reference like 'alias.${l}' if already imported with an alias`:`For DatatypeProperty:
|
|
31
|
-
1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
|
|
32
|
-
2. If '${l}' should be a class, change property type to ObjectProperty`,f.entityName=s,f.propertyName="range",f.actualValue=l,f.expectedValue=m==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",t.push(f)}}}return t}async isTypeAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){if(o!==null&&c.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=o!==null?s:t,l=a.body[p];if(l&&typeof l=="object"&&!Array.isArray(l)){let f=l.type?.toString();if(this.isValidRangeTargetType(f))return!0}let y=new Set;if(await this.isTypeAvailableInImportsRecursive(a,r,p,y))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let c of n){let a=await r.getHighestCompatibleVersionAsync(i,c);if(a){let p=a.body[t];if(p&&typeof p=="object"&&!Array.isArray(p)){let y=p.type?.toString();if(this.isValidRangeTargetType(y))return!0}if(await this.isTypeAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var G=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,r){let t=[],o=new Map,s=new D(r);await s.buildEntityIndexAsync(e);for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n,a=!1,p=c.type;if(Array.isArray(p)){for(let l of p)if(l?.toString()==="ObjectProperty"){a=!0;break}}else p?.toString()==="ObjectProperty"&&(a=!0);if(a){let l=c.range,y=[];if(Array.isArray(l))for(let m of l){let f=m?.toString();f&&y.push(f)}else{let m=l?.toString();m&&y.push(m)}for(let m of y)this.xsdTypes.has(m)||(o.has(m)||o.set(m,[]),o.get(m).push(i))}}for(let[i,n]of o)if(!await s.resolveEntityAsync(i,e))for(let a of n){let p=new g;p.ruleType=this.ruleName,p.severity="Warning",p.message=`ObjectProperty references class '${i}' which may not be imported`,p.suggestion=`Ensure the namespace containing '${i}' is imported, or define '${i}' in this document`,p.entityName=a,p.propertyName="range",p.actualValue=i,t.push(p)}return t}};var J=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,r){let t=[],o=new D(r),s=new we(o),i=await o.buildEntityIndexAsync(e),n=await this.buildPropertyMetadataAsync(e,r,o,i);for(let[c,a]of Object.entries(e.body))typeof a=="object"&&a!==null&&!Array.isArray(a)&&await this.scanEntityForObjectProperties(a,c,"",n,o,s,e,t);return t}async scanEntityForObjectProperties(e,r,t,o,s,i,n,c){for(let[a,p]of Object.entries(e)){if(this.standardProperties.has(a))continue;let l,y=await s.resolveEntityAsync(a,n);if(y?.uri){let m=`${y.uri.publisher}/${y.uri.package_}/${y.uri.name}`;l=o.get(m)}if(!l){let m=a,f=a.lastIndexOf(".");f>0&&f<a.length-1&&(m=a.substring(f+1)),l=o.get(m)}if(l&&i.isEffectiveObjectProperty(l.propertyType,l.rangeUri)){let f=t?`${t}.${a}`:a;if(typeof p=="string"&&p.trim().length>0){let d=p.trim();if(d.includes(",")){let h=d.split(",").map(P=>P.trim()).filter(P=>P.length>0);c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
|
|
33
|
-
${a}:
|
|
34
|
-
- ${h[0]}
|
|
35
|
-
${h.slice(1).map(P=>` - ${P}`).join(`
|
|
36
|
-
`)}`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:`A single reference to ${l.range??"an entity"} OR a YAML list`});continue}let b=await s.resolveEntityAsync(d,n);if(b)l.range&&(await this.validateRangeType(b,l.range,s,n)||c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${l.range}, but '${d}' may not be a ${l.range}`,suggestion:`Ensure '${d}' is defined with appropriate type`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:l.range}));else{let h=l.range??"entity";c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' references '${d}' which is not defined or imported`,suggestion:`Define '${d}' or import a namespace that contains it. Expected range: ${h}`,entityName:r,propertyName:a,propertyPath:f,actualValue:d,expectedValue:"Defined or imported entity"})}}else if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let d=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(p,r,d,o,s,i,n,c)}else if(Array.isArray(p))for(let d=0;d<p.length;d++){let b=p[d];if(typeof b=="string"&&b.trim().length>0){let h=b.trim(),P=await s.resolveEntityAsync(h,n);if(P){if(l.range&&!await this.validateRangeType(P,l.range,s,n)){let de=t?`${t}.${a}[${d}]`:`${a}[${d}]`;c.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${l.range}, but '${h}' may not be a ${l.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:r,propertyName:`${a}[${d}]`,propertyPath:de,actualValue:h,expectedValue:l.range})}}else{let ve=l.range??"entity",de=t?`${t}.${a}[${d}]`:`${a}[${d}]`;c.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' references '${h}' which is not defined or imported`,suggestion:`Define '${h}' or import a namespace that contains it. Expected range: ${ve}`,entityName:r,propertyName:`${a}[${d}]`,propertyPath:de,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof b=="object"&&b!==null&&!Array.isArray(b)){let h=t?`${t}.${a}[${d}]`:`${a}[${d}]`;await this.scanEntityForObjectProperties(b,r,h,o,s,i,n,c)}}}if(typeof p=="object"&&p!==null&&!Array.isArray(p)&&!o.has(a)){let m=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(p,r,m,o,s,i,n,c)}else if(Array.isArray(p))for(let m=0;m<p.length;m++){let f=p[m];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=t?`${t}.${a}[${m}]`:`${a}[${m}]`;await this.scanEntityForObjectProperties(f,r,d,o,s,i,n,c)}}}}async validateRangeType(e,r,t,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(r))return!0;let i=e.entity.type;if(i){let n=[];if(Array.isArray(i))for(let c of i){let a=c?.toString();a&&a.trim().length>0&&n.push(a)}else{let c=i?.toString();c&&c.trim().length>0&&n.push(c)}for(let c of n){let a=c.includes(".")?c.split(".")[1]:c;if(a===r||r==="Property"&&(a==="DatatypeProperty"||a==="ObjectProperty"||a==="AnnotationProperty")||r==="Class"&&a==="Class"||await t.isSubclassOfAsync(c,r,o))return!0}}return!1}async buildPropertyMetadataAsync(e,r,t,o){let s=new Map;for(let[i,n]of o){let c=n.entity.type;if(c){let a=[];if(Array.isArray(c))for(let y of c){let m=y?.toString();m&&m.trim().length>0&&a.push(m)}else{let y=c?.toString();y&&y.trim().length>0&&a.push(y)}let p=!1,l="Property";for(let y of a){let m=y.includes(".")?y.split(".")[1]:y;if(m==="Property"||m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty"){p=!0,l=y;break}}if(p){let y={propertyType:l},m=n.entity.range;if(m){let f=m?.toString();if(f&&f.trim().length>0){y.range=f;let d=await t.resolveEntityAsync(f,e);d&&(y.rangeUri=d.uri)}}if(s.set(i,y),n.uri){let f=`${n.uri.publisher}/${n.uri.package_}/${n.uri.name}`;s.set(f,y)}}}}return s}};var Q=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,r,t){let o=[],s=new Map;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=this.getPropertyValue(a,"type");(p==="DatatypeProperty"||p?.endsWith(".DatatypeProperty")||p==="ObjectProperty"||p?.endsWith(".ObjectProperty")||p==="AnnotationProperty"||p?.endsWith(".AnnotationProperty"))&&s.set(n,a)}let i=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,r);for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=this.getPropertyValue(a,"type");if(!p||p==="Class"||p.endsWith(".Class")||p.endsWith("Property")||p==="AnnotationProperty")continue;this.validateEntityProperties(a,n,p,s,i,o)}return o}async buildClassHierarchyViaCache(e,r){let t=new Map,o=Le(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s){let n=await r.getClassDeclarations(i);for(let[c,a]of n)a.length>0&&t.set(c,a)}return t}async buildCompleteClassHierarchyAsync(e,r){let t=new Map,o=new Set,s=async(n,c)=>{if(!o.has(c)){o.add(c);for(let[a,p]of Object.entries(n.body))if(typeof p=="object"&&p!==null&&!Array.isArray(p)){let l=p,y=this.getPropertyValue(l,"type");if(y==="Class"||y?.endsWith(".Class")){let m=l.subClassOf;if(m===void 0){for(let d of Object.keys(l))if(d.endsWith(".subClassOf")){m=l[d];break}}let f=V(m);f.length>0&&t.set(a,f)}}if(n.metadata.imports)for(let[a,p]of Object.entries(n.metadata.imports))for(let l of p)try{let y=await r.getHighestCompatibleVersionAsync(a,l);if(y){let m=`${a}/${l.packageName}@${l.version}`;await s(y,m)}}catch{}}},i=e.metadata.namespace_?.toString()??"unknown";return await s(e,i),t}validateEntityProperties(e,r,t,o,s,i){for(let[n,c]of Object.entries(e)){if(this.standardProperties.has(n))continue;let a=n,p=n.lastIndexOf(".");p>0&&p<n.length-1&&(a=n.substring(p+1));let l=o.get(a);if(!l)continue;let y=this.getPropertyValue(l,"domain");if(y){if(!this.isTypeCompatibleWithDomain(t,y,s)){let m=r.split(".")[0];i.push({ruleType:this.ruleName,severity:"Error",entityName:m,propertyName:r,actualValue:n,message:`Property '${n}' has domain '${y}' but is used on '${t}' at '${r}'`,suggestion:`Either:
|
|
37
|
-
1. Use this property only on '${y}' instances
|
|
38
|
-
2. Change the property domain to include '${t}'
|
|
39
|
-
3. Create a different property for '${t}'`,expectedValue:`Property used on ${y} or its subclasses`})}if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=c,f=this.getPropertyValue(m,"type");if(f){let d=`${r}.${n}`;this.validateEntityProperties(m,d,f,o,s,i)}else{let d=this.getPropertyValue(l,"range");if(d){let b=`${r}.${n}`;this.validateEntityProperties(m,b,d,o,s,i)}}}else if(Array.isArray(c))for(let m=0;m<c.length;m++){let f=c[m];if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let d=f,b=this.getPropertyValue(d,"type");if(b){let h=`${r}.${n}[${m}]`;this.validateEntityProperties(d,h,b,o,s,i)}else{let h=this.getPropertyValue(l,"range");if(h){let P=`${r}.${n}[${m}]`;this.validateEntityProperties(d,P,h,o,s,i)}}}}}}}isTypeCompatibleWithDomain(e,r,t){if(e===r)return!0;let o=new Set,s=[e];for(;s.length>0;){let i=s.shift();if(o.has(i))continue;o.add(i);let n=t.get(i);if(n)for(let c of n){if(c===r)return!0;s.push(c)}}return!1}getPropertyValue(e,r){if(r in e){let t=e[r];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${r}`)){let o=e[t];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let r=[];for(let t of e)r.push(t?.toString()??"");return r.length>0?r[0]:void 0}return e?.toString()}};function Le(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var ee=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,r){let t=[],o=new Map;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,c=this.getPropertyValue(n,"type");(c==="DatatypeProperty"||c==="ObjectProperty")&&o.set(s,n)}for(let[s,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let n=i,c=this.getPropertyValue(n,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[a,p]of Object.entries(n)){if(a==="type"||a==="label"||a==="comment")continue;let l=a,y=a.lastIndexOf(".");y>0&&y<a.length-1&&(l=a.substring(y+1));let m=o.get(l);if(!m)continue;let f=this.getPropertyValue(m,"type"),d=this.getPropertyValue(m,"range");if(f==="DatatypeProperty"){if(typeof p=="object"&&p!==null&&!Array.isArray(p)||Array.isArray(p))t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' is a DatatypeProperty with range '${d}' but instance '${s}' has a complex object value`,suggestion:`Either:
|
|
40
|
-
1. Create a class for this data and change '${a}' to an ObjectProperty
|
|
41
|
-
2. Store as a JSON string to keep it as DatatypeProperty
|
|
42
|
-
3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${d}'`});else if(!this.validateDatatypeValue(d,p)){let b={ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' expects type '${d}' but instance '${s}' has value of type '${this.getValueTypeName(p)}'`,suggestion:`Provide a value of type '${d}'`,toString:()=>""};d&&(b.expectedValue=d),t.push(b)}}else if(f==="ObjectProperty")if(Array.isArray(p))for(let b=0;b<p.length;b++){let h=p[b];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:`${a}[${b}]`,message:`ObjectProperty '${a}' array item ${b} in instance '${s}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof p!="string"&&(typeof p!="object"||p===null||Array.isArray(p))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`ObjectProperty '${a}' in instance '${s}' has invalid value type '${this.getValueTypeName(p)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${d} or embedded ${d} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let o=[];for(let s of t)o.push(s?.toString()??"");return o.length>0?o[0]:void 0}return t?.toString()}}};var te=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],o=new Map,s=new Set;for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let p=c.type;if(p)if(Array.isArray(p))for(let l of p){let y=l?.toString();if(y==="Class"||y&&y.endsWith(".Class")){s.add(n);break}}else{let l=p?.toString();(l==="Class"||l&&l.endsWith(".Class"))&&s.add(n)}}for(let[n,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let a=c,p=a.type;if(p)if(Array.isArray(p)){let l=!1;for(let y of p){let m=y?.toString();if(m&&this.isDefinitionType(m)){l=!0;break}}if(!l)for(let y of p){let m=y?.toString();m&&m.trim().length>0&&(o.has(m)||o.set(m,[]),o.get(m).push(n))}}else{let l=p?.toString();l&&l.trim().length>0&&(this.isDefinitionType(l)||(o.has(l)||o.set(l,[]),o.get(l).push(n)))}this.checkNestedTypes(a,n,o,n)}let i=new D(r);for(let[n,c]of o){if(this.builtInClasses.has(n)||s.has(n))continue;let a=await i.resolveEntityAsync(n,e);if(!(a&&this.isClassEntity(a.entity))){let l=Array.from(new Set(c)).sort();for(let y of l)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${n}' is not defined or imported`,suggestion:`Define '${n}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:n,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e,i=s.type;if(i){let n=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(i))for(let c of i){let a=c?.toString();a&&a.trim().length>0&&!n.has(a)&&(t.has(a)||t.set(a,[]),t.get(a).push(o))}else{let c=i?.toString();c&&c.trim().length>0&&!n.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(o))}}for(let[n,c]of Object.entries(s))if(n!=="type"){let a=`${o}.${n}`;this.checkNestedTypes(c,r,t,a)}}else if(Array.isArray(e))for(let s=0;s<e.length;s++){let i=`${o}[${s}]`;this.checkNestedTypes(e[s],r,t,i)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let o=t?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var re=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let o=[],s;if(t){let i=await t.getKanonaks(),n=Me(e);s=n?i.filter(c=>c instanceof O&&c.namespace===n):[]}else{let i=new j(e,r);s=await new A().parseKanonaks(i)}for(let i of s)i instanceof O&&this.checkDefined(i,i.name,o);return o}checkDefined(e,r,t){for(let o of e.statement)if(o instanceof Ee){let s=o.predicate.subject?.name??"(unknown)";for(let i of o.links)i.target||t.push(this.unresolvedLinkError(r,s,i.reference));for(let i of je(o.object))t.push(this.malformedLinkError(r,s,i.snippet))}else if(o instanceof Ie)this.checkDefined(o.object,r,t);else if(o instanceof Oe)for(let s of o.object)s instanceof w&&this.checkDefined(s,r,t)}unresolvedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
43
|
-
|
|
44
|
-
Possible solutions:
|
|
45
|
-
\u2022 Import the package that defines '${t}' so the link can resolve
|
|
46
|
-
\u2022 Check for typos in the reference name
|
|
47
|
-
\u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,o}malformedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Malformed embedded reference near '${t}' in '${r}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${r}' does not form a complete [[reference]] link.
|
|
48
|
-
|
|
49
|
-
A reference may not span a line break \u2014 the most common cause is wrapping a
|
|
50
|
-
long reference across two lines in a block scalar, e.g.:
|
|
51
|
-
... read for [[persistent-energy-
|
|
52
|
-
shock]] held ...
|
|
53
|
-
which is parsed as literal text, not a link. Keep each [[reference]] on one
|
|
54
|
-
line (let the line run long), or check for an unterminated [[.`,o}};function Me(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var xe="kanonak.org",_e="look",We={publisher:xe,package_:_e,name:"displayLabel"},He={publisher:xe,package_:_e,name:"displaySummary"},oe=class{ruleName="DisplayLensScope";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=Fe(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&(this.checkLens(s,n,We,"displayLabel",o),this.checkLens(s,n,He,"displaySummary",o));return o}checkLens(e,r,t,o,s){let i=E(r,t);if(!i)return;let n=[],c=ue(r);if(c&&n.push(c),n.push(...Se(r)),n.length===0)return;n.some(p=>$(e,p,i).ok)||s.push(this.scopeError(r.name,o,i.name))}scopeError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`${r} points at '${t}', which is not a property in scope for '${e}'`,o.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",o.suggestion=`'${t}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
|
|
55
|
-
|
|
56
|
-
Possible solutions:
|
|
57
|
-
\u2022 Point ${r} at a property declared on this class (or an ancestor / rdfs.Resource)
|
|
58
|
-
\u2022 Set the property's domain to this class if it should apply here
|
|
59
|
-
\u2022 Use rdfs.label / rdfs.comment for the universal default`,o}};function Fe(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}function pe(u,e,r){let t=[];return ce(u,r,{input:e},t),t}function ce(u,e,r,t){if(me(e,v.VarRef)){let i=ge(e,v.varName);return i?r[i]:void 0}if(me(e,v.PropertyRead)){let i=I(e,v.readSource),n=i?ce(u,i,r,t):void 0,c=E(e,v.readProp);if(!n||!c)return;let a=$(u,n,c);if(!a.ok){t.push({contextClass:n,propertyUri:c,via:"PropertyRead"});return}return a.descriptor?.range}if(me(e,v.Traverse)){let i=I(e,v.traverseSource),n=i?ce(u,i,r,t):void 0,c=E(e,v.through),a;if(n&&c){let l=$(u,n,c);l.ok?a=l.descriptor?.range:t.push({contextClass:n,propertyUri:c,via:"Traverse"})}let p=I(e,v.step);return p?ce(u,p,{...r,input:a},t):void 0}let o=ge(e,v.loopVar),s=o?{...r,[o]:void 0}:r;for(let i of Be(e))ce(u,i,s,t)}function Be(u){let e=[];for(let r of u.statement){let t=r.object;if(t instanceof w)e.push(t);else if(Array.isArray(t))for(let o of t)o instanceof w&&e.push(o)}return e}var le="kanonak.org",ye="look",qe={publisher:le,package_:ye,name:"semanticSvg"},Xe={publisher:le,package_:ye,name:"tierChip"},ze={publisher:le,package_:ye,name:"tierIcon"},Ye={publisher:le,package_:ye,name:"tierCard"},Ze={publisher:le,package_:ye,name:"tierFull"},Ge=[Xe,ze,Ye,Ze],ne=class{ruleName="LookSemanticSvgPath";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=Je(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&this.checkSemanticSvg(s,n,o);return o}checkSemanticSvg(e,r,t){let o=I(r,qe);if(!o)return;let s=ue(r);if(s)for(let i of Ge){let n=I(o,i);if(n)for(let c of pe(e,s,n))t.push(this.toError(r.name,i.name,c))}}toError(e,r,t){let o=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,i=s===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${s}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,n=new g;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=`look.semanticSvg.${r}`,n.actualValue=o,n.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${i}. The read would silently return undefined at render time.`,n.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,n.suggestion=`Property '${o}' is not in scope for '${s}'.
|
|
60
|
-
|
|
61
|
-
Possible solutions:
|
|
62
|
-
\u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
|
|
63
|
-
\u2022 If the property should apply to '${s}', adjust its domain
|
|
64
|
-
\u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,n}};function Je(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var se="kanonak.org",ae="view",Qe={publisher:se,package_:ae,name:"bind"},et={publisher:se,package_:ae,name:"produces"},tt={publisher:se,package_:ae,name:"projections"},rt={publisher:se,package_:ae,name:"where"},ot={publisher:se,package_:ae,name:"value"},nt={publisher:se,package_:ae,name:"as"},ie=class{ruleName="TxExpressionPath";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new A().parseKanonaks(new j(e,r));let i=at(e);if(!i)return o;for(let n of s)n instanceof O&&n.namespace===i&&this.checkView(s,n,o);return o}checkView(e,r,t){let o=E(r,Qe);if(!o)return;let s=E(r,et),i=0;for(let c of st(e,he(r,tt))){let a=I(c,ot);if(a)for(let l of pe(e,o,a))t.push(this.toError(r.name,`view.projections[${i}].value`,o,l));let p=E(c,nt);p&&s&&($(e,s,p).ok||t.push(this.asError(r.name,i,s,p))),i+=1}let n=0;for(let c of it(r,rt)){for(let a of pe(e,o,c))t.push(this.toError(r.name,`view.where[${n}]`,o,a));n+=1}}asError(e,r,t,o){let s=`${o.publisher}/${o.package_}/${o.name}`,i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`view.projections[${r}].as`,i.actualValue=s,i.message=`Projection stores its value under property '${o.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.`,i.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${s}' is not in scope for produces class '${t.name}'.
|
|
65
|
-
|
|
66
|
-
Possible solutions:
|
|
67
|
-
\u2022 Use an output property whose domain covers '${t.name}'
|
|
68
|
-
\u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
|
|
69
|
-
\u2022 If the value belongs on a different output class, adjust the view's produces`,i}toError(e,r,t,o){let s=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,i=o.contextClass.name,n=i===t.name?`the view's bound class '${t.name}'`:`'${i}', reached by traversal from the view's bound class '${t.name}'`,c=new g;return c.ruleType=this.ruleName,c.severity="Error",c.entityName=e,c.propertyName=r,c.actualValue=s,c.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for ${n}. The read would silently return undefined when the view materializes.`,c.expectedValue=`A property whose domain is '${i}', an ancestor, or rdfs.Resource`,c.suggestion=`Property '${s}' is not in scope for '${i}'.
|
|
70
|
-
|
|
71
|
-
Possible solutions:
|
|
72
|
-
\u2022 Read a property declared on '${i}' (or an ancestor / rdfs.Resource)
|
|
73
|
-
\u2022 If the property should apply to '${i}', adjust its domain
|
|
74
|
-
\u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function it(u,e){let r=I(u,e);return r?[r]:he(u,e).filter(t=>t instanceof w)}function st(u,e){let r=[];for(let t of e)if(t instanceof w)r.push(t);else if(t instanceof Ae){let o=$e(u,t.subject);o&&r.push(o)}return r}function at(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${k(e.version)}`}var Ve=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new De,this.documentRules=[new K,new N,new C,new T],this.repositoryRules=[new x,new _,new U,new L,new M,new W,new H,new F,new B,new q,new X,new z,new Y,new Z,new G,new J,new Q,new ee,new te,new re,new oe,new ne,new ie]}async validateAsync(e,r,t){let o=new S;for(let s of this.documentRules)try{let i=s.validate(e);this.addErrorsToResult(o,i)}catch(i){let n=new g;n.ruleType=s.ruleName,n.severity="Error",n.message=`Validation rule '${s.ruleName}' failed: ${i instanceof Error?i.message:String(i)}`,o.errors.push(n)}if(r){let s=[],i=t?.repository??r;for(let n of this.repositoryRules)try{let c=await n.validateAsync(e,i,t);this.addErrorsToResult(o,c)}catch(c){let a=c instanceof Error?c.message:String(c);s.push({ruleName:n.ruleName,cause:a})}if(s.length>0){let n=new Map;for(let{ruleName:c,cause:a}of s){let p=n.get(a);p?p.push(c):n.set(a,[c])}for(let[c,a]of n){let p=new g;p.ruleType=a[0],p.severity="Error",a.length===1?p.message=`Validation rule '${a[0]}' failed: ${c}`:p.message=`${c} (affects ${a.length} rules: ${a.join(", ")})`,o.errors.push(p)}}}return o.isValid=o.errors.length===0,o}async validateYamlAsync(e,r,t){let o=this.parser.parseWithErrors(e);if(!o.isValid){let s=new S;s.isValid=!1;for(let i of o.errors){let n=new g;n.ruleType="ParseError",n.severity="Error",n.lineNumber=i.line,n.column=i.column,n.message=i.message,i.keyName&&(n.entityName=i.keyName),i.errorType==="DuplicateKey"&&(n.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(n)}return s}return await this.validateAsync(o.document,r,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let r=this.documentRules.findIndex(t=>t instanceof e);r>=0&&this.documentRules.splice(r,1)}removeRepositoryRule(e){let r=this.repositoryRules.findIndex(t=>t instanceof e);r>=0&&this.repositoryRules.splice(r,1)}addErrorsToResult(e,r){for(let t of r)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{S as a,R as b,g as c,be as d,ke as e,K as f,N as g,C as h,T as i,x as j,_ as k,U as l,L as m,M as n,W as o,H as p,F as q,B as r,q as s,X as t,z as u,Y as v,Z as w,G as x,J as y,Q as z,ee as A,te as B,re as C,oe as D,ne as E,ie as F,Ve as G};
|