discogs-marketplace-api-nodejs 1.17.1 → 1.18.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 CHANGED
@@ -1,11 +1,11 @@
1
- # 🎧 Discogs Marketplace API NodeJS
1
+ # Discogs Marketplace API NodeJS
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/discogs-marketplace-api-nodejs?logo=npm&color=CB3837)](https://www.npmjs.com/package/discogs-marketplace-api-nodejs) ![GitHub Repo stars](https://img.shields.io/github/stars/KirianCaumes/Discogs-Marketplace-API-NodeJS?style=flat&logo=github&label=Stars&color=%23181717) [![GitHub License](https://img.shields.io/github/license/KirianCaumes/Discogs-Marketplace-API-NodeJS?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI%2FPg0KPHN2ZyBmaWxsPSIjZmZmIiBhcmlhLWhpZGRlbj0idHJ1ZSIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIxNiIgZGF0YS12aWV3LWNvbXBvbmVudD0idHJ1ZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgPg0KICAgIDxwYXRoIGQ9Ik04Ljc1Ljc1VjJoLjk4NWMuMzA0IDAgLjYwMy4wOC44NjcuMjMxbDEuMjkuNzM2Yy4wMzguMDIyLjA4LjAzMy4xMjQuMDMzaDIuMjM0YS43NS43NSAwIDAgMSAwIDEuNWgtLjQyN2wyLjExMSA0LjY5MmEuNzUuNzUgMCAwIDEtLjE1NC44MzhsLS41My0uNTMuNTI5LjUzMS0uMDAxLjAwMi0uMDAyLjAwMi0uMDA2LjAwNi0uMDA2LjAwNS0uMDEuMDEtLjA0NS4wNGMtLjIxLjE3Ni0uNDQxLjMyNy0uNjg2LjQ1QzE0LjU1NiAxMC43OCAxMy44OCAxMSAxMyAxMWE0LjQ5OCA0LjQ5OCAwIDAgMS0yLjAyMy0uNDU0IDMuNTQ0IDMuNTQ0IDAgMCAxLS42ODYtLjQ1bC0uMDQ1LS4wNC0uMDE2LS4wMTUtLjAwNi0uMDA2LS4wMDQtLjAwNHYtLjAwMWEuNzUuNzUgMCAwIDEtLjE1NC0uODM4TDEyLjE3OCA0LjVoLS4xNjJjLS4zMDUgMC0uNjA0LS4wNzktLjg2OC0uMjMxbC0xLjI5LS43MzZhLjI0NS4yNDUgMCAwIDAtLjEyNC0uMDMzSDguNzVWMTNoMi41YS43NS43NSAwIDAgMSAwIDEuNWgtNi41YS43NS43NSAwIDAgMSAwLTEuNWgyLjVWMy41aC0uOTg0YS4yNDUuMjQ1IDAgMCAwLS4xMjQuMDMzbC0xLjI4OS43MzdjLS4yNjUuMTUtLjU2NC4yMy0uODY5LjIzaC0uMTYybDIuMTEyIDQuNjkyYS43NS43NSAwIDAgMS0uMTU0LjgzOGwtLjUzLS41My41MjkuNTMxLS4wMDEuMDAyLS4wMDIuMDAyLS4wMDYuMDA2LS4wMTYuMDE1LS4wNDUuMDRjLS4yMS4xNzYtLjQ0MS4zMjctLjY4Ni40NUM0LjU1NiAxMC43OCAzLjg4IDExIDMgMTFhNC40OTggNC40OTggMCAwIDEtMi4wMjMtLjQ1NCAzLjU0NCAzLjU0NCAwIDAgMS0uNjg2LS40NWwtLjA0NS0uMDQtLjAxNi0uMDE1LS4wMDYtLjAwNi0uMDA0LS4wMDR2LS4wMDFhLjc1Ljc1IDAgMCAxLS4xNTQtLjgzOEwyLjE3OCA0LjVIMS43NWEuNzUuNzUgMCAwIDEgMC0xLjVoMi4yMzRhLjI0OS4yNDkgMCAwIDAgLjEyNS0uMDMzbDEuMjg4LS43MzdjLjI2NS0uMTUuNTY0LS4yMy44NjktLjIzaC45ODRWLjc1YS43NS43NSAwIDAgMSAxLjUgMFptMi45NDUgOC40NzdjLjI4NS4xMzUuNzE4LjI3MyAxLjMwNS4yNzNzMS4wMi0uMTM4IDEuMzA1LS4yNzNMMTMgNi4zMjdabS0xMCAwYy4yODUuMTM1LjcxOC4yNzMgMS4zMDUuMjczczEuMDItLjEzOCAxLjMwNS0uMjczTDMgNi4zMjdaIj48L3BhdGg%2BDQo8L3N2Zz4%3D&logoColor=fff&label=License)](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/blob/master/LICENSE) [![Support this project](https://img.shields.io/badge/Support%20this%20project-003087?logo=PayPal&logoColor=fff)](https://www.paypal.me/KirianCaumes)
4
4
 
5
- A modern TypeScript/Node.js client for scraping and retrieving Discogs Marketplace listings — flexible, type safe, and easy to use. 💿
6
- > 💪 No Discogs API token required — this client scrapes public Marketplace data.
5
+ A modern TypeScript/Node.js client for scraping and retrieving Discogs Marketplace listings — flexible, type safe, and easy to use.
6
+ > No Discogs API token required — this client scrapes public Marketplace data.
7
7
 
8
- ## 🚀 Installation
8
+ ## Installation
9
9
 
10
10
  ```sh
11
11
  npm install discogs-marketplace-api-nodejs
@@ -15,18 +15,9 @@ npm install discogs-marketplace-api-nodejs
15
15
  ```
16
16
 
17
17
  The searches go through the API of the Discogs shop (`https://www.discogs.com/shop/list`), from a headless browser.
18
+ For many searches, or on a server, see [Browser](#browser).
18
19
 
19
- You can also pass your own [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright) browser as second parameter of `search`. You then manage its lifecycle.
20
-
21
- ```ts
22
- import { chromium } from 'patchright'
23
-
24
- const browser = await chromium.launch({ headless: true })
25
- const result = await DiscogsMarketplace.search({ artistIds: [244819] }, browser)
26
- await browser.close()
27
- ```
28
-
29
- ## ⚡ Quick Start
20
+ ## Quick Start
30
21
 
31
22
  ```ts
32
23
  import { DiscogsMarketplace } from 'discogs-marketplace-api-nodejs'
@@ -41,7 +32,7 @@ const result = await DiscogsMarketplace.search({
41
32
  console.log(result.items)
42
33
  ```
43
34
 
44
- ## 📚 Usage Examples
35
+ ## Usage Examples
45
36
 
46
37
  ### 1. Get 250 latest listings by a specific artist in the Rock genre, then the next 250
47
38
 
@@ -146,9 +137,61 @@ const result = await DiscogsMarketplace.search({
146
137
  })
147
138
  ```
148
139
 
149
- ## 🧩 API Reference
140
+ ## Browser
141
+
142
+ By default, each call launches a headless Chromium and closes it. Every search then starts without the clearance of
143
+ Cloudflare (`cf_clearance` cookie), and is blocked more often, especially from a datacenter IP.
144
+
145
+ For many searches, or on a server, pass your own [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright)
146
+ browser context as last parameter of `search` and `getWantlistReleaseIds`. It keeps the clearance from one search to
147
+ another, and you manage its lifecycle.
148
+
149
+ ```ts
150
+ import { chromium } from 'patchright'
151
+
152
+ const context = await chromium.launchPersistentContext('./profile', {
153
+ channel: 'chrome',
154
+ headless: false,
155
+ viewport: null,
156
+ args: ['--no-sandbox', '--disable-dev-shm-usage'],
157
+ })
158
+ const result = await DiscogsMarketplace.search({ artistIds: [244819] }, context)
159
+ await context.close()
160
+ ```
161
+
162
+ - **One context for the whole app**, not one per search, so that every search benefits from the clearance.
163
+ - **Real Chrome, headful** (`channel: 'chrome'`, `headless: false`): it passes Cloudflare far more often. Install it
164
+ with `npx patchright install --with-deps chrome`.
165
+ - **Persistent profile** (`'./profile'`), so the clearance survives restarts. After a crash, delete its `Singleton*`
166
+ files, or Chrome refuses to start.
167
+ - **Without GPU** (server, Docker), add `--disable-gpu --enable-unsafe-swiftshader` to `args`, so Chrome does not hang
168
+ and keeps WebGL.
169
+ - **`env`**: Chrome gets your whole environment, secrets included. Pass only what it needs (`PATH`, `HOME`, `DISPLAY`,
170
+ `XAUTHORITY`...), and its language with `LANG` rather than the `locale` option.
171
+ - **Still blocked?** The IP is the problem: go through a residential proxy (`proxy` option).
172
+
173
+ On a server, headful Chrome needs a display: run your app under Xvfb (`xvfb-run -a node index.js`). With Docker:
174
+
175
+ ```dockerfile
176
+ FROM node:24-slim
177
+
178
+ RUN apt-get update \
179
+ && apt-get install -y --no-install-recommends ca-certificates curl tini xauth xvfb \
180
+ && rm -rf /var/lib/apt/lists/*
181
+
182
+ WORKDIR /app
183
+ COPY package*.json ./
184
+ RUN npm ci && npx patchright install --with-deps chrome
185
+ COPY . .
186
+
187
+ # -g passes the stop signal to the app, which xvfb-run does not
188
+ ENTRYPOINT ["/usr/bin/tini", "-g", "--", "xvfb-run", "-a"]
189
+ CMD ["node", "index.js"]
190
+ ```
191
+
192
+ ## API Reference
150
193
 
151
- ### `DiscogsMarketplace.search(searchParams, browserInstance?)`
194
+ ### `DiscogsMarketplace.search(searchParams, browserContext?)`
152
195
 
153
196
  | Field | Type | Description | Example | Default |
154
197
  |-------------------------|-----------------------|------------------------------------------------|-----------------------------------|-----------------|
@@ -175,6 +218,7 @@ const result = await DiscogsMarketplace.search({
175
218
  | `hideGenericSleeves` | `boolean` | Hide generic sleeves. | – | `false` |
176
219
  | `hideSleevelessMedia` | `boolean` | Hide sleeveless media. | – | `false` |
177
220
  | `showUnavailable` | `boolean` | Show unavailable items. | – | `true` |
221
+ | `withCommunityStats` | `boolean` | Get `community` and `release.rating` (slower). | – | `true` |
178
222
  | `sort` | `Sort` | Sort and sort order (see below). | `'price,asc'` | `'listed,desc'` |
179
223
  | `limit` | `number` | Number of results per page (at most 250). | `100` | `25` |
180
224
  | `after` | `string` | Cursor of the page, from `nextCursor`. | – | – |
@@ -255,19 +299,19 @@ interface SearchResult {
255
299
  }
256
300
  ```
257
301
 
258
- ## 🛠️ Development & Contribution
302
+ ## Development & Contribution
259
303
 
260
304
  - Clone the repo and use the included devcontainer/VSCode setup.
261
305
  - Run: `npm install`
262
306
  - Add your contribution.
263
307
  - Use `npm test` to run unit tests.
264
- - Open a pull request with your new additions! 🎉
308
+ - Open a pull request with your new additions!
265
309
 
266
- ## 👉 Known Issues
310
+ ## Known Issues
267
311
 
268
312
  - Some search parameters might not be compatible with every type of queries.
269
313
  - For other edge cases, feel free to open an [issue on GitHub](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/issues).
270
314
 
271
- ## 📃 License
315
+ ## License
272
316
 
273
317
  Licensed under [MIT](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/blob/master/LICENSE).
@@ -131,6 +131,12 @@ export interface SearchParams {
131
131
  * @default true
132
132
  */
133
133
  showUnavailable?: boolean;
134
+ /**
135
+ * Get the community stats of the releases (`community` and `release.rating`), at the cost of a second request.
136
+ * If false, `community` is 0 and `release.rating` is null.
137
+ * @default true
138
+ */
139
+ withCommunityStats?: boolean;
134
140
  /**
135
141
  * Sort order for the results.
136
142
  * @default 'listed,desc'
@@ -1,10 +1,10 @@
1
- import type { Browser, BrowserContext } from 'patchright';
1
+ import type { BrowserContext } from 'patchright';
2
2
  /**
3
- * Run a function in a headless browser context suited to call Discogs, closing what it opened afterwards.
3
+ * Run a function in a browser context suited to call Discogs, closing what it opened afterwards.
4
4
  * It looks like a regular Chrome with JavaScript enabled, which Cloudflare lets through more often than the User-Agent
5
5
  * of the Discogs apps without JavaScript, especially from datacenter IPs.
6
- * @param browserInstance Browser to use, launched and closed here when not provided
6
+ * @param browserContext Browser context to use as is, launched and closed here when not provided
7
7
  * @param fn Function to run
8
8
  * @returns Result of the function
9
9
  */
10
- export default function withBrowserContext<T>(browserInstance: Browser | undefined, fn: (browserContext: BrowserContext) => Promise<T>): Promise<T>;
10
+ export default function withBrowserContext<T>(browserContext: BrowserContext | undefined, fn: (browserContext: BrowserContext) => Promise<T>): Promise<T>;
@@ -23,27 +23,22 @@ async function getChromeIdentity(browser) {
23
23
  }
24
24
  }
25
25
  /**
26
- * Run a function in a headless browser context suited to call Discogs, closing what it opened afterwards.
26
+ * Run a function in a browser context suited to call Discogs, closing what it opened afterwards.
27
27
  * It looks like a regular Chrome with JavaScript enabled, which Cloudflare lets through more often than the User-Agent
28
28
  * of the Discogs apps without JavaScript, especially from datacenter IPs.
29
- * @param browserInstance Browser to use, launched and closed here when not provided
29
+ * @param browserContext Browser context to use as is, launched and closed here when not provided
30
30
  * @param fn Function to run
31
31
  * @returns Result of the function
32
32
  */
33
- async function withBrowserContext(browserInstance, fn) {
34
- const browser = browserInstance ?? (await patchright_1.chromium.launch({ headless: true, chromiumSandbox: false }));
33
+ async function withBrowserContext(browserContext, fn) {
34
+ if (browserContext) {
35
+ return fn(browserContext);
36
+ }
37
+ const browser = await patchright_1.chromium.launch({ headless: true, chromiumSandbox: false });
35
38
  try {
36
- const browserContext = await browser.newContext(await getChromeIdentity(browser));
37
- try {
38
- return await fn(browserContext);
39
- }
40
- finally {
41
- await browserContext.close();
42
- }
39
+ return await fn(await browser.newContext(await getChromeIdentity(browser)));
43
40
  }
44
41
  finally {
45
- if (!browserInstance) {
46
- await browser.close();
47
- }
42
+ await browser.close();
48
43
  }
49
44
  }
@@ -7,4 +7,4 @@ import type { BrowserContext } from 'patchright';
7
7
  * @param browserContext Patchright browser context
8
8
  * @returns Items found, total, next cursor and url of the same search on Discogs
9
9
  */
10
- export default function scrapeMarketplace({ query, artistIds, labelIds, masterIds, releaseIds, sellerIds, genres, styles, formats, formatDescriptions, mediaConditions, sleeveConditions, from, currencies, priceRange, sellerRatingMin, sellerRatingCountMin, years, isMakeAnOfferOnly, hasItemPhotos, hideGenericSleeves, hideSleevelessMedia, showUnavailable, sort, limit, after, }: SearchParams, browserContext: BrowserContext): Promise<SearchResult>;
10
+ export default function scrapeMarketplace({ query, artistIds, labelIds, masterIds, releaseIds, sellerIds, genres, styles, formats, formatDescriptions, mediaConditions, sleeveConditions, from, currencies, priceRange, sellerRatingMin, sellerRatingCountMin, years, isMakeAnOfferOnly, hasItemPhotos, hideGenericSleeves, hideSleevelessMedia, showUnavailable, withCommunityStats, sort, limit, after, }: SearchParams, browserContext: BrowserContext): Promise<SearchResult>;
@@ -49,6 +49,19 @@ const CONDITIONS = {
49
49
  NOT_GRADED: 'Not Graded',
50
50
  NO_COVER: 'No Cover',
51
51
  };
52
+ /**
53
+ * Get a new clearance of Cloudflare (`cf_clearance` cookie), the page staying on the Discogs origin
54
+ * @param page Page
55
+ */
56
+ async function renewClearance(page) {
57
+ const hasClearance = async () => (await page.context().cookies('https://www.discogs.com')).some(x => x.name === 'cf_clearance');
58
+ // Only an HTML page gets it, without one already, sometimes after its load
59
+ await page.context().clearCookies({ name: 'cf_clearance', domain: '.discogs.com' });
60
+ await page.goto('https://www.discogs.com/shop/list', { waitUntil: 'commit' });
61
+ for (let i = 0; i < 100 && !(await hasClearance()); i++) {
62
+ await page.waitForTimeout(100);
63
+ }
64
+ }
52
65
  /**
53
66
  * Run a GraphQL query of the Discogs shop from the page, which must be on the Discogs origin.
54
67
  * @param page Page
@@ -57,11 +70,12 @@ const CONDITIONS = {
57
70
  * @returns Response
58
71
  */
59
72
  async function queryGraphql(page, operationName, variables) {
60
- const { status, cfMitigated, cfRay, json } = await page.evaluate(async (body) => {
73
+ const run = () => page.evaluate(async (body) => {
61
74
  const res = await fetch('/graphql', {
62
75
  method: 'POST',
63
76
  headers: { 'Content-Type': 'application/json' },
64
77
  body: JSON.stringify(body),
78
+ signal: AbortSignal.timeout(30_000),
65
79
  });
66
80
  return {
67
81
  status: res.status,
@@ -70,6 +84,13 @@ async function queryGraphql(page, operationName, variables) {
70
84
  json: (await res.json().catch(() => null)),
71
85
  };
72
86
  }, { operationName, variables, extensions: { persistedQuery: { version: 1, sha256Hash: HASHES[operationName] } } });
87
+ let response = await run();
88
+ // Without a clearance of Cloudflare, or a refused one (new IP…)
89
+ if (response.cfMitigated) {
90
+ await renewClearance(page);
91
+ response = await run();
92
+ }
93
+ const { status, cfMitigated, cfRay, json } = response;
73
94
  const result = json;
74
95
  if (cfMitigated) {
75
96
  throw new Error(`An error ${status} occurred: blocked by Cloudflare (${cfMitigated}, cf-ray ${cfRay ?? '?'}).`);
@@ -119,7 +140,7 @@ function decodeHtmlEntities(text) {
119
140
  * @param browserContext Patchright browser context
120
141
  * @returns Items found, total, next cursor and url of the same search on Discogs
121
142
  */
122
- async function scrapeMarketplace({ query, artistIds, labelIds, masterIds, releaseIds, sellerIds, genres, styles, formats, formatDescriptions, mediaConditions, sleeveConditions, from, currencies, priceRange, sellerRatingMin, sellerRatingCountMin, years, isMakeAnOfferOnly = false, hasItemPhotos = false, hideGenericSleeves = false, hideSleevelessMedia = false, showUnavailable = true, sort = 'listed,desc', limit = 25, after, }, browserContext) {
143
+ async function scrapeMarketplace({ query, artistIds, labelIds, masterIds, releaseIds, sellerIds, genres, styles, formats, formatDescriptions, mediaConditions, sleeveConditions, from, currencies, priceRange, sellerRatingMin, sellerRatingCountMin, years, isMakeAnOfferOnly = false, hasItemPhotos = false, hideGenericSleeves = false, hideSleevelessMedia = false, showUnavailable = true, withCommunityStats = true, sort = 'listed,desc', limit = 25, after, }, browserContext) {
123
144
  const [sortField = 'listed', sortOrder = 'desc'] = sort.split(',');
124
145
  const countries = from?.flatMap(code => {
125
146
  const names = Object.keys(country_data_1.default).filter(key => code === country_data_1.default[key]);
@@ -210,10 +231,10 @@ async function scrapeMarketplace({ query, artistIds, labelIds, masterIds, releas
210
231
  after,
211
232
  })).data?.marketplaceSearch;
212
233
  const nodes = result?.edges?.map(x => x.node ?? {}) ?? [];
213
- const releaseIdsFound = [...new Set(nodes.map(x => x.release?.discogsId ?? 0).filter(x => !!x))];
234
+ // The community stats and the rating of the releases are not part of the listings
235
+ const releaseIdsFound = withCommunityStats ? [...new Set(nodes.map(x => x.release?.discogsId ?? 0).filter(x => !!x))] : [];
214
236
  const { data: details } = releaseIdsFound.length
215
- ? // The community stats and the rating of the releases are not part of the listings
216
- await queryGraphql(browserPage, 'Releases', { discogsIds: releaseIdsFound, first: 1 })
237
+ ? await queryGraphql(browserPage, 'Releases', { discogsIds: releaseIdsFound, first: 1 })
217
238
  : { data: undefined };
218
239
  const releaseDetails = new Map(details?.releases?.map(x => [x?.discogsId ?? 0, x]) ?? []);
219
240
  const items = nodes.map(node => {
package/dist/search.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { SearchParams } from './interfaces/search-params.interface.js';
2
2
  import type SearchResult from './interfaces/search-result.interface.js';
3
- import type { Browser } from 'patchright';
3
+ import type { BrowserContext } from 'patchright';
4
4
  /**
5
5
  * Performs a search on the Discogs marketplace using the provided parameters.
6
6
  * @param searchParams - The search parameters, including query, pagination, and filters.
7
- * @param browserInstance - Optional Patchright browser instance. If provided, you must manage its lifecycle.
7
+ * @param browserContext - Optional Patchright browser context, which keeps the clearance of Cloudflare from one search to another.
8
+ * If provided, you must manage its lifecycle.
8
9
  * @returns A promise that resolves to the search results, including items, total, next cursor and the generated URL.
9
10
  */
10
- export default function search(searchParams: SearchParams, browserInstance?: Browser): Promise<SearchResult>;
11
+ export default function search(searchParams: SearchParams, browserContext?: BrowserContext): Promise<SearchResult>;
package/dist/search.js CHANGED
@@ -11,12 +11,13 @@ const MAX_RELEASE_IDS = 2000;
11
11
  /**
12
12
  * Performs a search on the Discogs marketplace using the provided parameters.
13
13
  * @param searchParams - The search parameters, including query, pagination, and filters.
14
- * @param browserInstance - Optional Patchright browser instance. If provided, you must manage its lifecycle.
14
+ * @param browserContext - Optional Patchright browser context, which keeps the clearance of Cloudflare from one search to another.
15
+ * If provided, you must manage its lifecycle.
15
16
  * @returns A promise that resolves to the search results, including items, total, next cursor and the generated URL.
16
17
  */
17
- async function search(searchParams, browserInstance) {
18
+ async function search(searchParams, browserContext) {
18
19
  if ((searchParams.releaseIds?.length ?? 0) > MAX_RELEASE_IDS) {
19
20
  throw new Error(`At most ${MAX_RELEASE_IDS} release IDs are supported.`);
20
21
  }
21
- return (0, browser_context_1.default)(browserInstance, browserContext => (0, marketplace_scraper_1.default)(searchParams, browserContext));
22
+ return (0, browser_context_1.default)(browserContext, x => (0, marketplace_scraper_1.default)(searchParams, x));
22
23
  }
@@ -1,4 +1,4 @@
1
- import type { Browser } from 'patchright';
1
+ import type { BrowserContext } from 'patchright';
2
2
  /**
3
3
  * Options to get the releases of a wantlist: either from the Discogs API, possibly with a token, or only the ones for sale
4
4
  */
@@ -22,7 +22,7 @@ export type WantlistOptions = {
22
22
  * By default, it reads the public Discogs API (limited to 25 requests per minute without token, 60 with).
23
23
  * @param username - Username whose wantlist is read.
24
24
  * @param options - Options.
25
- * @param browserInstance - Optional Patchright browser instance, only used with `onlyForSale`. If provided, you must manage its lifecycle.
25
+ * @param browserContext - Optional Patchright browser context, only used with `onlyForSale`. If provided, you must manage its lifecycle.
26
26
  * @returns A promise that resolves to the release IDs.
27
27
  */
28
- export default function getWantlistReleaseIds(username: string, { token, onlyForSale }?: WantlistOptions, browserInstance?: Browser): Promise<Array<number>>;
28
+ export default function getWantlistReleaseIds(username: string, { token, onlyForSale }?: WantlistOptions, browserContext?: BrowserContext): Promise<Array<number>>;
package/dist/wantlist.js CHANGED
@@ -32,6 +32,7 @@ function fetchWantlist(username, token) {
32
32
  page: pageNumber.toString(),
33
33
  per_page: API_PER_PAGE.toString(),
34
34
  }).toString()}`, {
35
+ signal: AbortSignal.timeout(30_000),
35
36
  headers: {
36
37
  'User-Agent': `DiscogsMarketplaceApiNodeJS-${username}`,
37
38
  ...(token ? { Authorization: `Discogs token=${token}` } : {}),
@@ -94,12 +95,12 @@ function scrapeWantlist(username, browserContext) {
94
95
  * By default, it reads the public Discogs API (limited to 25 requests per minute without token, 60 with).
95
96
  * @param username - Username whose wantlist is read.
96
97
  * @param options - Options.
97
- * @param browserInstance - Optional Patchright browser instance, only used with `onlyForSale`. If provided, you must manage its lifecycle.
98
+ * @param browserContext - Optional Patchright browser context, only used with `onlyForSale`. If provided, you must manage its lifecycle.
98
99
  * @returns A promise that resolves to the release IDs.
99
100
  */
100
- async function getWantlistReleaseIds(username, { token, onlyForSale = false } = {}, browserInstance) {
101
+ async function getWantlistReleaseIds(username, { token, onlyForSale = false } = {}, browserContext) {
101
102
  if (onlyForSale) {
102
- return (0, browser_context_1.default)(browserInstance, browserContext => scrapeWantlist(username, browserContext));
103
+ return (0, browser_context_1.default)(browserContext, x => scrapeWantlist(username, x));
103
104
  }
104
105
  return fetchWantlist(username, token);
105
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discogs-marketplace-api-nodejs",
3
- "version": "1.17.1",
3
+ "version": "1.18.1",
4
4
  "description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
5
5
  "keywords": [
6
6
  "discogs",
@@ -40,28 +40,28 @@
40
40
  }
41
41
  ],
42
42
  "dependencies": {
43
- "patchright": "^1.63.0"
43
+ "patchright": "^1.64.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@eslint/js": "^9.39.5",
47
- "@types/node": "^24.13.6",
48
- "@typescript-eslint/eslint-plugin": "^8.70.0",
49
- "@typescript-eslint/parser": "^8.70.0",
50
- "cspell": "^10.3.3",
47
+ "@types/node": "^24.19.2",
48
+ "@typescript-eslint/eslint-plugin": "^8.72.1",
49
+ "@typescript-eslint/parser": "^8.72.1",
50
+ "cspell": "^10.4.0",
51
51
  "eslint": "^9.39.5",
52
52
  "eslint-config-prettier": "^10.1.8",
53
53
  "eslint-import-resolver-typescript": "^4.4.5",
54
54
  "eslint-plugin-import": "^2.32.0",
55
- "eslint-plugin-jsdoc": "^64.5.4",
56
- "globals": "^17.12.0",
55
+ "eslint-plugin-jsdoc": "^65.4.2",
56
+ "globals": "^17.13.0",
57
57
  "husky": "^9.1.7",
58
- "knip": "^6.37.0",
59
- "lint-staged": "^17.5.1",
60
- "prettier": "^3.9.8",
58
+ "knip": "^6.43.0",
59
+ "lint-staged": "^17.6.0",
60
+ "prettier": "^3.9.10",
61
61
  "rimraf": "^6.1.3",
62
- "tsc-alias": "^1.9.5",
62
+ "tsc-alias": "^1.9.9",
63
63
  "tsx": "^4.23.15",
64
64
  "typescript": "^6.0.3",
65
- "typescript-eslint": "^8.70.0"
65
+ "typescript-eslint": "^8.72.1"
66
66
  }
67
67
  }