discogs-marketplace-api-nodejs 1.16.9 → 1.17.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 (46) hide show
  1. package/README.MD +111 -151
  2. package/dist/data/country.data.d.ts +1 -1
  3. package/dist/data/style.data.d.ts +763 -0
  4. package/dist/data/style.data.js +765 -0
  5. package/dist/index.d.ts +4 -1
  6. package/dist/index.js +2 -1
  7. package/dist/interfaces/api/marketplace-search-result.api.interface.d.ts +148 -0
  8. package/dist/interfaces/api/{shop-details-result.api.interface.d.ts → releases-result.api.interface.d.ts} +4 -1
  9. package/dist/interfaces/api/wantlist-result.api.interface.d.ts +109 -0
  10. package/dist/interfaces/search-params.interface.d.ts +76 -156
  11. package/dist/interfaces/search-result.interface.d.ts +21 -19
  12. package/dist/scrapers/browser-context.d.ts +10 -0
  13. package/dist/scrapers/browser-context.js +49 -0
  14. package/dist/scrapers/marketplace.scraper.d.ts +10 -0
  15. package/dist/scrapers/marketplace.scraper.js +300 -0
  16. package/dist/search.d.ts +4 -7
  17. package/dist/search.js +10 -57
  18. package/dist/types/condition.type.d.ts +4 -0
  19. package/dist/types/currency.type.d.ts +1 -1
  20. package/dist/types/format-description.type.d.ts +1 -1
  21. package/dist/types/sort.type.d.ts +1 -1
  22. package/dist/types/style.type.d.ts +2 -1
  23. package/dist/wantlist.d.ts +28 -0
  24. package/dist/wantlist.js +105 -0
  25. package/package.json +14 -16
  26. package/dist/data/currency.data.d.ts +0 -36
  27. package/dist/data/currency.data.js +0 -35
  28. package/dist/interfaces/api/shop-result-error.api.interface.d.ts +0 -8
  29. package/dist/interfaces/api/shop-result.api.interface.d.ts +0 -111
  30. package/dist/scrapers/extractors/legacy.extractor.d.ts +0 -11
  31. package/dist/scrapers/extractors/legacy.extractor.js +0 -138
  32. package/dist/scrapers/legacy.scraper.d.ts +0 -13
  33. package/dist/scrapers/legacy.scraper.js +0 -75
  34. package/dist/scrapers/modern.scraper.d.ts +0 -13
  35. package/dist/scrapers/modern.scraper.js +0 -199
  36. package/dist/scrapers/wantlist.scraper.d.ts +0 -13
  37. package/dist/scrapers/wantlist.scraper.js +0 -66
  38. package/dist/types/api.type.d.ts +0 -4
  39. package/dist/types/api.type.js +0 -2
  40. package/dist/types/lang.type.d.ts +0 -4
  41. package/dist/types/lang.type.js +0 -2
  42. package/dist/types/limit.type.d.ts +0 -4
  43. package/dist/types/limit.type.js +0 -2
  44. /package/dist/interfaces/api/{shop-details-result.api.interface.js → marketplace-search-result.api.interface.js} +0 -0
  45. /package/dist/interfaces/api/{shop-result-error.api.interface.js → releases-result.api.interface.js} +0 -0
  46. /package/dist/interfaces/api/{shop-result.api.interface.js → wantlist-result.api.interface.js} +0 -0
