@lonca/trendyol 0.11.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-BZeFAlrp.d.cts → client-CCA1P7sb.d.cts} +4 -16
- package/dist/{client-BZeFAlrp.d.ts → client-CCA1P7sb.d.ts} +4 -16
- package/dist/index.cjs +16 -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 +17 -108
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +16 -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 +17 -108
- package/dist/testing.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-
|
|
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-
|
|
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 { aT as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-
|
|
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-
|
|
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,
|
|
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
|
-
* **
|
|
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`.
|
|
@@ -1260,7 +1259,8 @@ var OrdersResource = class {
|
|
|
1260
1259
|
const items = (data.content ?? []).map(normalizePackage2);
|
|
1261
1260
|
const totalPages = typeof data.totalPages === "number" ? data.totalPages : 0;
|
|
1262
1261
|
const result = { items };
|
|
1263
|
-
|
|
1262
|
+
const nextPageWithinCap = (page + 2) * size <= MAX_OFFSET_RECORDS;
|
|
1263
|
+
if (page + 1 < totalPages && nextPageWithinCap) {
|
|
1264
1264
|
result.nextCursor = String(page + 1);
|
|
1265
1265
|
}
|
|
1266
1266
|
return result;
|
|
@@ -2782,14 +2782,6 @@ function extractErrorsArray(body) {
|
|
|
2782
2782
|
}
|
|
2783
2783
|
return void 0;
|
|
2784
2784
|
}
|
|
2785
|
-
function parseRetryAfter(header) {
|
|
2786
|
-
if (!header) return void 0;
|
|
2787
|
-
const seconds = Number(header);
|
|
2788
|
-
if (!Number.isNaN(seconds)) return Math.max(0, seconds * 1e3);
|
|
2789
|
-
const epoch = Date.parse(header);
|
|
2790
|
-
if (!Number.isNaN(epoch)) return Math.max(0, epoch - Date.now());
|
|
2791
|
-
return void 0;
|
|
2792
|
-
}
|
|
2793
2785
|
|
|
2794
2786
|
// src/transport.ts
|
|
2795
2787
|
var BASE_URLS = {
|
|
@@ -2800,95 +2792,26 @@ var TrendyolTransport = class {
|
|
|
2800
2792
|
constructor(config) {
|
|
2801
2793
|
this.config = config;
|
|
2802
2794
|
this.baseUrl = BASE_URLS[config.env];
|
|
2803
|
-
this.
|
|
2804
|
-
|
|
2805
|
-
|
|
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
|
+
});
|
|
2806
2805
|
}
|
|
2807
2806
|
config;
|
|
2808
2807
|
baseUrl;
|
|
2809
|
-
|
|
2810
|
-
timeoutMs;
|
|
2811
|
-
fetchImpl;
|
|
2808
|
+
requester;
|
|
2812
2809
|
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
2813
2810
|
get sellerId() {
|
|
2814
2811
|
return this.config.sellerId;
|
|
2815
2812
|
}
|
|
2816
|
-
|
|
2817
|
-
return
|
|
2818
|
-
async (attempt) => {
|
|
2819
|
-
if (opts.rateLimiter) await opts.rateLimiter.acquire(opts.signal);
|
|
2820
|
-
const url = this.buildUrl(opts.path, opts.query);
|
|
2821
|
-
const correlationId = randomUUID();
|
|
2822
|
-
const headers = { ...this.buildHeaders(correlationId), ...opts.headers };
|
|
2823
|
-
const init = {
|
|
2824
|
-
method: opts.method,
|
|
2825
|
-
headers,
|
|
2826
|
-
signal: this.composeSignal(opts.signal)
|
|
2827
|
-
};
|
|
2828
|
-
if (opts.body !== void 0 && opts.method !== "GET") {
|
|
2829
|
-
if (opts.body instanceof FormData) {
|
|
2830
|
-
init.body = opts.body;
|
|
2831
|
-
delete headers["Content-Type"];
|
|
2832
|
-
} else {
|
|
2833
|
-
init.body = JSON.stringify(opts.body);
|
|
2834
|
-
}
|
|
2835
|
-
}
|
|
2836
|
-
this.logger.debug("trendyol.request", {
|
|
2837
|
-
method: opts.method,
|
|
2838
|
-
url,
|
|
2839
|
-
correlationId,
|
|
2840
|
-
attempt
|
|
2841
|
-
});
|
|
2842
|
-
let response;
|
|
2843
|
-
try {
|
|
2844
|
-
response = await this.fetchImpl(url, init);
|
|
2845
|
-
} catch (err) {
|
|
2846
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
2847
|
-
throw new TimeoutError({
|
|
2848
|
-
message: `Trendyol request timed out after ${this.timeoutMs}ms`,
|
|
2849
|
-
cause: err
|
|
2850
|
-
});
|
|
2851
|
-
}
|
|
2852
|
-
throw new NetworkError({
|
|
2853
|
-
message: "Trendyol network failure",
|
|
2854
|
-
cause: err
|
|
2855
|
-
});
|
|
2856
|
-
}
|
|
2857
|
-
if (!response.ok) {
|
|
2858
|
-
const body = await safeJson(response);
|
|
2859
|
-
const retryAfterMs = parseRetryAfter(response.headers.get("retry-after"));
|
|
2860
|
-
const error = mapHttpError(response.status, body, retryAfterMs);
|
|
2861
|
-
this.logger.warn("trendyol.error", {
|
|
2862
|
-
method: opts.method,
|
|
2863
|
-
url,
|
|
2864
|
-
correlationId,
|
|
2865
|
-
status: response.status,
|
|
2866
|
-
code: error.code,
|
|
2867
|
-
retryable: error.retryable
|
|
2868
|
-
});
|
|
2869
|
-
throw error;
|
|
2870
|
-
}
|
|
2871
|
-
this.logger.debug("trendyol.response", {
|
|
2872
|
-
correlationId,
|
|
2873
|
-
status: response.status
|
|
2874
|
-
});
|
|
2875
|
-
if (response.status === 204) return void 0;
|
|
2876
|
-
return await safeJson(response);
|
|
2877
|
-
},
|
|
2878
|
-
{
|
|
2879
|
-
signal: opts.signal,
|
|
2880
|
-
onRetry: (err, attempt, delay2) => {
|
|
2881
|
-
if (err instanceof LoncaError) {
|
|
2882
|
-
this.logger.warn("trendyol.retry", {
|
|
2883
|
-
attempt,
|
|
2884
|
-
delayMs: delay2,
|
|
2885
|
-
code: err.code,
|
|
2886
|
-
status: err.status
|
|
2887
|
-
});
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
);
|
|
2813
|
+
request(opts) {
|
|
2814
|
+
return this.requester(opts);
|
|
2892
2815
|
}
|
|
2893
2816
|
buildUrl(path, query) {
|
|
2894
2817
|
const url = new URL(path, this.baseUrl);
|
|
@@ -2911,21 +2834,7 @@ var TrendyolTransport = class {
|
|
|
2911
2834
|
Accept: "application/json"
|
|
2912
2835
|
};
|
|
2913
2836
|
}
|
|
2914
|
-
composeSignal(external) {
|
|
2915
|
-
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
2916
|
-
if (!external) return timeoutSignal;
|
|
2917
|
-
return AbortSignal.any([external, timeoutSignal]);
|
|
2918
|
-
}
|
|
2919
2837
|
};
|
|
2920
|
-
async function safeJson(response) {
|
|
2921
|
-
const text = await response.text();
|
|
2922
|
-
if (!text) return void 0;
|
|
2923
|
-
try {
|
|
2924
|
-
return JSON.parse(text);
|
|
2925
|
-
} catch {
|
|
2926
|
-
return text;
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
2838
|
|
|
2930
2839
|
// src/client.ts
|
|
2931
2840
|
function createTrendyolClient(opts) {
|