@kanonak-protocol/sdk 3.11.0 → 3.12.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/KanonakUri-4VJGV3FN.js +1 -0
- package/dist/browser.js +2 -48
- package/dist/chunk-3JRHG2JH.js +1 -0
- package/dist/chunk-7M7XXZOV.js +1 -0
- package/dist/chunk-AFF2TQ7Y.js +2 -0
- package/dist/chunk-C54LRL2A.js +42 -0
- package/dist/chunk-CNM3SY5S.js +2 -0
- package/dist/chunk-CRR4BQKR.js +1 -0
- package/dist/chunk-FQHALFRR.js +1 -0
- package/dist/chunk-FUUTGGJS.js +1 -0
- package/dist/chunk-GKQVJITL.js +1 -0
- package/dist/chunk-MYITGTGJ.js +1 -0
- package/dist/chunk-NPWF35XZ.js +1 -0
- package/dist/chunk-ODIECDN7.js +1 -0
- package/dist/chunk-QJ66UBDY.js +1 -0
- package/dist/chunk-RGMZAKJV.js +1 -0
- package/dist/chunk-USLG7UIM.js +4 -0
- package/dist/chunk-W6T7MOKY.js +1 -0
- package/dist/chunk-YENGFI2R.js +1 -0
- package/dist/ctl/index.js +1 -4
- package/dist/filtering/index.js +1 -1
- package/dist/index.js +26 -72
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/browser.js +1 -2
- package/dist/repositories/index.js +1 -2
- package/dist/resolution/index.js +1 -1
- package/dist/transformations/DocAst.d.ts +120 -0
- package/dist/transformations/DocAstUriConstants.d.ts +65 -0
- package/dist/transformations/FormatOverride.d.ts +34 -0
- package/dist/transformations/ReferenceResolver.d.ts +23 -0
- package/dist/transformations/TransformationEngine.d.ts +72 -0
- package/dist/transformations/backends/HtmlBackend.d.ts +7 -0
- package/dist/transformations/backends/IDocumentAstBackend.d.ts +16 -0
- package/dist/transformations/backends/JsonBackend.d.ts +12 -0
- package/dist/transformations/backends/MarkdownFrontmatterBackend.d.ts +7 -0
- package/dist/transformations/backends/SimpleMarkdownRenderer.d.ts +17 -0
- package/dist/transformations/backends/SvgBackend.d.ts +7 -0
- package/dist/transformations/backends/TomlBackend.d.ts +7 -0
- package/dist/transformations/index.d.ts +18 -0
- package/dist/transformations/index.js +84 -0
- package/dist/transformations/v3/CompiledTransformationV3.d.ts +370 -0
- package/dist/transformations/v3/ExpressionEngineV3.d.ts +75 -0
- package/dist/transformations/v3/TransformationLoaderV3.d.ts +22 -0
- package/dist/transformations/v3/TransformationRunnerV3.d.ts +92 -0
- package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +200 -0
- package/dist/uri-helpers/SingleDocumentRepository.d.ts +28 -0
- package/dist/uri-helpers/UriHelpers.d.ts +89 -0
- package/dist/uri-helpers/index.d.ts +3 -0
- package/dist/uri-helpers/index.js +1 -0
- package/dist/validation/index.js +1 -42
- package/package.json +18 -2
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed, parsed-once representation of a transformations@3.0.0
|
|
3
|
+
* Transformation. Produced by `TransformationLoaderV3` from a
|
|
4
|
+
* `SubjectKanonak` whose RDF type is either `InstanceTransformation`
|
|
5
|
+
* or `SetTransformation`; consumed by `TransformationRunnerV3` and
|
|
6
|
+
* `ExpressionEngineV3`.
|
|
7
|
+
*
|
|
8
|
+
* The full Expression type union is declared here even though slice 1
|
|
9
|
+
* only implements a subset — declaring it upfront means later slices
|
|
10
|
+
* add behavior (loader cases, engine cases) rather than type members.
|
|
11
|
+
*
|
|
12
|
+
* V3 SHAPE NOTES (vs V2):
|
|
13
|
+
* - Top level is a discriminated union over `kind: 'instance' | 'set'`,
|
|
14
|
+
* mirroring the InstanceTransformation/SetTransformation split.
|
|
15
|
+
* - InputPattern carries `sortBy` (ordered list of SortKeys); the V2
|
|
16
|
+
* pattern had no sort.
|
|
17
|
+
* - SetTransformation may carry `partitionBy` for fan-out.
|
|
18
|
+
* - Expression nodes are tagged by their `kind` string here (the
|
|
19
|
+
* compiled form), but in the YAML they're dispatched by RDF type
|
|
20
|
+
* (real OWL hierarchy, not a discriminator instance).
|
|
21
|
+
*/
|
|
22
|
+
import type { EntityUri } from '../../uri-helpers/UriHelpers.js';
|
|
23
|
+
export type CompiledTransformationV3 = CompiledInstanceTransformationV3 | CompiledSetTransformationV3;
|
|
24
|
+
export interface CompiledTransformationV3Base {
|
|
25
|
+
/** Local name of the transformation entity, for diagnostics. */
|
|
26
|
+
name: string;
|
|
27
|
+
inputPattern: CompiledInputPatternV3;
|
|
28
|
+
rule: CompiledExpressionV3;
|
|
29
|
+
artifactName: CompiledExpressionV3;
|
|
30
|
+
/**
|
|
31
|
+
* The set of OutputFormat URIs this transformation supports, keyed
|
|
32
|
+
* by the OutputFormat's local name. The runner rejects requests to
|
|
33
|
+
* render in a format not in this set.
|
|
34
|
+
*/
|
|
35
|
+
outputs: Set<string>;
|
|
36
|
+
/** Per-output-format overrides keyed by the OutputFormat's local name. */
|
|
37
|
+
overrides: Map<string, CompiledFormatOverrideV3>;
|
|
38
|
+
}
|
|
39
|
+
export interface CompiledInstanceTransformationV3 extends CompiledTransformationV3Base {
|
|
40
|
+
kind: 'instance';
|
|
41
|
+
}
|
|
42
|
+
export interface CompiledSetTransformationV3 extends CompiledTransformationV3Base {
|
|
43
|
+
kind: 'set';
|
|
44
|
+
/**
|
|
45
|
+
* When set, the runner partitions the matched input set on this
|
|
46
|
+
* property and emits one Artifact per partition; `key` and `inputs`
|
|
47
|
+
* are bound for each evaluation. When undefined, the runner runs
|
|
48
|
+
* `rule` and `artifactName` once with `inputs` bound to the whole
|
|
49
|
+
* matched set, emitting a single Artifact.
|
|
50
|
+
*/
|
|
51
|
+
partitionBy?: EntityUri | undefined;
|
|
52
|
+
}
|
|
53
|
+
export interface CompiledInputPatternV3 {
|
|
54
|
+
/** The class URI whose instances are eligible. */
|
|
55
|
+
matchesClass: EntityUri;
|
|
56
|
+
/** Property URIs that must each resolve to non-empty on each instance. */
|
|
57
|
+
requires: EntityUri[];
|
|
58
|
+
/**
|
|
59
|
+
* Ordered list of sort criteria (primary first, ties broken by
|
|
60
|
+
* subsequent keys). Empty for transformations that don't need order.
|
|
61
|
+
*/
|
|
62
|
+
sortBy: CompiledSortKeyV3[];
|
|
63
|
+
}
|
|
64
|
+
export interface CompiledSortKeyV3 {
|
|
65
|
+
byProperty: EntityUri;
|
|
66
|
+
order: 'ascending' | 'descending';
|
|
67
|
+
}
|
|
68
|
+
export interface CompiledFormatOverrideV3 {
|
|
69
|
+
metadataKeys?: string[] | undefined;
|
|
70
|
+
metadataRenames: Map<string, string>;
|
|
71
|
+
trailingNewline?: boolean | undefined;
|
|
72
|
+
/** When true, backends suppress their default chrome (HTML's
|
|
73
|
+
* doctype + style + metadata <dl>; analogous in other backends). */
|
|
74
|
+
omitWrapper?: boolean | undefined;
|
|
75
|
+
}
|
|
76
|
+
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | 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;
|
|
77
|
+
export interface CompiledStringLiteralV3 {
|
|
78
|
+
kind: 'string-literal';
|
|
79
|
+
value: string;
|
|
80
|
+
}
|
|
81
|
+
export interface CompiledIntegerLiteralV3 {
|
|
82
|
+
kind: 'integer-literal';
|
|
83
|
+
value: number;
|
|
84
|
+
}
|
|
85
|
+
export interface CompiledDecimalLiteralV3 {
|
|
86
|
+
kind: 'decimal-literal';
|
|
87
|
+
value: number;
|
|
88
|
+
}
|
|
89
|
+
export interface CompiledBooleanLiteralV3 {
|
|
90
|
+
kind: 'boolean-literal';
|
|
91
|
+
value: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface CompiledVarRefV3 {
|
|
94
|
+
kind: 'var-ref';
|
|
95
|
+
varName: string;
|
|
96
|
+
}
|
|
97
|
+
export interface CompiledPropertyReadV3 {
|
|
98
|
+
kind: 'property-read';
|
|
99
|
+
source: CompiledExpressionV3;
|
|
100
|
+
readProp: EntityUri;
|
|
101
|
+
}
|
|
102
|
+
export interface CompiledTraverseV3 {
|
|
103
|
+
kind: 'traverse';
|
|
104
|
+
source: CompiledExpressionV3;
|
|
105
|
+
through: EntityUri;
|
|
106
|
+
step: CompiledExpressionV3;
|
|
107
|
+
}
|
|
108
|
+
export interface CompiledBuildAstNodeV3 {
|
|
109
|
+
kind: 'build-ast-node';
|
|
110
|
+
astClass: EntityUri;
|
|
111
|
+
set: CompiledFieldBindingV3[];
|
|
112
|
+
}
|
|
113
|
+
export interface CompiledFieldBindingV3 {
|
|
114
|
+
field: EntityUri;
|
|
115
|
+
value: CompiledExpressionV3;
|
|
116
|
+
}
|
|
117
|
+
export interface CompiledWhenV3 {
|
|
118
|
+
kind: 'when';
|
|
119
|
+
condition: CompiledExpressionV3;
|
|
120
|
+
thenBuild: CompiledExpressionV3;
|
|
121
|
+
elseBuild?: CompiledExpressionV3 | undefined;
|
|
122
|
+
}
|
|
123
|
+
export interface CompiledConcatV3 {
|
|
124
|
+
kind: 'concat';
|
|
125
|
+
parts: CompiledExpressionV3[];
|
|
126
|
+
}
|
|
127
|
+
export interface CompiledFallbackV3 {
|
|
128
|
+
kind: 'fallback';
|
|
129
|
+
primary: CompiledExpressionV3;
|
|
130
|
+
alternate: CompiledExpressionV3;
|
|
131
|
+
}
|
|
132
|
+
export interface CompiledUriNameV3 {
|
|
133
|
+
kind: 'uri-name';
|
|
134
|
+
source: CompiledExpressionV3;
|
|
135
|
+
}
|
|
136
|
+
export interface CompiledUriPublisherV3 {
|
|
137
|
+
kind: 'uri-publisher';
|
|
138
|
+
source: CompiledExpressionV3;
|
|
139
|
+
}
|
|
140
|
+
export interface CompiledUriPackageV3 {
|
|
141
|
+
kind: 'uri-package';
|
|
142
|
+
source: CompiledExpressionV3;
|
|
143
|
+
}
|
|
144
|
+
export interface CompiledUriVersionV3 {
|
|
145
|
+
kind: 'uri-version';
|
|
146
|
+
source: CompiledExpressionV3;
|
|
147
|
+
}
|
|
148
|
+
export interface CompiledSubjectUriV3 {
|
|
149
|
+
kind: 'subject-uri';
|
|
150
|
+
source: CompiledExpressionV3;
|
|
151
|
+
}
|
|
152
|
+
export interface CompiledUriLiteralV3 {
|
|
153
|
+
kind: 'uri-literal';
|
|
154
|
+
refTo: EntityUri;
|
|
155
|
+
}
|
|
156
|
+
export interface CompiledDisplayLabelV3 {
|
|
157
|
+
kind: 'display-label';
|
|
158
|
+
labelTarget: EntityUri;
|
|
159
|
+
labelSource: EntityUri;
|
|
160
|
+
}
|
|
161
|
+
export interface CompiledResolveRefV3 {
|
|
162
|
+
kind: 'resolve-ref';
|
|
163
|
+
source: CompiledExpressionV3;
|
|
164
|
+
}
|
|
165
|
+
export interface CompiledAllStatementsV3 {
|
|
166
|
+
kind: 'all-statements';
|
|
167
|
+
source: CompiledExpressionV3;
|
|
168
|
+
}
|
|
169
|
+
export interface CompiledStatementPredicateV3 {
|
|
170
|
+
kind: 'statement-predicate';
|
|
171
|
+
source: CompiledExpressionV3;
|
|
172
|
+
}
|
|
173
|
+
export interface CompiledStatementValueV3 {
|
|
174
|
+
kind: 'statement-value';
|
|
175
|
+
source: CompiledExpressionV3;
|
|
176
|
+
}
|
|
177
|
+
/** Named output formats supported by the engine. */
|
|
178
|
+
export type DateFormatKindV3 = 'iso-date' | 'iso-datetime' | 'short-date' | 'long-date' | 'year' | 'month-year';
|
|
179
|
+
export interface CompiledDateFormatV3 {
|
|
180
|
+
kind: 'date-format';
|
|
181
|
+
source: CompiledExpressionV3;
|
|
182
|
+
format: DateFormatKindV3;
|
|
183
|
+
}
|
|
184
|
+
export interface CompiledAddV3 {
|
|
185
|
+
kind: 'add';
|
|
186
|
+
left: CompiledExpressionV3;
|
|
187
|
+
right: CompiledExpressionV3;
|
|
188
|
+
}
|
|
189
|
+
export interface CompiledSubtractV3 {
|
|
190
|
+
kind: 'subtract';
|
|
191
|
+
left: CompiledExpressionV3;
|
|
192
|
+
right: CompiledExpressionV3;
|
|
193
|
+
}
|
|
194
|
+
export interface CompiledMultiplyV3 {
|
|
195
|
+
kind: 'multiply';
|
|
196
|
+
left: CompiledExpressionV3;
|
|
197
|
+
right: CompiledExpressionV3;
|
|
198
|
+
}
|
|
199
|
+
export interface CompiledDivideV3 {
|
|
200
|
+
kind: 'divide';
|
|
201
|
+
left: CompiledExpressionV3;
|
|
202
|
+
right: CompiledExpressionV3;
|
|
203
|
+
}
|
|
204
|
+
export interface CompiledReverseV3 {
|
|
205
|
+
kind: 'reverse';
|
|
206
|
+
source: CompiledExpressionV3;
|
|
207
|
+
}
|
|
208
|
+
export interface CompiledWindowedMapV3 {
|
|
209
|
+
kind: 'windowed-map';
|
|
210
|
+
source: CompiledExpressionV3;
|
|
211
|
+
windowSize: number;
|
|
212
|
+
windowVar: string;
|
|
213
|
+
windowBody: CompiledExpressionV3;
|
|
214
|
+
}
|
|
215
|
+
export interface CompiledPairwiseMapV3 {
|
|
216
|
+
kind: 'pairwise-map';
|
|
217
|
+
source: CompiledExpressionV3;
|
|
218
|
+
firstVar: string;
|
|
219
|
+
secondVar: string;
|
|
220
|
+
pairBody: CompiledExpressionV3;
|
|
221
|
+
}
|
|
222
|
+
export interface CompiledScanV3 {
|
|
223
|
+
kind: 'scan';
|
|
224
|
+
source: CompiledExpressionV3;
|
|
225
|
+
initialState: CompiledExpressionV3;
|
|
226
|
+
stateVar: string;
|
|
227
|
+
elementVar: string;
|
|
228
|
+
accumulate: CompiledExpressionV3;
|
|
229
|
+
}
|
|
230
|
+
export interface CompiledListItemAtV3 {
|
|
231
|
+
kind: 'list-item-at';
|
|
232
|
+
source: CompiledExpressionV3;
|
|
233
|
+
itemIndex: CompiledExpressionV3;
|
|
234
|
+
}
|
|
235
|
+
export interface CompiledEqualsV3 {
|
|
236
|
+
kind: 'equals';
|
|
237
|
+
left: CompiledExpressionV3;
|
|
238
|
+
right: CompiledExpressionV3;
|
|
239
|
+
}
|
|
240
|
+
export interface CompiledGreaterThanV3 {
|
|
241
|
+
kind: 'greater-than';
|
|
242
|
+
left: CompiledExpressionV3;
|
|
243
|
+
right: CompiledExpressionV3;
|
|
244
|
+
}
|
|
245
|
+
export interface CompiledLessThanV3 {
|
|
246
|
+
kind: 'less-than';
|
|
247
|
+
left: CompiledExpressionV3;
|
|
248
|
+
right: CompiledExpressionV3;
|
|
249
|
+
}
|
|
250
|
+
export interface CompiledGreaterThanOrEqualV3 {
|
|
251
|
+
kind: 'greater-than-or-equal';
|
|
252
|
+
left: CompiledExpressionV3;
|
|
253
|
+
right: CompiledExpressionV3;
|
|
254
|
+
}
|
|
255
|
+
export interface CompiledLessThanOrEqualV3 {
|
|
256
|
+
kind: 'less-than-or-equal';
|
|
257
|
+
left: CompiledExpressionV3;
|
|
258
|
+
right: CompiledExpressionV3;
|
|
259
|
+
}
|
|
260
|
+
export interface CompiledNotV3 {
|
|
261
|
+
kind: 'not';
|
|
262
|
+
operand: CompiledExpressionV3;
|
|
263
|
+
}
|
|
264
|
+
export interface CompiledAndV3 {
|
|
265
|
+
kind: 'and';
|
|
266
|
+
operands: CompiledExpressionV3[];
|
|
267
|
+
}
|
|
268
|
+
export interface CompiledOrV3 {
|
|
269
|
+
kind: 'or';
|
|
270
|
+
operands: CompiledExpressionV3[];
|
|
271
|
+
}
|
|
272
|
+
export interface CompiledContainsV3 {
|
|
273
|
+
kind: 'contains';
|
|
274
|
+
haystack: CompiledExpressionV3;
|
|
275
|
+
needle: CompiledExpressionV3;
|
|
276
|
+
}
|
|
277
|
+
export interface CompiledAbsV3 {
|
|
278
|
+
kind: 'abs';
|
|
279
|
+
value: CompiledExpressionV3;
|
|
280
|
+
}
|
|
281
|
+
export interface CompiledNegateV3 {
|
|
282
|
+
kind: 'negate';
|
|
283
|
+
value: CompiledExpressionV3;
|
|
284
|
+
}
|
|
285
|
+
export interface CompiledIsReferenceV3 {
|
|
286
|
+
kind: 'is-reference';
|
|
287
|
+
check: CompiledExpressionV3;
|
|
288
|
+
}
|
|
289
|
+
export interface CompiledIsEmbeddedV3 {
|
|
290
|
+
kind: 'is-embedded';
|
|
291
|
+
check: CompiledExpressionV3;
|
|
292
|
+
}
|
|
293
|
+
export interface CompiledIsListV3 {
|
|
294
|
+
kind: 'is-list';
|
|
295
|
+
check: CompiledExpressionV3;
|
|
296
|
+
}
|
|
297
|
+
export interface CompiledStatementObjectV3 {
|
|
298
|
+
kind: 'statement-object';
|
|
299
|
+
source: CompiledExpressionV3;
|
|
300
|
+
}
|
|
301
|
+
export type NormalizeKindV3 = 'trim-end';
|
|
302
|
+
export interface CompiledNormalizeV3 {
|
|
303
|
+
kind: 'normalize';
|
|
304
|
+
source: CompiledExpressionV3;
|
|
305
|
+
normKind: NormalizeKindV3;
|
|
306
|
+
}
|
|
307
|
+
export interface CompiledIsSetV3 {
|
|
308
|
+
kind: 'is-set';
|
|
309
|
+
check: CompiledExpressionV3;
|
|
310
|
+
}
|
|
311
|
+
export interface CompiledCallFragmentV3 {
|
|
312
|
+
kind: 'call-fragment';
|
|
313
|
+
/** The fragment's compiled body, inlined at compile time. */
|
|
314
|
+
body: CompiledExpressionV3;
|
|
315
|
+
}
|
|
316
|
+
export interface CompiledJoinV3 {
|
|
317
|
+
kind: 'join';
|
|
318
|
+
source: CompiledExpressionV3;
|
|
319
|
+
separator: string;
|
|
320
|
+
}
|
|
321
|
+
export interface CompiledCountV3 {
|
|
322
|
+
kind: 'count';
|
|
323
|
+
source: CompiledExpressionV3;
|
|
324
|
+
}
|
|
325
|
+
export interface CompiledSumV3 {
|
|
326
|
+
kind: 'sum';
|
|
327
|
+
source: CompiledExpressionV3;
|
|
328
|
+
}
|
|
329
|
+
export interface CompiledMinV3 {
|
|
330
|
+
kind: 'min';
|
|
331
|
+
source: CompiledExpressionV3;
|
|
332
|
+
}
|
|
333
|
+
export interface CompiledMaxV3 {
|
|
334
|
+
kind: 'max';
|
|
335
|
+
source: CompiledExpressionV3;
|
|
336
|
+
}
|
|
337
|
+
export interface CompiledAverageV3 {
|
|
338
|
+
kind: 'average';
|
|
339
|
+
source: CompiledExpressionV3;
|
|
340
|
+
}
|
|
341
|
+
export interface CompiledForEachV3 {
|
|
342
|
+
kind: 'for-each';
|
|
343
|
+
source: CompiledExpressionV3;
|
|
344
|
+
loopVar: string;
|
|
345
|
+
emit: CompiledExpressionV3;
|
|
346
|
+
}
|
|
347
|
+
export interface CompiledListMapV3 {
|
|
348
|
+
kind: 'list-map';
|
|
349
|
+
source: CompiledExpressionV3;
|
|
350
|
+
loopVar: string;
|
|
351
|
+
mapBody: CompiledExpressionV3;
|
|
352
|
+
}
|
|
353
|
+
export interface CompiledFilterV3 {
|
|
354
|
+
kind: 'filter';
|
|
355
|
+
source: CompiledExpressionV3;
|
|
356
|
+
loopVar: string;
|
|
357
|
+
predicate: CompiledExpressionV3;
|
|
358
|
+
}
|
|
359
|
+
export interface CompiledPartitionByV3 {
|
|
360
|
+
kind: 'partition-by';
|
|
361
|
+
source: CompiledExpressionV3;
|
|
362
|
+
loopVar: string;
|
|
363
|
+
partitionKey: CompiledExpressionV3;
|
|
364
|
+
}
|
|
365
|
+
export interface CompiledDistinctByV3 {
|
|
366
|
+
kind: 'distinct-by';
|
|
367
|
+
source: CompiledExpressionV3;
|
|
368
|
+
loopVar: string;
|
|
369
|
+
distinctKey: CompiledExpressionV3;
|
|
370
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates a `CompiledExpressionV3` tree against an environment.
|
|
3
|
+
*
|
|
4
|
+
* Covers the full v3 Expression hierarchy. Aggregations are strict
|
|
5
|
+
* about element types — non-numeric elements in a Sum/Min/Max/Average
|
|
6
|
+
* raise a runtime error. Min/Max/Average on an empty list also error
|
|
7
|
+
* (per the ontology contract); Sum on empty returns 0; Count works
|
|
8
|
+
* regardless of element type.
|
|
9
|
+
*
|
|
10
|
+
* Property reads walk `statement[]` by canonical predicate URI via
|
|
11
|
+
* `UriHelpers`. Reference resolution during traversal goes through
|
|
12
|
+
* the shared `ReferenceResolver`.
|
|
13
|
+
*/
|
|
14
|
+
import { type Kanonak } from '../../kanonaks/index.js';
|
|
15
|
+
import { type EntityUri } from '../../uri-helpers/UriHelpers.js';
|
|
16
|
+
import { ReferenceResolver } from '../ReferenceResolver.js';
|
|
17
|
+
import type { CompiledExpressionV3 } from './CompiledTransformationV3.js';
|
|
18
|
+
/**
|
|
19
|
+
* Runtime representation of a Partition produced by the
|
|
20
|
+
* `PartitionBy` expression. Carries the partition key value plus
|
|
21
|
+
* the list of source elements that share that key.
|
|
22
|
+
*
|
|
23
|
+
* The engine surfaces Partitions as plain JS objects; PropertyRead
|
|
24
|
+
* special-cases this shape so authors can read `partition.key` and
|
|
25
|
+
* `partition.members` from inside a ForEach over the partition list.
|
|
26
|
+
*/
|
|
27
|
+
export interface RuntimePartitionV3 {
|
|
28
|
+
kind: 'Partition';
|
|
29
|
+
key: EnvValue;
|
|
30
|
+
members: Kanonak[];
|
|
31
|
+
}
|
|
32
|
+
export type EnvValue = string | number | boolean | Kanonak | Kanonak[] | EnvValue[] | RuntimePartitionV3 | EntityUri | unknown | undefined | null;
|
|
33
|
+
export type Env = Map<string, EnvValue>;
|
|
34
|
+
export declare class ExpressionEvalErrorV3 extends Error {
|
|
35
|
+
}
|
|
36
|
+
export declare class ExpressionEngineV3 {
|
|
37
|
+
private readonly resolver;
|
|
38
|
+
private readonly catalog;
|
|
39
|
+
constructor(resolver: ReferenceResolver, catalog: Kanonak[]);
|
|
40
|
+
evaluate(expr: CompiledExpressionV3, env: Env): Promise<EnvValue>;
|
|
41
|
+
/**
|
|
42
|
+
* Evaluate a source expression and coerce its result into a list.
|
|
43
|
+
* Single-valued results are wrapped in a single-element list so
|
|
44
|
+
* downstream operations don't have to special-case scalar sources
|
|
45
|
+
* (e.g. an aggregation over a property that happens to be
|
|
46
|
+
* single-valued for one instance and multi-valued for another).
|
|
47
|
+
*/
|
|
48
|
+
private evaluateList;
|
|
49
|
+
/**
|
|
50
|
+
* Re-run an iterator with reverse iteration order, preserving each
|
|
51
|
+
* iteration's body output as a logical group. Returns `undefined`
|
|
52
|
+
* for non-iterator sources so the caller falls back to flat-list
|
|
53
|
+
* reversal.
|
|
54
|
+
*
|
|
55
|
+
* Why this exists: iterators (PairwiseMap, ForEach, WindowedMap)
|
|
56
|
+
* flatten array body results into a single output list. Wrapping
|
|
57
|
+
* one in `tx.Reverse` then applies a flat-list reverse, which
|
|
58
|
+
* scrambles per-iteration contents (#18). Re-iterating with
|
|
59
|
+
* reversed source preserves per-iteration body output structure
|
|
60
|
+
* while delivering the iteration sequence in newest-first order.
|
|
61
|
+
*
|
|
62
|
+
* For PairwiseMap, `firstVar` and `secondVar` still bind in
|
|
63
|
+
* chronological order (earlier→later) so per-pair body semantics
|
|
64
|
+
* are unchanged — only the visit order of pairs reverses. This
|
|
65
|
+
* matches the canonical "ascending sortBy + Reverse for newest-
|
|
66
|
+
* first changelog" idiom from issue #14's worked example.
|
|
67
|
+
*
|
|
68
|
+
* ListMap is included even though ListMap doesn't flatten —
|
|
69
|
+
* Reverse over ListMap should still surface body output in
|
|
70
|
+
* reverse order, which falling back to flat reversal would do
|
|
71
|
+
* correctly already; including it here keeps the semantics
|
|
72
|
+
* consistent (re-iterate with reversed source).
|
|
73
|
+
*/
|
|
74
|
+
private evaluateReverseIterator;
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiles a transformations@3.0.0 SubjectKanonak into a typed
|
|
3
|
+
* CompiledTransformationV3. Walks `statement[]` via the SDK's parsed
|
|
4
|
+
* object model — never re-parses YAML, never matches on alias
|
|
5
|
+
* prefixes. Property reads go through `UriHelpers`; type dispatch
|
|
6
|
+
* uses `hasType` against canonical `TX_V3` URIs.
|
|
7
|
+
*
|
|
8
|
+
* Throws `TransformationLoadErrorV3` with a breadcrumb path on the
|
|
9
|
+
* first shape violation.
|
|
10
|
+
*/
|
|
11
|
+
import { SubjectKanonak, type Kanonak } from '../../kanonaks/index.js';
|
|
12
|
+
import type { CompiledTransformationV3 } from './CompiledTransformationV3.js';
|
|
13
|
+
export declare class TransformationLoadErrorV3 extends Error {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
constructor(message: string, path: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Top-level entry point. Determines whether the SubjectKanonak is an
|
|
19
|
+
* InstanceTransformation or SetTransformation by RDF type, then
|
|
20
|
+
* dispatches to the appropriate compiler.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compileTransformationV3(transformation: SubjectKanonak, catalog: Kanonak[]): CompiledTransformationV3;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime entry point for transformations@3.0.0.
|
|
3
|
+
*
|
|
4
|
+
* Two pipelines:
|
|
5
|
+
*
|
|
6
|
+
* - InstanceTransformation: 1 input → 1 artifact. The runner filters
|
|
7
|
+
* candidates by InputPattern, then evaluates `rule` and
|
|
8
|
+
* `artifactName` once per candidate with `input` bound. Sort
|
|
9
|
+
* order on the InputPattern affects the order of emitted
|
|
10
|
+
* artifacts but doesn't change the cardinality.
|
|
11
|
+
*
|
|
12
|
+
* - SetTransformation:
|
|
13
|
+
* Without partitionBy: N candidates → 1 artifact, with `inputs`
|
|
14
|
+
* bound to the entire matched (and optionally sorted) list.
|
|
15
|
+
* With partitionBy: candidates are partitioned by the property
|
|
16
|
+
* value; one artifact per partition, with `inputs` bound to
|
|
17
|
+
* that partition's members and `key` bound to the partition
|
|
18
|
+
* value. Candidates whose partition property is absent are
|
|
19
|
+
* dropped (no group is created).
|
|
20
|
+
*
|
|
21
|
+
* Sort behavior:
|
|
22
|
+
* - SortKey.byProperty is read off each candidate. Missing values
|
|
23
|
+
* sort last (ascending) or first (descending). Lists or
|
|
24
|
+
* references on the sort property are an authoring error caught
|
|
25
|
+
* here at runtime.
|
|
26
|
+
*
|
|
27
|
+
* The runner does NOT touch the filesystem — writing is the
|
|
28
|
+
* deployment handler / CLI's job. Backends are version-agnostic and
|
|
29
|
+
* shared with any other transformation runtime.
|
|
30
|
+
*/
|
|
31
|
+
import { SubjectKanonak, type Kanonak } from '../../kanonaks/index.js';
|
|
32
|
+
import { KanonakParser, KanonakObjectParser } from '../../parsing/index.js';
|
|
33
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
34
|
+
import type { IDocumentAstBackend } from '../backends/IDocumentAstBackend.js';
|
|
35
|
+
import { TransformationLoadErrorV3 } from './TransformationLoaderV3.js';
|
|
36
|
+
import type { CompiledTransformationV3 } from './CompiledTransformationV3.js';
|
|
37
|
+
export interface ArtifactV3 {
|
|
38
|
+
/** Filename stem (no directory, no extension). */
|
|
39
|
+
fileName: string;
|
|
40
|
+
/** OutputFormat local name this was rendered as. */
|
|
41
|
+
format: string;
|
|
42
|
+
/** Serialized bytes. */
|
|
43
|
+
content: string;
|
|
44
|
+
/** Provenance — which subject(s) drove this artifact. */
|
|
45
|
+
source: ArtifactProvenanceV3;
|
|
46
|
+
}
|
|
47
|
+
export type ArtifactProvenanceV3 = {
|
|
48
|
+
kind: 'instance';
|
|
49
|
+
sourceName: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'set';
|
|
52
|
+
memberCount: number;
|
|
53
|
+
partitionKey?: string;
|
|
54
|
+
};
|
|
55
|
+
export interface FormatDescriptorV3 {
|
|
56
|
+
formatUri: string;
|
|
57
|
+
extension: string;
|
|
58
|
+
}
|
|
59
|
+
export declare const SUPPORTED_FORMATS_V3: Record<string, FormatDescriptorV3>;
|
|
60
|
+
export interface RunInputV3 {
|
|
61
|
+
transformation: SubjectKanonak;
|
|
62
|
+
/** Candidate input subjects. Caller is responsible for subclass-aware selection. */
|
|
63
|
+
instances: SubjectKanonak[];
|
|
64
|
+
/** All loaded kanonaks for fragment lookup + reference resolution. */
|
|
65
|
+
allKanonaks: Kanonak[];
|
|
66
|
+
/**
|
|
67
|
+
* Optional kanonaks of the transformation's own package (where any
|
|
68
|
+
* ExpressionFragments live). Falls back to allKanonaks.
|
|
69
|
+
*/
|
|
70
|
+
transformationKanonaks?: Kanonak[];
|
|
71
|
+
/** Repository for cross-package reference resolution at evaluation time. */
|
|
72
|
+
repository: IKanonakDocumentRepository;
|
|
73
|
+
parser: KanonakParser;
|
|
74
|
+
objectParser: KanonakObjectParser;
|
|
75
|
+
/** OutputFormat local name (e.g. `'markdown-with-frontmatter'`). */
|
|
76
|
+
outputFormat: string;
|
|
77
|
+
}
|
|
78
|
+
export declare class TransformationRunnerErrorV3 extends Error {
|
|
79
|
+
}
|
|
80
|
+
export declare class TransformationRunnerV3 {
|
|
81
|
+
private readonly backends;
|
|
82
|
+
constructor();
|
|
83
|
+
register(backend: IDocumentAstBackend): void;
|
|
84
|
+
run(input: RunInputV3): Promise<ArtifactV3[]>;
|
|
85
|
+
private runInstance;
|
|
86
|
+
private runSet;
|
|
87
|
+
private runSetSingle;
|
|
88
|
+
private runSetWithPartition;
|
|
89
|
+
private findBackend;
|
|
90
|
+
}
|
|
91
|
+
export { TransformationLoadErrorV3 };
|
|
92
|
+
export type { CompiledTransformationV3 };
|