@lde/search-indexer 0.2.0 → 0.3.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,5 +1,5 @@
1
1
  import { type DatasetSelector, type DistributionResolver, type Writer } from '@lde/pipeline';
2
- import type { RootType, SearchDocument } from '@lde/search';
2
+ import type { RootType, SearchDocument, SearchSchema } from '@lde/search';
3
3
  import type { Client } from 'typesense';
4
4
  import type { IndexerConfig } from './config.js';
5
5
  /** The registry-backed dataset selection the configuration describes. */
@@ -9,8 +9,13 @@ export declare function datasetSelectorFrom(config: IndexerConfig): DatasetSelec
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
11
  * so, so the read side must be configured with the same prefix.
12
+ *
13
+ * The mounted schema the pipeline hands each call travels into the writer: a
14
+ * type that surfaces an inline reference builds its collection from the
15
+ * Reference Type the schema resolves, so the nested fields are declared rather
16
+ * than silently dropped.
12
17
  */
13
- export declare function writerFactoryFrom(client: Client, config: IndexerConfig): (searchType: RootType) => Writer<SearchDocument>;
18
+ export declare function writerFactoryFrom(client: Client, config: IndexerConfig): (searchType: RootType, schema: SearchSchema) => Writer<SearchDocument>;
14
19
  /**
15
20
  * The distribution resolver the configuration describes: with `QLEVER_IMAGE`
16
21
  * set, an {@link ImportResolver} that imports data dumps into a
@@ -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,MAAM,aAAa,CAAC;AAO5D,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;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,GACpB,CAAC,UAAU,EAAE,QAAQ,KAAK,MAAM,CAAC,cAAc,CAAC,CAWlD;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":"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"}
@@ -16,14 +16,22 @@ export function datasetSelectorFrom(config) {
16
16
  * {@link InPlaceRebuild} or {@link BlueGreenRebuild} per root type, its
17
17
  * collection name derived from the type – prefixed when the deployment says
18
18
  * so, so the read side must be configured with the same prefix.
19
+ *
20
+ * The mounted schema the pipeline hands each call travels into the writer: a
21
+ * type that surfaces an inline reference builds its collection from the
22
+ * Reference Type the schema resolves, so the nested fields are declared rather
23
+ * than silently dropped.
19
24
  */
20
25
  export function writerFactoryFrom(client, config) {
21
- return (searchType) => {
22
- const options = config.collectionPrefix
23
- ? {
24
- name: `${config.collectionPrefix}${deriveCollectionName(searchType)}`,
25
- }
26
- : {};
26
+ return (searchType, schema) => {
27
+ const options = {
28
+ schema,
29
+ ...(config.collectionPrefix
30
+ ? {
31
+ name: `${config.collectionPrefix}${deriveCollectionName(searchType)}`,
32
+ }
33
+ : {}),
34
+ };
27
35
  return config.rebuildMode === 'blue-green'
28
36
  ? new BlueGreenRebuild(client, searchType, options)
29
37
  : new InPlaceRebuild(client, searchType, options);
package/dist/config.d.ts CHANGED
@@ -11,6 +11,15 @@ export interface IndexerConfig {
11
11
  /** SPARQL endpoint of the DCAT dataset registry the selection queries
12
12
  * (`REGISTRY_ENDPOINT`). */
13
13
  readonly registryEndpoint: URL;
14
+ /**
15
+ * Root types extracted from {@link registryEndpoint} instead of from each
16
+ * dataset’s own distribution (`REGISTRY_ROOT_TYPES`, whitespace- or
17
+ * comma-separated {@link SearchType.name}s) – the dataset’s own description
18
+ * and what hangs off it, which live in the register rather than in the data a
19
+ * publisher ships. Empty when unset: every type reads the distribution, the
20
+ * behaviour before this setting existed.
21
+ */
22
+ readonly registryRootTypes: readonly string[];
14
23
  /** Dataset selection within the registry: explicit IRIs (`DATASETS`),
15
24
  * search criteria (`DATASET_CRITERIA`), or every dataset when neither is
16
25
  * set. */
@@ -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;IAClC;iCAC6B;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC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mE;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,CAqFf"}
package/dist/config.js CHANGED
@@ -57,6 +57,7 @@ export function configFromEnvironment(environment) {
57
57
  const config = {
58
58
  schemaModulePath: environment['SCHEMA_MODULE'] ?? '/config/search-schema.mjs',
59
59
  registryEndpoint,
60
+ registryRootTypes: names(environment['REGISTRY_ROOT_TYPES']),
60
61
  datasetCriteria,
61
62
  typesense: {
62
63
  host: required('TYPESENSE_HOST'),
@@ -74,6 +75,16 @@ export function configFromEnvironment(environment) {
74
75
  }
75
76
  return config;
76
77
  }
78
+ /**
79
+ * A whitespace- or comma-separated list variable, as a list. The names
80
+ * themselves are validated against the mounted schema when the pipeline is
81
+ * wired – config has no schema to check them against.
82
+ */
83
+ function names(value) {
84
+ return value === undefined
85
+ ? []
86
+ : value.split(/[\s,]+/).filter((name) => name.length > 0);
87
+ }
77
88
  /** `DATASETS` (whitespace-separated IRIs) or `DATASET_CRITERIA` (a JSON
78
89
  * object) – never both; neither selects the whole registry. */
79
90
  function criteriaFromEnvironment(environment, problems) {
@@ -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,CAuBxC"}
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"}
package/dist/indexer.js CHANGED
@@ -29,6 +29,12 @@ export async function createSearchIndexer(config) {
29
29
  datasets: datasetSelectorFrom(config),
30
30
  distributionResolver: distributionResolverFrom(config),
31
31
  writerFor: writerFactoryFrom(client, config),
32
+ registryTypes: config.registryRootTypes.length > 0
33
+ ? {
34
+ endpoint: config.registryEndpoint,
35
+ names: config.registryRootTypes,
36
+ }
37
+ : undefined,
32
38
  provenanceStore: config.provenance
33
39
  ? new FileProvenanceStore({ path: config.provenance.path })
34
40
  : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-indexer",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
@@ -29,11 +29,11 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@lde/dataset-registry-client": "^0.9.1",
32
- "@lde/pipeline": "^0.35.4",
33
- "@lde/pipeline-console-reporter": "^0.26.4",
34
- "@lde/search": "^0.14.0",
35
- "@lde/search-pipeline": "^0.14.0",
36
- "@lde/search-typesense": "^0.17.0",
32
+ "@lde/pipeline": "^0.35.5",
33
+ "@lde/pipeline-console-reporter": "^0.26.5",
34
+ "@lde/search": "^0.15.0",
35
+ "@lde/search-pipeline": "^0.15.1",
36
+ "@lde/search-typesense": "^0.18.1",
37
37
  "@lde/sparql-qlever": "^0.15.3",
38
38
  "commander": "^15.0.0",
39
39
  "tslib": "^2.3.0",