@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.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.
|
|
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({
|
|
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').
|
|
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
|
-
|
|
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 = '
|
|
4303
|
+
const VERSION = '3.0.1';
|
|
4286
4304
|
const LIBRARY_NAME = 'etsy-v3-api-client';
|
|
4287
4305
|
function getLibraryInfo() {
|
|
4288
4306
|
return {
|