@pol-studios/db 1.0.15 → 1.0.17
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/auth/context.js +2 -2
- package/dist/auth/hooks.js +3 -3
- package/dist/auth/index.js +3 -3
- package/dist/{chunk-WLHUPDBI.js → chunk-36DVUMQD.js} +2 -2
- package/dist/{chunk-O4P43BD7.js → chunk-72WV3ALS.js} +2 -2
- package/dist/{chunk-QJQRGM7E.js → chunk-FHVF26YA.js} +3 -3
- package/dist/{chunk-7OQKP7EP.js → chunk-PMRV6WND.js} +13 -3
- package/dist/chunk-PMRV6WND.js.map +1 -0
- package/dist/{chunk-NSVDEHEI.js → chunk-RMRYGICS.js} +4 -4
- package/dist/{chunk-CBLXKHSK.js → chunk-YERWPV6B.js} +151 -70
- package/dist/{chunk-CBLXKHSK.js.map → chunk-YERWPV6B.js.map} +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/index.js +6 -6
- package/dist/index.native.js +6 -6
- package/dist/index.web.js +5 -5
- package/dist/with-auth/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-7OQKP7EP.js.map +0 -1
- /package/dist/{chunk-WLHUPDBI.js.map → chunk-36DVUMQD.js.map} +0 -0
- /package/dist/{chunk-O4P43BD7.js.map → chunk-72WV3ALS.js.map} +0 -0
- /package/dist/{chunk-QJQRGM7E.js.map → chunk-FHVF26YA.js.map} +0 -0
- /package/dist/{chunk-NSVDEHEI.js.map → chunk-RMRYGICS.js.map} +0 -0
|
@@ -774,9 +774,19 @@ function useDbUpdate(table, t0) {
|
|
|
774
774
|
}
|
|
775
775
|
|
|
776
776
|
// src/hooks/useDbUpsert.ts
|
|
777
|
-
import {
|
|
777
|
+
import { c as _c3 } from "react/compiler-runtime";
|
|
778
778
|
import { useMutation as useMutation3, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
779
|
-
function useDbUpsert(table,
|
|
779
|
+
function useDbUpsert(table, t0) {
|
|
780
|
+
const $ = _c3(28);
|
|
781
|
+
let t1;
|
|
782
|
+
if ($[0] !== t0) {
|
|
783
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
784
|
+
$[0] = t0;
|
|
785
|
+
$[1] = t1;
|
|
786
|
+
} else {
|
|
787
|
+
t1 = $[1];
|
|
788
|
+
}
|
|
789
|
+
const options = t1;
|
|
780
790
|
const {
|
|
781
791
|
registry
|
|
782
792
|
} = useDataLayerCore();
|
|
@@ -787,75 +797,146 @@ function useDbUpsert(table, options = {}) {
|
|
|
787
797
|
const {
|
|
788
798
|
onSuccess,
|
|
789
799
|
onError,
|
|
790
|
-
invalidateTables
|
|
800
|
+
invalidateTables: t2
|
|
791
801
|
} = options;
|
|
792
|
-
|
|
793
|
-
|
|
802
|
+
let t3;
|
|
803
|
+
if ($[2] !== t2 || $[3] !== table) {
|
|
804
|
+
t3 = t2 === void 0 ? [table] : t2;
|
|
805
|
+
$[2] = t2;
|
|
806
|
+
$[3] = table;
|
|
807
|
+
$[4] = t3;
|
|
808
|
+
} else {
|
|
809
|
+
t3 = $[4];
|
|
810
|
+
}
|
|
811
|
+
const invalidateTables = t3;
|
|
812
|
+
let t4;
|
|
813
|
+
bb0: {
|
|
814
|
+
if (!status.isInitialized) {
|
|
815
|
+
t4 = null;
|
|
816
|
+
break bb0;
|
|
817
|
+
}
|
|
818
|
+
;
|
|
794
819
|
try {
|
|
795
|
-
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
820
|
+
let t62;
|
|
821
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
822
|
+
t62 = registry.getAdapter(table);
|
|
823
|
+
$[5] = registry;
|
|
824
|
+
$[6] = table;
|
|
825
|
+
$[7] = t62;
|
|
826
|
+
} else {
|
|
827
|
+
t62 = $[7];
|
|
801
828
|
}
|
|
802
|
-
|
|
803
|
-
|
|
829
|
+
const resolvedAdapter = t62;
|
|
830
|
+
t4 = resolvedAdapter;
|
|
831
|
+
} catch (t52) {
|
|
832
|
+
const error = t52;
|
|
804
833
|
if (__DEV__) {
|
|
805
834
|
console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
|
|
806
835
|
}
|
|
807
|
-
|
|
808
|
-
}
|
|
809
|
-
}, [registry, table, status.isInitialized, status.currentBackend]);
|
|
810
|
-
const mutationFn = useCallback4(async (data) => {
|
|
811
|
-
if (__DEV__) {
|
|
812
|
-
console.log(`[useDbUpsert] mutationFn called for table "${table}":`, {
|
|
813
|
-
adapterName: adapter?.name ?? "null",
|
|
814
|
-
dataKeys: Object.keys(data),
|
|
815
|
-
hasId: "id" in data
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
if (!adapter) {
|
|
819
|
-
throw new Error(`Adapter not available for table: ${table}`);
|
|
820
|
-
}
|
|
821
|
-
const result = await adapter.upsert(table, data);
|
|
822
|
-
if (__DEV__) {
|
|
823
|
-
console.log(`[useDbUpsert] upsert completed for table "${table}":`, {
|
|
824
|
-
adapterName: adapter.name,
|
|
825
|
-
resultId: result?.id ?? "unknown"
|
|
826
|
-
});
|
|
836
|
+
t4 = null;
|
|
827
837
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
838
|
+
}
|
|
839
|
+
const adapter = t4;
|
|
840
|
+
let t5;
|
|
841
|
+
if ($[8] !== adapter || $[9] !== table) {
|
|
842
|
+
t5 = async (data) => {
|
|
843
|
+
if (__DEV__) {
|
|
844
|
+
console.log(`[useDbUpsert] mutationFn called for table "${table}":`, {
|
|
845
|
+
adapterName: adapter?.name ?? "null",
|
|
846
|
+
dataKeys: Object.keys(data),
|
|
847
|
+
hasId: "id" in data
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
if (!adapter) {
|
|
851
|
+
throw new Error(`Adapter not available for table: ${table}`);
|
|
852
|
+
}
|
|
853
|
+
const result = await adapter.upsert(table, data);
|
|
854
|
+
if (__DEV__) {
|
|
855
|
+
console.log(`[useDbUpsert] upsert completed for table "${table}":`, {
|
|
856
|
+
adapterName: adapter.name,
|
|
857
|
+
resultId: result?.id ?? "unknown"
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
return result;
|
|
861
|
+
};
|
|
862
|
+
$[8] = adapter;
|
|
863
|
+
$[9] = table;
|
|
864
|
+
$[10] = t5;
|
|
865
|
+
} else {
|
|
866
|
+
t5 = $[10];
|
|
867
|
+
}
|
|
868
|
+
const mutationFn = t5;
|
|
869
|
+
let t6;
|
|
870
|
+
if ($[11] !== invalidateTables || $[12] !== onSuccess || $[13] !== queryClient) {
|
|
871
|
+
t6 = (data_0) => {
|
|
833
872
|
invalidateTables.forEach((t) => {
|
|
834
873
|
queryClient.invalidateQueries({
|
|
835
874
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === t
|
|
836
875
|
});
|
|
837
876
|
});
|
|
838
877
|
onSuccess?.(data_0);
|
|
839
|
-
}
|
|
840
|
-
|
|
878
|
+
};
|
|
879
|
+
$[11] = invalidateTables;
|
|
880
|
+
$[12] = onSuccess;
|
|
881
|
+
$[13] = queryClient;
|
|
882
|
+
$[14] = t6;
|
|
883
|
+
} else {
|
|
884
|
+
t6 = $[14];
|
|
885
|
+
}
|
|
886
|
+
let t7;
|
|
887
|
+
if ($[15] !== onError) {
|
|
888
|
+
t7 = (error_0) => {
|
|
841
889
|
onError?.(error_0 instanceof Error ? error_0 : new Error(String(error_0)));
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
890
|
+
};
|
|
891
|
+
$[15] = onError;
|
|
892
|
+
$[16] = t7;
|
|
893
|
+
} else {
|
|
894
|
+
t7 = $[16];
|
|
895
|
+
}
|
|
896
|
+
let t8;
|
|
897
|
+
if ($[17] !== mutationFn || $[18] !== t6 || $[19] !== t7) {
|
|
898
|
+
t8 = {
|
|
899
|
+
mutationFn,
|
|
900
|
+
onSuccess: t6,
|
|
901
|
+
onError: t7
|
|
902
|
+
};
|
|
903
|
+
$[17] = mutationFn;
|
|
904
|
+
$[18] = t6;
|
|
905
|
+
$[19] = t7;
|
|
906
|
+
$[20] = t8;
|
|
907
|
+
} else {
|
|
908
|
+
t8 = $[20];
|
|
909
|
+
}
|
|
910
|
+
const mutation = useMutation3(t8);
|
|
911
|
+
const t9 = mutation.error;
|
|
912
|
+
let t10;
|
|
913
|
+
if ($[21] !== mutation.data || $[22] !== mutation.isPending || $[23] !== mutation.mutate || $[24] !== mutation.mutateAsync || $[25] !== mutation.reset || $[26] !== t9) {
|
|
914
|
+
t10 = {
|
|
915
|
+
mutate: mutation.mutate,
|
|
916
|
+
mutateAsync: mutation.mutateAsync,
|
|
917
|
+
isPending: mutation.isPending,
|
|
918
|
+
error: t9,
|
|
919
|
+
reset: mutation.reset,
|
|
920
|
+
data: mutation.data
|
|
921
|
+
};
|
|
922
|
+
$[21] = mutation.data;
|
|
923
|
+
$[22] = mutation.isPending;
|
|
924
|
+
$[23] = mutation.mutate;
|
|
925
|
+
$[24] = mutation.mutateAsync;
|
|
926
|
+
$[25] = mutation.reset;
|
|
927
|
+
$[26] = t9;
|
|
928
|
+
$[27] = t10;
|
|
929
|
+
} else {
|
|
930
|
+
t10 = $[27];
|
|
931
|
+
}
|
|
932
|
+
return t10;
|
|
852
933
|
}
|
|
853
934
|
|
|
854
935
|
// src/hooks/useDbDelete.ts
|
|
855
|
-
import { c as
|
|
936
|
+
import { c as _c4 } from "react/compiler-runtime";
|
|
856
937
|
import { useMutation as useMutation4, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
857
938
|
function useDbDelete(table, t0) {
|
|
858
|
-
const $ =
|
|
939
|
+
const $ = _c4(34);
|
|
859
940
|
let t1;
|
|
860
941
|
if ($[0] !== t0) {
|
|
861
942
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -1032,7 +1113,7 @@ function useDbDelete(table, t0) {
|
|
|
1032
1113
|
}
|
|
1033
1114
|
|
|
1034
1115
|
// src/hooks/useDbInfiniteQuery.ts
|
|
1035
|
-
import { useMemo as
|
|
1116
|
+
import { useMemo as useMemo4, useCallback as useCallback4 } from "react";
|
|
1036
1117
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1037
1118
|
function buildInfiniteQueryKey(table, options) {
|
|
1038
1119
|
return ["v3", "infinite-query", table, options.select ?? "*", JSON.stringify(options.where ?? {}), JSON.stringify(options.orderBy ?? []), options.pageSize ?? 50, options.searchText ?? "", JSON.stringify(options.searchFields ?? [])];
|
|
@@ -1086,7 +1167,7 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1086
1167
|
searchFields,
|
|
1087
1168
|
...queryOptions
|
|
1088
1169
|
} = options;
|
|
1089
|
-
const adapter =
|
|
1170
|
+
const adapter = useMemo4(() => {
|
|
1090
1171
|
if (!status.isInitialized) return null;
|
|
1091
1172
|
try {
|
|
1092
1173
|
return registry.getAdapter(tableName);
|
|
@@ -1094,14 +1175,14 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1094
1175
|
return null;
|
|
1095
1176
|
}
|
|
1096
1177
|
}, [registry, tableName, status.isInitialized, status.currentBackend]);
|
|
1097
|
-
const queryKey =
|
|
1098
|
-
const effectiveWhere =
|
|
1178
|
+
const queryKey = useMemo4(() => buildInfiniteQueryKey(tableName, options), [tableName, serializeInfiniteQueryOptions(options)]);
|
|
1179
|
+
const effectiveWhere = useMemo4(() => {
|
|
1099
1180
|
if (searchText && searchFields && searchFields.length > 0) {
|
|
1100
1181
|
return buildSearchWhereClause(searchText, searchFields, queryOptions.where);
|
|
1101
1182
|
}
|
|
1102
1183
|
return queryOptions.where;
|
|
1103
1184
|
}, [searchText, searchFields, queryOptions.where]);
|
|
1104
|
-
const memoizedQueryOptions =
|
|
1185
|
+
const memoizedQueryOptions = useMemo4(() => ({
|
|
1105
1186
|
select: queryOptions.select,
|
|
1106
1187
|
where: effectiveWhere,
|
|
1107
1188
|
orderBy: queryOptions.orderBy
|
|
@@ -1141,20 +1222,20 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1141
1222
|
staleTime,
|
|
1142
1223
|
refetchOnWindowFocus
|
|
1143
1224
|
});
|
|
1144
|
-
const flattenedData =
|
|
1225
|
+
const flattenedData = useMemo4(() => {
|
|
1145
1226
|
if (!infiniteQuery.data?.pages) return void 0;
|
|
1146
1227
|
return infiniteQuery.data.pages.flatMap((page_0) => page_0.data);
|
|
1147
1228
|
}, [infiniteQuery.data?.pages]);
|
|
1148
|
-
const count =
|
|
1229
|
+
const count = useMemo4(() => {
|
|
1149
1230
|
if (!infiniteQuery.data?.pages || infiniteQuery.data.pages.length === 0) {
|
|
1150
1231
|
return void 0;
|
|
1151
1232
|
}
|
|
1152
1233
|
return infiniteQuery.data.pages[infiniteQuery.data.pages.length - 1].count;
|
|
1153
1234
|
}, [infiniteQuery.data?.pages]);
|
|
1154
|
-
const fetchNextPage =
|
|
1235
|
+
const fetchNextPage = useCallback4(async () => {
|
|
1155
1236
|
await infiniteQuery.fetchNextPage();
|
|
1156
1237
|
}, [infiniteQuery]);
|
|
1157
|
-
const refetch =
|
|
1238
|
+
const refetch = useCallback4(async () => {
|
|
1158
1239
|
await infiniteQuery.refetch();
|
|
1159
1240
|
}, [infiniteQuery]);
|
|
1160
1241
|
return {
|
|
@@ -1172,10 +1253,10 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1172
1253
|
}
|
|
1173
1254
|
|
|
1174
1255
|
// src/hooks/useDbCount.ts
|
|
1175
|
-
import { c as
|
|
1256
|
+
import { c as _c5 } from "react/compiler-runtime";
|
|
1176
1257
|
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
1177
1258
|
function useDbCount(table, t0) {
|
|
1178
|
-
const $ =
|
|
1259
|
+
const $ = _c5(27);
|
|
1179
1260
|
let t1;
|
|
1180
1261
|
if ($[0] !== t0) {
|
|
1181
1262
|
t1 = t0 === void 0 ? {} : t0;
|
|
@@ -1310,7 +1391,7 @@ function useDbCount(table, t0) {
|
|
|
1310
1391
|
}
|
|
1311
1392
|
|
|
1312
1393
|
// src/hooks/useSyncStatus.ts
|
|
1313
|
-
import { c as
|
|
1394
|
+
import { c as _c6 } from "react/compiler-runtime";
|
|
1314
1395
|
import { useState as useState2, useEffect as useEffect3, useContext as useContext2 } from "react";
|
|
1315
1396
|
var defaultSyncStatus = {
|
|
1316
1397
|
isConnected: true,
|
|
@@ -1321,7 +1402,7 @@ var defaultSyncStatus = {
|
|
|
1321
1402
|
error: null
|
|
1322
1403
|
};
|
|
1323
1404
|
function useSyncStatus() {
|
|
1324
|
-
const $ =
|
|
1405
|
+
const $ = _c6(6);
|
|
1325
1406
|
const statusContext = useContext2(DataLayerStatusContext);
|
|
1326
1407
|
const coreContext = useContext2(DataLayerCoreContext);
|
|
1327
1408
|
if (!statusContext || !coreContext) {
|
|
@@ -1364,10 +1445,10 @@ function useSyncStatus() {
|
|
|
1364
1445
|
}
|
|
1365
1446
|
|
|
1366
1447
|
// src/hooks/useSyncControl.ts
|
|
1367
|
-
import { c as
|
|
1448
|
+
import { c as _c7 } from "react/compiler-runtime";
|
|
1368
1449
|
import { useContext as useContext3 } from "react";
|
|
1369
1450
|
function useSyncControl() {
|
|
1370
|
-
const $ =
|
|
1451
|
+
const $ = _c7(1);
|
|
1371
1452
|
const statusContext = useContext3(DataLayerStatusContext);
|
|
1372
1453
|
const coreContext = useContext3(DataLayerCoreContext);
|
|
1373
1454
|
if (!statusContext || !coreContext) {
|
|
@@ -1418,9 +1499,9 @@ async function _temp() {
|
|
|
1418
1499
|
}
|
|
1419
1500
|
|
|
1420
1501
|
// src/hooks/useOnlineStatus.ts
|
|
1421
|
-
import { c as
|
|
1502
|
+
import { c as _c8 } from "react/compiler-runtime";
|
|
1422
1503
|
function useOnlineStatus() {
|
|
1423
|
-
const $ =
|
|
1504
|
+
const $ = _c8(4);
|
|
1424
1505
|
const {
|
|
1425
1506
|
powerSync
|
|
1426
1507
|
} = useDataLayerCore();
|
|
@@ -1466,4 +1547,4 @@ export {
|
|
|
1466
1547
|
useSyncControl,
|
|
1467
1548
|
useOnlineStatus
|
|
1468
1549
|
};
|
|
1469
|
-
//# sourceMappingURL=chunk-
|
|
1550
|
+
//# sourceMappingURL=chunk-YERWPV6B.js.map
|