@lde/search 0.26.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.
@@ -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;AAmID;;;;;;;;;;;;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"}
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,20 +113,17 @@ 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
- // A Reference Type is nested inside its referrer and keyed in no collection
107
- // of its own, so its entries carry no `id` – whether or not the graph happened
108
- // to name the node. Nesting carries a referent's FIELDS, not a document key
109
- // (ADR 24), and nothing reads one here: the collection declares an `id` for a
110
- // locally-nested Root Type alone, a weld names the flat identity companion
111
- // beside the entry, and an entry's own key answers no query. Emitting it made
112
- // an entry's shape depend on whether a publisher minted an IRI for a
113
- // relationship – arbitrary to a consumer, and a field the collection never
114
- // declared.
115
- if (searchType.class === undefined) {
116
- return undefined;
117
- }
118
127
  const nodeIri = documentKey(node);
119
128
  if (nodeIri === undefined || searchType.key === undefined) {
120
129
  return nodeIri;
@@ -636,8 +645,14 @@ function applyNestedReferents(document, values, field, nestedType, schema, conte
636
645
  // or a keyed target re-keying two referent IRIs to the same document key. The
637
646
  // pre-fan-out shape deduped, because those values met inside one entry and
638
647
  // `applyFacet` deduped them there; split across entries they would reach the
639
- // index and the API as byte-identical duplicates instead.
640
- const distinct = dedupeBy(referents, (referent) => JSON.stringify(referent));
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));
641
656
  if (distinct.length === 0) {
642
657
  return distinct;
643
658
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search",
3
- "version": "0.26.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",