@ezcoder.dev/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/index.d.ts +18 -0
- package/dist/analytics/index.js +76 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/animation/index.d.ts +172 -0
- package/dist/animation/index.js +81 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/auth/index.d.ts +80 -0
- package/dist/auth/index.js +463 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/chunk-5XIZHBKE.js +372 -0
- package/dist/chunk-5XIZHBKE.js.map +1 -0
- package/dist/chunk-G7XDUN3Z.js +141 -0
- package/dist/chunk-G7XDUN3Z.js.map +1 -0
- package/dist/chunk-YNDCD53D.js +212 -0
- package/dist/chunk-YNDCD53D.js.map +1 -0
- package/dist/cms/index.d.ts +44 -0
- package/dist/cms/index.js +106 -0
- package/dist/cms/index.js.map +1 -0
- package/dist/errors/index.d.ts +20 -0
- package/dist/errors/index.js +61 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications/index.d.ts +30 -0
- package/dist/notifications/index.js +191 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/payments/index.d.ts +89 -0
- package/dist/payments/index.js +408 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/roles/index.d.ts +37 -0
- package/dist/roles/index.js +120 -0
- package/dist/roles/index.js.map +1 -0
- package/dist/seo/index.d.ts +39 -0
- package/dist/seo/index.js +89 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/server/index.d.ts +72 -0
- package/dist/server/index.js +191 -0
- package/dist/server/index.js.map +1 -0
- package/dist/storage/index.d.ts +52 -0
- package/dist/storage/index.js +212 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-DtY5lp3P.d.ts +90 -0
- package/package.json +105 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthContext
|
|
3
|
+
} from "../chunk-YNDCD53D.js";
|
|
4
|
+
import "../chunk-5XIZHBKE.js";
|
|
5
|
+
import {
|
|
6
|
+
features,
|
|
7
|
+
supabase
|
|
8
|
+
} from "../chunk-G7XDUN3Z.js";
|
|
9
|
+
|
|
10
|
+
// src/notifications/useNotifications.ts
|
|
11
|
+
import { useState, useEffect, useCallback, useContext } from "react";
|
|
12
|
+
var DEMO_NOTIFICATIONS = [
|
|
13
|
+
{
|
|
14
|
+
id: "demo-1",
|
|
15
|
+
type: "info",
|
|
16
|
+
title: "Welcome!",
|
|
17
|
+
message: "Connect a database to enable real-time notifications.",
|
|
18
|
+
read: false,
|
|
19
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
function useNotifications() {
|
|
23
|
+
const auth = useContext(AuthContext);
|
|
24
|
+
const [notifications, setNotifications] = useState([]);
|
|
25
|
+
const [loading, setLoading] = useState(true);
|
|
26
|
+
const userId = auth?.user?.id;
|
|
27
|
+
const fetchNotifications = useCallback(async () => {
|
|
28
|
+
if (!features.auth || !userId) {
|
|
29
|
+
setNotifications(DEMO_NOTIFICATIONS);
|
|
30
|
+
setLoading(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const { data, error } = await supabase.from("notifications").select("*").eq("user_id", userId).order("created_at", { ascending: false }).limit(50);
|
|
35
|
+
if (error) {
|
|
36
|
+
setNotifications(DEMO_NOTIFICATIONS);
|
|
37
|
+
} else {
|
|
38
|
+
setNotifications(data || []);
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
setNotifications(DEMO_NOTIFICATIONS);
|
|
42
|
+
} finally {
|
|
43
|
+
setLoading(false);
|
|
44
|
+
}
|
|
45
|
+
}, [userId]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
fetchNotifications();
|
|
48
|
+
}, [fetchNotifications]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!features.auth || !userId) return;
|
|
51
|
+
const channel = supabase.channel(`notifications_${userId}`).on(
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
"postgres_changes",
|
|
54
|
+
{
|
|
55
|
+
event: "INSERT",
|
|
56
|
+
schema: "public",
|
|
57
|
+
table: "notifications",
|
|
58
|
+
filter: `user_id=eq.${userId}`
|
|
59
|
+
},
|
|
60
|
+
(payload) => {
|
|
61
|
+
setNotifications((prev) => [payload.new, ...prev]);
|
|
62
|
+
}
|
|
63
|
+
).subscribe();
|
|
64
|
+
return () => {
|
|
65
|
+
supabase.removeChannel(channel);
|
|
66
|
+
};
|
|
67
|
+
}, [userId]);
|
|
68
|
+
const markAsRead = useCallback(async (notificationId) => {
|
|
69
|
+
if (!features.auth) return;
|
|
70
|
+
await supabase.from("notifications").update({ read: true, read_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", notificationId);
|
|
71
|
+
setNotifications(
|
|
72
|
+
(prev) => prev.map((n) => n.id === notificationId ? { ...n, read: true } : n)
|
|
73
|
+
);
|
|
74
|
+
}, []);
|
|
75
|
+
const markAllAsRead = useCallback(async () => {
|
|
76
|
+
if (!features.auth || !userId) return;
|
|
77
|
+
await supabase.from("notifications").update({ read: true, read_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("user_id", userId).eq("read", false);
|
|
78
|
+
setNotifications((prev) => prev.map((n) => ({ ...n, read: true })));
|
|
79
|
+
}, [userId]);
|
|
80
|
+
const deleteNotification = useCallback(async (notificationId) => {
|
|
81
|
+
if (!features.auth) return;
|
|
82
|
+
await supabase.from("notifications").delete().eq("id", notificationId);
|
|
83
|
+
setNotifications((prev) => prev.filter((n) => n.id !== notificationId));
|
|
84
|
+
}, []);
|
|
85
|
+
const unreadCount = notifications.filter((n) => !n.read).length;
|
|
86
|
+
return {
|
|
87
|
+
notifications,
|
|
88
|
+
unreadCount,
|
|
89
|
+
loading,
|
|
90
|
+
isConfigured: features.auth,
|
|
91
|
+
markAsRead,
|
|
92
|
+
markAllAsRead,
|
|
93
|
+
deleteNotification,
|
|
94
|
+
refetch: fetchNotifications
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/notifications/NotificationCenter.tsx
|
|
99
|
+
import { useState as useState2 } from "react";
|
|
100
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
101
|
+
function NotificationCenter({ className = "" }) {
|
|
102
|
+
const { notifications, unreadCount, markAsRead, markAllAsRead, deleteNotification } = useNotifications();
|
|
103
|
+
const [open, setOpen] = useState2(false);
|
|
104
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { position: "relative", display: "inline-block" }, children: [
|
|
105
|
+
/* @__PURE__ */ jsxs(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
onClick: () => setOpen(!open),
|
|
109
|
+
style: {
|
|
110
|
+
background: "none",
|
|
111
|
+
border: "none",
|
|
112
|
+
cursor: "pointer",
|
|
113
|
+
position: "relative",
|
|
114
|
+
padding: "8px",
|
|
115
|
+
fontSize: "20px"
|
|
116
|
+
},
|
|
117
|
+
children: [
|
|
118
|
+
"\u{1F514}",
|
|
119
|
+
unreadCount > 0 && /* @__PURE__ */ jsx("span", { style: {
|
|
120
|
+
position: "absolute",
|
|
121
|
+
top: "2px",
|
|
122
|
+
right: "2px",
|
|
123
|
+
backgroundColor: "#dc2626",
|
|
124
|
+
color: "white",
|
|
125
|
+
fontSize: "10px",
|
|
126
|
+
borderRadius: "50%",
|
|
127
|
+
width: "18px",
|
|
128
|
+
height: "18px",
|
|
129
|
+
display: "flex",
|
|
130
|
+
alignItems: "center",
|
|
131
|
+
justifyContent: "center"
|
|
132
|
+
}, children: unreadCount > 9 ? "9+" : unreadCount })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
open && /* @__PURE__ */ jsxs("div", { style: {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
right: 0,
|
|
139
|
+
top: "100%",
|
|
140
|
+
width: "320px",
|
|
141
|
+
backgroundColor: "white",
|
|
142
|
+
border: "1px solid #e5e7eb",
|
|
143
|
+
borderRadius: "8px",
|
|
144
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
|
|
145
|
+
zIndex: 50,
|
|
146
|
+
maxHeight: "400px",
|
|
147
|
+
overflow: "auto"
|
|
148
|
+
}, children: [
|
|
149
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: "12px 16px", borderBottom: "1px solid #e5e7eb", display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
150
|
+
/* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: "Notifications" }),
|
|
151
|
+
unreadCount > 0 && /* @__PURE__ */ jsx("button", { onClick: () => markAllAsRead(), style: { background: "none", border: "none", color: "#3b82f6", cursor: "pointer", fontSize: "12px" }, children: "Mark all read" })
|
|
152
|
+
] }),
|
|
153
|
+
notifications.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: "24px", textAlign: "center", color: "#9ca3af" }, children: "No notifications" }) : notifications.map((n) => /* @__PURE__ */ jsx(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
style: {
|
|
157
|
+
padding: "12px 16px",
|
|
158
|
+
borderBottom: "1px solid #f3f4f6",
|
|
159
|
+
backgroundColor: n.read ? "transparent" : "#eff6ff",
|
|
160
|
+
cursor: "pointer"
|
|
161
|
+
},
|
|
162
|
+
onClick: () => !n.read && markAsRead(n.id),
|
|
163
|
+
children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start" }, children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
165
|
+
/* @__PURE__ */ jsx("p", { style: { fontWeight: 500, fontSize: "14px", marginBottom: "2px" }, children: n.title }),
|
|
166
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#6b7280", fontSize: "13px" }, children: n.message }),
|
|
167
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#9ca3af", fontSize: "11px", marginTop: "4px" }, children: new Date(n.created_at).toLocaleDateString() })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
"button",
|
|
171
|
+
{
|
|
172
|
+
onClick: (e) => {
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
deleteNotification(n.id);
|
|
175
|
+
},
|
|
176
|
+
style: { background: "none", border: "none", color: "#9ca3af", cursor: "pointer", fontSize: "16px" },
|
|
177
|
+
children: "\xD7"
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] })
|
|
181
|
+
},
|
|
182
|
+
n.id
|
|
183
|
+
))
|
|
184
|
+
] })
|
|
185
|
+
] });
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
NotificationCenter,
|
|
189
|
+
useNotifications
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/useNotifications.ts","../../src/notifications/NotificationCenter.tsx"],"sourcesContent":["import { useState, useEffect, useCallback, useContext } from 'react';\nimport { supabase } from '../core/supabase';\nimport { features } from '../core/config';\nimport { AuthContext } from '../auth/AuthProvider';\n\ninterface Notification {\n id: string;\n type: string;\n title: string;\n message: string;\n data?: Record<string, unknown>;\n read: boolean;\n read_at?: string;\n created_at: string;\n}\n\nconst DEMO_NOTIFICATIONS: Notification[] = [\n {\n id: 'demo-1',\n type: 'info',\n title: 'Welcome!',\n message: 'Connect a database to enable real-time notifications.',\n read: false,\n created_at: new Date().toISOString(),\n },\n];\n\ninterface UseNotificationsReturn {\n notifications: Notification[];\n unreadCount: number;\n loading: boolean;\n isConfigured: boolean;\n markAsRead: (notificationId: string) => Promise<void>;\n markAllAsRead: () => Promise<void>;\n deleteNotification: (notificationId: string) => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nexport function useNotifications(): UseNotificationsReturn {\n const auth = useContext(AuthContext);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [loading, setLoading] = useState(true);\n\n const userId = auth?.user?.id;\n\n const fetchNotifications = useCallback(async () => {\n if (!features.auth || !userId) {\n setNotifications(DEMO_NOTIFICATIONS);\n setLoading(false);\n return;\n }\n\n try {\n const { data, error } = await supabase\n .from('notifications')\n .select('*')\n .eq('user_id', userId)\n .order('created_at', { ascending: false })\n .limit(50);\n\n if (error) {\n setNotifications(DEMO_NOTIFICATIONS);\n } else {\n setNotifications((data as Notification[]) || []);\n }\n } catch {\n setNotifications(DEMO_NOTIFICATIONS);\n } finally {\n setLoading(false);\n }\n }, [userId]);\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n if (!features.auth || !userId) return;\n\n const channel = supabase\n .channel(`notifications_${userId}`)\n .on(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n 'postgres_changes' as any,\n {\n event: 'INSERT',\n schema: 'public',\n table: 'notifications',\n filter: `user_id=eq.${userId}`,\n },\n (payload: { new: Notification }) => {\n setNotifications((prev) => [payload.new, ...prev]);\n }\n )\n .subscribe();\n\n return () => {\n supabase.removeChannel(channel);\n };\n }, [userId]);\n\n const markAsRead = useCallback(async (notificationId: string) => {\n if (!features.auth) return;\n\n await supabase\n .from('notifications')\n .update({ read: true, read_at: new Date().toISOString() })\n .eq('id', notificationId);\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, read: true } : n))\n );\n }, []);\n\n const markAllAsRead = useCallback(async () => {\n if (!features.auth || !userId) return;\n\n await supabase\n .from('notifications')\n .update({ read: true, read_at: new Date().toISOString() })\n .eq('user_id', userId)\n .eq('read', false);\n\n setNotifications((prev) => prev.map((n) => ({ ...n, read: true })));\n }, [userId]);\n\n const deleteNotification = useCallback(async (notificationId: string) => {\n if (!features.auth) return;\n\n await supabase.from('notifications').delete().eq('id', notificationId);\n setNotifications((prev) => prev.filter((n) => n.id !== notificationId));\n }, []);\n\n const unreadCount = notifications.filter((n) => !n.read).length;\n\n return {\n notifications,\n unreadCount,\n loading,\n isConfigured: features.auth,\n markAsRead,\n markAllAsRead,\n deleteNotification,\n refetch: fetchNotifications,\n };\n}\n","import { useState } from 'react';\nimport { useNotifications } from './useNotifications';\n\ninterface NotificationCenterProps {\n className?: string;\n}\n\nexport function NotificationCenter({ className = '' }: NotificationCenterProps) {\n const { notifications, unreadCount, markAsRead, markAllAsRead, deleteNotification } = useNotifications();\n const [open, setOpen] = useState(false);\n\n return (\n <div className={className} style={{ position: 'relative', display: 'inline-block' }}>\n <button\n onClick={() => setOpen(!open)}\n style={{\n background: 'none', border: 'none', cursor: 'pointer',\n position: 'relative', padding: '8px', fontSize: '20px',\n }}\n >\n 🔔\n {unreadCount > 0 && (\n <span style={{\n position: 'absolute', top: '2px', right: '2px',\n backgroundColor: '#dc2626', color: 'white', fontSize: '10px',\n borderRadius: '50%', width: '18px', height: '18px',\n display: 'flex', alignItems: 'center', justifyContent: 'center',\n }}>\n {unreadCount > 9 ? '9+' : unreadCount}\n </span>\n )}\n </button>\n\n {open && (\n <div style={{\n position: 'absolute', right: 0, top: '100%', width: '320px',\n backgroundColor: 'white', border: '1px solid #e5e7eb',\n borderRadius: '8px', boxShadow: '0 4px 12px rgba(0,0,0,0.1)',\n zIndex: 50, maxHeight: '400px', overflow: 'auto',\n }}>\n <div style={{ padding: '12px 16px', borderBottom: '1px solid #e5e7eb', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <span style={{ fontWeight: 600 }}>Notifications</span>\n {unreadCount > 0 && (\n <button onClick={() => markAllAsRead()} style={{ background: 'none', border: 'none', color: '#3b82f6', cursor: 'pointer', fontSize: '12px' }}>\n Mark all read\n </button>\n )}\n </div>\n\n {notifications.length === 0 ? (\n <div style={{ padding: '24px', textAlign: 'center', color: '#9ca3af' }}>\n No notifications\n </div>\n ) : (\n notifications.map((n) => (\n <div\n key={n.id}\n style={{\n padding: '12px 16px', borderBottom: '1px solid #f3f4f6',\n backgroundColor: n.read ? 'transparent' : '#eff6ff',\n cursor: 'pointer',\n }}\n onClick={() => !n.read && markAsRead(n.id)}\n >\n <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>\n <div>\n <p style={{ fontWeight: 500, fontSize: '14px', marginBottom: '2px' }}>{n.title}</p>\n <p style={{ color: '#6b7280', fontSize: '13px' }}>{n.message}</p>\n <p style={{ color: '#9ca3af', fontSize: '11px', marginTop: '4px' }}>\n {new Date(n.created_at).toLocaleDateString()}\n </p>\n </div>\n <button\n onClick={(e) => { e.stopPropagation(); deleteNotification(n.id); }}\n style={{ background: 'none', border: 'none', color: '#9ca3af', cursor: 'pointer', fontSize: '16px' }}\n >\n ×\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,UAAU,WAAW,aAAa,kBAAkB;AAgB7D,IAAM,qBAAqC;AAAA,EACzC;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,EACrC;AACF;AAaO,SAAS,mBAA2C;AACzD,QAAM,OAAO,WAAW,WAAW;AACnC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAyB,CAAC,CAAC;AACrE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAE3C,QAAM,SAAS,MAAM,MAAM;AAE3B,QAAM,qBAAqB,YAAY,YAAY;AACjD,QAAI,CAAC,SAAS,QAAQ,CAAC,QAAQ;AAC7B,uBAAiB,kBAAkB;AACnC,iBAAW,KAAK;AAChB;AAAA,IACF;AAEA,QAAI;AACF,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,SAC3B,KAAK,eAAe,EACpB,OAAO,GAAG,EACV,GAAG,WAAW,MAAM,EACpB,MAAM,cAAc,EAAE,WAAW,MAAM,CAAC,EACxC,MAAM,EAA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C,+BAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,gBAAgB,iBAAiB,YAAY,aAAa,GACvF;AAAA,iCAAC,SACC;AAAA,kCAAC,OAAE,OAAO,EAAE,YAAY,KAAK,UAAU,QAAQ,cAAc,MAAM,GAAI,YAAE,OAAM;AAAA,cAC/E,oBAAC,OAAE,OAAO,EAAE,OAAO,WAAW,UAAU,OAAO,GAAI,YAAE,SAAQ;AAAA,cAC7D,oBAAC,OAAE,OAAO,EAAE,OAAO,WAAW,UAAU,QAAQ,WAAW,MAAM,GAC9D,cAAI,KAAK,EAAE,UAAU,EAAE,mBAAmB,GAC7C;AAAA,eACF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,SAAS,CAAC,MAAM;AAAE,oBAAE,gBAAgB;AAAG,qCAAmB,EAAE,EAAE;AAAA,gBAAG;AAAA,gBACjE,OAAO,EAAE,YAAY,QAAQ,QAAQ,QAAQ,OAAO,WAAW,QAAQ,WAAW,UAAU,OAAO;AAAA,gBACpG;AAAA;AAAA,YAED;AAAA,aACF;AAAA;AAAA,QAtBK,EAAE;AAAA,MAuBT,CACD;AAAA,OAEL;AAAA,KAEJ;AAEJ;","names":["useState","useState"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { e as SubscriptionTier, d as SubscriptionStatus } from '../types-DtY5lp3P.js';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
interface SubscriptionState {
|
|
5
|
+
customerId: string | null;
|
|
6
|
+
tier: SubscriptionTier;
|
|
7
|
+
status: SubscriptionStatus | null;
|
|
8
|
+
currentPeriodEnd: string | null;
|
|
9
|
+
}
|
|
10
|
+
interface UseSubscriptionReturn {
|
|
11
|
+
subscription: SubscriptionState | null;
|
|
12
|
+
tier: SubscriptionTier;
|
|
13
|
+
status: SubscriptionStatus | null;
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
isPro: boolean;
|
|
16
|
+
isBusiness: boolean;
|
|
17
|
+
isEnterprise: boolean;
|
|
18
|
+
canAccess: (requiredTier: SubscriptionTier) => boolean;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
isConfigured: boolean;
|
|
21
|
+
user: unknown;
|
|
22
|
+
profile: unknown;
|
|
23
|
+
isAuthenticated: boolean;
|
|
24
|
+
refetch: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare function useSubscription(): UseSubscriptionReturn;
|
|
27
|
+
|
|
28
|
+
interface CustomerAccessReturn {
|
|
29
|
+
loading: boolean;
|
|
30
|
+
hasAccess: boolean;
|
|
31
|
+
customer: Record<string, unknown> | null;
|
|
32
|
+
subscription: Record<string, unknown> | null;
|
|
33
|
+
error: string | null;
|
|
34
|
+
refresh: () => Promise<void>;
|
|
35
|
+
logout: () => void;
|
|
36
|
+
}
|
|
37
|
+
declare function useCustomerAccess(): CustomerAccessReturn;
|
|
38
|
+
|
|
39
|
+
interface BuyButtonProps {
|
|
40
|
+
priceId: string;
|
|
41
|
+
productName?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
customerEmail?: string;
|
|
46
|
+
quantity?: number;
|
|
47
|
+
successUrl?: string;
|
|
48
|
+
cancelUrl?: string;
|
|
49
|
+
}
|
|
50
|
+
declare function BuyButton({ priceId, productName, className, children, disabled, customerEmail, quantity, successUrl, cancelUrl, }: BuyButtonProps): react_jsx_runtime.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface PricingPlan {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
monthlyPriceId?: string;
|
|
56
|
+
yearlyPriceId?: string;
|
|
57
|
+
monthlyPrice: number;
|
|
58
|
+
yearlyPrice?: number;
|
|
59
|
+
features: string[];
|
|
60
|
+
highlighted?: boolean;
|
|
61
|
+
cta?: string;
|
|
62
|
+
}
|
|
63
|
+
interface PricingTableProps {
|
|
64
|
+
plans?: PricingPlan[];
|
|
65
|
+
className?: string;
|
|
66
|
+
customerEmail?: string;
|
|
67
|
+
}
|
|
68
|
+
declare function PricingTable({ plans, className, customerEmail }: PricingTableProps): react_jsx_runtime.JSX.Element;
|
|
69
|
+
|
|
70
|
+
interface SubscriptionManagerProps {
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
declare function SubscriptionManager({ className }: SubscriptionManagerProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
|
|
75
|
+
interface ManageSubscriptionButtonProps {
|
|
76
|
+
children?: React.ReactNode;
|
|
77
|
+
className?: string;
|
|
78
|
+
customerId?: string;
|
|
79
|
+
}
|
|
80
|
+
declare function ManageSubscriptionButton({ children, className, customerId }: ManageSubscriptionButtonProps): react_jsx_runtime.JSX.Element;
|
|
81
|
+
|
|
82
|
+
interface ProtectedContentProps {
|
|
83
|
+
children: React.ReactNode;
|
|
84
|
+
fallback?: React.ReactNode;
|
|
85
|
+
loadingComponent?: React.ReactNode;
|
|
86
|
+
}
|
|
87
|
+
declare function ProtectedContent({ children, fallback, loadingComponent }: ProtectedContentProps): react_jsx_runtime.JSX.Element;
|
|
88
|
+
|
|
89
|
+
export { BuyButton, ManageSubscriptionButton, PricingTable, ProtectedContent, SubscriptionManager, useCustomerAccess, useSubscription };
|