@kanonak-protocol/sdk 3.75.0 → 3.77.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.
Files changed (39) hide show
  1. package/dist/browser.d.ts +2 -0
  2. package/dist/browser.js +2 -2
  3. package/dist/chunk-CG43Z65M.js +2 -0
  4. package/dist/chunk-IUZZDC2U.js +1 -0
  5. package/dist/{chunk-FX7JDGL6.js → chunk-KXVSGB6Q.js} +1 -1
  6. package/dist/chunk-NPEGVH4R.js +84 -0
  7. package/dist/{chunk-GN2XODVC.js → chunk-PJMOM5H7.js} +1 -1
  8. package/dist/{chunk-F5ANO7MJ.js → chunk-RVOMWGIN.js} +1 -1
  9. package/dist/chunk-XQS5LDSO.js +1 -0
  10. package/dist/{chunk-X5TYWQRA.js → chunk-XWRVENU6.js} +1 -1
  11. package/dist/chunk-Z5ELOT2C.js +1 -0
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +26 -26
  14. package/dist/introspection/OntologyModel.d.ts +80 -7
  15. package/dist/introspection/ShaclConstraints.d.ts +48 -0
  16. package/dist/introspection/index.d.ts +1 -1
  17. package/dist/parsing/index.js +1 -1
  18. package/dist/reasoning/index.js +1 -1
  19. package/dist/resolution/TypeDirectedResolver.d.ts +11 -0
  20. package/dist/resolution/index.d.ts +1 -1
  21. package/dist/resolution/index.js +1 -1
  22. package/dist/search/index.js +1 -1
  23. package/dist/server/index.js +1 -1
  24. package/dist/transformations/index.js +1 -1
  25. package/dist/uri-helpers/UriHelpers.d.ts +6 -0
  26. package/dist/uri-helpers/index.d.ts +1 -1
  27. package/dist/uri-helpers/index.js +1 -1
  28. package/dist/validation/index.d.ts +1 -1
  29. package/dist/validation/index.js +1 -1
  30. package/dist/validation/rules/repository/DiamondNameClashRule.d.ts +30 -0
  31. package/dist/validation/rules/repository/OwlOneOfRule.d.ts +28 -0
  32. package/dist/validation/rules/repository/ShaclShapeRule.d.ts +32 -0
  33. package/dist/validation/rules/repository/index.d.ts +3 -0
  34. package/package.json +2 -2
  35. package/dist/chunk-BGQKZBNE.js +0 -1
  36. package/dist/chunk-C7RZIMEH.js +0 -80
  37. package/dist/chunk-CRKSKIAL.js +0 -1
  38. package/dist/chunk-G2DKKSZ4.js +0 -1
  39. package/dist/chunk-Y7TGQ7UF.js +0 -2
@@ -104,6 +104,12 @@ export declare function findAllResourcesByCanonicalUri(catalog: Kanonak[], uri:
104
104
  package_: string;
105
105
  name: string;
106
106
  }): SubjectKanonak[];
107
+ /**
108
+ * True when a defined kanonak carries any statement for the given property
109
+ * URI — regardless of value. Distinguishes "property present (e.g. an empty
110
+ * list)" from "property absent", which the value getters cannot.
111
+ */
112
+ export declare function hasProperty(defined: DefinedKanonak, property: EntityUri): boolean;
107
113
  /**
108
114
  * Read a datatype property value (string, number, boolean) off a defined
109
115
  * kanonak, by property URI. Returns `undefined` when the property is not
@@ -1,3 +1,3 @@
1
- export { uriKey, uriMatches, toCanonicalUrl, hasType, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
1
+ export { uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
2
2
  export type { EntityUri, CanonicalUriParts } from './UriHelpers.js';
3
3
  export { SingleDocumentRepository } from './SingleDocumentRepository.js';
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../chunk-CRKSKIAL.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{m as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,h as getDatatypeValue,k as getEmbeddedValue,l as getListValues,j as getReferenceUri,i as getStringValue,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"../chunk-XQS5LDSO.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{n as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,i as getDatatypeValue,l as getEmbeddedValue,m as getListValues,k as getReferenceUri,j as getStringValue,h as hasProperty,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
@@ -8,4 +8,4 @@ export { KanonakObjectValidator } from './KanonakObjectValidator.js';
8
8
  export type { IDocumentValidationRule } from './rules/document/IDocumentValidationRule.js';
9
9
  export type { IRepositoryValidationRule } from './rules/repository/IRepositoryValidationRule.js';
10
10
  export { NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule } from './rules/document/index.js';
11
- export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, TxExpressionPathRule } from './rules/repository/index.js';
11
+ export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, TxExpressionPathRule, ShaclShapeRule, OwlOneOfRule, DiamondNameClashRule } from './rules/repository/index.js';
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,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-C7RZIMEH.js";import"../chunk-SHDHMKMJ.js";import"../chunk-G2DKKSZ4.js";import"../chunk-TJPQETHV.js";import"../chunk-BGQKZBNE.js";import"../chunk-CRKSKIAL.js";import"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,D as DisplayLensScopeRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,G as KanonakObjectValidator,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,F as TxExpressionPathRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
1
+ import{A,B,C,D,E,F,G,H,K as I,L as J,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-NPEGVH4R.js";import"../chunk-SHDHMKMJ.js";import"../chunk-IUZZDC2U.js";import"../chunk-TJPQETHV.js";import"../chunk-Z5ELOT2C.js";import"../chunk-XQS5LDSO.js";import"../chunk-IOMNZBK4.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,I as DiamondNameClashRule,D as DisplayLensScopeRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,J as KanonakObjectValidator,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,H as OwlOneOfRule,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,G as ShaclShapeRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,F as TxExpressionPathRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
@@ -0,0 +1,30 @@
1
+ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
+ import { OntologyValidationError } from '../../OntologyValidationError.js';
4
+ import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
+ import type { ValidationCache } from '../../ValidationCache.js';
6
+ /**
7
+ * Errors when a class inherits, through its `subClassOf` graph, two or more
8
+ * DISTINCT properties (different URIs) that share a local name but are
9
+ * type-INCOMPATIBLE — differing in resolved range or in cardinality (single
10
+ * vs list). This is a "diamond name-clash": the typed-SDK generators model
11
+ * classes as interfaces with multiple inheritance (TS `extends A, B`, C#
12
+ * `: IA, IB`, …), and two same-named-but-incompatible members make the
13
+ * generated interface uncompilable. Catching it at validate time turns a
14
+ * cryptic downstream compile failure into a loud, actionable design-time error.
15
+ *
16
+ * Benign cases do NOT fire: one property reached through multiple diamond paths
17
+ * (same URI — deduped), two parents referencing the same property (same URI),
18
+ * two distinct same-named properties whose range AND cardinality agree (the
19
+ * generated members are identical and merge), and different local names.
20
+ *
21
+ * General class-hierarchy well-formedness — independent of SHACL — but
22
+ * cardinality compatibility reads the SHACL-derived `minCount`/`maxCount` (#52)
23
+ * when shapes are present. Built on the canonical `propertiesInScope` (the
24
+ * exact set that lands on the class's interface) + `superClassChain`.
25
+ */
26
+ export declare class DiamondNameClashRule implements IRepositoryValidationRule {
27
+ readonly ruleName = "DiamondNameClash";
28
+ validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
29
+ private toError;
30
+ }
@@ -0,0 +1,28 @@
1
+ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
+ import { OntologyValidationError } from '../../OntologyValidationError.js';
4
+ import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
+ import type { ValidationCache } from '../../ValidationCache.js';
6
+ /**
7
+ * Validates the `owl:oneOf` class-level enumeration marker (#53) so a closed
8
+ * enumeration means what it says before `buildOntologyModel` surfaces it as an
9
+ * EnumDef. Because an `rdf:List` member that does not resolve in scope is
10
+ * parsed as a literal (the heterogeneous-list rule that lets `sh:in` carry
11
+ * literals), a typo'd or unimported individual would silently become a literal
12
+ * — this rule restores fail-loud:
13
+ *
14
+ * - a member that is a literal → Error (a class enumeration is of named
15
+ * individuals; literal value sets belong on a property via `sh:in`). This is
16
+ * also what a misspelled / unimported individual surfaces as.
17
+ * - a member that resolves to a class / property / datatype → Error (a schema
18
+ * definition is not an individual).
19
+ * - an empty `owl:oneOf` → Warning (an enumeration with no members).
20
+ *
21
+ * Recognized by the durable `kanonak.org/core-owl` identity of `oneOf`, never
22
+ * by alias or name shape.
23
+ */
24
+ export declare class OwlOneOfRule implements IRepositoryValidationRule {
25
+ readonly ruleName = "OwlOneOf";
26
+ validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
27
+ private err;
28
+ }
@@ -0,0 +1,32 @@
1
+ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
+ import { OntologyValidationError } from '../../OntologyValidationError.js';
4
+ import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
+ import type { ValidationCache } from '../../ValidationCache.js';
6
+ /**
7
+ * Validates scoped-SHACL shapes (`kanonak.org/core-shacl`) are well-formed so
8
+ * authoring mistakes surface at `kanonak validate` time rather than producing a
9
+ * silently-wrong type-model in `buildOntologyModel` (#52 Part B). Fires only
10
+ * when the document declares NodeShape/PropertyShape resources.
11
+ *
12
+ * Structural problems are Errors: a PropertyShape with no `sh:path`; a path /
13
+ * targetClass / sh:class / sh:datatype that does not resolve; `sh:datatype` and
14
+ * `sh:class` both set; reversed numeric bounds; an invalid `sh:pattern` regex
15
+ * or flags; an empty `sh:in`. A path that resolves but is not in scope for the
16
+ * enclosing `sh:targetClass`, and a facet applied to an incompatible value
17
+ * kind, are Warnings (the constraint would never bind anything).
18
+ *
19
+ * Built on the parsed object model — shapes and their fields are recognized by
20
+ * durable core-shacl URI identity and references resolve through
21
+ * `resolvePropertyStep` / `findSubjectByUri`, never by alias or name shape.
22
+ */
23
+ export declare class ShaclShapeRule implements IRepositoryValidationRule {
24
+ readonly ruleName = "ShaclShape";
25
+ validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
26
+ private checkPropertyShape;
27
+ private checkOrder;
28
+ private resolvesToClass;
29
+ private resolvesToDatatype;
30
+ private isNumericDatatypeRange;
31
+ private err;
32
+ }
@@ -23,3 +23,6 @@ export { DisplayLensScopeRule } from './DisplayLensScopeRule.js';
23
23
  export { LookSemanticSvgPathRule } from './LookSemanticSvgPathRule.js';
24
24
  export { LookBandPathRule } from './LookBandPathRule.js';
25
25
  export { TxExpressionPathRule } from './TxExpressionPathRule.js';
26
+ export { ShaclShapeRule } from './ShaclShapeRule.js';
27
+ export { OwlOneOfRule } from './OwlOneOfRule.js';
28
+ export { DiamondNameClashRule } from './DiamondNameClashRule.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "3.75.0",
3
+ "version": "3.77.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",
@@ -122,7 +122,7 @@
122
122
  "yaml-parser"
123
123
  ],
