@lde/search 0.5.0 → 0.6.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  The core of the LDE search family: packages that together act as a **generator
4
4
  for search engines**. You write one declarative `SearchSchema`, and everything
5
5
  a running search engine needs is derived from it: the document projection, the
6
- engine collection schema, the query semantics, and the API surface. All these
6
+ engine collection definition, the query semantics, and the API surface. All these
7
7
  are kept in sync automatically rather than handwritten per deployment.
8
8
 
9
9
  The core itself is **engine-, API- and domain-agnostic**: it bakes in no search
@@ -34,7 +34,7 @@ It provides four things:
34
34
 
35
35
  ```
36
36
  SearchSchema ─┬─► projection (projectGraph → flat documents) [here]
37
- ├─► engine adapter (collection schema + query compiler) e.g. @lde/search-typesense
37
+ ├─► engine adapter (collection definition + query compiler) e.g. @lde/search-typesense
38
38
  ├─► query semantics (SearchQuery, filter/sort/facet) [here]
39
39
  └─► API surface (GraphQL / REST) e.g. @lde/search-api-graphql
40
40
  ```
@@ -50,7 +50,7 @@ results: engine response ──parse──► SearchResult ──shape──
50
50
  ```
51
51
 
52
52
  Validation happens before the first arrow (SHACL over the RDF) and inside the
53
- last (the engine enforces its collection schema); between them every stage is
53
+ last (the engine enforces its collection definition); between them every stage is
54
54
  a typed, deterministic function — easy to test, and swappable per deployment.
55
55
 
56
56
  ## Entry points
@@ -72,11 +72,11 @@ Exports are stratified by audience:
72
72
  The model has three levels, with analogues in SHACL ([one possible source](#why-a-declarative-model))
73
73
  and GraphQL (one of the surfaces):
74
74
 
75
- | Term | What it is | SHACL | GraphQL |
76
- | -------------- | --------------------------------------------------------------------------------------------------------------- | -------------- | ----------- |
77
- | `SearchField` | One queryable field: a `kind`, the IR `path` it projects from, and the capability flags it opts into | property shape | field |
78
- | `SearchType` | One root type’s complete declaration: its logical API `name`, its `type` IRI and its fields (incl. derived) | NodeShape | object type |
79
- | `SearchSchema` | The whole search declaration: every `SearchType`, keyed by `type` IRI — build one with `searchSchema(...types)` | shapes graph | schema |
75
+ | Term | What it is | SHACL | GraphQL |
76
+ | -------------- | ---------------------------------------------------------------------------------------------------------------- | -------------- | ----------- |
77
+ | `SearchField` | One queryable field: a `kind`, the IR `path` it projects from, and the capability flags it opts into | property shape | field |
78
+ | `SearchType` | One root type’s complete declaration: its logical API `name`, its `class` IRI and its fields (incl. derived) | NodeShape | object type |
79
+ | `SearchSchema` | The whole search declaration: every `SearchType`, keyed by `class` IRI — build one with `searchSchema(...types)` | shapes graph | schema |
80
80
 
81
81
  `projectGraph` and the GraphQL surface consume a `SearchSchema` (projecting
82
82
  every type in one pass); the engine port executes one `SearchType` at a time.
@@ -92,7 +92,7 @@ Two conventions hold across the whole family:
92
92
  `engine.search(type, query)`.
93
93
  - **Factory verbs** — the verb tells you what kind of thing comes back.
94
94
  `define*` captures a declaration as a literal (`defineSearchType`);
95
- `build*` is a pure data-to-data constructor (`buildCollectionSchema`,
95
+ `build*` is a pure data-to-data constructor (`buildCollectionDefinition`,
96
96
  `buildSearchParams`, `buildGraphQLSchema`); `create*` makes a stateful
97
97
  instance (`createTypesenseSearchEngine`). A bare noun (`searchSchema`)
98
98
  constructs the trivial container it names.
@@ -104,7 +104,7 @@ read (or a `derive` function for a **derived** field, computed from the framed
104
104
  node in declaration order — so it may read fields declared before it), and the
105
105
  capabilities it opts into. The physical field names a declaration fans out to
106
106
  (per-locale search/sort keys) come from
107
- `physicalFields`, the single convention projection, the collection schema and the
107
+ `physicalFields`, the single convention projection, the collection definition and the
108
108
  query compiler all share.
109
109
 
110
110
  ```ts
