@profplum700/etsy-v3-api-client 2.5.3 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -12
- package/README.md +128 -128
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.esm.js +44 -19
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +1 -1
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +47 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.esm.js +47 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/node.cjs +47 -20
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +47 -21
- package/dist/node.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.js +0 -8517
- package/dist/index.js.map +0 -1
- package/dist/index.umd.js +0 -1180
- package/dist/index.umd.js.map +0 -1
- package/dist/index.umd.min.js +0 -2
- package/dist/index.umd.min.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1571,6 +1571,11 @@ declare class FileTokenStorage implements TokenStorage {
|
|
|
1571
1571
|
private _deleteFile;
|
|
1572
1572
|
}
|
|
1573
1573
|
|
|
1574
|
+
declare const ETSY_RATE_LIMITS: {
|
|
1575
|
+
readonly MAX_REQUESTS_PER_DAY: 5000;
|
|
1576
|
+
readonly MAX_REQUESTS_PER_SECOND: 5;
|
|
1577
|
+
readonly MIN_REQUEST_INTERVAL: 200;
|
|
1578
|
+
};
|
|
1574
1579
|
declare class EtsyRateLimiter {
|
|
1575
1580
|
private requestCount;
|
|
1576
1581
|
private dailyReset;
|
|
@@ -2081,5 +2086,5 @@ declare function getLibraryInfo(): {
|
|
|
2081
2086
|
homepage: string;
|
|
2082
2087
|
};
|
|
2083
2088
|
|
|
2084
|
-
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 };
|
|
2089
|
+
export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_RATE_LIMITS, 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 };
|
|
2085
2090
|
export type { AdvancedCachingConfig, AnalyticsPluginConfig, ApproachingLimitCallback, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CachingPluginConfig, ConsolidateReturnPoliciesParams, CreateDraftListingParams, CreateListingTranslationParams, CreateReadinessStateParams, CreateReceiptShipmentParams, CreateReturnPolicyParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShippingProfileUpgradeParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingFile, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyListingTranslation, EtsyListingVariationImage, EtsyListingVideo, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPlugin, EtsyRateLimitHeaders, EtsyReview, EtsySellerTaxonomyNode, EtsyShippingCarrier, EtsyShippingCarrierMailClass, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopHolidayPreference, EtsyShopProcessingProfile, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopReturnPolicy, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyUserAddress, EtsyWebhookEvent, EtsyWebhookEventType, FindActiveListingsByShopParams, FindShopsParams, GetFeaturedListingsParams, GetLedgerEntryPaymentsParams, GetListingsByIdsParams, GetListingsByReturnPolicyParams, GetListingsBySectionParams, GetListingsByShopReceiptParams, GetPaymentAccountLedgerEntriesParams, GetReadinessStateParams, GetReviewsParams, GetShopReceiptsParams, GetTransactionsByListingParams, GetTransactionsByShopParams, 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, TokenScopesParams, TokenScopesResponse, TokenStorage, UpdateHolidayPreferencesParams, UpdateListingInventoryParams, UpdateListingParams, UpdateListingPropertyParams, UpdateListingTranslationParams, UpdateReadinessStateParams, UpdateReturnPolicyParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShippingProfileUpgradeParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UpdateVariationImagesParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
|
package/dist/index.esm.js
CHANGED
|
@@ -673,6 +673,11 @@ class FileTokenStorage {
|
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
|
|
676
|
+
const ETSY_RATE_LIMITS = {
|
|
677
|
+
MAX_REQUESTS_PER_DAY: 5000,
|
|
678
|
+
MAX_REQUESTS_PER_SECOND: 5,
|
|
679
|
+
MIN_REQUEST_INTERVAL: 200,
|
|
680
|
+
};
|
|
676
681
|
class EtsyRateLimiter {
|
|
677
682
|
constructor(config) {
|
|
678
683
|
this.requestCount = 0;
|
|
@@ -681,9 +686,9 @@ class EtsyRateLimiter {
|
|
|
681
686
|
this.isHeaderBasedLimiting = false;
|
|
682
687
|
this.currentRetryCount = 0;
|
|
683
688
|
this.config = {
|
|
684
|
-
maxRequestsPerDay:
|
|
685
|
-
maxRequestsPerSecond:
|
|
686
|
-
minRequestInterval:
|
|
689
|
+
maxRequestsPerDay: ETSY_RATE_LIMITS.MAX_REQUESTS_PER_DAY,
|
|
690
|
+
maxRequestsPerSecond: ETSY_RATE_LIMITS.MAX_REQUESTS_PER_SECOND,
|
|
691
|
+
minRequestInterval: ETSY_RATE_LIMITS.MIN_REQUEST_INTERVAL,
|
|
687
692
|
maxRetries: 3,
|
|
688
693
|
baseDelayMs: 1000,
|
|
689
694
|
maxDelayMs: 30000,
|
|
@@ -738,7 +743,7 @@ class EtsyRateLimiter {
|
|
|
738
743
|
if (value === null)
|
|
739
744
|
return undefined;
|
|
740
745
|
const num = parseInt(value, 10);
|
|
741
|
-
return isNaN(num) ? undefined : num;
|
|
746
|
+
return Number.isNaN(num) ? undefined : num;
|
|
742
747
|
};
|
|
743
748
|
return {
|
|
744
749
|
limitPerSecond: parseNumber(getHeader('x-limit-per-second')),
|
|
@@ -1079,7 +1084,7 @@ class FieldValidator {
|
|
|
1079
1084
|
const value = data[this.field];
|
|
1080
1085
|
if (value === undefined || value === null)
|
|
1081
1086
|
return null;
|
|
1082
|
-
if (typeof value !== 'number' || isNaN(value)) {
|
|
1087
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
1083
1088
|
return {
|
|
1084
1089
|
field: this.field,
|
|
1085
1090
|
message: options.message || `${this.field} must be a number`,
|
|
@@ -1288,9 +1293,14 @@ function combineValidators(...validators) {
|
|
|
1288
1293
|
|
|
1289
1294
|
class DefaultLogger {
|
|
1290
1295
|
debug(message, ...args) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1296
|
+
let isDevelopment;
|
|
1297
|
+
if (isNode$1) {
|
|
1298
|
+
isDevelopment = process.env.NODE_ENV === 'development';
|
|
1299
|
+
}
|
|
1300
|
+
else {
|
|
1301
|
+
const host = window.location?.hostname;
|
|
1302
|
+
isDevelopment = host === 'localhost' || host === '127.0.0.1';
|
|
1303
|
+
}
|
|
1294
1304
|
if (isDevelopment) {
|
|
1295
1305
|
console.log(`[DEBUG] ${message}`, ...args);
|
|
1296
1306
|
}
|
|
@@ -1339,9 +1349,9 @@ class EtsyClient {
|
|
|
1339
1349
|
this.sharedSecret = config.sharedSecret;
|
|
1340
1350
|
if (config.rateLimiting?.enabled !== false) {
|
|
1341
1351
|
this.rateLimiter = new EtsyRateLimiter({
|
|
1342
|
-
maxRequestsPerDay: config.rateLimiting?.maxRequestsPerDay ||
|
|
1343
|
-
maxRequestsPerSecond: config.rateLimiting?.maxRequestsPerSecond ||
|
|
1344
|
-
minRequestInterval: config.rateLimiting?.minRequestInterval ??
|
|
1352
|
+
maxRequestsPerDay: config.rateLimiting?.maxRequestsPerDay || ETSY_RATE_LIMITS.MAX_REQUESTS_PER_DAY,
|
|
1353
|
+
maxRequestsPerSecond: config.rateLimiting?.maxRequestsPerSecond || ETSY_RATE_LIMITS.MAX_REQUESTS_PER_SECOND,
|
|
1354
|
+
minRequestInterval: config.rateLimiting?.minRequestInterval ?? ETSY_RATE_LIMITS.MIN_REQUEST_INTERVAL,
|
|
1345
1355
|
maxRetries: config.rateLimiting?.maxRetries,
|
|
1346
1356
|
baseDelayMs: config.rateLimiting?.baseDelayMs,
|
|
1347
1357
|
maxDelayMs: config.rateLimiting?.maxDelayMs,
|
|
@@ -1372,7 +1382,12 @@ class EtsyClient {
|
|
|
1372
1382
|
if (useCache && this.cache && requestOptions.method === 'GET') {
|
|
1373
1383
|
const cached = await this.cache.get(cacheKey);
|
|
1374
1384
|
if (cached) {
|
|
1375
|
-
|
|
1385
|
+
try {
|
|
1386
|
+
return JSON.parse(cached);
|
|
1387
|
+
}
|
|
1388
|
+
catch {
|
|
1389
|
+
await this.cache.delete(cacheKey);
|
|
1390
|
+
}
|
|
1376
1391
|
}
|
|
1377
1392
|
}
|
|
1378
1393
|
await this.rateLimiter.waitForRateLimit();
|
|
@@ -2602,9 +2617,9 @@ class GlobalRequestQueue {
|
|
|
2602
2617
|
this.requestCount = 0;
|
|
2603
2618
|
this.dailyReset = new Date();
|
|
2604
2619
|
this.lastRequestTime = 0;
|
|
2605
|
-
this.maxRequestsPerDay =
|
|
2606
|
-
this.maxRequestsPerSecond =
|
|
2607
|
-
this.minRequestInterval =
|
|
2620
|
+
this.maxRequestsPerDay = ETSY_RATE_LIMITS.MAX_REQUESTS_PER_DAY;
|
|
2621
|
+
this.maxRequestsPerSecond = ETSY_RATE_LIMITS.MAX_REQUESTS_PER_SECOND;
|
|
2622
|
+
this.minRequestInterval = ETSY_RATE_LIMITS.MIN_REQUEST_INTERVAL;
|
|
2608
2623
|
this.setNextDailyReset();
|
|
2609
2624
|
}
|
|
2610
2625
|
static getInstance() {
|
|
@@ -2689,11 +2704,12 @@ class GlobalRequestQueue {
|
|
|
2689
2704
|
try {
|
|
2690
2705
|
let result;
|
|
2691
2706
|
if (item.timeout) {
|
|
2692
|
-
const
|
|
2707
|
+
const timeout = item.timeout;
|
|
2708
|
+
const remainingTimeout = timeout - elapsed;
|
|
2693
2709
|
let timeoutId;
|
|
2694
2710
|
const timeoutPromise = new Promise((_, reject) => {
|
|
2695
2711
|
timeoutId = setTimeout(() => {
|
|
2696
|
-
reject(new Error(`Request timeout after ${
|
|
2712
|
+
reject(new Error(`Request timeout after ${timeout}ms (exceeded during execution)`));
|
|
2697
2713
|
}, remainingTimeout);
|
|
2698
2714
|
if (timeoutId && typeof timeoutId.unref === 'function') {
|
|
2699
2715
|
timeoutId.unref();
|
|
@@ -3010,7 +3026,18 @@ class EtsyWebhookHandler {
|
|
|
3010
3026
|
}
|
|
3011
3027
|
}
|
|
3012
3028
|
parseEvent(payload) {
|
|
3013
|
-
|
|
3029
|
+
let data;
|
|
3030
|
+
if (typeof payload === 'string') {
|
|
3031
|
+
try {
|
|
3032
|
+
data = JSON.parse(payload);
|
|
3033
|
+
}
|
|
3034
|
+
catch {
|
|
3035
|
+
throw new Error('Invalid webhook payload: malformed JSON');
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
else {
|
|
3039
|
+
data = payload;
|
|
3040
|
+
}
|
|
3014
3041
|
if (!data.type || !data.data) {
|
|
3015
3042
|
throw new Error('Invalid webhook event format');
|
|
3016
3043
|
}
|
|
@@ -3400,7 +3427,6 @@ function createCacheStorage(config = {}) {
|
|
|
3400
3427
|
case 'lfu':
|
|
3401
3428
|
return new LFUCache(config);
|
|
3402
3429
|
case 'ttl':
|
|
3403
|
-
return new LRUCache(config);
|
|
3404
3430
|
default:
|
|
3405
3431
|
return new LRUCache(config);
|
|
3406
3432
|
}
|
|
@@ -4215,7 +4241,7 @@ function createCachingPlugin(config = {}) {
|
|
|
4215
4241
|
};
|
|
4216
4242
|
}
|
|
4217
4243
|
function createRateLimitPlugin(config = {}) {
|
|
4218
|
-
const maxRequestsPerSecond = config.maxRequestsPerSecond ||
|
|
4244
|
+
const maxRequestsPerSecond = config.maxRequestsPerSecond || ETSY_RATE_LIMITS.MAX_REQUESTS_PER_SECOND;
|
|
4219
4245
|
const requests = [];
|
|
4220
4246
|
return {
|
|
4221
4247
|
name: 'rateLimit',
|
|
@@ -4269,5 +4295,5 @@ function getLibraryInfo() {
|
|
|
4269
4295
|
};
|
|
4270
4296
|
}
|
|
4271
4297
|
|
|
4272
|
-
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$1 as isBrowser, isNode$1 as isNode, isSecureStorageSupported, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withQueue, withRetry };
|
|
4298
|
+
export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_RATE_LIMITS, 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$1 as isBrowser, isNode$1 as isNode, isSecureStorageSupported, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withQueue, withRetry };
|
|
4273
4299
|
//# sourceMappingURL=index.esm.js.map
|