@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
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ApproveClaimLineItemsInput, B as BarcodeCategoryLookup,
|
|
1
|
+
import { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-BZeFAlrp.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-BZeFAlrp.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 {
|
|
2
|
-
export { A as ApproveClaimLineItemsInput, B as BarcodeCategoryLookup,
|
|
1
|
+
import { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-BZeFAlrp.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-BZeFAlrp.js';
|
|
3
3
|
import * as _lonca_core from '@lonca/core';
|
|
4
4
|
import { NormalizedOrderStatus } from '@lonca/core';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1064,6 +1064,7 @@ var LocationsResource = class {
|
|
|
1064
1064
|
};
|
|
1065
1065
|
var MAX_PAGE_SIZE = 200;
|
|
1066
1066
|
var DEFAULT_PAGE_SIZE2 = 50;
|
|
1067
|
+
var MAX_OFFSET_RECORDS = 1e4;
|
|
1067
1068
|
function toIso3(epochMs) {
|
|
1068
1069
|
if (typeof epochMs !== "number" || !Number.isFinite(epochMs) || epochMs === 0) {
|
|
1069
1070
|
return void 0;
|
|
@@ -1240,6 +1241,11 @@ var OrdersResource = class {
|
|
|
1240
1241
|
async list(params = {}) {
|
|
1241
1242
|
const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE2, MAX_PAGE_SIZE);
|
|
1242
1243
|
const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
1244
|
+
if ((page + 1) * size > MAX_OFFSET_RECORDS) {
|
|
1245
|
+
throw new ValidationError({
|
|
1246
|
+
message: `getShipmentPackages can reach at most ${MAX_OFFSET_RECORDS} records (page ${page} \xD7 size ${size} exceeds it); use listStream() for full scans`
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1243
1249
|
const query = { page, size };
|
|
1244
1250
|
if (params.status) query.status = params.status;
|
|
1245
1251
|
if (params.orderNumber) query.orderNumber = params.orderNumber;
|
|
@@ -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`).
|
|
@@ -2731,7 +2819,7 @@ var TrendyolTransport = class {
|
|
|
2731
2819
|
if (opts.rateLimiter) await opts.rateLimiter.acquire(opts.signal);
|
|
2732
2820
|
const url = this.buildUrl(opts.path, opts.query);
|
|
2733
2821
|
const correlationId = randomUUID();
|
|
2734
|
-
const headers = this.buildHeaders(correlationId);
|
|
2822
|
+
const headers = { ...this.buildHeaders(correlationId), ...opts.headers };
|
|
2735
2823
|
const init = {
|
|
2736
2824
|
method: opts.method,
|
|
2737
2825
|
headers,
|