@lonca/trendyol 1.1.0 → 1.2.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 CHANGED
@@ -41,7 +41,7 @@ Each entry is a method on the client.
41
41
  | `finance` | `getSettlements({...})`, `getOtherFinancials({...})` — both return typed `FinancialTransaction[]` |
42
42
  | `labels` | `createCommon(trackingNumber, {format: 'ZPL', ...})`, `getCommon(trackingNumber)` |
43
43
  | `testOrders` | `create({...})`, `updateStatus(id, status, { lines?, params? })`, `setClaimsWaitingInAction()` — **STAGE-only utility** |
44
- | `locations` | `getCountries()`, `getTurkeyCities()`, `getTurkeyDistricts(cityCode)`, `getTurkeyNeighborhoods(cityCode, districtCode)`, `getAzerbaijanCities()`, `getAzerbaijanDistricts(...)`, `getCitiesByCountry/getDistrictsByCity(...)` |
44
+ | `locations` | `getCountries()`, `getTurkeyCities()`, `getTurkeyDistricts(cityId)`, `getTurkeyNeighborhoods(cityId, districtId)`, `getAzerbaijanCities()`, `getAzerbaijanDistricts(...)`, `getCitiesByCountry/getDistrictsByCity(...)` |
45
45
  | `exportCenter` | `listProducts({...})`, `createProducts(items)`, `updatePrices(items)`, `updateStocks(items)`, `getBatchStatus(batchId)`, `listPackagesV2/V3({...})`, `getPackageItems({packageId, ...})`, `getCategoryAttributes(id)`, `getCareInstructions()`, `getCompositions()`, `getOrigins()` — **Trendyol Export Center / İhracat Merkezi** |
46
46
  | `videos` | `create({contentId, url, ...})`, `list({id?, sellerIntegrationStatus?, ...})` — product-page video upload + status |
47
47
  | **top-level** | `parseWebhookEvent(rawBody)`, `normalizeShipmentPackage(rawNode)` — for inbound webhook handlers |
