@pol-studios/db 1.0.24 → 1.0.25

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.
@@ -12,8 +12,8 @@ import {
12
12
  useUserMetadataState,
13
13
  useUserMetadataValue,
14
14
  userMetadataContext
15
- } from "../chunk-VZMZXL37.js";
16
- import "../chunk-2DOYFTN4.js";
15
+ } from "../chunk-PZLVL7DU.js";
16
+ import "../chunk-LVUK5USN.js";
17
17
  import "../chunk-GC3TBUWE.js";
18
18
  import "../chunk-J4ZVCXZ4.js";
19
19
  import "../chunk-OQ7U6EQ3.js";
@@ -11,14 +11,14 @@ import {
11
11
  usePermissionLoading,
12
12
  usePermissionsBatch,
13
13
  useSetupAuth
14
- } from "../chunk-VWPLASGY.js";
14
+ } from "../chunk-IZX7ZEUF.js";
15
15
  import {
16
16
  useSetUserMetadata,
17
17
  useUserMetadata,
18
18
  useUserMetadataState,
19
19
  useUserMetadataValue
20
- } from "../chunk-VZMZXL37.js";
21
- import "../chunk-2DOYFTN4.js";
20
+ } from "../chunk-PZLVL7DU.js";
21
+ import "../chunk-LVUK5USN.js";
22
22
  import "../chunk-GC3TBUWE.js";
23
23
  import "../chunk-J4ZVCXZ4.js";
24
24
  import "../chunk-OQ7U6EQ3.js";
@@ -12,7 +12,7 @@ import {
12
12
  usePermissionLoading,
13
13
  usePermissionsBatch,
14
14
  useSetupAuth
15
- } from "../chunk-VWPLASGY.js";
15
+ } from "../chunk-IZX7ZEUF.js";
16
16
  import {
17
17
  AuthProvider,
18
18
  PermissionProvider,
@@ -27,8 +27,8 @@ import {
27
27
  useUserMetadataState,
28
28
  useUserMetadataValue,
29
29
  userMetadataContext
30
- } from "../chunk-VZMZXL37.js";
31
- import "../chunk-2DOYFTN4.js";
30
+ } from "../chunk-PZLVL7DU.js";
31
+ import "../chunk-LVUK5USN.js";
32
32
  import {
33
33
  hasAccess,
34
34
  hasAllAccess,
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-SM73S2DY.js";
4
4
  import {
5
5
  useSetupAuth
6
- } from "./chunk-VWPLASGY.js";
6
+ } from "./chunk-IZX7ZEUF.js";
7
7
  import {
8
8
  useDbQuery
9
- } from "./chunk-VZMZXL37.js";
9
+ } from "./chunk-PZLVL7DU.js";
10
10
  import {
11
11
  useDbUpsert
12
- } from "./chunk-2DOYFTN4.js";
12
+ } from "./chunk-LVUK5USN.js";
13
13
  import {
14
14
  delay,
15
15
  isNullOrWhitespace,
@@ -467,4 +467,4 @@ export {
467
467
  useSetUserMetadata,
468
468
  useUserMetadataState
469
469
  };
470
- //# sourceMappingURL=chunk-LABTYQOJ.js.map
470
+ //# sourceMappingURL=chunk-DJWC43OA.js.map
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-7SCJNYTE.js";
7
7
  import {
8
8
  useDbQuery
9
- } from "./chunk-VZMZXL37.js";
9
+ } from "./chunk-PZLVL7DU.js";
10
10
  import {
11
11
  useDbUpsert
12
- } from "./chunk-2DOYFTN4.js";
12
+ } from "./chunk-LVUK5USN.js";
13
13
  import {
14
14
  getSupabaseUrl
15
15
  } from "./chunk-GC3TBUWE.js";
@@ -3388,4 +3388,4 @@ export {
3388
3388
  useApplyFeedback,
3389
3389
  useResolveFeedback
3390
3390
  };
3391
- //# sourceMappingURL=chunk-7OLNKLII.js.map
3391
+ //# sourceMappingURL=chunk-GXMSZ5S6.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  permissionContext,
3
3
  setupAuthContext
