@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.
- package/dist/fetchMetadata.d.ts +6 -12
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +244 -206
- package/dist/index.js.map +1 -1
- package/dist/match/scoreMetadataCandidate.d.ts +5 -6
- package/dist/metadataInputFromResolvedArchive.d.ts +9 -0
- package/dist/metadataInputFromResolvedArchive.test.d.ts +1 -0
- package/dist/providers/projectGutenberg/identifier.d.ts +3 -6
- package/dist/types/fetchMetadataInput.d.ts +30 -0
- package/dist/types/fetchedMetadata.d.ts +2 -1
- package/dist/types/match.d.ts +1 -1
- package/dist/types/provider.d.ts +10 -14
- package/dist/utils/hasSearchTerms.d.ts +2 -2
- package/package.json +4 -4
package/dist/types/provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResolvedMetadata } from '@prose-reader/archive-reader';
|
|
2
|
-
|
|
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
|
|
30
|
+
* the terms you can search on out of the compact input, return normalized
|
|
31
31
|
* candidates.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
|
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 (
|
|
47
|
-
* if (
|
|
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(
|
|
51
|
-
* `&author=${encodeURIComponent(
|
|
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: (
|
|
71
|
+
readonly search: (input: FetchMetadataInput, context: MetadataProviderContext) => Promise<ReadonlyArray<MetadataCandidate>>;
|
|
76
72
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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: (
|
|
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.
|
|
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.
|
|
33
|
-
"@prose-reader/shared": "^1.
|
|
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": "
|
|
36
|
+
"gitHead": "99cc96dab3e29677ab017246bbad836b54720284"
|
|
37
37
|
}
|