@kanonak-protocol/sdk 5.26.0 → 5.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-BA4HAURJ.js +1 -0
  3. package/dist/{chunk-Q3TDDWKS.js → chunk-GJAYU443.js} +1 -1
  4. package/dist/{chunk-WVXOHCW2.js → chunk-KDMBMX3J.js} +1 -1
  5. package/dist/chunk-N3XODYH5.js +1 -0
  6. package/dist/{chunk-HND3PKKR.js → chunk-RJK6Y4HS.js} +1 -1
  7. package/dist/{chunk-ZUWSZQAJ.js → chunk-S2VGNHHF.js} +1 -1
  8. package/dist/chunk-SR6I5ZSI.js +68 -0
  9. package/dist/chunk-SUXSCSHO.js +1 -0
  10. package/dist/chunk-TW7NJDMW.js +152 -0
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/kanonaks/walkDefinedKanonaks.d.ts +10 -1
  14. package/dist/look/LookRenderer.d.ts +36 -0
  15. package/dist/look/displayValue.d.ts +3 -5
  16. package/dist/parsing/index.js +1 -1
  17. package/dist/reasoning/index.js +1 -1
  18. package/dist/resolution/index.js +1 -1
  19. package/dist/search/index.js +1 -1
  20. package/dist/server/index.js +18 -10
  21. package/dist/server/renderDiagnostics.d.ts +10 -0
  22. package/dist/transformations/index.js +2 -2
  23. package/dist/transformations/v3/CompiledTransformationV3.d.ts +17 -1
  24. package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +5 -0
  25. package/dist/uri-helpers/UriHelpers.d.ts +19 -0
  26. package/dist/uri-helpers/index.d.ts +1 -1
  27. package/dist/uri-helpers/index.js +1 -1
  28. package/dist/validation/index.d.ts +1 -1
  29. package/dist/validation/index.js +1 -1
  30. package/dist/validation/rules/repository/TxExpressionCompilesRule.d.ts +62 -0
  31. package/dist/validation/rules/repository/index.d.ts +1 -0
  32. package/package.json +2 -2
  33. package/dist/chunk-AUXSXDZB.js +0 -152
  34. package/dist/chunk-CYXNYNE7.js +0 -63
  35. package/dist/chunk-EKSYQ6CU.js +0 -1
  36. package/dist/chunk-H6UAD2LP.js +0 -1
  37. package/dist/chunk-ITI65NHP.js +0 -1
@@ -90,7 +90,7 @@ export interface CompiledFormatOverrideV3 {
90
90
  * doctype + style + metadata <dl>; analogous in other backends). */
91
91
  omitWrapper?: boolean | undefined;
92
92
  }