124
124
  "dependencies": {
125
- "@kanonak-protocol/types": "^3.75.0",
125
+ "@kanonak-protocol/types": "^3.77.0",
126
126
  "ignore": "^7.0.5",
127
127
  "js-yaml": "^4.1.0",
128
128
  "yaml": "^2.7.0"
@@ -1 +0,0 @@
1
- import{a as p,f as U,i as _,j as m,l as j}from"./chunk-CRKSKIAL.js";import{i as g}from"./chunk-IOMNZBK4.js";import{c as K,d as S}from"./chunk-W6T7MOKY.js";import{a as b}from"./chunk-FUUTGGJS.js";var $=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function s(r){let n=r;if(n.entity&&typeof n.entity=="object"){let e=n.entity.type;if(typeof e=="string"){let a={publisher:"",package_:"",name:e.includes(".")?e.substring(e.lastIndexOf(".")+1):e};return g(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}if(n.statement&&Array.isArray(n.statement)){for(let e of n.statement)if(e.predicate?.subject?.name==="type"&&e.object?.subject){let t=e.object.subject,a={publisher:t.publisher??"",package_:t.package_??"",name:t.name};return g(a),{publisher:a.publisher,package_:a.package_,name:a.name}}}return null}function c(r,n){return $.has(`${r}/${n}`)}var k=class r{static getTypeUri(n){return s(n)}static isCoreOntologyType(n){return c(n.publisher,n.package_)}static isClassType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="Class":!1}static isDatatypeType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="Datatype":!1}static isDatatypePropertyType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="DatatypeProperty":!1}static isObjectPropertyType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="ObjectProperty":!1}static isAnnotationPropertyType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="AnnotationProperty":!1}static isGenericPropertyType(n){let e=s(n);return e?c(e.publisher,e.package_)&&e.name==="Property":!1}static isAnyPropertyType(n){let e=s(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"}static isSchemaDefinitionType(n){let e=s(n);return!e||!c(e.publisher,e.package_)?!1:e.name==="Class"||e.name==="Property"||e.name==="DatatypeProperty"||e.name==="ObjectProperty"||e.name==="AnnotationProperty"||e.name==="Datatype"}static isInstanceOfKnownClass(n,e){if(r.isSchemaDefinitionType(n))return!1;let t=s(n);return t?e.has(t.name):!1}};function P(r){if(!r||r.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=r.trim(),e=n.split("/");if(e.length===1){let t=e[0];if(!t)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(t.includes("@"))throw new Error(`Invalid Kanonak address: "${r}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:t}}if(e.length===2){let[t,a]=e;if(!t||!a)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:t,package_:a};let i=a.substring(0,o),u=a.substring(o+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${r}". Expected publisher/package[@version].`);let f=A(u);return{kind:"package",publisher:t,package_:i,version:f}}return{kind:"resource",uri:b.parse(n)}}function q(r){switch(r.kind){case"publisher":return r.publisher;case"package":return r.version?`${r.publisher}/${r.package_}@${r.version.major}.${r.version.minor}.${r.version.patch}`:`${r.publisher}/${r.package_}`;case"resource":return r.uri.toString()}}function A(r){let n=r.split(".").map(Number);return w(n[0]||0,n[1]||0,n[2]||0)}function w(r,n,e){return{major:r,minor:n,patch:e,toString:()=>`${r}.${n}.${e}`,equals:t=>!t||typeof t!="object"?!1:t.major===r&&t.minor===n&&t.patch===e,getHashCode:()=>r<<20|n<<10|e,compareTo:t=>r!==t.major?r-t.major:n!==t.minor?n-t.minor:e-t.patch}}var l="kanonak.org",y="core-rdf",T={publisher:l,package_:y,name:"domain"},v={publisher:l,package_:y,name:"range"},x={publisher:l,package_:y,name:"subClassOf"},D={publisher:l,package_:y,name:"type"},R={publisher:l,package_:y,name:"label"},C=new b(l,y,"Resource"),O=r=>r;function I(r){try{let n=P(`${r.namespace}/${r.name}`);return n.kind==="resource"?n.uri:void 0}catch{return}}function d(r,n){let e=m(r,n);if(e)return[e];let t=[];for(let a of j(r,n))a instanceof S&&t.push(a.subject);return t}function V(r,n){let e=new Set([p(C)]),t=new Set,a=[new b(n.publisher,n.package_,n.name)];for(;a.length>0;){let o=a.shift(),i=p(o);if(t.has(i))continue;t.add(i),e.add(i);let u=U(r,o);u&&a.push(...d(u,x))}return e}function B(r,n){let e=V(r,n),t=[],a=new Set;for(let o of r){if(!(o instanceof K))continue;let i=O(o);if(!k.isAnyPropertyType(i)||!d(o,T).some(E=>e.has(p(E))))continue;let f=I(o);if(!f)continue;let h=p(f);a.has(h)||(a.add(h),t.push({uri:f,label:_(o,R),kind:k.isObjectPropertyType(i)?"object":k.isDatatypePropertyType(i)?"datatype":"other",range:m(o,v)}))}return t}function Q(r,n,e){let t=B(r,n).find(a=>p(a.uri)===p(e));return t?{ok:!0,descriptor:t}:{ok:!1,message:`Property ${e.publisher}/${e.package_}/${e.name} is not in scope for ${n.publisher}/${n.package_}/${n.name}.`}}function X(r){return d(r,D)}export{k as a,P as b,q as c,I as d,B as e,Q as f,X as g};
@@ -1,80 +0,0 @@
1
- import{d as $}from"./chunk-SHDHMKMJ.js";import{a as D,c as je,d as Ke,f as O}from"./chunk-G2DKKSZ4.js";import{a as Ee}from"./chunk-TJPQETHV.js";import{d as T,f as N,g as Ce}from"./chunk-BGQKZBNE.js";import{d as A,f as Ne,i as ke,j as I,k as P,l as K,m as S}from"./chunk-CRKSKIAL.js";import{a as E,b as j,c as Se}from"./chunk-IOMNZBK4.js";import{c as w,d as Oe,k as we,l as $e}from"./chunk-W6T7MOKY.js";import{e as V}from"./chunk-2ACBWC7K.js";var x=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var k=(o=>(o.Warning="Warning",o.Error="Error",o))(k||{});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 Re=class u{resolvedDocuments=[];currentEntityPath;withPath(e){let o=new u;return o.resolvedDocuments=this.resolvedDocuments,o.currentEntityPath=e,o}};var Ve=class{constructor(e){this.underlying=e;this.repository=new ve(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new O().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let o=this.importClosureCache.get(e);return o||(o=this.computeImportClosure(e),this.importClosureCache.set(e,o),o)}async getClassDeclarations(e){let o=this.classDeclarationsCache.get(e);return o||(o=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,o),o)}async getPropertyNames(e){let o=this.propertyNamesCache.get(e);return o||(o=this.computePropertyNames(e),this.propertyNamesCache.set(e,o),o)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let o=new Set([e]),t=[e],r=await this.buildDocsByIdIndex();for(;t.length>0;){let s=t.shift(),n=r.get(s);if(n?.metadata.imports)for(let[i,c]of Object.entries(n.metadata.imports))for(let a of c){let p=await this.repository.getHighestCompatibleVersionAsync(i,a);if(!p)continue;let l=Pe(p);!l||o.has(l)||(o.add(l),t.push(l))}}return o}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),o=new Map;for(let t of e){let r=Pe(t);r&&o.set(r,t)}return o}async computeClassDeclarations(e){let o=await this.findDocById(e),t=new Map;if(!o)return t;for(let[r,s]of Object.entries(o.body)){if(!Te(s))continue;let n=s,i=xe(n,"type");if(i==="Class"||i?.endsWith(".Class")){let c=qe(n);t.set(r,c)}}return t}async computePropertyNames(e){let o=await this.findDocById(e),t=new Set;if(!o)return t;for(let[r,s]of Object.entries(o.body)){if(!Te(s))continue;let i=xe(s,"type");(i==="ObjectProperty"||i?.endsWith(".ObjectProperty")||i==="DatatypeProperty"||i?.endsWith(".DatatypeProperty")||i==="AnnotationProperty"||i?.endsWith(".AnnotationProperty")||i==="Property"||i?.endsWith(".Property"))&&t.add(r)}return t}async findDocById(e){let o=await this.getAllDocuments();for(let t of o)if(Pe(t)===e)return t}};function Pe(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}function Te(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}function xe(u,e){if(e in u)return _e(u[e]);for(let o of Object.keys(u))if(o.endsWith(`.${e}`))return _e(u[o])}function _e(u){return Array.isArray(u)?u.length>0?String(u[0]):void 0:u==null?void 0:String(u)}function qe(u){let e=u.subClassOf;if(e===void 0){for(let o of Object.keys(u))if(o.endsWith(".subClassOf")){e=u[o];break}}return E(e)}var ve=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}`,r=this.byNamespaceCache.get(t);return r||(r=this.inner.getDocumentsByNamespaceAsync(e,o),this.byNamespaceCache.set(t,r),r)}getHighestCompatibleVersionAsync(e,o){let t=o.version,r=t?`${t.major}.${t.minor}.${t.patch}`:"",s=`${e}/${o.packageName}@${o.versionOperator}:${r}`,n=this.highestVersionCache.get(s);return n||(n=this.inner.getHighestCompatibleVersionAsync(e,o),this.highestVersionCache.set(s,n),n)}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 _=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 o=[];for(let[t,r]of Object.entries(e.body))r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(t,r,o);return o}validateEntity(e,o,t){for(let[r,s]of Object.entries(o)){let n=s?.toString()??"";if(n&&u.NAMESPACE_PREFIX_PATTERN.test(n)){let i=this.getSuggestionForPrefixedValue(n),c=e.split(".")[0],a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=r,a.expectedValue=i,a.message=`Invalid namespace prefix '${n}'. Use '${i}' 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}.${r}`,s,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 U=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 o=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[r,s]of Object.entries(e.body)){let n=u.VALID_AUGMENTATION_PATTERN.test(r);if(!n&&!t&&u.RESERVED_WORDS.has(r.toLowerCase())){let i=new g;i.ruleType=this.ruleName,i.severity="Error",i.entityName=r,i.message=`Entity name '${r}' 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(!n&&!u.VALID_NAME_PATTERN.test(r)){let i;/^\d/.test(r)?i="Entity names must start with a letter, not a number.":r.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 g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=r,c.message=`Invalid entity name '${r}'. ${i}`,c.suggestion=i,o.push(c)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validatePropertyNames(r,s,o)}return o}validatePropertyNames(e,o,t){for(let r of Object.keys(o))if(!u.VALID_PROPERTIES.has(r)&&!u.VALID_PROPERTY_NAME_PATTERN.test(r)){let s=new g;s.ruleType=this.ruleName,s.severity="Warning",s.entityName=e,s.propertyName=r,s.message=`Property name '${r}' 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 L=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 o=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return o;let t=this.isPropertyDefinedAsClass(e);for(let[r,s]of Object.entries(e.body))if(s&&typeof s=="object"&&!Array.isArray(s)){let n=s,i=n.type;if(i){let c=[];if(Array.isArray(i))for(let a of i){let p=a?.toString();p&&p==="Property"&&!t&&c.push(p)}else{let a=i?.toString();a&&a==="Property"&&!t&&c.push(a)}for(let a of c){let p=this.getPropertyValue(n,"range"),l=this.determinePropertyType(p),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=r,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.",o.push(y)}}}return o}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,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 r=o.type;if(r){let s=r.toString();return s==="Class"||s.endsWith(".Class")}}return!1}};var M=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let o=[];for(let[t,r]of Object.entries(e.body)){if(typeof r!="object"||r===null||Array.isArray(r)||t.includes("."))continue;let s=r,n="type"in s,i=s.type?.toString().trim();if(!n||!i){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.)",o.push(c)}}return o}};var W=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,o){let t=[],r=new j(o),s=await this.buildPropertyRangeMap(e,r);for(let[n,i]of Object.entries(e.body))typeof i=="object"&&i!==null&&!Array.isArray(i)&&await this.checkEmbeddedTypes(n,i,void 0,s,r,e,t,0);return t}pickRange(e,o,t){if(e.length===0)return;if(e.length===1)return e[0].range;let r=o.indexOf(".");if(r>0){let s=o.substring(0,r),n=e.find(i=>i.declaringAlias===s);if(n)return n.range}if(t){let s=this.localName(t),n=e.find(i=>this.localName(i.domain)===s);if(n)return n.range}return e[0].range}async checkEmbeddedTypes(e,o,t,r,s,n,i,c){if(c>0){let p=o.type;if(p!=null){let l=await this.validateEmbeddedType(e,String(p),t,s,n);l&&i.push(l)}}let a=o.type!==void 0&&o.type!==null?String(o.type):void 0;for(let[p,l]of Object.entries(o)){let y=this.localName(p),m=r.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,r,s,n,i,c+1)}else await this.checkEmbeddedTypes(`${e}.${p}`,l,d,r,s,n,i,c+1)}}async validateEmbeddedType(e,o,t,r,s){if(o.length===0||!t)return null;let n=this.localName(o),i=this.localName(t);if(i==="Resource"||i==="Class")return null;let c=e.split(".")[0];if(n===i){let p=new g;return p.ruleType=this.ruleName,p.severity="Warning",p.entityName=c,p.propertyName=e,p.actualValue=o,p.expectedValue=t,p.message=`Embedded object at '${e}' declares 'type: ${o}', 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: ${o}' line, or keep it if explicitness is preferred over concision.`,p}if(await r.isSubclassOfAsync(o,t,s)||(n!==o||i!==t)&&await r.isSubclassOfAsync(n,i,s))return null;let a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=c,a.propertyName=e,a.actualValue=o,a.expectedValue=t,a.message=`Embedded object at '${e}' has 'type: ${o}', which is not a subclass of the parent property's range '${t}'.`,a.suggestion=`Either remove the 'type: ${o}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${o}' class definition so the relationship holds.`,a}localName(e){let o=e.lastIndexOf(".");return o<0||o===e.length-1?e:e.substring(o+1)}async buildPropertyRangeMap(e,o){let t=new Map,r=await o.buildEntityIndexAsync(e),s=new Map;for(let[n,i]of r){let c=i.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=i.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let f=i.entity.domain,d=f!=null?String(f):"",b=i.uri.toString(),h=s.get(b),v=n.includes(".");(!h||v&&!h.entityName.includes("."))&&s.set(b,{entityName:n,domain:d,range:m})}for(let n of s.values()){let i=this.localName(n.entityName),c=n.entityName.indexOf("."),a=c>0?n.entityName.substring(0,c):void 0,p=t.get(i)??[];p.push({domain:n.domain,range:n.range,declaringAlias:a}),t.set(i,p)}return t}};import{VersionOperator as he}from"@kanonak-protocol/types/document/models/enums";var B=class{ruleName="ImportExistence";async validateAsync(e,o){let t=[];if(!e.metadata?.imports)return t;let r=await o.getAllDocumentsAsync();for(let[s,n]of Object.entries(e.metadata.imports))for(let i of n)if(!await o.getHighestCompatibleVersionAsync(s,i)){let a=await this.determineImportErrorAsync(o,s,i,r),p=new g;p.ruleType=this.ruleName,p.severity="Error",p.message=a.message,p.suggestion=a.suggestion,p.entityName=`Import: ${s}/${i.packageName}`,p.actualValue=i.toString(),p.expectedValue=a.expectedValue,t.push(p)}return t}async determineImportErrorAsync(e,o,t,r){let s=await e.getDocumentsByNamespaceAsync(o,t.packageName);if(s.length===0){let a=r.filter(m=>m.metadata.namespace_?.publisher===o).map(m=>m.metadata.namespace_.package_).filter((m,f,d)=>d.indexOf(m)===f),p=this.findSimilarPackages(t.packageName,a),l=`Import '${o}/${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 ${o}: ${a.slice(0,5).join(", ")}`:`No packages found for publisher '${o}'. Verify the publisher name is correct.`;return{message:l,suggestion:y,expectedValue:"Existing package"}}let i=s.filter(a=>a.metadata.namespace_?.version).map(a=>a.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 he.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case he.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case he.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case he.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(n=>n.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(n.toLowerCase()));if(t.length>0)return t.sort((n,i)=>n.length-i.length);let r=o.map(n=>({package:n,distance:this.levenshteinDistance(e.toLowerCase(),n.toLowerCase())})).sort((n,i)=>n.distance-i.distance),s=Math.max(3,Math.floor(e.length*.4));return r.filter(n=>n.distance<=s).map(n=>n.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,r=o.length,s=Array(t+1).fill(null).map(()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)s[n][0]=n;for(let n=0;n<=r;n++)s[0][n]=n;for(let n=1;n<=t;n++)for(let i=1;i<=r;i++){let c=e[n-1]===o[i-1]?0:1;s[n][i]=Math.min(Math.min(s[n-1][i]+1,s[n][i-1]+1),s[n-1][i-1]+c)}return s[t][r]}};var H=class{ruleName="UnresolvedReference";async validateAsync(e,o){let t=[],r=new j(o),s=await r.buildEntityIndexAsync(e),n=new Set;for(let[i,c]of s.entries()){let a=c.entity.type;if(a){let p=a.toString();(p==="ObjectProperty"||p.endsWith(".ObjectProperty"))&&n.add(i)}}for(let[i,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"||!(n.has(l)||Array.from(n).some(f=>f.endsWith(`.${l}`)))||await this.validateReferenceValue(i,l,y,e,r,t)}return t}async validateReferenceValue(e,o,t,r,s,n){if(t!=null){if(typeof t=="string")await s.resolveEntityAsync(t,r)||n.push(this.createUnresolvedReferenceError(e,o,t));else if(Array.isArray(t))for(let i=0;i<t.length;i++){let c=t[i];typeof c=="string"&&(await s.resolveEntityAsync(c,r)||n.push(this.createUnresolvedReferenceError(e,`${o}[${i}]`,c)))}}}createUnresolvedReferenceError(e,o,t){let r=`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=o,s.actualValue=t,s.message=`Reference to '${t}' could not be resolved`,s.suggestion=r,s.expectedValue="A valid entity reference that exists in the current document or imported namespaces",s}getPropertyValue(e,o){let t=e[o];return t?t.toString():null}};var F=class{ruleName="ClassHierarchyCycle";async validateAsync(e,o){let t=[],r=new Map,s=new Set;await this.buildClassHierarchy(e,o,r,s);for(let[n,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=n,y=this.detectCycle(l,r);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,o,t,r){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&r.has(s))){s&&r.add(s);for(let[n,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i,a=c.type,p=c.subClassOf;if(a?.toString()==="Class"&&p){let l=E(p);l.length>0&&t.set(n,l)}}if(e.metadata?.imports)for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,c);a&&await this.buildClassHierarchy(a,o,t,r)}}}detectCycle(e,o){let t=[],r=new Set;return this.detectCycleRecursive(e,o,t,r)}detectCycleRecursive(e,o,t,r){if(t.includes(e)){let n=t.indexOf(e),i=t.slice(n);return i.push(e),i}if(r.has(e))return null;t.push(e),r.add(e);let s=o.get(e);if(s)for(let n of s){let i=this.detectCycleRecursive(n,o,t,r);if(i)return i}return t.pop(),null}};var q=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,o){let t=[],r=new Map,s=new Set;await this.buildPropertyHierarchy(e,o,r,s);for(let[n,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)&&i.subPropertyOf){let p=n,l=this.detectCycle(p,r);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,o,t,r){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&r.has(s))){s&&r.add(s);for(let[n,i]of Object.entries(e.body))if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i,a=c.type;if(a){let p=a.toString();if(p==="DatatypeProperty"||p==="ObjectProperty"||p==="AnnotationProperty"){let l=c.subPropertyOf;if(l){let y=E(l);y.length>0&&t.set(n,y)}}}}if(e.metadata?.imports)for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,c);a&&await this.buildPropertyHierarchy(a,o,t,r)}}}detectCycle(e,o){let t=[],r=new Set;return this.detectCycleRecursive(e,o,t,r)}detectCycleRecursive(e,o,t,r){if(t.includes(e)){let n=t.indexOf(e),i=t.slice(n);return i.push(e),i}if(r.has(e))return null;t.push(e),r.add(e);let s=o.get(e);if(s)for(let n of s){let i=this.detectCycleRecursive(n,o,t,r);if(i)return i}return t.pop(),null}};var X=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,o){let t=[];for(let[r,s]of Object.entries(e.body)){if(typeof s!="object"||s===null||Array.isArray(s))continue;let n=s,i=n.type?.toString();if(i==="DatatypeProperty"||i==="ObjectProperty"||i?.endsWith(".DatatypeProperty")||i?.endsWith(".ObjectProperty")){let c="range"in n,a=n.range?.toString().trim();if(!c||!a){let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=r,p.propertyName="range",p.message=`Property '${r}' must have a 'range' defined.`,p.suggestion=i==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",p.expectedValue=i==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(p)}}}return t}};var z=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,o){let t=[],r=new Set;for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n.type?.toString();this.isClassLikeType(c)&&r.add(s)}for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=E(n.subClassOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInClasses.has(p)||r.has(p))continue;if(!await this.isClassAvailableInImports(e,o,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,o,t){if(!e.metadata.imports)return!1;let r=null,s=t;if(t.includes(".")){let n=t.split(".",2);r=n[0],s=n[1]}for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){if(r!==null&&c.alias!==r)continue;let a=await o.getHighestCompatibleVersionAsync(n,c);if(a){let p=r!==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,o,p,y))return!0}}return!1}async isClassAvailableInImportsRecursive(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(s&&r.has(s)||(s&&r.add(s),!e.metadata.imports))return!1;for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,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,o,t,r))return!0}}return!1}};var Y=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,o){let t=[],r=new Set;for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n.type?.toString();(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty")&&r.add(s)}for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=E(n.subPropertyOf);for(let a=0;a<c.length;a++){let p=c[a];if(this.builtInProperties.has(p)||r.has(p))continue;if(!await this.isPropertyAvailableInImports(e,o,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,o,t){if(!e.metadata.imports)return!1;let r=null,s=t;if(t.includes(".")){let n=t.split(".",2);r=n[0],s=n[1]}for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){if(r!==null&&c.alias!==r)continue;let a=await o.getHighestCompatibleVersionAsync(n,c);if(a){let p=r!==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,o,p,y))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(s&&r.has(s)||(s&&r.add(s),!e.metadata.imports))return!1;for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,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,o,t,r))return!0}}return!1}};var Z=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,o){let t=[],r=e.metadata.namespace_?.toString();if(!r)return t;let s=new Map,n=new Set;await this.buildImportGraph(e,o,s,n);let i=this.detectCycle(r,s);if(i){let c=i.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,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(!(!s||r.has(s))&&(r.add(s),e.metadata.imports)){let n=[];for(let[i,c]of Object.entries(e.metadata.imports))for(let a of c){let p=`${i}/${a.packageName}@${a.version}`;n.push(p);let l=await o.getHighestCompatibleVersionAsync(i,a);l&&await this.buildImportGraph(l,o,t,r)}n.length>0&&t.set(s,n)}}detectCycle(e,o){let t=[],r=new Set;return this.detectCycleRecursive(e,o,t,r)}detectCycleRecursive(e,o,t,r){let s=t.indexOf(e);if(s>=0){let i=t.slice(s);return i.push(e),i}if(r.has(e))return null;t.push(e),r.add(e);let n=o.get(e);if(n)for(let i of n){let c=this.detectCycleRecursive(i,o,t,r);if(c)return c}return t.pop(),null}};var G=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,o,t){let r=[],s=new Set,n=t?await this.closurePropertyNamesViaCache(e,t):void 0,i=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,o,f,d,n,i)){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",r.push(h)}}}return r}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,o,t,r,s,n){if(s!==void 0&&n!==void 0){if(r===null)return s.has(t);let i=n.get(r);return i?i.has(t):!1}return await this.isPropertyAvailableInImports(e,o,t,r)}async closurePropertyNamesViaCache(e,o){let t=new Set,r=Ue(e);if(!r)return t;let s=await o.getImportClosure(r);for(let n of s)if(n!==r)for(let i of await o.getPropertyNames(n))t.add(i);return t}async aliasClosurePropertyNamesViaCache(e,o){let t=new Map;if(!e.metadata.imports)return t;for(let[r,s]of Object.entries(e.metadata.imports))for(let n of s){if(!n.alias)continue;let i=await o.repository.getHighestCompatibleVersionAsync(r,n);if(!i)continue;let c=Ue(i);if(!c)continue;let a=await o.getImportClosure(c),p=t.get(n.alias)??new Set;for(let l of a)for(let y of await o.getPropertyNames(l))p.add(y);t.set(n.alias,p)}return t}async isPropertyAvailableInImports(e,o,t,r){if(!e.metadata.imports)return!1;for(let[s,n]of Object.entries(e.metadata.imports))for(let i of n){if(r!==null&&i.alias!==r)continue;let c=await o.getHighestCompatibleVersionAsync(s,i);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,o,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(s&&r.has(s)||(s&&r.add(s),!e.metadata.imports))return!1;for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,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,o,t,r))return!0}}return!1}};function Ue(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var J=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,o){let t=[],r=new Set;for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n.type?.toString();this.isPropertyType(c)&&r.add(s)}for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let i=n,c=i.type?.toString();if(!this.isPropertyType(c)&&!this.isClassType(c))continue;for(let[a,p]of Object.entries(i)){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(r.has(l))continue;if(!await this.isPropertyAvailableInImports(e,o,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,o,t,r){if(!e.metadata.imports)return!1;for(let[s,n]of Object.entries(e.metadata.imports))for(let i of n){if(r!==null&&i.alias!==r)continue;let c=await o.getHighestCompatibleVersionAsync(s,i);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,o,t,p))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(s&&r.has(s)||(s&&r.add(s),!e.metadata.imports))return!1;for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,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,o,t,r))return!0}}return!1}};var Q=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,o){let t=[],r=new Set,s=[];for(let[n,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i,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(n);let l=this.getPropertyValue(c,"range");l&&this.xsdTypes.has(l)&&r.add(l)}}if(r.size>0&&!await this.checkXsdImportAsync(e.metadata,o)){let i=Array.from(r).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: ${i}`,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,o,t=new Set){if(!e?.imports)return!1;let r=e.namespace_?.toString()??"";if(r&&t.has(r))return!1;r&&t.add(r);for(let[,s]of Object.entries(e.imports))for(let n of s)if(n.packageName==="xsd"||n.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[s,n]of Object.entries(e.imports))for(let i of n){let c=await o.getHighestCompatibleVersionAsync(s,i);if(c?.metadata&&await this.checkXsdImportAsync(c.metadata,o,t))return!0}return!1}getPropertyValue(e,o){return e[o]?.toString()}};var ee=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,o){let t=[],{entitySources:r,importPaths:s}=await this.buildEntitySourceMapAsync(e,o),n=await this.buildDatatypePropertyNamesAsync(e,o);for(let[i,c]of Object.entries(e.body))typeof c=="object"&&c!==null&&!Array.isArray(c)&&this.validateEntityReferences(i,c,r,s,n,e,t);return t}async buildEntitySourceMapAsync(e,o){let t=new Map,r=new Set,s=new Map;for(let n of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(n)||t.set(n,[]),t.get(n).push(`(local:${i})`)}if(e.metadata.imports)for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,c);if(a){let p=a.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(a,t,r,s,[p],o)}}return{entitySources:t,importPaths:s}}async collectEntitiesRecursivelyAsync(e,o,t,r,s,n){let i=e.metadata.namespace_?.toString()??"";if(!t.has(i)){t.add(i),r.has(i)||r.set(i,s);for(let c of Object.keys(e.body)){o.has(c)||o.set(c,[]);let a=o.get(c);a.includes(i)||a.push(i)}if(e.metadata.imports)for(let[c,a]of Object.entries(e.metadata.imports))for(let p of a){let l=await n.getHighestCompatibleVersionAsync(c,p);if(l){let y=l.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(l,o,t,r,[...s,y],n)}}}}async buildDatatypePropertyNamesAsync(e,o){let t=new Set,r=new Set;if(await this.collectDatatypePropertiesAsync(e,t,r,o),e.metadata.imports)for(let[s,n]of Object.entries(e.metadata.imports))for(let i of n){let c=await o.getHighestCompatibleVersionAsync(s,i);c&&await this.collectDatatypePropertiesAsync(c,t,r,o)}return t}async collectDatatypePropertiesAsync(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let[n,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let c=i.type;if(typeof c!="string")continue;(c.includes(".")?c.substring(c.lastIndexOf(".")+1):c)==="DatatypeProperty"&&o.add(n)}if(e.metadata.imports)for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await r.getHighestCompatibleVersionAsync(n,c);a&&await this.collectDatatypePropertiesAsync(a,o,t,r)}}}validateEntityReferences(e,o,t,r,s,n,i){for(let[c,a]of Object.entries(o)){let p=c;if(p&&!p.includes(".")){let l=t.get(p);if(l&&l.length>1&&!l.some(m=>m.startsWith("(local:"))){let m=l.filter(f=>!f.startsWith("(local:"));m.length>1&&i.push(this.createAmbiguityError(e,p,`Property '${p}'`,m,r,n,!0,p))}}this.validatePropertyValue(e,p,a,t,r,s,n,i)}}validatePropertyValue(e,o,t,r,s,n,i,c){if(t==null)return;let a=o&&o.includes(".")?o.substring(o.lastIndexOf(".")+1):o,p=!!a&&n.has(a);if(typeof t=="string"&&!t.includes(".")&&!p){let l=r.get(t);if(l&&l.length>1&&!l.some(m=>m.startsWith("(local:"))){let m=l.filter(f=>!f.startsWith("(local:"));m.length>1&&c.push(this.createAmbiguityError(e,o,`Reference '${t}'`,m,s,i,!1,t))}}else if(Array.isArray(t))for(let l=0;l<t.length;l++){let y=`${e}.${o}[${l}]`;this.validatePropertyValue(y,o,t[l],r,s,n,i,c)}else if(typeof t=="object"&&!Array.isArray(t)){let l=o?`${e}.${o}`:e;this.validateEntityReferences(l,t,r,s,n,i,c)}}createAmbiguityError(e,o,t,r,s,n,i,c){let a=[];for(let b of r){let h=this.findAliasForNamespace(n,b);if(h){let v=o?.split(".").pop()??o;a.push(`${h}.${v}`)}}let p=a.length>0?`Use one of: ${a.map(b=>`'${b}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${o}')`,l=r.map(b=>{let h=s.get(b);return!h||h.length===0?` \u2022 ${b}`:h.length===1?` \u2022 ${b} (direct import)`:` \u2022 ${b}
24
- imported via: ${h.join(" \u2192 ")}`}).join(`
25
- `),y=e.split(".")[0],m=e.includes(".")?e:o,f=new g;f.ruleType=this.ruleName,f.severity="Error",f.entityName=y,m&&(f.propertyName=m);let d=c??o;return d&&(f.actualValue=d),f.message=`${t} is ambiguous - defined in multiple imported namespaces`,f.suggestion=`${p}
26
-
27
- Defined in:
28
- ${l}`,f.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",f}findAliasForNamespace(e,o){if(!e.metadata.imports)return null;for(let[t,r]of Object.entries(e.metadata.imports))for(let s of r)if(`${t}/${s.packageName}@${s.version}`===o&&s.alias)return s.alias;return null}};var te=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,o){let t=[],r=new Set;for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let c=n.type?.toString();this.isValidRangeTargetType(c)&&r.add(s)}for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let i=n,c=i.type?.toString();if(c!=="DatatypeProperty"&&c!=="ObjectProperty"&&!c?.endsWith(".DatatypeProperty")&&!c?.endsWith(".ObjectProperty"))continue;let a=i.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)||r.has(l))continue;if(!await this.isTypeAvailableInImports(e,o,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:
29
- 1. Define '${l}' as a Class in this namespace, OR
30
- 2. Import the namespace that contains '${l}', OR
31
- 3. Use a qualified reference like 'alias.${l}' if already imported with an alias`:`For DatatypeProperty:
32
- 1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
33
- 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,o,t){if(!e.metadata.imports)return!1;let r=null,s=t;if(t.includes(".")){let n=t.split(".",2);r=n[0],s=n[1]}for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){if(r!==null&&c.alias!==r)continue;let a=await o.getHighestCompatibleVersionAsync(n,c);if(a){let p=r!==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,o,p,y))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,o,t,r){let s=e.metadata.namespace_?.toString()??"";if(s&&r.has(s)||(s&&r.add(s),!e.metadata.imports))return!1;for(let[n,i]of Object.entries(e.metadata.imports))for(let c of i){let a=await o.getHighestCompatibleVersionAsync(n,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,o,t,r))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var oe=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,o){let t=[],r=new Map,s=new j(o);await s.buildEntityIndexAsync(e);for(let[n,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let c=i,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)||(r.has(m)||r.set(m,[]),r.get(m).push(n))}}for(let[n,i]of r)if(!await s.resolveEntityAsync(n,e))for(let a of i){let p=new g;p.ruleType=this.ruleName,p.severity="Warning",p.message=`ObjectProperty references class '${n}' which may not be imported`,p.suggestion=`Ensure the namespace containing '${n}' is imported, or define '${n}' in this document`,p.entityName=a,p.propertyName="range",p.actualValue=n,t.push(p)}return t}};var re=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,o){let t=[],r=new j(o),s=new Se(r),n=await r.buildEntityIndexAsync(e),i=await this.buildPropertyMetadataAsync(e,o,r,n);for(let[c,a]of Object.entries(e.body))typeof a=="object"&&a!==null&&!Array.isArray(a)&&await this.scanEntityForObjectProperties(a,c,"",i,r,s,e,t);return t}async scanEntityForObjectProperties(e,o,t,r,s,n,i,c){for(let[a,p]of Object.entries(e)){if(this.standardProperties.has(a))continue;let l,y=await s.resolveEntityAsync(a,i);if(y?.uri){let m=`${y.uri.publisher}/${y.uri.package_}/${y.uri.name}`;l=r.get(m)}if(!l){let m=a,f=a.lastIndexOf(".");f>0&&f<a.length-1&&(m=a.substring(f+1)),l=r.get(m)}if(l&&n.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(v=>v.trim()).filter(v=>v.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:
34
- ${a}:
35
- - ${h[0]}
36
- ${h.slice(1).map(v=>` - ${v}`).join(`
37
- `)}`,entityName:o,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,i);if(b)l.range&&(await this.validateRangeType(b,l.range,s,i)||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:o,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:o,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,o,d,r,s,n,i,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(),v=await s.resolveEntityAsync(h,i);if(v){if(l.range&&!await this.validateRangeType(v,l.range,s,i)){let be=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:o,propertyName:`${a}[${d}]`,propertyPath:be,actualValue:h,expectedValue:l.range})}}else{let Ie=l.range??"entity",be=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: ${Ie}`,entityName:o,propertyName:`${a}[${d}]`,propertyPath:be,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,o,h,r,s,n,i,c)}}}if(typeof p=="object"&&p!==null&&!Array.isArray(p)&&!r.has(a)){let m=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(p,o,m,r,s,n,i,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,o,d,r,s,n,i,c)}}}}async validateRangeType(e,o,t,r){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(o))return!0;let n=e.entity.type;if(n){let i=[];if(Array.isArray(n))for(let c of n){let a=c?.toString();a&&a.trim().length>0&&i.push(a)}else{let c=n?.toString();c&&c.trim().length>0&&i.push(c)}for(let c of i){let a=c.includes(".")?c.split(".")[1]:c;if(a===o||o==="Property"&&(a==="DatatypeProperty"||a==="ObjectProperty"||a==="AnnotationProperty")||o==="Class"&&a==="Class"||await t.isSubclassOfAsync(c,o,r))return!0}}return!1}async buildPropertyMetadataAsync(e,o,t,r){let s=new Map;for(let[n,i]of r){let c=i.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=i.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(n,y),i.uri){let f=`${i.uri.publisher}/${i.uri.package_}/${i.uri.name}`;s.set(f,y)}}}}return s}};var ne=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,o,t){let r=[],s=new Map;for(let[i,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(i,a)}let n=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,o);for(let[i,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,i,p,s,n,r)}return r}async buildClassHierarchyViaCache(e,o){let t=new Map,r=Xe(e);if(!r)return t;let s=await o.getImportClosure(r);for(let n of s){let i=await o.getClassDeclarations(n);for(let[c,a]of i)a.length>0&&t.set(c,a)}return t}async buildCompleteClassHierarchyAsync(e,o){let t=new Map,r=new Set,s=async(i,c)=>{if(!r.has(c)){r.add(c);for(let[a,p]of Object.entries(i.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=E(m);f.length>0&&t.set(a,f)}}if(i.metadata.imports)for(let[a,p]of Object.entries(i.metadata.imports))for(let l of p)try{let y=await o.getHighestCompatibleVersionAsync(a,l);if(y){let m=`${a}/${l.packageName}@${l.version}`;await s(y,m)}}catch{}}},n=e.metadata.namespace_?.toString()??"unknown";return await s(e,n),t}validateEntityProperties(e,o,t,r,s,n){for(let[i,c]of Object.entries(e)){if(this.standardProperties.has(i))continue;let a=i,p=i.lastIndexOf(".");p>0&&p<i.length-1&&(a=i.substring(p+1));let l=r.get(a);if(!l)continue;let y=this.getPropertyValue(l,"domain");if(y){if(!this.isTypeCompatibleWithDomain(t,y,s)){let m=o.split(".")[0];n.push({ruleType:this.ruleName,severity:"Error",entityName:m,propertyName:o,actualValue:i,message:`Property '${i}' has domain '${y}' but is used on '${t}' at '${o}'`,suggestion:`Either:
38
- 1. Use this property only on '${y}' instances
39
- 2. Change the property domain to include '${t}'
40
- 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=`${o}.${i}`;this.validateEntityProperties(m,d,f,r,s,n)}else{let d=this.getPropertyValue(l,"range");if(d){let b=`${o}.${i}`;this.validateEntityProperties(m,b,d,r,s,n)}}}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=`${o}.${i}[${m}]`;this.validateEntityProperties(d,h,b,r,s,n)}else{let h=this.getPropertyValue(l,"range");if(h){let v=`${o}.${i}[${m}]`;this.validateEntityProperties(d,v,h,r,s,n)}}}}}}}isTypeCompatibleWithDomain(e,o,t){if(e===o)return!0;let r=new Set,s=[e];for(;s.length>0;){let n=s.shift();if(r.has(n))continue;r.add(n);let i=t.get(n);if(i)for(let c of i){if(c===o)return!0;s.push(c)}}return!1}getPropertyValue(e,o){if(o in e){let t=e[o];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${o}`)){let r=e[t];return this.extractFirstValue(r)}}extractFirstValue(e){if(Array.isArray(e)){let o=[];for(let t of e)o.push(t?.toString()??"");return o.length>0?o[0]:void 0}return e?.toString()}};function Xe(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var ie=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,o){let t=[],r=new Map;for(let[s,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let i=n,c=this.getPropertyValue(i,"type");(c==="DatatypeProperty"||c==="ObjectProperty")&&r.set(s,i)}for(let[s,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n,c=this.getPropertyValue(i,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[a,p]of Object.entries(i)){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=r.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:
41
- 1. Create a class for this data and change '${a}' to an ObjectProperty
42
- 2. Store as a JSON string to keep it as DatatypeProperty
43
- 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,o){switch(e?.toLowerCase()){case"string":return typeof o=="string";case"integer":case"int":return typeof o=="number"&&Number.isInteger(o);case"decimal":return typeof o=="number";case"boolean":return typeof o=="boolean";case"float":case"double":return typeof o=="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,o){if(o in e){let t=e[o];if(Array.isArray(t)){let r=[];for(let s of t)r.push(s?.toString()??"");return r.length>0?r[0]:void 0}return t?.toString()}}};var se=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,o){let t=[],r=new Map,s=new Set;for(let[i,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(i);break}}else{let l=p?.toString();(l==="Class"||l&&l.endsWith(".Class"))&&s.add(i)}}for(let[i,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&&(r.has(m)||r.set(m,[]),r.get(m).push(i))}}else{let l=p?.toString();l&&l.trim().length>0&&(this.isDefinitionType(l)||(r.has(l)||r.set(l,[]),r.get(l).push(i)))}this.checkNestedTypes(a,i,r,i)}let n=new j(o);for(let[i,c]of r){if(this.builtInClasses.has(i)||s.has(i))continue;let a=await n.resolveEntityAsync(i,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 '${i}' is not defined or imported`,suggestion:`Define '${i}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:i,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,o,t,r){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e,n=s.type;if(n){let i=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(n))for(let c of n){let a=c?.toString();a&&a.trim().length>0&&!i.has(a)&&(t.has(a)||t.set(a,[]),t.get(a).push(r))}else{let c=n?.toString();c&&c.trim().length>0&&!i.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(r))}}for(let[i,c]of Object.entries(s))if(i!=="type"){let a=`${r}.${i}`;this.checkNestedTypes(c,o,t,a)}}else if(Array.isArray(e))for(let s=0;s<e.length;s++){let n=`${r}[${s}]`;this.checkNestedTypes(e[s],o,t,n)}}isClassEntity(e){if(!e)return!1;let o=e.type;if(!o)return!1;if(Array.isArray(o))for(let t of o){let r=t?.toString();if(r==="Class"||r&&r.endsWith(".Class"))return!0}else{let t=o?.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 ae=class{ruleName="MarkdownLink";async validateAsync(e,o,t){let r=[],s;if(t){let n=await t.getKanonaks(),i=ze(e);s=i?n.filter(c=>c instanceof w&&c.namespace===i):[]}else{let n=new S(e,o);s=await new O().parseKanonaks(n)}for(let n of s)n instanceof w&&this.checkDefined(n,n.name,r);return r}checkDefined(e,o,t){for(let r of e.statement)if(r instanceof je){let s=r.predicate.subject?.name??"(unknown)";for(let n of r.links)n.target||t.push(this.unresolvedLinkError(o,s,n.reference));for(let n of Ke(r.object))t.push(this.malformedLinkError(o,s,n.snippet))}else if(r instanceof we)this.checkDefined(r.object,o,t);else if(r instanceof $e)for(let s of r.object)s instanceof D&&this.checkDefined(s,o,t)}unresolvedLinkError(e,o,t){let r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t,r.message=`Embedded link [[${t}]] in '${o}' could not be resolved`,r.expectedValue="A reference resolvable through the document's import closure",r.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
44
-
45
- Possible solutions:
46
- \u2022 Import the package that defines '${t}' so the link can resolve
47
- \u2022 Check for typos in the reference name
48
- \u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,r}malformedLinkError(e,o,t){let r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t,r.message=`Malformed embedded reference near '${t}' in '${o}'`,r.expectedValue="A single-line [[reference]] with no internal line break",r.suggestion=`A '[[' in '${o}' does not form a complete [[reference]] link.
49
-
50
- A reference may not span a line break \u2014 the most common cause is wrapping a
51
- long reference across two lines in a block scalar, e.g.:
52
- ... read for [[persistent-energy-
53
- shock]] held ...
54
- which is parsed as literal text, not a link. Keep each [[reference]] on one
55
- line (let the line run long), or check for an unterminated [[.`,r}};function ze(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var Le="kanonak.org",Me="look",Ye={publisher:Le,package_:Me,name:"displayLabel"},Ze={publisher:Le,package_:Me,name:"displaySummary"},ce=class{ruleName="DisplayLensScope";async validateAsync(e,o,t){let r=[],s;t?s=await t.getKanonaks():s=await new O().parseKanonaks(new S(e,o));let n=Ge(e);if(!n)return r;for(let i of s)i instanceof w&&i.namespace===n&&(this.checkLens(s,i,Ye,"displayLabel",r),this.checkLens(s,i,Ze,"displaySummary",r));return r}checkLens(e,o,t,r,s){let n=I(o,t);if(!n)return;let i=[],c=T(o);if(c&&i.push(c),i.push(...Ce(o)),i.length===0)return;i.some(p=>N(e,p,n).ok)||s.push(this.scopeError(o.name,r,n.name))}scopeError(e,o,t){let r=new g;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=o,r.actualValue=t,r.message=`${o} points at '${t}', which is not a property in scope for '${e}'`,r.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",r.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.
56
-
57
- Possible solutions:
58
- \u2022 Point ${o} at a property declared on this class (or an ancestor / rdfs.Resource)
59
- \u2022 Set the property's domain to this class if it should apply here
60
- \u2022 Use rdfs.label / rdfs.comment for the universal default`,r}};function Ge(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}function C(u,e,o){let t=[];return ue(u,o,{input:e},t),t}function ue(u,e,o,t){if(A(e,$.VarRef)){let n=ke(e,$.varName);return n?o[n]:void 0}if(A(e,$.PropertyRead)){let n=P(e,$.readSource),i=n?ue(u,n,o,t):void 0,c=I(e,$.readProp);if(!i||!c)return;let a=N(u,i,c);if(!a.ok){t.push({contextClass:i,propertyUri:c,via:"PropertyRead"});return}return a.descriptor?.range}if(A(e,$.Traverse)){let n=P(e,$.traverseSource),i=n?ue(u,n,o,t):void 0,c=I(e,$.through),a;if(i&&c){let l=N(u,i,c);l.ok?a=l.descriptor?.range:t.push({contextClass:i,propertyUri:c,via:"Traverse"})}let p=P(e,$.step);return p?ue(u,p,{...o,input:a},t):void 0}let r=ke(e,$.loopVar),s=r?{...o,[r]:void 0}:o;for(let n of Je(e))ue(u,n,s,t)}function Je(u){let e=[];for(let o of u.statement){let t=o.object;if(t instanceof D)e.push(t);else if(Array.isArray(t))for(let r of t)r instanceof D&&e.push(r)}return e}var fe="kanonak.org",de="look",Qe={publisher:fe,package_:de,name:"semanticSvg"},et={publisher:fe,package_:de,name:"tierChip"},tt={publisher:fe,package_:de,name:"tierIcon"},ot={publisher:fe,package_:de,name:"tierCard"},rt={publisher:fe,package_:de,name:"tierFull"},nt=[et,tt,ot,rt],pe=class{ruleName="LookSemanticSvgPath";async validateAsync(e,o,t){let r=[],s;t?s=await t.getKanonaks():s=await new O().parseKanonaks(new S(e,o));let n=it(e);if(!n)return r;for(let i of s)i instanceof w&&i.namespace===n&&this.checkSemanticSvg(s,i,r);return r}checkSemanticSvg(e,o,t){let r=P(o,Qe);if(!r)return;let s=T(o);if(s)for(let n of nt){let i=P(r,n);if(i)for(let c of C(e,s,i))t.push(this.toError(o.name,n.name,c))}}toError(e,o,t){let r=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,n=s===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${s}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new g;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${o}`,i.actualValue=r,i.message=`tx.${t.via} reads property '${t.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${n}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${r}' is not in scope for '${s}'.
61
-
62
- Possible solutions:
63
- \u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
64
- \u2022 If the property should apply to '${s}', adjust its domain
65
- \u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function it(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var st="kanonak.org",R=(u,e)=>({publisher:st,package_:u,name:e}),at=R("derivation","look"),ct=R("look","bands"),pt=R("look","Distribution"),lt=R("look","StatRow"),yt=R("look","VersionDelta"),mt=R("look","Timeline"),ut=R("look","VersionDiff"),ft=R("look","TimePlot"),dt=R("look","ReferenceList"),gt=R("look","Diagram"),ht=R("look","alphaPath"),bt=R("look","betaPath"),De=R("look","metricPath"),We=R("look","lowerPath"),Be=R("look","upperPath"),He=R("look","hueBy"),kt=R("look","statPath"),Rt=R("look","laneBy"),Fe=R("look","labelPath"),Pt=R("look","badgePath"),Vt=R("look","mapPath"),vt=R("look","nodeNote"),Dt=R("look","edgeValue"),At=R("look","stats"),It=R("look","facets"),Et=R("look","channels"),Ot=R("look","track"),wt=R("look","source"),$t=R("look","relation"),jt=R("look","entries"),ge=class{ruleName="LookBandPath";async validateAsync(e,o,t){let r=[],s;t?s=await t.getKanonaks():s=await new O().parseKanonaks(new S(e,o));let n=Kt(e);if(!n)return r;for(let i of s)i instanceof w&&i.namespace===n&&this.checkDeclaration(s,i,r);return r}checkDeclaration(e,o,t){let r=P(o,at);if(!r)return;let s=T(o);if(!s)return;let n=K(r,ct).filter(i=>i instanceof D);for(let i of n)for(let c of this.carriersOf(e,i,s))for(let a of C(e,c.context,c.expr))t.push(this.toError(o.name,c.slot,a))}carriersOf(e,o,t){let r=[],s=(n,i)=>{let c=P(o,n);c&&r.push({slot:`look.${n.name}`,context:i,expr:c})};if(A(o,pt))for(let n of[ht,bt,De,We,Be,He])s(n,t);if(A(o,yt)&&s(De,t),A(o,lt)){let n=K(o,At).filter(i=>i instanceof D);for(let i of n){let c=P(i,kt);c&&r.push({slot:"look.stats[].statPath",context:t,expr:c})}}if(A(o,mt)||A(o,ut)){let n=this.rangeOf(e,t,I(o,Ot));if(n)for(let i of[De,We,Be,He])s(i,n)}if(A(o,ft)){let n=this.rangeOf(e,t,I(o,wt));if(n)for(let i of[Rt,Fe])s(i,n)}if(A(o,dt))for(let n of K(o,jt)){let i=n instanceof D?void 0:St(n),c=this.rangeOf(e,t,i);if(c)for(let a of[Fe,Pt])s(a,c)}if(A(o,gt)){let n=K(o,It).filter(i=>i instanceof D);for(let i of n){let c=this.rangeOf(e,t,I(i,$t));if(!c)continue;let a=P(i,vt);a&&r.push({slot:"look.facets[].nodeNote",context:c,expr:a});let p=P(i,Dt);p&&r.push({slot:"look.facets[].edgeValue",context:c,expr:p});let l=K(i,Et).filter(y=>y instanceof D);for(let y of l){let m=P(y,Vt);m&&r.push({slot:"look.facets[].channels[].mapPath",context:c,expr:m})}}}return r}rangeOf(e,o,t){if(!t)return;let r=N(e,o,t);return r.ok?r.descriptor?.range:void 0}toError(e,o,t){let r=`${t.propertyUri.publisher}/${t.propertyUri.package_}/${t.propertyUri.name}`,s=t.contextClass.name,n=new g;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=o,n.actualValue=r,n.message=`tx.${t.via} reads property '${t.propertyUri.name}', but its domain is not in scope for '${s}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,n.expectedValue=`A property whose domain is '${s}', an ancestor, or rdfs.Resource`,n.suggestion=`Property '${r}' is not in scope for '${s}'.
66
-
67
- Possible solutions:
68
- \u2022 Read a property declared on '${s}' (or an ancestor / rdfs.Resource)
69
- \u2022 If the property should apply to '${s}', adjust its domain
70
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,n}};function St(u){let e=u.subject;return e&&typeof e.name=="string"?e:void 0}function Kt(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var ye="kanonak.org",me="view",Nt={publisher:ye,package_:me,name:"bind"},Ct={publisher:ye,package_:me,name:"produces"},Tt={publisher:ye,package_:me,name:"projections"},xt={publisher:ye,package_:me,name:"where"},_t={publisher:ye,package_:me,name:"value"},Ut={publisher:ye,package_:me,name:"as"},le=class{ruleName="TxExpressionPath";async validateAsync(e,o,t){let r=[],s;t?s=await t.getKanonaks():s=await new O().parseKanonaks(new S(e,o));let n=Wt(e);if(!n)return r;for(let i of s)i instanceof w&&i.namespace===n&&this.checkView(s,i,r);return r}checkView(e,o,t){let r=I(o,Nt);if(!r)return;let s=I(o,Ct),n=0;for(let c of Mt(e,K(o,Tt))){let a=P(c,_t);if(a)for(let l of C(e,r,a))t.push(this.toError(o.name,`view.projections[${n}].value`,r,l));let p=I(c,Ut);p&&s&&(N(e,s,p).ok||t.push(this.asError(o.name,n,s,p))),n+=1}let i=0;for(let c of Lt(o,xt)){for(let a of C(e,r,c))t.push(this.toError(o.name,`view.where[${i}]`,r,a));i+=1}}asError(e,o,t,r){let s=`${r.publisher}/${r.package_}/${r.name}`,n=new g;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=`view.projections[${o}].as`,n.actualValue=s,n.message=`Projection stores its value under property '${r.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.`,n.expectedValue=`A property whose domain is '${t.name}', an ancestor, or rdfs.Resource`,n.suggestion=`Property '${s}' is not in scope for produces class '${t.name}'.
71
-
72
- Possible solutions:
73
- \u2022 Use an output property whose domain covers '${t.name}'
74
- \u2022 Define a new property in the ViewPackage with domain '${t.name}' and the right range
75
- \u2022 If the value belongs on a different output class, adjust the view's produces`,n}toError(e,o,t,r){let s=`${r.propertyUri.publisher}/${r.propertyUri.package_}/${r.propertyUri.name}`,n=r.contextClass.name,i=n===t.name?`the view's bound class '${t.name}'`:`'${n}', 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=o,c.actualValue=s,c.message=`tx.${r.via} reads property '${r.propertyUri.name}', but its domain is not in scope for ${i}. The read would silently return undefined when the view materializes.`,c.expectedValue=`A property whose domain is '${n}', an ancestor, or rdfs.Resource`,c.suggestion=`Property '${s}' is not in scope for '${n}'.
76
-
77
- Possible solutions:
78
- \u2022 Read a property declared on '${n}' (or an ancestor / rdfs.Resource)
79
- \u2022 If the property should apply to '${n}', adjust its domain
80
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,c}};function Lt(u,e){let o=P(u,e);return o?[o]:K(u,e).filter(t=>t instanceof D)}function Mt(u,e){let o=[];for(let t of e)if(t instanceof D)o.push(t);else if(t instanceof Oe){let r=Ne(u,t.subject);r&&o.push(r)}return o}function Wt(u){let e=u.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${V(e.version)}`}var Ae=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new Ee,this.documentRules=[new _,new U,new L,new M],this.repositoryRules=[new W,new B,new H,new F,new q,new X,new z,new Y,new Z,new G,new J,new Q,new ee,new te,new oe,new re,new ne,new ie,new se,new ae,new ce,new pe,new ge,new le]}async validateAsync(e,o,t){let r=new x;for(let s of this.documentRules)try{let n=s.validate(e);this.addErrorsToResult(r,n)}catch(n){let i=new g;i.ruleType=s.ruleName,i.severity="Error",i.message=`Validation rule '${s.ruleName}' failed: ${n instanceof Error?n.message:String(n)}`,r.errors.push(i)}if(o){let s=[],n=t?.repository??o;for(let i of this.repositoryRules)try{let c=await i.validateAsync(e,n,t);this.addErrorsToResult(r,c)}catch(c){let a=c instanceof Error?c.message:String(c);s.push({ruleName:i.ruleName,cause:a})}if(s.length>0){let i=new Map;for(let{ruleName:c,cause:a}of s){let p=i.get(a);p?p.push(c):i.set(a,[c])}for(let[c,a]of i){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(", ")})`,r.errors.push(p)}}}return r.isValid=r.errors.length===0,r}async validateYamlAsync(e,o,t){let r=this.parser.parseWithErrors(e);if(!r.isValid){let s=new x;s.isValid=!1;for(let n of r.errors){let i=new g;i.ruleType="ParseError",i.severity="Error",i.lineNumber=n.line,i.column=n.column,i.message=n.message,n.keyName&&(i.entityName=n.keyName),n.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(i)}return s}return await this.validateAsync(r.document,o,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let o=this.documentRules.findIndex(t=>t instanceof e);o>=0&&this.documentRules.splice(o,1)}removeRepositoryRule(e){let o=this.repositoryRules.findIndex(t=>t instanceof e);o>=0&&this.repositoryRules.splice(o,1)}addErrorsToResult(e,o){for(let t of o)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{x as a,k as b,g as c,Re as d,Ve as e,_ as f,U as g,L as h,M as i,W as j,B as k,H as l,F as m,q as n,X as o,z as p,Y as q,Z as r,G as s,J as t,Q as u,ee as v,te as w,oe as x,re as y,ne as z,ie as A,se as B,ae as C,ce as D,pe as E,le as F,Ae as G};
@@ -1 +0,0 @@
1
- import{b as y,c as i,g as l,h as g,i as b,j as u,k,l as K}from"./chunk-W6T7MOKY.js";import{c as d,g as m}from"./chunk-2ACBWC7K.js";function D(t){return`${t.publisher}/${t.package_}/${t.name}`}function f(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function j(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function h(t,e){if(!(t instanceof y))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let r=n.object;if(f(r.subject,e))return!0}return!1}function U(t,e){let n=[];for(let o of t)o instanceof i&&h(o,e)&&n.push(o);return n}function $(t,e){let n=e.version,o=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let r of t){if(!(r instanceof i)||r.name!==e.name)continue;let a=r.namespace||"";if(o!==void 0){if(a===o)return r}else if(a.startsWith(`${e.publisher}/${e.package_}@`))return r}}function E(t,e){let n=[];for(let o of t){if(!(o instanceof i)||o.name!==e.name)continue;(o.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(o)}return n.sort((o,r)=>{let a=m((o.namespace||"").split("@")[1]??""),c=m((r.namespace||"").split("@")[1]??"");return a?c?d(c,a):-1:c?1:0}),n}function s(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&f(o.subject,e))return n}}function S(t,e){let n=s(t,e);if(n&&(n instanceof l||n instanceof g||n instanceof b))return n.object}function x(t,e){let n=S(t,e);return typeof n=="string"?n:void 0}function A(t,e){let n=s(t,e);if(n instanceof u)return n.object.subject}function R(t,e){let n=s(t,e);if(n instanceof k)return n.object}function v(t,e){let n=s(t,e);return n instanceof K?n.object??[]:[]}var p=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{D as a,f as b,j as c,h as d,U as e,$ as f,E as g,S as h,x as i,A as j,R as k,v as l,p as m};
@@ -1 +0,0 @@
1
- import{a as A}from"./chunk-TJPQETHV.js";import{b as N,c as _,i as M}from"./chunk-IOMNZBK4.js";import{a as $,b as L,c as w,d as g,g as j,h as D,i as O,j as P,k as S,l as K}from"./chunk-W6T7MOKY.js";var b=class extends L{name};var R=class extends ${value};var I=class extends j{links=[]};var B=/\[\[([^\[\]\n]+)\]\]/g,z=/\[\[/g,V=/```[\s\S]*?```|`[^`\n]*`/g;function U(p){let e=[];for(let t of p.matchAll(V))e.push([t.index,t.index+t[0].length]);return e}function Q(p){if(!p||!p.includes("[["))return[];let e=U(p),t=o=>e.some(([n,c])=>o>=n&&o<c),r=new Set(x(p).map(o=>o.startOffset)),a=[];for(let o of p.matchAll(z)){let n=o.index;if(t(n)||r.has(n))continue;let c=p.slice(n,n+48).replace(/\s+/g," ").trim();a.push({startOffset:n,snippet:c})}return a}function x(p){if(!p||!p.includes("[["))return[];let e=[];for(let a of p.matchAll(V))e.push([a.index,a.index+a[0].length]);let t=a=>e.some(([o,n])=>a>=o&&a<n),r=[];for(let a of p.matchAll(B)){let o=a.index;if(t(o))continue;let n=a[1],c=n.indexOf("|"),i=(c===-1?n:n.slice(0,c)).trim();if(i.length===0)continue;let m=c===-1?"":n.slice(c+1).trim(),d={reference:i,startOffset:o,endOffset:o+a[0].length};m.length>0&&(d.displayText=m),r.push(d)}return r}var C=class{constructor(e){}async parseKanonaks(e){let t=[],r=await e.getAllDocumentsAsync(),a=new N(e),o=new _(a);for(let s of r){let f=s.metadata.namespace_?.toString()??"";for(let[u,y]of Object.entries(s.body)){let k=new w,l=this.resolveCanonicalEntity(u,s,f);k.namespace=l.namespace,k.name=l.name,k.statement=[];let h=await this.parseStatements(y,s,a,o,e);k.statement.push(...h),t.push(k)}}let n=new Map,c=new Map,i=[];for(let s of t)if(s instanceof w){let f=`${s.namespace}/${s.name}`,u=n.get(f);if(u){let y=c.get(f);for(let k of s.statement){let l=v(k);y.has(l)||(y.add(l),u.statement.push(k))}}else{let y=new Set,k=[];for(let l of s.statement){let h=v(l);y.has(h)||(y.add(h),k.push(l))}s.statement=k,c.set(f,y),n.set(f,s),i.push(s)}}else i.push(s);let m=new Set;for(let s of i)if(s instanceof w){let f=s.namespace||"",u=f.indexOf("/"),y=u>=0?f.slice(0,u):"",k=u>=0?f.slice(u+1):"",l=k.indexOf("@"),h=l>=0?k.slice(0,l):k;m.add(`${y}/${h}/${s.name}`)}let d=s=>m.has(`${s.publisher}/${s.package_}/${s.name}`);for(let s of i)s instanceof w&&this.canonicalizeStatementBuiltins(s.statement,d);return i}canonicalizeStatementBuiltins(e,t){for(let r of e){let a=r.predicate?.subject;if(M(a,t),r instanceof P)r.object instanceof g&&M(r.object.subject,t);else if(r instanceof S)r.object&&this.canonicalizeStatementBuiltins(r.object.statement,t);else if(r instanceof K)for(let o of r.object??[])o instanceof g?M(o.subject,t):o instanceof b&&this.canonicalizeStatementBuiltins(o.statement,t)}}resolveCanonicalEntity(e,t,r){if(!e.includes(".")||!t.metadata?.imports)return{namespace:r,name:e};let a=e.indexOf("."),o=e.substring(0,a),n=e.substring(a+1);for(let[c,i]of Object.entries(t.metadata.imports))for(let m of i)if((m.alias??m.packageName)===o){let s=m.version;return{namespace:`${c}/${m.packageName}@${s.major}.${s.minor}.${s.patch}`,name:n}}return{namespace:r,name:e}}async parseStatements(e,t,r,a,o){let n=[];if(typeof e!="object"||e===null||Array.isArray(e))return n;for(let[c,i]of Object.entries(e))try{let m=await this.getPropertyMetadata(c,t,r,o,a);if(!m)continue;let d=await this.parsePropertyValue(c,i,m,t,r,a,o);d&&n.push(d)}catch(m){throw new Error(`Failed to parse property '${c}': ${m.message}`,{cause:m})}return n}async getPropertyMetadata(e,t,r,a,o){let n=await r.resolveEntityAsync(e,t);if(!n)return;let c=n.entity,i=c.type?.toString()??"",m=i.includes(".")?i.substring(i.lastIndexOf(".")+1):i;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(m))return;let s=o.getPropertyTypeClassification(i),f=c.range?.toString(),u;if(s==="ObjectProperty")u="ObjectProperty";else if(s==="DatatypeProperty")u="DatatypeProperty";else{let l=f&&f.includes(".")?f.substring(f.lastIndexOf(".")+1):f??"";(f?o.isKnownXsdDatatypeName(f):!1)||l==="Literal"?u="DatatypeProperty":u="ObjectProperty"}let y;if(f){let l=t;if(n.isImported&&n.definedInNamespace){if(typeof a.getDocumentAsync!="function")throw new Error(`Cannot resolve the range of imported property '${e}': the parse repository cannot fetch defining document '${n.definedInNamespace}'. Thread the real repository through to embedded-object parsing \u2014 no stub, no fallback.`);let T=await a.getDocumentAsync(n.definedInNamespace);if(!T)throw new Error(`Cannot resolve the range of imported property '${e}': defining document '${n.definedInNamespace}' was not found in the repository.`);l=T}y=(await r.resolveEntityAsync(f,l))?.uri}return{propertyUri:n.uri.toString(),propertyType:u,range:f,rangeUri:y,isImported:n.isImported,definedInNamespace:n.definedInNamespace}}async parsePropertyValue(e,t,r,a,o,n,c){let i=r.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(i,t,r,a,o,n,c);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(i,t,r,a,o,n);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(i,t,r,a,o,n,c)}}async parseDatatypeValue(e,t,r,a,o,n){if(t instanceof Date)return j.parse(e,t.toISOString());if(typeof t=="string")return n.isSubstitutableDatatype(r.rangeUri)?await this.parseSubstitutableValue(e,t,a,o):j.parse(e,t);if(typeof t=="number")return D.parse(e,t);if(typeof t=="boolean"){let c=new O;return c.predicate=g.parse(e),c.object=t,c}}async parseSubstitutableValue(e,t,r,a){let o=new I;o.predicate=g.parse(e),o.object=t;for(let n of x(t)){let c=await a.resolveEntityAsync(n.reference,r),i;c&&(i=new g,i.subject=c.uri);let m={reference:n.reference,startOffset:n.startOffset,endOffset:n.endOffset};n.displayText!==void 0&&(m.displayText=n.displayText),i!==void 0&&(m.target=i),o.links.push(m)}return o}async parseObjectValue(e,t,r,a,o,n,c){if(typeof t=="string"){let i=await this.resolveReference(t,a,o);if(!i)return;let m=new P;return m.predicate=g.parse(e),m.object=i,m}if(typeof t=="object"&&!Array.isArray(t)){let i=new b;if(i.statement=await this.parseStatements(t,a,o,n,c),i.statement.length>0){let s=new S;return s.predicate=g.parse(e),s.object=i,s}let m=[];for(let[s,f]of Object.entries(t))if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let u=new b;u.name=s,u.statement=await this.parseStatements(f,a,o,n,c),m.push(u)}else if(typeof f=="string"){let u=await this.resolveReference(f,a,o);u&&m.push(u)}if(m.length>0){let s=new K;return s.predicate=g.parse(e),s.object=m,s}let d=new S;return d.predicate=g.parse(e),d.object=i,d}}async parseListValue(e,t,r,a,o,n,c){let i=[],m=r.propertyType==="DatatypeProperty";for(let s of t){if(m&&(typeof s=="string"||typeof s=="number"||typeof s=="boolean")){let f=new R;f.value=s,i.push(f);continue}if(m&&s instanceof Date){let f=new R;f.value=s.toISOString(),i.push(f);continue}if(typeof s=="string"){let f=await this.resolveReference(s,a,o);f&&i.push(f)}else if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let f=new b;f.statement=await this.parseStatements(s,a,o,n,c),i.push(f)}}let d=new K;return d.predicate=g.parse(e),d.object=i,d}async resolveReference(e,t,r){let a=await r.resolveEntityAsync(e,t);if(a){let n=new g;return n.subject=a.uri,n}let o=t.metadata?.namespace_;if(o){let{KanonakUri:n}=await import("./KanonakUri-4VJGV3FN.js"),c=o.version??{major:0,minor:0,patch:0,toString:()=>"0.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};if(e.includes(".")){let m=e.indexOf("."),d=e.substring(0,m),s=e.substring(m+1);if(t.metadata?.imports){for(let[f,u]of Object.entries(t.metadata.imports))for(let y of u)if((y.alias??y.packageName)===d){let l=new g;return l.subject=new n(f,y.packageName,s,y.version),l}}}let i=new g;return i.subject=new n(o.publisher,o.package_,e,c),i}return null}async saveKanonaks(e,t){let r=new Map;for(let a of e)a instanceof w&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,o]of r){let n=await this.convertKanonaksToDocument(a,o),c=`${a.split("@")[0]}.yml`;await t.saveDocumentAsync(n,c)}}async serializeToYaml(e,t){let r=e.filter(n=>n instanceof w&&n.namespace===t);if(r.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let a=await this.convertKanonaksToDocument(t,r);return new A().save(a)}async convertKanonaksToDocument(e,t){let a={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let n=[];for(let c of Object.values(this.imports))n.push(...c);return n}},body:{}},o=new Map;for(let n of t){let c={};for(let i of n.statement){let[m,d]=this.convertStatementToProperty(i);m&&d!==null&&d!==void 0&&(c[m]=d),this.collectImportsFromStatement(i,e,o)}a.body[n.name]=c}return a}convertStatementToProperty(e){if(e instanceof j)return[e.predicate.subject.name,e.object];if(e instanceof D)return[e.predicate.subject.name,e.object];if(e instanceof O)return[e.predicate.subject.name,e.object];if(e instanceof P)return[e.predicate.subject.name,e.object.subject.name];if(e instanceof K){let t=this.convertKanonakListToValue(e.object);return[e.predicate.subject.name,t]}else if(e instanceof S){let t=this.convertEmbeddedKanonakToValue(e.object);return[e.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(e){let t=[];for(let r of e)r instanceof g?t.push(r.subject.name):r instanceof b&&t.push(this.convertEmbeddedKanonakToValue(r));return t}convertEmbeddedKanonakToValue(e){let t={};for(let r of e.statement){let[a,o]=this.convertStatementToProperty(r);a&&o!==null&&o!==void 0&&(t[a]=o)}return t}collectImportsFromStatement(e,t,r){}};function v(p){let e=p.predicate?.subject;return(e?`${e.publisher}/${e.package_}/${e.name}`:"?")+"="+X(p)}function X(p){return p instanceof I?"m:"+String(p.object):p instanceof j?"s:"+String(p.object):p instanceof D?"n:"+String(p.object):p instanceof O?"b:"+String(p.object):p instanceof P?"r:"+E(p.object):p instanceof S?"e:"+E(p.object):p instanceof K?"l:["+(p.object??[]).map(E).join("|")+"]":"x"}function E(p){if(!p)return"";if(p instanceof g){let e=p.subject;return"R("+(e?`${e.publisher}/${e.package_}/${e.name}`:"")+")"}return p instanceof b?"E("+(p.statement??[]).map(v).join(";")+")":p instanceof R?"L("+String(p.value)+")":"N"}export{b as a,R as b,I as c,Q as d,x as e,C as f};
@@ -1,2 +0,0 @@
1
- import{c as S,f as R}from"./chunk-G2DKKSZ4.js";import{a as h}from"./chunk-BGQKZBNE.js";var E=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(E||{}),A=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(A||{}),$=class{static async buildFromRepository(n){let l=await new R().parseKanonaks(n),p=await n.getAllDocumentsAsync(),a=[],s=[],t=new Set,o=new Set,d=new Map;for(let y of l){let c=y;c.name&&(h.isClassType(c)&&t.add(c.name),(h.isObjectPropertyType(c)||h.isGenericPropertyType(c))&&o.add(c.name))}for(let y of p)for(let[c,g]of Object.entries(y.body))o.has(c)&&g?.range&&typeof g.range=="string"&&d.set(c,g.range);let u=new Map;for(let y of l){let c=y;c.name&&u.set(c.name,c)}for(let y of p){let c=y.metadata.namespace_,g=c?`${c.publisher}/${c.package_}`:"",i=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",f=x(y);for(let[m,b]of Object.entries(y.body)){if(!b||typeof b!="object")continue;let P=u.get(m),k="Unknown";if(P){let T=P;h.isClassType(T)?k="Class":h.isObjectPropertyType(T)?k="ObjectProperty":h.isDatatypePropertyType(T)?k="DatatypeProperty":h.isAnnotationPropertyType(T)?k="AnnotationProperty":h.isDatatypeType(T)?k="Datatype":h.isGenericPropertyType(T)?k="ObjectProperty":h.isInstanceOfKnownClass(T,t)&&(k="Instance")}let j=g&&i?`${g}/${m}@${i}`:m,C={};for(let[T,O]of Object.entries(b))T!=="type"&&(typeof O!="object"||O===null)&&(C[T]=O);a.push({id:j,label:b.label??m,type:k,namespace:g,properties:C}),v(j,b,k,t,o,s,g,i,f),N(j,b,o,d,a,s,g,i,f),L(j,P,s)}}return{nodes:a,edges:s}}static buildFromDocument(n){let r=[],l=[],p=n.metadata.namespace_,a=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",s=p?`${p.publisher}/${p.package_}`:"",t=new Set,o=new Set,d=new Map,u=x(n);for(let[g,i]of Object.entries(n.body)){let f=i?.type;f&&(K(f,u)&&t.add(g),M(f,u)&&(o.add(g),i.range&&typeof i.range=="string"&&d.set(g,i.range)))}for(let[g,i]of Object.entries(n.body)){if(!i||typeof i!="object")continue;let f=i.type,m=U(f,g,t,u),b=s&&a?`${s}/${g}@${a}`:g,P={};for(let[k,j]of Object.entries(i))k!=="type"&&(typeof j!="object"||j===null)&&(P[k]=j);r.push({id:b,label:i.label??g,type:m,namespace:s,properties:P}),v(b,i,m,t,o,l,s,a,u),N(b,i,o,d,r,l,s,a,u)}let y=new Set(r.map(g=>g.id)),c=l.filter(g=>y.has(g.source)&&y.has(g.target));return{nodes:r,edges:c}}};function x(e,n){let r=new Map;if(e.metadata?.imports)for(let[l,p]of Object.entries(e.metadata.imports))for(let a of p){let s=a.alias??a.packageName,t=a.version,o=`${t.major}.${t.minor}.${t.patch}`;r.set(s,{publisher:l,package_:a.packageName,version:o})}return r}var _={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},G=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function D(e,n){if(e.includes(".")){let r=e.indexOf("."),l=e.substring(0,r),p=e.substring(r+1),a=n.get(l);if(a)return`${a.publisher}/${a.package_}/${p}`}return null}function K(e,n){let r=D(e,n);return r?_[r]==="Class":!1}function M(e,n){let r=D(e,n);return r?G.has(r):!1}function U(e,n,r,l){if(!e||e==="Package")return"Unknown";let p=D(e,l);if(p){let s=_[p];if(s)return s;let t=p.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let a=e.split(".").pop()??e;return r.has(a)?"Instance":"Unknown"}var I=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function v(e,n,r,l,p,a,s,t,o){let d=n.type,u=n.subClassOf;if(u){let i=Array.isArray(u)?u:[u];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subClassOf",label:"subClassOf"})}let y=n.subPropertyOf;if(y){let i=Array.isArray(y)?y:[y];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&d){let i=d.split(".").pop()??d;a.push({source:e,target:w(i,s,t,o),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[i,f]of Object.entries(n)){if(I.has(i)||!p.has(i))continue;let m=Array.isArray(f)?f:[f];for(let b of m)typeof b=="string"&&V(b)&&a.push({source:e,target:w(b,s,t,o),type:"propertyValue",label:i,propertyId:w(i,s,t,o)})}let c=r==="ObjectProperty"||r==="DatatypeProperty",g=n.domain&&n.range;if((c||g)&&n.domain&&n.range){let i=typeof n.domain=="string"?n.domain:null,f=typeof n.range=="string"?n.range:null;i&&f&&a.push({source:w(i,s,t,o),target:w(f,s,t,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function N(e,n,r,l,p,a,s,t,o){for(let[d,u]of Object.entries(n)){if(I.has(d)||typeof u!="object"||u===null||Array.isArray(u))continue;let y=u,c=`${e}/${d}`,g=l.get(d),i=g?g.split(".").pop()??g:"Unknown",f={};for(let[b,P]of Object.entries(y))(typeof P!="object"||P===null)&&(f[b]=P);p.push({id:c,label:`${i} (embedded)`,type:"Instance",namespace:s,properties:f});let m=s&&t?`${s}/${d}@${t}`:d;a.push({source:e,target:c,type:"propertyValue",label:d,propertyId:r.has(d)?m:void 0}),g&&a.push({source:c,target:w(i,s,t,o),type:"instanceOf",label:"type (inferred)"}),N(c,y,r,l,p,a,s,t,o)}}function L(e,n,r){let l=n?.statement;if(Array.isArray(l))for(let p of l){if(!(p instanceof S))continue;let a=p.predicate?.subject?.name??"";for(let s of p.links){let t=s.target?.subject;if(!t)continue;let o=t.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";r.push({source:e,target:`${t.publisher}/${t.package_}/${t.name}${d}`,type:"embeddedLink",label:a})}}}function V(e){return!(!e||e.includes(" ")||e.includes(`
2
- `)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,r,l){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let p=e.indexOf("."),a=e.substring(0,p),s=e.substring(p+1);if(l){let t=l.get(a);if(t)return`${t.publisher}/${t.package_}/${s}@${t.version}`}return n&&r?`${n}/${s}@${r}`:s}return n&&r?`${n}/${e}@${r}`:e}function Y(e){if(!e.expiresAt)return!1;let n=new Date(e.expiresAt),r=300*1e3;return n.getTime()<=Date.now()+r}function Q(e){return!!e.accessToken&&!Y(e)}function X(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}export{E as a,A as b,$ as c,Y as d,Q as e,X as f};