@lde/search 0.25.0 → 0.27.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/engine.d.ts +7 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/project.d.ts +5 -5
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +33 -3
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -123,10 +123,13 @@ export type SearchValue = string | number | boolean | readonly string[] | Locali
|
|
|
123
123
|
* values grouped together, so a multi-valued reference never degrades into
|
|
124
124
|
* parallel arrays a consumer has to pair by index.
|
|
125
125
|
*
|
|
126
|
-
* `id
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
126
|
+
* **No `id`**: nesting carries the referent’s fields, not a document key, and a
|
|
127
|
+
* Reference Type is kept in no collection for a key to address it in. A named
|
|
128
|
+
* node and a blank one therefore nest alike. The exception is a
|
|
129
|
+
* {@link ReferenceStrategy.local local} lookup, which nests a Root Type – there
|
|
130
|
+
* the `id` is the key its own collection files the referent under, and the
|
|
131
|
+
* lookup resolves against it. Distinct from {@link Reference}, which is what an
|
|
132
|
+
* `idOnly`/`labelOnly` reference carries – there the IRI *is* the value.
|
|
130
133
|
*/
|
|
131
134
|
export interface NestedDocument {
|
|
132
135
|
readonly [field: string]: SearchValue | undefined;
|
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,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,YAAY,CAC3B,KAAK,SAAS,SAAS,UAAU,EAAE,GAAG,SAAS,UA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,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
package/dist/project.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { Quad } from '@rdfjs/types';
|
|
|
2
2
|
import { type FramedNode } from './frame-by-type.js';
|
|
3
3
|
import { type ProjectionValue, type RootType, type SearchSchema, type SearchType } from './schema.js';
|
|
4
4
|
/**
|
|
5
|
-
* A projected node: the fields of one {@link SearchType}, flat. A
|
|
6
|
-
* carries the `id` that keys it – it is a {@link SearchDocument}
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* identity.
|
|
5
|
+
* A projected node: the fields of one {@link SearchType}, flat. A **Root Type**
|
|
6
|
+
* carries the `id` that keys it – as a root it is a {@link SearchDocument}, and
|
|
7
|
+
* nested by a {@link ReferenceStrategy.local local} lookup it is what the lookup
|
|
8
|
+
* resolves against. A **Reference Type** never does: it is kept in no collection,
|
|
9
|
+
* so nesting needs the referent’s fields and not its identity.
|
|
10
10
|
*/
|
|
11
11
|
export type ProjectedNode = Record<string, unknown>;
|
|
12
12
|
/** A flat search document. `id` is the engine document key. */
|
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;AAEzC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAkBL,KAAK,eAAe,EAEpB,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;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAkBL,KAAK,eAAe,EAEpB,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;AA4ID;;;;;;;;;;;;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
|
@@ -42,8 +42,20 @@ export function projectDocument(node, searchType, schema, context = NO_PROJECTIO
|
|
|
42
42
|
* {@link ReferenceStrategy.local local} lookup projects its endpoint through.
|
|
43
43
|
* The second matters more than it looks – a Root Type’s reading-device fields
|
|
44
44
|
* exist for its OWN derives, and nothing in a referring document wants them.
|
|
45
|
+
*
|
|
46
|
+
* A Reference Type entry’s `id` is pruned here too. It is a reading device of
|
|
47
|
+
* the same kind: the node IRI a derive on the referrer may read, and never a
|
|
48
|
+
* document key – an entry is kept in no collection, a weld names the flat
|
|
49
|
+
* identity companion beside it, and an entry's own key answers no query (ADR
|
|
50
|
+
* 24). Left in, it would make an entry's shape depend on whether a publisher
|
|
51
|
+
* minted an IRI for a relationship, and be a field the collection never
|
|
52
|
+
* declared. A Root Type keeps its `id` wherever it nests: that is the key its
|
|
53
|
+
* own collection files it under, and a `local` lookup resolves against it.
|
|
45
54
|
*/
|
|
46
55
|
function pruneInternalFields(document, searchType, schema) {
|
|
56
|
+
if (searchType.class === undefined) {
|
|
57
|
+
delete document.id;
|
|
58
|
+
}
|
|
47
59
|
for (const field of searchType.fields) {
|
|
48
60
|
if (isInternalField(field)) {
|
|
49
61
|
delete document[field.name];
|
|
@@ -101,6 +113,15 @@ function documentKey(node) {
|
|
|
101
113
|
* The key is assigned before any `derive` runs, so a derive sees the key and
|
|
102
114
|
* never the node IRI; a deployment that wants the node IRI declares a plain
|
|
103
115
|
* `idOnly` reference over the same path.
|
|
116
|
+
*
|
|
117
|
+
* A Reference Type has no key, so its entry gets the node IRI itself – as a
|
|
118
|
+
* reading device only. A Reference Type is nested in its referrer and kept in
|
|
119
|
+
* no collection, so nothing downstream resolves an entry by key, and
|
|
120
|
+
* {@link pruneInternalFields} removes the `id` again before the document
|
|
121
|
+
* leaves the projection, exactly as it removes a no-role helper field. What
|
|
122
|
+
* stays is the window in between: a `derive` on the referrer reads the entry's
|
|
123
|
+
* IRI where that IRI is the data – a IIIF manifest among a work's media, stated
|
|
124
|
+
* by its `@id` and nothing else – and surfaces it under a field of its own.
|
|
104
125
|
*/
|
|
105
126
|
function documentIdOf(node, searchType) {
|
|
106
127
|
const nodeIri = documentKey(node);
|
|
@@ -464,7 +485,10 @@ function applyProjectionValue(document, field, from, context, schema) {
|
|
|
464
485
|
* {@link ProjectedNode} for a single reference, an array for an `array` one.
|
|
465
486
|
* A referent needs **no identity**: nesting carries its fields, not a document
|
|
466
487
|
* key, so a blank-node referent – whose `@id` JSON-LD 1.1 framing prunes when its
|
|
467
|
-
* label occurs once – nests exactly like a named one
|
|
488
|
+
* label occurs once – nests exactly like a named one. Neither carries an `id`:
|
|
489
|
+
* a Reference Type is kept in no collection, so nothing resolves an entry by
|
|
490
|
+
* key, and an entry's shape no longer depends on whether a publisher minted an
|
|
491
|
+
* IRI for the relationship ({@link documentIdOf}).
|
|
468
492
|
* The referent is projected in full – internal fields included – so the
|
|
469
493
|
* declaring type’s (or the reference type’s own) derives can read them;
|
|
470
494
|
* {@link pruneInternalFields} then removes the internal fields from a *surfaced*
|
|
@@ -621,8 +645,14 @@ function applyNestedReferents(document, values, field, nestedType, schema, conte
|
|
|
621
645
|
// or a keyed target re-keying two referent IRIs to the same document key. The
|
|
622
646
|
// pre-fan-out shape deduped, because those values met inside one entry and
|
|
623
647
|
// `applyFacet` deduped them there; split across entries they would reach the
|
|
624
|
-
// index and the API as byte-identical duplicates instead.
|
|
625
|
-
|
|
648
|
+
// index and the API as byte-identical duplicates instead. A Reference Type
|
|
649
|
+
// entry's `id` is left out of the comparison: it is pruned before the
|
|
650
|
+
// document leaves the projection, so two statements of one fact through two
|
|
651
|
+
// edge nodes are the one entry they will be once it is gone. A Root Type's
|
|
652
|
+
// `id` is its key and stays part of what makes an entry distinct.
|
|
653
|
+
const distinct = dedupeBy(referents, (referent) => JSON.stringify(nestedType.class === undefined
|
|
654
|
+
? { ...referent, id: undefined }
|
|
655
|
+
: referent));
|
|
626
656
|
if (distinct.length === 0) {
|
|
627
657
|
return distinct;
|
|
628
658
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Engine- and domain-agnostic core for RDF-backed search: a unified declarative field model (SearchField/SearchType/SearchSchema), a neutral query IR, the SearchEngine port with logical result types, and a streaming CONSTRUCT-to-document projection. Bakes in no engine, protocol, or domain.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|