@kanonak-protocol/sdk 3.70.0 → 3.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/{chunk-EOMKFFKU.js → chunk-ATH6636H.js} +1 -1
- package/dist/{chunk-N224PFBI.js → chunk-BGQKZBNE.js} +1 -1
- package/dist/chunk-CRKSKIAL.js +1 -0
- package/dist/{chunk-W4LPC6VM.js → chunk-F5ANO7MJ.js} +1 -1
- package/dist/{chunk-2OXZDBHX.js → chunk-FX7JDGL6.js} +1 -1
- package/dist/chunk-G2DKKSZ4.js +1 -0
- package/dist/{chunk-6T2XFOMU.js → chunk-GN2XODVC.js} +1 -1
- package/dist/chunk-IOMNZBK4.js +1 -0
- package/dist/chunk-LKBG2MK6.js +2 -0
- package/dist/{chunk-C5NKFT7W.js → chunk-MCU5IAMS.js} +24 -24
- package/dist/chunk-RRODBYIK.js +74 -0
- package/dist/chunk-TJPQETHV.js +1 -0
- package/dist/{chunk-7ZCFYITD.js → chunk-Y7TGQ7UF.js} +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -26
- package/dist/parsing/index.js +1 -1
- package/dist/producer/Entitlement.d.ts +75 -0
- package/dist/producer/IPackageProducer.d.ts +59 -0
- package/dist/producer/PackageBuilder.d.ts +130 -0
- package/dist/producer/ProducerRepository.d.ts +44 -0
- package/dist/producer/index.d.ts +6 -0
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/HttpKanonakDocumentRepository.d.ts +20 -0
- package/dist/repositories/PublisherConfig.d.ts +10 -0
- package/dist/repositories/PublisherIndex.d.ts +3 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/assembleModel.d.ts +2 -0
- package/dist/server/index.js +2 -2
- package/dist/server/types.d.ts +9 -0
- package/dist/transformations/index.js +1 -1
- package/dist/uri-helpers/UriHelpers.d.ts +18 -0
- package/dist/uri-helpers/index.d.ts +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/TxExpressionPathChecker.d.ts +39 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/LookSemanticSvgPathRule.d.ts +13 -23
- package/dist/validation/rules/repository/TxExpressionPathRule.d.ts +28 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/dist/view/ViewMaterializer.d.ts +65 -0
- package/dist/view/index.d.ts +2 -0
- package/package.json +2 -2
- package/dist/chunk-64TVBQFR.js +0 -1
- package/dist/chunk-ORFSMEMM.js +0 -1
- package/dist/chunk-PODBS4IU.js +0 -1
- package/dist/chunk-Q4DKP5DO.js +0 -1
- package/dist/chunk-U75VPNYW.js +0 -2
- package/dist/chunk-XEFBKQY5.js +0 -64
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { uriKey, uriMatches, toCanonicalUrl, hasType, findSubjectsByType, findSubjectByUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
|
|
1
|
+
export { uriKey, uriMatches, toCanonicalUrl, hasType, 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}from"../chunk-
|
|
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};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Kanonak } from '../kanonaks/Kanonak.js';
|
|
2
|
+
import { EmbeddedKanonak } from '../kanonaks/EmbeddedKanonak.js';
|
|
3
|
+
import { type EntityUri } from '../uri-helpers/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* One out-of-scope path step found while walking a `tx.Expression` tree.
|
|
6
|
+
* `contextClass` is the type the step was read against (the View's bound
|
|
7
|
+
* class for a top-level read, or an intermediate type reached after one
|
|
8
|
+
* or more traversals); `propertyUri` is the offending property; `via`
|
|
9
|
+
* records which step kind referenced it.
|
|
10
|
+
*/
|
|
11
|
+
export interface TxPathFailure {
|
|
12
|
+
contextClass: EntityUri;
|
|
13
|
+
propertyUri: EntityUri;
|
|
14
|
+
via: 'PropertyRead' | 'Traverse';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Walk a `tx.Expression` tree and report every `tx.PropertyRead` /
|
|
18
|
+
* `tx.Traverse` step whose property is not in scope for the type it is
|
|
19
|
+
* read against. The bound instance is available as the `input` binding,
|
|
20
|
+
* typed `rootContext`. Context advances through each resolved property's
|
|
21
|
+
* declared `range`, so multi-step paths (a `tx.Traverse` whose `step`
|
|
22
|
+
* reads a property off the traversed-to subject, or a `tx.PropertyRead`
|
|
23
|
+
* whose `readSource` is itself a read) are validated step-by-step.
|
|
24
|
+
*
|
|
25
|
+
* This is the canonical path-chain checker behind both
|
|
26
|
+
* `LookSemanticSvgPathRule` (context = the class a `look.semanticSvg` is
|
|
27
|
+
* declared on) and `TxExpressionPathRule` (context = a `view.View`'s
|
|
28
|
+
* `view.bind`). It resolves every property through the object model via
|
|
29
|
+
* `resolvePropertyStep`, never by local name.
|
|
30
|
+
*
|
|
31
|
+
* Scope notes: a `VarRef` to any name other than a known class-typed
|
|
32
|
+
* binding (e.g. the pre-computed `label`/`uri` env strings, or an
|
|
33
|
+
* iterator's element variable) yields an unknown type, so reads rooted at
|
|
34
|
+
* it are left unchecked rather than falsely flagged — the same
|
|
35
|
+
* conservative stance the engine takes at render time. Traversing a step
|
|
36
|
+
* whose range is a datatype is not yet rejected here (the "can't traverse
|
|
37
|
+
* past a literal" refinement); only out-of-scope properties are reported.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkTxExpressionPaths(catalog: Kanonak[], rootContext: EntityUri, expr: EmbeddedKanonak): TxPathFailure[];
|
|
@@ -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 } 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 } from './rules/repository/index.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,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-RRODBYIK.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};
|
|
@@ -4,33 +4,23 @@ import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
|
4
4
|
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
5
5
|
import type { ValidationCache } from '../../ValidationCache.js';
|
|
6
6
|
/**
|
|
7
|
-
* Validates that `tx.PropertyRead`
|
|
8
|
-
* tier fragments reference properties in scope for the
|
|
9
|
-
* the SemanticSvg is declared. When a tier authored on
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
* Validates that `tx.PropertyRead` / `tx.Traverse` steps inside
|
|
8
|
+
* `look.semanticSvg` tier fragments reference properties in scope for the
|
|
9
|
+
* class on which the SemanticSvg is declared. When a tier authored on
|
|
10
|
+
* class C reads property P off the rendered instance, P's domain must
|
|
11
|
+
* cover C (the class itself, an ancestor, or rdfs.Resource); otherwise
|
|
12
|
+
* the read silently returns undefined at render time and the tier's
|
|
13
|
+
* substitution leaks empty.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* PropertyReads in other `tx.Expression`-ranged contexts (e.g.
|
|
21
|
-
* `tx.Transformation.rule`) are out of scope here; the generalized
|
|
22
|
-
* chain walker will cover them.
|
|
15
|
+
* The path walk is the shared, context-advancing
|
|
16
|
+
* `checkTxExpressionPaths` — the same engine `TxExpressionPathRule` uses
|
|
17
|
+
* for `view.View` projections. This rule only supplies the look-specific
|
|
18
|
+
* root context (the declaring class) and the look-specific diagnostic
|
|
19
|
+
* wording.
|
|
23
20
|
*/
|
|
24
21
|
export declare class LookSemanticSvgPathRule implements IRepositoryValidationRule {
|
|
25
22
|
readonly ruleName = "LookSemanticSvgPath";
|
|
26
23
|
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
27
24
|
private checkSemanticSvg;
|
|
28
|
-
|
|
29
|
-
* Recursively walk an Expression embed, checking PropertyReads and
|
|
30
|
-
* descending into known nesting properties. Unknown Expression kinds
|
|
31
|
-
* are still recursed via every embedded child so we don't miss reads
|
|
32
|
-
* inside future Expression subclasses.
|
|
33
|
-
*/
|
|
34
|
-
private walkExpression;
|
|
35
|
-
private checkPropertyRead;
|
|
25
|
+
private toError;
|
|
36
26
|
}
|
|
@@ -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 projection paths of a `view.View` against its bound
|
|
8
|
+
* class. A View declares `view.bind` (its context class) and a list of
|
|
9
|
+
* `view.Projection`s whose `view.value` is a `tx.Expression` computed
|
|
10
|
+
* against each bound instance, plus optional `view.where` predicate
|
|
11
|
+
* expressions. Every `tx.PropertyRead` / `tx.Traverse` step inside those
|
|
12
|
+
* expressions must reference a property in scope for the type it is read
|
|
13
|
+
* against (the bound class, or an intermediate type reached by an earlier
|
|
14
|
+
* traversal) — otherwise the read silently returns undefined when the
|
|
15
|
+
* View materializes.
|
|
16
|
+
*
|
|
17
|
+
* Shares the context-advancing path walker with `LookSemanticSvgPathRule`
|
|
18
|
+
* (`checkTxExpressionPaths`); the only difference is the root context —
|
|
19
|
+
* here the View's `view.bind`, there the class a `look.semanticSvg` is
|
|
20
|
+
* declared on. The generalized form tracked in typescript#48.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TxExpressionPathRule implements IRepositoryValidationRule {
|
|
23
|
+
readonly ruleName = "TxExpressionPath";
|
|
24
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
|
|
25
|
+
private checkView;
|
|
26
|
+
private asError;
|
|
27
|
+
private toError;
|
|
28
|
+
}
|
|
@@ -21,3 +21,4 @@ export { EmbeddedKanonakTypeRule } from './EmbeddedKanonakTypeRule.js';
|
|
|
21
21
|
export { MarkdownLinkRule } from './MarkdownLinkRule.js';
|
|
22
22
|
export { DisplayLensScopeRule } from './DisplayLensScopeRule.js';
|
|
23
23
|
export { LookSemanticSvgPathRule } from './LookSemanticSvgPathRule.js';
|
|
24
|
+
export { TxExpressionPathRule } from './TxExpressionPathRule.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import { KanonakParser } from '../parsing/KanonakParser.js';
|
|
3
|
+
import { type EntityUri } from '../uri-helpers/index.js';
|
|
4
|
+
export interface MaterializeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* ISO-8601 timestamp recorded as the EphemeralPackage's `resolvedAt`.
|
|
7
|
+
* The SDK never reads the clock itself (it would make results
|
|
8
|
+
* non-deterministic and untestable); the caller supplies it. Omitted →
|
|
9
|
+
* no `resolvedAt` is written. It lives on the header, outside the hashed
|
|
10
|
+
* body, so two identical runs still share a content hash.
|
|
11
|
+
*/
|
|
12
|
+
resolvedAt?: string;
|
|
13
|
+
/** Optional per-invocation id recorded as `id` (also header-only). */
|
|
14
|
+
invocationId?: string;
|
|
15
|
+
/** Reasoning profile used to find instances of `bind`. */
|
|
16
|
+
reasoningProfile?: 'rdfs' | 'owl-rl-classification';
|
|
17
|
+
}
|
|
18
|
+
export interface MaterializeResult {
|
|
19
|
+
/** The EphemeralPackage as `.kan.yml` text. */
|
|
20
|
+
yaml: string;
|
|
21
|
+
/** `sha256:` content hash of the body (the `ck.contentHash` value). */
|
|
22
|
+
contentHash: string;
|
|
23
|
+
/** Address-safe package name (`q-<hex16>`), derived from the hash. */
|
|
24
|
+
packageName: string;
|
|
25
|
+
/** Publisher the EphemeralPackage is minted under (the View's publisher). */
|
|
26
|
+
publisher: string;
|
|
27
|
+
/** Number of result instances produced. */
|
|
28
|
+
rowCount: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The in-graph producer for the View Language. Given a `view.View` (or a
|
|
32
|
+
* `view.ViewPackage` whose `rootView` is one), it resolves the View
|
|
33
|
+
* against the local catalog and materializes the result as a versionless
|
|
34
|
+
* `EphemeralPackage`:
|
|
35
|
+
*
|
|
36
|
+
* 1. find every instance of the View's `bind` class (subclass-aware,
|
|
37
|
+
* via the reasoner);
|
|
38
|
+
* 2. keep those for which every `where` predicate holds;
|
|
39
|
+
* 3. for each, mint one `produces` instance whose properties are the
|
|
40
|
+
* projections (`value` evaluated against the instance, stored under
|
|
41
|
+
* `as`), plus a `view.derivedFrom` reference back to the stable
|
|
42
|
+
* source — a reference, never a copy;
|
|
43
|
+
* 4. wrap the instances in an EphemeralPackage whose import closure makes
|
|
44
|
+
* the shape self-describing, with a content-hash identity.
|
|
45
|
+
*
|
|
46
|
+
* This is one producer behind a producer-agnostic contract: a backend
|
|
47
|
+
* binding (Polygon, DynamoDB, …) fulfils the same View by emitting the
|
|
48
|
+
* same EphemeralPackage shape. Selection views (no `produces`) are not yet
|
|
49
|
+
* materialized here and fail visibly rather than guessing a shape.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ViewMaterializer {
|
|
52
|
+
private readonly repository;
|
|
53
|
+
private readonly parser;
|
|
54
|
+
private readonly objectParser;
|
|
55
|
+
private readonly builder;
|
|
56
|
+
constructor(repository: IKanonakDocumentRepository, parser?: KanonakParser);
|
|
57
|
+
materialize(viewRef: EntityUri, opts?: MaterializeOptions): Promise<MaterializeResult>;
|
|
58
|
+
private resolveView;
|
|
59
|
+
private readProjections;
|
|
60
|
+
private reason;
|
|
61
|
+
private findInstances;
|
|
62
|
+
private passesWhere;
|
|
63
|
+
private evaluateValue;
|
|
64
|
+
private rowName;
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.72.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.
|
|
125
|
+
"@kanonak-protocol/types": "^3.72.0",
|
|
126
126
|
"ignore": "^7.0.5",
|
|
127
127
|
"js-yaml": "^4.1.0",
|
|
128
128
|
"yaml": "^2.7.0"
|
package/dist/chunk-64TVBQFR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-FUUTGGJS.js";function K(n){if(Array.isArray(n))return n.map(t=>t?.toString()??"").filter(t=>t.length>0);let e=n?.toString();return e?[e]:[]}var S=class{cache=new Map;repository;logger;constructor(e,t){this.repository=e,this.logger=t}async resolveEntityAsync(e,t){let a=t.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(a);if(s){let p=s.get(e);if(p)return p}let r=await this.buildEntityIndexAsyncInternal(t,new Set,"");return this.cache.set(a,r),r.get(e)??null}async resolveAllEntitiesAsync(e,t){let a=await this.buildAllEntitiesIndexAsync(t,new Set,"");if(e.includes(".")){let s=e.split("."),r=s[0],p=s[1],g=await this.findDocumentForAlias(t,r);return g?await this.resolveAllEntitiesAsync(p,g):[]}return a.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,t,a){let s=[],r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),s;t.add(r);let p=a.length===0?r:`${a} \u2192 ${r}`;for(let[g,i]of Object.entries(e.body))if(!g.includes(".")&&i&&typeof i=="object"&&!Array.isArray(i)){let u=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:g,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,g,u),entity:i,definedInNamespace:r,isImported:a.length>0,importPath:p})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${r}`),e.metadata?.imports){let g=Object.values(e.metadata.imports).reduce((i,u)=>i+u.length,0);this.logger?.debug?.(`Processing ${g} import(s) for ${r}`);for(let[i,u]of Object.entries(e.metadata.imports))for(let f of u)try{this.logger?.debug?.(`Resolving import: ${i}/${f.packageName}`);let y=await this.repository.getHighestCompatibleVersionAsync(i,f);if(y){this.logger?.debug?.(`Successfully loaded import: ${y.metadata?.namespace_?.toString()}`);let m=await this.buildAllEntitiesIndexAsync(y,t,p);s.push(...m),this.logger?.debug?.(`Added ${m.length} entities from import ${y.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${i}/${f.packageName}`)}catch(y){let m=y;throw this.logger?.error?.(`Failed to process import ${i}/${f.packageName} for namespace ${r}. Error: ${m.message}`,m),new Error(`Failed to process import ${i}/${f.packageName} for namespace ${r}. See inner exception for details.`,{cause:y})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"")}async buildEntityIndexAsyncInternal(e,t,a){let s=new Map,r=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${r}`),t.has(r))return this.logger?.debug?.(`Skipping ${r} - already visited (circular import prevention)`),s;t.add(r);let p=a.length===0?r:`${a} \u2192 ${r}`,g=0;for(let[i,u]of Object.entries(e.body))if(!i.includes(".")&&u&&typeof u=="object"&&!Array.isArray(u)&&!s.has(i)){let f=e.metadata.namespace_?.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.set(i,{entityName:i,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,i,f),entity:u,definedInNamespace:r,isImported:a.length>0,importPath:p}),g++}if(this.logger?.debug?.(`Indexed ${g} entities from ${r}`),e.metadata?.imports){let i=Object.values(e.metadata.imports).reduce((u,f)=>u+f.length,0);this.logger?.debug?.(`Processing ${i} import(s) for ${r}`);for(let[u,f]of Object.entries(e.metadata.imports))for(let y of f)try{this.logger?.debug?.(`Resolving import: ${u}/${y.packageName}`);let m=await this.repository.getHighestCompatibleVersionAsync(u,y);if(m){this.logger?.debug?.(`Successfully loaded import: ${m.metadata?.namespace_?.toString()}`);let A=await this.buildEntityIndexAsyncInternal(m,t,p),$=0;for(let[R,h]of A.entries()){let b=s.get(R);if(!b)s.set(R,h),$++;else if(b.isImported&&h.isImported&&(b.uri.publisher!==h.uri.publisher||b.uri.package_!==h.uri.package_)){let k=b.isAmbiguous?b:{...b,isAmbiguous:!0,ambiguousNamespaces:[b.definedInNamespace]};k.ambiguousNamespaces.includes(h.definedInNamespace)||k.ambiguousNamespaces.push(h.definedInNamespace),s.set(R,k),this.logger?.warn?.(`Ambiguous reference '${R}': defined in ${k.ambiguousNamespaces.join(", ")}`)}if(y.alias&&!R.includes(".")){let k=`${y.alias}.${R}`;s.has(k)||(s.set(k,h),$++)}}this.logger?.debug?.(`Merged ${$} entities from import ${m.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${u}/${y.packageName}`)}catch(m){let A=m;throw this.logger?.error?.(`Failed to process import ${u}/${y.packageName} for namespace ${r}. Error: ${A.message}`,A),new Error(`Failed to process import ${u}/${y.packageName} for namespace ${r}. See inner exception for details.`,{cause:m})}}return s}async findDocumentForAlias(e,t){if(!e.metadata?.imports)return null;for(let[a,s]of Object.entries(e.metadata.imports))for(let r of s){if(r.alias===t)return await this.repository.getHighestCompatibleVersionAsync(a,r);if(!r.alias&&r.packageName===t)return await this.repository.getHighestCompatibleVersionAsync(a,r)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}async isSubclassOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubclassOfRecursiveAsync(e,t,a,s)}async isSubclassOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let r=await this.resolveEntityAsync(e,a);if(!r?.entity)return!1;let p=r.entity.subClassOf;if(p){let g=K(p);for(let i of g)if(i===t||await this.isSubclassOfRecursiveAsync(i,t,a,s))return!0}return!1}async isSubpropertyOfAsync(e,t,a){if(e===t)return!0;let s=new Set;return await this.isSubpropertyOfRecursiveAsync(e,t,a,s)}async isSubpropertyOfRecursiveAsync(e,t,a,s){if(s.has(e))return!1;s.add(e);let r=await this.resolveEntityAsync(e,a);if(!r?.entity)return!1;let p=r.entity.subPropertyOf;if(p){let g=K(p);for(let i of g)if(i===t||await this.isSubpropertyOfRecursiveAsync(i,t,a,s))return!0}return!1}};var v=class n{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","bool","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&n.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let t=e.includes(".")?e.split(".")[1]:e;return n.KNOWN_XSD_DATATYPES.has(t.toLowerCase())}async isClassTypeAsync(e,t){if(this.isKnownXsdDatatypeName(e))return!1;let a=await this.resourceResolver.resolveEntityAsync(e,t);if(a){let s=a.entity.type;if(s){let r=String(s);return r==="Class"||r==="rdfs.Class"||r.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,t){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(t)||e==="Property"&&this.isLiteralType(t))}isEffectiveObjectProperty(e,t){return!!(e==="ObjectProperty"||e==="Property"&&t&&!this.isXsdDatatype(t)&&!this.isLiteralType(t))}};function T(n){return`${n.publisher}/${n.package_}/${n.name}`}function c(n,e,t){return`${n}/${e}/${t}`}function L(n){return`${n.s}|${n.p}|${O(n.o)}`}function O(n){switch(n.kind){case"uri":return`u:${n.key}`;case"literal":return`l:${n.datatype}:${n.lexical}`;case"blank":return`b:${n.id}`}}function N(n,e,t){return{s:n,p:e,o:{kind:"uri",key:t}}}var l="kanonak.org",o="core-rdf",d="core-owl",D="core-kanonak",_=new Map([["type",o],["subClassOf",o],["subPropertyOf",o],["domain",o],["range",o],["label",o],["comment",o],["seeAlso",o],["isDefinedBy",o],["member",o],["Resource",o],["Class",o],["Property",o],["Datatype",o],["Literal",o],["List",o],["ObjectProperty",d],["DatatypeProperty",d],["AnnotationProperty",d],["Thing",d],["Nothing",d],["Package",D]]),x=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function F(n,e){if(!n||!n.name)return;let t=_.get(n.name);if(t){if(x.has(n.name)){n.publisher=l,n.package_=t;return}n.publisher===l&&n.package_===t||n.publisher&&n.publisher.length>0&&(!e||e(n))||(n.publisher=l,n.package_=t)}}var w=class{type=c(l,o,"type");subClassOf=c(l,o,"subClassOf");subPropertyOf=c(l,o,"subPropertyOf");domain=c(l,o,"domain");range=c(l,o,"range");label=c(l,o,"label");comment=c(l,o,"comment");resource=c(l,o,"Resource");class_=c(l,o,"Class");datatype=c(l,o,"Datatype");literal=c(l,o,"Literal");equivalentClass=c(l,d,"equivalentClass");equivalentProperty=c(l,d,"equivalentProperty");inverseOf=c(l,d,"inverseOf");sameAs=c(l,d,"sameAs");transitiveProperty=c(l,d,"TransitiveProperty");symmetricProperty=c(l,d,"SymmetricProperty");objectProperty=c(l,d,"ObjectProperty");datatypeProperty=c(l,d,"DatatypeProperty");annotationProperty=c(l,d,"AnnotationProperty");package_=c(l,D,"Package")};export{K as a,S as b,v as c,T as d,c as e,L as f,O as g,N as h,F as i,w as j};
|
package/dist/chunk-ORFSMEMM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as y,b as g}from"./chunk-2ACBWC7K.js";import*as h from"js-yaml";var k=class{parse(e){let t=this.parseWithErrors(e);if(!t.isValid){let a=t.errors[0];throw new Error(`YAML parse error at line ${a.line}, column ${a.column}: ${a.message}`)}return t.document}parseWithErrors(e){let t=[],a;try{e=e.replace(/^\uFEFF/,"");let s=h.load(e);if(!s||typeof s!="object")return a={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:a,errors:t,isValid:!0};let r=this.extractMetadata(s),n=this.extractBody(s,r);return a={metadata:r,body:n,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:a,errors:t,isValid:!0}}catch(s){let r=s,n={message:r.message||"Unknown parse error",line:r.mark?.line??0,column:r.mark?.column??0,errorType:r.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${r.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${r.mark?.line??0}: ${r.message||"Unknown parse error"}`};return t.push(n),{document:void 0,errors:t,isValid:!1}}}save(e){let t={};if(e.metadata.namespace_){let a=e.metadata.namespace_,s={type:"Package",publisher:a.publisher};a.version&&(s.version=`${a.version.major}.${a.version.minor}.${a.version.patch}`),e.metadata.imports&&(s.imports=this.serializeImports(e.metadata.imports)),t[a.package_]=s}return Object.assign(t,e.body),h.dump(t,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(e){let t=e.imports;return Object.defineProperty(e,"allImports",{get:function(){if(!t)return[];let a=[];for(let s of Object.values(t))a.push(...s);return a},enumerable:!0,configurable:!0}),e}createVersion(e,t,a){return{major:e,minor:t,patch:a,toString:()=>`${e}.${t}.${a}`,equals:r=>!r||typeof r!="object"?!1:r.major===e&&r.minor===t&&r.patch===a,getHashCode:()=>e<<20|t<<10|a,compareTo:r=>e!==r.major?e-r.major:t!==r.minor?t-r.minor:a-r.patch}}extractMetadata(e){let t=this.createEmptyMetadata();for(let[a,s]of Object.entries(e))if(s&&typeof s=="object"&&s.type==="Package"){t.type_="Package";let r=a,n=s.publisher,i=s.version?this.parseVersion(s.version):void 0;return n&&r&&(t.namespace_={publisher:n,package_:r,version:i,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:o=>!o||typeof o!="object"?!1:o.publisher===n&&o.package_===r&&(!i||!o.version||i.equals(o.version)),getHashCode:()=>{let o=0;for(let c=0;c<n.length;c++)o=(o<<5)-o+n.charCodeAt(c);for(let c=0;c<r.length;c++)o=(o<<5)-o+r.charCodeAt(c);return o|0}}),s.imports&&Array.isArray(s.imports)&&(t.imports=this.parseImportsV3(s.imports)),this.addAllImportsGetter(t)}if(e.kanonak&&typeof e.kanonak=="object"){let a=e.kanonak;return(a.publisher||a.package||a.version)&&(t.namespace_=this.parseNamespace(a)),a.imports&&typeof a.imports=="object"&&(t.imports=this.parseImportsLegacy(a.imports)),this.addAllImportsGetter(t)}return t}extractBody(e,t){let a={};for(let[s,r]of Object.entries(e))if(!(s==="kanonak"||s==="namespace"||s==="imports"))if(r&&typeof r=="object"&&r.type==="Package"){let n={};for(let[i,o]of Object.entries(r))i==="publisher"||i==="version"||i==="imports"||(n[i]=o);a[s]=n}else a[s]=r;return a}parseNamespace(e){if(typeof e=="string"){let r=e.match(/^([^/]+)\/([^@]+)(?:@(.+))?$/);if(r){let n=r[3]?this.parseVersion(r[3]):this.createVersion(1,0,0);return{publisher:r[1],package_:r[2],version:n,toString:()=>e,equals:i=>!i||typeof i!="object"?!1:i.publisher===r[1]&&i.package_===r[2]&&(!n||!i.version||n.equals(i.version)),getHashCode:()=>{let i=0;for(let o=0;o<r[1].length;o++)i=(i<<5)-i+r[1].charCodeAt(o);for(let o=0;o<r[2].length;o++)i=(i<<5)-i+r[2].charCodeAt(o);return i|0}}}}let t=e.publisher||"",a=e.package||"",s=e.version?this.parseVersion(e.version):this.createVersion(1,0,0);return{publisher:t,package_:a,version:s,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:r=>!r||typeof r!="object"?!1:r.publisher===t&&r.package_===a&&(!s||!r.version||s.equals(r.version)),getHashCode:()=>{let r=0;for(let n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n);for(let n=0;n<a.length;n++)r=(r<<5)-r+a.charCodeAt(n);return r|0}}}parseVersion(e){if(typeof e=="string"){let t=e.split(".").map(Number);return this.createVersion(t[0]||0,t[1]||0,t[2]||0)}return this.createVersion(e.major||0,e.minor||0,e.patch||0)}parseImportsV3(e){let t={};for(let a of e)if(!(!a||typeof a!="object"))if(a.packages&&Array.isArray(a.packages)){let s=a.publisher;if(!s)throw new Error("PublisherImport requires 'publisher' property");t[s]||(t[s]=[]);for(let r of a.packages){if(!r||typeof r!="object")continue;let n=this.parseImportFromEmbeddedObject(r,s);t[s].push(n)}}else{let s=this.parseImportFromEmbeddedObject(a,a.publisher),r=s.publisher||"";t[r]||(t[r]=[]),t[r].push(s)}return t}parseImportsLegacy(e){let t={};for(let[a,s]of Object.entries(e))Array.isArray(s)&&(t[a]=s.map(r=>this.parseImport(r,a)));return t}parseImportFromEmbeddedObject(e,t){let a=e.package;if(!a)throw new Error("Import requires 'package' property");let s=e.match;if(!s)throw new Error("Import requires 'match' property");let r=e.version;if(!r)throw new Error("Import requires 'version' property");let n=this.parseVersion(r),i=this.parseVersionOperator(s),o=this.calculateMaxVersion(s,n),c=e.alias;return{package_:`${a} ${s} ${n.toString()}`,publisher:t,packageName:a,versionOperator:i,version:n,alias:c,minVersion:n,maxVersion:o,toEmbeddedObject:()=>{let m={package:a,match:s,version:n.toString()};return c&&(m.alias=c),m},toString:()=>c?`${a} ${s} ${n.toString()} as ${c}`:`${a} ${s} ${n.toString()}`}}buildImport(e,t,a,s){return this.parseImport({packageName:e,operator:t,version:a},s)}parseImport(e,t){if(typeof e=="string"){let o=e.match(/^(.+?)\s*([~^=*])\s*(\S+)\s+as\s+(\S+)$/);if(o){let m=o[1].trim(),u=o[2],p=this.parseVersion(o[3].trim()),l=o[4].trim(),d=this.parseVersionOperator(u),v=this.calculateMaxVersion(u,p);return{package_:e,publisher:t,packageName:m,versionOperator:d,version:p,alias:l,minVersion:p,maxVersion:v,toEmbeddedObject:()=>{let f={package:m,match:u,version:p.toString()};return l&&(f.alias=l),f},toString:()=>`${m} ${u} ${p.toString()} as ${l}`}}let c=e.match(/^(.+?)\s*([~^=*])\s*(.+)$/);if(c){let m=c[1].trim(),u=c[2],p=this.parseVersion(c[3].trim()),l=this.parseVersionOperator(u),d=this.calculateMaxVersion(u,p);return{package_:e,publisher:t,packageName:m,versionOperator:l,version:p,alias:void 0,minVersion:p,maxVersion:d,toEmbeddedObject:()=>({package:m,match:u,version:p.toString()}),toString:()=>`${m} ${u} ${p.toString()}`}}}let a=this.parseVersionOperator(e.operator||"~"),s=this.parseVersion(e.version||"1.0.0"),r=e.packageName||e.package||"",n=g(a),i=this.calculateMaxVersion(e.operator||"~",s);return{package_:e.package||"",publisher:t,packageName:r,versionOperator:a,version:s,alias:e.alias,minVersion:s,maxVersion:i,toEmbeddedObject:()=>{let o={package:r,match:n,version:s.toString()};return e.alias&&(o.alias=e.alias),o},toString:()=>`${r} ${n} ${s.toString()}`}}parseVersionOperator(e){return y(e)}calculateMaxVersion(e,t){switch(e){case"~":return this.createVersion(t.major,t.minor+1,0);case"^":return t.major===0?this.createVersion(0,t.minor+1,0):this.createVersion(t.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(e){let t=[];for(let[a,s]of Object.entries(e)){let r={publisher:a,packages:s.map(n=>{let i=g(n.versionOperator),o={package:n.packageName,match:i,version:`${n.version.major}.${n.version.minor}.${n.version.patch}`};return n.alias&&(o.alias=n.alias),o})};t.push(r)}return t}};export{k as a};
|
package/dist/chunk-PODBS4IU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E}from"./chunk-ORFSMEMM.js";import{b as $,c as _,i as M}from"./chunk-64TVBQFR.js";import{a as L,b as N,c as j,d as g,g as S,h as D,i as O,j as P,k as w,l as K}from"./chunk-W6T7MOKY.js";var b=class extends N{name};var R=class extends L{value};var I=class extends S{links=[]};var B=/\[\[([^\[\]\n]+)\]\]/g,z=/\[\[/g,V=/```[\s\S]*?```|`[^`\n]*`/g;function U(c){let e=[];for(let t of c.matchAll(V))e.push([t.index,t.index+t[0].length]);return e}function Q(c){if(!c||!c.includes("[["))return[];let e=U(c),t=o=>e.some(([n,s])=>o>=n&&o<s),r=new Set(T(c).map(o=>o.startOffset)),a=[];for(let o of c.matchAll(z)){let n=o.index;if(t(n)||r.has(n))continue;let s=c.slice(n,n+48).replace(/\s+/g," ").trim();a.push({startOffset:n,snippet:s})}return a}function T(c){if(!c||!c.includes("[["))return[];let e=[];for(let a of c.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 c.matchAll(B)){let o=a.index;if(t(o))continue;let n=a[1],s=n.indexOf("|"),p=(s===-1?n:n.slice(0,s)).trim();if(p.length===0)continue;let m=s===-1?"":n.slice(s+1).trim(),f={reference:p,startOffset:o,endOffset:o+a[0].length};m.length>0&&(f.displayText=m),r.push(f)}return r}var C=class{constructor(e){}async parseKanonaks(e){let t=[],r=await e.getAllDocumentsAsync(),a=new $(e),o=new _(a);for(let i of r){let u=i.metadata.namespace_?.toString()??"";for(let[y,l]of Object.entries(i.body)){let k=new j,d=this.resolveCanonicalEntity(y,i,u);k.namespace=d.namespace,k.name=d.name,k.statement=[];let h=await this.parseStatements(l,i,a,o,e);k.statement.push(...h),t.push(k)}}let n=new Map,s=new Map,p=[];for(let i of t)if(i instanceof j){let u=`${i.namespace}/${i.name}`,y=n.get(u);if(y){let l=s.get(u);for(let k of i.statement){let d=v(k);l.has(d)||(l.add(d),y.statement.push(k))}}else{let l=new Set,k=[];for(let d of i.statement){let h=v(d);l.has(h)||(l.add(h),k.push(d))}i.statement=k,s.set(u,l),n.set(u,i),p.push(i)}}else p.push(i);let m=new Set;for(let i of p)if(i instanceof j){let u=i.namespace||"",y=u.indexOf("/"),l=y>=0?u.slice(0,y):"",k=y>=0?u.slice(y+1):"",d=k.indexOf("@"),h=d>=0?k.slice(0,d):k;m.add(`${l}/${h}/${i.name}`)}let f=i=>m.has(`${i.publisher}/${i.package_}/${i.name}`);for(let i of p)i instanceof j&&this.canonicalizeStatementBuiltins(i.statement,f);return p}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 w)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[s,p]of Object.entries(t.metadata.imports))for(let m of p)if((m.alias??m.packageName)===o){let i=m.version;return{namespace:`${s}/${m.packageName}@${i.major}.${i.minor}.${i.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[s,p]of Object.entries(e))try{let m=await this.getPropertyMetadata(s,t,r,o,a);if(!m)continue;let f=await this.parsePropertyValue(s,p,m,t,r,a);f&&n.push(f)}catch(m){console.error(`Error parsing property ${s}:`,m)}return n}async getPropertyMetadata(e,t,r,a,o){let n=await r.resolveEntityAsync(e,t);if(!n)return;let s=n.entity,p=s.type?.toString()??"",m=p.includes(".")?p.substring(p.lastIndexOf(".")+1):p;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(m))return;let i=o.getPropertyTypeClassification(p),u=s.range?.toString(),y;if(i==="ObjectProperty")y="ObjectProperty";else if(i==="DatatypeProperty")y="DatatypeProperty";else{let d=u&&u.includes(".")?u.substring(u.lastIndexOf(".")+1):u??"";(u?o.isKnownXsdDatatypeName(u):!1)||d==="Literal"?y="DatatypeProperty":y="ObjectProperty"}let l;if(u){let d=t;if(n.isImported&&n.definedInNamespace&&typeof a.getDocumentAsync=="function"){let x=await a.getDocumentAsync(n.definedInNamespace);x&&(d=x)}l=(await r.resolveEntityAsync(u,d))?.uri}return{propertyUri:n.uri.toString(),propertyType:y,range:u,rangeUri:l,isImported:n.isImported,definedInNamespace:n.definedInNamespace}}async parsePropertyValue(e,t,r,a,o,n){let s=r.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(s,t,r,a,o,n);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(s,t,r,a,o,n);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(s,t,r,a,o,n)}}async parseDatatypeValue(e,t,r,a,o,n){if(t instanceof Date)return S.parse(e,t.toISOString());if(typeof t=="string")return n.isSubstitutableDatatype(r.rangeUri)?await this.parseSubstitutableValue(e,t,a,o):S.parse(e,t);if(typeof t=="number")return D.parse(e,t);if(typeof t=="boolean"){let s=new O;return s.predicate=g.parse(e),s.object=t,s}}async parseSubstitutableValue(e,t,r,a){let o=new I;o.predicate=g.parse(e),o.object=t;for(let n of T(t)){let s=await a.resolveEntityAsync(n.reference,r),p;s&&(p=new g,p.subject=s.uri);let m={reference:n.reference,startOffset:n.startOffset,endOffset:n.endOffset};n.displayText!==void 0&&(m.displayText=n.displayText),p!==void 0&&(m.target=p),o.links.push(m)}return o}async parseObjectValue(e,t,r,a,o,n){if(typeof t=="string"){let s=await this.resolveReference(t,a,o);if(!s)return;let p=new P;return p.predicate=g.parse(e),p.object=s,p}if(typeof t=="object"&&!Array.isArray(t)){let s=new b;if(s.statement=await this.parseStatements(t,a,o,n,{}),s.statement.length>0){let f=new w;return f.predicate=g.parse(e),f.object=s,f}let p=[];for(let[f,i]of Object.entries(t))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let u=new b;u.name=f,u.statement=await this.parseStatements(i,a,o,n,{}),p.push(u)}else if(typeof i=="string"){let u=await this.resolveReference(i,a,o);u&&p.push(u)}if(p.length>0){let f=new K;return f.predicate=g.parse(e),f.object=p,f}let m=new w;return m.predicate=g.parse(e),m.object=s,m}}async parseListValue(e,t,r,a,o,n){let s=[],p=r.propertyType==="DatatypeProperty";for(let f of t){if(p&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean")){let i=new R;i.value=f,s.push(i);continue}if(p&&f instanceof Date){let i=new R;i.value=f.toISOString(),s.push(i);continue}if(typeof f=="string"){let i=await this.resolveReference(f,a,o);i&&s.push(i)}else if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let i=new b;i.statement=await this.parseStatements(f,a,o,n,{}),s.push(i)}}let m=new K;return m.predicate=g.parse(e),m.object=s,m}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"),s=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("."),f=e.substring(0,m),i=e.substring(m+1);if(t.metadata?.imports){for(let[u,y]of Object.entries(t.metadata.imports))for(let l of y)if((l.alias??l.packageName)===f){let d=new g;return d.subject=new n(u,l.packageName,i,l.version),d}}}let p=new g;return p.subject=new n(o.publisher,o.package_,e,s),p}return null}async saveKanonaks(e,t){let r=new Map;for(let a of e)a instanceof j&&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),s=`${a.split("@")[0]}.yml`;await t.saveDocumentAsync(n,s)}}async serializeToYaml(e,t){let r=e.filter(n=>n instanceof j&&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 E().save(a)}async convertKanonaksToDocument(e,t){let a={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let n=[];for(let s of Object.values(this.imports))n.push(...s);return n}},body:{}},o=new Map;for(let n of t){let s={};for(let p of n.statement){let[m,f]=this.convertStatementToProperty(p);m&&f!==null&&f!==void 0&&(s[m]=f),this.collectImportsFromStatement(p,e,o)}a.body[n.name]=s}return a}convertStatementToProperty(e){if(e instanceof S)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 w){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(c){let e=c.predicate?.subject;return(e?`${e.publisher}/${e.package_}/${e.name}`:"?")+"="+X(c)}function X(c){return c instanceof I?"m:"+String(c.object):c instanceof S?"s:"+String(c.object):c instanceof D?"n:"+String(c.object):c instanceof O?"b:"+String(c.object):c instanceof P?"r:"+A(c.object):c instanceof w?"e:"+A(c.object):c instanceof K?"l:["+(c.object??[]).map(A).join("|")+"]":"x"}function A(c){if(!c)return"";if(c instanceof g){let e=c.subject;return"R("+(e?`${e.publisher}/${e.package_}/${e.name}`:"")+")"}return c instanceof b?"E("+(c.statement??[]).map(v).join(";")+")":c instanceof R?"L("+String(c.value)+")":"N"}export{b as a,R as b,I as c,Q as d,T as e,C as f};
|
package/dist/chunk-Q4DKP5DO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as f,c as i,g as p,h as d,i as y,j as s,k as l,l as g}from"./chunk-W6T7MOKY.js";function K(t){return`${t.publisher}/${t.package_}/${t.name}`}function c(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function D(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 b(t,e){if(!(t instanceof f))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof s){let r=n.object;if(c(r.subject,e))return!0}return!1}function h(t,e){let n=[];for(let o of t)o instanceof i&&b(o,e)&&n.push(o);return n}function S(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 u=r.namespace||"";if(o!==void 0){if(u===o)return r}else if(u.startsWith(`${e.publisher}/${e.package_}@`))return r}}function a(t,e){for(let n of t.statement){let o=n.predicate;if(o?.subject&&c(o.subject,e))return n}}function k(t,e){let n=a(t,e);if(n&&(n instanceof p||n instanceof d||n instanceof y))return n.object}function j(t,e){let n=k(t,e);return typeof n=="string"?n:void 0}function U(t,e){let n=a(t,e);if(n instanceof s)return n.object.subject}function E(t,e){let n=a(t,e);if(n instanceof l)return n.object}function $(t,e){let n=a(t,e);return n instanceof g?n.object??[]:[]}var m=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{K as a,c as b,D as c,b as d,h as e,S as f,k as g,j as h,U as i,E as j,$ as k,m as l};
|
package/dist/chunk-U75VPNYW.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as f}from"./chunk-SC5M74NM.js";import{a as d}from"./chunk-ORFSMEMM.js";var k="https://{publisher}/index.txt",x="https://{publisher}/{package}/{version}.kan.yml",v={version:1};function F(a){return{version:1,index:k.replaceAll("{publisher}",a),package:x.replaceAll("{publisher}",a),auth:"none"}}var h=class{cache=new Map;getConfig(n){let e=this.cache.get(n);return e||(e=this.fetchConfig(n),this.cache.set(n,e),e.catch(()=>{this.cache.get(n)===e&&this.cache.delete(n)})),e}async fetchConfig(n){let e=`https://${n}/.well-known/kanonak.json`,r;try{r=await fetch(e)}catch{return v}if(r.status===404)return v;if(!r.ok)throw new Error(`Failed to fetch publisher config: ${e} (${r.status} ${r.statusText})`);let t=await r.json();if(typeof t.version!="number")throw new Error(`Invalid publisher config at ${e}: missing or invalid "version" field`);let s={version:t.version};return typeof t.index=="string"&&(s.index=t.index),typeof t.package=="string"&&(s.package=t.package),(t.auth==="none"||t.auth==="oauth"||t.auth==="bearer")&&(s.auth=t.auth),Array.isArray(t.render)&&t.render.every(i=>typeof i=="string")&&(s.render=t.render),s}resolveIndexUrl(n,e){let r=e.index??k;return y(r,{publisher:n})}resolvePackageUrl(n,e,r,t){let s=t.package??x;return y(s,{publisher:n,package:e,version:r})}};function y(a,n){let e=a;for(let[t,s]of Object.entries(n))e=e.replaceAll(`{${t}}`,s);let r=e.match(/\{[a-z]+\}/);if(r)throw new Error(`Unresolved variable ${r[0]} in URL template: ${a}`);return e}import{VersionOperator as l}from"@kanonak-protocol/types/document/models/enums";var g=class a{indexCache=new Map;configResolver;fetchFn;constructor(n){this.configResolver=n?.configResolver??new h,this.fetchFn=n?.fetchFn}async resolveVersion(n,e){let r=await this.getPackageVersions(n,e.packageName);if(r.length===0)return null;let t=r.filter(s=>this.isVersionCompatible(s,e.version,e.versionOperator));return t.length===0?null:(t.sort((s,i)=>this.compareVersionStrings(i,s)),t[0])}async getHighestVersion(n,e){let r=await this.getPackageVersions(n,e);return r.length===0?null:[...r].sort((s,i)=>this.compareVersionStrings(i,s))[0]}async listLatestPackages(n){let e=await this.getIndex(n),r=[];for(let[t,s]of e){if(s.length===0)continue;let i=[...s].sort((o,c)=>this.compareVersionStrings(c,o));r.push({packageName:t,version:i[0]})}return r.sort((t,s)=>t.packageName.localeCompare(s.packageName)),r}async getPackageUrl(n,e,r){let t=await this.configResolver.getConfig(n);return this.configResolver.resolvePackageUrl(n,e,r,t)}async getPackageVersions(n,e){return(await this.getIndex(n)).get(e)??[]}getIndex(n){let e=this.indexCache.get(n);return e||(e=this.fetchIndex(n),this.indexCache.set(n,e),e.catch(()=>{this.indexCache.get(n)===e&&this.indexCache.delete(n)})),e}async fetchIndex(n){let e=await this.configResolver.getConfig(n),r=this.configResolver.resolveIndexUrl(n,e),t=this.fetchFn?await this.fetchFn(r,n):await fetch(r);if(!t.ok)throw new Error(`Failed to fetch publisher index: ${r} (${t.status} ${t.statusText})`);let s=await t.text();return a.parseIndex(s)}static parseIndex(n){let e=new Map;for(let r of n.split(`
|
|
2
|
-
`)){let t=r.trim();if(!t||t.startsWith("#"))continue;let s=t.indexOf("/");if(s===-1)continue;let i=t.substring(0,s),o=t.substring(s+1);if(!i||!o)continue;let c=e.get(i);c?c.push(o):e.set(i,[o])}return e}isVersionCompatible(n,e,r){let t=a.parseVersion(n);if(!t)return!1;switch(r){case l.Any:return!0;case l.Exact:return t.major===e.major&&t.minor===e.minor&&t.patch===e.patch;case l.Compatible:return t.major===e.major&&t.minor===e.minor&&t.patch>=e.patch;case l.Major:return t.major!==e.major?!1:t.minor>e.minor?!0:t.minor===e.minor?t.patch>=e.patch:!1;default:return!1}}static parseVersion(n){let e=n.split(".");if(e.length<2)return null;let r=parseInt(e[0],10),t=parseInt(e[1],10),s=e.length>=3?parseInt(e[2],10):0;return isNaN(r)||isNaN(t)||isNaN(s)?null:{major:r,minor:t,patch:s}}compareVersionStrings(n,e){let r=a.parseVersion(n),t=a.parseVersion(e);return!r&&!t?0:r?t?r.major!==t.major?r.major-t.major:r.minor!==t.minor?r.minor-t.minor:r.patch-t.patch:1:-1}};var P=class{parser=new d;publisherIndex;documents=new Map;contentCache=new Map;fetchFn;onFetch;getFromCache;constructor(n){this.onFetch=n?.onFetch,this.getFromCache=n?.getFromCache,this.fetchFn=n?.fetchFn,this.publisherIndex=n?.fetchFn?new g({fetchFn:n.fetchFn}):new g}async getHighestCompatibleVersionAsync(n,e){let r=await this.publisherIndex.resolveVersion(n,e);if(!r)return null;let t=`${n}/${e.packageName}@${r}`,s=this.documents.get(t);if(s)return s;if(this.getFromCache){let m=this.getFromCache(n,e.packageName,r);if(m){let p=this.parser.parse(m);return f(p,n,e.packageName,r),this.documents.set(t,p),this.contentCache.set(t,m),p}}let i=await this.publisherIndex.getPackageUrl(n,e.packageName,r),o=this.fetchFn?await this.fetchFn(i,n):await fetch(i);if(!o.ok)throw new Error(`Failed to fetch Kanonak package: ${i} (${o.status} ${o.statusText})`);let c=await o.text(),u=this.parser.parse(c);return f(u,n,e.packageName,r),this.onFetch&&this.onFetch(n,e.packageName,r,c),this.documents.set(t,u),this.contentCache.set(t,c),u}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(n){return this.documents.get(n)??null}async getDocumentsByNamespaceAsync(n,e){return Array.from(this.documents.values()).filter(r=>{let t=r.metadata.namespace_;return t&&t.publisher===n&&t.package_===e})}async saveDocumentAsync(n,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async deleteDocumentAsync(n){throw new Error("HttpKanonakDocumentRepository is read-only")}async clearNamespaceAsync(n,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(n){return this.contentCache.get(n)??null}async getDocumentUriAsync(n){let e=n.match(/^(.+?)\/(.+?)@(.+)$/);if(!e)return null;let[,r,t,s]=e;return this.publisherIndex.getPackageUrl(r,t,s)}};export{F as a,h as b,g as c,P as d};
|
package/dist/chunk-XEFBKQY5.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import{d as A}from"./chunk-SHDHMKMJ.js";import{a as ee,c as ke,d as Ve,f as D}from"./chunk-PODBS4IU.js";import{a as he}from"./chunk-ORFSMEMM.js";import{d as ae,f as le,g as Ae}from"./chunk-N224PFBI.js";import{d as ne,h as ve,i as ie,j as se,k as De,l as O}from"./chunk-Q4DKP5DO.js";import{a as V,b as v,c as Pe}from"./chunk-64TVBQFR.js";import{c as I,k as be,l as Re}from"./chunk-W6T7MOKY.js";import{e as P}from"./chunk-2ACBWC7K.js";var w=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ye=class d{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new d;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var ue=class{constructor(e){this.underlying=e;this.repository=new fe(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new D().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],o=await this.buildDocsByIdIndex();for(;t.length>0;){let s=t.shift(),i=o.get(s);if(i?.metadata.imports)for(let[n,l]of Object.entries(i.metadata.imports))for(let a of l){let c=await this.repository.getHighestCompatibleVersionAsync(n,a);if(!c)continue;let p=me(c);!p||r.has(p)||(r.add(p),t.push(p))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let o=me(t);o&&r.set(o,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ie(s))continue;let i=s,n=Oe(i,"type");if(n==="Class"||n?.endsWith(".Class")){let l=Se(i);t.set(o,l)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[o,s]of Object.entries(r.body)){if(!Ie(s))continue;let n=Oe(s,"type");(n==="ObjectProperty"||n?.endsWith(".ObjectProperty")||n==="DatatypeProperty"||n?.endsWith(".DatatypeProperty")||n==="AnnotationProperty"||n?.endsWith(".AnnotationProperty")||n==="Property"||n?.endsWith(".Property"))&&t.add(o)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(me(t)===e)return t}};function me(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}function Ie(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function Oe(d,e){if(e in d)return we(d[e]);for(let r of Object.keys(d))if(r.endsWith(`.${e}`))return we(d[r])}function we(d){return Array.isArray(d)?d.length>0?String(d[0]):void 0:d==null?void 0:String(d)}function Se(d){let e=d.subClassOf;if(e===void 0){for(let r of Object.keys(d))if(r.endsWith(".subClassOf")){e=d[r];break}}return V(e)}var fe=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){let t=`${e}/${r}`,o=this.byNamespaceCache.get(t);return o||(o=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,o),o)}getHighestCompatibleVersionAsync(e,r){let t=r.version,o=t?`${t.major}.${t.minor}.${t.patch}`:"",s=`${e}/${r.packageName}@${r.versionOperator}:${o}`,i=this.highestVersionCache.get(s);return i||(i=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(s,i),i)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var E=class d{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let r=[];for(let[t,o]of Object.entries(e.body))o&&typeof o=="object"&&!Array.isArray(o)&&this.validateEntity(t,o,r);return r}validateEntity(e,r,t){for(let[o,s]of Object.entries(r)){let i=s?.toString()??"";if(i&&d.NAMESPACE_PREFIX_PATTERN.test(i)){let n=this.getSuggestionForPrefixedValue(i),l=e.split(".")[0],a=new g;a.ruleType=this.ruleName,a.severity="Error",a.entityName=l,a.propertyName=e,a.actualValue=o,a.expectedValue=n,a.message=`Invalid namespace prefix '${i}'. Use '${n}' without prefix.`,a.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(a)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validateEntity(`${e}.${o}`,s,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var j=class d{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[o,s]of Object.entries(e.body)){let i=d.VALID_AUGMENTATION_PATTERN.test(o);if(!i&&!t&&d.RESERVED_WORDS.has(o.toLowerCase())){let n=new g;n.ruleType=this.ruleName,n.severity="Error",n.entityName=o,n.message=`Entity name '${o}' is a reserved word and cannot be used.`,n.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(n);continue}if(!i&&!d.VALID_NAME_PATTERN.test(o)){let n;/^\d/.test(o)?n="Entity names must start with a letter, not a number.":o.includes(" ")?n="Entity names cannot contain spaces. Use camelCase or underscores instead.":n="Entity names must start with a letter and contain only letters, numbers, and underscores.";let l=new g;l.ruleType=this.ruleName,l.severity="Error",l.entityName=o,l.message=`Invalid entity name '${o}'. ${n}`,l.suggestion=n,r.push(l)}s&&typeof s=="object"&&!Array.isArray(s)&&this.validatePropertyNames(o,s,r)}return r}validatePropertyNames(e,r,t){for(let o of Object.keys(r))if(!d.VALID_PROPERTIES.has(o)&&!d.VALID_PROPERTY_NAME_PATTERN.test(o)){let s=new g;s.ruleType=this.ruleName,s.severity="Warning",s.entityName=e,s.propertyName=o,s.message=`Property name '${o}' in entity '${e}' doesn't follow naming conventions.`,s.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(s)}}};var $=class d{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[o,s]of Object.entries(e.body))if(s&&typeof s=="object"&&!Array.isArray(s)){let i=s,n=i.type;if(n){let l=[];if(Array.isArray(n))for(let a of n){let c=a?.toString();c&&c==="Property"&&!t&&l.push(c)}else{let a=n?.toString();a&&a==="Property"&&!t&&l.push(a)}for(let a of l){let c=this.getPropertyValue(i,"range"),p=this.determinePropertyType(c),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=o,y.propertyName="type",y.actualValue=a,y.expectedValue=p,y.message=`Invalid property type '${a}'. Use '${p}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":d.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r.type;if(o){let s=o.toString();return s==="Class"||s.endsWith(".Class")}}return!1}};var S=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,o]of Object.entries(e.body)){if(typeof o!="object"||o===null||Array.isArray(o)||t.includes("."))continue;let s=o,i="type"in s,n=s.type?.toString().trim();if(!i||!n){let l=new g;l.ruleType=this.ruleName,l.severity="Error",l.entityName=t,l.propertyName="type",l.message=`Subject Kanonak '${t}' must have a 'type' property.`,l.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.`,l.expectedValue="A valid class name (Scene, Character, Story, etc.)",r.push(l)}}return r}};var C=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,r){let t=[],o=new v(r),s=await this.buildPropertyRangeMap(e,o);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&await this.checkEmbeddedTypes(i,n,void 0,s,o,e,t,0);return t}pickRange(e,r,t){if(e.length===0)return;if(e.length===1)return e[0].range;let o=r.indexOf(".");if(o>0){let s=r.substring(0,o),i=e.find(n=>n.declaringAlias===s);if(i)return i.range}if(t){let s=this.localName(t),i=e.find(n=>this.localName(n.domain)===s);if(i)return i.range}return e[0].range}async checkEmbeddedTypes(e,r,t,o,s,i,n,l){if(l>0){let c=r.type;if(c!=null){let p=await this.validateEmbeddedType(e,String(c),t,s,i);p&&n.push(p)}}let a=r.type!==void 0&&r.type!==null?String(r.type):void 0;for(let[c,p]of Object.entries(r)){let y=this.localName(c),m=o.get(y),f=(m!==void 0?this.pickRange(m,c,a):void 0)??t;if(typeof p=="object"&&p!==null)if(Array.isArray(p))for(let b=0;b<p.length;b++){let h=p[b];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${c}[${b}]`,h,f,o,s,i,n,l+1)}else await this.checkEmbeddedTypes(`${e}.${c}`,p,f,o,s,i,n,l+1)}}async validateEmbeddedType(e,r,t,o,s){if(r.length===0||!t)return null;let i=this.localName(r),n=this.localName(t);if(n==="Resource"||n==="Class")return null;let l=e.split(".")[0];if(i===n){let c=new g;return c.ruleType=this.ruleName,c.severity="Warning",c.entityName=l,c.propertyName=e,c.actualValue=r,c.expectedValue=t,c.message=`Embedded object at '${e}' declares 'type: ${r}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,c.suggestion=`Remove the 'type: ${r}' line, or keep it if explicitness is preferred over concision.`,c}if(await o.isSubclassOfAsync(r,t,s)||(i!==r||n!==t)&&await o.isSubclassOfAsync(i,n,s))return null;let a=new g;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=l,a.propertyName=e,a.actualValue=r,a.expectedValue=t,a.message=`Embedded object at '${e}' has 'type: ${r}', which is not a subclass of the parent property's range '${t}'.`,a.suggestion=`Either remove the 'type: ${r}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${r}' class definition so the relationship holds.`,a}localName(e){let r=e.lastIndexOf(".");return r<0||r===e.length-1?e:e.substring(r+1)}async buildPropertyRangeMap(e,r){let t=new Map,o=await r.buildEntityIndexAsync(e),s=new Map;for(let[i,n]of o){let l=n.entity.type;if(l==null)continue;let a=String(l),c=this.localName(a);if(!(c==="Property"||c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty"))continue;let y=n.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let u=n.entity.domain,f=u!=null?String(u):"",b=n.uri.toString(),h=s.get(b),k=i.includes(".");(!h||k&&!h.entityName.includes("."))&&s.set(b,{entityName:i,domain:f,range:m})}for(let i of s.values()){let n=this.localName(i.entityName),l=i.entityName.indexOf("."),a=l>0?i.entityName.substring(0,l):void 0,c=t.get(n)??[];c.push({domain:i.domain,range:i.range,declaringAlias:a}),t.set(n,c)}return t}};import{VersionOperator as ce}from"@kanonak-protocol/types/document/models/enums";var N=class{ruleName="ImportExistence";async validateAsync(e,r){let t=[];if(!e.metadata?.imports)return t;let o=await r.getAllDocumentsAsync();for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i)if(!await r.getHighestCompatibleVersionAsync(s,n)){let a=await this.determineImportErrorAsync(r,s,n,o),c=new g;c.ruleType=this.ruleName,c.severity="Error",c.message=a.message,c.suggestion=a.suggestion,c.entityName=`Import: ${s}/${n.packageName}`,c.actualValue=n.toString(),c.expectedValue=a.expectedValue,t.push(c)}return t}async determineImportErrorAsync(e,r,t,o){let s=await e.getDocumentsByNamespaceAsync(r,t.packageName);if(s.length===0){let a=o.filter(m=>m.metadata.namespace_?.publisher===r).map(m=>m.metadata.namespace_.package_).filter((m,u,f)=>f.indexOf(m)===u),c=this.findSimilarPackages(t.packageName,a),p=`Import '${r}/${t.package_}' not found - package does not exist`,y=c.length>0?`Did you mean: ${c.slice(0,3).join(", ")}?`:a.length>0?`Available packages in ${r}: ${a.slice(0,5).join(", ")}`:`No packages found for publisher '${r}'. Verify the publisher name is correct.`;return{message:p,suggestion:y,expectedValue:"Existing package"}}let n=s.filter(a=>a.metadata.namespace_?.version).map(a=>a.metadata.namespace_.version.toString()).sort().join(", "),l=this.getAcceptableVersionRange(t);return{message:`Import '${r}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${n}. Required: ${l}`,expectedValue:l}}getAcceptableVersionRange(e){switch(e.versionOperator){case ce.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case ce.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case ce.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case ce.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,r){if(r.length===0)return[];let t=r.filter(i=>i.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(i.toLowerCase()));if(t.length>0)return t.sort((i,n)=>i.length-n.length);let o=r.map(i=>({package:i,distance:this.levenshteinDistance(e.toLowerCase(),i.toLowerCase())})).sort((i,n)=>i.distance-n.distance),s=Math.max(3,Math.floor(e.length*.4));return o.filter(i=>i.distance<=s).map(i=>i.package)}levenshteinDistance(e,r){if(!e||e.length===0)return r?.length??0;if(!r||r.length===0)return e.length;let t=e.length,o=r.length,s=Array(t+1).fill(null).map(()=>Array(o+1).fill(0));for(let i=0;i<=t;i++)s[i][0]=i;for(let i=0;i<=o;i++)s[0][i]=i;for(let i=1;i<=t;i++)for(let n=1;n<=o;n++){let l=e[i-1]===r[n-1]?0:1;s[i][n]=Math.min(Math.min(s[i-1][n]+1,s[i][n-1]+1),s[i-1][n-1]+l)}return s[t][o]}};var K=class{ruleName="UnresolvedReference";async validateAsync(e,r){let t=[],o=new v(r),s=await o.buildEntityIndexAsync(e),i=new Set;for(let[n,l]of s.entries()){let a=l.entity.type;if(a){let c=a.toString();(c==="ObjectProperty"||c.endsWith(".ObjectProperty"))&&i.add(n)}}for(let[n,l]of Object.entries(e.body)){if(!l||typeof l!="object"||Array.isArray(l))continue;let a=l,c=this.getPropertyValue(a,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[p,y]of Object.entries(a))p==="type"||p==="label"||p==="comment"||!(i.has(p)||Array.from(i).some(u=>u.endsWith(`.${p}`)))||await this.validateReferenceValue(n,p,y,e,o,t)}return t}async validateReferenceValue(e,r,t,o,s,i){if(t!=null){if(typeof t=="string")await s.resolveEntityAsync(t,o)||i.push(this.createUnresolvedReferenceError(e,r,t));else if(Array.isArray(t))for(let n=0;n<t.length;n++){let l=t[n];typeof l=="string"&&(await s.resolveEntityAsync(l,o)||i.push(this.createUnresolvedReferenceError(e,`${r}[${n}]`,l)))}}}createUnresolvedReferenceError(e,r,t){let o=`The entity '${t}' cannot be found in the current document or any imported namespaces.
|
|
5
|
-
|
|
6
|
-
Possible solutions:
|
|
7
|
-
\u2022 Add import if the entity is defined in another namespace:
|
|
8
|
-
kanonak namespace add-import <publisher>/<package>@<version>
|
|
9
|
-
\u2022 Check for typos in the reference name '${t}'
|
|
10
|
-
\u2022 Define '${t}' in the current namespace or an appropriate namespace
|
|
11
|
-
\u2022 Use 'kanonak search type ${t} --include-imports' to locate the entity`,s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=r,s.actualValue=t,s.message=`Reference to '${t}' could not be resolved`,s.suggestion=o,s.expectedValue="A valid entity reference that exists in the current document or imported namespaces",s}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}};var T=class{ruleName="ClassHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildClassHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,a=l.type,c=l.subClassOf;if(a?.toString()==="Class"&&c){let p=i,y=this.detectCycle(p,o);if(y){let m=y.join(" \u2192 "),u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Circular class hierarchy detected: ${m}`,u.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",u.entityName=p,u.propertyName="subClassOf",u.actualValue=m,t.push(u);break}}}return t}async buildClassHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,a=l.type,c=l.subClassOf;if(a?.toString()==="Class"&&c){let p=V(c);p.length>0&&t.set(i,p)}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);a&&await this.buildClassHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var x=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,r){let t=[],o=new Map,s=new Set;await this.buildPropertyHierarchy(e,r,o,s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.subPropertyOf){let c=i,p=this.detectCycle(c,o);if(p){let y=p.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=c,m.propertyName="subPropertyOf",m.actualValue=y,t.push(m);break}}return t}async buildPropertyHierarchy(e,r,t,o){let s=e.metadata?.namespace_?.toString()??"";if(!(s&&o.has(s))){s&&o.add(s);for(let[i,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)){let l=n,a=l.type;if(a){let c=a.toString();if(c==="DatatypeProperty"||c==="ObjectProperty"||c==="AnnotationProperty"){let p=l.subPropertyOf;if(p){let y=V(p);y.length>0&&t.set(i,y)}}}}if(e.metadata?.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);a&&await this.buildPropertyHierarchy(a,r,t,o)}}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){if(t.includes(e)){let i=t.indexOf(e),n=t.slice(i);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let s=r.get(e);if(s)for(let i of s){let n=this.detectCycleRecursive(i,r,t,o);if(n)return n}return t.pop(),null}};var _=class{get ruleName(){return"PropertyRangeRequired"}async validateAsync(e,r){let t=[];for(let[o,s]of Object.entries(e.body)){if(typeof s!="object"||s===null||Array.isArray(s))continue;let i=s,n=i.type?.toString();if(n==="DatatypeProperty"||n==="ObjectProperty"||n?.endsWith(".DatatypeProperty")||n?.endsWith(".ObjectProperty")){let l="range"in i,a=i.range?.toString().trim();if(!l||!a){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=o,c.propertyName="range",c.message=`Property '${o}' must have a 'range' defined.`,c.suggestion=n==="DatatypeProperty"?"Add a range like: range: string (or integer, boolean, etc.)":"Add a range like: range: ClassName (the class this property expects)",c.expectedValue=n==="DatatypeProperty"?"A datatype (string, integer, boolean, decimal, etc.)":"A class name (Character, Scene, Story, etc.)",t.push(c)}}}return t}};var L=class{builtInClasses=new Set(["Resource","Class","Datatype","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"SubClassOfReference"}isClassLikeType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=i.type?.toString();this.isClassLikeType(l)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=V(i.subClassOf);for(let a=0;a<l.length;a++){let c=l[a];if(this.builtInClasses.has(c)||o.has(c))continue;if(!await this.isClassAvailableInImports(e,r,c)){let y=l.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Class '${c}' referenced in subClassOf${y} is not defined or imported`,m.suggestion=`Define '${c}' as a Class, or import a namespace that contains it`,m.entityName=s,m.propertyName="subClassOf",m.actualValue=c,m.expectedValue="Defined or imported class",t.push(m)}}}return t}async isClassAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){if(o!==null&&l.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=o!==null?s:t,p=a.body[c];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isClassLikeType(u))return!0}let y=new Set;if(await this.isClassAvailableInImportsRecursive(a,r,c,y))return!0}}return!1}async isClassAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let y=c.type?.toString();if(this.isClassLikeType(y))return!0}if(await this.isClassAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var M=class{builtInProperties=new Set(["type","label","comment","domain","range","subPropertyOf","subClassOf","inverseOf","sameAs","seeAlso","isDefinedBy","functional","required"]);get ruleName(){return"SubPropertyOfReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=i.type?.toString();(l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty")&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=V(i.subPropertyOf);for(let a=0;a<l.length;a++){let c=l[a];if(this.builtInProperties.has(c)||o.has(c))continue;if(!await this.isPropertyAvailableInImports(e,r,c)){let y=l.length>1?`[${a}]`:"",m=new g;m.ruleType=this.ruleName,m.severity="Error",m.message=`Property '${c}' referenced in subPropertyOf${y} is not defined or imported`,m.suggestion=`Define '${c}' as a DatatypeProperty or ObjectProperty, or import a namespace that contains it`,m.entityName=s,m.propertyName="subPropertyOf",m.actualValue=c,m.expectedValue="Defined or imported property",t.push(m)}}}return t}async isPropertyAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){if(o!==null&&l.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=o!==null?s:t,p=a.body[c];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(u==="DatatypeProperty"||u==="ObjectProperty"||u==="AnnotationProperty")return!0}let y=new Set;if(await this.isPropertyAvailableInImportsRecursive(a,r,c,y))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let y=c.type?.toString();if(y==="DatatypeProperty"||y==="ObjectProperty"||y==="AnnotationProperty")return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var U=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,r){let t=[],o=e.metadata.namespace_?.toString();if(!o)return t;let s=new Map,i=new Set;await this.buildImportGraph(e,r,s,i);let n=this.detectCycle(o,s);if(n){let l=n.join(" \u2192 "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`Circular namespace import detected: ${l}`,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=l,t.push(a)}return t}async buildImportGraph(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!(!s||o.has(s))&&(o.add(s),e.metadata.imports)){let i=[];for(let[n,l]of Object.entries(e.metadata.imports))for(let a of l){let c=`${n}/${a.packageName}@${a.version}`;i.push(c);let p=await r.getHighestCompatibleVersionAsync(n,a);p&&await this.buildImportGraph(p,r,t,o)}i.length>0&&t.set(s,i)}}detectCycle(e,r){let t=[],o=new Set;return this.detectCycleRecursive(e,r,t,o)}detectCycleRecursive(e,r,t,o){let s=t.indexOf(e);if(s>=0){let n=t.slice(s);return n.push(e),n}if(o.has(e))return null;t.push(e),o.add(e);let i=r.get(e);if(i)for(let n of i){let l=this.detectCycleRecursive(n,r,t,o);if(l)return l}return t.pop(),null}};var W=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"InstancePropertyReference"}async validateAsync(e,r,t){let o=[],s=new Set,i=t?await this.closurePropertyNamesViaCache(e,t):void 0,n=t?await this.aliasClosurePropertyNamesViaCache(e,t):void 0;for(let[l,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let p=a.type?.toString();this.isPropertyType(p)&&s.add(l)}for(let[l,a]of Object.entries(e.body))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c=a,p=c.type?.toString();if(this.isPropertyType(p)||this.isClassType(p))continue;for(let[y,m]of Object.entries(c)){if(!y||this.metadataKeys.has(y))continue;let u=y,f=null;if(y.includes(".")){let h=y.lastIndexOf(".");f=y.substring(0,h),u=y.substring(h+1)}if(s.has(u))continue;if(!await this.isPropertyAvailable(e,r,u,f,i,n)){let h=new g;h.ruleType=this.ruleName,h.severity="Error",h.message=`Property '${y}' is not defined or imported`,h.suggestion=f?`The property '${u}' is not found in the imported namespace with alias '${f}'.
|
|
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=l,h.propertyName=y,h.actualValue=m?.toString(),h.expectedValue="A defined or imported property",o.push(h)}}}return o}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailable(e,r,t,o,s,i){if(s!==void 0&&i!==void 0){if(o===null)return s.has(t);let n=i.get(o);return n?n.has(t):!1}return await this.isPropertyAvailableInImports(e,r,t,o)}async closurePropertyNamesViaCache(e,r){let t=new Set,o=Ee(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s)if(i!==o)for(let n of await r.getPropertyNames(i))t.add(n);return t}async aliasClosurePropertyNamesViaCache(e,r){let t=new Map;if(!e.metadata.imports)return t;for(let[o,s]of Object.entries(e.metadata.imports))for(let i of s){if(!i.alias)continue;let n=await r.repository.getHighestCompatibleVersionAsync(o,i);if(!n)continue;let l=Ee(n);if(!l)continue;let a=await r.getImportClosure(l),c=t.get(i.alias)??new Set;for(let p of a)for(let y of await r.getPropertyNames(p))c.add(y);t.set(i.alias,c)}return t}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let l=await r.getHighestCompatibleVersionAsync(s,n);if(l){let a=l.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let c=new Set;if(await this.isPropertyAvailableInImportsRecursive(l,r,t,c))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let y=c.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};function Ee(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var H=class{metadataKeys=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","inverseOf","transitive","symmetric","functional","inverseFunctional"]);get ruleName(){return"DefinitionPropertyReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=i.type?.toString();this.isPropertyType(l)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,l=n.type?.toString();if(!this.isPropertyType(l)&&!this.isClassType(l))continue;for(let[a,c]of Object.entries(n)){if(!a||this.metadataKeys.has(a))continue;let p=a,y=null;if(a.includes(".")){let u=a.lastIndexOf(".");y=a.substring(0,u),p=a.substring(u+1)}if(o.has(p))continue;if(!await this.isPropertyAvailableInImports(e,r,p,y)){let u=this.isClassType(l)?"class":"property",f=new g;f.ruleType=this.ruleName,f.severity="Error",f.message=`Property '${a}' used on ${u} '${s}' is not defined or imported`,f.suggestion=y?`The property '${p}' 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`,f.entityName=s,f.propertyName=a,f.actualValue=c?.toString(),f.expectedValue="A defined or imported property",t.push(f)}}}return t}isPropertyType(e){return e?e==="ObjectProperty"||e==="DatatypeProperty"||e==="AnnotationProperty"||e==="Property"||e.endsWith(".ObjectProperty")||e.endsWith(".DatatypeProperty")||e.endsWith(".AnnotationProperty")||e.endsWith(".Property"):!1}isClassType(e){return e?e==="Class"||e.endsWith(".Class"):!1}async isPropertyAvailableInImports(e,r,t,o){if(!e.metadata.imports)return!1;for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){if(o!==null&&n.alias!==o)continue;let l=await r.getHighestCompatibleVersionAsync(s,n);if(l){let a=l.body[t];if(a&&typeof a=="object"&&!Array.isArray(a)){let y=a.type?.toString();if(this.isPropertyType(y))return!0}let c=new Set;if(await this.isPropertyAvailableInImportsRecursive(l,r,t,c))return!0}}return!1}async isPropertyAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let y=c.type?.toString();if(this.isPropertyType(y))return!0}if(await this.isPropertyAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}};var F=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"XsdImport"}async validateAsync(e,r){let t=[],o=new Set,s=[];for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let l=n,a=!1,c=l.type;if(Array.isArray(c)){for(let p of c)if(p?.toString()==="DatatypeProperty"){a=!0;break}}else c?.toString()==="DatatypeProperty"&&(a=!0);if(a){s.push(i);let p=this.getPropertyValue(l,"range");p&&this.xsdTypes.has(p)&&o.add(p)}}if(o.size>0&&!await this.checkXsdImportAsync(e.metadata,r)){let n=Array.from(o).sort().join(", "),l=s.sort().join(", "),a=new g;a.ruleType=this.ruleName,a.severity="Error",a.message=`XSD namespace not imported but XSD types are used: ${n}`,a.suggestion=`Add an XSD import to the imports section. The core XSD types package is 'core-xsd' from publisher 'kanonak.org'. Used by properties: ${l}`,a.entityName="imports",t.push(a)}return t}async checkXsdImportAsync(e,r,t=new Set){if(!e?.imports)return!1;let o=e.namespace_?.toString()??"";if(o&&t.has(o))return!1;o&&t.add(o);for(let[,s]of Object.entries(e.imports))for(let i of s)if(i.packageName==="xsd"||i.packageName.toLowerCase().endsWith("-xsd"))return!0;for(let[s,i]of Object.entries(e.imports))for(let n of i){let l=await r.getHighestCompatibleVersionAsync(s,n);if(l?.metadata&&await this.checkXsdImportAsync(l.metadata,r,t))return!0}return!1}getPropertyValue(e,r){return e[r]?.toString()}};var B=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,r){let t=[],o=await this.buildEntitySourceMapAsync(e,r),s=await this.buildDatatypePropertyNamesAsync(e,r);for(let[i,n]of Object.entries(e.body))typeof n=="object"&&n!==null&&!Array.isArray(n)&&this.validateEntityReferences(i,n,o,s,e,t);return t}async buildEntitySourceMapAsync(e,r){let t=new Map,o=new Set;for(let s of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";t.has(s)||t.set(s,[]),t.get(s).push(`(local:${i})`)}if(e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let l=await r.getHighestCompatibleVersionAsync(s,n);l&&await this.collectEntitiesRecursivelyAsync(l,t,o,r)}return t}async collectEntitiesRecursivelyAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let i of Object.keys(e.body)){r.has(i)||r.set(i,[]);let n=r.get(i);n.includes(s)||n.push(s)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await o.getHighestCompatibleVersionAsync(i,l);a&&await this.collectEntitiesRecursivelyAsync(a,r,t,o)}}}async buildDatatypePropertyNamesAsync(e,r){let t=new Set,o=new Set;if(await this.collectDatatypePropertiesAsync(e,t,o,r),e.metadata.imports)for(let[s,i]of Object.entries(e.metadata.imports))for(let n of i){let l=await r.getHighestCompatibleVersionAsync(s,n);l&&await this.collectDatatypePropertiesAsync(l,t,o,r)}return t}async collectDatatypePropertiesAsync(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(!t.has(s)){t.add(s);for(let[i,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let l=n.type;if(typeof l!="string")continue;(l.includes(".")?l.substring(l.lastIndexOf(".")+1):l)==="DatatypeProperty"&&r.add(i)}if(e.metadata.imports)for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await o.getHighestCompatibleVersionAsync(i,l);a&&await this.collectDatatypePropertiesAsync(a,r,t,o)}}}validateEntityReferences(e,r,t,o,s,i){for(let[n,l]of Object.entries(r)){let a=n;if(a&&!a.includes(".")){let c=t.get(a);if(c&&c.length>1&&!c.some(y=>y.startsWith("(local:"))){let y=c.filter(m=>!m.startsWith("(local:"));y.length>1&&i.push(this.createAmbiguityError(e,a,`Property '${a}'`,y,s,!0,a))}}this.validatePropertyValue(e,a,l,t,o,s,i)}}validatePropertyValue(e,r,t,o,s,i,n){if(t==null)return;let l=r&&r.includes(".")?r.substring(r.lastIndexOf(".")+1):r,a=!!l&&s.has(l);if(typeof t=="string"&&!t.includes(".")&&!a){let c=o.get(t);if(c&&c.length>1&&!c.some(y=>y.startsWith("(local:"))){let y=c.filter(m=>!m.startsWith("(local:"));y.length>1&&n.push(this.createAmbiguityError(e,r,`Reference '${t}'`,y,i,!1,t))}}else if(Array.isArray(t))for(let c=0;c<t.length;c++){let p=`${e}.${r}[${c}]`;this.validatePropertyValue(p,r,t[c],o,s,i,n)}else if(typeof t=="object"&&!Array.isArray(t)){let c=r?`${e}.${r}`:e;this.validateEntityReferences(c,t,o,s,i,n)}}createAmbiguityError(e,r,t,o,s,i,n){let l=[];for(let f of o){let b=this.findAliasForNamespace(s,f);if(b){let h=r?.split(".").pop()??r;l.push(`${b}.${h}`)}}let a=l.length>0?`Use one of: ${l.map(f=>`'${f}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${r}')`,c=o.map(f=>` \u2022 ${f}`).join(`
|
|
24
|
-
`),p=e.split(".")[0],y=e.includes(".")?e:r,m=new g;m.ruleType=this.ruleName,m.severity="Error",m.entityName=p,y&&(m.propertyName=y);let u=n??r;return u&&(m.actualValue=u),m.message=`${t} is ambiguous - defined in multiple imported namespaces`,m.suggestion=`${a}
|
|
25
|
-
|
|
26
|
-
Defined in:
|
|
27
|
-
${c}`,m.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",m}findAliasForNamespace(e,r){if(!e.metadata.imports)return null;for(let[t,o]of Object.entries(e.metadata.imports))for(let s of o)if(`${t}/${s.packageName}@${s.version}`===r&&s.alias)return s.alias;return null}};var q=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]);primitiveTypes=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","dateTime","date","time","duration","anyURI","anySimpleType","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte","base64Binary","hexBinary","Literal","Resource"]);get ruleName(){return"PropertyRangeReference"}async validateAsync(e,r){let t=[],o=new Set;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=i.type?.toString();this.isValidRangeTargetType(l)&&o.add(s)}for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,l=n.type?.toString();if(l!=="DatatypeProperty"&&l!=="ObjectProperty"&&!l?.endsWith(".DatatypeProperty")&&!l?.endsWith(".ObjectProperty"))continue;let a=n.range;if(!a)continue;let c=[];if(Array.isArray(a))for(let p of a){let y=p?.toString();y&&c.push(y)}else{let p=a?.toString();p&&c.push(p)}if(c.length===0)continue;for(let p of c){if(this.primitiveTypes.has(p)||this.builtInClasses.has(p)||o.has(p))continue;if(!await this.isTypeAvailableInImports(e,r,p)){let m=l?.includes("ObjectProperty")?"ObjectProperty":"DatatypeProperty",u=new g;u.ruleType=this.ruleName,u.severity="Error",u.message=`Property '${s}' has range '${p}' which is not defined or imported`,u.suggestion=m==="ObjectProperty"?`For ObjectProperty:
|
|
28
|
-
1. Define '${p}' as a Class in this namespace, OR
|
|
29
|
-
2. Import the namespace that contains '${p}', OR
|
|
30
|
-
3. Use a qualified reference like 'alias.${p}' if already imported with an alias`:`For DatatypeProperty:
|
|
31
|
-
1. Use a primitive type (string, integer, boolean, dateTime, etc.), OR
|
|
32
|
-
2. If '${p}' should be a class, change property type to ObjectProperty`,u.entityName=s,u.propertyName="range",u.actualValue=p,u.expectedValue=m==="ObjectProperty"?"A defined or imported class name":"A primitive type or defined class",t.push(u)}}}return t}async isTypeAvailableInImports(e,r,t){if(!e.metadata.imports)return!1;let o=null,s=t;if(t.includes(".")){let i=t.split(".",2);o=i[0],s=i[1]}for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){if(o!==null&&l.alias!==o)continue;let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=o!==null?s:t,p=a.body[c];if(p&&typeof p=="object"&&!Array.isArray(p)){let u=p.type?.toString();if(this.isValidRangeTargetType(u))return!0}let y=new Set;if(await this.isTypeAvailableInImportsRecursive(a,r,c,y))return!0}}return!1}async isTypeAvailableInImportsRecursive(e,r,t,o){let s=e.metadata.namespace_?.toString()??"";if(s&&o.has(s)||(s&&o.add(s),!e.metadata.imports))return!1;for(let[i,n]of Object.entries(e.metadata.imports))for(let l of n){let a=await r.getHighestCompatibleVersionAsync(i,l);if(a){let c=a.body[t];if(c&&typeof c=="object"&&!Array.isArray(c)){let y=c.type?.toString();if(this.isValidRangeTargetType(y))return!0}if(await this.isTypeAvailableInImportsRecursive(a,r,t,o))return!0}}return!1}isValidRangeTargetType(e){return e?e==="Class"||e.endsWith(".Class")||e==="Datatype"||e.endsWith(".Datatype"):!1}};var X=class{xsdTypes=new Set(["string","integer","boolean","decimal","float","double","date","dateTime","time","duration","anyURI","base64Binary","hexBinary","long","int","short","byte","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger","nonNegativeInteger","normalizedString","token","language","Name","NCName","ENTITY","ENTITIES","IDREF","IDREFS","NMTOKEN","NMTOKENS"]);get ruleName(){return"ObjectPropertyImport"}async validateAsync(e,r){let t=[],o=new Map,s=new v(r);await s.buildEntityIndexAsync(e);for(let[i,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let l=n,a=!1,c=l.type;if(Array.isArray(c)){for(let p of c)if(p?.toString()==="ObjectProperty"){a=!0;break}}else c?.toString()==="ObjectProperty"&&(a=!0);if(a){let p=l.range,y=[];if(Array.isArray(p))for(let m of p){let u=m?.toString();u&&y.push(u)}else{let m=p?.toString();m&&y.push(m)}for(let m of y)this.xsdTypes.has(m)||(o.has(m)||o.set(m,[]),o.get(m).push(i))}}for(let[i,n]of o)if(!await s.resolveEntityAsync(i,e))for(let a of n){let c=new g;c.ruleType=this.ruleName,c.severity="Warning",c.message=`ObjectProperty references class '${i}' which may not be imported`,c.suggestion=`Ensure the namespace containing '${i}' is imported, or define '${i}' in this document`,c.entityName=a,c.propertyName="range",c.actualValue=i,t.push(c)}return t}};var z=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"ObjectPropertyValue"}async validateAsync(e,r){let t=[],o=new v(r),s=new Pe(o),i=await o.buildEntityIndexAsync(e),n=await this.buildPropertyMetadataAsync(e,r,o,i);for(let[l,a]of Object.entries(e.body))typeof a=="object"&&a!==null&&!Array.isArray(a)&&await this.scanEntityForObjectProperties(a,l,"",n,o,s,e,t);return t}async scanEntityForObjectProperties(e,r,t,o,s,i,n,l){for(let[a,c]of Object.entries(e)){if(this.standardProperties.has(a))continue;let p,y=await s.resolveEntityAsync(a,n);if(y?.uri){let m=`${y.uri.publisher}/${y.uri.package_}/${y.uri.name}`;p=o.get(m)}if(!p){let m=a,u=a.lastIndexOf(".");u>0&&u<a.length-1&&(m=a.substring(u+1)),p=o.get(m)}if(p&&i.isEffectiveObjectProperty(p.propertyType,p.rangeUri)){let u=t?`${t}.${a}`:a;if(typeof c=="string"&&c.trim().length>0){let f=c.trim();if(f.includes(",")){let h=f.split(",").map(k=>k.trim()).filter(k=>k.length>0);l.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' has a comma-separated string value, but ObjectProperty expects a list of references`,suggestion:`Use YAML list format:
|
|
33
|
-
${a}:
|
|
34
|
-
- ${h[0]}
|
|
35
|
-
${h.slice(1).map(k=>` - ${k}`).join(`
|
|
36
|
-
`)}`,entityName:r,propertyName:a,propertyPath:u,actualValue:f,expectedValue:`A single reference to ${p.range??"an entity"} OR a YAML list`});continue}let b=await s.resolveEntityAsync(f,n);if(b)p.range&&(await this.validateRangeType(b,p.range,s,n)||l.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${p.range}, but '${f}' may not be a ${p.range}`,suggestion:`Ensure '${f}' is defined with appropriate type`,entityName:r,propertyName:a,propertyPath:u,actualValue:f,expectedValue:p.range}));else{let h=p.range??"entity";l.push({ruleType:this.ruleName,severity:"Error",message:`Property '${a}' references '${f}' which is not defined or imported`,suggestion:`Define '${f}' or import a namespace that contains it. Expected range: ${h}`,entityName:r,propertyName:a,propertyPath:u,actualValue:f,expectedValue:"Defined or imported entity"})}}else if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let f=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(c,r,f,o,s,i,n,l)}else if(Array.isArray(c))for(let f=0;f<c.length;f++){let b=c[f];if(typeof b=="string"&&b.trim().length>0){let h=b.trim(),k=await s.resolveEntityAsync(h,n);if(k){if(p.range&&!await this.validateRangeType(k,p.range,s,n)){let pe=t?`${t}.${a}[${f}]`:`${a}[${f}]`;l.push({ruleType:this.ruleName,severity:"Warning",message:`Property '${a}' expects a ${p.range}, but '${h}' may not be a ${p.range}`,suggestion:`Ensure '${h}' is defined with appropriate type`,entityName:r,propertyName:`${a}[${f}]`,propertyPath:pe,actualValue:h,expectedValue:p.range})}}else{let ge=p.range??"entity",pe=t?`${t}.${a}[${f}]`:`${a}[${f}]`;l.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: ${ge}`,entityName:r,propertyName:`${a}[${f}]`,propertyPath:pe,actualValue:h,expectedValue:"Defined or imported entity"})}}else if(typeof b=="object"&&b!==null&&!Array.isArray(b)){let h=t?`${t}.${a}[${f}]`:`${a}[${f}]`;await this.scanEntityForObjectProperties(b,r,h,o,s,i,n,l)}}}if(typeof c=="object"&&c!==null&&!Array.isArray(c)&&!o.has(a)){let m=t?`${t}.${a}`:a;await this.scanEntityForObjectProperties(c,r,m,o,s,i,n,l)}else if(Array.isArray(c))for(let m=0;m<c.length;m++){let u=c[m];if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let f=t?`${t}.${a}[${m}]`:`${a}[${m}]`;await this.scanEntityForObjectProperties(u,r,f,o,s,i,n,l)}}}}async validateRangeType(e,r,t,o){if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty","Class","Resource"]).has(r))return!0;let i=e.entity.type;if(i){let n=[];if(Array.isArray(i))for(let l of i){let a=l?.toString();a&&a.trim().length>0&&n.push(a)}else{let l=i?.toString();l&&l.trim().length>0&&n.push(l)}for(let l of n){let a=l.includes(".")?l.split(".")[1]:l;if(a===r||r==="Property"&&(a==="DatatypeProperty"||a==="ObjectProperty"||a==="AnnotationProperty")||r==="Class"&&a==="Class"||await t.isSubclassOfAsync(l,r,o))return!0}}return!1}async buildPropertyMetadataAsync(e,r,t,o){let s=new Map;for(let[i,n]of o){let l=n.entity.type;if(l){let a=[];if(Array.isArray(l))for(let y of l){let m=y?.toString();m&&m.trim().length>0&&a.push(m)}else{let y=l?.toString();y&&y.trim().length>0&&a.push(y)}let c=!1,p="Property";for(let y of a){let m=y.includes(".")?y.split(".")[1]:y;if(m==="Property"||m==="DatatypeProperty"||m==="ObjectProperty"||m==="AnnotationProperty"){c=!0,p=y;break}}if(c){let y={propertyType:p},m=n.entity.range;if(m){let u=m?.toString();if(u&&u.trim().length>0){y.range=u;let f=await t.resolveEntityAsync(u,e);f&&(y.rangeUri=f.uri)}}if(s.set(i,y),n.uri){let u=`${n.uri.publisher}/${n.uri.package_}/${n.uri.name}`;s.set(u,y)}}}}return s}};var Y=class{standardProperties=new Set(["type","label","comment","subClassOf","domain","range","subPropertyOf","inverseOf","sameAs","seeAlso","isDefinedBy"]);get ruleName(){return"PropertyDomain"}async validateAsync(e,r,t){let o=[],s=new Map;for(let[n,l]of Object.entries(e.body))if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let a=l,c=this.getPropertyValue(a,"type");(c==="DatatypeProperty"||c?.endsWith(".DatatypeProperty")||c==="ObjectProperty"||c?.endsWith(".ObjectProperty")||c==="AnnotationProperty"||c?.endsWith(".AnnotationProperty"))&&s.set(n,a)}let i=t?await this.buildClassHierarchyViaCache(e,t):await this.buildCompleteClassHierarchyAsync(e,r);for(let[n,l]of Object.entries(e.body))if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let a=l,c=this.getPropertyValue(a,"type");if(!c||c==="Class"||c.endsWith(".Class")||c.endsWith("Property")||c==="AnnotationProperty")continue;this.validateEntityProperties(a,n,c,s,i,o)}return o}async buildClassHierarchyViaCache(e,r){let t=new Map,o=Ce(e);if(!o)return t;let s=await r.getImportClosure(o);for(let i of s){let n=await r.getClassDeclarations(i);for(let[l,a]of n)a.length>0&&t.set(l,a)}return t}async buildCompleteClassHierarchyAsync(e,r){let t=new Map,o=new Set,s=async(n,l)=>{if(!o.has(l)){o.add(l);for(let[a,c]of Object.entries(n.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let p=c,y=this.getPropertyValue(p,"type");if(y==="Class"||y?.endsWith(".Class")){let m=p.subClassOf;if(m===void 0){for(let f of Object.keys(p))if(f.endsWith(".subClassOf")){m=p[f];break}}let u=V(m);u.length>0&&t.set(a,u)}}if(n.metadata.imports)for(let[a,c]of Object.entries(n.metadata.imports))for(let p of c)try{let y=await r.getHighestCompatibleVersionAsync(a,p);if(y){let m=`${a}/${p.packageName}@${p.version}`;await s(y,m)}}catch{}}},i=e.metadata.namespace_?.toString()??"unknown";return await s(e,i),t}validateEntityProperties(e,r,t,o,s,i){for(let[n,l]of Object.entries(e)){if(this.standardProperties.has(n))continue;let a=n,c=n.lastIndexOf(".");c>0&&c<n.length-1&&(a=n.substring(c+1));let p=o.get(a);if(!p)continue;let y=this.getPropertyValue(p,"domain");if(y){if(!this.isTypeCompatibleWithDomain(t,y,s)){let m=r.split(".")[0];i.push({ruleType:this.ruleName,severity:"Error",entityName:m,propertyName:r,actualValue:n,message:`Property '${n}' has domain '${y}' but is used on '${t}' at '${r}'`,suggestion:`Either:
|
|
37
|
-
1. Use this property only on '${y}' instances
|
|
38
|
-
2. Change the property domain to include '${t}'
|
|
39
|
-
3. Create a different property for '${t}'`,expectedValue:`Property used on ${y} or its subclasses`})}if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let m=l,u=this.getPropertyValue(m,"type");if(u){let f=`${r}.${n}`;this.validateEntityProperties(m,f,u,o,s,i)}else{let f=this.getPropertyValue(p,"range");if(f){let b=`${r}.${n}`;this.validateEntityProperties(m,b,f,o,s,i)}}}else if(Array.isArray(l))for(let m=0;m<l.length;m++){let u=l[m];if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let f=u,b=this.getPropertyValue(f,"type");if(b){let h=`${r}.${n}[${m}]`;this.validateEntityProperties(f,h,b,o,s,i)}else{let h=this.getPropertyValue(p,"range");if(h){let k=`${r}.${n}[${m}]`;this.validateEntityProperties(f,k,h,o,s,i)}}}}}}}isTypeCompatibleWithDomain(e,r,t){if(e===r)return!0;let o=new Set,s=[e];for(;s.length>0;){let i=s.shift();if(o.has(i))continue;o.add(i);let n=t.get(i);if(n)for(let l of n){if(l===r)return!0;s.push(l)}}return!1}getPropertyValue(e,r){if(r in e){let t=e[r];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${r}`)){let o=e[t];return this.extractFirstValue(o)}}extractFirstValue(e){if(Array.isArray(e)){let r=[];for(let t of e)r.push(t?.toString()??"");return r.length>0?r[0]:void 0}return e?.toString()}};function Ce(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var Z=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,r){let t=[],o=new Map;for(let[s,i]of Object.entries(e.body))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let n=i,l=this.getPropertyValue(n,"type");(l==="DatatypeProperty"||l==="ObjectProperty")&&o.set(s,n)}for(let[s,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let n=i,l=this.getPropertyValue(n,"type");if(!(!l||l==="Class"||l.endsWith("Property")||l==="AnnotationProperty"))for(let[a,c]of Object.entries(n)){if(a==="type"||a==="label"||a==="comment")continue;let p=a,y=a.lastIndexOf(".");y>0&&y<a.length-1&&(p=a.substring(y+1));let m=o.get(p);if(!m)continue;let u=this.getPropertyValue(m,"type"),f=this.getPropertyValue(m,"range");if(u==="DatatypeProperty"){if(typeof c=="object"&&c!==null&&!Array.isArray(c)||Array.isArray(c))t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' is a DatatypeProperty with range '${f}' but instance '${s}' has a complex object value`,suggestion:`Either:
|
|
40
|
-
1. Create a class for this data and change '${a}' to an ObjectProperty
|
|
41
|
-
2. Store as a JSON string to keep it as DatatypeProperty
|
|
42
|
-
3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${f}'`});else if(!this.validateDatatypeValue(f,c)){let b={ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`Property '${a}' expects type '${f}' but instance '${s}' has value of type '${this.getValueTypeName(c)}'`,suggestion:`Provide a value of type '${f}'`,toString:()=>""};f&&(b.expectedValue=f),t.push(b)}}else if(u==="ObjectProperty")if(Array.isArray(c))for(let b=0;b<c.length;b++){let h=c[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 c!="string"&&(typeof c!="object"||c===null||Array.isArray(c))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:s,propertyName:a,message:`ObjectProperty '${a}' in instance '${s}' has invalid value type '${this.getValueTypeName(c)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${f} or embedded ${f} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let o=[];for(let s of t)o.push(s?.toString()??"");return o.length>0?o[0]:void 0}return t?.toString()}}};var G=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],o=new Map,s=new Set;for(let[n,l]of Object.entries(e.body))if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let c=l.type;if(c)if(Array.isArray(c))for(let p of c){let y=p?.toString();if(y==="Class"||y&&y.endsWith(".Class")){s.add(n);break}}else{let p=c?.toString();(p==="Class"||p&&p.endsWith(".Class"))&&s.add(n)}}for(let[n,l]of Object.entries(e.body))if(typeof l=="object"&&l!==null&&!Array.isArray(l)){let a=l,c=a.type;if(c)if(Array.isArray(c)){let p=!1;for(let y of c){let m=y?.toString();if(m&&this.isDefinitionType(m)){p=!0;break}}if(!p)for(let y of c){let m=y?.toString();m&&m.trim().length>0&&(o.has(m)||o.set(m,[]),o.get(m).push(n))}}else{let p=c?.toString();p&&p.trim().length>0&&(this.isDefinitionType(p)||(o.has(p)||o.set(p,[]),o.get(p).push(n)))}this.checkNestedTypes(a,n,o,n)}let i=new v(r);for(let[n,l]of o){if(this.builtInClasses.has(n)||s.has(n))continue;let a=await i.resolveEntityAsync(n,e);if(!(a&&this.isClassEntity(a.entity))){let p=Array.from(new Set(l)).sort();for(let y of p)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${n}' is not defined or imported`,suggestion:`Define '${n}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:n,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,o){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=e,i=s.type;if(i){let n=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(i))for(let l of i){let a=l?.toString();a&&a.trim().length>0&&!n.has(a)&&(t.has(a)||t.set(a,[]),t.get(a).push(o))}else{let l=i?.toString();l&&l.trim().length>0&&!n.has(l)&&(t.has(l)||t.set(l,[]),t.get(l).push(o))}}for(let[n,l]of Object.entries(s))if(n!=="type"){let a=`${o}.${n}`;this.checkNestedTypes(l,r,t,a)}}else if(Array.isArray(e))for(let s=0;s<e.length;s++){let i=`${o}[${s}]`;this.checkNestedTypes(e[s],r,t,i)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let o=t?.toString();if(o==="Class"||o&&o.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var J=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let o=[],s;if(t){let i=await t.getKanonaks(),n=Ne(e);s=n?i.filter(l=>l instanceof I&&l.namespace===n):[]}else{let i=new O(e,r);s=await new D().parseKanonaks(i)}for(let i of s)i instanceof I&&this.checkDefined(i,i.name,o);return o}checkDefined(e,r,t){for(let o of e.statement)if(o instanceof ke){let s=o.predicate.subject?.name??"(unknown)";for(let i of o.links)i.target||t.push(this.unresolvedLinkError(r,s,i.reference));for(let i of Ve(o.object))t.push(this.malformedLinkError(r,s,i.snippet))}else if(o instanceof be)this.checkDefined(o.object,r,t);else if(o instanceof Re)for(let s of o.object)s instanceof ee&&this.checkDefined(s,r,t)}unresolvedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,o.expectedValue="A reference resolvable through the document's import closure",o.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
43
|
-
|
|
44
|
-
Possible solutions:
|
|
45
|
-
\u2022 Import the package that defines '${t}' so the link can resolve
|
|
46
|
-
\u2022 Check for typos in the reference name
|
|
47
|
-
\u2022 If the name collides across imports, alias-qualify it: [[alias.${t}]]`,o}malformedLinkError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`Malformed embedded reference near '${t}' in '${r}'`,o.expectedValue="A single-line [[reference]] with no internal line break",o.suggestion=`A '[[' in '${r}' does not form a complete [[reference]] link.
|
|
48
|
-
|
|
49
|
-
A reference may not span a line break \u2014 the most common cause is wrapping a
|
|
50
|
-
long reference across two lines in a block scalar, e.g.:
|
|
51
|
-
... read for [[persistent-energy-
|
|
52
|
-
shock]] held ...
|
|
53
|
-
which is parsed as literal text, not a link. Keep each [[reference]] on one
|
|
54
|
-
line (let the line run long), or check for an unterminated [[.`,o}};function Ne(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var je="kanonak.org",$e="look",Ke={publisher:je,package_:$e,name:"displayLabel"},Te={publisher:je,package_:$e,name:"displaySummary"},Q=class{ruleName="DisplayLensScope";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new D().parseKanonaks(new O(e,r));let i=xe(e);if(!i)return o;for(let n of s)n instanceof I&&n.namespace===i&&(this.checkLens(s,n,Ke,"displayLabel",o),this.checkLens(s,n,Te,"displaySummary",o));return o}checkLens(e,r,t,o,s){let i=ie(r,t);if(!i)return;let n=[],l=ae(r);if(l&&n.push(l),n.push(...Ae(r)),n.length===0)return;n.some(c=>le(e,c,i).ok)||s.push(this.scopeError(r.name,o,i.name))}scopeError(e,r,t){let o=new g;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName=r,o.actualValue=t,o.message=`${r} points at '${t}', which is not a property in scope for '${e}'`,o.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",o.suggestion=`'${t}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
|
|
55
|
-
|
|
56
|
-
Possible solutions:
|
|
57
|
-
\u2022 Point ${r} at a property declared on this class (or an ancestor / rdfs.Resource)
|
|
58
|
-
\u2022 Set the property's domain to this class if it should apply here
|
|
59
|
-
\u2022 Use rdfs.label / rdfs.comment for the universal default`,o}};function xe(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var re="kanonak.org",oe="look",_e={publisher:re,package_:oe,name:"semanticSvg"},Le={publisher:re,package_:oe,name:"tierChip"},Me={publisher:re,package_:oe,name:"tierIcon"},Ue={publisher:re,package_:oe,name:"tierCard"},We={publisher:re,package_:oe,name:"tierFull"},He=[Le,Me,Ue,We],te=class{ruleName="LookSemanticSvgPath";async validateAsync(e,r,t){let o=[],s;t?s=await t.getKanonaks():s=await new D().parseKanonaks(new O(e,r));let i=Fe(e);if(!i)return o;for(let n of s)n instanceof I&&n.namespace===i&&this.checkSemanticSvg(s,n,o);return o}checkSemanticSvg(e,r,t){let o=se(r,_e);if(!o)return;let s=ae(r);if(s)for(let i of He){let n=se(o,i);n&&this.walkExpression(e,s,r.name,i.name,n,t)}}walkExpression(e,r,t,o,s,i){if(ne(s,A.PropertyRead)&&this.checkPropertyRead(e,r,t,o,s,i),ne(s,A.Concat)){for(let n of De(s,A.parts))n instanceof ee&&this.walkExpression(e,r,t,o,n,i);return}for(let n of s.statement){let l=n.object;l instanceof ee&&this.walkExpression(e,r,t,o,l,i)}}checkPropertyRead(e,r,t,o,s,i){let n=se(s,A.readSource);if(!n||!ne(n,A.VarRef)||ve(n,A.varName)!=="input")return;let a=ie(s,A.readProp);if(!a||le(e,r,a).ok)return;let p=new g;p.ruleType=this.ruleName,p.severity="Error",p.entityName=t,p.propertyName=`look.semanticSvg.${o}`,p.actualValue=`${a.publisher}/${a.package_}/${a.name}`,p.message=`tx.PropertyRead reads property '${a.name}' off the rendered instance, but its domain is not in scope for '${t}' (the class this SemanticSvg is declared on). The read would silently return undefined at render time.`,p.expectedValue=`A property whose domain is '${t}', an ancestor, or rdfs.Resource`,p.suggestion=`Property '${a.publisher}/${a.package_}/${a.name}' resolves, but its domain does not cover '${t}'.
|
|
60
|
-
|
|
61
|
-
Possible solutions:
|
|
62
|
-
\u2022 Read a property declared on '${t}' (or an ancestor / rdfs.Resource)
|
|
63
|
-
\u2022 If the property should apply to '${t}', adjust its domain
|
|
64
|
-
\u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i.push(p)}};function Fe(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${P(e.version)}`}var de=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new he,this.documentRules=[new E,new j,new $,new S],this.repositoryRules=[new C,new N,new K,new T,new x,new _,new L,new M,new U,new W,new H,new F,new B,new q,new X,new z,new Y,new Z,new G,new J,new Q,new te]}async validateAsync(e,r,t){let o=new w;for(let s of this.documentRules)try{let i=s.validate(e);this.addErrorsToResult(o,i)}catch(i){let n=new g;n.ruleType=s.ruleName,n.severity="Error",n.message=`Validation rule '${s.ruleName}' failed: ${i instanceof Error?i.message:String(i)}`,o.errors.push(n)}if(r){let s=[],i=t?.repository??r;for(let n of this.repositoryRules)try{let l=await n.validateAsync(e,i,t);this.addErrorsToResult(o,l)}catch(l){let a=l instanceof Error?l.message:String(l);s.push({ruleName:n.ruleName,cause:a})}if(s.length>0){let n=new Map;for(let{ruleName:l,cause:a}of s){let c=n.get(a);c?c.push(l):n.set(a,[l])}for(let[l,a]of n){let c=new g;c.ruleType=a[0],c.severity="Error",a.length===1?c.message=`Validation rule '${a[0]}' failed: ${l}`:c.message=`${l} (affects ${a.length} rules: ${a.join(", ")})`,o.errors.push(c)}}}return o.isValid=o.errors.length===0,o}async validateYamlAsync(e,r,t){let o=this.parser.parseWithErrors(e);if(!o.isValid){let s=new w;s.isValid=!1;for(let i of o.errors){let n=new g;n.ruleType="ParseError",n.severity="Error",n.lineNumber=i.line,n.column=i.column,n.message=i.message,i.keyName&&(n.entityName=i.keyName),i.errorType==="DuplicateKey"&&(n.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),s.errors.push(n)}return s}return await this.validateAsync(o.document,r,t)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let r=this.documentRules.findIndex(t=>t instanceof e);r>=0&&this.documentRules.splice(r,1)}removeRepositoryRule(e){let r=this.repositoryRules.findIndex(t=>t instanceof e);r>=0&&this.repositoryRules.splice(r,1)}addErrorsToResult(e,r){for(let t of r)t.severity==="Error"?e.errors.push(t):this.includeWarnings&&e.warnings.push(t)}};export{w as a,R as b,g as c,ye as d,ue as e,E as f,j as g,$ as h,S as i,C as j,N as k,K as l,T as m,x as n,_ as o,L as p,M as q,U as r,W as s,H as t,F as u,B as v,q as w,X as x,z as y,Y as z,Z as A,G as B,J as C,Q as D,de as E};
|