@pol-studios/db 1.0.31 → 1.0.34
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-Dc7nF2IG.d.ts → DataLayerContext-BwMk4VpG.d.ts} +92 -8
- package/dist/UserMetadataContext-QLIv-mfF.d.ts +171 -0
- package/dist/{UserMetadataContext-B8gVWGMl.d.ts → UserMetadataContext-pQb3A8_Q.d.ts} +1 -1
- package/dist/auth/context.d.ts +53 -5
- package/dist/auth/context.js +30 -8
- package/dist/auth/guards.d.ts +9 -9
- package/dist/auth/guards.js +2 -3
- package/dist/auth/hooks.d.ts +108 -4
- package/dist/auth/hooks.js +13 -9
- package/dist/auth/index.d.ts +6 -6
- package/dist/auth/index.js +45 -17
- package/dist/chunk-5HJLTYRA.js +355 -0
- package/dist/chunk-5HJLTYRA.js.map +1 -0
- package/dist/{chunk-WX4ABYIF.js → chunk-67HMVGV7.js} +292 -94
- package/dist/chunk-67HMVGV7.js.map +1 -0
- package/dist/chunk-6KN7KLEG.js +1 -0
- package/dist/{chunk-FZF26ZRB.js → chunk-7BGDQT5X.js} +29 -16
- package/dist/{chunk-FZF26ZRB.js.map → chunk-7BGDQT5X.js.map} +1 -1
- package/dist/{chunk-P4UZ7IXC.js → chunk-7D4SUZUM.js} +1 -5
- package/dist/{chunk-3PJTNH2L.js → chunk-AKIRHA4Q.js} +2 -2
- package/dist/{chunk-OQ7U6EQ3.js → chunk-AML2TLXJ.js} +3801 -3424
- package/dist/chunk-AML2TLXJ.js.map +1 -0
- package/dist/{chunk-5EFDS7SR.js → chunk-DMVUEJG2.js} +7 -2
- package/dist/chunk-DMVUEJG2.js.map +1 -0
- package/dist/{chunk-ADD5MIMK.js → chunk-FESQS4S5.js} +15 -15
- package/dist/{chunk-ADD5MIMK.js.map → chunk-FESQS4S5.js.map} +1 -1
- package/dist/{chunk-U5UNPBKB.js → chunk-FI6JAD5G.js} +3 -3
- package/dist/{chunk-TKWR5AAY.js → chunk-JOULSXOI.js} +2 -2
- package/dist/{chunk-HTJ2FQW5.js → chunk-LF3V3ERS.js} +13 -15
- package/dist/{chunk-HTJ2FQW5.js.map → chunk-LF3V3ERS.js.map} +1 -1
- package/dist/{chunk-5BLKZUKM.js → chunk-MREERKQU.js} +45 -14
- package/dist/chunk-MREERKQU.js.map +1 -0
- package/dist/{chunk-VGEMLNNM.js → chunk-NP34C3O3.js} +306 -704
- package/dist/chunk-NP34C3O3.js.map +1 -0
- package/dist/{chunk-CNIGRBRE.js → chunk-QJZUIAHA.js} +43 -19
- package/dist/{chunk-CNIGRBRE.js.map → chunk-QJZUIAHA.js.map} +1 -1
- package/dist/{chunk-HAWJTZCK.js → chunk-RT4O5H2E.js} +5 -7
- package/dist/chunk-RT4O5H2E.js.map +1 -0
- package/dist/{chunk-2NVSXZKQ.js → chunk-TN7QINPK.js} +74 -309
- package/dist/chunk-TN7QINPK.js.map +1 -0
- package/dist/chunk-UBHORKBS.js +215 -0
- package/dist/chunk-UBHORKBS.js.map +1 -0
- package/dist/{chunk-WVF7RUW5.js → chunk-WM25QE7E.js} +3 -3
- package/dist/{chunk-H6365JPC.js → chunk-YUX6RGLZ.js} +3 -3
- package/dist/{chunk-H6365JPC.js.map → chunk-YUX6RGLZ.js.map} +1 -1
- package/dist/{chunk-H3LNH2NT.js → chunk-Z456IHCB.js} +5 -9
- package/dist/{chunk-H3LNH2NT.js.map → chunk-Z456IHCB.js.map} +1 -1
- package/dist/{chunk-JAATANS3.js → chunk-ZCOFRJQD.js} +3 -3
- package/dist/{chunk-JAATANS3.js.map → chunk-ZCOFRJQD.js.map} +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +2 -2
- package/dist/core/index.d.ts +54 -31
- package/dist/{executor-Br27YZvl.d.ts → executor-YJw4m7Q7.d.ts} +9 -1
- package/dist/gen/index.js +1 -1
- package/dist/hooks/index.d.ts +3 -22
- package/dist/hooks/index.js +12 -9
- package/dist/{index-CYFdO0iB.d.ts → index-lveh8qb0.d.ts} +1 -1
- package/dist/index.d.ts +38 -10
- package/dist/index.js +57 -36
- package/dist/index.native.d.ts +19 -13
- package/dist/index.native.js +64 -35
- package/dist/index.web.d.ts +18 -45
- package/dist/index.web.js +58 -49
- package/dist/index.web.js.map +1 -1
- package/dist/mutation/index.d.ts +2 -2
- package/dist/mutation/index.js +5 -5
- package/dist/parser/index.js +4 -4
- package/dist/powersync-bridge/index.d.ts +18 -3
- package/dist/powersync-bridge/index.js +2 -2
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +7 -8
- package/dist/realtime/index.js +7 -9
- package/dist/realtime/index.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +6 -7
- package/dist/{useBatchUpsert-9OYjibLh.d.ts → useBatchUpsert-DAkiCNo3.d.ts} +1 -1
- package/dist/{useDbCount-Dk0yCKlT.d.ts → useDbCount-DWfYB2iu.d.ts} +16 -2
- package/dist/{useResolveFeedback-C1KucfdQ.d.ts → useResolveFeedback-CxLccZKK.d.ts} +197 -93
- package/dist/{useSupabase-DvWVuHHE.d.ts → useSupabase-DSZNeXnF.d.ts} +1 -1
- package/dist/with-auth/index.d.ts +2 -2
- package/dist/with-auth/index.js +46 -33
- package/dist/with-auth/index.js.map +1 -1
- package/package.json +18 -8
- package/dist/UserMetadataContext-DntmpK41.d.ts +0 -33
- package/dist/canvas-C4TBBDUL.node +0 -0
- package/dist/canvas-ZQNCL7JL.js +0 -1541
- package/dist/canvas-ZQNCL7JL.js.map +0 -1
- package/dist/chunk-2NVSXZKQ.js.map +0 -1
- package/dist/chunk-5BLKZUKM.js.map +0 -1
- package/dist/chunk-5EFDS7SR.js.map +0 -1
- package/dist/chunk-HAWJTZCK.js.map +0 -1
- package/dist/chunk-NSIAAYW3.js +0 -1
- package/dist/chunk-O7SETNGD.js +0 -3391
- package/dist/chunk-O7SETNGD.js.map +0 -1
- package/dist/chunk-OQ7U6EQ3.js.map +0 -1
- package/dist/chunk-VGEMLNNM.js.map +0 -1
- package/dist/chunk-WX4ABYIF.js.map +0 -1
- package/dist/dist-NDNRSNOG.js +0 -521
- package/dist/dist-NDNRSNOG.js.map +0 -1
- package/dist/pdf-PHXP7RHD.js +0 -20336
- package/dist/pdf-PHXP7RHD.js.map +0 -1
- /package/dist/{chunk-NSIAAYW3.js.map → chunk-6KN7KLEG.js.map} +0 -0
- /package/dist/{chunk-P4UZ7IXC.js.map → chunk-7D4SUZUM.js.map} +0 -0
- /package/dist/{chunk-3PJTNH2L.js.map → chunk-AKIRHA4Q.js.map} +0 -0
- /package/dist/{chunk-U5UNPBKB.js.map → chunk-FI6JAD5G.js.map} +0 -0
- /package/dist/{chunk-TKWR5AAY.js.map → chunk-JOULSXOI.js.map} +0 -0
- /package/dist/{chunk-WVF7RUW5.js.map → chunk-WM25QE7E.js.map} +0 -0
|
@@ -1,215 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataLayerCoreContext,
|
|
3
|
+
DataLayerStatusContext,
|
|
4
|
+
devLog,
|
|
5
|
+
devWarn,
|
|
6
|
+
useDataLayerCore,
|
|
7
|
+
useDataLayerStatus,
|
|
8
|
+
useDbQuery
|
|
9
|
+
} from "./chunk-UBHORKBS.js";
|
|
1
10
|
import {
|
|
2
11
|
getSupabaseUrl
|
|
3
12
|
} from "./chunk-GC3TBUWE.js";
|
|
4
|
-
import {
|
|
5
|
-
omit
|
|
6
|
-
} from "./chunk-OQ7U6EQ3.js";
|
|
7
13
|
import {
|
|
8
14
|
useSupabase
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
__require
|
|
12
|
-
} from "./chunk-P4UZ7IXC.js";
|
|
13
|
-
|
|
14
|
-
// src/hooks/useDataLayer.ts
|
|
15
|
-
import { useContext } from "react";
|
|
16
|
-
|
|
17
|
-
// src/providers/DataLayerContext.ts
|
|
18
|
-
import { createContext } from "react";
|
|
19
|
-
var DataLayerCoreContext = createContext(null);
|
|
20
|
-
DataLayerCoreContext.displayName = "DataLayerCoreContext";
|
|
21
|
-
var DataLayerStatusContext = createContext(null);
|
|
22
|
-
DataLayerStatusContext.displayName = "DataLayerStatusContext";
|
|
23
|
-
var DataLayerContext = createContext(null);
|
|
24
|
-
DataLayerContext.displayName = "DataLayerContext";
|
|
25
|
-
|
|
26
|
-
// src/hooks/useDataLayer.ts
|
|
27
|
-
function useDataLayerCore() {
|
|
28
|
-
const context = useContext(DataLayerCoreContext);
|
|
29
|
-
if (!context) {
|
|
30
|
-
throw new Error("useDataLayerCore must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
31
|
-
}
|
|
32
|
-
return context;
|
|
33
|
-
}
|
|
34
|
-
function useDataLayerStatus() {
|
|
35
|
-
const context = useContext(DataLayerStatusContext);
|
|
36
|
-
if (!context) {
|
|
37
|
-
throw new Error("useDataLayerStatus must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
38
|
-
}
|
|
39
|
-
return context;
|
|
40
|
-
}
|
|
41
|
-
function useDataLayer() {
|
|
42
|
-
const context = useContext(DataLayerContext);
|
|
43
|
-
if (!context) {
|
|
44
|
-
throw new Error("useDataLayer must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
45
|
-
}
|
|
46
|
-
return context;
|
|
47
|
-
}
|
|
48
|
-
function useDataLayerOptional() {
|
|
49
|
-
return useContext(DataLayerContext);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/hooks/useDbQuery.ts
|
|
53
|
-
import { useMemo, useEffect, useCallback, useRef } from "react";
|
|
54
|
-
import { useQuery } from "@tanstack/react-query";
|
|
55
|
-
|
|
56
|
-
// src/utils/dev-log.ts
|
|
57
|
-
function devLog(prefix, message) {
|
|
58
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
59
|
-
console.log(`[${prefix}] ${message}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function devWarn(prefix, message) {
|
|
63
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
64
|
-
console.warn(`[${prefix}] ${message}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/hooks/useDbQuery.ts
|
|
69
|
-
function buildQueryKey(table, options) {
|
|
70
|
-
return ["v3", "query", table, options.select ?? "*", JSON.stringify(options.where ?? {}), JSON.stringify(options.orderBy ?? []), options.limit, options.offset];
|
|
71
|
-
}
|
|
72
|
-
function serializeQueryOptions(options) {
|
|
73
|
-
return JSON.stringify({
|
|
74
|
-
select: options.select,
|
|
75
|
-
where: options.where,
|
|
76
|
-
orderBy: options.orderBy,
|
|
77
|
-
limit: options.limit,
|
|
78
|
-
offset: options.offset
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function resolveTableName(table) {
|
|
82
|
-
if (typeof table === "string") {
|
|
83
|
-
return table;
|
|
84
|
-
}
|
|
85
|
-
return `${table.schema}.${table.table}`;
|
|
86
|
-
}
|
|
87
|
-
function useDbQuery(table, options = {}) {
|
|
88
|
-
const tableName = typeof table === "string" ? table : resolveTableName(table);
|
|
89
|
-
const {
|
|
90
|
-
registry,
|
|
91
|
-
queryClient,
|
|
92
|
-
powerSync
|
|
93
|
-
} = useDataLayerCore();
|
|
94
|
-
const isPowerSync = powerSync !== null;
|
|
95
|
-
const {
|
|
96
|
-
enabled = true,
|
|
97
|
-
staleTime = isPowerSync ? 0 : 3e4,
|
|
98
|
-
gcTime = 3e5,
|
|
99
|
-
// 5 minutes - keep in memory for instant display while refetching
|
|
100
|
-
refetchOnWindowFocus = true,
|
|
101
|
-
refetchOnMount = isPowerSync ? "always" : true,
|
|
102
|
-
realtime = isPowerSync,
|
|
103
|
-
// Enable real-time subscriptions by default for PowerSync
|
|
104
|
-
...queryOptions
|
|
105
|
-
} = options;
|
|
106
|
-
const adapter = useMemo(() => {
|
|
107
|
-
try {
|
|
108
|
-
return registry.getAdapter(tableName);
|
|
109
|
-
} catch {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}, [registry, tableName]);
|
|
113
|
-
const serializedOptions = useMemo(() => serializeQueryOptions(options), [options.select, options.where, options.orderBy, options.limit, options.offset]);
|
|
114
|
-
const queryKey = useMemo(() => buildQueryKey(tableName, options), [tableName, serializedOptions]);
|
|
115
|
-
const memoizedQueryOptions = useMemo(() => ({
|
|
116
|
-
select: queryOptions.select,
|
|
117
|
-
where: queryOptions.where,
|
|
118
|
-
orderBy: queryOptions.orderBy,
|
|
119
|
-
limit: queryOptions.limit,
|
|
120
|
-
offset: queryOptions.offset
|
|
121
|
-
}), [serializedOptions]);
|
|
122
|
-
const queryFn = useCallback(async () => {
|
|
123
|
-
if (!adapter) {
|
|
124
|
-
throw new Error(`Adapter not available for table: ${tableName}`);
|
|
125
|
-
}
|
|
126
|
-
const result = await adapter.query(tableName, memoizedQueryOptions);
|
|
127
|
-
return result;
|
|
128
|
-
}, [adapter, tableName, memoizedQueryOptions]);
|
|
129
|
-
const query = useQuery({
|
|
130
|
-
queryKey,
|
|
131
|
-
queryFn,
|
|
132
|
-
enabled: enabled && adapter !== null,
|
|
133
|
-
staleTime,
|
|
134
|
-
gcTime,
|
|
135
|
-
refetchOnWindowFocus,
|
|
136
|
-
refetchOnMount
|
|
137
|
-
});
|
|
138
|
-
const invalidateTimeoutRef = useRef(null);
|
|
139
|
-
const debouncedInvalidate = useCallback(() => {
|
|
140
|
-
if (invalidateTimeoutRef.current) {
|
|
141
|
-
clearTimeout(invalidateTimeoutRef.current);
|
|
142
|
-
}
|
|
143
|
-
invalidateTimeoutRef.current = setTimeout(() => {
|
|
144
|
-
queryClient.invalidateQueries({
|
|
145
|
-
queryKey
|
|
146
|
-
});
|
|
147
|
-
}, 100);
|
|
148
|
-
}, [queryClient, queryKey]);
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
return () => {
|
|
151
|
-
if (invalidateTimeoutRef.current) {
|
|
152
|
-
clearTimeout(invalidateTimeoutRef.current);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}, []);
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (!realtime || !adapter?.subscribe) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
let isFirstCallback = true;
|
|
161
|
-
const unsubscribe = adapter.subscribe(tableName, memoizedQueryOptions, (data) => {
|
|
162
|
-
if (isFirstCallback) {
|
|
163
|
-
isFirstCallback = false;
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const hasRelations = memoizedQueryOptions.select?.includes("(");
|
|
167
|
-
if (hasRelations) {
|
|
168
|
-
debouncedInvalidate();
|
|
169
|
-
} else {
|
|
170
|
-
queryClient.setQueryData(queryKey, {
|
|
171
|
-
data,
|
|
172
|
-
count: data.length
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
return () => {
|
|
177
|
-
unsubscribe();
|
|
178
|
-
};
|
|
179
|
-
}, [realtime, adapter, tableName, memoizedQueryOptions, queryClient, queryKey, debouncedInvalidate]);
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
const adapterName = adapter?.name ?? "unknown";
|
|
182
|
-
if (query.isError && query.error) {
|
|
183
|
-
devWarn("useDbQuery", `${tableName} via ${adapterName}: Error - ${query.error.message}`);
|
|
184
|
-
}
|
|
185
|
-
if (query.isSuccess && query.data?.data?.length === 0) {
|
|
186
|
-
devLog("useDbQuery", `${tableName} via ${adapterName}: 0 results`);
|
|
187
|
-
}
|
|
188
|
-
}, [query.isError, query.error, query.isSuccess, query.data, tableName, adapter]);
|
|
189
|
-
const refetch = useCallback(async () => {
|
|
190
|
-
await query.refetch();
|
|
191
|
-
}, [query]);
|
|
192
|
-
return {
|
|
193
|
-
data: query.data?.data,
|
|
194
|
-
isLoading: query.isLoading,
|
|
195
|
-
isPending: query.isPending,
|
|
196
|
-
isFetching: query.isFetching,
|
|
197
|
-
isRefetching: query.isFetching,
|
|
198
|
-
// Alias for V2 compatibility
|
|
199
|
-
isSuccess: query.isSuccess,
|
|
200
|
-
isError: query.isError,
|
|
201
|
-
error: query.error,
|
|
202
|
-
refetch,
|
|
203
|
-
count: query.data?.count,
|
|
204
|
-
isStale: query.isStale,
|
|
205
|
-
dataUpdatedAt: query.dataUpdatedAt ?? null
|
|
206
|
-
};
|
|
207
|
-
}
|
|
15
|
+
} from "./chunk-DMVUEJG2.js";
|
|
208
16
|
|
|
209
17
|
// src/hooks/useDbQueryById.ts
|
|
210
|
-
import { useCallback
|
|
211
|
-
import { useQuery
|
|
212
|
-
function
|
|
18
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
19
|
+
import { useQuery } from "@tanstack/react-query";
|
|
20
|
+
function buildQueryKey(table, id, select) {
|
|
213
21
|
return ["v3", "queryById", table, id, select ?? "*"];
|
|
214
22
|
}
|
|
215
23
|
function useDbQueryById(table, id, options = {}) {
|
|
@@ -221,15 +29,15 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
221
29
|
enabled = id != null,
|
|
222
30
|
staleTime = 3e4
|
|
223
31
|
} = options;
|
|
224
|
-
const adapter =
|
|
32
|
+
const adapter = useMemo(() => {
|
|
225
33
|
try {
|
|
226
34
|
return registry.getAdapter(table);
|
|
227
35
|
} catch {
|
|
228
36
|
return null;
|
|
229
37
|
}
|
|
230
38
|
}, [registry, table]);
|
|
231
|
-
const queryKey =
|
|
232
|
-
const queryFn =
|
|
39
|
+
const queryKey = useMemo(() => buildQueryKey(table, id, select), [table, id, select]);
|
|
40
|
+
const queryFn = useCallback(async () => {
|
|
233
41
|
if (!adapter) {
|
|
234
42
|
throw new Error(`Adapter not available for table: ${table}`);
|
|
235
43
|
}
|
|
@@ -250,13 +58,13 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
250
58
|
});
|
|
251
59
|
return result.data[0] ?? null;
|
|
252
60
|
}, [adapter, table, id, select]);
|
|
253
|
-
const query =
|
|
61
|
+
const query = useQuery({
|
|
254
62
|
queryKey,
|
|
255
63
|
queryFn,
|
|
256
64
|
enabled: enabled && adapter !== null && id != null,
|
|
257
65
|
staleTime
|
|
258
66
|
});
|
|
259
|
-
|
|
67
|
+
useEffect(() => {
|
|
260
68
|
const adapterName = adapter?.name ?? "unknown";
|
|
261
69
|
if (query.isError && query.error) {
|
|
262
70
|
devWarn("useDbQueryById", `${table}(${id}) via ${adapterName}: Error - ${query.error.message}`);
|
|
@@ -265,7 +73,7 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
265
73
|
devLog("useDbQueryById", `${table}(${id}) via ${adapterName}: not found`);
|
|
266
74
|
}
|
|
267
75
|
}, [query.isError, query.error, query.isSuccess, query.data, table, id, adapter]);
|
|
268
|
-
const refetch =
|
|
76
|
+
const refetch = useCallback(async () => {
|
|
269
77
|
await query.refetch();
|
|
270
78
|
}, [query]);
|
|
271
79
|
return {
|
|
@@ -279,9 +87,10 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
279
87
|
}
|
|
280
88
|
|
|
281
89
|
// src/hooks/useAdvanceQuery.ts
|
|
282
|
-
import { useCallback as
|
|
283
|
-
import { useQuery as
|
|
90
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState, useEffect as useEffect2 } from "react";
|
|
91
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
284
92
|
import { useSessionStorageState } from "@pol-studios/hooks/storage";
|
|
93
|
+
import { omit } from "@pol-studios/utils";
|
|
285
94
|
var createDefaultFilterState = () => ({
|
|
286
95
|
id: "root",
|
|
287
96
|
op: "AND",
|
|
@@ -314,7 +123,7 @@ function useAdvanceQuery(table, options) {
|
|
|
314
123
|
} = options;
|
|
315
124
|
const isPowerSync = powerSync !== null;
|
|
316
125
|
const realtimeEnabled = realtime ?? isPowerSync;
|
|
317
|
-
const defaultFilterState =
|
|
126
|
+
const defaultFilterState = useMemo2(
|
|
318
127
|
() => initialFilters ?? createDefaultFilterState(),
|
|
319
128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
320
129
|
[]
|
|
@@ -322,16 +131,16 @@ function useAdvanceQuery(table, options) {
|
|
|
322
131
|
);
|
|
323
132
|
const [filtersRaw, setFiltersRaw] = useSessionStorageState(filterKey, defaultFilterState);
|
|
324
133
|
const filters = filtersRaw ?? defaultFilterState;
|
|
325
|
-
const setFilters =
|
|
134
|
+
const setFilters = useCallback2((action) => {
|
|
326
135
|
if (typeof action === "function") {
|
|
327
136
|
setFiltersRaw((prev) => action(prev ?? defaultFilterState));
|
|
328
137
|
} else {
|
|
329
138
|
setFiltersRaw(action);
|
|
330
139
|
}
|
|
331
140
|
}, [setFiltersRaw, defaultFilterState]);
|
|
332
|
-
const hasAdvancedFilters =
|
|
141
|
+
const hasAdvancedFilters = useMemo2(() => (filters?.filters?.length ?? 0) > 0 || !!filters?.naturalLanguageQuery, [filters?.filters?.length, filters?.naturalLanguageQuery]);
|
|
333
142
|
const usePowerSyncPath = !hasAdvancedFilters;
|
|
334
|
-
const powerSyncOrderBy =
|
|
143
|
+
const powerSyncOrderBy = useMemo2(() => {
|
|
335
144
|
if (filters?.sort && filters.sort.length > 0) {
|
|
336
145
|
return filters.sort.map((s) => ({
|
|
337
146
|
field: s.field,
|
|
@@ -351,8 +160,8 @@ function useAdvanceQuery(table, options) {
|
|
|
351
160
|
// Enable watch() subscriptions for reactive updates
|
|
352
161
|
});
|
|
353
162
|
const [extraData, setExtraData] = useState({});
|
|
354
|
-
const edgeFunctionQueryKey =
|
|
355
|
-
const edgeFunctionResult =
|
|
163
|
+
const edgeFunctionQueryKey = useMemo2(() => ["v3", "advance-query", tableName, select, JSON.stringify(where), JSON.stringify(filters)], [tableName, select, where, filters]);
|
|
164
|
+
const edgeFunctionResult = useQuery2({
|
|
356
165
|
queryKey: edgeFunctionQueryKey,
|
|
357
166
|
queryFn: async ({
|
|
358
167
|
signal
|
|
@@ -457,7 +266,7 @@ function useAdvanceQuery(table, options) {
|
|
|
457
266
|
refetchOnMount: true,
|
|
458
267
|
refetchOnWindowFocus: false
|
|
459
268
|
});
|
|
460
|
-
|
|
269
|
+
useEffect2(() => {
|
|
461
270
|
if (!realtimeEnabled || usePowerSyncPath || !enabled) {
|
|
462
271
|
return;
|
|
463
272
|
}
|
|
@@ -477,7 +286,7 @@ function useAdvanceQuery(table, options) {
|
|
|
477
286
|
supabase.removeChannel(channel);
|
|
478
287
|
};
|
|
479
288
|
}, [realtimeEnabled, usePowerSyncPath, enabled, supabase, tableName, filterKey, queryClient, edgeFunctionQueryKey]);
|
|
480
|
-
|
|
289
|
+
useEffect2(() => {
|
|
481
290
|
if (usePowerSyncPath) return;
|
|
482
291
|
const pathName = "EdgeFunction";
|
|
483
292
|
if (edgeFunctionResult.isError && edgeFunctionResult.error) {
|
|
@@ -487,7 +296,7 @@ function useAdvanceQuery(table, options) {
|
|
|
487
296
|
devLog("useAdvanceQuery", `${tableName} via ${pathName}: 0 results`);
|
|
488
297
|
}
|
|
489
298
|
}, [usePowerSyncPath, edgeFunctionResult.isError, edgeFunctionResult.error, edgeFunctionResult.isSuccess, edgeFunctionResult.data, tableName]);
|
|
490
|
-
const result =
|
|
299
|
+
const result = useMemo2(() => {
|
|
491
300
|
if (usePowerSyncPath) {
|
|
492
301
|
return {
|
|
493
302
|
data: powerSyncResult.data,
|
|
@@ -525,7 +334,7 @@ function useAdvanceQuery(table, options) {
|
|
|
525
334
|
import { c as _c } from "react/compiler-runtime";
|
|
526
335
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
527
336
|
function useDbInsert(table, t0) {
|
|
528
|
-
const $ = _c(
|
|
337
|
+
const $ = _c(25);
|
|
529
338
|
let t1;
|
|
530
339
|
if ($[0] !== t0) {
|
|
531
340
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -555,39 +364,21 @@ function useDbInsert(table, t0) {
|
|
|
555
364
|
}
|
|
556
365
|
const invalidateTables = t3;
|
|
557
366
|
let t4;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
$[5] = registry;
|
|
563
|
-
$[6] = table;
|
|
564
|
-
$[7] = t52;
|
|
565
|
-
} else {
|
|
566
|
-
t52 = $[7];
|
|
567
|
-
}
|
|
568
|
-
t4 = t52;
|
|
569
|
-
} catch {
|
|
570
|
-
t4 = null;
|
|
571
|
-
}
|
|
572
|
-
const adapter = t4;
|
|
573
|
-
let t5;
|
|
574
|
-
if ($[8] !== adapter || $[9] !== table) {
|
|
575
|
-
t5 = async (data) => {
|
|
576
|
-
if (!adapter) {
|
|
577
|
-
throw new Error(`Adapter not available for table: ${table}`);
|
|
578
|
-
}
|
|
579
|
-
return adapter.insert(table, data);
|
|
367
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
368
|
+
t4 = async (data) => {
|
|
369
|
+
const adapter = registry.getAdapter(table, "write");
|
|
370
|
+
return await adapter.insert(table, data);
|
|
580
371
|
};
|
|
581
|
-
$[
|
|
582
|
-
$[
|
|
583
|
-
$[
|
|
372
|
+
$[5] = registry;
|
|
373
|
+
$[6] = table;
|
|
374
|
+
$[7] = t4;
|
|
584
375
|
} else {
|
|
585
|
-
|
|
376
|
+
t4 = $[7];
|
|
586
377
|
}
|
|
587
|
-
const mutationFn =
|
|
588
|
-
let
|
|
589
|
-
if ($[
|
|
590
|
-
|
|
378
|
+
const mutationFn = t4;
|
|
379
|
+
let t5;
|
|
380
|
+
if ($[8] !== invalidateTables || $[9] !== onSuccess || $[10] !== queryClient) {
|
|
381
|
+
t5 = (data_0) => {
|
|
591
382
|
invalidateTables.forEach((t) => {
|
|
592
383
|
queryClient.invalidateQueries({
|
|
593
384
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === t
|
|
@@ -595,67 +386,67 @@ function useDbInsert(table, t0) {
|
|
|
595
386
|
});
|
|
596
387
|
onSuccess?.(data_0);
|
|
597
388
|
};
|
|
598
|
-
$[
|
|
599
|
-
$[
|
|
600
|
-
$[
|
|
601
|
-
$[
|
|
389
|
+
$[8] = invalidateTables;
|
|
390
|
+
$[9] = onSuccess;
|
|
391
|
+
$[10] = queryClient;
|
|
392
|
+
$[11] = t5;
|
|
602
393
|
} else {
|
|
603
|
-
|
|
394
|
+
t5 = $[11];
|
|
604
395
|
}
|
|
605
|
-
let
|
|
606
|
-
if ($[
|
|
607
|
-
|
|
396
|
+
let t6;
|
|
397
|
+
if ($[12] !== onError) {
|
|
398
|
+
t6 = (error) => {
|
|
608
399
|
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
609
400
|
};
|
|
610
|
-
$[
|
|
611
|
-
$[
|
|
401
|
+
$[12] = onError;
|
|
402
|
+
$[13] = t6;
|
|
612
403
|
} else {
|
|
613
|
-
|
|
404
|
+
t6 = $[13];
|
|
614
405
|
}
|
|
615
|
-
let
|
|
616
|
-
if ($[
|
|
617
|
-
|
|
406
|
+
let t7;
|
|
407
|
+
if ($[14] !== mutationFn || $[15] !== t5 || $[16] !== t6) {
|
|
408
|
+
t7 = {
|
|
618
409
|
mutationFn,
|
|
619
|
-
onSuccess:
|
|
620
|
-
onError:
|
|
410
|
+
onSuccess: t5,
|
|
411
|
+
onError: t6
|
|
621
412
|
};
|
|
622
|
-
$[
|
|
623
|
-
$[
|
|
624
|
-
$[
|
|
625
|
-
$[
|
|
413
|
+
$[14] = mutationFn;
|
|
414
|
+
$[15] = t5;
|
|
415
|
+
$[16] = t6;
|
|
416
|
+
$[17] = t7;
|
|
626
417
|
} else {
|
|
627
|
-
|
|
418
|
+
t7 = $[17];
|
|
628
419
|
}
|
|
629
|
-
const mutation = useMutation(
|
|
630
|
-
const
|
|
631
|
-
let
|
|
632
|
-
if ($[
|
|
633
|
-
|
|
420
|
+
const mutation = useMutation(t7);
|
|
421
|
+
const t8 = mutation.error;
|
|
422
|
+
let t9;
|
|
423
|
+
if ($[18] !== mutation.data || $[19] !== mutation.isPending || $[20] !== mutation.mutate || $[21] !== mutation.mutateAsync || $[22] !== mutation.reset || $[23] !== t8) {
|
|
424
|
+
t9 = {
|
|
634
425
|
mutate: mutation.mutate,
|
|
635
426
|
mutateAsync: mutation.mutateAsync,
|
|
636
427
|
isPending: mutation.isPending,
|
|
637
|
-
error:
|
|
428
|
+
error: t8,
|
|
638
429
|
reset: mutation.reset,
|
|
639
430
|
data: mutation.data
|
|
640
431
|
};
|
|
641
|
-
$[
|
|
642
|
-
$[
|
|
643
|
-
$[
|
|
644
|
-
$[
|
|
645
|
-
$[
|
|
646
|
-
$[
|
|
647
|
-
$[
|
|
432
|
+
$[18] = mutation.data;
|
|
433
|
+
$[19] = mutation.isPending;
|
|
434
|
+
$[20] = mutation.mutate;
|
|
435
|
+
$[21] = mutation.mutateAsync;
|
|
436
|
+
$[22] = mutation.reset;
|
|
437
|
+
$[23] = t8;
|
|
438
|
+
$[24] = t9;
|
|
648
439
|
} else {
|
|
649
|
-
|
|
440
|
+
t9 = $[24];
|
|
650
441
|
}
|
|
651
|
-
return
|
|
442
|
+
return t9;
|
|
652
443
|
}
|
|
653
444
|
|
|
654
445
|
// src/hooks/useDbUpdate.ts
|
|
655
446
|
import { c as _c2 } from "react/compiler-runtime";
|
|
656
447
|
import { useMutation as useMutation2, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
657
448
|
function useDbUpdate(table, t0) {
|
|
658
|
-
const $ = _c2(
|
|
449
|
+
const $ = _c2(32);
|
|
659
450
|
let t1;
|
|
660
451
|
if ($[0] !== t0) {
|
|
661
452
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -687,39 +478,21 @@ function useDbUpdate(table, t0) {
|
|
|
687
478
|
const invalidateTables = t4;
|
|
688
479
|
const optimistic = t3 === void 0 ? false : t3;
|
|
689
480
|
let t5;
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
$[5] = registry;
|
|
695
|
-
$[6] = table;
|
|
696
|
-
$[7] = t62;
|
|
697
|
-
} else {
|
|
698
|
-
t62 = $[7];
|
|
699
|
-
}
|
|
700
|
-
t5 = t62;
|
|
701
|
-
} catch {
|
|
702
|
-
t5 = null;
|
|
703
|
-
}
|
|
704
|
-
const adapter = t5;
|
|
705
|
-
let t6;
|
|
706
|
-
if ($[8] !== adapter || $[9] !== table) {
|
|
707
|
-
t6 = async (params) => {
|
|
708
|
-
if (!adapter) {
|
|
709
|
-
throw new Error(`Adapter not available for table: ${table}`);
|
|
710
|
-
}
|
|
711
|
-
return adapter.update(table, params.id, params.data);
|
|
481
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
482
|
+
t5 = async (params) => {
|
|
483
|
+
const adapter = registry.getAdapter(table, "write");
|
|
484
|
+
return await adapter.update(table, params.id, params.data);
|
|
712
485
|
};
|
|
713
|
-
$[
|
|
714
|
-
$[
|
|
715
|
-
$[
|
|
486
|
+
$[5] = registry;
|
|
487
|
+
$[6] = table;
|
|
488
|
+
$[7] = t5;
|
|
716
489
|
} else {
|
|
717
|
-
|
|
490
|
+
t5 = $[7];
|
|
718
491
|
}
|
|
719
|
-
const mutationFn =
|
|
720
|
-
let
|
|
721
|
-
if ($[
|
|
722
|
-
|
|
492
|
+
const mutationFn = t5;
|
|
493
|
+
let t6;
|
|
494
|
+
if ($[8] !== optimistic || $[9] !== queryClient || $[10] !== table) {
|
|
495
|
+
t6 = optimistic ? async () => {
|
|
723
496
|
await queryClient.cancelQueries({
|
|
724
497
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === table
|
|
725
498
|
});
|
|
@@ -730,16 +503,16 @@ function useDbUpdate(table, t0) {
|
|
|
730
503
|
previousData
|
|
731
504
|
};
|
|
732
505
|
} : void 0;
|
|
733
|
-
$[
|
|
734
|
-
$[
|
|
735
|
-
$[
|
|
736
|
-
$[
|
|
506
|
+
$[8] = optimistic;
|
|
507
|
+
$[9] = queryClient;
|
|
508
|
+
$[10] = table;
|
|
509
|
+
$[11] = t6;
|
|
737
510
|
} else {
|
|
738
|
-
|
|
511
|
+
t6 = $[11];
|
|
739
512
|
}
|
|
740
|
-
let
|
|
741
|
-
if ($[
|
|
742
|
-
|
|
513
|
+
let t7;
|
|
514
|
+
if ($[12] !== invalidateTables || $[13] !== onSuccess || $[14] !== queryClient) {
|
|
515
|
+
t7 = (data) => {
|
|
743
516
|
invalidateTables.forEach((t) => {
|
|
744
517
|
queryClient.invalidateQueries({
|
|
745
518
|
predicate: (query_1) => query_1.queryKey[0] === "v3" && query_1.queryKey[2] === t
|
|
@@ -747,77 +520,77 @@ function useDbUpdate(table, t0) {
|
|
|
747
520
|
});
|
|
748
521
|
onSuccess?.(data);
|
|
749
522
|
};
|
|
750
|
-
$[
|
|
751
|
-
$[
|
|
752
|
-
$[
|
|
753
|
-
$[
|
|
523
|
+
$[12] = invalidateTables;
|
|
524
|
+
$[13] = onSuccess;
|
|
525
|
+
$[14] = queryClient;
|
|
526
|
+
$[15] = t7;
|
|
754
527
|
} else {
|
|
755
|
-
|
|
528
|
+
t7 = $[15];
|
|
756
529
|
}
|
|
757
|
-
let
|
|
758
|
-
if ($[
|
|
759
|
-
|
|
530
|
+
let t8;
|
|
531
|
+
if ($[16] !== onError || $[17] !== optimistic || $[18] !== queryClient) {
|
|
532
|
+
t8 = (error, _variables, context) => {
|
|
760
533
|
if (optimistic && context?.previousData) {
|
|
761
|
-
context.previousData.forEach((
|
|
762
|
-
const [queryKey, data_0] =
|
|
534
|
+
context.previousData.forEach((t92) => {
|
|
535
|
+
const [queryKey, data_0] = t92;
|
|
763
536
|
queryClient.setQueryData(queryKey, data_0);
|
|
764
537
|
});
|
|
765
538
|
}
|
|
766
539
|
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
767
540
|
};
|
|
768
|
-
$[
|
|
769
|
-
$[
|
|
770
|
-
$[
|
|
771
|
-
$[
|
|
541
|
+
$[16] = onError;
|
|
542
|
+
$[17] = optimistic;
|
|
543
|
+
$[18] = queryClient;
|
|
544
|
+
$[19] = t8;
|
|
772
545
|
} else {
|
|
773
|
-
|
|
546
|
+
t8 = $[19];
|
|
774
547
|
}
|
|
775
|
-
let
|
|
776
|
-
if ($[
|
|
777
|
-
|
|
548
|
+
let t9;
|
|
549
|
+
if ($[20] !== mutationFn || $[21] !== t6 || $[22] !== t7 || $[23] !== t8) {
|
|
550
|
+
t9 = {
|
|
778
551
|
mutationFn,
|
|
779
|
-
onMutate:
|
|
780
|
-
onSuccess:
|
|
781
|
-
onError:
|
|
552
|
+
onMutate: t6,
|
|
553
|
+
onSuccess: t7,
|
|
554
|
+
onError: t8
|
|
782
555
|
};
|
|
783
|
-
$[
|
|
784
|
-
$[
|
|
785
|
-
$[
|
|
786
|
-
$[
|
|
787
|
-
$[
|
|
556
|
+
$[20] = mutationFn;
|
|
557
|
+
$[21] = t6;
|
|
558
|
+
$[22] = t7;
|
|
559
|
+
$[23] = t8;
|
|
560
|
+
$[24] = t9;
|
|
788
561
|
} else {
|
|
789
|
-
|
|
562
|
+
t9 = $[24];
|
|
790
563
|
}
|
|
791
|
-
const mutation = useMutation2(
|
|
792
|
-
const
|
|
793
|
-
let
|
|
794
|
-
if ($[
|
|
795
|
-
|
|
564
|
+
const mutation = useMutation2(t9);
|
|
565
|
+
const t10 = mutation.error;
|
|
566
|
+
let t11;
|
|
567
|
+
if ($[25] !== mutation.data || $[26] !== mutation.isPending || $[27] !== mutation.mutate || $[28] !== mutation.mutateAsync || $[29] !== mutation.reset || $[30] !== t10) {
|
|
568
|
+
t11 = {
|
|
796
569
|
mutate: mutation.mutate,
|
|
797
570
|
mutateAsync: mutation.mutateAsync,
|
|
798
571
|
isPending: mutation.isPending,
|
|
799
|
-
error:
|
|
572
|
+
error: t10,
|
|
800
573
|
reset: mutation.reset,
|
|
801
574
|
data: mutation.data
|
|
802
575
|
};
|
|
803
|
-
$[
|
|
804
|
-
$[
|
|
805
|
-
$[
|
|
806
|
-
$[
|
|
807
|
-
$[
|
|
808
|
-
$[
|
|
809
|
-
$[
|
|
576
|
+
$[25] = mutation.data;
|
|
577
|
+
$[26] = mutation.isPending;
|
|
578
|
+
$[27] = mutation.mutate;
|
|
579
|
+
$[28] = mutation.mutateAsync;
|
|
580
|
+
$[29] = mutation.reset;
|
|
581
|
+
$[30] = t10;
|
|
582
|
+
$[31] = t11;
|
|
810
583
|
} else {
|
|
811
|
-
|
|
584
|
+
t11 = $[31];
|
|
812
585
|
}
|
|
813
|
-
return
|
|
586
|
+
return t11;
|
|
814
587
|
}
|
|
815
588
|
|
|
816
589
|
// src/hooks/useDbUpsert.ts
|
|
817
590
|
import { c as _c3 } from "react/compiler-runtime";
|
|
818
591
|
import { useMutation as useMutation3, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
819
592
|
function useDbUpsert(table, t0) {
|
|
820
|
-
const $ = _c3(
|
|
593
|
+
const $ = _c3(25);
|
|
821
594
|
let t1;
|
|
822
595
|
if ($[0] !== t0) {
|
|
823
596
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -847,58 +620,21 @@ function useDbUpsert(table, t0) {
|
|
|
847
620
|
}
|
|
848
621
|
const invalidateTables = t3;
|
|
849
622
|
let t4;
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
t62 = registry.getAdapter(table);
|
|
855
|
-
$[5] = registry;
|
|
856
|
-
$[6] = table;
|
|
857
|
-
$[7] = t62;
|
|
858
|
-
} else {
|
|
859
|
-
t62 = $[7];
|
|
860
|
-
}
|
|
861
|
-
t4 = t62;
|
|
862
|
-
} catch (t5) {
|
|
863
|
-
const error = t5;
|
|
864
|
-
if (__DEV__) {
|
|
865
|
-
console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
|
|
866
|
-
}
|
|
867
|
-
t4 = null;
|
|
868
|
-
}
|
|
869
|
-
const adapter = t4;
|
|
870
|
-
let t6;
|
|
871
|
-
if ($[8] !== adapter || $[9] !== table) {
|
|
872
|
-
t6 = async (data) => {
|
|
873
|
-
if (__DEV__) {
|
|
874
|
-
console.log(`[useDbUpsert] mutationFn called for table "${table}":`, {
|
|
875
|
-
adapterName: adapter?.name ?? "null",
|
|
876
|
-
dataKeys: Object.keys(data),
|
|
877
|
-
hasId: "id" in data
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
if (!adapter) {
|
|
881
|
-
throw new Error(`Adapter not available for table: ${table}`);
|
|
882
|
-
}
|
|
883
|
-
const result = await adapter.upsert(table, data);
|
|
884
|
-
if (__DEV__) {
|
|
885
|
-
console.log(`[useDbUpsert] upsert completed for table "${table}":`, {
|
|
886
|
-
adapterName: adapter.name,
|
|
887
|
-
resultId: result?.id ?? "unknown"
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
return result;
|
|
623
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
624
|
+
t4 = async (data) => {
|
|
625
|
+
const adapter = registry.getAdapter(table, "write");
|
|
626
|
+
return await adapter.upsert(table, data);
|
|
891
627
|
};
|
|
892
|
-
$[
|
|
893
|
-
$[
|
|
894
|
-
$[
|
|
628
|
+
$[5] = registry;
|
|
629
|
+
$[6] = table;
|
|
630
|
+
$[7] = t4;
|
|
895
631
|
} else {
|
|
896
|
-
|
|
632
|
+
t4 = $[7];
|
|
897
633
|
}
|
|
898
|
-
const mutationFn =
|
|
899
|
-
let
|
|
900
|
-
if ($[
|
|
901
|
-
|
|
634
|
+
const mutationFn = t4;
|
|
635
|
+
let t5;
|
|
636
|
+
if ($[8] !== invalidateTables || $[9] !== onSuccess || $[10] !== queryClient) {
|
|
637
|
+
t5 = (data_0) => {
|
|
902
638
|
invalidateTables.forEach((t) => {
|
|
903
639
|
queryClient.invalidateQueries({
|
|
904
640
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === t
|
|
@@ -906,67 +642,67 @@ function useDbUpsert(table, t0) {
|
|
|
906
642
|
});
|
|
907
643
|
onSuccess?.(data_0);
|
|
908
644
|
};
|
|
909
|
-
$[
|
|
910
|
-
$[
|
|
911
|
-
$[
|
|
912
|
-
$[
|
|
645
|
+
$[8] = invalidateTables;
|
|
646
|
+
$[9] = onSuccess;
|
|
647
|
+
$[10] = queryClient;
|
|
648
|
+
$[11] = t5;
|
|
913
649
|
} else {
|
|
914
|
-
|
|
650
|
+
t5 = $[11];
|
|
915
651
|
}
|
|
916
|
-
let
|
|
917
|
-
if ($[
|
|
918
|
-
|
|
919
|
-
onError?.(
|
|
652
|
+
let t6;
|
|
653
|
+
if ($[12] !== onError) {
|
|
654
|
+
t6 = (error) => {
|
|
655
|
+
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
920
656
|
};
|
|
921
|
-
$[
|
|
922
|
-
$[
|
|
657
|
+
$[12] = onError;
|
|
658
|
+
$[13] = t6;
|
|
923
659
|
} else {
|
|
924
|
-
|
|
660
|
+
t6 = $[13];
|
|
925
661
|
}
|
|
926
|
-
let
|
|
927
|
-
if ($[
|
|
928
|
-
|
|
662
|
+
let t7;
|
|
663
|
+
if ($[14] !== mutationFn || $[15] !== t5 || $[16] !== t6) {
|
|
664
|
+
t7 = {
|
|
929
665
|
mutationFn,
|
|
930
|
-
onSuccess:
|
|
931
|
-
onError:
|
|
666
|
+
onSuccess: t5,
|
|
667
|
+
onError: t6
|
|
932
668
|
};
|
|
933
|
-
$[
|
|
934
|
-
$[
|
|
935
|
-
$[
|
|
936
|
-
$[
|
|
669
|
+
$[14] = mutationFn;
|
|
670
|
+
$[15] = t5;
|
|
671
|
+
$[16] = t6;
|
|
672
|
+
$[17] = t7;
|
|
937
673
|
} else {
|
|
938
|
-
|
|
674
|
+
t7 = $[17];
|
|
939
675
|
}
|
|
940
|
-
const mutation = useMutation3(
|
|
941
|
-
const
|
|
942
|
-
let
|
|
943
|
-
if ($[
|
|
944
|
-
|
|
676
|
+
const mutation = useMutation3(t7);
|
|
677
|
+
const t8 = mutation.error;
|
|
678
|
+
let t9;
|
|
679
|
+
if ($[18] !== mutation.data || $[19] !== mutation.isPending || $[20] !== mutation.mutate || $[21] !== mutation.mutateAsync || $[22] !== mutation.reset || $[23] !== t8) {
|
|
680
|
+
t9 = {
|
|
945
681
|
mutate: mutation.mutate,
|
|
946
682
|
mutateAsync: mutation.mutateAsync,
|
|
947
683
|
isPending: mutation.isPending,
|
|
948
|
-
error:
|
|
684
|
+
error: t8,
|
|
949
685
|
reset: mutation.reset,
|
|
950
686
|
data: mutation.data
|
|
951
687
|
};
|
|
952
|
-
$[
|
|
953
|
-
$[
|
|
954
|
-
$[
|
|
955
|
-
$[
|
|
956
|
-
$[
|
|
957
|
-
$[
|
|
958
|
-
$[
|
|
688
|
+
$[18] = mutation.data;
|
|
689
|
+
$[19] = mutation.isPending;
|
|
690
|
+
$[20] = mutation.mutate;
|
|
691
|
+
$[21] = mutation.mutateAsync;
|
|
692
|
+
$[22] = mutation.reset;
|
|
693
|
+
$[23] = t8;
|
|
694
|
+
$[24] = t9;
|
|
959
695
|
} else {
|
|
960
|
-
|
|
696
|
+
t9 = $[24];
|
|
961
697
|
}
|
|
962
|
-
return
|
|
698
|
+
return t9;
|
|
963
699
|
}
|
|
964
700
|
|
|
965
701
|
// src/hooks/useDbDelete.ts
|
|
966
702
|
import { c as _c4 } from "react/compiler-runtime";
|
|
967
703
|
import { useMutation as useMutation4, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
968
704
|
function useDbDelete(table, t0) {
|
|
969
|
-
const $ = _c4(
|
|
705
|
+
const $ = _c4(31);
|
|
970
706
|
let t1;
|
|
971
707
|
if ($[0] !== t0) {
|
|
972
708
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -998,39 +734,21 @@ function useDbDelete(table, t0) {
|
|
|
998
734
|
const invalidateTables = t4;
|
|
999
735
|
const optimistic = t3 === void 0 ? false : t3;
|
|
1000
736
|
let t5;
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
t62 = registry.getAdapter(table);
|
|
1005
|
-
$[5] = registry;
|
|
1006
|
-
$[6] = table;
|
|
1007
|
-
$[7] = t62;
|
|
1008
|
-
} else {
|
|
1009
|
-
t62 = $[7];
|
|
1010
|
-
}
|
|
1011
|
-
t5 = t62;
|
|
1012
|
-
} catch {
|
|
1013
|
-
t5 = null;
|
|
1014
|
-
}
|
|
1015
|
-
const adapter = t5;
|
|
1016
|
-
let t6;
|
|
1017
|
-
if ($[8] !== adapter || $[9] !== table) {
|
|
1018
|
-
t6 = async (id) => {
|
|
1019
|
-
if (!adapter) {
|
|
1020
|
-
throw new Error(`Adapter not available for table: ${table}`);
|
|
1021
|
-
}
|
|
737
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
738
|
+
t5 = async (id) => {
|
|
739
|
+
const adapter = registry.getAdapter(table, "write");
|
|
1022
740
|
await adapter.delete(table, id);
|
|
1023
741
|
};
|
|
1024
|
-
$[
|
|
1025
|
-
$[
|
|
1026
|
-
$[
|
|
742
|
+
$[5] = registry;
|
|
743
|
+
$[6] = table;
|
|
744
|
+
$[7] = t5;
|
|
1027
745
|
} else {
|
|
1028
|
-
|
|
746
|
+
t5 = $[7];
|
|
1029
747
|
}
|
|
1030
|
-
const mutationFn =
|
|
1031
|
-
let
|
|
1032
|
-
if ($[
|
|
1033
|
-
|
|
748
|
+
const mutationFn = t5;
|
|
749
|
+
let t6;
|
|
750
|
+
if ($[8] !== optimistic || $[9] !== queryClient || $[10] !== table) {
|
|
751
|
+
t6 = optimistic ? async (id_0) => {
|
|
1034
752
|
await queryClient.cancelQueries({
|
|
1035
753
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === table
|
|
1036
754
|
});
|
|
@@ -1052,16 +770,16 @@ function useDbDelete(table, t0) {
|
|
|
1052
770
|
previousData
|
|
1053
771
|
};
|
|
1054
772
|
} : void 0;
|
|
1055
|
-
$[
|
|
1056
|
-
$[
|
|
1057
|
-
$[
|
|
1058
|
-
$[
|
|
773
|
+
$[8] = optimistic;
|
|
774
|
+
$[9] = queryClient;
|
|
775
|
+
$[10] = table;
|
|
776
|
+
$[11] = t6;
|
|
1059
777
|
} else {
|
|
1060
|
-
|
|
778
|
+
t6 = $[11];
|
|
1061
779
|
}
|
|
1062
|
-
let
|
|
1063
|
-
if ($[
|
|
1064
|
-
|
|
780
|
+
let t7;
|
|
781
|
+
if ($[12] !== invalidateTables || $[13] !== onSuccess || $[14] !== queryClient) {
|
|
782
|
+
t7 = () => {
|
|
1065
783
|
invalidateTables.forEach((t) => {
|
|
1066
784
|
queryClient.invalidateQueries({
|
|
1067
785
|
predicate: (query_2) => query_2.queryKey[0] === "v3" && query_2.queryKey[2] === t
|
|
@@ -1069,72 +787,72 @@ function useDbDelete(table, t0) {
|
|
|
1069
787
|
});
|
|
1070
788
|
onSuccess?.();
|
|
1071
789
|
};
|
|
1072
|
-
$[
|
|
1073
|
-
$[
|
|
1074
|
-
$[
|
|
1075
|
-
$[
|
|
790
|
+
$[12] = invalidateTables;
|
|
791
|
+
$[13] = onSuccess;
|
|
792
|
+
$[14] = queryClient;
|
|
793
|
+
$[15] = t7;
|
|
1076
794
|
} else {
|
|
1077
|
-
|
|
795
|
+
t7 = $[15];
|
|
1078
796
|
}
|
|
1079
|
-
let
|
|
1080
|
-
if ($[
|
|
1081
|
-
|
|
797
|
+
let t8;
|
|
798
|
+
if ($[16] !== onError || $[17] !== optimistic || $[18] !== queryClient) {
|
|
799
|
+
t8 = (error, _id, context) => {
|
|
1082
800
|
if (optimistic && context?.previousData) {
|
|
1083
|
-
context.previousData.forEach((
|
|
1084
|
-
const [queryKey, data] =
|
|
801
|
+
context.previousData.forEach((t92) => {
|
|
802
|
+
const [queryKey, data] = t92;
|
|
1085
803
|
queryClient.setQueryData(queryKey, data);
|
|
1086
804
|
});
|
|
1087
805
|
}
|
|
1088
806
|
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
1089
807
|
};
|
|
1090
|
-
$[
|
|
1091
|
-
$[
|
|
1092
|
-
$[
|
|
1093
|
-
$[
|
|
808
|
+
$[16] = onError;
|
|
809
|
+
$[17] = optimistic;
|
|
810
|
+
$[18] = queryClient;
|
|
811
|
+
$[19] = t8;
|
|
1094
812
|
} else {
|
|
1095
|
-
|
|
813
|
+
t8 = $[19];
|
|
1096
814
|
}
|
|
1097
|
-
let
|
|
1098
|
-
if ($[
|
|
1099
|
-
|
|
815
|
+
let t9;
|
|
816
|
+
if ($[20] !== mutationFn || $[21] !== t6 || $[22] !== t7 || $[23] !== t8) {
|
|
817
|
+
t9 = {
|
|
1100
818
|
mutationFn,
|
|
1101
|
-
onMutate:
|
|
1102
|
-
onSuccess:
|
|
1103
|
-
onError:
|
|
819
|
+
onMutate: t6,
|
|
820
|
+
onSuccess: t7,
|
|
821
|
+
onError: t8
|
|
1104
822
|
};
|
|
1105
|
-
$[
|
|
1106
|
-
$[
|
|
1107
|
-
$[
|
|
1108
|
-
$[
|
|
1109
|
-
$[
|
|
823
|
+
$[20] = mutationFn;
|
|
824
|
+
$[21] = t6;
|
|
825
|
+
$[22] = t7;
|
|
826
|
+
$[23] = t8;
|
|
827
|
+
$[24] = t9;
|
|
1110
828
|
} else {
|
|
1111
|
-
|
|
829
|
+
t9 = $[24];
|
|
1112
830
|
}
|
|
1113
|
-
const mutation = useMutation4(
|
|
1114
|
-
const
|
|
1115
|
-
let
|
|
1116
|
-
if ($[
|
|
1117
|
-
|
|
831
|
+
const mutation = useMutation4(t9);
|
|
832
|
+
const t10 = mutation.error;
|
|
833
|
+
let t11;
|
|
834
|
+
if ($[25] !== mutation.isPending || $[26] !== mutation.mutate || $[27] !== mutation.mutateAsync || $[28] !== mutation.reset || $[29] !== t10) {
|
|
835
|
+
t11 = {
|
|
1118
836
|
mutate: mutation.mutate,
|
|
1119
837
|
mutateAsync: mutation.mutateAsync,
|
|
1120
838
|
isPending: mutation.isPending,
|
|
1121
|
-
error:
|
|
839
|
+
error: t10,
|
|
1122
840
|
reset: mutation.reset
|
|
1123
841
|
};
|
|
1124
|
-
$[
|
|
1125
|
-
$[
|
|
1126
|
-
$[
|
|
1127
|
-
$[
|
|
1128
|
-
$[
|
|
1129
|
-
$[
|
|
842
|
+
$[25] = mutation.isPending;
|
|
843
|
+
$[26] = mutation.mutate;
|
|
844
|
+
$[27] = mutation.mutateAsync;
|
|
845
|
+
$[28] = mutation.reset;
|
|
846
|
+
$[29] = t10;
|
|
847
|
+
$[30] = t11;
|
|
1130
848
|
} else {
|
|
1131
|
-
|
|
849
|
+
t11 = $[30];
|
|
1132
850
|
}
|
|
1133
|
-
return
|
|
851
|
+
return t11;
|
|
1134
852
|
}
|
|
1135
853
|
|
|
1136
854
|
// src/hooks/useDbInfiniteQuery.ts
|
|
1137
|
-
import { useMemo as
|
|
855
|
+
import { useMemo as useMemo3, useCallback as useCallback3, useEffect as useEffect3 } from "react";
|
|
1138
856
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1139
857
|
function buildInfiniteQueryKey(table, options) {
|
|
1140
858
|
return ["v3", "infinite-query", table, options.select ?? "*", JSON.stringify(options.where ?? {}), JSON.stringify(options.orderBy ?? []), options.pageSize ?? 50, options.searchText ?? "", JSON.stringify(options.searchFields ?? [])];
|
|
@@ -1149,7 +867,7 @@ function serializeInfiniteQueryOptions(options) {
|
|
|
1149
867
|
searchFields: options.searchFields
|
|
1150
868
|
});
|
|
1151
869
|
}
|
|
1152
|
-
function
|
|
870
|
+
function resolveTableName(table) {
|
|
1153
871
|
if (typeof table === "string") {
|
|
1154
872
|
return table;
|
|
1155
873
|
}
|
|
@@ -1172,7 +890,7 @@ function buildSearchWhereClause(searchText, searchFields, existingWhere) {
|
|
|
1172
890
|
};
|
|
1173
891
|
}
|
|
1174
892
|
function useDbInfiniteQuery(table, options = {}) {
|
|
1175
|
-
const tableName =
|
|
893
|
+
const tableName = resolveTableName(table);
|
|
1176
894
|
const {
|
|
1177
895
|
registry
|
|
1178
896
|
} = useDataLayerCore();
|
|
@@ -1185,22 +903,22 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1185
903
|
searchFields,
|
|
1186
904
|
...queryOptions
|
|
1187
905
|
} = options;
|
|
1188
|
-
const adapter =
|
|
906
|
+
const adapter = useMemo3(() => {
|
|
1189
907
|
try {
|
|
1190
908
|
return registry.getAdapter(tableName);
|
|
1191
909
|
} catch {
|
|
1192
910
|
return null;
|
|
1193
911
|
}
|
|
1194
912
|
}, [registry, tableName]);
|
|
1195
|
-
const serializedOptions =
|
|
1196
|
-
const queryKey =
|
|
1197
|
-
const effectiveWhere =
|
|
913
|
+
const serializedOptions = useMemo3(() => serializeInfiniteQueryOptions(options), [options.select, options.where, options.orderBy, options.pageSize, options.searchText, options.searchFields]);
|
|
914
|
+
const queryKey = useMemo3(() => buildInfiniteQueryKey(tableName, options), [tableName, serializedOptions]);
|
|
915
|
+
const effectiveWhere = useMemo3(() => {
|
|
1198
916
|
if (searchText && searchFields && searchFields.length > 0) {
|
|
1199
917
|
return buildSearchWhereClause(searchText, searchFields, queryOptions.where);
|
|
1200
918
|
}
|
|
1201
919
|
return queryOptions.where;
|
|
1202
920
|
}, [searchText, searchFields, queryOptions.where]);
|
|
1203
|
-
const memoizedQueryOptions =
|
|
921
|
+
const memoizedQueryOptions = useMemo3(() => ({
|
|
1204
922
|
select: queryOptions.select,
|
|
1205
923
|
where: effectiveWhere,
|
|
1206
924
|
orderBy: queryOptions.orderBy
|
|
@@ -1240,23 +958,23 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1240
958
|
staleTime,
|
|
1241
959
|
refetchOnWindowFocus
|
|
1242
960
|
});
|
|
1243
|
-
const flattenedData =
|
|
961
|
+
const flattenedData = useMemo3(() => {
|
|
1244
962
|
if (!infiniteQuery.data?.pages) return void 0;
|
|
1245
963
|
return infiniteQuery.data.pages.flatMap((page_0) => page_0.data);
|
|
1246
964
|
}, [infiniteQuery.data?.pages]);
|
|
1247
|
-
const count =
|
|
965
|
+
const count = useMemo3(() => {
|
|
1248
966
|
if (!infiniteQuery.data?.pages || infiniteQuery.data.pages.length === 0) {
|
|
1249
967
|
return void 0;
|
|
1250
968
|
}
|
|
1251
969
|
return infiniteQuery.data.pages[infiniteQuery.data.pages.length - 1].count;
|
|
1252
970
|
}, [infiniteQuery.data?.pages]);
|
|
1253
|
-
const fetchNextPage =
|
|
971
|
+
const fetchNextPage = useCallback3(async () => {
|
|
1254
972
|
await infiniteQuery.fetchNextPage();
|
|
1255
973
|
}, [infiniteQuery]);
|
|
1256
|
-
const refetch =
|
|
974
|
+
const refetch = useCallback3(async () => {
|
|
1257
975
|
await infiniteQuery.refetch();
|
|
1258
976
|
}, [infiniteQuery]);
|
|
1259
|
-
|
|
977
|
+
useEffect3(() => {
|
|
1260
978
|
const adapterName = adapter?.name ?? "unknown";
|
|
1261
979
|
if (infiniteQuery.isError && infiniteQuery.error) {
|
|
1262
980
|
devWarn("useDbInfiniteQuery", `${tableName} via ${adapterName}: Error - ${infiniteQuery.error.message}`);
|
|
@@ -1281,8 +999,8 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1281
999
|
|
|
1282
1000
|
// src/hooks/useDbCount.ts
|
|
1283
1001
|
import { c as _c5 } from "react/compiler-runtime";
|
|
1284
|
-
import { useEffect as
|
|
1285
|
-
import { useQuery as
|
|
1002
|
+
import { useEffect as useEffect4 } from "react";
|
|
1003
|
+
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
1286
1004
|
function useDbCount(table, t0) {
|
|
1287
1005
|
const $ = _c5(37);
|
|
1288
1006
|
let t1;
|
|
@@ -1375,7 +1093,7 @@ function useDbCount(table, t0) {
|
|
|
1375
1093
|
} else {
|
|
1376
1094
|
t9 = $[18];
|
|
1377
1095
|
}
|
|
1378
|
-
const query =
|
|
1096
|
+
const query = useQuery3(t9);
|
|
1379
1097
|
let t10;
|
|
1380
1098
|
if ($[19] !== adapter?.name || $[20] !== query.error || $[21] !== query.isError || $[22] !== table) {
|
|
1381
1099
|
t10 = () => {
|
|
@@ -1403,7 +1121,7 @@ function useDbCount(table, t0) {
|
|
|
1403
1121
|
} else {
|
|
1404
1122
|
t11 = $[28];
|
|
1405
1123
|
}
|
|
1406
|
-
|
|
1124
|
+
useEffect4(t10, t11);
|
|
1407
1125
|
let t12;
|
|
1408
1126
|
if ($[29] !== query) {
|
|
1409
1127
|
t12 = async () => {
|
|
@@ -1439,7 +1157,7 @@ function useDbCount(table, t0) {
|
|
|
1439
1157
|
|
|
1440
1158
|
// src/hooks/useSyncStatus.ts
|
|
1441
1159
|
import { c as _c6 } from "react/compiler-runtime";
|
|
1442
|
-
import { useState as useState2, useEffect as
|
|
1160
|
+
import { useState as useState2, useEffect as useEffect5, useContext } from "react";
|
|
1443
1161
|
var defaultSyncStatus = {
|
|
1444
1162
|
isConnected: true,
|
|
1445
1163
|
// Supabase-only mode is always "connected" when online
|
|
@@ -1450,8 +1168,8 @@ var defaultSyncStatus = {
|
|
|
1450
1168
|
};
|
|
1451
1169
|
function useSyncStatus() {
|
|
1452
1170
|
const $ = _c6(6);
|
|
1453
|
-
const statusContext =
|
|
1454
|
-
const coreContext =
|
|
1171
|
+
const statusContext = useContext(DataLayerStatusContext);
|
|
1172
|
+
const coreContext = useContext(DataLayerCoreContext);
|
|
1455
1173
|
if (!statusContext || !coreContext) {
|
|
1456
1174
|
throw new Error("useSyncStatus must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
1457
1175
|
}
|
|
@@ -1487,44 +1205,16 @@ function useSyncStatus() {
|
|
|
1487
1205
|
t0 = $[4];
|
|
1488
1206
|
t1 = $[5];
|
|
1489
1207
|
}
|
|
1490
|
-
|
|
1208
|
+
useEffect5(t0, t1);
|
|
1491
1209
|
return currentStatus;
|
|
1492
1210
|
}
|
|
1493
1211
|
|
|
1494
1212
|
// src/hooks/useSyncControl.ts
|
|
1495
1213
|
import { c as _c7 } from "react/compiler-runtime";
|
|
1496
|
-
import { useContext as
|
|
1497
|
-
var failedUploadStore = null;
|
|
1498
|
-
try {
|
|
1499
|
-
const powersyncSync = __require("@pol-studios/powersync/sync");
|
|
1500
|
-
failedUploadStore = powersyncSync.failedUploadStore;
|
|
1501
|
-
} catch {
|
|
1502
|
-
}
|
|
1503
|
-
var failedUploadListeners = /* @__PURE__ */ new Set();
|
|
1504
|
-
var cachedFailedUploads = [];
|
|
1505
|
-
var EMPTY_FAILED_UPLOADS = [];
|
|
1506
|
-
function subscribeToFailedUploads(callback) {
|
|
1507
|
-
failedUploadListeners.add(callback);
|
|
1508
|
-
return () => {
|
|
1509
|
-
failedUploadListeners.delete(callback);
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
function getFailedUploadsSnapshot() {
|
|
1513
|
-
if (!failedUploadStore) {
|
|
1514
|
-
return EMPTY_FAILED_UPLOADS;
|
|
1515
|
-
}
|
|
1516
|
-
const uploads = failedUploadStore.getAll();
|
|
1517
|
-
if (uploads.length !== cachedFailedUploads.length || uploads.some((u, i) => u.id !== cachedFailedUploads[i]?.id)) {
|
|
1518
|
-
cachedFailedUploads = uploads;
|
|
1519
|
-
}
|
|
1520
|
-
return cachedFailedUploads;
|
|
1521
|
-
}
|
|
1522
|
-
function notifyFailedUploadListeners() {
|
|
1523
|
-
failedUploadListeners.forEach((listener) => listener());
|
|
1524
|
-
}
|
|
1214
|
+
import { useContext as useContext2 } from "react";
|
|
1525
1215
|
function useSyncControl() {
|
|
1526
|
-
const $ = _c7(
|
|
1527
|
-
const coreContext =
|
|
1216
|
+
const $ = _c7(1);
|
|
1217
|
+
const coreContext = useContext2(DataLayerCoreContext);
|
|
1528
1218
|
if (!coreContext) {
|
|
1529
1219
|
throw new Error("useSyncControl must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
1530
1220
|
}
|
|
@@ -1533,137 +1223,57 @@ function useSyncControl() {
|
|
|
1533
1223
|
powerSync
|
|
1534
1224
|
} = coreContext;
|
|
1535
1225
|
const isPowerSyncActive = powerSync !== null;
|
|
1536
|
-
const [isAutoRetryPaused, setIsAutoRetryPaused] = useState3(false);
|
|
1537
|
-
const failedUploads = useSyncExternalStore(subscribeToFailedUploads, getFailedUploadsSnapshot, _temp);
|
|
1538
1226
|
let t0;
|
|
1539
|
-
if ($[0]
|
|
1540
|
-
t0 =
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
notifyFailedUploadListeners();
|
|
1551
|
-
await syncControl.triggerSync();
|
|
1227
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1228
|
+
t0 = {
|
|
1229
|
+
triggerSync: _temp,
|
|
1230
|
+
startLiveSync: _temp2,
|
|
1231
|
+
stopLiveSync: _temp3,
|
|
1232
|
+
setScope: _temp4,
|
|
1233
|
+
pauseAutoRetry: _temp5,
|
|
1234
|
+
resumeAutoRetry: _temp6,
|
|
1235
|
+
isAutoRetryPaused: false,
|
|
1236
|
+
addPendingMutation: _temp7,
|
|
1237
|
+
removePendingMutation: _temp8
|
|
1552
1238
|
};
|
|
1553
|
-
$[0] =
|
|
1554
|
-
$[1] = syncControl;
|
|
1555
|
-
$[2] = t0;
|
|
1239
|
+
$[0] = t0;
|
|
1556
1240
|
} else {
|
|
1557
|
-
t0 = $[
|
|
1241
|
+
t0 = $[0];
|
|
1558
1242
|
}
|
|
1559
|
-
const
|
|
1560
|
-
const clearFailedUploads = _temp2;
|
|
1243
|
+
const noOpControls = t0;
|
|
1561
1244
|
let t1;
|
|
1562
|
-
if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1563
|
-
t1 = () => {
|
|
1564
|
-
setIsAutoRetryPaused(true);
|
|
1565
|
-
console.log("[useSyncControl] Auto-retry paused");
|
|
1566
|
-
};
|
|
1567
|
-
$[3] = t1;
|
|
1568
|
-
} else {
|
|
1569
|
-
t1 = $[3];
|
|
1570
|
-
}
|
|
1571
|
-
const pauseAutoRetry = t1;
|
|
1572
|
-
let t2;
|
|
1573
|
-
if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1574
|
-
t2 = () => {
|
|
1575
|
-
setIsAutoRetryPaused(false);
|
|
1576
|
-
console.log("[useSyncControl] Auto-retry resumed");
|
|
1577
|
-
};
|
|
1578
|
-
$[4] = t2;
|
|
1579
|
-
} else {
|
|
1580
|
-
t2 = $[4];
|
|
1581
|
-
}
|
|
1582
|
-
const resumeAutoRetry = t2;
|
|
1583
|
-
let t3;
|
|
1584
|
-
if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1585
|
-
t3 = {
|
|
1586
|
-
triggerSync: _temp3,
|
|
1587
|
-
startLiveSync: _temp4,
|
|
1588
|
-
stopLiveSync: _temp5,
|
|
1589
|
-
setScope: _temp6,
|
|
1590
|
-
retryFailedUploads: _temp7,
|
|
1591
|
-
clearFailedUploads: _temp8,
|
|
1592
|
-
failedUploads: [],
|
|
1593
|
-
pauseAutoRetry: _temp9,
|
|
1594
|
-
resumeAutoRetry: _temp0,
|
|
1595
|
-
isAutoRetryPaused: false
|
|
1596
|
-
};
|
|
1597
|
-
$[5] = t3;
|
|
1598
|
-
} else {
|
|
1599
|
-
t3 = $[5];
|
|
1600
|
-
}
|
|
1601
|
-
const noOpControls = t3;
|
|
1602
|
-
let t4;
|
|
1603
1245
|
bb0: {
|
|
1604
1246
|
if (isPowerSyncActive) {
|
|
1605
|
-
|
|
1606
|
-
if ($[6] !== failedUploads || $[7] !== isAutoRetryPaused || $[8] !== retryFailedUploads || $[9] !== syncControl) {
|
|
1607
|
-
t5 = {
|
|
1608
|
-
...syncControl,
|
|
1609
|
-
retryFailedUploads,
|
|
1610
|
-
clearFailedUploads,
|
|
1611
|
-
failedUploads,
|
|
1612
|
-
pauseAutoRetry,
|
|
1613
|
-
resumeAutoRetry,
|
|
1614
|
-
isAutoRetryPaused
|
|
1615
|
-
};
|
|
1616
|
-
$[6] = failedUploads;
|
|
1617
|
-
$[7] = isAutoRetryPaused;
|
|
1618
|
-
$[8] = retryFailedUploads;
|
|
1619
|
-
$[9] = syncControl;
|
|
1620
|
-
$[10] = t5;
|
|
1621
|
-
} else {
|
|
1622
|
-
t5 = $[10];
|
|
1623
|
-
}
|
|
1624
|
-
t4 = t5;
|
|
1247
|
+
t1 = syncControl;
|
|
1625
1248
|
break bb0;
|
|
1626
1249
|
}
|
|
1627
|
-
|
|
1250
|
+
t1 = noOpControls;
|
|
1628
1251
|
}
|
|
1629
|
-
const controls =
|
|
1252
|
+
const controls = t1;
|
|
1630
1253
|
return controls;
|
|
1631
1254
|
}
|
|
1632
|
-
function
|
|
1633
|
-
console.warn("[useSyncControl] resumeAutoRetry called but PowerSync is not available");
|
|
1255
|
+
function _temp8() {
|
|
1634
1256
|
}
|
|
1635
|
-
function
|
|
1636
|
-
console.warn("[useSyncControl] pauseAutoRetry called but PowerSync is not available");
|
|
1257
|
+
function _temp7() {
|
|
1637
1258
|
}
|
|
1638
|
-
function
|
|
1639
|
-
console.warn("[useSyncControl]
|
|
1259
|
+
function _temp6() {
|
|
1260
|
+
console.warn("[useSyncControl] resumeAutoRetry called but PowerSync is not available");
|
|
1640
1261
|
}
|
|
1641
|
-
|
|
1642
|
-
console.warn("[useSyncControl]
|
|
1262
|
+
function _temp5() {
|
|
1263
|
+
console.warn("[useSyncControl] pauseAutoRetry called but PowerSync is not available");
|
|
1643
1264
|
}
|
|
1644
|
-
async function
|
|
1265
|
+
async function _temp4(_scopeName, _values) {
|
|
1645
1266
|
console.warn("[useSyncControl] setScope called but PowerSync is not available");
|
|
1646
1267
|
}
|
|
1647
|
-
function
|
|
1268
|
+
function _temp3() {
|
|
1648
1269
|
console.warn("[useSyncControl] stopLiveSync called but PowerSync is not available");
|
|
1649
1270
|
}
|
|
1650
|
-
async function
|
|
1271
|
+
async function _temp2() {
|
|
1651
1272
|
console.warn("[useSyncControl] startLiveSync called but PowerSync is not available");
|
|
1652
1273
|
}
|
|
1653
|
-
async function
|
|
1274
|
+
async function _temp() {
|
|
1654
1275
|
console.warn("[useSyncControl] triggerSync called but PowerSync is not available");
|
|
1655
1276
|
}
|
|
1656
|
-
function _temp2() {
|
|
1657
|
-
if (!failedUploadStore) {
|
|
1658
|
-
console.warn("[useSyncControl] clearFailedUploads called but failedUploadStore is not available");
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
failedUploadStore.clear();
|
|
1662
|
-
notifyFailedUploadListeners();
|
|
1663
|
-
}
|
|
1664
|
-
function _temp() {
|
|
1665
|
-
return EMPTY_FAILED_UPLOADS;
|
|
1666
|
-
}
|
|
1667
1277
|
|
|
1668
1278
|
// src/hooks/useOnlineStatus.ts
|
|
1669
1279
|
import { c as _c8 } from "react/compiler-runtime";
|
|
@@ -1694,14 +1304,6 @@ function useOnlineStatus() {
|
|
|
1694
1304
|
}
|
|
1695
1305
|
|
|
1696
1306
|
export {
|
|
1697
|
-
DataLayerCoreContext,
|
|
1698
|
-
DataLayerStatusContext,
|
|
1699
|
-
DataLayerContext,
|
|
1700
|
-
useDataLayerCore,
|
|
1701
|
-
useDataLayerStatus,
|
|
1702
|
-
useDataLayer,
|
|
1703
|
-
useDataLayerOptional,
|
|
1704
|
-
useDbQuery,
|
|
1705
1307
|
useDbQueryById,
|
|
1706
1308
|
useAdvanceQuery,
|
|
1707
1309
|
useDbInsert,
|
|
@@ -1714,4 +1316,4 @@ export {
|
|
|
1714
1316
|
useSyncControl,
|
|
1715
1317
|
useOnlineStatus
|
|
1716
1318
|
};
|
|
1717
|
-
//# sourceMappingURL=chunk-
|
|
1319
|
+
//# sourceMappingURL=chunk-NP34C3O3.js.map
|