@@ -0,0 +1,10 @@
1
+ import type { Browser, BrowserContext } from 'patchright';
2
+ /**
3
+ * Run a function in a headless browser context suited to call Discogs, closing what it opened afterwards.
4
+ * It looks like a regular Chrome with JavaScript enabled, which Cloudflare lets through more often than the User-Agent
5
+ * of the Discogs apps without JavaScript, especially from datacenter IPs.
6
+ * @param browserInstance Browser to use, launched and closed here when not provided
7
+ * @param fn Function to run
8
+ * @returns Result of the function
9
+ */
10
+ export default function withBrowserContext<T>(browserInstance: Browser | undefined, fn: (browserContext: BrowserContext) => Promise<T>): Promise<T>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = withBrowserContext;
4
+ const patchright_1 = require("patchright");
5
+ /**
6
+ * Get the browser options of a regular Chrome of the same version as the browser, as its default User-Agent and
7
+ * `sec-ch-ua` header give away the headless mode ("HeadlessChrome").
8
+ * @param browser Browser
9
+ * @returns User-Agent, in the reduced form of Chrome ("Chrome/153.0.0.0"), and `sec-ch-ua` header
10
+ */
11
+ async function getChromeIdentity(browser) {
12
+ const session = await browser.newBrowserCDPSession();
13
+ try {
14
+ const { userAgent } = await session.send('Browser.getVersion');
15
+ const [major] = browser.version().split('.');
16
+ return {
17
+ userAgent: userAgent.replace(/HeadlessChrome\/[\d.]+/, `Chrome/${major ?? ''}.0.0.0`),
18
+ extraHTTPHeaders: { 'sec-ch-ua': `"Google Chrome";v="${major ?? ''}", "Not_A Brand";v="8", "Chromium";v="${major ?? ''}"` },
19
+ };
20
+ }
21
+ finally {
22
+ await session.detach();
23
+ }
24
+ }
25
+ /**
26
+ * Run a function in a headless browser context suited to call Discogs, closing what it opened afterwards.
27
+ * It looks like a regular Chrome with JavaScript enabled, which Cloudflare lets through more often than the User-Agent
28
+ * of the Discogs apps without JavaScript, especially from datacenter IPs.
29
+ * @param browserInstance Browser to use, launched and closed here when not provided
30
+ * @param fn Function to run
31
+ * @returns Result of the function
32
+ */
33
+ async function withBrowserContext(browserInstance, fn) {
34
+ const browser = browserInstance ?? (await patchright_1.chromium.launch({ headless: true, chromiumSandbox: false }));
35
+ 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
+ }
43
+ }
44
+ finally {
45
+ if (!browserInstance) {
46
+ await browser.close();
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,10 @@
1
+ import type { SearchParams } from '../interfaces/search-params.interface.js';
2
+ import type SearchResult from '../interfaces/search-result.interface.js';
3
+ import type { BrowserContext } from 'patchright';
4
+ /**
5
+ * Searches the listings through the `MarketplaceSearch` GraphQL query of the Discogs shop.
6
+ * @param searchParams Search parameters
7
+ * @param browserContext Patchright browser context
8
+ * @returns Items found, total, next cursor and url of the same search on Discogs
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>;
@@ -0,0 +1,300 @@
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.default = scrapeMarketplace;
7
+ const country_data_1 = __importDefault(require("../data/country.data.js"));
8
+ const style_data_1 = __importDefault(require("../data/style.data.js"));
9
+ /** Hashes of the persisted GraphQL queries of the Discogs shop */
10
+ const HASHES = {
11
+ MarketplaceSearch: '7ce2bd7801f216b0999648d626c935fc86c8fd85e562529bd87b690c974f08c2',
12
+ Releases: 'ee9d48441023ebd1e6ca169e550581b45de216e88b40711acb6617e49e1bb0cb',
13
+ };
14
+ /** Sort dimensions of the Discogs shop */
15
+ const SORT_DIMENSIONS = {
16
+ listed: 'LISTED_DATE',
17
+ condition: 'MEDIA_CONDITION',
18
+ sleeveCondition: 'SLEEVE_CONDITION',
19
+ artist: 'ARTIST',
20
+ title: 'TITLE',
21
+ year: 'YEAR',
22
+ releaseCountry: 'COUNTRY',
23
+ seller: 'SELLER',
24
+ sellerRating: 'SELLER_RATING',
25
+ sellerRatingCount: 'SELLER_RATING_COUNT',
26
+ shipsFrom: 'SHIPS_FROM',
27
+ price: 'PRICE',
28
+ };
29
+ /** Sort slugs of the Discogs shop url, which does not offer every sort of its API */
30
+ const SORT_SLUGS = {
31
+ listed: 'date-listed',
32
+ condition: 'media-condition',
33
+ artist: 'artist',
34
+ title: 'title',
35
+ seller: 'seller',
36
+ price: 'price',
37
+ };
38
+ /** Conditions as returned by the API, to the labels used everywhere else */
39
+ const CONDITIONS = {
40
+ MINT: 'Mint (M)',
41
+ NEAR_MINT: 'Near Mint (NM or M-)',
42
+ VERY_GOOD_PLUS: 'Very Good Plus (VG+)',
43
+ VERY_GOOD: 'Very Good (VG)',
44
+ GOOD_PLUS: 'Good Plus (G+)',
45
+ GOOD: 'Good (G)',
46
+ FAIR: 'Fair (F)',
47
+ POOR: 'Poor (P)',
48
+ GENERIC: 'Generic',
49
+ NOT_GRADED: 'Not Graded',
50
+ NO_COVER: 'No Cover',
51
+ };
52
+ /**
53
+ * Run a GraphQL query of the Discogs shop from the page, which must be on the Discogs origin.
54
+ * @param page Page
55
+ * @param operationName Name of the persisted query
56
+ * @param variables Variables
57
+ * @returns Response
58
+ */
59
+ async function queryGraphql(page, operationName, variables) {
60
+ const { status, cfMitigated, cfRay, json } = await page.evaluate(async (body) => {
61
+ const res = await fetch('/graphql', {
62
+ method: 'POST',
63
+ headers: { 'Content-Type': 'application/json' },
64
+ body: JSON.stringify(body),
65
+ });
66
+ return {
67
+ status: res.status,
68
+ cfMitigated: res.headers.get('cf-mitigated'),
69
+ cfRay: res.headers.get('cf-ray'),
70
+ json: (await res.json().catch(() => null)),
71
+ };
72
+ }, { operationName, variables, extensions: { persistedQuery: { version: 1, sha256Hash: HASHES[operationName] } } });
73
+ const result = json;
74
+ if (cfMitigated) {
75
+ throw new Error(`An error ${status} occurred: blocked by Cloudflare (${cfMitigated}, cf-ray ${cfRay ?? '?'}).`);
76
+ }
77
+ if (!result?.data) {
78
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
79
+ throw new Error(result?.errors?.map(x => x.message).join(', ') || `An error ${status} occurred.`);
80
+ }
81
+ return result;
82
+ }
83
+ /**
84
+ * Format a price as a string combining amount and currency
85
+ * @param price Price
86
+ * @param price.amount Amount
87
+ * @param price.currency Currency
88
+ * @returns Price
89
+ */
90
+ function formatPrice(price) {
91
+ return `${price?.currency === 'JPY' ? (price.amount ?? 0) : (price?.amount ?? 0).toFixed(2)} ${price?.currency ?? ''}`;
92
+ }
93
+ /**
94
+ * Get a condition from the value returned by the API
95
+ * @param value Value
96
+ * @returns Condition
97
+ */
98
+ function toCondition(value) {
99
+ const full = value ? (CONDITIONS[value] ?? value) : null;
100
+ return { full, short: /\(([^)]+)\)/.exec(full ?? '')?.[1] ?? null };
101
+ }
102
+ /** HTML entities the notes of the sellers can hold, besides the numeric ones */
103
+ const HTML_ENTITIES = { quot: '"', apos: "'", lt: '<', gt: '>', nbsp: '\u00a0' }; // cspell: disable-line
104
+ /**
105
+ * Decode the HTML entities of a text, as the notes of the sellers come HTML escaped
106
+ * @param text Text
107
+ * @returns Decoded text
108
+ */
109
+ function decodeHtmlEntities(text) {
110
+ return text
111
+ .replace(/&#(\d+);/g, (_, code) => String.fromCodePoint(Number(code)))
112
+ .replace(/&#x([\da-f]+);/gi, (_, code) => String.fromCodePoint(parseInt(code, 16)))
113
+ .replace(new RegExp(`&(${Object.keys(HTML_ENTITIES).join('|')});`, 'g'), (_, name) => HTML_ENTITIES[name] ?? '')
114
+ .replace(/&amp;/g, '&');
115
+ }
116
+ /**
117
+ * Searches the listings through the `MarketplaceSearch` GraphQL query of the Discogs shop.
118
+ * @param searchParams Search parameters
119
+ * @param browserContext Patchright browser context
120
+ * @returns Items found, total, next cursor and url of the same search on Discogs
121
+ */
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) {
123
+ const [sortField = 'listed', sortOrder = 'desc'] = sort.split(',');
124
+ const countries = from?.flatMap(code => {
125
+ const names = Object.keys(country_data_1.default).filter(key => code === country_data_1.default[key]);
126
+ return names.length ? names : [code];
127
+ });
128
+ const styleIds = styles?.flatMap(name => {
129
+ const ids = style_data_1.default[name];
130
+ return ids ? [ids] : [];
131
+ }) ?? [];
132
+ /** Url of the same search on the Discogs shop */
133
+ const urlGenerated = [
134
+ 'https://www.discogs.com/shop/list',
135
+ new URLSearchParams([
136
+ ['q', query ?? ''],
137
+ ...(artistIds?.map(x => ['artist', x.toString()]) ?? []),
138
+ ...(labelIds?.map(x => ['label', x.toString()]) ?? []),
139
+ ...(masterIds?.map(x => ['master', x.toString()]) ?? []),
140
+ ...(releaseIds?.map(x => ['release', x.toString()]) ?? []),
141
+ ...(sellerIds?.map(x => ['seller', x.toString()]) ?? []),
142
+ ...(genres?.map(x => ['genre', x]) ?? []),
143
+ ...(styles?.map(x => ['style', x]) ?? []),
144
+ ...(formats?.map(x => ['formatName', x]) ?? []),
145
+ ...(formatDescriptions?.map(x => ['formatDescription', x]) ?? []),
146
+ ...(mediaConditions?.map(x => ['mediaCondition', x]) ?? []),
147
+ ...(sleeveConditions?.map(x => ['sleeveCondition', x]) ?? []),
148
+ ...(countries?.map(x => ['shipsFrom', x]) ?? []),
149
+ ['priceMin', priceRange?.min.toString() ?? ''],
150
+ ['priceMax', priceRange?.max.toString() ?? ''],
151
+ ['year', years?.min.toString() ?? ''],
152
+ ['year', years?.max.toString() ?? ''],
153
+ ['allowsOffers', isMakeAnOfferOnly ? 'true' : ''],
154
+ ['hasItemPhotos', hasItemPhotos ? 'true' : ''],
155
+ ['hideGenericSleeves', hideGenericSleeves ? 'true' : ''],
156
+ ['hideSleevelessMedia', hideSleevelessMedia ? 'true' : ''],
157
+ ['showUnavailable', showUnavailable ? 'true' : ''],
158
+ ...(SORT_SLUGS[sortField]
159
+ ? [
160
+ ['sort', SORT_SLUGS[sortField]],
161
+ ['sortOrder', sortOrder === 'asc' ? 'ascending' : 'descending'],
162
+ ]
163
+ : []),
164
+ ['size', limit.toString()],
165
+ ['after', after ?? ''],
166
+ ].filter(([, x]) => !!x)).toString(),
167
+ ].join('?');
168
+ const browserPage = await browserContext.newPage();
169
+ try {
170
+ // The API can only be called from the Discogs origin: go there through its lightest page
171
+ await browserPage.goto('https://www.discogs.com/robots.txt', { waitUntil: 'commit' });
172
+ const filter = Object.fromEntries(Object.entries({
173
+ artist: artistIds,
174
+ label: labelIds,
175
+ master: masterIds,
176
+ release: releaseIds,
177
+ seller: sellerIds,
178
+ genre: genres,
179
+ genreAnd: genres?.length ? true : undefined,
180
+ styleId: styleIds.length ? [...new Set(styleIds.flat())] : undefined,
181
+ styleIdAnd: styleIds.length ? styleIds.every(x => x.length === 1) : undefined,
182
+ formatName: formats,
183
+ formatNameAnd: formats?.length ? true : undefined,
184
+ formatDescription: formatDescriptions,
185
+ formatDescriptionAnd: formatDescriptions?.length ? true : undefined,
186
+ mediaCondition: mediaConditions,
187
+ sleeveCondition: sleeveConditions,
188
+ shipsFrom: countries,
189
+ currency: currencies,
190
+ sellerRatingMin,
191
+ sellerRatingCountMin,
192
+ priceRangeLow: priceRange?.min,
193
+ priceRangeHigh: priceRange?.max,
194
+ yearRangeLow: years?.min,
195
+ yearRangeHigh: years?.max,
196
+ allowsOffers: isMakeAnOfferOnly || undefined,
197
+ hasInventoryImages: hasItemPhotos || undefined,
198
+ hideGenericSleeves: hideGenericSleeves || undefined,
199
+ hideSleevelessMedia: hideSleevelessMedia || undefined,
200
+ showUnavailable: showUnavailable || undefined,
201
+ }).filter(([, x]) => x !== undefined && !(Array.isArray(x) && !x.length)));
202
+ const result = (await queryGraphql(browserPage, 'MarketplaceSearch', {
203
+ query: query || undefined, // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
204
+ filter: Object.keys(filter).length ? filter : undefined,
205
+ sort: {
206
+ dimension: SORT_DIMENSIONS[sortField] ?? SORT_DIMENSIONS.listed,
207
+ direction: sortOrder === 'asc' ? 'ASCENDING' : 'DESCENDING',
208
+ },
209
+ first: limit,
210
+ after,
211
+ })).data?.marketplaceSearch;
212
+ const nodes = result?.edges?.map(x => x.node ?? {}) ?? [];
213
+ const releaseIdsFound = [...new Set(nodes.map(x => x.release?.discogsId ?? 0).filter(x => !!x))];
214
+ 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 })
217
+ : { data: undefined };
218
+ const releaseDetails = new Map(details?.releases?.map(x => [x?.discogsId ?? 0, x]) ?? []);
219
+ const items = nodes.map(node => {
220
+ const release = node.release ?? {};
221
+ const artists = release.primaryArtists ?? [];
222
+ const labels = (release.labels ?? []).filter(x => x.labelRole === 'LABEL');
223
+ const description = release.formatSummary?.description;
224
+ const media = toCondition(node.mediaCondition);
225
+ const releaseDetail = releaseDetails.get(release.discogsId ?? 0);
226
+ const year = Number(release.released?.slice(0, 4));
227
+ return {
228
+ id: Number(node.id),
229
+ title: `${artists.map(x => x.displayName ?? '').join(', ')} - ${release.title ?? ''} (${release.formatSummary?.primaryFormat ?? ''})`,
230
+ artists: artists.map(x => ({
231
+ id: x.artist?.discogsId ?? null,
232
+ name: x.displayName ?? '',
233
+ url: x.artist?.discogsId ? `https://www.discogs.com/artist/${x.artist.discogsId}` : null,
234
+ })),
235
+ release: {
236
+ id: release.discogsId ?? 0,
237
+ name: release.title ?? '',
238
+ url: `https://www.discogs.com/release/${release.discogsId ?? 0}`,
239
+ year: year || null,
240
+ country: release.country ?? null,
241
+ rating: releaseDetail?.ratings?.averageRating || null, // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
242
+ },
243
+ formats: [
244
+ ...new Set([
245
+ release.formatSummary?.primaryFormat,
246
+ ...(release.formatSummary?.recordingTypes ?? []),
247
+ ...(Array.isArray(description) ? description : (description?.split(', ') ?? [])),
248
+ ].filter((x) => !!x)),
249
+ ],
250
+ labels: labels.map(x => ({
251
+ id: x.label?.discogsId ?? 0,
252
+ name: x.label?.name ?? '',
253
+ url: `https://www.discogs.com/label/${x.label?.discogsId ?? 0}`,
254
+ })),
255
+ url: `https://www.discogs.com/shop/item/${node.id ?? ''}`,
256
+ listedAt: node.listedDate ? new Date(node.listedDate) : null,
257
+ catnos: labels.map(x => x.catalogNumber ?? '').filter(x => !!x),
258
+ imageUrl: release.images?.edges?.[0]?.node?.thumbnail?.webpUrl ?? null,
259
+ photos: [...(node.itemPhotos ?? [])].sort((a, b) => (a.position ?? 0) - (b.position ?? 0)).map(x => x.url ?? ''),
260
+ description: node.publicNotes ? decodeHtmlEntities(node.publicNotes) : null,
261
+ isAcceptingOffer: node.offerOk ?? false,
262
+ isAvailable: node.availability?.isAvailable ?? true,
263
+ condition: {
264
+ media: { full: media.full ?? '', short: media.short ?? '' },
265
+ sleeve: toCondition(node.sleeveCondition),
266
+ },
267
+ seller: {
268
+ id: node.seller?.discogsId ?? 0,
269
+ name: node.seller?.username ?? '',
270
+ url: `https://www.discogs.com/seller/${node.seller?.username ?? ''}/profile`,
271
+ score: node.sellerInfo?.rating ? `${node.sellerInfo.rating.toFixed(1)}%` : null,
272
+ notes: node.sellerInfo?.ratingCount ?? null,
273
+ isIndependent: node.sellerInfo?.independentSeller ?? false,
274
+ },
275
+ price: {
276
+ base: formatPrice(node.price),
277
+ shipping: node.shipping?.price ? formatPrice(node.shipping.price) : null,
278
+ },
279
+ country: {
280
+ name: node.sellerInfo?.shipsFrom ?? '',
281
+ code: country_data_1.default[node.sellerInfo?.shipsFrom],
282
+ },
283
+ community: {
284
+ have: releaseDetail?.inCollectionCount ?? 0,
285
+ want: releaseDetail?.inWantlistCount ?? 0,
286
+ },
287
+ };
288
+ });
289
+ return {
290
+ items,
291
+ total: result?.totalCount ?? 0,
292
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
293
+ nextCursor: (result?.pageInfo?.hasNextPage && result.pageInfo.endCursor) || null,
294
+ urlGenerated,
295
+ };
296
+ }
297
+ finally {
298
+ await browserPage.close();
299
+ }
300
+ }
package/dist/search.d.ts CHANGED
@@ -1,13 +1,10 @@
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 'playwright-chromium';
4
- export declare const DEFAULT_LIMIT = 25;
5
- export declare const DEFAULT_PAGE = 1;
6
- export declare const DEFAULT_SORT = "listed,desc";
3
+ import type { Browser } from 'patchright';
7
4
  /**
8
5
  * Performs a search on the Discogs marketplace using the provided parameters.
9
- * @param searchParams - The search parameters, including API type, query, pagination, and filters.
10
- * @param browserInstance - Optional Playwright browser instance. If provided, you must manage its lifecycle.
11
- * @returns A promise that resolves to the search results, including items, pagination info, and the generated URL.
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.
8
+ * @returns A promise that resolves to the search results, including items, total, next cursor and the generated URL.
12
9
  */
