@lonca/trendyol 0.2.0 → 0.3.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/index.cjs CHANGED
@@ -36,6 +36,29 @@ var BrandsResource = class {
36
36
  const nextCursor = page + 1 < data.totalPages ? String(page + 1) : void 0;
37
37
  return nextCursor !== void 0 ? { items, nextCursor } : { items };
38
38
  }
39
+ /**
40
+ * Search brands by name. Useful when you need a brand's numeric ID for
41
+ * `createProducts` and don't want to page through the full `list()`
42
+ * (1000 brands per page).
43
+ *
44
+ * **Discovery-first wire fact (verified STAGE 2026-05-25):** Trendyol's
45
+ * doc claims this is a case-sensitive *exact* match, but live behaviour
46
+ * is **substring + case-insensitive** — `search('Trendyol')` returns
47
+ * 17 hits including `TRENDYOLMILLA`, `trendyol vavist`, `Trendyol Üyelik`.
48
+ * Plan for ranking your results client-side if you need an exact match.
49
+ * The endpoint returns an empty array when nothing matches (no 404).
50
+ *
51
+ * @param name The brand name to search for.
52
+ */
53
+ async search(name) {
54
+ const data = await this.transport.request({
55
+ method: "GET",
56
+ path: "/integration/product/brands/by-name",
57
+ query: { name },
58
+ rateLimiter: this.limiter
59
+ });
60
+ return (data ?? []).map((b) => ({ id: String(b.id), name: b.name }));
61
+ }
39
62
  };
