@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.cjs CHANGED
@@ -28,76 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  let zod_mini = require("zod/mini");
29
29
  zod_mini = __toESM(zod_mini);
30
30
 
31
- //#region src/errors/teez-error.ts
32
- /**
33
- * Base error class for all SDK-related errors.
34
- */
35
- var TeezError = class extends Error {
36
- name = "TeezError";
37
- };
38
-
39
- //#endregion
40
- //#region src/errors/teez-validation-error.ts
41
- /**
42
- * Error thrown when validation fails.
43
- */
44
- var TeezValidationError = class extends TeezError {
45
- name = "TeezValidationError";
46
- /**
47
- * List of standardized validation issues.
48
- */
49
- issues;
50
- /**
51
- * The raw data that failed validation.
52
- */
53
- data;
54
- constructor(message, { issues, data, ...errorOptions }) {
55
- super(message, errorOptions);
56
- this.issues = issues;
57
- this.data = data;
58
- }
59
- };
60
-
61
- //#endregion
62
- //#region src/http/helpers.ts
63
- /**
64
- * Constructs a full URL with query parameters.
65
- */
66
- function buildUrl(path, baseUrl, queryParams) {
67
- const url = new URL(path, baseUrl);
68
- if (queryParams != void 0) for (const [key, value] of Object.entries(queryParams)) {
69
- if (value == void 0) continue;
70
- if (Array.isArray(value)) for (const item of value) url.searchParams.append(key, String(item));
71
- else url.searchParams.set(key, String(value));
72
- }
73
- return String(url);
74
- }
75
- /**
76
- * Converts Zod ZodError to abstract ValidationIssue[].
77
- */
78
- function toValidationIssues(error) {
79
- return error.issues.map((issue) => ({
80
- code: issue.code,
81
- path: issue.path,
82
- message: issue.message
83
- }));
84
- }
85
- /**
86
- * Validates and parses the API response data against a schema.
87
- */
88
- function parseResponse(schema, data) {
89
- const result = zod_mini.safeParse(schema, data);
90
- if (!result.success) throw new TeezValidationError("Response validation failed", {
91
- issues: toValidationIssues(result.error),
92
- data
93
- });
94
- return result.data;
95
- }
96
-
97
- //#endregion
98
31
  //#region src/api/auth/schemas.ts
99
32
  /**
100
- * Response schema for login.
33
+ * Response schema for initiating phone login.
101
34
  */
102
35
  const AuthApiLoginResponseSchema = zod_mini.void();
103
36
  /**
@@ -105,13 +38,13 @@ const AuthApiLoginResponseSchema = zod_mini.void();
105
38
  */
106
39
  const AuthApiVerifyResponseSchema = zod_mini.object({
107
40
  userId: zod_mini.string(),
41
+ phone: zod_mini.string(),
108
42
  accessToken: zod_mini.string(),
109
43
  refreshToken: zod_mini.string(),
110
- phone: zod_mini.string(),
44
+ paymentId: zod_mini.nullish(zod_mini.number()),
111
45
  pickupPoint: zod_mini.nullish(zod_mini.unknown()),
112
46
  address: zod_mini.nullish(zod_mini.unknown()),
113
- recipient: zod_mini.nullish(zod_mini.unknown()),
114
- paymentId: zod_mini.nullish(zod_mini.number())
47
+ recipient: zod_mini.nullish(zod_mini.unknown())
115
48
  });
116
49
  /**
117
50
  * Response schema for token validation.
@@ -149,11 +82,11 @@ var AuthApi = class {
149
82
  * phone: "+77071234567"
150
83
  * });
151
84
  */
152
- async login(params) {
153
- return parseResponse(AuthApiLoginResponseSchema, await this.http.post({
85
+ login(params) {
86
+ return this.http.post({
154
87
  path: "/auth/login",
155
88
  body: params
156
- }));
89
+ }, AuthApiLoginResponseSchema);
157
90
  }
158
91
  /**
159
92
  * Verifies OTP code and obtains JWT access and refresh tokens.
@@ -164,11 +97,11 @@ var AuthApi = class {
164
97
  * otpCode: "2610"
165
98
  * });
166
99
  */
167
- async verify(params) {
168
- return parseResponse(AuthApiVerifyResponseSchema, await this.http.post({
100
+ verify(params) {
101
+ return this.http.post({
169
102
  path: "/auth/verify",
170
103
  body: params
171
- }));
104
+ }, AuthApiVerifyResponseSchema);
172
105
  }
173
106
  /**
174
107
  * Validates the current JWT token and retrieves user information.
@@ -176,12 +109,11 @@ var AuthApi = class {
176
109
  * @example
177
110
  * const response = await client.auth.checkToken();
178
111
  */
179
- async checkToken(params = {}) {
180
- return await this.http.get({
112
+ checkToken(params = {}) {
113
+ return this.http.get({
181
114
  path: "/auth/check-token",
182
- params,
183
- schema: AuthApiCheckTokenResponseSchema
184
- });
115
+ params
116
+ }, AuthApiCheckTokenResponseSchema);
185
117
  }
186
118
  };
187
119
 
@@ -249,9 +181,8 @@ var BannersApi = class {
249
181
  list(params = {}) {
250
182
  return this.http.get({
251
183
  path: "/api/v3/banners",
252
- params,
253
- schema: BannersApiListResponseSchema
254
- });
184
+ params
185
+ }, BannersApiListResponseSchema);
255
186
  }
256
187
  };
