@lde/search 0.28.0 → 0.29.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/adapter.d.ts +2 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +2 -1
- package/dist/engine.d.ts +15 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/join-graph.js +4 -2
- package/dist/language.d.ts +22 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +54 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +170 -45
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +33 -16
- package/dist/schema.d.ts +92 -36
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +225 -78
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +13 -5
- package/package.json +1 -1
package/dist/adapter.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* deployment author declaring a schema and running searches needs none of
|
|
7
7
|
* this; the main entry point carries that (small) authoring surface.
|
|
8
8
|
*/
|
|
9
|
-
export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName,
|
|
9
|
+
export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isAbsoluteIri, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
|
|
10
10
|
export type { PhysicalFields } from './schema.js';
|
|
11
11
|
export { physicalNameTokens } from './physical-name.js';
|
|
12
|
+
export { matchLanguage } from './language.js';
|
|
12
13
|
export { joinGraph, MAX_JOIN_DEPTH } from './join-graph.js';
|
|
13
14
|
export type { JoinGraph } from './join-graph.js';
|
|
14
15
|
export { filterOperatorFor, filterOperator, filterOn, isWelded, isUnsatisfiable, validateQuery, assertValidQuery, resolvePath, pageForOffset, } from './query.js';
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
package/dist/adapter.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* deployment author declaring a schema and running searches needs none of
|
|
7
7
|
* this; the main entry point carries that (small) authoring surface.
|
|
8
8
|
*/
|
|
9
|
-
export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName,
|
|
9
|
+
export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isAbsoluteIri, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
|
|
10
10
|
export { physicalNameTokens } from './physical-name.js';
|
|
11
|
+
export { matchLanguage } from './language.js';
|
|
11
12
|
export { joinGraph, MAX_JOIN_DEPTH } from './join-graph.js';
|
|
12
13
|
export { filterOperatorFor, filterOperator, filterOn, isWelded, isUnsatisfiable, validateQuery, assertValidQuery, resolvePath, pageForOffset, } from './query.js';
|
package/dist/engine.d.ts
CHANGED
|
@@ -133,7 +133,22 @@ export type SearchValue = string | number | boolean | readonly string[] | Locali
|
|
|
133
133
|
*/
|
|
134
134
|
export interface NestedDocument {
|
|
135
135
|
readonly [field: string]: SearchValue | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The `name` of the Root Type this document is read through, where the
|
|
138
|
+
* field that carries it is a `lookup` naming **several** targets – the
|
|
139
|
+
* declaration it was resolved or stored against. Such a lookup serves
|
|
140
|
+
* referents of any of its targets under one field, and this is what tells a
|
|
141
|
+
* surface which one each referent is, so it can type the value per referent
|
|
142
|
+
* instead of claiming one kind for all of them. Absent where there is
|
|
143
|
+
* nothing to tell apart: a single-target lookup, or an inline reference’s
|
|
144
|
+
* entry. Keyed by a symbol so it can never collide with a declared field
|
|
145
|
+
* name.
|
|
146
|
+
*/
|
|
147
|
+
readonly [NESTED_DOCUMENT_TYPE]?: string;
|
|
136
148
|
}
|
|
149
|
+
/** The key under which a {@link NestedDocument} carries the `name` of the
|
|
150
|
+
* Root Type it is read through. */
|
|
151
|
+
export declare const NESTED_DOCUMENT_TYPE: unique symbol;
|
|
137
152
|
/**
|
|
138
153
|
* A JSON-LD-style language map (`@container: @language`, `@set` arrays); the key
|
|
139
154
|
* `und` carries untagged (`@none`) values. The surface flattens it to a
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,K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Graph, MAX_JOIN_DEPTH } from './join-graph.js';
|
|
|
6
6
|
export type { JoinGraph } from './join-graph.js';
|
|
7
7
|
export { filterOn } from './query.js';
|
|
8
8
|
export type { SearchQuery, ReferenceProjection, Filter, Criterion, CriterionBase, WeldedCriterion, Sort, } from './query.js';
|
|
9
|
+
export { NESTED_DOCUMENT_TYPE } from './engine.js';
|
|
9
10
|
export type { SearchEngine, SearchResult, SearchHit, ResultDocument, SearchValue, LocalizedValue, Reference, NestedDocument, FacetBucket, FacetMap, FacetsOutcome, FacetFieldsOf, OutputFieldsOf, } from './engine.js';
|
|
10
11
|
export type { FramedNode } from './frame-by-type.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,EAMN,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,aAAa,EACb,eAAe,EACf,IAAI,GACL,MAAM,YAAY,CAAC;AAIpB,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,EACT,cAAc,EACd,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,EAMN,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,aAAa,EACb,eAAe,EACf,IAAI,GACL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,EACT,cAAc,EACd,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,3 +27,6 @@ export { joinGraph, MAX_JOIN_DEPTH } from './join-graph.js';
|
|
|
27
27
|
// policy (`queryDefaults`) appends to `where`, so it belongs on the authoring
|
|
28
28
|
// surface and not only on the adapter one.
|
|
29
29
|
export { filterOn } from './query.js';
|
|
30
|
+
// Engine port + the logical result document returned across it. An engine is
|
|
31
|
+
// bound to the whole SearchSchema at construction by its adapter factory.
|
|
32
|
+
export { NESTED_DOCUMENT_TYPE } from './engine.js';
|
package/dist/join-graph.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { labelSourceNamesOf, referenceFields, } from './schema.js';
|
|
2
2
|
/**
|
|
3
3
|
* The deepest `on` path a query may state: `dataset → publisher → country` is
|
|
4
4
|
* three hops. Fixed rather than configurable, and enforced in the query IR
|
|
@@ -103,7 +103,9 @@ function declaredEdges(searchType, byName) {
|
|
|
103
103
|
// field, which a Reference Type cannot carry (a nested field is `output`
|
|
104
104
|
// only). So a joinable edge always has a collection at the far end without
|
|
105
105
|
// a rule of its own.
|
|
106
|
-
|
|
106
|
+
// One target, never several: `validateSearchType` refuses `joinable` on a
|
|
107
|
+
// reference naming more than one.
|
|
108
|
+
const target = byName.get(labelSourceNamesOf(field)[0]);
|
|
107
109
|
const claimed = claimedBy.get(target.name);
|
|
108
110
|
if (claimed !== undefined) {
|
|
109
111
|
throw new Error(`Search type “${searchType.name}” declares two joinable references to “${target.name}” (“${claimed}” and “${field.name}”); an engine addresses a join by collection, not by field, so only one reference per target can be joinable. Drop “joinable” from one of them – it keeps its labels, facets and id filtering.`);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entries of `candidates` that language tag `tag` matches, best first, as
|
|
3
|
+
* the entries themselves (so a caller can index back into `candidates`).
|
|
4
|
+
*
|
|
5
|
+
* Tags are compared per BCP-47 subtag and case-insensitively, as language
|
|
6
|
+
* ranges (RFC 4647). A candidate matches when it shares the tag’s primary
|
|
7
|
+
* language, ranked:
|
|
8
|
+
*
|
|
9
|
+
* 1. the exact tag (`nl-NL` for `nl-NL`);
|
|
10
|
+
* 2. the tag’s truncations, most specific first – RFC 4647 lookup, so a
|
|
11
|
+
* request for `nl-NL` finds a declared `nl`;
|
|
12
|
+
* 3. the tags it is a prefix of, in `candidates` order – RFC 4647 basic
|
|
13
|
+
* filtering, so a range `nl` finds `nl-NL` and `nl-BE`;
|
|
14
|
+
* 4. the remaining tags of the same language, longest shared prefix first, so
|
|
15
|
+
* a request for `nl-NL` still finds `nl-BE` rather than another language.
|
|
16
|
+
*
|
|
17
|
+
* The exact match therefore still wins where a general and a specific tag sit
|
|
18
|
+
* side by side (`en` and `en-GB`). `und`, the untagged bucket, matches nothing
|
|
19
|
+
* but `und`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function matchLanguage(tag: string, candidates: readonly string[]): string[];
|
|
22
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CA4BV"}
|
package/dist/language.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entries of `candidates` that language tag `tag` matches, best first, as
|
|
3
|
+
* the entries themselves (so a caller can index back into `candidates`).
|
|
4
|
+
*
|
|
5
|
+
* Tags are compared per BCP-47 subtag and case-insensitively, as language
|
|
6
|
+
* ranges (RFC 4647). A candidate matches when it shares the tag’s primary
|
|
7
|
+
* language, ranked:
|
|
8
|
+
*
|
|
9
|
+
* 1. the exact tag (`nl-NL` for `nl-NL`);
|
|
10
|
+
* 2. the tag’s truncations, most specific first – RFC 4647 lookup, so a
|
|
11
|
+
* request for `nl-NL` finds a declared `nl`;
|
|
12
|
+
* 3. the tags it is a prefix of, in `candidates` order – RFC 4647 basic
|
|
13
|
+
* filtering, so a range `nl` finds `nl-NL` and `nl-BE`;
|
|
14
|
+
* 4. the remaining tags of the same language, longest shared prefix first, so
|
|
15
|
+
* a request for `nl-NL` still finds `nl-BE` rather than another language.
|
|
16
|
+
*
|
|
17
|
+
* The exact match therefore still wins where a general and a specific tag sit
|
|
18
|
+
* side by side (`en` and `en-GB`). `und`, the untagged bucket, matches nothing
|
|
19
|
+
* but `und`.
|
|
20
|
+
*/
|
|
21
|
+
export function matchLanguage(tag, candidates) {
|
|
22
|
+
const subtags = tag.toLowerCase().split('-');
|
|
23
|
+
const ranked = [];
|
|
24
|
+
for (const candidate of candidates) {
|
|
25
|
+
const candidateSubtags = candidate.toLowerCase().split('-');
|
|
26
|
+
const shared = sharedPrefixLength(subtags, candidateSubtags);
|
|
27
|
+
const exact = shared === subtags.length && shared === candidateSubtags.length;
|
|
28
|
+
if (shared === 0 || (subtags[0] === 'und' && !exact)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const kind = exact
|
|
32
|
+
? 0
|
|
33
|
+
: shared === candidateSubtags.length
|
|
34
|
+
? 1
|
|
35
|
+
: shared === subtags.length
|
|
36
|
+
? 2
|
|
37
|
+
: 3;
|
|
38
|
+
// Extensions keep candidate order; truncations and siblings rank by how
|
|
39
|
+
// much of the tag they share.
|
|
40
|
+
ranked.push({ candidate, kind, closeness: kind === 2 ? 0 : shared });
|
|
41
|
+
}
|
|
42
|
+
return ranked
|
|
43
|
+
.sort((left, right) => left.kind - right.kind || right.closeness - left.closeness)
|
|
44
|
+
.map(({ candidate }) => candidate);
|
|
45
|
+
}
|
|
46
|
+
function sharedPrefixLength(left, right) {
|
|
47
|
+
let length = 0;
|
|
48
|
+
while (length < left.length &&
|
|
49
|
+
length < right.length &&
|
|
50
|
+
left[length] === right[length]) {
|
|
51
|
+
length++;
|
|
52
|
+
}
|
|
53
|
+
return length;
|
|
54
|
+
}
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAoBL,KAAK,eAAe,EAIpB,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,+DAA+D;AAC/D,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAChD,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAC1C;IACC,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,YAAY,EACrB,OAAO,GAAE,iBAAyC,GACjD,cAAc,CAgBhB;AAmLD;;;;;;;;;;;;GAYG;AACH,wBAAuB,YAAY,CACjC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EACrB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,QAAQ,EACpB,OAAO,GAAE,iBAAyC,GACjD,aAAa,CAAC,cAAc,CAAC,CAc/B"}
|
package/dist/project.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fold } from '@lde/text-normalization';
|
|
2
|
+
import { matchLanguage } from './language.js';
|
|
2
3
|
import { buildSubjectIndex, frameSubjects, } from './frame-by-type.js';
|
|
3
|
-
import { assertTypeInSchema, displayFieldName, documentKeyOf, fieldNamed,
|
|
4
|
+
import { assertTypeInSchema, displayFieldName, documentKeyOf, fieldNamed, identityFieldOf, inheritedFacetPolicies, inlineFramingDepth, irAlias, isAbsoluteIri, isInternalField, isInlineReference, isoToUnixSeconds, localLookupTargetsOf, physicalFields, referencedTargetsOf, referenceTypeNamed, storedTargetOf, TARGET_FIELD, } from './schema.js';
|
|
4
5
|
/** The context a projection runs with when its caller supplied none. */
|
|
5
6
|
const NO_PROJECTION_CONTEXT = {};
|
|
6
7
|
/**
|
|
@@ -64,19 +65,21 @@ function pruneInternalFields(document, searchType, schema) {
|
|
|
64
65
|
if (schema === undefined || field.kind !== 'reference') {
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
? referenceTypeNamed(schema, field.ref.typeName)
|
|
69
|
-
:
|
|
68
|
+
const nestedTypes = field.ref?.strategy === 'inline'
|
|
69
|
+
? [referenceTypeNamed(schema, field.ref.typeName)].filter((type) => type !== undefined)
|
|
70
|
+
: localLookupTargetsOf(field, schema);
|
|
70
71
|
const nested = document[field.name];
|
|
71
|
-
if (
|
|
72
|
+
if (nestedTypes.length === 0 || nested === undefined) {
|
|
72
73
|
continue;
|
|
73
74
|
}
|
|
74
75
|
for (const referent of Array.isArray(nested) ? nested : [nested]) {
|
|
75
|
-
pruneInternalFields(referent,
|
|
76
|
+
pruneInternalFields(referent, nestedTypes.length === 1
|
|
77
|
+
? nestedTypes[0]
|
|
78
|
+
: storedTargetOf(referent, nestedTypes), schema);
|
|
76
79
|
}
|
|
77
80
|
// Two entries that differed only in their node IRI are one entry now that
|
|
78
81
|
// it is gone – two edge nodes stating the same fact.
|
|
79
|
-
if (
|
|
82
|
+
if (nestedTypes[0].class === undefined && Array.isArray(nested)) {
|
|
80
83
|
document[field.name] = dedupeBy(nested, (referent) => JSON.stringify(referent));
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -253,9 +256,9 @@ function applyField(document, node, field, searchType, schema, context, nested)
|
|
|
253
256
|
// is an entry like any other, minus its `id`. Same reason as above for
|
|
254
257
|
// needing a schema: without one there is no target to project through.
|
|
255
258
|
if (field.kind === 'reference' && schema !== undefined) {
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
const endpoints = applyNestedReferents(document, valuesOf(node, alias), field,
|
|
259
|
+
const localTargets = localLookupTargetsOf(field, schema);
|
|
260
|
+
if (localTargets.length > 0) {
|
|
261
|
+
const endpoints = applyNestedReferents(document, valuesOf(node, alias), field, localTargets, schema, context);
|
|
259
262
|
// A `local` lookup stores an object, so its own id is a level deeper than
|
|
260
263
|
// a filter can reach – an engine welds conditions on an entry's LEAF
|
|
261
264
|
// fields only. `filterable` therefore fans out the id beside the object,
|
|
@@ -269,8 +272,12 @@ function applyField(document, node, field, searchType, schema, context, nested)
|
|
|
269
272
|
return applyText(document, langValuesOf(node, alias), field);
|
|
270
273
|
case 'keyword':
|
|
271
274
|
return applyFacet(document, literalsOf(node, alias), field, schema);
|
|
272
|
-
case 'reference':
|
|
273
|
-
|
|
275
|
+
case 'reference': {
|
|
276
|
+
const targetsById = new Map();
|
|
277
|
+
const values = referenceValues(node, alias, field, schema, targetsById);
|
|
278
|
+
rememberTargets(document, targetsById);
|
|
279
|
+
return applyFacet(document, values, field, schema, targetsById);
|
|
280
|
+
}
|
|
274
281
|
case 'integer':
|
|
275
282
|
return setNumber(document, field.name, toInteger(firstLiteralOf(node, alias)));
|
|
276
283
|
case 'number':
|
|
@@ -315,27 +322,87 @@ function applyField(document, node, field, searchType, schema, context, nested)
|
|
|
315
322
|
* referent’s node IRIs therefore sees a key instead, which is why the two are
|
|
316
323
|
* worth declaring together only deliberately.
|
|
317
324
|
*/
|
|
318
|
-
function referenceValues(node, alias, field, schema) {
|
|
319
|
-
const targetName = labelSourceNameOf(field);
|
|
320
|
-
if (schema === undefined || targetName === undefined) {
|
|
321
|
-
return irisOf(node, alias);
|
|
322
|
-
}
|
|
325
|
+
function referenceValues(node, alias, field, schema, targetsById) {
|
|
323
326
|
// Guaranteed declared: `searchSchema` validates that every named target
|
|
324
327
|
// resolves, and the projection only ever runs against a type of its schema.
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
328
|
+
const targets = referencedTargetsOf(field, schema);
|
|
329
|
+
if (targets.length === 0) {
|
|
327
330
|
return irisOf(node, alias);
|
|
328
331
|
}
|
|
329
|
-
const keyFieldName = target.key.field;
|
|
330
332
|
return valuesOf(node, alias)
|
|
331
333
|
.map((value) => {
|
|
332
334
|
const iri = iriString(value);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
335
|
+
if (iri === undefined) {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
// Each referent is re-keyed through the target IT belongs to – the one
|
|
339
|
+
// its `rdf:type` matches – so a person keyed on an authority IRI and an
|
|
340
|
+
// organization keyed on nothing store, under one field, the ids their
|
|
341
|
+
// own collections file them under.
|
|
342
|
+
const target = targetOfReferent(value, targets);
|
|
343
|
+
const keyed = target.key === undefined
|
|
344
|
+
? iri
|
|
345
|
+
: documentKeyOf(target, iri, isObject(value)
|
|
346
|
+
? keyCandidatesOf(value, target, target.key.field)
|
|
347
|
+
: []);
|
|
348
|
+
// Remembered only where there was a choice: a single-target reference
|
|
349
|
+
// stays byte-identical to what it was, symbol keys included. Keyed by
|
|
350
|
+
// what the field STORES – the value after its own `transform`, which
|
|
351
|
+
// `applyFacet` applies before it reads this map.
|
|
352
|
+
if (keyed !== undefined && targets.length > 1) {
|
|
353
|
+
targetsById.set(field.transform === undefined ? keyed : field.transform(keyed), target);
|
|
354
|
+
}
|
|
355
|
+
return keyed;
|
|
336
356
|
})
|
|
337
357
|
.filter((value) => value !== undefined);
|
|
338
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* The Root Type a framed referent belongs to, among the targets its reference
|
|
361
|
+
* names: the first whose `class` is among the referent’s `rdf:type`s, which
|
|
362
|
+
* the extraction emits and framing carries as `@type`; else the first target
|
|
363
|
+
* declared. One target needs no evidence at all. This is the one reading of
|
|
364
|
+
* *which of several targets is this*, so re-keying, the facet policy and the
|
|
365
|
+
* stored discriminator ({@link TARGET_FIELD}) cannot disagree.
|
|
366
|
+
*/
|
|
367
|
+
function targetOfReferent(value, targets) {
|
|
368
|
+
if (targets.length === 1 || !isObject(value)) {
|
|
369
|
+
return targets[0];
|
|
370
|
+
}
|
|
371
|
+
const raw = value['@type'];
|
|
372
|
+
const classes = new Set((Array.isArray(raw) ? raw : [raw]).filter((type) => typeof type === 'string'));
|
|
373
|
+
return targets.find((target) => classes.has(target.class)) ?? targets[0];
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The targets the reference values of a projected node were resolved through,
|
|
377
|
+
* by id – kept beside the node under a symbol, so it never reaches the
|
|
378
|
+
* writer, for the one reader that needs it after projection: the identity
|
|
379
|
+
* companion of an inline reference, which admits an entry’s id to a facet by
|
|
380
|
+
* the policy of the target that id belongs to. Only a reference naming
|
|
381
|
+
* several targets has anything to remember.
|
|
382
|
+
*/
|
|
383
|
+
const REFERENT_TARGETS = Symbol('referentTargets');
|
|
384
|
+
function rememberTargets(document, targetsById) {
|
|
385
|
+
if (targetsById.size === 0) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const node = document;
|
|
389
|
+
const remembered = (node[REFERENT_TARGETS] ??= new Map());
|
|
390
|
+
for (const [id, target] of targetsById) {
|
|
391
|
+
remembered.set(id, target);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Whether an id deserves a facet bucket, by the {@link FacetKeys facet policy}
|
|
396
|
+
* of the target it belongs to: admitted where that target declares none, and
|
|
397
|
+
* by its `only` where it does. `targetName` is the target the id was resolved
|
|
398
|
+
* or stored against; an id whose target is unknown falls back to the first
|
|
399
|
+
* declared, the same precedence every other reading of several targets uses.
|
|
400
|
+
*/
|
|
401
|
+
function admitsFacet(policies, targets, targetName, id) {
|
|
402
|
+
// Policies are inherited from targets, so where any exists a target does.
|
|
403
|
+
const policy = policies.get(targetName ?? targets[0].name);
|
|
404
|
+
return policy === undefined || policy.only(id);
|
|
405
|
+
}
|
|
339
406
|
/**
|
|
340
407
|
* Project a text field. **Display** (when `output`) preserves *every* language
|
|
341
408
|
* present – one label per language, or every label of it for an `array` field
|
|
@@ -391,9 +458,36 @@ function applyText(document, values, field) {
|
|
|
391
458
|
// here it simply indexes nothing.
|
|
392
459
|
if (field.searchable !== undefined || field.sortable === true) {
|
|
393
460
|
const names = physicalFields(field);
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
461
|
+
// A literal lands under the declared locale its tag best matches as a
|
|
462
|
+
// language range, so `nl-NL` titles are keyed under a declared `nl`; within
|
|
463
|
+
// a locale, the exact tag comes first.
|
|
464
|
+
const valuesPerLanguage = new Map();
|
|
465
|
+
for (const { lang, value } of values) {
|
|
466
|
+
const languageValues = valuesPerLanguage.get(lang);
|
|
467
|
+
if (languageValues === undefined) {
|
|
468
|
+
valuesPerLanguage.set(lang, [value]);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
languageValues.push(value);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const languagesPerLocale = new Map();
|
|
475
|
+
for (const entry of valuesPerLanguage) {
|
|
476
|
+
const locale = matchLanguage(entry[0], field.locales)[0];
|
|
477
|
+
if (locale !== undefined) {
|
|
478
|
+
languagesPerLocale.set(locale, [
|
|
479
|
+
...(languagesPerLocale.get(locale) ?? []),
|
|
480
|
+
entry,
|
|
481
|
+
]);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const valuesPerLocale = field.locales.map((locale) => {
|
|
485
|
+
const entries = languagesPerLocale.get(locale) ?? [];
|
|
486
|
+
const ranked = matchLanguage(locale, entries.map(([language]) => language));
|
|
487
|
+
return entries
|
|
488
|
+
.sort(([left], [right]) => ranked.indexOf(left) - ranked.indexOf(right))
|
|
489
|
+
.flatMap(([, languageValues]) => languageValues);
|
|
490
|
+
});
|
|
397
491
|
// What every locale’s sort key falls back to: the document’s first value
|
|
398
492
|
// in `locales` order, which is the declaration’s own statement of which
|
|
399
493
|
// language stands in for the others.
|
|
@@ -422,7 +516,7 @@ function foldedSearchValue(values) {
|
|
|
422
516
|
* already-read raw values).
|
|
423
517
|
*
|
|
424
518
|
* A reference inheriting a {@link FacetKeys facet policy} from the type it
|
|
425
|
-
* names ({@link
|
|
519
|
+
* names ({@link inheritedFacetPolicies}) also writes the `${name}_facet` companion
|
|
426
520
|
* the engine facets instead of the field: the subset of **what the field
|
|
427
521
|
* stores** that the policy admits. So it is written after the field’s own
|
|
428
522
|
* `transform` and the IRI filter, from the same `values` – for a keyed target
|
|
@@ -441,7 +535,7 @@ function foldedSearchValue(values) {
|
|
|
441
535
|
* engine rejects, or – where it does not type-check, as inside a nested
|
|
442
536
|
* document – a value the API cannot serialize.
|
|
443
537
|
*/
|
|
444
|
-
function applyFacet(document, raw, field, schema) {
|
|
538
|
+
function applyFacet(document, raw, field, schema, targetsById) {
|
|
445
539
|
// A `reference` stores identity, so what it stores must be an IRI whatever
|
|
446
540
|
// route the value arrived by. {@link iriString} guards the graph path, but a
|
|
447
541
|
// `transform` runs after it and a `from` projection value never passes it at
|
|
@@ -453,21 +547,25 @@ function applyFacet(document, raw, field, schema) {
|
|
|
453
547
|
const folded = dedupe(values.map((value) => fold(value)));
|
|
454
548
|
const names = physicalFields(field, schema);
|
|
455
549
|
const searchField = names.search[0];
|
|
456
|
-
const
|
|
550
|
+
const policies = inheritedFacetPolicies(field, schema);
|
|
551
|
+
const inherited = policies.size > 0;
|
|
457
552
|
// `names.facet` is the companion exactly when a policy is inherited –
|
|
458
|
-
// physicalFields reads the same `
|
|
553
|
+
// physicalFields reads the same `inheritedFacetPolicies`.
|
|
459
554
|
const facetField = names.facet;
|
|
460
555
|
// The companion is a subset of what the field STORES – for a single-valued
|
|
461
556
|
// field its first value, not the first admitted of all of them, or the facet
|
|
462
557
|
// would count a value no filter on the field can reproduce.
|
|
463
558
|
const stored = field.array === true ? values : values.slice(0, 1);
|
|
464
|
-
const
|
|
559
|
+
const targets = referencedTargetsOf(field, schema);
|
|
560
|
+
const admitted = !inherited
|
|
561
|
+
? []
|
|
562
|
+
: stored.filter((id) => admitsFacet(policies, targets, targetsById?.get(id)?.name, id));
|
|
465
563
|
if (field.array === true) {
|
|
466
564
|
setArray(document, field.name, stored);
|
|
467
565
|
if (field.searchable) {
|
|
468
566
|
setArray(document, searchField, folded);
|
|
469
567
|
}
|
|
470
|
-
if (
|
|
568
|
+
if (inherited) {
|
|
471
569
|
setArray(document, facetField, admitted);
|
|
472
570
|
}
|
|
473
571
|
return;
|
|
@@ -476,7 +574,7 @@ function applyFacet(document, raw, field, schema) {
|
|
|
476
574
|
if (field.searchable) {
|
|
477
575
|
setString(document, searchField, folded[0]);
|
|
478
576
|
}
|
|
479
|
-
if (
|
|
577
|
+
if (inherited) {
|
|
480
578
|
setString(document, facetField, admitted[0]);
|
|
481
579
|
}
|
|
482
580
|
}
|
|
@@ -527,7 +625,7 @@ function applyInlineReference(document, node, alias, field, schema, context, nes
|
|
|
527
625
|
if (referenceType === undefined) {
|
|
528
626
|
return;
|
|
529
627
|
}
|
|
530
|
-
const referents = applyNestedReferents(document, valuesOf(node, alias), field, referenceType, schema, context);
|
|
628
|
+
const referents = applyNestedReferents(document, valuesOf(node, alias), field, [referenceType], schema, context);
|
|
531
629
|
applyIdentityCompanion(document, referents, field, schema, nested);
|
|
532
630
|
}
|
|
533
631
|
/**
|
|
@@ -556,11 +654,24 @@ function applyIdentityCompanion(document, referents, field, schema, nested) {
|
|
|
556
654
|
// keeps the first referent and drops the rest, and a companion holding an id
|
|
557
655
|
// from a dropped one would match a filter whose hit shows no such entry.
|
|
558
656
|
const stored = field.array === true ? referents : referents.slice(0, 1);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
657
|
+
// Each id with the target it was resolved through, for the facet policy
|
|
658
|
+
// below: a stored endpoint says so itself ({@link TARGET_FIELD}), a bare id
|
|
659
|
+
// was remembered when the entry was projected ({@link rememberTargets}).
|
|
660
|
+
const targetById = new Map();
|
|
661
|
+
for (const referent of stored) {
|
|
662
|
+
const remembered = referent[REFERENT_TARGETS];
|
|
663
|
+
const raw = referent[identity];
|
|
664
|
+
for (const value of Array.isArray(raw) ? raw : [raw]) {
|
|
665
|
+
const id = identityValue(value);
|
|
666
|
+
if (id === undefined || targetById.has(id)) {
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
targetById.set(id, isObject(value) && typeof value[TARGET_FIELD] === 'string'
|
|
670
|
+
? value[TARGET_FIELD]
|
|
671
|
+
: remembered?.get(id)?.name);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
const ids = [...targetById.keys()];
|
|
564
675
|
if (ids.length === 0) {
|
|
565
676
|
return;
|
|
566
677
|
}
|
|
@@ -568,9 +679,10 @@ function applyIdentityCompanion(document, referents, field, schema, nested) {
|
|
|
568
679
|
// Same rule as every other facetable reference: where the target declares a
|
|
569
680
|
// facet policy, the facet reads a narrowed companion of its own, so an
|
|
570
681
|
// excluded id is never seen by the engine rather than merely unlabelled.
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
573
|
-
|
|
682
|
+
const policies = inheritedFacetPolicies(field, schema);
|
|
683
|
+
if (policies.size > 0) {
|
|
684
|
+
const targets = referencedTargetsOf(identityFieldOf(field, schema), schema);
|
|
685
|
+
setIdentity(document, names.facet, ids.filter((id) => admitsFacet(policies, targets, targetById.get(id), id)), field, nested);
|
|
574
686
|
}
|
|
575
687
|
}
|
|
576
688
|
/**
|
|
@@ -648,14 +760,27 @@ function identityValue(value) {
|
|
|
648
760
|
* top-level document of that type would be – so the stored id is the one the
|
|
649
761
|
* target’s collection files it under, and the lookup can find it.
|
|
650
762
|
*/
|
|
651
|
-
function applyNestedReferents(document, values, field,
|
|
763
|
+
function applyNestedReferents(document, values, field, nestedTypes, schema, context) {
|
|
652
764
|
// One node may stand for several entries: a weldable leaf is single-valued,
|
|
653
765
|
// so an edge the graph gave several roles or several endpoints fans out into
|
|
654
766
|
// one entry per combination BEFORE it is projected (ADR 26).
|
|
655
767
|
const referents = values
|
|
656
768
|
.filter(isObject)
|
|
657
|
-
.flatMap((value) =>
|
|
658
|
-
|
|
769
|
+
.flatMap((value) => {
|
|
770
|
+
// A lookup naming several targets projects each referent through the
|
|
771
|
+
// one it belongs to, and stores which – so an engine adapter can read
|
|
772
|
+
// an entry no collection answers for through the right declaration.
|
|
773
|
+
const nestedType = nestedTypes.length === 1
|
|
774
|
+
? nestedTypes[0]
|
|
775
|
+
: targetOfReferent(value, nestedTypes);
|
|
776
|
+
return tuplesOf(value, nestedType, field).map((tuple) => {
|
|
777
|
+
const projected = projectFields(tuple, nestedType, schema, context, true);
|
|
778
|
+
if (nestedTypes.length > 1 && Object.keys(projected).length > 0) {
|
|
779
|
+
projected[TARGET_FIELD] = nestedType.name;
|
|
780
|
+
}
|
|
781
|
+
return projected;
|
|
782
|
+
});
|
|
783
|
+
})
|
|
659
784
|
// Fields, not identity, are what makes something a referent: a literal
|
|
660
785
|
// value object under the alias (dirty source data), or a node this
|
|
661
786
|
// reference type reads nothing from, projects nothing and is no referent.
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAClC,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;gEAC4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,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