40
63
  function normalizeCategory(node) {
41
64
  return {
@@ -65,12 +88,16 @@ function normalizeAttribute(node) {
65
88
  }
66
89
  return out;
67
90
  }
91
+ var MAX_ATTR_VALUES_PAGE_SIZE = 1e3;
92
+ var DEFAULT_ATTR_VALUES_PAGE_SIZE = 100;
68
93
  var CategoriesResource = class {
69
- constructor(transport, limiter) {
94
+ constructor(transport, limiter, sellerId) {
70
95
  this.transport = transport;
96
+ this.sellerId = sellerId;
71
97
  this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
72
98
  }
73
99
  transport;
100
+ sellerId;
74
101
  limiter;
75
102
  /**
76
103
  * Fetch the full Trendyol category tree.
@@ -112,6 +139,87 @@ var CategoriesResource = class {
112
139
  }
113
140
  return list.map(normalizeAttribute);
114
141
  }
142
+ /**
143
+ * Fetch the allowed values for a single category attribute (paginated).
144
+ *
145
+ * `getCategoryAttributes` returns attribute metadata + flags but typically
146
+ * omits the value catalog. Use this method to fetch the catalog for an
147
+ * attribute when `allowCustom` is `false` and you need to map your data
148
+ * onto Trendyol's accepted values.
149
+ *
150
+ * @param categoryId Trendyol numeric category ID; accepts `string` or `number`.
151
+ * @param attributeId Attribute ID returned by `getAttributes`.
152
+ * @param params Cursor pagination (max page size 1000; default 100).
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { paginate } from '@lonca/core';
157
+ * for await (const value of paginate((p) =>
158
+ * client.categories.getAttributeValues(catId, attrId, p),
159
+ * )) {
160
+ * console.log(value.id, value.name);
161
+ * }
162
+ * ```
163
+ */
164
+ async getAttributeValues(categoryId, attributeId, params = {}) {
165
+ const catId = encodeURIComponent(String(categoryId));
166
+ const attrId = encodeURIComponent(String(attributeId));
167
+ const size = Math.min(params.limit ?? DEFAULT_ATTR_VALUES_PAGE_SIZE, MAX_ATTR_VALUES_PAGE_SIZE);
168
+ const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
169
+ const data = await this.transport.request({
170
+ method: "GET",
171
+ path: `/integration/product/categories/${catId}/attributes/${attrId}/values`,
172
+ query: { page, size },
173
+ rateLimiter: this.limiter
174
+ });
175
+ const items = (data.content ?? []).map((item) => ({
176
+ id: item.attributeValueId !== void 0 ? String(item.attributeValueId) : "",
177
+ name: item.attributeValue ?? item.attributeValueName ?? ""
178
+ }));
179
+ const result = { items };
180
+ const totalPages = typeof data.totalPages === "number" ? data.totalPages : 0;
181
+ if (page + 1 < totalPages) {
182
+ result.nextCursor = String(page + 1);
183
+ }
184
+ return result;
185
+ }
186
+ /**
187
+ * Look up category info for a list of barcodes (Trendyol Export Center
188
+ * / AutoFT endpoint).
189
+ *
190
+ * **Requires Export Center enrollment.** Sellers who have not joined
191
+ * Trendyol's "İhracat Merkezi" program will get an auth error on this
192
+ * endpoint even though their regular Marketplace credentials are valid.
193
+ *
194
+ * @param barcodes 1–N barcodes to look up.
195
+ * @throws {ValidationError} when `barcodes` is empty.
196
+ * @throws Error when the client was created without a `sellerId` and this
197
+ * method is called directly (use `createTrendyolClient` to wire it).
198
+ */
199
+ async getByBarcodes(barcodes) {
200
+ if (!Array.isArray(barcodes) || barcodes.length === 0) {
201
+ throw new core.ValidationError({ message: "getByBarcodes: barcodes must not be empty" });
202
+ }
203
+ if (this.sellerId === void 0) {
204
+ throw new Error(
205
+ "CategoriesResource.getByBarcodes requires a sellerId; instantiate via createTrendyolClient"
206
+ );
207
+ }
208
+ const data = await this.transport.request({
209
+ method: "POST",
210
+ path: `/integration/ecgw/v1/${this.sellerId}/lookup/product-categories/by-barcodes`,
211
+ body: { barcodes },
212
+ rateLimiter: this.limiter
213
+ });
214
+ const matches = Object.entries(data.barcodeCategories ?? {}).map(([barcode, cat]) => ({
215
+ barcode,
216
+ category: {
217
+ id: cat.id !== void 0 ? String(cat.id) : "",
218
+ name: cat.displayName ?? ""
219
+ }
220
+ }));
221
+ return { matches, notFound: data.notFound ?? [] };
222
+ }
115
223
  };
116
224
  function extractAttributeList(data) {
117
225
  if (Array.isArray(data)) return data;
@@ -363,6 +471,7 @@ var OrdersResource = class {
363
471
  };
364
472
  var DEFAULT_PAGE_SIZE3 = 50;
365
473
  var MAX_PAGE_SIZE2 = 1e3;
474
+ var MAX_BUYBOX_BARCODES = 10;
366
475
  function normalizeRef(ref) {
367
476
  return {
368
477
  id: ref?.id !== void 0 ? String(ref.id) : "",
@@ -427,6 +536,82 @@ function normalizeProduct(node) {
427
536
  if (node.lastModifiedBy !== void 0) out.lastModifiedBy = node.lastModifiedBy;
428
537
  return out;
429
538
  }
539
+ function normalizeUnapprovedRejectReason(r) {
540
+ const out = {};
541
+ if (r.rejectReason !== void 0) out.rejectReason = r.rejectReason;
542
+ if (r.rejectReasonDetail !== void 0) out.rejectReasonDetail = r.rejectReasonDetail;
543
+ return out;
544
+ }
545
+ function normalizeUnapproved(node) {
546
+ const imagesSource = node.images ?? node.media;
547
+ const out = {
548
+ productMainId: node.productMainId ?? "",
549
+ brand: normalizeRef(node.brand),
550
+ category: normalizeRef(node.category),
551
+ barcode: node.barcode ?? "",
552
+ title: node.title ?? "",
553
+ images: normalizeImages(imagesSource),
554
+ attributes: (node.attributes ?? []).map(normalizeAttribute2),
555
+ rejectReasonDetails: (node.rejectReasonDetails ?? []).map(normalizeUnapprovedRejectReason),
556
+ raw: node
557
+ };
558
+ if (node.supplierId !== void 0) out.supplierId = String(node.supplierId);
559
+ if (node.status !== void 0) out.status = node.status;
560
+ if (node.description !== void 0) out.description = node.description;
561
+ if (typeof node.quantity === "number") out.quantity = node.quantity;
562
+ if (typeof node.listPrice === "number") out.listPrice = node.listPrice;
563
+ if (typeof node.salePrice === "number") out.salePrice = node.salePrice;
564
+ if (typeof node.vatRate === "number") out.vatRate = node.vatRate;
565
+ if (node.dimensionalWeight !== void 0 && node.dimensionalWeight !== null) {
566
+ out.dimensionalWeight = node.dimensionalWeight;
567
+ }
568
+ if (node.stockCode !== void 0) out.stockCode = node.stockCode;
569
+ if (node.origin !== void 0) out.origin = node.origin;
570
+ if (node.locationBasedDelivery !== void 0) {
571
+ out.locationBasedDelivery = node.locationBasedDelivery;
572
+ }
573
+ if (node.lotNumber !== void 0) out.lotNumber = node.lotNumber;
574
+ if (node.specialConsumptionTax !== void 0) {
575
+ out.specialConsumptionTax = node.specialConsumptionTax;
576
+ }
577
+ if (node.sgrPrice !== void 0) out.sgrPrice = node.sgrPrice;
578
+ const createdAt = toIso2(node.createDateTime);
579
+ if (createdAt) out.createdAt = createdAt;
580
+ const updatedAt = toIso2(node.lastUpdateDate);
581
+ if (updatedAt) out.updatedAt = updatedAt;
582
+ const priceChanged = toIso2(node.lastPriceChangeDate);
583
+ if (priceChanged) out.lastPriceChangedAt = priceChanged;
584
+ const stockChanged = toIso2(node.lastStockChangeDate);
585
+ if (stockChanged) out.lastStockChangedAt = stockChanged;
586
+ return out;
587
+ }
588
+ function normalizeBuyboxInfo(node) {
589
+ const out = {
590
+ barcode: node.barcode ?? "",
591
+ raw: node
592
+ };
593
+ if (typeof node.buyboxOrder === "number") out.buyboxOrder = node.buyboxOrder;
594
+ if (typeof node.buyboxPrice === "number") out.buyboxPrice = node.buyboxPrice;
595
+ if (typeof node.hasMultipleSeller === "boolean") {
596
+ out.hasMultipleSeller = node.hasMultipleSeller;
597
+ }
598
+ if (node.secondBuyboxPrice !== void 0) out.secondBuyboxPrice = node.secondBuyboxPrice;
599
+ if (node.thirdBuyboxPrice !== void 0) out.thirdBuyboxPrice = node.thirdBuyboxPrice;
600
+ return out;
601
+ }
602
+ function normalizeProductBase(data) {
603
+ const out = {
604
+ barcode: data.barcode ?? "",
605
+ approved: !!data.approved,
606
+ archived: !!data.archived,
607
+ raw: data
608
+ };
609
+ const approvedAt = toIso2(data.approvedDate);
610
+ if (approvedAt) out.approvedAt = approvedAt;
611
+ if (data.listingId !== void 0) out.listingId = data.listingId;
612
+ if (data.contentId !== void 0) out.contentId = String(data.contentId);
613
+ return out;
614
+ }
430
615
  function normalizeBatchResult(data) {
431
616
  const items = (data.items ?? []).map((item) => {
432
617
  const result = {};
@@ -454,17 +639,52 @@ function normalizeBatchResult(data) {
454
639
  if (data.storeFrontCode !== void 0) out.storeFrontCode = data.storeFrontCode;
455
640
  return out;
456
641
  }
642
+ var MAX_WRITE_ITEMS = 1e3;
643
+ var DELETE_RATE_PER_MIN = 100;
457
644
  var ProductsResource = class {
458
645
  constructor(transport, sellerId, options = {}) {
459
646
  this.transport = transport;
460
647
  this.sellerId = sellerId;
461
648
  this.filterLimiter = options.filterLimiter ?? new core.TokenBucketRateLimiter({ capacity: 2e3, intervalMs: 6e4 });
462
649
  this.batchLimiter = options.batchLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
650
+ this.buyboxLimiter = options.buyboxLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
651
+ this.writeLimiter = options.writeLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
652
+ this.deleteLimiter = options.deleteLimiter ?? new core.TokenBucketRateLimiter({ capacity: DELETE_RATE_PER_MIN, intervalMs: 6e4 });
463
653
  }
464
654
  transport;
465
655
  sellerId;
466
656
  filterLimiter;
467
657
  batchLimiter;
658
+ buyboxLimiter;
659
+ writeLimiter;
660
+ deleteLimiter;
661
+ validateBarcodes(barcodes, methodLabel) {
662
+ if (!Array.isArray(barcodes) || barcodes.length === 0) {
663
+ throw new core.ValidationError({ message: `${methodLabel}: barcodes must not be empty` });
664
+ }
665
+ if (barcodes.length > MAX_WRITE_ITEMS) {
666
+ throw new core.ValidationError({
667
+ message: `${methodLabel}: max ${MAX_WRITE_ITEMS} barcodes per call (got ${barcodes.length})`
668
+ });
669
+ }
670
+ }
671
+ async submitWrite(endpoint, items, methodLabel) {
672
+ if (!Array.isArray(items) || items.length === 0) {
673
+ throw new core.ValidationError({ message: `${methodLabel}: items must not be empty` });
674
+ }
675
+ if (items.length > MAX_WRITE_ITEMS) {
676
+ throw new core.ValidationError({
677
+ message: `${methodLabel}: max ${MAX_WRITE_ITEMS} items per call (got ${items.length})`
678
+ });
679
+ }
680
+ const data = await this.transport.request({
681
+ method: "POST",
682
+ path: `/integration/product/sellers/${this.sellerId}${endpoint}`,
683
+ body: { items },
684
+ rateLimiter: this.writeLimiter
685
+ });
686
+ return { batchRequestId: data?.batchRequestId ?? "" };
687
+ }
468
688
  /**
469
689
  * List approved products. Use `paginate()` from `@lonca/core` to iterate
470
690
  * lazily across pages.
@@ -526,6 +746,235 @@ var ProductsResource = class {
526
746
  });
527
747
  return normalizeBatchResult(data);
528
748
  }
749
+ /**
750
+ * List **unapproved** (draft / rejected / pending-review) products.
751
+ *
752
+ * Wire shape is intentionally flatter than the approved-product shape:
753
+ * each barcode is one top-level item with `barcode`, `quantity`, `salePrice`
754
+ * etc. at the root. Rejected drafts carry `rejectReasonDetails` so you can
755
+ * surface why Trendyol's content team turned them down.
756
+ *
757
+ * Pagination follows the same convention as `list()`: `cursor` from the
758
+ * previous response forwards as `nextPageToken`.
759
+ *
760
+ * @example
761
+ * ```ts
762
+ * const page = await client.products.listUnapproved({ limit: 50 });
763
+ * for (const draft of page.items) {
764
+ * if (draft.status === 'rejected') {
765
+ * console.warn(draft.barcode, draft.rejectReasonDetails);
766
+ * }
767
+ * }
768
+ * ```
769
+ */
770
+ async listUnapproved(params = {}) {
771
+ const size = Math.min(params.limit ?? DEFAULT_PAGE_SIZE3, MAX_PAGE_SIZE2);
772
+ const query = { size };
773
+ if (params.cursor) {
774
+ query.nextPageToken = params.cursor;
775
+ } else {
776
+ query.page = 0;
777
+ }
778
+ if (params.barcode) query.barcode = params.barcode;
779
+ if (params.startDate) query.startDate = params.startDate.getTime();
780
+ if (params.endDate) query.endDate = params.endDate.getTime();
781
+ if (params.dateQueryType) query.dateQueryType = params.dateQueryType;
782
+ if (params.supplierId !== void 0) query.supplierId = params.supplierId;
783
+ const data = await this.transport.request({
784
+ method: "GET",
785
+ path: `/integration/product/sellers/${this.sellerId}/products/unapproved`,
786
+ query,
787
+ rateLimiter: this.filterLimiter
788
+ });
789
+ const items = (data.content ?? []).map(normalizeUnapproved);
790
+ const page = { items };
791
+ if (data.nextPageToken) {
792
+ page.nextCursor = data.nextPageToken;
793
+ }
794
+ return page;
795
+ }
796
+ /**
797
+ * Fetch the basic lifecycle status of a single product by barcode.
798
+ *
799
+ * Cheap and useful as a polling primitive after `createProducts`: poll
800
+ * this endpoint until `approved` flips to `true` (or use
801
+ * `client.products.getBatchStatus()` to track the originating batch).
802
+ *
803
+ * @param barcode The product barcode to look up.
804
+ */
805
+ async getBase(barcode) {
806
+ const code = encodeURIComponent(barcode);
807
+ const data = await this.transport.request({
808
+ method: "GET",
809
+ path: `/integration/product/sellers/${this.sellerId}/product/${code}`,
810
+ rateLimiter: this.filterLimiter
811
+ });
812
+ return normalizeProductBase(data);
813
+ }
814
+ /**
815
+ * Fetch buybox information for up to 10 barcodes in one call.
816
+ *
817
+ * Returns rank (`buyboxOrder === 1` means you hold the buybox), the
818
+ * current buybox price, and — beyond the spec — the second and third
819
+ * competing prices when other sellers are present.
820
+ *
821
+ * @param barcodes 1–10 product barcodes.
822
+ * @throws {ValidationError} when `barcodes` is empty or longer than 10.
823
+ */
824
+ async getBuyboxInfo(barcodes) {
825
+ if (!Array.isArray(barcodes) || barcodes.length === 0) {
826
+ throw new core.ValidationError({
827
+ message: "getBuyboxInfo: barcodes must be a non-empty array"
828
+ });
829
+ }
830
+ if (barcodes.length > MAX_BUYBOX_BARCODES) {
831
+ throw new core.ValidationError({
832
+ message: `getBuyboxInfo: max ${MAX_BUYBOX_BARCODES} barcodes per call (got ${barcodes.length})`
833
+ });
834
+ }
835
+ const data = await this.transport.request({
836
+ method: "POST",
837
+ path: `/integration/product/sellers/${this.sellerId}/products/buybox-information`,
838
+ body: { barcodes },
839
+ rateLimiter: this.buyboxLimiter
840
+ });
841
+ const list = data.buyboxInfo ?? data.content ?? [];
842
+ return list.map(normalizeBuyboxInfo);
843
+ }
844
+ /**
845
+ * Create products (V2). Async batch — returns a `batchRequestId` you can
846
+ * poll with `getBatchStatus`. Max 1000 items per call.
847
+ *
848
+ * Trendyol requires the full V2 attribute payload — fetch via
849
+ * `categories.getAttributes` (and `categories.getAttributeValues` for
850
+ * values when `allowCustom === false`). Shipment / returning warehouse
851
+ * IDs come from `suppliers.getAddresses`.
852
+ *
853
+ * @throws {ValidationError} when `items` is empty or longer than 1000.
854
+ */
855
+ async create(items) {
856
+ return this.submitWrite("/v2/products", items, "createProducts");
857
+ }
858
+ /**
859
+ * Update **content** of approved products (title, description, images,
860
+ * attributes). Identified by `contentId`. Partial update is supported
861
+ * except for attributes — if you update ANY attribute, send ALL of them.
862
+ *
863
+ * @throws {ValidationError} when `items` is empty or longer than 1000.
864
+ */
865
+ async updateContent(items) {
866
+ return this.submitWrite("/products/content-bulk-update", items, "updateContent");
867
+ }
868
+ /**
869
+ * Update **variant** fields of approved products (stockCode, vatRate,
870
+ * dimensionalWeight, warehouse IDs, location-based delivery, lot). Identified
871
+ * by `barcode`. The barcode itself cannot be changed via this endpoint.
872
+ *
873
+ * @throws {ValidationError} when `items` is empty or longer than 1000.
874
+ */
875
+ async updateVariants(items) {
876
+ return this.submitWrite("/products/variant-bulk-update", items, "updateVariants");
877
+ }
878
+ /**
879
+ * Update **unapproved** (draft) products. Identified by `barcode`. All
880
+ * other fields are optional partial updates. Use this to fix drafts that
881
+ * Trendyol rejected — `client.products.listUnapproved` surfaces the
882
+ * `rejectReasonDetails` you need to act on.
883
+ *
884
+ * **Gotcha (verified live STAGE 2026-05-25):** Trendyol's V2 spec claims
885
+ * only `barcode` is required, but the endpoint returns HTTP 500
886
+ * (`TrendyolSystemException` / `TypeError`) when too many optional fields
887
+ * are omitted. In practice, send at least `title`, `description`,
888
+ * `productMainId`, `brandId`, `categoryId`, `stockCode`,
889
+ * `dimensionalWeight`, `vatRate`, `images[]`, and `attributes[]` (an
890
+ * empty array is OK for the latter). The SDK forwards your payload
891
+ * as-is; trim fields only if you have verified the server accepts it.
892
+ *
893
+ * @throws {ValidationError} when `items` is empty or longer than 1000.
894
+ */
895
+ async updateUnapproved(items) {
896
+ return this.submitWrite("/products/unapproved-bulk-update", items, "updateUnapproved");
897
+ }
898
+ /**
899
+ * Update product **delivery information** (deliveryDuration,
900
+ * fastDeliveryType). Identified by `barcode`.
901
+ *
902
+ * @throws {ValidationError} when `items` is empty or longer than 1000.
903
+ */
904
+ async updateDeliveryInfo(items) {
905
+ return this.submitWrite("/products/delivery-info-bulk-update", items, "updateDeliveryInfo");
906
+ }
907
+ /**
908
+ * Delete products by barcode. Trendyol allows deletion of unapproved
909
+ * products and approved products that have been archived for more than a
910
+ * day (and have not been sales-stopped by Trendyol).
911
+ *
912
+ * Async batch — returns `{ batchRequestId }` to poll via `getBatchStatus`.
913
+ * Separately rate-limited at **100 req/min** (much tighter than create/update).
914
+ *
915
+ * @param barcodes 1–1000 barcodes.
916
+ * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
917
+ */
918
+ async delete(barcodes) {
919
+ this.validateBarcodes(barcodes, "delete");
920
+ const data = await this.transport.request({
921
+ method: "DELETE",
922
+ path: `/integration/product/sellers/${this.sellerId}/products`,
923
+ body: { items: barcodes.map((barcode) => ({ barcode })) },
924
+ rateLimiter: this.deleteLimiter
925
+ });
926
+ return { batchRequestId: data?.batchRequestId ?? "" };
927
+ }
928
+ /**
929
+ * Archive products by barcode (Trendyol's `archived=true` state).
930
+ * Archived products are not visible to customers; pair with `delete`
931
+ * after the 24-hour archive cool-down to remove them entirely.
932
+ *
933
+ * Async batch — returns `{ batchRequestId }`.
934
+ *
935
+ * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
936
+ */
937
+ async archive(barcodes) {
938
+ return this.setArchivedState(barcodes, true, "archive");
939
+ }
940
+ /**
941
+ * Unarchive products by barcode (Trendyol's `archived=false` state).
942
+ * Restores visibility for previously-archived products.
943
+ *
944
+ * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
945
+ */
946
+ async unarchive(barcodes) {
947
+ return this.setArchivedState(barcodes, false, "unarchive");
948
+ }
949
+ async setArchivedState(barcodes, archived, methodLabel) {
950
+ this.validateBarcodes(barcodes, methodLabel);
951
+ const data = await this.transport.request({
952
+ method: "PUT",
953
+ path: `/integration/product/sellers/${this.sellerId}/products/archive-state`,
954
+ body: { items: barcodes.map((barcode) => ({ barcode, archived })) },
955
+ rateLimiter: this.writeLimiter
956
+ });
957
+ return { batchRequestId: data?.batchRequestId ?? "" };
958
+ }
959
+ /**
960
+ * Unlock products whose sale was paused by Trendyol due to pricing
961
+ * issues (under/over-pricing, critical price error, supplier issues).
962
+ * Restores selling status for the listed barcodes.
963
+ *
964
+ * Async batch — returns `{ batchRequestId }`.
965
+ *
966
+ * @throws {ValidationError} when `barcodes` is empty or longer than 1000.
967
+ */
968
+ async unlock(barcodes) {
969
+ this.validateBarcodes(barcodes, "unlock");
970
+ const data = await this.transport.request({
971
+ method: "PUT",
972
+ path: `/integration/product/sellers/${this.sellerId}/products/unlock`,
973
+ body: { items: barcodes.map((barcode) => ({ barcode })) },
974
+ rateLimiter: this.writeLimiter
975
+ });
976
+ return { batchRequestId: data?.batchRequestId ?? "" };
977
+ }
529
978
  };
530
979
  var VALID_TYPES = /* @__PURE__ */ new Set([
531
980
  "SHIPMENT",
@@ -810,7 +1259,7 @@ function createTrendyolClient(opts) {
810
1259
  });
811
1260
  return {
812
1261
  brands: new BrandsResource(transport),
813
- categories: new CategoriesResource(transport),
1262
+ categories: new CategoriesResource(transport, void 0, opts.sellerId),
814
1263
  suppliers: new SuppliersResource(transport, opts.sellerId),
815
1264
  products: new ProductsResource(transport, opts.sellerId),
816
1265
  inventory: new InventoryResource(transport, opts.sellerId),