@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/CHANGELOG.md +6 -0
- package/README.md +10 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.esm.js +46 -28
- 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 +46 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -6
- package/dist/index.esm.js +46 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/node.cjs +46 -28
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +46 -28
- package/dist/node.esm.js.map +1 -1
- package/package.json +13 -13
package/dist/node.cjs
CHANGED
|
@@ -251,6 +251,26 @@ class EtsyRateLimitError extends Error {
|
|
|
251
251
|
return this.errorType !== 'qpd_exhausted';
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
const ETSY_WHEN_MADE_VALUES = [
|
|
255
|
+
'2020_2026',
|
|
256
|
+
'2010_2019',
|
|
257
|
+
'2007_2009',
|
|
258
|
+
'before_2007',
|
|
259
|
+
'2000_2006',
|
|
260
|
+
'1990s',
|
|
261
|
+
'1980s',
|
|
262
|
+
'1970s',
|
|
263
|
+
'1960s',
|
|
264
|
+
'1950s',
|
|
265
|
+
'1940s',
|
|
266
|
+
'1930s',
|
|
267
|
+
'1920s',
|
|
268
|
+
'1910s',
|
|
269
|
+
'1900s',
|
|
270
|
+
'1800s',
|
|
271
|
+
'1700s',
|
|
272
|
+
'before_1700'
|
|
273
|
+
];
|
|
254
274
|
|
|
255
275
|
const isBrowser$1 = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
256
276
|
const isNode$1 = typeof process !== 'undefined' && !!process.versions?.node;
|
|
@@ -1088,10 +1108,10 @@ class FieldValidator {
|
|
|
1088
1108
|
const value = data[this.field];
|
|
1089
1109
|
if (value === undefined || value === null)
|
|
1090
1110
|
return null;
|
|
1091
|
-
if (typeof value !== 'number' || Number.
|
|
1111
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
1092
1112
|
return {
|
|
1093
1113
|
field: this.field,
|
|
1094
|
-
message: options.message || `${this.field} must be a number`,
|
|
1114
|
+
message: options.message || `${this.field} must be a finite number`,
|
|
1095
1115
|
value
|
|
1096
1116
|
};
|
|
1097
1117
|
}
|
|
@@ -1196,28 +1216,10 @@ const CreateListingSchema = new Validator()
|
|
|
1196
1216
|
.rule(field('title').string({ min: 1, max: 140, message: 'title must be 1-140 characters' }))
|
|
1197
1217
|
.rule(field('description').string({ max: 65535, message: 'description must be less than 65535 characters' }))
|
|
1198
1218
|
.rule(field('price').required())
|
|
1199
|
-
.rule(field('price').number({
|
|
1219
|
+
.rule(field('price').number({ positive: true, message: 'price must be a finite positive number' }))
|
|
1200
1220
|
.rule(field('who_made').enum(['i_did', 'someone_else', 'collective'], 'who_made must be one of: i_did, someone_else, collective'))
|
|
1201
|
-
.rule(field('when_made').
|
|
1202
|
-
'made_to_order',
|
|
1203
|
-
'2020_2024',
|
|
1204
|
-
'2010_2019',
|
|
1205
|
-
'2005_2009',
|
|
1206
|
-
'2000_2004',
|
|
1207
|
-
'1990s',
|
|
1208
|
-
'1980s',
|
|
1209
|
-
'1970s',
|
|
1210
|
-
'1960s',
|
|
1211
|
-
'1950s',
|
|
1212
|
-
'1940s',
|
|
1213
|
-
'1930s',
|
|
1214
|
-
'1920s',
|
|
1215
|
-
'1910s',
|
|
1216
|
-
'1900s',
|
|
1217
|
-
'1800s',
|
|
1218
|
-
'1700s',
|
|
1219
|
-
'before_1700'
|
|
1220
|
-
]))
|
|
1221
|
+
.rule(field('when_made').required())
|
|
1222
|
+
.rule(field('when_made').enum(['made_to_order', ...ETSY_WHEN_MADE_VALUES]))
|
|
1221
1223
|
.rule(field('taxonomy_id').required())
|
|
1222
1224
|
.rule(field('taxonomy_id').number({ integer: true, positive: true, message: 'taxonomy_id must be a positive integer' }));
|
|
1223
1225
|
const UpdateListingSchema = new Validator()
|
|
@@ -1346,6 +1348,9 @@ class MemoryCache {
|
|
|
1346
1348
|
}
|
|
1347
1349
|
class EtsyClient {
|
|
1348
1350
|
constructor(config) {
|
|
1351
|
+
if (!config.sharedSecret) {
|
|
1352
|
+
throw new EtsyAuthError('sharedSecret is REQUIRED for Etsy API v3 application usage. See: https://github.com/profplum700/etsy-v3-api-client/issues/21');
|
|
1353
|
+
}
|
|
1349
1354
|
this.tokenManager = new TokenManager(config);
|
|
1350
1355
|
this.baseUrl = config.baseUrl || 'https://api.etsy.com/v3/application';
|
|
1351
1356
|
this.logger = new DefaultLogger();
|
|
@@ -1465,10 +1470,7 @@ class EtsyClient {
|
|
|
1465
1470
|
return body;
|
|
1466
1471
|
}
|
|
1467
1472
|
getApiKey() {
|
|
1468
|
-
|
|
1469
|
-
return `${this.keystring}:${this.sharedSecret}`;
|
|
1470
|
-
}
|
|
1471
|
-
return this.keystring;
|
|
1473
|
+
return `${this.keystring}:${this.sharedSecret}`;
|
|
1472
1474
|
}
|
|
1473
1475
|
async getUser() {
|
|
1474
1476
|
return this.makeRequest('/users/me');
|
|
@@ -2139,6 +2141,22 @@ class EtsyClient {
|
|
|
2139
2141
|
async deleteListingVideo(shopId, listingId, videoId) {
|
|
2140
2142
|
await this.makeRequest(`/shops/${shopId}/listings/${listingId}/videos/${videoId}`, { method: 'DELETE' }, false);
|
|
2141
2143
|
}
|
|
2144
|
+
async getListingPersonalizations(listingId) {
|
|
2145
|
+
return this.makeRequest(`/listings/${listingId}/personalization`);
|
|
2146
|
+
}
|
|
2147
|
+
async updateListingPersonalization(shopId, listingId, params) {
|
|
2148
|
+
const { supports_multiple_personalization_questions, ...body } = params;
|
|
2149
|
+
const query = supports_multiple_personalization_questions
|
|
2150
|
+
? '?supports_multiple_personalization_questions=true'
|
|
2151
|
+
: '';
|
|
2152
|
+
return this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization${query}`, {
|
|
2153
|
+
method: 'POST',
|
|
2154
|
+
body: JSON.stringify(body)
|
|
2155
|
+
}, false);
|
|
2156
|
+
}
|
|
2157
|
+
async deleteListingPersonalization(shopId, listingId) {
|
|
2158
|
+
await this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization`, { method: 'DELETE' }, false);
|
|
2159
|
+
}
|
|
2142
2160
|
async createListingTranslation(shopId, listingId, language, params) {
|
|
2143
2161
|
const body = this.buildFormBody(params);
|
|
2144
2162
|
return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`, {
|
|
@@ -4286,7 +4304,7 @@ function createTokenManager(config, storage) {
|
|
|
4286
4304
|
function createRateLimiter(config) {
|
|
4287
4305
|
return new EtsyRateLimiter(config);
|
|
4288
4306
|
}
|
|
4289
|
-
const VERSION = '
|
|
4307
|
+
const VERSION = '3.0.1';
|
|
4290
4308
|
const LIBRARY_NAME = 'etsy-v3-api-client';
|
|
4291
4309
|
function getLibraryInfo() {
|
|
4292
4310
|
return {
|