@profplum700/etsy-v3-api-client 2.5.4 → 3.0.1

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
@@ -1,6 +1,6 @@
1
1
  interface EtsyClientConfig {
2
2
  keystring: string;
3
- sharedSecret?: string;
3
+ sharedSecret: string;
4
4
  accessToken: string;
5
5
  refreshToken: string;
6
6
  expiresAt: Date;
@@ -183,6 +183,10 @@ interface EtsyListing {
183
183
  occasion?: string;
184
184
  style_id?: number[];
185
185
  non_taxable?: boolean;
186
+ is_personalizable?: boolean;
187
+ personalization_is_required?: boolean;
188
+ personalization_char_count_max?: number;
189
+ personalization_instructions?: string;
186
190
  is_customizable?: boolean;
187
191
  is_digital?: boolean;
188
192
  file_data?: string;
@@ -285,6 +289,28 @@ interface ListingParams {
285
289
  legacy?: boolean;
286
290
  }
287
291
  type ListingIncludes = 'Shipping' | 'Images' | 'Shop' | 'User' | 'Translations' | 'Inventory' | 'Videos';
292
+ type EtsyPersonalizationQuestionType = 'text_input' | 'dropdown' | 'unlabeled_upload' | 'labeled_upload';
293
+ interface EtsyPersonalizationOption {
294
+ option_id?: number | null;
295
+ label: string;
296
+ }
297
+ interface EtsyPersonalizationQuestion {
298
+ question_id?: number | null;
299
+ question_type: EtsyPersonalizationQuestionType;
300
+ question_text: string;
301
+ instructions?: string | null;
302
+ required: boolean;
303
+ max_allowed_characters?: number | null;
304
+ max_allowed_files?: number | null;
305
+ options?: EtsyPersonalizationOption[] | null;
306
+ }
307
+ interface EtsyListingPersonalization {
308
+ personalization_questions: EtsyPersonalizationQuestion[];
309
+ }
310
+ interface UpdatePersonalizationParams {
311
+ personalization_questions: EtsyPersonalizationQuestion[];
312
+ supports_multiple_personalization_questions?: boolean;
313
+ }
288
314
  interface SearchParams {
289
315
  limit?: number;
290
316
  offset?: number;
@@ -402,7 +428,7 @@ interface LoggerInterface {
402
428
  warn(_message: string, ..._args: unknown[]): void;
403
429
  error(_message: string, ..._args: unknown[]): void;
404
430
  }
405
- declare const ETSY_WHEN_MADE_VALUES: readonly ["1990s", "1980s", "1970s", "1960s", "1950s", "1940s", "1930s", "1920s", "1910s", "1900s", "1800s", "1700s", "before_1700"];
431
+ declare const ETSY_WHEN_MADE_VALUES: readonly ["2020_2026", "2010_2019", "2007_2009", "before_2007", "2000_2006", "1990s", "1980s", "1970s", "1960s", "1950s", "1940s", "1930s", "1920s", "1910s", "1900s", "1800s", "1700s", "before_1700"];
406
432
  interface UpdateShopParams {
407
433
  title?: string;
408
434
  announcement?: string;
@@ -1308,7 +1334,7 @@ declare class EtsyClient {
1308
1334
  private cache?;
1309
1335
  private cacheTtl;
1310
1336
  private keystring;
1311
- private sharedSecret?;
1337
+ private sharedSecret;
1312
1338
  private bulkOperationManager;
1313
1339
  constructor(config: EtsyClientConfig);
1314
1340
  private makeRequest;
@@ -1412,6 +1438,9 @@ declare class EtsyClient {
1412
1438
  getListingVideos(listingId: string): Promise<EtsyListingVideo[]>;
1413
1439
  getListingVideo(listingId: string, videoId: string): Promise<EtsyListingVideo>;
1414
1440
  deleteListingVideo(shopId: string, listingId: string, videoId: string): Promise<void>;
1441
+ getListingPersonalizations(listingId: string): Promise<EtsyListingPersonalization>;
1442
+ updateListingPersonalization(shopId: string, listingId: string, params: UpdatePersonalizationParams): Promise<EtsyListingPersonalization>;
1443
+ deleteListingPersonalization(shopId: string, listingId: string): Promise<void>;
1415
1444
  createListingTranslation(shopId: string, listingId: string, language: string, params: CreateListingTranslationParams): Promise<EtsyListingTranslation>;
1416
1445
  getListingTranslation(shopId: string, listingId: string, language: string): Promise<EtsyListingTranslation>;
1417
1446
  updateListingTranslation(shopId: string, listingId: string, language: string, params: UpdateListingTranslationParams): Promise<EtsyListingTranslation>;
@@ -1702,7 +1731,7 @@ interface WebhookConfig {
1702
1731
  algorithm?: 'sha256' | 'sha1';
1703
1732
  verifySignatures?: boolean;
1704
1733
  }
1705
- type EtsyWebhookEventType = 'receipt.updated' | 'receipt.created' | 'listing.updated' | 'listing.created' | 'listing.deactivated' | 'shop.updated';
1734
+ type EtsyWebhookEventType = 'receipt.updated' | 'receipt.created' | 'listing.updated' | 'listing.created' | 'listing.deactivated' | 'shop.updated' | 'order.shipped' | 'order.delivered' | 'order.paid' | 'order.canceled';
1706
1735
  interface EtsyWebhookEvent {
1707
1736
  type: EtsyWebhookEventType;
1708
1737
  timestamp: number;
@@ -2075,7 +2104,7 @@ declare function createAuthHelper(config: AuthHelperConfig): AuthHelper;
2075
2104
  declare function createTokenManager(config: EtsyClientConfig, storage?: TokenStorage): TokenManager;
2076
2105
  declare function createRateLimiter(config?: Partial<RateLimitConfig>): EtsyRateLimiter;
2077
2106
 
2078
- declare const VERSION = "2.2.0";
2107
+ declare const VERSION = "3.0.1";
2079
2108
  declare const LIBRARY_NAME = "etsy-v3-api-client";
2080
2109
  declare function getLibraryInfo(): {
2081
2110
  name: string;
@@ -2087,4 +2116,4 @@ declare function getLibraryInfo(): {
2087
2116
  };
2088
2117
 
2089
2118
  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 };
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 };
2119
+ 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, EtsyListingPersonalization, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyListingTranslation, EtsyListingVariationImage, EtsyListingVideo, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsyPersonalizationOption, EtsyPersonalizationQuestion, EtsyPersonalizationQuestionType, 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, UpdatePersonalizationParams, 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
@@ -247,6 +247,26 @@ class EtsyRateLimitError extends Error {
247
247
  return this.errorType !== 'qpd_exhausted';
248
248
  }
249
249
  }
250
+ const ETSY_WHEN_MADE_VALUES = [
251
+ '2020_2026',
252
+ '2010_2019',
253
+ '2007_2009',
254
+ 'before_2007',
255
+ '2000_2006',
256
+ '1990s',
257
+ '1980s',
258
+ '1970s',
259
+ '1960s',
260
+ '1950s',
261
+ '1940s',
262
+ '1930s',
263
+ '1920s',
264
+ '1910s',
265
+ '1900s',
266
+ '1800s',
267
+ '1700s',
268
+ 'before_1700'
269
+ ];
250
270
 
251
271
  const isBrowser$1 = typeof window !== 'undefined' && typeof window.document !== 'undefined';
252
272
  const isNode$1 = typeof process !== 'undefined' && !!process.versions?.node;
@@ -1084,10 +1104,10 @@ class FieldValidator {
1084
1104
  const value = data[this.field];
1085
1105
  if (value === undefined || value === null)
1086
1106
  return null;
1087
- if (typeof value !== 'number' || Number.isNaN(value)) {
1107
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
1088
1108
  return {
1089
1109
  field: this.field,
1090
- message: options.message || `${this.field} must be a number`,
1110
+ message: options.message || `${this.field} must be a finite number`,
1091
1111
  value
1092
1112
  };
1093
1113
  }
@@ -1192,28 +1212,10 @@ const CreateListingSchema = new Validator()
1192
1212
  .rule(field('title').string({ min: 1, max: 140, message: 'title must be 1-140 characters' }))
1193
1213
  .rule(field('description').string({ max: 65535, message: 'description must be less than 65535 characters' }))
1194
1214
  .rule(field('price').required())
1195
- .rule(field('price').number({ min: 0.2, max: 50000, message: 'price must be between 0.20 and 50000.00' }))
1215
+ .rule(field('price').number({ positive: true, message: 'price must be a finite positive number' }))
1196
1216
  .rule(field('who_made').enum(['i_did', 'someone_else', 'collective'], 'who_made must be one of: i_did, someone_else, collective'))
1197
- .rule(field('when_made').enum([
1198
- 'made_to_order',
1199
- '2020_2024',
1200
- '2010_2019',
1201
- '2005_2009',
1202
- '2000_2004',
1203
- '1990s',
1204
- '1980s',
1205
- '1970s',
1206
- '1960s',
1207
- '1950s',
1208
- '1940s',
1209
- '1930s',
1210
- '1920s',
1211
- '1910s',
1212
- '1900s',
1213
- '1800s',
1214
- '1700s',
1215
- 'before_1700'
1216
- ]))
1217
+ .rule(field('when_made').required())
1218
+ .rule(field('when_made').enum(['made_to_order', ...ETSY_WHEN_MADE_VALUES]))
1217
1219
  .rule(field('taxonomy_id').required())
1218
1220
  .rule(field('taxonomy_id').number({ integer: true, positive: true, message: 'taxonomy_id must be a positive integer' }));
1219
1221
  const UpdateListingSchema = new Validator()
@@ -1342,6 +1344,9 @@ class MemoryCache {
1342
1344
  }
1343
1345
  class EtsyClient {
1344
1346
  constructor(config) {
1347
+ if (!config.sharedSecret) {
1348
+ throw new EtsyAuthError('sharedSecret is REQUIRED for Etsy API v3 application usage. See: https://github.com/profplum700/etsy-v3-api-client/issues/21');
1349
+ }
1345
1350
  this.tokenManager = new TokenManager(config);
1346
1351
  this.baseUrl = config.baseUrl || 'https://api.etsy.com/v3/application';
1347
1352
  this.logger = new DefaultLogger();
@@ -1461,10 +1466,7 @@ class EtsyClient {
1461
1466
  return body;
1462
1467
  }
1463
1468
  getApiKey() {
1464
- if (this.sharedSecret) {
1465
- return `${this.keystring}:${this.sharedSecret}`;
1466
- }
1467
- return this.keystring;
1469
+ return `${this.keystring}:${this.sharedSecret}`;
1468
1470
  }
1469
1471
  async getUser() {
1470
1472
  return this.makeRequest('/users/me');
@@ -2135,6 +2137,22 @@ class EtsyClient {
2135
2137
  async deleteListingVideo(shopId, listingId, videoId) {
2136
2138
  await this.makeRequest(`/shops/${shopId}/listings/${listingId}/videos/${videoId}`, { method: 'DELETE' }, false);
2137
2139
  }
2140
+ async getListingPersonalizations(listingId) {
2141
+ return this.makeRequest(`/listings/${listingId}/personalization`);
2142
+ }
2143
+ async updateListingPersonalization(shopId, listingId, params) {
2144
+ const { supports_multiple_personalization_questions, ...body } = params;
2145
+ const query = supports_multiple_personalization_questions
2146
+ ? '?supports_multiple_personalization_questions=true'
2147
+ : '';
2148
+ return this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization${query}`, {
2149
+ method: 'POST',
2150
+ body: JSON.stringify(body)
2151
+ }, false);
2152
+ }
2153
+ async deleteListingPersonalization(shopId, listingId) {
2154
+ await this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization`, { method: 'DELETE' }, false);
2155
+ }
2138
2156
  async createListingTranslation(shopId, listingId, language, params) {
2139
2157
  const body = this.buildFormBody(params);
2140
2158
  return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`, {
@@ -4282,7 +4300,7 @@ function createTokenManager(config, storage) {
4282
4300
  function createRateLimiter(config) {
4283
4301
  return new EtsyRateLimiter(config);
4284
4302
  }
4285
- const VERSION = '2.2.0';
4303
+ const VERSION = '3.0.1';
4286
4304
  const LIBRARY_NAME = 'etsy-v3-api-client';
4287
4305
  function getLibraryInfo() {
4288
4306
  return {