@infuro/cms-core 1.0.34 → 1.0.36

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 (152) hide show
  1. package/README.md +13 -0
  2. package/dist/OrderTrackPage-W3J6WIG2.js +426 -0
  3. package/dist/OrderTrackPage-Z6FCJQYY.cjs +428 -0
  4. package/dist/admin.cjs +35254 -21613
  5. package/dist/admin.d.cts +192 -9
  6. package/dist/admin.d.ts +192 -9
  7. package/dist/admin.js +34301 -20755
  8. package/dist/api.cjs +137 -17531
  9. package/dist/api.d.cts +633 -3
  10. package/dist/api.d.ts +633 -3
  11. package/dist/api.js +15 -17528
  12. package/dist/auth.cjs +192 -1034
  13. package/dist/auth.d.cts +197 -54
  14. package/dist/auth.d.ts +197 -54
  15. package/dist/auth.js +4 -966
  16. package/dist/chunk-2AEVFOQP.cjs +30436 -0
  17. package/dist/chunk-3DZRIZOD.cjs +52 -0
  18. package/dist/chunk-5ELSW2UP.js +150 -0
  19. package/dist/chunk-7NMT3GBR.cjs +29 -0
  20. package/dist/chunk-COBORIJH.cjs +2373 -0
  21. package/dist/chunk-CRFV5WJK.js +16 -0
  22. package/dist/chunk-D5FBNKQM.cjs +104 -0
  23. package/dist/chunk-FG6I64HP.js +604 -0
  24. package/dist/chunk-GO7PPYNU.js +76 -0
  25. package/dist/chunk-HCIRL37O.js +21 -0
  26. package/dist/chunk-HF3L2GIT.cjs +194 -0
  27. package/dist/chunk-HT5DI3XW.cjs +82 -0
  28. package/dist/chunk-JC6DLWTE.js +21 -0
  29. package/dist/chunk-JS2W7XZ4.js +30312 -0
  30. package/dist/chunk-JXF23MPG.js +25 -0
  31. package/dist/chunk-KFFB6EMZ.js +123 -0
  32. package/dist/chunk-KPKFNLQQ.cjs +648 -0
  33. package/dist/chunk-LI2IXVAY.js +171 -0
  34. package/dist/chunk-MQBT33IV.js +48 -0
  35. package/dist/chunk-OOTLNH63.cjs +18 -0
  36. package/dist/chunk-PNOKNSG2.cjs +222 -0
  37. package/dist/chunk-SHUYVCID.js +4 -0
  38. package/dist/chunk-SPQFNIYJ.cjs +132 -0
  39. package/dist/chunk-SYBOCAWB.js +97 -0
  40. package/dist/chunk-TDV6EJHV.js +192 -0
  41. package/dist/chunk-UCKN4BBY.cjs +24 -0
  42. package/dist/chunk-UF3BYUXY.js +616 -0
  43. package/dist/chunk-UPLVMVRX.cjs +23 -0
  44. package/dist/chunk-USNT2KNT.cjs +6 -0
  45. package/dist/chunk-VMY2S32H.js +2342 -0
  46. package/dist/chunk-WEMDMVHQ.js +216 -0
  47. package/dist/chunk-WO2DW4AU.cjs +182 -0
  48. package/dist/chunk-X47PBV4I.js +79 -0
  49. package/dist/chunk-X6H5VBQ2.cjs +620 -0
  50. package/dist/chunk-XQ3QUHWR.cjs +83 -0
  51. package/dist/chunk-XW5ATPRW.cjs +155 -0
  52. package/dist/cli.cjs +107 -86
  53. package/dist/cli.js +66 -29
  54. package/dist/email-queue-CGZBVVAS.js +2 -0
  55. package/dist/email-queue-TPZWLTIV.cjs +23 -0
  56. package/dist/emit-order-notification-trigger-D2N3KFHL.cjs +16 -0
  57. package/dist/emit-order-notification-trigger-IVLWKKJL.js +3 -0
  58. package/dist/erp-config-enabled-CUMQ6N2V.cjs +11 -0
  59. package/dist/erp-config-enabled-T37X7T34.js +2 -0
  60. package/dist/erp-order-invoice-3YISSOWW.js +3 -0
  61. package/dist/erp-order-invoice-ZR5F2KTA.cjs +12 -0
  62. package/dist/event-order-defaults-EMWBIGL3.cjs +39 -0
  63. package/dist/event-order-defaults-SDRNAZHC.js +2 -0
  64. package/dist/hooks.cjs +259 -132
  65. package/dist/hooks.d.cts +42 -1
  66. package/dist/hooks.d.ts +42 -1
  67. package/dist/hooks.js +234 -91
  68. package/dist/index.cjs +3679 -22356
  69. package/dist/index.d.cts +2173 -643
  70. package/dist/index.d.ts +2173 -643
  71. package/dist/index.js +2587 -22119
  72. package/dist/interpolate-WAKPN56R.cjs +11 -0
  73. package/dist/interpolate-WDUWDF3I.js +2 -0
  74. package/dist/migrations/1779400000000-ConvertStatusToEnum.ts +142 -0
  75. package/dist/migrations/1779400000000-SeedDefaultCurrencies.ts +33 -0
  76. package/dist/migrations/1779500000000-VendorRolesAndPermissions.ts +102 -0
  77. package/dist/migrations/1779600000000-VendorRegistrationProfile.ts +52 -0
  78. package/dist/migrations/1779700000000-CollectionIsCatalog.ts +22 -0
  79. package/dist/migrations/1779710000000-CollectionPlatformCatalog.ts +60 -0
  80. package/dist/migrations/1779720000000-ProductCategoryPlatformCatalog.ts +157 -0
  81. package/dist/migrations/1779800000000-EventsAndEventProducts.ts +173 -0
  82. package/dist/migrations/1779810000000-BackfillVendorRoleEventsPermissions.ts +38 -0
  83. package/dist/migrations/1779820000000-FixProductsCategoryForeignKey.ts +70 -0
  84. package/dist/migrations/1779830000000-ProductTitleColumn.ts +32 -0
  85. package/dist/migrations/1779840000000-EventAboutAndVisibilityFields.ts +34 -0
  86. package/dist/migrations/1779850000000-EventCityCountrySplit.ts +43 -0
  87. package/dist/migrations/1779860000000-CreateCombos.ts +140 -0
  88. package/dist/migrations/1780100000000-OrderAttendeesEventId.ts +55 -0
  89. package/dist/migrations/1780110000000-EventContactFormId.ts +49 -0
  90. package/dist/migrations/1780130000000-ProductVariants.ts +54 -0
  91. package/dist/migrations/1780140000000-EventManagementEnhancements.ts +44 -0
  92. package/dist/migrations/1780160000000-EventRegistrationGstProductContactForm.ts +79 -0
  93. package/dist/migrations/1780170000000-ComboCurrencyPrices.ts +20 -0
  94. package/dist/migrations/1781110000000-VendorOwnerCombosPermission.ts +38 -0
  95. package/dist/migrations/1781120000000-RefundPoliciesAndRequests.ts +225 -0
  96. package/dist/migrations/1781130000000-CreateAttendees.ts +44 -0
  97. package/dist/migrations/1781140000000-EventOrderNotifications.ts +29 -0
  98. package/dist/migrations/1781150000000-EventNamedLists.ts +28 -0
  99. package/dist/migrations/1781160000000-RefundPolicyEventTiers.ts +27 -0
  100. package/dist/migrations/1781170000000-EventRefundPolicy.ts +42 -0
  101. package/dist/migrations/1781180000000-RemoveCartItemsUniqueConstraint.ts +15 -0
  102. package/dist/migrations/1781190000000-RenameProductTaxesToProductConfig.ts +84 -0
  103. package/dist/migrations/1781200000000-VendorOwnerProductConfigPermissions.ts +51 -0
  104. package/dist/migrations/1781210000000-VendorRoleProductConfigPermissions.ts +46 -0
  105. package/dist/migrations/1781220000000-AddWhatsappTriggerBindings.ts +23 -0
  106. package/dist/migrations/1781230000000-AddOrderNotificationTriggers.ts +46 -0
  107. package/dist/migrations/1781240000000-DropEventOrderNotificationColumns.ts +29 -0
  108. package/dist/migrations/1781250000000-RemoveOrderRefundedTrigger.ts +36 -0
  109. package/dist/migrations/helpers/vendor-role-seed.ts +243 -0
  110. package/dist/paid-order-erp-3USEG6WL.js +3 -0
  111. package/dist/paid-order-erp-FSQ3GSXE.cjs +12 -0
  112. package/dist/pg-boss-service-4XF2TQ2E.js +2 -0
  113. package/dist/pg-boss-service-L6MTF4EQ.cjs +15 -0
  114. package/dist/razorpay-KLO2KNCB.js +49 -0
  115. package/dist/razorpay-U23LGY72.cjs +56 -0
  116. package/dist/rbac-debug-db-HWP65A4O.cjs +35 -0
  117. package/dist/rbac-debug-db-QJH3AD34.js +33 -0
  118. package/dist/sms-defaults-2NL24H57.js +2 -0
  119. package/dist/sms-defaults-KCOPKQBA.cjs +19 -0
  120. package/dist/stripe-4FD27QVJ.js +51 -0
  121. package/dist/stripe-VU6OEG2D.cjs +57 -0
  122. package/dist/theme.cjs +31 -59
  123. package/dist/theme.d.cts +78 -3
  124. package/dist/theme.d.ts +78 -3
  125. package/dist/theme.js +23 -20
  126. package/dist/vendor-invite-status-77O7ZQ3U.cjs +19 -0
  127. package/dist/vendor-invite-status-PWJ3DE76.js +2 -0
  128. package/dist/whatsapp-trigger-dispatcher-ONHXI7UY.cjs +19 -0
  129. package/dist/whatsapp-trigger-dispatcher-PWFI4FKP.js +6 -0
  130. package/package.json +147 -142
  131. package/dist/admin.cjs.map +0 -1
  132. package/dist/admin.js.map +0 -1
  133. package/dist/api.cjs.map +0 -1
  134. package/dist/api.js.map +0 -1
  135. package/dist/auth.cjs.map +0 -1
  136. package/dist/auth.js.map +0 -1
  137. package/dist/cli.cjs.map +0 -1
  138. package/dist/cli.js.map +0 -1
  139. package/dist/config-DJ5CmQvS.d.cts +0 -8
  140. package/dist/config-DJ5CmQvS.d.ts +0 -8
  141. package/dist/hooks.cjs.map +0 -1
  142. package/dist/hooks.js.map +0 -1
  143. package/dist/index-Bf5GO8fu.d.cts +0 -583
  144. package/dist/index-DOiJuMQA.d.ts +0 -583
  145. package/dist/index.cjs.map +0 -1
  146. package/dist/index.js.map +0 -1
  147. package/dist/theme.cjs.map +0 -1
  148. package/dist/theme.js.map +0 -1
  149. package/dist/types-DCVaXlPV.d.cts +0 -78
  150. package/dist/types-DCVaXlPV.d.ts +0 -78
  151. package/dist/vendor-scope-DTYhJk_I.d.cts +0 -129
  152. package/dist/vendor-scope-DTYhJk_I.d.ts +0 -129
