discogs-marketplace-api-nodejs 1.5.2 → 1.6.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.
Files changed (84) hide show
  1. package/README.MD +111 -97
  2. package/dist/data/countries.data.d.ts +306 -0
  3. package/dist/data/countries.data.js +327 -0
  4. package/dist/data/currencies.data.d.ts +33 -0
  5. package/dist/data/currencies.data.js +35 -0
  6. package/dist/data/index.d.ts +3 -0
  7. package/dist/data/index.js +10 -0
  8. package/dist/index.d.ts +2 -6
  9. package/dist/index.js +0 -12
  10. package/dist/marketplace.d.ts +2 -2
  11. package/dist/marketplace.js +16 -18
  12. package/dist/types/commons/index.d.ts +4 -0
  13. package/dist/types/commons/input.type.d.ts +95 -0
  14. package/dist/{interfaces/output-error.interface.d.ts → types/commons/output-error.type.d.ts} +3 -2
  15. package/dist/types/commons/output-sucess.type.d.ts +116 -0
  16. package/dist/types/unions/condition.type.d.ts +5 -0
  17. package/dist/types/unions/currency.type.d.ts +5 -0
  18. package/dist/types/unions/format-description.type.d.ts +5 -0
  19. package/dist/types/unions/format.type.d.ts +5 -0
  20. package/dist/types/unions/from.type.d.ts +5 -0
  21. package/dist/types/unions/from.type.js +2 -0
  22. package/dist/types/unions/genre.type.d.ts +5 -0
  23. package/dist/types/unions/genre.type.js +2 -0
  24. package/dist/types/unions/index.d.ts +12 -0
  25. package/dist/types/unions/index.js +2 -0
  26. package/dist/types/unions/lang.type.d.ts +5 -0
  27. package/dist/types/unions/lang.type.js +2 -0
  28. package/dist/types/{limit.type.d.ts → unions/limit.type.d.ts} +1 -1
  29. package/dist/types/unions/limit.type.js +2 -0
  30. package/dist/types/unions/search-type.type.d.ts +5 -0
  31. package/dist/types/unions/search-type.type.js +2 -0
  32. package/dist/types/unions/sort.type.d.ts +5 -0
  33. package/dist/types/unions/sort.type.js +2 -0
  34. package/dist/types/unions/style.type.d.ts +5 -0
  35. package/dist/types/unions/style.type.js +2 -0
  36. package/package.json +19 -16
  37. package/dist/enums/currency.enum.d.ts +0 -19
  38. package/dist/enums/currency.enum.js +0 -22
  39. package/dist/enums/format-description.enum.d.ts +0 -144
  40. package/dist/enums/format-description.enum.js +0 -147
  41. package/dist/enums/format.enum.d.ts +0 -59
  42. package/dist/enums/format.enum.js +0 -62
  43. package/dist/enums/from.enum.d.ts +0 -251
  44. package/dist/enums/from.enum.js +0 -254
  45. package/dist/enums/genre.enum.d.ts +0 -21
  46. package/dist/enums/genre.enum.js +0 -24
  47. package/dist/enums/index.d.ts +0 -11
  48. package/dist/enums/index.js +0 -26
  49. package/dist/enums/iso/country-code.enum.d.ts +0 -255
  50. package/dist/enums/iso/country-code.enum.js +0 -258
  51. package/dist/enums/iso/country-name.enum.d.ts +0 -255
  52. package/dist/enums/iso/country-name.enum.js +0 -258
  53. package/dist/enums/iso/index.d.ts +0 -3
  54. package/dist/enums/iso/index.js +0 -10
  55. package/dist/enums/iso/translate/discogs-country-name-to-iso-code.enum.d.ts +0 -69
  56. package/dist/enums/iso/translate/discogs-country-name-to-iso-code.enum.js +0 -72
  57. package/dist/enums/iso/translate/discogs-currency-to-iso-code.enum.d.ts +0 -36
  58. package/dist/enums/iso/translate/discogs-currency-to-iso-code.enum.js +0 -39
  59. package/dist/enums/iso/translate/index.d.ts +0 -3
  60. package/dist/enums/iso/translate/index.js +0 -10
  61. package/dist/enums/lang.enum.d.ts +0 -15
  62. package/dist/enums/lang.enum.js +0 -18
  63. package/dist/enums/media-condition.enum.d.ts +0 -14
  64. package/dist/enums/media-condition.enum.js +0 -17
  65. package/dist/enums/stort.enum.d.ts +0 -62
  66. package/dist/enums/stort.enum.js +0 -65
  67. package/dist/enums/style.enum.d.ts +0 -255
  68. package/dist/enums/style.enum.js +0 -258
  69. package/dist/enums/type.enum.d.ts +0 -30
  70. package/dist/enums/type.enum.js +0 -33
  71. package/dist/interfaces/index.d.ts +0 -6
  72. package/dist/interfaces/input.interface.d.ts +0 -80
  73. package/dist/interfaces/item.interface.d.ts +0 -89
  74. package/dist/interfaces/output-sucess.interface.d.ts +0 -32
  75. package/dist/interfaces/year.interface.d.ts +0 -9
  76. package/dist/types/index.d.ts +0 -2
  77. /package/dist/{interfaces → types/commons}/index.js +0 -0
  78. /package/dist/{interfaces/input.interface.js → types/commons/input.type.js} +0 -0
  79. /package/dist/{interfaces/item.interface.js → types/commons/output-error.type.js} +0 -0
  80. /package/dist/{interfaces/output-error.interface.js → types/commons/output-sucess.type.js} +0 -0
  81. /package/dist/{interfaces/output-sucess.interface.js → types/unions/condition.type.js} +0 -0
  82. /package/dist/{interfaces/year.interface.js → types/unions/currency.type.js} +0 -0
  83. /package/dist/types/{index.js → unions/format-description.type.js} +0 -0
  84. /package/dist/types/{limit.type.js → unions/format.type.js} +0 -0
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * ISO name
5
+ * {@link https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes}
6
+ */
7
+ const COUNTRIES_ISO = {
8
+ Afghanistan: 'AF',
9
+ 'Åland Islands': 'AX',
10
+ Albania: 'AL',
11
+ Algeria: 'DZ',
12
+ 'American Samoa': 'AS',
13
+ Andorra: 'AD',
14
+ Angola: 'AO',
15
+ Anguilla: 'AI',
16
+ Antarctica: 'AQ',
17
+ 'Antigua and Barbuda': 'AG',
18
+ Argentina: 'AR',
19
+ Armenia: 'AM',
20
+ Aruba: 'AW',
21
+ Australia: 'AU',
22
+ Austria: 'AT',
23
+ Azerbaijan: 'AZ',
24
+ Bahamas: 'BS',
25
+ Bahrain: 'BH',
26
+ Bangladesh: 'BD',
27
+ Barbados: 'BB',
28
+ Belarus: 'BY',
29
+ Belgium: 'BE',
30
+ Belize: 'BZ',
31
+ Benin: 'BJ',
32
+ Bermuda: 'BM',
33
+ Bhutan: 'BT',
34
+ 'Bolivia (Plurinational State of)': 'BO',
35
+ 'Bonaire, Sint Eustatius and Saba': 'BQ',
36
+ 'Bosnia and Herzegovina': 'BA',
37
+ Botswana: 'BW',
38
+ 'Bouvet Island': 'BV',
39
+ Brazil: 'BR',
40
+ 'British Indian Ocean Territory': 'IO',
41
+ 'Brunei Darussalam': 'BN',
42
+ Bulgaria: 'BG',
43
+ 'Burkina Faso': 'BF',
44
+ Burundi: 'BI',
45
+ 'Cabo Verde': 'CV',
46
+ Cambodia: 'KH',
47
+ Cameroon: 'CM',
48
+ Canada: 'CA',
49
+ 'Cayman Islands': 'KY',
50
+ 'Central African Republic': 'CF',
51
+ Chad: 'TD',
52
+ Chile: 'CL',
53
+ China: 'CN',
54
+ 'Christmas Island': 'CX',
55
+ 'Cocos (Keeling) Islands': 'CC',
56
+ Colombia: 'CO',
57
+ Comoros: 'KM',
58
+ Congo: 'CG',
59
+ 'Congo, Democratic Republic of the': 'CD',
60
+ 'Cook Islands': 'CK',
61
+ 'Costa Rica': 'CR',
62
+ "Côte d'Ivoire": 'CI',
63
+ Croatia: 'HR',
64
+ Cuba: 'CU',
65
+ Curaçao: 'CW',
66
+ Cyprus: 'CY',
67
+ Czechia: 'CZ',
68
+ Denmark: 'DK',
69
+ Djibouti: 'DJ',
70
+ Dominica: 'DM',
71
+ 'Dominican Republic': 'DO',
72
+ Ecuador: 'EC',
73
+ Egypt: 'EG',
74
+ 'El Salvador': 'SV',
75
+ 'Equatorial Guinea': 'GQ',
76
+ Eritrea: 'ER',
77
+ Estonia: 'EE',
78
+ Eswatini: 'SZ',
79
+ Ethiopia: 'ET',
80
+ 'Falkland Islands (Malvinas)': 'FK',
81
+ 'Faroe Islands': 'FO',
82
+ Fiji: 'FJ',
83
+ Finland: 'FI',
84
+ France: 'FR',
85
+ 'French Guiana': 'GF',
86
+ 'French Polynesia': 'PF',
87
+ 'French Southern Territories': 'TF',
88
+ Gabon: 'GA',
89
+ Gambia: 'GM',
90
+ Georgia: 'GE',
91
+ Germany: 'DE',
92
+ Ghana: 'GH',
93
+ Gibraltar: 'GI',
94
+ Greece: 'GR',
95
+ Greenland: 'GL',
96
+ Grenada: 'GD',
97
+ Guadeloupe: 'GP',
98
+ Guam: 'GU',
99
+ Guatemala: 'GT',
100
+ Guernsey: 'GG',
101
+ Guinea: 'GN',
102
+ 'Guinea-Bissau': 'GW',
103
+ Guyana: 'GY',
104
+ Haiti: 'HT',
105
+ 'Heard Island and McDonald Islands': 'HM',
106
+ 'Holy See': 'VA',
107
+ Honduras: 'HN',
108
+ 'Hong Kong': 'HK',
109
+ Hungary: 'HU',
110
+ Iceland: 'IS',
111
+ India: 'IN',
112
+ Indonesia: 'ID',
113
+ 'Iran (Islamic Republic of)': 'IR',
114
+ Iraq: 'IQ',
115
+ Ireland: 'IE',
116
+ 'Isle of Man': 'IM',
117
+ Israel: 'IL',
118
+ Italy: 'IT',
119
+ Jamaica: 'JM',
120
+ Japan: 'JP',
121
+ Jersey: 'JE',
122
+ Jordan: 'JO',
123
+ Kazakhstan: 'KZ',
124
+ Kenya: 'KE',
125
+ Kiribati: 'KI',
126
+ "Korea (Democratic People's Republic of)": 'KP',
127
+ 'Korea, Republic of': 'KR',
128
+ Kuwait: 'KW',
129
+ Kyrgyzstan: 'KG',
130
+ "Lao People's Democratic Republic": 'LA',
131
+ Latvia: 'LV',
132
+ Lebanon: 'LB',
133
+ Lesotho: 'LS',
134
+ Liberia: 'LR',
135
+ Libya: 'LY',
136
+ Liechtenstein: 'LI',
137
+ Lithuania: 'LT',
138
+ Luxembourg: 'LU',
139
+ Macao: 'MO',
140
+ Madagascar: 'MG',
141
+ Malawi: 'MW',
142
+ Malaysia: 'MY',
143
+ Maldives: 'MV',
144
+ Mali: 'ML',
145
+ Malta: 'MT',
146
+ 'Marshall Islands': 'MH',
147
+ Martinique: 'MQ',
148
+ Mauritania: 'MR',
149
+ Mauritius: 'MU',
150
+ Mayotte: 'YT',
151
+ Mexico: 'MX',
152
+ 'Micronesia (Federated States of)': 'FM',
153
+ 'Moldova, Republic of': 'MD',
154
+ Monaco: 'MC',
155
+ Mongolia: 'MN',
156
+ Montenegro: 'ME',
157
+ Montserrat: 'MS',
158
+ Morocco: 'MA',
159
+ Mozambique: 'MZ',
160
+ Myanmar: 'MM',
161
+ Namibia: 'NA',
162
+ Nauru: 'NR',
163
+ Nepal: 'NP',
164
+ Netherlands: 'NL',
165
+ 'New Caledonia': 'NC',
166
+ 'New Zealand': 'NZ',
167
+ Nicaragua: 'NI',
168
+ Niger: 'NE',
169
+ Nigeria: 'NG',
170
+ Niue: 'NU',
171
+ 'Norfolk Island': 'NF',
172
+ 'North Macedonia': 'MK',
173
+ 'Northern Mariana Islands': 'MP',
174
+ Norway: 'NO',
175
+ Oman: 'OM',
176
+ Pakistan: 'PK',
177
+ Palau: 'PW',
178
+ 'Palestine, State of': 'PS',
179
+ Panama: 'PA',
180
+ 'Papua New Guinea': 'PG',
181
+ Paraguay: 'PY',
182
+ Peru: 'PE',
183
+ Philippines: 'PH',
184
+ Pitcairn: 'PN',
185
+ Poland: 'PL',
186
+ Portugal: 'PT',
187
+ 'Puerto Rico': 'PR',
188
+ Qatar: 'QA',
189
+ Réunion: 'RE',
190
+ Romania: 'RO',
191
+ 'Russian Federation': 'RU',
192
+ Rwanda: 'RW',
193
+ 'Saint Barthélemy': 'BL',
194
+ 'Saint Helena, Ascension and Tristan da Cunha': 'SH',
195
+ 'Saint Kitts and Nevis': 'KN',
196
+ 'Saint Lucia': 'LC',
197
+ 'Saint Martin (French part)': 'MF',
198
+ 'Saint Pierre and Miquelon': 'PM',
199
+ 'Saint Vincent and the Grenadines': 'VC',
200
+ Samoa: 'WS',
201
+ 'San Marino': 'SM',
202
+ 'Sao Tome and Principe': 'ST',
203
+ 'Saudi Arabia': 'SA',
204
+ Senegal: 'SN',
205
+ Serbia: 'RS',
206
+ Seychelles: 'SC',
207
+ 'Sierra Leone': 'SL',
208
+ Singapore: 'SG',
209
+ 'Sint Maarten (Dutch part)': 'SX',
210
+ Slovakia: 'SK',
211
+ Slovenia: 'SI',
212
+ 'Solomon Islands': 'SB',
213
+ Somalia: 'SO',
214
+ 'South Africa': 'ZA',
215
+ 'South Georgia and the South Sandwich Islands': 'GS',
216
+ 'South Sudan': 'SS',
217
+ Spain: 'ES',
218
+ 'Sri Lanka': 'LK',
219
+ Sudan: 'SD',
220
+ Suriname: 'SR',
221
+ 'Svalbard and Jan Mayen': 'SJ',
222
+ Sweden: 'SE',
223
+ Switzerland: 'CH',
224
+ 'Syrian Arab Republic': 'SY',
225
+ 'Taiwan, Province of China': 'TW',
226
+ Tajikistan: 'TJ',
227
+ 'Tanzania, United Republic of': 'TZ',
228
+ Thailand: 'TH',
229
+ 'Timor-Leste': 'TL',
230
+ Togo: 'TG',
231
+ Tokelau: 'TK',
232
+ Tonga: 'TO',
233
+ 'Trinidad and Tobago': 'TT',
234
+ Tunisia: 'TN',
235
+ Turkey: 'TR',
236
+ Turkmenistan: 'TM',
237
+ 'Turks and Caicos Islands': 'TC',
238
+ Tuvalu: 'TV',
239
+ Uganda: 'UG',
240
+ Ukraine: 'UA',
241
+ 'United Arab Emirates': 'AE',
242
+ 'United Kingdom of Great Britain and Northern Ireland': 'GB',
243
+ 'United States of America': 'US',
244
+ 'United States Minor Outlying Islands': 'UM',
245
+ Uruguay: 'UY',
246
+ Uzbekistan: 'UZ',
247
+ Vanuatu: 'VU',
248
+ 'Venezuela (Bolivarian Republic of)': 'VE',
249
+ 'Viet Nam': 'VN',
250
+ 'Virgin Islands (British)': 'VG',
251
+ 'Virgin Islands (U.S.)': 'VI',
252
+ 'Wallis and Futuna': 'WF',
253
+ 'Western Sahara': 'EH',
254
+ Yemen: 'YE',
255
+ Zambia: 'ZM',
256
+ Zimbabwe: 'ZW',
257
+ };
258
+ /**
259
+ * Alternative names used on Discogs
260
+ * @example Get country that need to be translated
261
+ * // Got to https://www.discogs.com/settings/seller/
262
+ * // Take all the data before this comment, and past it in console as a const
263
+ * // Run in console top get enum:
264
+ * [...document.getElementById('seller-country').options]
265
+ * .map(x => x.value)
266
+ * .filter(x => x)
267
+ * .filter(x => !Object.keys(COUNTRIES_ISO).includes(x))
268
+ * .reduce((a,b) => ({ ...a, [b]: null }), {})
269
+ */
270
+ const COUNTRIES_DISCOGS = {
271
+ Azerbaidjan: 'AZ',
272
+ Bolivia: 'BO',
273
+ 'Bosnia-Herzegovina': 'BA',
274
+ 'Cape Verde': 'CV',
275
+ 'Czech Republic': 'CZ',
276
+ 'East Timor': 'TL',
277
+ 'Falkland Islands': 'FK',
278
+ 'Former Czechoslovakia': 'CZ',
279
+ 'Former USSR': 'RU',
280
+ 'France (European Territory)': 'FR',
281
+ 'French Guyana': 'GY',
282
+ 'Guadeloupe (French)': 'GP',
283
+ 'Guam (USA)': 'GU',
284
+ 'Guinea Bissau': 'GW',
285
+ 'Heard and McDonald Islands': 'HM',
286
+ Iran: 'IR',
287
+ "Ivory Coast (Cote D'Ivoire)": 'CI',
288
+ Laos: 'LA',
289
+ Macau: 'MO',
290
+ Macedonia: 'MK',
291
+ 'Martinique (French)': 'MQ',
292
+ Micronesia: 'FM',
293
+ 'Netherlands Antilles': 'CW',
294
+ 'Neutral Zone': '',
295
+ 'New Caledonia (French)': 'NC',
296
+ 'Pitcairn Island': 'PN',
297
+ 'Polynesia (French)': 'PF',
298
+ 'Reunion (French)': 'RE',
299
+ 'S. Georgia & S. Sandwich Isls.': 'GS',
300
+ 'Saint Helena': 'SH',
301
+ 'Saint Kitts & Nevis Anguilla': 'KN',
302
+ 'Saint Tome (Sao Tome) and Princi': 'ST',
303
+ 'Saint Vincent & Grenadines': 'VC',
304
+ 'Slovak Republic': 'SK',
305
+ 'South Korea': 'KR',
306
+ 'Spain (Canary Islands)': 'IC',
307
+ 'Svalbard and Jan Mayen Islands': 'SJ',
308
+ Swaziland: 'SZ',
309
+ Syria: 'SY',
310
+ Tadjikistan: 'TJ',
311
+ Taiwan: 'TW',
312
+ Tanzania: 'TZ',
313
+ 'United Kingdom': 'GB',
314
+ 'Northern Ireland': 'GB',
315
+ 'United Kingdom (Channel Islands)': '',
316
+ 'United States': 'US',
317
+ 'USA Minor Outlying Islands': 'UM',
318
+ 'Vatican City State': 'VA',
319
+ Venezuela: 'VE',
320
+ Vietnam: 'VN',
321
+ 'Virgin Islands (USA)': 'VI',
322
+ 'Wallis and Futuna Islands': 'WF',
323
+ Yugoslavia: 'GR',
324
+ Zaire: 'CD',
325
+ };
326
+ const COUNTRIES = Object.assign(Object.assign({}, COUNTRIES_ISO), COUNTRIES_DISCOGS);
327
+ exports.default = COUNTRIES;
@@ -0,0 +1,33 @@
1
+ declare const CURRENCIES: {
2
+ readonly $US: "USD";
3
+ readonly US$: "USD";
4
+ readonly USD: "USD";
5
+ readonly '\u00A3GB': "GBP";
6
+ readonly GBP: "GBP";
7
+ readonly $CA: "CAD";
8
+ readonly CA$: "CAD";
9
+ readonly CAD: "CAD";
10
+ readonly $AU: "AUD";
11
+ readonly AU$: "AUD";
12
+ readonly AUD: "AUD";
13
+ readonly JPY: "JPY";
14
+ readonly CHF: "CHF";
15
+ readonly MX$: "MXN";
16
+ readonly $MX: "MXN";
17
+ readonly MXN: "MXN";
18
+ readonly $NZ: "NZD";
19
+ readonly NZ$: "NZD";
20
+ readonly NZD: "NZD";
21
+ readonly SEK: "SEK";
22
+ readonly ZAR: "ZAR";
23
+ readonly BRL: "BRL";
24
+ readonly DKK: "DKK";
25
+ readonly A$: "AUD";
26
+ readonly R$: "BRL";
27
+ readonly EUR: "EUR";
28
+ readonly '\u20AC': "EUR";
29
+ readonly $: "USD";
30
+ readonly '\u00A3': "GBP";
31
+ readonly '\u00A5': "JPY";
32
+ };
33
+ export default CURRENCIES;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const CURRENCIES = {
4
+ $US: 'USD',
5
+ US$: 'USD',
6
+ USD: 'USD',
7
+ '£GB': 'GBP',
8
+ GBP: 'GBP',
9
+ $CA: 'CAD',
10
+ CA$: 'CAD',
11
+ CAD: 'CAD',
12
+ $AU: 'AUD',
13
+ AU$: 'AUD',
14
+ AUD: 'AUD',
15
+ JPY: 'JPY',
16
+ CHF: 'CHF',
17
+ MX$: 'MXN',
18
+ $MX: 'MXN',
19
+ MXN: 'MXN',
20
+ $NZ: 'NZD',
21
+ NZ$: 'NZD',
22
+ NZD: 'NZD',
23
+ SEK: 'SEK',
24
+ ZAR: 'ZAR',
25
+ BRL: 'BRL',
26
+ DKK: 'DKK',
27
+ A$: 'AUD',
28
+ R$: 'BRL',
29
+ EUR: 'EUR',
30
+ '€': 'EUR',
31
+ $: 'USD',
32
+ '£': 'GBP',
33
+ '¥': 'JPY',
34
+ };
35
+ exports.default = CURRENCIES;
@@ -0,0 +1,3 @@
1
+ import COUNTRIES from '../data/countries.data.js';
2
+ import CURRENCIES from '../data/currencies.data.js';
3
+ export { COUNTRIES, CURRENCIES, };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CURRENCIES = exports.COUNTRIES = void 0;
7
+ const countries_data_1 = __importDefault(require("../data/countries.data.js"));
8
+ exports.COUNTRIES = countries_data_1.default;
9
+ const currencies_data_1 = __importDefault(require("../data/currencies.data.js"));
10
+ exports.CURRENCIES = currencies_data_1.default;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- import { ECurrency, EFormat, EFormatDescription, EFrom, EGenre, ELang, EMediaCondition, ESort, EStyle, EType } from './enums/index.js';
2
- import { IYears, IInput, IOutputSuccess, IOutputError, IItem } from './interfaces/index.js';
3
- import { LimitType } from './types/index.js';
1
+ import { InputType, OutputErrorType, OutputSuccessType } from './types/commons/index.js';
4
2
  import DiscogsMarketplace from './marketplace.js';
