@01.software/sdk 0.2.9-dev.260309.c56872d → 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 +252 -258
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +324 -161
  11. package/dist/index.d.ts +324 -161
  12. package/dist/index.js +255 -258
  13. package/dist/index.js.map +1 -1
  14. package/dist/{payload-types-2wbfaDxp.d.cts → payload-types-BjvBwB8Z.d.cts} +1633 -507
  15. package/dist/{payload-types-2wbfaDxp.d.ts → payload-types-BjvBwB8Z.d.ts} +1633 -507
  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-I6ZDGW1d.d.ts → webhook-CszIpUKn.d.cts} +2 -2
  47. package/dist/{webhook-Byzl1A0g.d.cts → 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 +66 -33
  51. package/dist/auth-BieKA-OQ.d.ts +0 -298
  52. package/dist/auth-CAV8xgZk.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);
@@ -693,42 +660,44 @@ var ProductApi = class {
693
660
 
694
661
  // src/utils/types.ts
695
662
  var resolveRelation = (ref) => {
696
- if (typeof ref === "string" || ref === null || ref === void 0)
663
+ if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
697
664
  return null;
698
665
  return ref;
699
666
  };
700
- var objectFor = resolveRelation;
701
667
 
702
668
  // src/core/metadata/index.ts
703
- var COLLECTION_META_FIELDS = {
704
- products: { description: "subtitle", image: "thumbnail" },
705
- posts: { description: "excerpt", image: "thumbnail" },
706
- documents: { description: "summary", image: "" },
707
- playlists: { description: "description", image: "image" }
708
- };
709
- var DEFAULT_META_FIELDS = { description: "description", image: "thumbnail" };
710
- function extractMetaFields(collection, doc) {
711
- var _a, _b, _c, _d;
712
- const mapping = (_a = COLLECTION_META_FIELDS[collection]) != null ? _a : DEFAULT_META_FIELDS;
669
+ function extractSeo(doc) {
670
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
671
+ const seo = (_a = doc.seo) != null ? _a : {};
672
+ const og = (_b = seo.openGraph) != null ? _b : {};
713
673
  return {
714
- title: (_b = doc.title) != null ? _b : null,
715
- description: mapping.description ? (_c = doc[mapping.description]) != null ? _c : null : null,
716
- image: mapping.image ? (_d = doc[mapping.image]) != null ? _d : null : null
674
+ title: (_d = (_c = seo.title) != null ? _c : doc.title) != null ? _d : null,
675
+ description: (_e = seo.description) != null ? _e : null,
676
+ noIndex: (_f = seo.noIndex) != null ? _f : null,
677
+ canonical: (_g = seo.canonical) != null ? _g : null,
678
+ openGraph: {
679
+ title: (_h = og.title) != null ? _h : null,
680
+ description: (_i = og.description) != null ? _i : null,
681
+ image: (_j = og.image) != null ? _j : null
682
+ }
717
683
  };
718
684
  }
719
685
  function generateMetadata(input, options) {
720
- var _a, _b, _c, _d;
721
- const title = (_b = (_a = input.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
722
- const description = (_d = (_c = input.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
723
- const image = resolveMetaImage(input.image);
724
- return {
686
+ var _a, _b, _c, _d, _e, _f, _g;
687
+ const title = (_a = input.title) != null ? _a : void 0;
688
+ const description = (_b = input.description) != null ? _b : void 0;
689
+ const ogTitle = (_d = (_c = input.openGraph) == null ? void 0 : _c.title) != null ? _d : title;
690
+ const ogDescription = (_f = (_e = input.openGraph) == null ? void 0 : _e.description) != null ? _f : description;
691
+ const image = resolveMetaImage((_g = input.openGraph) == null ? void 0 : _g.image);
692
+ return __spreadProps(__spreadValues(__spreadValues({
725
693
  title,
726
- description,
727
- openGraph: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, title && { title }), description && { description }), (options == null ? void 0 : options.siteName) && { siteName: options.siteName }), image && { images: [image] }),
694
+ description
695
+ }, input.noIndex && { robots: { index: false, follow: false } }), input.canonical && { alternates: { canonical: input.canonical } }), {
696
+ openGraph: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, ogTitle && { title: ogTitle }), ogDescription && { description: ogDescription }), (options == null ? void 0 : options.siteName) && { siteName: options.siteName }), image && { images: [image] }),
728
697
  twitter: __spreadValues(__spreadValues(__spreadValues({
729
698
  card: image ? "summary_large_image" : "summary"
730
- }, title && { title }), description && { description }), image && { images: [image.url] })
731
- };
699
+ }, ogTitle && { title: ogTitle }), ogDescription && { description: ogDescription }), image && { images: [image.url] })
700
+ });
732
701
  }