package/dist/hooks.cjs CHANGED
@@ -1,64 +1,162 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
2
+
3
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
+ var React2 = require('react');
29
5
 
30
- // src/hooks/index.ts
31
- var hooks_exports = {};
32
- __export(hooks_exports, {
33
- CaptchaProvider: () => CaptchaProvider,
34
- PluginProvider: () => PluginProvider,
35
- useAnalytics: () => useAnalytics,
36
- useCaptchaPayload: () => useCaptchaPayload,
37
- useIsMobile: () => useIsMobile,
38
- usePlugin: () => usePlugin
39
- });
40
- module.exports = __toCommonJS(hooks_exports);
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
41
9
 
42
- // src/hooks/use-mobile.ts
43
- var import_react = require("react");
44
10
  var MOBILE_BREAKPOINT = 768;
45
11
  function useIsMobile() {
46
- const [isMobile, setIsMobile] = (0, import_react.useState)(void 0);
47
- (0, import_react.useEffect)(() => {
12
+ const [isMobile, setIsMobile] = React2.useState(void 0);
13
+ React2.useEffect(() => {
48
14
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
49
- const onChange = () => setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
15
+ const onChange = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(() => setIsMobile(window.innerWidth < MOBILE_BREAKPOINT), "onChange");
50
16
  mql.addEventListener("change", onChange);
51
17
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
52
18
  return () => mql.removeEventListener("change", onChange);
53
19
  }, []);
54
20
  return !!isMobile;
55
21
  }
56
-
57
- // src/hooks/use-analytics.ts
58
- var import_react2 = require("react");
22
+ chunkUSNT2KNT_cjs.__name(useIsMobile, "useIsMobile");
23
+ function useCatalogCategories(enabled = true) {
24
+ const [categories, setCategories] = React2.useState([]);
25
+ const [loading, setLoading] = React2.useState(enabled);
26
+ const [error, setError] = React2.useState(null);
27
+ React2.useEffect(() => {
28
+ if (!enabled) {
29
+ setLoading(false);
30
+ return;
31
+ }
32
+ let cancelled = false;
33
+ setLoading(true);
34
+ (async () => {
35
+ try {
36
+ const res = await fetch("/api/product_categories?limit=500&sortField=sortOrder&sortOrder=asc&active=true&isCatalog=true");
37
+ const data = await res.json().catch(() => ({}));
38
+ if (!res.ok) {
39
+ const msg = typeof data.error === "string" ? data.error : "Failed to load categories";
40
+ throw new Error(msg);
41
+ }
42
+ if (cancelled) return;
43
+ const rows = Array.isArray(data.data) ? data.data : [];
44
+ setCategories(rows.filter((c) => c.active !== false));
45
+ } catch (e) {
46
+ if (!cancelled) {
47
+ setError(e instanceof Error ? e.message : "Could not load categories");
48
+ }
49
+ } finally {
50
+ if (!cancelled) setLoading(false);
51
+ }
52
+ })();
53
+ return () => {
54
+ cancelled = true;
55
+ };
56
+ }, [
57
+ enabled
58
+ ]);
59
+ return {
60
+ categories,
61
+ loading,
62
+ error
63
+ };
64
+ }
65
+ chunkUSNT2KNT_cjs.__name(useCatalogCategories, "useCatalogCategories");
66
+ function vendorCategoryWorkspaceUrl(categoryId, collectionId) {
67
+ const params = new URLSearchParams({
68
+ categoryId: String(categoryId)
69
+ });
70
+ if (collectionId != null && String(collectionId).trim() !== "") {
71
+ params.set("collectionId", String(collectionId));
72
+ }
73
+ return `/admin/products?${params.toString()}`;
74
+ }
75
+ chunkUSNT2KNT_cjs.__name(vendorCategoryWorkspaceUrl, "vendorCategoryWorkspaceUrl");
76
+ function vendorCollectionCreateUrl(categoryId, from, options) {
77
+ const params = new URLSearchParams({
78
+ categoryId: String(categoryId)
79
+ });
80
+ if (options?.isCatalog) params.set("isCatalog", "true");
81
+ const base = `/admin/collections/create?${params.toString()}`;
82
+ return from ? `${base}&from=${encodeURIComponent(from)}` : base;
83
+ }
84
+ chunkUSNT2KNT_cjs.__name(vendorCollectionCreateUrl, "vendorCollectionCreateUrl");
85
+ function vendorProductCreateUrl(categoryId, options) {
86
+ const params = new URLSearchParams({
87
+ categoryId: String(categoryId)
88
+ });
89
+ if (options?.collectionId != null && String(options.collectionId).trim() !== "") {
90
+ params.set("collectionId", String(options.collectionId));
91
+ }
92
+ if (options?.eventId != null && String(options.eventId).trim() !== "") {
93
+ params.set("eventId", String(options.eventId));
94
+ }
95
+ const base = `/admin/products/create?${params.toString()}`;
96
+ return options?.from ? `${base}&from=${encodeURIComponent(options.from)}` : base;
97
+ }
98
+ chunkUSNT2KNT_cjs.__name(vendorProductCreateUrl, "vendorProductCreateUrl");
99
+ function vendorEventProductCreateUrl(eventId, options) {
100
+ const params = new URLSearchParams({
101
+ eventId: String(eventId)
102
+ });
103
+ if (options?.categoryId != null && String(options.categoryId).trim() !== "") {
104
+ params.set("categoryId", String(options.categoryId));
105
+ }
106
+ const base = `/admin/products/create?${params.toString()}`;
107
+ return options?.from ? `${base}&from=${encodeURIComponent(options.from)}` : base;
108
+ }
109
+ chunkUSNT2KNT_cjs.__name(vendorEventProductCreateUrl, "vendorEventProductCreateUrl");
110
+ function useCatalogCollections(enabled = true) {
111
+ const [collections, setCollections] = React2.useState([]);
112
+ const [loading, setLoading] = React2.useState(enabled);
113
+ const [error, setError] = React2.useState(null);
114
+ React2.useEffect(() => {
115
+ if (!enabled) {
116
+ setLoading(false);
117
+ return;
118
+ }
119
+ let cancelled = false;
120
+ setLoading(true);
121
+ (async () => {
122
+ try {
123
+ const res = await fetch("/api/collections?limit=500&sortField=sortOrder&sortOrder=asc&active=true&isCatalog=true");
124
+ const data = await res.json().catch(() => ({}));
125
+ if (!res.ok) {
126
+ const msg = typeof data.error === "string" ? data.error : "Failed to load collections";
127
+ throw new Error(msg);
128
+ }
129
+ if (cancelled) return;
130
+ const rows = Array.isArray(data.data) ? data.data : [];
131
+ setCollections(rows.filter((c) => c.active !== false));
132
+ } catch (e) {
133
+ if (!cancelled) {
134
+ setError(e instanceof Error ? e.message : "Could not load collections");
135
+ }
136
+ } finally {
137
+ if (!cancelled) setLoading(false);
138
+ }
139
+ })();
140
+ return () => {
141
+ cancelled = true;
142
+ };
143
+ }, [
144
+ enabled
145
+ ]);
146
+ return {
147
+ collections,
148
+ loading,
149
+ error
150
+ };
151
+ }
152
+ chunkUSNT2KNT_cjs.__name(useCatalogCollections, "useCatalogCollections");
153
+ function vendorCollectionProductsUrl(collectionId) {
154
+ return `/admin/products?collectionId=${collectionId}`;
155
+ }
156
+ chunkUSNT2KNT_cjs.__name(vendorCollectionProductsUrl, "vendorCollectionProductsUrl");
59
157
  function useAnalytics(pathname) {
60
158
  const isAdminRoute = pathname != null && pathname.startsWith("/admin");
61
- (0, import_react2.useEffect)(() => {
159
+ React2.useEffect(() => {
62
160
  if (isAdminRoute && typeof window !== "undefined") {
63
161
  if (typeof window.gtag === "function") {
64
162
  window.gtag = () => {
@@ -68,35 +166,35 @@ function useAnalytics(pathname) {
68
166
  window.dataLayer = [];
69
167
  }
70
168
  }
71
- }, [isAdminRoute]);
72
- return { isAdminRoute, shouldTrack: !isAdminRoute };
169
+ }, [
170
+ isAdminRoute
171
+ ]);
172
+ return {
173
+ isAdminRoute,
174
+ shouldTrack: !isAdminRoute
175
+ };
73
176
  }
74
-
75
- // src/hooks/use-plugin.ts
76
- var import_react3 = __toESM(require("react"), 1);
77
- var PluginContext = (0, import_react3.createContext)(null);
78
- function PluginProvider({
79
- getPlugin,
80
- children
81
- }) {
82
- return import_react3.default.createElement(PluginContext.Provider, { value: { getPlugin } }, children);
177
+ chunkUSNT2KNT_cjs.__name(useAnalytics, "useAnalytics");
178
+ var PluginContext = React2.createContext(null);
179
+ function PluginProvider({ getPlugin, children }) {
180
+ return React2__default.default.createElement(PluginContext.Provider, {
181
+ value: {
182
+ getPlugin
183
+ }
184
+ }, children);
83
185
  }
186
+ chunkUSNT2KNT_cjs.__name(PluginProvider, "PluginProvider");
84
187
  function usePlugin(name) {
85
- const ctx = (0, import_react3.useContext)(PluginContext);
188
+ const ctx = React2.useContext(PluginContext);
86
189
  if (!ctx) return void 0;
87
190
  return ctx.getPlugin(name);
88
191
  }
89
-
90
- // src/components/CaptchaProvider.tsx
91
- var import_react4 = require("react");
92
- var import_jsx_runtime = require("react/jsx-runtime");
93
- var CaptchaReactContext = (0, import_react4.createContext)(null);
192
+ chunkUSNT2KNT_cjs.__name(usePlugin, "usePlugin");
193
+ var CaptchaReactContext = /* @__PURE__ */ React2.createContext(null);
94
194
  function loadScript(src) {
95
195
  return new Promise((resolve, reject) => {
96
196
  const base = src.split("?")[0] ?? src;
97
- const existing = Array.from(document.querySelectorAll("script[src]")).some(
98
- (el) => el.src.startsWith(base)
99
- );
197
+ const existing = Array.from(document.querySelectorAll("script[src]")).some((el) => el.src.startsWith(base));
100
198
  if (existing) {
101
199
  resolve();
102
200
  return;
@@ -109,14 +207,15 @@ function loadScript(src) {
109
207
  document.head.appendChild(s);
110
208
  });
111
209
  }
210
+ chunkUSNT2KNT_cjs.__name(loadScript, "loadScript");
112
211
  function CaptchaProvider({ children }) {
113
- const [config, setConfig] = (0, import_react4.useState)(null);
114
- const [selectedProvider, setSelectedProvider] = (0, import_react4.useState)(null);
115
- const [ready, setReady] = (0, import_react4.useState)(false);
116
- const turnstileWidgetIdRef = (0, import_react4.useRef)(null);
117
- const turnstileContainerRef = (0, import_react4.useRef)(null);
118
- const turnstileTokenRef = (0, import_react4.useRef)(null);
119
- (0, import_react4.useEffect)(() => {
212
+ const [config, setConfig] = React2.useState(null);
213
+ const [selectedProvider, setSelectedProvider] = React2.useState(null);
214
+ const [ready, setReady] = React2.useState(false);
215
+ const turnstileWidgetIdRef = React2.useRef(null);
216
+ const turnstileContainerRef = React2.useRef(null);
217
+ const turnstileTokenRef = React2.useRef(null);
218
+ React2.useEffect(() => {
120
219
  let cancelled = false;
121
220
  fetch("/api/public/captcha-config").then((r) => r.ok ? r.json() : null).then((c) => {
122
221
  if (cancelled || !c) return;
@@ -130,7 +229,7 @@ function CaptchaProvider({ children }) {
130
229
  cancelled = true;
131
230
  };
132
231
  }, []);
133
- (0, import_react4.useEffect)(() => {
232
+ React2.useEffect(() => {
134
233
  if (!config?.enabled || !selectedProvider) return;
135
234
  const siteKeyFor = config.availableProviders.find((p) => p.id === selectedProvider)?.siteKey;
136
235
  if (!siteKeyFor) return;
@@ -138,9 +237,7 @@ function CaptchaProvider({ children }) {
138
237
  (async () => {
139
238
  try {
140
239
  if (selectedProvider === "recaptcha_v3") {
141
- await loadScript(
142
- `https://www.google.com/recaptcha/api.js?render=${encodeURIComponent(siteKeyFor)}`
143
- );
240
+ await loadScript(`https://www.google.com/recaptcha/api.js?render=${encodeURIComponent(siteKeyFor)}`);
144
241
  } else {
145
242
  await loadScript("https://challenges.cloudflare.com/turnstile/v0/api.js");
146
243
  if (cancelled || !turnstileContainerRef.current || !window.turnstile) return;
@@ -154,21 +251,21 @@ function CaptchaProvider({ children }) {
154
251
  const wid = window.turnstile.render(turnstileContainerRef.current, {
155
252
  sitekey: siteKeyFor,
156
253
  execution: "execute",
157
- callback: (token) => {
254
+ callback: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((token) => {
158
255
  const p = turnstileTokenRef.current;
159
256
  turnstileTokenRef.current = null;
160
257
  p?.resolve(token);
161
- },
162
- "error-callback": () => {
258
+ }, "callback"),
259
+ "error-callback": /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(() => {
163
260
  const p = turnstileTokenRef.current;
164
261
  turnstileTokenRef.current = null;
165
262
  p?.reject(new Error("Turnstile error"));
166
- },
167
- "expired-callback": () => {
263
+ }, "error-callback"),
264
+ "expired-callback": /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(() => {
168
265
  const p = turnstileTokenRef.current;
169
266
  turnstileTokenRef.current = null;
170
267
  p?.reject(new Error("Turnstile expired"));
171
- }
268
+ }, "expired-callback")
172
269
  });
173
270
  turnstileWidgetIdRef.current = wid;
174
271
  }
@@ -178,8 +275,11 @@ function CaptchaProvider({ children }) {
178
275
  return () => {
179
276
  cancelled = true;
180
277
  };
181
- }, [config, selectedProvider]);
182
- const getCaptchaPayload = (0, import_react4.useCallback)(async () => {
278
+ }, [
279
+ config,
280
+ selectedProvider
281
+ ]);
282
+ const getCaptchaPayload = React2.useCallback(async () => {
183
283
  if (!config?.enabled || !selectedProvider) return {};
184
284
  const siteKeyFor = config.availableProviders.find((p) => p.id === selectedProvider)?.siteKey;
185
285
  if (!siteKeyFor) return {};
@@ -187,15 +287,23 @@ function CaptchaProvider({ children }) {
187
287
  if (!window.grecaptcha) return {};
188
288
  const token2 = await new Promise((resolve, reject) => {
189
289
  window.grecaptcha.ready(() => {
190
- window.grecaptcha.execute(siteKeyFor, { action: "submit" }).then(resolve).catch(reject);
290
+ window.grecaptcha.execute(siteKeyFor, {
291
+ action: "submit"
292
+ }).then(resolve).catch(reject);
191
293
  });
192
294
  });
193
- return { captchaToken: token2, captchaProvider: "recaptcha_v3" };
295
+ return {
296
+ captchaToken: token2,
297
+ captchaProvider: "recaptcha_v3"
298
+ };
194
299
  }
195
300
  const wid = turnstileWidgetIdRef.current;
196
301
  if (!wid || !window.turnstile) return {};
197
302
  const token = await new Promise((resolve, reject) => {
198
- turnstileTokenRef.current = { resolve, reject };
303
+ turnstileTokenRef.current = {
304
+ resolve,
305
+ reject
306
+ };
199
307
  try {
200
308
  window.turnstile.reset(wid);
201
309
  window.turnstile.execute(wid);
@@ -204,50 +312,69 @@ function CaptchaProvider({ children }) {
204
312
  reject(e instanceof Error ? e : new Error("Turnstile execute failed"));
205
313
  }
206
314
  });
207
- return { captchaToken: token, captchaProvider: "turnstile" };
208
- }, [config, selectedProvider]);
209
- const ctx = (0, import_react4.useMemo)(
210
- () => ({
211
- config,
212
- ready,
213
- selectedProvider,
214
- setSelectedProvider,
215
- getCaptchaPayload
216
- }),
217
- [config, ready, selectedProvider, getCaptchaPayload]
218
- );
219
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CaptchaReactContext.Provider, { value: ctx, children: [
220
- config?.enabled && config.multipleProviders ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-2 text-sm text-muted-foreground max-w-md", children: [
221
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "mr-2", htmlFor: "captcha-provider-select", children: "Verification" }),
222
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
- "select",
224
- {
225
- id: "captcha-provider-select",
226
- className: "border rounded px-2 py-1 bg-background",
227
- value: selectedProvider ?? "",
228
- onChange: (e) => setSelectedProvider(e.target.value),
229
- children: config.availableProviders.map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: p.id, children: p.id === "turnstile" ? "Cloudflare Turnstile" : "Google reCAPTCHA v3" }, p.id))
230
- }
231
- )
232
- ] }) : null,
233
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: turnstileContainerRef, className: "hidden", "aria-hidden": true }),
234
- children
235
- ] });
315
+ return {
316
+ captchaToken: token,
317
+ captchaProvider: "turnstile"
318
+ };
319
+ }, [
320
+ config,
321
+ selectedProvider
322
+ ]);
323
+ const ctx = React2.useMemo(() => ({
324
+ config,
325
+ ready,
326
+ selectedProvider,
327
+ setSelectedProvider,
328
+ getCaptchaPayload
329
+ }), [
330
+ config,
331
+ ready,
332
+ selectedProvider,
333
+ getCaptchaPayload
334
+ ]);
335
+ return /* @__PURE__ */ React2__default.default.createElement(CaptchaReactContext.Provider, {
336
+ value: ctx
337
+ }, config?.enabled && config.multipleProviders ? /* @__PURE__ */ React2__default.default.createElement("div", {
338
+ className: "mb-2 text-sm text-muted-foreground max-w-md"
339
+ }, /* @__PURE__ */ React2__default.default.createElement("label", {
340
+ className: "mr-2",
341
+ htmlFor: "captcha-provider-select"
342
+ }, "Verification"), /* @__PURE__ */ React2__default.default.createElement("select", {
343
+ id: "captcha-provider-select",
344
+ className: "border rounded px-2 py-1 bg-background",
345
+ value: selectedProvider ?? "",
346
+ onChange: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((e) => setSelectedProvider(e.target.value), "onChange")
347
+ }, config.availableProviders.map((p) => /* @__PURE__ */ React2__default.default.createElement("option", {
348
+ key: p.id,
349
+ value: p.id
350
+ }, p.id === "turnstile" ? "Cloudflare Turnstile" : "Google reCAPTCHA v3")))) : null, /* @__PURE__ */ React2__default.default.createElement("div", {
351
+ ref: turnstileContainerRef,
352
+ className: "hidden",
353
+ "aria-hidden": true
354
+ }), children);
236
355
  }
356
+ chunkUSNT2KNT_cjs.__name(CaptchaProvider, "CaptchaProvider");
237
357
  function useCaptchaPayload() {
238
- const ctx = (0, import_react4.useContext)(CaptchaReactContext);
239
- return (0, import_react4.useCallback)(async () => {
358
+ const ctx = React2.useContext(CaptchaReactContext);
359
+ return React2.useCallback(async () => {
240
360
  if (!ctx?.config?.enabled || !ctx.ready) return {};
241
361
  return ctx.getCaptchaPayload();
242
- }, [ctx]);
362
+ }, [
363
+ ctx
364
+ ]);
243
365
  }
244
- // Annotate the CommonJS export names for ESM import in node:
245
- 0 && (module.exports = {
246
- CaptchaProvider,
247
- PluginProvider,
248
- useAnalytics,
249
- useCaptchaPayload,
250
- useIsMobile,
251
- usePlugin
252
- });
253
- //# sourceMappingURL=hooks.cjs.map
366
+ chunkUSNT2KNT_cjs.__name(useCaptchaPayload, "useCaptchaPayload");
367
+
368
+ exports.CaptchaProvider = CaptchaProvider;
369
+ exports.PluginProvider = PluginProvider;
370
+ exports.useAnalytics = useAnalytics;
371
+ exports.useCaptchaPayload = useCaptchaPayload;
372
+ exports.useCatalogCategories = useCatalogCategories;
373
+ exports.useCatalogCollections = useCatalogCollections;
374
+ exports.useIsMobile = useIsMobile;
375
+ exports.usePlugin = usePlugin;
376
+ exports.vendorCategoryWorkspaceUrl = vendorCategoryWorkspaceUrl;
377
+ exports.vendorCollectionCreateUrl = vendorCollectionCreateUrl;
378
+ exports.vendorCollectionProductsUrl = vendorCollectionProductsUrl;
379
+ exports.vendorEventProductCreateUrl = vendorEventProductCreateUrl;
380
+ exports.vendorProductCreateUrl = vendorProductCreateUrl;
package/dist/hooks.d.cts CHANGED
@@ -3,6 +3,47 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  declare function useIsMobile(): boolean;
5
5
 
6
+ type CatalogCategory = {
7
+ id: number;
8
+ name: string;
9
+ slug?: string;
10
+ active?: boolean;
11
+ sortOrder?: number;
12
+ };
13
+ declare function useCatalogCategories(enabled?: boolean): {
14
+ categories: CatalogCategory[];
15
+ loading: boolean;
16
+ error: string | null;
17
+ };
18
+ declare function vendorCategoryWorkspaceUrl(categoryId: number | string, collectionId?: number | string): string;
19
+ declare function vendorCollectionCreateUrl(categoryId: number | string, from?: string, options?: {
20
+ isCatalog?: boolean;
21
+ }): string;
22
+ declare function vendorProductCreateUrl(categoryId: number | string, options?: {
23
+ from?: string;
24
+ collectionId?: number | string;
25
+ eventId?: number | string;
26
+ }): string;
27
+ /** Product create URL from an event detail/edit page (optional category tab). */
28
+ declare function vendorEventProductCreateUrl(eventId: number | string, options?: {
29
+ from?: string;
30
+ categoryId?: number | string;
31
+ }): string;
32
+
33
+ type CatalogCollection = {
34
+ id: number;
35
+ name: string;
36
+ slug?: string;
37
+ active?: boolean;
38
+ sortOrder?: number;
39
+ };
40
+ declare function useCatalogCollections(enabled?: boolean): {
41
+ collections: CatalogCollection[];
42
+ loading: boolean;
43
+ error: string | null;
44
+ };
45
+ declare function vendorCollectionProductsUrl(collectionId: number | string): string;
46
+
6
47
  /**
7
48
  * Call from app with pathname from usePathname() (next/navigation).
8
49
  * Disables tracking on admin routes when pathname starts with /admin.
@@ -42,4 +83,4 @@ declare function CaptchaProvider({ children }: {
42
83
  /** Returns a function that resolves to captcha fields for JSON bodies, or {} if disabled / not ready. */
43
84
  declare function useCaptchaPayload(): () => Promise<Record<string, string>>;
44
85
 
45
- export { CaptchaProvider, PluginProvider, useAnalytics, useCaptchaPayload, useIsMobile, usePlugin };
86
+ export { CaptchaProvider, type CatalogCategory, type CatalogCollection, PluginProvider, useAnalytics, useCaptchaPayload, useCatalogCategories, useCatalogCollections, useIsMobile, usePlugin, vendorCategoryWorkspaceUrl, vendorCollectionCreateUrl, vendorCollectionProductsUrl, vendorEventProductCreateUrl, vendorProductCreateUrl };
package/dist/hooks.d.ts CHANGED
@@ -3,6 +3,47 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  declare function useIsMobile(): boolean;
5
5
 
6
+ type CatalogCategory = {
7
+ id: number;
8
+ name: string;
9
+ slug?: string;
10
+ active?: boolean;
11
+ sortOrder?: number;
12
+ };
13
+ declare function useCatalogCategories(enabled?: boolean): {
14
+ categories: CatalogCategory[];
15
+ loading: boolean;
16
+ error: string | null;
17
+ };
18
+ declare function vendorCategoryWorkspaceUrl(categoryId: number | string, collectionId?: number | string): string;
19
+ declare function vendorCollectionCreateUrl(categoryId: number | string, from?: string, options?: {
20
+ isCatalog?: boolean;
21
+ }): string;
22
+ declare function vendorProductCreateUrl(categoryId: number | string, options?: {
23
+ from?: string;
24
+ collectionId?: number | string;
25
+ eventId?: number | string;
26
+ }): string;
27
+ /** Product create URL from an event detail/edit page (optional category tab). */
28
+ declare function vendorEventProductCreateUrl(eventId: number | string, options?: {
29
+ from?: string;
30
+ categoryId?: number | string;
31
+ }): string;
32
+
33
+ type CatalogCollection = {
34
+ id: number;
35
+ name: string;
36
+ slug?: string;
37
+ active?: boolean;
38
+ sortOrder?: number;
39
+ };
40
+ declare function useCatalogCollections(enabled?: boolean): {
41
+ collections: CatalogCollection[];
42
+ loading: boolean;
43
+ error: string | null;
44
+ };
45
+ declare function vendorCollectionProductsUrl(collectionId: number | string): string;
46
+
6
47
  /**
7
48
  * Call from app with pathname from usePathname() (next/navigation).
8
49
  * Disables tracking on admin routes when pathname starts with /admin.
@@ -42,4 +83,4 @@ declare function CaptchaProvider({ children }: {
42
83
  /** Returns a function that resolves to captcha fields for JSON bodies, or {} if disabled / not ready. */
43
84
  declare function useCaptchaPayload(): () => Promise<Record<string, string>>;
44
85
 
45
- export { CaptchaProvider, PluginProvider, useAnalytics, useCaptchaPayload, useIsMobile, usePlugin };
86
+ export { CaptchaProvider, type CatalogCategory, type CatalogCollection, PluginProvider, useAnalytics, useCaptchaPayload, useCatalogCategories, useCatalogCollections, useIsMobile, usePlugin, vendorCategoryWorkspaceUrl, vendorCollectionCreateUrl, vendorCollectionProductsUrl, vendorEventProductCreateUrl, vendorProductCreateUrl };