@teez-sdk/teez-b2c-api 2.1.0 → 3.0.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.mjs CHANGED
@@ -1,75 +1,9 @@
1
1
  import * as z from "zod/mini";
2
+ import { safeParse } from "zod/mini";
2
3
 
3
- //#region src/errors/teez-error.ts
4
- /**
5
- * Base error class for all SDK-related errors.
6
- */
7
- var TeezError = class extends Error {
8
- name = "TeezError";
9
- };
10
-
11
- //#endregion
12
- //#region src/errors/teez-validation-error.ts
13
- /**
14
- * Error thrown when validation fails.
15
- */
16
- var TeezValidationError = class extends TeezError {
17
- name = "TeezValidationError";
18
- /**
19
- * List of standardized validation issues.
20
- */
21
- issues;
22
- /**
23
- * The raw data that failed validation.
24
- */
25
- data;
26
- constructor(message, { issues, data, ...errorOptions }) {
27
- super(message, errorOptions);
28
- this.issues = issues;
29
- this.data = data;
30
- }
31
- };
32
-
33
- //#endregion
34
- //#region src/http/helpers.ts
35
- /**
36
- * Constructs a full URL with query parameters.
37
- */
38
- function buildUrl(path, baseUrl, queryParams) {
39
- const url = new URL(path, baseUrl);
40
- if (queryParams != void 0) for (const [key, value] of Object.entries(queryParams)) {
41
- if (value == void 0) continue;
42
- if (Array.isArray(value)) for (const item of value) url.searchParams.append(key, String(item));
43
- else url.searchParams.set(key, String(value));
44
- }
45
- return String(url);
46
- }
47
- /**
48
- * Converts Zod ZodError to abstract ValidationIssue[].
49
- */
50
- function toValidationIssues(error) {
51
- return error.issues.map((issue) => ({
52
- code: issue.code,
53
- path: issue.path,
54
- message: issue.message
55
- }));
56
- }
57
- /**
58
- * Validates and parses the API response data against a schema.
59
- */
60
- function parseResponse(schema, data) {
61
- const result = z.safeParse(schema, data);
62
- if (!result.success) throw new TeezValidationError("Response validation failed", {
63
- issues: toValidationIssues(result.error),
64
- data
65
- });
66
- return result.data;
67
- }
68
-
69
- //#endregion
70
4
  //#region src/api/auth/schemas.ts
71
5
  /**
72
- * Response schema for login.
6
+ * Response schema for initiating phone login.
73
7
  */
74
8
  const AuthApiLoginResponseSchema = z.void();
75
9
  /**
@@ -77,13 +11,13 @@ const AuthApiLoginResponseSchema = z.void();
77
11
  */
78
12
  const AuthApiVerifyResponseSchema = z.object({
79
13
  userId: z.string(),
14
+ phone: z.string(),
80
15
  accessToken: z.string(),
81
16
  refreshToken: z.string(),
82
- phone: z.string(),
17
+ paymentId: z.nullish(z.number()),
83
18
  pickupPoint: z.nullish(z.unknown()),
84
19
  address: z.nullish(z.unknown()),
85
- recipient: z.nullish(z.unknown()),
86
- paymentId: z.nullish(z.number())
20
+ recipient: z.nullish(z.unknown())
87
21
  });
88
22
  /**
89
23
  * Response schema for token validation.
@@ -121,11 +55,11 @@ var AuthApi = class {
121
55
  * phone: "+77071234567"
122
56
  * });
123
57
  */
124
- async login(params) {
125
- return parseResponse(AuthApiLoginResponseSchema, await this.http.post({
58
+ login(params) {
59
+ return this.http.post({
126
60
  path: "/auth/login",
127
61
  body: params
128
- }));
62
+ }, AuthApiLoginResponseSchema);
129
63
  }
130
64
  /**
131
65
  * Verifies OTP code and obtains JWT access and refresh tokens.
@@ -136,11 +70,11 @@ var AuthApi = class {
136
70
  * otpCode: "2610"
137
71
  * });
138
72
  */
139
- async verify(params) {
140
- return parseResponse(AuthApiVerifyResponseSchema, await this.http.post({
73
+ verify(params) {
74
+ return this.http.post({
141
75
  path: "/auth/verify",
142
76
  body: params
143
- }));
77
+ }, AuthApiVerifyResponseSchema);
144
78
  }
145
79
  /**
146
80
  * Validates the current JWT token and retrieves user information.
@@ -148,12 +82,11 @@ var AuthApi = class {
148
82
  * @example
149
83
  * const response = await client.auth.checkToken();
150
84
  */
151
- async checkToken(params = {}) {
152
- return await this.http.get({
85
+ checkToken(params = {}) {
86
+ return this.http.get({
153
87
  path: "/auth/check-token",
154
- params,
155
- schema: AuthApiCheckTokenResponseSchema
156
- });
88
+ params
89
+ }, AuthApiCheckTokenResponseSchema);
157
90
  }
158
91
  };
159
92
 
@@ -221,9 +154,8 @@ var BannersApi = class {
221
154
  list(params = {}) {
222
155
  return this.http.get({
223
156
  path: "/api/v3/banners",
224
- params,
225
- schema: BannersApiListResponseSchema
226
- });
157
+ params
158
+ }, BannersApiListResponseSchema);
227
159
  }
228
160
  };
