@profplum700/etsy-v3-api-client 2.3.1 → 2.3.9

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
@@ -292,19 +292,33 @@ interface EtsyErrorDetails {
292
292
  field?: string;
293
293
  suggestion?: string;
294
294
  retryAfter?: number;
295
+ endpoint?: string;
296
+ timestamp?: Date;
297
+ validationErrors?: Array<{
298
+ field: string;
299
+ message: string;
300
+ }>;
295
301
  }
296
302
  declare class EtsyApiError extends Error {
297
303
  _statusCode?: number | undefined;
298
304
  _response?: unknown | undefined;
299
305
  _retryAfter?: number | undefined;
300
306
  details: EtsyErrorDetails;
301
- constructor(message: string, _statusCode?: number | undefined, _response?: unknown | undefined, _retryAfter?: number | undefined);
307
+ readonly endpoint?: string;
308
+ readonly suggestions: string[];
309
+ readonly docsUrl: string;
310
+ readonly timestamp: Date;
311
+ constructor(message: string, _statusCode?: number | undefined, _response?: unknown | undefined, _retryAfter?: number | undefined, endpoint?: string);
302
312
  get statusCode(): number | undefined;
303
313
  get response(): unknown | undefined;
304
314
  isRetryable(): boolean;
305
315
  getRetryAfter(): number | null;
306
316
  getRateLimitReset(): Date | null;
317
+ private generateSuggestions;
318
+ private generateDocsUrl;
307
319
  getUserFriendlyMessage(): string;
320
+ toString(): string;
321
+ toJSON(): Record<string, unknown>;
308
322
  }