257
188
 
@@ -326,9 +257,8 @@ var CategoriesApi = class {
326
257
  list(params = {}) {
327
258
  return this.http.get({
328
259
  path: "/categories",
329
- params,
330
- schema: CategoriesApiListResponseSchema
331
- });
260
+ params
261
+ }, CategoriesApiListResponseSchema);
332
262
  }
333
263
  /**
334
264
  * Retrieves detailed information about a specific category by its ID.
@@ -341,9 +271,8 @@ var CategoriesApi = class {
341
271
  get(params) {
342
272
  return this.http.get({
343
273
  path: `/categories/${params.categoryId}`,
344
- params,
345
- schema: CategoriesApiGetResponseSchema
346
- });
274
+ params
275
+ }, CategoriesApiGetResponseSchema);
347
276
  }
348
277
  /**
349
278
  * Retrieves parent categories for specific category IDs.
@@ -356,9 +285,8 @@ var CategoriesApi = class {
356
285
  getParents(params) {
357
286
  return this.http.get({
358
287
  path: "/api/v1/categories/parents",
359
- params,
360
- schema: CategoriesApiGetParentsResponseSchema
361
- });
288
+ params
289
+ }, CategoriesApiGetParentsResponseSchema);
362
290
  }
363
291
  };
364
292
 
@@ -517,9 +445,8 @@ var CollectionsApi = class {
517
445
  getSkus(params) {
518
446
  return this.http.get({
519
447
  path: "/api/v2/collections/skus",
520
- params,
521
- schema: CollectionsApiGetSkusResponseSchema
522
- });
448
+ params
449
+ }, CollectionsApiGetSkusResponseSchema);
523
450
  }
524
451
  /**
525
452
  * Retrieves a list of all collections.
@@ -530,9 +457,8 @@ var CollectionsApi = class {
530
457
  list(params = {}) {
531
458
  return this.http.get({
532
459
  path: "/collections",
533
- params,
534
- schema: CollectionsApiListResponseSchema
535
- });
460
+ params
461
+ }, CollectionsApiListResponseSchema);
536
462
  }
537
463
  /**
538
464
  * Retrieves detailed information about a specific collection by its ID.
@@ -545,9 +471,139 @@ var CollectionsApi = class {
545
471
  get(params) {
546
472
  return this.http.get({
547
473
  path: `/collections/${params.collectionId}`,
548
- params,
549
- schema: CollectionsApiGetResponseSchema
550
- });
474
+ params
475
+ }, CollectionsApiGetResponseSchema);
476
+ }
477
+ };
478
+
479
+ //#endregion
480
+ //#region src/api/favorites/schemas.ts
481
+ /**
482
+ * Schema for a product badge.
483
+ */
484
+ const FavoritesApiBadgeSchema = zod_mini.object({
485
+ label: zod_mini.string(),
486
+ backgroundColor: zod_mini.nullish(zod_mini.number()),
487
+ textColor: zod_mini.number()
488
+ });
489
+ /**
490
+ * Type literal for stock availability type
491
+ */
492
+ const FavoritesStockAvailabilityTypeSchema = zod_mini.literal("stock");
493
+ /**
494
+ * Schema for stock availability information.
495
+ */
496
+ const FavoritesApiStockAvailabilitySchema = zod_mini.object({
497
+ type: FavoritesStockAvailabilityTypeSchema,
498
+ svg: zod_mini.nullish(zod_mini.string()),
499
+ text: zod_mini.string(),
500
+ maxQty: zod_mini.number(),
501
+ maxQtyReason: zod_mini.string()
502
+ });
503
+ /**
504
+ * Schema for a favorited item (SKU).
505
+ */
506
+ const FavoritesApiItemSchema = zod_mini.object({
507
+ productId: zod_mini.number(),
508
+ skuId: zod_mini.number(),
509
+ imageUrl: zod_mini.string(),
510
+ name: zod_mini.string(),
511
+ shortDescription: zod_mini.string(),
512
+ thumbnailUrl: zod_mini.string(),
513
+ originalPrice: zod_mini.number(),
514
+ price: zod_mini.number(),
515
+ qty: zod_mini.number(),
516
+ stockAvailability: zod_mini.nullish(FavoritesApiStockAvailabilitySchema),
517
+ isPromo: zod_mini.boolean(),
518
+ promoName: zod_mini.nullish(zod_mini.string()),
519
+ promocodes: zod_mini.array(zod_mini.string()),
520
+ qtyPurchasedInfo: zod_mini.nullish(zod_mini.string()),
521
+ rating: zod_mini.nullish(zod_mini.number()),
522
+ scoreQuantity: zod_mini.nullish(zod_mini.number()),
523
+ badge: zod_mini.nullish(FavoritesApiBadgeSchema),
524
+ moderationStatus: zod_mini.number()
525
+ });
526
+ /**
527
+ * Response schema for the favorites list.
528
+ */
529
+ const FavoritesApiListResponseSchema = zod_mini.object({ items: zod_mini.array(FavoritesApiItemSchema) });
530
+ /**
531
+ * Response schema for retrieving favorite SKU IDs.
532
+ */
533
+ const FavoritesApiGetIdsResponseSchema = zod_mini.object({ skuIds: zod_mini.array(zod_mini.number()) });
534
+ /**
535
+ * Response schema for adding a SKU to favorites.
536
+ */
537
+ const FavoritesApiAddResponseSchema = zod_mini.nullish(zod_mini.null());
538
+ /**
539
+ * Response schema for removing a SKU from favorites.
540
+ */
541
+ const FavoritesApiRemoveResponseSchema = zod_mini.nullish(zod_mini.null());
542
+
543
+ //#endregion
544
+ //#region src/api/favorites/api.ts
545
+ /**
546
+ * API for managing user favorites.
547
+ */
548
+ var FavoritesApi = class {
549
+ /**
550
+ * Initializes a new instance of the FavoritesApi.
551
+ *
552
+ * @param http HTTP client instance.
553
+ */
554
+ constructor(http) {
555
+ this.http = http;
556
+ }
557
+ /**
558
+ * Retrieves a paginated list of favorited items.
559
+ *
560
+ * @example
561
+ * const favorites = await client.favorites.list({
562
+ * pageNumber: 1,
563
+ * pageSize: 20
564
+ * });
565
+ */
566
+ list(params = {}) {
567
+ return this.http.get({
568
+ path: "/api/v1/favorites",
569
+ params
570
+ }, FavoritesApiListResponseSchema);
571
+ }
572
+ /**
573
+ * Retrieves the list of IDs of favorited SKUs.
574
+ *
575
+ * @example
576
+ * const { skuIds } = await client.favorites.getIds();
577
+ */
578
+ getIds(params = {}) {
579
+ return this.http.get({
580
+ path: "/api/v1/favorites/ids",
581
+ params
582
+ }, FavoritesApiGetIdsResponseSchema);
583
+ }
584
+ /**
585
+ * Adds SKUs to favorites.
586
+ *
587
+ * @example
588
+ * await client.favorites.add({ skuIds: [12345, 67890] });
589
+ */
590
+ add(params) {
591
+ return this.http.post({
592
+ path: "/api/v1/favorites",
593
+ body: params.skuIds
594
+ }, FavoritesApiAddResponseSchema);
595
+ }
596
+ /**
597
+ * Removes SKUs from favorites.
598
+ *
599
+ * @example
600
+ * await client.favorites.remove({ skuIds: [12345, 67890] });
601
+ */
602
+ remove(params) {
603
+ return this.http.delete({
604
+ path: "/api/v1/favorites",
605
+ body: params.skuIds
606
+ }, FavoritesApiRemoveResponseSchema);
551
607
  }
552
608
  };
