@kanonak-protocol/sdk 5.34.0 → 5.36.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.d.ts +4 -0
- package/dist/browser.js +1 -1
- package/dist/{chunk-BMKA5YBF.js → chunk-4QXD6HKI.js} +1 -1
- package/dist/chunk-6TEJENCD.js +68 -0
- package/dist/chunk-7TU55KLO.js +1 -0
- package/dist/{chunk-FLITV5YI.js → chunk-H7SX57L7.js} +1 -1
- package/dist/chunk-IN5VVPYH.js +1 -0
- package/dist/chunk-Q2FG7DME.js +1 -0
- package/dist/chunk-ROKDCCJN.js +155 -0
- package/dist/{chunk-64A7JMOY.js → chunk-VENZTHCC.js} +1 -1
- package/dist/chunk-XNEWQEB6.js +1 -0
- package/dist/{chunk-JIQNO36P.js → chunk-YBHIELES.js} +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/kanonaks/LiteralKanonak.d.ts +10 -0
- package/dist/kanonaks/walkDefinedKanonaks.d.ts +23 -18
- package/dist/look/LookRenderer.d.ts +10 -5
- package/dist/parsing/KanonakObjectParser.d.ts +8 -0
- package/dist/parsing/index.js +1 -1
- package/dist/producer/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/transformations/v3/TransformationLoaderV3.d.ts +8 -2
- package/dist/uri-helpers/PropertyValues.d.ts +105 -0
- package/dist/uri-helpers/UriHelpers.d.ts +40 -5
- package/dist/uri-helpers/index.d.ts +4 -2
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/MarkdownLinkRule.d.ts +1 -0
- package/package.json +2 -2
- package/dist/chunk-A7N2BMMP.js +0 -1
- package/dist/chunk-CJMVIOZX.js +0 -1
- package/dist/chunk-ESABMC5L.js +0 -1
- package/dist/chunk-FL42CQAH.js +0 -155
- package/dist/chunk-LO5IH6OE.js +0 -68
- package/dist/chunk-R53WM2ZP.js +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Kanonak } from '../kanonaks/Kanonak.js';
|
|
2
|
+
import { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
|
|
3
|
+
import { EmbeddedKanonak } from '../kanonaks/EmbeddedKanonak.js';
|
|
4
|
+
import type { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
|
|
5
|
+
import type { KanonakUri } from '../resolution/KanonakUri.js';
|
|
6
|
+
import type { MarkdownLink } from '../statements/MarkdownStatement.js';
|
|
7
|
+
import { type EntityUri, type RawPropertyValue } from './UriHelpers.js';
|
|
8
|
+
/**
|
|
9
|
+
* One value of a property, whatever form it was authored in (typescript#123).
|
|
10
|
+
*
|
|
11
|
+
* - `subject`: a reference, resolved to the subject it names in the catalog;
|
|
12
|
+
* - `embedded`: an inline value — a single embedded object, a list item, or a
|
|
13
|
+
* dict-keyed entry;
|
|
14
|
+
* - `unresolved`: a reference the catalog cannot resolve — returned, never
|
|
15
|
+
* dropped, so "names something absent" stays distinguishable from "names
|
|
16
|
+
* nothing";
|
|
17
|
+
* - `literal`: a literal value. Legitimate where a property's range admits
|
|
18
|
+
* literals (a datatype property, the members of an `rdf:List` such as
|
|
19
|
+
* `sh:in` or `owl:oneOf`); on an object property it is a modelling error
|
|
20
|
+
* the validator reports — returned all the same, so a consumer that wants
|
|
21
|
+
* only resources filters by kind in its own code.
|
|
22
|
+
*
|
|
23
|
+
* Every value carries its ADDRESS — the node's address plus the protocol's
|
|
24
|
+
* fragment path for this value (see {@link valuesOf}) — and `fromList`:
|
|
25
|
+
* whether it was authored as an item of a list rather than as the property's
|
|
26
|
+
* single value. An editor writing a value back needs the second (editing a
|
|
27
|
+
* list item vs setting a single value); the address already reflects it.
|
|
28
|
+
*/
|
|
29
|
+
export type PropertyValue = {
|
|
30
|
+
kind: 'subject';
|
|
31
|
+
node: SubjectKanonak;
|
|
32
|
+
uri: KanonakUri;
|
|
33
|
+
address: string;
|
|
34
|
+
fromList: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'embedded';
|
|
37
|
+
node: EmbeddedKanonak;
|
|
38
|
+
address: string;
|
|
39
|
+
fromList: boolean;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'unresolved';
|
|
42
|
+
uri: KanonakUri;
|
|
43
|
+
address: string;
|
|
44
|
+
fromList: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'literal';
|
|
47
|
+
value: string | number | boolean;
|
|
48
|
+
/** Canonical-form datatype carrier, when the value was range-typed. */
|
|
49
|
+
carrier?: string | undefined;
|
|
50
|
+
/** The raw lexical token as authored. */
|
|
51
|
+
lexical?: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* A prose value's `[[reference]]` placeholders, resolved through the
|
|
54
|
+
* import closure by the parser (single values and list items alike).
|
|
55
|
+
* Present exactly when the value is prose (core-prose Markdown /
|
|
56
|
+
* SubstitutableString).
|
|
57
|
+
*/
|
|
58
|
+
links?: readonly MarkdownLink[] | undefined;
|
|
59
|
+
address: string;
|
|
60
|
+
fromList: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Every value of a property on a node, in authored order, each resolved and
|
|
64
|
+
* addressed — THE form-agnostic read of "the values of this property".
|
|
65
|
+
*
|
|
66
|
+
* Reads every statement the property has on the node (the open-world merge
|
|
67
|
+
* can fold several documents' statements onto one subject) and every form
|
|
68
|
+
* each was written in. References resolve through `catalog` with exactly the
|
|
69
|
+
* semantics of `findSubjectByUri` (a versioned reference matches that version;
|
|
70
|
+
* a versionless one the first version in the catalog), via an index built
|
|
71
|
+
* once per catalog.
|
|
72
|
+
*
|
|
73
|
+
* Addressing follows the protocol's `uri-fragments` convention: a fragment
|
|
74
|
+
* after `#` whose segments are property names, `.`-separated, with `[N]` for
|
|
75
|
+
* a position. `nodeAddress` is the node's own address — a subject's canonical
|
|
76
|
+
* key, or an embedded value's address from an earlier call — so nested values
|
|
77
|
+
* compose (`box#parts[1].subparts[0]`). A property's value is addressed:
|
|
78
|
+
*
|
|
79
|
+
* - by its dict key when it was authored as a dict-keyed entry
|
|
80
|
+
* (`product#offers.north`) — the form the convention prefers, since a name
|
|
81
|
+
* does not shift when entries reorder;
|
|
82
|
+
* - by position `[N]` when it came from a list or the property has more than
|
|
83
|
+
* one value (`N` counts across all of the property's values, so it is
|
|
84
|
+
* unique within the catalog — though in a merged view it depends on which
|
|
85
|
+
* documents are loaded, which is why names are the stable form);
|
|
86
|
+
* - by the property name alone when it is the property's single value
|
|
87
|
+
* (`alice#address`).
|
|
88
|
+
*/
|
|
89
|
+
export declare function valuesOf(node: DefinedKanonak, property: EntityUri, catalog: Kanonak[], nodeAddress: string): PropertyValue[];
|
|
90
|
+
/**
|
|
91
|
+
* A subject's own address — its canonical key `publisher/package/name` —
|
|
92
|
+
* the root that every value address under it extends (`valuesOf`,
|
|
93
|
+
* `walkDefinedKanonaks`, and a conformance finding's focus node).
|
|
94
|
+
*/
|
|
95
|
+
export declare function subjectAddress(subject: SubjectKanonak): string;
|
|
96
|
+
/**
|
|
97
|
+
* THE address computation: every raw value of a property with its fragment
|
|
98
|
+
* address under `nodeAddress`, per the protocol's uri-fragments convention
|
|
99
|
+
* (see {@link valuesOf}). Shared by `valuesOf` and `walkDefinedKanonaks`, so
|
|
100
|
+
* one node has one address whichever way it is reached.
|
|
101
|
+
*/
|
|
102
|
+
export declare function addressedValuesOf(node: DefinedKanonak, property: EntityUri, nodeAddress: string): {
|
|
103
|
+
value: RawPropertyValue;
|
|
104
|
+
address: string;
|
|
105
|
+
}[];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
|
|
2
2
|
import { EmbeddedKanonak } from '../kanonaks/EmbeddedKanonak.js';
|
|
3
3
|
import { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
|
|
4
|
+
import { ReferenceKanonak } from '../kanonaks/ReferenceKanonak.js';
|
|
4
5
|
import { Kanonak } from '../kanonaks/Kanonak.js';
|
|
5
6
|
import { KanonakUri } from '../resolution/KanonakUri.js';
|
|
7
|
+
import { type MarkdownLink } from '../statements/MarkdownStatement.js';
|
|
6
8
|
import type { IStatement } from '../statements/IStatement.js';
|
|
7
9
|
/**
|
|
8
10
|
* Canonical URI identity for an ontology entity.
|
|
@@ -67,14 +69,47 @@ export declare function toCanonicalUrl(uri: CanonicalUriParts): string;
|
|
|
67
69
|
*/
|
|
68
70
|
export declare function typeReferenceUris(kanonak: Kanonak): KanonakUri[];
|
|
69
71
|
/**
|
|
70
|
-
* The canonical URIs a
|
|
71
|
-
*
|
|
72
|
+
* The canonical URIs a property names — the reference values of
|
|
73
|
+
* {@link rawValuesOf}, read across every statement for the property, whether
|
|
74
|
+
* each was authored as a single reference or in a list. Embedded and literal
|
|
75
|
+
* values are not references and are not returned; unresolvable references
|
|
76
|
+
* ARE (this reads names, it does not resolve them).
|
|
72
77
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* {@link typeReferenceUris} is the `rdf:type` case by name.
|
|
78
|
+
* The one way to read "which resources does this property name?" without a
|
|
79
|
+
* catalog — the shape a `subClassOf` or type walk needs.
|
|
80
|
+
* {@link typeReferenceUris} is the `rdf:type` case by name. To read every
|
|
81
|
+
* value of a property — resolved subjects, embedded values, literals — use
|
|
82
|
+
* `valuesOf`, which walks the same statements.
|
|
76
83
|
*/
|
|
77
84
|
export declare function referenceUris(kanonak: Kanonak, property: EntityUri): KanonakUri[];
|
|
85
|
+
/** One value of a property as authored, before resolution or addressing. */
|
|
86
|
+
export interface RawPropertyValue {
|
|
87
|
+
item: ReferenceKanonak | EmbeddedKanonak | RawLiteral;
|
|
88
|
+
/** Whether the value came from a list (so it is addressed by position or dict key). */
|
|
89
|
+
fromList: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** A literal value, from a scalar statement or a list item. */
|
|
92
|
+
export interface RawLiteral {
|
|
93
|
+
readonly literal: true;
|
|
94
|
+
value: string | number | boolean;
|
|
95
|
+
carrier?: string | undefined;
|
|
96
|
+
lexical?: string | undefined;
|
|
97
|
+
/** A prose value's resolved `[[links]]` — present exactly when the value is prose. */
|
|
98
|
+
links?: readonly MarkdownLink[] | undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Every value of a property on a defined kanonak, in statement order — THE
|
|
102
|
+
* statement walk under both {@link referenceUris} and `valuesOf`.
|
|
103
|
+
*
|
|
104
|
+
* Reads EVERY statement for the property, not the first: the open-world
|
|
105
|
+
* merge folds each document's assertions onto one subject, so a property can
|
|
106
|
+
* carry several statements (a superclass declared in one package and another
|
|
107
|
+
* added by an augmenting package). A reader that stops at the first statement
|
|
108
|
+
* silently loses the rest. Every authored form comes back: a single
|
|
109
|
+
* reference, a single embedded value, a single literal, and every list item.
|
|
110
|
+
* A list item of any other kind is an object-model bug and throws.
|
|
111
|
+
*/
|
|
112
|
+
export declare function rawValuesOf(kanonak: Kanonak, property: EntityUri): RawPropertyValue[];
|
|
78
113
|
export declare function hasType(kanonak: Kanonak, target: EntityUri): boolean;
|
|
79
114
|
/**
|
|
80
115
|
* Filter a list of parsed kanonaks down to `SubjectKanonak`s whose type
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { typeReferenceUris, referenceUris, uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, findStatement, } from './UriHelpers.js';
|
|
2
|
-
export type { EntityUri, CanonicalUriParts } from './UriHelpers.js';
|
|
1
|
+
export { typeReferenceUris, referenceUris, rawValuesOf, uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, findStatement, } from './UriHelpers.js';
|
|
2
|
+
export type { EntityUri, CanonicalUriParts, RawPropertyValue, RawLiteral } from './UriHelpers.js';
|
|
3
|
+
export { valuesOf, subjectAddress } from './PropertyValues.js';
|
|
4
|
+
export type { PropertyValue } from './PropertyValues.js';
|
|
3
5
|
export { SingleDocumentRepository } from './SingleDocumentRepository.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as j,B as k,C as l,D as m,E as n,F as o,G as p,H as q,I as r,J as s,L as t,r as a,s as b,t as c,u as d,v as e,w as f,x as g,y as h,z as i}from"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{t as SingleDocumentRepository,j as findAllResourcesByCanonicalUri,k as findStatement,i as findSubjectByUri,h as findSubjectsByType,m as getDatatypeValue,p as getEmbeddedValue,q as getListValues,o as getReferenceUri,n as getStringValue,l as hasProperty,g as hasType,f as rawValuesOf,e as referenceUris,s as subjectAddress,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches,r as valuesOf};
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-6TEJENCD.js";import"../chunk-KIBR3HAT.js";import"../chunk-ROKDCCJN.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-Q2FG7DME.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-7TU55KLO.js";import"../chunk-XNEWQEB6.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
|
|
@@ -24,6 +24,7 @@ export declare class MarkdownLinkRule implements IRepositoryValidationRule {
|
|
|
24
24
|
* handles recursion into embeddeds, so this inspects a single level.
|
|
25
25
|
*/
|
|
26
26
|
private checkNode;
|
|
27
|
+
private checkProse;
|
|
27
28
|
private unresolvedLinkError;
|
|
28
29
|
private malformedLinkError;
|
|
29
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.36.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",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
],
|
|
135
135
|
"dependencies": {
|
|
136
136
|
"@kanonak-protocol/canonical": "^0.1.3",
|
|
137
|
-
"@kanonak-protocol/types": "^5.
|
|
137
|
+
"@kanonak-protocol/types": "^5.36.0",
|
|
138
138
|
"ignore": "^7.0.5",
|
|
139
139
|
"js-yaml": "^4.1.0",
|
|
140
140
|
"yaml": "^2.7.0",
|
package/dist/chunk-A7N2BMMP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as X}from"./chunk-HF5FJBS2.js";import{a as h,b as H,c as J,ia as Q,ja as U,ka as N,qa as Z}from"./chunk-ESABMC5L.js";import{a as q,c as w,d as g,g as R,h as L,i as E,j as O,k as K,l as P,m as A,n as x,t as Y}from"./chunk-CJMVIOZX.js";import{a as I}from"./chunk-FUUTGGJS.js";import{b as G}from"./chunk-F67UH4FD.js";import{k as W}from"./chunk-QILEJIFU.js";var j=class extends q{value;carrier;lexical};var T=class extends R{links=[]};var ae="kanonak.org",oe="transformations",we=3,e=f=>({publisher:ae,package_:oe,name:f}),M={Transformation:e("Transformation"),InstanceTransformation:e("InstanceTransformation"),SetTransformation:e("SetTransformation"),inputPattern:e("inputPattern"),rule:e("rule"),artifactName:e("artifactName"),outputs:e("outputs"),formatOverrides:e("formatOverrides"),partitionBy:e("partitionBy"),InputPattern:e("InputPattern"),matchesClass:e("matchesClass"),requires:e("requires"),sortBy:e("sortBy"),SortKey:e("SortKey"),byProperty:e("byProperty"),order:e("order"),SortOrder:e("SortOrder"),ascending:e("ascending"),descending:e("descending"),OutputFormat:e("OutputFormat"),backendUri:e("backendUri"),FormatOverride:e("FormatOverride"),formatTarget:e("formatTarget"),metadataKeys:e("metadataKeys"),metadataRenames:e("metadataRenames"),trailingNewline:e("trailingNewline"),omitWrapper:e("omitWrapper"),RenameEntry:e("RenameEntry"),fromKey:e("fromKey"),toKey:e("toKey"),FMT_MARKDOWN_FRONTMATTER:e("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:e("plain-markdown"),FMT_TOML:e("toml"),FMT_JSON:e("json"),FMT_HTML:e("html"),FMT_SVG:e("svg"),Expression:e("Expression"),ListSourcedExpression:e("ListSourcedExpression"),ListAggregate:e("ListAggregate"),IteratingExpression:e("IteratingExpression"),BuildAstNode:e("BuildAstNode"),astClass:e("astClass"),set:e("set"),AstFieldBinding:e("AstFieldBinding"),field:e("field"),bindValue:e("bindValue"),When:e("When"),condition:e("condition"),thenBuild:e("thenBuild"),elseBuild:e("elseBuild"),Concat:e("Concat"),parts:e("parts"),Fallback:e("Fallback"),primary:e("primary"),alternate:e("alternate"),StringLiteral:e("StringLiteral"),stringLiteral:e("stringLiteral"),IntegerLiteral:e("IntegerLiteral"),integerLiteral:e("integerLiteral"),DecimalLiteral:e("DecimalLiteral"),decimalLiteral:e("decimalLiteral"),BooleanLiteral:e("BooleanLiteral"),booleanLiteral:e("booleanLiteral"),VarRef:e("VarRef"),varName:e("varName"),PropertyRead:e("PropertyRead"),readSource:e("readSource"),readProp:e("readProp"),Traverse:e("Traverse"),traverseSource:e("traverseSource"),through:e("through"),step:e("step"),UriName:e("UriName"),uriNameOf:e("uriNameOf"),UriPublisher:e("UriPublisher"),uriPublisherOf:e("uriPublisherOf"),UriPackage:e("UriPackage"),uriPackageOf:e("uriPackageOf"),UriVersion:e("UriVersion"),uriVersionOf:e("uriVersionOf"),SubjectUri:e("SubjectUri"),subjectOf:e("subjectOf"),UriLiteral:e("UriLiteral"),refTo:e("refTo"),DisplayLabel:e("DisplayLabel"),labelTarget:e("labelTarget"),labelSource:e("labelSource"),ResolveRef:e("ResolveRef"),resolveSource:e("resolveSource"),Normalize:e("Normalize"),normSource:e("normSource"),normKind:e("normKind"),NormalizeKind:e("NormalizeKind"),NORM_TRIM_END:e("trim-end"),NORM_TO_UPPER:e("to-upper"),NORM_TO_LOWER:e("to-lower"),NORM_FIRST_CHAR:e("first-char"),UnescapedString:e("UnescapedString"),unescapedSource:e("unescapedSource"),IsSet:e("IsSet"),checkExpr:e("checkExpr"),ExpressionFragment:e("ExpressionFragment"),body:e("body"),CallFragment:e("CallFragment"),fragmentRef:e("fragmentRef"),source:e("source"),Join:e("Join"),separator:e("separator"),Count:e("Count"),Sum:e("Sum"),Min:e("Min"),Max:e("Max"),Average:e("Average"),loopVar:e("loopVar"),ForEach:e("ForEach"),emit:e("emit"),ListMap:e("ListMap"),mapBody:e("mapBody"),Filter:e("Filter"),predicate:e("predicate"),PartitionBy:e("PartitionBy"),partitionKey:e("partitionKey"),DistinctBy:e("DistinctBy"),distinctKey:e("distinctKey"),Partition:e("Partition"),key:e("key"),members:e("members"),AllStatements:e("AllStatements"),statementsOf:e("statementsOf"),StatementPredicate:e("StatementPredicate"),predicateOf:e("predicateOf"),StatementValue:e("StatementValue"),valueOf:e("valueOf"),DateFormat:e("DateFormat"),dateSource:e("dateSource"),dateFormat:e("dateFormat"),NumberFormat:e("NumberFormat"),numberSource:e("numberSource"),numberStyle:e("numberStyle"),fractionDigits:e("fractionDigits"),currencyCode:e("currencyCode"),BinaryArithmetic:e("BinaryArithmetic"),arithLeft:e("arithLeft"),arithRight:e("arithRight"),Add:e("Add"),Subtract:e("Subtract"),Multiply:e("Multiply"),Divide:e("Divide"),Reverse:e("Reverse"),WindowedMap:e("WindowedMap"),windowSize:e("windowSize"),windowVar:e("windowVar"),windowBody:e("windowBody"),PairwiseMap:e("PairwiseMap"),firstVar:e("firstVar"),secondVar:e("secondVar"),pairBody:e("pairBody"),Scan:e("Scan"),initialState:e("initialState"),stateVar:e("stateVar"),elementVar:e("elementVar"),accumulate:e("accumulate"),ListItemAt:e("ListItemAt"),itemIndex:e("itemIndex"),BinaryComparison:e("BinaryComparison"),compareLeft:e("compareLeft"),compareRight:e("compareRight"),Equals:e("Equals"),GreaterThan:e("GreaterThan"),LessThan:e("LessThan"),GreaterThanOrEqual:e("GreaterThanOrEqual"),LessThanOrEqual:e("LessThanOrEqual"),Not:e("Not"),operand:e("operand"),BooleanLogic:e("BooleanLogic"),operands:e("operands"),And:e("And"),Or:e("Or"),Contains:e("Contains"),haystack:e("haystack"),needle:e("needle"),UnaryNumericOp:e("UnaryNumericOp"),value:e("value"),Abs:e("Abs"),Negate:e("Negate"),KindPredicate:e("KindPredicate"),IsReference:e("IsReference"),IsEmbedded:e("IsEmbedded"),IsList:e("IsList"),kindCheck:e("kindCheck"),IsString:e("IsString"),IsNumber:e("IsNumber"),IsBoolean:e("IsBoolean"),StatementObject:e("StatementObject"),statementSource:e("statementSource"),Let:e("Let"),letName:e("letName"),letValue:e("letValue"),letBody:e("letBody"),GetStatementByName:e("GetStatementByName"),inSubject:e("inSubject"),byName:e("byName"),RenderMarkdown:e("RenderMarkdown"),renderSource:e("renderSource"),renderProp:e("renderProp"),renderFormat:e("renderFormat"),RenderFormat:e("RenderFormat"),RENDER_HTML:e("render-html"),RENDER_MARKDOWN:e("render-markdown")};import{Carrier as S,carrierOf as se}from"@kanonak-protocol/canonical";function _(f){return se(`${f.publisher}/${f.package_}/${f.name}`)}var ie=/\[\[([^\[\]\n]+)\]\]/g,ce=/\[\[/g,ee=/```[\s\S]*?```|`[^`\n]*`/g;function pe(f){let t=[];for(let n of f.matchAll(ee))t.push([n.index,n.index+n[0].length]);return t}function je(f){if(!f||!f.includes("[["))return[];let t=pe(f),n=s=>t.some(([o,c])=>s>=o&&s<c),r=new Set(V(f).map(s=>s.startOffset)),a=[];for(let s of f.matchAll(ce)){let o=s.index;if(n(o)||r.has(o))continue;let c=f.slice(o,o+48).replace(/\s+/g," ").trim();a.push({startOffset:o,snippet:c})}return a}function V(f){if(!f||!f.includes("[["))return[];let t=[];for(let a of f.matchAll(ee))t.push([a.index,a.index+a[0].length]);let n=a=>t.some(([s,o])=>a>=s&&a<o),r=[];for(let a of f.matchAll(ie)){let s=a.index;if(n(s))continue;let o=a[1],c=o.indexOf("|"),p=(c===-1?o:o.slice(0,c)).trim();if(p.length===0)continue;let i=c===-1?"":o.slice(c+1).trim(),m={reference:p,startOffset:s,endOffset:s+a[0].length};i.length>0&&(m.displayText=i),r.push(m)}return r}import{VersionOperator as fe}from"@kanonak-protocol/types/document/models/enums";function ne(f,t){for(let n of f)n instanceof w&&B(n,n.name,t)}function B(f,t,n){n({kanonak:f,path:t});for(let r of f.statement){let a=r.predicate?.subject?.name;if(r instanceof K)B(r.object,te(t,a,r.object),n);else if(r instanceof P)for(let s=0;s<r.object.length;s++){let o=r.object[s];o instanceof h&&B(o,te(t,a,o,s),n)}}}function te(f,t,n,r){let a=`${f}.${t??"<embedded>"}`,s=n instanceof h?n.name:void 0;return s?`${a}.${s}`:r===void 0?a:`${a}[${r}]`}var me={...U("range"),name:"range"};function ue(f){let t=f.lastIndexOf(".");return t===-1?f:f.slice(t+1)}var re=class{constructor(t){}async parseKanonaks(t,n){let r=await t.getAllDocumentsAsync(),a=new H(t),s=new J(a);this.knownPropertyClasses.clear();let o=await this.parseAllDocumentsAsync(r,a,s,t),c=await this.mergeAndCanonicalizeAsync(o,t);return await this.learnPropertyClassesAsync(c,r,a)&&(o=await this.parseAllDocumentsAsync(r,a,s,t),c=await this.mergeAndCanonicalizeAsync(o,t)),n&&(n.authored=o),c}knownPropertyClasses=new Map;async learnPropertyClassesAsync(t,n,r){let a=new Map;for(let p of n){let i=p.metadata.namespace_?.toString();i&&a.set(i,p)}let s=[],o=new Set;ne(t,({kanonak:p})=>{for(let i of p.unresolvedPredicates){let m=`${i.sourceDoc}::${i.key}`;o.has(m)||(o.add(m),s.push(i))}});let c=!1;for(let p of s){let i=a.get(p.sourceDoc);if(!i)continue;let m=await r.resolveEntityAsync(p.key,i);if(!m)continue;let d=A(m.uri);if(this.knownPropertyClasses.has(d))continue;let u=Y(t,m.uri);if(!u)continue;let l=Z(t,u);l&&(this.knownPropertyClasses.set(d,l),c=!0)}return c}async parseAllDocumentsAsync(t,n,r,a){let s=[];for(let o of t){let c=o.metadata.namespace_?.toString()??"";for(let[p,i]of Object.entries(o.body)){let m=new w,d=this.resolveCanonicalEntity(p,o,c);m.namespace=d.namespace,m.name=d.name,m.statement=[];let u=await this.parseStatements(i,o,n,r,a);m.statement.push(...u.statements),m.unresolvedPredicates=u.unresolved,F(m,c),s.push(m)}}return s}async mergeAndCanonicalizeAsync(t,n){let r=new Map,a=new Map,s=[];for(let i of t)if(i instanceof w){let m=`${i.namespace}/${i.name}`,d=r.get(m);if(d){let u=a.get(m);for(let l of i.statement){let y=$(l);u.has(y)||(u.add(y),d.statement.push(l))}for(let l of i.unresolvedPredicates)d.unresolvedPredicates.some(y=>y.key===l.key&&y.sourceDoc===l.sourceDoc)||d.unresolvedPredicates.push(l)}else{let u=new w;u.namespace=i.namespace,u.name=i.name,u.sourceDoc=i.sourceDoc;let l=new Set;for(let y of i.statement){let k=$(y);l.has(k)||(l.add(k),u.statement.push(y))}u.unresolvedPredicates=[...i.unresolvedPredicates],a.set(m,l),r.set(m,u),s.push(u)}}else s.push(i);let o=new Set;for(let i of s)if(i instanceof w){let m=i.namespace||"",d=m.indexOf("/"),u=d>=0?m.slice(0,d):"",l=d>=0?m.slice(d+1):"",y=l.indexOf("@"),k=y>=0?l.slice(0,y):l;o.add(`${u}/${k}/${i.name}`)}let c=i=>o.has(`${i.publisher}/${i.package_}/${i.name}`),p=new Map;for(let i of["core-rdf","core-owl","core-kanonak"]){let m=await n.getDocumentsByNamespaceAsync("kanonak.org",i);p.set(i,W(m).chosen?.metadata.namespace_?.version??void 0)}for(let i of t)i instanceof w&&this.canonicalizeStatementBuiltins(i.statement,c,p);return s}canonicalizeStatementBuiltins(t,n,r){for(let a of t){let s=a.predicate?.subject;if(N(s,n,r),a instanceof O)a.object instanceof g&&N(a.object.subject,n,r);else if(a instanceof K)a.object&&this.canonicalizeStatementBuiltins(a.object.statement,n,r);else if(a instanceof P)for(let o of a.object??[])o instanceof g?N(o.subject,n,r):o instanceof h&&this.canonicalizeStatementBuiltins(o.statement,n,r)}}resolveCanonicalEntity(t,n,r){if(!t.includes(".")||!n.metadata?.imports)return{namespace:r,name:t};let a=t.indexOf("."),s=t.substring(0,a),o=t.substring(a+1);for(let[c,p]of Object.entries(n.metadata.imports))for(let i of p)if((i.alias??i.packageName)===s){let d=i.version;return{namespace:`${c}/${i.packageName}@${d.major}.${d.minor}.${d.patch}`,name:o}}return{namespace:r,name:t}}async parseStatements(t,n,r,a,s){let o=[],c=[];if(typeof t!="object"||t===null||Array.isArray(t))return{statements:o,unresolved:c};let p=n.metadata.namespace_?.toString()??"";for(let[i,m]of Object.entries(t))try{let d=await this.getPropertyMetadata(i,n,r,s,a);if(!d){let l=i.includes(".")?i.slice(i.lastIndexOf(".")+1):i;Q(l)||c.push({key:i,sourceDoc:p});continue}let u=await this.parsePropertyValue(i,m,d,n,r,a,s);u&&o.push(u)}catch(d){throw new Error(`Failed to parse property '${i}': ${d.message}`,{cause:d})}return{statements:o,unresolved:c}}async getPropertyMetadata(t,n,r,a,s){let o=await r.resolveEntityAsync(t,n);if(!o)return;let c=o.entity,p=c.type?.toString()??"",i=p.includes(".")?p.substring(p.lastIndexOf(".")+1):p,m=new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]),d=this.knownPropertyClasses.get(A(o.uri));if(!m.has(i)&&!d)return;let u=d??s.getPropertyTypeClassification(p),l,y=async()=>{if(l)return l;if(!(o.isImported&&o.definedInNamespace))return l=n,n;if(typeof a.getDocumentAsync!="function")throw new Error(`Cannot resolve the range of imported property '${t}': the parse repository cannot fetch defining document '${o.definedInNamespace}'. Thread the real repository through to embedded-object parsing \u2014 no stub, no fallback.`);let v=await a.getDocumentAsync(o.definedInNamespace);if(!v)throw new Error(`Cannot resolve the range of imported property '${t}': defining document '${o.definedInNamespace}' was not found in the repository.`);return l=v,v},k=await this.readDefinitionSlot(c,me,y,r),b=k==null?void 0:String(k),D;if(u==="ObjectProperty")D="ObjectProperty";else if(u==="DatatypeProperty")D="DatatypeProperty";else{let v=b&&b.includes(".")?b.substring(b.lastIndexOf(".")+1):b??"";(b?s.isKnownXsdDatatypeName(b):!1)||v==="Literal"?D="DatatypeProperty":D="ObjectProperty"}let z;return b&&(z=(await r.resolveEntityAsync(b,await y()))?.uri),{propertyUri:o.uri.toString(),propertyType:D,range:b,rangeUri:z,isImported:o.isImported,definedInNamespace:o.definedInNamespace}}async readDefinitionSlot(t,n,r,a){let s=Object.keys(t).filter(i=>ue(i)===n.name);if(s.length===0)return;let o=await r(),c=U(n.name),p=c!==void 0&&c.publisher===n.publisher&&c.package_===n.package_;for(let i of s){let m=await a.resolveEntityAsync(i,o);if(m){if(x(m.uri,n))return t[i];continue}if(!i.includes(".")&&p)return t[i]}}async parsePropertyValue(t,n,r,a,s,o,c){let p=r.propertyUri;if(n!=null){if(Array.isArray(n))return this.parseListValue(p,n,r,a,s,o,c);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(p,n,r,a,s,o);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(p,n,r,a,s,o,c)}}async parseDatatypeValue(t,n,r,a,s,o){let c;if(typeof n=="string"){if(o.isSubstitutableDatatype(r.rangeUri))return await this.parseSubstitutableValue(t,n,a,s);c=n}else if(typeof n=="number"||typeof n=="boolean")c=String(n);else return;return this.typedScalarStatement(t,c,r)}typedScalarStatement(t,n,r){let a=g.parse(t),s=r.rangeUri?_(r.rangeUri):void 0;if(s===S.Boolean){let c=new E;return c.predicate=a,c.object=n==="true"||n==="1",c.carrier=s,c.lexical=n,c}if(s===S.Integer||s===S.Decimal||s===S.Double||s===S.Float){let c=new L;return c.predicate=a,c.object=Number(n),c.carrier=s,c.lexical=n,c}let o=R.parse(t,n);return s&&(o.carrier=s,o.lexical=n),o}typedListLiteral(t,n){let r=new j,a=n.rangeUri?_(n.rangeUri):void 0;return a===S.Boolean?r.value=t==="true"||t==="1":a===S.Integer||a===S.Decimal||a===S.Double||a===S.Float?r.value=Number(t):r.value=t,a&&(r.carrier=a,r.lexical=t),r}async parseSubstitutableValue(t,n,r,a){let s=new T;s.predicate=g.parse(t),s.object=n;for(let o of V(n)){let c=this.linkReference(o.reference,r);if(!c){let i=await a.resolveEntityAsync(o.reference,r);i&&(c=new g,c.subject=i.uri)}let p={reference:o.reference,startOffset:o.startOffset,endOffset:o.endOffset};o.displayText!==void 0&&(p.displayText=o.displayText),c!==void 0&&(p.target=c),s.links.push(p)}return s}async parseObjectValue(t,n,r,a,s,o,c){if(typeof n=="string"){if(r.rangeUri&&x(r.rangeUri,M.Expression))return this.coerceExpressionLiteral(t,n,r.rangeUri);let p=await this.resolveReference(n,a,s);if(!p)return;let i=new O;return i.predicate=g.parse(t),i.object=p,i}if(typeof n=="object"&&!Array.isArray(n)){let p=await this.parseStatements(n,a,s,o,c);if(p.statements.length>0){let d=new h;d.statement=p.statements,d.unresolvedPredicates=p.unresolved,r.rangeUri&&(d.rangeType=r.rangeUri);let u=new K;return u.predicate=g.parse(t),u.object=d,u}let i=[];for(let[d,u]of Object.entries(n))if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let l=new h;l.name=d,r.rangeUri&&(l.rangeType=r.rangeUri);let y=await this.parseStatements(u,a,s,o,c);l.statement=y.statements,l.unresolvedPredicates=y.unresolved,i.push(l)}else if(typeof u=="string"){let l=await this.resolveReference(u,a,s);l&&i.push(l)}if(i.length>0){let d=new P;return d.predicate=g.parse(t),d.object=i,d}let m=new K;return m.predicate=g.parse(t),m.object=new h,r.rangeUri&&(m.object.rangeType=r.rangeUri),m}}coerceExpressionLiteral(t,n,r){let a=new h,s=new O,o=new g;o.subject=new I("kanonak.org","core-rdf","type"),s.predicate=o;let c=new g;c.subject=new I(r.publisher,r.package_,M.StringLiteral.name,r.version),s.object=c;let p=new R,i=new g;i.subject=new I(r.publisher,r.package_,M.stringLiteral.name,r.version),p.predicate=i,p.object=n,a.statement=[s,p];let m=new K;return m.predicate=g.parse(t),m.object=a,m}async parseListValue(t,n,r,a,s,o,c){let p=[],i=r.propertyType==="DatatypeProperty",m=r.rangeUri?.publisher==="kanonak.org"&&r.rangeUri?.package_==="core-rdf"&&r.rangeUri?.name==="List"||!r.rangeUri&&(r.range?.includes(".")?r.range.substring(r.range.lastIndexOf(".")+1):r.range)==="List";for(let u of n){let l=typeof u=="string"||typeof u=="number"||typeof u=="boolean";if(i&&l){let y=typeof u=="string"?u:String(u);p.push(this.typedListLiteral(y,r));continue}if(m&&l){if(typeof u=="string"){let y=await s.resolveEntityAsync(u,a);if(y){let k=new g;k.subject=y.uri,p.push(k)}else{let k=new j;k.value=u,p.push(k)}}else{let y=new j;y.value=u,p.push(y)}continue}if(typeof u=="string"){let y=await this.resolveReference(u,a,s);y&&p.push(y)}else if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let y=new h;r.rangeUri&&(y.rangeType=r.rangeUri);let k=await this.parseStatements(u,a,s,o,c);y.statement=k.statements,y.unresolvedPredicates=k.unresolved,p.push(y)}}let d=new P;return d.predicate=g.parse(t),d.object=p,d}linkReference(t,n){let r=t.indexOf(".");if(r<=0||!n.metadata?.imports)return;let a=t.substring(0,r),s=t.substring(r+1);for(let[o,c]of Object.entries(n.metadata.imports))for(let p of c){if(!G(p)||(p.alias??p.packageName)!==a)continue;let i=new g,m=p.versionOperator===fe.Exact?p.version:void 0;return i.subject=new I(o,p.packageName,s,m),i}}async resolveReference(t,n,r){let a=this.linkReference(t,n);if(a)return a;let s=await r.resolveEntityAsync(t,n);if(s){let c=new g;return c.subject=s.uri,c}let o=n.metadata?.namespace_;if(o){let{KanonakUri:c}=await import("./KanonakUri-4VJGV3FN.js");if(t.includes(".")){let i=t.indexOf("."),m=t.substring(0,i),d=t.substring(i+1);if(n.metadata?.imports){for(let[u,l]of Object.entries(n.metadata.imports))for(let y of l)if((y.alias??y.packageName)===m){let b=new g;return b.subject=new c(u,y.packageName,d,y.version),b}}}let p=new g;return p.subject=new c(o.publisher,o.package_,t,o.version??void 0),p}return null}async saveKanonaks(t,n){let r=new Map;for(let a of t)a instanceof w&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,s]of r){let o=await this.convertKanonaksToDocument(a,s),c=`${a.split("@")[0]}.yml`;await n.saveDocumentAsync(o,c)}}async serializeToYaml(t,n){let r=t.filter(o=>o instanceof w&&o.namespace===n);if(r.length===0)throw new Error(`No kanonaks found with namespace '${n}'`);let a=await this.convertKanonaksToDocument(n,r);return new X().save(a)}async convertKanonaksToDocument(t,n){let a={metadata:{namespace_:t,get allImports(){if(!this.imports)return[];let o=[];for(let c of Object.values(this.imports))o.push(...c);return o}},body:{}},s=new Map;for(let o of n){let c={};for(let p of o.statement){let[i,m]=this.convertStatementToProperty(p);i&&m!==null&&m!==void 0&&(c[i]=m),this.collectImportsFromStatement(p,t,s)}a.body[o.name]=c}return a}convertStatementToProperty(t){if(t instanceof R)return[t.predicate.subject.name,t.object];if(t instanceof L)return[t.predicate.subject.name,t.object];if(t instanceof E)return[t.predicate.subject.name,t.object];if(t instanceof O)return[t.predicate.subject.name,t.object.subject.name];if(t instanceof P){let n=this.convertKanonakListToValue(t.object);return[t.predicate.subject.name,n]}else if(t instanceof K){let n=this.convertEmbeddedKanonakToValue(t.object);return[t.predicate.subject.name,n]}return[null,null]}convertKanonakListToValue(t){let n=[];for(let r of t)r instanceof g?n.push(r.subject.name):r instanceof h&&n.push(this.convertEmbeddedKanonakToValue(r));return n}convertEmbeddedKanonakToValue(t){let n={};for(let r of t.statement){let[a,s]=this.convertStatementToProperty(r);a&&s!==null&&s!==void 0&&(n[a]=s)}return n}collectImportsFromStatement(t,n,r){}};function F(f,t){f.sourceDoc=t;for(let n of f.statement)if(n instanceof K)F(n.object,t);else if(n instanceof P)for(let r of n.object)r instanceof h&&F(r,t)}function $(f){let t=f.predicate?.subject;return(t?`${t.publisher}/${t.package_}/${t.name}`:"?")+"="+de(f)}function de(f){return f instanceof T?"m:"+String(f.object):f instanceof R?"s:"+String(f.object):f instanceof L?"n:"+String(f.object):f instanceof E?"b:"+String(f.object):f instanceof O?"r:"+C(f.object):f instanceof K?"e:"+C(f.object):f instanceof P?"l:["+(f.object??[]).map(C).join("|")+"]":"x"}function C(f){if(!f)return"";if(f instanceof g){let t=f.subject;return"R("+(t?`${t.publisher}/${t.package_}/${t.name}`:"")+")"}return f instanceof h?"E("+(f.statement??[]).map($).join(";")+")":f instanceof j?"L("+String(f.value)+")":"N"}export{j as a,T as b,ne as c,ae as d,oe as e,we as f,M as g,S as h,_ as i,je as j,V as k,re as l};
|
package/dist/chunk-CJMVIOZX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./chunk-FUUTGGJS.js";import{c as U,g as S}from"./chunk-QILEJIFU.js";var p=class{};var m=class extends p{statement=[];unresolvedPredicates=[];sourceDoc=""};var f=class extends m{namespace;name;icon};var a=class e extends p{subject;static parse(n){let t=new e;return t.subject=h.parse(n),t}};var s=class{predicate;object};var c=class extends s{carrier;lexical};var y=class e extends c{static parse(n,t){let r=new e;return r.predicate=a.parse(n),r.object=t,r}};var k=class e extends c{static parse(n,t){let r=new e;return r.predicate=a.parse(n),r.object=t,r}};var b=class extends c{};var u=class e extends s{static parse(n,t){let r=new e;return r.predicate=a.parse(n),r.object=a.parse(t),r}};var g=class extends s{};var l=class extends s{};function $(e){return`${e.publisher}/${e.package_}/${e.name}`}function K(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}function A(e){let n=e.version;return n&&typeof n.major=="number"?`https://${e.publisher}/${e.package_}/${n.major}.${n.minor}.${n.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function P(e){return D(e,v)}var v={publisher:"kanonak.org",package_:"core-rdf",name:"type"};function D(e,n){if(!(e instanceof m))return[];let t=[];for(let r of e.statement){let o=r.predicate;if(!(!o?.subject||!K(o.subject,n))){if(r instanceof u)t.push(r.object.subject);else if(r instanceof l)for(let i of r.object)i instanceof a&&t.push(i.subject)}}return t}function R(e,n){if(!(e instanceof m))return!1;for(let t of e.statement)if(t.predicate?.subject?.name==="type"&&t instanceof u){let o=t.object;if(K(o.subject,n))return!0}return!1}function I(e,n){let t=[];for(let r of e)r instanceof f&&R(r,n)&&t.push(r);return t}function V(e,n){let t=n.version,r=t&&typeof t.major=="number"?`${n.publisher}/${n.package_}@${t.major}.${t.minor}.${t.patch}`:void 0;for(let o of e){if(!(o instanceof f)||o.name!==n.name)continue;let i=o.namespace||"";if(r!==void 0){if(i===r)return o}else if(i.startsWith(`${n.publisher}/${n.package_}@`))return o}}function w(e,n){let t=[];for(let r of e){if(!(r instanceof f)||r.name!==n.name)continue;(r.namespace||"").startsWith(`${n.publisher}/${n.package_}@`)&&t.push(r)}return t.sort((r,o)=>{let i=S((r.namespace||"").split("@")[1]??""),j=S((o.namespace||"").split("@")[1]??"");return i?j?U(j,i):-1:j?1:0}),t}function d(e,n){for(let t of e.statement){let r=t.predicate;if(r?.subject&&K(r.subject,n))return t}}function C(e,n){return d(e,n)!==void 0}function E(e,n){let t=d(e,n);if(t&&(t instanceof y||t instanceof k||t instanceof b))return t.object}function _(e,n){let t=E(e,n);return typeof t=="string"?t:void 0}function T(e,n){let t=d(e,n);if(t instanceof u)return t.object.subject}function B(e,n){let t=d(e,n);if(t instanceof g)return t.object}function N(e,n){let t=d(e,n);return t instanceof l?t.object??[]:[]}var x=class{constructor(n,t){this.doc=n;this.broader=t}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(n){return this.broader.getDocumentAsync(n)}async getDocumentsByNamespaceAsync(n,t){return this.broader.getDocumentsByNamespaceAsync(n,t)}async getHighestCompatibleVersionAsync(n,t){return this.broader.getHighestCompatibleVersionAsync(n,t)}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(n){return this.broader.getDocumentContentAsync(n)}async getDocumentUriAsync(n){return this.broader.getDocumentUriAsync(n)}};export{p as a,m as b,f as c,a as d,s as e,c as f,y as g,k as h,b as i,u as j,g as k,l,$ as m,K as n,A as o,P as p,D as q,R as r,I as s,V as t,w as u,d as v,C as w,E as x,_ as y,T as z,B as A,N as B,x as C};
|
package/dist/chunk-ESABMC5L.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as J,b as X,c as Y,d as q,m as b,n as W,p as Q,t as z,u as j,y as M,z as w}from"./chunk-CJMVIOZX.js";import{a as _}from"./chunk-FUUTGGJS.js";import{b as I}from"./chunk-F67UH4FD.js";var H=class extends X{name;rangeType};var Z=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let r=n.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(r);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(r,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let r=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],u=await this.findDocumentForAlias(n,a);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,r){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=r.length===0?a:`${r} \u2192 ${a}`;for(let[u,c]of Object.entries(e.body))if(!u.includes(".")&&c&&typeof c=="object"&&!Array.isArray(c)){if(!e.metadata.namespace_)continue;let g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};s.push({entityName:u,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,g),entity:c,definedInNamespace:a,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,g)=>c+g.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${a}`);for(let[c,g]of Object.entries(e.metadata.imports))for(let m of g)if(!I(m))try{this.logger?.debug?.(`Resolving import: ${c}/${m.packageName}`);let d=await this.repository.getHighestCompatibleVersionAsync(c,m);if(d){this.logger?.debug?.(`Successfully loaded import: ${d.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(d,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${d.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${m.packageName}`)}catch(d){let k=d;throw this.logger?.error?.(`Failed to process import ${c}/${m.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${m.packageName} for namespace ${a}. See inner exception for details.`,{cause:d})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,r,s){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let u=s.get(i);if(u)return u;n.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,g=0;for(let[m,d]of Object.entries(e.body))if(!m.includes(".")&&d&&typeof d=="object"&&!Array.isArray(d)){if(!e.metadata.namespace_)continue;if(!a.has(m)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(m,{entityName:m,uri:new _(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,m,k),entity:d,definedInNamespace:i,isImported:r.length>0,importPath:c}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let m=Object.values(e.metadata.imports).reduce((d,k)=>d+k.length,0);this.logger?.debug?.(`Processing ${m} import(s) for ${i}`);for(let[d,k]of Object.entries(e.metadata.imports))for(let S of k)if(!I(S))try{this.logger?.debug?.(`Resolving import: ${d}/${S.packageName}`);let P=await this.repository.getHighestCompatibleVersionAsync(d,S);if(P){this.logger?.debug?.(`Successfully loaded import: ${P.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(P,n,c,s),v=0;for(let[x,C]of U.entries()){let h=a.get(x);if(!h)a.set(x,C),v++;else if(h.isImported&&C.isImported&&(h.uri.publisher!==C.uri.publisher||h.uri.package_!==C.uri.package_)){let K=h.isAmbiguous?h:{...h,isAmbiguous:!0,ambiguousNamespaces:[h.definedInNamespace]};K.ambiguousNamespaces.includes(C.definedInNamespace)||K.ambiguousNamespaces.push(C.definedInNamespace),a.set(x,K),this.logger?.warn?.(`Ambiguous reference '${x}': defined in ${K.ambiguousNamespaces.join(", ")}`)}if(S.alias&&!x.includes(".")){let K=`${S.alias}.${x}`;a.has(K)||(a.set(K,C),v++)}}this.logger?.debug?.(`Merged ${v} entities from import ${P.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${d}/${S.packageName}`)}catch(P){let U=P;throw this.logger?.error?.(`Failed to process import ${d}/${S.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${d}/${S.packageName} for namespace ${i}. See inner exception for details.`,{cause:P})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[r,s]of Object.entries(e.metadata.imports))for(let a of s)if(!I(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(r,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(r,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var ee=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","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"&&t.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 t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let r=await this.resourceResolver.resolveEntityAsync(e,n);if(r){let s=r.entity.type;if(s){let a=String(s);return a==="Class"||a==="rdfs.Class"||a.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,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function te(t){if(!t||t.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let e=t.trim(),n=e.split("/");if(n.length===1){let r=n[0];if(!r)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${t}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(n.length===2){let[r,s]=n;if(!r||!s)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let a=s.indexOf("@");if(a===-1)return{kind:"package",publisher:r,package_:s};let i=s.substring(0,a),u=s.substring(a+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${t}". Expected publisher/package[@version].`);let c=pe(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:_.parse(e)}}function ve(t){switch(t.kind){case"publisher":return t.publisher;case"package":return t.version?`${t.publisher}/${t.package_}@${t.version.major}.${t.version.minor}.${t.version.patch}`:`${t.publisher}/${t.package_}`;case"resource":return t.uri.toString()}}function pe(t){let e=t.split(".").map(Number);return ce(e[0]||0,e[1]||0,e[2]||0)}function ce(t,e,n){return{major:t,minor:e,patch:n,toString:()=>`${t}.${e}.${n}`,equals:r=>!r||typeof r!="object"?!1:r.major===t&&r.minor===e&&r.patch===n,getHashCode:()=>t<<20|e<<10|n,compareTo:r=>t!==r.major?t-r.major:e!==r.minor?e-r.minor:n-r.patch}}function Me(t){return`${t.publisher}/${t.package_}/${t.name}`}function y(t,e,n){return`${t}/${e}/${n}`}function we(t){return`${t.s}|${t.p}|${le(t.o)}`}function le(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function Le(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var ue="kanonak.org",ye="core-shacl",o=t=>({publisher:ue,package_:ye,name:t}),D=o("Shape"),T=o("NodeShape"),N=o("PropertyShape"),Fe=o("targetClass"),Be=o("property"),Ge=o("path"),Xe=o("minCount"),Ye=o("maxCount"),qe=o("datatype"),We=o("class"),Qe=o("in"),ze=o("pattern"),Je=o("flags"),Ze=o("minLength"),et=o("maxLength"),tt=o("minInclusive"),nt=o("maxInclusive"),rt=o("message"),ot=o("targetNode"),at=o("targetSubjectsOf"),st=o("targetObjectsOf"),it=o("closed"),pt=o("ignoredProperties"),ct=o("nodeKind"),lt=o("IRI"),ut=o("BlankNode"),yt=o("Literal"),dt=o("severity"),mt=o("Violation"),gt=o("Warning"),ft=o("Info"),kt=o("ValidationReport"),bt=o("conforms"),St=o("result"),ht=o("ValidationResult"),_t=o("focusNode"),Pt=o("resultPath"),Ct=o("resultMessage"),Kt=o("resultSeverity"),Et=o("sourceShape"),At=o("value"),xt=o("sourceConstraintComponent"),Rt=o("MinCountConstraintComponent"),Ot=o("MaxCountConstraintComponent"),Ut=o("DatatypeConstraintComponent"),It=o("ClassConstraintComponent"),Ht=o("InConstraintComponent"),Dt=o("PatternConstraintComponent"),Tt=o("MinLengthConstraintComponent"),Nt=o("MaxLengthConstraintComponent"),$t=o("MinInclusiveConstraintComponent"),vt=o("MaxInclusiveConstraintComponent"),jt=o("NodeKindConstraintComponent"),Mt=o("ClosedConstraintComponent"),wt=o("hasValue"),Lt=o("qualifiedValueShape"),Vt=o("qualifiedMinCount"),Ft=o("qualifiedMaxCount"),Bt=o("HasValueConstraintComponent"),Gt=o("QualifiedMinCountConstraintComponent"),Xt=o("QualifiedMaxCountConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",re="core-kanonak",V=new Map([["type",p],["subClassOf",p],["subPropertyOf",p],["domain",p],["range",p],["label",p],["comment",p],["seeAlso",p],["isDefinedBy",p],["member",p],["Resource",p],["Class",p],["Property",p],["Datatype",p],["Literal",p],["List",p],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",re]]),de=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function Qt(t){return V.has(t)}function zt(t){let e=V.get(t);return e?{publisher:l,package_:e}:void 0}function F(t,e,n){if(!t||!t.name)return;let r=V.get(t.name);if(!r)return;let s=()=>{t.publisher=l,t.package_=r,n&&(t.version=n.get(r))};if(de.has(t.name)){let a=t.publisher===l&&t.package_===r;t.publisher=l,t.package_=r,!a&&n&&(t.version=n.get(r));return}t.publisher===l&&t.package_===r||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var ne=class{type=y(l,p,"type");subClassOf=y(l,p,"subClassOf");subPropertyOf=y(l,p,"subPropertyOf");domain=y(l,p,"domain");range=y(l,p,"range");label=y(l,p,"label");comment=y(l,p,"comment");resource=y(l,p,"Resource");class_=y(l,p,"Class");datatype=y(l,p,"Datatype");literal=y(l,p,"Literal");equivalentClass=y(l,f,"equivalentClass");equivalentProperty=y(l,f,"equivalentProperty");inverseOf=y(l,f,"inverseOf");sameAs=y(l,f,"sameAs");transitiveProperty=y(l,f,"TransitiveProperty");symmetricProperty=y(l,f,"SymmetricProperty");objectProperty=y(l,f,"ObjectProperty");datatypeProperty=y(l,f,"DatatypeProperty");annotationProperty=y(l,f,"AnnotationProperty");package_=y(l,re,"Package");shape=L(D);nodeShape=L(T);propertyShape=L(N)};function L(t){return y(t.publisher,t.package_,t.name)}var me=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return F(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ae(t)[0]??null}function ae(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?Q(t).map(n=>{let r={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return F(r),{publisher:r.publisher,package_:r.package_,name:r.name}}):[]}var ge=[D,T,N];function O(t,e){return me.has(`${t}/${e}`)}var fe=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function B(t){if(O(t.publisher,t.package_))return fe.has(t.name)?t.name:void 0}var oe=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ae(e).some(r=>O(r.publisher,r.package_)&&r.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ge.some(r=>W(n,r)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let r=R(e);return r?n.has(r.name):!1}};var E="kanonak.org",A="core-rdf",ke={publisher:E,package_:A,name:"domain"},be={publisher:E,package_:A,name:"range"},Se={publisher:E,package_:A,name:"subClassOf"},he={publisher:E,package_:A,name:"type"},_e={publisher:E,package_:A,name:"label"},Pe={publisher:E,package_:A,name:"comment"},Ce=new _(E,A,"Resource");function Ke(t){try{let e=te(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function G(t,e){let n=w(t,e);if(n)return[n];let r=[];for(let s of J(t,e))s instanceof q&&r.push(s.subject);return r}function ie(t,e){let n=[],r=new Set,s="version"in e?e.version:void 0,a=[new _(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),u=b(i);if(r.has(u))continue;r.add(u),n.push(i);let c=Ee(t,i);c&&a.push(...G(c,Se))}return n}function Ee(t,e){return e.version&&typeof e.version.major=="number"?z(t,e)??j(t,e)[0]:j(t,e)[0]}function $(t,e){let n;for(let r of Oe(e)){let s=Ae(t,r);if(s){if(s!=="Property")return s;n??=s}}return n}function Ae(t,e){let n=B(e);if(n)return n;let r=se.get(t);r||(r=new Map,se.set(t,r));let s=e.version,a=s&&typeof s.major=="number"?`${b(e)}@${s.major}.${s.minor}.${s.patch}`:b(e),i=r.get(a);if(i!==void 0)return i??void 0;let u;for(let c of ie(t,e)){let g=B(c);if(g){if(g!=="Property"){u=g;break}u??="Property"}}return r.set(a,u??null),u}var se=new WeakMap;function yn(t,e){return $(t,e)!==void 0}function dn(t,e){return $(t,e)==="ObjectProperty"}function mn(t,e){return $(t,e)==="DatatypeProperty"}function xe(t,e){let n=new Set([b(Ce)]);for(let r of ie(t,e))n.add(b(r));return n}function Re(t,e){let n=xe(t,e),r=[],s=new Set;for(let a of t){if(!(a instanceof Y))continue;let i=$(t,a);if(!i)continue;let u=G(a,ke);if(!u.some(m=>n.has(b(m))))continue;let c=Ke(a);if(!c)continue;let g=b(c);s.has(g)||(s.add(g),r.push({uri:c,label:M(a,_e),comment:M(a,Pe),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:w(a,be),domains:u}))}return r}function gn(t,e,n){let r=Re(t,e).find(s=>b(s.uri)===b(n));return r?{ok:!0,descriptor:r}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Oe(t){let e=G(t,he);return e.length>0?e:t instanceof H&&t.rangeType?[t.rangeType]:[]}export{H as a,Z as b,ee as c,te as d,ve as e,Me as f,y as g,we as h,le as i,Le as j,ue as k,ye as l,D as m,T as n,N as o,Fe as p,Be as q,Ge as r,Xe as s,Ye as t,qe as u,We as v,Qe as w,ze as x,Je as y,Ze as z,et as A,tt as B,nt as C,rt as D,ot as E,at as F,st as G,it as H,pt as I,ct as J,lt as K,ut as L,yt as M,dt as N,mt as O,gt as P,ft as Q,Rt as R,Ot as S,Ut as T,It as U,Ht as V,Dt as W,Tt as X,Nt as Y,$t as Z,vt as _,jt as $,Mt as aa,wt as ba,Lt as ca,Vt as da,Ft as ea,Bt as fa,Gt as ga,Xt as ha,Qt as ia,zt as ja,F as ka,ne as la,B as ma,oe as na,Ke as oa,ie as pa,$ as qa,yn as ra,dn as sa,mn as ta,Re as ua,gn as va,Oe as wa};
|