@metreeca/keep-sparql 0.10.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/LICENSE +201 -0
- package/README.md +106 -0
- package/dist/_/_decode.d.ts +20 -0
- package/dist/_/_decode.d.ts.map +1 -0
- package/dist/_/_decode.js +55 -0
- package/dist/_/_decode.js.map +1 -0
- package/dist/_/_encode.d.ts +112 -0
- package/dist/_/_encode.d.ts.map +1 -0
- package/dist/_/_encode.js +262 -0
- package/dist/_/_encode.js.map +1 -0
- package/dist/_/_flake.d.ts +16 -0
- package/dist/_/_flake.d.ts.map +1 -0
- package/dist/_/_flake.js +65 -0
- package/dist/_/_flake.js.map +1 -0
- package/dist/_/_union.d.ts +28 -0
- package/dist/_/_union.d.ts.map +1 -0
- package/dist/_/_union.js +51 -0
- package/dist/_/_union.js.map +1 -0
- package/dist/detect/decode.d.ts +25 -0
- package/dist/detect/decode.d.ts.map +1 -0
- package/dist/detect/decode.js +34 -0
- package/dist/detect/decode.js.map +1 -0
- package/dist/detect/encode.d.ts +25 -0
- package/dist/detect/encode.d.ts.map +1 -0
- package/dist/detect/encode.js +30 -0
- package/dist/detect/encode.js.map +1 -0
- package/dist/detect/index.d.ts +17 -0
- package/dist/detect/index.d.ts.map +1 -0
- package/dist/detect/index.js +55 -0
- package/dist/detect/index.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup/decode.d.ts +33 -0
- package/dist/lookup/decode.d.ts.map +1 -0
- package/dist/lookup/decode.js +193 -0
- package/dist/lookup/decode.js.map +1 -0
- package/dist/lookup/encode.d.ts +46 -0
- package/dist/lookup/encode.d.ts.map +1 -0
- package/dist/lookup/encode.js +111 -0
- package/dist/lookup/encode.js.map +1 -0
- package/dist/lookup/index.d.ts +21 -0
- package/dist/lookup/index.d.ts.map +1 -0
- package/dist/lookup/index.js +72 -0
- package/dist/lookup/index.js.map +1 -0
- package/dist/modify/decode.d.ts +22 -0
- package/dist/modify/decode.d.ts.map +1 -0
- package/dist/modify/decode.js +26 -0
- package/dist/modify/decode.js.map +1 -0
- package/dist/modify/encode.d.ts +21 -0
- package/dist/modify/encode.d.ts.map +1 -0
- package/dist/modify/encode.js +184 -0
- package/dist/modify/encode.js.map +1 -0
- package/dist/modify/index.d.ts +22 -0
- package/dist/modify/index.d.ts.map +1 -0
- package/dist/modify/index.js +44 -0
- package/dist/modify/index.js.map +1 -0
- package/dist/select/decode.d.ts +16 -0
- package/dist/select/decode.d.ts.map +1 -0
- package/dist/select/decode.js +229 -0
- package/dist/select/decode.js.map +1 -0
- package/dist/select/encode.d.ts +16 -0
- package/dist/select/encode.d.ts.map +1 -0
- package/dist/select/encode.js +434 -0
- package/dist/select/encode.js.map +1 -0
- package/dist/select/index.d.ts +16 -0
- package/dist/select/index.d.ts.map +1 -0
- package/dist/select/index.js +38 -0
- package/dist/select/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2025-2026 Metreeca srl
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Select-pass result decoder.
|
|
18
|
+
*
|
|
19
|
+
* Materialises each queued {@link Select}'s collection value from the batched SELECT's solution tuples,
|
|
20
|
+
* one member per row: the element column (the outer `order by` fixes its order) read tuple by tuple, its
|
|
21
|
+
* distinct members in returned order. A scalar or coalesced localised member carries its own value in the
|
|
22
|
+
* row (a plain string, cartesian-fanned for an array-per-tag property); a structured member (resource,
|
|
23
|
+
* reference, or union) is expanded through the supplied {@link Broker}, its own content re-fetched by the
|
|
24
|
+
* lookup pass rather than reconstructed here. A union member is classified by the variant discriminator
|
|
25
|
+
* column that bound (union.md §Model), with no term inspection.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { getShapeTarget } from "@metreeca/blue/reference";
|
|
30
|
+
import { isObject } from "@metreeca/core";
|
|
31
|
+
import { getFlakeEntries, getFlakeProjection, getFlakeVariant, isBranch, isDrainedFlake, isPropertyBranch } from "@metreeca/keep-flake";
|
|
32
|
+
import { isProjection, isTemplate } from "@metreeca/qest/template";
|
|
33
|
+
import { termToValue } from "../_/_decode.js";
|
|
34
|
+
import { getUnionPlaceholders } from "../_/_union.js";
|
|
35
|
+
/**
|
|
36
|
+
* Settles each batched select request against the SELECT solution.
|
|
37
|
+
*
|
|
38
|
+
* @param scope The variable scope shared with the encoder, recovering per-request tuple slots
|
|
39
|
+
* @param batch The queued select requests to settle, each paired with its {@link Flake | query plan} and deferred
|
|
40
|
+
* @param broker The cross-pass channel expanding localised properties through the resources pass
|
|
41
|
+
* @param tuples The solution tuples returned by the batched SELECT round
|
|
42
|
+
*/
|
|
43
|
+
export function decode(scope, batch, broker, tuples) {
|
|
44
|
+
const guard = scope.resolve(batch);
|
|
45
|
+
batch.forEach(({ request, flake, resolve, reject }, index) => {
|
|
46
|
+
const placeholder = request.query[0];
|
|
47
|
+
const locale = request.locale;
|
|
48
|
+
collection(flake, placeholder, locale, index)
|
|
49
|
+
.then(resolve)
|
|
50
|
+
.catch(reject);
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Reads one request's collection: the flake root's bound members in the returned order,
|
|
54
|
+
* each decoded from its own tuple, omitting any that resolve to no value.
|
|
55
|
+
*/
|
|
56
|
+
function collection(flake, placeholder, locale, index) {
|
|
57
|
+
const projected = isProjection(placeholder);
|
|
58
|
+
function stamped(tuple) {
|
|
59
|
+
const block = tuple[guard];
|
|
60
|
+
return block?.kind === "typed" && block.text === String(index);
|
|
61
|
+
}
|
|
62
|
+
return Promise.all(tuples.filter(stamped).map(tuple => projected
|
|
63
|
+
? row(flake, tuple, locale)
|
|
64
|
+
: element(flake, placeholder, tuple[scope.resolve(flake)], tuple, locale))).then(values =>
|
|
65
|
+
// members always decode to a value (only requested variants are retrieved); the filter only narrows
|
|
66
|
+
// `decodeElement`'s type, which admits `undefined` for its nested / projection-cell callers
|
|
67
|
+
values.filter(value => value !== undefined));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Decodes one projection row: every binding the query projects (`getFlakeProjection`), keyed by its
|
|
71
|
+
* alias, read from its computed cell, omitting a binding that resolves to no value (§5.6). The row is
|
|
72
|
+
* always surfaced — a filtered-out item contributes no row-group, so a present group is a present row.
|
|
73
|
+
*/
|
|
74
|
+
function row(flake, tuple, locale) {
|
|
75
|
+
return Promise.all(Object.entries(getFlakeProjection(flake))
|
|
76
|
+
.map(([alias, node]) => cell(flake.range, node)
|
|
77
|
+
.then(value => [alias, value])))
|
|
78
|
+
.then(slots => slots.reduce((row, [alias, value]) => value === undefined ? row : { ...row, [alias]: value }, {}));
|
|
79
|
+
/**
|
|
80
|
+
* Decodes one projection cell: a structurally-addressed localised binding (a tag-range map placeholder)
|
|
81
|
+
* carries the owning resource's reference, whose localised property the broker then expands into a
|
|
82
|
+
* tag-preserving cell (§6); any other binding coerces its single computed term (embedded-resource cells
|
|
83
|
+
* to follow).
|
|
84
|
+
*/
|
|
85
|
+
function cell(host, flake) {
|
|
86
|
+
const placeholder = flake.drain?.mould;
|
|
87
|
+
const branch = isBranch(flake) && isPropertyBranch(flake) ? flake : undefined;
|
|
88
|
+
// the cell's effective resolved range (never empty), the same source the encoder projects and binds by
|
|
89
|
+
const variants = flake.range.variants;
|
|
90
|
+
const single = variants.length === 1 ? variants[0] : undefined;
|
|
91
|
+
const [enclosing] = host.variants;
|
|
92
|
+
if (branch !== undefined && single?.kind === "dictionary"
|
|
93
|
+
&& isObject(placeholder)
|
|
94
|
+
&& host.variants.length === 1
|
|
95
|
+
&& (enclosing.kind === "resource" || enclosing.kind === "reference")) {
|
|
96
|
+
const owner = tuple[scope.resolve(branch)];
|
|
97
|
+
const owning = getShapeTarget(enclosing);
|
|
98
|
+
return owner === undefined || owning === undefined
|
|
99
|
+
? Promise.resolve(undefined)
|
|
100
|
+
: text(owning, branch, branch.path[branch.path.length - 1], owner);
|
|
101
|
+
}
|
|
102
|
+
else if (branch !== undefined && variants.length > 1) {
|
|
103
|
+
// a union binding classifies on its populated variant column, which carries the term itself, so it
|
|
104
|
+
// delegates straight to the element decoder without a separate value column to read
|
|
105
|
+
return element(branch, placeholder, undefined, tuple, locale);
|
|
106
|
+
}
|
|
107
|
+
else if (branch !== undefined && (single?.kind === "resource"
|
|
108
|
+
|| (single?.kind === "reference" && (isTemplate(placeholder) || getFlakeEntries(branch).some(isDrainedFlake))))) {
|
|
109
|
+
const nested = tuple[scope.resolve(branch)];
|
|
110
|
+
if (nested === undefined) {
|
|
111
|
+
return Promise.resolve(undefined);
|
|
112
|
+
}
|
|
113
|
+
else if (isTemplate(placeholder) || getFlakeEntries(branch).some(isDrainedFlake)) {
|
|
114
|
+
// a structured reference/resource binding delegates its folded sub-structure (§5.6) straight to
|
|
115
|
+
// the lookup pass, keyed on the bound member reference
|
|
116
|
+
const target = getShapeTarget(variants[0]);
|
|
117
|
+
return nested.kind === "named" && target !== undefined
|
|
118
|
+
? expand(nested.iri, target, getFlakeEntries(branch), locale)
|
|
119
|
+
: Promise.resolve(undefined);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// an unstructured resource binding has no sub-structure to expand, so its term decodes as an id
|
|
123
|
+
return Promise.resolve(termToValue(nested));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const bound = tuple[scope.resolve(flake)];
|
|
128
|
+
return Promise.resolve(bound !== undefined ? termToValue(bound) : undefined);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Expands a localised property by delegating to the resources pass: looks up the owning `subject`
|
|
133
|
+
* restricted to this property under its requested placeholder, then plucks the decoded value back.
|
|
134
|
+
*/
|
|
135
|
+
function text(shape, branch, field, subject) {
|
|
136
|
+
// a localised entry resolves as one structured value, so its drain is a Model, never a multi-valued Query
|
|
137
|
+
const model = branch.drain?.mould;
|
|
138
|
+
const placeholder = isObject(model) ? model : "";
|
|
139
|
+
return subject.kind === "named"
|
|
140
|
+
? broker.lookup({ entry: subject.iri, shape, model: { [field]: placeholder }, locale })
|
|
141
|
+
.then(resource => resource[field])
|
|
142
|
+
: Promise.resolve(undefined);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Decodes one member from its solution tuple: a union by the variant guard that bound, a
|
|
147
|
+
* resource or expanded reference by delegating its expansion to the lookup pass, any other shape by
|
|
148
|
+
* coercing the element term. Resolves to `undefined` when a union member matches no requested variant.
|
|
149
|
+
*/
|
|
150
|
+
function element(flake, placeholder, element, tuple, locale) {
|
|
151
|
+
const variants = flake.range.variants;
|
|
152
|
+
const single = variants[0];
|
|
153
|
+
if (variants.length > 1) {
|
|
154
|
+
// a union projects one column per variant — text included (§5.8.1) — each carrying the value behind
|
|
155
|
+
// its membership gate (union.md §Model): the populated column is both the term and its variant
|
|
156
|
+
// classifier, so the term rides the bound column rather than a separate value column
|
|
157
|
+
const present = [...getUnionPlaceholders(variants, placeholder)].flatMap(([variant, mould]) => {
|
|
158
|
+
const term = tuple[scope.resolve(flake, variant)];
|
|
159
|
+
return term !== undefined ? [{ variant, mould, term }] : [];
|
|
160
|
+
})[0];
|
|
161
|
+
return present === undefined
|
|
162
|
+
? Promise.resolve(undefined)
|
|
163
|
+
: variant(present.variant, flake, present.mould, present.term);
|
|
164
|
+
}
|
|
165
|
+
else if (element === undefined) {
|
|
166
|
+
return Promise.resolve(undefined);
|
|
167
|
+
}
|
|
168
|
+
else if ((single.kind === "resource" || single.kind === "reference")
|
|
169
|
+
&& (isTemplate(placeholder) || getFlakeEntries(flake).some(isDrainedFlake))) {
|
|
170
|
+
// range dereferences a reference to its target resource, so resource and reference coincide here; the
|
|
171
|
+
// expansion is gated on the drain (a nested template or folded branches, §5.6), so a leaf reference —
|
|
172
|
+
// no structure to expand — falls through and is decoded as an id by `termToValue`
|
|
173
|
+
const target = single.kind === "reference" ? getShapeTarget(single) : single;
|
|
174
|
+
return element.kind === "named" && target !== undefined
|
|
175
|
+
? expand(element.iri, target, getFlakeEntries(flake), locale)
|
|
176
|
+
: Promise.resolve(undefined);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
return Promise.resolve(termToValue(element));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Decodes a member under its fixed variant: a literal variant coerces the element term, a node variant
|
|
183
|
+
* delegates its expansion to the lookup pass, and a bare (non-template) reference variant keeps the
|
|
184
|
+
* element reference.
|
|
185
|
+
*/
|
|
186
|
+
function variant(variant, flake, placeholder, element) {
|
|
187
|
+
if (variant.kind === "dictionary") {
|
|
188
|
+
// a dictionary variant's cell is its language-tagged literal (§6): a structural request (a tag-map
|
|
189
|
+
// mould) surfaces it as a single-tag map, a coalesced one (a plain-string mould) as the plain string
|
|
190
|
+
return Promise.resolve(element.kind === "tagged"
|
|
191
|
+
? isObject(placeholder) ? { [element.language]: element.text } : element.text
|
|
192
|
+
: undefined);
|
|
193
|
+
}
|
|
194
|
+
else if (variant.kind === "reference" && !isTemplate(placeholder) && !getFlakeVariant(flake, variant).some(isDrainedFlake)) {
|
|
195
|
+
return Promise.resolve(element.kind === "named" ? element.iri : undefined);
|
|
196
|
+
}
|
|
197
|
+
else if (variant.kind === "reference" || variant.kind === "resource") {
|
|
198
|
+
const target = getShapeTarget(variant);
|
|
199
|
+
return element.kind === "named" && target !== undefined
|
|
200
|
+
? expand(element.iri, target, getFlakeVariant(flake, variant), locale)
|
|
201
|
+
: Promise.resolve(undefined);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return Promise.resolve(termToValue(element));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Expands a structured member through the lookup pass: reassembles its retrieval template from the
|
|
210
|
+
* requested branches and hands it to the broker, keyed on the member entry. The read-side dual of
|
|
211
|
+
* the resources pass's set-valued delegation, so the member's own content — its scalars, localised text,
|
|
212
|
+
* and nested collections alike — is the lookup handler's responsibility and the select decoder never
|
|
213
|
+
* reconstructs it from the returned tuples.
|
|
214
|
+
*/
|
|
215
|
+
function expand(entry, shape, branches, locale) {
|
|
216
|
+
return broker.lookup({
|
|
217
|
+
entry,
|
|
218
|
+
shape,
|
|
219
|
+
model: branches
|
|
220
|
+
.filter(branch => branch.drain !== undefined)
|
|
221
|
+
.reduce((model, branch) => ({
|
|
222
|
+
...model,
|
|
223
|
+
[branch.path[branch.path.length - 1]]: branch.drain?.mould ?? ""
|
|
224
|
+
}), {}),
|
|
225
|
+
locale
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/select/decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAmB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EAGN,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EA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AC,CAAC,CAAC;YAE9C,CAAC;QAEF,CAAC;IAEF,CAAC;IAGD;;;;;;OAMG;IACH,SAAS,MAAM,CACd,KAAgB,EAChB,KAAoB,EACpB,QAA2B,EAC3B,MAAsB;QAGtB,OAAO,MAAM,CAAC,MAAM,CAAC;YAEpB,KAAK;YACL,KAAK;YAEL,KAAK,EAAE,QAAQ;iBACb,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC;iBAC5C,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC3B,GAAG,KAAK;gBACR,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;aAC9D,CAAC,EAAE,EAAE,CAAC;YAER,MAAM;SAEN,CAAC,CAAC;IAEJ,CAAC;AAEF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Scope } from "@metreeca/core/scope";
|
|
2
|
+
import { type Flake } from "@metreeca/keep-flake";
|
|
3
|
+
import type { Deferred, Select } from "@metreeca/keep/batching";
|
|
4
|
+
import { type SPARQL, type Variable } from "@metreeca/wire-sparql";
|
|
5
|
+
/**
|
|
6
|
+
* Folds every queued select request into one batched SPARQL SELECT.
|
|
7
|
+
*
|
|
8
|
+
* @param scope The variable scope shared with the decoder, allocating per-request solution slots
|
|
9
|
+
* @param batch The queued select requests to encode, each paired with its {@link Flake | query plan} and deferred
|
|
10
|
+
*
|
|
11
|
+
* @returns The batched SELECT query covering every request in `batch`
|
|
12
|
+
*/
|
|
13
|
+
export declare function encode(scope: Scope<Variable>, batch: readonly (Deferred<Select> & {
|
|
14
|
+
readonly flake: Flake;
|
|
15
|
+
})[]): SPARQL;
|
|
16
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/select/encode.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAEN,KAAK,KAAK,EAkBV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAqDnE;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EACtB,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CAAE,CAAC,EAAE,GAC/D,MAAM,CAiqBR"}
|