discogs-marketplace-api-nodejs 1.3.9 → 1.4.0

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