229
161
 
@@ -298,9 +230,8 @@ var CategoriesApi = class {
298
230
  list(params = {}) {
299
231
  return this.http.get({
300
232
  path: "/categories",
301
- params,
302
- schema: CategoriesApiListResponseSchema
303
- });
233
+ params
234
+ }, CategoriesApiListResponseSchema);
304
235
  }
305
236
  /**
306
237
  * Retrieves detailed information about a specific category by its ID.
@@ -313,9 +244,8 @@ var CategoriesApi = class {
313
244
  get(params) {
314
245
  return this.http.get({
315
246
  path: `/categories/${params.categoryId}`,
316
- params,
317
- schema: CategoriesApiGetResponseSchema
318
- });
247
+ params
248
+ }, CategoriesApiGetResponseSchema);
319
249
  }
320
250
  /**
321
251
  * Retrieves parent categories for specific category IDs.
@@ -328,9 +258,8 @@ var CategoriesApi = class {
328
258
  getParents(params) {
329
259
  return this.http.get({
330
260
  path: "/api/v1/categories/parents",
331
- params,
332
- schema: CategoriesApiGetParentsResponseSchema
333
- });
261
+ params
262
+ }, CategoriesApiGetParentsResponseSchema);
334
263
  }
335
264
  };
336
265
 
@@ -489,9 +418,8 @@ var CollectionsApi = class {
489
418
  getSkus(params) {
490
419
  return this.http.get({
491
420
  path: "/api/v2/collections/skus",
492
- params,
493
- schema: CollectionsApiGetSkusResponseSchema
494
- });
421
+ params
422
+ }, CollectionsApiGetSkusResponseSchema);
495
423
  }
496
424
  /**
497
425
  * Retrieves a list of all collections.
@@ -502,9 +430,8 @@ var CollectionsApi = class {
502
430
  list(params = {}) {
503
431
  return this.http.get({
504
432
  path: "/collections",
505
- params,
506
- schema: CollectionsApiListResponseSchema
507
- });
433
+ params
434
+ }, CollectionsApiListResponseSchema);
508
435
  }
509
436
  /**
510
437
  * Retrieves detailed information about a specific collection by its ID.
@@ -517,9 +444,139 @@ var CollectionsApi = class {
517
444
  get(params) {
518
445
  return this.http.get({
519
446
  path: `/collections/${params.collectionId}`,
520
- params,
521
- schema: CollectionsApiGetResponseSchema
522
- });
447
+ params
448
+ }, CollectionsApiGetResponseSchema);
449
+ }
450
+ };
451
+
452
+ //#endregion
453
+ //#region src/api/favorites/schemas.ts
454
+ /**
455
+ * Schema for a product badge.
456
+ */
457
+ const FavoritesApiBadgeSchema = z.object({
458
+ label: z.string(),
459
+ backgroundColor: z.nullish(z.number()),
460
+ textColor: z.number()
461
+ });
462
+ /**
463
+ * Type literal for stock availability type
464
+ */
465
+ const FavoritesStockAvailabilityTypeSchema = z.literal("stock");
466
+ /**
467
+ * Schema for stock availability information.
468
+ */
469
+ const FavoritesApiStockAvailabilitySchema = z.object({
470
+ type: FavoritesStockAvailabilityTypeSchema,
471
+ svg: z.nullish(z.string()),
472
+ text: z.string(),
473
+ maxQty: z.number(),
474
+ maxQtyReason: z.string()
475
+ });
476
+ /**
477
+ * Schema for a favorited item (SKU).
478
+ */
479
+ const FavoritesApiItemSchema = z.object({
480
+ productId: z.number(),
481
+ skuId: z.number(),
482
+ imageUrl: z.string(),
483
+ name: z.string(),
484
+ shortDescription: z.string(),
485
+ thumbnailUrl: z.string(),
486
+ originalPrice: z.number(),
487
+ price: z.number(),
488
+ qty: z.number(),
489
+ stockAvailability: z.nullish(FavoritesApiStockAvailabilitySchema),
490
+ isPromo: z.boolean(),
491
+ promoName: z.nullish(z.string()),
492
+ promocodes: z.array(z.string()),
493
+ qtyPurchasedInfo: z.nullish(z.string()),
494
+ rating: z.nullish(z.number()),
495
+ scoreQuantity: z.nullish(z.number()),
496
+ badge: z.nullish(FavoritesApiBadgeSchema),
497
+ moderationStatus: z.number()
498
+ });
499
+ /**
500
+ * Response schema for the favorites list.
501
+ */
502
+ const FavoritesApiListResponseSchema = z.object({ items: z.array(FavoritesApiItemSchema) });
503
+ /**
504
+ * Response schema for retrieving favorite SKU IDs.
505
+ */
506
+ const FavoritesApiGetIdsResponseSchema = z.object({ skuIds: z.array(z.number()) });
507
+ /**
508
+ * Response schema for adding a SKU to favorites.
509
+ */
510
+ const FavoritesApiAddResponseSchema = z.nullish(z.null());
511
+ /**
512
+ * Response schema for removing a SKU from favorites.
513
+ */
514
+ const FavoritesApiRemoveResponseSchema = z.nullish(z.null());
515
+
516
+ //#endregion
517
+ //#region src/api/favorites/api.ts
518
+ /**
519
+ * API for managing user favorites.
520
+ */
521
+ var FavoritesApi = class {
522
+ /**
523
+ * Initializes a new instance of the FavoritesApi.
524
+ *
525
+ * @param http HTTP client instance.
526
+ */
527
+ constructor(http) {
528
+ this.http = http;
529
+ }
530
+ /**
531
+ * Retrieves a paginated list of favorited items.
532
+ *
533
+ * @example
534
+ * const favorites = await client.favorites.list({
535
+ * pageNumber: 1,
536
+ * pageSize: 20
537
+ * });
538
+ */
539
+ list(params = {}) {
540
+ return this.http.get({
541
+ path: "/api/v1/favorites",
542
+ params
543
+ }, FavoritesApiListResponseSchema);
544
+ }
545
+ /**
546
+ * Retrieves the list of IDs of favorited SKUs.
547
+ *
548
+ * @example
549
+ * const { skuIds } = await client.favorites.getIds();
550
+ */
551
+ getIds(params = {}) {
552
+ return this.http.get({
553
+ path: "/api/v1/favorites/ids",
554
+ params
555
+ }, FavoritesApiGetIdsResponseSchema);
556
+ }
557
+ /**
558
+ * Adds SKUs to favorites.
559
+ *
560
+ * @example
561
+ * await client.favorites.add({ skuIds: [12345, 67890] });
562
+ */
563
+ add(params) {
564
+ return this.http.post({
565
+ path: "/api/v1/favorites",
566
+ body: params.skuIds
567
+ }, FavoritesApiAddResponseSchema);
568
+ }
569
+ /**
570
+ * Removes SKUs from favorites.
571
+ *
572
+ * @example
573
+ * await client.favorites.remove({ skuIds: [12345, 67890] });
574
+ */
575
+ remove(params) {
576
+ return this.http.delete({
577
+ path: "/api/v1/favorites",
578
+ body: params.skuIds
579
+ }, FavoritesApiRemoveResponseSchema);
523
580
  }
524
581
  };