93
- export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledUnescapedStringV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledIsStringV3 | CompiledIsNumberV3 | CompiledIsBooleanV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
93
+ export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledUnescapedStringV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledNumberFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledIsStringV3 | CompiledIsNumberV3 | CompiledIsBooleanV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
94
94
  export interface CompiledStringLiteralV3 {
95
95
  kind: 'string-literal';
96
96
  value: string;
@@ -212,6 +212,22 @@ export interface CompiledDateFormatV3 {
212
212
  source: CompiledExpressionV3;
213
213
  format: DateFormatKindV3;
214
214
  }
215
+ /**
216
+ * Presentation styles for the NumberFormat primitive. Deliberately
217
+ * ORTHOGONAL to `fractionDigits`: a style says how the number is scaled and
218
+ * decorated, precision is a separate slot, so any style composes with any
219
+ * precision without a named format per pair (`percent-1`, `percent-2`, …).
220
+ */
221
+ export type NumberStyleV3 = 'decimal' | 'percent' | 'basis-points' | 'currency' | 'compact';
222
+ export interface CompiledNumberFormatV3 {
223
+ kind: 'number-format';
224
+ source: CompiledExpressionV3;
225
+ style: NumberStyleV3;
226
+ /** Undefined = render the number's own digits, no padding or rounding. */
227
+ fractionDigits?: number;
228
+ /** ISO 4217; only meaningful for the `currency` style. Defaults to USD. */
229
+ currencyCode?: string;
230
+ }
215
231
  export interface CompiledAddV3 {
216
232
  kind: 'add';
217
233
  left: CompiledExpressionV3;
@@ -151,6 +151,11 @@ export declare const TX_V3: {
151
151
  readonly DateFormat: EntityUri;
152
152
  readonly dateSource: EntityUri;
153
153
  readonly dateFormat: EntityUri;
154
+ readonly NumberFormat: EntityUri;
155
+ readonly numberSource: EntityUri;
156
+ readonly numberStyle: EntityUri;
157
+ readonly fractionDigits: EntityUri;
158
+ readonly currencyCode: EntityUri;
154
159
  readonly BinaryArithmetic: EntityUri;
155
160
  readonly arithLeft: EntityUri;
156
161
  readonly arithRight: EntityUri;
@@ -55,6 +55,25 @@ export declare function toCanonicalUrl(uri: CanonicalUriParts): string;
55
55
  * True when a `Kanonak` is a `DefinedKanonak` whose `type` statement's
56
56
  * object URI matches the given class URI.
57
57
  */
58
+ /**
59
+ * The canonical URIs of a defined kanonak's declared type(s), whether the
60
+ * `type` statement was authored as a single reference or a list.
61
+ *
62
+ * THE one way to ask "what is this?" before a subsumption walk. Three private
63
+ * copies of this read had grown up independently (`LookRenderer`,
64
+ * `findDerivation`, `look/displayValue`); consolidating them is tracked
65
+ * separately — new code uses this.
66
+ */
67
+ export declare function typeReferenceUris(kanonak: Kanonak): KanonakUri[];
68
+ /**
69
+ * The canonical URIs a reference-valued property points at, whether it was
70
+ * authored as a single reference or a list. Non-reference values are skipped.
71
+ *
72
+ * THE one way to read "which resources does this property name?" — the shape
73
+ * every cascade needs before a `subClassOf` or type walk.
74
+ * {@link typeReferenceUris} is the `rdf:type` case by name.
75
+ */
76
+ export declare function referenceUris(kanonak: Kanonak, property: EntityUri): KanonakUri[];
58
77
  export declare function hasType(kanonak: Kanonak, target: EntityUri): boolean;
59
78
  /**
60
79
  * Filter a list of parsed kanonaks down to `SubjectKanonak`s whose type
@@ -1,3 +1,3 @@
1
- export { uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
1
+ export { typeReferenceUris, referenceUris, uriKey, uriMatches, toCanonicalUrl, hasType, hasProperty, findSubjectsByType, findSubjectByUri, findAllResourcesByCanonicalUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
2
2
  export type { EntityUri, CanonicalUriParts } from './UriHelpers.js';
3
3
  export { SingleDocumentRepository } from './SingleDocumentRepository.js';
@@ -1 +1 @@
1
- import{m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"../chunk-H6UAD2LP.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{n as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,i as getDatatypeValue,l as getEmbeddedValue,m as getListValues,k as getReferenceUri,j as getStringValue,h as hasProperty,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
1
+ import{A as o,B as p,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{p as SingleDocumentRepository,i as findAllResourcesByCanonicalUri,h as findSubjectByUri,g as findSubjectsByType,k as getDatatypeValue,n as getEmbeddedValue,o as getListValues,m as getReferenceUri,l as getStringValue,j as hasProperty,f as hasType,e as referenceUris,c as toCanonicalUrl,d as typeReferenceUris,a as uriKey,b as uriMatches};
@@ -8,4 +8,4 @@ export { KanonakObjectValidator } from './KanonakObjectValidator.js';
8
8
  export type { IDocumentValidationRule } from './rules/document/IDocumentValidationRule.js';
9
9
  export type { IRepositoryValidationRule } from './rules/repository/IRepositoryValidationRule.js';
10
10
  export { NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule, PackageHeaderRule } from './rules/document/index.js';
11
- export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, UnresolvedPredicateRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyKindRangeConsistencyRule, ReservedNameShadowRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, LookBandPathRule, TxExpressionPathRule, ShaclShapeRule, OwlOneOfRule, DiamondNameClashRule } from './rules/repository/index.js';
11
+ export { ImportExistenceRule, UnresolvedReferenceRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, UnresolvedPredicateRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyKindRangeConsistencyRule, ReservedNameShadowRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule, DisplayLensScopeRule, LookSemanticSvgPathRule, TxExpressionCompilesRule, LookBandPathRule, TxExpressionPathRule, ShaclShapeRule, OwlOneOfRule, DiamondNameClashRule } from './rules/repository/index.js';
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,K as I,L as J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-CYXNYNE7.js";import"../chunk-BRCVOR7A.js";import"../chunk-AUXSXDZB.js";import"../chunk-6VIUXP4N.js";import"../chunk-ITI65NHP.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import"../chunk-EKSYQ6CU.js";import"../chunk-H6UAD2LP.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,I as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,J as KanonakObjectValidator,E as LookBandPathRule,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,H as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,G as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,F as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
1
+ import{A,B,C,D,E,F,G,H,I,L as J,M as K,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-SR6I5ZSI.js";import"../chunk-BRCVOR7A.js";import"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,J as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,K as KanonakObjectValidator,F as LookBandPathRule,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,I as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,H as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,E as TxExpressionCompilesRule,G as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
@@ -0,0 +1,62 @@
1
+ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
2
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
3
+ import { OntologyValidationError } from '../../OntologyValidationError.js';
4
+ import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
5
+ import type { ValidationCache } from '../../ValidationCache.js';
6
+ /**
7
+ * Every authored `tx.Expression` must COMPILE — checked at
8
+ * `kanonak validate` time, where the author can act on it
9
+ * (kanonak-protocol/typescript#107 A1).
10
+ *
11
+ * `TransformationLoaderV3` already refuses an expression whose node class
12
+ * no runner implements, with a message naming the offending node. What was
13
+ * missing is anyone asking it before render. `math@1.0.0` extends `tx`
14
+ * exactly as designed — its classes subclass `tx.UnaryNumericOp` and reuse
15
+ * `tx.value` — so every structural rule passed it, `kanonak validate`
16
+ * reported 0 errors, and the failure only appeared as a value silently
17
+ * absent from a rendered page.
18
+ *
19
+ * This rule closes the gap by ATTEMPTING THE COMPILE rather than keeping a
20
+ * second list of node classes. The loader is the one authority on what the
21
+ * runner implements; a parallel list here would drift from it the moment a
22
+ * primitive is added (`feedback_one_canonical_way`), and drift in a
23
+ * validator is worse than no validator — it would pass authored input the
24
+ * runner then rejects.
25
+ *
26
+ * Scope: expression ROOTS only. An expression tree is compiled from its
27
+ * root, and the loader's error already carries the path to the offending
28
+ * node inside it, so compiling nested nodes independently would report one
29
+ * problem several times. A node is a root when its parent is not itself an
30
+ * expression — determined by object identity during the walk, not by
31
+ * naming the properties that carry expressions (which would be a magic-
32
+ * string list, and would miss every slot added later).
33
+ *
34
+ * Sibling rules cover the INSIDE of an expression that does compile:
35
+ * `TxExpressionPathRule` and `LookSemanticSvgPathRule` check that each
36
+ * `PropertyRead` / `Traverse` step is in scope for its context type. This
37
+ * rule is the prior question — whether the tree is a tree the runner can
38
+ * even build.
39
+ *
40
+ * SCOPE — and why this rule is NOT "every tx.Expression must compile".
41
+ *
42
+ * `tx.Expression` is open for extension: a publisher may subclass it with
43
+ * their own node classes and evaluate them with their OWN runner. That is the
44
+ * designed pattern, stated by `kanonak.org/math` itself — "the per-language
45
+ * primitive implementations live in the runners, keyed on the node class" —
46
+ * and it is in real use (e.g. a streaming vocabulary whose `VarRef` is
47
+ * `subClassOf tx.Expression`, evaluated by a stream processor that has never
48
+ * heard of this SDK).
49
+ *
50
+ * So the v3 loader is the authority on what THIS SDK's engine implements, and
51
+ * on nothing else. An expression carried by someone else's property is not
52
+ * this validator's business, and flagging it was a closed-world assumption in
53
+ * an open-world protocol. The rule therefore checks only expressions sitting
54
+ * in a slot one of the SDK's three consumers will actually evaluate
55
+ * ({@link SDK_EVALUATED_VOCABULARIES}) — where an uncompilable tree really
56
+ * does mean a value that silently never appears.
57
+ */
58
+ export declare class TxExpressionCompilesRule implements IRepositoryValidationRule {
59
+ readonly ruleName = "TxExpressionCompiles";
60
+ validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<OntologyValidationError[]>;
61
+ private toError;
62
+ }
@@ -19,6 +19,7 @@ export { EmbeddedKanonakTypeRule } from './EmbeddedKanonakTypeRule.js';
19
19
  export { MarkdownLinkRule } from './MarkdownLinkRule.js';
20
20
  export { DisplayLensScopeRule } from './DisplayLensScopeRule.js';
21
21
  export { LookSemanticSvgPathRule } from './LookSemanticSvgPathRule.js';
22
+ export { TxExpressionCompilesRule } from './TxExpressionCompilesRule.js';
22
23
  export { LookBandPathRule } from './LookBandPathRule.js';
23
24
  export { UnrenderableBandRule } from './UnrenderableBandRule.js';
24
25
  export { TxExpressionPathRule } from './TxExpressionPathRule.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "5.26.0",
3
+ "version": "5.28.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",
@@ -126,7 +126,7 @@
126
126
  ],
127
127
  "dependencies": {
128
128
  "@kanonak-protocol/canonical": "^0.1.3",
129
- "@kanonak-protocol/types": "^5.26.0",
129
+ "@kanonak-protocol/types": "^5.28.0",
130
130
  "ignore": "^7.0.5",
131
131
  "js-yaml": "^4.1.0",
132
132
  "yaml": "^2.7.0",