discogs-marketplace-api-nodejs 1.7.0 → 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 +13 -6
- package/dist/data/countries.data.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/marketplace.js +6 -4
- package/dist/types/commons/index.d.ts +1 -1
- package/dist/types/commons/input.type.d.ts +6 -4
- package/dist/types/unions/from.type.d.ts +1 -1
- package/package.json +27 -22
- /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
|
@@ -44,6 +44,7 @@ const result = await DiscogsMarketplace.search({
|
|
|
44
44
|
// https://www.discogs.com/sell/mywants?limit=50&user=Kirian_&sort=price,asc
|
|
45
45
|
const result = await DiscogsMarketplace.search({
|
|
46
46
|
limit: 50,
|
|
47
|
+
page: 1,
|
|
47
48
|
sort: 'Price Lowest',
|
|
48
49
|
searchType: 'user',
|
|
49
50
|
searchValue: 'Kirian_',
|
|
@@ -56,6 +57,7 @@ const result = await DiscogsMarketplace.search({
|
|
|
56
57
|
// https://www.discogs.com/sell/release/767931?sort=seller,asc&limit=25&page=1
|
|
57
58
|
const result = await DiscogsMarketplace.search({
|
|
58
59
|
sort: 'Seller A-Z',
|
|
60
|
+
page: 1,
|
|
59
61
|
searchType: 'release_id',
|
|
60
62
|
searchValue: '767931',
|
|
61
63
|
})
|
|
@@ -67,6 +69,7 @@ const result = await DiscogsMarketplace.search({
|
|
|
67
69
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=100&q=in+flames&page=1
|
|
68
70
|
const result = await DiscogsMarketplace.search({
|
|
69
71
|
limit: 100,
|
|
72
|
+
page: 1,
|
|
70
73
|
sort: 'Listed Newest',
|
|
71
74
|
searchType: 'q',
|
|
72
75
|
searchValue: 'in flames',
|
|
@@ -79,6 +82,7 @@ const result = await DiscogsMarketplace.search({
|
|
|
79
82
|
// https://www.discogs.com/seller/Kirian_/profile?sort=listed,desc&limit=25&page=1
|
|
80
83
|
const result = await DiscogsMarketplace.search({
|
|
81
84
|
sort: 'Listed Newest',
|
|
85
|
+
page: 1,
|
|
82
86
|
searchType: 'q',
|
|
83
87
|
searchValue: '',
|
|
84
88
|
seller: 'Kirian_',
|
|
@@ -91,6 +95,7 @@ const result = await DiscogsMarketplace.search({
|
|
|
91
95
|
// https://www.discogs.com/seller/Kirian_/mywants?sort=listed,desc&limit=25&user=Kirian_&page=1
|
|
92
96
|
const result = await DiscogsMarketplace.search({
|
|
93
97
|
sort: 'Listed Newest',
|
|
98
|
+
page: 1,
|
|
94
99
|
searchType: 'user',
|
|
95
100
|
searchValue: 'Kirian_',
|
|
96
101
|
seller: 'Kirian_',
|
|
@@ -119,7 +124,7 @@ type InputType = {
|
|
|
119
124
|
/**
|
|
120
125
|
* Value to search corresponding to searchType
|
|
121
126
|
*/
|
|
122
|
-
searchValue
|
|
127
|
+
searchValue?: string | number
|
|
123
128
|
/**
|
|
124
129
|
* Currency
|
|
125
130
|
*/
|
|
@@ -174,16 +179,18 @@ type InputType = {
|
|
|
174
179
|
*/
|
|
175
180
|
seller?: string
|
|
176
181
|
/**
|
|
177
|
-
* Sort elements by
|
|
182
|
+
* Sort elements by.
|
|
183
|
+
* Default to `Listed Newest`.
|
|
178
184
|
*/
|
|
179
185
|
sort?: SortType
|
|
180
186
|
/**
|
|
181
|
-
* Limit of elements to search (25 | 50 | 100 | 250)
|
|
187
|
+
* Limit of elements to search (25 | 50 | 100 | 250).
|
|
188
|
+
* Default to `25`.
|
|
182
189
|
*/
|
|
183
190
|
limit?: LimitType
|
|
184
191
|
/**
|
|
185
192
|
* Page (Must be < 401 or discogs will return an error 404).
|
|
186
|
-
* Default to `
|
|
193
|
+
* Default to `1`.
|
|
187
194
|
*/
|
|
188
195
|
page?: number
|
|
189
196
|
/**
|
|
@@ -275,7 +282,7 @@ type OutputErrorType = {
|
|
|
275
282
|
|
|
276
283
|
There is a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) on that project already configured, feel free to use it.
|
|
277
284
|
|
|
278
|
-
Install
|
|
285
|
+
Install dependencies with:
|
|
279
286
|
|
|
280
287
|
```sh
|
|
281
288
|
npm install
|
|
@@ -287,7 +294,7 @@ You can open a pull request with your new additions.
|
|
|
287
294
|
|
|
288
295
|
### Linkedom
|
|
289
296
|
|
|
290
|
-
If you are using this
|
|
297
|
+
If you are using this library on a Typescript project, you might encounter issues with `linkedom`.
|
|
291
298
|
|
|
292
299
|
To fix it, use this in command line: `--skipLibCheck` or add that in you `tsconfig.json`:
|
|
293
300
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { InputType, OutputErrorType, OutputSuccessType } from './types/commons/index.js';
|
|
2
1
|
import DiscogsMarketplace from './marketplace.js';
|
|
2
|
+
import type { InputType, OutputErrorType, OutputSuccessType } from './types/commons/index.js';
|
|
3
3
|
export { DiscogsMarketplace, InputType, OutputErrorType, OutputSuccessType };
|
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,6 +53,7 @@ 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
|
},
|
|
@@ -71,13 +72,13 @@ class Marketplace {
|
|
|
71
72
|
if ((response === null || response === void 0 ? void 0 : response.data) && response.status) {
|
|
72
73
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
73
74
|
throw {
|
|
74
|
-
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',
|
|
75
76
|
code: response.status,
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
79
80
|
throw {
|
|
80
|
-
message: message || 'An error
|
|
81
|
+
message: message || 'An error occurred',
|
|
81
82
|
code: 500,
|
|
82
83
|
};
|
|
83
84
|
}
|
|
@@ -195,6 +196,7 @@ class Marketplace {
|
|
|
195
196
|
url: `https://www.discogs.com${(_13 = el.querySelector('a.item_description_title')) === null || _13 === void 0 ? void 0 : _13.href}`,
|
|
196
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),
|
|
197
198
|
catnos: (_20 = (_19 = (_18 = (_17 = (_16 = el
|
|
199
|
+
// cspell: disable-next-line
|
|
198
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 : [],
|
|
199
201
|
imageUrl: (_22 = (_21 = el.querySelector('.marketplace_image')) === null || _21 === void 0 ? void 0 : _21.getAttribute('data-src')) !== null && _22 !== void 0 ? _22 : '',
|
|
200
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 : '',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type InputType from '../../types/commons/input.type.js';
|
|
2
2
|
import type OutputErrorType from '../../types/commons/output-error.type.js';
|
|
3
|
-
import type OutputSuccessType from '../../types/commons/output-
|
|
3
|
+
import type OutputSuccessType from '../../types/commons/output-success.type.js';
|
|
4
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;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.7.
|
|
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,7 +16,7 @@
|
|
|
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",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"eslint:fix": "eslint src test --ext .ts,.js --fix",
|
|
25
25
|
"eslint": "eslint src test --ext .ts,.js",
|
|
26
26
|
"prettier": "prettier --check .",
|
|
27
|
-
"prettier:fix": "prettier --write ."
|
|
27
|
+
"prettier:fix": "prettier --write .",
|
|
28
|
+
"cspell": "npx cspell ./ --no-progress"
|
|
28
29
|
},
|
|
29
30
|
"main": "dist/index.js",
|
|
30
31
|
"types": "dist/index.d.ts",
|
|
@@ -32,28 +33,32 @@
|
|
|
32
33
|
"node": ">=14.0.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"axios": "^1.
|
|
36
|
-
"linkedom": "^0.
|
|
37
|
-
"user-agents": "^1.
|
|
36
|
+
"axios": "^1.6.0",
|
|
37
|
+
"linkedom": "^0.16.1",
|
|
38
|
+
"user-agents": "^1.1.15"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@types/jest": "^29.5.
|
|
41
|
-
"@types/node": "^18.
|
|
42
|
-
"@types/user-agents": "^1.0.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
44
|
-
"@typescript-eslint/parser": "^
|
|
45
|
-
"
|
|
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",
|
|
46
48
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
47
|
-
"eslint-config-airbnb-typescript": "^17.
|
|
48
|
-
"eslint-config-prettier": "^
|
|
49
|
-
"eslint-
|
|
50
|
-
"eslint-plugin-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
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",
|
|
54
59
|
"ts-node": "^10.9.1",
|
|
55
|
-
"tsc-alias": "^1.8.
|
|
60
|
+
"tsc-alias": "^1.8.8",
|
|
56
61
|
"tsconfig-paths": "^4.2.0",
|
|
57
|
-
"typescript": "^5.
|
|
62
|
+
"typescript": "^5.2.2"
|
|
58
63
|
}
|
|
59
64
|
}
|
|
File without changes
|
|
File without changes
|