@01.software/sdk 0.2.9-dev.260310.cf511cb → 0.2.9-dev.260311.892250f

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.
Files changed (58) hide show
  1. package/README.md +21 -8
  2. package/dist/auth.cjs +3 -1
  3. package/dist/auth.cjs.map +1 -1
  4. package/dist/auth.d.cts +36 -3
  5. package/dist/auth.d.ts +36 -3
  6. package/dist/auth.js +3 -1
  7. package/dist/auth.js.map +1 -1
  8. package/dist/index.cjs +214 -231
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +321 -155
  11. package/dist/index.d.ts +321 -155
  12. package/dist/index.js +217 -231
  13. package/dist/index.js.map +1 -1
  14. package/dist/{payload-types-Cq93wqIe.d.cts → payload-types-BjvBwB8Z.d.cts} +1601 -1373
  15. package/dist/{payload-types-Cq93wqIe.d.ts → payload-types-BjvBwB8Z.d.ts} +1601 -1373
  16. package/dist/ui/code-block.cjs +182 -0
  17. package/dist/ui/code-block.cjs.map +1 -0
  18. package/dist/ui/code-block.d.cts +62 -0
  19. package/dist/ui/code-block.d.ts +62 -0
  20. package/dist/ui/code-block.js +152 -0
  21. package/dist/ui/code-block.js.map +1 -0
  22. package/dist/{flow.cjs → ui/flow.cjs} +120 -96
  23. package/dist/ui/flow.cjs.map +1 -0
  24. package/dist/{flow.d.cts → ui/flow.d.cts} +27 -11
  25. package/dist/{flow.d.ts → ui/flow.d.ts} +27 -11
  26. package/dist/{flow.js → ui/flow.js} +119 -94
  27. package/dist/ui/flow.js.map +1 -0
  28. package/dist/{components.cjs → ui/form.cjs} +27 -520
  29. package/dist/ui/form.cjs.map +1 -0
  30. package/dist/ui/form.d.cts +37 -0
  31. package/dist/ui/form.d.ts +37 -0
  32. package/dist/{components.js → ui/form.js} +20 -516
  33. package/dist/ui/form.js.map +1 -0
  34. package/dist/ui/image.cjs +208 -0
  35. package/dist/ui/image.cjs.map +1 -0
  36. package/dist/ui/image.d.cts +44 -0
  37. package/dist/ui/image.d.ts +44 -0
  38. package/dist/ui/image.js +180 -0
  39. package/dist/ui/image.js.map +1 -0
  40. package/dist/ui/rich-text.cjs +258 -0
  41. package/dist/ui/rich-text.cjs.map +1 -0
  42. package/dist/ui/rich-text.d.cts +110 -0
  43. package/dist/ui/rich-text.d.ts +110 -0
  44. package/dist/ui/rich-text.js +235 -0
  45. package/dist/ui/rich-text.js.map +1 -0
  46. package/dist/{webhook-NRdVwXN7.d.cts → webhook-CszIpUKn.d.cts} +2 -2
  47. package/dist/{webhook-C_7s0K66.d.ts → webhook-_LdLdjGa.d.ts} +2 -2
  48. package/dist/webhook.d.cts +2 -2
  49. package/dist/webhook.d.ts +2 -2
  50. package/package.json +47 -12
  51. package/dist/auth-CVVo5UT5.d.ts +0 -298
  52. package/dist/auth-CqgrT1qd.d.cts +0 -298
  53. package/dist/components.cjs.map +0 -1
  54. package/dist/components.d.cts +0 -240
  55. package/dist/components.d.ts +0 -240
  56. package/dist/components.js.map +0 -1
  57. package/dist/flow.cjs.map +0 -1
  58. package/dist/flow.js.map +0 -1
package/dist/index.js CHANGED
@@ -51,8 +51,86 @@ var __async = (__this, __arguments, generator) => {
51
51
  });
52
52
  };
53
53
 
54
- // src/core/internal/utils/index.ts
54
+ // src/core/internal/utils/jwt.ts
55
55
  import { SignJWT, jwtVerify, decodeJwt } from "jose";