733
702
  function resolveMetaImage(ref) {
734
703
  var _a;
@@ -838,7 +807,7 @@ var CollectionQueryBuilder = class {
838
807
  const doc = docs[0];
839
808
  if (!doc) return null;
840
809
  return generateMetadata(
841
- extractMetaFields(String(this.collection), doc),
810
+ extractSeo(doc),
842
811
  metadataOptions
843
812
  );
844
813
  });
@@ -852,7 +821,7 @@ var CollectionQueryBuilder = class {
852
821
  return __async(this, null, function* () {
853
822
  const doc = yield this.findById(id, { depth: 1 });
854
823
  return generateMetadata(
855
- extractMetaFields(String(this.collection), doc),
824
+ extractSeo(doc),
856
825
  metadataOptions
857
826
  );
858
827
  });
@@ -960,6 +929,7 @@ var HttpClient = class {
960
929
  nextPage: (_b = jsonData.nextPage) != null ? _b : null
961
930
  };
962
931
  } catch (error) {
932
+ if (error instanceof SDKError) throw error;
963
933
  throw createApiError("Failed to parse response.", response.status, {
964
934
  contentType,
965
935
  error: error instanceof Error ? error.message : error
@@ -986,6 +956,7 @@ var HttpClient = class {
986
956
  errors: jsonData.errors
987
957
  };
988
958
  } catch (error) {
959
+ if (error instanceof SDKError) throw error;
989
960
  throw createApiError("Failed to parse response.", response.status, {
990
961
  contentType,
991
962
  error: error instanceof Error ? error.message : error
@@ -1005,6 +976,7 @@ var HttpClient = class {
1005
976
  const jsonData = yield response.json();
1006
977
  return jsonData;
1007
978
  } catch (error) {
979
+ if (error instanceof SDKError) throw error;
1008
980
  throw createApiError("Failed to parse response.", response.status, {
1009
981
  contentType,
1010
982
  error: error instanceof Error ? error.message : error
@@ -1040,7 +1012,7 @@ var CollectionClient = class extends HttpClient {
1040
1012
  requestFind(endpoint, options) {
1041
1013
  return __async(this, null, function* () {
1042
1014
  const url = this.buildUrl(endpoint, options);
1043
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1015
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1044
1016
  return this.parseFindResponse(response);
1045
1017
  });
1046
1018
  }
@@ -1051,7 +1023,7 @@ var CollectionClient = class extends HttpClient {
1051
1023
  requestFindById(endpoint, options) {
1052
1024
  return __async(this, null, function* () {
1053
1025
  const url = this.buildUrl(endpoint, options);
1054
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1026
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1055
1027
  return this.parseDocumentResponse(response);
1056
1028
  });
1057
1029
  }
@@ -1061,7 +1033,7 @@ var CollectionClient = class extends HttpClient {
1061
1033
  */
1062
1034
  requestCreate(endpoint, data) {
1063
1035
  return __async(this, null, function* () {
1064
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1036
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1065
1037
  method: "POST",
1066
1038
  body: data ? JSON.stringify(data) : void 0
1067
1039
  }));
@@ -1074,7 +1046,7 @@ var CollectionClient = class extends HttpClient {
1074
1046
  */
1075
1047
  requestUpdate(endpoint, data) {
1076
1048
  return __async(this, null, function* () {
1077
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1049
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1078
1050
  method: "PATCH",
1079
1051
  body: data ? JSON.stringify(data) : void 0
1080
1052
  }));
@@ -1088,7 +1060,7 @@ var CollectionClient = class extends HttpClient {
1088
1060
  requestCount(endpoint, options) {
1089
1061
  return __async(this, null, function* () {
1090
1062
  const url = this.buildUrl(endpoint, options);
1091
- const response = yield _fetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1063
+ const response = yield httpFetch(url, __spreadProps(__spreadValues({}, this.defaultOptions), { method: "GET" }));
1092
1064
  return this.parseDocumentResponse(response);
1093
1065
  });
1094
1066
  }
@@ -1098,7 +1070,7 @@ var CollectionClient = class extends HttpClient {
1098
1070
  */
1099
1071
  requestUpdateMany(endpoint, data) {
1100
1072
  return __async(this, null, function* () {
1101
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1073
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1102
1074
  method: "PATCH",
1103
1075
  body: JSON.stringify(data)
1104
1076
  }));
@@ -1111,7 +1083,7 @@ var CollectionClient = class extends HttpClient {
1111
1083
  */
1112
1084
  requestDelete(endpoint) {
1113
1085
  return __async(this, null, function* () {
1114
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1086
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1115
1087
  method: "DELETE"
1116
1088
  }));
1117
1089
  return this.parseDocumentResponse(response);
@@ -1123,7 +1095,7 @@ var CollectionClient = class extends HttpClient {
1123
1095
  */
1124
1096
  requestDeleteMany(endpoint, data) {
1125
1097
  return __async(this, null, function* () {
1126
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1098
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1127
1099
  method: "DELETE",
1128
1100
  body: JSON.stringify(data)
1129
1101
  }));
@@ -1136,7 +1108,7 @@ var CollectionClient = class extends HttpClient {
1136
1108
  */
1137
1109
  requestCreateWithFile(endpoint, data, file, filename) {
1138
1110
  return __async(this, null, function* () {
1139
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1111
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1140
1112
  method: "POST",
1141
1113
  body: buildPayloadFormData(data, file, filename)
1142
1114
  }));
@@ -1149,7 +1121,7 @@ var CollectionClient = class extends HttpClient {
1149
1121
  */
1150
1122
  requestUpdateWithFile(endpoint, data, file, filename) {
1151
1123
  return __async(this, null, function* () {
1152
- const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1124
+ const response = yield httpFetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
1153
1125
  method: "PATCH",
1154
1126
  body: buildPayloadFormData(data, file, filename)
1155
1127
  }));
@@ -1200,15 +1172,23 @@ var COLLECTIONS = [
1200
1172
  "post-images",
1201
1173
  "playlists",
1202
1174
  "playlist-images",
1175
+ "playlist-categories",
1176
+ "playlist-tags",
1203
1177
  "musics",
1204
1178
  "galleries",
1205
1179
  "gallery-images",
1206
1180
  "gallery-categories",
1181
+ "gallery-tags",
1207
1182
  "flows",
1208
1183
  "flow-images",
1209
1184
  "flow-node-types",
1210
1185
  "flow-edge-types",
1186
+ "flow-categories",
1187
+ "flow-tags",
1211
1188
  "videos",
1189
+ "video-images",
1190
+ "video-categories",
1191
+ "video-tags",
1212
1192
  "live-streams",
1213
1193
  "live-stream-images",
1214
1194
  "forms",
@@ -1495,7 +1475,7 @@ function getQueryClient() {
1495
1475
  return browserQueryClient;
1496
1476
  }
1497
1477
 
1498
- // src/core/query/query-hooks.ts
1478
+ // src/core/query/collection-hooks.ts
1499
1479
  import {
1500
1480
  useQuery as useQueryOriginal,
1501
1481
  useSuspenseQuery as useSuspenseQueryOriginal,
@@ -1503,6 +1483,8 @@ import {
1503
1483
  useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,
1504
1484
  useMutation as useMutationOriginal
1505
1485
  } from "@tanstack/react-query";
1486
+
1487
+ // src/core/query/query-keys.ts
1506
1488
  function collectionKeys(collection) {
1507
1489
  return {
1508
1490
  all: [collection],
@@ -1518,20 +1500,13 @@ var customerKeys = {
1518
1500
  all: ["customer"],
1519
1501
  me: () => ["customer", "me"]
1520
1502
  };
1503
+
1504
+ // src/core/query/collection-hooks.ts
1521
1505
  var DEFAULT_PAGE_SIZE = 20;
1522
- var QueryHooks = class {
1523
- constructor(queryClient, collectionClient, customerAuth) {
1506
+ var CollectionHooks = class {
1507
+ constructor(queryClient, collectionClient) {
1524
1508
  this.queryClient = queryClient;
1525
1509
  this.collectionClient = collectionClient;
1526
- this.customerAuth = customerAuth;
1527
- }
1528
- ensureCustomerAuth() {
1529
- if (!this.customerAuth) {
1530
- throw createConfigError(
1531
- "Customer hooks require BrowserClient. Use createBrowserClient() instead of createServerClient()."
1532
- );
1533
- }
1534
- return this.customerAuth;
1535
1510
  }
1536
1511
  // ===== useQuery =====
1537
1512
  useQuery(params, options) {
@@ -1730,10 +1705,45 @@ var QueryHooks = class {
1730
1705
  );
1731
1706
  }
1732
1707
  }
1733
- // ===== 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 =====
1734
1744
  useCustomerMe(options) {
1735
1745
  var _a, _b;
1736
- return useQueryOriginal(__spreadProps(__spreadValues({
1746
+ return useQueryOriginal2(__spreadProps(__spreadValues({
1737
1747
  queryKey: customerKeys.me(),
1738
1748
  queryFn: () => __async(this, null, function* () {
1739
1749
  return yield this.ensureCustomerAuth().me();
@@ -1742,32 +1752,22 @@ var QueryHooks = class {
1742
1752
  enabled: ((_a = options == null ? void 0 : options.enabled) != null ? _a : true) && !!((_b = this.customerAuth) == null ? void 0 : _b.isAuthenticated())
1743
1753
  }));
1744
1754
  }
1755
+ // ===== Mutations =====
1745
1756
  useCustomerLogin(options) {
1746
- return useMutationOriginal({
1747
- mutationFn: (data) => __async(this, null, function* () {
1748
- return yield this.ensureCustomerAuth().login(data);
1749
- }),
1750
- onSuccess: (data) => {
1751
- var _a;
1752
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1753
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1754
- },
1755
- onError: options == null ? void 0 : options.onError,
1756
- onSettled: options == null ? void 0 : options.onSettled
1757
- });
1757
+ return createMutation(
1758
+ (data) => this.ensureCustomerAuth().login(data),
1759
+ options,
1760
+ this.invalidateMe
1761
+ );
1758
1762
  }
1759
1763
  useCustomerRegister(options) {
1760
- return useMutationOriginal({
1761
- mutationFn: (data) => __async(this, null, function* () {
1762
- return yield this.ensureCustomerAuth().register(data);
1763
- }),
1764
- onSuccess: options == null ? void 0 : options.onSuccess,
1765
- onError: options == null ? void 0 : options.onError,
1766
- onSettled: options == null ? void 0 : options.onSettled
1767
- });
1764
+ return createMutation(
1765
+ (data) => this.ensureCustomerAuth().register(data),
1766
+ options
1767
+ );
1768
1768
  }
1769
1769
  useCustomerLogout(options) {
1770
- return useMutationOriginal({
1770
+ return useMutationOriginal2({
1771
1771
  mutationFn: () => __async(this, null, function* () {
1772
1772
  this.ensureCustomerAuth().logout();
1773
1773
  }),
@@ -1781,76 +1781,47 @@ var QueryHooks = class {
1781
1781
  });
1782
1782
  }
1783
1783
  useCustomerForgotPassword(options) {
1784
- return useMutationOriginal({
1785
- mutationFn: (email) => __async(this, null, function* () {
1786
- yield this.ensureCustomerAuth().forgotPassword(email);
1784
+ return createMutation(
1785
+ (email) => this.ensureCustomerAuth().forgotPassword(email).then(() => {
1787
1786
  }),
1788
- onSuccess: options == null ? void 0 : options.onSuccess,
1789
- onError: options == null ? void 0 : options.onError,
1790
- onSettled: options == null ? void 0 : options.onSettled
1791
- });
1787
+ options
1788
+ );
1792
1789
  }
1793
1790
  useCustomerResetPassword(options) {
1794
- return useMutationOriginal({
1795
- mutationFn: (data) => __async(this, null, function* () {
1796
- yield this.ensureCustomerAuth().resetPassword(data.token, data.password);
1791
+ return createMutation(
1792
+ (data) => this.ensureCustomerAuth().resetPassword(data.token, data.password).then(() => {
1797
1793
  }),
1798
- onSuccess: options == null ? void 0 : options.onSuccess,
1799
- onError: options == null ? void 0 : options.onError,
1800
- onSettled: options == null ? void 0 : options.onSettled
1801
- });
1794
+ options
1795
+ );
1802
1796
  }
1803
1797
  useCustomerVerifyEmail(options) {
1804
- return useMutationOriginal({
1805
- mutationFn: (token) => __async(this, null, function* () {
1806
- yield this.ensureCustomerAuth().verifyEmail(token);
1798
+ return createMutation(
1799
+ (token) => this.ensureCustomerAuth().verifyEmail(token).then(() => {
1807
1800
  }),
1808
- onSuccess: () => {
1809
- var _a;
1810
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1811
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
1812
- },
1813
- onError: options == null ? void 0 : options.onError,
1814
- onSettled: options == null ? void 0 : options.onSettled
1815
- });
1801
+ options,
1802
+ this.invalidateMe
1803
+ );
1816
1804
  }
1817
1805
  useCustomerRefreshToken(options) {
1818
- return useMutationOriginal({
1819
- mutationFn: () => __async(this, null, function* () {
1820
- return yield this.ensureCustomerAuth().refreshToken();
1821
- }),
1822
- onSuccess: (data) => {
1823
- var _a;
1824
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1825
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1826
- },
1827
- onError: options == null ? void 0 : options.onError,
1828
- onSettled: options == null ? void 0 : options.onSettled
1829
- });
1806
+ return createMutation(
1807
+ () => this.ensureCustomerAuth().refreshToken(),
1808
+ options,
1809
+ this.invalidateMe
1810
+ );
1830
1811
  }
1831
1812
  useCustomerUpdateProfile(options) {
1832
- return useMutationOriginal({
1833
- mutationFn: (data) => __async(this, null, function* () {
1834
- return yield this.ensureCustomerAuth().updateProfile(data);
1835
- }),
1836
- onSuccess: (data) => {
1837
- var _a;
1838
- this.queryClient.invalidateQueries({ queryKey: customerKeys.me() });
1839
- (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
1840
- },
1841
- onError: options == null ? void 0 : options.onError,
1842
- onSettled: options == null ? void 0 : options.onSettled
1843
- });
1813
+ return createMutation(
1814
+ (data) => this.ensureCustomerAuth().updateProfile(data),
1815
+ options,
1816
+ this.invalidateMe
1817
+ );
1844
1818
  }
1845
1819
  useCustomerChangePassword(options) {
1846
- return useMutationOriginal({
1847
- mutationFn: (data) => __async(this, null, function* () {
1848
- yield this.ensureCustomerAuth().changePassword(data.currentPassword, data.newPassword);
1820
+ return createMutation(
1821
+ (data) => this.ensureCustomerAuth().changePassword(data.currentPassword, data.newPassword).then(() => {
1849
1822
  }),
1850
- onSuccess: options == null ? void 0 : options.onSuccess,
1851
- onError: options == null ? void 0 : options.onError,
1852
- onSettled: options == null ? void 0 : options.onSettled
1853
- });
1823
+ options
1824
+ );
1854
1825
  }
1855
1826
  // ===== Customer Cache Utilities =====
1856
1827
  invalidateCustomerQueries() {
@@ -1864,6 +1835,29 @@ var QueryHooks = class {
1864
1835
  }
1865
1836
  };
1866
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
+
1867
1861
  // src/core/client/client.ts
1868
1862
  var BrowserClient = class {
1869
1863
  constructor(options) {
@@ -2172,19 +2166,23 @@ function getVideoMp4Url(playbackId, resolution = "high") {
2172
2166
  }
2173
2167
  export {
2174
2168
  ApiError,
2169
+ BaseApi,
2175
2170
  BrowserClient,
2176
2171
  COLLECTIONS,
2177
2172
  CartApi,
2178
2173
  CollectionClient,
2174
+ CollectionHooks,
2179
2175
  CollectionQueryBuilder,
2180
2176
  ConfigError,
2181
2177
  CustomerAuth,
2178
+ CustomerHooks,
2182
2179
  GoneError,
2183
2180
  IMAGE_SIZES,
2184
2181
  NetworkError,
2185
2182
  OrderApi,
2186
2183
  ProductApi,
2187
2184
  QueryHooks,
2185
+ SDKError,
2188
2186
  ServerClient,
2189
2187
  ServiceUnavailableError,
2190
2188
  TimeoutError,
@@ -2222,7 +2220,6 @@ export {
2222
2220
  isUsageLimitError,
2223
2221
  isValidWebhookEvent,
2224
2222
  isValidationError,
2225
- objectFor,
2226
2223
  parseApiKey,
2227
2224
  resolveRelation,
2228
2225
  verifyServerToken