@library-pals/isbn 1.0.1 → 1.1.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 CHANGED
@@ -55,17 +55,98 @@ Response follows the same schema, but some fields could depend on the service
55
55
  that was used to find the book. In general, Google Books API returns more
56
56
  information.
57
57
 
58
+ #### Response: Google
59
+
60
+ <!-- google 9780374104092 -->
61
+
58
62
  ```json
59
63
  {
60
- "isbn": 9780374104092,
61
64
  "title": "Annihilation",
62
65
  "authors": ["Jeff VanderMeer"],
63
66
  "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.",
64
67
  "pageCount": 209,
65
68
  "printType": "BOOK",
66
- "categories": ["Fiction"],
67
- "thumbnail": "http://books.google.com/books/content?id=2cl7AgAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
68
- "link": "https://books.google.com/books/about/Annihilation.html?hl=&id=2cl7AgAAQBAJ"
69
+ "categories": [
70
+ "Fiction",
71
+ "Fiction / General",
72
+ "Fiction / Fantasy / General",
73
+ "Fiction / Horror",
74
+ "Fiction / Literary",
75
+ "Fiction / Science Fiction / General",
76
+ "Fiction / Science Fiction / Action & Adventure",
77
+ "Fiction / Thrillers / Suspense",
78
+ "Fiction / Dystopian"
79
+ ],
80
+ "thumbnail": "http://books.google.com/books/publisher/content?id=2cl7AgAAQBAJ&printsec=frontcover&img=1&zoom=6&edge=curl&source=gbs_api",
81
+ "link": "https://books.google.com/books/about/Annihilation.html?hl=&id=2cl7AgAAQBAJ",
82
+ "publisher": "Macmillan",
83
+ "publishedDate": "2014-02-04",
84
+ "language": "en",
85
+ "isbn": "9780374104092"
86
+ }
87
+ ```
88
+
89
+ #### Response: OpenLibrary
90
+
91
+ <!-- openlibrary 9780374104092 -->
92
+
93
+ ```json
94
+ {
95
+ "title": "Annihilation",
96
+ "authors": ["Jeff VanderMeer"],
97
+ "description": "Area X has been cut off from the rest of the continent for decades. Nature has reclaimed the last vestiges of human civilization. The twelfth expedition arrives expecting the unexpected, and Area X delivers. They discover a massive topographic anomaly and life-forms that surpass understanding. But it's the surprises that came across the border with them, and the secrets the expedition members are keeping from one another that change everything.",
98
+ "pageCount": 208,
99
+ "printType": "BOOK",
100
+ "categories": [
101
+ "Nebula Award Winner",
102
+ "award:nebula_award=novel",
103
+ "award:nebula_award=2015",
104
+ "Discoveries in geography",
105
+ "Fiction",
106
+ "Scientists",
107
+ "Science-Fiction",
108
+ "Suspense fiction",
109
+ "Paranormal fiction",
110
+ "Women scientists",
111
+ "Science fiction",
112
+ "Fantasy fiction",
113
+ "Mystery fiction",
114
+ "Adventure fiction",
115
+ "Exploration",
116
+ "Amerikanisches Englisch",
117
+ "Fiction, science fiction, action & adventure",
118
+ "Fiction, suspense",
119
+ "Action & Adventure",
120
+ "Dystopian",
121
+ "Fantasy",
122
+ "Extrasensory perception",
123
+ "Literary",
124
+ "Suspense",
125
+ "Thrillers",
126
+ "General",
127
+ "Pollution",
128
+ "horror",
129
+ "body horror",
130
+ "alien invasion",
131
+ "nyt:trade-fiction-paperback=2018-03-18",
132
+ "New York Times bestseller",
133
+ "Explorers",
134
+ "Secrecy",
135
+ "Scientific expeditions",
136
+ "Psychic ability",
137
+ "Fiction, thrillers, suspense",
138
+ "Discoveries in geography--fiction",
139
+ "Scientists--fiction",
140
+ "Women scientists--fiction",
141
+ "Ps3572.a4284 a84 2014",
142
+ "813/.54"
143
+ ],
144
+ "thumbnail": "https://covers.openlibrary.org/b/id/10520611-L.jpg",
145
+ "link": "https://openlibrary.org/books/OL31444108M",
146
+ "publisher": "Farrar, Straus and Giroux",
147
+ "publishedDate": "2014",
148
+ "language": "en",
149
+ "isbn": "9780374104092"
69
150
  }
70
151
  ```