309
323
  declare class EtsyAuthError extends Error {
310
324
  _code?: string | undefined;
@@ -1210,6 +1224,44 @@ declare class EtsyRateLimiter {
1210
1224
  }
1211
1225
  declare const defaultRateLimiter: EtsyRateLimiter;
1212
1226
 
1227
+ type RequestPriority = 'high' | 'normal' | 'low';
1228
+ interface QueueOptions {
1229
+ priority?: RequestPriority;
1230
+ timeout?: number;
1231
+ endpoint?: string;
1232
+ }
1233
+ declare class GlobalRequestQueue {
1234
+ private static instance;
1235
+ private queue;
1236
+ private processing;
1237
+ private rateLimits;
1238
+ private requestCount;
1239
+ private dailyReset;
1240
+ private lastRequestTime;
1241
+ private readonly maxRequestsPerDay;
1242
+ private readonly maxRequestsPerSecond;
1243
+ private readonly minRequestInterval;
1244
+ private constructor();
1245
+ static getInstance(): GlobalRequestQueue;
1246
+ static resetInstance(): void;
1247
+ enqueue<T>(request: () => Promise<T>, options?: QueueOptions): Promise<T>;
1248
+ getStatus(): {
1249
+ queueLength: number;
1250
+ processing: boolean;
1251
+ remainingRequests: number;
1252
+ resetTime: Date;
1253
+ };
1254
+ clear(): void;
1255
+ private processQueue;
1256
+ private waitForRateLimit;
1257
+ private updateRateLimitInfo;
1258
+ private setNextDailyReset;
1259
+ private generateId;
1260
+ private delay;
1261
+ }
1262
+ declare function getGlobalQueue(): GlobalRequestQueue;
1263
+ declare function withQueue<T>(request: () => Promise<T>, options?: QueueOptions): Promise<T>;
1264
+
1213
1265
  interface PaginationOptions {
1214
1266
  limit?: number;
1215
1267
  offset?: number;
@@ -1516,6 +1568,97 @@ declare class WebhookSecurity {
1516
1568
  }
1517
1569
  declare function createWebhookSecurity(secret: string, algorithm?: 'sha256' | 'sha1' | 'sha512'): WebhookSecurity;
1518
1570
 
1571
+ interface SecureTokenStorageConfig {
1572
+ keyPrefix?: string;
1573
+ derivationInput?: string;
1574
+ useSessionStorage?: boolean;
1575
+ }
1576
+ declare class SecureTokenStorage implements TokenStorage {
1577
+ private readonly keyPrefix;
1578
+ private readonly derivationInput;
1579
+ private readonly storage;
1580
+ private encryptionKey;
1581
+ constructor(config?: SecureTokenStorageConfig);
1582
+ save(tokens: EtsyTokens): Promise<void>;
1583
+ load(): Promise<EtsyTokens | null>;
1584
+ clear(): Promise<void>;
1585
+ private getEncryptionKey;
1586
+ private deriveKeyMaterial;
1587
+ private generateIntegrity;
1588
+ private getDefaultDerivationInput;
1589
+ private stringToArrayBuffer;
1590
+ private arrayBufferToBase64;
1591
+ private base64ToArrayBuffer;
1592
+ private compareArrayBuffers;
1593
+ }
1594
+ declare function isSecureStorageSupported(): boolean;
1595
+
1596
+ interface PluginRequestConfig {
1597
+ method: string;
1598
+ endpoint: string;
1599
+ params?: Record<string, unknown>;
1600
+ headers?: Record<string, string>;
1601
+ body?: unknown;
1602
+ }
1603
+ interface PluginResponse<T = unknown> {
1604
+ data: T;
1605
+ status: number;
1606
+ headers?: Record<string, string>;
1607
+ }
1608
+ interface EtsyPlugin {
1609
+ name: string;
1610
+ version?: string;
1611
+ onBeforeRequest?: (config: PluginRequestConfig) => Promise<PluginRequestConfig> | PluginRequestConfig;
1612
+ onAfterResponse?: <T>(response: PluginResponse<T>) => Promise<PluginResponse<T>> | PluginResponse<T>;
1613
+ onError?: (error: Error) => Promise<void> | void;
1614
+ onInit?: () => Promise<void> | void;
1615
+ onDestroy?: () => Promise<void> | void;
1616
+ }
1617
+ declare class PluginManager {
1618
+ private plugins;
1619
+ register(plugin: EtsyPlugin): Promise<void>;
1620
+ unregister(pluginName: string): Promise<boolean>;
1621
+ getPlugins(): ReadonlyArray<EtsyPlugin>;
1622
+ getPlugin(name: string): EtsyPlugin | undefined;
1623
+ executeBeforeRequest(config: PluginRequestConfig): Promise<PluginRequestConfig>;
1624
+ executeAfterResponse<T>(response: PluginResponse<T>): Promise<PluginResponse<T>>;
1625
+ executeOnError(error: Error): Promise<void>;
1626
+ clear(): Promise<void>;
1627
+ }
1628
+ interface AnalyticsPluginConfig {
1629
+ trackingId: string;
1630
+ trackEndpoint?: (endpoint: string, method: string, duration: number) => void;
1631
+ trackError?: (error: Error) => void;
1632
+ }
1633
+ declare function createAnalyticsPlugin(config: AnalyticsPluginConfig): EtsyPlugin;
1634
+ interface RetryPluginConfig {
1635
+ maxRetries?: number;
1636
+ retryDelay?: number;
1637
+ retryableStatusCodes?: number[];
1638
+ onRetry?: (attempt: number, error: Error) => void;
1639
+ }
1640
+ declare function createRetryPlugin(config?: RetryPluginConfig): EtsyPlugin;
1641
+ interface LoggingPluginConfig {
1642
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
1643
+ logger?: {
1644
+ debug: (message: string, ...args: unknown[]) => void;
1645
+ info: (message: string, ...args: unknown[]) => void;
1646
+ warn: (message: string, ...args: unknown[]) => void;
1647
+ error: (message: string, ...args: unknown[]) => void;
1648
+ };
1649
+ }
1650
+ declare function createLoggingPlugin(config?: LoggingPluginConfig): EtsyPlugin;
1651
+ interface CachingPluginConfig {
1652
+ ttl?: number;
1653
+ keyGenerator?: (config: PluginRequestConfig) => string;
1654
+ }
1655
+ declare function createCachingPlugin(config?: CachingPluginConfig): EtsyPlugin;
1656
+ interface RateLimitPluginConfig {
1657
+ maxRequestsPerSecond?: number;
1658
+ onRateLimitExceeded?: () => void;
1659
+ }
1660
+ declare function createRateLimitPlugin(config?: RateLimitPluginConfig): EtsyPlugin;
1661
+
1519
1662
  declare const isBrowser: boolean;
1520
1663
  declare const isNode: boolean;
1521
1664
  declare const hasLocalStorage: boolean;
@@ -1556,5 +1699,5 @@ declare function getLibraryInfo(): {
1556
1699
  homepage: string;
1557
1700
  };
1558
1701
 
1559
- export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_SCOPES, EncryptedFileTokenStorage, EtsyApiError, EtsyAuthError, EtsyClient, EtsyRateLimitError, EtsyRateLimiter, EtsyWebhookHandler, FieldValidator, FileTokenStorage, LFUCache, LIBRARY_NAME, LRUCache, ListingQueryBuilder, LocalStorageTokenStorage, MemoryTokenStorage, PaginatedResults, ReceiptQueryBuilder, RedisCacheStorage, RetryManager, SessionStorageTokenStorage, TokenManager, UpdateListingSchema, UpdateShopSchema, VERSION, ValidationException, Validator, WebhookSecurity, combineValidators, createAuthHelper, createBatchQuery, createBulkOperationManager, createCacheStorage, createCacheWithInvalidation, createCodeChallenge, createDefaultTokenStorage, createEtsyClient, createListingQuery, createPaginatedResults, createRateLimiter, createReceiptQuery, createRedisCacheStorage, createTokenManager, createValidator, createWebhookHandler, createWebhookSecurity, decryptAES256GCM, EtsyClient as default, defaultRateLimiter, deriveKeyFromPassword, encryptAES256GCM, executeBulkOperation, field, generateCodeVerifier, generateEncryptionKey, generateRandomBase64Url, generateState, getAvailableStorage, getEnvironmentInfo, getLibraryInfo, hasLocalStorage, hasSessionStorage, isBrowser, isNode, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withRetry };
1560
- export type { AdvancedCachingConfig, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, 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, EtsySellerTaxonomyNode, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyWebhookEvent, EtsyWebhookEventType, GetPaymentAccountLedgerEntriesParams, GetShopReceiptsParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, PageFetcher, PaginationOptions, RateLimitConfig, RateLimitStatus, RedisClientLike, RedisConfig, RetryConfig, RetryOptions, SearchParams, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenStorage, UpdateListingInventoryParams, UpdateListingParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
1702
+ 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 };
1703
+ export type { AdvancedCachingConfig, AnalyticsPluginConfig, 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, 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, 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 };