discogs-marketplace-api-nodejs 1.14.2 → 1.14.4

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.
@@ -28,6 +28,23 @@ export default interface ShopDetailsResultApi {
28
28
  };
29
29
  /** DiscogsId */
30
30
  discogsId?: number;
31
+ } | null>;
32
+ };
33
+ /** Errors */
34
+ errors?: Array<{
35
+ /** Message */
36
+ message?: string;
37
+ /** Path */
38
+ path?: [string, number];
39
+ }>;
40
+ /** Extensions */
41
+ extensions?: {
42
+ /** ValueCompletion */
43
+ valueCompletion?: Array<{
44
+ /** Message */
45
+ message?: string;
46
+ /** Path */
47
+ path?: [string, number];
31
48
  }>;
32
49
  };
33
50
  }
@@ -0,0 +1,8 @@
1
+ export default interface ShopResultErrorApi {
2
+ /** Success */
3
+ success: false;
4
+ /** Code */
5
+ code: number;
6
+ /** Detail */
7
+ detail: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -164,6 +164,7 @@ interface SearchParamsModernBase extends SearchParamsBase {
164
164
  sort?: Exclude<Sort, 'label,asc' | 'label,desc'>;
165
165
  /**
166
166
  * Number of results to return per page.
167
+ * It must be less than or equal to 250.
167
168
  * @default 25
168
169
  */
169
170
  limit?: number;
@@ -71,7 +71,10 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
71
71
  referrer: 'https://discogs.com',
72
72
  });
73
73
  if (!response.ok) {
74
- throw new Error(response.statusText || `An error ${response.status} occurred.`);
74
+ const message = response.headers.get('Content-Type')?.includes('application/json')
75
+ ? (await response.json()).detail
76
+ : '';
77
+ throw new Error(message || response.statusText || `An error ${response.status} occurred.`);
75
78
  }
76
79
  const result = (await response.json());
77
80
  const detailsResponse = await globalThis.fetch('https://www.discogs.com/graphql', {
@@ -100,14 +103,19 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
100
103
  throw new Error(detailsResponse.statusText || `An error ${detailsResponse.status} occurred.`);
101
104
  }
102
105
  const detailsResult = (await detailsResponse.json());
103
- const details = Object.fromEntries(detailsResult.data?.releases?.map(release => [
104
- release.discogsId ?? 0,
105
- {
106
- imageUrl: release.images?.edges?.[0]?.node?.thumbnail?.webpUrl ?? null,
107
- want: release.inWantlistCount ?? 0,
108
- have: release.inCollectionCount ?? 0,
109
- },
110
- ]) ?? []);
106
+ const details = Object.fromEntries(detailsResult.data?.releases?.map(release => {
107
+ if (!release?.discogsId) {
108
+ return [0, { imageUrl: null, want: 0, have: 0 }];
109
+ }
110
+ return [
111
+ release.discogsId ?? 0,
112
+ {
113
+ imageUrl: release.images?.edges?.[0]?.node?.thumbnail?.webpUrl ?? null,
114
+ want: release.inWantlistCount ?? 0,
115
+ have: release.inCollectionCount ?? 0,
116
+ },
117
+ ];
118
+ }) ?? []);
111
119
  const items = result.items?.map(item => {
112
120
  const detail = details[item.release?.releaseId ?? 0];
113
121
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discogs-marketplace-api-nodejs",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
5
5
  "keywords": [
6
6
  "discogs",