@prose-reader/metadata-fetcher 1.341.0 → 1.342.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,5 +1,5 @@
1
1
  import { ResolvedMetadata } from '@prose-reader/archive-reader';
2
- export type MetadataIdentifier = NonNullable<ResolvedMetadata["identifiers"]>[number];
2
+ import { FetchMetadataInput } from './fetchMetadataInput.ts';
3
3
  export type MetadataProviderContext = {
4
4
  /**
5
5
  * How many candidates the caller will keep. A hint for the provider's own
@@ -27,28 +27,24 @@ export type MetadataCandidate = {
27
27
  };
28
28
  /**
29
29
  * A pluggable metadata source. Implementing one is: pick a stable `id`, read
30
- * the terms you can search on out of the metadata, return normalized
30
+ * the terms you can search on out of the compact input, return normalized
31
31
  * candidates.
32
32
  *
33
- * Both sides of a lookup speak {@link ResolvedMetadata} — what the book said
34
- * going in, what the catalog says coming back. There is no separate query
35
- * shape to learn: the vocabulary is already sparse by contract (`field !==
36
- * undefined` is a reliable presence check) and already carries everything a
37
- * catalog could key on, down to the format-scoped corners. `metadataAuthors`
38
- * is exported for the one derivation that needs the role vocabulary.
33
+ * Inputs contain only fields understood for lookup and matching. Returned
34
+ * candidates remain rich {@link ResolvedMetadata} entities.
39
35
  *
40
36
  * ```ts
41
- * import { type MetadataProvider, metadataAuthors } from "@prose-reader/metadata-fetcher"
37
+ * import { type MetadataProvider } from "@prose-reader/metadata-fetcher"
42
38
  *
43
39
  * const myProvider: MetadataProvider = {
44
40
  * id: "myCatalog",
45
41
  * name: "My Catalog",
46
- * search: async (metadata, { limit, signal }) => {
47
- * if (metadata.title === undefined) return []
42
+ * search: async (input, { limit, signal }) => {
43
+ * if (input.title === undefined) return []
48
44
  *
49
45
  * const response = await fetch(
50
- * `https://example.com/search?q=${encodeURIComponent(metadata.title)}` +
51
- * `&author=${encodeURIComponent(metadataAuthors(metadata)[0] ?? "")}`,
46
+ * `https://example.com/search?q=${encodeURIComponent(input.title)}` +
47
+ * `&author=${encodeURIComponent(input.authors?.[0] ?? "")}`,
52
48
  * { signal },
53
49
  * )
54
50
  * const { results } = await response.json()
@@ -72,5 +68,5 @@ export type MetadataProvider = {
72
68
  * nothing to search on, or nothing found. Throwing is allowed — a failing
73
69
  * provider never fails the fetch, it lands in `failedProviders`.
74
70
  */
75
- readonly search: (metadata: ResolvedMetadata, context: MetadataProviderContext) => Promise<ReadonlyArray<MetadataCandidate>>;
71
+ readonly search: (input: FetchMetadataInput, context: MetadataProviderContext) => Promise<ReadonlyArray<MetadataCandidate>>;
76
72
  };
@@ -1,7 +1,7 @@
1
- import { ResolvedMetadata } from '@prose-reader/archive-reader';
1
+ import { FetchMetadataInput } from '../types/fetchMetadataInput.ts';
2
2
  /**
3
3
  * Whether a catalog has anything to go on, so a lookup with nothing to ask
4
4
  * about costs no round trip. Publication details, a language, or a page count
5
5
  * narrow a search but cannot start one.
6
6
  */
7
- export declare const hasSearchTerms: (metadata: ResolvedMetadata) => boolean;
7
+ export declare const hasSearchTerms: (input: FetchMetadataInput) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prose-reader/metadata-fetcher",
3
- "version": "1.341.0",
3
+ "version": "1.342.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  "test:watch": "vitest watch"
30
30
  },
31
31
  "dependencies": {
32
- "@prose-reader/archive-reader": "^1.341.0",
33
- "@prose-reader/shared": "^1.341.0",
32
+ "@prose-reader/archive-reader": "^1.342.0",
33
+ "@prose-reader/shared": "^1.342.0",
34
34
  "xmldoc": "^2.0.0"
35
35
  },
36
- "gitHead": "620bf290b88f12f2313f7b19aa4d4abdcf124ef1"
36
+ "gitHead": "99cc96dab3e29677ab017246bbad836b54720284"
37
37
  }