@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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { aP as ShipmentPackage, a2 as KnownShipmentPackageStatus } from './client-0omWgpd_.cjs';
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_.cjs';
1
+ import { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-CCA1P7sb.cjs';
2
+ export { A as ApproveClaimLineItemsInput, a as ApprovedProductStatus, B as BarcodeCategoryLookup, b as BatchAcceptedResponse, c as BatchPollOptions, d as BatchRequestItemResult, e as BatchRequestResult, f as BatchRequestStatus, g as Brand, h as BrandsResource, i as BuyboxInfo, C as CancelPackageItemInput, j as CareInstruction, k as CargoInvoiceItem, l as CategoriesResource, m as Category, n as CategoryAttribute, o as CategoryAttributeValue, p as City, q as Claim, r as ClaimIssueReason, s as ClaimItemAudit, t as ClaimItemStatus, u as ClaimsResource, v as CommonLabel, w as CommonLabelEntry, x as CompensationItemDetail, y as CompensationTicket, z as CompensationTicketState, D as Country, E as CreateClaimInput, F as CreateClaimIssueInput, G as CreateClaimItemInput, H as CreateClientOptions, I as CreateCommonLabelInput, J as CreateProductV2Input, K as CreateTestOrderInput, L as CreateVideoInput, M as DeleteInvoiceLinkInput, N as DeliveryOptionInput, O as District, P as ExportBatchAcceptedResponse, Q as ExportBatchStatus, R as ExportCategoryAttribute, S as ExportCenterResource, T as ExportPackage, U as ExportPackageItem, V as ExportPackageStatus, W as ExportPriceUpdateInput, X as ExportProduct, Y as ExportProductInput, Z as ExportStockUpdateInput, _ as FinanceResource, $ as FinancialTransaction, a0 as GetExportPackageItemsParams, a1 as InventoryResource, a2 as InvoicesResource, a4 as LabelsResource, a5 as LaborCostInput, a6 as ListCategoryAttributeValuesParams, a7 as ListClaimsParams, a8 as ListCompensationTicketsParams, a9 as ListExportPackagesV2Params, aa as ListExportPackagesV3Params, ab as ListExportProductsParams, ac as ListFinanceParams, ad as ListInventoryAndPriceParams, ae as ListOrdersParams, af as ListOrdersStreamParams, ag as ListProductsParams, ah as ListQuestionsParams, ai as ListUnapprovedProductsParams, aj as ListVideosParams, ak as LocationsResource, al as NamedRef, am as Neighborhood, an as OrderAddress, ao as OrderAddressLines, ap as OrderCustomer, aq as OrderLine, ar as OrderLineDiscountDetail, as as OrdersResource, at as OtherFinancialRow, au as PackageDetail, av as PackageHistoryEntry, aw as PackageLineUpdate, ax as PriceInventoryUpdate, ay as ProcessAlternativeDeliveryInput, az as Product, aA as ProductAttribute, aB as ProductAttributeV2Input, aC as ProductBase, aD as ProductComposition, aE as ProductImageInput, aF as ProductOrigin, aG as ProductStockPrice, aH as ProductStockPriceVariant, aI as ProductVariant, aJ as ProductsResource, aK as QuantitySplit, aL as Question, aM as QuestionAnswer, aN as QuestionStatus, aO as QuestionsResource, aP as SellerIntegrationStatus, aQ as SellerVideo, aR as SendInvoiceLinkInput, aS as SettlementRow, aU as ShipmentPackageStatus, aV as SplitGroup, aW as SplitPackagePlan, aX as SupplierAddress, aY as SupplierAddressType, aZ as SuppliersResource, a_ as SuppliersResourceOptions, a$ as TestOrderStatus, b0 as TestOrdersResource, b1 as TrendyolCapabilities, b2 as TrendyolCargoProvider, b3 as TrendyolClient, b4 as TrendyolEnvironment, b5 as UnapprovedDateQueryType, b6 as UnapprovedProduct, b7 as UnapprovedProductRejectReason, b8 as UnapprovedProductStatus, b9 as UpdateBoxInfoInput, ba as UpdateContentInput, bb as UpdateDeliveryInfoInput, bc as UpdatePackageStatusInput, bd as UpdatePriceInventoryResponse, be as UpdateUnapprovedInput, bf as UpdateVariantInput, bg as UploadInvoiceFileInput, bh as VideosResource, bi as Webhook, bj as WebhookAuthenticationType, bk as WebhookInput, bl as WebhooksResource, bm as createTrendyolClient, bn as normalizeShipmentPackage, bo as pollBatchStatus, bp as trendyolCapabilities } from './client-CCA1P7sb.cjs';
3
3
  import * as _lonca_core from '@lonca/core';
4
4
  import { NormalizedOrderStatus } from '@lonca/core';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-CCA1P7sb.js';
2
+ export { A as ApproveClaimLineItemsInput, a as ApprovedProductStatus, B as BarcodeCategoryLookup, b as BatchAcceptedResponse, c as BatchPollOptions, d as BatchRequestItemResult, e as BatchRequestResult, f as BatchRequestStatus, g as Brand, h as BrandsResource, i as BuyboxInfo, C as CancelPackageItemInput, j as CareInstruction, k as CargoInvoiceItem, l as CategoriesResource, m as Category, n as CategoryAttribute, o as CategoryAttributeValue, p as City, q as Claim, r as ClaimIssueReason, s as ClaimItemAudit, t as ClaimItemStatus, u as ClaimsResource, v as CommonLabel, w as CommonLabelEntry, x as CompensationItemDetail, y as CompensationTicket, z as CompensationTicketState, D as Country, E as CreateClaimInput, F as CreateClaimIssueInput, G as CreateClaimItemInput, H as CreateClientOptions, I as CreateCommonLabelInput, J as CreateProductV2Input, K as CreateTestOrderInput, L as CreateVideoInput, M as DeleteInvoiceLinkInput, N as DeliveryOptionInput, O as District, P as ExportBatchAcceptedResponse, Q as ExportBatchStatus, R as ExportCategoryAttribute, S as ExportCenterResource, T as ExportPackage, U as ExportPackageItem, V as ExportPackageStatus, W as ExportPriceUpdateInput, X as ExportProduct, Y as ExportProductInput, Z as ExportStockUpdateInput, _ as FinanceResource, $ as FinancialTransaction, a0 as GetExportPackageItemsParams, a1 as InventoryResource, a2 as InvoicesResource, a4 as LabelsResource, a5 as LaborCostInput, a6 as ListCategoryAttributeValuesParams, a7 as ListClaimsParams, a8 as ListCompensationTicketsParams, a9 as ListExportPackagesV2Params, aa as ListExportPackagesV3Params, ab as ListExportProductsParams, ac as ListFinanceParams, ad as ListInventoryAndPriceParams, ae as ListOrdersParams, af as ListOrdersStreamParams, ag as ListProductsParams, ah as ListQuestionsParams, ai as ListUnapprovedProductsParams, aj as ListVideosParams, ak as LocationsResource, al as NamedRef, am as Neighborhood, an as OrderAddress, ao as OrderAddressLines, ap as OrderCustomer, aq as OrderLine, ar as OrderLineDiscountDetail, as as OrdersResource, at as OtherFinancialRow, au as PackageDetail, av as PackageHistoryEntry, aw as PackageLineUpdate, ax as PriceInventoryUpdate, ay as ProcessAlternativeDeliveryInput, az as Product, aA as ProductAttribute, aB as ProductAttributeV2Input, aC as ProductBase, aD as ProductComposition, aE as ProductImageInput, aF as ProductOrigin, aG as ProductStockPrice, aH as ProductStockPriceVariant, aI as ProductVariant, aJ as ProductsResource, aK as QuantitySplit, aL as Question, aM as QuestionAnswer, aN as QuestionStatus, aO as QuestionsResource, aP as SellerIntegrationStatus, aQ as SellerVideo, aR as SendInvoiceLinkInput, aS as SettlementRow, aU as ShipmentPackageStatus, aV as SplitGroup, aW as SplitPackagePlan, aX as SupplierAddress, aY as SupplierAddressType, aZ as SuppliersResource, a_ as SuppliersResourceOptions, a$ as TestOrderStatus, b0 as TestOrdersResource, b1 as TrendyolCapabilities, b2 as TrendyolCargoProvider, b3 as TrendyolClient, b4 as TrendyolEnvironment, b5 as UnapprovedDateQueryType, b6 as UnapprovedProduct, b7 as UnapprovedProductRejectReason, b8 as UnapprovedProductStatus, b9 as UpdateBoxInfoInput, ba as UpdateContentInput, bb as UpdateDeliveryInfoInput, bc as UpdatePackageStatusInput, bd as UpdatePriceInventoryResponse, be as UpdateUnapprovedInput, bf as UpdateVariantInput, bg as UploadInvoiceFileInput, bh as VideosResource, bi as Webhook, bj as WebhookAuthenticationType, bk as WebhookInput, bl as WebhooksResource, bm as createTrendyolClient, bn as normalizeShipmentPackage, bo as pollBatchStatus, bp as trendyolCapabilities } from './client-CCA1P7sb.js';
3
3
  import * as _lonca_core from '@lonca/core';
4
4
  import { NormalizedOrderStatus } from '@lonca/core';
5
5
 
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { createStatusNormalizer, TokenBucketRateLimiter, ValidationError, TimeoutError, ServerError, noopLogger, retry, NetworkError, LoncaError, RateLimitError, NotFoundError, AuthError } from '@lonca/core';
2
- import { randomUUID } from 'crypto';
1
+ import { createStatusNormalizer, TokenBucketRateLimiter, ValidationError, TimeoutError, ServerError, createRequester, LoncaError, RateLimitError, NotFoundError, AuthError } from '@lonca/core';
3
2
 
4
3
  // src/resources/brands.ts
5
4
  var DEFAULT_PAGE_SIZE = 1e3;
@@ -39,7 +38,7 @@ var BrandsResource = class {
39
38
  * `createProducts` and don't want to page through the full `list()`
40
39
  * (1000 brands per page).
41
40
  *
42
- * **Discovery-first wire fact (verified STAGE 2026-05-25):** Trendyol's
41
+ * **Wire fact (verified STAGE 2026-05-25):** Trendyol's
43
42
  * doc claims this is a case-sensitive *exact* match, but live behaviour
44
43
  * is **substring + case-insensitive** — `search('Trendyol')` returns
45
44
  * 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
@@ -1064,6 +1063,7 @@ var LocationsResource = class {
1064
1063
  };
1065
1064
  var MAX_PAGE_SIZE = 200;
1066
1065
  var DEFAULT_PAGE_SIZE2 = 50;
1066
+ var MAX_OFFSET_RECORDS = 1e4;
1067
1067
  function toIso3(epochMs) {
1068
1068
  if (typeof epochMs !== "number" || !Number.isFinite(epochMs) || epochMs === 0) {
1069
1069
  return void 0;
@@ -1240,6 +1240,11 @@ var OrdersResource = class {
1240
1240
  async list(params = {}) {
1241
1241
  const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE2, MAX_PAGE_SIZE);
1242
1242
  const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
1243
+ if ((page + 1) * size > MAX_OFFSET_RECORDS) {
1244
+ throw new ValidationError({
1245
+ message: `getShipmentPackages can reach at most ${MAX_OFFSET_RECORDS} records (page ${page} \xD7 size ${size} exceeds it); use listStream() for full scans`
1246
+ });
1247
+ }
1243
1248
  const query = { page, size };
1244
1249
  if (params.status) query.status = params.status;
1245
1250
  if (params.orderNumber) query.orderNumber = params.orderNumber;
@@ -1254,7 +1259,8 @@ var OrdersResource = class {
1254
1259
  const items = (data.content ?? []).map(normalizePackage2);
1255
1260
  const totalPages = typeof data.totalPages === "number" ? data.totalPages : 0;
1256
1261
  const result = { items };
1257
- if (page + 1 < totalPages) {
1262
+ const nextPageWithinCap = (page + 2) * size <= MAX_OFFSET_RECORDS;
1263
+ if (page + 1 < totalPages && nextPageWithinCap) {
1258
1264
  result.nextCursor = String(page + 1);
1259
1265
  }
1260
1266
  return result;
@@ -1693,6 +1699,7 @@ var OrdersResource = class {
1693
1699
  };
1694
1700
  var DEFAULT_PAGE_SIZE3 = 50;
1695
1701
  var MAX_PAGE_SIZE2 = 1e3;
1702
+ var MAX_INVENTORY_PAGE_SIZE = 100;
1696
1703
  var MAX_BUYBOX_BARCODES = 10;
1697
1704
  function normalizeRef(ref) {
1698
1705
  return {
@@ -1758,6 +1765,30 @@ function normalizeProduct(node) {
1758
1765
  if (node.lastModifiedBy !== void 0) out.lastModifiedBy = node.lastModifiedBy;
1759
1766
  return out;
1760
1767
  }
1768
+ function normalizeStockPriceVariant(node) {
1769
+ const out = {
1770
+ variantId: node.variantId !== void 0 ? String(node.variantId) : "",
1771
+ barcode: node.barcode ?? "",
1772
+ raw: node
1773
+ };
1774
+ if (typeof node.salePrice === "number") out.salePrice = node.salePrice;
1775
+ if (typeof node.listPrice === "number") out.listPrice = node.listPrice;
1776
+ if (typeof node.quantity === "number") out.quantity = node.quantity;
1777
+ if (node.stockCode !== void 0) out.stockCode = node.stockCode;
1778
+ if (node.stockLastModifiedDate !== void 0 && node.stockLastModifiedDate !== null) {
1779
+ const iso = toIso4(node.stockLastModifiedDate);
1780
+ if (iso) out.stockLastModifiedAt = iso;
1781
+ }
1782
+ return out;
1783
+ }
1784
+ function normalizeStockPrice(node) {
1785
+ return {
1786
+ contentId: node.contentId !== void 0 ? String(node.contentId) : "",
1787
+ productMainId: node.productMainId ?? "",
1788
+ variants: (node.variants ?? []).map(normalizeStockPriceVariant),
1789
+ raw: node
1790
+ };
1791
+ }
1761
1792
  function normalizeUnapprovedRejectReason(r) {
1762
1793
  const out = {};
1763
1794
  if (r.rejectReason !== void 0) out.rejectReason = r.rejectReason;
@@ -1948,6 +1979,63 @@ var ProductsResource = class {
1948
1979
  }
1949
1980
  return page;
1950
1981
  }
1982
+ /**
1983
+ * List **stock and price** for approved products — Trendyol's lightweight
1984
+ * `inventory-and-price` filter. A slim alternative to {@link list} when you
1985
+ * only need pricing + stock: the response carries `contentId`,
1986
+ * `productMainId`, and a `variants[]` array with `barcode`, `salePrice`,
1987
+ * `listPrice`, `quantity`, `stockCode`, and `stockLastModifiedAt` — nothing
1988
+ * else.
1989
+ *
1990
+ * Filter by `barcode`, `contentId`, `stockCode`, `productMainId`, or listing
1991
+ * `status`. Sort with `orderByDirection` (`SellerCreatedDate`). `size` caps
1992
+ * at **100** here (tighter than `list`'s 1000).
1993
+ *
1994
+ * Pagination follows the same convention as {@link list}: pass our opaque
1995
+ * `cursor` from the previous response and we forward it as `nextPageToken`
1996
+ * (required once the dataset exceeds 10,000 items).
1997
+ *
1998
+ * @example
1999
+ * ```ts
2000
+ * import { paginate } from '@lonca/core';
2001
+ * for await (const p of paginate((q) =>
2002
+ * client.products.listInventoryAndPrice({ ...q, status: 'onSale' }),
2003
+ * )) {
2004
+ * for (const v of p.variants) {
2005
+ * console.log(v.barcode, v.quantity, v.salePrice);
2006
+ * }
2007
+ * }
2008
+ * ```
2009
+ */
2010
+ async listInventoryAndPrice(params = {}) {
2011
+ const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE3, MAX_INVENTORY_PAGE_SIZE);
2012
+ const query = { size };
2013
+ if (params.cursor) {
2014
+ query.nextPageToken = params.cursor;
2015
+ } else {
2016
+ query.page = 0;
2017
+ }
2018
+ if (params.barcode) query.barcode = params.barcode;
2019
+ if (params.contentId) query.contentId = params.contentId;
2020
+ if (params.stockCode) query.stockCode = params.stockCode;
2021
+ if (params.productMainId) query.productMainId = params.productMainId;
2022
+ if (params.status) query.status = params.status;
2023
+ if (params.orderByDirection) query.orderByDirection = params.orderByDirection;
2024
+ const headers = params.storeFrontCode ? { storeFrontCode: params.storeFrontCode } : void 0;
2025
+ const data = await this.transport.request({
2026
+ method: "GET",
2027
+ path: `/integration/product/sellers/${this.transport.sellerId}/products/approved/inventory-and-price`,
2028
+ query,
2029
+ headers,
2030
+ rateLimiter: this.filterLimiter
2031
+ });
2032
+ const items = (data.content ?? []).map(normalizeStockPrice);
2033
+ const page = { items };
2034
+ if (data.nextPageToken) {
2035
+ page.nextCursor = data.nextPageToken;
2036
+ }
2037
+ return page;
2038
+ }
1951
2039
  /**
1952
2040
  * Poll a batch request returned by an async write (e.g. `createProducts`,
1953
2041
  * `updatePriceAndInventory`).
@@ -2694,14 +2782,6 @@ function extractErrorsArray(body) {
2694
2782
  }
2695
2783
  return void 0;
2696
2784
  }
2697
- function parseRetryAfter(header) {
2698
- if (!header) return void 0;
2699
- const seconds = Number(header);
2700
- if (!Number.isNaN(seconds)) return Math.max(0, seconds * 1e3);
2701
- const epoch = Date.parse(header);
2702
- if (!Number.isNaN(epoch)) return Math.max(0, epoch - Date.now());
2703
- return void 0;
2704
- }
2705
2785
 
2706
2786
  // src/transport.ts
2707
2787
  var BASE_URLS = {
@@ -2712,95 +2792,26 @@ var TrendyolTransport = class {
2712
2792
  constructor(config) {
2713
2793
  this.config = config;
2714
2794
  this.baseUrl = BASE_URLS[config.env];
2715
- this.logger = config.logger ?? noopLogger;
2716
- this.timeoutMs = config.timeoutMs ?? 3e4;
2717
- this.fetchImpl = config.fetch ?? fetch;
2795
+ this.requester = createRequester({
2796
+ fetch: config.fetch ?? fetch,
2797
+ logger: config.logger,
2798
+ timeoutMs: config.timeoutMs ?? 3e4,
2799
+ label: "Trendyol",
2800
+ logPrefix: "trendyol",
2801
+ buildUrl: (opts) => this.buildUrl(opts.path, opts.query),
2802
+ buildHeaders: (correlationId) => this.buildHeaders(correlationId),
2803
+ mapHttpError
2804
+ });
2718
2805
  }
2719
2806
  config;
2720
2807
  baseUrl;
2721
- logger;
2722
- timeoutMs;
2723
- fetchImpl;
2808
+ requester;
2724
2809
  /** Seller ID this transport is configured with. Resources read it for path-building. */
2725
2810
  get sellerId() {
2726
2811
  return this.config.sellerId;
2727
2812
  }
2728
- async request(opts) {
2729
- return retry(
2730
- async (attempt) => {
2731
- if (opts.rateLimiter) await opts.rateLimiter.acquire(opts.signal);
2732
- const url = this.buildUrl(opts.path, opts.query);
2733
- const correlationId = randomUUID();
2734
- const headers = this.buildHeaders(correlationId);
2735
- const init = {
2736
- method: opts.method,
2737
- headers,
2738
- signal: this.composeSignal(opts.signal)
2739
- };
2740
- if (opts.body !== void 0 && opts.method !== "GET") {
2741
- if (opts.body instanceof FormData) {
2742
- init.body = opts.body;
2743
- delete headers["Content-Type"];
2744
- } else {
2745
- init.body = JSON.stringify(opts.body);
2746
- }
2747
- }
2748
- this.logger.debug("trendyol.request", {
2749
- method: opts.method,
2750
- url,
2751
- correlationId,
2752
- attempt
2753
- });
2754
- let response;
2755
- try {
2756
- response = await this.fetchImpl(url, init);
2757
- } catch (err) {
2758
- if (err instanceof Error && err.name === "AbortError") {
2759
- throw new TimeoutError({
2760
- message: `Trendyol request timed out after ${this.timeoutMs}ms`,
2761
- cause: err
2762
- });
2763
- }
2764
- throw new NetworkError({
2765
- message: "Trendyol network failure",
2766
- cause: err
2767
- });
2768
- }
2769
- if (!response.ok) {
2770
- const body = await safeJson(response);
2771
- const retryAfterMs = parseRetryAfter(response.headers.get("retry-after"));
2772
- const error = mapHttpError(response.status, body, retryAfterMs);
2773
- this.logger.warn("trendyol.error", {
2774
- method: opts.method,
2775
- url,
2776
- correlationId,
2777
- status: response.status,
2778
- code: error.code,
2779
- retryable: error.retryable
2780
- });
2781
- throw error;
2782
- }
2783
- this.logger.debug("trendyol.response", {
2784
- correlationId,
2785
- status: response.status
2786
- });
2787
- if (response.status === 204) return void 0;
2788
- return await safeJson(response);
2789
- },
2790
- {
2791
- signal: opts.signal,
2792
- onRetry: (err, attempt, delay2) => {
2793
- if (err instanceof LoncaError) {
2794
- this.logger.warn("trendyol.retry", {
2795
- attempt,
2796
- delayMs: delay2,
2797
- code: err.code,
2798
- status: err.status
2799
- });
2800
- }
2801
- }
2802
- }
2803
- );
2813
+ request(opts) {
2814
+ return this.requester(opts);
2804
2815
  }
2805
2816
  buildUrl(path, query) {
2806
2817
  const url = new URL(path, this.baseUrl);
@@ -2823,21 +2834,7 @@ var TrendyolTransport = class {
2823
2834
  Accept: "application/json"
2824
2835
  };
2825
2836
  }
2826
- composeSignal(external) {
2827
- const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
2828
- if (!external) return timeoutSignal;
2829
- return AbortSignal.any([external, timeoutSignal]);
2830
- }
2831
2837
  };
2832
- async function safeJson(response) {
2833
- const text = await response.text();
2834
- if (!text) return void 0;
2835
- try {
2836
- return JSON.parse(text);
2837
- } catch {
2838
- return text;
2839
- }
2840
- }
2841
2838
 
2842
2839
  // src/client.ts
2843
2840
  function createTrendyolClient(opts) {