4
- } from "./chunk-VZMZXL37.js";
4
+ } from "./chunk-PZLVL7DU.js";
5
5
  import {
6
6
  isUsable
7
7
  } from "./chunk-OQ7U6EQ3.js";
@@ -244,4 +244,4 @@ export {
244
244
  useInvalidatePermission,
245
245
  usePermissionLoading
246
246
  };
247
- //# sourceMappingURL=chunk-VWPLASGY.js.map
247
+ //# sourceMappingURL=chunk-IZX7ZEUF.js.map
@@ -74,12 +74,10 @@ function useDbQuery(table, options = {}) {
74
74
  const tableName = typeof table === "string" ? table : resolveTableName(table);
75
75
  const {
76
76
  registry,
77
- queryClient
77
+ queryClient,
78
+ powerSync
78
79
  } = useDataLayerCore();
79
- const {
80
- status
81
- } = useDataLayerStatus();
82
- const isPowerSync = status.currentBackend === "powersync";
80
+ const isPowerSync = powerSync !== null;
83
81
  const {
84
82
  enabled = true,
85
83
  staleTime = isPowerSync ? 0 : 3e4,
@@ -92,13 +90,12 @@ function useDbQuery(table, options = {}) {
92
90
  ...queryOptions
93
91
  } = options;
94
92
  const adapter = useMemo(() => {
95
- if (!status.isInitialized) return null;
96
93
  try {
97
94
  return registry.getAdapter(tableName);
98
95
  } catch {
99
96
  return null;
100
97
  }
101
- }, [registry, tableName, status.isInitialized, status.currentBackend]);
98
+ }, [registry, tableName]);
102
99
  const queryKey = useMemo(() => buildQueryKey(tableName, options), [tableName, serializeQueryOptions(options)]);
