@library-pals/isbn 0.2.0 → 1.0.1
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 +20 -41
- package/package.json +18 -22
- package/src/index.d.ts +84 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +36 -42
- package/src/provider-resolvers.d.ts +33 -0
- package/src/provider-resolvers.d.ts.map +1 -0
- package/src/provider-resolvers.js +16 -11
- package/src/providers/google.d.ts +187 -0
- package/src/providers/google.d.ts.map +1 -0
- package/src/providers/google.js +110 -15
- package/src/providers/isbndb.d.ts +184 -0
- package/src/providers/isbndb.d.ts.map +1 -0
- package/src/providers/isbndb.js +95 -27
- package/src/providers/open-library.d.ts +256 -0
- package/src/providers/open-library.d.ts.map +1 -0
- package/src/providers/open-library.js +173 -41
- package/.gitattributes +0 -2
- package/.github/workflows/npm-publish.yml +0 -30
- package/.github/workflows/test.yml +0 -16
- package/src/cli.js +0 -41
- package/src/providers/worldcat.js +0 -63
|
@@ -0,0 +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;;;;;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"}
|
package/src/providers/google.js
CHANGED
|
@@ -5,32 +5,127 @@ import {
|
|
|
5
5
|
GOOGLE_BOOKS_API_BOOK,
|
|
6
6
|
} from "../provider-resolvers.js";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import('../index.js').Book} Book
|
|
10
|
+
* @typedef {import('axios').AxiosRequestConfig} AxiosRequestConfig
|
|
11
|
+
*/
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* Resolves book information from Google Books API using the provided ISBN.
|
|
10
15
|
* @param {string} isbn - The ISBN of the book.
|
|
11
|
-
* @param {
|
|
12
|
-
* @returns {Promise<
|
|
16
|
+
* @param {AxiosRequestConfig} options - Additional options for the API request.
|
|
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
20
|
export async function resolveGoogle(isbn, options) {
|
|
16
21
|
const requestOptions = {
|
|
17
22
|
...defaultOptions,
|
|
18
23
|
...options,
|
|
19
|
-
url: `${GOOGLE_BOOKS_API_BASE}${GOOGLE_BOOKS_API_BOOK}?q=isbn:${isbn}`,
|
|
20
24
|
};
|
|
25
|
+
const url = `${GOOGLE_BOOKS_API_BASE}${GOOGLE_BOOKS_API_BOOK}?q=isbn:${isbn}`;
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
try {
|
|
28
|
+
const response = await axios.get(url, requestOptions);
|
|
29
|
+
if (response.status !== 200) {
|
|
30
|
+
throw new Error(`Wrong response code: ${response.status}`);
|
|
31
|
+
}
|
|
32
|
+
const books = response.data;
|
|
33
|
+
if (!books.totalItems) {
|
|
34
|
+
throw new Error(`No books found with isbn: ${isbn}`);
|
|
35
|
+
}
|
|
36
|
+
// In very rare circumstances books.items[0] is undefined (see #2)
|
|
37
|
+
if (!books.items || books.items.length === 0) {
|
|
38
|
+
throw new Error(`No volume info found for book with isbn: ${isbn}`);
|
|
39
|
+
}
|
|
40
|
+
const book = books.items[0];
|
|
41
|
+
return standardize(book.volumeInfo, isbn);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(error.message);
|
|
25
44
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {object} ImageLinks
|
|
49
|
+
* @property {string} [extraLarge] - extraLarge
|
|
50
|
+
* @property {string} [large] - large
|
|
51
|
+
* @property {string} [medium] - medium
|
|
52
|
+
* @property {string} [small] - small
|
|
53
|
+
* @property {string} [thumbnail] - thumbnail
|
|
54
|
+
* @property {string} [smallThumbnail] - smallThumbnail
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {object} GoogleBook
|
|
59
|
+
* @property {string} title - The title of the book.
|
|
60
|
+
* @property {string} subtitle - The subtitle of the book.
|
|
61
|
+
* @property {string[]} authors - The authors of the book.
|
|
62
|
+
* @property {string} publisher - The publisher of the book.
|
|
63
|
+
* @property {string} publishedDate - The published date of the book.
|
|
64
|
+
* @property {string} description - The description of the book.
|
|
65
|
+
* @property {object[]} industryIdentifiers - The industry identifiers of the book.
|
|
66
|
+
* @property {object} readingModes - The reading modes of the book.
|
|
67
|
+
* @property {number} pageCount - The number of pages in the book.
|
|
68
|
+
* @property {string} printType - The print type of the book.
|
|
69
|
+
* @property {string[]} categories - The categories of the book.
|
|
70
|
+
* @property {number} averageRating - The average rating of the book.
|
|
71
|
+
* @property {number} ratingsCount - The ratings count of the book.
|
|
72
|
+
* @property {string} maturityRating - The maturity rating of the book.
|
|
73
|
+
* @property {boolean} allowAnonLogging - The allow anon logging of the book.
|
|
74
|
+
* @property {string} contentVersion - The content version of the book.
|
|
75
|
+
* @property {object} panelizationSummary - The panelization summary of the book.
|
|
76
|
+
* @property {ImageLinks} [imageLinks] - The image links of the book.
|
|
77
|
+
* @property {string} language - The language of the book.
|
|
78
|
+
* @property {string} previewLink - The preview link of the book.
|
|
79
|
+
* @property {string} infoLink - The info link of the book.
|
|
80
|
+
* @property {string} canonicalVolumeLink - The canonical volume link of the book.
|
|
81
|
+
* @property {object} saleInfo - The sale info of the book.
|
|
82
|
+
* @property {object} accessInfo - The access info of the book.
|
|
83
|
+
* @property {object} searchInfo - The search info of the book.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Standardizes a book object by extracting relevant information from the provided book object.
|
|
88
|
+
* @param {GoogleBook} book - The book object to be standardized.
|
|
89
|
+
* @param {string} isbn - The book's ISBN.
|
|
90
|
+
* @returns {Book} The standardized book object.
|
|
91
|
+
*/
|
|
92
|
+
export function standardize(book, isbn) {
|
|
93
|
+
const standardBook = {
|
|
94
|
+
title: book.title,
|
|
95
|
+
authors: book.authors,
|
|
96
|
+
description: book.description,
|
|
97
|
+
pageCount: book.pageCount,
|
|
98
|
+
printType: book.printType,
|
|
99
|
+
categories: book.categories,
|
|
100
|
+
thumbnail: getLargestThumbnail(book.imageLinks),
|
|
101
|
+
link: book.canonicalVolumeLink,
|
|
102
|
+
isbn,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return standardBook;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get the largest available thumbnail from a book's image links.
|
|
110
|
+
* @param {ImageLinks} [imageLinks] - The image links object.
|
|
111
|
+
* @returns {string|undefined} The URL of the largest thumbnail, or undefined if not found.
|
|
112
|
+
*/
|
|
113
|
+
function getLargestThumbnail(imageLinks) {
|
|
114
|
+
const sizes = [
|
|
115
|
+
"extraLarge",
|
|
116
|
+
"large",
|
|
117
|
+
"medium",
|
|
118
|
+
"small",
|
|
119
|
+
"thumbnail",
|
|
120
|
+
"smallThumbnail",
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
if (!imageLinks) return;
|
|
124
|
+
|
|
125
|
+
for (const size of sizes) {
|
|
126
|
+
if (size in imageLinks) {
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
return imageLinks[size];
|
|
129
|
+
}
|
|
33
130
|
}
|
|
34
|
-
const book = books.items[0].volumeInfo;
|
|
35
|
-
return book;
|
|
36
131
|
}
|
|
@@ -0,0 +1,184 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/src/providers/isbndb.js
CHANGED
|
@@ -5,56 +5,124 @@ import {
|
|
|
5
5
|
ISBNDB_API_BOOK,
|
|
6
6
|
} from "../provider-resolvers.js";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import('../index.js').Book} Book
|
|
10
|
+
* @typedef {import('axios').AxiosRequestConfig} AxiosRequestConfig
|
|
11
|
+
*/
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* Resolves the ISBN using the ISBNdb API.
|
|
10
15
|
* @param {string} isbn - The ISBN to resolve.
|
|
11
|
-
* @param {
|
|
12
|
-
* @returns {Promise<
|
|
16
|
+
* @param {AxiosRequestConfig} options - Additional options for the request.
|
|
17
|
+
* @returns {Promise<Book>} - A promise that resolves to the standardized book data.
|
|
13
18
|
* @throws {Error} - If the response code is not 200 or if no books are found with the given ISBN.
|
|
14
19
|
*/
|
|
15
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
|
+
|
|
16
25
|
const requestOptions = {
|
|
17
26
|
...defaultOptions,
|
|
18
27
|
...options,
|
|
19
|
-
|
|
20
|
-
headers: { Authorization: process.env.ISBNDB_API_KEY || "" },
|
|
28
|
+
headers: { Authorization: process.env.ISBNDB_API_KEY },
|
|
21
29
|
};
|
|
22
30
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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);
|
|
32
45
|
}
|
|
33
|
-
return standardize(books.book);
|
|
34
46
|
}
|
|
35
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
|
+
|
|
36
111
|
/**
|
|
37
112
|
* Standardizes a book object by transforming its properties into a consistent format.
|
|
38
|
-
* @param {
|
|
39
|
-
* @
|
|
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.
|
|
40
116
|
*/
|
|
41
|
-
function standardize(book) {
|
|
117
|
+
function standardize(book, isbn) {
|
|
42
118
|
return {
|
|
43
119
|
title: book.title_long,
|
|
44
|
-
publishedDate: book.date_published,
|
|
45
120
|
authors: book.authors,
|
|
46
121
|
description: book.overview,
|
|
47
|
-
industryIdentifiers: [book.isbn, book.isbn13, book.dewey_decimal].filter(
|
|
48
|
-
Boolean
|
|
49
|
-
),
|
|
50
122
|
pageCount: book.pages,
|
|
51
123
|
printType: "BOOK",
|
|
52
124
|
categories: book.subjects,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
thumbnail: book.image,
|
|
56
|
-
},
|
|
57
|
-
publisher: book.publisher,
|
|
58
|
-
language: book.language,
|
|
125
|
+
thumbnail: book.image,
|
|
126
|
+
isbn,
|
|
59
127
|
};
|
|
60
128
|
}
|