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