5
- export { ECurrency, EFormat, EFormatDescription, EFrom, EGenre, ELang, EMediaCondition, ESort, EStyle, EType, };
6
- export { IInput, IItem, IOutputError, IOutputSuccess, IYears, };
7
- export { LimitType, };
3
+ export { InputType, OutputErrorType, OutputSuccessType, };
8
4
  export default DiscogsMarketplace;
package/dist/index.js CHANGED
@@ -3,17 +3,5 @@ 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.EType = exports.EStyle = exports.ESort = exports.EMediaCondition = exports.ELang = exports.EGenre = exports.EFrom = exports.EFormatDescription = exports.EFormat = exports.ECurrency = void 0;
7
- const enums_1 = require("./enums/index.js");
8
- Object.defineProperty(exports, "ECurrency", { enumerable: true, get: function () { return enums_1.ECurrency; } });
9
- Object.defineProperty(exports, "EFormat", { enumerable: true, get: function () { return enums_1.EFormat; } });
10
- Object.defineProperty(exports, "EFormatDescription", { enumerable: true, get: function () { return enums_1.EFormatDescription; } });
11
- Object.defineProperty(exports, "EFrom", { enumerable: true, get: function () { return enums_1.EFrom; } });
12
- Object.defineProperty(exports, "EGenre", { enumerable: true, get: function () { return enums_1.EGenre; } });
13
- Object.defineProperty(exports, "ELang", { enumerable: true, get: function () { return enums_1.ELang; } });
14
- Object.defineProperty(exports, "EMediaCondition", { enumerable: true, get: function () { return enums_1.EMediaCondition; } });
15
- Object.defineProperty(exports, "ESort", { enumerable: true, get: function () { return enums_1.ESort; } });
16
- Object.defineProperty(exports, "EStyle", { enumerable: true, get: function () { return enums_1.EStyle; } });
17
- Object.defineProperty(exports, "EType", { enumerable: true, get: function () { return enums_1.EType; } });
18
6
  const marketplace_1 = __importDefault(require("./marketplace.js"));
