@lonca/trendyol 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -33
- package/dist/{client-0omWgpd_.d.cts → client-CCA1P7sb.d.cts} +117 -18
- package/dist/{client-0omWgpd_.d.ts → client-CCA1P7sb.d.ts} +117 -18
- package/dist/index.cjs +104 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +105 -108
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +104 -107
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +105 -108
- package/dist/testing.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,35 +8,38 @@
|
|
|
8
8
|
|
|
9
9
|
Type-safe TypeScript SDK for the [Trendyol Marketplace API](https://developers.trendyol.com).
|
|
10
10
|
|
|
11
|
-
>
|
|
11
|
+
> [!IMPORTANT]
|
|
12
|
+
> **Unofficial.** This is an independent, community-maintained SDK. It is not affiliated with, endorsed by, or supported by Trendyol. "Trendyol" and related names are trademarks of their respective owners.
|
|
13
|
+
|
|
14
|
+
> **Trendyol surface complete.** 16 resources spanning catalog, orders, claims, finance, webhooks, and Export Center, plus a `parseWebhookEvent` helper for inbound event handling. Every endpoint a non-AutoFT non-V1 seller can hit is covered. See the [npm badge](https://www.npmjs.com/package/@lonca/trendyol) above for the current release.
|
|
12
15
|
|
|
13
16
|
## Coverage
|
|
14
17
|
|
|
15
|
-
Each entry is a method on the client.
|
|
18
|
+
Each entry is a method on the client.
|
|
16
19
|
|
|
17
20
|
| Resource | Methods |
|
|
18
21
|
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
-
| `brands` | `list()`, `search(name)`
|
|
20
|
-
| `categories` | `list()`, `getAttributes(id)`, `getAttributeValues(catId, attrId)
|
|
22
|
+
| `brands` | `list()`, `search(name)` |
|
|
23
|
+
| `categories` | `list()`, `getAttributes(id)`, `getAttributeValues(catId, attrId)`, `getByBarcodes(barcodes)` (AutoFT) |
|
|
21
24
|
| `suppliers` | `getAddresses({forceRefresh?})` (1-hour cache; rate-limited 1 req/hour on Trendyol) |
|
|
22
|
-
| `products` read | `list({...})`
|
|
23
|
-
| `products` write | `create(items)`, `updateContent(items)`, `updateVariants(items)`, `updateUnapproved(items)
|
|
25
|
+
| `products` read | `list({...})`, `listInventoryAndPrice({...})` (lightweight stock + price), `listUnapproved({...})`, `getBase(barcode)`, `getBuyboxInfo(barcodes)`, `getBatchStatus(id)` |
|
|
26
|
+
| `products` write | `create(items)`, `updateContent(items)`, `updateVariants(items)`, `updateUnapproved(items)`, `updateDeliveryInfo(items)` |
|
|
24
27
|
| `products` life | `delete(barcodes)`, `archive(barcodes)`, `unarchive(barcodes)`, `unlock(barcodes)` |
|
|
25
|
-
| `inventory` | `update(items)`
|
|
26
|
-
| `orders` read | `list({...})
|
|
28
|
+
| `inventory` | `update(items)` (stock + price, async batch) |
|
|
29
|
+
| `orders` read | `list({...})`, `listStream({...})` (opaque cursor for >10K), `getCargoInvoiceItems(serial, {...})` |
|
|
27
30
|
| `orders` write | `updatePackageStatus(id, {...})`, `cancelPackageItem(id, {...})`, `extendDeliveryDate(id, 1\|2\|3)`, `processAlternativeDelivery(id, {...})` |
|
|
28
31
|
| `orders` split | `splitPackage`, `splitPackageByQuantity`, `multiSplitPackage`, `splitMultiPackagesByQuantity` (4 variants) |
|
|
29
32
|
| `orders` cargo | `changeCargoProvider(id, code)`, `manualDeliverByPackageId(id)`, `manualDeliverByTrackingNumber(trk)`, `markDeliveredByService(id)` |
|
|
30
33
|
| `orders` ops | `updateBoxInfo(id, {...})`, `updateLaborCosts(id, items)`, `updateWarehouse(id, warehouseId)` |
|
|
31
34
|
| `orders` returns | `manualReturnByPackageId(id)`, `manualReturnByTrackingNumber(trk)`, `getCompensationTickets({...})` (TEX) |
|
|
32
|
-
| `claims` | `create({...})`, `createIssue(id, {...})` (multipart), `approveLineItems(id, {...})`, `list({...})`, `getIssueReasons()
|
|
35
|
+
| `claims` | `create({...})`, `createIssue(id, {...})` (multipart), `approveLineItems(id, {...})`, `list({...})`, `getIssueReasons()`, `getItemAudits(itemId)` |
|
|
33
36
|
| `webhooks` | `create({...})`, `list()`, `update(id, {...})`, `delete(id)`, `activate(id)`, `deactivate(id)` |
|
|
34
|
-
| `questions` | `get(id)`, `list({...})
|
|
37
|
+
| `questions` | `get(id)`, `list({...})`, `answer(id, text)` |
|
|
35
38
|
| `invoices` | `uploadFile({shipmentPackageId, file, ...})` (multipart), `sendLink({...})`, `deleteLink({...})` |
|
|
36
|
-
| `finance` | `getSettlements({...})`, `getOtherFinancials({...})` — both return typed `FinancialTransaction[]`
|
|
37
|
-
| `labels` | `createCommon(trackingNumber, {format: 'ZPL', ...})`, `getCommon(trackingNumber)`
|
|
39
|
+
| `finance` | `getSettlements({...})`, `getOtherFinancials({...})` — both return typed `FinancialTransaction[]` |
|
|
40
|
+
| `labels` | `createCommon(trackingNumber, {format: 'ZPL', ...})`, `getCommon(trackingNumber)` |
|
|
38
41
|
| `testOrders` | `create({...})`, `updateStatus(id, status)`, `setClaimsWaitingInAction()` — **STAGE-only utility** |
|
|
39
|
-
| `locations` | `getCountries()
|
|
42
|
+
| `locations` | `getCountries()`, `getTurkeyCities()`, `getTurkeyDistricts(cityCode)`, `getTurkeyNeighborhoods(cityCode, districtCode)`, `getAzerbaijanCities()`, `getAzerbaijanDistricts(...)`, `getCitiesByCountry/getDistrictsByCity(...)` |
|
|
40
43
|
| `exportCenter` | `listProducts({...})`, `createProducts(items)`, `updatePrices(items)`, `updateStocks(items)`, `getBatchStatus(batchId)`, `listPackagesV2/V3({...})`, `getPackageItems({packageId, ...})`, `getCategoryAttributes(id)`, `getCareInstructions()`, `getCompositions()`, `getOrigins()` — **Trendyol Export Center / İhracat Merkezi** |
|
|
41
44
|
| `videos` | `create({contentId, url, ...})`, `list({id?, sellerIntegrationStatus?, ...})` — product-page video upload + status |
|
|
42
45
|
| **top-level** | `parseWebhookEvent(rawBody)`, `normalizeShipmentPackage(rawNode)` — for inbound webhook handlers |
|
|
@@ -238,6 +241,7 @@ await client.suppliers.getAddresses({ forceRefresh: true });
|
|
|
238
241
|
|
|
239
242
|
// products — read
|
|
240
243
|
await client.products.list({ barcode: 'BC1' });
|
|
244
|
+
await client.products.listInventoryAndPrice({ status: 'onSale', limit: 100 }); // stock + price only
|
|
241
245
|
await client.products.listUnapproved({ limit: 50 });
|
|
242
246
|
await client.products.getBase('BC1');
|
|
243
247
|
await client.products.getBuyboxInfo(['BC1', 'BC2']); // max 10 per call
|
|
@@ -379,25 +383,6 @@ const status = await client.products.getBatchStatus(batchRequestId);
|
|
|
379
383
|
|
|
380
384
|
**Important:** Trendyol's overall batch `status` can lag at `PROCESSING` even after each `items[].status` has settled. Trust the per-item status, or re-read the affected products via `list({ barcode })` / `getBase(barcode)` to verify the change landed. Batch results are retained for **4 hours** on Trendyol's side.
|
|
381
385
|
|
|
382
|
-
## Discovery-first wire fixes
|
|
383
|
-
|
|
384
|
-
`@lonca/trendyol` was built by hitting the live Trendyol STAGE for every endpoint before writing types. Places where the official OpenAPI spec disagrees with the live wire are normalized automatically:
|
|
385
|
-
|
|
386
|
-
- `categories.getAttributeValues`: spec says `attributeValueName`, wire returns `attributeValue` → SDK normalizes to `{ id, name }`
|
|
387
|
-
- `products.listUnapproved`: spec says `media: [{url}]`, wire returns `images: [{url}]` → SDK exposes `images: string[]`
|
|
388
|
-
- `products.getBuyboxInfo`: wire returns extra `secondBuyboxPrice` / `thirdBuyboxPrice` fields beyond spec → both surfaced
|
|
389
|
-
- `products.updateUnapproved`: spec marks only `barcode` required, but live endpoint returns HTTP 500 (`TypeError`) when too many optional fields are omitted → documented in JSDoc
|
|
390
|
-
- `brands.search`: docs claim case-sensitive exact match, live is substring + case-insensitive → documented in JSDoc
|
|
391
|
-
- `getBatchRequestResult`: returns `PROCESSING + empty items` for unknown batch IDs (not 404)
|
|
392
|
-
- `orders.listStream` returns package ID as `id`, regular `orders.list` returns it as `shipmentPackageId` → normalizer accepts both
|
|
393
|
-
- `orders.updateLaborCosts`: body is a **raw array** (no `{ items: [...] }` envelope) — only endpoint in the surface that does this
|
|
394
|
-
- `getCompensationTickets`: spec says `{ data: { items: [] } }`, but SDK also accepts `{ data: [] }` and `{ content: [] }` defensively
|
|
395
|
-
- `labels.getCommon`: response is `{ data: [{ label, format }] }` → SDK surfaces `labels[]` for ergonomic access
|
|
396
|
-
- `finance.*`: both `getSettlements` and `getOtherFinancials` share the same `FinancialTransaction` wire schema → unified typed surface
|
|
397
|
-
- `webhooks.list`: SDK accepts 3 envelope shapes (`[]` raw, `{ webhooks: [] }`, `{ content: [] }`) and 3 active-flag spellings (`active`, `isActive`, `status: 'ACTIVE'`)
|
|
398
|
-
|
|
399
|
-
Each fix is pinned by a regression mock test using the exact STAGE shape.
|
|
400
|
-
|
|
401
386
|
## Authentication
|
|
402
387
|
|
|
403
388
|
Trendyol uses HTTP Basic Auth. Get your `sellerId`, `apiKey`, and `apiSecret` from the [Trendyol Partner Panel → Account Info → Integration Information](https://partner.trendyol.com/account/info?tab=integrationInformation) (master-user only).
|
|
@@ -413,7 +398,7 @@ Trendyol uses HTTP Basic Auth. Get your `sellerId`, `apiKey`, and `apiSecret` fr
|
|
|
413
398
|
|
|
414
399
|
## Built-in robustness
|
|
415
400
|
|
|
416
|
-
- **
|
|
401
|
+
- **Idempotency-aware retry with exponential backoff** — reads (`GET`) retry on 429 (honoring `Retry-After`), 5xx, and network/timeout errors. Writes (`POST`/`PUT`/`DELETE`) retry **only** on 429, which the server rejects before processing; ambiguous 5xx/network/timeout failures on a write are not replayed, so a transient error can't duplicate an order action or stock/price push. A `Retry-After: 0` no longer collapses backoff to an immediate retry.
|
|
417
402
|
- **Per-endpoint rate limiting** (token bucket) sized to Trendyol's documented limits — see defaults below; override per resource
|
|
418
403
|
- **Per-request correlation ID** — every call gets a UUID surfaced in log messages and the `x-correlationid` header for Trendyol-side log tracing
|
|
419
404
|
- **Structured errors** via `@lonca/core` (`AuthError`, `RateLimitError`, `NotFoundError`, `ServerError`, `ValidationError`, `NetworkError`, `TimeoutError`)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger, TokenBucketRateLimiter, CursorPaginationParams, CursorPage, OffsetPaginationParams } from '@lonca/core';
|
|
1
|
+
import { Logger, BaseRequestOptions, TokenBucketRateLimiter, CursorPaginationParams, CursorPage, OffsetPaginationParams } from '@lonca/core';
|
|
2
2
|
|
|
3
3
|
declare const BASE_URLS: {
|
|
4
4
|
readonly prod: "https://apigw.trendyol.com";
|
|
@@ -18,29 +18,22 @@ interface TransportConfig {
|
|
|
18
18
|
/** Override the underlying `fetch` (tests inject a mock). */
|
|
19
19
|
fetch?: typeof fetch;
|
|
20
20
|
}
|
|
21
|
-
interface RequestOptions {
|
|
21
|
+
interface RequestOptions extends BaseRequestOptions {
|
|
22
22
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
23
23
|
/** Path beginning with `/` (e.g., `/sapigw/brands`). */
|
|
24
24
|
path: string;
|
|
25
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
26
|
}
|
|
31
27
|
declare class TrendyolTransport {
|
|
32
28
|
private readonly config;
|
|
33
29
|
private readonly baseUrl;
|
|
34
|
-
private readonly
|
|
35
|
-
private readonly timeoutMs;
|
|
36
|
-
private readonly fetchImpl;
|
|
30
|
+
private readonly requester;
|
|
37
31
|
constructor(config: TransportConfig);
|
|
38
32
|
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
39
33
|
get sellerId(): number;
|
|
40
34
|
request<T>(opts: RequestOptions): Promise<T>;
|
|
41
35
|
private buildUrl;
|
|
42
36
|
private buildHeaders;
|
|
43
|
-
private composeSignal;
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
/**
|
|
@@ -84,7 +77,7 @@ declare class BrandsResource {
|
|
|
84
77
|
* `createProducts` and don't want to page through the full `list()`
|
|
85
78
|
* (1000 brands per page).
|
|
86
79
|
*
|
|
87
|
-
* **
|
|
80
|
+
* **Wire fact (verified STAGE 2026-05-25):** Trendyol's
|
|
88
81
|
* doc claims this is a case-sensitive *exact* match, but live behaviour
|
|
89
82
|
* is **substring + case-insensitive** — `search('Trendyol')` returns
|
|
90
83
|
* 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
|
|
@@ -937,6 +930,51 @@ interface UnapprovedProduct {
|
|
|
937
930
|
/** Untouched raw response. */
|
|
938
931
|
raw: Record<string, unknown>;
|
|
939
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* Listing-status filter accepted by `filterProducts` inventory-and-price.
|
|
935
|
+
*
|
|
936
|
+
* Trendyol documents `archived`, `blacklisted`, `locked`, `onSale`, and
|
|
937
|
+
* `notOnSale`. Open (`string & {}`) so a value Trendyol adds later still
|
|
938
|
+
* type-checks.
|
|
939
|
+
*/
|
|
940
|
+
type ApprovedProductStatus = 'archived' | 'blacklisted' | 'locked' | 'onSale' | 'notOnSale' | (string & {});
|
|
941
|
+
/**
|
|
942
|
+
* A single variant's stock + price, returned by
|
|
943
|
+
* `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
944
|
+
* `inventory-and-price` filter). Intentionally narrow: this endpoint returns
|
|
945
|
+
* only pricing + stock, not the full product/variant shape exposed by
|
|
946
|
+
* {@link ProductVariant}.
|
|
947
|
+
*/
|
|
948
|
+
interface ProductStockPriceVariant {
|
|
949
|
+
variantId: string;
|
|
950
|
+
barcode: string;
|
|
951
|
+
/** Sale price (price the customer pays). */
|
|
952
|
+
salePrice?: number;
|
|
953
|
+
/** List price (pre-discount reference price). */
|
|
954
|
+
listPrice?: number;
|
|
955
|
+
/** Stock quantity. */
|
|
956
|
+
quantity?: number;
|
|
957
|
+
stockCode?: string;
|
|
958
|
+
/**
|
|
959
|
+
* ISO 8601 UTC string (from `stockLastModifiedDate` ms-epoch). Absent when
|
|
960
|
+
* the variant's stock has never been updated (Trendyol returns `null`).
|
|
961
|
+
*/
|
|
962
|
+
stockLastModifiedAt?: string;
|
|
963
|
+
/** Untouched raw response. */
|
|
964
|
+
raw: Record<string, unknown>;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* An approved product's stock + price, returned by
|
|
968
|
+
* `products.listInventoryAndPrice`. Slimmer than {@link Product} — it carries
|
|
969
|
+
* only the identifiers and the per-variant stock/price.
|
|
970
|
+
*/
|
|
971
|
+
interface ProductStockPrice {
|
|
972
|
+
contentId: string;
|
|
973
|
+
productMainId: string;
|
|
974
|
+
variants: ProductStockPriceVariant[];
|
|
975
|
+
/** Untouched raw response. */
|
|
976
|
+
raw: Record<string, unknown>;
|
|
977
|
+
}
|
|
940
978
|
/**
|
|
941
979
|
* Basic lifecycle info for a single product, returned by `getProductBase`.
|
|
942
980
|
*
|
|
@@ -1541,13 +1579,19 @@ declare function normalizeShipmentPackage(rawNode: unknown): ShipmentPackage;
|
|
|
1541
1579
|
/**
|
|
1542
1580
|
* Trendyol order (shipment-package) endpoints.
|
|
1543
1581
|
*
|
|
1544
|
-
* Rate limit (per Trendyol service limits):
|
|
1545
|
-
*
|
|
1582
|
+
* Rate limit (per Trendyol service limits): tunable via the constructor with a
|
|
1583
|
+
* generous default.
|
|
1584
|
+
*
|
|
1585
|
+
* Pagination: `getShipmentPackages` (`list`) uses page-based pagination (not
|
|
1586
|
+
* nextPageToken). The SDK exposes `CursorPage<ShipmentPackage>` so the caller
|
|
1587
|
+
* can iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes
|
|
1588
|
+
* the page index.
|
|
1546
1589
|
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1590
|
+
* **2026-06-08 limit:** `getShipmentPackages` reaches at most 10,000 records —
|
|
1591
|
+
* requests past that offset return HTTP 429. For full scans, periodic syncs, or
|
|
1592
|
+
* exports use {@link OrdersResource.listStream} (`getShipmentPackagesStream`),
|
|
1593
|
+
* which paginates with an opaque cursor and is not subject to the cap. Note the
|
|
1594
|
+
* stream endpoint exposes only the last 3 months of orders.
|
|
1551
1595
|
*/
|
|
1552
1596
|
declare class OrdersResource {
|
|
1553
1597
|
private readonly transport;
|
|
@@ -1902,6 +1946,32 @@ interface ListProductsParams extends CursorPaginationParams {
|
|
|
1902
1946
|
/** Filter products updated on or before this date. */
|
|
1903
1947
|
endDate?: Date;
|
|
1904
1948
|
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Filters for `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
1951
|
+
* `inventory-and-price` approved-product filter). All filters are optional;
|
|
1952
|
+
* pass none to page through every approved product's stock + price.
|
|
1953
|
+
*/
|
|
1954
|
+
interface ListInventoryAndPriceParams extends CursorPaginationParams {
|
|
1955
|
+
/** Filter by a single barcode. */
|
|
1956
|
+
barcode?: string;
|
|
1957
|
+
/** Filter by a single contentId. */
|
|
1958
|
+
contentId?: string;
|
|
1959
|
+
/** Filter by the seller's stock code. */
|
|
1960
|
+
stockCode?: string;
|
|
1961
|
+
/** Filter by the seller's productMainId. */
|
|
1962
|
+
productMainId?: string;
|
|
1963
|
+
/** Filter by listing status (archived / blacklisted / locked / onSale / notOnSale). */
|
|
1964
|
+
status?: ApprovedProductStatus;
|
|
1965
|
+
/**
|
|
1966
|
+
* Sort by `SellerCreatedDate`. `ASC` = oldest→newest, `DESC` = newest→oldest.
|
|
1967
|
+
*/
|
|
1968
|
+
orderByDirection?: 'ASC' | 'DESC';
|
|
1969
|
+
/**
|
|
1970
|
+
* Storefront code sent as the `storeFrontCode` header. Required on the
|
|
1971
|
+
* International marketplace; optional on the Türkiye marketplace.
|
|
1972
|
+
*/
|
|
1973
|
+
storeFrontCode?: string;
|
|
1974
|
+
}
|
|
1905
1975
|
/** Date field to filter against on `listUnapproved` (default: server choice). */
|
|
1906
1976
|
type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
|
|
1907
1977
|
interface ListUnapprovedProductsParams extends CursorPaginationParams {
|
|
@@ -1962,6 +2032,35 @@ declare class ProductsResource {
|
|
|
1962
2032
|
* ```
|
|
1963
2033
|
*/
|
|
1964
2034
|
list(params?: ListProductsParams): Promise<CursorPage<Product>>;
|
|
2035
|
+
/**
|
|
2036
|
+
* List **stock and price** for approved products — Trendyol's lightweight
|
|
2037
|
+
* `inventory-and-price` filter. A slim alternative to {@link list} when you
|
|
2038
|
+
* only need pricing + stock: the response carries `contentId`,
|
|
2039
|
+
* `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
|
|
2040
|
+
* `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
|
|
2041
|
+
* else.
|
|
2042
|
+
*
|
|
2043
|
+
* Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
|
|
2044
|
+
* `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
|
|
2045
|
+
* at **100** here (tighter than `list`'s 1000).
|
|
2046
|
+
*
|
|
2047
|
+
* Pagination follows the same convention as {@link list}: pass our opaque
|
|
2048
|
+
* `cursor` from the previous response and we forward it as `nextPageToken`
|
|
2049
|
+
* (required once the dataset exceeds 10,000 items).
|
|
2050
|
+
*
|
|
2051
|
+
* @example
|
|
2052
|
+
* ```ts
|
|
2053
|
+
* import { paginate } from '@lonca/core';
|
|
2054
|
+
* for await (const p of paginate((q) =>
|
|
2055
|
+
* client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
|
|
2056
|
+
* )) {
|
|
2057
|
+
* for (const v of p.variants) {
|
|
2058
|
+
* console.log(v.barcode, v.quantity, v.salePrice);
|
|
2059
|
+
* }
|
|
2060
|
+
* }
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
listInventoryAndPrice(params?: ListInventoryAndPriceParams): Promise<CursorPage<ProductStockPrice>>;
|
|
1965
2064
|
/**
|
|
1966
2065
|
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
1967
2066
|
* `updatePriceAndInventory`).
|
|
@@ -2523,4 +2622,4 @@ interface TrendyolClient {
|
|
|
2523
2622
|
*/
|
|
2524
2623
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
2525
2624
|
|
|
2526
|
-
export { type
|
|
2625
|
+
export { type FinancialTransaction as $, type ApproveClaimLineItemsInput as A, type BarcodeCategoryLookup as B, type CancelPackageItemInput as C, type Country as D, type CreateClaimInput as E, type CreateClaimIssueInput as F, type CreateClaimItemInput as G, type CreateClientOptions as H, type CreateCommonLabelInput as I, type CreateProductV2Input as J, type CreateTestOrderInput as K, type CreateVideoInput as L, type DeleteInvoiceLinkInput as M, type DeliveryOptionInput as N, type District as O, type ExportBatchAcceptedResponse as P, type ExportBatchStatus as Q, type ExportCategoryAttribute as R, ExportCenterResource as S, type ExportPackage as T, type ExportPackageItem as U, type ExportPackageStatus as V, type ExportPriceUpdateInput as W, type ExportProduct as X, type ExportProductInput as Y, type ExportStockUpdateInput as Z, FinanceResource as _, type ApprovedProductStatus as a, type TestOrderStatus as a$, type GetExportPackageItemsParams as a0, InventoryResource as a1, InvoicesResource as a2, type KnownShipmentPackageStatus as a3, LabelsResource as a4, type LaborCostInput as a5, type ListCategoryAttributeValuesParams as a6, type ListClaimsParams as a7, type ListCompensationTicketsParams as a8, type ListExportPackagesV2Params as a9, type ProductAttribute as aA, type ProductAttributeV2Input as aB, type ProductBase as aC, type ProductComposition as aD, type ProductImageInput as aE, type ProductOrigin as aF, type ProductStockPrice as aG, type ProductStockPriceVariant as aH, type ProductVariant as aI, ProductsResource as aJ, type QuantitySplit as aK, type Question as aL, type QuestionAnswer as aM, type QuestionStatus as aN, QuestionsResource as aO, type SellerIntegrationStatus as aP, type SellerVideo as aQ, type SendInvoiceLinkInput as aR, type SettlementRow as aS, type ShipmentPackage as aT, type ShipmentPackageStatus as aU, type SplitGroup as aV, type SplitPackagePlan as aW, type SupplierAddress as aX, type SupplierAddressType as aY, SuppliersResource as aZ, type SuppliersResourceOptions as a_, type ListExportPackagesV3Params as aa, type ListExportProductsParams as ab, type ListFinanceParams as ac, type ListInventoryAndPriceParams as ad, type ListOrdersParams as ae, type ListOrdersStreamParams as af, type ListProductsParams as ag, type ListQuestionsParams as ah, type ListUnapprovedProductsParams as ai, type ListVideosParams as aj, LocationsResource as ak, type NamedRef as al, type Neighborhood as am, type OrderAddress as an, type OrderAddressLines as ao, type OrderCustomer as ap, type OrderLine as aq, type OrderLineDiscountDetail as ar, OrdersResource as as, type OtherFinancialRow as at, type PackageDetail as au, type PackageHistoryEntry as av, type PackageLineUpdate as aw, type PriceInventoryUpdate as ax, type ProcessAlternativeDeliveryInput as ay, type Product as az, type BatchAcceptedResponse as b, TestOrdersResource as b0, type TrendyolCapabilities as b1, type TrendyolCargoProvider as b2, type TrendyolClient as b3, type TrendyolEnvironment as b4, type UnapprovedDateQueryType as b5, type UnapprovedProduct as b6, type UnapprovedProductRejectReason as b7, type UnapprovedProductStatus as b8, type UpdateBoxInfoInput as b9, type UpdateContentInput as ba, type UpdateDeliveryInfoInput as bb, type UpdatePackageStatusInput as bc, type UpdatePriceInventoryResponse as bd, type UpdateUnapprovedInput as be, type UpdateVariantInput as bf, type UploadInvoiceFileInput as bg, VideosResource as bh, type Webhook as bi, type WebhookAuthenticationType as bj, type WebhookInput as bk, WebhooksResource as bl, createTrendyolClient as bm, normalizeShipmentPackage as bn, pollBatchStatus as bo, trendyolCapabilities as bp, type BatchPollOptions as c, type BatchRequestItemResult as d, type BatchRequestResult as e, type BatchRequestStatus as f, type Brand as g, BrandsResource as h, type BuyboxInfo as i, type CareInstruction as j, type CargoInvoiceItem as k, CategoriesResource as l, type Category as m, type CategoryAttribute as n, type CategoryAttributeValue as o, type City as p, type Claim as q, type ClaimIssueReason as r, type ClaimItemAudit as s, type ClaimItemStatus as t, ClaimsResource as u, type CommonLabel as v, type CommonLabelEntry as w, type CompensationItemDetail as x, type CompensationTicket as y, type CompensationTicketState as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger, TokenBucketRateLimiter, CursorPaginationParams, CursorPage, OffsetPaginationParams } from '@lonca/core';
|
|
1
|
+
import { Logger, BaseRequestOptions, TokenBucketRateLimiter, CursorPaginationParams, CursorPage, OffsetPaginationParams } from '@lonca/core';
|
|
2
2
|
|
|
3
3
|
declare const BASE_URLS: {
|
|
4
4
|
readonly prod: "https://apigw.trendyol.com";
|
|
@@ -18,29 +18,22 @@ interface TransportConfig {
|
|
|
18
18
|
/** Override the underlying `fetch` (tests inject a mock). */
|
|
19
19
|
fetch?: typeof fetch;
|
|
20
20
|
}
|
|
21
|
-
interface RequestOptions {
|
|
21
|
+
interface RequestOptions extends BaseRequestOptions {
|
|
22
22
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
23
23
|
/** Path beginning with `/` (e.g., `/sapigw/brands`). */
|
|
24
24
|
path: string;
|
|
25
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
26
|
}
|
|
31
27
|
declare class TrendyolTransport {
|
|
32
28
|
private readonly config;
|
|
33
29
|
private readonly baseUrl;
|
|
34
|
-
private readonly
|
|
35
|
-
private readonly timeoutMs;
|
|
36
|
-
private readonly fetchImpl;
|
|
30
|
+
private readonly requester;
|
|
37
31
|
constructor(config: TransportConfig);
|
|
38
32
|
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
39
33
|
get sellerId(): number;
|
|
40
34
|
request<T>(opts: RequestOptions): Promise<T>;
|
|
41
35
|
private buildUrl;
|
|
42
36
|
private buildHeaders;
|
|
43
|
-
private composeSignal;
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
/**
|
|
@@ -84,7 +77,7 @@ declare class BrandsResource {
|
|
|
84
77
|
* `createProducts` and don't want to page through the full `list()`
|
|
85
78
|
* (1000 brands per page).
|
|
86
79
|
*
|
|
87
|
-
* **
|
|
80
|
+
* **Wire fact (verified STAGE 2026-05-25):** Trendyol's
|
|
88
81
|
* doc claims this is a case-sensitive *exact* match, but live behaviour
|
|
89
82
|
* is **substring + case-insensitive** — `search('Trendyol')` returns
|
|
90
83
|
* 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
|
|
@@ -937,6 +930,51 @@ interface UnapprovedProduct {
|
|
|
937
930
|
/** Untouched raw response. */
|
|
938
931
|
raw: Record<string, unknown>;
|
|
939
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* Listing-status filter accepted by `filterProducts` inventory-and-price.
|
|
935
|
+
*
|
|
936
|
+
* Trendyol documents `archived`, `blacklisted`, `locked`, `onSale`, and
|
|
937
|
+
* `notOnSale`. Open (`string & {}`) so a value Trendyol adds later still
|
|
938
|
+
* type-checks.
|
|
939
|
+
*/
|
|
940
|
+
type ApprovedProductStatus = 'archived' | 'blacklisted' | 'locked' | 'onSale' | 'notOnSale' | (string & {});
|
|
941
|
+
/**
|
|
942
|
+
* A single variant's stock + price, returned by
|
|
943
|
+
* `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
944
|
+
* `inventory-and-price` filter). Intentionally narrow: this endpoint returns
|
|
945
|
+
* only pricing + stock, not the full product/variant shape exposed by
|
|
946
|
+
* {@link ProductVariant}.
|
|
947
|
+
*/
|
|
948
|
+
interface ProductStockPriceVariant {
|
|
949
|
+
variantId: string;
|
|
950
|
+
barcode: string;
|
|
951
|
+
/** Sale price (price the customer pays). */
|
|
952
|
+
salePrice?: number;
|
|
953
|
+
/** List price (pre-discount reference price). */
|
|
954
|
+
listPrice?: number;
|
|
955
|
+
/** Stock quantity. */
|
|
956
|
+
quantity?: number;
|
|
957
|
+
stockCode?: string;
|
|
958
|
+
/**
|
|
959
|
+
* ISO 8601 UTC string (from `stockLastModifiedDate` ms-epoch). Absent when
|
|
960
|
+
* the variant's stock has never been updated (Trendyol returns `null`).
|
|
961
|
+
*/
|
|
962
|
+
stockLastModifiedAt?: string;
|
|
963
|
+
/** Untouched raw response. */
|
|
964
|
+
raw: Record<string, unknown>;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* An approved product's stock + price, returned by
|
|
968
|
+
* `products.listInventoryAndPrice`. Slimmer than {@link Product} — it carries
|
|
969
|
+
* only the identifiers and the per-variant stock/price.
|
|
970
|
+
*/
|
|
971
|
+
interface ProductStockPrice {
|
|
972
|
+
contentId: string;
|
|
973
|
+
productMainId: string;
|
|
974
|
+
variants: ProductStockPriceVariant[];
|
|
975
|
+
/** Untouched raw response. */
|
|
976
|
+
raw: Record<string, unknown>;
|
|
977
|
+
}
|
|
940
978
|
/**
|
|
941
979
|
* Basic lifecycle info for a single product, returned by `getProductBase`.
|
|
942
980
|
*
|
|
@@ -1541,13 +1579,19 @@ declare function normalizeShipmentPackage(rawNode: unknown): ShipmentPackage;
|
|
|
1541
1579
|
/**
|
|
1542
1580
|
* Trendyol order (shipment-package) endpoints.
|
|
1543
1581
|
*
|
|
1544
|
-
* Rate limit (per Trendyol service limits):
|
|
1545
|
-
*
|
|
1582
|
+
* Rate limit (per Trendyol service limits): tunable via the constructor with a
|
|
1583
|
+
* generous default.
|
|
1584
|
+
*
|
|
1585
|
+
* Pagination: `getShipmentPackages` (`list`) uses page-based pagination (not
|
|
1586
|
+
* nextPageToken). The SDK exposes `CursorPage<ShipmentPackage>` so the caller
|
|
1587
|
+
* can iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes
|
|
1588
|
+
* the page index.
|
|
1546
1589
|
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1590
|
+
* **2026-06-08 limit:** `getShipmentPackages` reaches at most 10,000 records —
|
|
1591
|
+
* requests past that offset return HTTP 429. For full scans, periodic syncs, or
|
|
1592
|
+
* exports use {@link OrdersResource.listStream} (`getShipmentPackagesStream`),
|
|
1593
|
+
* which paginates with an opaque cursor and is not subject to the cap. Note the
|
|
1594
|
+
* stream endpoint exposes only the last 3 months of orders.
|
|
1551
1595
|
*/
|
|
1552
1596
|
declare class OrdersResource {
|
|
1553
1597
|
private readonly transport;
|
|
@@ -1902,6 +1946,32 @@ interface ListProductsParams extends CursorPaginationParams {
|
|
|
1902
1946
|
/** Filter products updated on or before this date. */
|
|
1903
1947
|
endDate?: Date;
|
|
1904
1948
|
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Filters for `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
1951
|
+
* `inventory-and-price` approved-product filter). All filters are optional;
|
|
1952
|
+
* pass none to page through every approved product's stock + price.
|
|
1953
|
+
*/
|
|
1954
|
+
interface ListInventoryAndPriceParams extends CursorPaginationParams {
|
|
1955
|
+
/** Filter by a single barcode. */
|
|
1956
|
+
barcode?: string;
|
|
1957
|
+
/** Filter by a single contentId. */
|
|
1958
|
+
contentId?: string;
|
|
1959
|
+
/** Filter by the seller's stock code. */
|
|
1960
|
+
stockCode?: string;
|
|
1961
|
+
/** Filter by the seller's productMainId. */
|
|
1962
|
+
productMainId?: string;
|
|
1963
|
+
/** Filter by listing status (archived / blacklisted / locked / onSale / notOnSale). */
|
|
1964
|
+
status?: ApprovedProductStatus;
|
|
1965
|
+
/**
|
|
1966
|
+
* Sort by `SellerCreatedDate`. `ASC` = oldest→newest, `DESC` = newest→oldest.
|
|
1967
|
+
*/
|
|
1968
|
+
orderByDirection?: 'ASC' | 'DESC';
|
|
1969
|
+
/**
|
|
1970
|
+
* Storefront code sent as the `storeFrontCode` header. Required on the
|
|
1971
|
+
* International marketplace; optional on the Türkiye marketplace.
|
|
1972
|
+
*/
|
|
1973
|
+
storeFrontCode?: string;
|
|
1974
|
+
}
|
|
1905
1975
|
/** Date field to filter against on `listUnapproved` (default: server choice). */
|
|
1906
1976
|
type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
|
|
1907
1977
|
interface ListUnapprovedProductsParams extends CursorPaginationParams {
|
|
@@ -1962,6 +2032,35 @@ declare class ProductsResource {
|
|
|
1962
2032
|
* ```
|
|
1963
2033
|
*/
|
|
1964
2034
|
list(params?: ListProductsParams): Promise<CursorPage<Product>>;
|
|
2035
|
+
/**
|
|
2036
|
+
* List **stock and price** for approved products — Trendyol's lightweight
|
|
2037
|
+
* `inventory-and-price` filter. A slim alternative to {@link list} when you
|
|
2038
|
+
* only need pricing + stock: the response carries `contentId`,
|
|
2039
|
+
* `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
|
|
2040
|
+
* `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
|
|
2041
|
+
* else.
|
|
2042
|
+
*
|
|
2043
|
+
* Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
|
|
2044
|
+
* `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
|
|
2045
|
+
* at **100** here (tighter than `list`'s 1000).
|
|
2046
|
+
*
|
|
2047
|
+
* Pagination follows the same convention as {@link list}: pass our opaque
|
|
2048
|
+
* `cursor` from the previous response and we forward it as `nextPageToken`
|
|
2049
|
+
* (required once the dataset exceeds 10,000 items).
|
|
2050
|
+
*
|
|
2051
|
+
* @example
|
|
2052
|
+
* ```ts
|
|
2053
|
+
* import { paginate } from '@lonca/core';
|
|
2054
|
+
* for await (const p of paginate((q) =>
|
|
2055
|
+
* client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
|
|
2056
|
+
* )) {
|
|
2057
|
+
* for (const v of p.variants) {
|
|
2058
|
+
* console.log(v.barcode, v.quantity, v.salePrice);
|
|
2059
|
+
* }
|
|
2060
|
+
* }
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
listInventoryAndPrice(params?: ListInventoryAndPriceParams): Promise<CursorPage<ProductStockPrice>>;
|
|
1965
2064
|
/**
|
|
1966
2065
|
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
1967
2066
|
* `updatePriceAndInventory`).
|
|
@@ -2523,4 +2622,4 @@ interface TrendyolClient {
|
|
|
2523
2622
|
*/
|
|
2524
2623
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
2525
2624
|
|
|
2526
|
-
export { type
|
|
2625
|
+
export { type FinancialTransaction as $, type ApproveClaimLineItemsInput as A, type BarcodeCategoryLookup as B, type CancelPackageItemInput as C, type Country as D, type CreateClaimInput as E, type CreateClaimIssueInput as F, type CreateClaimItemInput as G, type CreateClientOptions as H, type CreateCommonLabelInput as I, type CreateProductV2Input as J, type CreateTestOrderInput as K, type CreateVideoInput as L, type DeleteInvoiceLinkInput as M, type DeliveryOptionInput as N, type District as O, type ExportBatchAcceptedResponse as P, type ExportBatchStatus as Q, type ExportCategoryAttribute as R, ExportCenterResource as S, type ExportPackage as T, type ExportPackageItem as U, type ExportPackageStatus as V, type ExportPriceUpdateInput as W, type ExportProduct as X, type ExportProductInput as Y, type ExportStockUpdateInput as Z, FinanceResource as _, type ApprovedProductStatus as a, type TestOrderStatus as a$, type GetExportPackageItemsParams as a0, InventoryResource as a1, InvoicesResource as a2, type KnownShipmentPackageStatus as a3, LabelsResource as a4, type LaborCostInput as a5, type ListCategoryAttributeValuesParams as a6, type ListClaimsParams as a7, type ListCompensationTicketsParams as a8, type ListExportPackagesV2Params as a9, type ProductAttribute as aA, type ProductAttributeV2Input as aB, type ProductBase as aC, type ProductComposition as aD, type ProductImageInput as aE, type ProductOrigin as aF, type ProductStockPrice as aG, type ProductStockPriceVariant as aH, type ProductVariant as aI, ProductsResource as aJ, type QuantitySplit as aK, type Question as aL, type QuestionAnswer as aM, type QuestionStatus as aN, QuestionsResource as aO, type SellerIntegrationStatus as aP, type SellerVideo as aQ, type SendInvoiceLinkInput as aR, type SettlementRow as aS, type ShipmentPackage as aT, type ShipmentPackageStatus as aU, type SplitGroup as aV, type SplitPackagePlan as aW, type SupplierAddress as aX, type SupplierAddressType as aY, SuppliersResource as aZ, type SuppliersResourceOptions as a_, type ListExportPackagesV3Params as aa, type ListExportProductsParams as ab, type ListFinanceParams as ac, type ListInventoryAndPriceParams as ad, type ListOrdersParams as ae, type ListOrdersStreamParams as af, type ListProductsParams as ag, type ListQuestionsParams as ah, type ListUnapprovedProductsParams as ai, type ListVideosParams as aj, LocationsResource as ak, type NamedRef as al, type Neighborhood as am, type OrderAddress as an, type OrderAddressLines as ao, type OrderCustomer as ap, type OrderLine as aq, type OrderLineDiscountDetail as ar, OrdersResource as as, type OtherFinancialRow as at, type PackageDetail as au, type PackageHistoryEntry as av, type PackageLineUpdate as aw, type PriceInventoryUpdate as ax, type ProcessAlternativeDeliveryInput as ay, type Product as az, type BatchAcceptedResponse as b, TestOrdersResource as b0, type TrendyolCapabilities as b1, type TrendyolCargoProvider as b2, type TrendyolClient as b3, type TrendyolEnvironment as b4, type UnapprovedDateQueryType as b5, type UnapprovedProduct as b6, type UnapprovedProductRejectReason as b7, type UnapprovedProductStatus as b8, type UpdateBoxInfoInput as b9, type UpdateContentInput as ba, type UpdateDeliveryInfoInput as bb, type UpdatePackageStatusInput as bc, type UpdatePriceInventoryResponse as bd, type UpdateUnapprovedInput as be, type UpdateVariantInput as bf, type UploadInvoiceFileInput as bg, VideosResource as bh, type Webhook as bi, type WebhookAuthenticationType as bj, type WebhookInput as bk, WebhooksResource as bl, createTrendyolClient as bm, normalizeShipmentPackage as bn, pollBatchStatus as bo, trendyolCapabilities as bp, type BatchPollOptions as c, type BatchRequestItemResult as d, type BatchRequestResult as e, type BatchRequestStatus as f, type Brand as g, BrandsResource as h, type BuyboxInfo as i, type CareInstruction as j, type CargoInvoiceItem as k, CategoriesResource as l, type Category as m, type CategoryAttribute as n, type CategoryAttributeValue as o, type City as p, type Claim as q, type ClaimIssueReason as r, type ClaimItemAudit as s, type ClaimItemStatus as t, ClaimsResource as u, type CommonLabel as v, type CommonLabelEntry as w, type CompensationItemDetail as x, type CompensationTicket as y, type CompensationTicketState as z };
|