@lonca/trendyol 1.1.0 → 1.2.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.
@@ -1,4 +1,4 @@
1
- import { g as BatchRequestStatus, ba as TrendyolClient } from './client-Bp0jKEU7.cjs';
1
+ import { g as BatchRequestStatus, ba as TrendyolClient } from './client-BhSJFkFo.cjs';
2
2
  import '@lonca/core';
3
3
 
4
4
  /** A request the fake client received, normalized for matching in a `handler`. */
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { g as BatchRequestStatus, ba as TrendyolClient } from './client-Bp0jKEU7.js';
1
+ import { g as BatchRequestStatus, ba as TrendyolClient } from './client-BhSJFkFo.js';
2
2
  import '@lonca/core';
3
3
 
4
4
  /** A request the fake client received, normalized for matching in a `handler`. */
package/dist/testing.js CHANGED
@@ -82,7 +82,6 @@ function normalizeCategory(node) {
82
82
  }
83
83
  function normalizeAttribute(node) {
84
84
  const attr = node.attribute ?? { id: 0, name: "" };
85
- const rawValues = node.attributeValues ?? [];
86
85
  const out = {
87
86
  id: String(attr.id),
88
87
  name: attr.name,
@@ -90,7 +89,8 @@ function normalizeAttribute(node) {
90
89
  allowCustom: !!node.allowCustom,
91
90
  varianter: !!node.varianter,
92
91
  slicer: !!node.slicer,
93
- values: rawValues.map((v) => ({ id: String(v.id), name: v.name }))
92
+ // Deprecated: normally empty — see `attributeValues` on the node above.
93
+ values: (node.attributeValues ?? []).map((v) => ({ id: String(v.id), name: v.name }))
94
94
  };
95
95
  if (node.categoryId !== void 0) {
96
96
  out.categoryId = String(node.categoryId);
@@ -152,8 +152,8 @@ var CategoriesResource = class {
152
152
  /**
153
153
  * Fetch the allowed values for a single category attribute (paginated).
154
154
  *
155
- * `getCategoryAttributes` returns attribute metadata + flags but typically
156
- * omits the value catalog. Use this method to fetch the catalog for an
155
+ * `getCategoryAttributes` returns attribute metadata + flags only, never the
156
+ * value catalog (docs and prod wire agree). Use this method to fetch the catalog for an
157
157
  * attribute when `allowCustom` is `false` and you need to map your data
158
158
  * onto Trendyol's accepted values.
159
159
  *
@@ -1100,8 +1100,7 @@ var LocationsResource = class {
1100
1100
  return n(data, (node) => ({
1101
1101
  id: node.id !== void 0 ? String(node.id) : void 0,
1102
1102
  code: String(node.code ?? node.id ?? ""),
1103
- name: node.name,
1104
- cityCode: node.cityCode !== void 0 ? String(node.cityCode) : void 0
1103
+ name: node.name
1105
1104
  }));
1106
1105
  }
1107
1106
  async neighborhoods(path) {
@@ -1110,12 +1109,16 @@ var LocationsResource = class {
1110
1109
  path,
1111
1110
  rateLimiter: this.limiter
1112
1111
  });
1113
- return n(data, (node) => ({
1114
- id: node.id !== void 0 ? String(node.id) : void 0,
1115
- code: String(node.code ?? node.id ?? ""),
1116
- name: node.name,
1117
- districtCode: node.districtCode !== void 0 ? String(node.districtCode) : void 0
1118
- }));
1112
+ return n(data, (node) => {
1113
+ const id = node.id !== void 0 ? String(node.id) : void 0;
1114
+ return {
1115
+ id,
1116
+ // Neighborhood rows have no code; `code` mirrors the id (as it always did in practice).
1117
+ code: id ?? "",
1118
+ name: node.name,
1119
+ postCode: typeof node.postCode === "string" ? node.postCode : void 0
1120
+ };
1121
+ });
1119
1122
  }
1120
1123
  };
1121
1124
  var MAX_PAGE_SIZE = 200;
@@ -2468,29 +2471,35 @@ var VALID_TYPES = /* @__PURE__ */ new Set([
2468
2471
  "WAREHOUSE"
2469
2472
  ]);
2470
2473
  function normalizeAddressType(raw) {
2471
- if (raw && VALID_TYPES.has(raw)) {
2472
- return raw;
2474
+ const upper = typeof raw === "string" ? raw.toUpperCase() : void 0;
2475
+ if (upper && VALID_TYPES.has(upper)) {
2476
+ return upper;
2473
2477
  }
2474
- const stripped = raw?.replace(/_ADDRESS$/, "");
2478
+ const stripped = upper?.replace(/_ADDRESS$/, "");
2475
2479
  if (stripped && VALID_TYPES.has(stripped)) {
2476
2480
  return stripped;
2477
2481
  }
2478
2482
  return "SHIPMENT";
2479
2483
  }
2484
+ function optionalString(value) {
2485
+ return typeof value === "number" || typeof value === "string" ? String(value) : void 0;
2486
+ }
2480
2487
  function normalizeAddress2(node) {
2481
2488
  return {
2482
2489
  id: String(node.id),
2483
- name: node.name,
2484
2490
  addressType: normalizeAddressType(node.addressType),
2485
2491
  isShipmentAddress: node.isShipmentAddress ?? false,
2486
2492
  isReturningAddress: node.isReturningAddress ?? false,
2487
2493
  isInvoiceAddress: node.isInvoiceAddress ?? false,
2488
2494
  isDefault: node.isDefault ?? false,
2489
2495
  address: node.address,
2496
+ fullAddress: node.fullAddress,
2497
+ country: node.country,
2490
2498
  city: node.city,
2499
+ cityCode: optionalString(node.cityCode),
2491
2500
  district: node.district,
2492
- postCode: node.postCode,
2493
- fullName: node.fullName
2501
+ districtId: optionalString(node.districtId),
2502
+ postCode: node.postCode
2494
2503
  };
2495
2504
  }
2496
2505
  var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;