19
7
  exports.default = marketplace_1.default;
@@ -1,4 +1,4 @@
1
- import { IInput, IOutputSuccess } from './interfaces/index.js';
1
+ import type { InputType, OutputSuccessType } from './types/commons/index.js';
2
2
  /**
3
3
  * Discogs Marketplace
4
4
  */
@@ -7,7 +7,7 @@ export default abstract class Marketplace {
7
7
  * Search elements on discogs
8
8
  * @returns Items found
9
9
  */
10
- static search({ searchType, searchValue, currency, genre, style, format, formatDescription, mediaCondition, year, years, isAudioSample, isMakeAnOfferOnly, from, seller, sort, limit, page, lang, }: IInput): Promise<IOutputSuccess>;
10
+ static search({ searchType, searchValue, currency, genre, style, format, formatDescription, condition, year, years, isAudioSample, isMakeAnOfferOnly, from, seller, sort, limit, page, lang, }: InputType): Promise<OutputSuccessType>;
11
11
  /**
12
12
  * Generate URL to be parsed
13
13
  * @returns Url
@@ -12,11 +12,9 @@ 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");
15
16
  const user_agents_1 = __importDefault(require("user-agents"));
16
17
  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
18
  const axios_1 = __importDefault(require("axios"));
21
19
  /**
22
20
  * Discogs Marketplace
@@ -26,7 +24,7 @@ class Marketplace {
26
24
  * Search elements on discogs
27
25
  * @returns Items found
28
26
  */
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, }) {
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 = undefined, limit = 25, page = undefined, lang = 'en', }) {
30
28
  var _a, _b, _c, _d;
31
29
  return __awaiter(this, void 0, void 0, function* () {
32
30
  try {
@@ -40,7 +38,7 @@ class Marketplace {
40
38
  style: (style === null || style === void 0 ? void 0 : style.length) ? style : undefined,
41
39
  format: (format === null || format === void 0 ? void 0 : format.length) ? format : undefined,
42
40
  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,
41
+ condition: (condition === null || condition === void 0 ? void 0 : condition.length) ? condition : undefined,
44
42
  year: year && !years ? year : undefined,
45
43
  year1: (years === null || years === void 0 ? void 0 : years.min) && !year ? years === null || years === void 0 ? void 0 : years.min : undefined,
46
44
  year2: (years === null || years === void 0 ? void 0 : years.max) && !year ? years === null || years === void 0 ? void 0 : years.max : undefined,
@@ -51,7 +49,9 @@ class Marketplace {
51
49
  page,
52
50
  sort,
53
51
  },
54
- paramsSerializer: this.serializeParams,
52
+ paramsSerializer: {
53
+ serialize: this.serializeParams,
54
+ },
55
55
  headers: {
56
56
  'X-PJAX': 'true',
57
57
  'User-Agent': new user_agents_1.default().toString(),
@@ -87,11 +87,11 @@ class Marketplace {
87
87
  let url = `https://www.discogs.com/${lang}/`;
88
88
  if (seller) {
89
89
  url += `seller/${seller}/`;
90
- url += searchType === enums_1.EType.USER ? 'mywants' : 'profile';
90
+ url += searchType === 'user' ? 'mywants' : 'profile';
91
91
  }
92
92
  else {
93
93
  url += 'sell/';
94
- url += searchType === enums_1.EType.USER ? 'mywants' : 'list';
94
+ url += searchType === 'user' ? 'mywants' : 'list';
95
95
  }
96
96
  return url;
97
97
  }
@@ -130,14 +130,13 @@ class Marketplace {
130
130
  var _a;
131
131
  if (!value)
132
132
  return value;
133
- const currency = (_a = Object.keys(translate_1.EDiscogsCurrencyToIsoCode).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
134
- if (!currency)
133
+ const currencyFound = (_a = Object.keys(data_1.CURRENCIES).find(key => value.includes(key))) !== null && _a !== void 0 ? _a : '';
134
+ if (!currencyFound)
135
135
  return value;
136
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- const currencyClean = translate_1.EDiscogsCurrencyToIsoCode[currency];
136
+ const currencyClean = data_1.CURRENCIES[currencyFound];
138
137
  const amount = value
139
- .replace(currencyClean !== enums_1.ECurrency.JPY ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
140
- .replace(currency, '') // Remove original currency
138
+ .replace(currencyClean !== 'JPY' ? /[.](?=.*[.])/g : /\./g, '') // Remove all dot but last, except if JPY
139
+ .replace(currencyFound, '') // Remove original currency
141
140
  .replace(/\s/g, ''); // Remove spaces
142
141
  return `${amount} ${currencyClean}`
143
142
  .replace(/\s\s+/g, ' '); // Remove useless spaces
@@ -148,7 +147,7 @@ class Marketplace {
148
147
  * @param urlGenerated Url generated
149
148
  * @returns Items found
150
149
  */
151
- static getData(document, urlGenerated, { searchType = enums_1.EType.STRING, searchValue = undefined, limit = 25, page = 1, }) {
150
+ static getData(document, urlGenerated, { searchType = 'q', searchValue = undefined, limit = 25, page = 1, }) {
152
151
  var _a, _b, _c, _d, _e;
153
152
  const totalItems = parseFloat(
154
153
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -160,9 +159,8 @@ class Marketplace {
160
159
  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 : '');
161
160
  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);
162
161
  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);
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 : '';
164
- const countryCode = (Object.keys(iso_1.ECountryCode).find((key) => (iso_1.ECountryName[key] === countryName))
165
- || translate_1.EDiscogsCountryNameToIsoCode[countryName]);
162
+ 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
+ const countryCode = data_1.COUNTRIES[countryName];
166
164
  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);
167
165
  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);
168
166
  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);
@@ -0,0 +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-sucess.type.js';
4
+ export { InputType, OutputErrorType, OutputSuccessType, };
@@ -0,0 +1,95 @@
1
+ import type { LimitType, GenreType, CurrencyType, FromType, StyleType, FormatType, ConditionType, SortType, LangType, FormatDescriptionType, SearchTypeType } from '../../types/unions/index.js';
2
+ /**
3
+ * Element that can be provided by user
4
+ */
5
+ type InputType = {
6
+ /**
7
+ * Type of elements to search.
8
+ * Default to `q`.
9
+ * | Name | Description |
10
+ * |:---------: |:--------------------------:|
11
+ * | q | Basic query search |
12
+ * | master_id | Search in a master release |
13
+ * | release_id | Search in a release |
14
+ * | label_id | Search in a label |
15
+ * | artist_id | Search in a artist |
16
+ * | user | Search in user wantlist |
17
+ */
18
+ searchType: SearchTypeType;
19
+ /**
20
+ * Value to search corresponding to searchType
21
+ */
22
+ searchValue: string | number | undefined;
23
+ /**
24
+ * Currency
25
+ */
26
+ currency?: CurrencyType;
27
+ /**
28
+ * Genre
29
+ */
30
+ genre?: GenreType;
31
+ /**
32
+ * Styles
33
+ */
34
+ style?: StyleType[];
35
+ /**
36
+ * Formats
37
+ */
38
+ format?: FormatType[];
39
+ /**
40
+ * Format descriptions
41
+ */
42
+ formatDescription?: FormatDescriptionType[];
43
+ /**
44
+ * Media conditions
45
+ */
46
+ condition?: ConditionType[];
47
+ /**
48
+ * Year (Do not use it with `years`)
49
+ */
50
+ year?: number;
51
+ /**
52
+ * Interval of years (Do not use it with `year`)
53
+ */
54
+ years?: {
55
+ /** Min */
56
+ min: number;
57
+ /** Max */
58
+ max: number;
59
+ };
60
+ /**
61
+ * Is audio sample ?
62
+ */
63
+ isAudioSample?: boolean;
64
+ /**
65
+ * Is make an offer only ?
66
+ */
67
+ isMakeAnOfferOnly?: boolean;
68
+ /**
69
+ * Expedition country
70
+ */
71
+ from?: FromType;
72
+ /**
73
+ * Seller name
74
+ */
75
+ seller?: string;
76
+ /**
77
+ * Sort elements by
78
+ */
79
+ sort?: SortType;
80
+ /**
81
+ * Limit of elements to search (25 | 50 | 100 | 250)
82
+ */
83
+ limit?: LimitType;
84
+ /**
85
+ * Page (Must be < 401 or discogs will return an error 404).
86
+ * Default to `25`.
87
+ */
88
+ page?: number;
89
+ /**
90
+ * Lang to use for Discogs.
91
+ * Default to `en`.
92
+ */
93
+ lang?: LangType;
94
+ };
95
+ export default InputType;
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Result provided to user
3
3
  */
4
- export default interface IOutputError {
4
+ type OutputErrorType = {
5
5
  /** Message */
6
6
  message: string;
7
7
  /** Code */
8
8
  code: number;
9
- }
9
+ };
10
+ export default OutputErrorType;