sound-tank 1.2.0 → 1.3.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.
- package/.prtrc.json +13 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +120 -23
- package/dist/index.d.ts +120 -23
- package/dist/index.js +141 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/prt.json +10 -0
- package/vite.config.mts +19 -0
- package/bun.lockb +0 -0
package/.prtrc.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/ZacharyEggert/project-roadmap-tracking/refs/heads/master/schemas/config/v1.1.json",
|
|
3
|
+
"cache": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"maxSize": 10,
|
|
6
|
+
"watchFiles": true
|
|
7
|
+
},
|
|
8
|
+
"metadata": {
|
|
9
|
+
"description": "A typescript library for interacting with the Reverb Marketplace API",
|
|
10
|
+
"name": "Soundtank"
|
|
11
|
+
},
|
|
12
|
+
"path": "./prt.json"
|
|
13
|
+
}
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { Axios } from 'axios';
|
|
3
3
|
|
|
4
|
+
declare enum LinkMethods {
|
|
5
|
+
PUT = "PUT",
|
|
6
|
+
POST = "POST",
|
|
7
|
+
GET = "GET"
|
|
8
|
+
}
|
|
4
9
|
type Link = {
|
|
5
10
|
href: string;
|
|
6
|
-
method?:
|
|
11
|
+
method?: LinkMethods | Exclude<string, LinkMethods>;
|
|
7
12
|
};
|
|
8
13
|
type ShippingRate = {
|
|
9
14
|
region_code: string;
|
|
@@ -12,7 +17,12 @@ type ShippingRate = {
|
|
|
12
17
|
regional: boolean;
|
|
13
18
|
destination_postal_code_needed: boolean;
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
declare enum ListingStates {
|
|
21
|
+
SOLD = "sold",
|
|
22
|
+
LIVE = "live",
|
|
23
|
+
DRAFT = "draft"
|
|
24
|
+
}
|
|
25
|
+
type ListingStateSlug = ListingStates;
|
|
16
26
|
type ListingState = {
|
|
17
27
|
slug: ListingStateSlug;
|
|
18
28
|
description: string;
|
|
@@ -21,7 +31,7 @@ type ListingStats = {
|
|
|
21
31
|
views: number;
|
|
22
32
|
watches: number;
|
|
23
33
|
};
|
|
24
|
-
type ConditionDisplayName = 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor'
|
|
34
|
+
type ConditionDisplayName = 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor';
|
|
25
35
|
type ListingCondition = {
|
|
26
36
|
uuid: string;
|
|
27
37
|
displayName: ConditionDisplayName;
|
|
@@ -97,8 +107,42 @@ type Listing = {
|
|
|
97
107
|
}[];
|
|
98
108
|
_links: ListingLinks;
|
|
99
109
|
};
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
declare enum OrderStatusOptions {
|
|
111
|
+
Unpaid = "unpaid",
|
|
112
|
+
Paid = "paid",
|
|
113
|
+
AwaitingShipment = "awaiting_shipment",
|
|
114
|
+
Shipped = "shipped"
|
|
115
|
+
}
|
|
116
|
+
type OrderStatus = OrderStatusOptions | Exclude<string, OrderStatusOptions>;
|
|
117
|
+
declare enum ShippingProviders {
|
|
118
|
+
UPS = "UPS",
|
|
119
|
+
USPS = "USPS",
|
|
120
|
+
FedEx = "FedEx",
|
|
121
|
+
DHLDeutschland = "DHL Deutschland",
|
|
122
|
+
DHLExpress = "DHLExpress",
|
|
123
|
+
DHLGlobalMail = "DHLGlobalMail",
|
|
124
|
+
DHL = "DHL",
|
|
125
|
+
CanadaPost = "Canada Post",
|
|
126
|
+
CanPar = "CanPar",
|
|
127
|
+
RoyalMail = "Royal Mail",
|
|
128
|
+
PostNL = "PostNL",
|
|
129
|
+
AustraliaPost = "Australia Post",
|
|
130
|
+
EMS = "EMS",
|
|
131
|
+
LaPosteColissimo = "La Poste - Colissimo",
|
|
132
|
+
ChinaPost = "China Post",
|
|
133
|
+
GLS = "GLS",
|
|
134
|
+
Parcelforce = "Parcelforce",
|
|
135
|
+
Purolator = "Purolator",
|
|
136
|
+
Interlogistica = "Interlogistica",
|
|
137
|
+
CorreosEspaña = "Correos Espa\u00F1a",
|
|
138
|
+
UkrainePost = "Ukraine Post",
|
|
139
|
+
DPDGermany = "DPD Germany",
|
|
140
|
+
DPDUK = "DPD UK",
|
|
141
|
+
DPDFrance = "DPD France",
|
|
142
|
+
Hermes = "Hermes",
|
|
143
|
+
TNT = "TNT",
|
|
144
|
+
Other = "Other"
|
|
145
|
+
}
|
|
102
146
|
type OrderTaxResponsibleParty = 'reverb' | Exclude<string, 'reverb'>;
|
|
103
147
|
type OrderShippingMethod = 'shipped' | Exclude<string, 'shipped'>;
|
|
104
148
|
type OrderShipmentStatus = 'in_transit' | Exclude<string, 'in_transit'>;
|
|
@@ -133,7 +177,7 @@ type Order = {
|
|
|
133
177
|
shipping_address: ShippingAddress;
|
|
134
178
|
shipping_date: ReturnType<typeof Date.toString>;
|
|
135
179
|
shipped_at: ReturnType<typeof Date.toString>;
|
|
136
|
-
shipping_provider:
|
|
180
|
+
shipping_provider: ShippingProviders;
|
|
137
181
|
shipping_code: string;
|
|
138
182
|
shipping_method: OrderShippingMethod;
|
|
139
183
|
shipment_status: OrderShipmentStatus;
|
|
@@ -193,6 +237,42 @@ type ShippingAddress = {
|
|
|
193
237
|
};
|
|
194
238
|
};
|
|
195
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Configuration object for Reverb API operations.
|
|
242
|
+
* This contains all necessary settings to make API requests without requiring
|
|
243
|
+
* the entire Reverb instance to be passed around.
|
|
244
|
+
*/
|
|
245
|
+
interface ReverbConfig {
|
|
246
|
+
/**
|
|
247
|
+
* The root API endpoint URL
|
|
248
|
+
*/
|
|
249
|
+
rootEndpoint: RootEndpoint;
|
|
250
|
+
/**
|
|
251
|
+
* The API key for authentication
|
|
252
|
+
*/
|
|
253
|
+
apiKey: ApiKey;
|
|
254
|
+
/**
|
|
255
|
+
* Complete headers including authentication
|
|
256
|
+
*/
|
|
257
|
+
headers: AuthReverbHeaders;
|
|
258
|
+
/**
|
|
259
|
+
* API version to use
|
|
260
|
+
*/
|
|
261
|
+
version: ApiVersion;
|
|
262
|
+
/**
|
|
263
|
+
* Locale for API responses
|
|
264
|
+
*/
|
|
265
|
+
locale: Locale;
|
|
266
|
+
/**
|
|
267
|
+
* Display currency for prices
|
|
268
|
+
*/
|
|
269
|
+
displayCurrency: DisplayCurrency;
|
|
270
|
+
/**
|
|
271
|
+
* Optional shipping region
|
|
272
|
+
*/
|
|
273
|
+
shippingRegion?: ShippingRegion;
|
|
274
|
+
}
|
|
275
|
+
|
|
196
276
|
interface GetMyListingsOptions {
|
|
197
277
|
page?: number;
|
|
198
278
|
perPage?: number;
|
|
@@ -201,7 +281,7 @@ interface GetMyListingsOptions {
|
|
|
201
281
|
}
|
|
202
282
|
interface GetAllMyListingsOptions {
|
|
203
283
|
query?: string;
|
|
204
|
-
state?:
|
|
284
|
+
state?: ListingStates;
|
|
205
285
|
}
|
|
206
286
|
interface GetOneListingOptions {
|
|
207
287
|
id: string;
|
|
@@ -263,8 +343,19 @@ declare class Reverb {
|
|
|
263
343
|
private _displayCurrency;
|
|
264
344
|
private _shippingRegion;
|
|
265
345
|
private _locale;
|
|
346
|
+
private _config;
|
|
347
|
+
private _httpClient;
|
|
266
348
|
constructor(options: ReverbOptions);
|
|
349
|
+
/**
|
|
350
|
+
* Updates the headers based on the current state of the Reverb instance.
|
|
351
|
+
* This method is called whenever a property that affects the headers is changed, rather than every time a request is made.
|
|
352
|
+
*/
|
|
267
353
|
private updateHeaders;
|
|
354
|
+
/**
|
|
355
|
+
* Updates the internal config object based on current state.
|
|
356
|
+
* This is called whenever configuration-related properties change.
|
|
357
|
+
*/
|
|
358
|
+
private _updateConfig;
|
|
268
359
|
set locale(locale: Locale);
|
|
269
360
|
get locale(): Locale;
|
|
270
361
|
set shippingRegion(shippingRegion: ShippingRegion | undefined);
|
|
@@ -276,40 +367,46 @@ declare class Reverb {
|
|
|
276
367
|
get version(): ApiVersion;
|
|
277
368
|
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
278
369
|
get rootEndpoint(): RootEndpoint;
|
|
370
|
+
/**
|
|
371
|
+
* Gets the current configuration object.
|
|
372
|
+
* This provides access to all configuration values in a single object,
|
|
373
|
+
* useful for passing to methods without requiring the entire Reverb instance.
|
|
374
|
+
*/
|
|
375
|
+
get config(): ReverbConfig;
|
|
279
376
|
/**
|
|
280
377
|
* Retrieves the current user's listings.
|
|
281
|
-
* @param options - Optional parameters for the request.
|
|
282
|
-
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
378
|
+
* @param {methods.GetMyListingsOptions} options - Optional parameters for the request.
|
|
379
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response
|
|
283
380
|
*/
|
|
284
381
|
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
285
382
|
listings: Listing[];
|
|
286
|
-
}>, any>>;
|
|
383
|
+
}>, any, {}>>;
|
|
287
384
|
/**
|
|
288
385
|
* Retrieves the orders for the current user.
|
|
289
|
-
* @param options - An optional object containing options for the request.
|
|
290
|
-
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
386
|
+
* @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.
|
|
387
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response
|
|
291
388
|
*/
|
|
292
389
|
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
293
390
|
orders: Order[];
|
|
294
|
-
}>, any>>;
|
|
391
|
+
}>, any, {}>>;
|
|
295
392
|
/**
|
|
296
393
|
* Retrieves an arbitrary endpoint using the provided options.
|
|
297
|
-
* @param options - The options to use when retrieving the endpoint.
|
|
298
|
-
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
394
|
+
* @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.
|
|
395
|
+
* @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
299
396
|
*/
|
|
300
|
-
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any>>;
|
|
397
|
+
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
301
398
|
/**
|
|
302
399
|
* Retrieves a single listing based on the provided options.
|
|
303
|
-
* @param options - The options to use when retrieving the listing.
|
|
304
|
-
* @returns A Promise that resolves with the retrieved listing.
|
|
400
|
+
* @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.
|
|
401
|
+
* @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.
|
|
305
402
|
*/
|
|
306
|
-
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any>>;
|
|
403
|
+
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any, {}>>;
|
|
307
404
|
/**
|
|
308
405
|
* Retrieves all listings associated with the current user.
|
|
309
|
-
* @param options - An optional object containing options for the request.
|
|
310
|
-
* @returns A Promise that resolves with an array of listings.
|
|
406
|
+
* @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.
|
|
407
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.
|
|
311
408
|
*/
|
|
312
|
-
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any>>;
|
|
409
|
+
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any, {}>>;
|
|
313
410
|
}
|
|
314
411
|
|
|
315
|
-
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
|
412
|
+
export { type ApiKey, type ApiVersion, type AuthReverbHeaders, type DisplayCurrency, type Locale, type ReverbHeaders, type ReverbOptions, type RootEndpoint, type ShippingRegion, Reverb as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { Axios } from 'axios';
|
|
3
3
|
|
|
4
|
+
declare enum LinkMethods {
|
|
5
|
+
PUT = "PUT",
|
|
6
|
+
POST = "POST",
|
|
7
|
+
GET = "GET"
|
|
8
|
+
}
|
|
4
9
|
type Link = {
|
|
5
10
|
href: string;
|
|
6
|
-
method?:
|
|
11
|
+
method?: LinkMethods | Exclude<string, LinkMethods>;
|
|
7
12
|
};
|
|
8
13
|
type ShippingRate = {
|
|
9
14
|
region_code: string;
|
|
@@ -12,7 +17,12 @@ type ShippingRate = {
|
|
|
12
17
|
regional: boolean;
|
|
13
18
|
destination_postal_code_needed: boolean;
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
declare enum ListingStates {
|
|
21
|
+
SOLD = "sold",
|
|
22
|
+
LIVE = "live",
|
|
23
|
+
DRAFT = "draft"
|
|
24
|
+
}
|
|
25
|
+
type ListingStateSlug = ListingStates;
|
|
16
26
|
type ListingState = {
|
|
17
27
|
slug: ListingStateSlug;
|
|
18
28
|
description: string;
|
|
@@ -21,7 +31,7 @@ type ListingStats = {
|
|
|
21
31
|
views: number;
|
|
22
32
|
watches: number;
|
|
23
33
|
};
|
|
24
|
-
type ConditionDisplayName = 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor'
|
|
34
|
+
type ConditionDisplayName = 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor';
|
|
25
35
|
type ListingCondition = {
|
|
26
36
|
uuid: string;
|
|
27
37
|
displayName: ConditionDisplayName;
|
|
@@ -97,8 +107,42 @@ type Listing = {
|
|
|
97
107
|
}[];
|
|
98
108
|
_links: ListingLinks;
|
|
99
109
|
};
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
declare enum OrderStatusOptions {
|
|
111
|
+
Unpaid = "unpaid",
|
|
112
|
+
Paid = "paid",
|
|
113
|
+
AwaitingShipment = "awaiting_shipment",
|
|
114
|
+
Shipped = "shipped"
|
|
115
|
+
}
|
|
116
|
+
type OrderStatus = OrderStatusOptions | Exclude<string, OrderStatusOptions>;
|
|
117
|
+
declare enum ShippingProviders {
|
|
118
|
+
UPS = "UPS",
|
|
119
|
+
USPS = "USPS",
|
|
120
|
+
FedEx = "FedEx",
|
|
121
|
+
DHLDeutschland = "DHL Deutschland",
|
|
122
|
+
DHLExpress = "DHLExpress",
|
|
123
|
+
DHLGlobalMail = "DHLGlobalMail",
|
|
124
|
+
DHL = "DHL",
|
|
125
|
+
CanadaPost = "Canada Post",
|
|
126
|
+
CanPar = "CanPar",
|
|
127
|
+
RoyalMail = "Royal Mail",
|
|
128
|
+
PostNL = "PostNL",
|
|
129
|
+
AustraliaPost = "Australia Post",
|
|
130
|
+
EMS = "EMS",
|
|
131
|
+
LaPosteColissimo = "La Poste - Colissimo",
|
|
132
|
+
ChinaPost = "China Post",
|
|
133
|
+
GLS = "GLS",
|
|
134
|
+
Parcelforce = "Parcelforce",
|
|
135
|
+
Purolator = "Purolator",
|
|
136
|
+
Interlogistica = "Interlogistica",
|
|
137
|
+
CorreosEspaña = "Correos Espa\u00F1a",
|
|
138
|
+
UkrainePost = "Ukraine Post",
|
|
139
|
+
DPDGermany = "DPD Germany",
|
|
140
|
+
DPDUK = "DPD UK",
|
|
141
|
+
DPDFrance = "DPD France",
|
|
142
|
+
Hermes = "Hermes",
|
|
143
|
+
TNT = "TNT",
|
|
144
|
+
Other = "Other"
|
|
145
|
+
}
|
|
102
146
|
type OrderTaxResponsibleParty = 'reverb' | Exclude<string, 'reverb'>;
|
|
103
147
|
type OrderShippingMethod = 'shipped' | Exclude<string, 'shipped'>;
|
|
104
148
|
type OrderShipmentStatus = 'in_transit' | Exclude<string, 'in_transit'>;
|
|
@@ -133,7 +177,7 @@ type Order = {
|
|
|
133
177
|
shipping_address: ShippingAddress;
|
|
134
178
|
shipping_date: ReturnType<typeof Date.toString>;
|
|
135
179
|
shipped_at: ReturnType<typeof Date.toString>;
|
|
136
|
-
shipping_provider:
|
|
180
|
+
shipping_provider: ShippingProviders;
|
|
137
181
|
shipping_code: string;
|
|
138
182
|
shipping_method: OrderShippingMethod;
|
|
139
183
|
shipment_status: OrderShipmentStatus;
|
|
@@ -193,6 +237,42 @@ type ShippingAddress = {
|
|
|
193
237
|
};
|
|
194
238
|
};
|
|
195
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Configuration object for Reverb API operations.
|
|
242
|
+
* This contains all necessary settings to make API requests without requiring
|
|
243
|
+
* the entire Reverb instance to be passed around.
|
|
244
|
+
*/
|
|
245
|
+
interface ReverbConfig {
|
|
246
|
+
/**
|
|
247
|
+
* The root API endpoint URL
|
|
248
|
+
*/
|
|
249
|
+
rootEndpoint: RootEndpoint;
|
|
250
|
+
/**
|
|
251
|
+
* The API key for authentication
|
|
252
|
+
*/
|
|
253
|
+
apiKey: ApiKey;
|
|
254
|
+
/**
|
|
255
|
+
* Complete headers including authentication
|
|
256
|
+
*/
|
|
257
|
+
headers: AuthReverbHeaders;
|
|
258
|
+
/**
|
|
259
|
+
* API version to use
|
|
260
|
+
*/
|
|
261
|
+
version: ApiVersion;
|
|
262
|
+
/**
|
|
263
|
+
* Locale for API responses
|
|
264
|
+
*/
|
|
265
|
+
locale: Locale;
|
|
266
|
+
/**
|
|
267
|
+
* Display currency for prices
|
|
268
|
+
*/
|
|
269
|
+
displayCurrency: DisplayCurrency;
|
|
270
|
+
/**
|
|
271
|
+
* Optional shipping region
|
|
272
|
+
*/
|
|
273
|
+
shippingRegion?: ShippingRegion;
|
|
274
|
+
}
|
|
275
|
+
|
|
196
276
|
interface GetMyListingsOptions {
|
|
197
277
|
page?: number;
|
|
198
278
|
perPage?: number;
|
|
@@ -201,7 +281,7 @@ interface GetMyListingsOptions {
|
|
|
201
281
|
}
|
|
202
282
|
interface GetAllMyListingsOptions {
|
|
203
283
|
query?: string;
|
|
204
|
-
state?:
|
|
284
|
+
state?: ListingStates;
|
|
205
285
|
}
|
|
206
286
|
interface GetOneListingOptions {
|
|
207
287
|
id: string;
|
|
@@ -263,8 +343,19 @@ declare class Reverb {
|
|
|
263
343
|
private _displayCurrency;
|
|
264
344
|
private _shippingRegion;
|
|
265
345
|
private _locale;
|
|
346
|
+
private _config;
|
|
347
|
+
private _httpClient;
|
|
266
348
|
constructor(options: ReverbOptions);
|
|
349
|
+
/**
|
|
350
|
+
* Updates the headers based on the current state of the Reverb instance.
|
|
351
|
+
* This method is called whenever a property that affects the headers is changed, rather than every time a request is made.
|
|
352
|
+
*/
|
|
267
353
|
private updateHeaders;
|
|
354
|
+
/**
|
|
355
|
+
* Updates the internal config object based on current state.
|
|
356
|
+
* This is called whenever configuration-related properties change.
|
|
357
|
+
*/
|
|
358
|
+
private _updateConfig;
|
|
268
359
|
set locale(locale: Locale);
|
|
269
360
|
get locale(): Locale;
|
|
270
361
|
set shippingRegion(shippingRegion: ShippingRegion | undefined);
|
|
@@ -276,40 +367,46 @@ declare class Reverb {
|
|
|
276
367
|
get version(): ApiVersion;
|
|
277
368
|
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
278
369
|
get rootEndpoint(): RootEndpoint;
|
|
370
|
+
/**
|
|
371
|
+
* Gets the current configuration object.
|
|
372
|
+
* This provides access to all configuration values in a single object,
|
|
373
|
+
* useful for passing to methods without requiring the entire Reverb instance.
|
|
374
|
+
*/
|
|
375
|
+
get config(): ReverbConfig;
|
|
279
376
|
/**
|
|
280
377
|
* Retrieves the current user's listings.
|
|
281
|
-
* @param options - Optional parameters for the request.
|
|
282
|
-
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
378
|
+
* @param {methods.GetMyListingsOptions} options - Optional parameters for the request.
|
|
379
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response
|
|
283
380
|
*/
|
|
284
381
|
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
285
382
|
listings: Listing[];
|
|
286
|
-
}>, any>>;
|
|
383
|
+
}>, any, {}>>;
|
|
287
384
|
/**
|
|
288
385
|
* Retrieves the orders for the current user.
|
|
289
|
-
* @param options - An optional object containing options for the request.
|
|
290
|
-
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
386
|
+
* @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.
|
|
387
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response
|
|
291
388
|
*/
|
|
292
389
|
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
293
390
|
orders: Order[];
|
|
294
|
-
}>, any>>;
|
|
391
|
+
}>, any, {}>>;
|
|
295
392
|
/**
|
|
296
393
|
* Retrieves an arbitrary endpoint using the provided options.
|
|
297
|
-
* @param options - The options to use when retrieving the endpoint.
|
|
298
|
-
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
394
|
+
* @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.
|
|
395
|
+
* @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
299
396
|
*/
|
|
300
|
-
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any>>;
|
|
397
|
+
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
301
398
|
/**
|
|
302
399
|
* Retrieves a single listing based on the provided options.
|
|
303
|
-
* @param options - The options to use when retrieving the listing.
|
|
304
|
-
* @returns A Promise that resolves with the retrieved listing.
|
|
400
|
+
* @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.
|
|
401
|
+
* @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.
|
|
305
402
|
*/
|
|
306
|
-
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any>>;
|
|
403
|
+
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any, {}>>;
|
|
307
404
|
/**
|
|
308
405
|
* Retrieves all listings associated with the current user.
|
|
309
|
-
* @param options - An optional object containing options for the request.
|
|
310
|
-
* @returns A Promise that resolves with an array of listings.
|
|
406
|
+
* @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.
|
|
407
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.
|
|
311
408
|
*/
|
|
312
|
-
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any>>;
|
|
409
|
+
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any, {}>>;
|
|
313
410
|
}
|
|
314
411
|
|
|
315
|
-
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
|
412
|
+
export { type ApiKey, type ApiVersion, type AuthReverbHeaders, type DisplayCurrency, type Locale, type ReverbHeaders, type ReverbOptions, type RootEndpoint, type ShippingRegion, Reverb as default };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/methods/listings/getListings.ts
|
|
@@ -24,9 +24,9 @@ var getAllMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
|
24
24
|
let response;
|
|
25
25
|
do {
|
|
26
26
|
response = await getMyListings(reverb, { page, perPage, query, state });
|
|
27
|
-
listings = listings.concat(response.data.listings);
|
|
27
|
+
listings = listings.concat(_optionalChain([response, 'access', _ => _.data, 'optionalAccess', _2 => _2.listings]) || []);
|
|
28
28
|
page++;
|
|
29
|
-
} while (response.data.listings.length === perPage);
|
|
29
|
+
} while (_optionalChain([response, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.listings, 'optionalAccess', _5 => _5.length]) === perPage);
|
|
30
30
|
return { ...response, data: listings };
|
|
31
31
|
}, "getAllMyListings");
|
|
32
32
|
var getOneListing = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
@@ -65,6 +65,98 @@ var getArbitraryEndpoint = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
|
65
65
|
return response;
|
|
66
66
|
}, "getArbitraryEndpoint");
|
|
67
67
|
|
|
68
|
+
// src/config/ReverbConfig.ts
|
|
69
|
+
function createReverbConfig(params) {
|
|
70
|
+
return {
|
|
71
|
+
rootEndpoint: params.rootEndpoint,
|
|
72
|
+
apiKey: params.apiKey,
|
|
73
|
+
headers: params.headers,
|
|
74
|
+
version: params.version,
|
|
75
|
+
locale: params.locale,
|
|
76
|
+
displayCurrency: params.displayCurrency,
|
|
77
|
+
shippingRegion: params.shippingRegion
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
__name(createReverbConfig, "createReverbConfig");
|
|
81
|
+
|
|
82
|
+
// src/http/AxiosHttpClient.ts
|
|
83
|
+
|
|
84
|
+
var _AxiosHttpClient = class _AxiosHttpClient {
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new AxiosHttpClient instance
|
|
87
|
+
*
|
|
88
|
+
* @param axiosInstance - Optional custom axios instance. If not provided, uses the default axios instance.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* // Using default axios
|
|
93
|
+
* const client = new AxiosHttpClient();
|
|
94
|
+
*
|
|
95
|
+
* // Using custom axios instance
|
|
96
|
+
* const customAxios = axios.create({ baseURL: 'https://api.example.com' });
|
|
97
|
+
* const client = new AxiosHttpClient(customAxios);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
constructor(axiosInstance) {
|
|
101
|
+
this.axiosInstance = axiosInstance || _axios2.default;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Converts an AxiosResponse to HttpResponse.
|
|
105
|
+
* In practice, they're compatible, but this ensures type safety.
|
|
106
|
+
*/
|
|
107
|
+
convertResponse(response) {
|
|
108
|
+
return {
|
|
109
|
+
data: response.data,
|
|
110
|
+
status: response.status,
|
|
111
|
+
statusText: response.statusText,
|
|
112
|
+
headers: response.headers,
|
|
113
|
+
config: response.config,
|
|
114
|
+
request: response.request
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async get(url, config) {
|
|
118
|
+
const response = await this.axiosInstance.get(url, config);
|
|
119
|
+
return this.convertResponse(response);
|
|
120
|
+
}
|
|
121
|
+
async post(url, data, config) {
|
|
122
|
+
const response = await this.axiosInstance.post(url, data, config);
|
|
123
|
+
return this.convertResponse(response);
|
|
124
|
+
}
|
|
125
|
+
async put(url, data, config) {
|
|
126
|
+
const response = await this.axiosInstance.put(url, data, config);
|
|
127
|
+
return this.convertResponse(response);
|
|
128
|
+
}
|
|
129
|
+
async delete(url, config) {
|
|
130
|
+
const response = await this.axiosInstance.delete(url, config);
|
|
131
|
+
return this.convertResponse(response);
|
|
132
|
+
}
|
|
133
|
+
async patch(url, data, config) {
|
|
134
|
+
const response = await this.axiosInstance.patch(url, data, config);
|
|
135
|
+
return this.convertResponse(response);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the underlying axios instance.
|
|
139
|
+
* Useful for advanced axios features like interceptors.
|
|
140
|
+
*
|
|
141
|
+
* @returns The axios instance
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const client = new AxiosHttpClient();
|
|
146
|
+
* const axios = client.getAxiosInstance();
|
|
147
|
+
* axios.interceptors.request.use(config => {
|
|
148
|
+
* console.log('Request:', config);
|
|
149
|
+
* return config;
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
getAxiosInstance() {
|
|
154
|
+
return this.axiosInstance;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
__name(_AxiosHttpClient, "AxiosHttpClient");
|
|
158
|
+
var AxiosHttpClient = _AxiosHttpClient;
|
|
159
|
+
|
|
68
160
|
// src/Reverb.ts
|
|
69
161
|
var _Reverb = class _Reverb {
|
|
70
162
|
constructor(options) {
|
|
@@ -103,8 +195,14 @@ var _Reverb = class _Reverb {
|
|
|
103
195
|
..._Reverb.defaultHeaders,
|
|
104
196
|
Authorization: `Bearer ${this.apiKey}`
|
|
105
197
|
};
|
|
198
|
+
this._httpClient = new AxiosHttpClient();
|
|
106
199
|
this.updateHeaders();
|
|
200
|
+
this._updateConfig();
|
|
107
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Updates the headers based on the current state of the Reverb instance.
|
|
204
|
+
* This method is called whenever a property that affects the headers is changed, rather than every time a request is made.
|
|
205
|
+
*/
|
|
108
206
|
updateHeaders() {
|
|
109
207
|
const optionalHeaders = {};
|
|
110
208
|
if (this._shippingRegion)
|
|
@@ -118,9 +216,25 @@ var _Reverb = class _Reverb {
|
|
|
118
216
|
...optionalHeaders
|
|
119
217
|
};
|
|
120
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Updates the internal config object based on current state.
|
|
221
|
+
* This is called whenever configuration-related properties change.
|
|
222
|
+
*/
|
|
223
|
+
_updateConfig() {
|
|
224
|
+
this._config = createReverbConfig({
|
|
225
|
+
rootEndpoint: this._rootEndpoint,
|
|
226
|
+
apiKey: this.apiKey,
|
|
227
|
+
headers: this._headers,
|
|
228
|
+
version: this._version,
|
|
229
|
+
locale: this._locale,
|
|
230
|
+
displayCurrency: this._displayCurrency,
|
|
231
|
+
shippingRegion: this._shippingRegion
|
|
232
|
+
});
|
|
233
|
+
}
|
|
121
234
|
set locale(locale) {
|
|
122
235
|
this._locale = locale;
|
|
123
236
|
this.updateHeaders();
|
|
237
|
+
this._updateConfig();
|
|
124
238
|
}
|
|
125
239
|
get locale() {
|
|
126
240
|
return this._locale;
|
|
@@ -128,6 +242,7 @@ var _Reverb = class _Reverb {
|
|
|
128
242
|
set shippingRegion(shippingRegion) {
|
|
129
243
|
this._shippingRegion = shippingRegion;
|
|
130
244
|
this.updateHeaders();
|
|
245
|
+
this._updateConfig();
|
|
131
246
|
}
|
|
132
247
|
get shippingRegion() {
|
|
133
248
|
return this._shippingRegion;
|
|
@@ -138,6 +253,7 @@ var _Reverb = class _Reverb {
|
|
|
138
253
|
set displayCurrency(displayCurrency) {
|
|
139
254
|
this._displayCurrency = displayCurrency;
|
|
140
255
|
this.updateHeaders();
|
|
256
|
+
this._updateConfig();
|
|
141
257
|
}
|
|
142
258
|
get displayCurrency() {
|
|
143
259
|
return this._displayCurrency;
|
|
@@ -145,52 +261,62 @@ var _Reverb = class _Reverb {
|
|
|
145
261
|
set version(version) {
|
|
146
262
|
this._version = version;
|
|
147
263
|
this.updateHeaders();
|
|
264
|
+
this._updateConfig();
|
|
148
265
|
}
|
|
149
266
|
get version() {
|
|
150
267
|
return this._version;
|
|
151
268
|
}
|
|
152
269
|
set rootEndpoint(rootEndpoint) {
|
|
153
270
|
this._rootEndpoint = rootEndpoint;
|
|
271
|
+
this._updateConfig();
|
|
154
272
|
}
|
|
155
273
|
get rootEndpoint() {
|
|
156
274
|
return this._rootEndpoint;
|
|
157
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Gets the current configuration object.
|
|
278
|
+
* This provides access to all configuration values in a single object,
|
|
279
|
+
* useful for passing to methods without requiring the entire Reverb instance.
|
|
280
|
+
*/
|
|
281
|
+
get config() {
|
|
282
|
+
return this._config;
|
|
283
|
+
}
|
|
158
284
|
/**
|
|
159
285
|
* Retrieves the current user's listings.
|
|
160
|
-
* @param options - Optional parameters for the request.
|
|
161
|
-
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
286
|
+
* @param {methods.GetMyListingsOptions} options - Optional parameters for the request.
|
|
287
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response
|
|
162
288
|
*/
|
|
163
289
|
async getMyListings(options) {
|
|
164
290
|
return await getMyListings(this, _nullishCoalesce(options, () => ( {})));
|
|
165
291
|
}
|
|
166
292
|
/**
|
|
167
293
|
* Retrieves the orders for the current user.
|
|
168
|
-
* @param options - An optional object containing options for the request.
|
|
169
|
-
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
294
|
+
* @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.
|
|
295
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response
|
|
170
296
|
*/
|
|
171
297
|
async getMyOrders(options) {
|
|
172
298
|
return await getMyOrders(this, _nullishCoalesce(options, () => ( {})));
|
|
173
299
|
}
|
|
174
300
|
/**
|
|
175
301
|
* Retrieves an arbitrary endpoint using the provided options.
|
|
176
|
-
* @param options - The options to use when retrieving the endpoint.
|
|
177
|
-
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
302
|
+
* @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.
|
|
303
|
+
* @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
178
304
|
*/
|
|
179
305
|
async getArbitraryEndpoint(options) {
|
|
180
306
|
return await getArbitraryEndpoint(this, options);
|
|
181
307
|
}
|
|
182
308
|
/**
|
|
183
309
|
* Retrieves a single listing based on the provided options.
|
|
184
|
-
* @param options - The options to use when retrieving the listing.
|
|
185
|
-
* @returns A Promise that resolves with the retrieved listing.
|
|
310
|
+
* @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.
|
|
311
|
+
* @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.
|
|
186
312
|
*/
|
|
187
313
|
async getOneListing(options) {
|
|
188
314
|
return await getOneListing(this, options);
|
|
189
315
|
}
|
|
190
316
|
/**
|
|
191
317
|
* Retrieves all listings associated with the current user.
|
|
192
|
-
* @param options - An optional object containing options for the request.
|
|
193
|
-
* @returns A Promise that resolves with an array of listings.
|
|
318
|
+
* @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.
|
|
319
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.
|
|
194
320
|
*/
|
|
195
321
|
async getAllMyListings(options) {
|
|
196
322
|
return await getAllMyListings(this, _nullishCoalesce(options, () => ( {})));
|
|
@@ -209,8 +335,8 @@ _Reverb.defaultHeaders = {
|
|
|
209
335
|
var Reverb = _Reverb;
|
|
210
336
|
|
|
211
337
|
// src/index.ts
|
|
212
|
-
var
|
|
338
|
+
var index_default = Reverb;
|
|
213
339
|
|
|
214
340
|
|
|
215
|
-
exports.default =
|
|
341
|
+
exports.default = index_default;
|
|
216
342
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/Reverb.ts","../src/index.ts"],"names":["axios"],"mappings":";;;;AAEA,OAAO,WAA8B;AAqB9B,IAAM,gBAAgB,8BAC3B,QACA,YACG;AACH,QAAM,EAAE,MAAM,SAAS,OAAO,MAAM,IAAI;AAExC,QAAM,UAAU,GAAG,OAAO,YAAY;AACtC,QAAM,aAAa,OAAO,SAAS,IAAI,KAAK;AAC5C,QAAM,gBAAgB,UAAU,aAAa,OAAO,KAAK;AACzD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,MAAM,GAAG,OAAO,IAAI,UAAU,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW;AAEhF,QAAM,WAAW,MAAM,MAAM,IAE3B,KAAK;AAAA,IACL,SAAS,OAAO;AAAA,EAClB,CAAC;AAED,SAAO;AACT,GAtB6B;AA8BtB,IAAM,mBAAmB,8BAC9B,QACA,YACsC;AACtC,MAAI,OAAO;AACX,QAAM,UAAU;AAEhB,QAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,MAAI,WAAsB,CAAC;AAC3B,MAAI;AAEJ,KAAG;AACD,eAAW,MAAM,cAAc,QAAQ,EAAE,MAAM,SAAS,OAAO,MAAM,CAAC;AACtE,eAAW,SAAS,OAAO,SAAS,KAAK,QAAQ;AACjD;AAAA,EACF,SAAS,SAAS,KAAK,SAAS,WAAW;AAE3C,SAAO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,EACrB;AAAA,EACA,IAAI,kBAAmC;AACrC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,QAAQ,SAAqB;AAC/B,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACrB;AAAA,EACA,IAAI,UAAsB;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,aAAa,cAA4B;AAC3C,SAAK,gBAAgB;AAAA,EAEvB;AAAA,EACA,IAAI,eAA6B;AAC/B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAwC;AAC1D,WAAO,MAAc,cAAc,MAAM,WAAW,CAAC,CAAC;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,YAAY,SAAsC;AACtD,WAAO,MAAc,YAAY,MAAM,WAAW,CAAC,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBAAqB,SAA8C;AACvE,WAAO,MAAc,qBAAqB,MAAM,OAAO;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAuC;AACzD,WAAO,MAAc,cAAc,MAAM,OAAO;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA2C;AAChE,WAAO,MAAc,iBAAiB,MAAM,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAvK4B;AAAP,QACZ,iBAAgC;AAAA,EACrC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,sBAAsB;AAAA;AAAA,EAEtB,cAAc;AAChB;AATF,IAAqB,SAArB;;;AChCA,IAAO,cAAQ","sourcesContent":["// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Listing } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param reverb - The Reverb client instance.\n * @param options - The options to use when fetching the listings.\n * @returns A Promise that resolves to the paginated response containing the user's listings.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n) => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: string;\n}\n\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data.listings);\n page++;\n } while (response.data.listings.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options for the API request, including the ID of the listing to retrieve.\n * @returns A Promise that resolves with the retrieved listing. Structured as an axios response\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n const response = await axios.get<Listing>(baseUrl, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","// import type { } from '~/Reverb';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options to use for the API request.\n * @returns A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n) => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport const getMyRoot = async <T = any>(reverb: Reverb) => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param reverb - The Reverb instance to use for the request.\n * @param options - The options for the request, including the URL and any additional request configuration.\n * @returns A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n) => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n this.updateHeaders();\n }\n\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n // this.updateHeaders();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param options - Optional parameters for the request.\n * @returns A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param options - The options to use when retrieving the endpoint.\n * @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param options - The options to use when retrieving the listing.\n * @returns A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/sound-tank/sound-tank/dist/index.js","../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/config/ReverbConfig.ts","../src/http/AxiosHttpClient.ts","../src/Reverb.ts","../src/index.ts"],"names":[],"mappings":"AAAA,qxBAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;AACxF;AACA;ACAA,4EAAqC;AAsD9B,IAAM,cAAA,kBAAgB,MAAA,CAAA,MAAA,CAC3B,MAAA,EACA,OAAA,EAAA,GAC8E;AAC9E,EAAA,MAAM,EAAE,IAA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AA;AAEiC,EAAA;AACnB,IAAA;AACd,EAAA;AAEI,EAAA;AACG,IAAA;AACA,IAAA;AACA,IAAA;AACP,EAAA;AACI,EAAA;AACU,IAAA;AACd,EAAA;AAEY,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACP,EAAA;AAC0B,EAAA;AACZ,IAAA;AACd,EAAA;AAEiB,EAAA;AACV,IAAA;AACA,IAAA;AACP,EAAA;AACI,EAAA;AACU,IAAA;AACd,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO2B,EAAA;AACb,IAAA;AACd,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,EAAA;AACiB,IAAA;AACvB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,EAAA;AACiB,IAAA;AACvB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,EAAA;AACiB,IAAA;AACvB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,EAAA;AACiB,IAAA;AACvB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,EAAA;AACiB,IAAA;AACvB,EAAA;AACF;AA9M4B;AACnB;AACW,EAAA;AAChB,EAAA;AACQ,EAAA;AACR,EAAA;AACA,EAAA;AAAsB;AAER,EAAA;AAChB;AATF;ANySmB;AACA;AO5UZ;AP8UY;AACA;AACA","file":"/home/runner/work/sound-tank/sound-tank/dist/index.js","sourcesContent":[null,"// import type { } from '~/Reverb';\n\nimport { Listing, ListingStates } from '~/types';\nimport axios, { AxiosResponse } from 'axios';\n\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport { ReverbConfig } from '~/config/ReverbConfig';\nimport { HttpClient } from '~/http';\nimport { buildUrl, buildUrlWithQuery, paginateAll, createPaginatedResult } from '~/utils';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Internal implementation that uses HttpClient abstraction.\n * This is the new architecture that all methods will eventually use.\n */\nexport const getMyListingsWithClient = async (\n client: HttpClient,\n config: ReverbConfig,\n options: GetMyListingsOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[]; }>>> => {\n const { page, perPage, query, state } = options;\n\n const url = buildUrlWithQuery(\n buildUrl(config.rootEndpoint, '/my/listings'),\n {\n page,\n per_page: perPage,\n query,\n state,\n }\n );\n\n const response = await client.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: config.headers,\n });\n\n return response as AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>;\n};\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param {Reverb} reverb - The Reverb client instance.\n * @param {GetMyListingsOptions} options - The options to use when fetching the listings.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the paginated response containing the user's listings.\n * @throws Will throw an axios error if the request fails.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[]; }>>> => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: ListingStates;\n}\n\n/**\n * Internal implementation using HttpClient and pagination utility.\n */\nexport const getAllMyListingsWithClient = async (\n client: HttpClient,\n config: ReverbConfig,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n const { query, state } = options;\n\n // Use pagination utility to fetch all listings\n const allListings = await paginateAll<Listing>(\n async (page, perPage) => {\n const response = await getMyListingsWithClient(client, config, {\n page,\n perPage,\n query,\n state,\n });\n\n return createPaginatedResult(\n response.data.listings || [],\n perPage,\n page\n );\n },\n { perPage: 50 }\n );\n\n // Create a synthetic response matching the expected structure\n return {\n data: allListings,\n status: 200,\n statusText: 'OK',\n headers: {},\n config: {},\n } as AxiosResponse<Listing[]>;\n};\n\n/**\n * Retrieves all listings for the authenticated user, paginated.\n *\n * @param {Reverb} reverb - The Reverb client instance.\n * @param {GetAllMyListingsOptions} options - Options for the request.\n * @returns {Promise<AxiosResponse<Listing[]>>} A Promise that resolves to an array of listings.\n * @throws Will throw an axios error if the request fails.\n */\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data?.listings || []);\n page++;\n } while (response.data?.listings?.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param {Reverb} reverb - The Reverb instance to use for the API request.\n * @param {GetOneListingOptions} options - The options for the API request, including the ID of the listing to retrieve.\n * @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing. Structured as an axios response\n * @throws Will throw an axios error if the request fails.\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n\tconst response = await axios.get<Listing>(baseUrl, {\n\t\theaders: reverb.headers,\n\t});\n\treturn response;\n\n};\n","// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param {Reverb} reverb - The Reverb instance to use for the API request.\n * @param {GetMyOrdersOptions} options - The options to use for the API request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[]; }>>> => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\n\n/**\n * Retrieves the root endpoint of the Reverb API.\n * @param {Reverb} reverb - The Reverb instance to use for the request.\n * @returns {Promise<AxiosResponse<T>>} A Promise that resolves with the root endpoint data.\n * @template T - The type of the response data.\n */\nexport const getMyRoot = async <T = any>(reverb: Reverb): Promise<AxiosResponse<T>> => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string ;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param {Reverb} reverb - The Reverb instance to use for the request.\n * @param {GetArbitraryEndpointOptions} options - The options for the request, including the URL and any additional request configuration.\n * @returns {Promise<AxiosResponse<T>>} A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n): Promise<AxiosResponse<T>> => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import {\n ApiKey,\n ApiVersion,\n AuthReverbHeaders,\n DisplayCurrency,\n Locale,\n RootEndpoint,\n ShippingRegion,\n} from '../Reverb';\n\n/**\n * Configuration object for Reverb API operations.\n * This contains all necessary settings to make API requests without requiring\n * the entire Reverb instance to be passed around.\n */\nexport interface ReverbConfig {\n /**\n * The root API endpoint URL\n */\n rootEndpoint: RootEndpoint;\n\n /**\n * The API key for authentication\n */\n apiKey: ApiKey;\n\n /**\n * Complete headers including authentication\n */\n headers: AuthReverbHeaders;\n\n /**\n * API version to use\n */\n version: ApiVersion;\n\n /**\n * Locale for API responses\n */\n locale: Locale;\n\n /**\n * Display currency for prices\n */\n displayCurrency: DisplayCurrency;\n\n /**\n * Optional shipping region\n */\n shippingRegion?: ShippingRegion;\n}\n\n/**\n * Creates a ReverbConfig from individual configuration values.\n * This is a helper function to construct the config object with proper typing.\n */\nexport function createReverbConfig(params: {\n rootEndpoint: RootEndpoint;\n apiKey: ApiKey;\n headers: AuthReverbHeaders;\n version: ApiVersion;\n locale: Locale;\n displayCurrency: DisplayCurrency;\n shippingRegion?: ShippingRegion;\n}): ReverbConfig {\n return {\n rootEndpoint: params.rootEndpoint,\n apiKey: params.apiKey,\n headers: params.headers,\n version: params.version,\n locale: params.locale,\n displayCurrency: params.displayCurrency,\n shippingRegion: params.shippingRegion,\n };\n}\n","import axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport { HttpClient } from './HttpClient';\nimport { HttpRequestConfig, HttpResponse } from './types';\n\n/**\n * Production HTTP client implementation using axios.\n * Wraps axios to implement the HttpClient interface while preserving\n * all axios functionality and response structure.\n */\nexport class AxiosHttpClient implements HttpClient {\n private axiosInstance: AxiosInstance;\n\n /**\n * Creates a new AxiosHttpClient instance\n *\n * @param axiosInstance - Optional custom axios instance. If not provided, uses the default axios instance.\n *\n * @example\n * ```ts\n * // Using default axios\n * const client = new AxiosHttpClient();\n *\n * // Using custom axios instance\n * const customAxios = axios.create({ baseURL: 'https://api.example.com' });\n * const client = new AxiosHttpClient(customAxios);\n * ```\n */\n constructor(axiosInstance?: AxiosInstance) {\n this.axiosInstance = axiosInstance || axios;\n }\n\n /**\n * Converts an AxiosResponse to HttpResponse.\n * In practice, they're compatible, but this ensures type safety.\n */\n private convertResponse<T>(response: AxiosResponse<T>): HttpResponse<T> {\n return {\n data: response.data,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Record<string, string>,\n config: response.config as HttpRequestConfig,\n request: response.request,\n };\n }\n\n async get<T = any>(\n url: string,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.get<T>(url, config);\n return this.convertResponse(response);\n }\n\n async post<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.post<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n async put<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.put<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n async delete<T = any>(\n url: string,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.delete<T>(url, config);\n return this.convertResponse(response);\n }\n\n async patch<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.patch<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n /**\n * Gets the underlying axios instance.\n * Useful for advanced axios features like interceptors.\n *\n * @returns The axios instance\n *\n * @example\n * ```ts\n * const client = new AxiosHttpClient();\n * const axios = client.getAxiosInstance();\n * axios.interceptors.request.use(config => {\n * console.log('Request:', config);\n * return config;\n * });\n * ```\n */\n getAxiosInstance(): AxiosInstance {\n return this.axiosInstance;\n }\n}\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\nimport { ReverbConfig, createReverbConfig } from './config/ReverbConfig';\nimport { AxiosHttpClient, HttpClient } from './http';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n private _config!: ReverbConfig;\n private _httpClient: HttpClient;\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n // Initialize HTTP client\n this._httpClient = new AxiosHttpClient();\n\n this.updateHeaders();\n this._updateConfig();\n }\n\n\t/**\n\t * Updates the headers based on the current state of the Reverb instance.\n\t * This method is called whenever a property that affects the headers is changed, rather than every time a request is made.\n\t */\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n /**\n * Updates the internal config object based on current state.\n * This is called whenever configuration-related properties change.\n */\n private _updateConfig() {\n this._config = createReverbConfig({\n rootEndpoint: this._rootEndpoint,\n apiKey: this.apiKey,\n headers: this._headers,\n version: this._version,\n locale: this._locale,\n displayCurrency: this._displayCurrency,\n shippingRegion: this._shippingRegion,\n });\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n this._updateConfig();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n this._updateConfig();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n this._updateConfig();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n this._updateConfig();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n this._updateConfig();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Gets the current configuration object.\n * This provides access to all configuration values in a single object,\n * useful for passing to methods without requiring the entire Reverb instance.\n */\n get config(): ReverbConfig {\n return this._config;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param {methods.GetMyListingsOptions} options - Optional parameters for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.\n * @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.\n * @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -24,9 +24,9 @@ var getAllMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
|
24
24
|
let response;
|
|
25
25
|
do {
|
|
26
26
|
response = await getMyListings(reverb, { page, perPage, query, state });
|
|
27
|
-
listings = listings.concat(response.data
|
|
27
|
+
listings = listings.concat(response.data?.listings || []);
|
|
28
28
|
page++;
|
|
29
|
-
} while (response.data
|
|
29
|
+
} while (response.data?.listings?.length === perPage);
|
|
30
30
|
return { ...response, data: listings };
|
|
31
31
|
}, "getAllMyListings");
|
|
32
32
|
var getOneListing = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
@@ -65,6 +65,98 @@ var getArbitraryEndpoint = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
|
65
65
|
return response;
|
|
66
66
|
}, "getArbitraryEndpoint");
|
|
67
67
|
|
|
68
|
+
// src/config/ReverbConfig.ts
|
|
69
|
+
function createReverbConfig(params) {
|
|
70
|
+
return {
|
|
71
|
+
rootEndpoint: params.rootEndpoint,
|
|
72
|
+
apiKey: params.apiKey,
|
|
73
|
+
headers: params.headers,
|
|
74
|
+
version: params.version,
|
|
75
|
+
locale: params.locale,
|
|
76
|
+
displayCurrency: params.displayCurrency,
|
|
77
|
+
shippingRegion: params.shippingRegion
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
__name(createReverbConfig, "createReverbConfig");
|
|
81
|
+
|
|
82
|
+
// src/http/AxiosHttpClient.ts
|
|
83
|
+
import axios4 from "axios";
|
|
84
|
+
var _AxiosHttpClient = class _AxiosHttpClient {
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new AxiosHttpClient instance
|
|
87
|
+
*
|
|
88
|
+
* @param axiosInstance - Optional custom axios instance. If not provided, uses the default axios instance.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* // Using default axios
|
|
93
|
+
* const client = new AxiosHttpClient();
|
|
94
|
+
*
|
|
95
|
+
* // Using custom axios instance
|
|
96
|
+
* const customAxios = axios.create({ baseURL: 'https://api.example.com' });
|
|
97
|
+
* const client = new AxiosHttpClient(customAxios);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
constructor(axiosInstance) {
|
|
101
|
+
this.axiosInstance = axiosInstance || axios4;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Converts an AxiosResponse to HttpResponse.
|
|
105
|
+
* In practice, they're compatible, but this ensures type safety.
|
|
106
|
+
*/
|
|
107
|
+
convertResponse(response) {
|
|
108
|
+
return {
|
|
109
|
+
data: response.data,
|
|
110
|
+
status: response.status,
|
|
111
|
+
statusText: response.statusText,
|
|
112
|
+
headers: response.headers,
|
|
113
|
+
config: response.config,
|
|
114
|
+
request: response.request
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async get(url, config) {
|
|
118
|
+
const response = await this.axiosInstance.get(url, config);
|
|
119
|
+
return this.convertResponse(response);
|
|
120
|
+
}
|
|
121
|
+
async post(url, data, config) {
|
|
122
|
+
const response = await this.axiosInstance.post(url, data, config);
|
|
123
|
+
return this.convertResponse(response);
|
|
124
|
+
}
|
|
125
|
+
async put(url, data, config) {
|
|
126
|
+
const response = await this.axiosInstance.put(url, data, config);
|
|
127
|
+
return this.convertResponse(response);
|
|
128
|
+
}
|
|
129
|
+
async delete(url, config) {
|
|
130
|
+
const response = await this.axiosInstance.delete(url, config);
|
|
131
|
+
return this.convertResponse(response);
|
|
132
|
+
}
|
|
133
|
+
async patch(url, data, config) {
|
|
134
|
+
const response = await this.axiosInstance.patch(url, data, config);
|
|
135
|
+
return this.convertResponse(response);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the underlying axios instance.
|
|
139
|
+
* Useful for advanced axios features like interceptors.
|
|
140
|
+
*
|
|
141
|
+
* @returns The axios instance
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const client = new AxiosHttpClient();
|
|
146
|
+
* const axios = client.getAxiosInstance();
|
|
147
|
+
* axios.interceptors.request.use(config => {
|
|
148
|
+
* console.log('Request:', config);
|
|
149
|
+
* return config;
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
getAxiosInstance() {
|
|
154
|
+
return this.axiosInstance;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
__name(_AxiosHttpClient, "AxiosHttpClient");
|
|
158
|
+
var AxiosHttpClient = _AxiosHttpClient;
|
|
159
|
+
|
|
68
160
|
// src/Reverb.ts
|
|
69
161
|
var _Reverb = class _Reverb {
|
|
70
162
|
constructor(options) {
|
|
@@ -103,8 +195,14 @@ var _Reverb = class _Reverb {
|
|
|
103
195
|
..._Reverb.defaultHeaders,
|
|
104
196
|
Authorization: `Bearer ${this.apiKey}`
|
|
105
197
|
};
|
|
198
|
+
this._httpClient = new AxiosHttpClient();
|
|
106
199
|
this.updateHeaders();
|
|
200
|
+
this._updateConfig();
|
|
107
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Updates the headers based on the current state of the Reverb instance.
|
|
204
|
+
* This method is called whenever a property that affects the headers is changed, rather than every time a request is made.
|
|
205
|
+
*/
|
|
108
206
|
updateHeaders() {
|
|
109
207
|
const optionalHeaders = {};
|
|
110
208
|
if (this._shippingRegion)
|
|
@@ -118,9 +216,25 @@ var _Reverb = class _Reverb {
|
|
|
118
216
|
...optionalHeaders
|
|
119
217
|
};
|
|
120
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Updates the internal config object based on current state.
|
|
221
|
+
* This is called whenever configuration-related properties change.
|
|
222
|
+
*/
|
|
223
|
+
_updateConfig() {
|
|
224
|
+
this._config = createReverbConfig({
|
|
225
|
+
rootEndpoint: this._rootEndpoint,
|
|
226
|
+
apiKey: this.apiKey,
|
|
227
|
+
headers: this._headers,
|
|
228
|
+
version: this._version,
|
|
229
|
+
locale: this._locale,
|
|
230
|
+
displayCurrency: this._displayCurrency,
|
|
231
|
+
shippingRegion: this._shippingRegion
|
|
232
|
+
});
|
|
233
|
+
}
|
|
121
234
|
set locale(locale) {
|
|
122
235
|
this._locale = locale;
|
|
123
236
|
this.updateHeaders();
|
|
237
|
+
this._updateConfig();
|
|
124
238
|
}
|
|
125
239
|
get locale() {
|
|
126
240
|
return this._locale;
|
|
@@ -128,6 +242,7 @@ var _Reverb = class _Reverb {
|
|
|
128
242
|
set shippingRegion(shippingRegion) {
|
|
129
243
|
this._shippingRegion = shippingRegion;
|
|
130
244
|
this.updateHeaders();
|
|
245
|
+
this._updateConfig();
|
|
131
246
|
}
|
|
132
247
|
get shippingRegion() {
|
|
133
248
|
return this._shippingRegion;
|
|
@@ -138,6 +253,7 @@ var _Reverb = class _Reverb {
|
|
|
138
253
|
set displayCurrency(displayCurrency) {
|
|
139
254
|
this._displayCurrency = displayCurrency;
|
|
140
255
|
this.updateHeaders();
|
|
256
|
+
this._updateConfig();
|
|
141
257
|
}
|
|
142
258
|
get displayCurrency() {
|
|
143
259
|
return this._displayCurrency;
|
|
@@ -145,52 +261,62 @@ var _Reverb = class _Reverb {
|
|
|
145
261
|
set version(version) {
|
|
146
262
|
this._version = version;
|
|
147
263
|
this.updateHeaders();
|
|
264
|
+
this._updateConfig();
|
|
148
265
|
}
|
|
149
266
|
get version() {
|
|
150
267
|
return this._version;
|
|
151
268
|
}
|
|
152
269
|
set rootEndpoint(rootEndpoint) {
|
|
153
270
|
this._rootEndpoint = rootEndpoint;
|
|
271
|
+
this._updateConfig();
|
|
154
272
|
}
|
|
155
273
|
get rootEndpoint() {
|
|
156
274
|
return this._rootEndpoint;
|
|
157
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Gets the current configuration object.
|
|
278
|
+
* This provides access to all configuration values in a single object,
|
|
279
|
+
* useful for passing to methods without requiring the entire Reverb instance.
|
|
280
|
+
*/
|
|
281
|
+
get config() {
|
|
282
|
+
return this._config;
|
|
283
|
+
}
|
|
158
284
|
/**
|
|
159
285
|
* Retrieves the current user's listings.
|
|
160
|
-
* @param options - Optional parameters for the request.
|
|
161
|
-
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
286
|
+
* @param {methods.GetMyListingsOptions} options - Optional parameters for the request.
|
|
287
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response
|
|
162
288
|
*/
|
|
163
289
|
async getMyListings(options) {
|
|
164
290
|
return await getMyListings(this, options ?? {});
|
|
165
291
|
}
|
|
166
292
|
/**
|
|
167
293
|
* Retrieves the orders for the current user.
|
|
168
|
-
* @param options - An optional object containing options for the request.
|
|
169
|
-
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
294
|
+
* @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.
|
|
295
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response
|
|
170
296
|
*/
|
|
171
297
|
async getMyOrders(options) {
|
|
172
298
|
return await getMyOrders(this, options ?? {});
|
|
173
299
|
}
|
|
174
300
|
/**
|
|
175
301
|
* Retrieves an arbitrary endpoint using the provided options.
|
|
176
|
-
* @param options - The options to use when retrieving the endpoint.
|
|
177
|
-
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
302
|
+
* @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.
|
|
303
|
+
* @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
178
304
|
*/
|
|
179
305
|
async getArbitraryEndpoint(options) {
|
|
180
306
|
return await getArbitraryEndpoint(this, options);
|
|
181
307
|
}
|
|
182
308
|
/**
|
|
183
309
|
* Retrieves a single listing based on the provided options.
|
|
184
|
-
* @param options - The options to use when retrieving the listing.
|
|
185
|
-
* @returns A Promise that resolves with the retrieved listing.
|
|
310
|
+
* @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.
|
|
311
|
+
* @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.
|
|
186
312
|
*/
|
|
187
313
|
async getOneListing(options) {
|
|
188
314
|
return await getOneListing(this, options);
|
|
189
315
|
}
|
|
190
316
|
/**
|
|
191
317
|
* Retrieves all listings associated with the current user.
|
|
192
|
-
* @param options - An optional object containing options for the request.
|
|
193
|
-
* @returns A Promise that resolves with an array of listings.
|
|
318
|
+
* @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.
|
|
319
|
+
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.
|
|
194
320
|
*/
|
|
195
321
|
async getAllMyListings(options) {
|
|
196
322
|
return await getAllMyListings(this, options ?? {});
|
|
@@ -209,8 +335,8 @@ _Reverb.defaultHeaders = {
|
|
|
209
335
|
var Reverb = _Reverb;
|
|
210
336
|
|
|
211
337
|
// src/index.ts
|
|
212
|
-
var
|
|
338
|
+
var index_default = Reverb;
|
|
213
339
|
export {
|
|
214
|
-
|
|
340
|
+
index_default as default
|
|
215
341
|
};
|
|
216
342
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/Reverb.ts","../src/index.ts"],"sourcesContent":["// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Listing } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param reverb - The Reverb client instance.\n * @param options - The options to use when fetching the listings.\n * @returns A Promise that resolves to the paginated response containing the user's listings.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n) => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: string;\n}\n\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data.listings);\n page++;\n } while (response.data.listings.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options for the API request, including the ID of the listing to retrieve.\n * @returns A Promise that resolves with the retrieved listing. Structured as an axios response\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n const response = await axios.get<Listing>(baseUrl, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","// import type { } from '~/Reverb';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options to use for the API request.\n * @returns A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n) => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport const getMyRoot = async <T = any>(reverb: Reverb) => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param reverb - The Reverb instance to use for the request.\n * @param options - The options for the request, including the URL and any additional request configuration.\n * @returns A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n) => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n this.updateHeaders();\n }\n\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n // this.updateHeaders();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param options - Optional parameters for the request.\n * @returns A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param options - The options to use when retrieving the endpoint.\n * @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param options - The options to use when retrieving the listing.\n * @returns A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"],"mappings":";;;;AAEA,OAAO,WAA8B;AAqB9B,IAAM,gBAAgB,8BAC3B,QACA,YACG;AACH,QAAM,EAAE,MAAM,SAAS,OAAO,MAAM,IAAI;AAExC,QAAM,UAAU,GAAG,OAAO,YAAY;AACtC,QAAM,aAAa,OAAO,SAAS,IAAI,KAAK;AAC5C,QAAM,gBAAgB,UAAU,aAAa,OAAO,KAAK;AACzD,QAAM,cAAc,QAAQ,UAAU,K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AAM,OAAO;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAuC;AACzD,WAAO,MAAc,cAAc,MAAM,OAAO;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA2C;AAChE,WAAO,MAAc,iBAAiB,MAAM,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAvK4B;AAAP,QACZ,iBAAgC;AAAA,EACrC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,sBAAsB;AAAA;AAAA,EAEtB,cAAc;AAChB;AATF,IAAqB,SAArB;;;AChCA,IAAO,cAAQ;","names":["axios","axios","axios","axios"]}
|
|
1
|
+
{"version":3,"sources":["../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/config/ReverbConfig.ts","../src/http/AxiosHttpClient.ts","../src/Reverb.ts","../src/index.ts"],"sourcesContent":["// import type { } from '~/Reverb';\n\nimport { Listing, ListingStates } from '~/types';\nimport axios, { AxiosResponse } from 'axios';\n\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport { ReverbConfig } from '~/config/ReverbConfig';\nimport { HttpClient } from '~/http';\nimport { buildUrl, buildUrlWithQuery, paginateAll, createPaginatedResult } from '~/utils';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Internal implementation that uses HttpClient abstraction.\n * This is the new architecture that all methods will eventually use.\n */\nexport const getMyListingsWithClient = async (\n client: HttpClient,\n config: ReverbConfig,\n options: GetMyListingsOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[]; }>>> => {\n const { page, perPage, query, state } = options;\n\n const url = buildUrlWithQuery(\n buildUrl(config.rootEndpoint, '/my/listings'),\n {\n page,\n per_page: perPage,\n query,\n state,\n }\n );\n\n const response = await client.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: config.headers,\n });\n\n return response as AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>;\n};\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param {Reverb} reverb - The Reverb client instance.\n * @param {GetMyListingsOptions} options - The options to use when fetching the listings.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the paginated response containing the user's listings.\n * @throws Will throw an axios error if the request fails.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[]; }>>> => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: ListingStates;\n}\n\n/**\n * Internal implementation using HttpClient and pagination utility.\n */\nexport const getAllMyListingsWithClient = async (\n client: HttpClient,\n config: ReverbConfig,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n const { query, state } = options;\n\n // Use pagination utility to fetch all listings\n const allListings = await paginateAll<Listing>(\n async (page, perPage) => {\n const response = await getMyListingsWithClient(client, config, {\n page,\n perPage,\n query,\n state,\n });\n\n return createPaginatedResult(\n response.data.listings || [],\n perPage,\n page\n );\n },\n { perPage: 50 }\n );\n\n // Create a synthetic response matching the expected structure\n return {\n data: allListings,\n status: 200,\n statusText: 'OK',\n headers: {},\n config: {},\n } as AxiosResponse<Listing[]>;\n};\n\n/**\n * Retrieves all listings for the authenticated user, paginated.\n *\n * @param {Reverb} reverb - The Reverb client instance.\n * @param {GetAllMyListingsOptions} options - Options for the request.\n * @returns {Promise<AxiosResponse<Listing[]>>} A Promise that resolves to an array of listings.\n * @throws Will throw an axios error if the request fails.\n */\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data?.listings || []);\n page++;\n } while (response.data?.listings?.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param {Reverb} reverb - The Reverb instance to use for the API request.\n * @param {GetOneListingOptions} options - The options for the API request, including the ID of the listing to retrieve.\n * @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing. Structured as an axios response\n * @throws Will throw an axios error if the request fails.\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n\tconst response = await axios.get<Listing>(baseUrl, {\n\t\theaders: reverb.headers,\n\t});\n\treturn response;\n\n};\n","// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param {Reverb} reverb - The Reverb instance to use for the API request.\n * @param {GetMyOrdersOptions} options - The options to use for the API request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n): Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[]; }>>> => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\n\n/**\n * Retrieves the root endpoint of the Reverb API.\n * @param {Reverb} reverb - The Reverb instance to use for the request.\n * @returns {Promise<AxiosResponse<T>>} A Promise that resolves with the root endpoint data.\n * @template T - The type of the response data.\n */\nexport const getMyRoot = async <T = any>(reverb: Reverb): Promise<AxiosResponse<T>> => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string ;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param {Reverb} reverb - The Reverb instance to use for the request.\n * @param {GetArbitraryEndpointOptions} options - The options for the request, including the URL and any additional request configuration.\n * @returns {Promise<AxiosResponse<T>>} A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n): Promise<AxiosResponse<T>> => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import {\n ApiKey,\n ApiVersion,\n AuthReverbHeaders,\n DisplayCurrency,\n Locale,\n RootEndpoint,\n ShippingRegion,\n} from '../Reverb';\n\n/**\n * Configuration object for Reverb API operations.\n * This contains all necessary settings to make API requests without requiring\n * the entire Reverb instance to be passed around.\n */\nexport interface ReverbConfig {\n /**\n * The root API endpoint URL\n */\n rootEndpoint: RootEndpoint;\n\n /**\n * The API key for authentication\n */\n apiKey: ApiKey;\n\n /**\n * Complete headers including authentication\n */\n headers: AuthReverbHeaders;\n\n /**\n * API version to use\n */\n version: ApiVersion;\n\n /**\n * Locale for API responses\n */\n locale: Locale;\n\n /**\n * Display currency for prices\n */\n displayCurrency: DisplayCurrency;\n\n /**\n * Optional shipping region\n */\n shippingRegion?: ShippingRegion;\n}\n\n/**\n * Creates a ReverbConfig from individual configuration values.\n * This is a helper function to construct the config object with proper typing.\n */\nexport function createReverbConfig(params: {\n rootEndpoint: RootEndpoint;\n apiKey: ApiKey;\n headers: AuthReverbHeaders;\n version: ApiVersion;\n locale: Locale;\n displayCurrency: DisplayCurrency;\n shippingRegion?: ShippingRegion;\n}): ReverbConfig {\n return {\n rootEndpoint: params.rootEndpoint,\n apiKey: params.apiKey,\n headers: params.headers,\n version: params.version,\n locale: params.locale,\n displayCurrency: params.displayCurrency,\n shippingRegion: params.shippingRegion,\n };\n}\n","import axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport { HttpClient } from './HttpClient';\nimport { HttpRequestConfig, HttpResponse } from './types';\n\n/**\n * Production HTTP client implementation using axios.\n * Wraps axios to implement the HttpClient interface while preserving\n * all axios functionality and response structure.\n */\nexport class AxiosHttpClient implements HttpClient {\n private axiosInstance: AxiosInstance;\n\n /**\n * Creates a new AxiosHttpClient instance\n *\n * @param axiosInstance - Optional custom axios instance. If not provided, uses the default axios instance.\n *\n * @example\n * ```ts\n * // Using default axios\n * const client = new AxiosHttpClient();\n *\n * // Using custom axios instance\n * const customAxios = axios.create({ baseURL: 'https://api.example.com' });\n * const client = new AxiosHttpClient(customAxios);\n * ```\n */\n constructor(axiosInstance?: AxiosInstance) {\n this.axiosInstance = axiosInstance || axios;\n }\n\n /**\n * Converts an AxiosResponse to HttpResponse.\n * In practice, they're compatible, but this ensures type safety.\n */\n private convertResponse<T>(response: AxiosResponse<T>): HttpResponse<T> {\n return {\n data: response.data,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Record<string, string>,\n config: response.config as HttpRequestConfig,\n request: response.request,\n };\n }\n\n async get<T = any>(\n url: string,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.get<T>(url, config);\n return this.convertResponse(response);\n }\n\n async post<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.post<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n async put<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.put<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n async delete<T = any>(\n url: string,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.delete<T>(url, config);\n return this.convertResponse(response);\n }\n\n async patch<T = any>(\n url: string,\n data?: any,\n config?: HttpRequestConfig\n ): Promise<HttpResponse<T>> {\n const response = await this.axiosInstance.patch<T>(url, data, config);\n return this.convertResponse(response);\n }\n\n /**\n * Gets the underlying axios instance.\n * Useful for advanced axios features like interceptors.\n *\n * @returns The axios instance\n *\n * @example\n * ```ts\n * const client = new AxiosHttpClient();\n * const axios = client.getAxiosInstance();\n * axios.interceptors.request.use(config => {\n * console.log('Request:', config);\n * return config;\n * });\n * ```\n */\n getAxiosInstance(): AxiosInstance {\n return this.axiosInstance;\n }\n}\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\nimport { ReverbConfig, createReverbConfig } from './config/ReverbConfig';\nimport { AxiosHttpClient, HttpClient } from './http';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n private _config!: ReverbConfig;\n private _httpClient: HttpClient;\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n // Initialize HTTP client\n this._httpClient = new AxiosHttpClient();\n\n this.updateHeaders();\n this._updateConfig();\n }\n\n\t/**\n\t * Updates the headers based on the current state of the Reverb instance.\n\t * This method is called whenever a property that affects the headers is changed, rather than every time a request is made.\n\t */\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n /**\n * Updates the internal config object based on current state.\n * This is called whenever configuration-related properties change.\n */\n private _updateConfig() {\n this._config = createReverbConfig({\n rootEndpoint: this._rootEndpoint,\n apiKey: this.apiKey,\n headers: this._headers,\n version: this._version,\n locale: this._locale,\n displayCurrency: this._displayCurrency,\n shippingRegion: this._shippingRegion,\n });\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n this._updateConfig();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n this._updateConfig();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n this._updateConfig();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n this._updateConfig();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n this._updateConfig();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Gets the current configuration object.\n * This provides access to all configuration values in a single object,\n * useful for passing to methods without requiring the entire Reverb instance.\n */\n get config(): ReverbConfig {\n return this._config;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param {methods.GetMyListingsOptions} options - Optional parameters for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.\n * @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.\n * @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.\n * @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"],"mappings":";;;;AAGA,OAAO,WAA8B;AAsD9B,IAAM,gBAAgB,8BAC3B,QACA,YAC8E;AAC9E,QAAM,EAAE,MAAM,SAAS,OAAO,MAAM,IAAI;AAExC,QAAM,UAAU,GAAG,OAAO,YAAY;AACtC,QAAM,aAAa,OAAO,SAAS,IAAI,KAAK;AAC5C,QAAM,gBAAgB,UAAU,aAAa,OAAO,KAAK;AACzD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,MAAM,GAAG,OAAO,IAAI,UAAU,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW;AAEhF,QAAM,WAAW,MAAM,MAAM,IAE3B,KAAK;AAAA,IACL,SAAS,OAAO;AAAA,EAClB,CAAC;AAED,SAAO;AACT,GAtB6B;AA6EtB,IAAM,mBAAmB,8BAC9B,QACA,YACsC;AACtC,MAAI,OAAO;AACX,QAAM,UAAU;AAEhB,QAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,MAAI,WAAsB,CAAC;AAC3B,MAAI;AAEJ,KAAG;AACD,eAAW,MAAM,cAAc,QAAQ,EAAE,MAAM,SAAS,OAAO,MAAM,CAAC;AACtE,eAAW,SAAS,OAAO,SAAS,MAAM,YAAY,CAAC,CAAC;AACxD;AAAA,EACF,SAAS,SAAS,MAAM,UAAU,WAAW;AAE7C,SAAO,EAAE,GAAG,UAAU,MAAM,SAAS;AACvC,GAnBgC;AAgCzB,IAAM,gBAAgB,8BAC3B,QACA,YACG;AACH,QAAM,EAAE,G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ACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,YAAY,SAAsC;AACtD,WAAO,MAAc,YAAY,MAAM,WAAW,CAAC,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBAAqB,SAA8C;AACvE,WAAO,MAAc,qBAAqB,MAAM,OAAO;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAuC;AACzD,WAAO,MAAc,cAAc,MAAM,OAAO;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA2C;AAChE,WAAO,MAAc,iBAAiB,MAAM,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AA9M4B;AAAP,QACZ,iBAAgC;AAAA,EACrC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,sBAAsB;AAAA;AAAA,EAEtB,cAAc;AAChB;AATF,IAAqB,SAArB;;;AClCA,IAAO,gBAAQ;","names":["axios","axios","axios","axios","axios","axios"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sound-tank",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A library for interacting with the Reverb Marketplace API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"release": "yarn lint && yarn test && yarn build && changeset publish"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@changesets/cli": "^2.
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
24
|
+
"@changesets/cli": "^2.27.3",
|
|
25
|
+
"@types/node": "^24.1.0",
|
|
26
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
27
|
+
"dotenv": "^17.2.0",
|
|
28
|
+
"prettier": "^3.6.2",
|
|
29
|
+
"tsup": "^8.5.0",
|
|
30
|
+
"typescript": "^5.8.3",
|
|
31
|
+
"vitest": "^3.2.4"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"axios": "^1.4.0"
|
|
34
|
+
"axios": "^1.10.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/prt.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/ZacharyEggert/project-roadmap-tracking/refs/heads/master/schemas/roadmap/v1.json",
|
|
3
|
+
"metadata": {
|
|
4
|
+
"createdAt": "2026-02-04T03:58:54.410Z",
|
|
5
|
+
"createdBy": "project-roadmap-tracking CLI",
|
|
6
|
+
"description": "A project roadmap managed by Project Roadmap Tracking",
|
|
7
|
+
"name": "My Project Roadmap"
|
|
8
|
+
},
|
|
9
|
+
"tasks": []
|
|
10
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
// Explicitly include test files from tests/ directory
|
|
7
|
+
include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
include: ['src/**/*.ts'],
|
|
11
|
+
exclude: ['src/**/*.test.ts', 'src/**/*.spec.ts'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
resolve: {
|
|
15
|
+
alias: {
|
|
16
|
+
'~': path.resolve(__dirname, './src'),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
package/bun.lockb
DELETED
|
Binary file
|