@library-pals/isbn 1.4.4 → 1.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 +1 -1
- package/package.json +11 -12
- package/src/provider-resolvers.js +1 -1
- package/src/providers/librofm.js +13 -3
- package/types/provider-resolvers.d.ts +5 -1
- package/types/providers/librofm.d.ts +2 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@library-pals/isbn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Find books by ISBN",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
},
|
|
11
11
|
"types": "./types/index.d.ts",
|
|
12
12
|
"type": "module",
|
|
13
|
-
"main": "src/index.js",
|
|
14
13
|
"engines": {
|
|
15
14
|
"node": ">=20.0.0"
|
|
16
15
|
},
|
|
@@ -37,19 +36,19 @@
|
|
|
37
36
|
"author": "Katy DeCorah <@katydecorah>",
|
|
38
37
|
"license": "AGPL-3.0-or-later",
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@eslint/js": "^9.
|
|
41
|
-
"eslint": "^9.
|
|
42
|
-
"eslint-plugin-jest": "^
|
|
43
|
-
"eslint-plugin-jsdoc": "^
|
|
44
|
-
"eslint-plugin-unicorn": "^
|
|
45
|
-
"globals": "^
|
|
46
|
-
"jest": "^
|
|
47
|
-
"prettier": "^3.
|
|
39
|
+
"@eslint/js": "^9.36.0",
|
|
40
|
+
"eslint": "^9.36.0",
|
|
41
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
42
|
+
"eslint-plugin-jsdoc": "^60.4.1",
|
|
43
|
+
"eslint-plugin-unicorn": "^61.0.2",
|
|
44
|
+
"globals": "^16.4.0",
|
|
45
|
+
"jest": "^30.1.3",
|
|
46
|
+
"prettier": "^3.6.2",
|
|
48
47
|
"prettier-2": "npm:prettier@^2",
|
|
49
|
-
"typescript": "^5.
|
|
48
|
+
"typescript": "^5.9.2"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"axios": "^1.
|
|
51
|
+
"axios": "^1.12.2"
|
|
53
52
|
},
|
|
54
53
|
"bugs": {
|
|
55
54
|
"url": "https://github.com/library-pals/isbn/issues"
|
|
@@ -13,7 +13,7 @@ import { resolveLibroFm } from "./providers/librofm.js";
|
|
|
13
13
|
* @property {number} timeout - The timeout value in milliseconds.
|
|
14
14
|
*/
|
|
15
15
|
export const defaultOptions = {
|
|
16
|
-
timeout:
|
|
16
|
+
timeout: 15_000,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const GOOGLE_BOOKS_API_BASE = "https://www.googleapis.com";
|
package/src/providers/librofm.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
LIBROFM_API_BASE,
|
|
3
|
+
LIBROFM_API_BOOK,
|
|
4
|
+
defaultOptions,
|
|
5
|
+
} from "../provider-resolvers.js";
|
|
2
6
|
import axios from "axios";
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -9,13 +13,19 @@ import axios from "axios";
|
|
|
9
13
|
/**
|
|
10
14
|
* Resolves book information from Libro.fm using the provided ISBN.
|
|
11
15
|
* @param {string} isbn - The ISBN of the book.
|
|
16
|
+
* @param {AxiosRequestConfig} options - Additional options for the API request.
|
|
12
17
|
* @returns {Promise<Book>} The book information retrieved from the API.
|
|
13
18
|
* @throws {Error} If the API response code is not 200, or if no books are found with the provided ISBN, or if no volume information is found for the book.
|
|
14
19
|
*/
|
|
15
|
-
export async function resolveLibroFm(isbn) {
|
|
20
|
+
export async function resolveLibroFm(isbn, options) {
|
|
21
|
+
const requestOptions = {
|
|
22
|
+
...defaultOptions,
|
|
23
|
+
...options,
|
|
24
|
+
};
|
|
25
|
+
|
|
16
26
|
const url = `${LIBROFM_API_BASE}${LIBROFM_API_BOOK}/${isbn}`;
|
|
17
27
|
|
|
18
|
-
const response = await axios.get(url);
|
|
28
|
+
const response = await axios.get(url, requestOptions);
|
|
19
29
|
try {
|
|
20
30
|
if (response.status !== 200) {
|
|
21
31
|
throw new Error(`Unable to get ${url}: ${response.status}`);
|
|
@@ -25,8 +25,12 @@ export namespace PROVIDER_NAMES {
|
|
|
25
25
|
*/
|
|
26
26
|
export const DEFAULT_PROVIDERS: Providers;
|
|
27
27
|
export const PROVIDER_RESOLVERS: {
|
|
28
|
-
[
|
|
28
|
+
[PROVIDER_NAMES.GOOGLE]: typeof resolveGoogle;
|
|
29
|
+
[PROVIDER_NAMES.OPENLIBRARY]: typeof resolveOpenLibrary;
|
|
30
|
+
[PROVIDER_NAMES.LIBROFM]: typeof resolveLibroFm;
|
|
29
31
|
};
|
|
30
32
|
export type Providers = string[];
|
|
31
33
|
export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
|
|
32
34
|
import { resolveGoogle } from "./providers/google.js";
|
|
35
|
+
import { resolveOpenLibrary } from "./providers/open-library.js";
|
|
36
|
+
import { resolveLibroFm } from "./providers/librofm.js";
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Resolves book information from Libro.fm using the provided ISBN.
|
|
7
7
|
* @param {string} isbn - The ISBN of the book.
|
|
8
|
+
* @param {AxiosRequestConfig} options - Additional options for the API request.
|
|
8
9
|
* @returns {Promise<Book>} The book information retrieved from the API.
|
|
9
10
|
* @throws {Error} If the API response code is not 200, or if no books are found with the provided ISBN, or if no volume information is found for the book.
|
|
10
11
|
*/
|
|
11
|
-
export function resolveLibroFm(isbn: string): Promise<Book>;
|
|
12
|
+
export function resolveLibroFm(isbn: string, options: AxiosRequestConfig): Promise<Book>;
|
|
12
13
|
/**
|
|
13
14
|
* Standardizes a book object by extracting relevant information from the provided book object.
|
|
14
15
|
* @param {string} data - The data to be standardized.
|