@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/browser.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 = false;
|
|
@@ -1050,10 +1070,10 @@ class FieldValidator {
|
|
|
1050
1070
|
const value = data[this.field];
|
|
1051
1071
|
if (value === undefined || value === null)
|
|
1052
1072
|
return null;
|
|
1053
|
-
if (typeof value !== 'number' || Number.
|
|
1073
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
1054
1074
|
return {
|
|
1055
1075
|
field: this.field,
|
|
1056
|
-
message: options.message || `${this.field} must be a number`,
|
|
1076
|
+
message: options.message || `${this.field} must be a finite number`,
|
|
1057
1077
|
value
|
|
1058
1078
|
};
|
|
1059
1079
|
}
|
|
@@ -1158,28 +1178,10 @@ const CreateListingSchema = new Validator()
|
|
|
1158
1178
|
.rule(field('title').string({ min: 1, max: 140, message: 'title must be 1-140 characters' }))
|
|
1159
1179
|
.rule(field('description').string({ max: 65535, message: 'description must be less than 65535 characters' }))
|
|
1160
1180
|
.rule(field('price').required())
|
|
1161
|
-
.rule(field('price').number({
|
|
1181
|
+
.rule(field('price').number({ positive: true, message: 'price must be a finite positive number' }))
|
|
1162
1182
|
.rule(field('who_made').enum(['i_did', 'someone_else', 'collective'], 'who_made must be one of: i_did, someone_else, collective'))
|
|
1163
|
-
.rule(field('when_made').
|
|
1164
|
-
'made_to_order',
|
|
1165
|
-
'2020_2024',
|
|
1166
|
-
'2010_2019',
|
|
1167
|
-
'2005_2009',
|
|
1168
|
-
'2000_2004',
|
|
1169
|
-
'1990s',
|
|
1170
|
-
'1980s',
|
|
1171
|
-
'1970s',
|
|
1172
|
-
'1960s',
|
|
1173
|
-
'1950s',
|
|
1174
|
-
'1940s',
|
|
1175
|
-
'1930s',
|
|
1176
|
-
'1920s',
|
|
1177
|
-
'1910s',
|
|
1178
|
-
'1900s',
|
|
1179
|
-
'1800s',
|
|
1180
|
-
'1700s',
|
|
1181
|
-
'before_1700'
|
|
1182
|
-
]))
|
|
1183
|
+
.rule(field('when_made').required())
|
|
1184
|
+
.rule(field('when_made').enum(['made_to_order', ...ETSY_WHEN_MADE_VALUES]))
|
|
1183
1185
|
.rule(field('taxonomy_id').required())
|
|
1184
1186
|
.rule(field('taxonomy_id').number({ integer: true, positive: true, message: 'taxonomy_id must be a positive integer' }));
|
|
1185
1187
|
const UpdateListingSchema = new Validator()
|
|
@@ -1305,6 +1307,9 @@ class MemoryCache {
|
|
|
1305
1307
|
}
|
|
1306
1308
|
class EtsyClient {
|
|
1307
1309
|
constructor(config) {
|
|
1310
|
+
if (!config.sharedSecret) {
|
|
1311
|
+
throw new EtsyAuthError('sharedSecret is REQUIRED for Etsy API v3 application usage. See: https://github.com/profplum700/etsy-v3-api-client/issues/21');
|
|
1312
|
+
}
|
|
1308
1313
|
this.tokenManager = new TokenManager(config);
|
|
1309
1314
|
this.baseUrl = config.baseUrl || 'https://api.etsy.com/v3/application';
|
|
1310
1315
|
this.logger = new DefaultLogger();
|
|
@@ -1424,10 +1429,7 @@ class EtsyClient {
|
|
|
1424
1429
|
return body;
|
|
1425
1430
|
}
|
|
1426
1431
|
getApiKey() {
|
|
1427
|
-
|
|
1428
|
-
return `${this.keystring}:${this.sharedSecret}`;
|
|
1429
|
-
}
|
|
1430
|
-
return this.keystring;
|
|
1432
|
+
return `${this.keystring}:${this.sharedSecret}`;
|
|
1431
1433
|
}
|
|
1432
1434
|
async getUser() {
|
|
1433
1435
|
return this.makeRequest('/users/me');
|
|
@@ -2098,6 +2100,22 @@ class EtsyClient {
|
|
|
2098
2100
|
async deleteListingVideo(shopId, listingId, videoId) {
|
|
2099
2101
|
await this.makeRequest(`/shops/${shopId}/listings/${listingId}/videos/${videoId}`, { method: 'DELETE' }, false);
|
|
2100
2102
|
}
|
|
2103
|
+
async getListingPersonalizations(listingId) {
|
|
2104
|
+
return this.makeRequest(`/listings/${listingId}/personalization`);
|
|
2105
|
+
}
|
|
2106
|
+
async updateListingPersonalization(shopId, listingId, params) {
|
|
2107
|
+
const { supports_multiple_personalization_questions, ...body } = params;
|
|
2108
|
+
const query = supports_multiple_personalization_questions
|
|
2109
|
+
? '?supports_multiple_personalization_questions=true'
|
|
2110
|
+
: '';
|
|
2111
|
+
return this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization${query}`, {
|
|
2112
|
+
method: 'POST',
|
|
2113
|
+
body: JSON.stringify(body)
|
|
2114
|
+
}, false);
|
|
2115
|
+
}
|
|
2116
|
+
async deleteListingPersonalization(shopId, listingId) {
|
|
2117
|
+
await this.makeRequest(`/shops/${shopId}/listings/${listingId}/personalization`, { method: 'DELETE' }, false);
|
|
2118
|
+
}
|
|
2101
2119
|
async createListingTranslation(shopId, listingId, language, params) {
|
|
2102
2120
|
const body = this.buildFormBody(params);
|
|
2103
2121
|
return this.makeRequest(`/shops/${shopId}/listings/${listingId}/translations/${language}`, {
|
|
@@ -4094,7 +4112,7 @@ function createTokenManager(config, storage) {
|
|
|
4094
4112
|
function createRateLimiter(config) {
|
|
4095
4113
|
return new EtsyRateLimiter(config);
|
|
4096
4114
|
}
|
|
4097
|
-
const VERSION = '
|
|
4115
|
+
const VERSION = '3.0.1';
|
|
4098
4116
|
const LIBRARY_NAME = 'etsy-v3-api-client';
|
|
4099
4117
|
function getLibraryInfo() {
|
|
4100
4118
|
return {
|