@lonca/trendyol 0.10.0 → 0.11.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/{client-0omWgpd_.d.cts → client-BZeFAlrp.d.cts} +118 -7
- package/dist/{client-0omWgpd_.d.ts → client-BZeFAlrp.d.ts} +118 -7
- package/dist/index.cjs +89 -1
- 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 +89 -1
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +89 -1
- 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 +89 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,11 @@ interface RequestOptions {
|
|
|
25
25
|
query?: Record<string, string | number | boolean | undefined>;
|
|
26
26
|
body?: unknown;
|
|
27
27
|
signal?: AbortSignal;
|
|
28
|
+
/**
|
|
29
|
+
* Extra per-request headers merged over the default header set (caller
|
|
30
|
+
* headers win). Used for endpoint-specific headers like `storeFrontCode`.
|
|
31
|
+
*/
|
|
32
|
+
headers?: Record<string, string>;
|
|
28
33
|
/** Per-endpoint rate limiter; acquire one token before each attempt. */
|
|
29
34
|
rateLimiter?: TokenBucketRateLimiter;
|
|
30
35
|
}
|
|
@@ -937,6 +942,51 @@ interface UnapprovedProduct {
|
|
|
937
942
|
/** Untouched raw response. */
|
|
938
943
|
raw: Record<string, unknown>;
|
|
939
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Listing-status filter accepted by `filterProducts` inventory-and-price.
|
|
947
|
+
*
|
|
948
|
+
* Trendyol documents `archived`, `blacklisted`, `locked`, `onSale`, and
|
|
949
|
+
* `notOnSale`. Open (`string & {}`) so a value Trendyol adds later still
|
|
950
|
+
* type-checks.
|
|
951
|
+
*/
|
|
952
|
+
type ApprovedProductStatus = 'archived' | 'blacklisted' | 'locked' | 'onSale' | 'notOnSale' | (string & {});
|
|
953
|
+
/**
|
|
954
|
+
* A single variant's stock + price, returned by
|
|
955
|
+
* `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
956
|
+
* `inventory-and-price` filter). Intentionally narrow: this endpoint returns
|
|
957
|
+
* only pricing + stock, not the full product/variant shape exposed by
|
|
958
|
+
* {@link ProductVariant}.
|
|
959
|
+
*/
|
|
960
|
+
interface ProductStockPriceVariant {
|
|
961
|
+
variantId: string;
|
|
962
|
+
barcode: string;
|
|
963
|
+
/** Sale price (price the customer pays). */
|
|
964
|
+
salePrice?: number;
|
|
965
|
+
/** List price (pre-discount reference price). */
|
|
966
|
+
listPrice?: number;
|
|
967
|
+
/** Stock quantity. */
|
|
968
|
+
quantity?: number;
|
|
969
|
+
stockCode?: string;
|
|
970
|
+
/**
|
|
971
|
+
* ISO 8601 UTC string (from `stockLastModifiedDate` ms-epoch). Absent when
|
|
972
|
+
* the variant's stock has never been updated (Trendyol returns `null`).
|
|
973
|
+
*/
|
|
974
|
+
stockLastModifiedAt?: string;
|
|
975
|
+
/** Untouched raw response. */
|
|
976
|
+
raw: Record<string, unknown>;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* An approved product's stock + price, returned by
|
|
980
|
+
* `products.listInventoryAndPrice`. Slimmer than {@link Product} — it carries
|
|
981
|
+
* only the identifiers and the per-variant stock/price.
|
|
982
|
+
*/
|
|
983
|
+
interface ProductStockPrice {
|
|
984
|
+
contentId: string;
|
|
985
|
+
productMainId: string;
|
|
986
|
+
variants: ProductStockPriceVariant[];
|
|
987
|
+
/** Untouched raw response. */
|
|
988
|
+
raw: Record<string, unknown>;
|
|
989
|
+
}
|
|
940
990
|
/**
|
|
941
991
|
* Basic lifecycle info for a single product, returned by `getProductBase`.
|
|
942
992
|
*
|
|
@@ -1541,13 +1591,19 @@ declare function normalizeShipmentPackage(rawNode: unknown): ShipmentPackage;
|
|
|
1541
1591
|
/**
|
|
1542
1592
|
* Trendyol order (shipment-package) endpoints.
|
|
1543
1593
|
*
|
|
1544
|
-
* Rate limit (per Trendyol service limits):
|
|
1545
|
-
*
|
|
1594
|
+
* Rate limit (per Trendyol service limits): tunable via the constructor with a
|
|
1595
|
+
* generous default.
|
|
1596
|
+
*
|
|
1597
|
+
* Pagination: `getShipmentPackages` (`list`) uses page-based pagination (not
|
|
1598
|
+
* nextPageToken). The SDK exposes `CursorPage<ShipmentPackage>` so the caller
|
|
1599
|
+
* can iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes
|
|
1600
|
+
* the page index.
|
|
1546
1601
|
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1602
|
+
* **2026-06-08 limit:** `getShipmentPackages` reaches at most 10,000 records —
|
|
1603
|
+
* requests past that offset return HTTP 429. For full scans, periodic syncs, or
|
|
1604
|
+
* exports use {@link OrdersResource.listStream} (`getShipmentPackagesStream`),
|
|
1605
|
+
* which paginates with an opaque cursor and is not subject to the cap. Note the
|
|
1606
|
+
* stream endpoint exposes only the last 3 months of orders.
|
|
1551
1607
|
*/
|
|
1552
1608
|
declare class OrdersResource {
|
|
1553
1609
|
private readonly transport;
|
|
@@ -1902,6 +1958,32 @@ interface ListProductsParams extends CursorPaginationParams {
|
|
|
1902
1958
|
/** Filter products updated on or before this date. */
|
|
1903
1959
|
endDate?: Date;
|
|
1904
1960
|
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Filters for `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
1963
|
+
* `inventory-and-price` approved-product filter). All filters are optional;
|
|
1964
|
+
* pass none to page through every approved product's stock + price.
|
|
1965
|
+
*/
|
|
1966
|
+
interface ListInventoryAndPriceParams extends CursorPaginationParams {
|
|
1967
|
+
/** Filter by a single barcode. */
|
|
1968
|
+
barcode?: string;
|
|
1969
|
+
/** Filter by a single contentId. */
|
|
1970
|
+
contentId?: string;
|
|
1971
|
+
/** Filter by the seller's stock code. */
|
|
1972
|
+
stockCode?: string;
|
|
1973
|
+
/** Filter by the seller's productMainId. */
|
|
1974
|
+
productMainId?: string;
|
|
1975
|
+
/** Filter by listing status (archived / blacklisted / locked / onSale / notOnSale). */
|
|
1976
|
+
status?: ApprovedProductStatus;
|
|
1977
|
+
/**
|
|
1978
|
+
* Sort by `SellerCreatedDate`. `ASC` = oldest→newest, `DESC` = newest→oldest.
|
|
1979
|
+
*/
|
|
1980
|
+
orderByDirection?: 'ASC' | 'DESC';
|
|
1981
|
+
/**
|
|
1982
|
+
* Storefront code sent as the `storeFrontCode` header. Required on the
|
|
1983
|
+
* International marketplace; optional on the Türkiye marketplace.
|
|
1984
|
+
*/
|
|
1985
|
+
storeFrontCode?: string;
|
|
1986
|
+
}
|
|
1905
1987
|
/** Date field to filter against on `listUnapproved` (default: server choice). */
|
|
1906
1988
|
type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
|
|
1907
1989
|
interface ListUnapprovedProductsParams extends CursorPaginationParams {
|
|
@@ -1962,6 +2044,35 @@ declare class ProductsResource {
|
|
|
1962
2044
|
* ```
|
|
1963
2045
|
*/
|
|
1964
2046
|
list(params?: ListProductsParams): Promise<CursorPage<Product>>;
|
|
2047
|
+
/**
|
|
2048
|
+
* List **stock and price** for approved products — Trendyol's lightweight
|
|
2049
|
+
* `inventory-and-price` filter. A slim alternative to {@link list} when you
|
|
2050
|
+
* only need pricing + stock: the response carries `contentId`,
|
|
2051
|
+
* `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
|
|
2052
|
+
* `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
|
|
2053
|
+
* else.
|
|
2054
|
+
*
|
|
2055
|
+
* Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
|
|
2056
|
+
* `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
|
|
2057
|
+
* at **100** here (tighter than `list`'s 1000).
|
|
2058
|
+
*
|
|
2059
|
+
* Pagination follows the same convention as {@link list}: pass our opaque
|
|
2060
|
+
* `cursor` from the previous response and we forward it as `nextPageToken`
|
|
2061
|
+
* (required once the dataset exceeds 10,000 items).
|
|
2062
|
+
*
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```ts
|
|
2065
|
+
* import { paginate } from '@lonca/core';
|
|
2066
|
+
* for await (const p of paginate((q) =>
|
|
2067
|
+
* client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
|
|
2068
|
+
* )) {
|
|
2069
|
+
* for (const v of p.variants) {
|
|
2070
|
+
* console.log(v.barcode, v.quantity, v.salePrice);
|
|
2071
|
+
* }
|
|
2072
|
+
* }
|
|
2073
|
+
* ```
|
|
2074
|
+
*/
|
|
2075
|
+
listInventoryAndPrice(params?: ListInventoryAndPriceParams): Promise<CursorPage<ProductStockPrice>>;
|
|
1965
2076
|
/**
|
|
1966
2077
|
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
1967
2078
|
* `updatePriceAndInventory`).
|
|
@@ -2523,4 +2634,4 @@ interface TrendyolClient {
|
|
|
2523
2634
|
*/
|
|
2524
2635
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
2525
2636
|
|
|
2526
|
-
export { type
|
|
2637
|
+
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 };
|
|
@@ -25,6 +25,11 @@ interface RequestOptions {
|
|
|
25
25
|
query?: Record<string, string | number | boolean | undefined>;
|
|
26
26
|
body?: unknown;
|
|
27
27
|
signal?: AbortSignal;
|
|
28
|
+
/**
|
|
29
|
+
* Extra per-request headers merged over the default header set (caller
|
|
30
|
+
* headers win). Used for endpoint-specific headers like `storeFrontCode`.
|
|
31
|
+
*/
|
|
32
|
+
headers?: Record<string, string>;
|
|
28
33
|
/** Per-endpoint rate limiter; acquire one token before each attempt. */
|
|
29
34
|
rateLimiter?: TokenBucketRateLimiter;
|
|
30
35
|
}
|
|
@@ -937,6 +942,51 @@ interface UnapprovedProduct {
|
|
|
937
942
|
/** Untouched raw response. */
|
|
938
943
|
raw: Record<string, unknown>;
|
|
939
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Listing-status filter accepted by `filterProducts` inventory-and-price.
|
|
947
|
+
*
|
|
948
|
+
* Trendyol documents `archived`, `blacklisted`, `locked`, `onSale`, and
|
|
949
|
+
* `notOnSale`. Open (`string & {}`) so a value Trendyol adds later still
|
|
950
|
+
* type-checks.
|
|
951
|
+
*/
|
|
952
|
+
type ApprovedProductStatus = 'archived' | 'blacklisted' | 'locked' | 'onSale' | 'notOnSale' | (string & {});
|
|
953
|
+
/**
|
|
954
|
+
* A single variant's stock + price, returned by
|
|
955
|
+
* `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
956
|
+
* `inventory-and-price` filter). Intentionally narrow: this endpoint returns
|
|
957
|
+
* only pricing + stock, not the full product/variant shape exposed by
|
|
958
|
+
* {@link ProductVariant}.
|
|
959
|
+
*/
|
|
960
|
+
interface ProductStockPriceVariant {
|
|
961
|
+
variantId: string;
|
|
962
|
+
barcode: string;
|
|
963
|
+
/** Sale price (price the customer pays). */
|
|
964
|
+
salePrice?: number;
|
|
965
|
+
/** List price (pre-discount reference price). */
|
|
966
|
+
listPrice?: number;
|
|
967
|
+
/** Stock quantity. */
|
|
968
|
+
quantity?: number;
|
|
969
|
+
stockCode?: string;
|
|
970
|
+
/**
|
|
971
|
+
* ISO 8601 UTC string (from `stockLastModifiedDate` ms-epoch). Absent when
|
|
972
|
+
* the variant's stock has never been updated (Trendyol returns `null`).
|
|
973
|
+
*/
|
|
974
|
+
stockLastModifiedAt?: string;
|
|
975
|
+
/** Untouched raw response. */
|
|
976
|
+
raw: Record<string, unknown>;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* An approved product's stock + price, returned by
|
|
980
|
+
* `products.listInventoryAndPrice`. Slimmer than {@link Product} — it carries
|
|
981
|
+
* only the identifiers and the per-variant stock/price.
|
|
982
|
+
*/
|
|
983
|
+
interface ProductStockPrice {
|
|
984
|
+
contentId: string;
|
|
985
|
+
productMainId: string;
|
|
986
|
+
variants: ProductStockPriceVariant[];
|
|
987
|
+
/** Untouched raw response. */
|
|
988
|
+
raw: Record<string, unknown>;
|
|
989
|
+
}
|
|
940
990
|
/**
|
|
941
991
|
* Basic lifecycle info for a single product, returned by `getProductBase`.
|
|
942
992
|
*
|
|
@@ -1541,13 +1591,19 @@ declare function normalizeShipmentPackage(rawNode: unknown): ShipmentPackage;
|
|
|
1541
1591
|
/**
|
|
1542
1592
|
* Trendyol order (shipment-package) endpoints.
|
|
1543
1593
|
*
|
|
1544
|
-
* Rate limit (per Trendyol service limits):
|
|
1545
|
-
*
|
|
1594
|
+
* Rate limit (per Trendyol service limits): tunable via the constructor with a
|
|
1595
|
+
* generous default.
|
|
1596
|
+
*
|
|
1597
|
+
* Pagination: `getShipmentPackages` (`list`) uses page-based pagination (not
|
|
1598
|
+
* nextPageToken). The SDK exposes `CursorPage<ShipmentPackage>` so the caller
|
|
1599
|
+
* can iterate with `paginate()` from `@lonca/core`; the opaque cursor encodes
|
|
1600
|
+
* the page index.
|
|
1546
1601
|
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1602
|
+
* **2026-06-08 limit:** `getShipmentPackages` reaches at most 10,000 records —
|
|
1603
|
+
* requests past that offset return HTTP 429. For full scans, periodic syncs, or
|
|
1604
|
+
* exports use {@link OrdersResource.listStream} (`getShipmentPackagesStream`),
|
|
1605
|
+
* which paginates with an opaque cursor and is not subject to the cap. Note the
|
|
1606
|
+
* stream endpoint exposes only the last 3 months of orders.
|
|
1551
1607
|
*/
|
|
1552
1608
|
declare class OrdersResource {
|
|
1553
1609
|
private readonly transport;
|
|
@@ -1902,6 +1958,32 @@ interface ListProductsParams extends CursorPaginationParams {
|
|
|
1902
1958
|
/** Filter products updated on or before this date. */
|
|
1903
1959
|
endDate?: Date;
|
|
1904
1960
|
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Filters for `products.listInventoryAndPrice` (Trendyol's lightweight
|
|
1963
|
+
* `inventory-and-price` approved-product filter). All filters are optional;
|
|
1964
|
+
* pass none to page through every approved product's stock + price.
|
|
1965
|
+
*/
|
|
1966
|
+
interface ListInventoryAndPriceParams extends CursorPaginationParams {
|
|
1967
|
+
/** Filter by a single barcode. */
|
|
1968
|
+
barcode?: string;
|
|
1969
|
+
/** Filter by a single contentId. */
|
|
1970
|
+
contentId?: string;
|
|
1971
|
+
/** Filter by the seller's stock code. */
|
|
1972
|
+
stockCode?: string;
|
|
1973
|
+
/** Filter by the seller's productMainId. */
|
|
1974
|
+
productMainId?: string;
|
|
1975
|
+
/** Filter by listing status (archived / blacklisted / locked / onSale / notOnSale). */
|
|
1976
|
+
status?: ApprovedProductStatus;
|
|
1977
|
+
/**
|
|
1978
|
+
* Sort by `SellerCreatedDate`. `ASC` = oldest→newest, `DESC` = newest→oldest.
|
|
1979
|
+
*/
|
|
1980
|
+
orderByDirection?: 'ASC' | 'DESC';
|
|
1981
|
+
/**
|
|
1982
|
+
* Storefront code sent as the `storeFrontCode` header. Required on the
|
|
1983
|
+
* International marketplace; optional on the Türkiye marketplace.
|
|
1984
|
+
*/
|
|
1985
|
+
storeFrontCode?: string;
|
|
1986
|
+
}
|
|
1905
1987
|
/** Date field to filter against on `listUnapproved` (default: server choice). */
|
|
1906
1988
|
type UnapprovedDateQueryType = 'CREATED_DATE' | 'LAST_MODIFIED_DATE';
|
|
1907
1989
|
interface ListUnapprovedProductsParams extends CursorPaginationParams {
|
|
@@ -1962,6 +2044,35 @@ declare class ProductsResource {
|
|
|
1962
2044
|
* ```
|
|
1963
2045
|
*/
|
|
1964
2046
|
list(params?: ListProductsParams): Promise<CursorPage<Product>>;
|
|
2047
|
+
/**
|
|
2048
|
+
* List **stock and price** for approved products — Trendyol's lightweight
|
|
2049
|
+
* `inventory-and-price` filter. A slim alternative to {@link list} when you
|
|
2050
|
+
* only need pricing + stock: the response carries `contentId`,
|
|
2051
|
+
* `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
|
|
2052
|
+
* `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
|
|
2053
|
+
* else.
|
|
2054
|
+
*
|
|
2055
|
+
* Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
|
|
2056
|
+
* `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
|
|
2057
|
+
* at **100** here (tighter than `list`'s 1000).
|
|
2058
|
+
*
|
|
2059
|
+
* Pagination follows the same convention as {@link list}: pass our opaque
|
|
2060
|
+
* `cursor` from the previous response and we forward it as `nextPageToken`
|
|
2061
|
+
* (required once the dataset exceeds 10,000 items).
|
|
2062
|
+
*
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```ts
|
|
2065
|
+
* import { paginate } from '@lonca/core';
|
|
2066
|
+
* for await (const p of paginate((q) =>
|
|
2067
|
+
* client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
|
|
2068
|
+
* )) {
|
|
2069
|
+
* for (const v of p.variants) {
|
|
2070
|
+
* console.log(v.barcode, v.quantity, v.salePrice);
|
|
2071
|
+
* }
|
|
2072
|
+
* }
|
|
2073
|
+
* ```
|
|
2074
|
+
*/
|
|
2075
|
+
listInventoryAndPrice(params?: ListInventoryAndPriceParams): Promise<CursorPage<ProductStockPrice>>;
|
|
1965
2076
|
/**
|
|
1966
2077
|
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
1967
2078
|
* `updatePriceAndInventory`).
|
|
@@ -2523,4 +2634,4 @@ interface TrendyolClient {
|
|
|
2523
2634
|
*/
|
|
2524
2635
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
2525
2636
|
|
|
2526
|
-
export { type
|
|
2637
|
+
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 };
|
package/dist/index.cjs
CHANGED
|
@@ -1066,6 +1066,7 @@ var LocationsResource = class {
|
|
|
1066
1066
|
};
|
|
1067
1067
|
var MAX_PAGE_SIZE = 200;
|
|
1068
1068
|
var DEFAULT_PAGE_SIZE2 = 50;
|
|
1069
|
+
var MAX_OFFSET_RECORDS = 1e4;
|
|
1069
1070
|
function toIso3(epochMs) {
|
|
1070
1071
|
if (typeof epochMs !== "number" || !Number.isFinite(epochMs) || epochMs === 0) {
|
|
1071
1072
|
return void 0;
|
|
@@ -1242,6 +1243,11 @@ var OrdersResource = class {
|
|
|
1242
1243
|
async list(params = {}) {
|
|
1243
1244
|
const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE2, MAX_PAGE_SIZE);
|
|
1244
1245
|
const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
1246
|
+
if ((page + 1) * size > MAX_OFFSET_RECORDS) {
|
|
1247
|
+
throw new core.ValidationError({
|
|
1248
|
+
message: `getShipmentPackages can reach at most ${MAX_OFFSET_RECORDS} records (page ${page} \xD7 size ${size} exceeds it); use listStream() for full scans`
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1245
1251
|
const query = { page, size };
|
|
1246
1252
|
if (params.status) query.status = params.status;
|
|
1247
1253
|
if (params.orderNumber) query.orderNumber = params.orderNumber;
|
|
@@ -1695,6 +1701,7 @@ var OrdersResource = class {
|
|
|
1695
1701
|
};
|
|
1696
1702
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
1697
1703
|
var MAX_PAGE_SIZE2 = 1e3;
|
|
1704
|
+
var MAX_INVENTORY_PAGE_SIZE = 100;
|
|
1698
1705
|
var MAX_BUYBOX_BARCODES = 10;
|
|
1699
1706
|
function normalizeRef(ref) {
|
|
1700
1707
|
return {
|
|
@@ -1760,6 +1767,30 @@ function normalizeProduct(node) {
|
|
|
1760
1767
|
if (node.lastModifiedBy !== void 0) out.lastModifiedBy = node.lastModifiedBy;
|
|
1761
1768
|
return out;
|
|
1762
1769
|
}
|
|
1770
|
+
function normalizeStockPriceVariant(node) {
|
|
1771
|
+
const out = {
|
|
1772
|
+
variantId: node.variantId !== void 0 ? String(node.variantId) : "",
|
|
1773
|
+
barcode: node.barcode ?? "",
|
|
1774
|
+
raw: node
|
|
1775
|
+
};
|
|
1776
|
+
if (typeof node.salePrice === "number") out.salePrice = node.salePrice;
|
|
1777
|
+
if (typeof node.listPrice === "number") out.listPrice = node.listPrice;
|
|
1778
|
+
if (typeof node.quantity === "number") out.quantity = node.quantity;
|
|
1779
|
+
if (node.stockCode !== void 0) out.stockCode = node.stockCode;
|
|
1780
|
+
if (node.stockLastModifiedDate !== void 0 && node.stockLastModifiedDate !== null) {
|
|
1781
|
+
const iso = toIso4(node.stockLastModifiedDate);
|
|
1782
|
+
if (iso) out.stockLastModifiedAt = iso;
|
|
1783
|
+
}
|
|
1784
|
+
return out;
|
|
1785
|
+
}
|
|
1786
|
+
function normalizeStockPrice(node) {
|
|
1787
|
+
return {
|
|
1788
|
+
contentId: node.contentId !== void 0 ? String(node.contentId) : "",
|
|
1789
|
+
productMainId: node.productMainId ?? "",
|
|
1790
|
+
variants: (node.variants ?? []).map(normalizeStockPriceVariant),
|
|
1791
|
+
raw: node
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1763
1794
|
function normalizeUnapprovedRejectReason(r) {
|
|
1764
1795
|
const out = {};
|
|
1765
1796
|
if (r.rejectReason !== void 0) out.rejectReason = r.rejectReason;
|
|
@@ -1950,6 +1981,63 @@ var ProductsResource = class {
|
|
|
1950
1981
|
}
|
|
1951
1982
|
return page;
|
|
1952
1983
|
}
|
|
1984
|
+
/**
|
|
1985
|
+
* List **stock and price** for approved products — Trendyol's lightweight
|
|
1986
|
+
* `inventory-and-price` filter. A slim alternative to {@link list} when you
|
|
1987
|
+
* only need pricing + stock: the response carries `contentId`,
|
|
1988
|
+
* `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
|
|
1989
|
+
* `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
|
|
1990
|
+
* else.
|
|
1991
|
+
*
|
|
1992
|
+
* Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
|
|
1993
|
+
* `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
|
|
1994
|
+
* at **100** here (tighter than `list`'s 1000).
|
|
1995
|
+
*
|
|
1996
|
+
* Pagination follows the same convention as {@link list}: pass our opaque
|
|
1997
|
+
* `cursor` from the previous response and we forward it as `nextPageToken`
|
|
1998
|
+
* (required once the dataset exceeds 10,000 items).
|
|
1999
|
+
*
|
|
2000
|
+
* @example
|
|
2001
|
+
* ```ts
|
|
2002
|
+
* import { paginate } from '@lonca/core';
|
|
2003
|
+
* for await (const p of paginate((q) =>
|
|
2004
|
+
* client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
|
|
2005
|
+
* )) {
|
|
2006
|
+
* for (const v of p.variants) {
|
|
2007
|
+
* console.log(v.barcode, v.quantity, v.salePrice);
|
|
2008
|
+
* }
|
|
2009
|
+
* }
|
|
2010
|
+
* ```
|
|
2011
|
+
*/
|
|
2012
|
+
async listInventoryAndPrice(params = {}) {
|
|
2013
|
+
const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE3, MAX_INVENTORY_PAGE_SIZE);
|
|
2014
|
+
const query = { size };
|
|
2015
|
+
if (params.cursor) {
|
|
2016
|
+
query.nextPageToken = params.cursor;
|
|
2017
|
+
} else {
|
|
2018
|
+
query.page = 0;
|
|
2019
|
+
}
|
|
2020
|
+
if (params.barcode) query.barcode = params.barcode;
|
|
2021
|
+
if (params.contentId) query.contentId = params.contentId;
|
|
2022
|
+
if (params.stockCode) query.stockCode = params.stockCode;
|
|
2023
|
+
if (params.productMainId) query.productMainId = params.productMainId;
|
|
2024
|
+
if (params.status) query.status = params.status;
|
|
2025
|
+
if (params.orderByDirection) query.orderByDirection = params.orderByDirection;
|
|
2026
|
+
const headers = params.storeFrontCode ? { storeFrontCode: params.storeFrontCode } : void 0;
|
|
2027
|
+
const data = await this.transport.request({
|
|
2028
|
+
method: "GET",
|
|
2029
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/approved/inventory-and-price`,
|
|
2030
|
+
query,
|
|
2031
|
+
headers,
|
|
2032
|
+
rateLimiter: this.filterLimiter
|
|
2033
|
+
});
|
|
2034
|
+
const items = (data.content ?? []).map(normalizeStockPrice);
|
|
2035
|
+
const page = { items };
|
|
2036
|
+
if (data.nextPageToken) {
|
|
2037
|
+
page.nextCursor = data.nextPageToken;
|
|
2038
|
+
}
|
|
2039
|
+
return page;
|
|
2040
|
+
}
|
|
1953
2041
|
/**
|
|
1954
2042
|
* Poll a batch request returned by an async write (e.g. `createProducts`,
|
|
1955
2043
|
* `updatePriceAndInventory`).
|
|
@@ -2733,7 +2821,7 @@ var TrendyolTransport = class {
|
|
|
2733
2821
|
if (opts.rateLimiter) await opts.rateLimiter.acquire(opts.signal);
|
|
2734
2822
|
const url = this.buildUrl(opts.path, opts.query);
|
|
2735
2823
|
const correlationId = crypto.randomUUID();
|
|
2736
|
-
const headers = this.buildHeaders(correlationId);
|
|
2824
|
+
const headers = { ...this.buildHeaders(correlationId), ...opts.headers };
|
|
2737
2825
|
const init = {
|
|
2738
2826
|
method: opts.method,
|
|
2739
2827
|
headers,
|