103
100
  const memoizedQueryOptions = useMemo(() => ({
104
101
  select: queryOptions.select,
@@ -117,14 +114,14 @@ function useDbQuery(table, options = {}) {
117
114
  const query = useQuery({
118
115
  queryKey,
119
116
  queryFn,
120
- enabled: enabled && status.isInitialized && adapter !== null,
117
+ enabled: enabled && adapter !== null,
121
118
  staleTime,
122
119
  gcTime,
123
120
  refetchOnWindowFocus,
124
121
  refetchOnMount
125
122
  });
126
123
  useEffect(() => {
127
- if (!realtime || !adapter?.subscribe || !status.isInitialized) {
124
+ if (!realtime || !adapter?.subscribe) {
128
125
  return;
129
126
  }
130
127
  let isFirstCallback = true;
@@ -148,7 +145,7 @@ function useDbQuery(table, options = {}) {
148
145
  return () => {
149
146
  unsubscribe();
150
147
  };
151
- }, [realtime, adapter, tableName, memoizedQueryOptions, queryClient, queryKey, status.isInitialized]);
148
+ }, [realtime, adapter, tableName, memoizedQueryOptions, queryClient, queryKey]);
152
149
  const refetch = useCallback(async () => {
153
150
  await query.refetch();
154
151
  }, [query]);
@@ -179,22 +176,18 @@ function useDbQueryById(table, id, options = {}) {
179
176
  const {
180
177
  registry
181
178
  } = useDataLayerCore();
182
- const {
183
- status
184
- } = useDataLayerStatus();
185
179
  const {
186
180
  select,
187
181
  enabled = id != null,
188
182
  staleTime = 3e4
189
183
  } = options;
190
184
  const adapter = useMemo2(() => {
191
- if (!status.isInitialized) return null;
192
185
  try {
193
186
  return registry.getAdapter(table);
194
187
  } catch {
195
188
  return null;
196
189
  }
197
- }, [registry, table, status.isInitialized, status.currentBackend]);
190
+ }, [registry, table]);
198
191
  const queryKey = useMemo2(() => buildQueryKey2(table, id, select), [table, id, select]);
199
192
  const queryFn = useCallback2(async () => {
200
193
  if (!adapter) {
@@ -220,7 +213,7 @@ function useDbQueryById(table, id, options = {}) {
220
213
  const query = useQuery2({
221
214
  queryKey,
222
215
  queryFn,
223
- enabled: enabled && status.isInitialized && adapter !== null && id != null,
216
+ enabled: enabled && adapter !== null && id != null,
224
217
  staleTime
225
218
  });
226
219
  const refetch = useCallback2(async () => {
@@ -252,11 +245,9 @@ function useAdvanceQuery(table, options) {
252
245
  const tableName = typeof table === "string" ? table : `${table.schema}.${table.table}`;
253
246
  const {
254
247
  registry,
255
- queryClient
248
+ queryClient,
249
+ powerSync
256
250
  } = useDataLayerCore();
257
- const {
258
- status
259
- } = useDataLayerStatus();
260
251
  const supabase = useSupabase();
261
252
  const {
262
253
  filterKey,
@@ -272,7 +263,7 @@ function useAdvanceQuery(table, options) {
272
263
  offset,
273
264
  ...restOptions
274
265
  } = options;
275
- const isPowerSync = status.currentBackend === "powersync";
266
+ const isPowerSync = powerSync !== null;
276
267
  const realtimeEnabled = realtime ?? isPowerSync;
277
268
  const defaultFilterState = useMemo3(
278
269
  () => initialFilters ?? createDefaultFilterState(),
@@ -311,7 +302,7 @@ function useAdvanceQuery(table, options) {
311
302
  // Enable watch() subscriptions for reactive updates
312
303
  });
313
304
  const [extraData, setExtraData] = useState({});
314
- const edgeFunctionQueryKey = useMemo3(() => ["v3", "advance-query", tableName, select, JSON.stringify(where), JSON.stringify(filters), status.currentBackend], [tableName, select, where, filters, status.currentBackend]);
305
+ const edgeFunctionQueryKey = useMemo3(() => ["v3", "advance-query", tableName, select, JSON.stringify(where), JSON.stringify(filters)], [tableName, select, where, filters]);
315
306
  const edgeFunctionResult = useQuery3({
316
307
  queryKey: edgeFunctionQueryKey,
317
308
  queryFn: async ({
@@ -488,9 +479,6 @@ function useDbInsert(table, t0) {
488
479
  const {
489
480
  registry
490
481
  } = useDataLayerCore();
491
- const {
492
- status
493
- } = useDataLayerStatus();
494
482
  const queryClient = useQueryClient();
495
483
  const {
496
484
  onSuccess,
@@ -508,25 +496,19 @@ function useDbInsert(table, t0) {
508
496
  }
509
497
  const invalidateTables = t3;
510
498
  let t4;
511
- bb0: {
512
- if (!status.isInitialized) {
513
- t4 = null;
514
- break bb0;
515
- }
516
- try {
517
- let t52;
518
- if ($[5] !== registry || $[6] !== table) {
519
- t52 = registry.getAdapter(table);
520
- $[5] = registry;
521
- $[6] = table;
522
- $[7] = t52;
523
- } else {
524
- t52 = $[7];
525
- }
526
- t4 = t52;
527
- } catch {
528
- t4 = null;
499
+ try {
500
+ let t52;
501
+ if ($[5] !== registry || $[6] !== table) {
502
+ t52 = registry.getAdapter(table);
503
+ $[5] = registry;
504
+ $[6] = table;
505
+ $[7] = t52;
506
+ } else {
507
+ t52 = $[7];
529
508
  }
509
+ t4 = t52;
510
+ } catch {
511
+ t4 = null;
530
512
  }
531
513
  const adapter = t4;
532
514
  let t5;
@@ -627,9 +609,6 @@ function useDbUpdate(table, t0) {
627
609
  const {
628
610
  registry
629
611
  } = useDataLayerCore();
630
- const {
631
- status
632
- } = useDataLayerStatus();
633
612
  const queryClient = useQueryClient2();
634
613
  const {
635
614
  onSuccess,
@@ -649,25 +628,19 @@ function useDbUpdate(table, t0) {
649
628
  const invalidateTables = t4;
650
629
  const optimistic = t3 === void 0 ? false : t3;
651
630
  let t5;
652
- bb0: {
653
- if (!status.isInitialized) {
654
- t5 = null;
655
- break bb0;
656
- }
657
- try {
658
- let t62;
659
- if ($[5] !== registry || $[6] !== table) {
660
- t62 = registry.getAdapter(table);
661
- $[5] = registry;
662
- $[6] = table;
663
- $[7] = t62;
664
- } else {
665
- t62 = $[7];
666
- }
667
- t5 = t62;
668
- } catch {
669
- t5 = null;
631
+ try {
632
+ let t62;
633
+ if ($[5] !== registry || $[6] !== table) {
634
+ t62 = registry.getAdapter(table);
635
+ $[5] = registry;
636
+ $[6] = table;
637
+ $[7] = t62;
638
+ } else {
639
+ t62 = $[7];
670
640
  }
641
+ t5 = t62;
642
+ } catch {
643
+ t5 = null;
671
644
  }
672
645
  const adapter = t5;
673
646
  let t6;
@@ -798,9 +771,6 @@ function useDbUpsert(table, t0) {
798
771
  const {
799
772
  registry
800
773
  } = useDataLayerCore();
801
- const {
802
- status
803
- } = useDataLayerStatus();
804
774
  const queryClient = useQueryClient3();
805
775
  const {
806
776
  onSuccess,
@@ -818,36 +788,29 @@ function useDbUpsert(table, t0) {
818
788
  }
819
789
  const invalidateTables = t3;
820
790
  let t4;
821
- bb0: {
822
- if (!status.isInitialized) {
823
- t4 = null;
824
- break bb0;
791
+ ;
792
+ try {
793
+ let t62;
794
+ if ($[5] !== registry || $[6] !== table) {
795
+ t62 = registry.getAdapter(table);
796
+ $[5] = registry;
797
+ $[6] = table;
798
+ $[7] = t62;
799
+ } else {
800
+ t62 = $[7];
825
801
  }
826
- ;
827
- try {
828
- let t62;
829
- if ($[5] !== registry || $[6] !== table) {
830
- t62 = registry.getAdapter(table);
831
- $[5] = registry;
832
- $[6] = table;
833
- $[7] = t62;
834
- } else {
835
- t62 = $[7];
836
- }
837
- const resolvedAdapter = t62;
838
- t4 = resolvedAdapter;
839
- } catch (t52) {
840
- const error = t52;
841
- if (__DEV__) {
842
- console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
843
- }
844
- t4 = null;
802
+ t4 = t62;
803
+ } catch (t5) {
804
+ const error = t5;
805
+ if (__DEV__) {
806
+ console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
845
807
  }
808
+ t4 = null;
846
809
  }
847
810
  const adapter = t4;
848
- let t5;
811
+ let t6;
849
812
  if ($[8] !== adapter || $[9] !== table) {
850
- t5 = async (data) => {
813
+ t6 = async (data) => {
851
814
  if (__DEV__) {
852
815
  console.log(`[useDbUpsert] mutationFn called for table "${table}":`, {
853
816
  adapterName: adapter?.name ?? "null",
@@ -869,14 +832,14 @@ function useDbUpsert(table, t0) {
869
832
  };
870
833
  $[8] = adapter;
871
834
  $[9] = table;
872
- $[10] = t5;
835
+ $[10] = t6;
873
836
  } else {
874
- t5 = $[10];
837
+ t6 = $[10];
875
838
  }
876
- const mutationFn = t5;
877
- let t6;
839
+ const mutationFn = t6;
840
+ let t7;
878
841
  if ($[11] !== invalidateTables || $[12] !== onSuccess || $[13] !== queryClient) {
879
- t6 = (data_0) => {
842
+ t7 = (data_0) => {
880
843
  invalidateTables.forEach((t) => {
881
844
  queryClient.invalidateQueries({
882
845
  predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === t
@@ -887,43 +850,43 @@ function useDbUpsert(table, t0) {
887
850
  $[11] = invalidateTables;
888
851
  $[12] = onSuccess;
889
852
  $[13] = queryClient;
890
- $[14] = t6;
853
+ $[14] = t7;
891
854
  } else {
892
- t6 = $[14];
855
+ t7 = $[14];
893
856
  }
894
- let t7;
857
+ let t8;
895
858
  if ($[15] !== onError) {
896
- t7 = (error_0) => {
859
+ t8 = (error_0) => {
897
860
  onError?.(error_0 instanceof Error ? error_0 : new Error(String(error_0)));
898
861
  };
899
862
  $[15] = onError;
900
- $[16] = t7;
863
+ $[16] = t8;
901
864
  } else {
902
- t7 = $[16];
865
+ t8 = $[16];
903
866
  }
904
- let t8;
905
- if ($[17] !== mutationFn || $[18] !== t6 || $[19] !== t7) {
906
- t8 = {
867
+ let t9;
868
+ if ($[17] !== mutationFn || $[18] !== t7 || $[19] !== t8) {
869
+ t9 = {
907
870
  mutationFn,
908
- onSuccess: t6,
909
- onError: t7
871
+ onSuccess: t7,
872
+ onError: t8
910
873
  };
911
874
  $[17] = mutationFn;
912
- $[18] = t6;
913
- $[19] = t7;
914
- $[20] = t8;
875
+ $[18] = t7;
876
+ $[19] = t8;
877
+ $[20] = t9;
915
878
  } else {
916
- t8 = $[20];
879
+ t9 = $[20];
917
880
  }
918
- const mutation = useMutation3(t8);
919
- const t9 = mutation.error;
920
- let t10;
921
- if ($[21] !== mutation.data || $[22] !== mutation.isPending || $[23] !== mutation.mutate || $[24] !== mutation.mutateAsync || $[25] !== mutation.reset || $[26] !== t9) {
922
- t10 = {
881
+ const mutation = useMutation3(t9);
882
+ const t10 = mutation.error;
883
+ let t11;
884
+ if ($[21] !== mutation.data || $[22] !== mutation.isPending || $[23] !== mutation.mutate || $[24] !== mutation.mutateAsync || $[25] !== mutation.reset || $[26] !== t10) {
885
+ t11 = {
923
886
  mutate: mutation.mutate,
924
887
  mutateAsync: mutation.mutateAsync,
925
888
  isPending: mutation.isPending,
926
- error: t9,
889
+ error: t10,
927
890
  reset: mutation.reset,
928
891
  data: mutation.data
929
892
  };
@@ -932,12 +895,12 @@ function useDbUpsert(table, t0) {
932
895
  $[23] = mutation.mutate;
933
896
  $[24] = mutation.mutateAsync;
934
897
  $[25] = mutation.reset;
935
- $[26] = t9;
936
- $[27] = t10;
898
+ $[26] = t10;
899
+ $[27] = t11;
937
900
  } else {
938
- t10 = $[27];
901
+ t11 = $[27];
939
902
  }
940
- return t10;
903
+ return t11;
941
904
  }
942
905
 
943
906
  // src/hooks/useDbDelete.ts
@@ -957,9 +920,6 @@ function useDbDelete(table, t0) {
957
920
  const {
958
921
  registry
959
922
  } = useDataLayerCore();
960
- const {
961
- status
962
- } = useDataLayerStatus();
963
923
  const queryClient = useQueryClient4();
964
924
  const {
965
925
  onSuccess,
@@ -979,25 +939,19 @@ function useDbDelete(table, t0) {
979
939
  const invalidateTables = t4;
980
940
  const optimistic = t3 === void 0 ? false : t3;
981
941
  let t5;
982
- bb0: {
983
- if (!status.isInitialized) {
984
- t5 = null;
985
- break bb0;
986
- }
987
- try {
988
- let t62;
989
- if ($[5] !== registry || $[6] !== table) {
990
- t62 = registry.getAdapter(table);
991
- $[5] = registry;
992
- $[6] = table;
993
- $[7] = t62;
994
- } else {
995
- t62 = $[7];
996
- }
997
- t5 = t62;
998
- } catch {
999
- t5 = null;
942
+ try {
943
+ let t62;
944
+ if ($[5] !== registry || $[6] !== table) {
945
+ t62 = registry.getAdapter(table);
946
+ $[5] = registry;
947
+ $[6] = table;
948
+ $[7] = t62;
949
+ } else {
950
+ t62 = $[7];
1000
951
  }
952
+ t5 = t62;
953
+ } catch {
954
+ t5 = null;
1001
955
  }
1002
956
  const adapter = t5;
1003
957
  let t6;
@@ -1163,9 +1117,6 @@ function useDbInfiniteQuery(table, options = {}) {
1163
1117
  const {
1164
1118
  registry
1165
1119
  } = useDataLayerCore();
1166
- const {
1167
- status
1168
- } = useDataLayerStatus();
1169
1120
  const {
1170
1121
  enabled = true,
1171
1122
  staleTime = 3e4,
@@ -1176,13 +1127,12 @@ function useDbInfiniteQuery(table, options = {}) {
1176
1127
  ...queryOptions
1177
1128
  } = options;
1178
1129
  const adapter = useMemo4(() => {
1179
- if (!status.isInitialized) return null;
1180
1130
  try {
1181
1131
  return registry.getAdapter(tableName);
1182
1132
  } catch {
1183
1133
  return null;
1184
1134
  }
1185
- }, [registry, tableName, status.isInitialized, status.currentBackend]);
1135
+ }, [registry, tableName]);
1186
1136
  const queryKey = useMemo4(() => buildInfiniteQueryKey(tableName, options), [tableName, serializeInfiniteQueryOptions(options)]);
1187
1137
  const effectiveWhere = useMemo4(() => {
1188
1138
  if (searchText && searchFields && searchFields.length > 0) {
@@ -1226,7 +1176,7 @@ function useDbInfiniteQuery(table, options = {}) {
1226
1176
  }
1227
1177
  return allPages.length + 1;
1228
1178
  },
1229
- enabled: enabled && status.isInitialized && adapter !== null,
1179
+ enabled: enabled && adapter !== null,
1230
1180
  staleTime,
1231
1181
  refetchOnWindowFocus
1232
1182
  });
@@ -1277,9 +1227,6 @@ function useDbCount(table, t0) {
1277
1227
  const {
1278
1228
  registry
1279
1229
  } = useDataLayerCore();
1280
- const {
1281
- status
1282
- } = useDataLayerStatus();
1283
1230
  const {
1284
1231
  enabled: t2,
1285
1232
  staleTime: t3,
@@ -1288,25 +1235,19 @@ function useDbCount(table, t0) {
1288
1235
  const enabled = t2 === void 0 ? true : t2;
1289
1236
  const staleTime = t3 === void 0 ? 3e4 : t3;
1290
1237
  let t4;
1291
- bb0: {
1292
- if (!status.isInitialized) {
1293
- t4 = null;
1294
- break bb0;
1295
- }
1296
- try {
1297
- let t52;
1298
- if ($[2] !== registry || $[3] !== table) {
1299
- t52 = registry.getAdapter(table);
1300
- $[2] = registry;
1301
- $[3] = table;
1302
- $[4] = t52;
1303
- } else {
1304
- t52 = $[4];
1305
- }
1306
- t4 = t52;
1307
- } catch {
1308
- t4 = null;
1238
+ try {
1239
+ let t52;
1240
+ if ($[2] !== registry || $[3] !== table) {
1241
+ t52 = registry.getAdapter(table);
1242
+ $[2] = registry;
1243
+ $[3] = table;
1244
+ $[4] = t52;
1245
+ } else {
1246
+ t52 = $[4];
1309
1247
  }
1248
+ t4 = t52;
1249
+ } catch {
1250
+ t4 = null;
1310
1251
  }
1311
1252
  const adapter = t4;
1312
1253
  let t5;
@@ -1347,7 +1288,7 @@ function useDbCount(table, t0) {
1347
1288
  t7 = $[13];
1348
1289
  }
1349
1290
  const queryFn = t7;
1350
- const t8 = enabled && status.isInitialized && adapter !== null;
1291
+ const t8 = enabled && adapter !== null;
1351
1292
  let t9;
1352
1293
  if ($[14] !== queryFn || $[15] !== queryKey || $[16] !== staleTime || $[17] !== t8) {
1353
1294
  t9 = {
@@ -1674,4 +1615,4 @@ export {
1674
1615
  useSyncControl,
1675
1616
  useOnlineStatus
1676
1617
  };
1677
- //# sourceMappingURL=chunk-2DOYFTN4.js.map
1618
+ //# sourceMappingURL=chunk-LVUK5USN.js.map