56
+ function createServerToken(clientKey, secretKey, expiresIn = "1h") {
57
+ return __async(this, null, function* () {
58
+ if (!clientKey || !secretKey) {
59
+ throw new Error("clientKey and secretKey are required.");
60
+ }
61
+ const secret = new TextEncoder().encode(secretKey);
62
+ return new SignJWT({ clientKey }).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(secret);
63
+ });
64
+ }
65
+ function verifyServerToken(token, secretKey) {
66
+ return __async(this, null, function* () {
67
+ if (!token || !secretKey) {
68
+ throw new Error("token and secretKey are required.");
69
+ }
70
+ const secret = new TextEncoder().encode(secretKey);
71
+ const { payload } = yield jwtVerify(token, secret, {
72
+ algorithms: ["HS256"]
73
+ });
74
+ if (!payload.clientKey || typeof payload.clientKey !== "string") {
75
+ throw new Error("Invalid token payload: clientKey is missing");
76
+ }
77
+ return {
78
+ clientKey: payload.clientKey,
79
+ iat: payload.iat,
80
+ exp: payload.exp
81
+ };
82
+ });
83
+ }
84
+ function decodeServerToken(token) {
85
+ if (!token) {
86
+ throw new Error("token is required.");
87
+ }
88
+ const payload = decodeJwt(token);
89
+ if (!payload.clientKey || typeof payload.clientKey !== "string") {
90
+ throw new Error("Invalid token payload: clientKey is missing");
91
+ }
92
+ return {
93
+ clientKey: payload.clientKey,
94
+ iat: payload.iat,
95
+ exp: payload.exp
96
+ };
97
+ }
98
+
99
+ // src/core/internal/utils/encoding.ts
100
+ function createApiKey(clientKey, secretKey) {
101
+ if (!clientKey || !secretKey) {
102
+ throw new Error("clientKey and secretKey are required.");
103
+ }
104
+ if (typeof Buffer !== "undefined") {
105
+ return Buffer.from(`${clientKey}:${secretKey}`).toString("base64");
106
+ }
107
+ return btoa(`${clientKey}:${secretKey}`);
108
+ }
109
+ function parseApiKey(apiKey) {
110
+ if (!apiKey) {
111
+ throw new Error("apiKey is required.");
112
+ }
113
+ try {
114
+ let decoded;
115
+ if (typeof Buffer !== "undefined") {
116
+ decoded = Buffer.from(apiKey, "base64").toString("utf-8");
117
+ } else {
118
+ decoded = atob(apiKey);
119
+ }
120
+ const colonIndex = decoded.indexOf(":");
121
+ if (colonIndex === -1) {
122
+ throw new Error("Invalid format: missing colon separator");
123
+ }
124
+ const clientKey = decoded.substring(0, colonIndex);
125
+ const secretKey = decoded.substring(colonIndex + 1);
126
+ if (!clientKey || !secretKey) {
127
+ throw new Error("Invalid format: empty clientKey or secretKey");
128
+ }
129
+ return { clientKey, secretKey };
130
+ } catch (e) {
131
+ throw new Error('Invalid API key. Expected Base64 encoded "clientKey:secretKey"');
132
+ }
133
+ }
56
134
 
57
135
  // src/core/internal/errors/index.ts