553
609
 
@@ -588,9 +644,8 @@ var FeatureFlagsApi = class {
588
644
  list(params = {}) {
589
645
  return this.http.get({
590
646
  path: "/api/v1/feature-flags",
591
- params,
592
- schema: FeatureFlagsApiListResponseSchema
593
- });
647
+ params
648
+ }, FeatureFlagsApiListResponseSchema);
594
649
  }
595
650
  };
596
651
 
@@ -643,9 +698,9 @@ const ProductsApiGetReviewsResponseSchema = zod_mini.object({
643
698
  * Schema for a product badge.
644
699
  */
645
700
  const ProductsApiBadgeSchema = zod_mini.object({
646
- backgroundColor: zod_mini.number(),
647
701
  label: zod_mini.string(),
648
- textColor: zod_mini.number()
702
+ textColor: zod_mini.number(),
703
+ backgroundColor: zod_mini.nullish(zod_mini.number())
649
704
  });
650
705
  /**
651
706
  * Type literal for products stock availability type
@@ -676,12 +731,12 @@ const ProductsApiProductItemSchema = zod_mini.object({
676
731
  qty: zod_mini.number(),
677
732
  stockAvailability: zod_mini.nullish(ProductsApiStockAvailabilitySchema),
678
733
  isPromo: zod_mini.boolean(),
679
- promoName: zod_mini.string(),
734
+ promoName: zod_mini.nullish(zod_mini.string()),
680
735
  promocodes: zod_mini.array(zod_mini.string()),
681
736
  qtyPurchasedInfo: zod_mini.nullish(zod_mini.string()),
682
737
  rating: zod_mini.nullish(zod_mini.number()),
683
738
  scoreQuantity: zod_mini.nullish(zod_mini.number()),
684
- badge: ProductsApiBadgeSchema,
739
+ badge: zod_mini.nullish(ProductsApiBadgeSchema),
685
740
  moderationStatus: zod_mini.number()
686
741
  });
687
742
  /**
@@ -720,9 +775,8 @@ var ProductsApi = class {
720
775
  getSortOptions(params = {}) {
721
776
  return this.http.get({
722
777
  path: "/api/product/sort-options",
723
- params,
724
- schema: ProductsApiGetSortOptionsResponseSchema
725
- });
778
+ params
779
+ }, ProductsApiGetSortOptionsResponseSchema);
726
780
  }
727
781
  /**
728
782
  * Retrieves a list of products with optional filtering and pagination.
@@ -736,9 +790,8 @@ var ProductsApi = class {
736
790
  list(params = {}) {
737
791
  return this.http.get({
738
792
  path: "/api/v2/product",
739
- params,
740
- schema: ProductsApiListResponseSchema
741
- });
793
+ params
794
+ }, ProductsApiListResponseSchema);
742
795
  }
743
796
  /**
744
797
  * Retrieves reviews for a specific product.
@@ -751,9 +804,8 @@ var ProductsApi = class {
751
804
  getReviews(params) {
752
805
  return this.http.get({
753
806
  path: `/api/v1/product/${params.productId}/review`,
754
- params,
755
- schema: ProductsApiGetReviewsResponseSchema
756
- });
807
+ params
808
+ }, ProductsApiGetReviewsResponseSchema);
757
809
  }
758
810
  };
759
811
 
@@ -798,9 +850,8 @@ var PromoApi = class {
798
850
  list(params = {}) {
799
851
  return this.http.get({
800
852
  path: "/api/promo",
801
- params,
802
- schema: PromoApiListResponseSchema
803
- });
853
+ params
854
+ }, PromoApiListResponseSchema);
804
855
  }
805
856
  };
806
857
 
@@ -932,9 +983,8 @@ var ShopsApi = class {
932
983
  get(params) {
933
984
  return this.http.get({
934
985
  path: `/api/v1/shops/${params.shopId}`,
935
- params,
936
- schema: ShopsApiGetResponseSchema
937
- });
986
+ params
987
+ }, ShopsApiGetResponseSchema);
938
988
  }
939
989
  /**
940
990
  * Retrieves monobrand shop details.
@@ -945,9 +995,8 @@ var ShopsApi = class {
945
995
  getMonobrand(params = {}) {
946
996
  return this.http.get({
947
997
  path: "/api/v1/shops/monobrand",
948
- params,
949
- schema: ShopsApiGetMonobrandResponseSchema
950
- });
998
+ params
999
+ }, ShopsApiGetMonobrandResponseSchema);
951
1000
  }
952
1001
  /**
953
1002
  * Retrieves products for a specific shop.
@@ -961,9 +1010,8 @@ var ShopsApi = class {
961
1010
  getProducts(params) {
962
1011
  return this.http.get({
963
1012
  path: `/api/v2/shops/${params.shopId}/products`,
964
- params,
965
- schema: ShopsApiGetProductsResponseSchema
966
- });
1013
+ params
1014
+ }, ShopsApiGetProductsResponseSchema);
967
1015
  }
968
1016
  };
969
1017
 
@@ -1161,9 +1209,8 @@ var SkuApi = class {
1161
1209
  get(params) {
1162
1210
  return this.http.get({
1163
1211
  path: `/api/v2/sku/${params.skuId}`,
1164
- params,
1165
- schema: SkuApiGetResponseSchema
1166
- });
1212
+ params
1213
+ }, SkuApiGetResponseSchema);
1167
1214
  }
1168
1215
  /**
1169
1216
  * Retrieves similar SKUs.
@@ -1176,9 +1223,8 @@ var SkuApi = class {
1176
1223
  getSimilar(params) {
1177
1224
  return this.http.get({
1178
1225
  path: "/api/v2/sku/similar-skus",
1179
- params,
1180
- schema: SkuApiGetSimilarResponseSchema
1181
- });
1226
+ params
1227
+ }, SkuApiGetSimilarResponseSchema);
1182
1228
  }
1183
1229
  /**
1184
1230
  * Retrieves collections associated with a SKU.
@@ -1191,9 +1237,8 @@ var SkuApi = class {
1191
1237
  getCollections(params) {
1192
1238
  return this.http.get({
1193
1239
  path: `/sku/${params.skuId}/collections`,
1194
- params,
1195
- schema: SkuApiGetCollectionsResponseSchema
1196
- });
1240
+ params
1241
+ }, SkuApiGetCollectionsResponseSchema);
1197
1242
  }
1198
1243
  /**
1199
1244
  * Checks if a review is available for a SKU.
@@ -1206,9 +1251,78 @@ var SkuApi = class {
1206
1251
  getReviewAvailable(params) {
1207
1252
  return this.http.get({
1208
1253
  path: `/sku/${params.skuId}/review-available`,
1209
- params,
1210
- schema: SkuApiGetReviewAvailableResponseSchema
1211
- });
1254
+ params
1255
+ }, SkuApiGetReviewAvailableResponseSchema);
1256
+ }
1257
+ };
1258
+
1259
+ //#endregion
1260
+ //#region src/api/users/schemas.ts
1261
+ /**
1262
+ * Supported language enum for user preference
1263
+ */
1264
+ const UsersApiLanguageEnumSchema = zod_mini.enum(["ru", "kk"]);
1265
+ /**
1266
+ * Response schema for language update
1267
+ */
1268
+ const UsersApiUpdateLanguageResponseSchema = zod_mini.object({
1269
+ language: UsersApiLanguageEnumSchema,
1270
+ title: zod_mini.string(),
1271
+ message: zod_mini.string()
1272
+ });
1273
+ /**
1274
+ * Response schema for device registration
1275
+ */
1276
+ const UsersApiRegisterDeviceResponseSchema = zod_mini.nullish(zod_mini.null());
1277
+
1278
+ //#endregion
1279
+ //#region src/api/users/api.ts
1280
+ /**
1281
+ * API for user management operations.
1282
+ */
1283
+ var UsersApi = class {
1284
+ /**
1285
+ * Initializes a new instance of the UsersApi.
1286
+ *
1287
+ * @param http HTTP client instance.
1288
+ */
1289
+ constructor(http) {
1290
+ this.http = http;
1291
+ }
1292
+ /**
1293
+ * Updates the user's preferred language.
1294
+ *
1295
+ * @example
1296
+ * await client.users.updateLanguage({
1297
+ * language: "ru"
1298
+ * });
1299
+ */
1300
+ updateLanguage(params) {
1301
+ return this.http.patch({
1302
+ path: "/api/v1/users/me/language",
1303
+ body: params
1304
+ }, UsersApiUpdateLanguageResponseSchema);
1305
+ }
1306
+ /**
1307
+ * Registers device identity for analytics tracking.
1308
+ *
1309
+ * @example
1310
+ * await client.users.registerDevice({
1311
+ * deviceIdentity: {
1312
+ * sdkInformation: [
1313
+ * {
1314
+ * type: "Appsflyer",
1315
+ * deviceId: "1765694307025-6267413661002574019"
1316
+ * }
1317
+ * ]
1318
+ * }
1319
+ * });
1320
+ */
1321
+ registerDevice(params) {
1322
+ return this.http.post({
1323
+ path: "/api/v1/device-identities",
1324
+ body: params
1325
+ }, UsersApiRegisterDeviceResponseSchema);
1212
1326
  }
1213
1327
  };
1214
1328
 
@@ -1230,6 +1344,20 @@ const LANGUAGES = {
1230
1344
  */
1231
1345
  const DEFAULT_APP_VERSION = "200";
1232
1346
 
1347
+ //#endregion
1348
+ //#region src/utils/merge-headers.ts
1349
+ /**
1350
+ * Merges base headers with new ones (overrides).
1351
+ * Returns a new Headers instance without mutating the original source.
1352
+ */
1353
+ function mergeHeaders(base, overrides) {
1354
+ const result = new Headers(base);
1355
+ if (overrides != void 0) new Headers(overrides).forEach((value, key) => {
1356
+ result.set(key, value);
1357
+ });
1358
+ return result;
1359
+ }
1360
+
1233
1361
  //#endregion
1234
1362
  //#region src/config.ts
1235
1363
  /**
@@ -1240,22 +1368,20 @@ const DEFAULT_CONFIG = {
1240
1368
  appVersion: DEFAULT_APP_VERSION,
1241
1369
  language: "ru",
1242
1370
  timeout: 3e4,
1243
- headers: {}
1371
+ headers: new Headers()
1244
1372
  };
1245
1373
  /**
1246
1374
  * Merges user configuration with defaults.
1247
1375
  */
1248
1376
  function resolveConfig(config) {
1377
+ const headers = mergeHeaders(DEFAULT_CONFIG.headers, config?.headers);
1249
1378
  return {
1250
1379
  baseUrl: config?.baseUrl ?? DEFAULT_CONFIG.baseUrl,
1251
1380
  token: config?.token,
1252
1381
  appVersion: config?.appVersion ?? DEFAULT_CONFIG.appVersion,
1253
1382
  language: config?.language ?? DEFAULT_CONFIG.language,
1254
1383
  timeout: config?.timeout ?? DEFAULT_CONFIG.timeout,
1255
- headers: {
1256
- ...DEFAULT_CONFIG.headers,
1257
- ...config?.headers
1258
- }
1384
+ headers
1259
1385
  };
1260
1386
  }
1261
1387
  /**
@@ -1268,16 +1394,23 @@ function buildUserAgent(appVersion) {
1268
1394
  * Builds the headers object for API requests based on configuration.
1269
1395
  */
1270
1396
  function buildHeaders(config) {
1271
- const headers = {
1272
- "accept-language": config.language,
1273
- "user-agent": buildUserAgent(config.appVersion),
1274
- "x-app-version": config.appVersion,
1275
- ...config.headers
1276
- };
1277
- if (config.token !== void 0 && config.token !== null) headers["authorization"] = `Bearer ${config.token}`;
1397
+ const headers = new Headers(config.headers);
1398
+ headers.set("Accept-Language", config.language);
1399
+ headers.set("User-Agent", buildUserAgent(config.appVersion));
1400
+ headers.set("X-App-Version", config.appVersion);
1401
+ if (config.token != void 0) headers.set("Authorization", `Bearer ${config.token}`);
1278
1402
  return headers;
1279
1403
  }
1280
1404
 
1405
+ //#endregion
1406
+ //#region src/errors/teez-error.ts
1407
+ /**
1408
+ * Base error class for all SDK-related errors.
1409
+ */
1410
+ var TeezError = class extends Error {
1411
+ name = "TeezError";
1412
+ };
1413
+
1281
1414
  //#endregion
1282
1415
  //#region src/errors/teez-api-error.ts
1283
1416
  /**
@@ -1286,6 +1419,10 @@ function buildHeaders(config) {
1286
1419
  var TeezApiError = class extends TeezError {
1287
1420
  name = "TeezApiError";
1288
1421
  /**
1422
+ * URL of the request that failed.
1423
+ */
1424
+ url;
1425
+ /**
1289
1426
  * HTTP status code.
1290
1427
  */
1291
1428
  status;
@@ -1294,18 +1431,14 @@ var TeezApiError = class extends TeezError {
1294
1431
  */
1295
1432
  statusText;
1296
1433
  /**
1297
- * URL of the request that failed.
1298
- */
1299
- url;
1300
- /**
1301
1434
  * Response body, if available.
1302
1435
  */
1303
1436
  body;
1304
1437
  constructor(message, { url, status, statusText, body, ...errorOptions }) {
1305
1438
  super(message, errorOptions);
1439
+ this.url = url;
1306
1440
  this.status = status;
1307
1441
  this.statusText = statusText;
1308
- this.url = url;
1309
1442
  this.body = body;
1310
1443
  }
1311
1444
  /**
@@ -1367,6 +1500,64 @@ var TeezTimeoutError = class extends TeezError {
1367
1500
  }
1368
1501
  };
1369
1502
 
1503
+ //#endregion
1504
+ //#region src/errors/teez-validation-error.ts
1505
+ /**
1506
+ * Error thrown when validation fails.
1507
+ */
1508
+ var TeezValidationError = class extends TeezError {
1509
+ name = "TeezValidationError";
1510
+ /**
1511
+ * List of standardized validation issues.
1512
+ */
1513
+ issues;
1514
+ /**
1515
+ * The raw data that failed validation.
1516
+ */
1517
+ data;
1518
+ constructor(message, { issues, data, ...errorOptions }) {
1519
+ super(message, errorOptions);
1520
+ this.issues = issues;
1521
+ this.data = data;
1522
+ }
1523
+ };
1524
+
1525
+ //#endregion
1526
+ //#region src/http/helpers.ts
1527
+ /**
1528
+ * Constructs a full URL with query parameters.
1529
+ */
1530
+ function buildUrl(path, baseUrl, queryParams) {
1531
+ const url = new URL(path, baseUrl);
1532
+ if (queryParams != void 0) for (const [key, value] of Object.entries(queryParams)) {
1533
+ if (value == void 0) continue;
1534
+ if (Array.isArray(value)) for (const item of value) url.searchParams.append(key, String(item));
1535
+ else url.searchParams.set(key, String(value));
1536
+ }
1537
+ return url;
1538
+ }
1539
+ /**
1540
+ * Converts Zod ZodError to abstract ValidationIssue[].
1541
+ */
1542
+ function toValidationIssues(error) {
1543
+ return error.issues.map((issue) => ({
1544
+ code: issue.code,
1545
+ path: issue.path,
1546
+ message: issue.message
1547
+ }));
1548
+ }
1549
+ /**
1550
+ * Validates and parses the API response data against a schema.
1551
+ */
1552
+ function parseResponse(schema, data) {
1553
+ const result = (0, zod_mini.safeParse)(schema, data);
1554
+ if (!result.success) throw new TeezValidationError("Response validation failed", {
1555
+ issues: toValidationIssues(result.error),
1556
+ data
1557
+ });
1558
+ return result.data;
1559
+ }
1560
+
1370
1561
  //#endregion
1371
1562
  //#region src/http/client.ts
1372
1563
  /**
@@ -1383,51 +1574,52 @@ var HttpClient = class {
1383
1574
  headers;
1384
1575
  /**
1385
1576
  * Initializes a new instance of the HttpClient.
1386
- *
1387
- * @param config Resolved client configuration.
1388
1577
  */
1389
1578
  constructor(config) {
1390
1579
  this.config = config;
1391
1580
  this.headers = buildHeaders(config);
1392
1581
  }
1393
1582
  /**
1394
- * Performs a low-level HTTP request.
1395
- *
1396
- * @param options Request options.
1583
+ * Implementation of request method.
1397
1584
  */
1398
- async request(options) {
1399
- const { url, headers, ...fetchOptions } = options;
1585
+ async request({ path, params, headers: headersRaw, body: bodyRaw, ...options }, schema) {
1586
+ const url = buildUrl(path, this.config.baseUrl, params);
1587
+ const headers = mergeHeaders(this.headers, headersRaw);
1588
+ let body;
1589
+ if (bodyRaw !== void 0) {
1590
+ body = JSON.stringify(bodyRaw);
1591
+ if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
1592
+ }
1400
1593
  const controller = new AbortController();
1401
1594
  const timeoutId = setTimeout(() => {
1402
1595
  controller.abort();
1403
1596
  }, this.config.timeout);
1404
1597
  try {
1405
1598
  const response = await fetch(url, {
1406
- ...fetchOptions,
1407
- headers: {
1408
- ...this.headers,
1409
- ...headers
1410
- },
1599
+ ...options,
1600
+ headers,
1601
+ body,
1411
1602
  signal: controller.signal
1412
1603
  });
1413
1604
  if (!response.ok) {
1414
- let body;
1605
+ let errorBody;
1415
1606
  try {
1416
- body = await response.json();
1607
+ errorBody = await response.json();
1417
1608
  } catch {
1418
- body = await response.text().catch(() => void 0);
1609
+ errorBody = await response.text().catch(() => void 0);
1419
1610
  }
1420
1611
  throw new TeezApiError(`API request failed: ${response.status} ${response.statusText}`, {
1421
1612
  url,
1422
1613
  status: response.status,
1423
1614
  statusText: response.statusText,
1424
- body
1615
+ body: errorBody
1425
1616
  });
1426
1617
  }
1427
1618
  if (response.status === 204) return;
1428
- return await response.json();
1619
+ const data = await response.json();
1620
+ return schema != void 0 ? parseResponse(schema, data) : data;
1429
1621
  } catch (error) {
1430
- if (error instanceof TeezApiError) throw error;
1622
+ if (error instanceof TeezError) throw error;
1431
1623
  if (error instanceof DOMException && error.name === "AbortError") throw new TeezTimeoutError(`Request timed out after ${this.config.timeout}ms`, {
1432
1624
  url,
1433
1625
  timeout: this.config.timeout,
@@ -1442,55 +1634,51 @@ var HttpClient = class {
1442
1634
  }
1443
1635
  }
1444
1636
  /**
1445
- * Performs a GET request and validates the response.
1637
+ * Implementation of GET method.
1446
1638
  */
1447
- async get(options) {
1448
- const { path, params, schema, ...rest } = options;
1449
- const url = buildUrl(path, this.config.baseUrl, params);
1450
- return parseResponse(schema, await this.request({
1451
- url,
1452
- method: "GET",
1453
- ...rest
1454
- }));
1639
+ get(options, schema) {
1640
+ return schema != void 0 ? this.request({
1641
+ ...options,
1642
+ method: "GET"
1643
+ }, schema) : this.request({
1644
+ ...options,
1645
+ method: "GET"
1646
+ });
1455
1647
  }
1456
1648
  /**
1457
- * Performs a POST request.
1649
+ * Implementation of POST method.
1458
1650
  */
1459
- post(options) {
1460
- const { path, params, body, ...rest } = options;
1461
- const url = buildUrl(path, this.config.baseUrl, params);
1462
- return this.request({
1463
- url,
1464
- method: "POST",
1465
- headers: { "Content-Type": "application/json" },
1466
- body: body != void 0 ? JSON.stringify(body) : void 0,
1467
- ...rest
1651
+ post(options, schema) {
1652
+ return schema != void 0 ? this.request({
1653
+ ...options,
1654
+ method: "POST"
1655
+ }, schema) : this.request({
1656
+ ...options,
1657
+ method: "POST"
1468
1658
  });
1469
1659
  }
1470
1660
  /**
1471
- * Performs a PATCH request.
1661
+ * Implementation of PATCH method.
1472
1662
  */
1473
- patch(options) {
1474
- const { path, params, body, ...rest } = options;
1475
- const url = buildUrl(path, this.config.baseUrl, params);
1476
- return this.request({
1477
- url,
1478
- method: "PATCH",
1479
- headers: { "Content-Type": "application/json" },
1480
- body: body != void 0 ? JSON.stringify(body) : void 0,
1481
- ...rest
1663
+ patch(options, schema) {
1664
+ return schema != void 0 ? this.request({
1665
+ ...options,
1666
+ method: "PATCH"
1667
+ }, schema) : this.request({
1668
+ ...options,
1669
+ method: "PATCH"
1482
1670
  });
1483
1671
  }
1484
1672
  /**
1485
- * Performs a DELETE request.
1673
+ * Implementation of DELETE method.
1486
1674
  */
1487
- delete(options) {
1488
- const { path, params, ...rest } = options;
1489
- const url = buildUrl(path, this.config.baseUrl, params);
1490
- return this.request({
1491
- url,
1492
- method: "DELETE",
1493
- ...rest
1675
+ delete(options, schema) {
1676
+ return schema != void 0 ? this.request({
1677
+ ...options,
1678
+ method: "DELETE"
1679
+ }, schema) : this.request({
1680
+ ...options,
1681
+ method: "DELETE"
1494
1682
  });
1495
1683
  }
1496
1684
  };
@@ -1516,7 +1704,7 @@ var TeezClient = class {
1516
1704
  */
1517
1705
  http;
1518
1706
  /**
1519
- * API for authentication operations (login, verify OTP, check token).
1707
+ * API for authentication operations.
1520
1708
  */
1521
1709
  auth;
1522
1710
  /**
@@ -1532,6 +1720,10 @@ var TeezClient = class {
1532
1720
  */
1533
1721
  collections;
1534
1722
  /**
1723
+ * API for managing user favorites.
1724
+ */
1725
+ favorites;
1726
+ /**
1535
1727
  * API for retrieving feature flags.
1536
1728
  */
1537
1729
  featureFlags;
@@ -1552,6 +1744,10 @@ var TeezClient = class {
1552
1744
  */
1553
1745
  sku;
1554
1746
  /**
1747
+ * API for user management operations.
1748
+ */
1749
+ users;
1750
+ /**
1555
1751
  * Initializes a new instance of the TeezClient.
1556
1752
  *
1557
1753
  * @param config Optional client configuration.
@@ -1563,11 +1759,13 @@ var TeezClient = class {
1563
1759
  this.banners = new BannersApi(this.http);
1564
1760
  this.categories = new CategoriesApi(this.http);
1565
1761
  this.collections = new CollectionsApi(this.http);
1762
+ this.favorites = new FavoritesApi(this.http);
1566
1763
  this.featureFlags = new FeatureFlagsApi(this.http);
1567
1764
  this.products = new ProductsApi(this.http);
1568
1765
  this.promo = new PromoApi(this.http);
1569
1766
  this.shops = new ShopsApi(this.http);
1570
1767
  this.sku = new SkuApi(this.http);
1768
+ this.users = new UsersApi(this.http);
1571
1769
  }
1572
1770
  /**
1573
1771
  * Returns the current client configuration.
@@ -1607,6 +1805,15 @@ exports.CollectionsApiStockAvailabilitySchema = CollectionsApiStockAvailabilityS
1607
1805
  exports.CollectionsStockAvailabilityTypeSchema = CollectionsStockAvailabilityTypeSchema;
1608
1806
  exports.DEFAULT_APP_VERSION = DEFAULT_APP_VERSION;
1609
1807
  exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
1808
+ exports.FavoritesApi = FavoritesApi;
1809
+ exports.FavoritesApiAddResponseSchema = FavoritesApiAddResponseSchema;
1810
+ exports.FavoritesApiBadgeSchema = FavoritesApiBadgeSchema;
1811
+ exports.FavoritesApiGetIdsResponseSchema = FavoritesApiGetIdsResponseSchema;
1812
+ exports.FavoritesApiItemSchema = FavoritesApiItemSchema;
1813
+ exports.FavoritesApiListResponseSchema = FavoritesApiListResponseSchema;
1814
+ exports.FavoritesApiRemoveResponseSchema = FavoritesApiRemoveResponseSchema;
1815
+ exports.FavoritesApiStockAvailabilitySchema = FavoritesApiStockAvailabilitySchema;
1816
+ exports.FavoritesStockAvailabilityTypeSchema = FavoritesStockAvailabilityTypeSchema;
1610
1817
  exports.FeatureFlagsApi = FeatureFlagsApi;
1611
1818
  exports.FeatureFlagsApiItemSchema = FeatureFlagsApiItemSchema;
1612
1819
  exports.FeatureFlagsApiListResponseSchema = FeatureFlagsApiListResponseSchema;
@@ -1658,6 +1865,10 @@ exports.TeezError = TeezError;
1658
1865
  exports.TeezNetworkError = TeezNetworkError;
1659
1866
  exports.TeezTimeoutError = TeezTimeoutError;
1660
1867
  exports.TeezValidationError = TeezValidationError;
1868
+ exports.UsersApi = UsersApi;
1869
+ exports.UsersApiLanguageEnumSchema = UsersApiLanguageEnumSchema;
1870
+ exports.UsersApiRegisterDeviceResponseSchema = UsersApiRegisterDeviceResponseSchema;
1871
+ exports.UsersApiUpdateLanguageResponseSchema = UsersApiUpdateLanguageResponseSchema;
1661
1872
  exports.buildHeaders = buildHeaders;
1662
1873
  exports.buildUserAgent = buildUserAgent;
1663
1874
  exports.resolveConfig = resolveConfig;