@lonca/trendyol 0.8.0 → 0.10.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.d.ts CHANGED
@@ -1,2185 +1,7 @@
1
- import { Logger, TokenBucketRateLimiter, CursorPaginationParams, CursorPage } from '@lonca/core';
2
-
3
- declare const BASE_URLS: {
4
- readonly prod: "https://apigw.trendyol.com";
5
- readonly stage: "https://stageapigw.trendyol.com";
6
- };
7
- type TrendyolEnvironment = keyof typeof BASE_URLS;
8
- interface TransportConfig {
9
- sellerId: number;
10
- apiKey: string;
11
- apiSecret: string;
12
- env: TrendyolEnvironment;
13
- integratorName: string;
14
- clientIp?: string;
15
- logger?: Logger;
16
- /** Request timeout in ms. Default: 30_000. */
17
- timeoutMs?: number;
18
- /** Override the underlying `fetch` (tests inject a mock). */
19
- fetch?: typeof fetch;
20
- }
21
- interface RequestOptions {
22
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
23
- /** Path beginning with `/` (e.g., `/sapigw/brands`). */
24
- path: string;
25
- query?: Record<string, string | number | boolean | undefined>;
26
- body?: unknown;
27
- signal?: AbortSignal;
28
- /** Per-endpoint rate limiter; acquire one token before each attempt. */
29
- rateLimiter?: TokenBucketRateLimiter;
30
- }
31
- declare class TrendyolTransport {
32
- private readonly config;
33
- private readonly baseUrl;
34
- private readonly logger;
35
- private readonly timeoutMs;
36
- private readonly fetchImpl;
37
- constructor(config: TransportConfig);
38
- /** Seller ID this transport is configured with. Resources read it for path-building. */
39
- get sellerId(): number;
40
- request<T>(opts: RequestOptions): Promise<T>;
41
- private buildUrl;
42
- private buildHeaders;
43
- private composeSignal;
44
- }
45
-
46
- /**
47
- * A Trendyol marketplace brand.
48
- *
49
- * Trendyol returns numeric IDs; we normalize to `string` to match the
50
- * `@lonca/core` convention (string IDs across all Lonca SDKs).
51
- */
52
- interface Brand {
53
- id: string;
54
- name: string;
55
- }
56
-
57
- /**
58
- * Trendyol brand-list endpoint group.
59
- *
60
- * Rate limit: 50 req/min (per Trendyol service limits).
61
- *
62
- * Trendyol uses page-based pagination internally; we expose the cursor-based
63
- * `CursorPage` shape from `@lonca/core` so callers can drive everything with
64
- * `paginate()` and stay consistent across Lonca SDKs.
65
- */
66
- declare class BrandsResource {
67
- private readonly transport;
68
- private readonly limiter;
69
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
70
- /**
71
- * List Trendyol brands, one page at a time.
72
- *
73
- * @example
74
- * ```ts
75
- * import { paginate } from '@lonca/core';
76
- * for await (const brand of paginate((p) => client.brands.list(p))) {
77
- * console.log(brand.id, brand.name);
78
- * }
79
- * ```
80
- */
81
- list(params?: CursorPaginationParams): Promise<CursorPage<Brand>>;
82
- /**
83
- * Search brands by name. Useful when you need a brand's numeric ID for
84
- * `createProducts` and don't want to page through the full `list()`
85
- * (1000 brands per page).
86
- *
87
- * **Discovery-first wire fact (verified STAGE 2026-05-25):** Trendyol's
88
- * doc claims this is a case-sensitive *exact* match, but live behaviour
89
- * is **substring + case-insensitive** — `search('Trendyol')` returns
90
- * 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
91
- * Plan for ranking your results client-side if you need an exact match.
92
- * The endpoint returns an empty array when nothing matches (no 404).
93
- *
94
- * @param name The brand name to search for.
95
- */
96
- search(name: string): Promise<Brand[]>;
97
- }
98
-
99
- /**
100
- * A node in the Trendyol category tree.
101
- *
102
- * Trendyol exposes categories as a deeply nested structure where each node
103
- * can have child categories under `subCategories`. We normalize numeric IDs
104
- * to strings to match the `@lonca/core` convention.
105
- */
106
- interface Category {
107
- id: string;
108
- name: string;
109
- /** `null` when this is a root category. */
110
- parentId: string | null;
111
- subCategories: Category[];
112
- }
113
- /** A single allowed value for a category attribute. */
114
- interface CategoryAttributeValue {
115
- id: string;
116
- name: string;
117
- }
118
- /**
119
- * Result of `categories.getByBarcodes` — a barcode → category mapping
120
- * sourced from Trendyol's Export Center (AutoFT) lookup endpoint.
121
- */
122
- interface BarcodeCategoryLookup {
123
- /** Successful matches. */
124
- matches: Array<{
125
- barcode: string;
126
- category: {
127
- id: string;
128
- name: string;
129
- };
130
- }>;
131
- /** Barcodes Trendyol could not resolve to a category. */
132
- notFound: string[];
133
- }
134
- /**
135
- * A required or optional attribute for products in a given category.
136
- * Use these when constructing a `createProduct V2` payload — the API rejects
137
- * products that omit `required` attributes.
138
- */
139
- interface CategoryAttribute {
140
- id: string;
141
- name: string;
142
- /** The category this attribute belongs to (echoed back by Trendyol). */
143
- categoryId?: string;
144
- required: boolean;
145
- /** Whether the attribute accepts custom text values in addition to the listed ones. */
146
- allowCustom: boolean;
147
- /** Whether the attribute participates in product variants (e.g. color, size). */
148
- varianter: boolean;
149
- /** Whether the attribute is used as a price slicer (e.g. size for shoes). */
150
- slicer: boolean;
151
- /**
152
- * V2-only: whether the attribute accepts multiple values at once.
153
- * Present on responses from the V2 `getCategoryAttributes` endpoint; absent on V1.
154
- */
155
- allowMultipleAttributeValues?: boolean;
156
- /**
157
- * Allowed values for this attribute.
158
- *
159
- * NOTE: Trendyol's live API often omits this field on the `getCategoryAttributes`
160
- * response — the endpoint returns attribute metadata + flags, not the full value
161
- * catalog. In that case `values` is an empty array. If `allowCustom` is `true`,
162
- * any custom text is accepted; otherwise use `client.categories.getAttributeValues(categoryId, attributeId)`
163
- * to fetch the catalog from the dedicated V2 endpoint.
164
- */
165
- values: CategoryAttributeValue[];
166
- }
167
-
168
- type ListCategoryAttributeValuesParams = CursorPaginationParams;
169
- /**
170
- * Trendyol category-tree and category-attribute endpoints.
171
- *
172
- * Rate limits (per Trendyol service limits):
173
- * - Category list: 50 req/min
174
- * - Category attributes: 50 req/min
175
- * - Category attribute values: 50 req/min (same service tier)
176
- *
177
- * All three counters live on the same Trendyol service, so we share one
178
- * limiter across the endpoints.
179
- */
180
- declare class CategoriesResource {
181
- private readonly transport;
182
- private readonly limiter;
183
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
184
- /**
185
- * Fetch the full Trendyol category tree.
186
- *
187
- * Trendyol returns the entire tree in one response — there is no pagination.
188
- * Cache the result aggressively in your application; the tree changes rarely.
189
- */
190
- list(): Promise<Category[]>;
191
- /**
192
- * Fetch the attributes (required and optional) for a single category.
193
- *
194
- * Call this before `createProduct V2` so you know which attributes are
195
- * mandatory — the API rejects products that omit any `required` attribute.
196
- *
197
- * @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
198
- */
199
- getAttributes(categoryId: string | number): Promise<CategoryAttribute[]>;
200
- /**
201
- * Fetch the allowed values for a single category attribute (paginated).
202
- *
203
- * `getCategoryAttributes` returns attribute metadata + flags but typically
204
- * omits the value catalog. Use this method to fetch the catalog for an
205
- * attribute when `allowCustom` is `false` and you need to map your data
206
- * onto Trendyol's accepted values.
207
- *
208
- * @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
209
- * @param attributeId Attribute ID returned by `getAttributes`.
210
- * @param params Cursor pagination (max page size 1000; default 100).
211
- *
212
- * @example
213
- * ```ts
214
- * import { paginate } from '@lonca/core';
215
- * for await (const value of paginate((p) =>
216
- * client.categories.getAttributeValues(catId, attrId, p),
217
- * )) {
218
- * console.log(value.id, value.name);
219
- * }
220
- * ```
221
- */
222
- getAttributeValues(categoryId: string | number, attributeId: string | number, params?: ListCategoryAttributeValuesParams): Promise<CursorPage<CategoryAttributeValue>>;
223
- /**
224
- * Look up category info for a list of barcodes (Trendyol Export Center
225
- * / AutoFT endpoint).
226
- *
227
- * **Requires Export Center enrollment.** Sellers who have not joined
228
- * Trendyol's "İhracat Merkezi" program will get an auth error on this
229
- * endpoint even though their regular Marketplace credentials are valid.
230
- *
231
- * @param barcodes 1–N barcodes to look up.
232
- * @throws {ValidationError} when `barcodes` is empty.
233
- */
234
- getByBarcodes(barcodes: string[]): Promise<BarcodeCategoryLookup>;
235
- }
236
-
237
- /**
238
- * Trendyol claim ("iade" / return-claim) types.
239
- *
240
- * A claim is a customer-initiated return on a delivered order. The
241
- * seller can also open a `createClaimIssue` (a rejection) against a
242
- * customer-filed claim, and either party can have line items approved
243
- * via `approveClaimLineItems`.
244
- */
245
-
246
- /** One item inside `claims.create()`. */
247
- interface CreateClaimItemInput {
248
- /** Barcode of the ordered SKU. */
249
- barcode: string;
250
- /** Number of units being returned. */
251
- quantity: number;
252
- /**
253
- * Numeric reason code customers select on trendyol.com.
254
- * Trendyol's docs note `401` ("Vazgectim" — changed my mind) as a
255
- * safe default when you don't have a more specific code.
256
- */
257
- reasonId: number;
258
- /** Free-text note from the customer. */
259
- customerNote?: string;
260
- }
261
- /** Payload for `claims.create()`. */
262
- interface CreateClaimInput {
263
- /** The order to file the claim against. */
264
- orderNumber: string;
265
- claimItems: CreateClaimItemInput[];
266
- /** Trendyol customer ID (the one who placed the order). */
267
- customerId?: number;
268
- /** Suppress this claim from listing pages. */
269
- excludeListing?: boolean;
270
- /** Force a new shipment package to be created for the return. */
271
- forcePackageCreation?: boolean;
272
- }
273
- /**
274
- * Payload for `claims.createIssue()` — file a seller-side rejection
275
- * ("ret talebi") against a customer claim. Wire format is
276
- * `multipart/form-data` because optional `files` are PDF / JPEG
277
- * supporting documents.
278
- */
279
- interface CreateClaimIssueInput {
280
- /** Numeric reason ID from `claims.getIssueReasons()`. */
281
- claimIssueReasonId: number;
282
- /** Per-line claim item IDs being rejected. SDK joins with commas. */
283
- claimItemIdList: string[];
284
- /** Free-text explanation (≤500 chars). */
285
- description: string;
286
- /** Optional supporting documents (Blob / File). */
287
- files?: Blob[];
288
- }
289
- /** Payload for `claims.approveLineItems()`. */
290
- interface ApproveClaimLineItemsInput {
291
- /** Claim line-item IDs to approve. */
292
- claimLineItemIdList: string[];
293
- /** Optional extra params Trendyol forwards verbatim. */
294
- params?: Record<string, string>;
295
- }
296
- /**
297
- * Claim item lifecycle state. Open enum — Trendyol can add new states
298
- * without breaking callers.
299
- */
300
- type ClaimItemStatus = 'Created' | 'WaitingInAction' | 'WaitingFraudCheck' | 'Accepted' | 'Unresolved' | 'Rejected' | (string & {});
301
- /** Filter / pagination for `claims.list()`. */
302
- interface ListClaimsParams extends CursorPaginationParams {
303
- startDate?: Date;
304
- endDate?: Date;
305
- /** Filter claims by item-level status. */
306
- claimItemStatus?: ClaimItemStatus;
307
- }
308
- /**
309
- * A return claim. Trendyol returns ~20 fields; the SDK surfaces the
310
- * stable subset and keeps everything else on `raw`.
311
- */
312
- interface Claim {
313
- /** Claim ID (Trendyol returns it under both `id` and `claimId` — same value). */
314
- id: string;
315
- orderNumber: string;
316
- /** ISO 8601 UTC (from ms-epoch `orderDate`). */
317
- orderDate?: string;
318
- /** ISO 8601 UTC (from ms-epoch `claimDate`). */
319
- claimDate?: string;
320
- customerFirstName?: string;
321
- customerLastName?: string;
322
- /** Untouched raw claim — pull undocumented fields from here. */
323
- raw: Record<string, unknown>;
324
- }
325
- /** Rejection-reason catalog row from `claims.getIssueReasons()`. */
326
- interface ClaimIssueReason {
327
- id: number;
328
- name: string;
329
- }
330
- /**
331
- * Audit entry for a single claim item, returned by `claims.getItemAudits()`.
332
- * Trendyol's response shape varies; only `raw` is guaranteed.
333
- */
334
- interface ClaimItemAudit {
335
- /** Untouched raw audit row. */
336
- raw: Record<string, unknown>;
337
- }
338
-
339
- /**
340
- * Trendyol claims (return / iade) endpoints.
341
- *
342
- * Rate limit (per Trendyol service limits): shares the order service bucket;
343
- * the SDK provisions its own 1000 req/min limiter that the caller can override.
344
- */
345
- declare class ClaimsResource {
346
- private readonly transport;
347
- private readonly limiter;
348
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
349
- /**
350
- * Create a return claim against an order. Use this to file a return on
351
- * behalf of a customer (e.g. when they called your CS line). For
352
- * customer-initiated returns coming from trendyol.com, you receive them
353
- * via `claims.list()` — no need to call `create`.
354
- *
355
- * Returns whatever Trendyol returns (typically the new claim's identifier).
356
- *
357
- * @throws {ValidationError} when `claimItems` is empty.
358
- */
359
- create(input: CreateClaimInput): Promise<unknown>;
360
- /**
361
- * File a seller-side rejection ("ret talebi") against a customer claim.
362
- *
363
- * **Wire format: `multipart/form-data`** — the SDK builds the FormData
364
- * internally from the typed input. `claimItemIdList` is joined with
365
- * commas (Trendyol expects a single comma-separated string field).
366
- * Attach supporting docs (PDF / JPEG) via `files: [Blob, ...]`.
367
- */
368
- createIssue(claimId: string, input: CreateClaimIssueInput): Promise<unknown>;
369
- /**
370
- * Approve specific claim line items. After approval, Trendyol moves
371
- * those line items into the post-approval refund / return-shipping flow.
372
- *
373
- * @throws {ValidationError} when `claimLineItemIdList` is empty.
374
- */
375
- approveLineItems(claimId: string, input: ApproveClaimLineItemsInput): Promise<unknown>;
376
- /**
377
- * List claims (page-based; SDK exposes opaque cursor convention).
378
- *
379
- * @example
380
- * ```ts
381
- * import { paginate } from '@lonca/core';
382
- * for await (const c of paginate((p) =>
383
- * client.claims.list({ ...p, claimItemStatus: 'WaitingInAction' }),
384
- * )) {
385
- * console.log(c.id, c.orderNumber, c.claimDate);
386
- * }
387
- * ```
388
- */
389
- list(params?: ListClaimsParams): Promise<CursorPage<Claim>>;
390
- /**
391
- * Fetch the catalog of rejection-reason IDs the seller can use on
392
- * `claims.createIssue()`. Cache the result — it changes rarely.
393
- *
394
- * Note: this endpoint is **not seller-scoped** (no `sellerId` in path).
395
- */
396
- getIssueReasons(): Promise<ClaimIssueReason[]>;
397
- /**
398
- * Fetch the audit log for a single claim item (state transitions,
399
- * actor, timestamp). Trendyol's response shape varies — the SDK
400
- * surfaces each row as `{ raw }` and leaves field extraction to the
401
- * caller until we observe a stable shape on the wire.
402
- */
403
- getItemAudits(claimItemId: string): Promise<ClaimItemAudit[]>;
404
- }
405
-
406
- /**
407
- * Misc types for Trendyol's smaller surfaces — invoices, finance,
408
- * common labels, test orders, and location lookups. Most shapes are
409
- * loosely typed (`Record<string, unknown>`) because the Trendyol response
410
- * shapes here are wide and seldom-evolved; callers drill into `raw` for
411
- * fields beyond the stable surface.
412
- */
413
-
414
- interface UploadInvoiceFileInput {
415
- /** Trendyol shipment package ID (required). */
416
- shipmentPackageId: number;
417
- /** Invoice file (PDF / JPEG / PNG, max 10 MB). */
418
- file: Blob;
419
- /** ms-epoch — mandatory for micro-export orders, optional otherwise. */
420
- invoiceDateTime?: number;
421
- /**
422
- * Invoice number — mandatory for micro-export orders. Format:
423
- * `[A-Za-z0-9]{3}(20[2-9][0-9])\d{9}`.
424
- */
425
- invoiceNumber?: string;
426
- }
427
- interface SendInvoiceLinkInput {
428
- invoiceLink: string;
429
- shipmentPackageId: number;
430
- invoiceDateTime?: number;
431
- invoiceNumber?: string;
432
- }
433
- interface DeleteInvoiceLinkInput {
434
- serviceSourceId?: number;
435
- channelId?: number;
436
- customerId?: number;
437
- /** Forward-compatible: pass any extra fields Trendyol may add. */
438
- [key: string]: unknown;
439
- }
440
- /**
441
- * One row from Trendyol's current-account statement — returned by both
442
- * `finance.getSettlements()` and `finance.getOtherFinancials()` (both
443
- * endpoints share the `FinancialTransaction` wire schema).
444
- *
445
- * Field set verified against the spec on 2026-05-25. The SDK exposes the
446
- * stable subset; anything Trendyol adds later remains accessible via `raw`.
447
- */
448
- interface FinancialTransaction {
449
- /** Transaction ID (string per Trendyol). */
450
- id: string;
451
- /** ISO 8601 UTC (from ms-epoch `transactionDate`). */
452
- transactionDate?: string;
453
- /** Product barcode when the transaction is tied to a SKU. */
454
- barcode?: string | null;
455
- /** Transaction category (e.g. `'Satış'`, `'Ödeme'`). */
456
- transactionType?: string;
457
- /** Receipt ID ("dekont no") when applicable. */
458
- receiptId?: number | null;
459
- description?: string | null;
460
- /** Debit amount on the seller's account. */
461
- debt?: number;
462
- /** Credit amount on the seller's account. */
463
- credit?: number;
464
- paymentPeriod?: number | null;
465
- commissionRate?: number | null;
466
- commissionAmount?: number | null;
467
- commissionInvoiceSerialNumber?: string | null;
468
- /** Net seller revenue after Trendyol's cut. */
469
- sellerRevenue?: number | null;
470
- orderNumber?: string | null;
471
- paymentOrderId?: number | null;
472
- /** ISO 8601 UTC (from ms-epoch `paymentDate`). */
473
- paymentDate?: string;
474
- sellerId?: number;
475
- storeId?: number | null;
476
- storeName?: string | null;
477
- storeAddress?: string | null;
478
- country?: string | null;
479
- /** Untouched raw row — pull any undocumented fields from here. */
480
- raw: Record<string, unknown>;
481
- }
482
- /**
483
- * Aliases preserved for source-compatibility with `0.5.0`. Both legacy
484
- * names now resolve to the unified `FinancialTransaction`.
485
- *
486
- * @deprecated since `0.5.1` — use `FinancialTransaction`.
487
- */
488
- type SettlementRow = FinancialTransaction;
489
- /** @deprecated since `0.5.1` — use `FinancialTransaction`. */
490
- type OtherFinancialRow = FinancialTransaction;
491
- /**
492
- * Shared filter shape for both finance endpoints.
493
- * `transactionType` lets you scope to one settlement category.
494
- */
495
- interface ListFinanceParams extends CursorPaginationParams {
496
- startDate?: Date;
497
- endDate?: Date;
498
- transactionType?: string;
499
- }
500
- interface CreateCommonLabelInput {
501
- /** Currently the only documented format Trendyol accepts. */
502
- format: 'ZPL' | (string & {});
503
- boxQuantity?: number;
504
- /** Volumetric height (height × width × depth / 3000 → desi). */
505
- volumetricHeight?: number;
506
- }
507
- /** One label entry inside a `CommonLabel` response. */
508
- interface CommonLabelEntry {
509
- /** Encoded label payload (e.g. ZPL string `^XA...^XZ`). */
510
- label: string;
511
- format: 'ZPL' | (string & {});
512
- }
513
- /**
514
- * Response from `labels.getCommon()` — Trendyol's wire shape is
515
- * `{ data: [{ label, format }] }`. SDK surfaces the array directly via
516
- * `labels` for ergonomic access; `raw` is the untouched response.
517
- */
518
- interface CommonLabel {
519
- labels: CommonLabelEntry[];
520
- raw: Record<string, unknown>;
521
- }
522
- /**
523
- * Payload for `testOrders.create()`. Top-level requireds are
524
- * `customer`, `invoiceAddress`, `lines`, `seller`, `shippingAddress`;
525
- * each sub-object has its own field rules (see Trendyol's
526
- * `createTestOrder` reference). Kept loose because the inner schema is
527
- * deep and used only in STAGE.
528
- */
529
- interface CreateTestOrderInput {
530
- customer: Record<string, unknown>;
531
- invoiceAddress: Record<string, unknown>;
532
- shippingAddress: Record<string, unknown>;
533
- seller: Record<string, unknown>;
534
- lines: Array<Record<string, unknown>>;
535
- [key: string]: unknown;
536
- }
537
- type TestOrderStatus = 'Created' | 'Picking' | 'Invoiced' | 'Shipped' | 'Delivered' | 'Cancelled' | 'Returned' | 'UnDelivered' | (string & {});
538
- interface Country {
539
- /** ISO country code (e.g. `'TR'`, `'AZ'`). */
540
- code: string;
541
- name?: string;
542
- raw: Record<string, unknown>;
543
- }
544
- interface City {
545
- code: string;
546
- name?: string;
547
- countryCode?: string;
548
- raw: Record<string, unknown>;
549
- }
550
- interface District {
551
- code: string;
552
- name?: string;
553
- cityCode?: string;
554
- raw: Record<string, unknown>;
555
- }
556
- interface Neighborhood {
557
- code: string;
558
- name?: string;
559
- districtCode?: string;
560
- raw: Record<string, unknown>;
561
- }
562
-
563
- /**
564
- * Trendyol finance endpoints — current-account-statement settlements and
565
- * "other financials" (cargo invoices, labor cost adjustments, etc.).
566
- *
567
- * Both endpoints return the same `FinancialTransaction` shape on the wire,
568
- * so the SDK exposes one typed surface for them.
569
- */
570
- declare class FinanceResource {
571
- private readonly transport;
572
- private readonly limiter;
573
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
574
- getSettlements(params?: ListFinanceParams): Promise<CursorPage<FinancialTransaction>>;
575
- getOtherFinancials(params?: ListFinanceParams): Promise<CursorPage<FinancialTransaction>>;
576
- private queryPage;
577
- }
578
-
579
- /**
580
- * A single price / stock update entry.
581
- *
582
- * `barcode` is the only required field. Include any combination of:
583
- * - `quantity` to update stock (max 20 000 per product)
584
- * - `salePrice` to update the sale price
585
- * - `listPrice` to update the list (strikethrough) price
586
- *
587
- * `listPrice` must be greater than or equal to `salePrice`.
588
- */
589
- interface PriceInventoryUpdate {
590
- barcode: string;
591
- quantity?: number;
592
- salePrice?: number;
593
- listPrice?: number;
594
- }
595
- /** Response from `updatePriceAndInventory` — poll with `products.getBatchStatus`. */
596
- interface UpdatePriceInventoryResponse {
597
- batchRequestId: string;
598
- }
599
-
600
- /**
601
- * Trendyol stock & price update endpoint (a.k.a. `updatePriceAndInventory`).
602
- *
603
- * Rate limit: **none** — Trendyol explicitly lists this endpoint as
604
- * `NO LIMIT` in its service limits table. The `15-minute duplicate
605
- * suppression` rule still applies on Trendyol's side, but that's a
606
- * server-side concern.
607
- *
608
- * The endpoint is asynchronous. The response carries a `batchRequestId`
609
- * you can poll with `client.products.getBatchStatus(batchRequestId)` —
610
- * Trendyol retains the result for 4 hours.
611
- */
612
- declare class InventoryResource {
613
- private readonly transport;
614
- constructor(transport: TrendyolTransport);
615
- /**
616
- * Update price and/or stock for one or more SKUs (by barcode).
617
- *
618
- * @example
619
- * ```ts
620
- * const { batchRequestId } = await client.inventory.update([
621
- * { barcode: 'ABC123', quantity: 42, salePrice: 199.9, listPrice: 249.9 },
622
- * { barcode: 'XYZ789', quantity: 0 },
623
- * ]);
624
- * const status = await client.products.getBatchStatus(batchRequestId);
625
- * ```
626
- *
627
- * @throws {ValidationError} when `items` is empty or longer than 1000.
628
- */
629
- update(items: PriceInventoryUpdate[]): Promise<UpdatePriceInventoryResponse>;
630
- }
631
-
632
- /**
633
- * Trendyol invoice endpoints — upload PDF/JPEG/PNG invoice files or
634
- * register/delete invoice links. Pair these with `orders.updatePackageStatus(_, { status: 'Invoiced' })`
635
- * after invoice issuance.
636
- */
637
- declare class InvoicesResource {
638
- private readonly transport;
639
- private readonly limiter;
640
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
641
- /**
642
- * Upload an invoice file for a shipment package. **Multipart**: the
643
- * SDK builds the FormData internally from the typed input.
644
- *
645
- * Max 10 MB. Accepted formats: PDF, JPEG, PNG.
646
- */
647
- uploadFile(input: UploadInvoiceFileInput): Promise<unknown>;
648
- /** Register an invoice URL with Trendyol (alternative to uploading the file). */
649
- sendLink(input: SendInvoiceLinkInput): Promise<unknown>;
650
- /** Remove a previously-registered invoice link. */
651
- deleteLink(input: DeleteInvoiceLinkInput): Promise<unknown>;
652
- }
653
-
654
- /**
655
- * Common-label (ortak etiket) endpoints — request and retrieve a
656
- * combined ZPL shipping label for a cargo tracking number.
657
- */
658
- declare class LabelsResource {
659
- private readonly transport;
660
- private readonly limiter;
661
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
662
- /**
663
- * Request a common ZPL label for a cargo tracking number. After this
664
- * returns, call `getCommon()` with the same `cargoTrackingNumber` to
665
- * retrieve the generated label.
666
- *
667
- * @throws {ValidationError} when `format` is missing.
668
- */
669
- createCommon(cargoTrackingNumber: string | number, input: CreateCommonLabelInput): Promise<unknown>;
670
- /**
671
- * Retrieve the previously-created common label. Trendyol returns
672
- * `{ data: [{ label, format }] }`; the SDK surfaces the array as
673
- * `labels[]` for ergonomic access.
674
- *
675
- * Typically `labels.length === 1` per tracking number, but kept as an
676
- * array to match the wire shape.
677
- */
678
- getCommon(cargoTrackingNumber: string | number): Promise<CommonLabel>;
679
- }
680
-
681
- /**
682
- * Trendyol location lookups for building shipment / invoice addresses
683
- * with the correct city / district / neighborhood codes.
684
- *
685
- * Trendyol exposes these under a different prefix (`/integration/member/`)
686
- * — not under `/integration/order/` or `/integration/product/`.
687
- */
688
- declare class LocationsResource {
689
- private readonly transport;
690
- private readonly limiter;
691
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
692
- /** List all supported countries (Türkiye + AZ + GULF + CEE). */
693
- getCountries(): Promise<Country[]>;
694
- getTurkeyCities(): Promise<City[]>;
695
- getTurkeyDistricts(cityCode: string | number): Promise<District[]>;
696
- getTurkeyNeighborhoods(cityCode: string | number, districtCode: string | number): Promise<Neighborhood[]>;
697
- getAzerbaijanCities(): Promise<City[]>;
698
- getAzerbaijanDistricts(cityCode: string | number): Promise<District[]>;
699
- getCitiesByCountry(countryCode: string): Promise<City[]>;
700
- getDistrictsByCity(countryCode: string, cityId: string | number): Promise<District[]>;
701
- private cities;
702
- private districts;
703
- private neighborhoods;
704
- }
705
-
706
- /**
707
- * Trendyol shipment-package status.
708
- *
709
- * Trendyol uses ~13 distinct values (Created, Picking, Invoiced, Shipped,
710
- * Cancelled, Delivered, UnDelivered, Returned, UnSupplied, Awaiting,
711
- * UnPacked, AtCollectionPoint, Verified). Typed as a union with an open
712
- * escape so unknown values still type-check.
713
- */
714
- type ShipmentPackageStatus = 'Created' | 'Picking' | 'Invoiced' | 'Shipped' | 'Cancelled' | 'Delivered' | 'UnDelivered' | 'Returned' | 'UnSupplied' | 'Awaiting' | 'UnPacked' | 'AtCollectionPoint' | 'Verified' | (string & {});
715
- interface OrderAddressLines {
716
- addressLine1?: string;
717
- addressLine2?: string;
718
- }
719
- /**
720
- * A customer or invoice/shipment address returned alongside a shipment package.
721
- * Field set is conservative — Trendyol returns many optional locality fields
722
- * and we surface them as-is.
723
- */
724
- interface OrderAddress {
725
- id?: string;
726
- firstName?: string;
727
- lastName?: string;
728
- fullName?: string;
729
- company?: string;
730
- address1?: string;
731
- address2?: string;
732
- fullAddress?: string;
733
- shortAddress?: string;
734
- city?: string;
735
- cityCode?: number;
736
- district?: string;
737
- districtId?: number;
738
- neighborhoodId?: number;
739
- countyId?: number;
740
- countyName?: string;
741
- stateName?: string;
742
- postalCode?: string;
743
- countryCode?: string;
744
- phone?: string;
745
- addressLines?: OrderAddressLines;
746
- }
747
- /** Customer details on a shipment package (a subset of what Trendyol exposes). */
748
- interface OrderCustomer {
749
- id?: string;
750
- firstName: string;
751
- lastName: string;
752
- email?: string;
753
- taxNumber?: string;
754
- identityNumber?: string;
755
- }
756
- interface OrderLineDiscountDetail {
757
- lineItemPrice?: number;
758
- lineItemSellerDiscount?: number;
759
- lineItemTyDiscount?: number;
760
- }
761
- /** A single item line inside a shipment package. */
762
- interface OrderLine {
763
- /** Trendyol's `lineId`. */
764
- id: string;
765
- quantity: number;
766
- productName: string;
767
- barcode: string;
768
- productSize?: string;
769
- productColor?: string;
770
- stockCode?: string;
771
- contentId?: string;
772
- sellerId?: string;
773
- productCategoryId?: string;
774
- salesCampaignId?: string;
775
- currencyCode?: string;
776
- lineUnitPrice: number;
777
- lineGrossAmount: number;
778
- lineSellerDiscount?: number;
779
- lineTyDiscount?: number;
780
- lineTotalDiscount?: number;
781
- vatRate?: number;
782
- commission?: number;
783
- orderLineItemStatusName?: string;
784
- businessUnit?: string;
785
- fastDeliveryOptions?: unknown[];
786
- discountDetails?: OrderLineDiscountDetail[];
787
- /** Untouched raw line response. */
788
- raw: Record<string, unknown>;
789
- }
790
- /** A status transition entry in `packageHistories`. */
791
- interface PackageHistoryEntry {
792
- status?: ShipmentPackageStatus;
793
- /** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
794
- createdAt?: string;
795
- raw: Record<string, unknown>;
796
- }
797
- /**
798
- * A package line update tuple used by `updatePackageStatus` and
799
- * `cancelPackageItem`. `lineId` is the per-line ID from `ShipmentPackage.lines[].lineId`.
800
- */
801
- interface PackageLineUpdate {
802
- lineId: number;
803
- quantity: number;
804
- }
805
- /**
806
- * Input for `orders.updatePackageStatus`. Trendyol restricts the seller-side
807
- * status push to `Picking` (mark as being prepared) and `Invoiced`
808
- * (invoice issued); other transitions are driven by Trendyol / the cargo
809
- * provider. `lines` is optional and only used when transitioning subset of
810
- * line items.
811
- */
812
- interface UpdatePackageStatusInput {
813
- status: 'Picking' | 'Invoiced';
814
- lines?: PackageLineUpdate[];
815
- }
816
- /**
817
- * Input for `orders.cancelPackageItem` — Trendyol's "supply failure" notification.
818
- * Marks specific line items as un-suppliable. `reasonId` is a numeric code
819
- * Trendyol publishes separately (e.g. `577` = "tedarik edemiyorum"); consult
820
- * Trendyol's seller panel or the "Tedarik Edememe" docs for current values.
821
- */
822
- interface CancelPackageItemInput {
823
- lines: PackageLineUpdate[];
824
- reasonId: number;
825
- }
826
- /**
827
- * One row from `orders.getCargoInvoiceItems` — a cargo invoice line item
828
- * that ties a parcel ID to its cargo fee. Useful for reconciling Trendyol's
829
- * cargo deductions against your shipped packages.
830
- */
831
- interface CargoInvoiceItem {
832
- /** e.g. "Gönderi Kargo Bedeli" (outbound) or "İade Kargo Bedeli" (return). */
833
- shipmentPackageType?: string;
834
- /** Cargo parcel unique ID. */
835
- parcelUniqueId?: number | string;
836
- orderNumber?: string;
837
- /** Fee charged in this row. */
838
- amount?: number;
839
- /** Desi value used to compute the fee. */
840
- desi?: number;
841
- /** Untouched raw row. */
842
- raw: Record<string, unknown>;
843
- }
844
- /**
845
- * Filter params for `orders.listStream` — the streaming alternative to
846
- * `orders.list`. Uses Trendyol's opaque `nextCursor` (forwarded as the
847
- * `@lonca/core` `CursorPaginationParams.cursor`) instead of page-index
848
- * pagination.
849
- */
850
- interface ListOrdersStreamParams {
851
- cursor?: string;
852
- limit?: number;
853
- /**
854
- * CSV of package-item statuses to filter by (e.g.
855
- * `'Created,Picking,Invoiced'`). Trendyol accepts the same status
856
- * vocabulary as `ShipmentPackageStatus`.
857
- */
858
- packageItemStatuses?: string;
859
- /** Lower bound for `lastModified` (Trendyol expects ms-epoch). */
860
- lastModifiedStartDate?: Date;
861
- /** Upper bound for `lastModified`. */
862
- lastModifiedEndDate?: Date;
863
- }
864
- /**
865
- * Box / packaging metadata for `orders.updateBoxInfo`. Both fields are
866
- * optional but at least one should be set for the call to be meaningful.
867
- */
868
- interface UpdateBoxInfoInput {
869
- /** Desi value (volumetric weight used by Trendyol for shipping cost). */
870
- deci?: number;
871
- /** Number of physical boxes in the shipment. */
872
- boxQuantity?: number;
873
- }
874
- /**
875
- * Per-line labor cost for `orders.updateLaborCosts`. The Trendyol API
876
- * accepts a raw array of these (no envelope) — the SDK forwards as-is.
877
- */
878
- interface LaborCostInput {
879
- orderLineId: number;
880
- /** Labor cost charged per single unit of this line. */
881
- laborCostPerItem: number;
882
- }
883
- /**
884
- * Trendyol cargo provider codes accepted by `orders.changeCargoProvider`.
885
- * Use the string union for autocomplete; `(string & {})` keeps unknown
886
- * codes type-compatible so Trendyol can add providers without breaking
887
- * callers.
888
- */
889
- type TrendyolCargoProvider = 'YKMP' | 'ARASMP' | 'SURATMP' | 'HOROZMP' | 'DHLECOMMP' | 'PTTMP' | 'CEVAMP' | 'TEXMP' | 'KOLAYGELSINMP' | 'CEVATEDARIK' | (string & {});
890
- /**
891
- * Per-line quantity split for `orders.splitPackageByQuantity`. Each item
892
- * in `quantities` becomes its own new package containing that many units
893
- * of `orderLineId`.
894
- *
895
- * @example
896
- * // splits 5 units of line 100 into 3 packages: 2 + 2 + 1
897
- * { orderLineId: 100, quantities: [2, 2, 1] }
898
- */
899
- interface QuantitySplit {
900
- orderLineId: number;
901
- quantities: number[];
902
- }
903
- /**
904
- * A group of line IDs that should become a new package together,
905
- * for `orders.multiSplitPackage`.
906
- */
907
- interface SplitGroup {
908
- orderLineIds: number[];
909
- }
910
- /**
911
- * One package's contents for `orders.splitMultiPackagesByQuantity`. Each
912
- * element of the outer array becomes a new package; each `packageDetails`
913
- * entry carries an `orderLineId` and the **single** quantity assigned to
914
- * that package (note: singular `quantities`, despite the field name).
915
- */
916
- interface PackageDetail {
917
- orderLineId: number;
918
- /** Quantity of this line to include in this package (singular integer). */
919
- quantities: number;
920
- }
921
- interface SplitPackagePlan {
922
- packageDetails: PackageDetail[];
923
- }
924
- /**
925
- * Input for `orders.processAlternativeDelivery`. Used when the seller is
926
- * shipping via a non-Trendyol cargo provider — provide either a phone number
927
- * (which Trendyol SMSes the tracking link to) or a direct tracking URL.
928
- */
929
- interface ProcessAlternativeDeliveryInput {
930
- /** When true, `trackingInfo` is a phone number; when false, a tracking URL. */
931
- isPhoneNumber: boolean;
932
- trackingInfo: string;
933
- /** Provider-specific extra parameters (Trendyol forwards verbatim). */
934
- params: Record<string, string>;
935
- }
936
- /**
937
- * A Trendyol order — Trendyol models orders as "shipment packages". A single
938
- * customer order may produce multiple shipment packages (one per warehouse,
939
- * one per cancellation, etc.).
940
- *
941
- * `id` is the `shipmentPackageId` (the operational unit); `orderNumber`
942
- * groups packages that came from the same customer order.
943
- */
944
- interface ShipmentPackage {
945
- /** `shipmentPackageId` — the operational identifier for this package. */
946
- id: string;
947
- orderNumber: string;
948
- shipmentNumber?: string;
949
- originPackageIds?: string[] | null;
950
- warehouseId?: string;
951
- supplierId?: string;
952
- status: ShipmentPackageStatus;
953
- /** Usually identical to `status`; surfaced for completeness. */
954
- shipmentPackageStatus?: ShipmentPackageStatus;
955
- customer: OrderCustomer;
956
- orderDate: string;
957
- lastModifiedDate: string;
958
- agreedDeliveryDate?: string;
959
- estimatedDeliveryStartDate?: string;
960
- estimatedDeliveryEndDate?: string;
961
- originShipmentDate?: string;
962
- currencyCode: string;
963
- packageTotalPrice: number;
964
- packageGrossAmount: number;
965
- packageSellerDiscount: number;
966
- packageTyDiscount: number;
967
- packageTotalDiscount: number;
968
- invoiceAddress?: OrderAddress;
969
- shipmentAddress?: OrderAddress;
970
- deliveryAddressType?: string;
971
- cargoTrackingNumber?: string;
972
- cargoProviderName?: string;
973
- cargoProviderId?: string;
974
- cargoSenderNumber?: string;
975
- deliveryType?: string;
976
- whoPays?: number;
977
- timeSlotId?: number;
978
- fastDelivery?: boolean;
979
- fastDeliveryType?: string;
980
- deliveredByService?: boolean;
981
- commercial?: boolean;
982
- micro?: boolean;
983
- giftBoxRequested?: boolean;
984
- /** Renamed from Trendyol's wire field `3pByTrendyol` (identifier cannot start with a digit). */
985
- threePByTrendyol?: boolean;
986
- containsDangerousProduct?: boolean;
987
- isCod?: boolean;
988
- is4P?: boolean;
989
- invoiceLink?: string;
990
- createdBy?: string;
991
- lines: OrderLine[];
992
- packageHistories: PackageHistoryEntry[];
993
- /** Untouched raw response for fields not modeled yet. */
994
- raw: Record<string, unknown>;
995
- }
996
-
997
- /**
998
- * Returns + compensation types for Trendyol orders.
999
- *
1000
- * Trendyol distinguishes two separate concepts:
1001
- * - **Manual return** — seller-side notification that a package was
1002
- * received back (no body, just a state flip on the package).
1003
- * - **Compensation ticket** — Trendyol Express-specific dispute filed
1004
- * when a shipment is lost or damaged. Multi-state lifecycle with up to
1005
- * ~18 documented states.
1006
- */
1007
-
1008
- /**
1009
- * Lifecycle state of a Trendyol Express compensation ticket. Trendyol
1010
- * documents 18 distinct states (`Empty`, `MarkInCompensation`,
1011
- * `CompensationApproved`, etc.) — kept as an open enum so unknown future
1012
- * values still type-check.
1013
- *
1014
- * Verified against the official spec on 2026-05-25.
1015
- */
1016
- type CompensationTicketState = 'Empty' | 'MarkInCompensation' | 'OpenedForRefund' | 'StartCompensationFinanceProgress' | 'StartCompensationInApprovalProgress' | 'CompensationApproved' | 'CompensationRejected' | 'FoundAfterCompensationComplete' | 'NotCompensationCase' | 'FoundInCompensation' | 'FoundInvestigationProgress' | 'MarkCompensationCancel' | 'CreateCompensationTicket' | 'FinalizeCompensation' | 'CloseCompensationTicket' | 'FoundInvestigationProgressDeliveredToCustomer' | 'FoundInCompensationDeliveredToCustomer' | 'FoundAfterCompensationCompleteDeliveredToCustomer' | (string & {});
1017
- /** One line item under a compensation ticket. */
1018
- interface CompensationItemDetail {
1019
- /** Amount (e.g. unit price). */
1020
- itemAmount?: number;
1021
- itemCode?: string;
1022
- /** Item count (number of units claimed). */
1023
- itemCount?: number;
1024
- itemName?: string;
1025
- }
1026
- /**
1027
- * A Trendyol Express compensation ticket — filed when a shipment is lost
1028
- * or damaged in transit. Returned by `orders.getCompensationTickets()`.
1029
- */
1030
- interface CompensationTicket {
1031
- cargoProvider?: string;
1032
- compensateReason?: string;
1033
- /** ISO 8601 UTC string (converted from `createDate` ms-epoch). */
1034
- createdAt?: string;
1035
- currentState?: CompensationTicketState;
1036
- deliveryNumber?: string;
1037
- itemDetails: CompensationItemDetail[];
1038
- orderNumber?: string;
1039
- requestedBy?: string;
1040
- stateMessage?: string;
1041
- /** Total amount across items — Trendyol returns this as a string. */
1042
- totalItemsAmount?: string;
1043
- /** Untouched raw ticket response. */
1044
- raw: Record<string, unknown>;
1045
- }
1046
- /** Filter / pagination params for `orders.getCompensationTickets()`. */
1047
- interface ListCompensationTicketsParams extends CursorPaginationParams {
1048
- /** Lower bound on `createDate` (Trendyol expects ms-epoch). */
1049
- startDate?: Date;
1050
- /** Upper bound on `createDate`. */
1051
- endDate?: Date;
1052
- }
1053
-
1054
- interface ListOrdersParams extends CursorPaginationParams {
1055
- status?: ShipmentPackageStatus;
1056
- orderNumber?: string;
1057
- /** Filter packages updated on or after this date (Trendyol expects ms-epoch). */
1058
- startDate?: Date;
1059
- /** Filter packages updated on or before this date. */
1060
- endDate?: Date;
1061
- }
1062
- /**
1063
- * Normalize one raw Trendyol shipment-package node into the public
1064
- * `ShipmentPackage` shape. Exported so consumers handling Trendyol
1065
- * webhooks can reuse the SDK's normalization logic on the event body
1066
- * (Trendyol POSTs the same shape it returns from `getShipmentPackages`).
1067
- *
1068
- * For full-webhook parsing use `parseWebhookEvent(rawBody)` from the
1069
- * top-level package, which calls this internally per item.
1070
- */
1071
- declare function normalizeShipmentPackage(rawNode: unknown): ShipmentPackage;
1072
- /**
1073
- * Trendyol order (shipment-package) endpoints.
1074
- *
1075
- * Rate limit (per Trendyol service limits): scheduled to tighten on 2026-05-15;
1076
- * for now we set a generous default that the user can tune via the constructor.
1077
- *
1078
- * Pagination: Trendyol uses page-based pagination here (not nextPageToken).
1079
- * The SDK still exposes `CursorPage<ShipmentPackage>` so the caller can
1080
- * iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes the
1081
- * page index.
1082
- */
1083
- declare class OrdersResource {
1084
- private readonly transport;
1085
- private readonly limiter;
1086
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
1087
- /**
1088
- * List shipment packages for the seller.
1089
- *
1090
- * @example
1091
- * ```ts
1092
- * import { paginate } from '@lonca/core';
1093
- * for await (const pkg of paginate((p) => client.orders.list({ ...p, status: 'Created' }))) {
1094
- * console.log(pkg.id, pkg.status, pkg.customer.firstName);
1095
- * }
1096
- * ```
1097
- */
1098
- list(params?: ListOrdersParams): Promise<CursorPage<ShipmentPackage>>;
1099
- /**
1100
- * Push a shipment-package status update.
1101
- *
1102
- * Trendyol restricts the seller-side push to two transitions:
1103
- * - `Picking` — order picked up from the shelf / being prepared
1104
- * - `Invoiced` — invoice issued, ready for cargo handoff
1105
- *
1106
- * Other transitions (`Shipped`, `Delivered`, etc.) are driven by Trendyol
1107
- * or the cargo provider — call `processAlternativeDelivery` or
1108
- * `manualDeliverByPackageId` if you ship outside Trendyol's cargo
1109
- * network.
1110
- *
1111
- * Returns void; Trendyol responds with 200 + empty body on success.
1112
- */
1113
- updatePackageStatus(packageId: string | number, input: UpdatePackageStatusInput): Promise<void>;
1114
- /**
1115
- * Notify Trendyol that one or more line items cannot be supplied
1116
- * ("Tedarik Edememe Bildirimi"). Marks the listed line IDs as
1117
- * `UnSupplied`. Trendyol cancels those quantities and notifies the
1118
- * customer.
1119
- *
1120
- * `reasonId` is a numeric code Trendyol publishes separately — consult
1121
- * the seller panel or the "Tedarik Edememe" docs for current values.
1122
- *
1123
- * Returns void; Trendyol responds with 200 + empty body on success.
1124
- */
1125
- cancelPackageItem(packageId: string | number, input: CancelPackageItemInput): Promise<void>;
1126
- /**
1127
- * Extend the agreed delivery date for a shipment package by 1, 2, or 3 days.
1128
- * Trendyol enforces the [1, 3] range server-side; the SDK validates client-side
1129
- * to fail fast.
1130
- *
1131
- * Returns void; Trendyol responds with 200 + empty body on success.
1132
- */
1133
- extendDeliveryDate(packageId: string | number, extendedDayCount: 1 | 2 | 3): Promise<void>;
1134
- /**
1135
- * Notify Trendyol of an alternative delivery channel — used when the
1136
- * seller is shipping via a non-Trendyol cargo provider. Trendyol then
1137
- * either SMSes the customer the tracking link (when `isPhoneNumber` is
1138
- * `true`) or stores the tracking URL on the package directly.
1139
- *
1140
- * Returns void; Trendyol responds with 200 + empty body on success.
1141
- */
1142
- processAlternativeDelivery(packageId: string | number, input: ProcessAlternativeDeliveryInput): Promise<void>;
1143
- /**
1144
- * Split a shipment package by moving a set of line IDs into a new
1145
- * package. The original package keeps the remaining lines.
1146
- *
1147
- * @param packageId The package to split.
1148
- * @param orderLineIds Line IDs to move into the new package (1+).
1149
- * @throws {ValidationError} when `orderLineIds` is empty.
1150
- */
1151
- splitPackage(packageId: string | number, orderLineIds: number[]): Promise<void>;
1152
- /**
1153
- * Split a shipment package by quantity. Each `QuantitySplit` entry
1154
- * carves a single line into multiple packages — e.g. `{ orderLineId: 100,
1155
- * quantities: [2, 2, 1] }` splits 5 units of line 100 into three packages
1156
- * of 2 + 2 + 1.
1157
- *
1158
- * @throws {ValidationError} when `quantitySplit` is empty.
1159
- */
1160
- splitPackageByQuantity(packageId: string | number, quantitySplit: QuantitySplit[]): Promise<void>;
1161
- /**
1162
- * Split a shipment package into multiple new packages by grouping line
1163
- * IDs. Each `SplitGroup` becomes one new package containing the listed
1164
- * line IDs.
1165
- *
1166
- * @throws {ValidationError} when `splitGroups` is empty.
1167
- */
1168
- multiSplitPackage(packageId: string | number, splitGroups: SplitGroup[]): Promise<void>;
1169
- /**
1170
- * Split a shipment package into multiple new packages, each containing a
1171
- * mix of line items at specific quantities. This is the most expressive
1172
- * split — use it when you need fine-grained control over which line IDs
1173
- * and how many of each end up in each new package.
1174
- *
1175
- * @throws {ValidationError} when `splitPackages` is empty.
1176
- */
1177
- splitMultiPackagesByQuantity(packageId: string | number, splitPackages: SplitPackagePlan[]): Promise<void>;
1178
- /**
1179
- * Change the cargo provider on an existing shipment package. Use one of
1180
- * Trendyol's documented marketplace cargo codes (`'YKMP'`, `'ARASMP'`,
1181
- * `'SURATMP'`, etc.) — see `TrendyolCargoProvider` for the full list.
1182
- */
1183
- changeCargoProvider(packageId: string | number, cargoProvider: TrendyolCargoProvider): Promise<void>;
1184
- /**
1185
- * Mark a shipment package as manually delivered via its package ID.
1186
- * Used when the seller delivered the order outside Trendyol's cargo
1187
- * network and needs to flip the package to `Delivered` after handover.
1188
- *
1189
- * No request body; Trendyol responds with 200 + empty body on success.
1190
- */
1191
- manualDeliverByPackageId(packageId: string | number): Promise<void>;
1192
- /**
1193
- * Manual-deliver variant that takes the cargo tracking number instead
1194
- * of the package ID. Useful when you only have the tracking number on
1195
- * hand (e.g., from a cargo provider webhook).
1196
- *
1197
- * Note the path structure: tracking number sits at a sibling location,
1198
- * not under `/shipment-packages/{id}/...`.
1199
- */
1200
- manualDeliverByTrackingNumber(cargoTrackingNumber: string | number): Promise<void>;
1201
- /**
1202
- * Mark a package as delivered through an authorized service ("yetkili
1203
- * servis"). For appliance / installation-required products that are
1204
- * delivered + installed by a third-party service partner.
1205
- */
1206
- markDeliveredByService(packageId: string | number): Promise<void>;
1207
- /**
1208
- * Update box / packaging metadata on a shipment package (desi value
1209
- * and/or number of boxes). Either field can be sent alone.
1210
- */
1211
- updateBoxInfo(packageId: string | number, input: UpdateBoxInfoInput): Promise<void>;
1212
- /**
1213
- * Update labor costs for one or more order lines.
1214
- *
1215
- * **Wire note:** Trendyol's request body is a raw array (no envelope),
1216
- * not `{ items: [...] }`. The SDK forwards `items` verbatim.
1217
- *
1218
- * @throws {ValidationError} when `items` is empty.
1219
- */
1220
- updateLaborCosts(packageId: string | number, items: LaborCostInput[]): Promise<void>;
1221
- /**
1222
- * Reassign a shipment package to a different warehouse. `warehouseId`
1223
- * comes from `client.suppliers.getAddresses()` (filter by `isShipmentAddress`).
1224
- */
1225
- updateWarehouse(packageId: string | number, warehouseId: number): Promise<void>;
1226
- /**
1227
- * Stream variant of `list()`. Trendyol's `getShipmentPackagesStream`
1228
- * returns the same `ShipmentPackage` shape but paginates with an opaque
1229
- * cursor — useful when the dataset is large and page-based pagination
1230
- * would hit the 10 000-record cap.
1231
- *
1232
- * @example
1233
- * ```ts
1234
- * import { paginate } from '@lonca/core';
1235
- * for await (const pkg of paginate((p) =>
1236
- * client.orders.listStream({ ...p, packageItemStatuses: 'Created,Picking' }),
1237
- * )) {
1238
- * console.log(pkg.id, pkg.status);
1239
- * }
1240
- * ```
1241
- */
1242
- listStream(params?: ListOrdersStreamParams): Promise<CursorPage<ShipmentPackage>>;
1243
- /**
1244
- * Fetch the per-parcel cargo-fee breakdown for a single cargo invoice
1245
- * (Trendyol's `getCargoInvoiceItems`). Useful for reconciling Trendyol's
1246
- * cargo deductions against your shipped packages.
1247
- *
1248
- * `invoiceSerialNumber` is sourced from the Current Account Statement
1249
- * ("Cari Hesap Ekstresi") with `transactionType=DeductionInvoices`.
1250
- *
1251
- * Page-based pagination internally (cursor encodes the page index).
1252
- */
1253
- getCargoInvoiceItems(invoiceSerialNumber: string, params?: CursorPaginationParams): Promise<CursorPage<CargoInvoiceItem>>;
1254
- /**
1255
- * Notify Trendyol that a shipped package was returned to you (manual
1256
- * return flow, e.g. customer dropped it at your address or you got the
1257
- * package back without going through Trendyol's return cargo).
1258
- *
1259
- * No body; Trendyol responds with 200 + empty body on success.
1260
- */
1261
- manualReturnByPackageId(packageId: string | number): Promise<void>;
1262
- /**
1263
- * Manual-return variant that takes the cargo tracking number instead of
1264
- * the package ID. Useful when the cargo provider's webhook only carries
1265
- * the tracking number.
1266
- *
1267
- * Sibling path (not under `/{packageId}/...`).
1268
- */
1269
- manualReturnByTrackingNumber(cargoTrackingNumber: string | number): Promise<void>;
1270
- /**
1271
- * Fetch Trendyol Express compensation tickets (claims filed when a
1272
- * shipment is lost or damaged in transit). Page-based pagination
1273
- * internally; the SDK exposes the cursor convention.
1274
- *
1275
- * Note the different base path — `/integration/tex/compensation/...`,
1276
- * not the regular `/integration/order/...`.
1277
- *
1278
- * @example
1279
- * ```ts
1280
- * import { paginate } from '@lonca/core';
1281
- * const tickets = await client.orders.getCompensationTickets({
1282
- * startDate: new Date('2026-01-01'),
1283
- * endDate: new Date('2026-02-01'),
1284
- * });
1285
- * for (const t of tickets.items) {
1286
- * console.log(t.orderNumber, t.currentState, t.stateMessage);
1287
- * }
1288
- * ```
1289
- */
1290
- getCompensationTickets(params?: ListCompensationTicketsParams): Promise<CursorPage<CompensationTicket>>;
1291
- private packagePath;
1292
- }
1293
-
1294
- /** A `{ id, name }` reference object used in product/category/brand wire types. */
1295
- interface NamedRef {
1296
- id: string;
1297
- name: string;
1298
- }
1299
- /**
1300
- * A single attribute on a Trendyol product or variant.
1301
- *
1302
- * `attributeValueId` and `attributeValue` are mutually exclusive in createProduct
1303
- * payloads but can both be present in filter responses.
1304
- */
1305
- interface ProductAttribute {
1306
- attributeId: string;
1307
- attributeName?: string;
1308
- attributeValueId?: string;
1309
- attributeValue?: string;
1310
- }
1311
- /**
1312
- * A variant of a Trendyol product — the actual purchasable SKU.
1313
- *
1314
- * Trendyol scopes barcode + stock + commission to the variant level even for
1315
- * products that only have a single variant. To read a product's barcode use
1316
- * `product.variants[0].barcode`.
1317
- */
1318
- interface ProductVariant {
1319
- variantId: string;
1320
- barcode: string;
1321
- commission?: number;
1322
- attributes: ProductAttribute[];
1323
- productUrl?: string;
1324
- onSale?: boolean;
1325
- /** Stock quantity (when the response includes stock data). */
1326
- stock?: number;
1327
- /** Untouched raw response for fields not modeled yet. */
1328
- raw: Record<string, unknown>;
1329
- }
1330
- /**
1331
- * A Trendyol marketplace product (approved variant).
1332
- *
1333
- * Lonca surfaces the stable fields we have verified against live Trendyol
1334
- * responses. Everything else stays accessible via `raw`.
1335
- */
1336
- interface Product {
1337
- contentId: string;
1338
- productMainId: string;
1339
- title: string;
1340
- description?: string;
1341
- brand: NamedRef;
1342
- category: NamedRef;
1343
- /** Image URLs in display order. */
1344
- images: string[];
1345
- attributes: ProductAttribute[];
1346
- variants: ProductVariant[];
1347
- /** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
1348
- createdAt: string;
1349
- /** ISO 8601 UTC string. */
1350
- updatedAt: string;
1351
- lastModifiedBy?: string;
1352
- /** Untouched raw response — read fields we have not modeled yet. */
1353
- raw: Record<string, unknown>;
1354
- }
1355
- /**
1356
- * Lifecycle status of an unapproved (draft) product on Trendyol.
1357
- *
1358
- * Verified values seen on STAGE/PROD as of 2026-05-25:
1359
- * - `pendingApproval` — submitted; Trendyol content review in progress.
1360
- * - `rejected` — review failed; `rejectReasonDetails` is populated.
1361
- *
1362
- * Older docs also mention `waiting`. Treat as open-enum (`(string & {})`)
1363
- * since Trendyol can add new statuses without notice.
1364
- */
1365
- type UnapprovedProductStatus = 'pendingApproval' | 'waiting' | 'rejected' | (string & {});
1366
- interface UnapprovedProductRejectReason {
1367
- /** Short title (e.g. "Kategori Bilgisi Eksik veya Yanlış"). */
1368
- rejectReason?: string;
1369
- /** Full explanation of the rejection. */
1370
- rejectReasonDetail?: string;
1371
- }
1372
- /**
1373
- * An unapproved (draft) product as returned by `filterUnapprovedProducts`.
1374
- *
1375
- * Important: the wire shape is **flatter** than the approved-product shape
1376
- * exposed by `Product` — `barcode`, `quantity`, `salePrice`, etc. live at the
1377
- * root (no `variants[]` array). Each draft is one barcode/SKU.
1378
- *
1379
- * Verified against Trendyol STAGE on 2026-05-25. The official OpenAPI spec
1380
- * calls the image-list field `media`, but the live API returns it as
1381
- * `images`. SDK normalizes to `images`.
1382
- */
1383
- interface UnapprovedProduct {
1384
- /** Seller (supplier) ID echoed back by Trendyol. */
1385
- supplierId?: string;
1386
- productMainId: string;
1387
- /** Lifecycle status — see `UnapprovedProductStatus`. */
1388
- status?: UnapprovedProductStatus;
1389
- brand: NamedRef;
1390
- category: NamedRef;
1391
- barcode: string;
1392
- title: string;
1393
- description?: string;
1394
- /** Stock quantity at the moment of the query. */
1395
- quantity?: number;
1396
- listPrice?: number;
1397
- salePrice?: number;
1398
- /** VAT rate as a percentage (e.g. `20` for 20%). */
1399
- vatRate?: number;
1400
- dimensionalWeight?: number;
1401
- stockCode?: string;
1402
- /** Image URLs in display order (Trendyol's `images` field, spec says `media`). */
1403
- images: string[];
1404
- attributes: ProductAttribute[];
1405
- /** Populated when `status === 'rejected'`. */
1406
- rejectReasonDetails: UnapprovedProductRejectReason[];
1407
- /** Returned by Trendyol; null when the seller has not configured this. */
1408
- origin?: string | null;
1409
- locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
1410
- lotNumber?: string | null;
1411
- /** Special consumption tax (ÖTV) where applicable. */
1412
- specialConsumptionTax?: number | null;
1413
- /** Suggested governance retail price (Suggested Government Retail price). */
1414
- sgrPrice?: number | null;
1415
- /** ISO 8601 UTC string (from `createDateTime` ms-epoch). */
1416
- createdAt?: string;
1417
- /** ISO 8601 UTC string (from `lastUpdateDate`). */
1418
- updatedAt?: string;
1419
- /** ISO 8601 UTC string (from `lastPriceChangeDate`). */
1420
- lastPriceChangedAt?: string;
1421
- /** ISO 8601 UTC string (from `lastStockChangeDate`). */
1422
- lastStockChangedAt?: string;
1423
- /** Untouched raw response. */
1424
- raw: Record<string, unknown>;
1425
- }
1426
- /**
1427
- * Basic lifecycle info for a single product, returned by `getProductBase`.
1428
- *
1429
- * Cheap to call (no body — just barcode in path) and useful as a polling
1430
- * primitive after `createProducts` to detect `approved: true`.
1431
- */
1432
- interface ProductBase {
1433
- barcode: string;
1434
- approved: boolean;
1435
- archived: boolean;
1436
- /** ISO 8601 UTC string (from `approvedDate` ms-epoch); `undefined` until approved. */
1437
- approvedAt?: string;
1438
- /** Stable listing ID assigned after approval. */
1439
- listingId?: string;
1440
- /** Trendyol's content ID — the same field on `Product.contentId`. */
1441
- contentId?: string;
1442
- /** Untouched raw response. */
1443
- raw: Record<string, unknown>;
1444
- }
1445
- /**
1446
- * Buybox status for a single barcode, returned by `getBuyboxInformation`.
1447
- *
1448
- * `buyboxOrder === 1` means you currently hold the buybox.
1449
- * `secondBuyboxPrice` / `thirdBuyboxPrice` are surfaced from live wire (not
1450
- * in the spec) so you can see what other sellers are charging.
1451
- */
1452
- interface BuyboxInfo {
1453
- barcode: string;
1454
- /** Position in the buybox ranking (1 = you hold it). */
1455
- buyboxOrder?: number;
1456
- /** Current buybox-winning price. */
1457
- buyboxPrice?: number;
1458
- hasMultipleSeller?: boolean;
1459
- /** Second-best price (when multiple sellers compete). */
1460
- secondBuyboxPrice?: number | null;
1461
- /** Third-best price. */
1462
- thirdBuyboxPrice?: number | null;
1463
- /** Untouched raw response. */
1464
- raw: Record<string, unknown>;
1465
- }
1466
- /**
1467
- * Status of an async batch request returned by `createProducts`,
1468
- * `updatePriceAndInventory`, and other Trendyol bulk endpoints.
1469
- */
1470
- type BatchRequestStatus = 'PROCESSING' | 'COMPLETED' | 'FAILED' | (string & {});
1471
- interface BatchRequestItemResult {
1472
- requestItem?: unknown;
1473
- status?: string;
1474
- failureReasons?: string[];
1475
- }
1476
- /**
1477
- * Result of polling `getBatchRequestResult` for a previously-submitted batch.
1478
- *
1479
- * Trendyol retains batch results for **4 hours** after the originating request.
1480
- */
1481
- interface BatchRequestResult {
1482
- batchRequestId: string;
1483
- status: BatchRequestStatus;
1484
- itemCount?: number;
1485
- failedItemCount?: number;
1486
- items: BatchRequestItemResult[];
1487
- /** ISO 8601 UTC string (converted from Trendyol's ms-epoch). */
1488
- createdAt?: string;
1489
- /** ISO 8601 UTC string. */
1490
- lastModifiedAt?: string;
1491
- /** Trendyol category of submission (e.g. `MarketPlace`). */
1492
- sourceType?: string;
1493
- /** Operation type (e.g. `CreateProducts`, `PriceUpdate`). */
1494
- batchRequestType?: string;
1495
- notes?: string;
1496
- /** Storage object key Trendyol uses internally for the batch payload. */
1497
- objectKey?: string;
1498
- storeFrontCode?: string;
1499
- /** Untouched raw response. */
1500
- raw: Record<string, unknown>;
1501
- }
1502
-
1503
- /**
1504
- * Input types for Trendyol product write endpoints (V2).
1505
- *
1506
- * All five write endpoints (`createProducts`, `updateContentBulk`,
1507
- * `updateVariantBulk`, `updateUnapproved`, `updateDeliveryInfoBulk`) are
1508
- * async batch operations: SDK accepts the typed payload, Trendyol returns
1509
- * `{ batchRequestId }`, and the caller polls via `products.getBatchStatus`.
1510
- */
1511
- /** Response shape for every async write endpoint in the product API. */
1512
- interface BatchAcceptedResponse {
1513
- /** Opaque ID — pass to `products.getBatchStatus(...)` to track. */
1514
- batchRequestId: string;
1515
- }
1516
- /** A V2 product attribute payload. Mutually-exclusive value selectors. */
1517
- interface ProductAttributeV2Input {
1518
- attributeId: number;
1519
- /**
1520
- * One or more attribute value IDs (V2 supports multi-value when the
1521
- * attribute's `allowMultipleAttributeValues` flag is true).
1522
- */
1523
- attributeValueIds?: number[];
1524
- /** Free-text value (only when the attribute's `allowCustom` flag is true). */
1525
- attributeValue?: string;
1526
- }
1527
- /** Image entry: just a URL (Trendyol fetches the image asynchronously). */
1528
- interface ProductImageInput {
1529
- /** https URL; Trendyol recommends 1200×1800, 96 DPI. */
1530
- url: string;
1531
- }
1532
- /** Per-variant delivery option (used by `create` + `updateUnapproved`). */
1533
- interface DeliveryOptionInput {
1534
- deliveryDuration?: number;
1535
- fastDeliveryType?: 'SAME_DAY_SHIPPING' | 'FAST_DELIVERY';
1536
- }
1537
- /**
1538
- * Payload for one item in `createProducts` (V2).
1539
- *
1540
- * Trendyol requires all 14 fields listed in the spec — the type makes them
1541
- * non-optional so missing required fields fail at compile time, not at
1542
- * runtime after a failed batch.
1543
- */
1544
- interface CreateProductV2Input {
1545
- /** Barcode (≤40 chars, allows `.`, `-`, `_`). */
1546
- barcode: string;
1547
- /** Title (≤100 chars). */
1548
- title: string;
1549
- /** Parent product ID for variant grouping (≤40 chars). */
1550
- productMainId: string;
1551
- /** Trendyol numeric brand ID (from `brands.list`). */
1552
- brandId: number;
1553
- /** Trendyol numeric category ID (from `categories.list`). */
1554
- categoryId: number;
1555
- /** Initial stock quantity. */
1556
- quantity: number;
1557
- /** Seller-side stock code (≤100 chars). */
1558
- stockCode: string;
1559
- /** Desi value used for shipping cost calculation. */
1560
- dimensionalWeight: number;
1561
- /** HTML-friendly product description (≤30 000 chars). */
1562
- description: string;
1563
- /** List price (PSF). Must be ≥ `salePrice`. */
1564
- listPrice: number;
1565
- /** Sale price (TSF). */
1566
- salePrice: number;
1567
- /** 1–8 image URLs. */
1568
- images: ProductImageInput[];
1569
- /** VAT rate as integer percent (0, 1, 10, 20). */
1570
- vatRate: number;
1571
- /** Required attributes for the category — fetch via `categories.getAttributes`. */
1572
- attributes: ProductAttributeV2Input[];
1573
- /** Delivery duration / fast-delivery type. */
1574
- deliveryOption?: DeliveryOptionInput;
1575
- /** Lot/SKT info (≤100 chars). */
1576
- lotNumber?: string | null;
1577
- /** Shipment warehouse ID (from `suppliers.getAddresses`). */
1578
- shipmentAddressId?: number;
1579
- /** Returning warehouse ID. */
1580
- returningAddressId?: number;
1581
- }
1582
- /** Payload for one item in `updateContentBulk` (only `contentId` is required). */
1583
- interface UpdateContentInput {
1584
- /** From `Product.contentId` on `products.list` results. */
1585
- contentId: number;
1586
- title?: string;
1587
- description?: string;
1588
- images?: ProductImageInput[];
1589
- /**
1590
- * If you update ANY attribute, you must send ALL attributes — partial
1591
- * attribute updates are not supported by Trendyol on this endpoint.
1592
- */
1593
- attributes?: ProductAttributeV2Input[];
1594
- }
1595
- /**
1596
- * Payload for one item in `updateVariantBulk`. `barcode` is the identifier;
1597
- * Trendyol does not allow updating the barcode itself via this endpoint.
1598
- */
1599
- interface UpdateVariantInput {
1600
- barcode: string;
1601
- stockCode?: string;
1602
- vatRate?: number;
1603
- shipmentAddressId?: number;
1604
- returningAddressId?: number;
1605
- dimensionalWeight?: number;
1606
- lotNumber?: string | null;
1607
- locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
1608
- }
1609
- /** Payload for one item in `updateUnapprovedProducts` — all optional except `barcode`. */
1610
- interface UpdateUnapprovedInput {
1611
- barcode: string;
1612
- title?: string;
1613
- description?: string;
1614
- productMainId?: string;
1615
- brandId?: number;
1616
- categoryId?: number;
1617
- stockCode?: string;
1618
- dimensionalWeight?: number;
1619
- vatRate?: number;
1620
- deliveryOption?: DeliveryOptionInput;
1621
- locationBasedDelivery?: 'ENABLED' | 'DISABLED' | null;
1622
- lotNumber?: string | null;
1623
- shipmentAddressId?: number;
1624
- returningAddressId?: number;
1625
- images?: ProductImageInput[];
1626
- attributes?: ProductAttributeV2Input[];
1627
- }
1628
- /** Payload for one item in `updateDeliveryInfoBulk`. */
1629
- interface UpdateDeliveryInfoInput {
1630
- barcode: string;
1631
- deliveryOptions?: {
1632
- deliveryDuration?: number;
1633
- fastDeliveryType?: 'SAME_DAY_SHIPPING' | 'FAST_DELIVERY';
1634
- };
1635
- }
1636
-
1637
- interface ListProductsParams extends CursorPaginationParams {
1638
- /** Filter by a single barcode. */
1639
- barcode?: string;
1640
- /** Filter products updated on or after this date (Trendyol expects ms-epoch). */
1641
- startDate?: Date;
1642
- /** Filter products updated on or before this date. */
1643
- endDate?: Date;
1644
- }
1645
- /** Date field to filter against on `listUnapproved` (default: server choice). */
1646
- type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
1647
- interface ListUnapprovedProductsParams extends CursorPaginationParams {
1648
- barcode?: string;
1649
- startDate?: Date;
1650
- endDate?: Date;
1651
- /** Choose which date `startDate`/`endDate` apply to. */
1652
- dateQueryType?: UnapprovedDateQueryType;
1653
- /**
1654
- * Optional override of the seller-scoped query (rare; defaults to the
1655
- * client's `sellerId`).
1656
- */
1657
- supplierId?: number;
1658
- }
1659
- /**
1660
- * Trendyol product read + write + lifecycle + batch-result endpoints.
1661
- *
1662
- * Rate limits (per Trendyol service limits):
1663
- * - filterProducts (approved + unapproved + getProductBase): 2000 req/min
1664
- * - getBatchRequestResult: 1000 req/min
1665
- * - getBuyboxInformation: 1000 req/min
1666
- * - create/update/archive/unlock product writes: 1000 req/min (shared bucket)
1667
- * - delete: 100 req/min (separate bucket)
1668
- */
1669
- declare class ProductsResource {
1670
- private readonly transport;
1671
- private readonly filterLimiter;
1672
- private readonly batchLimiter;
1673
- private readonly buyboxLimiter;
1674
- private readonly writeLimiter;
1675
- private readonly deleteLimiter;
1676
- constructor(transport: TrendyolTransport, options?: {
1677
- filterLimiter?: TokenBucketRateLimiter;
1678
- batchLimiter?: TokenBucketRateLimiter;
1679
- buyboxLimiter?: TokenBucketRateLimiter;
1680
- writeLimiter?: TokenBucketRateLimiter;
1681
- deleteLimiter?: TokenBucketRateLimiter;
1682
- });
1683
- private validateBarcodes;
1684
- private submitWrite;
1685
- /**
1686
- * List approved products. Use `paginate()` from `@lonca/core` to iterate
1687
- * lazily across pages.
1688
- *
1689
- * Trendyol exposes both page-based and `nextPageToken`-based pagination
1690
- * (the latter required when the dataset exceeds 10,000 items). The SDK
1691
- * picks the right strategy automatically — pass our opaque `cursor` from
1692
- * the previous response and we forward it as `nextPageToken`.
1693
- *
1694
- * @example
1695
- * ```ts
1696
- * import { paginate } from '@lonca/core';
1697
- * for await (const product of paginate((p) => client.products.list(p))) {
1698
- * for (const variant of product.variants) {
1699
- * console.log(variant.barcode, product.title);
1700
- * }
1701
- * }
1702
- * ```
1703
- */
1704
- list(params?: ListProductsParams): Promise<CursorPage<Product>>;
1705
- /**
1706
- * Poll a batch request returned by an async write (e.g. `createProducts`,
1707
- * `updatePriceAndInventory`).
1708
- *
1709
- * Trendyol retains batch results for **4 hours** after the originating
1710
- * request — poll within that window.
1711
- *
1712
- * @param batchRequestId The opaque ID returned by the originating call.
1713
- */
1714
- getBatchStatus(batchRequestId: string): Promise<BatchRequestResult>;
1715
- /**
1716
- * List **unapproved** (draft / rejected / pending-review) products.
1717
- *
1718
- * Wire shape is intentionally flatter than the approved-product shape:
1719
- * each barcode is one top-level item with `barcode`, `quantity`, `salePrice`
1720
- * etc. at the root. Rejected drafts carry `rejectReasonDetails` so you can
1721
- * surface why Trendyol's content team turned them down.
1722
- *
1723
- * Pagination follows the same convention as `list()`: `cursor` from the
1724
- * previous response forwards as `nextPageToken`.
1725
- *
1726
- * @example
1727
- * ```ts
1728
- * const page = await client.products.listUnapproved({ limit: 50 });
1729
- * for (const draft of page.items) {
1730
- * if (draft.status === 'rejected') {
1731
- * console.warn(draft.barcode, draft.rejectReasonDetails);
1732
- * }
1733
- * }
1734
- * ```
1735
- */
1736
- listUnapproved(params?: ListUnapprovedProductsParams): Promise<CursorPage<UnapprovedProduct>>;
1737
- /**
1738
- * Fetch the basic lifecycle status of a single product by barcode.
1739
- *
1740
- * Cheap and useful as a polling primitive after `createProducts`: poll
1741
- * this endpoint until `approved` flips to `true` (or use
1742
- * `client.products.getBatchStatus()` to track the originating batch).
1743
- *
1744
- * @param barcode The product barcode to look up.
1745
- */
1746
- getBase(barcode: string): Promise<ProductBase>;
1747
- /**
1748
- * Fetch buybox information for up to 10 barcodes in one call.
1749
- *
1750
- * Returns rank (`buyboxOrder === 1` means you hold the buybox), the
1751
- * current buybox price, and — beyond the spec — the second and third
1752
- * competing prices when other sellers are present.
1753
- *
1754
- * @param barcodes 1–10 product barcodes.
1755
- * @throws {ValidationError} when `barcodes` is empty or longer than 10.
1756
- */
1757
- getBuyboxInfo(barcodes: string[]): Promise<BuyboxInfo[]>;
1758
- /**
1759
- * Create products (V2). Async batch — returns a `batchRequestId` you can
1760
- * poll with `getBatchStatus`. Max 1000 items per call.
1761
- *
1762
- * Trendyol requires the full V2 attribute payload — fetch via
1763
- * `categories.getAttributes` (and `categories.getAttributeValues` for
1764
- * values when `allowCustom === false`). Shipment / returning warehouse
1765
- * IDs come from `suppliers.getAddresses`.
1766
- *
1767
- * @throws {ValidationError} when `items` is empty or longer than 1000.
1768
- */
1769
- create(items: CreateProductV2Input[]): Promise<BatchAcceptedResponse>;
1770
- /**
1771
- * Update **content** of approved products (title, description, images,
1772
- * attributes). Identified by `contentId`. Partial update is supported
1773
- * except for attributes — if you update ANY attribute, send ALL of them.
1774
- *
1775
- * @throws {ValidationError} when `items` is empty or longer than 1000.
1776
- */
1777
- updateContent(items: UpdateContentInput[]): Promise<BatchAcceptedResponse>;
1778
- /**
1779
- * Update **variant** fields of approved products (stockCode, vatRate,
1780
- * dimensionalWeight, warehouse IDs, location-based delivery, lot). Identified
1781
- * by `barcode`. The barcode itself cannot be changed via this endpoint.
1782
- *
1783
- * @throws {ValidationError} when `items` is empty or longer than 1000.
1784
- */
1785
- updateVariants(items: UpdateVariantInput[]): Promise<BatchAcceptedResponse>;
1786
- /**
1787
- * Update **unapproved** (draft) products. Identified by `barcode`. All
1788
- * other fields are optional partial updates. Use this to fix drafts that
1789
- * Trendyol rejected — `client.products.listUnapproved` surfaces the
1790
- * `rejectReasonDetails` you need to act on.
1791
- *
1792
- * **Gotcha (verified live STAGE 2026-05-25):** Trendyol's V2 spec claims
1793
- * only `barcode` is required, but the endpoint returns HTTP 500
1794
- * (`TrendyolSystemException` / `TypeError`) when too many optional fields
1795
- * are omitted. In practice, send at least `title`, `description`,
1796
- * `productMainId`, `brandId`, `categoryId`, `stockCode`,
1797
- * `dimensionalWeight`, `vatRate`, `images[]`, and `attributes[]` (an
1798
- * empty array is OK for the latter). The SDK forwards your payload
1799
- * as-is; trim fields only if you have verified the server accepts it.
1800
- *
1801
- * @throws {ValidationError} when `items` is empty or longer than 1000.
1802
- */
1803
- updateUnapproved(items: UpdateUnapprovedInput[]): Promise<BatchAcceptedResponse>;
1804
- /**
1805
- * Update product **delivery information** (deliveryDuration,
1806
- * fastDeliveryType). Identified by `barcode`.
1807
- *
1808
- * @throws {ValidationError} when `items` is empty or longer than 1000.
1809
- */
1810
- updateDeliveryInfo(items: UpdateDeliveryInfoInput[]): Promise<BatchAcceptedResponse>;
1811
- /**
1812
- * Delete products by barcode. Trendyol allows deletion of unapproved
1813
- * products and approved products that have been archived for more than a
1814
- * day (and have not been sales-stopped by Trendyol).
1815
- *
1816
- * Async batch — returns `{ batchRequestId }` to poll via `getBatchStatus`.
1817
- * Separately rate-limited at **100 req/min** (much tighter than create/update).
1818
- *
1819
- * @param barcodes 1–1000 barcodes.
1820
- * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
1821
- */
1822
- delete(barcodes: string[]): Promise<BatchAcceptedResponse>;
1823
- /**
1824
- * Archive products by barcode (Trendyol's `archived=true` state).
1825
- * Archived products are not visible to customers; pair with `delete`
1826
- * after the 24-hour archive cool-down to remove them entirely.
1827
- *
1828
- * Async batch — returns `{ batchRequestId }`.
1829
- *
1830
- * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
1831
- */
1832
- archive(barcodes: string[]): Promise<BatchAcceptedResponse>;
1833
- /**
1834
- * Unarchive products by barcode (Trendyol's `archived=false` state).
1835
- * Restores visibility for previously-archived products.
1836
- *
1837
- * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
1838
- */
1839
- unarchive(barcodes: string[]): Promise<BatchAcceptedResponse>;
1840
- private setArchivedState;
1841
- /**
1842
- * Unlock products whose sale was paused by Trendyol due to pricing
1843
- * issues (under/over-pricing, critical price error, supplier issues).
1844
- * Restores selling status for the listed barcodes.
1845
- *
1846
- * Async batch — returns `{ batchRequestId }`.
1847
- *
1848
- * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
1849
- */
1850
- unlock(barcodes: string[]): Promise<BatchAcceptedResponse>;
1851
- }
1852
-
1853
- /**
1854
- * Trendyol customer Q&A types.
1855
- *
1856
- * Customers can post product questions on Trendyol; sellers reply via
1857
- * `questions.answer()`. Status lifecycle:
1858
- * `WAITING_FOR_ANSWER` → seller replies → `ANSWERED`
1859
- * → reported by another seller / Trendyol → `REPORTED`
1860
- * → rejected by Trendyol moderation → `REJECTED`
1861
- */
1862
-
1863
- type QuestionStatus = 'WAITING_FOR_ANSWER' | 'ANSWERED' | 'REJECTED' | 'REPORTED' | (string & {});
1864
- interface QuestionAnswer {
1865
- text?: string;
1866
- /** ISO 8601 UTC (converted from `creationDate` ms-epoch). */
1867
- createdAt?: string;
1868
- status?: string;
1869
- }
1870
- interface Question {
1871
- id: string;
1872
- text?: string;
1873
- customerId?: string;
1874
- /** Masked customer display name. */
1875
- userName?: string;
1876
- showUserName?: boolean;
1877
- status?: QuestionStatus;
1878
- /** Whether the question is visible publicly. */
1879
- public?: boolean;
1880
- productMainId?: string;
1881
- productName?: string;
1882
- imageUrl?: string;
1883
- webUrl?: string;
1884
- /** ISO 8601 UTC (from ms-epoch). */
1885
- createdAt?: string;
1886
- /** Trendyol's pre-formatted "answered on ..." message (Turkish). */
1887
- answeredDateMessage?: string;
1888
- answer?: QuestionAnswer;
1889
- rejectedAnswer?: QuestionAnswer;
1890
- /** ISO 8601 UTC if the question was rejected. */
1891
- rejectedAt?: string;
1892
- reason?: string;
1893
- reportReason?: string;
1894
- /** ISO 8601 UTC if the question was reported. */
1895
- reportedAt?: string;
1896
- /** Untouched raw response. */
1897
- raw: Record<string, unknown>;
1898
- }
1899
- interface ListQuestionsParams extends CursorPaginationParams {
1900
- /** Filter to questions about a specific product barcode. */
1901
- barcode?: string;
1902
- startDate?: Date;
1903
- endDate?: Date;
1904
- /** Filter by current status. */
1905
- status?: QuestionStatus;
1906
- }
1907
-
1908
- /**
1909
- * Trendyol customer Q&A management. Customers post product questions on
1910
- * Trendyol; sellers reply with `questions.answer()`.
1911
- */
1912
- declare class QuestionsResource {
1913
- private readonly transport;
1914
- private readonly limiter;
1915
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
1916
- /** Fetch a single question by its numeric ID. */
1917
- get(questionId: string | number): Promise<Question>;
1918
- /**
1919
- * Filter questions by barcode / date range / status. Page-based
1920
- * pagination internally; SDK exposes the opaque-cursor convention.
1921
- */
1922
- list(params?: ListQuestionsParams): Promise<CursorPage<Question>>;
1923
- /**
1924
- * Reply to a question. Trendyol enforces 10–2000 characters on the
1925
- * answer text; the SDK pre-validates client-side.
1926
- *
1927
- * @throws {ValidationError} when `text` is outside the 10–2000 char range.
1928
- */
1929
- answer(questionId: string | number, text: string): Promise<unknown>;
1930
- }
1931
-
1932
- /**
1933
- * The role an address plays in the seller's logistics flow.
1934
- *
1935
- * Trendyol allows a single physical address to play more than one role
1936
- * (e.g., shipment + invoice), so always check the boolean flags rather than
1937
- * relying solely on `addressType`.
1938
- */
1939
- type SupplierAddressType = 'SHIPMENT' | 'RETURNING' | 'INVOICE' | 'WAREHOUSE';
1940
- /**
1941
- * A supplier address registered in the Trendyol Partner Panel.
1942
- *
1943
- * Used by `createProduct V2` for `shipmentAddressId` / `returningAddressId`.
1944
- *
1945
- * NOTE: The exact field set is best-effort; some optional fields may differ
1946
- * once verified against real STAGE responses. Bumped fields land in a follow-up
1947
- * minor release if needed.
1948
- */
1949
- interface SupplierAddress {
1950
- id: string;
1951
- /** Free-form label set by the seller. */
1952
- name?: string;
1953
- /** Primary role declared by Trendyol. */
1954
- addressType: SupplierAddressType;
1955
- isShipmentAddress: boolean;
1956
- isReturningAddress: boolean;
1957
- isInvoiceAddress: boolean;
1958
- isDefault: boolean;
1959
- /** Multi-line address string as registered in the Partner Panel. */
1960
- address?: string;
1961
- city?: string;
1962
- district?: string;
1963
- postCode?: string;
1964
- fullName?: string;
1965
- }
1966
-
1967
- interface SuppliersResourceOptions {
1968
- /** Override the in-memory cache TTL. Defaults to 1 hour. */
1969
- cacheTtlMs?: number;
1970
- }
1971
- /**
1972
- * Trendyol supplier address endpoints.
1973
- *
1974
- * **Critical:** Trendyol rate-limits `getSuppliersAddresses` to **1 request
1975
- * per hour per seller**. This resource therefore wraps the endpoint with an
1976
- * in-memory cache (default TTL: 1 hour) so callers can request addresses
1977
- * as often as needed without tripping the limit.
1978
- *
1979
- * Use `{ forceRefresh: true }` or `invalidateCache()` only when you know the
1980
- * address list changed in the Partner Panel.
1981
- */
1982
- declare class SuppliersResource {
1983
- private readonly transport;
1984
- private cache;
1985
- private readonly cacheTtlMs;
1986
- private readonly limiter;
1987
- private inflight;
1988
- constructor(transport: TrendyolTransport, options?: SuppliersResourceOptions);
1989
- /**
1990
- * List the seller's registered addresses (shipment, returning, invoice, warehouse).
1991
- *
1992
- * Returns the cached value if it is still fresh. Concurrent calls share a
1993
- * single in-flight request.
1994
- */
1995
- getAddresses(options?: {
1996
- forceRefresh?: boolean;
1997
- }): Promise<SupplierAddress[]>;
1998
- /** Drop the cache; the next `getAddresses()` call hits the API. */
1999
- invalidateCache(): void;
2000
- private fetchFresh;
2001
- }
2002
-
2003
- /**
2004
- * STAGE-only helper endpoints for creating + driving test orders /
2005
- * test claims through their state machine. **Do not use in PROD** —
2006
- * Trendyol's test endpoints are scoped to the test environment.
2007
- */
2008
- declare class TestOrdersResource {
2009
- private readonly transport;
2010
- private readonly limiter;
2011
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
2012
- /**
2013
- * Create a test order with the given customer / addresses / lines. The
2014
- * SDK forwards the typed payload verbatim — drill into Trendyol's
2015
- * `createTestOrder` doc for inner field rules.
2016
- *
2017
- * @throws {ValidationError} when required top-level fields are missing.
2018
- */
2019
- create(input: CreateTestOrderInput): Promise<unknown>;
2020
- /** Push a test shipment package to the given status. */
2021
- updateStatus(packageId: string | number, status: TestOrderStatus): Promise<unknown>;
2022
- /** Move test claims to the `WaitingInAction` state. */
2023
- setClaimsWaitingInAction(): Promise<unknown>;
2024
- }
2025
-
2026
- /**
2027
- * Trendyol webhook subscription types.
2028
- *
2029
- * Webhooks let Trendyol push shipment-package status events to a URL you
2030
- * own instead of polling. Max 15 active webhooks per seller. Trendyol
2031
- * itself authenticates against your endpoint (you don't sign Trendyol's
2032
- * request) — pick `BASIC_AUTHENTICATION` (username+password) or `API_KEY`
2033
- * (rotatable; recommended).
2034
- */
2035
-
2036
- /** Auth method Trendyol uses when calling your webhook URL. */
2037
- type WebhookAuthenticationType = 'BASIC_AUTHENTICATION' | 'API_KEY';
2038
- /**
2039
- * Payload for `webhooks.create` / `webhooks.update`. Same shape for both.
2040
- */
2041
- interface WebhookInput {
2042
- /** Your endpoint URL (must accept POST JSON from Trendyol). */
2043
- url: string;
2044
- /** Auth scheme Trendyol will use to call your endpoint. */
2045
- authenticationType: WebhookAuthenticationType;
2046
- /** Username (only when `authenticationType === 'BASIC_AUTHENTICATION'`). */
2047
- username?: string;
2048
- /** Password (only when `authenticationType === 'BASIC_AUTHENTICATION'`). */
2049
- password?: string;
2050
- /** API key (only when `authenticationType === 'API_KEY'`). */
2051
- apiKey?: string;
2052
- /**
2053
- * Order statuses you want events for. Empty/omitted = all statuses.
2054
- * Trendyol accepts the same vocabulary as `ShipmentPackageStatus`
2055
- * (the upper-snake-case variants — `'CREATED'`, `'PICKING'`, etc. — see
2056
- * Trendyol docs for the exact wire spelling, which sometimes differs
2057
- * from the read-side `'Created'`/`'Picking'`).
2058
- */
2059
- subscribedStatuses?: string[];
2060
- }
2061
- /** A registered webhook subscription as returned by `webhooks.list`. */
2062
- interface Webhook {
2063
- id: string;
2064
- url?: string;
2065
- authenticationType?: WebhookAuthenticationType;
2066
- username?: string;
2067
- apiKey?: string;
2068
- subscribedStatuses?: string[];
2069
- /** Active vs deactivated. */
2070
- active?: boolean;
2071
- /** Untouched raw webhook entry. */
2072
- raw: Record<string, unknown>;
2073
- }
2074
-
2075
- /**
2076
- * Trendyol webhook subscription management.
2077
- *
2078
- * Max **15 active webhooks per seller** (Trendyol-enforced). Webhooks
2079
- * fire on shipment-package status events only — there is no webhook
2080
- * support for product / stock changes.
2081
- *
2082
- * Trendyol's gateway authenticates **against your endpoint** with the
2083
- * `authenticationType` you configure. Pick `API_KEY` over
2084
- * `BASIC_AUTHENTICATION` so you can rotate the secret without redeploying.
2085
- *
2086
- * No HMAC signature — security relies entirely on the auth method you
2087
- * pick + the secret you store with Trendyol.
2088
- */
2089
- declare class WebhooksResource {
2090
- private readonly transport;
2091
- private readonly limiter;
2092
- constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
2093
- /**
2094
- * Create a new webhook subscription. Trendyol caps subscriptions at 15
2095
- * per seller — the SDK does NOT pre-check (you'd need to call `list()`
2096
- * first), but Trendyol returns 400 when the cap is exceeded.
2097
- *
2098
- * @throws {ValidationError} when `url` or `authenticationType` is missing.
2099
- */
2100
- create(input: WebhookInput): Promise<unknown>;
2101
- /** List all registered webhook subscriptions. */
2102
- list(): Promise<Webhook[]>;
2103
- /**
2104
- * Update a webhook subscription. Same input shape as `create`; replaces
2105
- * the whole subscription (Trendyol does NOT partially update).
2106
- */
2107
- update(webhookId: string | number, input: WebhookInput): Promise<unknown>;
2108
- /** Permanently delete a webhook subscription. */
2109
- delete(webhookId: string | number): Promise<unknown>;
2110
- /** Re-activate a previously-deactivated webhook subscription. */
2111
- activate(webhookId: string | number): Promise<unknown>;
2112
- /**
2113
- * Deactivate a webhook subscription. Trendyol automatically deactivates
2114
- * a subscription after persistent delivery failures (and sends 2 emails);
2115
- * use `activate()` to bring it back online once your endpoint is healthy.
2116
- */
2117
- deactivate(webhookId: string | number): Promise<unknown>;
2118
- private validateInput;
2119
- private webhookPath;
2120
- }
2121
-
2122
- interface CreateClientOptions {
2123
- /** Trendyol seller (supplier) ID — visible in Partner Panel → Account Info. */
2124
- sellerId: number;
2125
- /** Trendyol API key. */
2126
- apiKey: string;
2127
- /** Trendyol API secret. */
2128
- apiSecret: string;
2129
- /** Which Trendyol environment to target. */
2130
- env: TrendyolEnvironment;
2131
- /**
2132
- * Integrator company name to send in `User-Agent` / `x-agentname`. Required —
2133
- * Trendyol uses this to attribute API traffic. Use `'SelfIntegration'` if
2134
- * the seller owns the integration code, otherwise your company / product name.
2135
- * Trendyol caps this at 30 alphanumeric characters.
2136
- */
2137
- integratorName: string;
2138
- /**
2139
- * IPv4 address to send in `x-clientip`.
2140
- * Defaults to `'127.0.0.1'` — Trendyol does not validate this against the
2141
- * request origin, the header just has to be present and IPv4-shaped.
2142
- */
2143
- clientIp?: string;
2144
- /** Optional structured logger (`@lonca/core` `Logger`). Defaults to no-op. */
2145
- logger?: Logger;
2146
- /** Request timeout in ms. Default: 30_000. */
2147
- timeoutMs?: number;
2148
- }
2149
- interface TrendyolClient {
2150
- brands: BrandsResource;
2151
- categories: CategoriesResource;
2152
- suppliers: SuppliersResource;
2153
- products: ProductsResource;
2154
- inventory: InventoryResource;
2155
- orders: OrdersResource;
2156
- claims: ClaimsResource;
2157
- webhooks: WebhooksResource;
2158
- questions: QuestionsResource;
2159
- invoices: InvoicesResource;
2160
- finance: FinanceResource;
2161
- labels: LabelsResource;
2162
- testOrders: TestOrdersResource;
2163
- locations: LocationsResource;
2164
- }
2165
- /**
2166
- * Create a Trendyol Marketplace SDK client.
2167
- *
2168
- * @example
2169
- * ```ts
2170
- * import { createTrendyolClient } from '@lonca/trendyol';
2171
- *
2172
- * const client = createTrendyolClient({
2173
- * sellerId: 12345,
2174
- * apiKey: process.env.TRENDYOL_API_KEY!,
2175
- * apiSecret: process.env.TRENDYOL_API_SECRET!,
2176
- * env: 'stage',
2177
- * });
2178
- *
2179
- * const page = await client.brands.list({ limit: 100 });
2180
- * ```
2181
- */
2182
- declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
1
+ import { aP as ShipmentPackage, a2 as KnownShipmentPackageStatus } from './client-0omWgpd_.js';
2
+ export { A as ApproveClaimLineItemsInput, B as BarcodeCategoryLookup, a as BatchAcceptedResponse, b as BatchPollOptions, c as BatchRequestItemResult, d as BatchRequestResult, e as BatchRequestStatus, f as Brand, g as BrandsResource, h as BuyboxInfo, C as CancelPackageItemInput, i as CareInstruction, j as CargoInvoiceItem, k as CategoriesResource, l as Category, m as CategoryAttribute, n as CategoryAttributeValue, o as City, p as Claim, q as ClaimIssueReason, r as ClaimItemAudit, s as ClaimItemStatus, t as ClaimsResource, u as CommonLabel, v as CommonLabelEntry, w as CompensationItemDetail, x as CompensationTicket, y as CompensationTicketState, z as Country, D as CreateClaimInput, E as CreateClaimIssueInput, F as CreateClaimItemInput, G as CreateClientOptions, H as CreateCommonLabelInput, I as CreateProductV2Input, J as CreateTestOrderInput, K as CreateVideoInput, L as DeleteInvoiceLinkInput, M as DeliveryOptionInput, N as District, O as ExportBatchAcceptedResponse, P as ExportBatchStatus, Q as ExportCategoryAttribute, R as ExportCenterResource, S as ExportPackage, T as ExportPackageItem, U as ExportPackageStatus, V as ExportPriceUpdateInput, W as ExportProduct, X as ExportProductInput, Y as ExportStockUpdateInput, Z as FinanceResource, _ as FinancialTransaction, $ as GetExportPackageItemsParams, a0 as InventoryResource, a1 as InvoicesResource, a3 as LabelsResource, a4 as LaborCostInput, a5 as ListCategoryAttributeValuesParams, a6 as ListClaimsParams, a7 as ListCompensationTicketsParams, a8 as ListExportPackagesV2Params, a9 as ListExportPackagesV3Params, aa as ListExportProductsParams, ab as ListFinanceParams, ac as ListOrdersParams, ad as ListOrdersStreamParams, ae as ListProductsParams, af as ListQuestionsParams, ag as ListUnapprovedProductsParams, ah as ListVideosParams, ai as LocationsResource, aj as NamedRef, ak as Neighborhood, al as OrderAddress, am as OrderAddressLines, an as OrderCustomer, ao as OrderLine, ap as OrderLineDiscountDetail, aq as OrdersResource, ar as OtherFinancialRow, as as PackageDetail, at as PackageHistoryEntry, au as PackageLineUpdate, av as PriceInventoryUpdate, aw as ProcessAlternativeDeliveryInput, ax as Product, ay as ProductAttribute, az as ProductAttributeV2Input, aA as ProductBase, aB as ProductComposition, aC as ProductImageInput, aD as ProductOrigin, aE as ProductVariant, aF as ProductsResource, aG as QuantitySplit, aH as Question, aI as QuestionAnswer, aJ as QuestionStatus, aK as QuestionsResource, aL as SellerIntegrationStatus, aM as SellerVideo, aN as SendInvoiceLinkInput, aO as SettlementRow, aQ as ShipmentPackageStatus, aR as SplitGroup, aS as SplitPackagePlan, aT as SupplierAddress, aU as SupplierAddressType, aV as SuppliersResource, aW as SuppliersResourceOptions, aX as TestOrderStatus, aY as TestOrdersResource, aZ as TrendyolCapabilities, a_ as TrendyolCargoProvider, a$ as TrendyolClient, b0 as TrendyolEnvironment, b1 as UnapprovedDateQueryType, b2 as UnapprovedProduct, b3 as UnapprovedProductRejectReason, b4 as UnapprovedProductStatus, b5 as UpdateBoxInfoInput, b6 as UpdateContentInput, b7 as UpdateDeliveryInfoInput, b8 as UpdatePackageStatusInput, b9 as UpdatePriceInventoryResponse, ba as UpdateUnapprovedInput, bb as UpdateVariantInput, bc as UploadInvoiceFileInput, bd as VideosResource, be as Webhook, bf as WebhookAuthenticationType, bg as WebhookInput, bh as WebhooksResource, bi as createTrendyolClient, bj as normalizeShipmentPackage, bk as pollBatchStatus, bl as trendyolCapabilities } from './client-0omWgpd_.js';
3
+ import * as _lonca_core from '@lonca/core';
4
+ import { NormalizedOrderStatus } from '@lonca/core';
2183
5
 
2184
6
  /**
2185
7
  * Inbound webhook event payloads — what Trendyol POSTs to YOUR endpoint
@@ -2269,4 +91,23 @@ interface WebhookEvent {
2269
91
  */
2270
92
  declare function parseWebhookEvent(rawBody: unknown): WebhookEvent;
2271
93
 
2272
- export { type ApproveClaimLineItemsInput, type BarcodeCategoryLookup, type BatchAcceptedResponse, type BatchRequestItemResult, type BatchRequestResult, type BatchRequestStatus, type Brand, BrandsResource, type BuyboxInfo, type CancelPackageItemInput, type CargoInvoiceItem, CategoriesResource, type Category, type CategoryAttribute, type CategoryAttributeValue, type City, type Claim, type ClaimIssueReason, type ClaimItemAudit, type ClaimItemStatus, ClaimsResource, type CommonLabel, type CommonLabelEntry, type CompensationItemDetail, type CompensationTicket, type CompensationTicketState, type Country, type CreateClaimInput, type CreateClaimIssueInput, type CreateClaimItemInput, type CreateClientOptions, type CreateCommonLabelInput, type CreateProductV2Input, type CreateTestOrderInput, type DeleteInvoiceLinkInput, type DeliveryOptionInput, type District, FinanceResource, type FinancialTransaction, InventoryResource, InvoicesResource, LabelsResource, type LaborCostInput, type ListCategoryAttributeValuesParams, type ListClaimsParams, type ListCompensationTicketsParams, type ListFinanceParams, type ListOrdersParams, type ListOrdersStreamParams, type ListProductsParams, type ListQuestionsParams, type ListUnapprovedProductsParams, LocationsResource, type NamedRef, type Neighborhood, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, type OtherFinancialRow, type PackageCreatedBy, type PackageDetail, type PackageHistoryEntry, type PackageLineUpdate, type PriceInventoryUpdate, type ProcessAlternativeDeliveryInput, type Product, type ProductAttribute, type ProductAttributeV2Input, type ProductBase, type ProductImageInput, type ProductVariant, ProductsResource, type QuantitySplit, type Question, type QuestionAnswer, type QuestionStatus, QuestionsResource, type SendInvoiceLinkInput, type SettlementRow, type ShipmentPackage, type ShipmentPackageStatus, type SplitGroup, type SplitPackagePlan, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, type TestOrderStatus, TestOrdersResource, type TrendyolCargoProvider, type TrendyolClient, type TrendyolEnvironment, type UnapprovedDateQueryType, type UnapprovedProduct, type UnapprovedProductRejectReason, type UnapprovedProductStatus, type UpdateBoxInfoInput, type UpdateContentInput, type UpdateDeliveryInfoInput, type UpdatePackageStatusInput, type UpdatePriceInventoryResponse, type UpdateUnapprovedInput, type UpdateVariantInput, type UploadInvoiceFileInput, type Webhook, type WebhookAuthenticationType, type WebhookEvent, type WebhookEventStatus, type WebhookInput, WebhooksResource, createTrendyolClient, normalizeShipmentPackage, parseWebhookEvent };
94
+ /**
95
+ * Exhaustive map from Trendyol's known shipment-package statuses to the
96
+ * marketplace-agnostic {@link NormalizedOrderStatus} vocabulary.
97
+ *
98
+ * Because the key type is the **closed** {@link KnownShipmentPackageStatus}
99
+ * union, adding a value there without mapping it here is a compile-time error.
100
+ * Some Trendyol states have no exact normalized equivalent and are folded onto
101
+ * the nearest lifecycle stage (noted inline).
102
+ */
103
+ declare const statusMap: Record<KnownShipmentPackageStatus, NormalizedOrderStatus>;
104
+ /**
105
+ * Normalize a raw Trendyol shipment-package status into the
106
+ * {@link NormalizedOrderStatus} vocabulary.
107
+ *
108
+ * Unknown raw values resolve to `{ normalized: 'unknown', mapped: false }` with
109
+ * the raw string preserved — never silently coerced to a valid-looking default.
110
+ */
111
+ declare const normalizeStatus: (raw: string) => _lonca_core.NormalizedStatusResult;
112
+
113
+ export { KnownShipmentPackageStatus, type PackageCreatedBy, ShipmentPackage, type WebhookEvent, type WebhookEventStatus, normalizeStatus, parseWebhookEvent, statusMap };