71
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@library-pals/isbn",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Find books by ISBN",
5
5
  "exports": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * @typedef {object} Book
3
3
  * @property {string} isbn - The ISBN of the book.
4
- * @property {string} title - The long title of the book.
4
+ * @property {string} title - The title of the book.
5
5
  * @property {string[]} authors - The authors of the book.
6
6
  * @property {string} description - The overview of the book.
7
7
  * @property {number} pageCount - The number of pages in the book.
8
- * @property {string} printType - The print type of the book. Always "BOOK" for this context.
8
+ * @property {string} printType - The print type of the book.
9
9
  * @property {string[]} categories - The subjects or categories of the book.
10
+ * @property {string} publisher - The publisher of the book.
11
+ * @property {string} publishedDate - The date the book was published.
12
+ * @property {string | undefined} [language] - The language of the book.
10
13
  * @property {string | undefined} [thumbnail] - The thumbnail image link of the book.
11
14
  * @property {string} [link] - The link of the book.
12
15
  */
@@ -47,7 +50,7 @@ export type Book = {
47
50
  */
48
51
  isbn: string;
49
52
  /**
50
- * - The long title of the book.
53
+ * - The title of the book.
51
54
  */
52
55
  title: string;
53
56
  /**
@@ -63,13 +66,25 @@ export type Book = {
63
66
  */
64
67
  pageCount: number;
65
68
  /**
66
- * - The print type of the book. Always "BOOK" for this context.
69
+ * - The print type of the book.
67
70
  */
68
71
  printType: string;
69
72
  /**
70
73
  * - The subjects or categories of the book.
71
74
  */
72
75
  categories: string[];
76
+ /**
77
+ * - The publisher of the book.
78
+ */
79
+ publisher: string;
80
+ /**
81
+ * - The date the book was published.
82
+ */
83
+ publishedDate: string;
84
+ /**
85
+ * - The language of the book.
86
+ */
87
+ language?: string | undefined;
73
88
  /**
74
89
  * - The thumbnail image link of the book.
75
90
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;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;;;;;UA9Ea,MAAM;;;;WACN,MAAM;;;;aACN,MAAM,EAAE;;;;iBACR,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;gBACN,MAAM,EAAE;;;;gBACR,MAAM,GAAG,SAAS;;;;WAClB,MAAM;;wBAIP,OAAO,yBAAyB,EAAE,SAAS;iCAC3C,OAAO,OAAO,EAAE,kBAAkB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;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;;;;;UAjFa,MAAM;;;;WACN,MAAM;;;;aACN,MAAM,EAAE;;;;iBACR,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;gBACN,MAAM,EAAE;;;;eACR,MAAM;;;;mBACN,MAAM;;;;eACN,MAAM,GAAG,SAAS;;;;gBAClB,MAAM,GAAG,SAAS;;;;WAClB,MAAM;;wBAIP,OAAO,yBAAyB,EAAE,SAAS;iCAC3C,OAAO,OAAO,EAAE,kBAAkB"}
package/src/index.js CHANGED
@@ -7,12 +7,15 @@ import {
7
7
  /**
8
8
  * @typedef {object} Book
9
9
  * @property {string} isbn - The ISBN of the book.
10
- * @property {string} title - The long title of the book.
10
+ * @property {string} title - The title of the book.
11
11
  * @property {string[]} authors - The authors of the book.
12
12
  * @property {string} description - The overview of the book.
13
13
  * @property {number} pageCount - The number of pages in the book.
14
- * @property {string} printType - The print type of the book. Always "BOOK" for this context.
14
+ * @property {string} printType - The print type of the book.
15
15
  * @property {string[]} categories - The subjects or categories of the book.
16
+ * @property {string} publisher - The publisher of the book.
17
+ * @property {string} publishedDate - The date the book was published.
18
+ * @property {string | undefined} [language] - The language of the book.
16
19
  * @property {string | undefined} [thumbnail] - The thumbnail image link of the book.
17
20
  * @property {string} [link] - The link of the book.
18
21
  */
@@ -50,10 +50,21 @@ export function resolveGoogle(isbn: string, options: AxiosRequestConfig): Promis
50
50
  /**
51
51
  * Standardizes a book object by extracting relevant information from the provided book object.
52
52
  * @param {GoogleBook} book - The book object to be standardized.
53
+ * @param {string} id - The book id.
53
54
  * @param {string} isbn - The book's ISBN.
54
- * @returns {Book} The standardized book object.
55
+ * @returns {Promise<Book>} The standardized book object.
55
56
  */
56
- export function standardize(book: GoogleBook, isbn: string): Book;
57
+ export function standardize(book: GoogleBook, id: string, isbn: string): Promise<Book>;
58
+ /**
59
+ * Retrieves the volume information for a book.
60
+ * @param {string} id - The book id.
61
+ * @returns {Promise<{imageLinks?: ImageLinks, categories?: string[]}>} - A promise that resolves to an array of author names.
62
+ * @throws {Error} - If there is an error retrieving the author information.
63
+ */
64
+ export function getVolume(id: string): Promise<{
65
+ imageLinks?: ImageLinks;
66
+ categories?: string[];
67
+ }>;
57
68
  export type Book = import('../index.js').Book;
58
69
  export type AxiosRequestConfig = import('axios').AxiosRequestConfig;
59
70
  export type ImageLinks = {
@@ -1 +1 @@
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;;;;;GAKG;AACH,kCAJW,UAAU,QACV,MAAM,GACJ,IAAI,CAgBhB;mBAjGY,OAAO,aAAa,EAAE,IAAI;iCAC1B,OAAO,OAAO,EAAE,kBAAkB;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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"}
@@ -38,7 +38,7 @@ export async function resolveGoogle(isbn, options) {
38
38
  throw new Error(`No volume info found for book with isbn: ${isbn}`);
39
39
  }
40
40
  const book = books.items[0];
41
- return standardize(book.volumeInfo, isbn);
41
+ return await standardize(book.volumeInfo, book.id, isbn);
42
42
  } catch (error) {
43
43
  throw new Error(error.message);
44
44
  }
@@ -86,25 +86,54 @@ export async function resolveGoogle(isbn, options) {
86
86
  /**
87
87
  * Standardizes a book object by extracting relevant information from the provided book object.
88
88
  * @param {GoogleBook} book - The book object to be standardized.
89
+ * @param {string} id - The book id.
89
90
  * @param {string} isbn - The book's ISBN.
90
- * @returns {Book} The standardized book object.
91
+ * @returns {Promise<Book>} The standardized book object.
91
92
  */
92
- export function standardize(book, isbn) {
93
+ export async function standardize(book, id, isbn) {
94
+ const { imageLinks = book.imageLinks, categories = book.categories } =
95
+ await getVolume(id);
96
+
93
97
  const standardBook = {
94
98
  title: book.title,
95
99
  authors: book.authors,
96
100
  description: book.description,
97
101
  pageCount: book.pageCount,
98
102
  printType: book.printType,
99
- categories: book.categories,
100
- thumbnail: getLargestThumbnail(book.imageLinks),
103
+ categories: formatCategories(categories),
104
+ thumbnail: getLargestThumbnail(imageLinks),
101
105
  link: book.canonicalVolumeLink,
106
+ publisher: book.publisher,
107
+ publishedDate: book.publishedDate,
108
+ language: book.language,
102
109
  isbn,
103
110
  };
104
111
 
105
112
  return standardBook;
106
113
  }
107
114
 
115
+ /**
116
+ * Retrieves the volume information for a book.
117
+ * @param {string} id - The book id.
118
+ * @returns {Promise<{imageLinks?: ImageLinks, categories?: string[]}>} - A promise that resolves to an array of author names.
119
+ * @throws {Error} - If there is an error retrieving the author information.
120
+ */
121
+ export async function getVolume(id) {
122
+ try {
123
+ const url = `${GOOGLE_BOOKS_API_BASE}${GOOGLE_BOOKS_API_BOOK}/${id}`;
124
+ const response = await axios.get(url);
125
+
126
+ if (response.status !== 200) {
127
+ throw new Error(`Unable to get volume ${id}: ${response.status}`);
128
+ }
129
+ return {
130
+ ...response.data.volumeInfo,
131
+ };
132
+ } catch (error) {
133
+ throw new Error(error.message);
134
+ }
135
+ }
136
+
108
137
  /**
109
138
  * Get the largest available thumbnail from a book's image links.
110
139
  * @param {ImageLinks} [imageLinks] - The image links object.
@@ -122,10 +151,34 @@ function getLargestThumbnail(imageLinks) {
122
151
 
123
152
  if (!imageLinks) return;
124
153
 
125
- for (const size of sizes) {
126
- if (size in imageLinks) {
127
- // @ts-ignore
128
- return imageLinks[size];
129
- }
130
- }
154
+ const size = sizes.find((size) => size in imageLinks);
155
+
156
+ // @ts-ignore
157
+ return removeQueryParameter(imageLinks[size], "imgtk");
158
+ }
159
+
160
+ /**
161
+ * Removes a query parameter from a URL.
162
+ * @param {string} url - The URL.
163
+ * @param {string} parameter - The query parameter to remove.
164
+ * @returns {string | undefined} The URL with the query parameter removed.
165
+ */
166
+ function removeQueryParameter(url, parameter) {
167
+ const urlObject = new URL(url);
168
+ urlObject.searchParams.delete(parameter);
169
+ return urlObject.toString();
170
+ }
171
+
172
+ /**
173
+ * Formats the categories array.
174
+ * @param {string[]} categories - The array of categories.
175
+ * @returns {string[]} The formatted categories array.
176
+ */
177
+ function formatCategories(categories) {
178
+ if (!categories || categories.length === 0) return [];
179
+
180
+ const [firstCategory] = categories;
181
+ return firstCategory.includes("/")
182
+ ? [firstCategory.split("/")[0].trim(), ...categories]
183
+ : categories;
131
184
  }
@@ -123,6 +123,9 @@ function standardize(book, isbn) {
123
123
  printType: "BOOK",
124
124
  categories: book.subjects,
125
125
  thumbnail: book.image,
126
+ publisher: book.publisher,
127
+ publishedDate: book.date_published,
128
+ language: book.language,
126
129
  isbn,
127
130
  };
128
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"open-library.d.ts","sourceRoot":"","sources":["open-library.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH;;;;;;GAMG;AACH,yCALW,MAAM,WACN,kBAAkB,GAChB,QAAQ,IAAI,CAAC,CAuBzB;AAED;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,kCAJW,eAAe,QACf,MAAM,GACJ,QAAQ,IAAI,CAAC,CAoBzB;AAED;;;;GAIG;AACH,uCAHW;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,EAAE,GACb,QAAQ,MAAM,EAAE,CAAC,CAuB7B;AAED;;;;;GAKG;AAEH;;;;GAIG;AACH,+BAHW,eAAe,GACb,QAAQ;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;CAAC,CAAC,CAuC3F;mBAnMY,OAAO,aAAa,EAAE,IAAI;iCAC1B,OAAO,OAAO,EAAE,kBAAkB;;;;;SAkCjC,MAAM;;;;;;SAKN,MAAM;;;;;;SAKN,MAAM;;;;;;UAKN,MAAM;;;;WACN,MAAM;;;;;;SAKN,MAAM;;;;;;UAKN,MAAM;;;;WACN,MAAM;;;;;;iBAKN,MAAM;;;;WACN,MAAM;;;;aACN,MAAM,EAAE;;;;kBACR,MAAM;;;;gBACN,MAAM,EAAE;;;;YACR,MAAM,EAAE;;;;mBACR,MAAM,EAAE;;;;eACR,QAAQ,EAAE;;;;oBACV,MAAM,EAAE;;;;cACR,MAAM,EAAE;;;;UACR,IAAI;;;;oBACJ,aAA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WACN,MAAM;;;;aACN,MAAM,EAAE;;;;kBACR,MAAM;;;;gBACN,MAAM,EAAE;;;;YACR,MAAM,EAAE;;;;mBACR,MAAM,EAAE;;;;eACR,QAAQ,EAAE;;;;oBACV,MAAM,EAAE;;;;cACR,MAAM,EAAE;;;;UACR,IAAI;;;;oBACJ,aAAa;;;;SACb,MAAM;;;;qBACN,MAAM;;;;WACN,IAAI,EAAE;;;;qBACN,MAAM;;;;WACN,MAAM;;;;aACN,MAAM,EAAE;;;;aACR,MAAM,EAAE;;;;qBACR,MAAM;;;;cACN,MAAM;;;;aACN,QAAQ;;;;mBACR,QAAQ;;;;;;iBA8DR,MAAM;;;;cACN,MAAM,EAAE;;;;aACR;QAAC,MAAM,EAAE;YAAC,GAAG,EAAE,MAAM,CAAA;SAAC,CAAA;KAAC,EAAE"}
@@ -118,6 +118,9 @@ export async function standardize(book, isbn) {
118
118
  link: book.key
119
119
  ? `${OPENLIBRARY_API_BASE}${book.key}`
120
120
  : `${OPENLIBRARY_API_BASE}${OPENLIBRARY_API_BOOK}/${isbn}`,
121
+ publisher: book.publishers?.join(", "),
122
+ publishedDate: book.publish_date,
123
+ language: formatLanguage(book.languages),
121
124
  isbn,
122
125
  };
123
126
 
@@ -202,3 +205,38 @@ export async function getWorks(book) {
202
205
  throw new Error(error.message);
203
206
  }
204
207
  }
208
+
209
+ /**
210
+ * Formats the language codes from Open Library API to their corresponding ISO 639-1 codes.
211
+ * @param {Language[]} languages - An array of language codes from Open Library API.
212
+ * @returns {string | undefined} - A new language map object with ISO 639-1 codes as keys and language codes as values.
213
+ */
214
+ function formatLanguage(languages) {
215
+ if (!languages || languages.length === 0) {
216
+ return;
217
+ }
218
+ /**
219
+ * Mapping of Open Library language codes to their corresponding language names.
220
+ * https://openlibrary.org/languages.json
221
+ * @type {{ [key: string]: string } } - A new language map object with ISO 639-1 codes as keys and language codes as values.
222
+ */
223
+ const newLanguageMap = {
224
+ "/languages/eng": "en",
225
+ "/languages/spa": "es",
226
+ "/languages/fre": "fr",
227
+ "/languages/ger": "de",
228
+ "/languages/rus": "ru",
229
+ "/languages/ita": "it",
230
+ "/languages/chi": "zh",
231
+ "/languages/jpn": "ja",
232
+ "/languages/por": "pt",
233
+ "/languages/ara": "ar",
234
+ "/languages/heb": "he",
235
+ "/languages/kor": "ko",
236
+ "/languages/pol": "pl",
237
+ "/languages/dut": "nl",
238
+ "/languages/lat": "la",
239
+ };
240
+
241
+ return newLanguageMap[languages[0].key] || undefined;
242
+ }