525
582
 
@@ -560,9 +617,8 @@ var FeatureFlagsApi = class {
560
617
  list(params = {}) {
561
618
  return this.http.get({
562
619
  path: "/api/v1/feature-flags",
563
- params,
564
- schema: FeatureFlagsApiListResponseSchema
565
- });
620
+ params
621
+ }, FeatureFlagsApiListResponseSchema);
566
622
  }
567
623
  };
568
624
 
@@ -615,9 +671,9 @@ const ProductsApiGetReviewsResponseSchema = z.object({
615
671
  * Schema for a product badge.
616
672
  */
617
673
  const ProductsApiBadgeSchema = z.object({
618
- backgroundColor: z.number(),
619
674
  label: z.string(),
620
- textColor: z.number()
675
+ textColor: z.number(),
676
+ backgroundColor: z.nullish(z.number())
621
677
  });
622
678
  /**
623
679
  * Type literal for products stock availability type
@@ -648,12 +704,12 @@ const ProductsApiProductItemSchema = z.object({
648
704
  qty: z.number(),
649
705
  stockAvailability: z.nullish(ProductsApiStockAvailabilitySchema),
650
706
  isPromo: z.boolean(),
651
- promoName: z.string(),
707
+ promoName: z.nullish(z.string()),
652
708
  promocodes: z.array(z.string()),
653
709
  qtyPurchasedInfo: z.nullish(z.string()),
654
710
  rating: z.nullish(z.number()),
655
711
  scoreQuantity: z.nullish(z.number()),
656
- badge: ProductsApiBadgeSchema,
712
+ badge: z.nullish(ProductsApiBadgeSchema),
657
713
  moderationStatus: z.number()
658
714
  });
659
715
  /**
@@ -692,9 +748,8 @@ var ProductsApi = class {
692
748
  getSortOptions(params = {}) {
693
749
  return this.http.get({
694
750
  path: "/api/product/sort-options",
695
- params,
696
- schema: ProductsApiGetSortOptionsResponseSchema
697
- });
751
+ params
752
+ }, ProductsApiGetSortOptionsResponseSchema);
698
753
  }
699
754
  /**
700
755
  * Retrieves a list of products with optional filtering and pagination.
@@ -708,9 +763,8 @@ var ProductsApi = class {
708
763
  list(params = {}) {
709
764
  return this.http.get({
710
765
  path: "/api/v2/product",
711
- params,
712
- schema: ProductsApiListResponseSchema
713
- });
766
+ params
767
+ }, ProductsApiListResponseSchema);
714
768
  }
715
769
  /**
716
770
  * Retrieves reviews for a specific product.
@@ -723,9 +777,8 @@ var ProductsApi = class {
723
777
  getReviews(params) {
724
778
  return this.http.get({
725
779
  path: `/api/v1/product/${params.productId}/review`,
726
- params,
727
- schema: ProductsApiGetReviewsResponseSchema
728
- });
780
+ params
781
+ }, ProductsApiGetReviewsResponseSchema);
729
782
  }
730
783
  };
731
784
 
@@ -770,9 +823,8 @@ var PromoApi = class {
770
823
  list(params = {}) {
771
824
  return this.http.get({
772
825
  path: "/api/promo",
773
- params,
774
- schema: PromoApiListResponseSchema
775
- });
826
+ params
827
+ }, PromoApiListResponseSchema);
776
828
  }
777
829
  };
778
830
 
@@ -904,9 +956,8 @@ var ShopsApi = class {
904
956
  get(params) {
905
957
  return this.http.get({
906
958
  path: `/api/v1/shops/${params.shopId}`,
907
- params,
908
- schema: ShopsApiGetResponseSchema
909
- });
959
+ params
960
+ }, ShopsApiGetResponseSchema);
910
961
  }
911
962
  /**
912
963
  * Retrieves monobrand shop details.
@@ -917,9 +968,8 @@ var ShopsApi = class {
917
968
  getMonobrand(params = {}) {
918
969
  return this.http.get({
919
970
  path: "/api/v1/shops/monobrand",
920
- params,
921
- schema: ShopsApiGetMonobrandResponseSchema
922
- });
971
+ params
972
+ }, ShopsApiGetMonobrandResponseSchema);
923
973
  }
924
974
  /**
925
975
  * Retrieves products for a specific shop.
@@ -933,9 +983,8 @@ var ShopsApi = class {
933
983
  getProducts(params) {
934
984
  return this.http.get({
935
985
  path: `/api/v2/shops/${params.shopId}/products`,
936
- params,
937
- schema: ShopsApiGetProductsResponseSchema
938
- });
986
+ params
987
+ }, ShopsApiGetProductsResponseSchema);
939
988
  }
940
989
  };
941
990
 
@@ -1133,9 +1182,8 @@ var SkuApi = class {
1133
1182
  get(params) {
1134
1183
  return this.http.get({
1135
1184
  path: `/api/v2/sku/${params.skuId}`,
1136
- params,
1137
- schema: SkuApiGetResponseSchema
1138
- });
1185
+ params
1186
+ }, SkuApiGetResponseSchema);
1139
1187
  }
1140
1188
  /**
1141
1189
  * Retrieves similar SKUs.
@@ -1148,9 +1196,8 @@ var SkuApi = class {
1148
1196
  getSimilar(params) {
1149
1197
  return this.http.get({
1150
1198
  path: "/api/v2/sku/similar-skus",
1151
- params,
1152
- schema: SkuApiGetSimilarResponseSchema
1153
- });
1199
+ params
1200
+ }, SkuApiGetSimilarResponseSchema);
1154
1201
  }
1155
1202
  /**
1156
1203
  * Retrieves collections associated with a SKU.
@@ -1163,9 +1210,8 @@ var SkuApi = class {
1163
1210
  getCollections(params) {
1164
1211
  return this.http.get({
1165
1212
  path: `/sku/${params.skuId}/collections`,
1166
- params,
1167
- schema: SkuApiGetCollectionsResponseSchema
1168
- });
1213
+ params
1214
+ }, SkuApiGetCollectionsResponseSchema);
1169
1215
  }
1170
1216
  /**
1171
1217
  * Checks if a review is available for a SKU.
@@ -1178,9 +1224,78 @@ var SkuApi = class {
1178
1224
  getReviewAvailable(params) {
1179
1225
  return this.http.get({
1180
1226
  path: `/sku/${params.skuId}/review-available`,
1181
- params,
1182
- schema: SkuApiGetReviewAvailableResponseSchema
1183
- });
1227
+ params
1228
+ }, SkuApiGetReviewAvailableResponseSchema);
1229
+ }
1230
+ };
1231
+
1232
+ //#endregion
1233
+ //#region src/api/users/schemas.ts
1234
+ /**
1235
+ * Supported language enum for user preference
1236
+ */
1237
+ const UsersApiLanguageEnumSchema = z.enum(["ru", "kk"]);
1238
+ /**
1239
+ * Response schema for language update
1240
+ */
1241
+ const UsersApiUpdateLanguageResponseSchema = z.object({
1242
+ language: UsersApiLanguageEnumSchema,
1243
+ title: z.string(),
1244
+ message: z.string()
1245
+ });
1246
+ /**
1247
+ * Response schema for device registration
1248
+ */
1249
+ const UsersApiRegisterDeviceResponseSchema = z.nullish(z.null());
1250
+
1251
+ //#endregion
1252
+ //#region src/api/users/api.ts
1253
+ /**
1254
+ * API for user management operations.
1255
+ */
1256
+ var UsersApi = class {
1257
+ /**
1258
+ * Initializes a new instance of the UsersApi.
1259
+ *
1260
+ * @param http HTTP client instance.
1261
+ */
1262
+ constructor(http) {
1263
+ this.http = http;
1264
+ }
1265
+ /**
1266
+ * Updates the user's preferred language.
1267
+ *
1268
+ * @example
1269
+ * await client.users.updateLanguage({
1270
+ * language: "ru"
1271
+ * });
1272
+ */
1273
+ updateLanguage(params) {
1274
+ return this.http.patch({
1275
+ path: "/api/v1/users/me/language",
1276
+ body: params
1277
+ }, UsersApiUpdateLanguageResponseSchema);
1278
+ }
1279
+ /**
1280
+ * Registers device identity for analytics tracking.
1281
+ *
1282
+ * @example
1283
+ * await client.users.registerDevice({
1284
+ * deviceIdentity: {
1285
+ * sdkInformation: [
1286
+ * {
1287
+ * type: "Appsflyer",
1288
+ * deviceId: "1765694307025-6267413661002574019"
1289
+ * }
1290
+ * ]
1291
+ * }
1292
+ * });
1293
+ */
1294
+ registerDevice(params) {
1295
+ return this.http.post({
1296
+ path: "/api/v1/device-identities",
1297
+ body: params
1298
+ }, UsersApiRegisterDeviceResponseSchema);
1184
1299
  }
1185
1300
  };
1186
1301
 
@@ -1202,6 +1317,20 @@ const LANGUAGES = {
1202
1317
  */
1203
1318
  const DEFAULT_APP_VERSION = "200";
1204
1319
 
1320
+ //#endregion
1321
+ //#region src/utils/merge-headers.ts
1322
+ /**
1323
+ * Merges base headers with new ones (overrides).
1324
+ * Returns a new Headers instance without mutating the original source.
1325
+ */
1326
+ function mergeHeaders(base, overrides) {
1327
+ const result = new Headers(base);
1328
+ if (overrides != void 0) new Headers(overrides).forEach((value, key) => {
1329
+ result.set(key, value);
1330
+ });
1331
+ return result;
1332
+ }
1333
+
1205
1334
  //#endregion
1206
1335
  //#region src/config.ts
1207
1336
  /**
@@ -1212,22 +1341,20 @@ const DEFAULT_CONFIG = {
1212
1341
  appVersion: DEFAULT_APP_VERSION,
1213
1342
  language: "ru",
1214
1343
  timeout: 3e4,
1215
- headers: {}
1344
+ headers: new Headers()
1216
1345
  };
1217
1346
  /**
1218
1347
  * Merges user configuration with defaults.
1219
1348
  */
1220
1349
  function resolveConfig(config) {
1350
+ const headers = mergeHeaders(DEFAULT_CONFIG.headers, config?.headers);
1221
1351
  return {
1222
1352
  baseUrl: config?.baseUrl ?? DEFAULT_CONFIG.baseUrl,
1223
1353
  token: config?.token,
1224
1354
  appVersion: config?.appVersion ?? DEFAULT_CONFIG.appVersion,
1225
1355
  language: config?.language ?? DEFAULT_CONFIG.language,
1226
1356
  timeout: config?.timeout ?? DEFAULT_CONFIG.timeout,
1227
- headers: {
1228
- ...DEFAULT_CONFIG.headers,
1229
- ...config?.headers
1230
- }
1357
+ headers
1231
1358
  };
1232
1359
  }
1233
1360
  /**
@@ -1240,16 +1367,23 @@ function buildUserAgent(appVersion) {
1240
1367
  * Builds the headers object for API requests based on configuration.
1241
1368
  */
1242
1369
  function buildHeaders(config) {
1243
- const headers = {
1244
- "accept-language": config.language,
1245
- "user-agent": buildUserAgent(config.appVersion),
1246
- "x-app-version": config.appVersion,
1247
- ...config.headers
1248
- };
1249
- if (config.token !== void 0 && config.token !== null) headers["authorization"] = `Bearer ${config.token}`;
1370
+ const headers = new Headers(config.headers);
1371
+ headers.set("Accept-Language", config.language);
1372
+ headers.set("User-Agent", buildUserAgent(config.appVersion));
1373
+ headers.set("X-App-Version", config.appVersion);
1374
+ if (config.token != void 0) headers.set("Authorization", `Bearer ${config.token}`);
1250
1375
  return headers;
1251
1376
  }
1252
1377
 
1378
+ //#endregion
1379
+ //#region src/errors/teez-error.ts
1380
+ /**
1381
+ * Base error class for all SDK-related errors.
1382
+ */
1383
+ var TeezError = class extends Error {
1384
+ name = "TeezError";
1385
+ };
1386
+
1253
1387
  //#endregion
1254
1388
  //#region src/errors/teez-api-error.ts
1255
1389
  /**
@@ -1258,6 +1392,10 @@ function buildHeaders(config) {
1258
1392
  var TeezApiError = class extends TeezError {
1259
1393
  name = "TeezApiError";
1260
1394
  /**
1395
+ * URL of the request that failed.
1396
+ */
1397
+ url;
1398
+ /**
1261
1399
  * HTTP status code.
1262
1400
  */
1263
1401
  status;
@@ -1266,18 +1404,14 @@ var TeezApiError = class extends TeezError {
1266
1404
  */
1267
1405
  statusText;
1268
1406
  /**
1269
- * URL of the request that failed.
1270
- */
1271
- url;
1272
- /**
1273
1407
  * Response body, if available.
1274
1408
  */
1275
1409
  body;
1276
1410
  constructor(message, { url, status, statusText, body, ...errorOptions }) {
1277
1411
  super(message, errorOptions);
1412
+ this.url = url;
1278
1413
  this.status = status;
1279
1414
  this.statusText = statusText;
1280
- this.url = url;
1281
1415
  this.body = body;
1282
1416
  }
1283
1417
  /**
@@ -1339,6 +1473,64 @@ var TeezTimeoutError = class extends TeezError {
1339
1473
  }
1340
1474
  };
1341
1475
 
1476
+ //#endregion
1477
+ //#region src/errors/teez-validation-error.ts
1478
+ /**
1479
+ * Error thrown when validation fails.
1480
+ */
1481
+ var TeezValidationError = class extends TeezError {
1482
+ name = "TeezValidationError";
1483
+ /**
1484
+ * List of standardized validation issues.
1485
+ */
1486
+ issues;
1487
+ /**
1488
+ * The raw data that failed validation.
1489
+ */
1490
+ data;
1491
+ constructor(message, { issues, data, ...errorOptions }) {
1492
+ super(message, errorOptions);
1493
+ this.issues = issues;
1494
+ this.data = data;
1495
+ }
1496
+ };
1497
+
1498
+ //#endregion
1499
+ //#region src/http/helpers.ts
1500
+ /**
1501
+ * Constructs a full URL with query parameters.
1502
+ */
1503
+ function buildUrl(path, baseUrl, queryParams) {
1504
+ const url = new URL(path, baseUrl);
1505
+ if (queryParams != void 0) for (const [key, value] of Object.entries(queryParams)) {
1506
+ if (value == void 0) continue;
1507
+ if (Array.isArray(value)) for (const item of value) url.searchParams.append(key, String(item));
1508
+ else url.searchParams.set(key, String(value));
1509
+ }
1510
+ return url;
1511
+ }
1512
+ /**
1513
+ * Converts Zod ZodError to abstract ValidationIssue[].
1514
+ */
1515
+ function toValidationIssues(error) {
1516
+ return error.issues.map((issue) => ({
1517
+ code: issue.code,
1518
+ path: issue.path,
1519
+ message: issue.message
1520
+ }));
1521
+ }
1522
+ /**
1523
+ * Validates and parses the API response data against a schema.
1524
+ */
1525
+ function parseResponse(schema, data) {
1526
+ const result = safeParse(schema, data);
1527
+ if (!result.success) throw new TeezValidationError("Response validation failed", {
1528
+ issues: toValidationIssues(result.error),
1529
+ data
1530
+ });
1531
+ return result.data;
1532
+ }
1533
+
1342
1534
  //#endregion
1343
1535
  //#region src/http/client.ts
1344
1536
  /**
@@ -1355,51 +1547,52 @@ var HttpClient = class {
1355
1547
  headers;
1356
1548
  /**
1357
1549
  * Initializes a new instance of the HttpClient.
1358
- *
1359
- * @param config Resolved client configuration.
1360
1550
  */
1361
1551
  constructor(config) {
1362
1552
  this.config = config;
1363
1553
  this.headers = buildHeaders(config);
1364
1554
  }
1365
1555
  /**
1366
- * Performs a low-level HTTP request.
1367
- *
1368
- * @param options Request options.
1556
+ * Implementation of request method.
1369
1557
  */
1370
- async request(options) {
1371
- const { url, headers, ...fetchOptions } = options;
1558
+ async request({ path, params, headers: headersRaw, body: bodyRaw, ...options }, schema) {
1559
+ const url = buildUrl(path, this.config.baseUrl, params);
1560
+ const headers = mergeHeaders(this.headers, headersRaw);
1561
+ let body;
1562
+ if (bodyRaw !== void 0) {
1563
+ body = JSON.stringify(bodyRaw);
1564
+ if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
1565
+ }
1372
1566
  const controller = new AbortController();
1373
1567
  const timeoutId = setTimeout(() => {
1374
1568
  controller.abort();
1375
1569
  }, this.config.timeout);
1376
1570
  try {
1377
1571
  const response = await fetch(url, {
1378
- ...fetchOptions,
1379
- headers: {
1380
- ...this.headers,
1381
- ...headers
1382
- },
1572
+ ...options,
1573
+ headers,
1574
+ body,
1383
1575
  signal: controller.signal
1384
1576
  });
1385
1577
  if (!response.ok) {
1386
- let body;
1578
+ let errorBody;
1387
1579
  try {
1388
- body = await response.json();
1580
+ errorBody = await response.json();
1389
1581
  } catch {
1390
- body = await response.text().catch(() => void 0);
1582
+ errorBody = await response.text().catch(() => void 0);
1391
1583
  }
1392
1584
  throw new TeezApiError(`API request failed: ${response.status} ${response.statusText}`, {
1393
1585
  url,
1394
1586
  status: response.status,
1395
1587
  statusText: response.statusText,
1396
- body
1588
+ body: errorBody
1397
1589
  });
1398
1590
  }
1399
1591
  if (response.status === 204) return;
1400
- return await response.json();
1592
+ const data = await response.json();
1593
+ return schema != void 0 ? parseResponse(schema, data) : data;
1401
1594
  } catch (error) {
1402
- if (error instanceof TeezApiError) throw error;
1595
+ if (error instanceof TeezError) throw error;
1403
1596
  if (error instanceof DOMException && error.name === "AbortError") throw new TeezTimeoutError(`Request timed out after ${this.config.timeout}ms`, {
1404
1597
  url,
1405
1598
  timeout: this.config.timeout,
@@ -1414,55 +1607,51 @@ var HttpClient = class {
1414
1607
  }
1415
1608
  }
1416
1609
  /**
1417
- * Performs a GET request and validates the response.
1610
+ * Implementation of GET method.
1418
1611
  */
1419
- async get(options) {
1420
- const { path, params, schema, ...rest } = options;
1421
- const url = buildUrl(path, this.config.baseUrl, params);
1422
- return parseResponse(schema, await this.request({
1423
- url,
1424
- method: "GET",
1425
- ...rest
1426
- }));
1612
+ get(options, schema) {
1613
+ return schema != void 0 ? this.request({
1614
+ ...options,
1615
+ method: "GET"
1616
+ }, schema) : this.request({
1617
+ ...options,
1618
+ method: "GET"
1619
+ });
1427
1620
  }
1428
1621
  /**
1429
- * Performs a POST request.
1622
+ * Implementation of POST method.
1430
1623
  */
1431
- post(options) {
1432
- const { path, params, body, ...rest } = options;
1433
- const url = buildUrl(path, this.config.baseUrl, params);
1434
- return this.request({
1435
- url,
1436
- method: "POST",
1437
- headers: { "Content-Type": "application/json" },
1438
- body: body != void 0 ? JSON.stringify(body) : void 0,
1439
- ...rest
1624
+ post(options, schema) {
1625
+ return schema != void 0 ? this.request({
1626
+ ...options,
1627
+ method: "POST"
1628
+ }, schema) : this.request({
1629
+ ...options,
1630
+ method: "POST"
1440
1631
  });
1441
1632
  }
1442
1633
  /**
1443
- * Performs a PATCH request.
1634
+ * Implementation of PATCH method.
1444
1635
  */
1445
- patch(options) {
1446
- const { path, params, body, ...rest } = options;
1447
- const url = buildUrl(path, this.config.baseUrl, params);
1448
- return this.request({
1449
- url,
1450
- method: "PATCH",
1451
- headers: { "Content-Type": "application/json" },
1452
- body: body != void 0 ? JSON.stringify(body) : void 0,
1453
- ...rest
1636
+ patch(options, schema) {
1637
+ return schema != void 0 ? this.request({
1638
+ ...options,
1639
+ method: "PATCH"
1640
+ }, schema) : this.request({
1641
+ ...options,
1642
+ method: "PATCH"
1454
1643
  });
1455
1644
  }
1456
1645
  /**
1457
- * Performs a DELETE request.
1646
+ * Implementation of DELETE method.
1458
1647
  */
1459
- delete(options) {
1460
- const { path, params, ...rest } = options;
1461
- const url = buildUrl(path, this.config.baseUrl, params);
1462
- return this.request({
1463
- url,
1464
- method: "DELETE",
1465
- ...rest
1648
+ delete(options, schema) {
1649
+ return schema != void 0 ? this.request({
1650
+ ...options,
1651
+ method: "DELETE"
1652
+ }, schema) : this.request({
1653
+ ...options,
1654
+ method: "DELETE"
1466
1655
  });
1467
1656
  }
1468
1657
  };
@@ -1488,7 +1677,7 @@ var TeezClient = class {
1488
1677
  */
1489
1678
  http;
1490
1679
  /**
1491
- * API for authentication operations (login, verify OTP, check token).
1680
+ * API for authentication operations.
1492
1681
  */
1493
1682
  auth;
1494
1683
  /**
@@ -1504,6 +1693,10 @@ var TeezClient = class {
1504
1693
  */
1505
1694
  collections;
1506
1695
  /**
1696
+ * API for managing user favorites.
1697
+ */
1698
+ favorites;
1699
+ /**
1507
1700
  * API for retrieving feature flags.
1508
1701
  */
1509
1702
  featureFlags;
@@ -1524,6 +1717,10 @@ var TeezClient = class {
1524
1717
  */
1525
1718
  sku;
1526
1719
  /**
1720
+ * API for user management operations.
1721
+ */
1722
+ users;
1723
+ /**
1527
1724
  * Initializes a new instance of the TeezClient.
1528
1725
  *
1529
1726
  * @param config Optional client configuration.
@@ -1535,11 +1732,13 @@ var TeezClient = class {
1535
1732
  this.banners = new BannersApi(this.http);
1536
1733
  this.categories = new CategoriesApi(this.http);
1537
1734
  this.collections = new CollectionsApi(this.http);
1735
+ this.favorites = new FavoritesApi(this.http);
1538
1736
  this.featureFlags = new FeatureFlagsApi(this.http);
1539
1737
  this.products = new ProductsApi(this.http);
1540
1738
  this.promo = new PromoApi(this.http);
1541
1739
  this.shops = new ShopsApi(this.http);
1542
1740
  this.sku = new SkuApi(this.http);
1741
+ this.users = new UsersApi(this.http);
1543
1742
  }
1544
1743
  /**
1545
1744
  * Returns the current client configuration.
@@ -1550,5 +1749,5 @@ var TeezClient = class {
1550
1749
  };
1551
1750
 
1552
1751
  //#endregion
1553
- export { AuthApi, AuthApiCheckTokenResponseSchema, AuthApiLoginResponseSchema, AuthApiVerifyResponseSchema, BASE_URL, BannerActionTypesSchema, BannerImageTypeSchema, BannersApi, BannersApiActionSchema, BannersApiBannerItemSchema, BannersApiImageSchema, BannersApiListResponseSchema, CategoriesApi, CategoriesApiGetParentsResponseItemSchema, CategoriesApiGetParentsResponseSchema, CategoriesApiGetResponseSchema, CategoriesApiListResponseItemSchema, CategoriesApiListResponseSchema, CollectionTypeSchema, CollectionsApi, CollectionsApiGetResponseSchema, CollectionsApiGetSkusResponseSchema, CollectionsApiListItemSchema, CollectionsApiListResponseSchema, CollectionsApiSkuItemSchema, CollectionsApiStockAvailabilitySchema, CollectionsStockAvailabilityTypeSchema, DEFAULT_APP_VERSION, DEFAULT_CONFIG, FeatureFlagsApi, FeatureFlagsApiItemSchema, FeatureFlagsApiListResponseSchema, LANGUAGES, ProductSortKeySchema, ProductsApi, ProductsApiBadgeSchema, ProductsApiGetReviewsResponseSchema, ProductsApiGetSortOptionsResponseSchema, ProductsApiListResponseSchema, ProductsApiProductItemSchema, ProductsApiReviewItemSchema, ProductsApiSortOptionSchema, ProductsApiStockAvailabilitySchema, ProductsStockAvailabilityTypeSchema, PromoApi, PromoApiItemSchema, PromoApiListResponseSchema, ShopsApi, ShopsApiContactInfoSchema, ShopsApiGetMonobrandResponseSchema, ShopsApiGetProductsResponseSchema, ShopsApiGetResponseSchema, ShopsApiProductItemSchema, ShopsApiShopItemSchema, ShopsApiStockAvailabilitySchema, ShopsApiTagSchema, ShopsStockAvailabilityTypeSchema, SkuApi, SkuApiAttributePropertySchema, SkuApiAttributePropertyValueSchema, SkuApiAttributeSchema, SkuApiBrandSchema, SkuApiCategorySchema, SkuApiCollectionItemSchema, SkuApiGetCollectionsResponseSchema, SkuApiGetResponseSchema, SkuApiGetReviewAvailableResponseSchema, SkuApiGetSimilarResponseSchema, SkuApiInstallmentSchema, SkuApiShopSchema, SkuApiSimilarItemSchema, SkuApiStockAvailabilitySchema, SkuApiTagSchema, SkuStockAvailabilityTypeSchema, TeezApiError, TeezClient, TeezError, TeezNetworkError, TeezTimeoutError, TeezValidationError, buildHeaders, buildUserAgent, resolveConfig };
1752
+ export { AuthApi, AuthApiCheckTokenResponseSchema, AuthApiLoginResponseSchema, AuthApiVerifyResponseSchema, BASE_URL, BannerActionTypesSchema, BannerImageTypeSchema, BannersApi, BannersApiActionSchema, BannersApiBannerItemSchema, BannersApiImageSchema, BannersApiListResponseSchema, CategoriesApi, CategoriesApiGetParentsResponseItemSchema, CategoriesApiGetParentsResponseSchema, CategoriesApiGetResponseSchema, CategoriesApiListResponseItemSchema, CategoriesApiListResponseSchema, CollectionTypeSchema, CollectionsApi, CollectionsApiGetResponseSchema, CollectionsApiGetSkusResponseSchema, CollectionsApiListItemSchema, CollectionsApiListResponseSchema, CollectionsApiSkuItemSchema, CollectionsApiStockAvailabilitySchema, CollectionsStockAvailabilityTypeSchema, DEFAULT_APP_VERSION, DEFAULT_CONFIG, FavoritesApi, FavoritesApiAddResponseSchema, FavoritesApiBadgeSchema, FavoritesApiGetIdsResponseSchema, FavoritesApiItemSchema, FavoritesApiListResponseSchema, FavoritesApiRemoveResponseSchema, FavoritesApiStockAvailabilitySchema, FavoritesStockAvailabilityTypeSchema, FeatureFlagsApi, FeatureFlagsApiItemSchema, FeatureFlagsApiListResponseSchema, LANGUAGES, ProductSortKeySchema, ProductsApi, ProductsApiBadgeSchema, ProductsApiGetReviewsResponseSchema, ProductsApiGetSortOptionsResponseSchema, ProductsApiListResponseSchema, ProductsApiProductItemSchema, ProductsApiReviewItemSchema, ProductsApiSortOptionSchema, ProductsApiStockAvailabilitySchema, ProductsStockAvailabilityTypeSchema, PromoApi, PromoApiItemSchema, PromoApiListResponseSchema, ShopsApi, ShopsApiContactInfoSchema, ShopsApiGetMonobrandResponseSchema, ShopsApiGetProductsResponseSchema, ShopsApiGetResponseSchema, ShopsApiProductItemSchema, ShopsApiShopItemSchema, ShopsApiStockAvailabilitySchema, ShopsApiTagSchema, ShopsStockAvailabilityTypeSchema, SkuApi, SkuApiAttributePropertySchema, SkuApiAttributePropertyValueSchema, SkuApiAttributeSchema, SkuApiBrandSchema, SkuApiCategorySchema, SkuApiCollectionItemSchema, SkuApiGetCollectionsResponseSchema, SkuApiGetResponseSchema, SkuApiGetReviewAvailableResponseSchema, SkuApiGetSimilarResponseSchema, SkuApiInstallmentSchema, SkuApiShopSchema, SkuApiSimilarItemSchema, SkuApiStockAvailabilitySchema, SkuApiTagSchema, SkuStockAvailabilityTypeSchema, TeezApiError, TeezClient, TeezError, TeezNetworkError, TeezTimeoutError, TeezValidationError, UsersApi, UsersApiLanguageEnumSchema, UsersApiRegisterDeviceResponseSchema, UsersApiUpdateLanguageResponseSchema, buildHeaders, buildUserAgent, resolveConfig };
1554
1753
  //# sourceMappingURL=index.mjs.map