discogs-marketplace-api-nodejs 1.3.9 → 1.5.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 +7 -15
- 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} +39 -2
- 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 +72 -126
- 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,126 +12,68 @@ 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
|
-
const playwright_chromium_1 = require("playwright-chromium");
|
|
33
15
|
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
16
|
const linkedom_1 = require("linkedom");
|
|
17
|
+
const enums_1 = require("./enums/index.js");
|
|
18
|
+
const translate_1 = require("./enums/iso/translate/index.js");
|
|
19
|
+
const iso_1 = require("./enums/iso/index.js");
|
|
20
|
+
const axios_1 = __importDefault(require("axios"));
|
|
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
|
|
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 = undefined, limit = 25, page = undefined, lang = enums_1.ELang.ENGLISH, }) {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
69
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
32
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
33
|
+
const config = {
|
|
34
|
+
url: this.generateUrl({ searchType, seller, lang }),
|
|
35
|
+
method: 'GET',
|
|
36
|
+
params: {
|
|
37
|
+
[searchType]: searchValue,
|
|
38
|
+
currency,
|
|
39
|
+
genre,
|
|
40
|
+
style: (style === null || style === void 0 ? void 0 : style.length) ? style : undefined,
|
|
41
|
+
format: (format === null || format === void 0 ? void 0 : format.length) ? format : undefined,
|
|
42
|
+
format_desc: (formatDescription === null || formatDescription === void 0 ? void 0 : formatDescription.length) ? formatDescription : undefined,
|
|
43
|
+
condition: (mediaCondition === null || mediaCondition === void 0 ? void 0 : mediaCondition.length) ? mediaCondition : undefined,
|
|
44
|
+
year: year && !years ? year : undefined,
|
|
45
|
+
year1: (years === null || years === void 0 ? void 0 : years.min) && !year ? years === null || years === void 0 ? void 0 : years.min : undefined,
|
|
46
|
+
year2: (years === null || years === void 0 ? void 0 : years.max) && !year ? years === null || years === void 0 ? void 0 : years.max : undefined,
|
|
47
|
+
audio: isAudioSample ? 1 : undefined,
|
|
48
|
+
offers: isMakeAnOfferOnly ? 1 : undefined,
|
|
49
|
+
ships_from: (from === null || from === void 0 ? void 0 : from.length) ? from : undefined,
|
|
50
|
+
limit,
|
|
51
|
+
page,
|
|
52
|
+
sort,
|
|
53
|
+
},
|
|
54
|
+
paramsSerializer: this.serializeParams,
|
|
55
|
+
headers: {
|
|
56
|
+
'X-PJAX': 'true',
|
|
57
|
+
'User-Agent': new user_agents_1.default().toString(),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const { data: bodyHTML } = yield axios_1.default.request(config);
|
|
61
|
+
return this.getData((0, linkedom_1.parseHTML)(bodyHTML).document, axios_1.default.getUri(config), {
|
|
62
|
+
searchType, searchValue, limit, page,
|
|
76
63
|
});
|
|
77
|
-
|
|
78
|
-
const page = yield context.newPage();
|
|
79
|
-
/** Block useless ressources */
|
|
80
|
-
yield page.route('**/*', route => ([
|
|
81
|
-
'stylesheet',
|
|
82
|
-
'image',
|
|
83
|
-
'media',
|
|
84
|
-
'font',
|
|
85
|
-
'script',
|
|
86
|
-
'texttrack',
|
|
87
|
-
'xhr',
|
|
88
|
-
'fetch',
|
|
89
|
-
'eventsource',
|
|
90
|
-
'websocket',
|
|
91
|
-
'manifest',
|
|
92
|
-
'other',
|
|
93
|
-
].includes(route.request().resourceType()) ? route.abort() : route.continue()));
|
|
94
|
-
/** Init page */
|
|
95
|
-
const response = yield page.goto(`${this.generateUrl()}?${this.serializeParams({
|
|
96
|
-
[this.searchType]: this.searchValue,
|
|
97
|
-
currency: this.currency,
|
|
98
|
-
genre: this.genre,
|
|
99
|
-
style: ((_a = this.style) === null || _a === void 0 ? void 0 : _a.length) ? this.style : undefined,
|
|
100
|
-
format: ((_b = this.format) === null || _b === void 0 ? void 0 : _b.length) ? (_c = this.format) === null || _c === void 0 ? void 0 : _c[0] : undefined,
|
|
101
|
-
format_desc: ((_d = this.formatDescription) === null || _d === void 0 ? void 0 : _d.length) ? this.formatDescription[0] : undefined,
|
|
102
|
-
condition: ((_e = this.mediaCondition) === null || _e === void 0 ? void 0 : _e.length) ? this.mediaCondition[0] : undefined,
|
|
103
|
-
year: this.year && !this.years ? this.year : undefined,
|
|
104
|
-
year1: ((_f = this.years) === null || _f === void 0 ? void 0 : _f.min) && !this.year ? (_g = this.years) === null || _g === void 0 ? void 0 : _g.min : undefined,
|
|
105
|
-
year2: ((_h = this.years) === null || _h === void 0 ? void 0 : _h.max) && !this.year ? (_j = this.years) === null || _j === void 0 ? void 0 : _j.max : undefined,
|
|
106
|
-
audio: this.isAudioSample ? 1 : 0,
|
|
107
|
-
offers: this.isMakeAnOfferOnly ? 1 : 0,
|
|
108
|
-
ships_from: ((_k = this.from) === null || _k === void 0 ? void 0 : _k.length) ? this.from : undefined,
|
|
109
|
-
limit: this.limit,
|
|
110
|
-
page: this.page,
|
|
111
|
-
sort: this.sort,
|
|
112
|
-
})}`);
|
|
113
|
-
/** Get url */
|
|
114
|
-
this.url = page.url();
|
|
115
|
-
/** Get HTML */
|
|
116
|
-
const bodyHTML = yield page.evaluate(() => { var _a; return (_a = document.getElementById('page_content')) === null || _a === void 0 ? void 0 : _a.outerHTML; });
|
|
117
|
-
/** Close browser */
|
|
118
|
-
yield browser.close();
|
|
119
|
-
/** If error, reject */
|
|
120
|
-
if (((_l = response === null || response === void 0 ? void 0 : response.status()) !== null && _l !== void 0 ? _l : 0) >= 400)
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
122
|
-
throw { document: bodyHTML, status: (_m = response === null || response === void 0 ? void 0 : response.status()) !== null && _m !== void 0 ? _m : 0 };
|
|
123
|
-
return this.getItem((0, linkedom_1.parseHTML)(bodyHTML).document);
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
65
|
}
|
|
125
66
|
catch (error) {
|
|
126
|
-
|
|
67
|
+
const { response, message } = error;
|
|
68
|
+
if ((response === null || response === void 0 ? void 0 : response.data) && response.status)
|
|
127
69
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
128
70
|
throw {
|
|
129
|
-
message: (
|
|
130
|
-
code:
|
|
71
|
+
message: (_d = (_c = (_b = (_a = (0, linkedom_1.parseHTML)(response.data).document) === null || _a === void 0 ? void 0 : _a.querySelector('h1 + p')) === null || _b === void 0 ? void 0 : _b.innerHTML) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : 'An error occured',
|
|
72
|
+
code: response.status,
|
|
131
73
|
};
|
|
132
74
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
133
75
|
throw {
|
|
134
|
-
message:
|
|
76
|
+
message: message || 'An error occured',
|
|
135
77
|
code: 500,
|
|
136
78
|
};
|
|
137
79
|
}
|
|
@@ -141,15 +83,15 @@ class Marketplace {
|
|
|
141
83
|
* Generate URL to be parsed
|
|
142
84
|
* @returns Url
|
|
143
85
|
*/
|
|
144
|
-
generateUrl() {
|
|
145
|
-
let url = `https://www.discogs.com/${
|
|
146
|
-
if (
|
|
147
|
-
url += `seller/${
|
|
148
|
-
url +=
|
|
86
|
+
static generateUrl({ searchType, seller, lang, }) {
|
|
87
|
+
let url = `https://www.discogs.com/${lang}/`;
|
|
88
|
+
if (seller) {
|
|
89
|
+
url += `seller/${seller}/`;
|
|
90
|
+
url += searchType === enums_1.EType.USER ? 'mywants' : 'profile';
|
|
149
91
|
}
|
|
150
92
|
else {
|
|
151
93
|
url += 'sell/';
|
|
152
|
-
url +=
|
|
94
|
+
url += searchType === enums_1.EType.USER ? 'mywants' : 'list';
|
|
153
95
|
}
|
|
154
96
|
return url;
|
|
155
97
|
}
|
|
@@ -158,8 +100,8 @@ class Marketplace {
|
|
|
158
100
|
* @param params Object of GET parameters
|
|
159
101
|
* @returns Url
|
|
160
102
|
*/
|
|
161
|
-
// eslint-disable-next-line
|
|
162
|
-
serializeParams(params) {
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
static serializeParams(params) {
|
|
163
105
|
const param = [];
|
|
164
106
|
// eslint-disable-next-line no-restricted-syntax
|
|
165
107
|
for (const key in params)
|
|
@@ -181,20 +123,20 @@ class Marketplace {
|
|
|
181
123
|
}
|
|
182
124
|
/**
|
|
183
125
|
* Function to convert currency to ISO name
|
|
184
|
-
* @param
|
|
126
|
+
* @param value String to clean
|
|
185
127
|
* @returns Cleanup string
|
|
186
128
|
*/
|
|
187
|
-
|
|
188
|
-
convertCurrency(value) {
|
|
129
|
+
static convertCurrency(value) {
|
|
189
130
|
var _a;
|
|
190
131
|
if (!value)
|
|
191
132
|
return value;
|
|
192
|
-
const currency = (_a = Object.keys(
|
|
133
|
+
const currency = (_a = Object.keys(translate_1.EDiscogsCurrencyToIsoCode).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
|
|
193
134
|
if (!currency)
|
|
194
135
|
return value;
|
|
195
|
-
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
const currencyClean = translate_1.EDiscogsCurrencyToIsoCode[currency];
|
|
196
138
|
const amount = value
|
|
197
|
-
.replace(currencyClean !==
|
|
139
|
+
.replace(currencyClean !== enums_1.ECurrency.JPY ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
|
|
198
140
|
.replace(currency, '') // Remove original currency
|
|
199
141
|
.replace(/\s/g, ''); // Remove spaces
|
|
200
142
|
return `${amount} ${currencyClean}`
|
|
@@ -203,20 +145,24 @@ class Marketplace {
|
|
|
203
145
|
/**
|
|
204
146
|
* Parse HTML to clean result
|
|
205
147
|
* @param document Document to parse
|
|
148
|
+
* @param urlGenerated Url generated
|
|
206
149
|
* @returns Items found
|
|
207
150
|
*/
|
|
208
|
-
|
|
209
|
-
var _a, _b, _c, _d, _e
|
|
210
|
-
const totalItems = parseFloat(
|
|
151
|
+
static getData(document, urlGenerated, { searchType = enums_1.EType.STRING, searchValue = undefined, limit = 25, page = 1, }) {
|
|
152
|
+
var _a, _b, _c, _d, _e;
|
|
153
|
+
const totalItems = parseFloat(
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
+
((_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
156
|
return {
|
|
212
157
|
items: ((_e = [...document.querySelectorAll('table.table_block tbody tr')]) === null || _e === void 0 ? void 0 : _e.map(el => {
|
|
213
158
|
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;
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
160
|
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
161
|
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
162
|
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
163
|
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
|
-
||
|
|
164
|
+
const isoCountryCode = (Object.keys(iso_1.ECountryCode).find((key) => (iso_1.ECountryName[key] === countryName))
|
|
165
|
+
|| translate_1.EDiscogsCountryNameToIsoCode[countryName]);
|
|
220
166
|
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
167
|
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
168
|
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);
|
|
@@ -264,7 +210,7 @@ class Marketplace {
|
|
|
264
210
|
},
|
|
265
211
|
from: {
|
|
266
212
|
countryName,
|
|
267
|
-
isoCountryName: (_58 =
|
|
213
|
+
isoCountryName: (_58 = iso_1.ECountryName[isoCountryCode]) !== null && _58 !== void 0 ? _58 : '',
|
|
268
214
|
isoCountryCode,
|
|
269
215
|
},
|
|
270
216
|
community: {
|
|
@@ -278,18 +224,18 @@ class Marketplace {
|
|
|
278
224
|
};
|
|
279
225
|
})) || [],
|
|
280
226
|
page: {
|
|
281
|
-
current:
|
|
282
|
-
total: Math.ceil(totalItems /
|
|
227
|
+
current: page,
|
|
228
|
+
total: Math.ceil(totalItems / limit),
|
|
283
229
|
},
|
|
284
230
|
result: {
|
|
285
231
|
total: totalItems,
|
|
286
|
-
perPage:
|
|
232
|
+
perPage: limit,
|
|
287
233
|
},
|
|
288
234
|
search: {
|
|
289
|
-
value:
|
|
290
|
-
type:
|
|
235
|
+
value: searchValue !== null && searchValue !== void 0 ? searchValue : '',
|
|
236
|
+
type: searchType,
|
|
291
237
|
},
|
|
292
|
-
urlGenerated:
|
|
238
|
+
urlGenerated: urlGenerated !== null && urlGenerated !== void 0 ? urlGenerated : '',
|
|
293
239
|
};
|
|
294
240
|
}
|
|
295
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"tsconfig-paths": "^3.14.1",
|
|
33
|
-
"user-agents": "^1.0.971"
|
|
30
|
+
"axios": "^0.27.2",
|
|
31
|
+
"linkedom": "^0.14.17",
|
|
32
|
+
"user-agents": "^1.0.1168"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@types/jest": "^
|
|
37
|
-
"@types/node": "^
|
|
35
|
+
"@types/jest": "^29.1.2",
|
|
36
|
+
"@types/node": "^18.8.5",
|
|
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.40.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.40.0",
|
|
40
|
+
"eslint": "^8.25.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.2.0",
|
|
46
|
+
"ts-jest": "^29.0.3",
|
|
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
|
}
|