@kanonak-protocol/types 1.1.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/README.md +33 -0
- package/dist/ctl/models/enums.d.ts +58 -0
- package/dist/ctl/models/enums.js +1 -0
- package/dist/ctl/models/types.d.ts +169 -0
- package/dist/ctl/models/types.js +0 -0
- package/dist/ctl/parsing/enums.d.ts +38 -0
- package/dist/ctl/parsing/enums.js +1 -0
- package/dist/ctl/parsing/types.d.ts +89 -0
- package/dist/ctl/parsing/types.js +0 -0
- package/dist/ctl/rendering/types.d.ts +39 -0
- package/dist/ctl/rendering/types.js +0 -0
- package/dist/ctl/resolution/enums.d.ts +34 -0
- package/dist/ctl/resolution/enums.js +1 -0
- package/dist/ctl/resolution/types.d.ts +156 -0
- package/dist/ctl/resolution/types.js +0 -0
- package/dist/ctl/validation/types.d.ts +10 -0
- package/dist/ctl/validation/types.js +0 -0
- package/dist/document/constants/types.d.ts +5 -0
- package/dist/document/constants/types.js +0 -0
- package/dist/document/filtering/index.d.ts +13 -0
- package/dist/document/filtering/index.js +0 -0
- package/dist/document/filtering/types.d.ts +14 -0
- package/dist/document/filtering/types.js +0 -0
- package/dist/document/models/enums.d.ts +21 -0
- package/dist/document/models/enums.js +1 -0
- package/dist/document/models/index.d.ts +47 -0
- package/dist/document/models/index.js +1 -0
- package/dist/document/models/types.d.ts +194 -0
- package/dist/document/models/types.js +0 -0
- package/dist/document/parsing/index.d.ts +19 -0
- package/dist/document/parsing/index.js +1 -0
- package/dist/document/parsing/types.d.ts +10 -0
- package/dist/document/parsing/types.js +0 -0
- package/dist/document/repositories/enums.d.ts +17 -0
- package/dist/document/repositories/enums.js +1 -0
- package/dist/document/repositories/types.d.ts +103 -0
- package/dist/document/repositories/types.js +0 -0
- package/dist/document/storage/index.d.ts +25 -0
- package/dist/document/storage/index.js +0 -0
- package/dist/document/storage/types.d.ts +5 -0
- package/dist/document/storage/types.js +0 -0
- package/dist/exporters/ctl/markdown/types.d.ts +10 -0
- package/dist/exporters/ctl/markdown/types.js +0 -0
- package/dist/object/kanonaks/types.d.ts +17 -0
- package/dist/object/kanonaks/types.js +0 -0
- package/dist/object/parsing/index.d.ts +21 -0
- package/dist/object/parsing/index.js +1 -0
- package/dist/object/parsing/types.d.ts +43 -0
- package/dist/object/parsing/types.js +0 -0
- package/dist/object/resolution/types.d.ts +116 -0
- package/dist/object/resolution/types.js +0 -0
- package/dist/object/statements/index.d.ts +2 -0
- package/dist/object/statements/index.js +0 -0
- package/dist/object/statements/types.d.ts +20 -0
- package/dist/object/statements/types.js +0 -0
- package/dist/object/uris/types.d.ts +17 -0
- package/dist/object/uris/types.js +0 -0
- package/dist/object/validation/enums.d.ts +13 -0
- package/dist/object/validation/enums.js +1 -0
- package/dist/object/validation/index.d.ts +19 -0
- package/dist/object/validation/index.js +1 -0
- package/dist/object/validation/rules/document/index.d.ts +17 -0
- package/dist/object/validation/rules/document/index.js +1 -0
- package/dist/object/validation/rules/document/types.d.ts +52 -0
- package/dist/object/validation/rules/document/types.js +0 -0
- package/dist/object/validation/rules/repository/index.d.ts +19 -0
- package/dist/object/validation/rules/repository/index.js +1 -0
- package/dist/object/validation/rules/repository/types.d.ts +148 -0
- package/dist/object/validation/rules/repository/types.js +0 -0
- package/dist/object/validation/types.d.ts +134 -0
- package/dist/object/validation/types.js +0 -0
- package/dist/registry/models/types.d.ts +253 -0
- package/dist/registry/models/types.js +0 -0
- package/dist/registry/oauth/types.d.ts +192 -0
- package/dist/registry/oauth/types.js +0 -0
- package/dist/registry/providers/enums.d.ts +8 -0
- package/dist/registry/providers/enums.js +1 -0
- package/dist/registry/providers/git/types.d.ts +43 -0
- package/dist/registry/providers/git/types.js +0 -0
- package/dist/registry/providers/github/models/types.d.ts +35 -0
- package/dist/registry/providers/github/models/types.js +0 -0
- package/dist/registry/providers/github/types.d.ts +30 -0
- package/dist/registry/providers/github/types.js +0 -0
- package/dist/registry/providers/index.d.ts +29 -0
- package/dist/registry/providers/index.js +0 -0
- package/dist/registry/providers/oci/types.d.ts +17 -0
- package/dist/registry/providers/oci/types.js +0 -0
- package/dist/registry/providers/types.d.ts +15 -0
- package/dist/registry/providers/types.js +0 -0
- package/dist/registry/services/index.d.ts +9 -0
- package/dist/registry/services/index.js +0 -0
- package/dist/registry/services/types.d.ts +153 -0
- package/dist/registry/services/types.js +0 -0
- package/package.json +177 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { KanonakDocument, Version } from '../../document/models/types';
|
|
2
|
+
import { KanonakUri } from '../../object/uris/types';
|
|
3
|
+
/**
|
|
4
|
+
* Builds KanonakUri instances from resource names, handling alias resolution and version resolution through imports.
|
|
5
|
+
*/
|
|
6
|
+
export interface KanonakUriBuilder {
|
|
7
|
+
/**
|
|
8
|
+
* Builds a KanonakUri from a resource name, resolving aliases and versions
|
|
9
|
+
*/
|
|
10
|
+
buildFromNameAsync(resourceName: string, currentDocument: KanonakDocument): Promise<KanonakUri | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Builds a KanonakUri from a resource name using a pre-built resource index
|
|
13
|
+
*/
|
|
14
|
+
buildFromName(resourceName: string, resourceIndex: Record<string, ResourceResolutionResult>, currentDocument: KanonakDocument): KanonakUri | null;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a KanonakUri directly from known components (for when resource is already resolved)
|
|
17
|
+
*/
|
|
18
|
+
create(publisher: string, package_: string, name: string, version?: Version | null): KanonakUri;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of resolving a resource across namespace boundaries
|
|
22
|
+
*/
|
|
23
|
+
export interface ResourceResolutionResult {
|
|
24
|
+
/**
|
|
25
|
+
* Name of the resource
|
|
26
|
+
*/
|
|
27
|
+
resourceName: string;
|
|
28
|
+
/**
|
|
29
|
+
* Full Kanonak URI identifying this resource uniquely
|
|
30
|
+
*/
|
|
31
|
+
uri: KanonakUri;
|
|
32
|
+
/**
|
|
33
|
+
* The actual resource dictionary from the YAML document
|
|
34
|
+
*/
|
|
35
|
+
resource: Map<any, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Full namespace where this resource is defined (e.g., "healthcare.org/clinical@1.0.0")
|
|
38
|
+
*/
|
|
39
|
+
definedInNamespace: string;
|
|
40
|
+
/**
|
|
41
|
+
* True if this resource was found in an imported namespace (vs the current document)
|
|
42
|
+
*/
|
|
43
|
+
isImported: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Import chain showing how we got to this resource (for debugging/education) Example: "example.com/app@1.0.0 → healthcare.org/clinical@1.0.0"
|
|
46
|
+
*/
|
|
47
|
+
importPath?: string | null | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves resources across namespace boundaries by following import chains transitively. Provides robust type checking that works across imported ontologies. Core component of the Kanonak.Object ontology engine - used by parser, validator, and all clients.
|
|
51
|
+
*/
|
|
52
|
+
export interface ResourceResolver {
|
|
53
|
+
/**
|
|
54
|
+
* Finds a resource in the current document or any transitively imported documents
|
|
55
|
+
*/
|
|
56
|
+
resolveResourceAsync(resourceName: string, currentDocument: KanonakDocument): Promise<ResourceResolutionResult | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Finds ALL matching resources across all namespaces (supports ambiguity detection and multi-definition navigation)
|
|
59
|
+
*/
|
|
60
|
+
resolveAllResourcesAsync(resourceName: string, currentDocument: KanonakDocument): Promise<Array<ResourceResolutionResult>>;
|
|
61
|
+
/**
|
|
62
|
+
* Builds a complete resource index from current document and all transitive imports
|
|
63
|
+
*/
|
|
64
|
+
buildResourceIndexAsync(document: KanonakDocument): Promise<Record<string, ResourceResolutionResult>>;
|
|
65
|
+
/** C# method 'ClearCache' has 2 overloads. Using overload with most parameters. */
|
|
66
|
+
/**
|
|
67
|
+
* Clears cache for a specific document.
|
|
68
|
+
*/
|
|
69
|
+
clearCache(documentKey: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a class is a subclass of another class (direct or transitive)
|
|
72
|
+
*/
|
|
73
|
+
isSubclassOfAsync(className: string, parentClassName: string, document: KanonakDocument): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a property is a subproperty of another property (direct or transitive)
|
|
76
|
+
*/
|
|
77
|
+
isSubpropertyOfAsync(propertyName: string, parentPropertyName: string, document: KanonakDocument): Promise<boolean>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Classifies Kanonak resources by their semantic type (Class, Property, Instance, etc.). This is the canonical source of truth for resource type classification. Uses resolved KanonakUri, NOT document-scoped aliases.
|
|
81
|
+
*/
|
|
82
|
+
export interface ResourceTypeClassifier {
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolves and validates types in Kanonak ontologies. Determines if a type is a datatype vs class, validates type references.
|
|
86
|
+
*/
|
|
87
|
+
export interface TypeResolver {
|
|
88
|
+
/**
|
|
89
|
+
* Checks if a KanonakUri refers to an XSD datatype
|
|
90
|
+
*/
|
|
91
|
+
isXsdDatatype(uri: KanonakUri | null): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if a KanonakUri refers to rdfs:Literal (the superclass of all literal datatypes)
|
|
94
|
+
*/
|
|
95
|
+
isLiteralType(uri: KanonakUri | null): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Checks if a type name refers to a known XSD datatype (string name check)
|
|
98
|
+
*/
|
|
99
|
+
isKnownXsdDatatypeName(typeName: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a type name refers to a class (vs a datatype)
|
|
102
|
+
*/
|
|
103
|
+
isClassTypeAsync(typeName: string, currentDocument: KanonakDocument): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the property type classification (DatatypeProperty, ObjectProperty, or Property)
|
|
106
|
+
*/
|
|
107
|
+
getPropertyTypeClassification(propertyType: string | null): string;
|
|
108
|
+
/**
|
|
109
|
+
* Determines if a property should be treated as a datatype property based on its type and range
|
|
110
|
+
*/
|
|
111
|
+
isEffectiveDatatypeProperty(propertyTypeClassification: string, rangeUri: KanonakUri | null): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Determines if a property should be treated as an object property based on its type and range
|
|
114
|
+
*/
|
|
115
|
+
isEffectiveObjectProperty(propertyTypeClassification: string, rangeUri: KanonakUri | null): boolean;
|
|
116
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Kanonak, EmbeddedKanonak, ReferenceKanonak } from '../../object/kanonaks/types';
|
|
2
|
+
import { IStatement } from '../../object/statements/index';
|
|
3
|
+
export interface Statement<TObject> extends IStatement {
|
|
4
|
+
predicate: ReferenceKanonak;
|
|
5
|
+
object_: TObject;
|
|
6
|
+
}
|
|
7
|
+
export interface ScalarStatement<TScalar> extends Statement<TScalar> {
|
|
8
|
+
}
|
|
9
|
+
export interface BooleanStatement extends ScalarStatement<boolean> {
|
|
10
|
+
}
|
|
11
|
+
export interface EmbeddedStatement extends Statement<EmbeddedKanonak> {
|
|
12
|
+
}
|
|
13
|
+
export interface ListStatement extends Statement<Array<Kanonak>> {
|
|
14
|
+
}
|
|
15
|
+
export interface NumberStatement extends ScalarStatement<number> {
|
|
16
|
+
}
|
|
17
|
+
export interface ReferenceStatement extends Statement<ReferenceKanonak> {
|
|
18
|
+
}
|
|
19
|
+
export interface StringStatement extends ScalarStatement<string> {
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Version } from '../../document/models/types';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a Kanonak Resource URI that uniquely identifies a resource within a package. Format: publisher/package[@version]/resource Examples: - stories.org/characters@1.0.0/romeo-montague (specific version) - stories.org/characters/romeo-montague (latest version) Note: This is distinct from a Kanonak Package URI (publisher/package[@version]) which identifies a package but not a specific resource within it.
|
|
4
|
+
*/
|
|
5
|
+
export interface KanonakUri {
|
|
6
|
+
publisher: string;
|
|
7
|
+
package_: string;
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The version of the package. If null, represents "latest" version.
|
|
11
|
+
*/
|
|
12
|
+
version?: Version | null | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Converts the Kanonak URI to its string representation.
|
|
15
|
+
*/
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=(g=>(g[g.Warning=0]="Warning",g[g.Error=1]="Error",g))(m||{});export{m as ValidationSeverity};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IKanonakDocumentRepository } from '../../document/models/index';
|
|
2
|
+
import { KanonakDocument } from '../../document/models/types';
|
|
3
|
+
import { OntologyValidationResult } from '../../object/validation/types';
|
|
4
|
+
export { IKanonakDocumentRepository };
|
|
5
|
+
export { KanonakDocument };
|
|
6
|
+
export { OntologyValidationResult };
|
|
7
|
+
/**
|
|
8
|
+
* Interface for validating Kanonak documents at the ontology level
|
|
9
|
+
*/
|
|
10
|
+
export interface IKanonakObjectValidator {
|
|
11
|
+
/**
|
|
12
|
+
* Validates a Kanonak document for ontological correctness
|
|
13
|
+
*/
|
|
14
|
+
validateAsync(document: KanonakDocument, repository?: IKanonakDocumentRepository | null): Promise<OntologyValidationResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Validates a Kanonak document from YAML text
|
|
17
|
+
*/
|
|
18
|
+
validateYamlAsync(yamlText: string, repository?: IKanonakDocumentRepository | null): Promise<OntologyValidationResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IKanonakDocumentRepository as o}from"../../document/models/index";import{KanonakDocument as t}from"../../document/models/types";import{OntologyValidationResult as n}from"../../object/validation/types";export{o as IKanonakDocumentRepository,t as KanonakDocument,n as OntologyValidationResult};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { KanonakDocument } from '../../../../document/models/types';
|
|
2
|
+
import { OntologyValidationError } from '../../../../object/validation/types';
|
|
3
|
+
export { KanonakDocument };
|
|
4
|
+
export { OntologyValidationError };
|
|
5
|
+
/**
|
|
6
|
+
* Interface for validation rules that operate on a document in isolation without needing external dependencies like repositories
|
|
7
|
+
*/
|
|
8
|
+
export interface IDocumentValidationRule {
|
|
9
|
+
/**
|
|
10
|
+
* The name of this validation rule
|
|
11
|
+
*/
|
|
12
|
+
readonly ruleName: string;
|
|
13
|
+
/**
|
|
14
|
+
* Validates a Kanonak document against this rule
|
|
15
|
+
*/
|
|
16
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{KanonakDocument as o}from"../../../../document/models/types";import{OntologyValidationError as r}from"../../../../object/validation/types";export{o as KanonakDocument,r as OntologyValidationError};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { KanonakDocument } from '../../../../document/models/types';
|
|
2
|
+
import { IDocumentValidationRule } from '../../../../object/validation/rules/document/index';
|
|
3
|
+
import { OntologyValidationError } from '../../../../object/validation/types';
|
|
4
|
+
/**
|
|
5
|
+
* Validates that embedded Kanonak objects (nested objects within properties) do NOT have explicit 'type' properties. Embedded objects automatically infer their type from the parent property's range. This enforces proper ontology modeling and prevents redundant type declarations.
|
|
6
|
+
*/
|
|
7
|
+
export interface EmbeddedKanonakNoExplicitTypeRule extends IDocumentValidationRule {
|
|
8
|
+
readonly ruleName: string;
|
|
9
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validates that namespace prefixes with colons are not used in Kanonak YAML. Kanonak uses dot notation for namespace aliases, not colon notation
|
|
13
|
+
*/
|
|
14
|
+
export interface NamespacePrefixRule extends IDocumentValidationRule {
|
|
15
|
+
readonly ruleName: string;
|
|
16
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates that Package declarations have required properties: publisher, version. This rule applies to documents using the new Package format (type: Package).
|
|
20
|
+
*/
|
|
21
|
+
export interface PackagePropertiesRule extends IDocumentValidationRule {
|
|
22
|
+
readonly ruleName: string;
|
|
23
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates that a Kanonak document contains exactly one Package declaration. The Package entry is identified by having 'type: Package'.
|
|
27
|
+
*/
|
|
28
|
+
export interface PackageRequiredRule extends IDocumentValidationRule {
|
|
29
|
+
readonly ruleName: string;
|
|
30
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validates that properties use specific types (DatatypeProperty, ObjectProperty, etc.) rather than generic Property type
|
|
34
|
+
*/
|
|
35
|
+
export interface PropertyTypeSpecificityRule extends IDocumentValidationRule {
|
|
36
|
+
readonly ruleName: string;
|
|
37
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validates that resource names follow Kanonak naming conventions Resource names must start with a letter and can only contain letters, numbers, and underscores
|
|
41
|
+
*/
|
|
42
|
+
export interface ResourceNamingRule extends IDocumentValidationRule {
|
|
43
|
+
readonly ruleName: string;
|
|
44
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validates that all Subject Kanonaks (top-level entities) have an explicit 'type' property. Subject Kanonaks must declare their type since there is no parent property to infer from.
|
|
48
|
+
*/
|
|
49
|
+
export interface SubjectKanonakTypeRequiredRule extends IDocumentValidationRule {
|
|
50
|
+
readonly ruleName: string;
|
|
51
|
+
validate(document: KanonakDocument): Array<OntologyValidationError>;
|
|
52
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IKanonakDocumentRepository } from '../../../../document/models/index';
|
|
2
|
+
import { KanonakDocument } from '../../../../document/models/types';
|
|
3
|
+
import { OntologyValidationError } from '../../../../object/validation/types';
|
|
4
|
+
export { IKanonakDocumentRepository };
|
|
5
|
+
export { KanonakDocument };
|
|
6
|
+
export { OntologyValidationError };
|
|
7
|
+
/**
|
|
8
|
+
* Interface for validation rules that require repository access to validate external dependencies and imports
|
|
9
|
+
*/
|
|
10
|
+
export interface IRepositoryValidationRule {
|
|
11
|
+
/**
|
|
12
|
+
* The name of this validation rule
|
|
13
|
+
*/
|
|
14
|
+
readonly ruleName: string;
|
|
15
|
+
/**
|
|
16
|
+
* Validates a Kanonak document against this rule using repository for external lookups
|
|
17
|
+
*/
|
|
18
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IKanonakDocumentRepository as o}from"../../../../document/models/index";import{KanonakDocument as r}from"../../../../document/models/types";import{OntologyValidationError as t}from"../../../../object/validation/types";export{o as IKanonakDocumentRepository,r as KanonakDocument,t as OntologyValidationError};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { IKanonakDocumentRepository } from '../../../../document/models/index';
|
|
2
|
+
import { KanonakDocument } from '../../../../document/models/types';
|
|
3
|
+
import { KanonakUri } from '../../../../object/uris/types';
|
|
4
|
+
import { IRepositoryValidationRule } from '../../../../object/validation/rules/repository/index';
|
|
5
|
+
import { OntologyValidationError } from '../../../../object/validation/types';
|
|
6
|
+
/**
|
|
7
|
+
* Validates that references to entities or properties are unambiguous. When multiple imports define the same entity/property name, namespace aliases MUST be used to disambiguate (e.g., 'people.name' vs 'heroes.name'). When only one source defines an entity, aliases are optional. Design Philosophy: - Aliases are document-scoped only (not transitive) - Aliases are required ONLY when ambiguity exists - Aliases are optional when references are unambiguous
|
|
8
|
+
*/
|
|
9
|
+
export interface AmbiguousReferenceRule extends IRepositoryValidationRule {
|
|
10
|
+
readonly ruleName: string;
|
|
11
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates that all classes used as entity types are properly defined or imported
|
|
15
|
+
*/
|
|
16
|
+
export interface ClassDefinitionRule extends IRepositoryValidationRule {
|
|
17
|
+
readonly ruleName: string;
|
|
18
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Detects circular dependencies in class hierarchies (subClassOf chains)
|
|
22
|
+
*/
|
|
23
|
+
export interface ClassHierarchyCycleRule extends IRepositoryValidationRule {
|
|
24
|
+
readonly ruleName: string;
|
|
25
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates that properties used on Class and Property definitions are actually defined. When a class or property definition uses a property (e.g., "icon: ✅"), this rule ensures that the property "icon" is defined as an ObjectProperty or DatatypeProperty either locally or in imported namespaces.
|
|
29
|
+
*/
|
|
30
|
+
export interface DefinitionPropertyReferenceRule extends IRepositoryValidationRule {
|
|
31
|
+
readonly ruleName: string;
|
|
32
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
33
|
+
}
|
|
34
|
+
export interface ImportErrorDetails {
|
|
35
|
+
message: string;
|
|
36
|
+
suggestion: string;
|
|
37
|
+
expectedValue: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validates that all imported namespaces actually exist in the repository and that version constraints can be satisfied
|
|
41
|
+
*/
|
|
42
|
+
export interface ImportExistenceRule extends IRepositoryValidationRule {
|
|
43
|
+
readonly ruleName: string;
|
|
44
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validates that properties used in entity instances are actually defined. When an entity instance uses a property (e.g., "assignedTo: some-agent"), this rule ensures that the property "assignedTo" is defined as an ObjectProperty or DatatypeProperty either locally or in imported namespaces.
|
|
48
|
+
*/
|
|
49
|
+
export interface InstancePropertyReferenceRule extends IRepositoryValidationRule {
|
|
50
|
+
readonly ruleName: string;
|
|
51
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detects circular dependencies in namespace imports. Circular dependencies prevent proper package resolution, so these must be caught during validation.
|
|
55
|
+
*/
|
|
56
|
+
export interface NamespaceImportCycleRule extends IRepositoryValidationRule {
|
|
57
|
+
readonly ruleName: string;
|
|
58
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates that namespaces for ObjectProperty range classes are imported
|
|
62
|
+
*/
|
|
63
|
+
export interface ObjectPropertyImportRule extends IRepositoryValidationRule {
|
|
64
|
+
readonly ruleName: string;
|
|
65
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validates that ALL ObjectProperty values point to existing entities. Uses TypeResolver to determine which properties are ObjectProperties (explicit or inferred from range).
|
|
69
|
+
*/
|
|
70
|
+
export interface ObjectPropertyValueValidationRule extends IRepositoryValidationRule {
|
|
71
|
+
readonly ruleName: string;
|
|
72
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Validates that properties are only used on instances of their declared domain class. Ensures properties are used on the correct types (domain validation).
|
|
76
|
+
*/
|
|
77
|
+
export interface PropertyDomainRule extends IRepositoryValidationRule {
|
|
78
|
+
readonly ruleName: string;
|
|
79
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Detects circular dependencies in property hierarchies (subPropertyOf chains)
|
|
83
|
+
*/
|
|
84
|
+
export interface PropertyHierarchyCycleRule extends IRepositoryValidationRule {
|
|
85
|
+
readonly ruleName: string;
|
|
86
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
87
|
+
}
|
|
88
|
+
export interface PropertyInfo {
|
|
89
|
+
propertyType: string;
|
|
90
|
+
range?: string | null | undefined;
|
|
91
|
+
rangeUri?: KanonakUri | null | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Validates that property range references point to valid types. For ObjectProperty, ensures the range refers to a defined class. For DatatypeProperty, ensures the range is a valid primitive type.
|
|
95
|
+
*/
|
|
96
|
+
export interface PropertyRangeReferenceRule extends IRepositoryValidationRule {
|
|
97
|
+
readonly ruleName: string;
|
|
98
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Validates that all property definitions have a 'range' specified. This is required for type inference and proper semantic validation.
|
|
102
|
+
*/
|
|
103
|
+
export interface PropertyRangeRequiredRule extends IRepositoryValidationRule {
|
|
104
|
+
readonly ruleName: string;
|
|
105
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validates that instance property values match their declared property types and ranges. Prevents setting complex objects on DatatypeProperties and ensures ObjectProperty values are valid.
|
|
109
|
+
*/
|
|
110
|
+
export interface PropertyValueTypeRule extends IRepositoryValidationRule {
|
|
111
|
+
readonly ruleName: string;
|
|
112
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validates that subClassOf references point to existing classes
|
|
116
|
+
*/
|
|
117
|
+
export interface SubClassOfReferenceRule extends IRepositoryValidationRule {
|
|
118
|
+
readonly ruleName: string;
|
|
119
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validates that subPropertyOf references point to existing properties
|
|
123
|
+
*/
|
|
124
|
+
export interface SubPropertyOfReferenceRule extends IRepositoryValidationRule {
|
|
125
|
+
readonly ruleName: string;
|
|
126
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Validates that there are no ambiguous type references when multiple imported namespaces define the same type. Suggests using namespace aliases to resolve ambiguity.
|
|
130
|
+
*/
|
|
131
|
+
export interface TypeAmbiguityRule extends IRepositoryValidationRule {
|
|
132
|
+
readonly ruleName: string;
|
|
133
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Validates that ObjectProperty instance references (Reference Statements) can be resolved. Checks that when an entity references another entity via an ObjectProperty, the referenced entity exists in the current document or imported namespaces.
|
|
137
|
+
*/
|
|
138
|
+
export interface UnresolvedReferenceRule extends IRepositoryValidationRule {
|
|
139
|
+
readonly ruleName: string;
|
|
140
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validates that XSD namespace is imported when DatatypeProperty uses XSD types
|
|
144
|
+
*/
|
|
145
|
+
export interface XsdImportRule extends IRepositoryValidationRule {
|
|
146
|
+
readonly ruleName: string;
|
|
147
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<Array<OntologyValidationError>>;
|
|
148
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { IKanonakDocumentRepository } from '../../document/models/index';
|
|
2
|
+
import { KanonakDocument } from '../../document/models/types';
|
|
3
|
+
import { PropertyMetadata } from '../../object/parsing/types';
|
|
4
|
+
import { ValidationSeverity } from '../../object/validation/enums';
|
|
5
|
+
import { IKanonakObjectValidator } from '../../object/validation/index';
|
|
6
|
+
import { IDocumentValidationRule } from '../../object/validation/rules/document/index';
|
|
7
|
+
import { IRepositoryValidationRule } from '../../object/validation/rules/repository/index';
|
|
8
|
+
/**
|
|
9
|
+
* Main validator for Kanonak documents at the ontology level
|
|
10
|
+
*/
|
|
11
|
+
export interface KanonakObjectValidator extends IKanonakObjectValidator {
|
|
12
|
+
/**
|
|
13
|
+
* Gets or sets whether to include warnings in validation results
|
|
14
|
+
*/
|
|
15
|
+
includeWarnings: boolean;
|
|
16
|
+
validateAsync(document: KanonakDocument, repository?: IKanonakDocumentRepository | null): Promise<OntologyValidationResult>;
|
|
17
|
+
validateYamlAsync(yamlText: string, repository?: IKanonakDocumentRepository | null): Promise<OntologyValidationResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a custom document validation rule
|
|
20
|
+
*/
|
|
21
|
+
addDocumentRule(rule: IDocumentValidationRule): void;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a custom repository validation rule
|
|
24
|
+
*/
|
|
25
|
+
addRepositoryRule(rule: IRepositoryValidationRule): void;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a document validation rule by type
|
|
28
|
+
*/
|
|
29
|
+
removeDocumentRule<T>(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Removes a repository validation rule by type
|
|
32
|
+
*/
|
|
33
|
+
removeRepositoryRule<T>(): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Represents a validation error or warning for ontological issues
|
|
37
|
+
*/
|
|
38
|
+
export interface OntologyValidationError {
|
|
39
|
+
/**
|
|
40
|
+
* The type of validation rule that was violated
|
|
41
|
+
*/
|
|
42
|
+
ruleType: string;
|
|
43
|
+
/**
|
|
44
|
+
* Severity level of the issue
|
|
45
|
+
*/
|
|
46
|
+
severity: ValidationSeverity;
|
|
47
|
+
/**
|
|
48
|
+
* Line number in the source file where the error occurred (if available)
|
|
49
|
+
*/
|
|
50
|
+
lineNumber?: number | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Column number in the source file where the error occurred (if available, primarily for parse errors)
|
|
53
|
+
*/
|
|
54
|
+
column?: number | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The resource (class, property, instance) where the error occurred
|
|
57
|
+
*/
|
|
58
|
+
resourceName?: string | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The property within the entity where the error occurred
|
|
61
|
+
*/
|
|
62
|
+
propertyName?: string | null | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The full path to the property, including nested paths and array indices. Examples: "hasTasks[0].hasDependency.dependsOn", "flowsThrough[2]", "simpleProperty" Used for positioning diagnostics in deeply nested structures.
|
|
65
|
+
*/
|
|
66
|
+
propertyPath?: string | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Human-readable error message
|
|
69
|
+
*/
|
|
70
|
+
message: string;
|
|
71
|
+
/**
|
|
72
|
+
* Suggestion for how to fix the issue
|
|
73
|
+
*/
|
|
74
|
+
suggestion?: string | null | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The actual value that caused the validation error
|
|
77
|
+
*/
|
|
78
|
+
actualValue?: string | null | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The expected or corrected value
|
|
81
|
+
*/
|
|
82
|
+
expectedValue?: string | null | undefined;
|
|
83
|
+
toString(): string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Result of ontology validation for a Kanonak document
|
|
87
|
+
*/
|
|
88
|
+
export interface OntologyValidationResult {
|
|
89
|
+
/**
|
|
90
|
+
* Whether the validation passed without errors
|
|
91
|
+
*/
|
|
92
|
+
isValid: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* List of validation errors found
|
|
95
|
+
*/
|
|
96
|
+
errors: Array<OntologyValidationError>;
|
|
97
|
+
/**
|
|
98
|
+
* List of validation warnings (non-fatal issues)
|
|
99
|
+
*/
|
|
100
|
+
warnings: Array<OntologyValidationError>;
|
|
101
|
+
/**
|
|
102
|
+
* Total count of issues (errors + warnings)
|
|
103
|
+
*/
|
|
104
|
+
readonly totalIssues: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Context for validation operations, carrying metadata needed for type inference and validation
|
|
108
|
+
*/
|
|
109
|
+
export interface ValidationContext {
|
|
110
|
+
/**
|
|
111
|
+
* The parent property metadata for the current embedded object being validated. Used to infer the expected type from the property's range.
|
|
112
|
+
*/
|
|
113
|
+
parentProperty?: PropertyMetadata | null | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* All resolved documents in the current validation scope (includes imports)
|
|
116
|
+
*/
|
|
117
|
+
resolvedDocuments: Array<KanonakDocument>;
|
|
118
|
+
/**
|
|
119
|
+
* The current path in the document hierarchy (for error reporting)
|
|
120
|
+
*/
|
|
121
|
+
currentResourcePath?: string | null | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Gets the inferred type for the current embedded object based on parent property's range
|
|
124
|
+
*/
|
|
125
|
+
getInferredType(): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new validation context with updated parent property metadata
|
|
128
|
+
*/
|
|
129
|
+
withParentProperty(metadata: PropertyMetadata | null): ValidationContext;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a new validation context with updated resource path
|
|
132
|
+
*/
|
|
133
|
+
withPath(path: string): ValidationContext;
|
|
134
|
+
}
|
|
File without changes
|