@lonca/trendyol 0.2.0 → 0.3.0
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.cjs +451 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +496 -9
- package/dist/index.d.ts +496 -9
- package/dist/index.js +451 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -77,6 +77,21 @@ declare class BrandsResource {
|
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
list(params?: CursorPaginationParams): Promise<CursorPage<Brand>>;
|
|
80
|
+
/**
|
|
81
|
+
* Search brands by name. Useful when you need a brand's numeric ID for
|
|
82
|
+
* `createProducts` and don't want to page through the full `list()`
|
|
83
|
+
* (1000 brands per page).
|
|
84
|
+
*
|
|
85
|
+
* **Discovery-first wire fact (verified STAGE 2026-05-25):** Trendyol's
|
|
86
|
+
* doc claims this is a case-sensitive *exact* match, but live behaviour
|
|
87
|
+
* is **substring + case-insensitive** — `search('Trendyol')` returns
|
|
88
|
+
* 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
|
|
89
|
+
* Plan for ranking your results client-side if you need an exact match.
|
|
90
|
+
* The endpoint returns an empty array when nothing matches (no 404).
|
|
91
|
+
*
|
|
92
|
+
* @param name The brand name to search for.
|
|
93
|
+
*/
|
|
94
|
+
search(name: string): Promise<Brand[]>;
|
|
80
95
|
}
|
|
81
96
|
|
|
82
97
|
/**
|
|
@@ -98,6 +113,22 @@ interface CategoryAttributeValue {
|
|
|
98
113
|
id: string;
|
|
99
114
|
name: string;
|
|
100
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Result of `categories.getByBarcodes` — a barcode → category mapping
|
|
118
|
+
* sourced from Trendyol's Export Center (AutoFT) lookup endpoint.
|
|
119
|
+
*/
|
|
120
|
+
interface BarcodeCategoryLookup {
|
|
121
|
+
/** Successful matches. */
|
|
122
|
+
matches: Array<{
|
|
123
|
+
barcode: string;
|
|
124
|
+
category: {
|
|
125
|
+
id: string;
|
|
126
|
+
name: string;
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
129
|
+
/** Barcodes Trendyol could not resolve to a category. */
|
|
130
|
+
notFound: string[];
|
|
131
|
+
}
|
|
101
132
|
/**
|
|
102
133
|
* A required or optional attribute for products in a given category.
|
|
103
134
|
* Use these when constructing a `createProduct V2` payload — the API rejects
|
|
@@ -126,27 +157,40 @@ interface CategoryAttribute {
|
|
|
126
157
|
* NOTE: Trendyol's live API often omits this field on the `getCategoryAttributes`
|
|
127
158
|
* response — the endpoint returns attribute metadata + flags, not the full value
|
|
128
159
|
* catalog. In that case `values` is an empty array. If `allowCustom` is `true`,
|
|
129
|
-
* any custom text is accepted; otherwise
|
|
130
|
-
*
|
|
131
|
-
* future release of this SDK).
|
|
160
|
+
* any custom text is accepted; otherwise use `client.categories.getAttributeValues(categoryId, attributeId)`
|
|
161
|
+
* to fetch the catalog from the dedicated V2 endpoint.
|
|
132
162
|
*/
|
|
133
163
|
values: CategoryAttributeValue[];
|
|
134
164
|
}
|
|
135
165
|
|
|
166
|
+
type ListCategoryAttributeValuesParams = CursorPaginationParams;
|
|
136
167
|
/**
|
|
137
168
|
* Trendyol category-tree and category-attribute endpoints.
|
|
138
169
|
*
|
|
139
170
|
* Rate limits (per Trendyol service limits):
|
|
140
171
|
* - Category list: 50 req/min
|
|
141
172
|
* - Category attributes: 50 req/min
|
|
173
|
+
* - Category attribute values: 50 req/min (same service tier)
|
|
142
174
|
*
|
|
143
|
-
*
|
|
144
|
-
* limiter across
|
|
175
|
+
* All three counters live on the same Trendyol service, so we share one
|
|
176
|
+
* limiter across the endpoints.
|
|
145
177
|
*/
|
|
146
178
|
declare class CategoriesResource {
|
|
147
179
|
private readonly transport;
|
|
180
|
+
/**
|
|
181
|
+
* Trendyol seller (supplier) ID — required only for the AutoFT-scoped
|
|
182
|
+
* `getByBarcodes` lookup. Other category endpoints don't need it.
|
|
183
|
+
* Provided automatically when constructed via `createTrendyolClient`.
|
|
184
|
+
*/
|
|
185
|
+
private readonly sellerId?;
|
|
148
186
|
private readonly limiter;
|
|
149
|
-
constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter
|
|
187
|
+
constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter,
|
|
188
|
+
/**
|
|
189
|
+
* Trendyol seller (supplier) ID — required only for the AutoFT-scoped
|
|
190
|
+
* `getByBarcodes` lookup. Other category endpoints don't need it.
|
|
191
|
+
* Provided automatically when constructed via `createTrendyolClient`.
|
|
192
|
+
*/
|
|
193
|
+
sellerId?: number | undefined);
|
|
150
194
|
/**
|
|
151
195
|
* Fetch the full Trendyol category tree.
|
|
152
196
|
*
|
|
@@ -163,6 +207,43 @@ declare class CategoriesResource {
|
|
|
163
207
|
* @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
|
|
164
208
|
*/
|
|
165
209
|
getAttributes(categoryId: string | number): Promise<CategoryAttribute[]>;
|
|
210
|
+
/**
|
|
211
|
+
* Fetch the allowed values for a single category attribute (paginated).
|
|
212
|
+
*
|
|
213
|
+
* `getCategoryAttributes` returns attribute metadata + flags but typically
|
|
214
|
+
* omits the value catalog. Use this method to fetch the catalog for an
|
|
215
|
+
* attribute when `allowCustom` is `false` and you need to map your data
|
|
216
|
+
* onto Trendyol's accepted values.
|
|
217
|
+
*
|
|
218
|
+
* @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
|
|
219
|
+
* @param attributeId Attribute ID returned by `getAttributes`.
|
|
220
|
+
* @param params Cursor pagination (max page size 1000; default 100).
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import { paginate } from '@lonca/core';
|
|
225
|
+
* for await (const value of paginate((p) =>
|
|
226
|
+
* client.categories.getAttributeValues(catId, attrId, p),
|
|
227
|
+
* )) {
|
|
228
|
+
* console.log(value.id, value.name);
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
getAttributeValues(categoryId: string | number, attributeId: string | number, params?: ListCategoryAttributeValuesParams): Promise<CursorPage<CategoryAttributeValue>>;
|
|
233
|
+
/**
|
|
234
|
+
* Look up category info for a list of barcodes (Trendyol Export Center
|
|
235
|
+
* / AutoFT endpoint).
|
|
236
|
+
*
|
|
237
|
+
* **Requires Export Center enrollment.** Sellers who have not joined
|
|
238
|
+
* Trendyol's "İhracat Merkezi" program will get an auth error on this
|
|
239
|
+
* endpoint even though their regular Marketplace credentials are valid.
|
|
240
|
+
*
|
|
241
|
+
* @param barcodes 1–N barcodes to look up.
|
|
242
|
+
* @throws {ValidationError} when `barcodes` is empty.
|
|
243
|
+
* @throws Error when the client was created without a `sellerId` and this
|
|
244
|
+
* method is called directly (use `createTrendyolClient` to wire it).
|
|
245
|
+
*/
|
|
246
|
+
getByBarcodes(barcodes: string[]): Promise<BarcodeCategoryLookup>;
|
|
166
247
|
}
|
|
167
248
|
|
|
168
249
|
/**
|
|
@@ -470,6 +551,117 @@ interface Product {
|
|
|
470
551
|
/** Untouched raw response — read fields we have not modeled yet. */
|
|
471
552
|
raw: Record<string, unknown>;
|
|
472
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Lifecycle status of an unapproved (draft) product on Trendyol.
|
|
556
|
+
*
|
|
557
|
+
* Verified values seen on STAGE/PROD as of 2026-05-25:
|
|
558
|
+
* - `pendingApproval` — submitted; Trendyol content review in progress.
|
|
559
|
+
* - `rejected` — review failed; `rejectReasonDetails` is populated.
|
|
560
|
+
*
|
|
561
|
+
* Older docs also mention `waiting`. Treat as open-enum (`(string & {})`)
|
|
562
|
+
* since Trendyol can add new statuses without notice.
|
|
563
|
+
*/
|
|
564
|
+
type UnapprovedProductStatus = 'pendingApproval' | 'waiting' | 'rejected' | (string & {});
|
|
565
|
+
interface UnapprovedProductRejectReason {
|
|
566
|
+
/** Short title (e.g. "Kategori Bilgisi Eksik veya Yanlış"). */
|
|
567
|
+
rejectReason?: string;
|
|
568
|
+
/** Full explanation of the rejection. */
|
|
569
|
+
rejectReasonDetail?: string;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* An unapproved (draft) product as returned by `filterUnapprovedProducts`.
|
|
573
|
+
*
|
|
574
|
+
* Important: the wire shape is **flatter** than the approved-product shape
|
|
575
|
+
* exposed by `Product` — `barcode`, `quantity`, `salePrice`, etc. live at the
|
|
576
|
+
* root (no `variants[]` array). Each draft is one barcode/SKU.
|
|
577
|
+
*
|
|
578
|
+
* Verified against Trendyol STAGE on 2026-05-25. The official OpenAPI spec
|
|
579
|
+
* calls the image-list field `media`, but the live API returns it as
|
|
580
|
+
* `images`. SDK normalizes to `images`.
|
|
581
|
+
*/
|
|
582
|
+
interface UnapprovedProduct {
|
|
583
|
+
/** Seller (supplier) ID echoed back by Trendyol. */
|
|
584
|
+
supplierId?: string;
|
|
585
|
+
productMainId: string;
|
|
586
|
+
/** Lifecycle status — see `UnapprovedProductStatus`. */
|
|
587
|
+
status?: UnapprovedProductStatus;
|
|
588
|
+
brand: NamedRef;
|
|
589
|
+
category: NamedRef;
|
|
590
|
+
barcode: string;
|
|
591
|
+
title: string;
|
|
592
|
+
description?: string;
|
|
593
|
+
/** Stock quantity at the moment of the query. */
|
|
594
|
+
quantity?: number;
|
|
595
|
+
listPrice?: number;
|
|
596
|
+
salePrice?: number;
|
|
597
|
+
/** VAT rate as a percentage (e.g. `20` for 20%). */
|
|
598
|
+
vatRate?: number;
|
|
599
|
+
dimensionalWeight?: number;
|
|
600
|
+
stockCode?: string;
|
|
601
|
+
/** Image URLs in display order (Trendyol's `images` field, spec says `media`). */
|
|
602
|
+
images: string[];
|
|
603
|
+
attributes: ProductAttribute[];
|
|
604
|
+
/** Populated when `status === 'rejected'`. */
|
|
605
|
+
rejectReasonDetails: UnapprovedProductRejectReason[];
|
|
606
|
+
/** Returned by Trendyol; null when the seller has not configured this. */
|
|
607
|
+
origin?: string | null;
|
|
608
|
+
locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
|
|
609
|
+
lotNumber?: string | null;
|
|
610
|
+
/** Special consumption tax (ÖTV) where applicable. */
|
|
611
|
+
specialConsumptionTax?: number | null;
|
|
612
|
+
/** Suggested governance retail price (Suggested Government Retail price). */
|
|
613
|
+
sgrPrice?: number | null;
|
|
614
|
+
/** ISO 8601 UTC string (from `createDateTime` ms-epoch). */
|
|
615
|
+
createdAt?: string;
|
|
616
|
+
/** ISO 8601 UTC string (from `lastUpdateDate`). */
|
|
617
|
+
updatedAt?: string;
|
|
618
|
+
/** ISO 8601 UTC string (from `lastPriceChangeDate`). */
|
|
619
|
+
lastPriceChangedAt?: string;
|
|
620
|
+
/** ISO 8601 UTC string (from `lastStockChangeDate`). */
|
|
621
|
+
lastStockChangedAt?: string;
|
|
622
|
+
/** Untouched raw response. */
|
|
623
|
+
raw: Record<string, unknown>;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Basic lifecycle info for a single product, returned by `getProductBase`.
|
|
627
|
+
*
|
|
628
|
+
* Cheap to call (no body — just barcode in path) and useful as a polling
|
|
629
|
+
* primitive after `createProducts` to detect `approved: true`.
|
|
630
|
+
*/
|
|
631
|
+
interface ProductBase {
|
|
632
|
+
barcode: string;
|
|
633
|
+
approved: boolean;
|
|
634
|
+
archived: boolean;
|
|
635
|
+
/** ISO 8601 UTC string (from `approvedDate` ms-epoch); `undefined` until approved. */
|
|
636
|
+
approvedAt?: string;
|
|
637
|
+
/** Stable listing ID assigned after approval. */
|
|
638
|
+
listingId?: string;
|
|
639
|
+
/** Trendyol's content ID — the same field on `Product.contentId`. */
|
|
640
|
+
contentId?: string;
|
|
641
|
+
/** Untouched raw response. */
|
|
642
|
+
raw: Record<string, unknown>;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Buybox status for a single barcode, returned by `getBuyboxInformation`.
|
|
646
|
+
*
|
|
647
|
+
* `buyboxOrder === 1` means you currently hold the buybox.
|
|
648
|
+
* `secondBuyboxPrice` / `thirdBuyboxPrice` are surfaced from live wire (not
|
|
649
|
+
* in the spec) so you can see what other sellers are charging.
|
|
650
|
+
*/
|
|
651
|
+
interface BuyboxInfo {
|
|
652
|
+
barcode: string;
|
|
653
|
+
/** Position in the buybox ranking (1 = you hold it). */
|
|
654
|
+
buyboxOrder?: number;
|
|
655
|
+
/** Current buybox-winning price. */
|
|
656
|
+
buyboxPrice?: number;
|
|
657
|
+
hasMultipleSeller?: boolean;
|
|
658
|
+
/** Second-best price (when multiple sellers compete). */
|
|
659
|
+
secondBuyboxPrice?: number | null;
|
|
660
|
+
/** Third-best price. */
|
|
661
|
+
thirdBuyboxPrice?: number | null;
|
|
662
|
+
/** Untouched raw response. */
|
|
663
|
+
raw: Record<string, unknown>;
|
|
664
|
+
}
|
|
473
665
|
/**
|
|
474
666
|
* Status of an async batch request returned by `createProducts`,
|
|
475
667
|
* `updatePriceAndInventory`, and other Trendyol bulk endpoints.
|
|
@@ -507,6 +699,140 @@ interface BatchRequestResult {
|
|
|
507
699
|
raw: Record<string, unknown>;
|
|
508
700
|
}
|
|
509
701
|
|
|
702
|
+
/**
|
|
703
|
+
* Input types for Trendyol product write endpoints (V2).
|
|
704
|
+
*
|
|
705
|
+
* All five write endpoints (`createProducts`, `updateContentBulk`,
|
|
706
|
+
* `updateVariantBulk`, `updateUnapproved`, `updateDeliveryInfoBulk`) are
|
|
707
|
+
* async batch operations: SDK accepts the typed payload, Trendyol returns
|
|
708
|
+
* `{ batchRequestId }`, and the caller polls via `products.getBatchStatus`.
|
|
709
|
+
*/
|
|
710
|
+
/** Response shape for every async write endpoint in the product API. */
|
|
711
|
+
interface BatchAcceptedResponse {
|
|
712
|
+
/** Opaque ID — pass to `products.getBatchStatus(...)` to track. */
|
|
713
|
+
batchRequestId: string;
|
|
714
|
+
}
|
|
715
|
+
/** A V2 product attribute payload. Mutually-exclusive value selectors. */
|
|
716
|
+
interface ProductAttributeV2Input {
|
|
717
|
+
attributeId: number;
|
|
718
|
+
/**
|
|
719
|
+
* One or more attribute value IDs (V2 supports multi-value when the
|
|
720
|
+
* attribute's `allowMultipleAttributeValues` flag is true).
|
|
721
|
+
*/
|
|
722
|
+
attributeValueIds?: number[];
|
|
723
|
+
/** Free-text value (only when the attribute's `allowCustom` flag is true). */
|
|
724
|
+
attributeValue?: string;
|
|
725
|
+
}
|
|
726
|
+
/** Image entry: just a URL (Trendyol fetches the image asynchronously). */
|
|
727
|
+
interface ProductImageInput {
|
|
728
|
+
/** https URL; Trendyol recommends 1200×1800, 96 DPI. */
|
|
729
|
+
url: string;
|
|
730
|
+
}
|
|
731
|
+
/** Per-variant delivery option (used by `create` + `updateUnapproved`). */
|
|
732
|
+
interface DeliveryOptionInput {
|
|
733
|
+
deliveryDuration?: number;
|
|
734
|
+
fastDeliveryType?: 'SAME_DAY_SHIPPING' | 'FAST_DELIVERY';
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Payload for one item in `createProducts` (V2).
|
|
738
|
+
*
|
|
739
|
+
* Trendyol requires all 14 fields listed in the spec — the type makes them
|
|
740
|
+
* non-optional so missing required fields fail at compile time, not at
|
|
741
|
+
* runtime after a failed batch.
|
|
742
|
+
*/
|
|
743
|
+
interface CreateProductV2Input {
|
|
744
|
+
/** Barcode (≤40 chars, allows `.`, `-`, `_`). */
|
|
745
|
+
barcode: string;
|
|
746
|
+
/** Title (≤100 chars). */
|
|
747
|
+
title: string;
|
|
748
|
+
/** Parent product ID for variant grouping (≤40 chars). */
|
|
749
|
+
productMainId: string;
|
|
750
|
+
/** Trendyol numeric brand ID (from `brands.list`). */
|
|
751
|
+
brandId: number;
|
|
752
|
+
/** Trendyol numeric category ID (from `categories.list`). */
|
|
753
|
+
categoryId: number;
|
|
754
|
+
/** Initial stock quantity. */
|
|
755
|
+
quantity: number;
|
|
756
|
+
/** Seller-side stock code (≤100 chars). */
|
|
757
|
+
stockCode: string;
|
|
758
|
+
/** Desi value used for shipping cost calculation. */
|
|
759
|
+
dimensionalWeight: number;
|
|
760
|
+
/** HTML-friendly product description (≤30 000 chars). */
|
|
761
|
+
description: string;
|
|
762
|
+
/** List price (PSF). Must be ≥ `salePrice`. */
|
|
763
|
+
listPrice: number;
|
|
764
|
+
/** Sale price (TSF). */
|
|
765
|
+
salePrice: number;
|
|
766
|
+
/** 1–8 image URLs. */
|
|
767
|
+
images: ProductImageInput[];
|
|
768
|
+
/** VAT rate as integer percent (0, 1, 10, 20). */
|
|
769
|
+
vatRate: number;
|
|
770
|
+
/** Required attributes for the category — fetch via `categories.getAttributes`. */
|
|
771
|
+
attributes: ProductAttributeV2Input[];
|
|
772
|
+
/** Delivery duration / fast-delivery type. */
|
|
773
|
+
deliveryOption?: DeliveryOptionInput;
|
|
774
|
+
/** Lot/SKT info (≤100 chars). */
|
|
775
|
+
lotNumber?: string | null;
|
|
776
|
+
/** Shipment warehouse ID (from `suppliers.getAddresses`). */
|
|
777
|
+
shipmentAddressId?: number;
|
|
778
|
+
/** Returning warehouse ID. */
|
|
779
|
+
returningAddressId?: number;
|
|
780
|
+
}
|
|
781
|
+
/** Payload for one item in `updateContentBulk` (only `contentId` is required). */
|
|
782
|
+
interface UpdateContentInput {
|
|
783
|
+
/** From `Product.contentId` on `products.list` results. */
|
|
784
|
+
contentId: number;
|
|
785
|
+
title?: string;
|
|
786
|
+
description?: string;
|
|
787
|
+
images?: ProductImageInput[];
|
|
788
|
+
/**
|
|
789
|
+
* If you update ANY attribute, you must send ALL attributes — partial
|
|
790
|
+
* attribute updates are not supported by Trendyol on this endpoint.
|
|
791
|
+
*/
|
|
792
|
+
attributes?: ProductAttributeV2Input[];
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Payload for one item in `updateVariantBulk`. `barcode` is the identifier;
|
|
796
|
+
* Trendyol does not allow updating the barcode itself via this endpoint.
|
|
797
|
+
*/
|
|
798
|
+
interface UpdateVariantInput {
|
|
799
|
+
barcode: string;
|
|
800
|
+
stockCode?: string;
|
|
801
|
+
vatRate?: number;
|
|
802
|
+
shipmentAddressId?: number;
|
|
803
|
+
returningAddressId?: number;
|
|
804
|
+
dimensionalWeight?: number;
|
|
805
|
+
lotNumber?: string | null;
|
|
806
|
+
locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
|
|
807
|
+
}
|
|
808
|
+
/** Payload for one item in `updateUnapprovedProducts` — all optional except `barcode`. */
|
|
809
|
+
interface UpdateUnapprovedInput {
|
|
810
|
+
barcode: string;
|
|
811
|
+
title?: string;
|
|
812
|
+
description?: string;
|
|
813
|
+
productMainId?: string;
|
|
814
|
+
brandId?: number;
|
|
815
|
+
categoryId?: number;
|
|
816
|
+
stockCode?: string;
|
|
817
|
+
dimensionalWeight?: number;
|
|
818
|
+
vatRate?: number;
|
|
819
|
+
deliveryOption?: DeliveryOptionInput;
|
|
820
|
+
locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
|
|
821
|
+
lotNumber?: string | null;
|
|
822
|
+
shipmentAddressId?: number;
|
|
823
|
+
returningAddressId?: number;
|
|
824
|
+
images?: ProductImageInput[];
|
|
825
|
+
attributes?: ProductAttributeV2Input[];
|
|
826
|
+
}
|
|
827
|
+
/** Payload for one item in `updateDeliveryInfoBulk`. */
|
|
828
|
+
interface UpdateDeliveryInfoInput {
|
|
829
|
+
barcode: string;
|
|
830
|
+
deliveryOptions?: {
|
|
831
|
+
deliveryDuration?: number;
|
|
832
|
+
fastDeliveryType?: 'SAME_DAY_SHIPPING' | 'FAST_DELIVERY';
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
|
|
510
836
|
interface ListProductsParams extends CursorPaginationParams {
|
|
511
837
|
/** Filter by a single barcode. */
|
|
512
838
|
barcode?: string;
|
|
@@ -515,22 +841,47 @@ interface ListProductsParams extends CursorPaginationParams {
|
|
|
515
841
|
/** Filter products updated on or before this date. */
|
|
516
842
|
endDate?: Date;
|
|
517
843
|
}
|
|
844
|
+
/** Date field to filter against on `listUnapproved` (default: server choice). */
|
|
845
|
+
type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
|
|
846
|
+
interface ListUnapprovedProductsParams extends CursorPaginationParams {
|
|
847
|
+
barcode?: string;
|
|
848
|
+
startDate?: Date;
|
|
849
|
+
endDate?: Date;
|
|
850
|
+
/** Choose which date `startDate`/`endDate` apply to. */
|
|
851
|
+
dateQueryType?: UnapprovedDateQueryType;
|
|
852
|
+
/**
|
|
853
|
+
* Optional override of the seller-scoped query (rare; defaults to the
|
|
854
|
+
* client's `sellerId`).
|
|
855
|
+
*/
|
|
856
|
+
supplierId?: number;
|
|
857
|
+
}
|
|
518
858
|
/**
|
|
519
|
-
* Trendyol product
|
|
859
|
+
* Trendyol product read + write + lifecycle + batch-result endpoints.
|
|
520
860
|
*
|
|
521
861
|
* Rate limits (per Trendyol service limits):
|
|
522
|
-
* - filterProducts: 2000 req/min
|
|
862
|
+
* - filterProducts (approved + unapproved + getProductBase): 2000 req/min
|
|
523
863
|
* - getBatchRequestResult: 1000 req/min
|
|
864
|
+
* - getBuyboxInformation: 1000 req/min
|
|
865
|
+
* - create/update/archive/unlock product writes: 1000 req/min (shared bucket)
|
|
866
|
+
* - delete: 100 req/min (separate bucket)
|
|
524
867
|
*/
|
|
525
868
|
declare class ProductsResource {
|
|
526
869
|
private readonly transport;
|
|
527
870
|
private readonly sellerId;
|
|
528
871
|
private readonly filterLimiter;
|
|
529
872
|
private readonly batchLimiter;
|
|
873
|
+
private readonly buyboxLimiter;
|
|
874
|
+
private readonly writeLimiter;
|
|
875
|
+
private readonly deleteLimiter;
|
|
530
876
|
constructor(transport: TrendyolTransport, sellerId: number, options?: {
|
|
531
877
|
filterLimiter?: TokenBucketRateLimiter;
|
|
532
878
|
batchLimiter?: TokenBucketRateLimiter;
|
|
879
|
+
buyboxLimiter?: TokenBucketRateLimiter;
|
|
880
|
+
writeLimiter?: TokenBucketRateLimiter;
|
|
881
|
+
deleteLimiter?: TokenBucketRateLimiter;
|
|
533
882
|
});
|
|
883
|
+
private validateBarcodes;
|
|
884
|
+
private submitWrite;
|
|
534
885
|
/**
|
|
535
886
|
* List approved products. Use `paginate()` from `@lonca/core` to iterate
|
|
536
887
|
* lazily across pages.
|
|
@@ -561,6 +912,142 @@ declare class ProductsResource {
|
|
|
561
912
|
* @param batchRequestId The opaque ID returned by the originating call.
|
|
562
913
|
*/
|
|
563
914
|
getBatchStatus(batchRequestId: string): Promise<BatchRequestResult>;
|
|
915
|
+
/**
|
|
916
|
+
* List **unapproved** (draft / rejected / pending-review) products.
|
|
917
|
+
*
|
|
918
|
+
* Wire shape is intentionally flatter than the approved-product shape:
|
|
919
|
+
* each barcode is one top-level item with `barcode`, `quantity`, `salePrice`
|
|
920
|
+
* etc. at the root. Rejected drafts carry `rejectReasonDetails` so you can
|
|
921
|
+
* surface why Trendyol's content team turned them down.
|
|
922
|
+
*
|
|
923
|
+
* Pagination follows the same convention as `list()`: `cursor` from the
|
|
924
|
+
* previous response forwards as `nextPageToken`.
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```ts
|
|
928
|
+
* const page = await client.products.listUnapproved({ limit: 50 });
|
|
929
|
+
* for (const draft of page.items) {
|
|
930
|
+
* if (draft.status === 'rejected') {
|
|
931
|
+
* console.warn(draft.barcode, draft.rejectReasonDetails);
|
|
932
|
+
* }
|
|
933
|
+
* }
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
listUnapproved(params?: ListUnapprovedProductsParams): Promise<CursorPage<UnapprovedProduct>>;
|
|
937
|
+
/**
|
|
938
|
+
* Fetch the basic lifecycle status of a single product by barcode.
|
|
939
|
+
*
|
|
940
|
+
* Cheap and useful as a polling primitive after `createProducts`: poll
|
|
941
|
+
* this endpoint until `approved` flips to `true` (or use
|
|
942
|
+
* `client.products.getBatchStatus()` to track the originating batch).
|
|
943
|
+
*
|
|
944
|
+
* @param barcode The product barcode to look up.
|
|
945
|
+
*/
|
|
946
|
+
getBase(barcode: string): Promise<ProductBase>;
|
|
947
|
+
/**
|
|
948
|
+
* Fetch buybox information for up to 10 barcodes in one call.
|
|
949
|
+
*
|
|
950
|
+
* Returns rank (`buyboxOrder === 1` means you hold the buybox), the
|
|
951
|
+
* current buybox price, and — beyond the spec — the second and third
|
|
952
|
+
* competing prices when other sellers are present.
|
|
953
|
+
*
|
|
954
|
+
* @param barcodes 1–10 product barcodes.
|
|
955
|
+
* @throws {ValidationError} when `barcodes` is empty or longer than 10.
|
|
956
|
+
*/
|
|
957
|
+
getBuyboxInfo(barcodes: string[]): Promise<BuyboxInfo[]>;
|
|
958
|
+
/**
|
|
959
|
+
* Create products (V2). Async batch — returns a `batchRequestId` you can
|
|
960
|
+
* poll with `getBatchStatus`. Max 1000 items per call.
|
|
961
|
+
*
|
|
962
|
+
* Trendyol requires the full V2 attribute payload — fetch via
|
|
963
|
+
* `categories.getAttributes` (and `categories.getAttributeValues` for
|
|
964
|
+
* values when `allowCustom === false`). Shipment / returning warehouse
|
|
965
|
+
* IDs come from `suppliers.getAddresses`.
|
|
966
|
+
*
|
|
967
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
968
|
+
*/
|
|
969
|
+
create(items: CreateProductV2Input[]): Promise<BatchAcceptedResponse>;
|
|
970
|
+
/**
|
|
971
|
+
* Update **content** of approved products (title, description, images,
|
|
972
|
+
* attributes). Identified by `contentId`. Partial update is supported
|
|
973
|
+
* except for attributes — if you update ANY attribute, send ALL of them.
|
|
974
|
+
*
|
|
975
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
976
|
+
*/
|
|
977
|
+
updateContent(items: UpdateContentInput[]): Promise<BatchAcceptedResponse>;
|
|
978
|
+
/**
|
|
979
|
+
* Update **variant** fields of approved products (stockCode, vatRate,
|
|
980
|
+
* dimensionalWeight, warehouse IDs, location-based delivery, lot). Identified
|
|
981
|
+
* by `barcode`. The barcode itself cannot be changed via this endpoint.
|
|
982
|
+
*
|
|
983
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
984
|
+
*/
|
|
985
|
+
updateVariants(items: UpdateVariantInput[]): Promise<BatchAcceptedResponse>;
|
|
986
|
+
/**
|
|
987
|
+
* Update **unapproved** (draft) products. Identified by `barcode`. All
|
|
988
|
+
* other fields are optional partial updates. Use this to fix drafts that
|
|
989
|
+
* Trendyol rejected — `client.products.listUnapproved` surfaces the
|
|
990
|
+
* `rejectReasonDetails` you need to act on.
|
|
991
|
+
*
|
|
992
|
+
* **Gotcha (verified live STAGE 2026-05-25):** Trendyol's V2 spec claims
|
|
993
|
+
* only `barcode` is required, but the endpoint returns HTTP 500
|
|
994
|
+
* (`TrendyolSystemException` / `TypeError`) when too many optional fields
|
|
995
|
+
* are omitted. In practice, send at least `title`, `description`,
|
|
996
|
+
* `productMainId`, `brandId`, `categoryId`, `stockCode`,
|
|
997
|
+
* `dimensionalWeight`, `vatRate`, `images[]`, and `attributes[]` (an
|
|
998
|
+
* empty array is OK for the latter). The SDK forwards your payload
|
|
999
|
+
* as-is; trim fields only if you have verified the server accepts it.
|
|
1000
|
+
*
|
|
1001
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
1002
|
+
*/
|
|
1003
|
+
updateUnapproved(items: UpdateUnapprovedInput[]): Promise<BatchAcceptedResponse>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Update product **delivery information** (deliveryDuration,
|
|
1006
|
+
* fastDeliveryType). Identified by `barcode`.
|
|
1007
|
+
*
|
|
1008
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
1009
|
+
*/
|
|
1010
|
+
updateDeliveryInfo(items: UpdateDeliveryInfoInput[]): Promise<BatchAcceptedResponse>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Delete products by barcode. Trendyol allows deletion of unapproved
|
|
1013
|
+
* products and approved products that have been archived for more than a
|
|
1014
|
+
* day (and have not been sales-stopped by Trendyol).
|
|
1015
|
+
*
|
|
1016
|
+
* Async batch — returns `{ batchRequestId }` to poll via `getBatchStatus`.
|
|
1017
|
+
* Separately rate-limited at **100 req/min** (much tighter than create/update).
|
|
1018
|
+
*
|
|
1019
|
+
* @param barcodes 1–1000 barcodes.
|
|
1020
|
+
* @throws {ValidationError} when `barcodes` is empty or longer than 1000.
|
|
1021
|
+
*/
|
|
1022
|
+
delete(barcodes: string[]): Promise<BatchAcceptedResponse>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Archive products by barcode (Trendyol's `archived=true` state).
|
|
1025
|
+
* Archived products are not visible to customers; pair with `delete`
|
|
1026
|
+
* after the 24-hour archive cool-down to remove them entirely.
|
|
1027
|
+
*
|
|
1028
|
+
* Async batch — returns `{ batchRequestId }`.
|
|
1029
|
+
*
|
|
1030
|
+
* @throws {ValidationError} when `barcodes` is empty or longer than 1000.
|
|
1031
|
+
*/
|
|
1032
|
+
archive(barcodes: string[]): Promise<BatchAcceptedResponse>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Unarchive products by barcode (Trendyol's `archived=false` state).
|
|
1035
|
+
* Restores visibility for previously-archived products.
|
|
1036
|
+
*
|
|
1037
|
+
* @throws {ValidationError} when `barcodes` is empty or longer than 1000.
|
|
1038
|
+
*/
|
|
1039
|
+
unarchive(barcodes: string[]): Promise<BatchAcceptedResponse>;
|
|
1040
|
+
private setArchivedState;
|
|
1041
|
+
/**
|
|
1042
|
+
* Unlock products whose sale was paused by Trendyol due to pricing
|
|
1043
|
+
* issues (under/over-pricing, critical price error, supplier issues).
|
|
1044
|
+
* Restores selling status for the listed barcodes.
|
|
1045
|
+
*
|
|
1046
|
+
* Async batch — returns `{ batchRequestId }`.
|
|
1047
|
+
*
|
|
1048
|
+
* @throws {ValidationError} when `barcodes` is empty or longer than 1000.
|
|
1049
|
+
*/
|
|
1050
|
+
unlock(barcodes: string[]): Promise<BatchAcceptedResponse>;
|
|
564
1051
|
}
|
|
565
1052
|
|
|
566
1053
|
/**
|
|
@@ -688,4 +1175,4 @@ interface TrendyolClient {
|
|
|
688
1175
|
*/
|
|
689
1176
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
690
1177
|
|
|
691
|
-
export { type BatchRequestItemResult, type BatchRequestResult, type BatchRequestStatus, type Brand, BrandsResource, CategoriesResource, type Category, type CategoryAttribute, type CategoryAttributeValue, type CreateClientOptions, InventoryResource, type ListOrdersParams, type ListProductsParams, type NamedRef, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, type PackageHistoryEntry, type PriceInventoryUpdate, type Product, type ProductAttribute, type ProductVariant, ProductsResource, type ShipmentPackage, type ShipmentPackageStatus, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, type TrendyolClient, type TrendyolEnvironment, type UpdatePriceInventoryResponse, createTrendyolClient };
|
|
1178
|
+
export { type BarcodeCategoryLookup, type BatchAcceptedResponse, type BatchRequestItemResult, type BatchRequestResult, type BatchRequestStatus, type Brand, BrandsResource, type BuyboxInfo, CategoriesResource, type Category, type CategoryAttribute, type CategoryAttributeValue, type CreateClientOptions, type CreateProductV2Input, type DeliveryOptionInput, InventoryResource, type ListCategoryAttributeValuesParams, type ListOrdersParams, type ListProductsParams, type ListUnapprovedProductsParams, type NamedRef, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, type PackageHistoryEntry, type PriceInventoryUpdate, type Product, type ProductAttribute, type ProductAttributeV2Input, type ProductBase, type ProductImageInput, type ProductVariant, ProductsResource, type ShipmentPackage, type ShipmentPackageStatus, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, type TrendyolClient, type TrendyolEnvironment, type UnapprovedDateQueryType, type UnapprovedProduct, type UnapprovedProductRejectReason, type UnapprovedProductStatus, type UpdateContentInput, type UpdateDeliveryInfoInput, type UpdatePriceInventoryResponse, type UpdateUnapprovedInput, type UpdateVariantInput, createTrendyolClient };
|