13
10
  export default function search(searchParams: SearchParams, browserInstance?: Browser): Promise<SearchResult>;
package/dist/search.js CHANGED
@@ -3,67 +3,20 @@ 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.DEFAULT_SORT = exports.DEFAULT_PAGE = exports.DEFAULT_LIMIT = void 0;
7
6
  exports.default = search;
8
- const playwright_extra_1 = require("playwright-extra");
9
- const puppeteer_extra_plugin_stealth_1 = __importDefault(require("puppeteer-extra-plugin-stealth"));
10
- const legacy_scraper_1 = __importDefault(require("./scrapers/legacy.scraper.js"));
11
- const wantlist_scraper_1 = __importDefault(require("./scrapers/wantlist.scraper.js"));
12
- const modern_scraper_1 = __importDefault(require("./scrapers/modern.scraper.js"));
13
- exports.DEFAULT_LIMIT = 25;
14
- exports.DEFAULT_PAGE = 1;
15
- exports.DEFAULT_SORT = 'listed,desc';
7
+ const browser_context_1 = __importDefault(require("./scrapers/browser-context.js"));
8
+ const marketplace_scraper_1 = __importDefault(require("./scrapers/marketplace.scraper.js"));
9
+ /** Release IDs a single search can filter on at most */
10
+ const MAX_RELEASE_IDS = 2000;
16
11
  /**
17
12
  * Performs a search on the Discogs marketplace using the provided parameters.
18
- * @param searchParams - The search parameters, including API type, query, pagination, and filters.
19
- * @param browserInstance - Optional Playwright browser instance. If provided, you must manage its lifecycle.
20
- * @returns A promise that resolves to the search results, including items, pagination info, and the generated URL.
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.
15
+ * @returns A promise that resolves to the search results, including items, total, next cursor and the generated URL.
21
16
  */