@@ -377,8 +377,8 @@ const { videoId } = await client.videos.create({ title, videoUrl, productContent
377
377
  // locations (no sellerId — utility lookup)
378
378
  const countries = await client.locations.getCountries();
379
379
  const cities = await client.locations.getTurkeyCities();
380
- const districts = await client.locations.getTurkeyDistricts(cityCode);
381
- const neighborhoods = await client.locations.getTurkeyNeighborhoods(cityCode, districtCode);
380
+ const districts = await client.locations.getTurkeyDistricts(city.id); // pass ids, not codes
381
+ const neighborhoods = await client.locations.getTurkeyNeighborhoods(city.id, district.id); // Neighborhood: id, name, postCode
382
382
  ```
383
383
 
384
384
  ## Mutation results
@@ -160,13 +160,13 @@ interface CategoryAttribute {
160
160
  */
161
161
  allowMultipleAttributeValues?: boolean;
162
162
  /**
163
- * Allowed values for this attribute.
163
+ * Allowed values, only if the response inlines them — normally an empty array.
164
164
  *
165
- * NOTE: Trendyol's live API often omits this field on the `getCategoryAttributes`
166
- * response — the endpoint returns attribute metadata + flags, not the full value
167
- * catalog. In that case `values` is an empty array. If `allowCustom` is `true`,
168
- * any custom text is accepted; otherwise use `client.categories.getAttributeValues(categoryId, attributeId)`
169
- * to fetch the catalog from the dedicated V2 endpoint.
165
+ * @deprecated Trendyol's `getCategoryAttributes` response carries no value list — neither the
166
+ * docs nor the prod wire (2026-10-10) have `attributeValues` — so this is normally `[]` (an
167
+ * inline list from an older response format is still mapped). Fetch the catalog with
168
+ * `client.categories.getAttributeValues(categoryId, attributeId)` (with `paginate()`); when
169
+ * `allowCustom` is `true`, any custom text is accepted as well.
170
170
  */
171
171
  values: CategoryAttributeValue[];
172
172
  }
@@ -206,8 +206,8 @@ declare class CategoriesResource {
206
206
  /**
207
207
  * Fetch the allowed values for a single category attribute (paginated).
208
208
  *
209
- * `getCategoryAttributes` returns attribute metadata + flags but typically
210
- * omits the value catalog. Use this method to fetch the catalog for an
209
+ * `getCategoryAttributes` returns attribute metadata + flags only, never the
210
+ * value catalog (docs and prod wire agree). Use this method to fetch the catalog for an
211
211
  * attribute when `allowCustom` is `false` and you need to map your data
212
212
  * onto Trendyol's accepted values.
213
213
  *
@@ -823,16 +823,34 @@ interface City {
823
823
  interface District {
824
824
  /** Trendyol's internal district id — pass to `getTurkeyNeighborhoods(cityId, district.id)`. */
825
825
  id?: string;
826
+ /** Trendyol's district code (the prod wire's `code`; falls back to the id when a row has none). */
826
827
  code: string;
827
828
  name?: string;
829
+ /**
830
+ * @deprecated Trendyol's district rows carry no city reference — neither the docs nor the prod
831
+ * wire (2026-10-10) have one — so this is always `undefined`. Keep the city you passed to
832
+ * `getTurkeyDistricts` / `getAzerbaijanDistricts` / `getDistrictsByCity` instead.
833
+ */
828
834
  cityCode?: string;
829
835
  raw: Record<string, unknown>;
830
836
  }
831
837
  interface Neighborhood {
832
838
  /** Trendyol's internal neighborhood id. */
833
839
  id?: string;
840
+ /**
841
+ * @deprecated Trendyol's neighborhood rows have no code (prod wire 2026-10-10: `id`, `name`,
842
+ * `postCode`; the docs list `id` and `name`), so this is always the same value as `id` (`''`
843
+ * when the row has no id). Use `id`.
844
+ */
834
845
  code: string;
835
846
  name?: string;
847
+ /** The neighborhood's postal code (prod wire `postCode`; not in Trendyol's docs). */
848
+ postCode?: string;
849
+ /**
850
+ * @deprecated Trendyol's neighborhood rows carry no district reference — neither the docs nor
851
+ * the prod wire (2026-10-10) have one — so this is always `undefined`. Keep the district you
852
+ * passed to `getTurkeyNeighborhoods` instead.
853
+ */
836
854
  districtCode?: string;
837
855
  raw: Record<string, unknown>;
838
856
  }
@@ -2413,25 +2431,43 @@ type SupplierAddressType = 'SHIPMENT' | 'RETURNING' | 'INVOICE' | 'WAREHOUSE';
2413
2431
  *
2414
2432
  * Used by `createProduct V2` for `shipmentAddressId` / `returningAddressId`.
2415
2433
  *
2416
- * NOTE: The exact field set is best-effort; some optional fields may differ
2417
- * once verified against real STAGE responses. Bumped fields land in a follow-up
2418
- * minor release if needed.
2434
+ * Field set checked against the docs and the prod wire (2026-10-10).
2419
2435
  */
2420
2436
  interface SupplierAddress {
2421
2437
  id: string;
2422
- /** Free-form label set by the seller. */
2438
+ /**
2439
+ * @deprecated Trendyol's address rows carry no name or label — neither the docs nor the prod
2440
+ * wire (2026-10-10) have one — so this is always `undefined`. Identify an address by `id`,
2441
+ * `addressType` and the role flags; use `fullAddress` / `address` for its text.
2442
+ */
2423
2443
  name?: string;
2424
- /** Primary role declared by Trendyol. */
2444
+ /**
2445
+ * Primary role declared by Trendyol. The docs spell it `Shipment` / `Invoice` / `Returning`;
2446
+ * the SDK upper-cases it.
2447
+ */
2425
2448
  addressType: SupplierAddressType;
2426
2449
  isShipmentAddress: boolean;
2427
2450
  isReturningAddress: boolean;
2428
2451
  isInvoiceAddress: boolean;
2429
2452
  isDefault: boolean;
2430
- /** Multi-line address string as registered in the Partner Panel. */
2453
+ /** Street address as registered in the Partner Panel. */
2431
2454
  address?: string;
2455
+ /** The complete address text (Trendyol's `fullAddress`). */
2456
+ fullAddress?: string;
2457
+ /** Country name as Trendyol sends it. */
2458
+ country?: string;
2432
2459
  city?: string;
2460
+ /** Trendyol's city code (stringified from the wire number). */
2461
+ cityCode?: string;
2433
2462
  district?: string;
2463
+ /** Trendyol's district id (stringified from the wire number). */
2464
+ districtId?: string;
2434
2465
  postCode?: string;
2466
+ /**
2467
+ * @deprecated Trendyol's address rows carry no `fullName` — neither the docs nor the prod wire
2468
+ * (2026-10-10) have one — so this is always `undefined`. Use `fullAddress` for the complete
2469
+ * address text.
2470
+ */
2435
2471
  fullName?: string;
2436
2472
  }
2437
2473
 
@@ -160,13 +160,13 @@ interface CategoryAttribute {
160
160
  */
161
161
  allowMultipleAttributeValues?: boolean;
162
162
  /**
163
- * Allowed values for this attribute.
163
+ * Allowed values, only if the response inlines them — normally an empty array.
164
164
  *
165
- * NOTE: Trendyol's live API often omits this field on the `getCategoryAttributes`
166
- * response — the endpoint returns attribute metadata + flags, not the full value
167
- * catalog. In that case `values` is an empty array. If `allowCustom` is `true`,
168
- * any custom text is accepted; otherwise use `client.categories.getAttributeValues(categoryId, attributeId)`
169
- * to fetch the catalog from the dedicated V2 endpoint.
165
+ * @deprecated Trendyol's `getCategoryAttributes` response carries no value list — neither the
166
+ * docs nor the prod wire (2026-10-10) have `attributeValues` — so this is normally `[]` (an
167
+ * inline list from an older response format is still mapped). Fetch the catalog with
168
+ * `client.categories.getAttributeValues(categoryId, attributeId)` (with `paginate()`); when
169
+ * `allowCustom` is `true`, any custom text is accepted as well.
170
170
  */
171
171
  values: CategoryAttributeValue[];
172
172
  }
@@ -206,8 +206,8 @@ declare class CategoriesResource {
206
206
  /**
207
207
  * Fetch the allowed values for a single category attribute (paginated).
208
208
  *
209
- * `getCategoryAttributes` returns attribute metadata + flags but typically
210
- * omits the value catalog. Use this method to fetch the catalog for an
209
+ * `getCategoryAttributes` returns attribute metadata + flags only, never the
210
+ * value catalog (docs and prod wire agree). Use this method to fetch the catalog for an
211
211
  * attribute when `allowCustom` is `false` and you need to map your data
212
212
  * onto Trendyol's accepted values.
213
213
  *
@@ -823,16 +823,34 @@ interface City {
823
823
  interface District {
824
824
  /** Trendyol's internal district id — pass to `getTurkeyNeighborhoods(cityId, district.id)`. */
825
825
  id?: string;
826
+ /** Trendyol's district code (the prod wire's `code`; falls back to the id when a row has none). */
826
827
  code: string;
827
828
  name?: string;
829
+ /**
830
+ * @deprecated Trendyol's district rows carry no city reference — neither the docs nor the prod
831
+ * wire (2026-10-10) have one — so this is always `undefined`. Keep the city you passed to
832
+ * `getTurkeyDistricts` / `getAzerbaijanDistricts` / `getDistrictsByCity` instead.
833
+ */
828
834
  cityCode?: string;
829
835
  raw: Record<string, unknown>;
830
836
  }
831
837
  interface Neighborhood {
832
838
  /** Trendyol's internal neighborhood id. */
833
839
  id?: string;
840
+ /**
841
+ * @deprecated Trendyol's neighborhood rows have no code (prod wire 2026-10-10: `id`, `name`,
842
+ * `postCode`; the docs list `id` and `name`), so this is always the same value as `id` (`''`
843
+ * when the row has no id). Use `id`.
844
+ */
834
845
  code: string;
835
846
  name?: string;
847
+ /** The neighborhood's postal code (prod wire `postCode`; not in Trendyol's docs). */
848
+ postCode?: string;
849
+ /**
850
+ * @deprecated Trendyol's neighborhood rows carry no district reference — neither the docs nor
851
+ * the prod wire (2026-10-10) have one — so this is always `undefined`. Keep the district you
852
+ * passed to `getTurkeyNeighborhoods` instead.
853
+ */
836
854
  districtCode?: string;
837
855
  raw: Record<string, unknown>;
838
856
  }
@@ -2413,25 +2431,43 @@ type SupplierAddressType = 'SHIPMENT' | 'RETURNING' | 'INVOICE' | 'WAREHOUSE';
2413
2431
  *
2414
2432
  * Used by `createProduct V2` for `shipmentAddressId` / `returningAddressId`.
2415
2433
  *
2416
- * NOTE: The exact field set is best-effort; some optional fields may differ
2417
- * once verified against real STAGE responses. Bumped fields land in a follow-up
2418
- * minor release if needed.
2434
+ * Field set checked against the docs and the prod wire (2026-10-10).
2419
2435
  */
2420
2436
  interface SupplierAddress {
2421
2437
  id: string;
2422
- /** Free-form label set by the seller. */
2438
+ /**
2439
+ * @deprecated Trendyol's address rows carry no name or label — neither the docs nor the prod
2440
+ * wire (2026-10-10) have one — so this is always `undefined`. Identify an address by `id`,
2441
+ * `addressType` and the role flags; use `fullAddress` / `address` for its text.
2442
+ */
2423
2443
  name?: string;
2424
- /** Primary role declared by Trendyol. */
2444
+ /**
2445
+ * Primary role declared by Trendyol. The docs spell it `Shipment` / `Invoice` / `Returning`;
2446
+ * the SDK upper-cases it.
2447
+ */
2425
2448
  addressType: SupplierAddressType;
2426
2449
  isShipmentAddress: boolean;
2427
2450
  isReturningAddress: boolean;
2428
2451
  isInvoiceAddress: boolean;
2429
2452
  isDefault: boolean;
2430
- /** Multi-line address string as registered in the Partner Panel. */
2453
+ /** Street address as registered in the Partner Panel. */
2431
2454
  address?: string;
2455
+ /** The complete address text (Trendyol's `fullAddress`). */
2456
+ fullAddress?: string;
2457
+ /** Country name as Trendyol sends it. */
2458
+ country?: string;
2432
2459
  city?: string;
2460
+ /** Trendyol's city code (stringified from the wire number). */
2461
+ cityCode?: string;
2433
2462
  district?: string;
2463
+ /** Trendyol's district id (stringified from the wire number). */
2464
+ districtId?: string;
2434
2465
  postCode?: string;
2466
+ /**
2467
+ * @deprecated Trendyol's address rows carry no `fullName` — neither the docs nor the prod wire
2468
+ * (2026-10-10) have one — so this is always `undefined`. Use `fullAddress` for the complete
2469
+ * address text.
2470
+ */
2435
2471
  fullName?: string;
2436
2472
  }
2437
2473
 
package/dist/index.cjs CHANGED
@@ -84,7 +84,6 @@ function normalizeCategory(node) {
84
84
  }
85
85
  function normalizeAttribute(node) {
86
86
  const attr = node.attribute ?? { id: 0, name: "" };
87
- const rawValues = node.attributeValues ?? [];
88
87
  const out = {
89
88
  id: String(attr.id),
90
89
  name: attr.name,
@@ -92,7 +91,8 @@ function normalizeAttribute(node) {
92
91
  allowCustom: !!node.allowCustom,
93
92
  varianter: !!node.varianter,
94
93
  slicer: !!node.slicer,
95
- values: rawValues.map((v) => ({ id: String(v.id), name: v.name }))
94
+ // Deprecated: normally empty — see `attributeValues` on the node above.
95
+ values: (node.attributeValues ?? []).map((v) => ({ id: String(v.id), name: v.name }))
96
96
  };
97
97
  if (node.categoryId !== void 0) {
98
98
  out.categoryId = String(node.categoryId);
@@ -154,8 +154,8 @@ var CategoriesResource = class {
154
154
  /**
155
155
  * Fetch the allowed values for a single category attribute (paginated).
156
156
  *
157
- * `getCategoryAttributes` returns attribute metadata + flags but typically
158
- * omits the value catalog. Use this method to fetch the catalog for an
157
+ * `getCategoryAttributes` returns attribute metadata + flags only, never the
158
+ * value catalog (docs and prod wire agree). Use this method to fetch the catalog for an
159
159
  * attribute when `allowCustom` is `false` and you need to map your data
160
160
  * onto Trendyol's accepted values.
161
161
  *
@@ -1102,8 +1102,7 @@ var LocationsResource = class {
1102
1102
  return n(data, (node) => ({
1103
1103
  id: node.id !== void 0 ? String(node.id) : void 0,
1104
1104
  code: String(node.code ?? node.id ?? ""),
1105
- name: node.name,
1106
- cityCode: node.cityCode !== void 0 ? String(node.cityCode) : void 0
1105
+ name: node.name
1107
1106
  }));
1108
1107
  }
1109
1108
  async neighborhoods(path) {
@@ -1112,12 +1111,16 @@ var LocationsResource = class {
1112
1111
  path,
1113
1112
  rateLimiter: this.limiter
1114
1113
  });
1115
- return n(data, (node) => ({
1116
- id: node.id !== void 0 ? String(node.id) : void 0,
1117
- code: String(node.code ?? node.id ?? ""),
1118
- name: node.name,
1119
- districtCode: node.districtCode !== void 0 ? String(node.districtCode) : void 0
1120
- }));
1114
+ return n(data, (node) => {
1115
+ const id = node.id !== void 0 ? String(node.id) : void 0;
1116
+ return {
1117
+ id,
1118
+ // Neighborhood rows have no code; `code` mirrors the id (as it always did in practice).
1119
+ code: id ?? "",
1120
+ name: node.name,
1121
+ postCode: typeof node.postCode === "string" ? node.postCode : void 0
1122
+ };
1123
+ });
1121
1124
  }
1122
1125
  };
1123
1126
  var MAX_PAGE_SIZE = 200;
@@ -2473,29 +2476,35 @@ var VALID_TYPES = /* @__PURE__ */ new Set([
2473
2476
  "WAREHOUSE"
2474
2477
  ]);
2475
2478
  function normalizeAddressType(raw) {
2476
- if (raw && VALID_TYPES.has(raw)) {
2477
- return raw;
2479
+ const upper = typeof raw === "string" ? raw.toUpperCase() : void 0;
2480
+ if (upper && VALID_TYPES.has(upper)) {
2481
+ return upper;
2478
2482
  }
2479
- const stripped = raw?.replace(/_ADDRESS$/, "");
2483
+ const stripped = upper?.replace(/_ADDRESS$/, "");
2480
2484
  if (stripped && VALID_TYPES.has(stripped)) {
2481
2485
  return stripped;
2482
2486
  }
2483
2487
  return "SHIPMENT";
2484
2488
  }
2489
+ function optionalString(value) {
2490
+ return typeof value === "number" || typeof value === "string" ? String(value) : void 0;
2491
+ }
2485
2492
  function normalizeAddress2(node) {
2486
2493
  return {
2487
2494
  id: String(node.id),
2488
- name: node.name,
2489
2495
  addressType: normalizeAddressType(node.addressType),
2490
2496
  isShipmentAddress: node.isShipmentAddress ?? false,
2491
2497
  isReturningAddress: node.isReturningAddress ?? false,
2492
2498
  isInvoiceAddress: node.isInvoiceAddress ?? false,
2493
2499
  isDefault: node.isDefault ?? false,
2494
2500
  address: node.address,
2501
+ fullAddress: node.fullAddress,
2502
+ country: node.country,
2495
2503
  city: node.city,
2504
+ cityCode: optionalString(node.cityCode),
2496
2505
  district: node.district,
2497
- postCode: node.postCode,
2498
- fullName: node.fullName
2506
+ districtId: optionalString(node.districtId),
2507
+ postCode: node.postCode
2499
2508
  };
2500
2509
  }
2501
2510
  var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;