import { aU as ShipmentPackage, a3 as KnownShipmentPackageStatus } from './client-CtygosAW.js'; 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 ProductContentBase, aF as ProductImageInput, aG as ProductOrigin, aH as ProductStockPrice, aI as ProductStockPriceVariant, aJ as ProductVariant, aK as ProductsResource, aL as QuantitySplit, aM as Question, aN as QuestionAnswer, aO as QuestionStatus, aP as QuestionsResource, aQ as SellerIntegrationStatus, aR as SellerVideo, aS as SendInvoiceLinkInput, aT as SettlementRow, aV as ShipmentPackageStatus, aW as SplitGroup, aX as SplitPackagePlan, aY as SupplierAddress, aZ as SupplierAddressType, a_ as SuppliersResource, a$ as SuppliersResourceOptions, b0 as TestOrderStatus, b1 as TestOrdersResource, b2 as TrendyolCapabilities, b3 as TrendyolCargoProvider, b4 as TrendyolClient, b5 as TrendyolEnvironment, b6 as UnapprovedDateQueryType, b7 as UnapprovedProduct, b8 as UnapprovedProductRejectReason, b9 as UnapprovedProductStatus, ba as UpdateBoxInfoInput, bb as UpdateContentInput, bc as UpdateDeliveryInfoInput, bd as UpdatePackageStatusInput, be as UpdatePriceInventoryResponse, bf as UpdateUnapprovedInput, bg as UpdateVariantInput, bh as UploadInvoiceFileInput, bi as VideosResource, bj as Webhook, bk as WebhookAuthenticationType, bl as WebhookInput, bm as WebhooksResource, bn as createTrendyolClient, bo as normalizeShipmentPackage, bp as pollBatchStatus, bq as trendyolCapabilities } from './client-CtygosAW.js'; import * as _lonca_core from '@lonca/core'; import { NormalizedOrderStatus } from '@lonca/core'; export { CursorPage, CursorPaginationParams, MutationResult, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core'; /** * Inbound webhook event payloads — what Trendyol POSTs to YOUR endpoint * when a subscribed shipment-package status event fires. * * Per Trendyol's "Webhook Model" doc: * - Method: POST, body: JSON * - Wire shape: identical to `getShipmentPackages` response envelope * (`{ totalElements, totalPages, page, size, content: [...] }`) * - Sent on every status transition for a subscribed status (see * `WebhookEventStatus` below) — the full order data is delivered * each time, not a delta. * * Trendyol authenticates against YOUR endpoint using the method you * configured on the subscription (BASIC_AUTHENTICATION or API_KEY). The * SDK does NOT validate auth on its end — handle that in your request * middleware before passing the body to `parseWebhookEvent`. * * Retry: on a non-2xx response, Trendyol retries every 5 minutes; after * persistent failures the subscription is auto-deactivated (you'll get * 2 emails). Reactivate via `client.webhooks.activate(id)` once your * endpoint is healthy again. */ /** * Status values Trendyol sends as the event trigger. Note the * **upper-snake-case** spelling here, distinct from `ShipmentPackageStatus` * (which uses PascalCase on the API read responses). */ type WebhookEventStatus = 'CREATED' | 'PICKING' | 'INVOICED' | 'SHIPPED' | 'CANCELLED' | 'DELIVERED' | 'UNDELIVERED' | 'RETURNED' | 'UNSUPPLIED' | 'AWAITING' | 'UNPACKED' | 'AT_COLLECTION_POINT' | 'VERIFIED' | (string & {}); /** * Origin of a package, surfaced as `ShipmentPackage.createdBy` on the * normalized event payload. Useful for routing logic (e.g. trigger a * different flow for `'split'` packages than `'order-creation'`). */ type PackageCreatedBy = 'order-creation' | 'cancel' | 'split' | 'transfer' | (string & {}); /** * The parsed webhook event body. `packages` is the normalized * `content[]` from the inbound JSON; `pageInfo` carries Trendyol's * pagination envelope verbatim so you can log / surface it. * * In practice `packages.length === 1` for status-change events, but the * model is defined as a page so the same handler can absorb future * batch events without breaking. */ interface WebhookEvent { packages: ShipmentPackage[]; pageInfo: { totalElements?: number; totalPages?: number; page?: number; size?: number; }; /** Raw inbound body — fall back here for fields the SDK doesn't surface. */ raw: Record; } /** * Top-level helper for parsing incoming Trendyol webhook event bodies * into the SDK's typed shape. * * Usage in an Express route: * * ```ts * import { parseWebhookEvent } from '@lonca/trendyol'; * * app.post('/trendyol/webhook', express.json(), (req, res) => { * const event = parseWebhookEvent(req.body); * for (const pkg of event.packages) { * // pkg: typed ShipmentPackage — same shape as orders.list() * await myQueue.enqueue({ packageId: pkg.id, status: pkg.status }); * } * res.sendStatus(200); * }); * ``` */ /** * Parse an inbound webhook body into a typed `WebhookEvent`. * * Accepts either an already-parsed object or a JSON string. Returns * normalized `ShipmentPackage[]` (the same shape `orders.list()` * produces), plus the page envelope and the raw body for fallthrough. * * @throws {ValidationError} when the body isn't an object / valid JSON, * or when `content` is missing or not an array. */ declare function parseWebhookEvent(rawBody: unknown): WebhookEvent; /** * Exhaustive map from Trendyol's known shipment-package statuses to the * marketplace-agnostic {@link NormalizedOrderStatus} vocabulary. * * Because the key type is the **closed** {@link KnownShipmentPackageStatus} * union, adding a value there without mapping it here is a compile-time error. * Some Trendyol states have no exact normalized equivalent and are folded onto * the nearest lifecycle stage (noted inline). */ declare const statusMap: Record; /** * Normalize a raw Trendyol shipment-package status into the * {@link NormalizedOrderStatus} vocabulary. * * Unknown raw values resolve to `{ normalized: 'unknown', mapped: false }` with * the raw string preserved — never silently coerced to a valid-looking default. */ declare const normalizeStatus: (raw: string) => _lonca_core.NormalizedStatusResult; export { KnownShipmentPackageStatus, type PackageCreatedBy, ShipmentPackage, type WebhookEvent, type WebhookEventStatus, normalizeStatus, parseWebhookEvent, statusMap };