58
136
  var SDKError = class _SDKError extends Error {
@@ -193,87 +271,11 @@ function resolveApiUrl(config) {
193
271
  return API_URLS.production;
194
272
  }
195
273
 
196
- // src/core/internal/utils/index.ts
274
+ // src/core/internal/utils/http.ts
197
275
  var DEFAULT_TIMEOUT = 3e4;
198
276
  var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
199
277
  var NON_RETRYABLE_STATUSES = [401, 403, 404, 422];
200
278
  var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
201
- function createServerToken(clientKey, secretKey, expiresIn = "1h") {
202
- return __async(this, null, function* () {
203
- if (!clientKey || !secretKey) {
204
- throw new Error("clientKey and secretKey are required.");
205
- }
206
- const secret = new TextEncoder().encode(secretKey);
207
- return new SignJWT({ clientKey }).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(secret);
208
- });
209
- }
210
- function verifyServerToken(token, secretKey) {
211
- return __async(this, null, function* () {
212
- if (!token || !secretKey) {
213
- throw new Error("token and secretKey are required.");
214
- }
215
- const secret = new TextEncoder().encode(secretKey);
216
- const { payload } = yield jwtVerify(token, secret, {
217
- algorithms: ["HS256"]
218
- });
219
- if (!payload.clientKey || typeof payload.clientKey !== "string") {
220
- throw new Error("Invalid token payload: clientKey is missing");
221
- }
222
- return {
223
- clientKey: payload.clientKey,
224
- iat: payload.iat,
225
- exp: payload.exp
226
- };
227
- });
228
- }
229
- function decodeServerToken(token) {
230
- if (!token) {
231
- throw new Error("token is required.");
232
- }
233
- const payload = decodeJwt(token);
234
- if (!payload.clientKey || typeof payload.clientKey !== "string") {
235
- throw new Error("Invalid token payload: clientKey is missing");
236
- }
237
- return {
238
- clientKey: payload.clientKey,
239
- iat: payload.iat,
240
- exp: payload.exp
241
- };
242
- }
243
- function createApiKey(clientKey, secretKey) {
244
- if (!clientKey || !secretKey) {
245
- throw new Error("clientKey and secretKey are required.");
246
- }
247
- if (typeof Buffer !== "undefined") {
248
- return Buffer.from(`${clientKey}:${secretKey}`).toString("base64");
249
- }
250
- return btoa(`${clientKey}:${secretKey}`);
251
- }
252
- function parseApiKey(apiKey) {
253
- if (!apiKey) {
254
- throw new Error("apiKey is required.");
255
- }
256
- try {
257
- let decoded;
258
- if (typeof Buffer !== "undefined") {
259
- decoded = Buffer.from(apiKey, "base64").toString("utf-8");
260
- } else {
261
- decoded = atob(apiKey);
262
- }
263
- const colonIndex = decoded.indexOf(":");
264
- if (colonIndex === -1) {
265
- throw new Error("Invalid format: missing colon separator");
266
- }
267
- const clientKey = decoded.substring(0, colonIndex);
268
- const secretKey = decoded.substring(colonIndex + 1);
269
- if (!clientKey || !secretKey) {
270
- throw new Error("Invalid format: empty clientKey or secretKey");
271
- }
272
- return { clientKey, secretKey };
273
- } catch (e) {
274
- throw new Error('Invalid API key. Expected Base64 encoded "clientKey:secretKey"');
275
- }
276
- }
277
279
  function debugLog(debug, type, message, data) {
278
280
  if (!debug) return;
279
281
  const shouldLog = debug === true || type === "request" && debug.logRequests || type === "response" && debug.logResponses || type === "error" && debug.logErrors;
@@ -295,7 +297,7 @@ function delay(ms) {
295
297
  return new Promise((resolve) => setTimeout(resolve, ms));
296
298
  });
297
299
  }
