@lonca/trendyol 0.1.0 → 0.2.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/LICENSE +21 -0
- package/dist/index.cjs +582 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +562 -1
- package/dist/index.d.ts +562 -1
- package/dist/index.js +579 -4
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,562 @@ declare class BrandsResource {
|
|
|
79
79
|
list(params?: CursorPaginationParams): Promise<CursorPage<Brand>>;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* A node in the Trendyol category tree.
|
|
84
|
+
*
|
|
85
|
+
* Trendyol exposes categories as a deeply nested structure where each node
|
|
86
|
+
* can have child categories under `subCategories`. We normalize numeric IDs
|
|
87
|
+
* to strings to match the `@lonca/core` convention.
|
|
88
|
+
*/
|
|
89
|
+
interface Category {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
/** `null` when this is a root category. */
|
|
93
|
+
parentId: string | null;
|
|
94
|
+
subCategories: Category[];
|
|
95
|
+
}
|
|
96
|
+
/** A single allowed value for a category attribute. */
|
|
97
|
+
interface CategoryAttributeValue {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A required or optional attribute for products in a given category.
|
|
103
|
+
* Use these when constructing a `createProduct V2` payload — the API rejects
|
|
104
|
+
* products that omit `required` attributes.
|
|
105
|
+
*/
|
|
106
|
+
interface CategoryAttribute {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
/** The category this attribute belongs to (echoed back by Trendyol). */
|
|
110
|
+
categoryId?: string;
|
|
111
|
+
required: boolean;
|
|
112
|
+
/** Whether the attribute accepts custom text values in addition to the listed ones. */
|
|
113
|
+
allowCustom: boolean;
|
|
114
|
+
/** Whether the attribute participates in product variants (e.g. color, size). */
|
|
115
|
+
varianter: boolean;
|
|
116
|
+
/** Whether the attribute is used as a price slicer (e.g. size for shoes). */
|
|
117
|
+
slicer: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* V2-only: whether the attribute accepts multiple values at once.
|
|
120
|
+
* Present on responses from the V2 `getCategoryAttributes` endpoint; absent on V1.
|
|
121
|
+
*/
|
|
122
|
+
allowMultipleAttributeValues?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Allowed values for this attribute.
|
|
125
|
+
*
|
|
126
|
+
* NOTE: Trendyol's live API often omits this field on the `getCategoryAttributes`
|
|
127
|
+
* response — the endpoint returns attribute metadata + flags, not the full value
|
|
128
|
+
* catalog. In that case `values` is an empty array. If `allowCustom` is `true`,
|
|
129
|
+
* any custom text is accepted; otherwise consult Trendyol's separate value
|
|
130
|
+
* lookup mechanisms (a dedicated `getAttributeValues` endpoint may land in a
|
|
131
|
+
* future release of this SDK).
|
|
132
|
+
*/
|
|
133
|
+
values: CategoryAttributeValue[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Trendyol category-tree and category-attribute endpoints.
|
|
138
|
+
*
|
|
139
|
+
* Rate limits (per Trendyol service limits):
|
|
140
|
+
* - Category list: 50 req/min
|
|
141
|
+
* - Category attributes: 50 req/min
|
|
142
|
+
*
|
|
143
|
+
* Both rate counters live on the same Trendyol service, so we share one
|
|
144
|
+
* limiter across both endpoints.
|
|
145
|
+
*/
|
|
146
|
+
declare class CategoriesResource {
|
|
147
|
+
private readonly transport;
|
|
148
|
+
private readonly limiter;
|
|
149
|
+
constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
|
|
150
|
+
/**
|
|
151
|
+
* Fetch the full Trendyol category tree.
|
|
152
|
+
*
|
|
153
|
+
* Trendyol returns the entire tree in one response — there is no pagination.
|
|
154
|
+
* Cache the result aggressively in your application; the tree changes rarely.
|
|
155
|
+
*/
|
|
156
|
+
list(): Promise<Category[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Fetch the attributes (required and optional) for a single category.
|
|
159
|
+
*
|
|
160
|
+
* Call this before `createProduct V2` so you know which attributes are
|
|
161
|
+
* mandatory — the API rejects products that omit any `required` attribute.
|
|
162
|
+
*
|
|
163
|
+
* @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
|
|
164
|
+
*/
|
|
165
|
+
getAttributes(categoryId: string | number): Promise<CategoryAttribute[]>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A single price / stock update entry.
|
|
170
|
+
*
|
|
171
|
+
* `barcode` is the only required field. Include any combination of:
|
|
172
|
+
* - `quantity` to update stock (max 20 000 per product)
|
|
173
|
+
* - `salePrice` to update the sale price
|
|
174
|
+
* - `listPrice` to update the list (strikethrough) price
|
|
175
|
+
*
|
|
176
|
+
* `listPrice` must be greater than or equal to `salePrice`.
|
|
177
|
+
*/
|
|
178
|
+
interface PriceInventoryUpdate {
|
|
179
|
+
barcode: string;
|
|
180
|
+
quantity?: number;
|
|
181
|
+
salePrice?: number;
|
|
182
|
+
listPrice?: number;
|
|
183
|
+
}
|
|
184
|
+
/** Response from `updatePriceAndInventory` — poll with `products.getBatchStatus`. */
|
|
185
|
+
interface UpdatePriceInventoryResponse {
|
|
186
|
+
batchRequestId: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Trendyol stock & price update endpoint (a.k.a. `updatePriceAndInventory`).
|
|
191
|
+
*
|
|
192
|
+
* Rate limit: **none** — Trendyol explicitly lists this endpoint as
|
|
193
|
+
* `NO LIMIT` in its service limits table. The `15-minute duplicate
|
|
194
|
+
* suppression` rule still applies on Trendyol's side, but that's a
|
|
195
|
+
* server-side concern.
|
|
196
|
+
*
|
|
197
|
+
* The endpoint is asynchronous. The response carries a `batchRequestId`
|
|
198
|
+
* you can poll with `client.products.getBatchStatus(batchRequestId)` —
|
|
199
|
+
* Trendyol retains the result for 4 hours.
|
|
200
|
+
*/
|
|
201
|
+
declare class InventoryResource {
|
|
202
|
+
private readonly transport;
|
|
203
|
+
private readonly sellerId;
|
|
204
|
+
constructor(transport: TrendyolTransport, sellerId: number);
|
|
205
|
+
/**
|
|
206
|
+
* Update price and/or stock for one or more SKUs (by barcode).
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const { batchRequestId } = await client.inventory.update([
|
|
211
|
+
* { barcode: 'ABC123', quantity: 42, salePrice: 199.9, listPrice: 249.9 },
|
|
212
|
+
* { barcode: 'XYZ789', quantity: 0 },
|
|
213
|
+
* ]);
|
|
214
|
+
* const status = await client.products.getBatchStatus(batchRequestId);
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @throws {ValidationError} when `items` is empty or longer than 1000.
|
|
218
|
+
*/
|
|
219
|
+
update(items: PriceInventoryUpdate[]): Promise<UpdatePriceInventoryResponse>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Trendyol shipment-package status.
|
|
224
|
+
*
|
|
225
|
+
* Trendyol uses ~13 distinct values (Created, Picking, Invoiced, Shipped,
|
|
226
|
+
* Cancelled, Delivered, UnDelivered, Returned, UnSupplied, Awaiting,
|
|
227
|
+
* UnPacked, AtCollectionPoint, Verified). Typed as a union with an open
|
|
228
|
+
* escape so unknown values still type-check.
|
|
229
|
+
*/
|
|
230
|
+
type ShipmentPackageStatus = 'Created' | 'Picking' | 'Invoiced' | 'Shipped' | 'Cancelled' | 'Delivered' | 'UnDelivered' | 'Returned' | 'UnSupplied' | 'Awaiting' | 'UnPacked' | 'AtCollectionPoint' | 'Verified' | (string & {});
|
|
231
|
+
interface OrderAddressLines {
|
|
232
|
+
addressLine1?: string;
|
|
233
|
+
addressLine2?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A customer or invoice/shipment address returned alongside a shipment package.
|
|
237
|
+
* Field set is conservative — Trendyol returns many optional locality fields
|
|
238
|
+
* and we surface them as-is.
|
|
239
|
+
*/
|
|
240
|
+
interface OrderAddress {
|
|
241
|
+
id?: string;
|
|
242
|
+
firstName?: string;
|
|
243
|
+
lastName?: string;
|
|
244
|
+
fullName?: string;
|
|
245
|
+
company?: string;
|
|
246
|
+
address1?: string;
|
|
247
|
+
address2?: string;
|
|
248
|
+
fullAddress?: string;
|
|
249
|
+
shortAddress?: string;
|
|
250
|
+
city?: string;
|
|
251
|
+
cityCode?: number;
|
|
252
|
+
district?: string;
|
|
253
|
+
districtId?: number;
|
|
254
|
+
neighborhoodId?: number;
|
|
255
|
+
countyId?: number;
|
|
256
|
+
countyName?: string;
|
|
257
|
+
stateName?: string;
|
|
258
|
+
postalCode?: string;
|
|
259
|
+
countryCode?: string;
|
|
260
|
+
phone?: string;
|
|
261
|
+
addressLines?: OrderAddressLines;
|
|
262
|
+
}
|
|
263
|
+
/** Customer details on a shipment package (a subset of what Trendyol exposes). */
|
|
264
|
+
interface OrderCustomer {
|
|
265
|
+
id?: string;
|
|
266
|
+
firstName: string;
|
|
267
|
+
lastName: string;
|
|
268
|
+
email?: string;
|
|
269
|
+
taxNumber?: string;
|
|
270
|
+
identityNumber?: string;
|
|
271
|
+
}
|
|
272
|
+
interface OrderLineDiscountDetail {
|
|
273
|
+
lineItemPrice?: number;
|
|
274
|
+
lineItemSellerDiscount?: number;
|
|
275
|
+
lineItemTyDiscount?: number;
|
|
276
|
+
}
|
|
277
|
+
/** A single item line inside a shipment package. */
|
|
278
|
+
interface OrderLine {
|
|
279
|
+
/** Trendyol's `lineId`. */
|
|
280
|
+
id: string;
|
|
281
|
+
quantity: number;
|
|
282
|
+
productName: string;
|
|
283
|
+
barcode: string;
|
|
284
|
+
productSize?: string;
|
|
285
|
+
productColor?: string;
|
|
286
|
+
stockCode?: string;
|
|
287
|
+
contentId?: string;
|
|
288
|
+
sellerId?: string;
|
|
289
|
+
productCategoryId?: string;
|
|
290
|
+
salesCampaignId?: string;
|
|
291
|
+
currencyCode?: string;
|
|
292
|
+
lineUnitPrice: number;
|
|
293
|
+
lineGrossAmount: number;
|
|
294
|
+
lineSellerDiscount?: number;
|
|
295
|
+
lineTyDiscount?: number;
|
|
296
|
+
lineTotalDiscount?: number;
|
|
297
|
+
vatRate?: number;
|
|
298
|
+
commission?: number;
|
|
299
|
+
orderLineItemStatusName?: string;
|
|
300
|
+
businessUnit?: string;
|
|
301
|
+
fastDeliveryOptions?: unknown[];
|
|
302
|
+
discountDetails?: OrderLineDiscountDetail[];
|
|
303
|
+
/** Untouched raw line response. */
|
|
304
|
+
raw: Record<string, unknown>;
|
|
305
|
+
}
|
|
306
|
+
/** A status transition entry in `packageHistories`. */
|
|
307
|
+
interface PackageHistoryEntry {
|
|
308
|
+
status?: ShipmentPackageStatus;
|
|
309
|
+
/** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
|
|
310
|
+
createdAt?: string;
|
|
311
|
+
raw: Record<string, unknown>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A Trendyol order — Trendyol models orders as "shipment packages". A single
|
|
315
|
+
* customer order may produce multiple shipment packages (one per warehouse,
|
|
316
|
+
* one per cancellation, etc.).
|
|
317
|
+
*
|
|
318
|
+
* `id` is the `shipmentPackageId` (the operational unit); `orderNumber`
|
|
319
|
+
* groups packages that came from the same customer order.
|
|
320
|
+
*/
|
|
321
|
+
interface ShipmentPackage {
|
|
322
|
+
/** `shipmentPackageId` — the operational identifier for this package. */
|
|
323
|
+
id: string;
|
|
324
|
+
orderNumber: string;
|
|
325
|
+
shipmentNumber?: string;
|
|
326
|
+
originPackageIds?: string[] | null;
|
|
327
|
+
warehouseId?: string;
|
|
328
|
+
supplierId?: string;
|
|
329
|
+
status: ShipmentPackageStatus;
|
|
330
|
+
/** Usually identical to `status`; surfaced for completeness. */
|
|
331
|
+
shipmentPackageStatus?: ShipmentPackageStatus;
|
|
332
|
+
customer: OrderCustomer;
|
|
333
|
+
orderDate: string;
|
|
334
|
+
lastModifiedDate: string;
|
|
335
|
+
agreedDeliveryDate?: string;
|
|
336
|
+
estimatedDeliveryStartDate?: string;
|
|
337
|
+
estimatedDeliveryEndDate?: string;
|
|
338
|
+
originShipmentDate?: string;
|
|
339
|
+
currencyCode: string;
|
|
340
|
+
packageTotalPrice: number;
|
|
341
|
+
packageGrossAmount: number;
|
|
342
|
+
packageSellerDiscount: number;
|
|
343
|
+
packageTyDiscount: number;
|
|
344
|
+
packageTotalDiscount: number;
|
|
345
|
+
invoiceAddress?: OrderAddress;
|
|
346
|
+
shipmentAddress?: OrderAddress;
|
|
347
|
+
deliveryAddressType?: string;
|
|
348
|
+
cargoTrackingNumber?: string;
|
|
349
|
+
cargoProviderName?: string;
|
|
350
|
+
cargoProviderId?: string;
|
|
351
|
+
cargoSenderNumber?: string;
|
|
352
|
+
deliveryType?: string;
|
|
353
|
+
whoPays?: number;
|
|
354
|
+
timeSlotId?: number;
|
|
355
|
+
fastDelivery?: boolean;
|
|
356
|
+
fastDeliveryType?: string;
|
|
357
|
+
deliveredByService?: boolean;
|
|
358
|
+
commercial?: boolean;
|
|
359
|
+
micro?: boolean;
|
|
360
|
+
giftBoxRequested?: boolean;
|
|
361
|
+
/** Renamed from Trendyol's wire field `3pByTrendyol` (identifier cannot start with a digit). */
|
|
362
|
+
threePByTrendyol?: boolean;
|
|
363
|
+
containsDangerousProduct?: boolean;
|
|
364
|
+
isCod?: boolean;
|
|
365
|
+
is4P?: boolean;
|
|
366
|
+
invoiceLink?: string;
|
|
367
|
+
createdBy?: string;
|
|
368
|
+
lines: OrderLine[];
|
|
369
|
+
packageHistories: PackageHistoryEntry[];
|
|
370
|
+
/** Untouched raw response for fields not modeled yet. */
|
|
371
|
+
raw: Record<string, unknown>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
interface ListOrdersParams extends CursorPaginationParams {
|
|
375
|
+
status?: ShipmentPackageStatus;
|
|
376
|
+
orderNumber?: string;
|
|
377
|
+
/** Filter packages updated on or after this date (Trendyol expects ms-epoch). */
|
|
378
|
+
startDate?: Date;
|
|
379
|
+
/** Filter packages updated on or before this date. */
|
|
380
|
+
endDate?: Date;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Trendyol order (shipment-package) endpoints.
|
|
384
|
+
*
|
|
385
|
+
* Rate limit (per Trendyol service limits): scheduled to tighten on 2026-05-15;
|
|
386
|
+
* for now we set a generous default that the user can tune via the constructor.
|
|
387
|
+
*
|
|
388
|
+
* Pagination: Trendyol uses page-based pagination here (not nextPageToken).
|
|
389
|
+
* The SDK still exposes `CursorPage<ShipmentPackage>` so the caller can
|
|
390
|
+
* iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes the
|
|
391
|
+
* page index.
|
|
392
|
+
*/
|
|
393
|
+
declare class OrdersResource {
|
|
394
|
+
private readonly transport;
|
|
395
|
+
private readonly sellerId;
|
|
396
|
+
private readonly limiter;
|
|
397
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
398
|
+
/**
|
|
399
|
+
* List shipment packages for the seller.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```ts
|
|
403
|
+
* import { paginate } from '@lonca/core';
|
|
404
|
+
* for await (const pkg of paginate((p) => client.orders.list({ ...p, status: 'Created' }))) {
|
|
405
|
+
* console.log(pkg.id, pkg.status, pkg.customer.firstName);
|
|
406
|
+
* }
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
list(params?: ListOrdersParams): Promise<CursorPage<ShipmentPackage>>;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A `{ id, name }` reference object used in product/category/brand wire types. */
|
|
413
|
+
interface NamedRef {
|
|
414
|
+
id: string;
|
|
415
|
+
name: string;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* A single attribute on a Trendyol product or variant.
|
|
419
|
+
*
|
|
420
|
+
* `attributeValueId` and `attributeValue` are mutually exclusive in createProduct
|
|
421
|
+
* payloads but can both be present in filter responses.
|
|
422
|
+
*/
|
|
423
|
+
interface ProductAttribute {
|
|
424
|
+
attributeId: string;
|
|
425
|
+
attributeName?: string;
|
|
426
|
+
attributeValueId?: string;
|
|
427
|
+
attributeValue?: string;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* A variant of a Trendyol product — the actual purchasable SKU.
|
|
431
|
+
*
|
|
432
|
+
* Trendyol scopes barcode + stock + commission to the variant level even for
|
|
433
|
+
* products that only have a single variant. To read a product's barcode use
|
|
434
|
+
* `product.variants[0].barcode`.
|
|
435
|
+
*/
|
|
436
|
+
interface ProductVariant {
|
|
437
|
+
variantId: string;
|
|
438
|
+
barcode: string;
|
|
439
|
+
commission?: number;
|
|
440
|
+
attributes: ProductAttribute[];
|
|
441
|
+
productUrl?: string;
|
|
442
|
+
onSale?: boolean;
|
|
443
|
+
/** Stock quantity (when the response includes stock data). */
|
|
444
|
+
stock?: number;
|
|
445
|
+
/** Untouched raw response for fields not modeled yet. */
|
|
446
|
+
raw: Record<string, unknown>;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* A Trendyol marketplace product (approved variant).
|
|
450
|
+
*
|
|
451
|
+
* Lonca surfaces the stable fields we have verified against live Trendyol
|
|
452
|
+
* responses. Everything else stays accessible via `raw`.
|
|
453
|
+
*/
|
|
454
|
+
interface Product {
|
|
455
|
+
contentId: string;
|
|
456
|
+
productMainId: string;
|
|
457
|
+
title: string;
|
|
458
|
+
description?: string;
|
|
459
|
+
brand: NamedRef;
|
|
460
|
+
category: NamedRef;
|
|
461
|
+
/** Image URLs in display order. */
|
|
462
|
+
images: string[];
|
|
463
|
+
attributes: ProductAttribute[];
|
|
464
|
+
variants: ProductVariant[];
|
|
465
|
+
/** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
|
|
466
|
+
createdAt: string;
|
|
467
|
+
/** ISO 8601 UTC string. */
|
|
468
|
+
updatedAt: string;
|
|
469
|
+
lastModifiedBy?: string;
|
|
470
|
+
/** Untouched raw response — read fields we have not modeled yet. */
|
|
471
|
+
raw: Record<string, unknown>;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Status of an async batch request returned by `createProducts`,
|
|
475
|
+
* `updatePriceAndInventory`, and other Trendyol bulk endpoints.
|
|
476
|
+
*/
|
|
477
|
+
type BatchRequestStatus = 'PROCESSING' | 'COMPLETED' | 'FAILED' | (string & {});
|
|
478
|
+
interface BatchRequestItemResult {
|
|
479
|
+
requestItem?: unknown;
|
|
480
|
+
status?: string;
|
|
481
|
+
failureReasons?: string[];
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Result of polling `getBatchRequestResult` for a previously-submitted batch.
|
|
485
|
+
*
|
|
486
|
+
* Trendyol retains batch results for **4 hours** after the originating request.
|
|
487
|
+
*/
|
|
488
|
+
interface BatchRequestResult {
|
|
489
|
+
batchRequestId: string;
|
|
490
|
+
status: BatchRequestStatus;
|
|
491
|
+
itemCount?: number;
|
|
492
|
+
failedItemCount?: number;
|
|
493
|
+
items: BatchRequestItemResult[];
|
|
494
|
+
/** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
|
|
495
|
+
createdAt?: string;
|
|
496
|
+
/** ISO 8601 UTC string. */
|
|
497
|
+
lastModifiedAt?: string;
|
|
498
|
+
/** Trendyol category of submission (e.g. `MarketPlace`). */
|
|
499
|
+
sourceType?: string;
|
|
500
|
+
/** Operation type (e.g. `CreateProducts`, `PriceUpdate`). */
|
|
501
|
+
batchRequestType?: string;
|
|
502
|
+
notes?: string;
|
|
503
|
+
/** Storage object key Trendyol uses internally for the batch payload. */
|
|
504
|
+
objectKey?: string;
|
|
505
|
+
storeFrontCode?: string;
|
|
506
|
+
/** Untouched raw response. */
|
|
507
|
+
raw: Record<string, unknown>;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
interface ListProductsParams extends CursorPaginationParams {
|
|
511
|
+
/** Filter by a single barcode. */
|
|
512
|
+
barcode?: string;
|
|
513
|
+
/** Filter products updated on or after this date (Trendyol expects ms-epoch). */
|
|
514
|
+
startDate?: Date;
|
|
515
|
+
/** Filter products updated on or before this date. */
|
|
516
|
+
endDate?: Date;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Trendyol product list + batch-result endpoints.
|
|
520
|
+
*
|
|
521
|
+
* Rate limits (per Trendyol service limits):
|
|
522
|
+
* - filterProducts: 2000 req/min
|
|
523
|
+
* - getBatchRequestResult: 1000 req/min
|
|
524
|
+
*/
|
|
525
|
+
declare class ProductsResource {
|
|
526
|
+
private readonly transport;
|
|
527
|
+
private readonly sellerId;
|
|
528
|
+
private readonly filterLimiter;
|
|
529
|
+
private readonly batchLimiter;
|
|
530
|
+
constructor(transport: TrendyolTransport, sellerId: number, options?: {
|
|
531
|
+
filterLimiter?: TokenBucketRateLimiter;
|
|
532
|
+
batchLimiter?: TokenBucketRateLimiter;
|
|
533
|
+
});
|
|
534
|
+
/**
|
|
535
|
+
* List approved products. Use `paginate()` from `@lonca/core` to iterate
|
|
536
|
+
* lazily across pages.
|
|
537
|
+
*
|
|
538
|
+
* Trendyol exposes both page-based and `nextPageToken`-based pagination
|
|
539
|
+
* (the latter required when the dataset exceeds 10,000 items). The SDK
|
|
540
|
+
* picks the right strategy automatically — pass our opaque `cursor` from
|
|
541
|
+
* the previous response and we forward it as `nextPageToken`.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```ts
|
|
545
|
+
* import { paginate } from '@lonca/core';
|
|
546
|
+
* for await (const product of paginate((p) => client.products.list(p))) {
|
|
547
|
+
* for (const variant of product.variants) {
|
|
548
|
+
* console.log(variant.barcode, product.title);
|
|
549
|
+
* }
|
|
550
|
+
* }
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
list(params?: ListProductsParams): Promise<CursorPage<Product>>;
|
|
554
|
+
/**
|
|
555
|
+
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
556
|
+
* `updatePriceAndInventory`).
|
|
557
|
+
*
|
|
558
|
+
* Trendyol retains batch results for **4 hours** after the originating
|
|
559
|
+
* request — poll within that window.
|
|
560
|
+
*
|
|
561
|
+
* @param batchRequestId The opaque ID returned by the originating call.
|
|
562
|
+
*/
|
|
563
|
+
getBatchStatus(batchRequestId: string): Promise<BatchRequestResult>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* The role an address plays in the seller's logistics flow.
|
|
568
|
+
*
|
|
569
|
+
* Trendyol allows a single physical address to play more than one role
|
|
570
|
+
* (e.g., shipment + invoice), so always check the boolean flags rather than
|
|
571
|
+
* relying solely on `addressType`.
|
|
572
|
+
*/
|
|
573
|
+
type SupplierAddressType = 'SHIPMENT' | 'RETURNING' | 'INVOICE' | 'WAREHOUSE';
|
|
574
|
+
/**
|
|
575
|
+
* A supplier address registered in the Trendyol Partner Panel.
|
|
576
|
+
*
|
|
577
|
+
* Used by `createProduct V2` for `shipmentAddressId` / `returningAddressId`.
|
|
578
|
+
*
|
|
579
|
+
* NOTE: The exact field set is best-effort; some optional fields may differ
|
|
580
|
+
* once verified against real STAGE responses. Bumped fields land in a follow-up
|
|
581
|
+
* minor release if needed.
|
|
582
|
+
*/
|
|
583
|
+
interface SupplierAddress {
|
|
584
|
+
id: string;
|
|
585
|
+
/** Free-form label set by the seller. */
|
|
586
|
+
name?: string;
|
|
587
|
+
/** Primary role declared by Trendyol. */
|
|
588
|
+
addressType: SupplierAddressType;
|
|
589
|
+
isShipmentAddress: boolean;
|
|
590
|
+
isReturningAddress: boolean;
|
|
591
|
+
isInvoiceAddress: boolean;
|
|
592
|
+
isDefault: boolean;
|
|
593
|
+
/** Multi-line address string as registered in the Partner Panel. */
|
|
594
|
+
address?: string;
|
|
595
|
+
city?: string;
|
|
596
|
+
district?: string;
|
|
597
|
+
postCode?: string;
|
|
598
|
+
fullName?: string;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
interface SuppliersResourceOptions {
|
|
602
|
+
/** Override the in-memory cache TTL. Defaults to 1 hour. */
|
|
603
|
+
cacheTtlMs?: number;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Trendyol supplier address endpoints.
|
|
607
|
+
*
|
|
608
|
+
* **Critical:** Trendyol rate-limits `getSuppliersAddresses` to **1 request
|
|
609
|
+
* per hour per seller**. This resource therefore wraps the endpoint with an
|
|
610
|
+
* in-memory cache (default TTL: 1 hour) so callers can request addresses
|
|
611
|
+
* as often as needed without tripping the limit.
|
|
612
|
+
*
|
|
613
|
+
* Use `{ forceRefresh: true }` or `invalidateCache()` only when you know the
|
|
614
|
+
* address list changed in the Partner Panel.
|
|
615
|
+
*/
|
|
616
|
+
declare class SuppliersResource {
|
|
617
|
+
private readonly transport;
|
|
618
|
+
private readonly sellerId;
|
|
619
|
+
private cache;
|
|
620
|
+
private readonly cacheTtlMs;
|
|
621
|
+
private readonly limiter;
|
|
622
|
+
private inflight;
|
|
623
|
+
constructor(transport: TrendyolTransport, sellerId: number, options?: SuppliersResourceOptions);
|
|
624
|
+
/**
|
|
625
|
+
* List the seller's registered addresses (shipment, returning, invoice, warehouse).
|
|
626
|
+
*
|
|
627
|
+
* Returns the cached value if it is still fresh. Concurrent calls share a
|
|
628
|
+
* single in-flight request.
|
|
629
|
+
*/
|
|
630
|
+
getAddresses(options?: {
|
|
631
|
+
forceRefresh?: boolean;
|
|
632
|
+
}): Promise<SupplierAddress[]>;
|
|
633
|
+
/** Drop the cache; the next `getAddresses()` call hits the API. */
|
|
634
|
+
invalidateCache(): void;
|
|
635
|
+
private fetchFresh;
|
|
636
|
+
}
|
|
637
|
+
|
|
82
638
|
interface CreateClientOptions {
|
|
83
639
|
/** Trendyol seller (supplier) ID — visible in Partner Panel → Account Info. */
|
|
84
640
|
sellerId: number;
|
|
@@ -107,6 +663,11 @@ interface CreateClientOptions {
|
|
|
107
663
|
}
|
|
108
664
|
interface TrendyolClient {
|
|
109
665
|
brands: BrandsResource;
|
|
666
|
+
categories: CategoriesResource;
|
|
667
|
+
suppliers: SuppliersResource;
|
|
668
|
+
products: ProductsResource;
|
|
669
|
+
inventory: InventoryResource;
|
|
670
|
+
orders: OrdersResource;
|
|
110
671
|
}
|
|
111
672
|
/**
|
|
112
673
|
* Create a Trendyol Marketplace SDK client.
|
|
@@ -127,4 +688,4 @@ interface TrendyolClient {
|
|
|
127
688
|
*/
|
|
128
689
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
129
690
|
|
|
130
|
-
export { type Brand, BrandsResource, type CreateClientOptions, type TrendyolClient, type TrendyolEnvironment, createTrendyolClient };
|
|
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 };
|