discogs-marketplace-api-nodejs 1.6.1 → 1.7.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 +15 -22
- package/dist/data/countries.data.js +1 -0
- package/dist/data/index.d.ts +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -1
- package/dist/marketplace.js +47 -29
- package/dist/types/commons/index.d.ts +4 -4
- package/dist/types/commons/input.type.d.ts +6 -4
- package/dist/types/unions/from.type.d.ts +1 -1
- package/dist/types/unions/index.d.ts +12 -12
- package/package.json +34 -25
- /package/dist/types/commons/{output-sucess.type.d.ts → output-success.type.d.ts} +0 -0
- /package/dist/types/commons/{output-sucess.type.js → output-success.type.js} +0 -0
package/README.MD
CHANGED
|
@@ -16,10 +16,10 @@ Import `DiscogsMarketplace` into your project:
|
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
// With ECMAScript 6 and +
|
|
19
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
19
|
+
import { DiscogsMarketplace } from 'discogs-marketplace-api-nodejs'
|
|
20
20
|
|
|
21
21
|
// With CommonJS
|
|
22
|
-
const DiscogsMarketplace = require('discogs-marketplace-api-nodejs').
|
|
22
|
+
const DiscogsMarketplace = require('discogs-marketplace-api-nodejs').DiscogsMarketplace
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Examples
|
|
@@ -27,8 +27,6 @@ const DiscogsMarketplace = require('discogs-marketplace-api-nodejs').default
|
|
|
27
27
|
- Get top 250 items, of the 2nd page, filtered by Rock, listed by newest, for a given artist
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
31
|
-
|
|
32
30
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock
|
|
33
31
|
const result = await DiscogsMarketplace.search({
|
|
34
32
|
limit: 250,
|
|
@@ -43,11 +41,10 @@ const result = await DiscogsMarketplace.search({
|
|
|
43
41
|
- Get top 50 items, of the 1st page, listed by price lowest, on a user wantlist
|
|
44
42
|
|
|
45
43
|
```js
|
|
46
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
47
|
-
|
|
48
44
|
// https://www.discogs.com/sell/mywants?limit=50&user=Kirian_&sort=price,asc
|
|
49
45
|
const result = await DiscogsMarketplace.search({
|
|
50
46
|
limit: 50,
|
|
47
|
+
page: 1,
|
|
51
48
|
sort: 'Price Lowest',
|
|
52
49
|
searchType: 'user',
|
|
53
50
|
searchValue: 'Kirian_',
|
|
@@ -57,11 +54,10 @@ const result = await DiscogsMarketplace.search({
|
|
|
57
54
|
- Get top 25 items, of the 1st page, listed by seller A-Z, on a release
|
|
58
55
|
|
|
59
56
|
```js
|
|
60
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
61
|
-
|
|
62
57
|
// https://www.discogs.com/sell/release/767931?sort=seller,asc&limit=25&page=1
|
|
63
58
|
const result = await DiscogsMarketplace.search({
|
|
64
59
|
sort: 'Seller A-Z',
|
|
60
|
+
page: 1,
|
|
65
61
|
searchType: 'release_id',
|
|
66
62
|
searchValue: '767931',
|
|
67
63
|
})
|
|
@@ -70,11 +66,10 @@ const result = await DiscogsMarketplace.search({
|
|
|
70
66
|
- Get top 100 items, of the 1st page, listed by newest, on a string search
|
|
71
67
|
|
|
72
68
|
```js
|
|
73
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
74
|
-
|
|
75
69
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=100&q=in+flames&page=1
|
|
76
70
|
const result = await DiscogsMarketplace.search({
|
|
77
71
|
limit: 100,
|
|
72
|
+
page: 1,
|
|
78
73
|
sort: 'Listed Newest',
|
|
79
74
|
searchType: 'q',
|
|
80
75
|
searchValue: 'in flames',
|
|
@@ -84,11 +79,10 @@ const result = await DiscogsMarketplace.search({
|
|
|
84
79
|
- Get top 25 items, of the 1st page, listed by newest, on a seller inventory
|
|
85
80
|
|
|
86
81
|
```js
|
|
87
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
88
|
-
|
|
89
82
|
// https://www.discogs.com/seller/Kirian_/profile?sort=listed,desc&limit=25&page=1
|
|
90
83
|
const result = await DiscogsMarketplace.search({
|
|
91
84
|
sort: 'Listed Newest',
|
|
85
|
+
page: 1,
|
|
92
86
|
searchType: 'q',
|
|
93
87
|
searchValue: '',
|
|
94
88
|
seller: 'Kirian_',
|
|
@@ -98,11 +92,10 @@ const result = await DiscogsMarketplace.search({
|
|
|
98
92
|
- Get top 25 items, of the 1st page, listed by newest, on a user wantlist, on a seller inventory
|
|
99
93
|
|
|
100
94
|
```js
|
|
101
|
-
import DiscogsMarketplace from 'discogs-marketplace-api-nodejs'
|
|
102
|
-
|
|
103
95
|
// https://www.discogs.com/seller/Kirian_/mywants?sort=listed,desc&limit=25&user=Kirian_&page=1
|
|
104
96
|
const result = await DiscogsMarketplace.search({
|
|
105
97
|
sort: 'Listed Newest',
|
|
98
|
+
page: 1,
|
|
106
99
|
searchType: 'user',
|
|
107
100
|
searchValue: 'Kirian_',
|
|
108
101
|
seller: 'Kirian_',
|
|
@@ -131,7 +124,7 @@ type InputType = {
|
|
|
131
124
|
/**
|
|
132
125
|
* Value to search corresponding to searchType
|
|
133
126
|
*/
|
|
134
|
-
searchValue
|
|
127
|
+
searchValue?: string | number
|
|
135
128
|
/**
|
|
136
129
|
* Currency
|
|
137
130
|
*/
|
|
@@ -186,16 +179,18 @@ type InputType = {
|
|
|
186
179
|
*/
|
|
187
180
|
seller?: string
|
|
188
181
|
/**
|
|
189
|
-
* Sort elements by
|
|
182
|
+
* Sort elements by.
|
|
183
|
+
* Default to `Listed Newest`.
|
|
190
184
|
*/
|
|
191
185
|
sort?: SortType
|
|
192
186
|
/**
|
|
193
|
-
* Limit of elements to search (25 | 50 | 100 | 250)
|
|
187
|
+
* Limit of elements to search (25 | 50 | 100 | 250).
|
|
188
|
+
* Default to `25`.
|
|
194
189
|
*/
|
|
195
190
|
limit?: LimitType
|
|
196
191
|
/**
|
|
197
192
|
* Page (Must be < 401 or discogs will return an error 404).
|
|
198
|
-
* Default to `
|
|
193
|
+
* Default to `1`.
|
|
199
194
|
*/
|
|
200
195
|
page?: number
|
|
201
196
|
/**
|
|
@@ -283,13 +278,11 @@ type OutputErrorType = {
|
|
|
283
278
|
}
|
|
284
279
|
```
|
|
285
280
|
|
|
286
|
-
Other interfaces can be found in `src/interfaces`.
|
|
287
|
-
|
|
288
281
|
## How to contribute
|
|
289
282
|
|
|
290
283
|
There is a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) on that project already configured, feel free to use it.
|
|
291
284
|
|
|
292
|
-
|
|
285
|
+
Install dependencies with:
|
|
293
286
|
|
|
294
287
|
```sh
|
|
295
288
|
npm install
|
|
@@ -301,7 +294,7 @@ You can open a pull request with your new additions.
|
|
|
301
294
|
|
|
302
295
|
### Linkedom
|
|
303
296
|
|
|
304
|
-
If you are using this
|
|
297
|
+
If you are using this library on a Typescript project, you might encounter issues with `linkedom`.
|
|
305
298
|
|
|
306
299
|
To fix it, use this in command line: `--skipLibCheck` or add that in you `tsconfig.json`:
|
|
307
300
|
|
package/dist/data/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { InputType, OutputErrorType, OutputSuccessType } from './types/commons/index.js';
|
|
2
1
|
import DiscogsMarketplace from './marketplace.js';
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
import type { InputType, OutputErrorType, OutputSuccessType } from './types/commons/index.js';
|
|
3
|
+
export { DiscogsMarketplace, InputType, OutputErrorType, OutputSuccessType };
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DiscogsMarketplace = void 0;
|
|
6
7
|
const marketplace_1 = __importDefault(require("./marketplace.js"));
|
|
7
|
-
exports.
|
|
8
|
+
exports.DiscogsMarketplace = marketplace_1.default;
|
package/dist/marketplace.js
CHANGED
|
@@ -12,10 +12,10 @@ 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 data_1 = require("./data/index.js");
|
|
16
15
|
const user_agents_1 = __importDefault(require("user-agents"));
|
|
17
16
|
const linkedom_1 = require("linkedom");
|
|
18
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const data_1 = require("./data/index.js");
|
|
19
19
|
/**
|
|
20
20
|
* Discogs Marketplace
|
|
21
21
|
*/
|
|
@@ -24,7 +24,7 @@ class Marketplace {
|
|
|
24
24
|
* Search elements on discogs
|
|
25
25
|
* @returns Items found
|
|
26
26
|
*/
|
|
27
|
-
static search({ searchType = 'q', searchValue = undefined, currency = undefined, genre = undefined, style = [], format = [], formatDescription = [], condition = [], year = undefined, years = undefined, isAudioSample = false, isMakeAnOfferOnly = false, from = undefined, seller = undefined, sort =
|
|
27
|
+
static search({ searchType = 'q', searchValue = undefined, currency = undefined, genre = undefined, style = [], format = [], formatDescription = [], condition = [], year = undefined, years = undefined, isAudioSample = false, isMakeAnOfferOnly = false, from = undefined, seller = undefined, sort = 'Listed Newest', limit = 25, page = 1, lang = 'en', }) {
|
|
28
28
|
var _a, _b, _c, _d;
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
try {
|
|
@@ -53,27 +53,32 @@ class Marketplace {
|
|
|
53
53
|
serialize: this.serializeParams,
|
|
54
54
|
},
|
|
55
55
|
headers: {
|
|
56
|
+
// cspell: disable-next-line
|
|
56
57
|
'X-PJAX': 'true',
|
|
57
58
|
'User-Agent': new user_agents_1.default().toString(),
|
|
58
59
|
},
|
|
59
60
|
};
|
|
60
61
|
const { data: bodyHTML } = yield axios_1.default.request(config);
|
|
61
62
|
return this.getData((0, linkedom_1.parseHTML)(bodyHTML).document, axios_1.default.getUri(config), {
|
|
62
|
-
searchType,
|
|
63
|
+
searchType,
|
|
64
|
+
searchValue,
|
|
65
|
+
limit,
|
|
66
|
+
page,
|
|
63
67
|
});
|
|
64
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
69
|
}
|
|
66
70
|
catch (error) {
|
|
67
71
|
const { response, message } = error;
|
|
68
|
-
if ((response === null || response === void 0 ? void 0 : response.data) && response.status)
|
|
72
|
+
if ((response === null || response === void 0 ? void 0 : response.data) && response.status) {
|
|
69
73
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
70
74
|
throw {
|
|
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
|
|
75
|
+
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 occurred',
|
|
72
76
|
code: response.status,
|
|
73
77
|
};
|
|
78
|
+
}
|
|
74
79
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
75
80
|
throw {
|
|
76
|
-
message: message || 'An error
|
|
81
|
+
message: message || 'An error occurred',
|
|
77
82
|
code: 500,
|
|
78
83
|
};
|
|
79
84
|
}
|
|
@@ -83,7 +88,7 @@ class Marketplace {
|
|
|
83
88
|
* Generate URL to be parsed
|
|
84
89
|
* @returns Url
|
|
85
90
|
*/
|
|
86
|
-
static generateUrl({ searchType, seller, lang
|
|
91
|
+
static generateUrl({ searchType, seller, lang }) {
|
|
87
92
|
let url = `https://www.discogs.com/${lang}/`;
|
|
88
93
|
if (seller) {
|
|
89
94
|
url += `seller/${seller}/`;
|
|
@@ -104,21 +109,28 @@ class Marketplace {
|
|
|
104
109
|
static serializeParams(params) {
|
|
105
110
|
const param = [];
|
|
106
111
|
// eslint-disable-next-line no-restricted-syntax
|
|
107
|
-
for (const key in params)
|
|
108
|
-
if (params[key] === undefined || params[key] === null)
|
|
112
|
+
for (const key in params) {
|
|
113
|
+
if (params[key] === undefined || params[key] === null) {
|
|
109
114
|
// eslint-disable-next-line no-continue
|
|
110
115
|
continue;
|
|
111
|
-
|
|
116
|
+
}
|
|
117
|
+
else if (Array.isArray(params[key])) {
|
|
112
118
|
/** Custom handle for array */
|
|
113
|
-
if (params[key].length > 0)
|
|
119
|
+
if (params[key].length > 0) {
|
|
114
120
|
// eslint-disable-next-line no-restricted-syntax
|
|
115
|
-
for (const el of params[key])
|
|
121
|
+
for (const el of params[key]) {
|
|
116
122
|
param.push(`${key}=${encodeURIComponent(el)}`);
|
|
117
|
-
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
118
126
|
// eslint-disable-next-line no-continue
|
|
119
127
|
continue;
|
|
120
|
-
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
121
131
|
param.push(`${key}=${encodeURIComponent(params[key])}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
122
134
|
return param.join('&');
|
|
123
135
|
}
|
|
124
136
|
/**
|
|
@@ -128,18 +140,19 @@ class Marketplace {
|
|
|
128
140
|
*/
|
|
129
141
|
static convertCurrency(value) {
|
|
130
142
|
var _a;
|
|
131
|
-
if (!value)
|
|
143
|
+
if (!value) {
|
|
132
144
|
return value;
|
|
145
|
+
}
|
|
133
146
|
const currencyFound = (_a = Object.keys(data_1.CURRENCIES).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
|
|
134
|
-
if (!currencyFound)
|
|
147
|
+
if (!currencyFound) {
|
|
135
148
|
return value;
|
|
149
|
+
}
|
|
136
150
|
const currencyClean = data_1.CURRENCIES[currencyFound];
|
|
137
151
|
const amount = value
|
|
138
152
|
.replace(currencyClean !== 'JPY' ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
|
|
139
153
|
.replace(currencyFound, '') // Remove original currency
|
|
140
154
|
.replace(/\s/g, ''); // Remove spaces
|
|
141
|
-
return `${amount} ${currencyClean}
|
|
142
|
-
.replace(/\s\s+/g, ' '); // Remove useless spaces
|
|
155
|
+
return `${amount} ${currencyClean}`.replace(/\s\s+/g, ' '); // Remove useless spaces
|
|
143
156
|
}
|
|
144
157
|
/**
|
|
145
158
|
* Parse HTML to clean result
|
|
@@ -147,23 +160,24 @@ class Marketplace {
|
|
|
147
160
|
* @param urlGenerated Url generated
|
|
148
161
|
* @returns Items found
|
|
149
162
|
*/
|
|
150
|
-
static getData(document, urlGenerated, { searchType = 'q', searchValue = undefined, limit = 25, page = 1
|
|
163
|
+
static getData(document, urlGenerated, { searchType = 'q', searchValue = undefined, limit = 25, page = 1 }) {
|
|
151
164
|
var _a, _b, _c, _d, _e;
|
|
152
|
-
const totalItems = parseFloat(
|
|
153
|
-
|
|
154
|
-
((_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');
|
|
165
|
+
const totalItems = parseFloat(((_d = (_c = (_b = (_a = document
|
|
166
|
+
.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');
|
|
155
167
|
return {
|
|
156
168
|
items: ((_e = [...document.querySelectorAll('table.table_block tbody tr')]) === null || _e === void 0 ? void 0 : _e.map(el => {
|
|
157
169
|
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;
|
|
158
170
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
-
const shipping = this.convertCurrency((_g = (_f = (_e = (_d = (_c = (_b = (_a = el
|
|
171
|
+
const shipping = this.convertCurrency((_g = (_f = (_e = (_d = (_c = (_b = (_a = el
|
|
172
|
+
.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 : '');
|
|
160
173
|
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);
|
|
161
174
|
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);
|
|
162
175
|
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.pop()) !== null && _q !== void 0 ? _q : '';
|
|
163
176
|
const countryCode = data_1.COUNTRIES[countryName];
|
|
164
177
|
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);
|
|
165
178
|
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);
|
|
166
|
-
const notes = Number.parseInt((_5 = (_4 = (_3 = (_2 = (_1 = (_0 = (_z = el
|
|
179
|
+
const notes = Number.parseInt((_5 = (_4 = (_3 = (_2 = (_1 = (_0 = (_z = el
|
|
180
|
+
.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);
|
|
167
181
|
const originalTitle = (_6 = el.querySelector('a.item_description_title')) === null || _6 === void 0 ? void 0 : _6.textContent;
|
|
168
182
|
const firstIndexOfDash = (_7 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.indexOf(' - ')) !== null && _7 !== void 0 ? _7 : -1;
|
|
169
183
|
const lastIndexOfParenthesis = (_8 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.lastIndexOf(' (')) !== null && _8 !== void 0 ? _8 : -1;
|
|
@@ -176,12 +190,14 @@ class Marketplace {
|
|
|
176
190
|
? (_10 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(firstIndexOfDash + 3, lastIndexOfParenthesis)) !== null && _10 !== void 0 ? _10 : ''
|
|
177
191
|
: '',
|
|
178
192
|
formats: lastIndexOfParenthesis > -1
|
|
179
|
-
? (
|
|
193
|
+
? (_12 = (_11 = originalTitle === null || originalTitle === void 0 ? void 0 : originalTitle.substring(lastIndexOfParenthesis + 2, originalTitle.length - 1)) === null || _11 === void 0 ? void 0 : _11.split(', ')) !== null && _12 !== void 0 ? _12 : []
|
|
180
194
|
: [],
|
|
181
195
|
},
|
|
182
196
|
url: `https://www.discogs.com${(_13 = el.querySelector('a.item_description_title')) === null || _13 === void 0 ? void 0 : _13.href}`,
|
|
183
|
-
labels: (_15 = (_14 = [...el.querySelectorAll(
|
|
184
|
-
catnos: (_20 = (_19 = (_18 = (_17 = (_16 = el
|
|
197
|
+
labels: (_15 = (_14 = [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]) === null || _14 === void 0 ? void 0 : _14.map(x => { var _a; return (_a = x === null || x === void 0 ? void 0 : x.textContent) !== null && _a !== void 0 ? _a : ''; })) === null || _15 === void 0 ? void 0 : _15.filter((value, index, self) => self.indexOf(value) === index),
|
|
198
|
+
catnos: (_20 = (_19 = (_18 = (_17 = (_16 = el
|
|
199
|
+
// cspell: disable-next-line
|
|
200
|
+
.querySelector('.label_and_cat .item_catno')) === null || _16 === void 0 ? void 0 : _16.textContent) === null || _17 === void 0 ? void 0 : _17.replace(/\s+/g, ' ')) === null || _18 === void 0 ? void 0 : _18.split(', ')) === null || _19 === void 0 ? void 0 : _19.filter(x => x !== 'none')) !== null && _20 !== void 0 ? _20 : [],
|
|
185
201
|
imageUrl: (_22 = (_21 = el.querySelector('.marketplace_image')) === null || _21 === void 0 ? void 0 : _21.getAttribute('data-src')) !== null && _22 !== void 0 ? _22 : '',
|
|
186
202
|
description: (_27 = (_26 = (_25 = (_24 = (_23 = el.querySelector('.item_condition')) === null || _23 === void 0 ? void 0 : _23.nextElementSibling) === null || _24 === void 0 ? void 0 : _24.textContent) === null || _25 === void 0 ? void 0 : _25.replace(/\s+/g, ' ')) === null || _26 === void 0 ? void 0 : _26.trim()) !== null && _27 !== void 0 ? _27 : '',
|
|
187
203
|
isAcceptingOffer: ((_31 = (_30 = (_29 = (_28 = el.querySelector('.item_add_to_cart p a strong')) === null || _28 === void 0 ? void 0 : _28.textContent) === null || _29 === void 0 ? void 0 : _29.split('/')) === null || _30 === void 0 ? void 0 : _30.length) !== null && _31 !== void 0 ? _31 : 0) > 1,
|
|
@@ -189,11 +205,13 @@ class Marketplace {
|
|
|
189
205
|
condition: {
|
|
190
206
|
media: {
|
|
191
207
|
full: (_36 = (_35 = (_34 = (_33 = el.querySelector('.item_condition span:nth-child(3)')) === null || _33 === void 0 ? void 0 : _33.textContent) === null || _34 === void 0 ? void 0 : _34.replace(/\s+/g, ' ')) === null || _35 === void 0 ? void 0 : _35.trim()) !== null && _36 !== void 0 ? _36 : '',
|
|
192
|
-
short: (_42 = (_41 = (_40 = (_39 = (_38 = (_37 = el
|
|
208
|
+
short: (_42 = (_41 = (_40 = (_39 = (_38 = (_37 = el
|
|
209
|
+
.querySelector('.item_condition span:nth-child(3)')) === null || _37 === void 0 ? void 0 : _37.textContent) === null || _38 === void 0 ? void 0 : _38.replace(/\s+/g, ' ')) === null || _39 === void 0 ? void 0 : _39.trim()) === null || _40 === void 0 ? void 0 : _40.match(/\(([^)]+)\)/)) === null || _41 === void 0 ? void 0 : _41[1]) !== null && _42 !== void 0 ? _42 : '',
|
|
193
210
|
},
|
|
194
211
|
sleeve: {
|
|
195
212
|
full: (_44 = (_43 = el.querySelector('.item_condition span.item_sleeve_condition')) === null || _43 === void 0 ? void 0 : _43.textContent) !== null && _44 !== void 0 ? _44 : '',
|
|
196
|
-
short: (_48 = (_47 = (_46 = (_45 = el
|
|
213
|
+
short: (_48 = (_47 = (_46 = (_45 = el
|
|
214
|
+
.querySelector('.item_condition span.item_sleeve_condition')) === null || _45 === void 0 ? void 0 : _45.textContent) === null || _46 === void 0 ? void 0 : _46.match(/\(([^)]+)\)/)) === null || _47 === void 0 ? void 0 : _47[1]) !== null && _48 !== void 0 ? _48 : '',
|
|
197
215
|
},
|
|
198
216
|
},
|
|
199
217
|
seller: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import InputType from '../../types/commons/input.type.js';
|
|
2
|
-
import OutputErrorType from '../../types/commons/output-error.type.js';
|
|
3
|
-
import OutputSuccessType from '../../types/commons/output-
|
|
4
|
-
export { InputType, OutputErrorType, OutputSuccessType
|
|
1
|
+
import type InputType from '../../types/commons/input.type.js';
|
|
2
|
+
import type OutputErrorType from '../../types/commons/output-error.type.js';
|
|
3
|
+
import type OutputSuccessType from '../../types/commons/output-success.type.js';
|
|
4
|
+
export { InputType, OutputErrorType, OutputSuccessType };
|
|
@@ -19,7 +19,7 @@ type InputType = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Value to search corresponding to searchType
|
|
21
21
|
*/
|
|
22
|
-
searchValue
|
|
22
|
+
searchValue?: string | number;
|
|
23
23
|
/**
|
|
24
24
|
* Currency
|
|
25
25
|
*/
|
|
@@ -74,16 +74,18 @@ type InputType = {
|
|
|
74
74
|
*/
|
|
75
75
|
seller?: string;
|
|
76
76
|
/**
|
|
77
|
-
* Sort elements by
|
|
77
|
+
* Sort elements by.
|
|
78
|
+
* Default to `Listed Newest`.
|
|
78
79
|
*/
|
|
79
80
|
sort?: SortType;
|
|
80
81
|
/**
|
|
81
|
-
* Limit of elements to search (25 | 50 | 100 | 250)
|
|
82
|
+
* Limit of elements to search (25 | 50 | 100 | 250).
|
|
83
|
+
* Default to `25`.
|
|
82
84
|
*/
|
|
83
85
|
limit?: LimitType;
|
|
84
86
|
/**
|
|
85
87
|
* Page (Must be < 401 or discogs will return an error 404).
|
|
86
|
-
* Default to `
|
|
88
|
+
* Default to `1`.
|
|
87
89
|
*/
|
|
88
90
|
page?: number;
|
|
89
91
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* From
|
|
3
3
|
*/
|
|
4
4
|
type FromType = 'Afghanistan' | 'Albania' | 'Algeria' | 'American Samoa' | 'Andorra' | 'Angola' | 'Anguilla' | 'Antarctica' | 'Antigua and Barbuda' | 'Argentina' | 'Armenia' | 'Aruba' | 'Australia' | 'Austria' | 'Azerbaidjan' | 'Bahamas' | 'Bahrain' | 'Bangladesh' | 'Barbados' | 'Belarus' | 'Belgium' | 'Belize' | 'Benin' | 'Bermuda' | 'Bhutan' | 'Bolivia' | 'Bosnia-Herzegovina' | 'Botswana' | 'Bouvet Island' | 'Brazil' | 'British Indian Ocean Territory' | 'Brunei Darussalam' | 'Bulgaria' | 'Burkina Faso' | 'Burundi' | 'Cambodia' | 'Cameroon' | 'Canada' | 'Cape Verde' | 'Cayman Islands' | 'Central African Republic' | 'Chad' | 'Chile' | 'China' | 'Christmas Island' | 'Cocos (Keeling) Islands' | 'Colombia' | 'Comoros' | 'Congo' | 'Cook Islands' | 'Costa Rica' | 'Croatia' | 'Cuba' | 'Cyprus' | 'Czech Republic' | 'Denmark' | 'Djibouti' | 'Dominica' | 'Dominican Republic' | 'East Timor' | 'Ecuador' | 'Egypt' | 'El Salvador' | 'Equatorial Guinea' | 'Eritrea' | 'Estonia' | 'Ethiopia' | 'Falkland Islands' | 'Faroe Islands' | 'Fiji' | 'Finland' | 'Former Czechoslovakia' | 'Former USSR' | 'France' | 'France (European Territory)' | 'French Guyana' | 'French Southern Territories' | 'Gabon' | 'Gambia' | 'Georgia' | 'Germany' | 'Ghana' | 'Gibraltar' | 'Greece' | 'Greenland' | 'Grenada' | 'Guadeloupe (French)' | 'Guam (USA)' | 'Guatemala' | 'Guinea' | 'Guinea Bissau' | 'Guyana' | 'Haiti' | 'Heard and McDonald Islands' | 'Honduras' | 'Hong Kong' | 'Hungary' | 'Iceland' | 'India' | 'Indonesia' | 'Iran' | 'Iraq' | 'Ireland' | 'Israel' | 'Italy' | "Ivory Coast (Cote D'Ivoire)" | 'Jamaica' | 'Japan' | 'Jordan' | 'Kazakhstan' | 'Kenya' | 'Kiribati' | 'Kuwait' | 'Kyrgyzstan' | 'Laos' | 'Latvia' | 'Lebanon' | 'Lesotho' | 'Liberia' | 'Libya' | 'Liechtenstein' | 'Lithuania' | 'Luxembourg' | 'Macau' | 'Macedonia' | 'Madagascar' | 'Malawi' | 'Malaysia' | 'Maldives' | 'Mali' | 'Malta' | 'Marshall Islands' | 'Martinique (French)' | 'Mauritania' | 'Mauritius' | 'Mayotte' | 'Mexico' | 'Micronesia' | 'Moldova, Republic of' | 'Monaco' | 'Mongolia' | 'Montenegro' | 'Montserrat' | 'Morocco' | 'Mozambique' | 'Myanmar' | 'Namibia' | 'Nauru' | 'Nepal' | 'Netherlands' | 'Netherlands Antilles' | 'Neutral Zone' | 'New Caledonia (French)' | 'New Zealand' | 'Nicaragua' | 'Niger' | 'Nigeria' | 'Niue' | 'Norfolk Island' | 'Northern Ireland' | 'Northern Mariana Islands' | 'Norway' | 'Oman' | 'Pakistan' | 'Palau' | 'Panama' | 'Papua New Guinea' | 'Paraguay' | 'Peru' | 'Philippines' | 'Pitcairn Island' | 'Poland' | 'Polynesia (French)' | 'Portugal' | 'Puerto Rico' | 'Qatar' | 'Reunion (French)' | 'Romania' | 'Russian Federation' | 'Rwanda' | 'S. Georgia & S. Sandwich Isls.' | 'Saint Helena' | 'Saint Kitts & Nevis Anguilla' | 'Saint Lucia' | 'Saint Pierre and Miquelon' | 'Saint Tome (Sao Tome) and Princi' | 'Saint Vincent & Grenadines' | 'Samoa' | 'San Marino' | 'Saudi Arabia' | 'Select your country' | 'Senegal' | 'Serbia' | 'Seychelles' | 'Sierra Leone' | 'Singapore' | 'Slovak Republic' | 'Slovenia' | 'Solomon Islands' | 'Somalia' | 'South Africa' | 'South Korea' | 'Spain' | 'Spain (Canary Islands)' | 'Sri Lanka' | 'Sudan' | 'Suriname' | 'Svalbard and Jan Mayen Islands' | 'Swaziland' | 'Sweden' | 'Switzerland' | 'Syria' | 'Tadjikistan' | 'Taiwan' | 'Tanzania' | 'Thailand' | 'Togo' | 'Tokelau' | 'Tonga' | 'Trinidad and Tobago' | 'Tunisia' | 'Turkey' | 'Turkmenistan' | 'Turks and Caicos Islands' | 'Tuvalu' | 'USA Minor Outlying Islands' | 'Uganda' | 'Ukraine' | 'United Arab Emirates' | 'United Kingdom' | 'United Kingdom (Channel Islands)' | 'United States' | 'Uruguay' | 'Uzbekistan' | 'Vanuatu' | 'Vatican City State' | 'Venezuela' | 'Vietnam' | 'Virgin Islands (British)' | 'Virgin Islands (USA)' | 'Wallis and Futuna Islands' | 'Western Sahara' | 'Yemen' | 'Yugoslavia' | 'Zaire' | 'Zambia' | 'Zimbabwe';
|
|
5
5
|
export default FromType;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import LimitType from '../../types/unions/limit.type.js';
|
|
2
|
-
import GenreType from '../../types/unions/genre.type.js';
|
|
3
|
-
import CurrencyType from '../../types/unions/currency.type.js';
|
|
4
|
-
import FromType from '../../types/unions/from.type.js';
|
|
5
|
-
import StyleType from '../../types/unions/style.type.js';
|
|
6
|
-
import FormatType from '../../types/unions/format.type.js';
|
|
7
|
-
import ConditionType from '../../types/unions/condition.type.js';
|
|
8
|
-
import SortType from '../../types/unions/sort.type.js';
|
|
9
|
-
import LangType from '../../types/unions/lang.type.js';
|
|
10
|
-
import FormatDescriptionType from '../../types/unions/format-description.type.js';
|
|
11
|
-
import SearchTypeType from '../../types/unions/search-type.type.js';
|
|
12
|
-
export { LimitType, GenreType, CurrencyType, FromType, StyleType, FormatType, ConditionType, SortType, LangType, FormatDescriptionType, SearchTypeType, };
|
|
1
|
+
import type LimitType from '../../types/unions/limit.type.js';
|
|
2
|
+
import type GenreType from '../../types/unions/genre.type.js';
|
|
3
|
+
import type CurrencyType from '../../types/unions/currency.type.js';
|
|
4
|
+
import type FromType from '../../types/unions/from.type.js';
|
|
5
|
+
import type StyleType from '../../types/unions/style.type.js';
|
|
6
|
+
import type FormatType from '../../types/unions/format.type.js';
|
|
7
|
+
import type ConditionType from '../../types/unions/condition.type.js';
|
|
8
|
+
import type SortType from '../../types/unions/sort.type.js';
|
|
9
|
+
import type LangType from '../../types/unions/lang.type.js';
|
|
10
|
+
import type FormatDescriptionType from '../../types/unions/format-description.type.js';
|
|
11
|
+
import type SearchTypeType from '../../types/unions/search-type.type.js';
|
|
12
|
+
export type { LimitType, GenreType, CurrencyType, FromType, StyleType, FormatType, ConditionType, SortType, LangType, FormatDescriptionType, SearchTypeType, };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Another (better ?) NodeJs library to fetch data from
|
|
3
|
+
"version": "1.7.1",
|
|
4
|
+
"description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
7
7
|
"marketplace",
|
|
@@ -16,40 +16,49 @@
|
|
|
16
16
|
"author": "KirianCaumes",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"prepare": "npm run build",
|
|
19
|
+
"prepare": "husky install && npm run build",
|
|
20
20
|
"prebuild": "rimraf dist",
|
|
21
21
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
22
22
|
"start:dev": "nodemon -r tsconfig-paths/register ./src/index.ts",
|
|
23
23
|
"test": "jest",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"eslint:fix": "eslint src test --ext .ts,.js --fix",
|
|
25
|
+
"eslint": "eslint src test --ext .ts,.js",
|
|
26
|
+
"prettier": "prettier --check .",
|
|
27
|
+
"prettier:fix": "prettier --write .",
|
|
28
|
+
"cspell": "npx cspell ./ --no-progress"
|
|
26
29
|
},
|
|
27
30
|
"main": "dist/index.js",
|
|
28
31
|
"types": "dist/index.d.ts",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=14.0.0"
|
|
34
|
+
},
|
|
29
35
|
"dependencies": {
|
|
30
|
-
"axios": "^1.
|
|
31
|
-
"linkedom": "^0.
|
|
32
|
-
"user-agents": "^1.
|
|
36
|
+
"axios": "^1.6.0",
|
|
37
|
+
"linkedom": "^0.16.1",
|
|
38
|
+
"user-agents": "^1.1.15"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
|
-
"@types/jest": "^29.
|
|
36
|
-
"@types/node": "^18.
|
|
37
|
-
"@types/user-agents": "^1.0.
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
39
|
-
"@typescript-eslint/parser": "^
|
|
40
|
-
"
|
|
41
|
+
"@types/jest": "^29.5.7",
|
|
42
|
+
"@types/node": "^18.18.8",
|
|
43
|
+
"@types/user-agents": "^1.0.3",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
45
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
46
|
+
"cspell": "^7.3.8",
|
|
47
|
+
"eslint": "^8.53.0",
|
|
41
48
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
42
|
-
"eslint-config-airbnb-typescript": "^17.
|
|
43
|
-
"eslint-
|
|
44
|
-
"eslint-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
49
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
50
|
+
"eslint-config-prettier": "^9.0.0",
|
|
51
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
52
|
+
"eslint-plugin-import": "^2.29.0",
|
|
53
|
+
"eslint-plugin-jsdoc": "^46.8.2",
|
|
54
|
+
"husky": "^8.0.3",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"lint-staged": "^15.0.2",
|
|
57
|
+
"prettier": "^3.0.3",
|
|
58
|
+
"ts-jest": "^29.1.1",
|
|
47
59
|
"ts-node": "^10.9.1",
|
|
48
|
-
"tsc-alias": "^1.8.
|
|
49
|
-
"tsconfig-paths": "^4.
|
|
50
|
-
"typescript": "^
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=14.0.0"
|
|
60
|
+
"tsc-alias": "^1.8.8",
|
|
61
|
+
"tsconfig-paths": "^4.2.0",
|
|
62
|
+
"typescript": "^5.2.2"
|
|
54
63
|
}
|
|
55
64
|
}
|
|
File without changes
|
|
File without changes
|