@lde/search-indexer 0.6.0 → 0.6.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.
@@ -8,7 +8,8 @@ export declare function datasetSelectorFrom(config: IndexerConfig): DatasetSelec
8
8
  * The engine-writer factory the configuration describes: an
9
9
  * {@link InPlaceRebuild} or {@link BlueGreenRebuild} per root type, its
10
10
  * collection name derived from the type – prefixed when the deployment says
11
- * so, so the read side must be configured with the same prefix.
11
+ * so, so the read side must be configured with the same prefix – and its
12
+ * untagged text stemmed in the configured {@link IndexerConfig.defaultLocale}.
12
13
  *
13
14
  * The mounted schema the pipeline hands each call travels into the writer: a
14
15
  * type that surfaces an inline reference builds its collection from the
@@ -1 +1 @@
1
- {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAK1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,GACpB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC,cAAc,CAAC,CAcxE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,GACpB,oBAAoB,GAAG,SAAS,CA0BlC"}
1
+ {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAK1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,GACpB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC,cAAc,CAAC,CAexE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,GACpB,oBAAoB,GAAG,SAAS,CA0BlC"}
@@ -1,5 +1,6 @@
1
- // Internal composition pieces of createSearchIndexer, split out so each can
2
- // be tested without running a pipeline (Pipeline keeps its wiring private).
1
+ // The composition pieces of createSearchIndexer, each usable on its own so a
2
+ // deployment that needs one bespoke stage keeps the rest of the wiring
3
+ // (Pipeline keeps its own wiring private).
3
4
  import { Client as RegistryClient } from '@lde/dataset-registry-client';
4
5
  import { ImportResolver, RegistrySelector, SparqlDistributionResolver, } from '@lde/pipeline';
5
6
  import { BlueGreenRebuild, deriveCollectionName, InPlaceRebuild, } from '@lde/search-typesense';
@@ -15,7 +16,8 @@ export function datasetSelectorFrom(config) {
15
16
  * The engine-writer factory the configuration describes: an
16
17
  * {@link InPlaceRebuild} or {@link BlueGreenRebuild} per root type, its
17
18
  * collection name derived from the type – prefixed when the deployment says
18
- * so, so the read side must be configured with the same prefix.
19
+ * so, so the read side must be configured with the same prefix – and its
20
+ * untagged text stemmed in the configured {@link IndexerConfig.defaultLocale}.
19
21
  *
20
22
  * The mounted schema the pipeline hands each call travels into the writer: a
21
23
  * type that surfaces an inline reference builds its collection from the
@@ -24,7 +26,8 @@ export function datasetSelectorFrom(config) {
24
26
  */
25
27
  export function writerFactoryFrom(client, config) {
26
28
  return (searchType, schema) => {
27
- const options = {
29
+ const writerOptions = {
30
+ defaultLocale: config.defaultLocale,
28
31
  schema,
29
32
  ...(config.collectionPrefix
30
33
  ? {
@@ -33,8 +36,8 @@ export function writerFactoryFrom(client, config) {
33
36
  : {}),
34
37
  };
35
38
  return config.rebuildMode === 'blue-green'
36
- ? new BlueGreenRebuild(client, searchType, options)
37
- : new InPlaceRebuild(client, searchType, options);
39
+ ? new BlueGreenRebuild(client, searchType, writerOptions)
40
+ : new InPlaceRebuild(client, searchType, writerOptions);
38
41
  };
39
42
  }
40
43
  /**
package/dist/config.d.ts CHANGED
@@ -32,6 +32,13 @@ export interface IndexerConfig {
32
32
  /** Prefix prepended to every derived collection name
33
33
  * (`COLLECTION_PREFIX`), e.g. for a shared multi-tenant engine. */
34
34
  readonly collectionPrefix?: string;
35
+ /**
36
+ * Stemming language for text that carries no language tag (`DEFAULT_LOCALE`,
37
+ * e.g. `nl`). Unset, such text is folded but **unstemmed** – no language is
38
+ * ever assumed – so `fietsen` does not match `fiets`. Text declaring a real
39
+ * locale always stems in its own language, whatever this says.
40
+ */
41
+ readonly defaultLocale?: string;
35
42
  /** Per-dataset processing memory: skip unchanged datasets
36
43
  * (`PROVENANCE_FILE` + `PIPELINE_VERSION`). */
37
44
  readonly provenance?: ProvenanceConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACl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ACtE,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,0BAA0B,GAAG,QAAQ,CAAC;IACpE,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;oCAGgC;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACxD,aAAa,CAsFf"}
package/dist/config.js CHANGED
@@ -67,6 +67,7 @@ export function configFromEnvironment(environment) {
67
67
  },
68
68
  rebuildMode: rebuildMode,
69
69
  collectionPrefix: environment['COLLECTION_PREFIX'],
70
+ defaultLocale: environment['DEFAULT_LOCALE'],
70
71
  provenance,
71
72
  qlever,
72
73
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { createSearchIndexer } from './indexer.js';
2
+ export type { SearchIndexerExtensions } from './indexer.js';
3
+ export { datasetSelectorFrom, distributionResolverFrom, writerFactoryFrom, } from './composition.js';
2
4
  export { configFromEnvironment } from './config.js';
3
5
  export type { IndexerConfig, ProvenanceConfig, QleverConfig, TypesenseConnection, } from './config.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAO5D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -4,4 +4,11 @@
4
4
  // `search-indexer` bin (src/cli.ts) and the Docker image are thin wrappers
5
5
  // over these.
6
6
  export { createSearchIndexer } from './indexer.js';
7
+ // The pieces createSearchIndexer composes. Adding a transform does NOT need
8
+ // these – that is `createSearchIndexer(config, { transforms })`. They are for
9
+ // the genuinely bespoke deployment (a non-SPARQL reader, another engine, a root
10
+ // selector that is not by class), which composes `searchStages`,
11
+ // `searchIndexWriter` and `Pipeline` directly and would otherwise also re-derive
12
+ // dataset selection, the QLever import path and collection naming.
13
+ export { datasetSelectorFrom, distributionResolverFrom, writerFactoryFrom, } from './composition.js';
7
14
  export { configFromEnvironment } from './config.js';
package/dist/indexer.d.ts CHANGED
@@ -1,13 +1,36 @@
1
- import { type Pipeline } from '@lde/pipeline';
1
+ import { type Pipeline, type QuadTransform, type ReaderContext } from '@lde/pipeline';
2
2
  import { type TypedSearchDocument } from '@lde/search-pipeline';
3
3
  import type { IndexerConfig } from './config.js';
4
+ /** What a deployment adds to the standard indexer – the domain behaviour no
5
+ * configuration can express. */
6
+ export interface SearchIndexerExtensions {
7
+ /**
8
+ * {@link QuadTransform}(s) per root type, keyed by `SearchType.name`: correct
9
+ * the data, mint a quad the source does not ship, drop one it should not.
10
+ * Attached to the type’s reader, so a transform sees each root’s quads before
11
+ * projection.
12
+ *
13
+ * This is the whole cost of adding behaviour – dataset selection, the QLever
14
+ * import path, registry-sourced types, collection naming, provenance and
15
+ * reporting stay wired. A name the schema does not declare throws at boot.
16
+ *
17
+ * A field a transform fills must still declare a `path`: projection skips a
18
+ * field with neither a `path` nor a `derive`.
19
+ */
20
+ readonly transforms?: Readonly<Record<string, QuadTransform<ReaderContext> | QuadTransform<ReaderContext>[]>>;
21
+ }
4
22
  /**
5
23
  * Compose the ready-to-run search indexer from an {@link IndexerConfig}: load
6
24
  * and validate the mounted schema module (the same file the served-API image
7
25
  * mounts), select datasets from the registry, bind the Typesense rebuild
8
26
  * writers, and wire the optional QLever import path and provenance store into
9
27
  * `searchIndexerPipeline`. Every misconfiguration – an invalid schema, an
10
- * underivable collection name – throws here, at boot, never mid-run.
28
+ * underivable collection name, a transform naming an undeclared type – throws
29
+ * here, at boot, never mid-run.
30
+ *
31
+ * `extensions` carries the domain behaviour a deployment adds on top
32
+ * ({@link SearchIndexerExtensions}); everything else about a deployment is
33
+ * configuration, so the bin and the Docker image need only the config.
11
34
  */
12
- export declare function createSearchIndexer(config: IndexerConfig): Promise<Pipeline<TypedSearchDocument>>;
35
+ export declare function createSearchIndexer(config: IndexerConfig, extensions?: SearchIndexerExtensions): Promise<Pipeline<TypedSearchDocument>>;
13
36
  //# sourceMappingURL=indexer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CA8BxC"}
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;iCACiC;AACjC,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAC5B,MAAM,CACJ,MAAM,EACN,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,CAC9D,CACF,CAAC;CACH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,UAAU,GAAE,uBAA4B,GACvC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CA+BxC"}
package/dist/indexer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FileProvenanceStore } from '@lde/pipeline';
1
+ import { FileProvenanceStore, } from '@lde/pipeline';
2
2
  import { ConsoleReporter } from '@lde/pipeline-console-reporter';
3
3
  import { loadSchemaModule } from '@lde/search/module';
4
4
  import { searchIndexerPipeline, } from '@lde/search-pipeline';
@@ -10,9 +10,14 @@ import { datasetSelectorFrom, distributionResolverFrom, writerFactoryFrom, } fro
10
10
  * mounts), select datasets from the registry, bind the Typesense rebuild
11
11
  * writers, and wire the optional QLever import path and provenance store into
12
12
  * `searchIndexerPipeline`. Every misconfiguration – an invalid schema, an
13
- * underivable collection name – throws here, at boot, never mid-run.
13
+ * underivable collection name, a transform naming an undeclared type – throws
14
+ * here, at boot, never mid-run.
15
+ *
16
+ * `extensions` carries the domain behaviour a deployment adds on top
17
+ * ({@link SearchIndexerExtensions}); everything else about a deployment is
18
+ * configuration, so the bin and the Docker image need only the config.
14
19
  */
15
- export async function createSearchIndexer(config) {
20
+ export async function createSearchIndexer(config, extensions = {}) {
16
21
  const { schema } = await loadSchemaModule(config.schemaModulePath);
17
22
  const client = new Client({
18
23
  nodes: [
@@ -40,5 +45,6 @@ export async function createSearchIndexer(config) {
40
45
  : undefined,
41
46
  pipelineVersion: config.provenance?.pipelineVersion,
42
47
  reporter: new ConsoleReporter(),
48
+ transforms: extensions.transforms,
43
49
  });
44
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-indexer",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "The @lde/search-pipeline indexer as a bootable process and prebuilt Docker image: loads a mounted schema-declaration module, dataset selection, Typesense connection and rebuild mode from the environment, then runs the object-grain searchIndexerPipeline once to completion. The composition layer that binds the engine-agnostic @lde/search-pipeline stages to @lde/search-typesense – the write-path counterpart of @lde/search-api-server.",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/ldelements/lde.git",
@@ -32,7 +32,7 @@
32
32
  "@lde/pipeline": "^0.35.6",
33
33
  "@lde/pipeline-console-reporter": "^0.26.6",
34
34
  "@lde/search": "^0.18.0",
35
- "@lde/search-pipeline": "^0.18.0",
35
+ "@lde/search-pipeline": "^0.18.1",
36
36
  "@lde/search-typesense": "^0.21.0",
37
37
  "@lde/sparql-qlever": "^0.15.3",
38
38
  "commander": "^15.0.0",