@lde/search 0.0.0 → 0.1.1

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":"frame-by-type.d.ts","sourceRoot":"","sources":["../src/frame-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAIjD;;;;;;;;;;GAUG;AACH,wBAAuB,WAAW,CAChC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,MAAM,GACf,aAAa,CAAC,UAAU,CAAC,CAU3B"}
1
+ {"version":3,"file":"frame-by-type.d.ts","sourceRoot":"","sources":["../src/frame-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAIjD;;;;;;;;;;GAUG;AACH,wBAAuB,WAAW,CAChC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,MAAM,GACf,aAAa,CAAC,UAAU,CAAC,CAkB3B"}
@@ -14,10 +14,14 @@ const FRAME_OPTIONS = { omitGraph: false, embed: '@always' };
14
14
  * framed keys are full predicate IRIs.
15
15
  */
16
16
  export async function* frameByType(quads, rootType) {
17
- const frame = { '@type': rootType };
18
- for (const subgraph of groupByRoot(quads, rootType)) {
17
+ for (const { rootIri, subgraph } of groupByRoot(quads, rootType)) {
19
18
  const expanded = await jsonld.fromRDF(subgraph);
20
- const framed = await jsonld.frame(expanded, frame, FRAME_OPTIONS);
19
+ // Frame for THIS specific root subject by `@id`, not just by root type. A
20
+ // one-hop reference can itself be of `rootType` (e.g. a terminology source
21
+ // that is also a separately registered dataset), so framing by type alone
22
+ // returns several root nodes and `[0]` could be the referenced one — which
23
+ // would emit it twice and drop this subject entirely.
24
+ const framed = await jsonld.frame(expanded, { '@id': rootIri }, FRAME_OPTIONS);
21
25
  const node = framed['@graph']?.[0];
22
26
  if (node !== undefined) {
23
27
  yield node;
@@ -58,6 +62,6 @@ function* groupByRoot(quads, rootType) {
58
62
  .filter((quad) => quad.object.termType === 'NamedNode' ||
59
63
  quad.object.termType === 'BlankNode')
60
64
  .flatMap((quad) => bySubject.get(quad.object.value) ?? []);
61
- yield [...owned, ...referenced];
65
+ yield { rootIri: iri, subgraph: [...owned, ...referenced] };
62
66
  }
63
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search",
3
- "version": "0.0.0",
3
+ "version": "0.1.1",
4
4
  "description": "Engine-agnostic search projection for RDF-backed pipelines: frame CONSTRUCT quads into a JSON-LD IR, then project that IR into flat search documents from a declarative field spec (the artifact a SHACL generator would emit)",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/ldelements/lde.git",
@@ -25,7 +25,7 @@
25
25
  "!**/*.tsbuildinfo"
26
26
  ],
27
27
  "dependencies": {
28
- "@lde/text-normalization": "^0.0.0",
28
+ "@lde/text-normalization": "0.1.0",
29
29
  "@rdfjs/types": "^2.0.1",
30
30
  "@tpluscode/rdf-ns-builders": "^5.0.0",
31
31
  "jsonld": "^9.0.0",