@profplum700/etsy-v3-api-client 2.4.0 → 2.4.2

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/dist/index.d.ts CHANGED
@@ -201,6 +201,17 @@ interface EtsyListing {
201
201
  skus?: string[];
202
202
  used_manufacturer?: boolean;
203
203
  }
204
+ interface EtsyReview {
205
+ review_id?: number;
206
+ rating?: number;
207
+ review?: string;
208
+ language?: string;
209
+ created_timestamp?: number;
210
+ created_tsz?: number;
211
+ listing_id?: number;
212
+ shop_id?: number;
213
+ [key: string]: unknown;
214
+ }
204
215
  interface EtsyListingImage {
205
216
  listing_image_id: number;
206
217
  hex_code?: string;
@@ -283,6 +294,12 @@ interface SearchParams {
283
294
  location?: string;
284
295
  shop_location?: string;
285
296
  }
297
+ interface GetReviewsParams {
298
+ limit?: number;
299
+ offset?: number;
300
+ min_created?: number;
301
+ max_created?: number;
302
+ }
286
303
  interface EtsyRateLimitHeaders {
287
304
  limitPerSecond?: number;
288
305
  remainingThisSecond?: number;
@@ -874,6 +891,14 @@ interface EtsyListingPropertyScale {
874
891
  display_name: string;
875
892
  description?: string;
876
893
  }
894
+ interface UpdateListingPropertyParams {
895
+ shopId: string | number;
896
+ listingId: string | number;
897
+ propertyId: number;
898
+ valueIds: number[];
899
+ values: string[];
900
+ scaleId?: number;
901
+ }
877
902
  interface EtsyBuyerTaxonomyNode {
878
903
  id: number;
879
904
  level: number;
@@ -1066,6 +1091,8 @@ declare class EtsyClient {
1066
1091
  findAllListingsActive(params?: SearchParams): Promise<EtsyListing[]>;
1067
1092
  getListingImages(listingId: string): Promise<EtsyListingImage[]>;
1068
1093
  getListingInventory(listingId: string): Promise<EtsyListingInventory>;
1094
+ getReviewsByListing(listingId: string, params?: GetReviewsParams): Promise<EtsyReview[]>;
1095
+ getReviewsByShop(shopId: string, params?: GetReviewsParams): Promise<EtsyReview[]>;
1069
1096
  getSellerTaxonomyNodes(): Promise<EtsySellerTaxonomyNode[]>;
1070
1097
  getUserShops(): Promise<EtsyShop[]>;
1071
1098
  updateShop(shopId: string, params: UpdateShopParams, options?: ValidationOptions): Promise<EtsyShop>;
@@ -1110,6 +1137,7 @@ declare class EtsyClient {
1110
1137
  getBuyerTaxonomyNodes(): Promise<EtsyBuyerTaxonomyNode[]>;
1111
1138
  getPropertiesByTaxonomyId(taxonomyId: number): Promise<EtsyBuyerTaxonomyProperty[]>;
1112
1139
  getListingProperties(shopId: string, listingId: string): Promise<EtsyListingProperty[]>;
1140
+ updateListingProperty(params: UpdateListingPropertyParams): Promise<EtsyListingProperty>;
1113
1141
  getShopProductionPartners(shopId: string): Promise<EtsyShopProductionPartner[]>;
1114
1142
  getRemainingRequests(): number;
1115
1143
  getRateLimitStatus(): RateLimitStatus;
@@ -1750,4 +1778,4 @@ declare function getLibraryInfo(): {
1750
1778
  };
1751
1779
 
1752
1780
  export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_SCOPES, EncryptedFileTokenStorage, EtsyApiError, EtsyAuthError, EtsyClient, EtsyRateLimitError, EtsyRateLimiter, EtsyWebhookHandler, FieldValidator, FileTokenStorage, GlobalRequestQueue, LFUCache, LIBRARY_NAME, LRUCache, ListingQueryBuilder, LocalStorageTokenStorage, MemoryTokenStorage, PaginatedResults, PluginManager, ReceiptQueryBuilder, RedisCacheStorage, RetryManager, SecureTokenStorage, SessionStorageTokenStorage, TokenManager, UpdateListingSchema, UpdateShopSchema, VERSION, ValidationException, Validator, WebhookSecurity, combineValidators, createAnalyticsPlugin, createAuthHelper, createBatchQuery, createBulkOperationManager, createCacheStorage, createCacheWithInvalidation, createCachingPlugin, createCodeChallenge, createDefaultTokenStorage, createEtsyClient, createListingQuery, createLoggingPlugin, createPaginatedResults, createRateLimitPlugin, createRateLimiter, createReceiptQuery, createRedisCacheStorage, createRetryPlugin, createTokenManager, createValidator, createWebhookHandler, createWebhookSecurity, decryptAES256GCM, EtsyClient as default, defaultRateLimiter, deriveKeyFromPassword, encryptAES256GCM, executeBulkOperation, field, generateCodeVerifier, generateEncryptionKey, generateRandomBase64Url, generateState, getAvailableStorage, getEnvironmentInfo, getGlobalQueue, getLibraryInfo, hasLocalStorage, hasSessionStorage, isBrowser, isNode, isSecureStorageSupported, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withQueue, withRetry };
1753
- export type { AdvancedCachingConfig, AnalyticsPluginConfig, ApproachingLimitCallback, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CachingPluginConfig, CreateDraftListingParams, CreateReceiptShipmentParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPlugin, EtsyRateLimitHeaders, EtsySellerTaxonomyNode, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyWebhookEvent, EtsyWebhookEventType, GetPaymentAccountLedgerEntriesParams, GetShopReceiptsParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, LoggingPluginConfig, PageFetcher, PaginationOptions, PluginRequestConfig, PluginResponse, QueueOptions, RateLimitConfig, RateLimitErrorType, RateLimitPluginConfig, RateLimitStatus, RedisClientLike, RedisConfig, RequestPriority, RetryConfig, RetryOptions, RetryPluginConfig, SearchParams, SecureTokenStorageConfig, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenStorage, UpdateListingInventoryParams, UpdateListingParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
1781
+ export type { AdvancedCachingConfig, AnalyticsPluginConfig, ApproachingLimitCallback, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CachingPluginConfig, CreateDraftListingParams, CreateReceiptShipmentParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPlugin, EtsyRateLimitHeaders, EtsyReview, EtsySellerTaxonomyNode, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyWebhookEvent, EtsyWebhookEventType, GetPaymentAccountLedgerEntriesParams, GetReviewsParams, GetShopReceiptsParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, LoggingPluginConfig, PageFetcher, PaginationOptions, PluginRequestConfig, PluginResponse, QueueOptions, RateLimitConfig, RateLimitErrorType, RateLimitPluginConfig, RateLimitStatus, RedisClientLike, RedisConfig, RequestPriority, RetryConfig, RetryOptions, RetryPluginConfig, SearchParams, SecureTokenStorageConfig, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenStorage, UpdateListingInventoryParams, UpdateListingParams, UpdateListingPropertyParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
package/dist/index.esm.js CHANGED
@@ -1531,6 +1531,36 @@ class EtsyClient {
1531
1531
  async getListingInventory(listingId) {
1532
1532
  return this.makeRequest(`/listings/${listingId}/inventory`);
1533
1533
  }
1534
+ async getReviewsByListing(listingId, params = {}) {
1535
+ const searchParams = new URLSearchParams();
1536
+ if (params.limit !== undefined)
1537
+ searchParams.set('limit', params.limit.toString());
1538
+ if (params.offset !== undefined)
1539
+ searchParams.set('offset', params.offset.toString());
1540
+ if (params.min_created !== undefined) {
1541
+ searchParams.set('min_created', params.min_created.toString());
1542
+ }
1543
+ if (params.max_created !== undefined) {
1544
+ searchParams.set('max_created', params.max_created.toString());
1545
+ }
1546
+ const response = await this.makeRequest(`/listings/${listingId}/reviews?${searchParams.toString()}`);
1547
+ return response.results;
1548
+ }
1549
+ async getReviewsByShop(shopId, params = {}) {
1550
+ const searchParams = new URLSearchParams();
1551
+ if (params.limit !== undefined)
1552
+ searchParams.set('limit', params.limit.toString());
1553
+ if (params.offset !== undefined)
1554
+ searchParams.set('offset', params.offset.toString());
1555
+ if (params.min_created !== undefined) {
1556
+ searchParams.set('min_created', params.min_created.toString());
1557
+ }
1558
+ if (params.max_created !== undefined) {
1559
+ searchParams.set('max_created', params.max_created.toString());
1560
+ }
1561
+ const response = await this.makeRequest(`/shops/${shopId}/reviews?${searchParams.toString()}`);
1562
+ return response.results;
1563
+ }
1534
1564
  async getSellerTaxonomyNodes() {
1535
1565
  const response = await this.makeRequest('/seller-taxonomy/nodes');
1536
1566
  return response.results;
@@ -1799,6 +1829,34 @@ class EtsyClient {
1799
1829
  const response = await this.makeRequest(`/shops/${shopId}/listings/${listingId}/properties`);
1800
1830
  return response.results;
1801
1831
  }
1832
+ async updateListingProperty(params) {
1833
+ const { shopId, listingId, propertyId, valueIds, values, scaleId } = params;
1834
+ const body = new URLSearchParams();
1835
+ valueIds.forEach(id => body.append('value_ids[]', id.toString()));
1836
+ values.forEach(val => body.append('values[]', val));
1837
+ if (scaleId !== undefined) {
1838
+ body.append('scale_id', scaleId.toString());
1839
+ }
1840
+ const url = `${this.baseUrl}/shops/${shopId}/listings/${listingId}/properties/${propertyId}`;
1841
+ await this.rateLimiter.waitForRateLimit();
1842
+ const accessToken = await this.tokenManager.getAccessToken();
1843
+ const response = await this.fetch(url, {
1844
+ method: 'PUT',
1845
+ headers: {
1846
+ 'Authorization': `Bearer ${accessToken}`,
1847
+ 'x-api-key': this.getApiKey(),
1848
+ 'Content-Type': 'application/x-www-form-urlencoded'
1849
+ },
1850
+ body: body.toString()
1851
+ });
1852
+ this.rateLimiter.updateFromHeaders(response.headers);
1853
+ this.rateLimiter.resetRetryCount();
1854
+ if (!response.ok) {
1855
+ const errorText = await response.text();
1856
+ throw new EtsyApiError(`Failed to update listing property: ${response.status} ${response.statusText}`, response.status, errorText);
1857
+ }
1858
+ return response.json();
1859
+ }
1802
1860
  async getShopProductionPartners(shopId) {
1803
1861
  const response = await this.makeRequest(`/shops/${shopId}/production-partners`);
1804
1862
  return response.results;
@@ -2152,12 +2210,23 @@ class GlobalRequestQueue {
2152
2210
  let result;
2153
2211
  if (item.timeout) {
2154
2212
  const remainingTimeout = item.timeout - elapsed;
2213
+ let timeoutId;
2155
2214
  const timeoutPromise = new Promise((_, reject) => {
2156
- setTimeout(() => {
2215
+ timeoutId = setTimeout(() => {
2157
2216
  reject(new Error(`Request timeout after ${item.timeout}ms (exceeded during execution)`));
2158
2217
  }, remainingTimeout);
2218
+ if (timeoutId && typeof timeoutId.unref === 'function') {
2219
+ timeoutId.unref();
2220
+ }
2159
2221
  });
2160
- result = await Promise.race([item.request(), timeoutPromise]);
2222
+ try {
2223
+ result = await Promise.race([item.request(), timeoutPromise]);
2224
+ }
2225
+ finally {
2226
+ if (timeoutId) {
2227
+ clearTimeout(timeoutId);
2228
+ }
2229
+ }
2161
2230
  }
2162
2231
  else {
2163
2232
  result = await item.request();