@library-pals/isbn 1.3.1 → 1.3.3

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 CHANGED
@@ -5,8 +5,6 @@ following providers:
5
5
 
6
6
  - [Google Books API](https://developers.google.com/books/)
7
7
  - [Open Library Books API](https://openlibrary.org/dev/docs/api/books)
8
- - [ISBNdb API](https://isbndb.com/apidocs/v2) using API key in the environment
9
- variable `ISBNDB_API_KEY`
10
8
  - [Libro.fm](https://libro.fm/explore)
11
9
 
12
10
  ## Acknowledgements
@@ -64,7 +62,7 @@ information.
64
62
  {
65
63
  "title": "Annihilation",
66
64
  "authors": ["Jeff VanderMeer"],
67
- "description": "Describes the 12th expedition to “Area X,” a region cut off from the continent for decades, by a group of intrepid women scientists who try to ignore the high mortality rates of those on the previous 11 missions. Original. 75,000 first printing.",
65
+ "description": "Area X has claimed the lives of members of eleven expeditions. The twelfth expedition consisting of four women hopes to map the terrain and collect specimens; to record all their observations, scientific and otherwise, of their surroundings and of one another; and, above all, to avoid being contaminated by Area X itself.",
68
66
  "pageCount": 209,
69
67
  "format": "book",
70
68
  "categories": [
@@ -210,5 +208,4 @@ try {
210
208
 
211
209
  See also
212
210
  [Google Books API Terms of Service](https://developers.google.com/books/terms),
213
- [Open Library Licensing](https://openlibrary.org/developers/licensing),
214
- [ISBNdb Terms and Conditions](https://isbndb.com/terms-and-conditions).
211
+ [Open Library Licensing](https://openlibrary.org/developers/licensing)
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@library-pals/isbn",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Find books by ISBN",
5
5
  "exports": "./src/index.js",
6
- "types": "./src/index.d.ts",
6
+ "types": "./types/index.d.ts",
7
7
  "type": "module",
8
8
  "engines": {
9
9
  "node": ">=20.0.0"
10
10
  },
11
11
  "scripts": {
12
- "build": "tsc --version && tsc --build --clean && tsc --build",
12
+ "build": "tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
13
13
  "prepack": "npm run build",
14
14
  "lint": "eslint .",
15
15
  "pretest": "npm run build && npm run lint",
@@ -26,27 +26,24 @@
26
26
  "google",
27
27
  "openlibrary",
28
28
  "api",
29
- "isbndb",
30
29
  "librofm"
31
30
  ],
32
31
  "author": "Katy DeCorah <@katydecorah>",
33
32
  "license": "AGPL-3.0-or-later",
34
33
  "devDependencies": {
35
- "@eslint/js": "^9.2.0",
36
- "eslint": "^9.2.0",
37
- "eslint-plugin-jest": "^28.5.0",
38
- "eslint-plugin-jsdoc": "^48.2.4",
39
- "eslint-plugin-unicorn": "^53.0.0",
40
- "globals": "^15.2.0",
34
+ "@eslint/js": "^9.9.0",
35
+ "eslint": "^9.9.0",
36
+ "eslint-plugin-jest": "^28.8.0",
37
+ "eslint-plugin-jsdoc": "^50.2.2",
38
+ "eslint-plugin-unicorn": "^55.0.0",
39
+ "globals": "^15.9.0",
41
40
  "jest": "^29.7.0",
42
- "prettier": "^3.2.5",
41
+ "prettier": "^3.3.3",
43
42
  "prettier-2": "npm:prettier@^2",
44
- "typescript": "^5.4.5"
43
+ "typescript": "^5.5.4"
45
44
  },
46
45
  "dependencies": {
47
- "axios": "^1.6.8",
48
- "string-strip-html": "^13.4.8",
49
- "xss": "^1.0.15"
46
+ "axios": "^1.7.4"
50
47
  },
51
48
  "bugs": {
52
49
  "url": "https://github.com/library-pals/isbn/issues"
@@ -1,6 +1,5 @@
1
1
  import { resolveGoogle } from "./providers/google.js";
2
2
  import { resolveOpenLibrary } from "./providers/open-library.js";
3
- import { resolveIsbnDb } from "./providers/isbndb.js";
4
3
  import { resolveLibroFm } from "./providers/librofm.js";
5
4
 
6
5
  /**
@@ -23,16 +22,12 @@ export const GOOGLE_BOOKS_API_BOOK = "/books/v1/volumes";
23
22
  export const OPENLIBRARY_API_BASE = "https://openlibrary.org";
24
23
  export const OPENLIBRARY_API_BOOK = "/isbn";
25
24
 
26
- export const ISBNDB_API_BASE = "https://api2.isbndb.com";
27
- export const ISBNDB_API_BOOK = "/book";
28
-
29
25
  export const LIBROFM_API_BASE = "https://libro.fm";
30
26
  export const LIBROFM_API_BOOK = "/audiobooks";
31
27
 
32
28
  export const PROVIDER_NAMES = {
33
29
  GOOGLE: "google",
34
30
  OPENLIBRARY: "openlibrary",
35
- ISBNDB: "isbndb",
36
31
  LIBROFM: "librofm",
37
32
  };
38
33
 
@@ -43,13 +38,11 @@ export const PROVIDER_NAMES = {
43
38
  export const DEFAULT_PROVIDERS = [
44
39
  PROVIDER_NAMES.GOOGLE,
45
40
  PROVIDER_NAMES.OPENLIBRARY,
46
- PROVIDER_NAMES.ISBNDB,
47
41
  PROVIDER_NAMES.LIBROFM,
48
42
  ];
49
43
 
50
44
  export const PROVIDER_RESOLVERS = {
51
45
  [PROVIDER_NAMES.GOOGLE]: resolveGoogle,
52
46
  [PROVIDER_NAMES.OPENLIBRARY]: resolveOpenLibrary,
53
- [PROVIDER_NAMES.ISBNDB]: resolveIsbnDb,
54
47
  [PROVIDER_NAMES.LIBROFM]: resolveLibroFm,
55
48
  };
@@ -1,7 +1,5 @@
1
1
  import { LIBROFM_API_BASE, LIBROFM_API_BOOK } from "../provider-resolvers.js";
2
2
  import axios from "axios";
3
- import xss from "xss";
4
- import { stripHtml } from "string-strip-html";
5
3
 
6
4
  /**
7
5
  * @typedef {import('../index.js').Book} Book
@@ -98,15 +96,14 @@ export async function standardize(data, isbn, url) {
98
96
  */
99
97
  export function formatDescription(description) {
100
98
  if (!description) return "";
101
- description = xss(description);
102
99
  // Replace <br> with a space
103
100
  description = description.replaceAll("<br>", " ");
104
101
  // Replace <b>—</b> with a dash
105
102
  description = description.replaceAll("<b>—</b>", "—");
106
103
  // Remove bold tags and contents
107
104
  description = description.replaceAll(/<b>.*?<\/b>/g, "");
108
- // Remove all other html elements
109
- description = stripHtml(description).result;
105
+ // Strip HTML tags
106
+ description = stripHtmlTags(description);
110
107
  // Trim
111
108
  description = description.trim();
112
109
  // Remove extra spaces
@@ -135,3 +132,27 @@ function extractGenres(text) {
135
132
 
136
133
  return genres;
137
134
  }
135
+
136
+ /**
137
+ * Encodes HTML special characters to prevent XSS attacks.
138
+ * @param {string} string - The string to encode.
139
+ * @returns {string} - The encoded string.
140
+ */
141
+ function encodeHTML(string) {
142
+ return string
143
+ .replaceAll("&", "&amp;")
144
+ .replaceAll("<", "&lt;")
145
+ .replaceAll(">", "&gt;")
146
+ .replaceAll('" ', "” ")
147
+ .replaceAll(' "', "“ ")
148
+ .replaceAll("'", "&#39;");
149
+ }
150
+
151
+ /**
152
+ * Removes HTML tags from a string and encodes it to prevent XSS attacks.
153
+ * @param {string} string - The string from which to remove HTML tags.
154
+ * @returns {string} - The sanitized string without HTML tags.
155
+ */
156
+ function stripHtmlTags(string) {
157
+ return encodeHTML(string.replaceAll(/<\/?[^>]+(>|$)/g, ""));
158
+ }
@@ -22,11 +22,10 @@ export default class Isbn {
22
22
  /**
23
23
  * @type {Providers}
24
24
  */
25
- _providers: import("./provider-resolvers.js").Providers;
25
+ _providers: Providers;
26
26
  PROVIDER_NAMES: {
27
27
  GOOGLE: string;
28
28
  OPENLIBRARY: string;
29
- ISBNDB: string;
30
29
  LIBROFM: string;
31
30
  };
32
31
  /**
@@ -100,6 +99,5 @@ export type Book = {
100
99
  */
101
100
  bookProvider: string;
102
101
  };
103
- export type Providers = import('./provider-resolvers.js').Providers;
104
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
105
- //# sourceMappingURL=index.d.ts.map
102
+ export type Providers = import("./provider-resolvers.js").Providers;
103
+ export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
@@ -12,14 +12,11 @@ export const GOOGLE_BOOKS_API_BASE: "https://www.googleapis.com";
12
12
  export const GOOGLE_BOOKS_API_BOOK: "/books/v1/volumes";
13
13
  export const OPENLIBRARY_API_BASE: "https://openlibrary.org";
14
14
  export const OPENLIBRARY_API_BOOK: "/isbn";
15
- export const ISBNDB_API_BASE: "https://api2.isbndb.com";
16
- export const ISBNDB_API_BOOK: "/book";
17
15
  export const LIBROFM_API_BASE: "https://libro.fm";
18
16
  export const LIBROFM_API_BOOK: "/audiobooks";
19
17
  export namespace PROVIDER_NAMES {
20
18
  let GOOGLE: string;
21
19
  let OPENLIBRARY: string;
22
- let ISBNDB: string;
23
20
  let LIBROFM: string;
24
21
  }
25
22
  /**
@@ -31,6 +28,5 @@ export const PROVIDER_RESOLVERS: {
31
28
  [x: string]: typeof resolveGoogle;
32
29
  };
33
30
  export type Providers = string[];
34
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
31
+ export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
35
32
  import { resolveGoogle } from "./providers/google.js";
36
- //# sourceMappingURL=provider-resolvers.d.ts.map
@@ -65,8 +65,8 @@ export function getVolume(id: string): Promise<{
65
65
  imageLinks?: ImageLinks;
66
66
  categories?: string[];
67
67
  }>;
68
- export type Book = import('../index.js').Book;
69
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
68
+ export type Book = import("../index.js").Book;
69
+ export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
70
70
  export type ImageLinks = {
71
71
  /**
72
72
  * - extraLarge
@@ -195,4 +195,3 @@ export type GoogleBook = {
195
195
  */
196
196
  searchInfo: object;
197
197
  };
198
- //# sourceMappingURL=google.d.ts.map
@@ -46,8 +46,8 @@ export function standardize(data: string, isbn: string, url: string): Promise<Bo
46
46
  * @returns {string} The formatted description.
47
47
  */
48
48
  export function formatDescription(description: string): string;
49
- export type Book = import('../index.js').Book;
50
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
49
+ export type Book = import("../index.js").Book;
50
+ export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
51
51
  export type Person = {
52
52
  /**
53
53
  * - The name of the person.
@@ -120,4 +120,3 @@ export type Audiobook = {
120
120
  */
121
121
  workExample: object;
122
122
  };
123
- //# sourceMappingURL=librofm.d.ts.map
@@ -95,8 +95,8 @@ export function getWorks(book: OpenLibraryBook): Promise<{
95
95
  key: string;
96
96
  }[];
97
97
  }>;
98
- export type Book = import('../index.js').Book;
99
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
98
+ export type Book = import("../index.js").Book;
99
+ export type AxiosRequestConfig = import("axios").AxiosRequestConfig;
100
100
  export type Author = {
101
101
  /**
102
102
  * - The key of the author.
@@ -253,4 +253,3 @@ export type OpenLibraryResponse = {
253
253
  };
254
254
  }[];
255
255
  };
256
- //# sourceMappingURL=open-library.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AAEH;IACE;;OAEG;IACH,wDAA+B;IAG7B;;;;;MAAoC;IAGtC;;;;;;OAMG;IACH,oBALW,MAAM,EAAE,GACN,MAAM,CAwBlB;IAED;;;;;;OAMG;IACH,cALW,MAAM,YACN,kBAAkB,GAChB,QAAQ,IAAI,CAAC,CAkBzB;CACF;;;;;UAlFa,MAAM;;;;WACN,MAAM;;;;aACN,MAAM,EAAE;;;;iBACR,MAAM;;;;gBACN,MAAM;;;;YACN,MAAM;;;;gBACN,MAAM,EAAE;;;;eACR,MAAM;;;;mBACN,MAAM;;;;eACN,MAAM,GAAG,SAAS;;;;gBAClB,MAAM,GAAG,SAAS;;;;WAClB,MAAM;;;;kBACN,MAAM;;wBAIP,OAAO,yBAAyB,EAAE,SAAS;iCAC3C,OAAO,OAAO,EAAE,kBAAkB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider-resolvers.d.ts","sourceRoot":"","sources":["provider-resolvers.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;GAIG;AACH,6BAHU,kBAAkB,CAK1B;AAEF,iEAAkE;AAClE,wDAAyD;AAEzD,6DAA8D;AAC9D,2CAA4C;AAE5C,wDAAyD;AACzD,sCAAuC;AAEvC,kDAAmD;AACnD,6CAA8C;;;;;;;AAS9C;;;GAGG;AACH,0CAKE;AAEF;;EAKE;wBAhDW,MAAM,EAAE;iCACR,OAAO,OAAO,EAAE,kBAAkB;8BAPjB,uBAAuB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["google.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH;;;;;;GAMG;AACH,oCALW,MAAM,WACN,kBAAkB,GAChB,QAAQ,IAAI,CAAC,CA4BzB;AAED;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;GAMG;AACH,kCALW,UAAU,MACV,MAAM,QACN,MAAM,GACJ,QAAQ,IAAI,CAAC,CAuBzB;AAED;;;;;GAKG;AACH,8BAJW,MAAM,GACJ,QAAQ;IAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAiBrE;mBA/HY,OAAO,aAAa,EAAE,IAAI;iCAC1B,OAAO,OAAO,EAAE,kBAAkB;;;;;iBAuCjC,MAAM;;;;YACN,MAAM;;;;aACN,MAAM;;;;YACN,MAAM;;;;gBACN,MAAM;;;;qBACN,MAAM;;;;;;WAKN,MAAM;;;;cACN,MAAM;;;;aACN,MAAM,EAAE;;;;eACR,MAAM;;;;mBACN,MAAM;;;;iBACN,MAAM;;;;yBACN,MAAM,EAAE;;;;kBACR,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;gBACN,MAAM,EAAE;;;;mBACR,MAAM;;;;kBACN,MAAM;;;;oBACN,MAAM;;;;sBACN,OAAO;;;;oBACP,MAAM;;;;yBACN,MAAM;;;;iBACN,UAAU;;;;cACV,MAAM;;;;iBACN,MAAM;;;;cACN,MAAM;;;;yBACN,MAAM;;;;cACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM"}
@@ -1,184 +0,0 @@
1
- /**
2
- * @typedef {import('../index.js').Book} Book
3
- * @typedef {import('axios').AxiosRequestConfig} AxiosRequestConfig
4
- */
5
- /**
6
- * Resolves the ISBN using the ISBNdb API.
7
- * @param {string} isbn - The ISBN to resolve.
8
- * @param {AxiosRequestConfig} options - Additional options for the request.
9
- * @returns {Promise<Book>} - A promise that resolves to the standardized book data.
10
- * @throws {Error} - If the response code is not 200 or if no books are found with the given ISBN.
11
- */
12
- export function resolveIsbnDb(isbn: string, options: AxiosRequestConfig): Promise<Book>;
13
- export type Book = import('../index.js').Book;
14
- export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
15
- export type Dimension = {
16
- /**
17
- * - The unit of the dimension.
18
- */
19
- unit: string;
20
- /**
21
- * - The value of the dimension.
22
- */
23
- value: number;
24
- };
25
- export type Offset = {
26
- /**
27
- * - The x offset.
28
- */
29
- x: string;
30
- /**
31
- * - The y offset.
32
- */
33
- y: string;
34
- };
35
- export type Price = {
36
- /**
37
- * - The condition of the book.
38
- */
39
- condition: string;
40
- /**
41
- * - The merchant selling the book.
42
- */
43
- merchant: string;
44
- /**
45
- * - The logo of the merchant.
46
- */
47
- merchant_logo: string;
48
- /**
49
- * - The offset of the merchant logo.
50
- */
51
- merchant_logo_offset: Offset;
52
- /**
53
- * - The shipping cost.
54
- */
55
- shipping: string;
56
- /**
57
- * - The price of the book.
58
- */
59
- price: string;
60
- /**
61
- * - The total cost.
62
- */
63
- total: string;
64
- /**
65
- * - The link to buy the book.
66
- */
67
- link: string;
68
- };
69
- export type OtherIsbn = {
70
- /**
71
- * - The ISBN of the book.
72
- */
73
- isbn: string;
74
- /**
75
- * - The binding of the book.
76
- */
77
- binding: string;
78
- };
79
- export type IsbnDbBook = {
80
- /**
81
- * - The title of the book.
82
- */
83
- title: string;
84
- /**
85
- * - The long title of the book.
86
- */
87
- title_long: string;
88
- /**
89
- * - The ISBN of the book.
90
- */
91
- isbn: string;
92
- /**
93
- * - The ISBN13 of the book.
94
- */
95
- isbn13: string;
96
- /**
97
- * - The Dewey Decimal classification of the book.
98
- */
99
- dewey_decimal: string;
100
- /**
101
- * - The binding of the book.
102
- */
103
- binding: string;
104
- /**
105
- * - The publisher of the book.
106
- */
107
- publisher: string;
108
- /**
109
- * - The language of the book.
110
- */
111
- language: string;
112
- /**
113
- * - The published date of the book.
114
- */
115
- date_published: string;
116
- /**
117
- * - The edition of the book.
118
- */
119
- edition: string;
120
- /**
121
- * - The number of pages in the book.
122
- */
123
- pages: number;
124
- /**
125
- * - The dimensions of the book.
126
- */
127
- dimensions: string;
128
- /**
129
- * - The structured dimensions of the book.
130
- */
131
- dimensions_structured: {
132
- length: Dimension;
133
- width: Dimension;
134
- height: Dimension;
135
- weight: Dimension;
136
- };
137
- /**
138
- * - The overview of the book.
139
- */
140
- overview: string;
141
- /**
142
- * - The image link of the book.
143
- */
144
- image: string;
145
- /**
146
- * - The manufacturer's suggested retail price of the book.
147
- */
148
- msrp: number;
149
- /**
150
- * - The excerpt of the book.
151
- */
152
- excerpt: string;
153
- /**
154
- * - The synopsis of the book.
155
- */
156
- synopsis: string;
157
- /**
158
- * - The authors of the book.
159
- */
160
- authors: string[];
161
- /**
162
- * - The subjects or categories of the book.
163
- */
164
- subjects: string[];
165
- /**
166
- * - The reviews of the book.
167
- */
168
- reviews: string[];
169
- /**
170
- * - The prices of the book.
171
- */
172
- prices: Price[];
173
- /**
174
- * - The related books.
175
- */
176
- related: {
177
- type: string;
178
- };
179
- /**
180
- * - The other ISBNs of the book.
181
- */
182
- other_isbns: OtherIsbn[];
183
- };
184
- //# sourceMappingURL=isbndb.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isbndb.d.ts","sourceRoot":"","sources":["isbndb.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH;;;;;;GAMG;AACH,oCALW,MAAM,WACN,kBAAkB,GAChB,QAAQ,IAAI,CAAC,CA6BzB;mBArCY,OAAO,aAAa,EAAE,IAAI;iCAC1B,OAAO,OAAO,EAAE,kBAAkB;;;;;UAwCjC,MAAM;;;;WACN,MAAM;;;;;;OAKN,MAAM;;;;OACN,MAAM;;;;;;eAKN,MAAM;;;;cACN,MAAM;;;;mBACN,MAAM;;;;0BACN,MAAM;;;;cACN,MAAM;;;;WACN,MAAM;;;;WACN,MAAM;;;;UACN,MAAM;;;;;;UAKN,MAAM;;;;aACN,MAAM;;;;;;WAKN,MAAM;;;;gBACN,MAAM;;;;UACN,MAAM;;;;YACN,MAAM;;;;mBACN,MAAM;;;;aACN,MAAM;;;;eACN,MAAM;;;;cACN,MAAM;;;;oBACN,MAAM;;;;aACN,MAAM;;;;WACN,MAAM;;;;gBACN,MAAM;;;;;QAE2B,MAAM,EAAvC,SAAS;QACwB,KAAK,EAAtC,SAAS;QACwB,MAAM,EAAvC,SAAS;QACwB,MAAM,EAAvC,SAAS;;;;;cACT,MAAM;;;;WACN,MAAM;;;;UACN,MAAM;;;;aACN,MAAM;;;;cACN,MAAM;;;;aACN,MAAM,EAAE;;;;cACR,MAAM,EAAE;;;;aACR,MAAM,EAAE;;;;YACR,KAAK,EAAE;;;;;QAES,IAAI,EAApB,MAAM;;;;;iBACN,SAAS,EAAE"}
@@ -1,132 +0,0 @@
1
- import axios from "axios";
2
- import {
3
- defaultOptions,
4
- ISBNDB_API_BASE,
5
- ISBNDB_API_BOOK,
6
- } from "../provider-resolvers.js";
7
-
8
- /**
9
- * @typedef {import('../index.js').Book} Book
10
- * @typedef {import('axios').AxiosRequestConfig} AxiosRequestConfig
11
- */
12
-
13
- /**
14
- * Resolves the ISBN using the ISBNdb API.
15
- * @param {string} isbn - The ISBN to resolve.
16
- * @param {AxiosRequestConfig} options - Additional options for the request.
17
- * @returns {Promise<Book>} - A promise that resolves to the standardized book data.
18
- * @throws {Error} - If the response code is not 200 or if no books are found with the given ISBN.
19
- */
20
- export async function resolveIsbnDb(isbn, options) {
21
- if (!process.env.ISBNDB_API_KEY) {
22
- throw new Error(`ISBNdb requires an API key`);
23
- }
24
-
25
- const requestOptions = {
26
- ...defaultOptions,
27
- ...options,
28
- headers: { Authorization: process.env.ISBNDB_API_KEY },
29
- };
30
-
31
- const url = `${ISBNDB_API_BASE}${ISBNDB_API_BOOK}/${isbn}`;
32
-
33
- try {
34
- const response = await axios.get(url, requestOptions);
35
- if (response.status !== 200) {
36
- throw new Error(`Wrong response code: ${response.status}`);
37
- }
38
- const books = response.data;
39
- if (!books.book) {
40
- throw new Error(`No books found with ISBN: ${isbn}`);
41
- }
42
- return standardize(books.book, isbn);
43
- } catch (error) {
44
- throw new Error(error.message);
45
- }
46
- }
47
-
48
- /**
49
- * @typedef {object} Dimension
50
- * @property {string} unit - The unit of the dimension.
51
- * @property {number} value - The value of the dimension.
52
- */
53
-
54
- /**
55
- * @typedef {object} Offset
56
- * @property {string} x - The x offset.
57
- * @property {string} y - The y offset.
58
- */
59
-
60
- /**
61
- * @typedef {object} Price
62
- * @property {string} condition - The condition of the book.
63
- * @property {string} merchant - The merchant selling the book.
64
- * @property {string} merchant_logo - The logo of the merchant.
65
- * @property {Offset} merchant_logo_offset - The offset of the merchant logo.
66
- * @property {string} shipping - The shipping cost.
67
- * @property {string} price - The price of the book.
68
- * @property {string} total - The total cost.
69
- * @property {string} link - The link to buy the book.
70
- */
71
-
72
- /**
73
- * @typedef {object} OtherIsbn
74
- * @property {string} isbn - The ISBN of the book.
75
- * @property {string} binding - The binding of the book.
76
- */
77
-
78
- /**
79
- * @typedef {object} IsbnDbBook
80
- * @property {string} title - The title of the book.
81
- * @property {string} title_long - The long title of the book.
82
- * @property {string} isbn - The ISBN of the book.
83
- * @property {string} isbn13 - The ISBN13 of the book.
84
- * @property {string} dewey_decimal - The Dewey Decimal classification of the book.
85
- * @property {string} binding - The binding of the book.
86
- * @property {string} publisher - The publisher of the book.
87
- * @property {string} language - The language of the book.
88
- * @property {string} date_published - The published date of the book.
89
- * @property {string} edition - The edition of the book.
90
- * @property {number} pages - The number of pages in the book.
91
- * @property {string} dimensions - The dimensions of the book.
92
- * @property {object} dimensions_structured - The structured dimensions of the book.
93
- * @property {Dimension} dimensions_structured.length - The length of the book.
94
- * @property {Dimension} dimensions_structured.width - The width of the book.
95
- * @property {Dimension} dimensions_structured.height - The height of the book.
96
- * @property {Dimension} dimensions_structured.weight - The weight of the book.
97
- * @property {string} overview - The overview of the book.
98
- * @property {string} image - The image link of the book.
99
- * @property {number} msrp - The manufacturer's suggested retail price of the book.
100
- * @property {string} excerpt - The excerpt of the book.
101
- * @property {string} synopsis - The synopsis of the book.
102
- * @property {string[]} authors - The authors of the book.
103
- * @property {string[]} subjects - The subjects or categories of the book.
104
- * @property {string[]} reviews - The reviews of the book.
105
- * @property {Price[]} prices - The prices of the book.
106
- * @property {object} related - The related books.
107
- * @property {string} related.type - The type of the related books.
108
- * @property {OtherIsbn[]} other_isbns - The other ISBNs of the book.
109
- */
110
-
111
- /**
112
- * Standardizes a book object by transforming its properties into a consistent format.
113
- * @param {IsbnDbBook} book - The book object to be standardized.
114
- * @param {string} isbn - The book's ISBN.
115
- * @returns {Book} - The standardized book object.
116
- */
117
- function standardize(book, isbn) {
118
- return {
119
- title: book.title_long,
120
- authors: book.authors,
121
- description: book.overview,
122
- pageCount: book.pages,
123
- format: "book",
124
- categories: book.subjects,
125
- thumbnail: book.image,
126
- publisher: book.publisher,
127
- publishedDate: book.date_published,
128
- language: book.language,
129
- isbn,
130
- bookProvider: "ISBNdb",
131
- };
132
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"librofm.d.ts","sourceRoot":"","sources":["librofm.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;;GAKG;AACH,qCAJW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAezB;AAED;;;;;;GAMG;AACH,kCALW,MAAM,QACN,MAAM,OACN,MAAM,GACJ,QAAQ,IAAI,CAAC,CAgCzB;AAED;;;GAGG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,+CAHW,MAAM,GACJ,MAAM,CAkBlB;mBA5GY,OAAO,aAAa,EAAE,IAAI;iCAC1B,OAAO,OAAO,EAAE,kBAAkB;;;;;UAgEjC,MAAM;;;;;;SAIN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