22
17
  async function search(searchParams, browserInstance) {
23
- const browser = browserInstance ??
24
- (await (() => {
25
- playwright_extra_1.chromium.use((0, puppeteer_extra_plugin_stealth_1.default)());
26
- return playwright_extra_1.chromium.launch({
27
- headless: true,
28
- chromiumSandbox: false,
29
- args: ['--no-sandbox', '--disable-setuid-sandbox'],
30
- });
31
- })());
32
- const browserContext = await browser.newContext({
33
- javaScriptEnabled: false,
34
- extraHTTPHeaders: searchParams.api === 'legacy' && !(searchParams.seller && searchParams.user)
35
- ? {
36
- 'X-PJAX': 'true',
37
- }
38
- : undefined,
39
- });
40
- try {
41
- const { items, total, urlGenerated } = await (() => {
42
- if (searchParams.api === 'v2' && searchParams.wantlist) {
43
- return (0, wantlist_scraper_1.default)(searchParams, browserContext);
44
- }
45
- if (searchParams.api === 'v2') {
46
- return (0, modern_scraper_1.default)(searchParams, browserContext);
47
- }
48
- return (0, legacy_scraper_1.default)(searchParams, browserContext);
49
- })();
50
- return {
51
- items,
52
- result: {
53
- total,
54
- perPage: searchParams.limit ?? exports.DEFAULT_LIMIT,
55
- },
56
- page: {
57
- current: searchParams.page ?? exports.DEFAULT_PAGE,
58
- total: Math.ceil(total / (searchParams.limit ?? exports.DEFAULT_LIMIT)),
59
- },
60
- urlGenerated,
61
- };
62
- }
63
- finally {
64
- await browserContext.close();
65
- if (!browserInstance) {
66
- await browser.close();
67
- }
18
+ if ((searchParams.releaseIds?.length ?? 0) > MAX_RELEASE_IDS) {
19
+ throw new Error(`At most ${MAX_RELEASE_IDS} release IDs are supported.`);
68
20
  }
21
+ return (0, browser_context_1.default)(browserInstance, browserContext => (0, marketplace_scraper_1.default)(searchParams, browserContext));
69
22
  }
@@ -2,3 +2,7 @@
2
2
  * Conditions
3
3
  */
4
4
  export type Condition = '0' | 'Fair (F)' | 'Good (G)' | 'Good Plus (G+)' | 'Mint (M)' | 'Near Mint (NM or M-)' | 'Poor (P)' | 'Very Good (VG)' | 'Very Good Plus (VG+)' | ({} & string);
5
+ /**
6
+ * Sleeve conditions
7
+ */
8
+ export type SleeveCondition = Condition | 'Generic' | 'No Cover' | 'Not Graded';
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Currencies
2
+ * Currencies of the Discogs marketplace
3
3
  */
4
4
  export type Currency = 'AUD' | 'BRL' | 'CAD' | 'CHF' | 'DKK' | 'EUR' | 'GBP' | 'JPY' | 'MXN' | 'NZD' | 'SEK' | 'USD' | 'ZAR' | ({} & string);
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * FormatDescriptions
3
3
  */
4
- export type FormatDescription = '1 ⅞ ips' | '1"' | '10"' | '10.5" NAB Reel' | '11"' | '12"' | '15 ips' | '15/16 ips' | '16 ⅔ RPM' | '16"' | '16mm' | '2 Minute' | '2"' | '2-Track Mono' | '2-Track Stereo' | '21cm' | '25cm' | '27cm' | '29cm' | '3 Minute' | '3 ¾ ips' | '3"' | '3" Cine Reel' | '3.5"' | '30 ips' | '33 ⅓ RPM' | '35cm' | '35mm' | '3½"' | '4 Minute' | '4"' | '4-Track Mono' | '4-Track Stereo' | '45 RPM' | '4K' | '5"' | '5" Cine Reel' | '5.25"' | '50cm' | '5½"' | '6"' | '6" Cine Reel' | '6½"' | '7 ½ ips' | '7"' | '7" Cine Reel' | '78 RPM' | '8 ⅓ RPM' | '8"' | '80 RPM' | '8K' | '9"' | '90 RPM' | 'AAC' | 'AIFC' | 'AIFF' | 'ALAC' | 'AMR' | 'APE' | 'AVCD' | 'AVI' | 'Advance' | 'Album' | 'Ambisonic' | 'Bioplastic' | 'Blu-ray Audio' | 'Business Card' | 'CD+G' | 'CD-ROM' | 'CD-Record' | 'CDi' | 'Card Backed' | 'Club Edition' | 'Compilation' | 'Concert' | 'Copy Protected' | 'DFF' | 'DSF' | 'DVD-Audio' | 'DVD-Data' | 'DVD-Video' | 'DVDplus' | 'Deluxe Edition' | 'Disc Image' | 'Double Sided' | 'DualDisc' | 'EP' | 'Enhanced' | 'Etched' | 'FLAC' | 'FLV' | 'HDCD' | 'Hybrid' | 'Jukebox' | 'LP' | 'Limited Edition' | 'MOV' | 'MP2' | 'MP3' | 'MP3 Surround' | 'MPEG Video' | 'MPEG-4 Video' | 'Maxi-Single' | 'Mini' | 'Mini-Album' | 'Minimax' | 'Mispress' | 'Misprint' | 'Mixed' | 'Mixtape' | 'Mono' | 'Multichannel' | 'NTSC' | 'Numbered' | 'Opus' | 'PAL' | 'Partially Mixed' | 'Partially Unofficial' | 'Picture Disc' | 'Promo' | 'Quadraphonic' | 'RA' | 'RM' | 'Reissue' | 'Remastered' | 'Repress' | 'SECAM' | 'SHN' | 'SVCD' | 'SWF' | 'Salon' | 'Sampler' | 'Shape' | 'Single' | 'Single Sided' | 'Special Edition' | 'Stereo' | 'Styrene' | 'TTA' | 'Test Pressing' | 'Transcription' | 'Unofficial Release' | 'VCD' | 'VinylDisc' | 'WAV' | 'WMA' | 'WMV' | 'WavPack' | 'White Label' | 'XRCD' | 'ogg-vorbis' | '¼"' | '½"' | '⅛"' | ({} & string);
4
+ export type FormatDescription = '1 ⅞ ips' | '1"' | '10"' | '10.5" NAB Reel' | '11"' | '12"' | '15 ips' | '15/16 ips' | '16 ⅔ RPM' | '16"' | '16mm' | '2 Minute' | '2"' | '2-Track Mono' | '2-Track Stereo' | '21cm' | '25cm' | '27cm' | '29cm' | '3 Minute' | '3 ¾ ips' | '3"' | '3" Cine Reel' | '3.5"' | '30 ips' | '33 ⅓ RPM' | '35cm' | '35mm' | '3½"' | '4 Minute' | '4"' | '4-Track Mono' | '4-Track Stereo' | '45 RPM' | '4K' | '5"' | '5" Cine Reel' | '5.25"' | '50cm' | '5½"' | '6"' | '6" Cine Reel' | '6½"' | '7 ½ ips' | '7"' | '7" Cine Reel' | '78 RPM' | '8 ⅓ RPM' | '8"' | '80 RPM' | '8K' | '9"' | '90 RPM' | 'AAC' | 'AIFC' | 'AIFF' | 'ALAC' | 'AMR' | 'APE' | 'AVCD' | 'AVI' | 'Advance' | 'Album' | 'Ambisonic' | 'Bioplastic' | 'Blu-ray Audio' | 'Business Card' | 'CD+G' | 'CD-ROM' | 'CD-Record' | 'CDi' | 'Card Backed' | 'Club Edition' | 'Compilation' | 'Concert' | 'Copy Protected' | 'DFF' | 'DSF' | 'DVD-Audio' | 'DVD-Data' | 'DVD-Video' | 'DVDplus' | 'Deluxe Edition' | 'Disc Image' | 'Double Sided' | 'DualDisc' | 'EP' | 'Enhanced' | 'Etched' | 'FLAC' | 'FLV' | 'HDCD' | 'Hybrid' | 'Jukebox' | 'LP' | 'Limited Edition' | 'MOV' | 'MP2' | 'MP3' | 'MP3 Surround' | 'MPEG Video' | 'MPEG-4 Video' | 'Maxi-Single' | 'Mini' | 'Mini-Album' | 'Minimax' | 'Mispress' | 'Misprint' | 'Mixed' | 'Mixtape' | 'Mono' | 'Multichannel' | 'NTSC' | 'Numbered' | 'Opus' | 'PAL' | 'Partially Mixed' | 'Partially Unofficial' | 'Picture Disc' | 'Promo' | 'Quadraphonic' | 'RA' | 'RM' | 'Record Store Day' | 'Reissue' | 'Remastered' | 'Repress' | 'SECAM' | 'SHN' | 'SVCD' | 'SWF' | 'Salon' | 'Sampler' | 'Shape' | 'Single' | 'Single Sided' | 'Special Cut' | 'Special Edition' | 'Stereo' | 'Styrene' | 'TTA' | 'Test Pressing' | 'Tour Recording' | 'Transcription' | 'Unofficial Release' | 'VCD' | 'VinylDisc' | 'WAV' | 'WMA' | 'WMV' | 'WavPack' | 'White Label' | 'XRCD' | 'ogg-vorbis' | '¼"' | '½"' | '⅛"' | ({} & string);
@@ -1,4 +1,4 @@
1
- type SortField = 'listed' | 'condition' | 'artist' | 'title' | 'label' | 'seller' | 'price';
1
+ type SortField = 'listed' | 'condition' | 'sleeveCondition' | 'artist' | 'title' | 'year' | 'releaseCountry' | 'seller' | 'sellerRating' | 'sellerRatingCount' | 'shipsFrom' | 'price';
2
2
  type SortDirection = 'asc' | 'desc';
3
3
  /**
4
4
  * Sorts
@@ -1,4 +1,5 @@
1
+ import type { StyleKeys } from '../data/style.data.js';
1
2
  /**
2
3
  * Styles
3
4
  */
4
- export type Style = 'AOR' | 'Aboriginal' | 'Abstract' | 'Acid' | 'Acid House' | 'Acid Jazz' | 'Acid Rock' | 'Acoustic' | 'African' | 'Afro-Cuban' | 'Afro-Cuban Jazz' | 'Afrobeat' | 'Aguinaldo' | 'Alternative Rock' | 'Ambient' | 'Andalusian Classical' | 'Andean Music' | 'Appalachian Music' | 'Arena Rock' | 'Art Rock' | 'Atmospheric Black Metal' | 'Audiobook' | 'Avant-garde Jazz' | 'Avantgarde' | 'Axé' | 'Azonto' | 'Bachata' | 'Baião' | 'Balearic' | 'Ballad' | 'Ballroom' | 'Baltimore Club' | 'Bambuco' | 'Bangladeshi Classical' | 'Barbershop' | 'Baroque' | 'Baroque Pop' | 'Basque Music' | 'Bass Music' | 'Bassline' | 'Batucada' | 'Bayou Funk' | 'Beat' | 'Beatbox' | 'Beatdown' | 'Beguine' | 'Bengali Music' | 'Berlin-School' | 'Bhangra' | 'Big Band' | 'Big Beat' | 'Black Metal' | 'Bleep' | 'Bluegrass' | 'Blues Rock' | 'Bolero' | 'Bollywood' | 'Bomba' | 'Bongo Flava' | 'Boogaloo' | 'Boogie' | 'Boogie Woogie' | 'Boom Bap' | 'Bop' | 'Bossa Nova' | 'Bossanova' | 'Bounce' | 'Brass Band' | 'Break-In' | 'Breakbeat' | 'Breakcore' | 'Breaks' | 'Brit Pop' | 'Britcore' | 'Britpop' | 'Broken Beat' | 'Bubblegum' | 'Bubbling' | 'Cabaret' | 'Caipira' | 'Cajun' | 'Calypso' | 'Cambodian Classical' | 'Candombe' | 'Cantopop' | 'Canzone Napoletana' | 'Cape Jazz' | 'Carimbó' | 'Carnatic' | 'Catalan Music' | 'Celtic' | 'Cha-Cha' | 'Chacarera' | 'Chamamé' | 'Champeta' | 'Chanson' | 'Charanga' | 'Chicago Blues' | 'Chillwave' | 'Chinese Classical' | 'Chiptune' | 'Choral' | 'Choro' | 'Chutney' | 'City Pop' | 'Classic Rock' | 'Classical' | 'Cloud Rap' | 'Cobla' | 'Coldwave' | 'Comedy' | 'Compas' | 'Conjunto' | 'Conscious' | 'Contemporary' | 'Contemporary Jazz' | 'Contemporary R&B' | 'Cool Jazz' | 'Copla' | 'Corrido' | 'Country' | 'Country Blues' | 'Country Rock' | 'Cretan' | 'Crunk' | 'Crust' | 'Cuatro' | 'Cubano' | 'Cumbia' | 'Cut-up/DJ' | 'DJ Battle Tool' | 'Dance-pop' | 'Dancehall' | 'Dangdut' | 'Danzon' | 'Dark Ambient' | 'Dark Jazz' | 'Darkwave' | 'Death Metal' | 'Deathcore' | 'Deathrock' | 'Deep House' | 'Deep Techno' | 'Delta Blues' | 'Depressive Black Metal' | 'Descarga' | 'Dialogue' | 'Disco' | 'Disco Polo' | 'Dixieland' | 'Donk' | 'Doo Wop' | 'Doom Metal' | 'Doomcore' | 'Downtempo' | 'Dream Pop' | 'Drone' | 'Drum n Bass' | 'Dub' | 'Dub Poetry' | 'Dub Techno' | 'Dubstep' | 'Dungeon Synth' | 'EBM' | 'Early' | 'East Coast Blues' | 'Easy Listening' | 'Education' | 'Educational' | 'Electric Blues' | 'Electro' | 'Electro House' | 'Electro Swing' | 'Electroacoustic' | 'Electroclash' | 'Emo' | 'Enka' | 'Erotic' | 'Ethereal' | 'Ethno-pop' | 'Euro House' | 'Euro-Disco' | 'Eurobeat' | 'Eurodance' | 'Europop' | 'Experimental' | 'Fado' | 'Favela Funk' | 'Field Recording' | 'Filk' | 'Flamenco' | 'Folk' | 'Folk Metal' | 'Folk Rock' | 'Footwork' | 'Forró' | 'Free Funk' | 'Free Improvisation' | 'Free Jazz' | 'Freestyle' | 'Freetekno' | 'Funaná' | 'Funeral Doom Metal' | 'Funk' | 'Funk Metal' | 'Funkot' | 'Fusion' | 'Future Jazz' | 'G-Funk' | 'Gabber' | 'Gagaku' | 'Gaita' | 'Galician Traditional' | 'Gamelan' | 'Gangsta' | 'Garage House' | 'Garage Rock' | 'Ghazal' | 'Ghetto' | 'Ghetto House' | 'Ghettotech' | 'Glam' | 'Glitch' | 'Glitch Hop' | 'Go-Go' | 'Goa Trance' | 'Gogo' | 'Goregrind' | 'Gospel' | 'Goth Rock' | 'Gothic Metal' | 'Gqom' | 'Grime' | 'Grindcore' | 'Griot' | 'Groove Metal' | 'Group Sounds' | 'Grunge' | 'Guaguancó' | 'Guajira' | 'Guaracha' | 'Guarania' | 'Guggenmusik' | 'Gwo Ka' | 'Gypsy Jazz' | 'Għana' | 'Halftime' | 'Hands Up' | 'Happy Hardcore' | 'Hard Beat' | 'Hard Bop' | 'Hard House' | 'Hard Rock' | 'Hard Techno' | 'Hard Trance' | 'Hardcore' | 'Hardcore Hip-Hop' | 'Hardstyle' | 'Harmonica Blues' | 'Harsh Noise Wall' | 'Hawaiian' | 'Health-Fitness' | 'Heavy Metal' | 'Hi NRG' | 'Highlife' | 'Hill Country Blues' | 'Hillbilly' | 'Hindustani' | 'Hip Hop' | 'Hip-House' | 'Hiplife' | 'Hokkien Pop' | 'Honky Tonk' | 'Horror Rock' | 'Horrorcore' | 'House' | 'Huayno' | 'Hyperpop' | 'Hyphy' | 'IDM' | 'Illbient' | 'Impressionist' | 'Indian Classical' | 'Indie Pop' | 'Indie Rock' | 'Indo-Pop' | 'Industrial' | 'Industrial Metal' | 'Instrumental' | 'Interview' | 'Italo House' | 'Italo-Disco' | 'Italodance' | 'J-Core' | 'J-Rock' | 'J-pop' | 'Jangle Pop' | 'Jazz-Funk' | 'Jazz-Rock' | 'Jazzdance' | 'Jazzy Hip-Hop' | 'Jersey Club' | 'Jibaro' | 'Joropo' | 'Jota' | 'Jug Band' | 'Juke' | 'Jump Blues' | 'Jumpstyle' | 'Jungle' | 'Junkanoo' | 'K-Rock' | 'K-pop' | 'Karaoke' | 'Kaseko' | 'Kayōkyoku' | 'Keroncong' | 'Kizomba' | 'Klasik' | 'Klezmer' | 'Korean Court Music' | 'Krautrock' | 'Kuduro' | 'Kwaito' | 'Lambada' | 'Lao Music' | 'Latin' | 'Latin Jazz' | 'Laïkó' | 'Leftfield' | 'Lento Violento' | 'Levenslied' | 'Light Music' | 'Liscio' | 'Lo-Fi' | 'Louisiana Blues' | 'Lounge' | 'Lovers Rock' | 'Luk Krung' | 'Luk Thung' | 'MPB' | 'Makina' | 'Maloya' | 'Mambo' | 'Mandopop' | 'Marcha Carnavalesca' | 'Marches' | 'Mariachi' | 'Marimba' | 'Math Rock' | 'Mbalax' | 'Medical' | 'Medieval' | 'Melodic Death Metal' | 'Melodic Hardcore' | 'Memphis Blues' | 'Mento' | 'Merengue' | 'Metalcore' | 'Miami Bass' | 'Military' | 'Milonga' | "Min'yō" | 'Minimal' | 'Minimal Techno' | 'Minneapolis Sound' | 'Mizrahi' | 'Mo Lam' | 'Mod' | 'Modal' | 'Modern' | 'Modern Classical' | 'Modern Electric Blues' | 'Monolog' | 'Moombahton' | 'Morna' | 'Motswako' | 'Mouth Music' | 'Movie Effects' | 'Mugham' | 'Musette' | 'Music Hall' | 'Musical' | 'Musique Concrète' | 'Música Criolla' | 'NDW' | 'Neo Soul' | 'Neo Trance' | 'Neo-Classical' | 'Neo-Romantic' | 'Neofolk' | 'Nerdcore Techno' | 'New Age' | 'New Beat' | 'New Jack Swing' | 'New Wave' | 'Nhạc Vàng' | 'No Wave' | 'Noise' | 'Noisecore' | 'Nordic' | 'Norteño' | 'Novelty' | 'Nu Metal' | 'Nu-Disco' | 'Nueva Cancion' | 'Nueva Trova' | 'Nursery Rhymes' | 'Néo Kyma' | 'Népzene' | 'Occitan' | 'Oi' | 'Opera' | 'Operetta' | 'Oratorio' | 'Ottoman Classical' | 'Overtone Singing' | 'P.Funk' | 'Pachanga' | 'Pacific' | 'Parody' | 'Pasodoble' | 'Persian Classical' | 'Philippine Classical' | 'Phleng Phuea Chiwit' | 'Phonk' | 'Piano Blues' | 'Piedmont Blues' | 'Piobaireachd' | 'Pipe & Drum' | 'Plena' | 'Poetry' | 'Political' | 'Polka' | 'Pop Punk' | 'Pop Rap' | 'Pop Rock' | 'Pornogrind' | 'Porro' | 'Post Bop' | 'Post Rock' | 'Post-Hardcore' | 'Post-Metal' | 'Post-Modern' | 'Post-Punk' | 'Power Electronics' | 'Power Metal' | 'Power Pop' | 'Power Violence' | 'Prog Rock' | 'Progressive Bluegrass' | 'Progressive Breaks' | 'Progressive House' | 'Progressive Metal' | 'Progressive Trance' | 'Promotional' | 'Psy-Trance' | 'Psychedelic' | 'Psychedelic Rock' | 'Psychobilly' | 'Pub Rock' | 'Public Broadcast' | 'Public Service Announcement' | 'Punk' | 'Qawwali' | 'Quechua' | 'Radioplay' | 'Ragga' | 'Ragga HipHop' | 'Ragtime' | 'Ranchera' | 'Rapso' | 'Raï' | 'Rebetiko' | 'Reggae' | 'Reggae Gospel' | 'Reggae-Pop' | 'Reggaeton' | 'Religious' | 'Renaissance' | 'Rhythm & Blues' | 'Rhythmic Noise' | 'RnB/Swing' | 'Rock & Roll' | 'Rock Opera' | 'Rockabilly' | 'Rocksteady' | 'Romani' | 'Romantic' | 'Roots Reggae' | 'Rumba' | 'Rune Singing' | 'Ryūkōka' | 'Rōkyoku' | 'Salegy' | 'Salsa' | 'Samba' | 'Samba-Canção' | 'Schlager' | 'Schranz' | 'Score' | 'Screw' | 'Sea Shanties' | 'Sean-nós' | 'Sephardic' | 'Seresta' | 'Serial' | 'Sermon' | 'Sertanejo' | 'Shaabi' | 'Shidaiqu' | 'Shoegaze' | 'Singeli' | 'Ska' | 'Skiffle' | 'Skweee' | 'Sludge Metal' | 'Smooth Jazz' | 'Soca' | 'Soft Rock' | 'Son' | 'Son Montuno' | 'Sonero' | 'Soukous' | 'Soul' | 'Soul-Jazz' | 'Sound Art' | 'Sound Collage' | 'Sound Poetry' | 'Soundtrack' | 'Southern Rock' | 'Space Rock' | 'Space-Age' | 'Spaza' | 'Special Effects' | 'Speech' | 'Speed Garage' | 'Speed Metal' | 'Speedcore' | 'Spirituals' | 'Spoken Word' | 'Steel Band' | 'Stoner Rock' | 'Story' | 'Stride' | 'Surf' | 'Swamp Pop' | 'Swing' | 'Swingbeat' | 'Symphonic Metal' | 'Symphonic Rock' | 'Synth-pop' | 'Synthwave' | 'Sámi Music' | 'Séga' | 'Taarab' | 'Tamil Film Music' | 'Tango' | 'Tech House' | 'Tech Trance' | 'Technical' | 'Technical Death Metal' | 'Techno' | 'Tejano' | 'Texas Blues' | 'Thai Classical' | 'Theme' | 'Therapy' | 'Thrash' | 'Thug Rap' | 'Timba' | 'Trallalero' | 'Trance' | 'Trap' | 'Tribal' | 'Tribal House' | 'Trip Hop' | 'Tropical House' | 'Trova' | 'Turntablism' | 'Twelve-tone' | 'Twist' | 'UK Funky' | 'UK Garage' | 'UK Street Soul' | 'Vallenato' | 'Vaporwave' | 'Vaudeville' | 'Video Game Music' | 'Viking Metal' | 'Villancicos' | 'Vocal' | 'Volksmusik' | 'Waiata' | 'Western Swing' | 'Witch House' | 'Yemenite Jewish' | 'Yé-Yé' | 'Zamba' | 'Zarzuela' | 'Zemer Ivri' | 'Zouk' | 'Zydeco' | 'Éntekhno' | ({} & string);
5
+ export type Style = StyleKeys | ({} & string);
@@ -0,0 +1,28 @@
1
+ import type { Browser } from 'patchright';
2
+ /**
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
+ */
5
+ export type WantlistOptions = {
6
+ /**
7
+ * Discogs personal access token, to read a private wantlist and get a higher rate limit.
8
+ * @see {@link https://www.discogs.com/settings/developers}
9
+ */
10
+ token?: string;
11
+ onlyForSale?: never;
12
+ } | {
13
+ token?: never;
14
+ /**
15
+ * If true, only the releases currently for sale are returned, read from the public wantlist page with a browser.
16
+ * @default false
17
+ */
18
+ onlyForSale?: boolean;
19
+ };
20
+ /**
21
+ * Gets the IDs of the releases in a user's wantlist, to pass as `releaseIds` to `search`.
22
+ * By default, it reads the public Discogs API (limited to 25 requests per minute without token, 60 with).
23
+ * @param username - Username whose wantlist is read.
24
+ * @param options - Options.
25
+ * @param browserInstance - Optional Patchright browser instance, only used with `onlyForSale`. If provided, you must manage its lifecycle.
26
+ * @returns A promise that resolves to the release IDs.
27
+ */
28
+ export default function getWantlistReleaseIds(username: string, { token, onlyForSale }?: WantlistOptions, browserInstance?: Browser): Promise<Array<number>>;