@pol-studios/db 1.0.10 → 1.0.12
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/DataLayerContext-CL6alnkb.d.ts +755 -0
- package/dist/UserMetadataContext-B8gVWGMl.d.ts +35 -0
- package/dist/UserMetadataContext-DntmpK41.d.ts +33 -0
- package/dist/auth/context.d.ts +3 -2
- package/dist/auth/context.js +5 -4
- package/dist/auth/guards.js +2 -2
- package/dist/auth/hooks.d.ts +3 -3
- package/dist/auth/hooks.js +6 -5
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.js +8 -6
- package/dist/{canvas-UVNDA54X.node → canvas-C4TBBDUL.node} +0 -0
- package/dist/{canvas-75Y7XMF3.js → canvas-ZQNCL7JL.js} +2 -2
- package/dist/chunk-5EFDS7SR.js +205 -0
- package/dist/chunk-5EFDS7SR.js.map +1 -0
- package/dist/{chunk-BRTW7CO5.js → chunk-7SCJNYTE.js} +1 -9
- package/dist/chunk-7SCJNYTE.js.map +1 -0
- package/dist/chunk-DJ6VLEAL.js +247 -0
- package/dist/chunk-DJ6VLEAL.js.map +1 -0
- package/dist/{chunk-Y3INY2CS.js → chunk-GC3TBUWE.js} +1 -1
- package/dist/chunk-GC3TBUWE.js.map +1 -0
- package/dist/{chunk-7HG6G25H.js → chunk-H3LNH2NT.js} +169 -268
- package/dist/chunk-H3LNH2NT.js.map +1 -0
- package/dist/{chunk-USJYMRUO.js → chunk-HAWJTZCK.js} +2 -2
- package/dist/chunk-HAWJTZCK.js.map +1 -0
- package/dist/chunk-JAATANS3.js +429 -0
- package/dist/chunk-JAATANS3.js.map +1 -0
- package/dist/chunk-LNJ3WF7V.js +470 -0
- package/dist/chunk-LNJ3WF7V.js.map +1 -0
- package/dist/chunk-N26IEHZT.js +79 -0
- package/dist/chunk-N26IEHZT.js.map +1 -0
- package/dist/chunk-NSIAAYW3.js +1 -0
- package/dist/chunk-NSIAAYW3.js.map +1 -0
- package/dist/chunk-NZON56CB.js +3864 -0
- package/dist/chunk-NZON56CB.js.map +1 -0
- package/dist/{chunk-O3K7R32P.js → chunk-OQ7U6EQ3.js} +118 -123
- package/dist/chunk-OQ7U6EQ3.js.map +1 -0
- package/dist/chunk-SM73S2DY.js +11 -0
- package/dist/chunk-SM73S2DY.js.map +1 -0
- package/dist/{chunk-JUVE3DWY.js → chunk-TKWR5AAY.js} +47 -65
- package/dist/chunk-TKWR5AAY.js.map +1 -0
- package/dist/{chunk-2IFGILT3.js → chunk-U5UNPBKB.js} +76 -107
- package/dist/chunk-U5UNPBKB.js.map +1 -0
- package/dist/chunk-WGDJ4IXR.js +921 -0
- package/dist/chunk-WGDJ4IXR.js.map +1 -0
- package/dist/chunk-WVF7RUW5.js +186 -0
- package/dist/chunk-WVF7RUW5.js.map +1 -0
- package/dist/{chunk-ZTSBF536.js → chunk-X3HZLNBV.js} +637 -435
- package/dist/chunk-X3HZLNBV.js.map +1 -0
- package/dist/{chunk-EL45Z26M.js → chunk-XU3SBFAG.js} +1219 -208
- package/dist/chunk-XU3SBFAG.js.map +1 -0
- package/dist/chunk-ZVBHWU7O.js +1412 -0
- package/dist/chunk-ZVBHWU7O.js.map +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +42 -23
- package/dist/client/index.js.map +1 -1
- package/dist/core/index.d.ts +19 -0
- package/dist/{index-BFu5_dS8.d.ts → database.types-ChFCG-4M.d.ts} +1 -177
- package/dist/gen/index.js +4 -2
- package/dist/hooks/index.d.ts +10 -3
- package/dist/hooks/index.js +8 -10
- package/dist/index-CQLyNG6A.d.ts +433 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +92 -48
- package/dist/index.native.d.ts +373 -33
- package/dist/index.native.js +79 -47
- package/dist/index.web.d.ts +10 -7
- package/dist/index.web.js +83 -78
- package/dist/index.web.js.map +1 -1
- package/dist/mutation/index.d.ts +2 -2
- package/dist/mutation/index.js +307 -122
- package/dist/mutation/index.js.map +1 -1
- package/dist/parser/index.js +2 -2
- package/dist/{pdf-3TIGQRLA.js → pdf-PHXP7RHD.js} +2 -2
- package/dist/powersync-bridge/index.d.ts +284 -0
- package/dist/powersync-bridge/index.js +22 -0
- package/dist/powersync-bridge/index.js.map +1 -0
- package/dist/query/index.js +5 -5
- package/dist/realtime/index.js +252 -128
- package/dist/realtime/index.js.map +1 -1
- package/dist/{UserMetadataContext-BYYqA6LI.d.ts → setupAuthContext-Kv-THH-h.d.ts} +1 -29
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.js +10 -5
- package/dist/{useBatchUpsert-CSQVX7w8.d.ts → useBatchUpsert-9OYjibLh.d.ts} +1 -1
- package/dist/{useDbCount-RGCuHmHp.d.ts → useDbCount-BG356T9i.d.ts} +3 -719
- package/dist/{useReceiptAI-Bn0czE7C.d.ts → useReceiptAI-6HkRpRml.d.ts} +1 -1
- package/dist/{useResolveFeedback-CpZPP8Pw.d.ts → useResolveFeedback-BWmatBlE.d.ts} +26 -45
- package/dist/{useSupabase-pPhUZHcl.d.ts → useSupabase-DvWVuHHE.d.ts} +2 -1
- package/dist/with-auth/index.d.ts +704 -0
- package/dist/with-auth/index.js +1221 -0
- package/dist/with-auth/index.js.map +1 -0
- package/package.json +25 -10
- package/dist/chunk-2IFGILT3.js.map +0 -1
- package/dist/chunk-3M2U6TXH.js +0 -928
- package/dist/chunk-3M2U6TXH.js.map +0 -1
- package/dist/chunk-5ZYAEGCJ.js +0 -416
- package/dist/chunk-5ZYAEGCJ.js.map +0 -1
- package/dist/chunk-7HG6G25H.js.map +0 -1
- package/dist/chunk-7XT7K4QT.js +0 -2687
- package/dist/chunk-7XT7K4QT.js.map +0 -1
- package/dist/chunk-AWFMICFV.js +0 -158
- package/dist/chunk-AWFMICFV.js.map +0 -1
- package/dist/chunk-BRTW7CO5.js.map +0 -1
- package/dist/chunk-EL45Z26M.js.map +0 -1
- package/dist/chunk-ERGF2FCE.js +0 -903
- package/dist/chunk-ERGF2FCE.js.map +0 -1
- package/dist/chunk-GK7B66LY.js +0 -135
- package/dist/chunk-GK7B66LY.js.map +0 -1
- package/dist/chunk-GQI6WJGI.js +0 -172
- package/dist/chunk-GQI6WJGI.js.map +0 -1
- package/dist/chunk-JUVE3DWY.js.map +0 -1
- package/dist/chunk-O3K7R32P.js.map +0 -1
- package/dist/chunk-SEY5UO2T.js +0 -89
- package/dist/chunk-SEY5UO2T.js.map +0 -1
- package/dist/chunk-USJYMRUO.js.map +0 -1
- package/dist/chunk-XX3IWSPM.js +0 -189
- package/dist/chunk-XX3IWSPM.js.map +0 -1
- package/dist/chunk-Y3INY2CS.js.map +0 -1
- package/dist/chunk-ZTSBF536.js.map +0 -1
- /package/dist/{canvas-75Y7XMF3.js.map → canvas-ZQNCL7JL.js.map} +0 -0
- /package/dist/{pdf-3TIGQRLA.js.map → pdf-PHXP7RHD.js.map} +0 -0
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UserMetadataContextProvider,
|
|
3
|
+
useLiveChangesIndicator,
|
|
4
|
+
useSetUserMetadata,
|
|
5
|
+
useUserMetadataState,
|
|
6
|
+
useUserMetadataValue,
|
|
7
|
+
userMetadataContext
|
|
8
|
+
} from "../chunk-LNJ3WF7V.js";
|
|
9
|
+
import "../chunk-SM73S2DY.js";
|
|
10
|
+
import "../chunk-NSIAAYW3.js";
|
|
11
|
+
import {
|
|
12
|
+
useAuth,
|
|
13
|
+
useSetupAuth
|
|
14
|
+
} from "../chunk-DJ6VLEAL.js";
|
|
15
|
+
import {
|
|
16
|
+
useDbQuery
|
|
17
|
+
} from "../chunk-WGDJ4IXR.js";
|
|
18
|
+
import {
|
|
19
|
+
useDbUpsert
|
|
20
|
+
} from "../chunk-ZVBHWU7O.js";
|
|
21
|
+
import "../chunk-HAWJTZCK.js";
|
|
22
|
+
import {
|
|
23
|
+
getSupabaseUrl
|
|
24
|
+
} from "../chunk-GC3TBUWE.js";
|
|
25
|
+
import "../chunk-J4ZVCXZ4.js";
|
|
26
|
+
import {
|
|
27
|
+
isNullOrWhitespace,
|
|
28
|
+
isUsable,
|
|
29
|
+
newUuid
|
|
30
|
+
} from "../chunk-OQ7U6EQ3.js";
|
|
31
|
+
import "../chunk-H6365JPC.js";
|
|
32
|
+
import "../chunk-3PJTNH2L.js";
|
|
33
|
+
import {
|
|
34
|
+
useSupabase
|
|
35
|
+
} from "../chunk-5EFDS7SR.js";
|
|
36
|
+
import "../chunk-P4UZ7IXC.js";
|
|
37
|
+
|
|
38
|
+
// src/hooks/useConsent.ts
|
|
39
|
+
import { useCallback, useMemo } from "react";
|
|
40
|
+
function useConsent() {
|
|
41
|
+
const supabase = useSupabase();
|
|
42
|
+
const {
|
|
43
|
+
user
|
|
44
|
+
} = useSetupAuth();
|
|
45
|
+
const consentsQuery = useDbQuery(supabase.schema("core").from("ConsentRecord").select("*").eq("userId", user?.id ?? "").order("createdAt", {
|
|
46
|
+
ascending: false
|
|
47
|
+
}), {
|
|
48
|
+
enabled: isUsable(user),
|
|
49
|
+
crossOrganization: true
|
|
50
|
+
});
|
|
51
|
+
const consents = useMemo(() => {
|
|
52
|
+
if (!consentsQuery.data) return [];
|
|
53
|
+
return consentsQuery.data;
|
|
54
|
+
}, [consentsQuery.data]);
|
|
55
|
+
const consentSummary = useMemo(() => {
|
|
56
|
+
const latestByType = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const consent of consents) {
|
|
58
|
+
if (!latestByType.has(consent.consentType)) {
|
|
59
|
+
latestByType.set(consent.consentType, consent);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return Array.from(latestByType.values()).map((record) => ({
|
|
63
|
+
consentType: record.consentType,
|
|
64
|
+
consentGiven: record.consentGiven,
|
|
65
|
+
consentVersion: record.consentVersion,
|
|
66
|
+
consentedAt: record.createdAt
|
|
67
|
+
}));
|
|
68
|
+
}, [consents]);
|
|
69
|
+
const recordConsent = useCallback(async (type, version, given, options) => {
|
|
70
|
+
if (!user?.id) {
|
|
71
|
+
console.error("Cannot record consent: user not authenticated");
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const userAgent = typeof window !== "undefined" ? window.navigator.userAgent : null;
|
|
76
|
+
const {
|
|
77
|
+
data,
|
|
78
|
+
error
|
|
79
|
+
} = await supabase.schema("core").from("ConsentRecord").insert({
|
|
80
|
+
userId: user.id,
|
|
81
|
+
consentType: type,
|
|
82
|
+
consentVersion: version,
|
|
83
|
+
consentGiven: given,
|
|
84
|
+
consentText: options?.consentText ?? null,
|
|
85
|
+
ipAddress: options?.ipAddress ?? null,
|
|
86
|
+
userAgent
|
|
87
|
+
}).select().single();
|
|
88
|
+
if (error) {
|
|
89
|
+
console.error("Error recording consent:", error);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
consentsQuery.refetch();
|
|
93
|
+
return data;
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.error("Error recording consent:", err);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}, [supabase, user?.id, consentsQuery]);
|
|
99
|
+
const withdrawConsent = useCallback(async (type_0, version_0) => {
|
|
100
|
+
return recordConsent(type_0, version_0, false);
|
|
101
|
+
}, [recordConsent]);
|
|
102
|
+
const hasActiveConsent = useCallback((type_1) => {
|
|
103
|
+
const summary = consentSummary.find((s) => s.consentType === type_1);
|
|
104
|
+
return summary?.consentGiven ?? false;
|
|
105
|
+
}, [consentSummary]);
|
|
106
|
+
const getLatestConsent = useCallback((type_2) => {
|
|
107
|
+
return consents.find((c) => c.consentType === type_2);
|
|
108
|
+
}, [consents]);
|
|
109
|
+
return {
|
|
110
|
+
recordConsent,
|
|
111
|
+
consents,
|
|
112
|
+
consentSummary,
|
|
113
|
+
withdrawConsent,
|
|
114
|
+
hasActiveConsent,
|
|
115
|
+
getLatestConsent,
|
|
116
|
+
isLoading: consentsQuery.isLoading,
|
|
117
|
+
error: consentsQuery.error,
|
|
118
|
+
refetch: consentsQuery.refetch
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
async function recordConsentForUser(supabase, userId, type, version, given, options) {
|
|
122
|
+
try {
|
|
123
|
+
const userAgent = typeof window !== "undefined" ? window.navigator.userAgent : null;
|
|
124
|
+
const {
|
|
125
|
+
data,
|
|
126
|
+
error
|
|
127
|
+
} = await supabase.schema("core").from("ConsentRecord").insert({
|
|
128
|
+
userId,
|
|
129
|
+
consentType: type,
|
|
130
|
+
consentVersion: version,
|
|
131
|
+
consentGiven: given,
|
|
132
|
+
consentText: options?.consentText ?? null,
|
|
133
|
+
ipAddress: options?.ipAddress ?? null,
|
|
134
|
+
userAgent
|
|
135
|
+
}).select().single();
|
|
136
|
+
if (error) {
|
|
137
|
+
console.error("Error recording consent:", error);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return data;
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.error("Error recording consent:", err);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
var useConsent_default = useConsent;
|
|
147
|
+
|
|
148
|
+
// src/hooks/useAccountDeletion.ts
|
|
149
|
+
import { c as _c } from "react/compiler-runtime";
|
|
150
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
151
|
+
var DELETION_STATUS_KEY = ["accountDeletionStatus"];
|
|
152
|
+
function useAccountDeletion() {
|
|
153
|
+
const $ = _c(56);
|
|
154
|
+
const supabase = useSupabase();
|
|
155
|
+
const queryClient = useQueryClient();
|
|
156
|
+
const {
|
|
157
|
+
user
|
|
158
|
+
} = useAuth();
|
|
159
|
+
let t0;
|
|
160
|
+
if ($[0] !== supabase) {
|
|
161
|
+
t0 = async () => {
|
|
162
|
+
const {
|
|
163
|
+
data,
|
|
164
|
+
error
|
|
165
|
+
} = await supabase.schema("core").rpc("get_deletion_status");
|
|
166
|
+
if (error) {
|
|
167
|
+
throw new Error(error.message);
|
|
168
|
+
}
|
|
169
|
+
return data;
|
|
170
|
+
};
|
|
171
|
+
$[0] = supabase;
|
|
172
|
+
$[1] = t0;
|
|
173
|
+
} else {
|
|
174
|
+
t0 = $[1];
|
|
175
|
+
}
|
|
176
|
+
const t1 = !!user;
|
|
177
|
+
let t2;
|
|
178
|
+
if ($[2] !== t0 || $[3] !== t1) {
|
|
179
|
+
t2 = {
|
|
180
|
+
queryKey: DELETION_STATUS_KEY,
|
|
181
|
+
queryFn: t0,
|
|
182
|
+
enabled: t1,
|
|
183
|
+
staleTime: 3e5,
|
|
184
|
+
refetchOnWindowFocus: true
|
|
185
|
+
};
|
|
186
|
+
$[2] = t0;
|
|
187
|
+
$[3] = t1;
|
|
188
|
+
$[4] = t2;
|
|
189
|
+
} else {
|
|
190
|
+
t2 = $[4];
|
|
191
|
+
}
|
|
192
|
+
const statusQuery = useQuery(t2);
|
|
193
|
+
let t3;
|
|
194
|
+
if ($[5] !== supabase) {
|
|
195
|
+
t3 = async (reason) => {
|
|
196
|
+
const {
|
|
197
|
+
data: data_0,
|
|
198
|
+
error: error_0
|
|
199
|
+
} = await supabase.schema("core").rpc("request_account_deletion", {
|
|
200
|
+
p_reason: reason
|
|
201
|
+
});
|
|
202
|
+
if (error_0) {
|
|
203
|
+
throw new Error(error_0.message);
|
|
204
|
+
}
|
|
205
|
+
return data_0;
|
|
206
|
+
};
|
|
207
|
+
$[5] = supabase;
|
|
208
|
+
$[6] = t3;
|
|
209
|
+
} else {
|
|
210
|
+
t3 = $[6];
|
|
211
|
+
}
|
|
212
|
+
let t4;
|
|
213
|
+
if ($[7] !== queryClient) {
|
|
214
|
+
t4 = (data_1) => {
|
|
215
|
+
if (data_1.success) {
|
|
216
|
+
queryClient.invalidateQueries({
|
|
217
|
+
queryKey: DELETION_STATUS_KEY
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
$[7] = queryClient;
|
|
222
|
+
$[8] = t4;
|
|
223
|
+
} else {
|
|
224
|
+
t4 = $[8];
|
|
225
|
+
}
|
|
226
|
+
let t5;
|
|
227
|
+
if ($[9] !== t3 || $[10] !== t4) {
|
|
228
|
+
t5 = {
|
|
229
|
+
mutationFn: t3,
|
|
230
|
+
onSuccess: t4
|
|
231
|
+
};
|
|
232
|
+
$[9] = t3;
|
|
233
|
+
$[10] = t4;
|
|
234
|
+
$[11] = t5;
|
|
235
|
+
} else {
|
|
236
|
+
t5 = $[11];
|
|
237
|
+
}
|
|
238
|
+
const requestMutation = useMutation(t5);
|
|
239
|
+
let t6;
|
|
240
|
+
if ($[12] !== supabase) {
|
|
241
|
+
t6 = async () => {
|
|
242
|
+
const {
|
|
243
|
+
data: data_2,
|
|
244
|
+
error: error_1
|
|
245
|
+
} = await supabase.schema("core").rpc("cancel_account_deletion");
|
|
246
|
+
if (error_1) {
|
|
247
|
+
throw new Error(error_1.message);
|
|
248
|
+
}
|
|
249
|
+
return data_2;
|
|
250
|
+
};
|
|
251
|
+
$[12] = supabase;
|
|
252
|
+
$[13] = t6;
|
|
253
|
+
} else {
|
|
254
|
+
t6 = $[13];
|
|
255
|
+
}
|
|
256
|
+
let t7;
|
|
257
|
+
if ($[14] !== queryClient) {
|
|
258
|
+
t7 = (data_3) => {
|
|
259
|
+
if (data_3.success) {
|
|
260
|
+
queryClient.invalidateQueries({
|
|
261
|
+
queryKey: DELETION_STATUS_KEY
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
$[14] = queryClient;
|
|
266
|
+
$[15] = t7;
|
|
267
|
+
} else {
|
|
268
|
+
t7 = $[15];
|
|
269
|
+
}
|
|
270
|
+
let t8;
|
|
271
|
+
if ($[16] !== t6 || $[17] !== t7) {
|
|
272
|
+
t8 = {
|
|
273
|
+
mutationFn: t6,
|
|
274
|
+
onSuccess: t7
|
|
275
|
+
};
|
|
276
|
+
$[16] = t6;
|
|
277
|
+
$[17] = t7;
|
|
278
|
+
$[18] = t8;
|
|
279
|
+
} else {
|
|
280
|
+
t8 = $[18];
|
|
281
|
+
}
|
|
282
|
+
const cancelMutation = useMutation(t8);
|
|
283
|
+
let t9;
|
|
284
|
+
if ($[19] !== requestMutation) {
|
|
285
|
+
t9 = async (reason_0) => requestMutation.mutateAsync(reason_0);
|
|
286
|
+
$[19] = requestMutation;
|
|
287
|
+
$[20] = t9;
|
|
288
|
+
} else {
|
|
289
|
+
t9 = $[20];
|
|
290
|
+
}
|
|
291
|
+
const requestDeletion = t9;
|
|
292
|
+
let t10;
|
|
293
|
+
if ($[21] !== cancelMutation) {
|
|
294
|
+
t10 = async () => cancelMutation.mutateAsync();
|
|
295
|
+
$[21] = cancelMutation;
|
|
296
|
+
$[22] = t10;
|
|
297
|
+
} else {
|
|
298
|
+
t10 = $[22];
|
|
299
|
+
}
|
|
300
|
+
const cancelDeletion = t10;
|
|
301
|
+
let t11;
|
|
302
|
+
if ($[23] !== queryClient) {
|
|
303
|
+
t11 = () => {
|
|
304
|
+
queryClient.invalidateQueries({
|
|
305
|
+
queryKey: DELETION_STATUS_KEY
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
$[23] = queryClient;
|
|
309
|
+
$[24] = t11;
|
|
310
|
+
} else {
|
|
311
|
+
t11 = $[24];
|
|
312
|
+
}
|
|
313
|
+
const refreshStatus = t11;
|
|
314
|
+
const status = statusQuery.data;
|
|
315
|
+
const request = status?.request;
|
|
316
|
+
const t12 = request?.status === "pending";
|
|
317
|
+
const t13 = request?.status === "cancelled";
|
|
318
|
+
const t14 = request?.status === "completed";
|
|
319
|
+
const t15 = request?.daysRemaining ?? null;
|
|
320
|
+
let t16;
|
|
321
|
+
if ($[25] !== request) {
|
|
322
|
+
t16 = request?.scheduledDeletionAt ? new Date(request.scheduledDeletionAt) : null;
|
|
323
|
+
$[25] = request;
|
|
324
|
+
$[26] = t16;
|
|
325
|
+
} else {
|
|
326
|
+
t16 = $[26];
|
|
327
|
+
}
|
|
328
|
+
let t17;
|
|
329
|
+
if ($[27] !== request) {
|
|
330
|
+
t17 = request?.requestedAt ? new Date(request.requestedAt) : null;
|
|
331
|
+
$[27] = request;
|
|
332
|
+
$[28] = t17;
|
|
333
|
+
} else {
|
|
334
|
+
t17 = $[28];
|
|
335
|
+
}
|
|
336
|
+
let t18;
|
|
337
|
+
if ($[29] !== request) {
|
|
338
|
+
t18 = request?.cancelledAt ? new Date(request.cancelledAt) : null;
|
|
339
|
+
$[29] = request;
|
|
340
|
+
$[30] = t18;
|
|
341
|
+
} else {
|
|
342
|
+
t18 = $[30];
|
|
343
|
+
}
|
|
344
|
+
const t19 = request?.reason ?? null;
|
|
345
|
+
let t20;
|
|
346
|
+
if ($[31] !== request || $[32] !== t12 || $[33] !== t13 || $[34] !== t14 || $[35] !== t15 || $[36] !== t16 || $[37] !== t17 || $[38] !== t18 || $[39] !== t19) {
|
|
347
|
+
t20 = {
|
|
348
|
+
deletionRequest: request,
|
|
349
|
+
isPendingDeletion: t12,
|
|
350
|
+
isCancelledDeletion: t13,
|
|
351
|
+
isCompletedDeletion: t14,
|
|
352
|
+
daysRemaining: t15,
|
|
353
|
+
scheduledDeletionAt: t16,
|
|
354
|
+
requestedAt: t17,
|
|
355
|
+
cancelledAt: t18,
|
|
356
|
+
reason: t19
|
|
357
|
+
};
|
|
358
|
+
$[31] = request;
|
|
359
|
+
$[32] = t12;
|
|
360
|
+
$[33] = t13;
|
|
361
|
+
$[34] = t14;
|
|
362
|
+
$[35] = t15;
|
|
363
|
+
$[36] = t16;
|
|
364
|
+
$[37] = t17;
|
|
365
|
+
$[38] = t18;
|
|
366
|
+
$[39] = t19;
|
|
367
|
+
$[40] = t20;
|
|
368
|
+
} else {
|
|
369
|
+
t20 = $[40];
|
|
370
|
+
}
|
|
371
|
+
const computedValues = t20;
|
|
372
|
+
let t21;
|
|
373
|
+
if ($[41] !== cancelDeletion || $[42] !== cancelMutation.data || $[43] !== cancelMutation.error || $[44] !== cancelMutation.isPending || $[45] !== computedValues || $[46] !== refreshStatus || $[47] !== requestDeletion || $[48] !== requestMutation.data || $[49] !== requestMutation.error || $[50] !== requestMutation.isPending || $[51] !== statusQuery.data || $[52] !== statusQuery.error || $[53] !== statusQuery.isError || $[54] !== statusQuery.isLoading) {
|
|
374
|
+
t21 = {
|
|
375
|
+
deletionStatus: statusQuery.data,
|
|
376
|
+
isLoading: statusQuery.isLoading,
|
|
377
|
+
isError: statusQuery.isError,
|
|
378
|
+
error: statusQuery.error,
|
|
379
|
+
...computedValues,
|
|
380
|
+
requestDeletion,
|
|
381
|
+
cancelDeletion,
|
|
382
|
+
refreshStatus,
|
|
383
|
+
isRequesting: requestMutation.isPending,
|
|
384
|
+
isCancelling: cancelMutation.isPending,
|
|
385
|
+
requestError: requestMutation.error,
|
|
386
|
+
cancelError: cancelMutation.error,
|
|
387
|
+
requestResult: requestMutation.data,
|
|
388
|
+
cancelResult: cancelMutation.data
|
|
389
|
+
};
|
|
390
|
+
$[41] = cancelDeletion;
|
|
391
|
+
$[42] = cancelMutation.data;
|
|
392
|
+
$[43] = cancelMutation.error;
|
|
393
|
+
$[44] = cancelMutation.isPending;
|
|
394
|
+
$[45] = computedValues;
|
|
395
|
+
$[46] = refreshStatus;
|
|
396
|
+
$[47] = requestDeletion;
|
|
397
|
+
$[48] = requestMutation.data;
|
|
398
|
+
$[49] = requestMutation.error;
|
|
399
|
+
$[50] = requestMutation.isPending;
|
|
400
|
+
$[51] = statusQuery.data;
|
|
401
|
+
$[52] = statusQuery.error;
|
|
402
|
+
$[53] = statusQuery.isError;
|
|
403
|
+
$[54] = statusQuery.isLoading;
|
|
404
|
+
$[55] = t21;
|
|
405
|
+
} else {
|
|
406
|
+
t21 = $[55];
|
|
407
|
+
}
|
|
408
|
+
return t21;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// src/hooks/useUserStatus.ts
|
|
412
|
+
import { c as _c2 } from "react/compiler-runtime";
|
|
413
|
+
import { useMutation as useMutation2, useQuery as useQuery2, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
414
|
+
var USER_STATUS_KEY = (userId) => ["userStatus", userId];
|
|
415
|
+
function useUserStatus(targetUserId) {
|
|
416
|
+
const $ = _c2(58);
|
|
417
|
+
const supabase = useSupabase();
|
|
418
|
+
const queryClient = useQueryClient2();
|
|
419
|
+
const {
|
|
420
|
+
user
|
|
421
|
+
} = useAuth();
|
|
422
|
+
const userId = targetUserId ?? user?.id;
|
|
423
|
+
const t0 = userId ?? "";
|
|
424
|
+
let t1;
|
|
425
|
+
if ($[0] !== t0) {
|
|
426
|
+
t1 = USER_STATUS_KEY(t0);
|
|
427
|
+
$[0] = t0;
|
|
428
|
+
$[1] = t1;
|
|
429
|
+
} else {
|
|
430
|
+
t1 = $[1];
|
|
431
|
+
}
|
|
432
|
+
let t2;
|
|
433
|
+
if ($[2] !== supabase || $[3] !== userId) {
|
|
434
|
+
t2 = async () => {
|
|
435
|
+
const {
|
|
436
|
+
data,
|
|
437
|
+
error
|
|
438
|
+
} = await supabase.schema("core").rpc("get_user_status", {
|
|
439
|
+
p_user_id: userId
|
|
440
|
+
});
|
|
441
|
+
if (error) {
|
|
442
|
+
throw new Error(error.message);
|
|
443
|
+
}
|
|
444
|
+
return data;
|
|
445
|
+
};
|
|
446
|
+
$[2] = supabase;
|
|
447
|
+
$[3] = userId;
|
|
448
|
+
$[4] = t2;
|
|
449
|
+
} else {
|
|
450
|
+
t2 = $[4];
|
|
451
|
+
}
|
|
452
|
+
const t3 = !!userId;
|
|
453
|
+
let t4;
|
|
454
|
+
if ($[5] !== t1 || $[6] !== t2 || $[7] !== t3) {
|
|
455
|
+
t4 = {
|
|
456
|
+
queryKey: t1,
|
|
457
|
+
queryFn: t2,
|
|
458
|
+
enabled: t3,
|
|
459
|
+
staleTime: 3e5,
|
|
460
|
+
refetchOnWindowFocus: true
|
|
461
|
+
};
|
|
462
|
+
$[5] = t1;
|
|
463
|
+
$[6] = t2;
|
|
464
|
+
$[7] = t3;
|
|
465
|
+
$[8] = t4;
|
|
466
|
+
} else {
|
|
467
|
+
t4 = $[8];
|
|
468
|
+
}
|
|
469
|
+
const statusQuery = useQuery2(t4);
|
|
470
|
+
let t5;
|
|
471
|
+
if ($[9] !== supabase) {
|
|
472
|
+
t5 = async (t62) => {
|
|
473
|
+
const {
|
|
474
|
+
userId: userId_0,
|
|
475
|
+
reason
|
|
476
|
+
} = t62;
|
|
477
|
+
const {
|
|
478
|
+
data: data_0,
|
|
479
|
+
error: error_0
|
|
480
|
+
} = await supabase.schema("core").rpc("archive_user", {
|
|
481
|
+
p_user_id: userId_0,
|
|
482
|
+
p_reason: reason ?? void 0
|
|
483
|
+
});
|
|
484
|
+
if (error_0) {
|
|
485
|
+
throw new Error(error_0.message);
|
|
486
|
+
}
|
|
487
|
+
return data_0;
|
|
488
|
+
};
|
|
489
|
+
$[9] = supabase;
|
|
490
|
+
$[10] = t5;
|
|
491
|
+
} else {
|
|
492
|
+
t5 = $[10];
|
|
493
|
+
}
|
|
494
|
+
let t6;
|
|
495
|
+
if ($[11] !== queryClient) {
|
|
496
|
+
t6 = (data_1, variables) => {
|
|
497
|
+
if (data_1.success) {
|
|
498
|
+
queryClient.invalidateQueries({
|
|
499
|
+
queryKey: USER_STATUS_KEY(variables.userId)
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
$[11] = queryClient;
|
|
504
|
+
$[12] = t6;
|
|
505
|
+
} else {
|
|
506
|
+
t6 = $[12];
|
|
507
|
+
}
|
|
508
|
+
let t7;
|
|
509
|
+
if ($[13] !== t5 || $[14] !== t6) {
|
|
510
|
+
t7 = {
|
|
511
|
+
mutationFn: t5,
|
|
512
|
+
onSuccess: t6
|
|
513
|
+
};
|
|
514
|
+
$[13] = t5;
|
|
515
|
+
$[14] = t6;
|
|
516
|
+
$[15] = t7;
|
|
517
|
+
} else {
|
|
518
|
+
t7 = $[15];
|
|
519
|
+
}
|
|
520
|
+
const archiveMutation = useMutation2(t7);
|
|
521
|
+
let t8;
|
|
522
|
+
if ($[16] !== supabase) {
|
|
523
|
+
t8 = async (userId_1) => {
|
|
524
|
+
const {
|
|
525
|
+
data: data_2,
|
|
526
|
+
error: error_1
|
|
527
|
+
} = await supabase.schema("core").rpc("unarchive_user", {
|
|
528
|
+
p_user_id: userId_1
|
|
529
|
+
});
|
|
530
|
+
if (error_1) {
|
|
531
|
+
throw new Error(error_1.message);
|
|
532
|
+
}
|
|
533
|
+
return data_2;
|
|
534
|
+
};
|
|
535
|
+
$[16] = supabase;
|
|
536
|
+
$[17] = t8;
|
|
537
|
+
} else {
|
|
538
|
+
t8 = $[17];
|
|
539
|
+
}
|
|
540
|
+
let t9;
|
|
541
|
+
if ($[18] !== queryClient) {
|
|
542
|
+
t9 = (data_3, userId_2) => {
|
|
543
|
+
if (data_3.success) {
|
|
544
|
+
queryClient.invalidateQueries({
|
|
545
|
+
queryKey: USER_STATUS_KEY(userId_2)
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
$[18] = queryClient;
|
|
550
|
+
$[19] = t9;
|
|
551
|
+
} else {
|
|
552
|
+
t9 = $[19];
|
|
553
|
+
}
|
|
554
|
+
let t10;
|
|
555
|
+
if ($[20] !== t8 || $[21] !== t9) {
|
|
556
|
+
t10 = {
|
|
557
|
+
mutationFn: t8,
|
|
558
|
+
onSuccess: t9
|
|
559
|
+
};
|
|
560
|
+
$[20] = t8;
|
|
561
|
+
$[21] = t9;
|
|
562
|
+
$[22] = t10;
|
|
563
|
+
} else {
|
|
564
|
+
t10 = $[22];
|
|
565
|
+
}
|
|
566
|
+
const unarchiveMutation = useMutation2(t10);
|
|
567
|
+
let t11;
|
|
568
|
+
if ($[23] !== archiveMutation) {
|
|
569
|
+
t11 = async (userId_3, reason_0) => archiveMutation.mutateAsync({
|
|
570
|
+
userId: userId_3,
|
|
571
|
+
reason: reason_0
|
|
572
|
+
});
|
|
573
|
+
$[23] = archiveMutation;
|
|
574
|
+
$[24] = t11;
|
|
575
|
+
} else {
|
|
576
|
+
t11 = $[24];
|
|
577
|
+
}
|
|
578
|
+
const archiveUser = t11;
|
|
579
|
+
let t12;
|
|
580
|
+
if ($[25] !== unarchiveMutation) {
|
|
581
|
+
t12 = async (userId_4) => unarchiveMutation.mutateAsync(userId_4);
|
|
582
|
+
$[25] = unarchiveMutation;
|
|
583
|
+
$[26] = t12;
|
|
584
|
+
} else {
|
|
585
|
+
t12 = $[26];
|
|
586
|
+
}
|
|
587
|
+
const unarchiveUser = t12;
|
|
588
|
+
let t13;
|
|
589
|
+
if ($[27] !== queryClient || $[28] !== userId) {
|
|
590
|
+
t13 = () => {
|
|
591
|
+
if (userId) {
|
|
592
|
+
queryClient.invalidateQueries({
|
|
593
|
+
queryKey: USER_STATUS_KEY(userId)
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
$[27] = queryClient;
|
|
598
|
+
$[28] = userId;
|
|
599
|
+
$[29] = t13;
|
|
600
|
+
} else {
|
|
601
|
+
t13 = $[29];
|
|
602
|
+
}
|
|
603
|
+
const refreshStatus = t13;
|
|
604
|
+
let t14;
|
|
605
|
+
if ($[30] !== queryClient) {
|
|
606
|
+
t14 = (userIdToInvalidate) => {
|
|
607
|
+
queryClient.invalidateQueries({
|
|
608
|
+
queryKey: USER_STATUS_KEY(userIdToInvalidate)
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
$[30] = queryClient;
|
|
612
|
+
$[31] = t14;
|
|
613
|
+
} else {
|
|
614
|
+
t14 = $[31];
|
|
615
|
+
}
|
|
616
|
+
const invalidateUserStatus = t14;
|
|
617
|
+
const statusData = statusQuery.data;
|
|
618
|
+
const t15 = statusData?.exists ?? false;
|
|
619
|
+
const t16 = statusData?.status;
|
|
620
|
+
const t17 = statusData?.isActive ?? false;
|
|
621
|
+
const t18 = statusData?.status === "archived";
|
|
622
|
+
const t19 = statusData?.status === "suspended";
|
|
623
|
+
let t20;
|
|
624
|
+
if ($[32] !== statusData) {
|
|
625
|
+
t20 = statusData?.archivedAt ? new Date(statusData.archivedAt) : null;
|
|
626
|
+
$[32] = statusData;
|
|
627
|
+
$[33] = t20;
|
|
628
|
+
} else {
|
|
629
|
+
t20 = $[33];
|
|
630
|
+
}
|
|
631
|
+
const t21 = statusData?.archivedBy ?? null;
|
|
632
|
+
let t22;
|
|
633
|
+
if ($[34] !== t15 || $[35] !== t16 || $[36] !== t17 || $[37] !== t18 || $[38] !== t19 || $[39] !== t20 || $[40] !== t21) {
|
|
634
|
+
t22 = {
|
|
635
|
+
exists: t15,
|
|
636
|
+
status: t16,
|
|
637
|
+
isActive: t17,
|
|
638
|
+
isArchived: t18,
|
|
639
|
+
isSuspended: t19,
|
|
640
|
+
archivedAt: t20,
|
|
641
|
+
archivedBy: t21
|
|
642
|
+
};
|
|
643
|
+
$[34] = t15;
|
|
644
|
+
$[35] = t16;
|
|
645
|
+
$[36] = t17;
|
|
646
|
+
$[37] = t18;
|
|
647
|
+
$[38] = t19;
|
|
648
|
+
$[39] = t20;
|
|
649
|
+
$[40] = t21;
|
|
650
|
+
$[41] = t22;
|
|
651
|
+
} else {
|
|
652
|
+
t22 = $[41];
|
|
653
|
+
}
|
|
654
|
+
const computedValues = t22;
|
|
655
|
+
let t23;
|
|
656
|
+
if ($[42] !== archiveMutation.data || $[43] !== archiveMutation.error || $[44] !== archiveMutation.isPending || $[45] !== archiveUser || $[46] !== computedValues || $[47] !== invalidateUserStatus || $[48] !== refreshStatus || $[49] !== statusQuery.data || $[50] !== statusQuery.error || $[51] !== statusQuery.isError || $[52] !== statusQuery.isLoading || $[53] !== unarchiveMutation.data || $[54] !== unarchiveMutation.error || $[55] !== unarchiveMutation.isPending || $[56] !== unarchiveUser) {
|
|
657
|
+
t23 = {
|
|
658
|
+
statusData: statusQuery.data,
|
|
659
|
+
isLoading: statusQuery.isLoading,
|
|
660
|
+
isError: statusQuery.isError,
|
|
661
|
+
error: statusQuery.error,
|
|
662
|
+
...computedValues,
|
|
663
|
+
archiveUser,
|
|
664
|
+
unarchiveUser,
|
|
665
|
+
refreshStatus,
|
|
666
|
+
invalidateUserStatus,
|
|
667
|
+
isArchiving: archiveMutation.isPending,
|
|
668
|
+
isUnarchiving: unarchiveMutation.isPending,
|
|
669
|
+
archiveError: archiveMutation.error,
|
|
670
|
+
unarchiveError: unarchiveMutation.error,
|
|
671
|
+
archiveResult: archiveMutation.data,
|
|
672
|
+
unarchiveResult: unarchiveMutation.data
|
|
673
|
+
};
|
|
674
|
+
$[42] = archiveMutation.data;
|
|
675
|
+
$[43] = archiveMutation.error;
|
|
676
|
+
$[44] = archiveMutation.isPending;
|
|
677
|
+
$[45] = archiveUser;
|
|
678
|
+
$[46] = computedValues;
|
|
679
|
+
$[47] = invalidateUserStatus;
|
|
680
|
+
$[48] = refreshStatus;
|
|
681
|
+
$[49] = statusQuery.data;
|
|
682
|
+
$[50] = statusQuery.error;
|
|
683
|
+
$[51] = statusQuery.isError;
|
|
684
|
+
$[52] = statusQuery.isLoading;
|
|
685
|
+
$[53] = unarchiveMutation.data;
|
|
686
|
+
$[54] = unarchiveMutation.error;
|
|
687
|
+
$[55] = unarchiveMutation.isPending;
|
|
688
|
+
$[56] = unarchiveUser;
|
|
689
|
+
$[57] = t23;
|
|
690
|
+
} else {
|
|
691
|
+
t23 = $[57];
|
|
692
|
+
}
|
|
693
|
+
return t23;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// src/hooks/useDataExport.ts
|
|
697
|
+
import { c as _c3 } from "react/compiler-runtime";
|
|
698
|
+
import { useMutation as useMutation3, useQuery as useQuery3, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
699
|
+
function useDataExport() {
|
|
700
|
+
const $ = _c3(35);
|
|
701
|
+
const supabase = useSupabase();
|
|
702
|
+
const auth = useAuth();
|
|
703
|
+
const queryClient = useQueryClient3();
|
|
704
|
+
let t0;
|
|
705
|
+
if ($[0] !== auth.user.id) {
|
|
706
|
+
t0 = ["dataExportHistory", auth.user.id];
|
|
707
|
+
$[0] = auth.user.id;
|
|
708
|
+
$[1] = t0;
|
|
709
|
+
} else {
|
|
710
|
+
t0 = $[1];
|
|
711
|
+
}
|
|
712
|
+
let t1;
|
|
713
|
+
if ($[2] !== auth.user.id || $[3] !== supabase) {
|
|
714
|
+
t1 = async () => {
|
|
715
|
+
const {
|
|
716
|
+
data,
|
|
717
|
+
error
|
|
718
|
+
} = await supabase.rpc("get_data_export_history", {
|
|
719
|
+
p_user_id: auth.user.id
|
|
720
|
+
});
|
|
721
|
+
if (error) {
|
|
722
|
+
throw new Error(`Failed to fetch export history: ${error.message}`);
|
|
723
|
+
}
|
|
724
|
+
return data || [];
|
|
725
|
+
};
|
|
726
|
+
$[2] = auth.user.id;
|
|
727
|
+
$[3] = supabase;
|
|
728
|
+
$[4] = t1;
|
|
729
|
+
} else {
|
|
730
|
+
t1 = $[4];
|
|
731
|
+
}
|
|
732
|
+
let t2;
|
|
733
|
+
if ($[5] !== t0 || $[6] !== t1) {
|
|
734
|
+
t2 = {
|
|
735
|
+
queryKey: t0,
|
|
736
|
+
queryFn: t1,
|
|
737
|
+
staleTime: 3e5
|
|
738
|
+
};
|
|
739
|
+
$[5] = t0;
|
|
740
|
+
$[6] = t1;
|
|
741
|
+
$[7] = t2;
|
|
742
|
+
} else {
|
|
743
|
+
t2 = $[7];
|
|
744
|
+
}
|
|
745
|
+
const historyQuery = useQuery3(t2);
|
|
746
|
+
let t3;
|
|
747
|
+
if ($[8] !== auth.user.id || $[9] !== supabase) {
|
|
748
|
+
t3 = async () => {
|
|
749
|
+
const {
|
|
750
|
+
data: data_0,
|
|
751
|
+
error: error_0
|
|
752
|
+
} = await supabase.rpc("export_user_personal_data", {
|
|
753
|
+
p_user_id: auth.user.id
|
|
754
|
+
});
|
|
755
|
+
if (error_0) {
|
|
756
|
+
throw new Error(`Failed to export personal data: ${error_0.message}`);
|
|
757
|
+
}
|
|
758
|
+
if (!data_0) {
|
|
759
|
+
throw new Error("No data returned from export");
|
|
760
|
+
}
|
|
761
|
+
return data_0;
|
|
762
|
+
};
|
|
763
|
+
$[8] = auth.user.id;
|
|
764
|
+
$[9] = supabase;
|
|
765
|
+
$[10] = t3;
|
|
766
|
+
} else {
|
|
767
|
+
t3 = $[10];
|
|
768
|
+
}
|
|
769
|
+
let t4;
|
|
770
|
+
if ($[11] !== auth.user.id || $[12] !== queryClient) {
|
|
771
|
+
t4 = () => {
|
|
772
|
+
queryClient.invalidateQueries({
|
|
773
|
+
queryKey: ["dataExportHistory", auth.user.id]
|
|
774
|
+
});
|
|
775
|
+
};
|
|
776
|
+
$[11] = auth.user.id;
|
|
777
|
+
$[12] = queryClient;
|
|
778
|
+
$[13] = t4;
|
|
779
|
+
} else {
|
|
780
|
+
t4 = $[13];
|
|
781
|
+
}
|
|
782
|
+
let t5;
|
|
783
|
+
if ($[14] !== t3 || $[15] !== t4) {
|
|
784
|
+
t5 = {
|
|
785
|
+
mutationFn: t3,
|
|
786
|
+
onSuccess: t4
|
|
787
|
+
};
|
|
788
|
+
$[14] = t3;
|
|
789
|
+
$[15] = t4;
|
|
790
|
+
$[16] = t5;
|
|
791
|
+
} else {
|
|
792
|
+
t5 = $[16];
|
|
793
|
+
}
|
|
794
|
+
const exportMutation = useMutation3(t5);
|
|
795
|
+
let t6;
|
|
796
|
+
if ($[17] !== exportMutation) {
|
|
797
|
+
t6 = async () => exportMutation.mutateAsync();
|
|
798
|
+
$[17] = exportMutation;
|
|
799
|
+
$[18] = t6;
|
|
800
|
+
} else {
|
|
801
|
+
t6 = $[18];
|
|
802
|
+
}
|
|
803
|
+
const exportMyData = t6;
|
|
804
|
+
let t7;
|
|
805
|
+
if ($[19] !== auth.user.id || $[20] !== queryClient || $[21] !== supabase) {
|
|
806
|
+
t7 = (data_1, filename) => {
|
|
807
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
808
|
+
const defaultFilename = `my-data-${timestamp}.json`;
|
|
809
|
+
const finalFilename = filename || defaultFilename;
|
|
810
|
+
const jsonString = JSON.stringify(data_1, null, 2);
|
|
811
|
+
const blob = new Blob([jsonString], {
|
|
812
|
+
type: "application/json"
|
|
813
|
+
});
|
|
814
|
+
const url = URL.createObjectURL(blob);
|
|
815
|
+
const link = document.createElement("a");
|
|
816
|
+
link.href = url;
|
|
817
|
+
link.download = finalFilename;
|
|
818
|
+
document.body.appendChild(link);
|
|
819
|
+
link.click();
|
|
820
|
+
document.body.removeChild(link);
|
|
821
|
+
URL.revokeObjectURL(url);
|
|
822
|
+
if (data_1.exportMetadata?.exportId) {
|
|
823
|
+
supabase.rpc("increment_export_download_count", {
|
|
824
|
+
p_export_id: data_1.exportMetadata.exportId
|
|
825
|
+
}).then(() => {
|
|
826
|
+
queryClient.invalidateQueries({
|
|
827
|
+
queryKey: ["dataExportHistory", auth.user.id]
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
$[19] = auth.user.id;
|
|
833
|
+
$[20] = queryClient;
|
|
834
|
+
$[21] = supabase;
|
|
835
|
+
$[22] = t7;
|
|
836
|
+
} else {
|
|
837
|
+
t7 = $[22];
|
|
838
|
+
}
|
|
839
|
+
const downloadAsJson = t7;
|
|
840
|
+
let t8;
|
|
841
|
+
if ($[23] !== historyQuery.data) {
|
|
842
|
+
t8 = () => historyQuery.data || [];
|
|
843
|
+
$[23] = historyQuery.data;
|
|
844
|
+
$[24] = t8;
|
|
845
|
+
} else {
|
|
846
|
+
t8 = $[24];
|
|
847
|
+
}
|
|
848
|
+
const getExportHistory = t8;
|
|
849
|
+
let t9;
|
|
850
|
+
if ($[25] !== auth.user.id || $[26] !== queryClient) {
|
|
851
|
+
t9 = () => {
|
|
852
|
+
queryClient.invalidateQueries({
|
|
853
|
+
queryKey: ["dataExportHistory", auth.user.id]
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
$[25] = auth.user.id;
|
|
857
|
+
$[26] = queryClient;
|
|
858
|
+
$[27] = t9;
|
|
859
|
+
} else {
|
|
860
|
+
t9 = $[27];
|
|
861
|
+
}
|
|
862
|
+
const refreshHistory = t9;
|
|
863
|
+
let t10;
|
|
864
|
+
if ($[28] !== downloadAsJson || $[29] !== exportMutation || $[30] !== exportMyData || $[31] !== getExportHistory || $[32] !== historyQuery || $[33] !== refreshHistory) {
|
|
865
|
+
t10 = {
|
|
866
|
+
exportMyData,
|
|
867
|
+
exportMutation,
|
|
868
|
+
downloadAsJson,
|
|
869
|
+
historyQuery,
|
|
870
|
+
getExportHistory,
|
|
871
|
+
refreshHistory,
|
|
872
|
+
isExporting: exportMutation.isPending,
|
|
873
|
+
isLoadingHistory: historyQuery.isLoading
|
|
874
|
+
};
|
|
875
|
+
$[28] = downloadAsJson;
|
|
876
|
+
$[29] = exportMutation;
|
|
877
|
+
$[30] = exportMyData;
|
|
878
|
+
$[31] = getExportHistory;
|
|
879
|
+
$[32] = historyQuery;
|
|
880
|
+
$[33] = refreshHistory;
|
|
881
|
+
$[34] = t10;
|
|
882
|
+
} else {
|
|
883
|
+
t10 = $[34];
|
|
884
|
+
}
|
|
885
|
+
return t10;
|
|
886
|
+
}
|
|
887
|
+
var useDataExport_default = useDataExport;
|
|
888
|
+
|
|
889
|
+
// src/useBackgroundTask.tsx
|
|
890
|
+
import { c as _c4 } from "react/compiler-runtime";
|
|
891
|
+
import { useToast } from "@pol-studios/hooks/toast";
|
|
892
|
+
function useBackgroundTask() {
|
|
893
|
+
const $ = _c4(12);
|
|
894
|
+
const supabase = useSupabase();
|
|
895
|
+
const {
|
|
896
|
+
user
|
|
897
|
+
} = useAuth();
|
|
898
|
+
const {
|
|
899
|
+
toast
|
|
900
|
+
} = useToast();
|
|
901
|
+
let t0;
|
|
902
|
+
if ($[0] !== supabase || $[1] !== toast || $[2] !== user) {
|
|
903
|
+
t0 = async function startTask2(request) {
|
|
904
|
+
if (user == null) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const taskResponse = await supabase.schema("core").from("Task").insert({
|
|
908
|
+
payload: request.body,
|
|
909
|
+
handlerId: request.handlerId,
|
|
910
|
+
title: request.title,
|
|
911
|
+
description: request.description,
|
|
912
|
+
createdBy: user.id,
|
|
913
|
+
payloadLength: JSON.stringify(request.body).length
|
|
914
|
+
}).select();
|
|
915
|
+
const task = taskResponse.data?.[0];
|
|
916
|
+
if (isUsable(task) === false) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
toast({
|
|
920
|
+
title: `Task Started: ${request.title}`
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
$[0] = supabase;
|
|
924
|
+
$[1] = toast;
|
|
925
|
+
$[2] = user;
|
|
926
|
+
$[3] = t0;
|
|
927
|
+
} else {
|
|
928
|
+
t0 = $[3];
|
|
929
|
+
}
|
|
930
|
+
const startTask = t0;
|
|
931
|
+
let t1;
|
|
932
|
+
if ($[4] !== supabase) {
|
|
933
|
+
t1 = async function retryTask2(taskId) {
|
|
934
|
+
const response = await supabase.functions.invoke("trigger-update", {
|
|
935
|
+
body: {
|
|
936
|
+
taskId,
|
|
937
|
+
action: "retry"
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
console.log(response.data);
|
|
941
|
+
if (response.error) {
|
|
942
|
+
throw response.error;
|
|
943
|
+
}
|
|
944
|
+
return response.data.id;
|
|
945
|
+
};
|
|
946
|
+
$[4] = supabase;
|
|
947
|
+
$[5] = t1;
|
|
948
|
+
} else {
|
|
949
|
+
t1 = $[5];
|
|
950
|
+
}
|
|
951
|
+
const retryTask = t1;
|
|
952
|
+
let t2;
|
|
953
|
+
if ($[6] !== supabase) {
|
|
954
|
+
t2 = async function cancelTask2(taskId_0) {
|
|
955
|
+
await supabase.functions.invoke("trigger-update", {
|
|
956
|
+
body: {
|
|
957
|
+
taskId: taskId_0,
|
|
958
|
+
action: "cancel"
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
$[6] = supabase;
|
|
963
|
+
$[7] = t2;
|
|
964
|
+
} else {
|
|
965
|
+
t2 = $[7];
|
|
966
|
+
}
|
|
967
|
+
const cancelTask = t2;
|
|
968
|
+
let t3;
|
|
969
|
+
if ($[8] !== cancelTask || $[9] !== retryTask || $[10] !== startTask) {
|
|
970
|
+
t3 = {
|
|
971
|
+
startTask,
|
|
972
|
+
retryTask,
|
|
973
|
+
cancelTask
|
|
974
|
+
};
|
|
975
|
+
$[8] = cancelTask;
|
|
976
|
+
$[9] = retryTask;
|
|
977
|
+
$[10] = startTask;
|
|
978
|
+
$[11] = t3;
|
|
979
|
+
} else {
|
|
980
|
+
t3 = $[11];
|
|
981
|
+
}
|
|
982
|
+
return t3;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/useUserMetadata.tsx
|
|
986
|
+
import { c as _c5 } from "react/compiler-runtime";
|
|
987
|
+
function useUserMetadata(key) {
|
|
988
|
+
const $ = _c5(16);
|
|
989
|
+
const supabase = useSupabase();
|
|
990
|
+
const {
|
|
991
|
+
user
|
|
992
|
+
} = useAuth();
|
|
993
|
+
let t0;
|
|
994
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
995
|
+
t0 = {
|
|
996
|
+
invalidateTables: ["UserMetadata"]
|
|
997
|
+
};
|
|
998
|
+
$[0] = t0;
|
|
999
|
+
} else {
|
|
1000
|
+
t0 = $[0];
|
|
1001
|
+
}
|
|
1002
|
+
const upsertMutation = useDbUpsert("UserMetadata", t0);
|
|
1003
|
+
let t1;
|
|
1004
|
+
if ($[1] !== key || $[2] !== supabase || $[3] !== user?.id) {
|
|
1005
|
+
t1 = supabase.from("UserMetadata").select().eq("userId", user?.id).eq("key", key).maybeSingle();
|
|
1006
|
+
$[1] = key;
|
|
1007
|
+
$[2] = supabase;
|
|
1008
|
+
$[3] = user?.id;
|
|
1009
|
+
$[4] = t1;
|
|
1010
|
+
} else {
|
|
1011
|
+
t1 = $[4];
|
|
1012
|
+
}
|
|
1013
|
+
let t2;
|
|
1014
|
+
if ($[5] !== user) {
|
|
1015
|
+
t2 = isUsable(user);
|
|
1016
|
+
$[5] = user;
|
|
1017
|
+
$[6] = t2;
|
|
1018
|
+
} else {
|
|
1019
|
+
t2 = $[6];
|
|
1020
|
+
}
|
|
1021
|
+
let t3;
|
|
1022
|
+
if ($[7] !== t2) {
|
|
1023
|
+
t3 = {
|
|
1024
|
+
crossOrganization: true,
|
|
1025
|
+
enabled: t2
|
|
1026
|
+
};
|
|
1027
|
+
$[7] = t2;
|
|
1028
|
+
$[8] = t3;
|
|
1029
|
+
} else {
|
|
1030
|
+
t3 = $[8];
|
|
1031
|
+
}
|
|
1032
|
+
const lastOpenRequest = useDbQuery(t1, t3);
|
|
1033
|
+
let t4;
|
|
1034
|
+
if ($[9] !== key || $[10] !== upsertMutation || $[11] !== user) {
|
|
1035
|
+
t4 = async function setMetadata2(value) {
|
|
1036
|
+
const newValue = {
|
|
1037
|
+
userId: user.id,
|
|
1038
|
+
key,
|
|
1039
|
+
value
|
|
1040
|
+
};
|
|
1041
|
+
await upsertMutation.mutateAsync(newValue);
|
|
1042
|
+
};
|
|
1043
|
+
$[9] = key;
|
|
1044
|
+
$[10] = upsertMutation;
|
|
1045
|
+
$[11] = user;
|
|
1046
|
+
$[12] = t4;
|
|
1047
|
+
} else {
|
|
1048
|
+
t4 = $[12];
|
|
1049
|
+
}
|
|
1050
|
+
const setMetadata = t4;
|
|
1051
|
+
let t5;
|
|
1052
|
+
if ($[13] !== lastOpenRequest || $[14] !== setMetadata) {
|
|
1053
|
+
t5 = [lastOpenRequest, setMetadata];
|
|
1054
|
+
$[13] = lastOpenRequest;
|
|
1055
|
+
$[14] = setMetadata;
|
|
1056
|
+
$[15] = t5;
|
|
1057
|
+
} else {
|
|
1058
|
+
t5 = $[15];
|
|
1059
|
+
}
|
|
1060
|
+
return t5;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// src/storage/useStorageUpload.ts
|
|
1064
|
+
import { c as _c6 } from "react/compiler-runtime";
|
|
1065
|
+
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
1066
|
+
import { Upload } from "tus-js-client";
|
|
1067
|
+
async function uploadFileWithMetadata(supabase, bucketName, filePath, file, metadata, onProgress) {
|
|
1068
|
+
const {
|
|
1069
|
+
data: {
|
|
1070
|
+
session
|
|
1071
|
+
}
|
|
1072
|
+
} = await supabase.auth.getSession();
|
|
1073
|
+
if (!session) {
|
|
1074
|
+
throw new Error("User must be logged in to upload files");
|
|
1075
|
+
}
|
|
1076
|
+
const contentType = "type" in file ? file.type : metadata.contentType ?? "application/octet-stream";
|
|
1077
|
+
return new Promise((resolve, reject) => {
|
|
1078
|
+
const upload = new Upload(file, {
|
|
1079
|
+
endpoint: `${getSupabaseUrl()}/storage/v1/upload/resumable`,
|
|
1080
|
+
retryDelays: [0, 3e3, 5e3, 1e4, 2e4],
|
|
1081
|
+
headers: {
|
|
1082
|
+
authorization: `Bearer ${session.access_token}`,
|
|
1083
|
+
"x-upsert": "true"
|
|
1084
|
+
},
|
|
1085
|
+
uploadDataDuringCreation: true,
|
|
1086
|
+
removeFingerprintOnSuccess: true,
|
|
1087
|
+
metadata: {
|
|
1088
|
+
bucketName,
|
|
1089
|
+
objectName: filePath,
|
|
1090
|
+
contentType,
|
|
1091
|
+
cacheControl: "3600",
|
|
1092
|
+
// Custom metadata gets stored in storage.objects.metadata
|
|
1093
|
+
...Object.fromEntries(Object.entries(metadata).map(([k, v]) => [k, String(v)]))
|
|
1094
|
+
},
|
|
1095
|
+
chunkSize: 6 * 1024 * 1024,
|
|
1096
|
+
// 6MB - required by Supabase
|
|
1097
|
+
onError: (error) => {
|
|
1098
|
+
console.error("Upload failed:", error);
|
|
1099
|
+
reject(error);
|
|
1100
|
+
},
|
|
1101
|
+
onProgress,
|
|
1102
|
+
onSuccess: () => {
|
|
1103
|
+
resolve();
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
upload.findPreviousUploads().then((previousUploads) => {
|
|
1107
|
+
if (previousUploads.length) {
|
|
1108
|
+
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
1109
|
+
}
|
|
1110
|
+
upload.start();
|
|
1111
|
+
});
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
function useStorageUpload(options) {
|
|
1115
|
+
const $ = _c6(3);
|
|
1116
|
+
const {
|
|
1117
|
+
bucketId
|
|
1118
|
+
} = options;
|
|
1119
|
+
const supabase = useSupabase();
|
|
1120
|
+
let t0;
|
|
1121
|
+
if ($[0] !== bucketId || $[1] !== supabase) {
|
|
1122
|
+
t0 = {
|
|
1123
|
+
mutationFn: async (input) => {
|
|
1124
|
+
const {
|
|
1125
|
+
file,
|
|
1126
|
+
fileName,
|
|
1127
|
+
directory,
|
|
1128
|
+
metadata: t1,
|
|
1129
|
+
onUploadProgress
|
|
1130
|
+
} = input;
|
|
1131
|
+
const metadata = t1 === void 0 ? {} : t1;
|
|
1132
|
+
const originalFileName = fileName ?? ("name" in file ? file.name : "") ?? ("fileName" in file ? file.fileName : "file");
|
|
1133
|
+
if (isNullOrWhitespace(originalFileName)) {
|
|
1134
|
+
throw new Error("File must have a valid name");
|
|
1135
|
+
}
|
|
1136
|
+
const extension = originalFileName.split(".").pop() ?? "";
|
|
1137
|
+
const uniqueFileName = `${newUuid()}.${extension}`;
|
|
1138
|
+
const path = directory ? `${directory}/14/${uniqueFileName}` : `14/${uniqueFileName}`;
|
|
1139
|
+
const contentType = "type" in file ? file.type.split("/").pop()?.toUpperCase() ?? "Unknown" : extension.toUpperCase();
|
|
1140
|
+
const uploadMetadata = {
|
|
1141
|
+
processingStatus: "None",
|
|
1142
|
+
contentType,
|
|
1143
|
+
originalFileName,
|
|
1144
|
+
...metadata
|
|
1145
|
+
};
|
|
1146
|
+
await uploadFileWithMetadata(supabase, bucketId, path, file, uploadMetadata, onUploadProgress);
|
|
1147
|
+
return {
|
|
1148
|
+
path,
|
|
1149
|
+
bucketId,
|
|
1150
|
+
originalFileName,
|
|
1151
|
+
contentType
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
$[0] = bucketId;
|
|
1156
|
+
$[1] = supabase;
|
|
1157
|
+
$[2] = t0;
|
|
1158
|
+
} else {
|
|
1159
|
+
t0 = $[2];
|
|
1160
|
+
}
|
|
1161
|
+
return useMutation4(t0);
|
|
1162
|
+
}
|
|
1163
|
+
function useStorageUploadWithEntity(options) {
|
|
1164
|
+
const $ = _c6(6);
|
|
1165
|
+
let updateEntity;
|
|
1166
|
+
let uploadOptions;
|
|
1167
|
+
if ($[0] !== options) {
|
|
1168
|
+
const {
|
|
1169
|
+
pathField,
|
|
1170
|
+
updateEntity: t02,
|
|
1171
|
+
...t1
|
|
1172
|
+
} = options;
|
|
1173
|
+
updateEntity = t02;
|
|
1174
|
+
uploadOptions = t1;
|
|
1175
|
+
$[0] = options;
|
|
1176
|
+
$[1] = updateEntity;
|
|
1177
|
+
$[2] = uploadOptions;
|
|
1178
|
+
} else {
|
|
1179
|
+
updateEntity = $[1];
|
|
1180
|
+
uploadOptions = $[2];
|
|
1181
|
+
}
|
|
1182
|
+
const uploadMutation = useStorageUpload(uploadOptions);
|
|
1183
|
+
let t0;
|
|
1184
|
+
if ($[3] !== updateEntity || $[4] !== uploadMutation) {
|
|
1185
|
+
t0 = {
|
|
1186
|
+
mutationFn: async (input) => {
|
|
1187
|
+
const {
|
|
1188
|
+
entity,
|
|
1189
|
+
...uploadInput
|
|
1190
|
+
} = input;
|
|
1191
|
+
const result = await uploadMutation.mutateAsync(uploadInput);
|
|
1192
|
+
await updateEntity(entity, result.path);
|
|
1193
|
+
return result;
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
$[3] = updateEntity;
|
|
1197
|
+
$[4] = uploadMutation;
|
|
1198
|
+
$[5] = t0;
|
|
1199
|
+
} else {
|
|
1200
|
+
t0 = $[5];
|
|
1201
|
+
}
|
|
1202
|
+
return useMutation4(t0);
|
|
1203
|
+
}
|
|
1204
|
+
export {
|
|
1205
|
+
UserMetadataContextProvider,
|
|
1206
|
+
recordConsentForUser,
|
|
1207
|
+
useAccountDeletion,
|
|
1208
|
+
useBackgroundTask,
|
|
1209
|
+
useConsent_default as useConsent,
|
|
1210
|
+
useDataExport_default as useDataExport,
|
|
1211
|
+
useLiveChangesIndicator,
|
|
1212
|
+
useSetUserMetadata,
|
|
1213
|
+
useStorageUpload,
|
|
1214
|
+
useStorageUploadWithEntity,
|
|
1215
|
+
useUserMetadata,
|
|
1216
|
+
useUserMetadataState,
|
|
1217
|
+
useUserMetadataValue,
|
|
1218
|
+
useUserStatus,
|
|
1219
|
+
userMetadataContext
|
|
1220
|
+
};
|
|
1221
|
+
//# sourceMappingURL=index.js.map
|