298
- function _fetch(url, options) {
300
+ function httpFetch(url, options) {
299
301
  return __async(this, null, function* () {
300
302
  var _b, _c, _d;
301
303
  const _a = options || {}, {
@@ -475,14 +477,14 @@ function _fetch(url, options) {
475
477
  });
476
478
  }
477
479
 
478
- // src/core/api/order-api.ts
479
- var OrderApi = class {
480
- constructor(options) {
480
+ // src/core/api/base-api.ts
481
+ var BaseApi = class {
482
+ constructor(apiName, options) {
481
483
  if (!options.clientKey) {
482
- throw createConfigError("clientKey is required for OrderApi.");
484
+ throw createConfigError(`clientKey is required for ${apiName}.`);
483
485
  }
484
486
  if (!options.secretKey) {
485
- throw createConfigError("secretKey is required for OrderApi.");
487
+ throw createConfigError(`secretKey is required for ${apiName}.`);
486
488
  }
487
489
  this.clientKey = options.clientKey;
488
490
  this.secretKey = options.secretKey;
@@ -490,7 +492,7 @@ var OrderApi = class {
490
492
  }
491
493
  request(endpoint, body) {
492
494
  return __async(this, null, function* () {
493
- const response = yield _fetch(endpoint, {
495
+ const response = yield httpFetch(endpoint, {
494
496
  method: "POST",
495
497
  clientKey: this.clientKey,
496
498
  secretKey: this.secretKey,
@@ -522,6 +524,13 @@ var OrderApi = class {
522
524
  return data;
523
525
  });
524
526
  }
527
+ };
528
+
529
+ // src/core/api/order-api.ts
530
+ var OrderApi = class extends BaseApi {
531
+ constructor(options) {
532
+ super("OrderApi", options);
533
+ }
525
534
  createOrder(params) {
526
535
  return this.request("/api/orders/create", params);
527
536
  }
@@ -584,7 +593,7 @@ var CartApi = class {
584
593
  execute(endpoint, method, body) {
585
594
  return __async(this, null, function* () {
586
595
  const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
587
- const response = yield _fetch(endpoint, __spreadValues(__spreadValues({
596
+ const response = yield httpFetch(endpoint, __spreadValues(__spreadValues({
588
597
  method,
589
598
  clientKey: this.clientKey,
590
599
  secretKey: this.secretKey,
@@ -640,51 +649,9 @@ var CartApi = class {
640
649
  };
641
650
 
642
651
  // src/core/api/product-api.ts
643
- var ProductApi = class {
652
+ var ProductApi = class extends BaseApi {
644
653
  constructor(options) {
645
- if (!options.clientKey) {
646
- throw createConfigError("clientKey is required for ProductApi.");
647
- }
648
- if (!options.secretKey) {
649
- throw createConfigError("secretKey is required for ProductApi.");
650
- }
651
- this.clientKey = options.clientKey;
652
- this.secretKey = options.secretKey;
653
- this.baseUrl = options.baseUrl;
654
- }
655
- request(endpoint, body) {
656
- return __async(this, null, function* () {
657
- const response = yield _fetch(endpoint, {
658
- method: "POST",
659
- clientKey: this.clientKey,
660
- secretKey: this.secretKey,
661
- baseUrl: this.baseUrl,
662
- body: JSON.stringify(body)
663
- });
664
- let data;
665
- try {
666
- data = yield response.json();
667
- } catch (e) {
668
- throw createApiError(
669
- `Invalid JSON response from ${endpoint}`,
670
- response.status,
671
- void 0,
672
- "Server returned an invalid response.",
673
- "Check if the API endpoint is available."
674
- );
675
- }
676
- if (data.error) {
677
- const errorMessage = typeof data.error === "string" ? data.error : "Unknown API error";
678
- throw createApiError(
679
- errorMessage,
680
- response.status,
681
- data,
682
- errorMessage,
683
- "An error occurred while processing the request."
684
- );
685
- }
686
- return data;
687
- });
654
+ super("ProductApi", options);
688
655
  }
689
656
  stockCheck(params) {
690
657
  return this.request("/api/products/stock-check", params);
@@ -1045,7 +1012,7 @@ var CollectionClient = class extends HttpClient {
1045
1012
  requestFind(endpoint, options) {
1046
1013
  return __async(this, null, function* () {
1047
1014
  const url = this.buildUrl(endpoint, options);
1048
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1015
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1049
1016
  return this.parseFindResponse(response);
1050
1017
  });
1051
1018
  }
@@ -1056,7 +1023,7 @@ var CollectionClient = class extends HttpClient {
1056
1023
  requestFindById(endpoint, options) {
1057
1024
  return __async(this, null, function* () {
1058
1025
  const url = this.buildUrl(endpoint, options);
1059
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1026
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1060
1027
  return this.parseDocumentResponse(response);
1061
1028
  });
1062
1029
  }
@@ -1066,7 +1033,7 @@ var CollectionClient = class extends HttpClient {
1066
1033
  */
1067
1034
  requestCreate(endpoint, data) {
1068
1035
  return __async(this, null, function* () {
1069
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1036
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1070
1037
  method: "POST",
1071
1038
  body: data ? JSON.stringify(data) : void 0
1072
1039
  }));
@@ -1079,7 +1046,7 @@ var CollectionClient = class extends HttpClient {
1079
1046
  */
1080
1047
  requestUpdate(endpoint, data) {
1081
1048
  return __async(this, null, function* () {
1082
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1049
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1083
1050
  method: "PATCH",
1084
1051
  body: data ? JSON.stringify(data) : void 0
1085
1052
  }));
@@ -1093,7 +1060,7 @@ var CollectionClient = class extends HttpClient {
1093
1060
  requestCount(endpoint, options) {
1094
1061
  return __async(this, null, function* () {
1095
1062
  const url = this.buildUrl(endpoint, options);
1096
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1063
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1097
1064
  return this.parseDocumentResponse(response);
1098
1065
  });
1099
1066
  }
@@ -1103,7 +1070,7 @@ var CollectionClient = class extends HttpClient {
1103
1070
  */
1104
1071
  requestUpdateMany(endpoint, data) {
1105
1072
  return __async(this, null, function* () {
1106
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1073
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1107
1074
  method: "PATCH",
1108
1075
  body: JSON.stringify(data)
1109
1076
  }));
@@ -1116,7 +1083,7 @@ var CollectionClient = class extends HttpClient {
1116
1083
  */
1117
1084
  requestDelete(endpoint) {
1118
1085
  return __async(this, null, function* () {
1119
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1086
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1120
1087
  method: "DELETE"
1121
1088
  }));
1122
1089
  return this.parseDocumentResponse(response);
@@ -1128,7 +1095,7 @@ var CollectionClient = class extends HttpClient {
1128
1095
  */
1129
1096
  requestDeleteMany(endpoint, data) {
1130
1097
  return __async(this, null, function* () {
1131
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1098
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1132
1099
  method: "DELETE",
1133
1100
  body: JSON.stringify(data)
1134
1101
  }));
@@ -1141,7 +1108,7 @@ var CollectionClient = class extends HttpClient {
1141
1108
  */
1142
1109
  requestCreateWithFile(endpoint, data, file, filename) {
1143
1110
  return __async(this, null, function* () {
1144
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1111
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1145
1112
  method: "POST",
1146
1113
  body: buildPayloadFormData(data, file, filename)
1147
1114
  }));
@@ -1154,7 +1121,7 @@ var CollectionClient = class extends HttpClient {
1154
1121
  */
1155
1122
  requestUpdateWithFile(endpoint, data, file, filename) {
1156
1123
  return __async(this, null, function* () {
1157
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1124
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1158
1125
  method: "PATCH",
1159
1126
  body: buildPayloadFormData(data, file, filename)
1160
1127
  }));
@@ -1206,6 +1173,7 @@ var COLLECTIONS = [
1206
1173
  "playlists",
1207
1174
  "playlist-images",
1208
1175
  "playlist-categories",
1176
+ "playlist-tags",
1209
1177
  "musics",
1210
1178
  "galleries",
1211
1179
  "gallery-images",
@@ -1215,6 +1183,7 @@ var COLLECTIONS = [
1215
1183
  "flow-images",
1216
1184
  "flow-node-types",
1217
1185
  "flow-edge-types",
1186
+ "flow-categories",
1218
1187
  "flow-tags",
1219
1188
  "videos",
1220
1189
  "video-images",
@@ -1506,7 +1475,7 @@ function getQueryClient() {
1506
1475
  return browserQueryClient;
1507
1476
  }
1508
1477
 
1509
- // src/core/query/query-hooks.ts
1478
+ // src/core/query/collection-hooks.ts
1510
1479
  import {
1511
1480
  useQuery as useQueryOriginal,
1512
1481
  useSuspenseQuery as useSuspenseQueryOriginal,
@@ -1514,6 +1483,8 @@ import {
1514
1483
  useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,
1515
1484
  useMutation as useMutationOriginal
1516
1485
  } from "@tanstack/react-query";
1486
+
1487
+ // src/core/query/query-keys.ts
1517
1488
  function collectionKeys(collection) {
1518
1489
  return {
1519
1490
  all: [collection],
@@ -1529,20 +1500,13 @@ var customerKeys = {
1529
1500
  all: ["customer"],
1530
1501
  me: () => ["customer", "me"]
1531
1502
  };
1503
+
1504
+ // src/core/query/collection-hooks.ts
1532
1505
  var DEFAULT_PAGE_SIZE = 20;
1533
- var QueryHooks = class {
1534
- constructor(queryClient, collectionClient, customerAuth) {
1506
+ var CollectionHooks = class {
1507
+ constructor(queryClient, collectionClient) {
1535
1508
  this.queryClient = queryClient;
1536
1509
  this.collectionClient = collectionClient;
1537
- this.customerAuth = customerAuth;
1538
- }
1539
- ensureCustomerAuth() {
1540
- if (!this.customerAuth) {
1541
- throw createConfigError(
1542
- "Customer hooks require BrowserClient. Use createBrowserClient() instead of createServerClient()."
1543
- );
1544
- }
1545
- return this.customerAuth;
1546
1510
  }
1547
1511
  // ===== useQuery =====
1548
1512
  useQuery(params, options) {
@@ -1741,10 +1705,45 @@ var QueryHooks = class {
1741
1705
  );
1742
1706
  }
1743
1707
  }
1744
- // ===== Customer Query Hooks =====
1708
+ };
1709
+
1710
+ // src/core/query/customer-hooks.ts
1711
+ import {
1712
+ useQuery as useQueryOriginal2,
1713
+ useMutation as useMutationOriginal2
1714
+ } from "@tanstack/react-query";
1715
+ function createMutation(mutationFn, callbacks, onSuccessExtra) {
1716
+ return useMutationOriginal2({
1717
+ mutationFn,
1718
+ onSuccess: (data) => {
1719
+ var _a;
1720
+ onSuccessExtra == null ? void 0 : onSuccessExtra(data);
1721
+ (_a = callbacks == null ? void 0 : callbacks.onSuccess) == null ? void 0 : _a.call(callbacks, data);
1722
+ },
1723
+ onError: callbacks == null ? void 0 : callbacks.onError,
1724
+ onSettled: callbacks == null ? void 0 : callbacks.onSettled
1725
+ });
1726
+ }
1727
+ var CustomerHooks = class {
1728
+ constructor(queryClient, customerAuth) {
1729
+ this.invalidateMe = () => {
1730
+ this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1731
+ };
1732
+ this.queryClient = queryClient;
1733
+ this.customerAuth = customerAuth;
1734
+ }
1735
+ ensureCustomerAuth() {
1736
+ if (!this.customerAuth) {
1737
+ throw createConfigError(
1738
+ "Customer hooks require BrowserClient. Use createBrowserClient() instead of createServerClient()."
1739
+ );
1740
+ }
1741
+ return this.customerAuth;
1742
+ }
1743
+ // ===== useCustomerMe =====
1745
1744
  useCustomerMe(options) {
1746
1745
  var _a, _b;
1747
- return useQueryOriginal(__spreadProps(__spreadValues({
1746
+ return useQueryOriginal2(__spreadProps(__spreadValues({
1748
1747
  queryKey: customerKeys.me(),
1749
1748
  queryFn: () => __async(this, null, function* () {
1750
1749
  return yield this.ensureCustomerAuth().me();
@@ -1753,32 +1752,22 @@ var QueryHooks = class {
1753
1752
  enabled: ((_a = options == null ? void 0 : options.enabled) != null ? _a : true) && !!((_b = this.customerAuth) == null ? void 0 : _b.isAuthenticated())
1754
1753
  }));
1755
1754
  }
1755
+ // ===== Mutations =====
1756
1756
  useCustomerLogin(options) {
1757
- return useMutationOriginal({
1758
- mutationFn: (data) => __async(this, null, function* () {
1759
- return yield this.ensureCustomerAuth().login(data);
1760
- }),
1761
- onSuccess: (data) => {
1762
- var _a;
1763
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1764
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1765
- },
1766
- onError: options == null ? void 0 : options.onError,
1767
- onSettled: options == null ? void 0 : options.onSettled
1768
- });
1757
+ return createMutation(
1758
+ (data) => this.ensureCustomerAuth().login(data),
1759
+ options,
1760
+ this.invalidateMe
1761
+ );
1769
1762
  }
1770
1763
  useCustomerRegister(options) {
1771
- return useMutationOriginal({
1772
- mutationFn: (data) => __async(this, null, function* () {
1773
- return yield this.ensureCustomerAuth().register(data);
1774
- }),
1775
- onSuccess: options == null ? void 0 : options.onSuccess,
1776
- onError: options == null ? void 0 : options.onError,
1777
- onSettled: options == null ? void 0 : options.onSettled
1778
- });
1764
+ return createMutation(
1765
+ (data) => this.ensureCustomerAuth().register(data),
1766
+ options
1767
+ );
1779
1768
  }
1780
1769
  useCustomerLogout(options) {
1781
- return useMutationOriginal({
1770
+ return useMutationOriginal2({
1782
1771
  mutationFn: () => __async(this, null, function* () {
1783
1772
  this.ensureCustomerAuth().logout();
1784
1773
  }),
@@ -1792,76 +1781,47 @@ var QueryHooks = class {
1792
1781
  });
1793
1782
  }
1794
1783
  useCustomerForgotPassword(options) {
1795
- return useMutationOriginal({
1796
- mutationFn: (email) => __async(this, null, function* () {
1797
- yield this.ensureCustomerAuth().forgotPassword(email);
1784
+ return createMutation(
1785
+ (email) => this.ensureCustomerAuth().forgotPassword(email).then(() => {
1798
1786
  }),
1799
- onSuccess: options == null ? void 0 : options.onSuccess,
1800
- onError: options == null ? void 0 : options.onError,
1801
- onSettled: options == null ? void 0 : options.onSettled
1802
- });
1787
+ options
1788
+ );
1803
1789
  }
1804
1790
  useCustomerResetPassword(options) {
1805
- return useMutationOriginal({
1806
- mutationFn: (data) => __async(this, null, function* () {
1807
- yield this.ensureCustomerAuth().resetPassword(data.token, data.password);
1791
+ return createMutation(
1792
+ (data) => this.ensureCustomerAuth().resetPassword(data.token, data.password).then(() => {
1808
1793
  }),
1809
- onSuccess: options == null ? void 0 : options.onSuccess,
1810
- onError: options == null ? void 0 : options.onError,
1811
- onSettled: options == null ? void 0 : options.onSettled
1812
- });
1794
+ options
1795
+ );
1813
1796
  }
1814
1797
  useCustomerVerifyEmail(options) {
1815
- return useMutationOriginal({
1816
- mutationFn: (token) => __async(this, null, function* () {
1817
- yield this.ensureCustomerAuth().verifyEmail(token);
1798
+ return createMutation(
1799
+ (token) => this.ensureCustomerAuth().verifyEmail(token).then(() => {
1818
1800
  }),
1819
- onSuccess: () => {
1820
- var _a;
1821
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1822
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
1823
- },
1824
- onError: options == null ? void 0 : options.onError,
1825
- onSettled: options == null ? void 0 : options.onSettled
1826
- });
1801
+ options,
1802
+ this.invalidateMe
1803
+ );
1827
1804
  }
1828
1805
  useCustomerRefreshToken(options) {
1829
- return useMutationOriginal({
1830
- mutationFn: () => __async(this, null, function* () {
1831
- return yield this.ensureCustomerAuth().refreshToken();
1832
- }),
1833
- onSuccess: (data) => {
1834
- var _a;
1835
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1836
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1837
- },
1838
- onError: options == null ? void 0 : options.onError,
1839
- onSettled: options == null ? void 0 : options.onSettled
1840
- });
1806
+ return createMutation(
1807
+ () => this.ensureCustomerAuth().refreshToken(),
1808
+ options,
1809
+ this.invalidateMe
1810
+ );
1841
1811
  }
1842
1812
  useCustomerUpdateProfile(options) {
1843
- return useMutationOriginal({
1844
- mutationFn: (data) => __async(this, null, function* () {
1845
- return yield this.ensureCustomerAuth().updateProfile(data);
1846
- }),
1847
- onSuccess: (data) => {
1848
- var _a;
1849
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1850
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1851
- },
1852
- onError: options == null ? void 0 : options.onError,
1853
- onSettled: options == null ? void 0 : options.onSettled
1854
- });
1813
+ return createMutation(
1814
+ (data) => this.ensureCustomerAuth().updateProfile(data),
1815
+ options,
1816
+ this.invalidateMe
1817
+ );
1855
1818
  }
1856
1819
  useCustomerChangePassword(options) {
1857
- return useMutationOriginal({
1858
- mutationFn: (data) => __async(this, null, function* () {
1859
- yield this.ensureCustomerAuth().changePassword(data.currentPassword, data.newPassword);
1820
+ return createMutation(
1821
+ (data) => this.ensureCustomerAuth().changePassword(data.currentPassword, data.newPassword).then(() => {
1860
1822
  }),
1861
- onSuccess: options == null ? void 0 : options.onSuccess,
1862
- onError: options == null ? void 0 : options.onError,
1863
- onSettled: options == null ? void 0 : options.onSettled
1864
- });
1823
+ options
1824
+ );
1865
1825
  }
1866
1826
  // ===== Customer Cache Utilities =====
1867
1827
  invalidateCustomerQueries() {
@@ -1875,6 +1835,29 @@ var QueryHooks = class {
1875
1835
  }
1876
1836
  };
1877
1837
 
1838
+ // src/core/query/query-hooks.ts
1839
+ var QueryHooks = class extends CollectionHooks {
1840
+ constructor(queryClient, collectionClient, customerAuth) {
1841
+ super(queryClient, collectionClient);
1842
+ // --- Customer hooks delegation ---
1843
+ this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
1844
+ this.useCustomerLogin = (...args) => this._customer.useCustomerLogin(...args);
1845
+ this.useCustomerRegister = (...args) => this._customer.useCustomerRegister(...args);
1846
+ this.useCustomerLogout = (...args) => this._customer.useCustomerLogout(...args);
1847
+ this.useCustomerForgotPassword = (...args) => this._customer.useCustomerForgotPassword(...args);
1848
+ this.useCustomerResetPassword = (...args) => this._customer.useCustomerResetPassword(...args);
1849
+ this.useCustomerVerifyEmail = (...args) => this._customer.useCustomerVerifyEmail(...args);
1850
+ this.useCustomerRefreshToken = (...args) => this._customer.useCustomerRefreshToken(...args);
1851
+ this.useCustomerUpdateProfile = (...args) => this._customer.useCustomerUpdateProfile(...args);
1852
+ this.useCustomerChangePassword = (...args) => this._customer.useCustomerChangePassword(...args);
1853
+ // --- Customer cache delegation ---
1854
+ this.invalidateCustomerQueries = () => this._customer.invalidateCustomerQueries();
1855
+ this.getCustomerData = () => this._customer.getCustomerData();
1856
+ this.setCustomerData = (data) => this._customer.setCustomerData(data);
1857
+ this._customer = new CustomerHooks(queryClient, customerAuth);
1858
+ }
1859
+ };
1860
+
1878
1861
  // src/core/client/client.ts
1879
1862
  var BrowserClient = class {
1880
1863
  constructor(options) {
@@ -2183,13 +2166,16 @@ function getVideoMp4Url(playbackId, resolution = "high") {
2183
2166
  }
2184
2167
  export {
2185
2168
  ApiError,
2169
+ BaseApi,
2186
2170
  BrowserClient,
2187
2171
  COLLECTIONS,
2188
2172
  CartApi,
2189
2173
  CollectionClient,
2174
+ CollectionHooks,
2190
2175
  CollectionQueryBuilder,
2191
2176
  ConfigError,
2192
2177
  CustomerAuth,
2178
+ CustomerHooks,
2193
2179
  GoneError,
2194
2180
  IMAGE_SIZES,
2195
2181
  NetworkError,