@@ -117,7 +117,7 @@ import {
117
117
 
118
118
  const DATASET = defineSearchType({
119
119
  name: 'Dataset', // logical API name: names the GraphQL type, a REST path, …
120
- type: 'http://www.w3.org/ns/dcat#Dataset',
120
+ class: 'http://www.w3.org/ns/dcat#Dataset',
121
121
  fields: [
122
122
  // → title_nl, title_en, title_search_nl/_en, title_sort_nl/_en
123
123
  {
@@ -189,7 +189,7 @@ rejects a structurally invalid declaration (duplicate field names, an `output`
189
189
  reference without `ref`, `text` without locales, `locales` on a non-text kind,
190
190
  `facetRanges` on a non-numeric kind, `searchable`/`transform` on a kind whose
191
191
  projection cannot honour it, `filterable`/`facetable` on `text`, two types
192
- sharing a `type` IRI or `name`) — the declaration-time counterpart of the
192
+ sharing a `class` IRI or `name`) — the declaration-time counterpart of the
193
193
  port’s always-on query validation, so a bad schema fails at startup rather
194
194
  than per document at index time. `validateSearchType` /
195
195
  `assertValidSearchType` are exported for validating a single declaration
package/dist/project.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface TypedSearchDocument {
21
21
  * its value from the node and the document as populated so far (so a derived
22
22
  * field may read fields declared before it). The physical field names a field
23
23
  * fans out to come from {@link physicalFields}, the single source shared with
24
- * the engine collection schema and the query compiler.
24
+ * the engine collection definition and the query compiler.
25
25
  */
26
26
  export declare function projectDocument(node: FramedNode, searchType: SearchType): SearchDocument;
27
27
  /**
package/dist/project.js CHANGED
@@ -7,12 +7,12 @@ import { isoToUnixSeconds, physicalFields, } from './schema.js';
7
7
  * its value from the node and the document as populated so far (so a derived
8
8
  * field may read fields declared before it). The physical field names a field
9
9
  * fans out to come from {@link physicalFields}, the single source shared with
10
- * the engine collection schema and the query compiler.
10
+ * the engine collection definition and the query compiler.
11
11
  */
12
12
  export function projectDocument(node, searchType) {
13
13
  const id = node['@id'];
14
14
  if (typeof id !== 'string') {
15
- throw new Error(`Cannot project a ${searchType.type} node without an @id: every search document needs a stable key, and an empty one would collide with other keyless nodes.`);
15
+ throw new Error(`Cannot project a ${searchType.class} node without an @id: every search document needs a stable key, and an empty one would collide with other keyless nodes.`);
16
16
  }
17
17
  const document = { id };
18
18
  for (const field of searchType.fields) {
@@ -36,9 +36,9 @@ export function projectDocument(node, searchType) {
36
36
  */
37
37
  export async function* projectGraph(quads, schema) {
38
38
  const types = [...schema.values()];
39
- const index = buildSubjectIndex(quads, types.map((searchType) => searchType.type));
39
+ const index = buildSubjectIndex(quads, types.map((searchType) => searchType.class));
40
40
  for (const searchType of types) {
41
- for await (const node of frameSubjects(index, searchType.type)) {
41
+ for await (const node of frameSubjects(index, searchType.class)) {
42
42
  yield { searchType, document: projectDocument(node, searchType) };
43
43
  }
44
44
  }
package/dist/schema.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { SearchDocument } from './project.js';
3
3
  /**
4
4
  * The engine-neutral kind of a queryable field. It drives every downstream
5
5
  * behavior: which physical fields the projection emits, the engine
6
- * collection-schema type, the `where`/facet/sort semantics, and the GraphQL
6
+ * collection-definition type, the `where`/facet/sort semantics, and the GraphQL
7
7
  * output/input type. The Typesense-vocabulary types (`string`, `int32`, …) are
8
8
  * *derived* from this by the engine adapter, never declared here.
9
9
  */
@@ -20,7 +20,7 @@ export type FilterOperator = 'in' | 'range' | 'is';
20
20
  export declare function filterOperatorFor(kind: FieldKind): FilterOperator | undefined;
21
21
  /**
22
22
  * One queryable field — the single declarative source that drives all four
23
- * consumers (projection, engine collection schema, query semantics, and the
23
+ * consumers (projection, engine collection definition, query semantics, and the
24
24
  * GraphQL surface).
25
25
  *
26
26
  * A **discriminated union by `kind`**: each kind declares exactly the
@@ -38,7 +38,7 @@ export declare function filterOperatorFor(kind: FieldKind): FilterOperator | und
38
38
  *
39
39
  * The physical field names a declaration fans out to (per-locale search/sort
40
40
  * keys) follow one convention, owned by
41
- * {@link physicalFields} so projection, collection-schema and query compiler
41
+ * {@link physicalFields} so projection, collection-definition and query compiler
42
42
  * cannot disagree.
43
43
  *
44
44
  * SHACL is one possible *source*, not a dependency: a generator can emit a
@@ -193,19 +193,22 @@ export interface FacetRange {
193
193
  }
194
194
  /**
195
195
  * One root type’s complete search declaration: its logical API `name`, the
196
- * `type` IRI its documents are instances of, and the queryable `fields`
197
- * (including {@link SearchField.derive derived} ones). A SHACL generator can
198
- * emit one per NodeShape (`name`←`sh:name`/local name, `type`←`sh:targetClass`,
199
- * `fields`←its property shapes), but that is a source, not a requirement.
196
+ * `class` IRI its documents are instances of (the RDF class), and the queryable
197
+ * `fields` (including {@link SearchField.derive derived} ones). A SHACL
198
+ * generator can emit one per NodeShape (`name`←`sh:name`/local name,
199
+ * `class`←`sh:targetClass`, `fields`←its property shapes), but that is a source,
200
+ * not a requirement.
200
201
  */
201
202
  export interface SearchType {
202
203
  /** Logical API name (PascalCase, e.g. `Dataset`) — names the type in the API
203
204
  * surfaces (GraphQL type names, a REST path), the way each field’s
204
205
  * {@link SearchField.name} names that field. Deliberately declared rather
205
- * than derived from the `type` IRI, so re-modelling the vocabulary cannot
206
+ * than derived from the `class` IRI, so re-modelling the vocabulary cannot
206
207
  * silently rename the public contract. */
207
208
  readonly name: string;
208
- readonly type: string;
209
+ /** The RDF class IRI its documents are instances of (`sh:targetClass`); the
210
+ * key a {@link SearchSchema} maps this type under. */
211
+ readonly class: string;
209
212
  readonly fields: readonly SearchField[];
210
213
  }
211
214
  /**
@@ -219,7 +222,7 @@ export interface SearchType {
219
222
  export declare function defineSearchType<const Type extends SearchType>(searchType: Type): Type;
220
223
  /**
221
224
  * The complete search declaration of a deployment: every root {@link SearchType},
222
- * keyed by its `type` IRI. Build one with {@link searchSchema}, which captures
225
+ * keyed by its `class` IRI. Build one with {@link searchSchema}, which captures
223
226
  * the declared types as a literal tuple (`Types`), so schema-bound consumers
224
227
  * (the engine port) can type their per-type behaviour off it. A plain
225
228
  * `: SearchSchema` annotation widens gracefully to `SearchType`.
@@ -233,11 +236,11 @@ export interface SearchSchema<Types extends readonly SearchType[] = readonly Sea
233
236
  readonly [validSearchSchema]: true;
234
237
  }
235
238
  /**
236
- * Build a {@link SearchSchema} from root-type declarations, keyed by `type`.
239
+ * Build a {@link SearchSchema} from root-type declarations, keyed by `class`.
237
240
  *
238
241
  * Every declaration is validated ({@link assertValidSearchType}) — the
239
242
  * declaration-time counterpart of the port’s `assertValidQuery` — and the
240
- * schema-wide invariants are enforced: no two types may share a `type` IRI
243
+ * schema-wide invariants are enforced: no two types may share a `class` IRI
241
244
  * (they would silently overwrite each other in the map) or a `name` (names
242
245
  * key the API surfaces). Throws on the first invalid declaration, so a bad
243
246
  * schema fails at startup, not per document at index time or per query.
@@ -301,7 +304,7 @@ export declare function assertValidSearchType(searchType: SearchType): void;
301
304
  /**
302
305
  * The physical engine fields one {@link SearchField} fans out into, grouped by
303
306
  * the role each plays. The single source of truth for the naming convention, so
304
- * the projection (writes them), the collection schema (declares them) and the
307
+ * the projection (writes them), the collection definition (declares them) and the
305
308
  * query compiler (reads them) cannot disagree.
306
309
  */
307
310
  export interface PhysicalFields {
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,SAAS,GACT,SAAS,GACT,QAAQ,GACR,SAAS,GACT,MAAM,GACN,WAAW,CAAC;AAEhB;oEACoE;AACpE,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAcnD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS,CAE7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,YAAY,CAAC;AAEjB,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B;wCACoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;+EAC2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB;;yCAEqC;IACrC,QAAQ,CAAC,QAA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;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,GACjB,KAAK,IAAI,YAAY,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGhE;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAoBjE"}
package/dist/schema.js CHANGED
@@ -28,11 +28,11 @@ export function defineSearchType(searchType) {
28
28
  return searchType;
29
29
  }
30
30
  /**
31
- * Build a {@link SearchSchema} from root-type declarations, keyed by `type`.
31
+ * Build a {@link SearchSchema} from root-type declarations, keyed by `class`.
32
32
  *
33
33
  * Every declaration is validated ({@link assertValidSearchType}) — the
34
34
  * declaration-time counterpart of the port’s `assertValidQuery` — and the
35
- * schema-wide invariants are enforced: no two types may share a `type` IRI
35
+ * schema-wide invariants are enforced: no two types may share a `class` IRI
36
36
  * (they would silently overwrite each other in the map) or a `name` (names
37
37
  * key the API surfaces). Throws on the first invalid declaration, so a bad
38
38
  * schema fails at startup, not per document at index time or per query.
@@ -42,18 +42,18 @@ export function searchSchema(...types) {
42
42
  const names = new Set();
43
43
  for (const searchType of types) {
44
44
  assertValidSearchType(searchType);
45
- if (typeIris.has(searchType.type)) {
46
- throw new Error(`Duplicate search type IRI “${searchType.type}”; each SearchType must declare a distinct type.`);
45
+ if (typeIris.has(searchType.class)) {
46
+ throw new Error(`Duplicate search type IRI “${searchType.class}”; each SearchType must declare a distinct class.`);
47
47
  }
48
48
  if (names.has(searchType.name)) {
49
49
  throw new Error(`Duplicate search type name “${searchType.name}”; each SearchType must declare a distinct name.`);
50
50
  }
51
- typeIris.add(searchType.type);
51
+ typeIris.add(searchType.class);
52
52
  names.add(searchType.name);
53
53
  }
54
54
  assertResolvableLabelSources(types);
55
55
  // The one blessed cast: only this validated constructor mints the brand.
56
- return new Map(types.map((searchType) => [searchType.type, searchType]));
56
+ return new Map(types.map((searchType) => [searchType.class, searchType]));
57
57
  }
58
58
  /**
59
59
  * The text field a label source serves labels from – the ‘label’ convention
@@ -193,7 +193,7 @@ export function validateSearchType(searchType) {
193
193
  * declaration object must be in the schema, not a lookalike.
194
194
  */
195
195
  export function assertTypeInSchema(schema, searchType) {
196
- if (schema.get(searchType.type) !== searchType) {
196
+ if (schema.get(searchType.class) !== searchType) {
197
197
  throw new Error(`Search type “${searchType.name}” is not in this engine’s schema; it serves ${[
198
198
  ...schema.values(),
199
199
  ]
package/dist/testing.js CHANGED
@@ -32,13 +32,13 @@ export function describeSearchEngineContract(name, engine) {
32
32
  expect(types().length).toBeGreaterThan(0);
33
33
  for (const searchType of types()) {
34
34
  expect(typeof searchType.name).toBe('string');
35
- expect(typeof searchType.type).toBe('string');
35
+ expect(typeof searchType.class).toBe('string');
36
36
  }
37
37
  });
38
38
  it('rejects a search type outside its schema', async () => {
39
39
  const foreign = {
40
40
  name: 'NotInSchema',
41
- type: 'urn:test:not-in-schema',
41
+ class: 'urn:test:not-in-schema',
42
42
  fields: [],
43
43
  };
44
44
  await expect(engine().search(foreign, browse(foreign))).rejects.toThrow(/not in this engine/);
@@ -78,7 +78,7 @@ export function describeSearchEngineContract(name, engine) {
78
78
  it('rejects a searchFacets batch for a type outside its schema', async () => {
79
79
  const foreign = {
80
80
  name: 'NotInSchema',
81
- type: 'urn:test:not-in-schema',
81
+ class: 'urn:test:not-in-schema',
82
82
  fields: [],
83
83
  };
84
84
  await expect(engine().searchFacets(foreign, [browse(foreign)])).rejects.toThrow(/not in this engine/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search",
3
- "version": "0.5.0",
3
+ "version": "0.6.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",