discogs-marketplace-api-nodejs 1.3.8 → 1.4.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 +2 -2
- package/dist/{enum/ECurrency.d.ts → enums/currency.enum.d.ts} +0 -0
- package/dist/{enum/ECurrency.js → enums/currency.enum.js} +0 -0
- package/dist/{enum/EFormatDescription.d.ts → enums/format-description.enum.d.ts} +0 -0
- package/dist/{enum/EFormatDescription.js → enums/format-description.enum.js} +0 -0
- package/dist/{enum/EFormat.d.ts → enums/format.enum.d.ts} +0 -0
- package/dist/{enum/EFormat.js → enums/format.enum.js} +0 -0
- package/dist/{enum/EFrom.d.ts → enums/from.enum.d.ts} +0 -0
- package/dist/{enum/EFrom.js → enums/from.enum.js} +0 -1
- package/dist/{enum/EGenre.d.ts → enums/genre.enum.d.ts} +0 -0
- package/dist/{enum/EGenre.js → enums/genre.enum.js} +0 -0
- package/dist/enums/index.d.ts +11 -0
- package/dist/enums/index.js +26 -0
- package/dist/{enum/iso/ECountryCode.d.ts → enums/iso/country-code.enum.d.ts} +0 -0
- package/dist/{enum/iso/ECountryCode.js → enums/iso/country-code.enum.js} +0 -0
- package/dist/{enum/iso/ECountryName.d.ts → enums/iso/country-name.enum.d.ts} +0 -0
- package/dist/{enum/iso/ECountryName.js → enums/iso/country-name.enum.js} +0 -0
- package/dist/enums/iso/index.d.ts +3 -0
- package/dist/enums/iso/index.js +10 -0
- package/dist/{enum/iso/EDiscogsCountryNameToIsoCode.d.ts → enums/iso/translate/discogs-country-name-to-iso-code.enum.d.ts} +0 -0
- package/dist/{enum/iso/EDiscogsCountryNameToIsoCode.js → enums/iso/translate/discogs-country-name-to-iso-code.enum.js} +0 -0
- package/dist/{enum/iso/translate/EDiscogsCurrencyToIsoCode.d.ts → enums/iso/translate/discogs-currency-to-iso-code.enum.d.ts} +0 -0
- package/dist/{enum/iso/translate/EDiscogsCurrencyToIsoCode.js → enums/iso/translate/discogs-currency-to-iso-code.enum.js} +0 -0
- package/dist/enums/iso/translate/index.d.ts +3 -0
- package/dist/enums/iso/translate/index.js +10 -0
- package/dist/{enum/ELang.d.ts → enums/lang.enum.d.ts} +0 -0
- package/dist/{enum/ELang.js → enums/lang.enum.js} +0 -0
- package/dist/{enum/EMediaCondition.d.ts → enums/media-condition.enum.d.ts} +0 -0
- package/dist/{enum/EMediaCondition.js → enums/media-condition.enum.js} +0 -0
- package/dist/{enum/ESort.d.ts → enums/stort.enum.d.ts} +0 -0
- package/dist/{enum/ESort.js → enums/stort.enum.js} +0 -0
- package/dist/{enum/EStyle.d.ts → enums/style.enum.d.ts} +0 -0
- package/dist/{enum/EStyle.js → enums/style.enum.js} +0 -0
- package/dist/{enum/EType.d.ts → enums/type.enum.d.ts} +0 -0
- package/dist/{enum/EType.js → enums/type.enum.js} +0 -0
- package/dist/index.d.ts +6 -20
- package/dist/index.js +13 -34
- package/dist/interfaces/index.d.ts +6 -0
- package/dist/{interface/IOutputError.js → interfaces/index.js} +0 -0
- package/dist/{interface/IInput.d.ts → interfaces/input.interface.d.ts} +4 -13
- package/dist/{interface/IYears.js → interfaces/input.interface.js} +0 -0
- package/dist/{interface/IItem.d.ts → interfaces/item.interface.d.ts} +40 -3
- package/dist/{type/TLimit.js → interfaces/item.interface.js} +0 -0
- package/dist/{interface/IOutputError.d.ts → interfaces/output-error.interface.d.ts} +2 -0
- package/dist/interfaces/output-error.interface.js +2 -0
- package/dist/{interface/IOutputSuccess.d.ts → interfaces/output-sucess.interface.d.ts} +13 -2
- package/dist/interfaces/output-sucess.interface.js +2 -0
- package/dist/{interface/IYears.d.ts → interfaces/year.interface.d.ts} +2 -0
- package/dist/interfaces/year.interface.js +2 -0
- package/dist/marketplace.d.ts +9 -30
- package/dist/marketplace.js +70 -97
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/limit.type.d.ts +5 -0
- package/dist/types/limit.type.js +2 -0
- package/package.json +22 -21
- package/dist/enum/EFromIso.d.ts +0 -316
- package/dist/enum/EFromIso.js +0 -321
- package/dist/enum/iso/EDiscogsCurrencyToIsoCode.d.ts +0 -23
- package/dist/enum/iso/EDiscogsCurrencyToIsoCode.js +0 -26
- package/dist/enum/iso/translate/EDiscogsCountryNameToIsoCode.d.ts +0 -69
- package/dist/enum/iso/translate/EDiscogsCountryNameToIsoCode.js +0 -72
- package/dist/enum/iso/translates/EDiscogsCountryNameToIsoCode.d.ts +0 -69
- package/dist/enum/iso/translates/EDiscogsCountryNameToIsoCode.js +0 -72
- package/dist/enum/iso/translates/EDiscogsCurrencyToIsoCode.d.ts +0 -23
- package/dist/enum/iso/translates/EDiscogsCurrencyToIsoCode.js +0 -26
- package/dist/interface/IDiscogsMarketplace.d.ts +0 -11
- package/dist/interface/IDiscogsMarketplace.js +0 -7
- package/dist/interface/IInput.js +0 -17
- package/dist/interface/IItem.js +0 -7
- package/dist/interface/IOutputSuccess.js +0 -7
- package/dist/type/TLimit.d.ts +0 -5
package/dist/marketplace.js
CHANGED
|
@@ -12,72 +12,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const ECountryCode_1 = __importDefault(require("./enum/iso/ECountryCode"));
|
|
16
|
-
const ECountryName_1 = __importDefault(require("./enum/iso/ECountryName"));
|
|
17
|
-
const ECurrency_1 = __importDefault(require("./enum/ECurrency"));
|
|
18
|
-
const EFormat_1 = __importDefault(require("./enum/EFormat"));
|
|
19
|
-
const EFormatDescription_1 = __importDefault(require("./enum/EFormatDescription"));
|
|
20
|
-
const EFrom_1 = __importDefault(require("./enum/EFrom"));
|
|
21
|
-
const EGenre_1 = __importDefault(require("./enum/EGenre"));
|
|
22
|
-
const ELang_1 = __importDefault(require("./enum/ELang"));
|
|
23
|
-
const EMediaCondition_1 = __importDefault(require("./enum/EMediaCondition"));
|
|
24
|
-
const ESort_1 = __importDefault(require("./enum/ESort"));
|
|
25
|
-
const EStyle_1 = __importDefault(require("./enum/EStyle"));
|
|
26
|
-
const EType_1 = __importDefault(require("./enum/EType"));
|
|
27
|
-
const IInput_1 = __importDefault(require("./interface/IInput"));
|
|
28
|
-
const IOutputError_1 = __importDefault(require("./interface/IOutputError"));
|
|
29
|
-
const IOutputSuccess_1 = __importDefault(require("./interface/IOutputSuccess"));
|
|
30
|
-
const IYears_1 = __importDefault(require("./interface/IYears"));
|
|
31
|
-
const TLimit_1 = __importDefault(require("./type/TLimit"));
|
|
32
15
|
const playwright_chromium_1 = require("playwright-chromium");
|
|
33
16
|
const user_agents_1 = __importDefault(require("user-agents"));
|
|
34
|
-
const EDiscogsCurrencyToIsoCode_1 = __importDefault(require("./enum/iso/translate/EDiscogsCurrencyToIsoCode"));
|
|
35
|
-
const EDiscogsCountryNameToIsoCode_1 = __importDefault(require("./enum/iso/translate/EDiscogsCountryNameToIsoCode"));
|
|
36
17
|
const linkedom_1 = require("linkedom");
|
|
18
|
+
const enums_1 = require("./enums/index.js");
|
|
19
|
+
const translate_1 = require("./enums/iso/translate/index.js");
|
|
20
|
+
const iso_1 = require("./enums/iso/index.js");
|
|
37
21
|
/**
|
|
38
22
|
* Discogs Marketplace
|
|
39
23
|
*/
|
|
40
24
|
class Marketplace {
|
|
41
|
-
constructor({ searchType = EType_1.default.STRING, searchValue = undefined, currency = undefined, genre = undefined, style = [], format = [], formatDescription = [], mediaCondition = [], year = undefined, years = undefined, isAudioSample = false, isMakeAnOfferOnly = false, from = undefined, seller = undefined, sort = ESort_1.default.LISTED_NEWEST, limit = 25, page = 1, lang = ELang_1.default.ENGLISH, }) {
|
|
42
|
-
/** Url generated by Playwright */
|
|
43
|
-
this.url = '';
|
|
44
|
-
this.searchType = searchType;
|
|
45
|
-
this.searchValue = searchValue;
|
|
46
|
-
this.currency = currency;
|
|
47
|
-
this.genre = genre;
|
|
48
|
-
this.style = style;
|
|
49
|
-
this.format = format;
|
|
50
|
-
this.formatDescription = formatDescription;
|
|
51
|
-
this.mediaCondition = mediaCondition;
|
|
52
|
-
this.year = year;
|
|
53
|
-
this.years = years;
|
|
54
|
-
this.isAudioSample = isAudioSample;
|
|
55
|
-
this.isMakeAnOfferOnly = isMakeAnOfferOnly;
|
|
56
|
-
this.from = from;
|
|
57
|
-
this.seller = seller;
|
|
58
|
-
this.sort = sort;
|
|
59
|
-
this.limit = limit;
|
|
60
|
-
this.page = page;
|
|
61
|
-
this.lang = lang;
|
|
62
|
-
}
|
|
63
25
|
/**
|
|
64
26
|
* Search elements on discogs
|
|
65
27
|
* @returns Items found
|
|
66
28
|
*/
|
|
67
|
-
search() {
|
|
68
|
-
var _a, _b, _c, _d, _e, _f
|
|
29
|
+
static search({ searchType = enums_1.EType.STRING, searchValue = undefined, currency = undefined, genre = undefined, style = [], format = [], formatDescription = [], mediaCondition = [], year = undefined, years = undefined, isAudioSample = false, isMakeAnOfferOnly = false, from = undefined, seller = undefined, sort = enums_1.ESort.LISTED_NEWEST, limit = 25, page = 1, lang = enums_1.ELang.ENGLISH, }) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
69
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
32
|
try {
|
|
71
33
|
/** Init browser */
|
|
72
34
|
const browser = yield playwright_chromium_1.chromium.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
|
|
73
35
|
/** Init context */
|
|
74
|
-
const
|
|
36
|
+
const browserContext = yield browser.newContext({
|
|
75
37
|
userAgent: new user_agents_1.default().toString(),
|
|
76
38
|
});
|
|
77
39
|
/** Init page */
|
|
78
|
-
const
|
|
40
|
+
const browserPage = yield browserContext.newPage();
|
|
79
41
|
/** Block useless ressources */
|
|
80
|
-
yield
|
|
42
|
+
yield browserPage.route('**/*', route => ([
|
|
81
43
|
'stylesheet',
|
|
82
44
|
'image',
|
|
83
45
|
'media',
|
|
@@ -92,41 +54,48 @@ class Marketplace {
|
|
|
92
54
|
'other',
|
|
93
55
|
].includes(route.request().resourceType()) ? route.abort() : route.continue()));
|
|
94
56
|
/** Init page */
|
|
95
|
-
const response = yield
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
57
|
+
const response = yield browserPage.goto(`${this.generateUrl({
|
|
58
|
+
searchType,
|
|
59
|
+
seller,
|
|
60
|
+
lang,
|
|
61
|
+
})}?${this.serializeParams({
|
|
62
|
+
[searchType]: searchValue,
|
|
63
|
+
currency,
|
|
64
|
+
genre,
|
|
65
|
+
style: (style === null || style === void 0 ? void 0 : style.length) ? style : undefined,
|
|
66
|
+
format: (format === null || format === void 0 ? void 0 : format.length) ? format === null || format === void 0 ? void 0 : format[0] : undefined,
|
|
67
|
+
format_desc: (formatDescription === null || formatDescription === void 0 ? void 0 : formatDescription.length) ? formatDescription[0] : undefined,
|
|
68
|
+
condition: (mediaCondition === null || mediaCondition === void 0 ? void 0 : mediaCondition.length) ? mediaCondition[0] : undefined,
|
|
69
|
+
year: year && !years ? year : undefined,
|
|
70
|
+
year1: (years === null || years === void 0 ? void 0 : years.min) && !year ? years === null || years === void 0 ? void 0 : years.min : undefined,
|
|
71
|
+
year2: (years === null || years === void 0 ? void 0 : years.max) && !year ? years === null || years === void 0 ? void 0 : years.max : undefined,
|
|
72
|
+
audio: isAudioSample ? 1 : 0,
|
|
73
|
+
offers: isMakeAnOfferOnly ? 1 : 0,
|
|
74
|
+
ships_from: (from === null || from === void 0 ? void 0 : from.length) ? from : undefined,
|
|
75
|
+
limit,
|
|
76
|
+
page,
|
|
77
|
+
sort,
|
|
78
|
+
})}`, { waitUntil: 'domcontentloaded' });
|
|
113
79
|
/** Get url */
|
|
114
|
-
|
|
80
|
+
const urlGenerated = browserPage.url();
|
|
115
81
|
/** Get HTML */
|
|
116
|
-
const bodyHTML = yield
|
|
82
|
+
const bodyHTML = yield browserPage.evaluate(() => { var _a; return (_a = document.getElementById('page_content')) === null || _a === void 0 ? void 0 : _a.outerHTML; });
|
|
117
83
|
/** Close browser */
|
|
118
84
|
yield browser.close();
|
|
119
85
|
/** If error, reject */
|
|
120
|
-
if (((
|
|
86
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.status()) !== null && _a !== void 0 ? _a : 0) >= 400)
|
|
121
87
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
122
|
-
throw { document: bodyHTML, status: (
|
|
123
|
-
return this.getItem((0, linkedom_1.parseHTML)(bodyHTML).document
|
|
88
|
+
throw { document: bodyHTML, status: (_b = response === null || response === void 0 ? void 0 : response.status()) !== null && _b !== void 0 ? _b : 0 };
|
|
89
|
+
return this.getItem((0, linkedom_1.parseHTML)(bodyHTML).document, urlGenerated, {
|
|
90
|
+
searchType, searchValue, limit, page,
|
|
91
|
+
});
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
93
|
}
|
|
125
94
|
catch (error) {
|
|
126
95
|
if ((error === null || error === void 0 ? void 0 : error.document) && error.status)
|
|
127
96
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
128
97
|
throw {
|
|
129
|
-
message: (
|
|
98
|
+
message: (_f = (_e = (_d = (_c = (0, linkedom_1.parseHTML)(error.document).document) === null || _c === void 0 ? void 0 : _c.querySelector('h1 + p')) === null || _d === void 0 ? void 0 : _d.innerHTML) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : 'An error occured',
|
|
130
99
|
code: error.status,
|
|
131
100
|
};
|
|
132
101
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
@@ -141,15 +110,15 @@ class Marketplace {
|
|
|
141
110
|
* Generate URL to be parsed
|
|
142
111
|
* @returns Url
|
|
143
112
|
*/
|
|
144
|
-
generateUrl() {
|
|
145
|
-
let url = `https://www.discogs.com/${
|
|
146
|
-
if (
|
|
147
|
-
url += `seller/${
|
|
148
|
-
url +=
|
|
113
|
+
static generateUrl({ searchType, seller, lang, }) {
|
|
114
|
+
let url = `https://www.discogs.com/${lang}/`;
|
|
115
|
+
if (seller) {
|
|
116
|
+
url += `seller/${seller}/`;
|
|
117
|
+
url += searchType === enums_1.EType.USER ? 'mywants' : 'profile';
|
|
149
118
|
}
|
|
150
119
|
else {
|
|
151
120
|
url += 'sell/';
|
|
152
|
-
url +=
|
|
121
|
+
url += searchType === enums_1.EType.USER ? 'mywants' : 'list';
|
|
153
122
|
}
|
|
154
123
|
return url;
|
|
155
124
|
}
|
|
@@ -158,8 +127,8 @@ class Marketplace {
|
|
|
158
127
|
* @param params Object of GET parameters
|
|
159
128
|
* @returns Url
|
|
160
129
|
*/
|
|
161
|
-
// eslint-disable-next-line
|
|
162
|
-
serializeParams(params) {
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
static serializeParams(params) {
|
|
163
132
|
const param = [];
|
|
164
133
|
// eslint-disable-next-line no-restricted-syntax
|
|
165
134
|
for (const key in params)
|
|
@@ -181,20 +150,20 @@ class Marketplace {
|
|
|
181
150
|
}
|
|
182
151
|
/**
|
|
183
152
|
* Function to convert currency to ISO name
|
|
184
|
-
* @param
|
|
153
|
+
* @param value String to clean
|
|
185
154
|
* @returns Cleanup string
|
|
186
155
|
*/
|
|
187
|
-
|
|
188
|
-
convertCurrency(value) {
|
|
156
|
+
static convertCurrency(value) {
|
|
189
157
|
var _a;
|
|
190
158
|
if (!value)
|
|
191
159
|
return value;
|
|
192
|
-
const currency = (_a = Object.keys(
|
|
160
|
+
const currency = (_a = Object.keys(translate_1.EDiscogsCurrencyToIsoCode).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
|
|
193
161
|
if (!currency)
|
|
194
162
|
return value;
|
|
195
|
-
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
164
|
+
const currencyClean = translate_1.EDiscogsCurrencyToIsoCode[currency];
|
|
196
165
|
const amount = value
|
|
197
|
-
.replace(currencyClean !==
|
|
166
|
+
.replace(currencyClean !== enums_1.ECurrency.JPY ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
|
|
198
167
|
.replace(currency, '') // Remove original currency
|
|
199
168
|
.replace(/\s/g, ''); // Remove spaces
|
|
200
169
|
return `${amount} ${currencyClean}`
|
|
@@ -203,20 +172,24 @@ class Marketplace {
|
|
|
203
172
|
/**
|
|
204
173
|
* Parse HTML to clean result
|
|
205
174
|
* @param document Document to parse
|
|
175
|
+
* @param urlGenerated Url generated
|
|
206
176
|
* @returns Items found
|
|
207
177
|
*/
|
|
208
|
-
getItem(document) {
|
|
209
|
-
var _a, _b, _c, _d, _e
|
|
210
|
-
const totalItems = parseFloat(
|
|
178
|
+
static getItem(document, urlGenerated, { searchType = enums_1.EType.STRING, searchValue = undefined, limit = 25, page = 1, }) {
|
|
179
|
+
var _a, _b, _c, _d, _e;
|
|
180
|
+
const totalItems = parseFloat(
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
+
((_d = (_c = (_b = (_a = document.querySelector('.pagination_total')) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.split(' ')) === null || _c === void 0 ? void 0 : _c.filter((x) => x).pop()) === null || _d === void 0 ? void 0 : _d.replace(/(,|\.|\s)/g, '')) || '0');
|
|
211
183
|
return {
|
|
212
184
|
items: ((_e = [...document.querySelectorAll('table.table_block tbody tr')]) === null || _e === void 0 ? void 0 : _e.map(el => {
|
|
213
185
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59;
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
187
|
const shipping = this.convertCurrency((_g = (_f = (_e = (_d = (_c = (_b = (_a = el.querySelector('.item_shipping')) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.replace(/(\s+|\+)/g, ' ')) === null || _e === void 0 ? void 0 : _e.trim()) === null || _f === void 0 ? void 0 : _f.replace(',', '.')) !== null && _g !== void 0 ? _g : '');
|
|
215
188
|
const have = Number.parseInt((_j = (_h = el.querySelector('.community_summary .community_result:nth-child(1) .community_number')) === null || _h === void 0 ? void 0 : _h.textContent) !== null && _j !== void 0 ? _j : '', 10);
|
|
216
189
|
const want = Number.parseInt((_l = (_k = el.querySelector('.community_summary .community_result:nth-child(2) .community_number')) === null || _k === void 0 ? void 0 : _k.textContent) !== null && _l !== void 0 ? _l : '', 10);
|
|
217
190
|
const countryName = (_q = (_p = (_o = (_m = el.querySelector('.seller_info li:nth-child(3)')) === null || _m === void 0 ? void 0 : _m.textContent) === null || _o === void 0 ? void 0 : _o.split(':')) === null || _p === void 0 ? void 0 : _p[1]) !== null && _q !== void 0 ? _q : '';
|
|
218
|
-
const isoCountryCode = (Object.keys(
|
|
219
|
-
||
|
|
191
|
+
const isoCountryCode = (Object.keys(iso_1.ECountryCode).find((key) => (iso_1.ECountryName[key] === countryName))
|
|
192
|
+
|| translate_1.EDiscogsCountryNameToIsoCode[countryName]);
|
|
220
193
|
const releaseId = Number.parseInt((_v = (_u = (_t = (_s = (_r = el.querySelector('a.item_release_link')) === null || _r === void 0 ? void 0 : _r.href.split('release/')) === null || _s === void 0 ? void 0 : _s.pop()) === null || _t === void 0 ? void 0 : _t.split('-')) === null || _u === void 0 ? void 0 : _u.shift()) !== null && _v !== void 0 ? _v : '0', 10);
|
|
221
194
|
const itemId = Number.parseInt((_y = (_x = (_w = el.querySelector('a.item_description_title')) === null || _w === void 0 ? void 0 : _w.href) === null || _x === void 0 ? void 0 : _x.split('/').pop()) !== null && _y !== void 0 ? _y : '0', 10);
|
|
222
195
|
const notes = Number.parseInt((_5 = (_4 = (_3 = (_2 = (_1 = (_0 = (_z = el.querySelector('.seller_info li:nth-child(2) .section_link')) === null || _z === void 0 ? void 0 : _z.textContent) === null || _0 === void 0 ? void 0 : _0.replace(/\s+/g, ' ')) === null || _1 === void 0 ? void 0 : _1.trim()) === null || _2 === void 0 ? void 0 : _2.split(' ')) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.replace(/,/g, '')) !== null && _5 !== void 0 ? _5 : '', 10);
|
|
@@ -224,7 +197,7 @@ class Marketplace {
|
|
|
224
197
|
const firstIndexOfDash = (_7 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.indexOf(' - ')) !== null && _7 !== void 0 ? _7 : -1;
|
|
225
198
|
const lastIndexOfParenthesis = (_8 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.lastIndexOf(' (')) !== null && _8 !== void 0 ? _8 : -1;
|
|
226
199
|
return {
|
|
227
|
-
|
|
200
|
+
id: Number.isNaN(itemId) ? 0 : itemId,
|
|
228
201
|
title: {
|
|
229
202
|
original: originalTitle !== null && originalTitle !== void 0 ? originalTitle : '',
|
|
230
203
|
artist: (_9 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(0, firstIndexOfDash)) !== null && _9 !== void 0 ? _9 : '',
|
|
@@ -264,7 +237,7 @@ class Marketplace {
|
|
|
264
237
|
},
|
|
265
238
|
from: {
|
|
266
239
|
countryName,
|
|
267
|
-
isoCountryName: (_58 =
|
|
240
|
+
isoCountryName: (_58 = iso_1.ECountryName[isoCountryCode]) !== null && _58 !== void 0 ? _58 : '',
|
|
268
241
|
isoCountryCode,
|
|
269
242
|
},
|
|
270
243
|
community: {
|
|
@@ -278,18 +251,18 @@ class Marketplace {
|
|
|
278
251
|
};
|
|
279
252
|
})) || [],
|
|
280
253
|
page: {
|
|
281
|
-
current:
|
|
282
|
-
total: Math.ceil(totalItems /
|
|
254
|
+
current: page,
|
|
255
|
+
total: Math.ceil(totalItems / limit),
|
|
283
256
|
},
|
|
284
257
|
result: {
|
|
285
258
|
total: totalItems,
|
|
286
|
-
perPage:
|
|
259
|
+
perPage: limit,
|
|
287
260
|
},
|
|
288
261
|
search: {
|
|
289
|
-
value:
|
|
290
|
-
type:
|
|
262
|
+
value: searchValue !== null && searchValue !== void 0 ? searchValue : '',
|
|
263
|
+
type: searchType,
|
|
291
264
|
},
|
|
292
|
-
urlGenerated:
|
|
265
|
+
urlGenerated: urlGenerated !== null && urlGenerated !== void 0 ? urlGenerated : '',
|
|
293
266
|
};
|
|
294
267
|
}
|
|
295
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Another (better ?) NodeJs library to fetch data from Discog's marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
@@ -16,36 +16,37 @@
|
|
|
16
16
|
"author": "KirianCaumes",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"start": "nodemon -r tsconfig-paths/register ./src/index.ts",
|
|
20
|
-
"build": "ttsc --project tsconfig.build.json --skipLibCheck",
|
|
21
|
-
"test": "jest",
|
|
22
19
|
"prepare": "npm run build",
|
|
20
|
+
"prebuild": "rimraf dist",
|
|
21
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
22
|
+
"start:dev": "nodemon -r tsconfig-paths/register ./src/index.ts",
|
|
23
|
+
"test": "jest",
|
|
23
24
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
24
25
|
"lint": "eslint \"src/**/*.ts\""
|
|
25
26
|
},
|
|
26
27
|
"main": "dist/index.js",
|
|
27
28
|
"types": "dist/index.d.ts",
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"linkedom": "^0.14.
|
|
30
|
-
"playwright-chromium": "^1.
|
|
31
|
-
"
|
|
32
|
-
"tsconfig-paths": "^3.12.0",
|
|
33
|
-
"user-agents": "^1.0.940"
|
|
30
|
+
"linkedom": "^0.14.16",
|
|
31
|
+
"playwright-chromium": "^1.26.1",
|
|
32
|
+
"user-agents": "^1.0.1151"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@types/jest": "^
|
|
37
|
-
"@types/node": "^
|
|
35
|
+
"@types/jest": "^29.0.3",
|
|
36
|
+
"@types/node": "^18.7.23",
|
|
38
37
|
"@types/user-agents": "^1.0.2",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
40
|
-
"@typescript-eslint/parser": "^5.
|
|
41
|
-
"eslint": "^8.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
39
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
40
|
+
"eslint": "^8.24.0",
|
|
42
41
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
43
|
-
"eslint-config-airbnb-typescript": "^
|
|
44
|
-
"eslint-plugin-import": "^2.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
42
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
43
|
+
"eslint-plugin-import": "^2.26.0",
|
|
44
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
45
|
+
"jest": "^29.0.3",
|
|
46
|
+
"ts-jest": "^29.0.2",
|
|
47
|
+
"ts-node": "^10.9.1",
|
|
48
|
+
"tsc-alias": "^1.7.0",
|
|
49
|
+
"tsconfig-paths": "^4.1.0",
|
|
50
|
+
"typescript": "^4.8.4"
|
|
50
51
|
}
|
|
51
52
|
}
|