@profplum700/etsy-v3-api-client 1.0.1 → 2.3.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 +290 -1
- package/README.md +28 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.esm.js +1766 -7
- 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 +1935 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1071 -5
- package/dist/index.esm.js +1893 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8517 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +1180 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/index.umd.min.js +2 -0
- package/dist/index.umd.min.js.map +1 -0
- package/dist/node.cjs +1935 -6
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +1893 -7
- package/dist/node.esm.js.map +1 -1
- package/package.json +25 -16
package/dist/index.d.ts
CHANGED
|
@@ -39,14 +39,28 @@ interface EtsyTokenResponse {
|
|
|
39
39
|
scope: string;
|
|
40
40
|
}
|
|
41
41
|
type TokenRefreshCallback = (_accessToken: string, _refreshToken: string, _expiresAt: Date) => void;
|
|
42
|
+
type TokenRotationCallback = (oldTokens: EtsyTokens, newTokens: EtsyTokens) => void | Promise<void>;
|
|
42
43
|
interface TokenStorage {
|
|
43
44
|
save(_tokens: EtsyTokens): Promise<void>;
|
|
44
45
|
load(): Promise<EtsyTokens | null>;
|
|
45
46
|
clear(): Promise<void>;
|
|
46
47
|
}
|
|
48
|
+
interface TokenRotationConfig {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
rotateBeforeExpiry: number;
|
|
51
|
+
onRotation?: TokenRotationCallback;
|
|
52
|
+
autoSchedule?: boolean;
|
|
53
|
+
checkInterval?: number;
|
|
54
|
+
}
|
|
55
|
+
interface EtsyPagination {
|
|
56
|
+
next_offset?: number;
|
|
57
|
+
effective_limit?: number;
|
|
58
|
+
effective_offset?: number;
|
|
59
|
+
}
|
|
47
60
|
interface EtsyApiResponse<T> {
|
|
48
61
|
count: number;
|
|
49
62
|
results: T[];
|
|
63
|
+
pagination?: EtsyPagination;
|
|
50
64
|
}
|
|
51
65
|
interface EtsyUser {
|
|
52
66
|
user_id: number;
|
|
@@ -233,6 +247,14 @@ interface EtsyListingPropertyValue {
|
|
|
233
247
|
value_ids?: number[];
|
|
234
248
|
values?: string[];
|
|
235
249
|
}
|
|
250
|
+
interface EtsySellerTaxonomyNode {
|
|
251
|
+
id: number;
|
|
252
|
+
level: number;
|
|
253
|
+
name: string;
|
|
254
|
+
parent_id: number | null;
|
|
255
|
+
children: EtsySellerTaxonomyNode[];
|
|
256
|
+
full_path_taxonomy_ids: number[];
|
|
257
|
+
}
|
|
236
258
|
interface ListingParams {
|
|
237
259
|
limit?: number;
|
|
238
260
|
offset?: number;
|
|
@@ -264,12 +286,25 @@ interface RateLimitStatus {
|
|
|
264
286
|
resetTime: Date;
|
|
265
287
|
canMakeRequest: boolean;
|
|
266
288
|
}
|
|
289
|
+
interface EtsyErrorDetails {
|
|
290
|
+
statusCode: number;
|
|
291
|
+
errorCode?: string;
|
|
292
|
+
field?: string;
|
|
293
|
+
suggestion?: string;
|
|
294
|
+
retryAfter?: number;
|
|
295
|
+
}
|
|
267
296
|
declare class EtsyApiError extends Error {
|
|
268
297
|
_statusCode?: number | undefined;
|
|
269
298
|
_response?: unknown | undefined;
|
|
270
|
-
|
|
299
|
+
_retryAfter?: number | undefined;
|
|
300
|
+
details: EtsyErrorDetails;
|
|
301
|
+
constructor(message: string, _statusCode?: number | undefined, _response?: unknown | undefined, _retryAfter?: number | undefined);
|
|
271
302
|
get statusCode(): number | undefined;
|
|
272
303
|
get response(): unknown | undefined;
|
|
304
|
+
isRetryable(): boolean;
|
|
305
|
+
getRetryAfter(): number | null;
|
|
306
|
+
getRateLimitReset(): Date | null;
|
|
307
|
+
getUserFriendlyMessage(): string;
|
|
273
308
|
}
|
|
274
309
|
declare class EtsyAuthError extends Error {
|
|
275
310
|
_code?: string | undefined;
|
|
@@ -293,6 +328,676 @@ interface LoggerInterface {
|
|
|
293
328
|
warn(_message: string, ..._args: unknown[]): void;
|
|
294
329
|
error(_message: string, ..._args: unknown[]): void;
|
|
295
330
|
}
|
|
331
|
+
declare const ETSY_WHEN_MADE_VALUES: readonly ["1990s", "1980s", "1970s", "1960s", "1950s", "1940s", "1930s", "1920s", "1910s", "1900s", "1800s", "1700s", "before_1700"];
|
|
332
|
+
interface UpdateShopParams {
|
|
333
|
+
title?: string;
|
|
334
|
+
announcement?: string;
|
|
335
|
+
sale_message?: string;
|
|
336
|
+
digital_sale_message?: string;
|
|
337
|
+
}
|
|
338
|
+
interface CreateShopSectionParams {
|
|
339
|
+
title: string;
|
|
340
|
+
}
|
|
341
|
+
interface UpdateShopSectionParams {
|
|
342
|
+
title: string;
|
|
343
|
+
}
|
|
344
|
+
interface EtsyShopReceipt {
|
|
345
|
+
receipt_id: number;
|
|
346
|
+
receipt_type: number;
|
|
347
|
+
seller_user_id: number;
|
|
348
|
+
seller_email: string;
|
|
349
|
+
buyer_user_id: number;
|
|
350
|
+
buyer_email: string;
|
|
351
|
+
name: string;
|
|
352
|
+
first_line: string;
|
|
353
|
+
second_line?: string;
|
|
354
|
+
city: string;
|
|
355
|
+
state?: string;
|
|
356
|
+
zip: string;
|
|
357
|
+
status: 'open' | 'completed' | 'payment-processing' | 'canceled';
|
|
358
|
+
formatted_address: string;
|
|
359
|
+
country_iso: string;
|
|
360
|
+
payment_method: string;
|
|
361
|
+
payment_email?: string;
|
|
362
|
+
message_from_seller?: string;
|
|
363
|
+
message_from_buyer?: string;
|
|
364
|
+
message_from_payment?: string;
|
|
365
|
+
is_paid: boolean;
|
|
366
|
+
is_shipped: boolean;
|
|
367
|
+
create_timestamp: number;
|
|
368
|
+
created_timestamp: number;
|
|
369
|
+
update_timestamp: number;
|
|
370
|
+
updated_timestamp: number;
|
|
371
|
+
is_gift: boolean;
|
|
372
|
+
gift_message?: string;
|
|
373
|
+
grandtotal: {
|
|
374
|
+
amount: number;
|
|
375
|
+
divisor: number;
|
|
376
|
+
currency_code: string;
|
|
377
|
+
};
|
|
378
|
+
subtotal: {
|
|
379
|
+
amount: number;
|
|
380
|
+
divisor: number;
|
|
381
|
+
currency_code: string;
|
|
382
|
+
};
|
|
383
|
+
total_price: {
|
|
384
|
+
amount: number;
|
|
385
|
+
divisor: number;
|
|
386
|
+
currency_code: string;
|
|
387
|
+
};
|
|
388
|
+
total_shipping_cost: {
|
|
389
|
+
amount: number;
|
|
390
|
+
divisor: number;
|
|
391
|
+
currency_code: string;
|
|
392
|
+
};
|
|
393
|
+
total_tax_cost: {
|
|
394
|
+
amount: number;
|
|
395
|
+
divisor: number;
|
|
396
|
+
currency_code: string;
|
|
397
|
+
};
|
|
398
|
+
total_vat_cost: {
|
|
399
|
+
amount: number;
|
|
400
|
+
divisor: number;
|
|
401
|
+
currency_code: string;
|
|
402
|
+
};
|
|
403
|
+
discount_amt: {
|
|
404
|
+
amount: number;
|
|
405
|
+
divisor: number;
|
|
406
|
+
currency_code: string;
|
|
407
|
+
};
|
|
408
|
+
gift_wrap_price: {
|
|
409
|
+
amount: number;
|
|
410
|
+
divisor: number;
|
|
411
|
+
currency_code: string;
|
|
412
|
+
};
|
|
413
|
+
shipments?: EtsyShopReceiptShipment[];
|
|
414
|
+
transactions?: EtsyShopReceiptTransaction[];
|
|
415
|
+
refunds?: EtsyShopRefund[];
|
|
416
|
+
}
|
|
417
|
+
interface EtsyShopReceiptTransaction {
|
|
418
|
+
transaction_id: number;
|
|
419
|
+
title: string;
|
|
420
|
+
description: string;
|
|
421
|
+
seller_user_id: number;
|
|
422
|
+
buyer_user_id: number;
|
|
423
|
+
create_timestamp: number;
|
|
424
|
+
created_timestamp: number;
|
|
425
|
+
paid_timestamp: number;
|
|
426
|
+
shipped_timestamp: number;
|
|
427
|
+
quantity: number;
|
|
428
|
+
listing_image_id?: number;
|
|
429
|
+
receipt_id: number;
|
|
430
|
+
is_digital: boolean;
|
|
431
|
+
file_data: string;
|
|
432
|
+
listing_id: number;
|
|
433
|
+
transaction_type: string;
|
|
434
|
+
product_id?: number;
|
|
435
|
+
sku?: string;
|
|
436
|
+
price: {
|
|
437
|
+
amount: number;
|
|
438
|
+
divisor: number;
|
|
439
|
+
currency_code: string;
|
|
440
|
+
};
|
|
441
|
+
shipping_cost: {
|
|
442
|
+
amount: number;
|
|
443
|
+
divisor: number;
|
|
444
|
+
currency_code: string;
|
|
445
|
+
};
|
|
446
|
+
variations?: EtsyTransactionVariation[];
|
|
447
|
+
product_data?: EtsyListingProduct[];
|
|
448
|
+
shipping_profile_id?: number;
|
|
449
|
+
min_processing_days?: number;
|
|
450
|
+
max_processing_days?: number;
|
|
451
|
+
shipping_method?: string;
|
|
452
|
+
shipping_upgrade?: string;
|
|
453
|
+
expected_ship_date?: number;
|
|
454
|
+
buyer_coupon?: number;
|
|
455
|
+
shop_coupon?: number;
|
|
456
|
+
}
|
|
457
|
+
interface EtsyTransactionVariation {
|
|
458
|
+
property_id: number;
|
|
459
|
+
value_id: number;
|
|
460
|
+
formatted_name: string;
|
|
461
|
+
formatted_value: string;
|
|
462
|
+
}
|
|
463
|
+
interface EtsyShopReceiptShipment {
|
|
464
|
+
receipt_shipping_id: number;
|
|
465
|
+
shipment_notification_timestamp: number;
|
|
466
|
+
carrier_name: string;
|
|
467
|
+
tracking_code: string;
|
|
468
|
+
}
|
|
469
|
+
interface EtsyShopRefund {
|
|
470
|
+
amount: {
|
|
471
|
+
amount: number;
|
|
472
|
+
divisor: number;
|
|
473
|
+
currency_code: string;
|
|
474
|
+
};
|
|
475
|
+
created_timestamp: number;
|
|
476
|
+
reason?: string;
|
|
477
|
+
note_from_issuer?: string;
|
|
478
|
+
status: string;
|
|
479
|
+
}
|
|
480
|
+
interface GetShopReceiptsParams {
|
|
481
|
+
limit?: number;
|
|
482
|
+
offset?: number;
|
|
483
|
+
sort_on?: 'created' | 'updated' | 'paid';
|
|
484
|
+
sort_order?: 'up' | 'down';
|
|
485
|
+
min_created?: number;
|
|
486
|
+
max_created?: number;
|
|
487
|
+
min_last_modified?: number;
|
|
488
|
+
max_last_modified?: number;
|
|
489
|
+
was_paid?: boolean;
|
|
490
|
+
was_shipped?: boolean;
|
|
491
|
+
was_delivered?: boolean;
|
|
492
|
+
}
|
|
493
|
+
interface UpdateShopReceiptParams {
|
|
494
|
+
was_shipped?: boolean;
|
|
495
|
+
was_paid?: boolean;
|
|
496
|
+
message_from_seller?: string;
|
|
497
|
+
}
|
|
498
|
+
interface EtsyShippingProfile {
|
|
499
|
+
shipping_profile_id: number;
|
|
500
|
+
title: string;
|
|
501
|
+
user_id: number;
|
|
502
|
+
min_processing_days: number;
|
|
503
|
+
max_processing_days: number;
|
|
504
|
+
processing_days_display_label: string;
|
|
505
|
+
origin_country_iso: string;
|
|
506
|
+
origin_postal_code?: string;
|
|
507
|
+
profile_type: 'manual' | 'calculated';
|
|
508
|
+
domestic_handling_fee?: number;
|
|
509
|
+
international_handling_fee?: number;
|
|
510
|
+
shipping_profile_destinations?: EtsyShippingProfileDestination[];
|
|
511
|
+
shipping_profile_upgrades?: EtsyShippingProfileUpgrade[];
|
|
512
|
+
}
|
|
513
|
+
interface EtsyShippingProfileDestination {
|
|
514
|
+
shipping_profile_destination_id: number;
|
|
515
|
+
shipping_profile_id: number;
|
|
516
|
+
origin_country_iso: string;
|
|
517
|
+
destination_country_iso?: string;
|
|
518
|
+
destination_region: string;
|
|
519
|
+
primary_cost: {
|
|
520
|
+
amount: number;
|
|
521
|
+
divisor: number;
|
|
522
|
+
currency_code: string;
|
|
523
|
+
};
|
|
524
|
+
secondary_cost: {
|
|
525
|
+
amount: number;
|
|
526
|
+
divisor: number;
|
|
527
|
+
currency_code: string;
|
|
528
|
+
};
|
|
529
|
+
shipping_carrier_id?: number;
|
|
530
|
+
mail_class?: string;
|
|
531
|
+
min_delivery_days?: number;
|
|
532
|
+
max_delivery_days?: number;
|
|
533
|
+
}
|
|
534
|
+
interface EtsyShippingProfileUpgrade {
|
|
535
|
+
shipping_profile_id: number;
|
|
536
|
+
upgrade_id: number;
|
|
537
|
+
upgrade_name: string;
|
|
538
|
+
type: string;
|
|
539
|
+
rank: number;
|
|
540
|
+
language: string;
|
|
541
|
+
price: {
|
|
542
|
+
amount: number;
|
|
543
|
+
divisor: number;
|
|
544
|
+
currency_code: string;
|
|
545
|
+
};
|
|
546
|
+
secondary_price: {
|
|
547
|
+
amount: number;
|
|
548
|
+
divisor: number;
|
|
549
|
+
currency_code: string;
|
|
550
|
+
};
|
|
551
|
+
shipping_carrier_id: number;
|
|
552
|
+
mail_class?: string;
|
|
553
|
+
min_delivery_days?: number;
|
|
554
|
+
max_delivery_days?: number;
|
|
555
|
+
}
|
|
556
|
+
interface CreateShippingProfileParams {
|
|
557
|
+
title: string;
|
|
558
|
+
origin_country_iso: string;
|
|
559
|
+
primary_cost: number;
|
|
560
|
+
secondary_cost: number;
|
|
561
|
+
min_processing_days: number;
|
|
562
|
+
max_processing_days: number;
|
|
563
|
+
processing_days_display_label?: string;
|
|
564
|
+
origin_postal_code?: string;
|
|
565
|
+
destination_country_iso?: string;
|
|
566
|
+
destination_region?: string;
|
|
567
|
+
mail_class?: string;
|
|
568
|
+
min_delivery_days?: number;
|
|
569
|
+
max_delivery_days?: number;
|
|
570
|
+
}
|
|
571
|
+
interface UpdateShippingProfileParams {
|
|
572
|
+
title?: string;
|
|
573
|
+
origin_country_iso?: string;
|
|
574
|
+
min_processing_days?: number;
|
|
575
|
+
max_processing_days?: number;
|
|
576
|
+
processing_days_display_label?: string;
|
|
577
|
+
origin_postal_code?: string;
|
|
578
|
+
}
|
|
579
|
+
interface CreateShippingProfileDestinationParams {
|
|
580
|
+
primary_cost: number;
|
|
581
|
+
secondary_cost: number;
|
|
582
|
+
destination_country_iso?: string;
|
|
583
|
+
destination_region?: string;
|
|
584
|
+
mail_class?: string;
|
|
585
|
+
min_delivery_days?: number;
|
|
586
|
+
max_delivery_days?: number;
|
|
587
|
+
}
|
|
588
|
+
interface UpdateShippingProfileDestinationParams {
|
|
589
|
+
primary_cost?: number;
|
|
590
|
+
secondary_cost?: number;
|
|
591
|
+
destination_country_iso?: string;
|
|
592
|
+
destination_region?: string;
|
|
593
|
+
mail_class?: string;
|
|
594
|
+
min_delivery_days?: number;
|
|
595
|
+
max_delivery_days?: number;
|
|
596
|
+
}
|
|
597
|
+
interface CreateReceiptShipmentParams {
|
|
598
|
+
tracking_code: string;
|
|
599
|
+
carrier_name: string;
|
|
600
|
+
send_bcc?: boolean;
|
|
601
|
+
note_to_buyer?: string;
|
|
602
|
+
}
|
|
603
|
+
interface EtsyPaymentAccountLedgerEntry {
|
|
604
|
+
entry_id: number;
|
|
605
|
+
ledger_id: number;
|
|
606
|
+
sequence_number: number;
|
|
607
|
+
amount: {
|
|
608
|
+
amount: number;
|
|
609
|
+
divisor: number;
|
|
610
|
+
currency_code: string;
|
|
611
|
+
};
|
|
612
|
+
currency: string;
|
|
613
|
+
description: string;
|
|
614
|
+
balance: {
|
|
615
|
+
amount: number;
|
|
616
|
+
divisor: number;
|
|
617
|
+
currency_code: string;
|
|
618
|
+
};
|
|
619
|
+
create_date: number;
|
|
620
|
+
created_timestamp: number;
|
|
621
|
+
ledger_type: string;
|
|
622
|
+
entry_type: string;
|
|
623
|
+
reference_type?: string;
|
|
624
|
+
reference_id?: string;
|
|
625
|
+
payment_adjustments?: EtsyPaymentAdjustment[];
|
|
626
|
+
}
|
|
627
|
+
interface EtsyPaymentAdjustment {
|
|
628
|
+
payment_adjustment_id: number;
|
|
629
|
+
payment_id: number;
|
|
630
|
+
status: string;
|
|
631
|
+
is_success: boolean;
|
|
632
|
+
user_id: number;
|
|
633
|
+
reason_code: string;
|
|
634
|
+
total_adjustment_amount: {
|
|
635
|
+
amount: number;
|
|
636
|
+
divisor: number;
|
|
637
|
+
currency_code: string;
|
|
638
|
+
};
|
|
639
|
+
shop_total_adjustment_amount: {
|
|
640
|
+
amount: number;
|
|
641
|
+
divisor: number;
|
|
642
|
+
currency_code: string;
|
|
643
|
+
};
|
|
644
|
+
buyer_total_adjustment_amount: {
|
|
645
|
+
amount: number;
|
|
646
|
+
divisor: number;
|
|
647
|
+
currency_code: string;
|
|
648
|
+
};
|
|
649
|
+
total_fee_adjustment_amount: {
|
|
650
|
+
amount: number;
|
|
651
|
+
divisor: number;
|
|
652
|
+
currency_code: string;
|
|
653
|
+
};
|
|
654
|
+
create_timestamp: number;
|
|
655
|
+
created_timestamp: number;
|
|
656
|
+
update_timestamp: number;
|
|
657
|
+
updated_timestamp: number;
|
|
658
|
+
}
|
|
659
|
+
interface EtsyPayment {
|
|
660
|
+
payment_id: number;
|
|
661
|
+
buyer_user_id: number;
|
|
662
|
+
shop_id: number;
|
|
663
|
+
receipt_id: number;
|
|
664
|
+
amount_gross: {
|
|
665
|
+
amount: number;
|
|
666
|
+
divisor: number;
|
|
667
|
+
currency_code: string;
|
|
668
|
+
};
|
|
669
|
+
amount_fees: {
|
|
670
|
+
amount: number;
|
|
671
|
+
divisor: number;
|
|
672
|
+
currency_code: string;
|
|
673
|
+
};
|
|
674
|
+
amount_net: {
|
|
675
|
+
amount: number;
|
|
676
|
+
divisor: number;
|
|
677
|
+
currency_code: string;
|
|
678
|
+
};
|
|
679
|
+
posted_gross: {
|
|
680
|
+
amount: number;
|
|
681
|
+
divisor: number;
|
|
682
|
+
currency_code: string;
|
|
683
|
+
};
|
|
684
|
+
posted_fees: {
|
|
685
|
+
amount: number;
|
|
686
|
+
divisor: number;
|
|
687
|
+
currency_code: string;
|
|
688
|
+
};
|
|
689
|
+
posted_net: {
|
|
690
|
+
amount: number;
|
|
691
|
+
divisor: number;
|
|
692
|
+
currency_code: string;
|
|
693
|
+
};
|
|
694
|
+
adjusted_gross: {
|
|
695
|
+
amount: number;
|
|
696
|
+
divisor: number;
|
|
697
|
+
currency_code: string;
|
|
698
|
+
};
|
|
699
|
+
adjusted_fees: {
|
|
700
|
+
amount: number;
|
|
701
|
+
divisor: number;
|
|
702
|
+
currency_code: string;
|
|
703
|
+
};
|
|
704
|
+
adjusted_net: {
|
|
705
|
+
amount: number;
|
|
706
|
+
divisor: number;
|
|
707
|
+
currency_code: string;
|
|
708
|
+
};
|
|
709
|
+
currency: string;
|
|
710
|
+
shop_currency: string;
|
|
711
|
+
buyer_currency: string;
|
|
712
|
+
shipping_user_id?: number;
|
|
713
|
+
shipping_address_id?: number;
|
|
714
|
+
billing_address_id: number;
|
|
715
|
+
status: string;
|
|
716
|
+
shipped_timestamp?: number;
|
|
717
|
+
create_timestamp: number;
|
|
718
|
+
created_timestamp: number;
|
|
719
|
+
update_timestamp: number;
|
|
720
|
+
updated_timestamp: number;
|
|
721
|
+
payment_adjustments?: EtsyPaymentAdjustment[];
|
|
722
|
+
}
|
|
723
|
+
interface GetPaymentAccountLedgerEntriesParams {
|
|
724
|
+
min_created: number;
|
|
725
|
+
max_created: number;
|
|
726
|
+
limit?: number;
|
|
727
|
+
offset?: number;
|
|
728
|
+
}
|
|
729
|
+
interface CreateDraftListingParams {
|
|
730
|
+
quantity: number;
|
|
731
|
+
title: string;
|
|
732
|
+
description: string;
|
|
733
|
+
price: number;
|
|
734
|
+
who_made: 'i_did' | 'someone_else' | 'collective';
|
|
735
|
+
when_made: typeof ETSY_WHEN_MADE_VALUES[number] | 'made_to_order';
|
|
736
|
+
taxonomy_id: number;
|
|
737
|
+
shipping_profile_id?: number;
|
|
738
|
+
return_policy_id?: number;
|
|
739
|
+
materials?: string[];
|
|
740
|
+
shop_section_id?: number;
|
|
741
|
+
processing_min?: number;
|
|
742
|
+
processing_max?: number;
|
|
743
|
+
tags?: string[];
|
|
744
|
+
styles?: string[];
|
|
745
|
+
item_weight?: number;
|
|
746
|
+
item_length?: number;
|
|
747
|
+
item_width?: number;
|
|
748
|
+
item_height?: number;
|
|
749
|
+
item_weight_unit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
750
|
+
item_dimensions_unit?: 'in' | 'ft' | 'mm' | 'cm' | 'm' | 'yd' | 'inches';
|
|
751
|
+
is_personalizable?: boolean;
|
|
752
|
+
personalization_is_required?: boolean;
|
|
753
|
+
personalization_char_count_max?: number;
|
|
754
|
+
personalization_instructions?: string;
|
|
755
|
+
production_partner_ids?: number[];
|
|
756
|
+
image_ids?: number[];
|
|
757
|
+
is_supply?: boolean;
|
|
758
|
+
is_customizable?: boolean;
|
|
759
|
+
is_taxable?: boolean;
|
|
760
|
+
type?: 'physical' | 'download' | 'both';
|
|
761
|
+
}
|
|
762
|
+
interface UpdateListingParams {
|
|
763
|
+
image_ids?: number[];
|
|
764
|
+
title?: string;
|
|
765
|
+
description?: string;
|
|
766
|
+
materials?: string[];
|
|
767
|
+
should_auto_renew?: boolean;
|
|
768
|
+
shipping_profile_id?: number;
|
|
769
|
+
return_policy_id?: number;
|
|
770
|
+
shop_section_id?: number;
|
|
771
|
+
item_weight?: number;
|
|
772
|
+
item_length?: number;
|
|
773
|
+
item_width?: number;
|
|
774
|
+
item_height?: number;
|
|
775
|
+
item_weight_unit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
776
|
+
item_dimensions_unit?: 'in' | 'ft' | 'mm' | 'cm' | 'm' | 'yd' | 'inches';
|
|
777
|
+
is_taxable?: boolean;
|
|
778
|
+
taxonomy_id?: number;
|
|
779
|
+
tags?: string[];
|
|
780
|
+
who_made?: 'i_did' | 'someone_else' | 'collective';
|
|
781
|
+
when_made?: typeof ETSY_WHEN_MADE_VALUES[number] | 'made_to_order';
|
|
782
|
+
featured_rank?: number;
|
|
783
|
+
is_personalizable?: boolean;
|
|
784
|
+
personalization_is_required?: boolean;
|
|
785
|
+
personalization_char_count_max?: number;
|
|
786
|
+
personalization_instructions?: string;
|
|
787
|
+
state?: 'active' | 'inactive' | 'draft';
|
|
788
|
+
is_supply?: boolean;
|
|
789
|
+
production_partner_ids?: number[];
|
|
790
|
+
type?: 'physical' | 'download' | 'both';
|
|
791
|
+
styles?: string[];
|
|
792
|
+
processing_min?: number;
|
|
793
|
+
processing_max?: number;
|
|
794
|
+
}
|
|
795
|
+
interface UpdateListingInventoryParams {
|
|
796
|
+
products: Array<{
|
|
797
|
+
sku?: string;
|
|
798
|
+
property_values?: Array<{
|
|
799
|
+
property_id: number;
|
|
800
|
+
property_name?: string;
|
|
801
|
+
scale_id?: number;
|
|
802
|
+
scale_name?: string;
|
|
803
|
+
value_ids?: number[];
|
|
804
|
+
values?: string[];
|
|
805
|
+
}>;
|
|
806
|
+
offerings: Array<{
|
|
807
|
+
offering_id?: number;
|
|
808
|
+
price: number;
|
|
809
|
+
quantity: number;
|
|
810
|
+
is_enabled: boolean;
|
|
811
|
+
}>;
|
|
812
|
+
}>;
|
|
813
|
+
price_on_property?: number[];
|
|
814
|
+
quantity_on_property?: number[];
|
|
815
|
+
sku_on_property?: number[];
|
|
816
|
+
}
|
|
817
|
+
interface EtsyListingProperty {
|
|
818
|
+
property_id: number;
|
|
819
|
+
name: string;
|
|
820
|
+
display_name: string;
|
|
821
|
+
scales?: EtsyListingPropertyScale[];
|
|
822
|
+
possible_values?: EtsyListingPropertyValue[];
|
|
823
|
+
selected_values?: EtsyListingPropertyValue[];
|
|
824
|
+
supports_attributes?: boolean;
|
|
825
|
+
supports_variations?: boolean;
|
|
826
|
+
is_multivalued?: boolean;
|
|
827
|
+
is_required?: boolean;
|
|
828
|
+
max_values_allowed?: number;
|
|
829
|
+
}
|
|
830
|
+
interface EtsyListingPropertyScale {
|
|
831
|
+
scale_id: number;
|
|
832
|
+
display_name: string;
|
|
833
|
+
description?: string;
|
|
834
|
+
}
|
|
835
|
+
interface EtsyBuyerTaxonomyNode {
|
|
836
|
+
id: number;
|
|
837
|
+
level: number;
|
|
838
|
+
name: string;
|
|
839
|
+
parent_id: number | null;
|
|
840
|
+
children: EtsyBuyerTaxonomyNode[];
|
|
841
|
+
full_path_taxonomy_ids: number[];
|
|
842
|
+
}
|
|
843
|
+
interface EtsyBuyerTaxonomyPropertyScale {
|
|
844
|
+
scale_id: number;
|
|
845
|
+
display_name: string;
|
|
846
|
+
description?: string;
|
|
847
|
+
}
|
|
848
|
+
interface EtsyBuyerTaxonomyPropertyValue {
|
|
849
|
+
value_id: number;
|
|
850
|
+
name: string;
|
|
851
|
+
scale_id?: number;
|
|
852
|
+
equal_to?: number[];
|
|
853
|
+
}
|
|
854
|
+
interface EtsyBuyerTaxonomyProperty {
|
|
855
|
+
property_id: number;
|
|
856
|
+
name: string;
|
|
857
|
+
display_name: string;
|
|
858
|
+
scales?: EtsyBuyerTaxonomyPropertyScale[];
|
|
859
|
+
possible_values?: EtsyBuyerTaxonomyPropertyValue[];
|
|
860
|
+
selected_values?: EtsyBuyerTaxonomyPropertyValue[];
|
|
861
|
+
supports_attributes: boolean;
|
|
862
|
+
supports_variations: boolean;
|
|
863
|
+
is_multivalued: boolean;
|
|
864
|
+
is_required: boolean;
|
|
865
|
+
max_values_allowed?: number;
|
|
866
|
+
}
|
|
867
|
+
interface EtsyShopProductionPartner {
|
|
868
|
+
production_partner_id: number;
|
|
869
|
+
partner_name: string;
|
|
870
|
+
location: string;
|
|
871
|
+
}
|
|
872
|
+
interface UploadListingImageParams {
|
|
873
|
+
image: File | Blob | Buffer;
|
|
874
|
+
listing_id: number;
|
|
875
|
+
rank?: number;
|
|
876
|
+
overwrite?: boolean;
|
|
877
|
+
is_watermarked?: boolean;
|
|
878
|
+
alt_text?: string;
|
|
879
|
+
}
|
|
880
|
+
interface UploadListingFileParams {
|
|
881
|
+
file: File | Blob | Buffer;
|
|
882
|
+
listing_id: number;
|
|
883
|
+
name?: string;
|
|
884
|
+
rank?: number;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
interface BulkOperationConfig {
|
|
888
|
+
concurrency?: number;
|
|
889
|
+
stopOnError?: boolean;
|
|
890
|
+
onProgress?: (completed: number, total: number, lastResult?: BulkOperationResult<unknown>) => void;
|
|
891
|
+
onItemComplete?: (result: BulkOperationResult<unknown>) => void;
|
|
892
|
+
onItemError?: (error: BulkOperationError) => void;
|
|
893
|
+
}
|
|
894
|
+
interface BulkOperationResult<T> {
|
|
895
|
+
success: boolean;
|
|
896
|
+
data?: T;
|
|
897
|
+
error?: Error;
|
|
898
|
+
id: string | number;
|
|
899
|
+
index: number;
|
|
900
|
+
}
|
|
901
|
+
interface BulkOperationError {
|
|
902
|
+
id: string | number;
|
|
903
|
+
index: number;
|
|
904
|
+
error: Error;
|
|
905
|
+
}
|
|
906
|
+
interface BulkUpdateListingOperation {
|
|
907
|
+
listingId: string | number;
|
|
908
|
+
updates: UpdateListingParams;
|
|
909
|
+
}
|
|
910
|
+
interface BulkImageUploadOperation {
|
|
911
|
+
file: Blob | Buffer | string;
|
|
912
|
+
rank: number;
|
|
913
|
+
altText?: string;
|
|
914
|
+
}
|
|
915
|
+
interface BulkOperationSummary<T> {
|
|
916
|
+
total: number;
|
|
917
|
+
successful: number;
|
|
918
|
+
failed: number;
|
|
919
|
+
results: BulkOperationResult<T>[];
|
|
920
|
+
errors: BulkOperationError[];
|
|
921
|
+
duration: number;
|
|
922
|
+
}
|
|
923
|
+
declare class BulkOperationManager {
|
|
924
|
+
private concurrency;
|
|
925
|
+
private stopOnError;
|
|
926
|
+
private onProgress?;
|
|
927
|
+
private onItemComplete?;
|
|
928
|
+
private onItemError?;
|
|
929
|
+
constructor(config?: BulkOperationConfig);
|
|
930
|
+
executeBulk<TInput, TOutput>(items: TInput[], operation: (item: TInput, index: number) => Promise<TOutput>, getId?: (item: TInput, index: number) => string | number): Promise<BulkOperationSummary<TOutput>>;
|
|
931
|
+
private worker;
|
|
932
|
+
setConcurrency(concurrency: number): void;
|
|
933
|
+
getConcurrency(): number;
|
|
934
|
+
}
|
|
935
|
+
declare function createBulkOperationManager(config?: BulkOperationConfig): BulkOperationManager;
|
|
936
|
+
declare function executeBulkOperation<TInput, TOutput>(items: TInput[], operation: (item: TInput, index: number) => Promise<TOutput>, config?: BulkOperationConfig): Promise<BulkOperationSummary<TOutput>>;
|
|
937
|
+
|
|
938
|
+
interface ValidationResult {
|
|
939
|
+
valid: boolean;
|
|
940
|
+
errors: ValidationError[];
|
|
941
|
+
}
|
|
942
|
+
interface ValidationError {
|
|
943
|
+
field: string;
|
|
944
|
+
message: string;
|
|
945
|
+
value?: unknown;
|
|
946
|
+
}
|
|
947
|
+
interface ValidationSchema<T = unknown> {
|
|
948
|
+
validate(data: T): ValidationResult;
|
|
949
|
+
}
|
|
950
|
+
interface ValidatorFunction<T = unknown> {
|
|
951
|
+
(data: T): ValidationResult;
|
|
952
|
+
}
|
|
953
|
+
declare class Validator<T = unknown> implements ValidationSchema<T> {
|
|
954
|
+
private validators;
|
|
955
|
+
rule(validator: (data: T) => ValidationError | null): this;
|
|
956
|
+
validate(data: T): ValidationResult;
|
|
957
|
+
}
|
|
958
|
+
declare class FieldValidator {
|
|
959
|
+
private field;
|
|
960
|
+
constructor(field: string);
|
|
961
|
+
required(message?: string): (data: unknown) => ValidationError | null;
|
|
962
|
+
string(options: {
|
|
963
|
+
min?: number;
|
|
964
|
+
max?: number;
|
|
965
|
+
pattern?: RegExp;
|
|
966
|
+
message?: string;
|
|
967
|
+
}): (data: unknown) => ValidationError | null;
|
|
968
|
+
number(options: {
|
|
969
|
+
min?: number;
|
|
970
|
+
max?: number;
|
|
971
|
+
integer?: boolean;
|
|
972
|
+
positive?: boolean;
|
|
973
|
+
message?: string;
|
|
974
|
+
}): (data: unknown) => ValidationError | null;
|
|
975
|
+
enum<T>(allowedValues: T[], message?: string): (data: unknown) => ValidationError | null;
|
|
976
|
+
array(options: {
|
|
977
|
+
min?: number;
|
|
978
|
+
max?: number;
|
|
979
|
+
itemValidator?: (item: unknown) => boolean;
|
|
980
|
+
message?: string;
|
|
981
|
+
}): (data: unknown) => ValidationError | null;
|
|
982
|
+
}
|
|
983
|
+
declare function field(fieldName: string): FieldValidator;
|
|
984
|
+
declare const CreateListingSchema: Validator<CreateDraftListingParams>;
|
|
985
|
+
declare const UpdateListingSchema: Validator<UpdateListingParams>;
|
|
986
|
+
declare const UpdateShopSchema: Validator<unknown>;
|
|
987
|
+
interface ValidationOptions {
|
|
988
|
+
validate?: boolean;
|
|
989
|
+
validateSchema?: ValidationSchema;
|
|
990
|
+
throwOnValidationError?: boolean;
|
|
991
|
+
validateResponse?: boolean;
|
|
992
|
+
}
|
|
993
|
+
declare class ValidationException extends Error {
|
|
994
|
+
errors: ValidationError[];
|
|
995
|
+
constructor(message: string, errors: ValidationError[]);
|
|
996
|
+
}
|
|
997
|
+
declare function validateOrThrow<T>(data: T, schema: ValidationSchema<T>, errorMessage?: string): void;
|
|
998
|
+
declare function validate<T>(data: T, schema: ValidationSchema<T>): ValidationResult;
|
|
999
|
+
declare function createValidator<T>(): Validator<T>;
|
|
1000
|
+
declare function combineValidators<T>(...validators: ValidationSchema<T>[]): ValidationSchema<T>;
|
|
296
1001
|
|
|
297
1002
|
declare class EtsyClient {
|
|
298
1003
|
private tokenManager;
|
|
@@ -302,6 +1007,7 @@ declare class EtsyClient {
|
|
|
302
1007
|
private cache?;
|
|
303
1008
|
private cacheTtl;
|
|
304
1009
|
private keystring;
|
|
1010
|
+
private bulkOperationManager;
|
|
305
1011
|
constructor(config: EtsyClientConfig);
|
|
306
1012
|
private makeRequest;
|
|
307
1013
|
private getApiKey;
|
|
@@ -315,6 +1021,51 @@ declare class EtsyClient {
|
|
|
315
1021
|
findAllListingsActive(params?: SearchParams): Promise<EtsyListing[]>;
|
|
316
1022
|
getListingImages(listingId: string): Promise<EtsyListingImage[]>;
|
|
317
1023
|
getListingInventory(listingId: string): Promise<EtsyListingInventory>;
|
|
1024
|
+
getSellerTaxonomyNodes(): Promise<EtsySellerTaxonomyNode[]>;
|
|
1025
|
+
getUserShops(): Promise<EtsyShop[]>;
|
|
1026
|
+
updateShop(shopId: string, params: UpdateShopParams, options?: ValidationOptions): Promise<EtsyShop>;
|
|
1027
|
+
createShopSection(shopId: string, params: CreateShopSectionParams): Promise<EtsyShopSection>;
|
|
1028
|
+
updateShopSection(shopId: string, sectionId: string, params: UpdateShopSectionParams): Promise<EtsyShopSection>;
|
|
1029
|
+
deleteShopSection(shopId: string, sectionId: string): Promise<void>;
|
|
1030
|
+
createDraftListing(shopId: string, params: CreateDraftListingParams, options?: ValidationOptions): Promise<EtsyListing>;
|
|
1031
|
+
updateListing(shopId: string, listingId: string, params: UpdateListingParams, options?: ValidationOptions): Promise<EtsyListing>;
|
|
1032
|
+
deleteListing(listingId: string): Promise<void>;
|
|
1033
|
+
updateListingInventory(listingId: string, params: UpdateListingInventoryParams): Promise<EtsyListingInventory>;
|
|
1034
|
+
uploadListingImage(shopId: string, listingId: string, imageData: Blob | Buffer, params?: {
|
|
1035
|
+
rank?: number;
|
|
1036
|
+
overwrite?: boolean;
|
|
1037
|
+
is_watermarked?: boolean;
|
|
1038
|
+
alt_text?: string;
|
|
1039
|
+
}): Promise<EtsyListingImage>;
|
|
1040
|
+
getListingImage(shopId: string, listingId: string, imageId: string): Promise<EtsyListingImage>;
|
|
1041
|
+
deleteListingImage(shopId: string, listingId: string, imageId: string): Promise<void>;
|
|
1042
|
+
bulkUpdateListings(shopId: string, operations: BulkUpdateListingOperation[], config?: BulkOperationConfig): Promise<BulkOperationSummary<EtsyListing>>;
|
|
1043
|
+
bulkUploadImages(shopId: string, listingId: string, images: BulkImageUploadOperation[], config?: BulkOperationConfig): Promise<BulkOperationSummary<EtsyListingImage>>;
|
|
1044
|
+
setBulkOperationConcurrency(concurrency: number): void;
|
|
1045
|
+
getShopReceipts(shopId: string, params?: GetShopReceiptsParams): Promise<EtsyShopReceipt[]>;
|
|
1046
|
+
getShopReceipt(shopId: string, receiptId: string): Promise<EtsyShopReceipt>;
|
|
1047
|
+
updateShopReceipt(shopId: string, receiptId: string, params: UpdateShopReceiptParams): Promise<EtsyShopReceipt>;
|
|
1048
|
+
getShopReceiptTransactions(shopId: string, receiptId: string): Promise<EtsyShopReceiptTransaction[]>;
|
|
1049
|
+
getShopTransaction(shopId: string, transactionId: string): Promise<EtsyShopReceiptTransaction>;
|
|
1050
|
+
getShopShippingProfiles(shopId: string): Promise<EtsyShippingProfile[]>;
|
|
1051
|
+
createShopShippingProfile(shopId: string, params: CreateShippingProfileParams): Promise<EtsyShippingProfile>;
|
|
1052
|
+
getShopShippingProfile(shopId: string, profileId: string): Promise<EtsyShippingProfile>;
|
|
1053
|
+
updateShopShippingProfile(shopId: string, profileId: string, params: UpdateShippingProfileParams): Promise<EtsyShippingProfile>;
|
|
1054
|
+
deleteShopShippingProfile(shopId: string, profileId: string): Promise<void>;
|
|
1055
|
+
getShopShippingProfileDestinations(shopId: string, profileId: string): Promise<EtsyShippingProfileDestination[]>;
|
|
1056
|
+
createShopShippingProfileDestination(shopId: string, profileId: string, params: CreateShippingProfileDestinationParams): Promise<EtsyShippingProfileDestination>;
|
|
1057
|
+
updateShopShippingProfileDestination(shopId: string, profileId: string, destinationId: string, params: UpdateShippingProfileDestinationParams): Promise<EtsyShippingProfileDestination>;
|
|
1058
|
+
deleteShopShippingProfileDestination(shopId: string, profileId: string, destinationId: string): Promise<void>;
|
|
1059
|
+
getShopShippingProfileUpgrades(shopId: string, profileId: string): Promise<EtsyShippingProfileUpgrade[]>;
|
|
1060
|
+
createReceiptShipment(shopId: string, receiptId: string, params: CreateReceiptShipmentParams): Promise<EtsyShopReceiptShipment>;
|
|
1061
|
+
getShopReceiptShipments(shopId: string, receiptId: string): Promise<EtsyShopReceiptShipment[]>;
|
|
1062
|
+
getShopPaymentAccountLedgerEntries(shopId: string, params: GetPaymentAccountLedgerEntriesParams): Promise<EtsyPaymentAccountLedgerEntry[]>;
|
|
1063
|
+
getShopPaymentAccountLedgerEntry(shopId: string, entryId: string): Promise<EtsyPaymentAccountLedgerEntry>;
|
|
1064
|
+
getShopPayment(shopId: string, paymentId: string): Promise<EtsyPayment>;
|
|
1065
|
+
getBuyerTaxonomyNodes(): Promise<EtsyBuyerTaxonomyNode[]>;
|
|
1066
|
+
getPropertiesByTaxonomyId(taxonomyId: number): Promise<EtsyBuyerTaxonomyProperty[]>;
|
|
1067
|
+
getListingProperties(shopId: string, listingId: string): Promise<EtsyListingProperty[]>;
|
|
1068
|
+
getShopProductionPartners(shopId: string): Promise<EtsyShopProductionPartner[]>;
|
|
318
1069
|
getRemainingRequests(): number;
|
|
319
1070
|
getRateLimitStatus(): RateLimitStatus;
|
|
320
1071
|
clearCache(): Promise<void>;
|
|
@@ -391,7 +1142,9 @@ declare class TokenManager {
|
|
|
391
1142
|
private refreshCallback?;
|
|
392
1143
|
private storage?;
|
|
393
1144
|
private refreshPromise?;
|
|
394
|
-
|
|
1145
|
+
private rotationConfig?;
|
|
1146
|
+
private rotationTimer?;
|
|
1147
|
+
constructor(config: EtsyClientConfig, storage?: TokenStorage, rotationConfig?: TokenRotationConfig);
|
|
395
1148
|
getAccessToken(): Promise<string>;
|
|
396
1149
|
refreshToken(): Promise<EtsyTokens>;
|
|
397
1150
|
private performTokenRefresh;
|
|
@@ -401,6 +1154,12 @@ declare class TokenManager {
|
|
|
401
1154
|
willTokenExpireSoon(minutes?: number): boolean;
|
|
402
1155
|
clearTokens(): Promise<void>;
|
|
403
1156
|
getTimeUntilExpiration(): number | null;
|
|
1157
|
+
needsProactiveRotation(): boolean;
|
|
1158
|
+
rotateToken(): Promise<EtsyTokens>;
|
|
1159
|
+
startRotationScheduler(): void;
|
|
1160
|
+
stopRotationScheduler(): void;
|
|
1161
|
+
updateRotationConfig(config: TokenRotationConfig): void;
|
|
1162
|
+
getRotationConfig(): TokenRotationConfig | undefined;
|
|
404
1163
|
private fetch;
|
|
405
1164
|
}
|
|
406
1165
|
declare function createDefaultTokenStorage(options?: {
|
|
@@ -429,6 +1188,7 @@ declare class FileTokenStorage implements TokenStorage {
|
|
|
429
1188
|
load(): Promise<EtsyTokens | null>;
|
|
430
1189
|
clear(): Promise<void>;
|
|
431
1190
|
private _writeFile;
|
|
1191
|
+
private _setFilePermissions;
|
|
432
1192
|
private _readFile;
|
|
433
1193
|
private _deleteFile;
|
|
434
1194
|
}
|
|
@@ -450,6 +1210,312 @@ declare class EtsyRateLimiter {
|
|
|
450
1210
|
}
|
|
451
1211
|
declare const defaultRateLimiter: EtsyRateLimiter;
|
|
452
1212
|
|
|
1213
|
+
interface PaginationOptions {
|
|
1214
|
+
limit?: number;
|
|
1215
|
+
offset?: number;
|
|
1216
|
+
maxPages?: number;
|
|
1217
|
+
maxItems?: number;
|
|
1218
|
+
}
|
|
1219
|
+
type PageFetcher<T> = (limit: number, offset: number) => Promise<EtsyApiResponse<T>>;
|
|
1220
|
+
declare class PaginatedResults<T> implements AsyncIterable<T> {
|
|
1221
|
+
private fetcher;
|
|
1222
|
+
private options;
|
|
1223
|
+
private currentPage;
|
|
1224
|
+
private currentOffset;
|
|
1225
|
+
private totalCount;
|
|
1226
|
+
private hasMore;
|
|
1227
|
+
constructor(fetcher: PageFetcher<T>, options?: PaginationOptions);
|
|
1228
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
1229
|
+
getAll(): Promise<T[]>;
|
|
1230
|
+
getCurrentPage(): T[];
|
|
1231
|
+
hasNextPage(): boolean;
|
|
1232
|
+
getNextPage(): Promise<T[]>;
|
|
1233
|
+
getTotalCount(): number | null;
|
|
1234
|
+
reset(): void;
|
|
1235
|
+
private fetchPage;
|
|
1236
|
+
}
|
|
1237
|
+
declare function createPaginatedResults<T>(fetcher: PageFetcher<T>, options?: PaginationOptions): PaginatedResults<T>;
|
|
1238
|
+
|
|
1239
|
+
interface RetryConfig {
|
|
1240
|
+
maxRetries: number;
|
|
1241
|
+
retryDelay: number;
|
|
1242
|
+
exponentialBackoff: boolean;
|
|
1243
|
+
retryableStatusCodes: number[];
|
|
1244
|
+
onRetry?: (attempt: number, error: Error) => void;
|
|
1245
|
+
maxRetryDelay?: number;
|
|
1246
|
+
jitter?: number;
|
|
1247
|
+
}
|
|
1248
|
+
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
1249
|
+
interface RetryOptions extends Partial<RetryConfig> {
|
|
1250
|
+
signal?: AbortSignal;
|
|
1251
|
+
}
|
|
1252
|
+
declare function withRetry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1253
|
+
declare class RetryManager {
|
|
1254
|
+
private config;
|
|
1255
|
+
constructor(config?: Partial<RetryConfig>);
|
|
1256
|
+
execute<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1257
|
+
updateConfig(config: Partial<RetryConfig>): void;
|
|
1258
|
+
getConfig(): RetryConfig;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
interface WebhookConfig {
|
|
1262
|
+
secret: string;
|
|
1263
|
+
algorithm?: 'sha256' | 'sha1';
|
|
1264
|
+
verifySignatures?: boolean;
|
|
1265
|
+
}
|
|
1266
|
+
type EtsyWebhookEventType = 'receipt.updated' | 'receipt.created' | 'listing.updated' | 'listing.created' | 'listing.deactivated' | 'shop.updated';
|
|
1267
|
+
interface EtsyWebhookEvent {
|
|
1268
|
+
type: EtsyWebhookEventType;
|
|
1269
|
+
timestamp: number;
|
|
1270
|
+
data: EtsyShopReceipt | EtsyListing | unknown;
|
|
1271
|
+
shop_id?: number;
|
|
1272
|
+
user_id?: number;
|
|
1273
|
+
}
|
|
1274
|
+
type WebhookEventHandler<T = unknown> = (data: T) => void | Promise<void>;
|
|
1275
|
+
declare class EtsyWebhookHandler {
|
|
1276
|
+
private config;
|
|
1277
|
+
private handlers;
|
|
1278
|
+
private crypto;
|
|
1279
|
+
constructor(config: WebhookConfig);
|
|
1280
|
+
verifySignature(payload: string, signature: string): boolean;
|
|
1281
|
+
parseEvent(payload: string | object): EtsyWebhookEvent;
|
|
1282
|
+
on<T = unknown>(eventType: EtsyWebhookEventType, handler: WebhookEventHandler<T>): void;
|
|
1283
|
+
off(eventType: EtsyWebhookEventType, handler: WebhookEventHandler): void;
|
|
1284
|
+
removeAllListeners(eventType?: EtsyWebhookEventType): void;
|
|
1285
|
+
private triggerHandlers;
|
|
1286
|
+
private timingSafeEqual;
|
|
1287
|
+
getHandlerCount(eventType: EtsyWebhookEventType): number;
|
|
1288
|
+
getRegisteredEventTypes(): EtsyWebhookEventType[];
|
|
1289
|
+
}
|
|
1290
|
+
declare function createWebhookHandler(config: WebhookConfig): EtsyWebhookHandler;
|
|
1291
|
+
|
|
1292
|
+
type CacheStrategy = 'lru' | 'lfu' | 'ttl' | 'custom';
|
|
1293
|
+
interface AdvancedCachingConfig {
|
|
1294
|
+
strategy?: CacheStrategy;
|
|
1295
|
+
ttl?: number;
|
|
1296
|
+
maxSize?: number;
|
|
1297
|
+
maxEntries?: number;
|
|
1298
|
+
invalidateOn?: {
|
|
1299
|
+
mutations?: boolean;
|
|
1300
|
+
patterns?: string[];
|
|
1301
|
+
};
|
|
1302
|
+
trackStats?: boolean;
|
|
1303
|
+
}
|
|
1304
|
+
interface CacheEntry {
|
|
1305
|
+
key: string;
|
|
1306
|
+
value: string;
|
|
1307
|
+
expires: number;
|
|
1308
|
+
size: number;
|
|
1309
|
+
accessCount: number;
|
|
1310
|
+
lastAccessed: number;
|
|
1311
|
+
created: number;
|
|
1312
|
+
}
|
|
1313
|
+
interface CacheStats {
|
|
1314
|
+
hits: number;
|
|
1315
|
+
misses: number;
|
|
1316
|
+
hitRate: number;
|
|
1317
|
+
missRate: number;
|
|
1318
|
+
size: number;
|
|
1319
|
+
entryCount: number;
|
|
1320
|
+
evictions: number;
|
|
1321
|
+
maxSize: number;
|
|
1322
|
+
maxEntries: number;
|
|
1323
|
+
}
|
|
1324
|
+
declare class LRUCache implements CacheStorage {
|
|
1325
|
+
private cache;
|
|
1326
|
+
private maxSize;
|
|
1327
|
+
private maxEntries;
|
|
1328
|
+
private ttl;
|
|
1329
|
+
private currentSize;
|
|
1330
|
+
private stats;
|
|
1331
|
+
private trackStats;
|
|
1332
|
+
constructor(config?: AdvancedCachingConfig);
|
|
1333
|
+
get(key: string): Promise<string | null>;
|
|
1334
|
+
set(key: string, value: string, ttl?: number): Promise<void>;
|
|
1335
|
+
delete(key: string): Promise<void>;
|
|
1336
|
+
clear(): Promise<void>;
|
|
1337
|
+
private evictLRU;
|
|
1338
|
+
private estimateSize;
|
|
1339
|
+
getStats(): CacheStats;
|
|
1340
|
+
}
|
|
1341
|
+
declare class LFUCache implements CacheStorage {
|
|
1342
|
+
private cache;
|
|
1343
|
+
private maxSize;
|
|
1344
|
+
private maxEntries;
|
|
1345
|
+
private ttl;
|
|
1346
|
+
private currentSize;
|
|
1347
|
+
private stats;
|
|
1348
|
+
private trackStats;
|
|
1349
|
+
constructor(config?: AdvancedCachingConfig);
|
|
1350
|
+
get(key: string): Promise<string | null>;
|
|
1351
|
+
set(key: string, value: string, ttl?: number): Promise<void>;
|
|
1352
|
+
delete(key: string): Promise<void>;
|
|
1353
|
+
clear(): Promise<void>;
|
|
1354
|
+
private evictLFU;
|
|
1355
|
+
private estimateSize;
|
|
1356
|
+
getStats(): CacheStats;
|
|
1357
|
+
}
|
|
1358
|
+
declare class CacheWithInvalidation implements CacheStorage {
|
|
1359
|
+
private baseCache;
|
|
1360
|
+
private invalidationPatterns;
|
|
1361
|
+
private mutationPatterns;
|
|
1362
|
+
constructor(baseCache: CacheStorage, config?: AdvancedCachingConfig);
|
|
1363
|
+
get(key: string): Promise<string | null>;
|
|
1364
|
+
set(key: string, value: string, ttl?: number): Promise<void>;
|
|
1365
|
+
delete(key: string): Promise<void>;
|
|
1366
|
+
clear(): Promise<void>;
|
|
1367
|
+
invalidatePattern(_pattern: string): Promise<void>;
|
|
1368
|
+
invalidateOnMutation(mutationType: string): Promise<void>;
|
|
1369
|
+
addInvalidationPattern(pattern: string): void;
|
|
1370
|
+
removeInvalidationPattern(pattern: string): void;
|
|
1371
|
+
addMutationPattern(mutationType: string, patterns: string[]): void;
|
|
1372
|
+
}
|
|
1373
|
+
interface RedisConfig {
|
|
1374
|
+
host: string;
|
|
1375
|
+
port: number;
|
|
1376
|
+
password?: string;
|
|
1377
|
+
db?: number;
|
|
1378
|
+
keyPrefix?: string;
|
|
1379
|
+
}
|
|
1380
|
+
interface RedisClientLike {
|
|
1381
|
+
get(key: string): Promise<string | null>;
|
|
1382
|
+
setex(key: string, ttl: number, value: string): Promise<void>;
|
|
1383
|
+
del(...keys: string[]): Promise<void>;
|
|
1384
|
+
keys(pattern: string): Promise<string[]>;
|
|
1385
|
+
}
|
|
1386
|
+
declare class RedisCacheStorage implements CacheStorage {
|
|
1387
|
+
private config;
|
|
1388
|
+
private client;
|
|
1389
|
+
private keyPrefix;
|
|
1390
|
+
constructor(config: RedisConfig, client: RedisClientLike);
|
|
1391
|
+
get(key: string): Promise<string | null>;
|
|
1392
|
+
set(key: string, value: string, ttl?: number): Promise<void>;
|
|
1393
|
+
delete(key: string): Promise<void>;
|
|
1394
|
+
clear(): Promise<void>;
|
|
1395
|
+
getClient(): RedisClientLike;
|
|
1396
|
+
}
|
|
1397
|
+
declare function createCacheStorage(config?: AdvancedCachingConfig): CacheStorage;
|
|
1398
|
+
declare function createCacheWithInvalidation(baseCache: CacheStorage, config?: AdvancedCachingConfig): CacheWithInvalidation;
|
|
1399
|
+
declare function createRedisCacheStorage(config: RedisConfig, client: RedisClientLike): RedisCacheStorage;
|
|
1400
|
+
|
|
1401
|
+
type SortOrder = 'asc' | 'desc';
|
|
1402
|
+
type ListingState = 'active' | 'inactive' | 'draft' | 'expired';
|
|
1403
|
+
type ListingSortOn = 'created' | 'price' | 'updated' | 'score';
|
|
1404
|
+
declare class ListingQueryBuilder {
|
|
1405
|
+
private client;
|
|
1406
|
+
private shopId?;
|
|
1407
|
+
private params;
|
|
1408
|
+
private includeFields;
|
|
1409
|
+
constructor(client: EtsyClient, shopId?: string);
|
|
1410
|
+
where(filters: {
|
|
1411
|
+
state?: ListingState;
|
|
1412
|
+
shop_section_id?: number;
|
|
1413
|
+
}): this;
|
|
1414
|
+
include(fields: string[]): this;
|
|
1415
|
+
limit(limit: number): this;
|
|
1416
|
+
offset(offset: number): this;
|
|
1417
|
+
sortBy(field: ListingSortOn, order?: SortOrder): this;
|
|
1418
|
+
fetch(): Promise<EtsyListing[]>;
|
|
1419
|
+
first(): Promise<EtsyListing | null>;
|
|
1420
|
+
count(): Promise<number>;
|
|
1421
|
+
}
|
|
1422
|
+
declare class ReceiptQueryBuilder {
|
|
1423
|
+
private client;
|
|
1424
|
+
private shopId;
|
|
1425
|
+
private params;
|
|
1426
|
+
constructor(client: EtsyClient, shopId: string);
|
|
1427
|
+
where(filters: {
|
|
1428
|
+
was_paid?: boolean;
|
|
1429
|
+
was_shipped?: boolean;
|
|
1430
|
+
was_delivered?: boolean;
|
|
1431
|
+
min_created?: number;
|
|
1432
|
+
max_created?: number;
|
|
1433
|
+
}): this;
|
|
1434
|
+
limit(limit: number): this;
|
|
1435
|
+
offset(offset: number): this;
|
|
1436
|
+
sortBy(field: 'created' | 'updated', order?: SortOrder): this;
|
|
1437
|
+
fetch(): Promise<EtsyShopReceipt[]>;
|
|
1438
|
+
first(): Promise<EtsyShopReceipt | null>;
|
|
1439
|
+
}
|
|
1440
|
+
declare class BatchQueryExecutor {
|
|
1441
|
+
private client;
|
|
1442
|
+
private operations;
|
|
1443
|
+
constructor(client: EtsyClient);
|
|
1444
|
+
getShop(shopId: string): this;
|
|
1445
|
+
getListings(shopId: string, params?: ListingParams): this;
|
|
1446
|
+
getReceipts(shopId: string, params?: GetShopReceiptsParams): this;
|
|
1447
|
+
custom<T>(operation: () => Promise<T>): this;
|
|
1448
|
+
execute(): Promise<unknown[]>;
|
|
1449
|
+
executeSequential(): Promise<unknown[]>;
|
|
1450
|
+
clear(): this;
|
|
1451
|
+
size(): number;
|
|
1452
|
+
}
|
|
1453
|
+
interface EtsyClientWithQueryBuilder extends EtsyClient {
|
|
1454
|
+
listings(shopId?: string): ListingQueryBuilder;
|
|
1455
|
+
receipts(shopId: string): ReceiptQueryBuilder;
|
|
1456
|
+
batch(): BatchQueryExecutor;
|
|
1457
|
+
}
|
|
1458
|
+
declare function withQueryBuilder(client: EtsyClient): EtsyClientWithQueryBuilder;
|
|
1459
|
+
declare function createListingQuery(client: EtsyClient, shopId?: string): ListingQueryBuilder;
|
|
1460
|
+
declare function createReceiptQuery(client: EtsyClient, shopId: string): ReceiptQueryBuilder;
|
|
1461
|
+
declare function createBatchQuery(client: EtsyClient): BatchQueryExecutor;
|
|
1462
|
+
|
|
1463
|
+
interface EncryptedData {
|
|
1464
|
+
ciphertext: string;
|
|
1465
|
+
iv: string;
|
|
1466
|
+
authTag: string;
|
|
1467
|
+
algorithm: string;
|
|
1468
|
+
}
|
|
1469
|
+
declare function encryptAES256GCM(data: string, key: Buffer | string): Promise<EncryptedData>;
|
|
1470
|
+
declare function decryptAES256GCM(encryptedData: EncryptedData, key: Buffer | string): Promise<string>;
|
|
1471
|
+
declare function generateEncryptionKey(length?: number): Promise<Buffer>;
|
|
1472
|
+
declare function deriveKeyFromPassword(password: string, salt: Buffer | string, iterations?: number, keyLength?: number): Promise<Buffer>;
|
|
1473
|
+
declare function validateEncryptionKey(key: Buffer | string, requiredLength?: number): boolean;
|
|
1474
|
+
|
|
1475
|
+
interface EncryptedStorageConfig {
|
|
1476
|
+
filePath: string;
|
|
1477
|
+
encryptionKey: string | Buffer;
|
|
1478
|
+
fileMode?: number;
|
|
1479
|
+
}
|
|
1480
|
+
declare class EncryptedFileTokenStorage implements TokenStorage {
|
|
1481
|
+
private filePath;
|
|
1482
|
+
private encryptionKey;
|
|
1483
|
+
private fileMode;
|
|
1484
|
+
constructor(config: EncryptedStorageConfig);
|
|
1485
|
+
save(tokens: EtsyTokens): Promise<void>;
|
|
1486
|
+
load(): Promise<EtsyTokens | null>;
|
|
1487
|
+
clear(): Promise<void>;
|
|
1488
|
+
getFilePath(): string;
|
|
1489
|
+
exists(): Promise<boolean>;
|
|
1490
|
+
private _writeFile;
|
|
1491
|
+
private _setFilePermissions;
|
|
1492
|
+
private _readFile;
|
|
1493
|
+
private _deleteFile;
|
|
1494
|
+
private _stat;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
interface WebhookSecurityConfig {
|
|
1498
|
+
secret: string;
|
|
1499
|
+
algorithm?: 'sha256' | 'sha1' | 'sha512';
|
|
1500
|
+
}
|
|
1501
|
+
declare class WebhookSecurity {
|
|
1502
|
+
private secret;
|
|
1503
|
+
private algorithm;
|
|
1504
|
+
private crypto;
|
|
1505
|
+
constructor(config: WebhookSecurityConfig);
|
|
1506
|
+
signRequest(payload: string | object, encoding?: 'hex' | 'base64'): string;
|
|
1507
|
+
verifySignature(payload: string | object, signature: string, encoding?: 'hex' | 'base64'): boolean;
|
|
1508
|
+
signRequestWithTimestamp(payload: string | object, timestamp?: number, encoding?: 'hex' | 'base64'): {
|
|
1509
|
+
timestamp: number;
|
|
1510
|
+
signature: string;
|
|
1511
|
+
};
|
|
1512
|
+
verifySignatureWithTimestamp(payload: string | object, signature: string, timestamp: number, maxAge?: number, encoding?: 'hex' | 'base64'): boolean;
|
|
1513
|
+
private timingSafeEqual;
|
|
1514
|
+
getAlgorithm(): string;
|
|
1515
|
+
updateSecret(newSecret: string): void;
|
|
1516
|
+
}
|
|
1517
|
+
declare function createWebhookSecurity(secret: string, algorithm?: 'sha256' | 'sha1' | 'sha512'): WebhookSecurity;
|
|
1518
|
+
|
|
453
1519
|
declare const isBrowser: boolean;
|
|
454
1520
|
declare const isNode: boolean;
|
|
455
1521
|
declare const hasLocalStorage: boolean;
|
|
@@ -479,7 +1545,7 @@ declare function createAuthHelper(config: AuthHelperConfig): AuthHelper;
|
|
|
479
1545
|
declare function createTokenManager(config: EtsyClientConfig, storage?: TokenStorage): TokenManager;
|
|
480
1546
|
declare function createRateLimiter(config?: Partial<RateLimitConfig>): EtsyRateLimiter;
|
|
481
1547
|
|
|
482
|
-
declare const VERSION = "
|
|
1548
|
+
declare const VERSION = "2.2.0";
|
|
483
1549
|
declare const LIBRARY_NAME = "etsy-v3-api-client";
|
|
484
1550
|
declare function getLibraryInfo(): {
|
|
485
1551
|
name: string;
|
|
@@ -490,5 +1556,5 @@ declare function getLibraryInfo(): {
|
|
|
490
1556
|
homepage: string;
|
|
491
1557
|
};
|
|
492
1558
|
|
|
493
|
-
export { AuthHelper, COMMON_SCOPE_COMBINATIONS, ETSY_SCOPES, EtsyApiError, EtsyAuthError, EtsyClient, EtsyRateLimitError, EtsyRateLimiter, FileTokenStorage, LIBRARY_NAME, LocalStorageTokenStorage, MemoryTokenStorage, SessionStorageTokenStorage, TokenManager, VERSION, createAuthHelper, createCodeChallenge, createDefaultTokenStorage, createEtsyClient, createRateLimiter, createTokenManager, EtsyClient as default, defaultRateLimiter, generateCodeVerifier, generateRandomBase64Url, generateState, getAvailableStorage, getEnvironmentInfo, getLibraryInfo, hasLocalStorage, hasSessionStorage, isBrowser, isNode, sha256, sha256Base64Url };
|
|
494
|
-
export type { AuthHelperConfig, CacheStorage, EtsyApiResponse, EtsyClientConfig, EtsyListing, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingPropertyValue, EtsyShop, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyUser, ListingParams, LoggerInterface, RateLimitConfig, RateLimitStatus, SearchParams, TokenRefreshCallback, TokenStorage };
|
|
1559
|
+
export { AuthHelper, BatchQueryExecutor, BulkOperationManager, COMMON_SCOPE_COMBINATIONS, CacheWithInvalidation, CreateListingSchema, DEFAULT_RETRY_CONFIG, ETSY_SCOPES, EncryptedFileTokenStorage, EtsyApiError, EtsyAuthError, EtsyClient, EtsyRateLimitError, EtsyRateLimiter, EtsyWebhookHandler, FieldValidator, FileTokenStorage, LFUCache, LIBRARY_NAME, LRUCache, ListingQueryBuilder, LocalStorageTokenStorage, MemoryTokenStorage, PaginatedResults, ReceiptQueryBuilder, RedisCacheStorage, RetryManager, SessionStorageTokenStorage, TokenManager, UpdateListingSchema, UpdateShopSchema, VERSION, ValidationException, Validator, WebhookSecurity, combineValidators, createAuthHelper, createBatchQuery, createBulkOperationManager, createCacheStorage, createCacheWithInvalidation, createCodeChallenge, createDefaultTokenStorage, createEtsyClient, createListingQuery, createPaginatedResults, createRateLimiter, createReceiptQuery, createRedisCacheStorage, createTokenManager, createValidator, createWebhookHandler, createWebhookSecurity, decryptAES256GCM, EtsyClient as default, defaultRateLimiter, deriveKeyFromPassword, encryptAES256GCM, executeBulkOperation, field, generateCodeVerifier, generateEncryptionKey, generateRandomBase64Url, generateState, getAvailableStorage, getEnvironmentInfo, getLibraryInfo, hasLocalStorage, hasSessionStorage, isBrowser, isNode, sha256, sha256Base64Url, validate, validateEncryptionKey, validateOrThrow, withQueryBuilder, withRetry };
|
|
1560
|
+
export type { AdvancedCachingConfig, AuthHelperConfig, BulkImageUploadOperation, BulkOperationConfig, BulkOperationError, BulkOperationResult, BulkOperationSummary, BulkUpdateListingOperation, CacheEntry, CacheStats, CacheStorage, CacheStrategy, CreateDraftListingParams, CreateReceiptShipmentParams, CreateShippingProfileDestinationParams, CreateShippingProfileParams, CreateShopSectionParams, EncryptedData, EncryptedStorageConfig, EtsyApiResponse, EtsyBuyerTaxonomyNode, EtsyBuyerTaxonomyProperty, EtsyBuyerTaxonomyPropertyScale, EtsyBuyerTaxonomyPropertyValue, EtsyClientConfig, EtsyClientWithQueryBuilder, EtsyErrorDetails, EtsyListing, EtsyListingImage, EtsyListingInventory, EtsyListingOffering, EtsyListingProduct, EtsyListingProperty, EtsyListingPropertyScale, EtsyListingPropertyValue, EtsyPagination, EtsyPayment, EtsyPaymentAccountLedgerEntry, EtsyPaymentAdjustment, EtsySellerTaxonomyNode, EtsyShippingProfile, EtsyShippingProfileDestination, EtsyShippingProfileUpgrade, EtsyShop, EtsyShopProductionPartner, EtsyShopReceipt, EtsyShopReceiptShipment, EtsyShopReceiptTransaction, EtsyShopRefund, EtsyShopSection, EtsyTokenResponse, EtsyTokens, EtsyTransactionVariation, EtsyUser, EtsyWebhookEvent, EtsyWebhookEventType, GetPaymentAccountLedgerEntriesParams, GetShopReceiptsParams, ListingParams, ListingSortOn, ListingState, LoggerInterface, PageFetcher, PaginationOptions, RateLimitConfig, RateLimitStatus, RedisClientLike, RedisConfig, RetryConfig, RetryOptions, SearchParams, SortOrder, TokenRefreshCallback, TokenRotationCallback, TokenRotationConfig, TokenStorage, UpdateListingInventoryParams, UpdateListingParams, UpdateShippingProfileDestinationParams, UpdateShippingProfileParams, UpdateShopParams, UpdateShopReceiptParams, UpdateShopSectionParams, UploadListingFileParams, UploadListingImageParams, ValidationError, ValidationOptions, ValidationResult, ValidationSchema, ValidatorFunction, WebhookConfig, WebhookEventHandler, WebhookSecurityConfig };
|