@lonca/trendyol 0.11.3 → 0.13.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.
@@ -1,4 +1,4 @@
1
- import { f as BatchRequestStatus, b3 as TrendyolClient } from './client-BJjLOn4v.cjs';
1
+ import { f as BatchRequestStatus, b3 as TrendyolClient } from './client-DMndJSb0.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 { f as BatchRequestStatus, b3 as TrendyolClient } from './client-BJjLOn4v.js';
1
+ import { f as BatchRequestStatus, b3 as TrendyolClient } from './client-DMndJSb0.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
@@ -714,12 +714,20 @@ var FinanceResource = class {
714
714
  );
715
715
  }
716
716
  async queryPage(path, params) {
717
- const size = Math.min(params.limit ?? 50, 200);
717
+ if (!params.transactionType) {
718
+ throw new ValidationError({
719
+ message: "finance: transactionType is required (Trendyol returns 500 without it) \u2014 pass e.g. { transactionType: 'Sale' }."
720
+ });
721
+ }
722
+ const size = (params.limit ?? 500) > 500 ? 1e3 : 500;
718
723
  const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
719
- const query = { page, size };
724
+ const query = {
725
+ page,
726
+ size,
727
+ transactionType: params.transactionType
728
+ };
720
729
  if (params.startDate) query.startDate = params.startDate.getTime();
721
730
  if (params.endDate) query.endDate = params.endDate.getTime();
722
- if (params.transactionType) query.transactionType = params.transactionType;
723
731
  const data = await this.transport.request({
724
732
  method: "GET",
725
733
  path,
@@ -996,22 +1004,32 @@ var LocationsResource = class {
996
1004
  async getTurkeyCities() {
997
1005
  return this.cities(`/integration/member/countries/domestic/TR/cities`);
998
1006
  }
999
- async getTurkeyDistricts(cityCode) {
1007
+ /**
1008
+ * List districts for a Turkish city. **Pass the city `id`** (`City.id`) — the
1009
+ * nested endpoint keys off Trendyol's internal id, not the display `code`, and
1010
+ * returns 500 for the code. Verified live.
1011
+ */
1012
+ async getTurkeyDistricts(cityId) {
1000
1013
  return this.districts(
1001
- `/integration/member/countries/domestic/TR/cities/${encodeURIComponent(String(cityCode))}/districts`
1014
+ `/integration/member/countries/domestic/TR/cities/${encodeURIComponent(String(cityId))}/districts`
1002
1015
  );
1003
1016
  }
1004
- async getTurkeyNeighborhoods(cityCode, districtCode) {
1017
+ /**
1018
+ * List neighborhoods for a Turkish district. **Pass the ids** (`City.id`,
1019
+ * `District.id`) — not the display codes (those 500).
1020
+ */
1021
+ async getTurkeyNeighborhoods(cityId, districtId) {
1005
1022
  return this.neighborhoods(
1006
- `/integration/member/countries/domestic/TR/cities/${encodeURIComponent(String(cityCode))}/districts/${encodeURIComponent(String(districtCode))}/neighborhoods`
1023
+ `/integration/member/countries/domestic/TR/cities/${encodeURIComponent(String(cityId))}/districts/${encodeURIComponent(String(districtId))}/neighborhoods`
1007
1024
  );
1008
1025
  }
1009
1026
  async getAzerbaijanCities() {
1010
1027
  return this.cities(`/integration/member/countries/domestic/AZ/cities`);
1011
1028
  }
1012
- async getAzerbaijanDistricts(cityCode) {
1029
+ /** List districts for an Azerbaijani city. **Pass the city `id`** (`City.id`), not `code`. */
1030
+ async getAzerbaijanDistricts(cityId) {
1013
1031
  return this.districts(
1014
- `/integration/member/countries/domestic/AZ/cities/${encodeURIComponent(String(cityCode))}/districts`
1032
+ `/integration/member/countries/domestic/AZ/cities/${encodeURIComponent(String(cityId))}/districts`
1015
1033
  );
1016
1034
  }
1017
1035
  // ─── International (GULF / CEE) ───────────────────────────────────────
@@ -1031,6 +1049,7 @@ var LocationsResource = class {
1031
1049
  rateLimiter: this.limiter
1032
1050
  });
1033
1051
  return n(data, (node) => ({
1052
+ id: node.id !== void 0 ? String(node.id) : void 0,
1034
1053
  code: String(node.code ?? node.id ?? ""),
1035
1054
  name: node.name,
1036
1055
  countryCode: node.countryCode
@@ -1043,6 +1062,7 @@ var LocationsResource = class {
1043
1062
  rateLimiter: this.limiter
1044
1063
  });
1045
1064
  return n(data, (node) => ({
1065
+ id: node.id !== void 0 ? String(node.id) : void 0,
1046
1066
  code: String(node.code ?? node.id ?? ""),
1047
1067
  name: node.name,
1048
1068
  cityCode: node.cityCode !== void 0 ? String(node.cityCode) : void 0
@@ -1055,6 +1075,7 @@ var LocationsResource = class {
1055
1075
  rateLimiter: this.limiter
1056
1076
  });
1057
1077
  return n(data, (node) => ({
1078
+ id: node.id !== void 0 ? String(node.id) : void 0,
1058
1079
  code: String(node.code ?? node.id ?? ""),
1059
1080
  name: node.name,
1060
1081
  districtCode: node.districtCode !== void 0 ? String(node.districtCode) : void 0