@lonca/trendyol 0.14.0 → 0.15.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/README.md +26 -8
- package/dist/{client-CtygosAW.d.cts → client-Dnfjvwah.d.cts} +143 -19
- package/dist/{client-CtygosAW.d.ts → client-Dnfjvwah.d.ts} +143 -19
- package/dist/index.cjs +91 -18
- 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 +92 -19
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +91 -18
- 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 +92 -19
- package/dist/testing.js.map +1 -1
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -954,18 +954,23 @@ var LabelsResource = class {
|
|
|
954
954
|
* returns, call `getCommon()` with the same `cargoTrackingNumber` to
|
|
955
955
|
* retrieve the generated label.
|
|
956
956
|
*
|
|
957
|
+
* Trendyol documents this endpoint (`createCommonLabel`) as a bare
|
|
958
|
+
* `200 OK` with no response body, so the SDK returns a `MutationResult`
|
|
959
|
+
* whose `raw` is whatever the gateway sent (normally `undefined`).
|
|
960
|
+
*
|
|
957
961
|
* @throws {ValidationError} when `format` is missing.
|
|
958
962
|
*/
|
|
959
963
|
async createCommon(cargoTrackingNumber, input) {
|
|
960
964
|
if (!input?.format) {
|
|
961
965
|
throw new core.ValidationError({ message: "labels.createCommon: format is required" });
|
|
962
966
|
}
|
|
963
|
-
|
|
967
|
+
const raw = await this.transport.request({
|
|
964
968
|
method: "POST",
|
|
965
969
|
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
966
970
|
body: input,
|
|
967
971
|
rateLimiter: this.limiter
|
|
968
972
|
});
|
|
973
|
+
return { raw };
|
|
969
974
|
}
|
|
970
975
|
/**
|
|
971
976
|
* Retrieve the previously-created common label. Trendyol returns
|
|
@@ -2415,6 +2420,9 @@ var QuestionsResource = class {
|
|
|
2415
2420
|
* Reply to a question. Trendyol enforces 10–2000 characters on the
|
|
2416
2421
|
* answer text; the SDK pre-validates client-side.
|
|
2417
2422
|
*
|
|
2423
|
+
* Trendyol documents the response as `{ answerId: number }`; the SDK
|
|
2424
|
+
* surfaces it as `answerId` and keeps the untouched body on `raw`.
|
|
2425
|
+
*
|
|
2418
2426
|
* @throws {ValidationError} when `text` is outside the 10–2000 char range.
|
|
2419
2427
|
*/
|
|
2420
2428
|
async answer(questionId, text) {
|
|
@@ -2428,12 +2436,15 @@ var QuestionsResource = class {
|
|
|
2428
2436
|
message: `questions.answer: text must be at most 2000 chars (got ${text.length})`
|
|
2429
2437
|
});
|
|
2430
2438
|
}
|
|
2431
|
-
|
|
2439
|
+
const raw = await this.transport.request({
|
|
2432
2440
|
method: "POST",
|
|
2433
2441
|
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
2434
2442
|
body: { text },
|
|
2435
2443
|
rateLimiter: this.limiter
|
|
2436
2444
|
});
|
|
2445
|
+
const out = { raw };
|
|
2446
|
+
if (typeof raw?.answerId === "number") out.answerId = raw.answerId;
|
|
2447
|
+
return out;
|
|
2437
2448
|
}
|
|
2438
2449
|
};
|
|
2439
2450
|
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -2526,6 +2537,9 @@ var TestOrdersResource = class {
|
|
|
2526
2537
|
* SDK forwards the typed payload verbatim — drill into Trendyol's
|
|
2527
2538
|
* `createTestOrder` doc for inner field rules.
|
|
2528
2539
|
*
|
|
2540
|
+
* Trendyol documents the response as `{ orderNumber: string }`; the SDK
|
|
2541
|
+
* surfaces it as `orderNumber` and keeps the untouched body on `raw`.
|
|
2542
|
+
*
|
|
2529
2543
|
* @throws {ValidationError} when required top-level fields are missing.
|
|
2530
2544
|
*/
|
|
2531
2545
|
async create(input) {
|
|
@@ -2534,29 +2548,52 @@ var TestOrdersResource = class {
|
|
|
2534
2548
|
throw new core.ValidationError({ message: `testOrders.create: ${k} is required` });
|
|
2535
2549
|
}
|
|
2536
2550
|
}
|
|
2537
|
-
|
|
2551
|
+
const raw = await this.transport.request({
|
|
2538
2552
|
method: "POST",
|
|
2539
2553
|
path: `/integration/test/order/orders/core`,
|
|
2540
2554
|
body: input,
|
|
2541
2555
|
rateLimiter: this.limiter
|
|
2542
2556
|
});
|
|
2557
|
+
const out = { raw };
|
|
2558
|
+
if (typeof raw?.orderNumber === "string") out.orderNumber = raw.orderNumber;
|
|
2559
|
+
else if (typeof raw?.orderNumber === "number") out.orderNumber = String(raw.orderNumber);
|
|
2560
|
+
return out;
|
|
2543
2561
|
}
|
|
2544
|
-
/**
|
|
2545
|
-
|
|
2546
|
-
|
|
2562
|
+
/**
|
|
2563
|
+
* Push a test shipment package to the given status. Trendyol's
|
|
2564
|
+
* `status-updates-on-test-orders` doc shows a `{ lines, params, status }`
|
|
2565
|
+
* body — pass `options` to send the documented `lines` / `params`;
|
|
2566
|
+
* omitted, the body stays `{ status }` alone as before. Documented
|
|
2567
|
+
* response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2568
|
+
*/
|
|
2569
|
+
async updateStatus(packageId, status, options = {}) {
|
|
2570
|
+
const raw = await this.transport.request({
|
|
2547
2571
|
method: "PUT",
|
|
2548
2572
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2549
|
-
body: {
|
|
2573
|
+
body: {
|
|
2574
|
+
...options.lines !== void 0 ? { lines: options.lines } : {},
|
|
2575
|
+
...options.params !== void 0 ? { params: options.params } : {},
|
|
2576
|
+
status
|
|
2577
|
+
},
|
|
2550
2578
|
rateLimiter: this.limiter
|
|
2551
2579
|
});
|
|
2580
|
+
return { raw };
|
|
2552
2581
|
}
|
|
2553
|
-
/**
|
|
2554
|
-
|
|
2555
|
-
|
|
2582
|
+
/**
|
|
2583
|
+
* Move test claims to the `WaitingInAction` state. Trendyol's
|
|
2584
|
+
* `updateTestOrderStatus` doc shows a `{ shipmentPackageId }` body (the
|
|
2585
|
+
* `orderShipmentPackageId` from `claims.list`); pass `input` to send it —
|
|
2586
|
+
* omitted, the request goes out body-less as before. Documented response
|
|
2587
|
+
* is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2588
|
+
*/
|
|
2589
|
+
async setClaimsWaitingInAction(input) {
|
|
2590
|
+
const raw = await this.transport.request({
|
|
2556
2591
|
method: "PUT",
|
|
2557
2592
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2593
|
+
...input ? { body: input } : {},
|
|
2558
2594
|
rateLimiter: this.limiter
|
|
2559
2595
|
});
|
|
2596
|
+
return { raw };
|
|
2560
2597
|
}
|
|
2561
2598
|
};
|
|
2562
2599
|
var VideosResource = class {
|
|
@@ -2572,18 +2609,25 @@ var VideosResource = class {
|
|
|
2572
2609
|
* Queue a video for upload. Trendyol downloads from the URL in the
|
|
2573
2610
|
* body asynchronously; poll `list()` (filtered by id) for status.
|
|
2574
2611
|
*
|
|
2612
|
+
* Trendyol documents the response as `{ videoId: string }`; the SDK
|
|
2613
|
+
* surfaces it as `videoId` (pass it to `list({ id })`) and keeps the
|
|
2614
|
+
* untouched body on `raw`.
|
|
2615
|
+
*
|
|
2575
2616
|
* @throws {ValidationError} when `input` is empty / not an object.
|
|
2576
2617
|
*/
|
|
2577
2618
|
async create(input) {
|
|
2578
2619
|
if (!input || typeof input !== "object") {
|
|
2579
2620
|
throw new core.ValidationError({ message: "videos.create: input is required" });
|
|
2580
2621
|
}
|
|
2581
|
-
|
|
2622
|
+
const raw = await this.transport.request({
|
|
2582
2623
|
method: "POST",
|
|
2583
2624
|
path: `/integration/video/sellers/${this.transport.sellerId}/videos`,
|
|
2584
2625
|
body: input,
|
|
2585
2626
|
rateLimiter: this.createLimiter
|
|
2586
2627
|
});
|
|
2628
|
+
const out = { raw };
|
|
2629
|
+
if (typeof raw?.videoId === "string") out.videoId = raw.videoId;
|
|
2630
|
+
return out;
|
|
2587
2631
|
}
|
|
2588
2632
|
/** List the seller's integration videos (optionally filtered by id / status). */
|
|
2589
2633
|
async list(params = {}) {
|
|
@@ -2635,16 +2679,24 @@ var WebhooksResource = class {
|
|
|
2635
2679
|
* per seller — the SDK does NOT pre-check (you'd need to call `list()`
|
|
2636
2680
|
* first), but Trendyol returns 400 when the cap is exceeded.
|
|
2637
2681
|
*
|
|
2682
|
+
* Trendyol documents the response as `{ id: string }` — the webhook ID
|
|
2683
|
+
* you need for `update` / `delete` / `activate` / `deactivate`. The SDK
|
|
2684
|
+
* surfaces it as `id` and keeps the untouched body on `raw`.
|
|
2685
|
+
*
|
|
2638
2686
|
* @throws {ValidationError} when `url` or `authenticationType` is missing.
|
|
2639
2687
|
*/
|
|
2640
2688
|
async create(input) {
|
|
2641
2689
|
this.validateInput(input, "create");
|
|
2642
|
-
|
|
2690
|
+
const raw = await this.transport.request({
|
|
2643
2691
|
method: "POST",
|
|
2644
2692
|
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2645
2693
|
body: input,
|
|
2646
2694
|
rateLimiter: this.limiter
|
|
2647
2695
|
});
|
|
2696
|
+
const out = { raw };
|
|
2697
|
+
if (typeof raw?.id === "string") out.id = raw.id;
|
|
2698
|
+
else if (typeof raw?.id === "number") out.id = String(raw.id);
|
|
2699
|
+
return out;
|
|
2648
2700
|
}
|
|
2649
2701
|
/** List all registered webhook subscriptions. */
|
|
2650
2702
|
async list() {
|
|
@@ -2659,43 +2711,57 @@ var WebhooksResource = class {
|
|
|
2659
2711
|
/**
|
|
2660
2712
|
* Update a webhook subscription. Same input shape as `create`; replaces
|
|
2661
2713
|
* the whole subscription (Trendyol does NOT partially update).
|
|
2714
|
+
*
|
|
2715
|
+
* Documented response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2662
2716
|
*/
|
|
2663
2717
|
async update(webhookId, input) {
|
|
2664
2718
|
this.validateInput(input, "update");
|
|
2665
|
-
|
|
2719
|
+
const raw = await this.transport.request({
|
|
2666
2720
|
method: "PUT",
|
|
2667
2721
|
path: this.webhookPath(webhookId),
|
|
2668
2722
|
body: input,
|
|
2669
2723
|
rateLimiter: this.limiter
|
|
2670
2724
|
});
|
|
2725
|
+
return { raw };
|
|
2671
2726
|
}
|
|
2672
|
-
/**
|
|
2727
|
+
/**
|
|
2728
|
+
* Permanently delete a webhook subscription. Documented response is a
|
|
2729
|
+
* bare `200 OK` (no body), hence `MutationResult`.
|
|
2730
|
+
*/
|
|
2673
2731
|
async delete(webhookId) {
|
|
2674
|
-
|
|
2732
|
+
const raw = await this.transport.request({
|
|
2675
2733
|
method: "DELETE",
|
|
2676
2734
|
path: this.webhookPath(webhookId),
|
|
2677
2735
|
rateLimiter: this.limiter
|
|
2678
2736
|
});
|
|
2737
|
+
return { raw };
|
|
2679
2738
|
}
|
|
2680
|
-
/**
|
|
2739
|
+
/**
|
|
2740
|
+
* Re-activate a previously-deactivated webhook subscription. Documented
|
|
2741
|
+
* response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2742
|
+
*/
|
|
2681
2743
|
async activate(webhookId) {
|
|
2682
|
-
|
|
2744
|
+
const raw = await this.transport.request({
|
|
2683
2745
|
method: "PUT",
|
|
2684
2746
|
path: `${this.webhookPath(webhookId)}/activate`,
|
|
2685
2747
|
rateLimiter: this.limiter
|
|
2686
2748
|
});
|
|
2749
|
+
return { raw };
|
|
2687
2750
|
}
|
|
2688
2751
|
/**
|
|
2689
2752
|
* Deactivate a webhook subscription. Trendyol automatically deactivates
|
|
2690
2753
|
* a subscription after persistent delivery failures (and sends 2 emails);
|
|
2691
2754
|
* use `activate()` to bring it back online once your endpoint is healthy.
|
|
2755
|
+
*
|
|
2756
|
+
* Documented response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2692
2757
|
*/
|
|
2693
2758
|
async deactivate(webhookId) {
|
|
2694
|
-
|
|
2759
|
+
const raw = await this.transport.request({
|
|
2695
2760
|
method: "PUT",
|
|
2696
2761
|
path: `${this.webhookPath(webhookId)}/deactivate`,
|
|
2697
2762
|
rateLimiter: this.limiter
|
|
2698
2763
|
});
|
|
2764
|
+
return { raw };
|
|
2699
2765
|
}
|
|
2700
2766
|
validateInput(input, method) {
|
|
2701
2767
|
if (!input?.url || typeof input.url !== "string") {
|
|
@@ -2743,6 +2809,13 @@ function buildUserAgent(sellerId, integratorName) {
|
|
|
2743
2809
|
return `${sellerId} - ${integratorName}`;
|
|
2744
2810
|
}
|
|
2745
2811
|
function mapHttpError(status, body, retryAfterMs) {
|
|
2812
|
+
if ((status === 401 || status === 403) && typeof body === "string") {
|
|
2813
|
+
return new core.AuthError({
|
|
2814
|
+
message: `Trendyol rejected the request before it reached the API (HTTP ${status}, non-JSON body) \u2014 check IP allowlisting / credentials / User-Agent`,
|
|
2815
|
+
status,
|
|
2816
|
+
data: { bodyKind: /^\s*</.test(body) ? "html" : "text", bodyLength: body.length }
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2746
2819
|
const data = { body };
|
|
2747
2820
|
const issues = normalizeErrorIssues(body);
|
|
2748
2821
|
switch (status) {
|