@pol-studios/db 1.0.21 → 1.0.22

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.
Files changed (43) hide show
  1. package/dist/auth/context.js +2 -2
  2. package/dist/auth/hooks.js +3 -3
  3. package/dist/auth/index.js +3 -3
  4. package/dist/{chunk-2T6WTCP4.js → chunk-3EVWXMUV.js} +54 -155
  5. package/dist/chunk-3EVWXMUV.js.map +1 -0
  6. package/dist/{chunk-YERWPV6B.js → chunk-3FHAKRDV.js} +145 -19
  7. package/dist/{chunk-YERWPV6B.js.map → chunk-3FHAKRDV.js.map} +1 -1
  8. package/dist/{chunk-X3HZLNBV.js → chunk-FKRACEHV.js} +2 -962
  9. package/dist/chunk-FKRACEHV.js.map +1 -0
  10. package/dist/{chunk-N26IEHZT.js → chunk-FZF26ZRB.js} +18 -2
  11. package/dist/{chunk-N26IEHZT.js.map → chunk-FZF26ZRB.js.map} +1 -1
  12. package/dist/chunk-HTJ2FQW5.js +963 -0
  13. package/dist/chunk-HTJ2FQW5.js.map +1 -0
  14. package/dist/{chunk-R5B2XMN5.js → chunk-I4BDZDHX.js} +1614 -2141
  15. package/dist/chunk-I4BDZDHX.js.map +1 -0
  16. package/dist/{chunk-36DVUMQD.js → chunk-LPC64MD4.js} +2 -2
  17. package/dist/{chunk-72WV3ALS.js → chunk-OUUQSI3Y.js} +2 -2
  18. package/dist/{chunk-RMRYGICS.js → chunk-WP6TIVPH.js} +4 -4
  19. package/dist/core/index.d.ts +30 -1
  20. package/dist/hooks/index.d.ts +20 -1
  21. package/dist/hooks/index.js +1 -1
  22. package/dist/{index-BNKhgDdC.d.ts → index-2YySlz7X.d.ts} +3 -3
  23. package/dist/index.d.ts +11 -12
  24. package/dist/index.js +14 -95
  25. package/dist/index.native.d.ts +12 -30
  26. package/dist/index.native.js +17 -96
  27. package/dist/index.web.d.ts +132 -15
  28. package/dist/index.web.js +585 -46
  29. package/dist/index.web.js.map +1 -1
  30. package/dist/powersync-bridge/index.d.ts +1 -1
  31. package/dist/powersync-bridge/index.js +1 -1
  32. package/dist/query/index.js +10 -8
  33. package/dist/types/index.d.ts +1 -1
  34. package/dist/{useDbCount-Id14x_1P.d.ts → useDbCount-s-aR9YeV.d.ts} +1 -1
  35. package/dist/{useResolveFeedback-Ca2rh_Bs.d.ts → useResolveFeedback-DTGcHpCs.d.ts} +275 -390
  36. package/dist/with-auth/index.js +4 -4
  37. package/package.json +13 -12
  38. package/dist/chunk-2T6WTCP4.js.map +0 -1
  39. package/dist/chunk-R5B2XMN5.js.map +0 -1
  40. package/dist/chunk-X3HZLNBV.js.map +0 -1
  41. /package/dist/{chunk-36DVUMQD.js.map → chunk-LPC64MD4.js.map} +0 -0
  42. /package/dist/{chunk-72WV3ALS.js.map → chunk-OUUQSI3Y.js.map} +0 -0
  43. /package/dist/{chunk-RMRYGICS.js.map → chunk-WP6TIVPH.js.map} +0 -0
@@ -12,8 +12,8 @@ import {
12
12
  useUserMetadataState,
13
13
  useUserMetadataValue,
14
14
  userMetadataContext
15
- } from "../chunk-72WV3ALS.js";
16
- import "../chunk-YERWPV6B.js";
15
+ } from "../chunk-OUUQSI3Y.js";
16
+ import "../chunk-3FHAKRDV.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-36DVUMQD.js";
14
+ } from "../chunk-LPC64MD4.js";
15
15
  import {
16
16
  useSetUserMetadata,
17
17
  useUserMetadata,
18
18
  useUserMetadataState,
19
19
  useUserMetadataValue
20
- } from "../chunk-72WV3ALS.js";
21
- import "../chunk-YERWPV6B.js";
20
+ } from "../chunk-OUUQSI3Y.js";
21
+ import "../chunk-3FHAKRDV.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-36DVUMQD.js";
15
+ } from "../chunk-LPC64MD4.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-72WV3ALS.js";
31
- import "../chunk-YERWPV6B.js";
30
+ } from "../chunk-OUUQSI3Y.js";
31
+ import "../chunk-3FHAKRDV.js";
32
32
  import {
33
33
  hasAccess,
34
34
  hasAllAccess,
@@ -3,23 +3,16 @@ import {
3
3
  createAdapterRegistry,
4
4
  createSupabaseAdapter,
5
5
  stripSchemaPrefix
6
- } from "./chunk-R5B2XMN5.js";
6
+ } from "./chunk-I4BDZDHX.js";
7
7
  import {
8
8
  DataLayerCoreContext,
9
9
  DataLayerStatusContext
10
- } from "./chunk-YERWPV6B.js";
10
+ } from "./chunk-3FHAKRDV.js";
11
11
  import {
12
12
  QueryExecutor,
13
13
  extractRelationNames,
14
14
  parseSelect
15
- } from "./chunk-X3HZLNBV.js";
16
- import {
17
- getSupabaseUrl
18
- } from "./chunk-GC3TBUWE.js";
19
- import {
20
- isNullOrWhitespace,
21
- newUuid
22
- } from "./chunk-OQ7U6EQ3.js";
15
+ } from "./chunk-FKRACEHV.js";
23
16
  import {
24
17
  useSupabase
25
18
  } from "./chunk-5EFDS7SR.js";
@@ -1134,119 +1127,6 @@ var require_merge_options = __commonJS({
1134
1127
  }
1135
1128
  });
1136
1129
 
1137
- // src/useDbUpload.ts
1138
- import { c as _c } from "react/compiler-runtime";
1139
- import { useMutation } from "@tanstack/react-query";
1140
- import { Upload } from "tus-js-client";
1141
- function sanitizeStorageKey(path) {
1142
- const cleaned = path.replace(/[\u202F\u00A0]/g, " ").normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
1143
- return cleaned.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_.\/]/g, "");
1144
- }
1145
- async function uploadFile(supabase, bucketName, fileName, fileBody, fileOptions, requestOptions) {
1146
- const {
1147
- data: {
1148
- session
1149
- }
1150
- } = await supabase.auth.getSession();
1151
- if (session === null) throw new Error("User needs to be logged in.");
1152
- const contentType = "type" in fileBody ? fileBody.type : fileOptions.contentType;
1153
- if (contentType === void 0) {
1154
- throw new Error("Needs content type for body.");
1155
- }
1156
- return new Promise((resolve, reject) => {
1157
- var upload = new Upload(fileBody, {
1158
- endpoint: `${getSupabaseUrl()}/storage/v1/upload/resumable`,
1159
- retryDelays: [0, 3e3, 5e3, 1e4, 2e4],
1160
- headers: {
1161
- ...fileOptions.headers,
1162
- authorization: `Bearer ${session.access_token}`,
1163
- "x-upsert": "true"
1164
- // optionally set upsert to true to overwrite existing files
1165
- },
1166
- uploadDataDuringCreation: true,
1167
- removeFingerprintOnSuccess: true,
1168
- // Important if you want to allow re-uploading the same file https://github.com/tus/tus-js-client/blob/main/docs/api.md#removefingerprintonsuccess
1169
- metadata: {
1170
- bucketName,
1171
- objectName: fileName,
1172
- contentType,
1173
- cacheControl: fileOptions.cacheControl ?? "3600",
1174
- duplex: fileOptions.duplex ?? "half"
1175
- },
1176
- chunkSize: 6 * 1024 * 1024,
1177
- // NOTE: it must be set to 6MB (for now) do not change it
1178
- onError: function(error) {
1179
- console.log("Failed because: " + error);
1180
- reject(error);
1181
- },
1182
- onProgress: requestOptions.onUploadProgress,
1183
- onSuccess: function(result) {
1184
- resolve(result);
1185
- }
1186
- });
1187
- return upload.findPreviousUploads().then(function(previousUploads) {
1188
- if (previousUploads.length) {
1189
- upload.resumeFromPreviousUpload(previousUploads[0]);
1190
- }
1191
- upload.start();
1192
- });
1193
- });
1194
- }
1195
- function useDbAttachmentUpload(bucketId, t0) {
1196
- const $ = _c(6);
1197
- let t1;
1198
- if ($[0] !== t0) {
1199
- t1 = t0 === void 0 ? {
1200
- onUploadProgress: _temp
1201
- } : t0;
1202
- $[0] = t0;
1203
- $[1] = t1;
1204
- } else {
1205
- t1 = $[1];
1206
- }
1207
- const options = t1;
1208
- const supabase = useSupabase();
1209
- let t2;
1210
- if ($[2] !== bucketId || $[3] !== options || $[4] !== supabase) {
1211
- t2 = {
1212
- mutationFn: async (item) => {
1213
- const directory = item.directory ?? newUuid();
1214
- const originalName = item.fileName ?? ("name" in item.file ? String(item.file.name) : "") ?? ("fileName" in item.file ? String(item.file.fileName) : "");
1215
- if (isNullOrWhitespace(originalName)) {
1216
- throw new Error("file must have a valid name");
1217
- }
1218
- const filePath = `${directory}/${sanitizeStorageKey(originalName)}`;
1219
- await uploadFile(supabase, bucketId, filePath, item.file, {
1220
- upsert: item.upsert,
1221
- cacheControl: item.cacheControl,
1222
- contentType: item.contentType,
1223
- duplex: item.duplex
1224
- }, {
1225
- ...options,
1226
- onUploadProgress: item.onUploadProgress ?? _temp2
1227
- });
1228
- return {
1229
- bucketId,
1230
- path: filePath,
1231
- contentType: item.contentType
1232
- };
1233
- }
1234
- };
1235
- $[2] = bucketId;
1236
- $[3] = options;
1237
- $[4] = supabase;
1238
- $[5] = t2;
1239
- } else {
1240
- t2 = $[5];
1241
- }
1242
- const uploadMutation = useMutation(t2);
1243
- return uploadMutation;
1244
- }
1245
- function _temp2() {
1246
- }
1247
- function _temp() {
1248
- }
1249
-
1250
1130
  // src/utils/type-transformer.ts
1251
1131
  function transformValueFromStorage(value, columnInfo) {
1252
1132
  if (value === null || value === void 0) {
@@ -1661,7 +1541,22 @@ var defaultSyncControl = {
1661
1541
  },
1662
1542
  setScope: async () => {
1663
1543
  console.warn("Scope control not available: PowerSync not initialized");
1664
- }
1544
+ },
1545
+ // Failed upload controls
1546
+ retryFailedUploads: async () => {
1547
+ console.warn("Retry not available: PowerSync not initialized");
1548
+ },
1549
+ clearFailedUploads: () => {
1550
+ console.warn("Clear failed uploads not available: PowerSync not initialized");
1551
+ },
1552
+ failedUploads: [],
1553
+ pauseAutoRetry: () => {
1554
+ console.warn("Pause auto-retry not available: PowerSync not initialized");
1555
+ },
1556
+ resumeAutoRetry: () => {
1557
+ console.warn("Resume auto-retry not available: PowerSync not initialized");
1558
+ },
1559
+ isAutoRetryPaused: false
1665
1560
  };
1666
1561
  function DataLayerProvider({
1667
1562
  config,
@@ -1705,9 +1600,6 @@ function DataLayerProvider({
1705
1600
  schema: config.schema
1706
1601
  });
1707
1602
  registry.initializeAutoDetection(detector);
1708
- if (powerSyncSyncStatus) {
1709
- detector.updateSyncStatus(powerSyncSyncStatus);
1710
- }
1711
1603
  const detection = detector.detect();
1712
1604
  setStatus({
1713
1605
  isInitialized: true,
@@ -1716,7 +1608,8 @@ function DataLayerProvider({
1716
1608
  isOnline: detection.isOnline,
1717
1609
  lastDetection: detection,
1718
1610
  error: null,
1719
- hasSynced: powerSyncSyncStatus?.hasSynced ?? false
1611
+ hasSynced: false
1612
+ // Will be updated by Sync Status Update Effect
1720
1613
  });
1721
1614
  } catch (error) {
1722
1615
  const err = error instanceof Error ? error : new Error(String(error));
@@ -1726,7 +1619,7 @@ function DataLayerProvider({
1726
1619
  }));
1727
1620
  onError?.(err);
1728
1621
  }
1729
- }, [powerSyncInstance, supabaseClient, queryClient, config.schema, registry, onError, powerSyncSyncStatus]);
1622
+ }, [powerSyncInstance, supabaseClient, queryClient, config.schema, registry, onError]);
1730
1623
  useEffect(() => {
1731
1624
  if (powerSyncSyncStatus?.isOnline !== void 0) {
1732
1625
  return;
@@ -1787,14 +1680,22 @@ function DataLayerProvider({
1787
1680
  useEffect(() => {
1788
1681
  if (!autoDetector) return;
1789
1682
  autoDetector.updateSyncStatus(powerSyncSyncStatus ?? null);
1790
- setStatus((prev) => ({
1791
- ...prev,
1792
- hasSynced: powerSyncSyncStatus?.hasSynced ?? false,
1793
- // Only update isOnline if powerSyncSyncStatus provides it (React Native via NetInfo)
1794
- ...powerSyncSyncStatus?.isOnline !== void 0 && {
1795
- isOnline: powerSyncSyncStatus.isOnline
1683
+ setStatus((prev) => {
1684
+ const newHasSynced = powerSyncSyncStatus?.hasSynced ?? false;
1685
+ const newIsOnline = powerSyncSyncStatus?.isOnline;
1686
+ const hasSyncedChanged = prev.hasSynced !== newHasSynced;
1687
+ const isOnlineChanged = newIsOnline !== void 0 && prev.isOnline !== newIsOnline;
1688
+ if (!hasSyncedChanged && !isOnlineChanged) {
1689
+ return prev;
1796
1690
  }
1797
- }));
1691
+ return {
1692
+ ...prev,
1693
+ hasSynced: newHasSynced,
1694
+ ...newIsOnline !== void 0 && {
1695
+ isOnline: newIsOnline
1696
+ }
1697
+ };
1698
+ });
1798
1699
  }, [autoDetector, powerSyncSyncStatus?.hasSynced, powerSyncSyncStatus?.connected, powerSyncSyncStatus?.connecting, powerSyncSyncStatus?.isOnline]);
1799
1700
  useEffect(() => {
1800
1701
  if (status.isInitialized && !status.error && onInitialized) {
@@ -4388,7 +4289,7 @@ var useSupabaseUpload = (options) => {
4388
4289
  };
4389
4290
 
4390
4291
  // src/conflicts/ConflictContext.tsx
4391
- import { c as _c2 } from "react/compiler-runtime";
4292
+ import { c as _c } from "react/compiler-runtime";
4392
4293
  import { createContext, useEffect as useEffect4, useReducer as useReducer2, useRef as useRef2 } from "react";
4393
4294
 
4394
4295
  // ../../../node_modules/.pnpm/merge-options@3.0.4/node_modules/merge-options/index.mjs
@@ -4672,7 +4573,7 @@ function conflictReducer(state, action) {
4672
4573
  }
4673
4574
  }
4674
4575
  function ConflictProvider(t0) {
4675
- const $ = _c2(29);
4576
+ const $ = _c(29);
4676
4577
  const {
4677
4578
  children,
4678
4579
  conflictBus
@@ -4706,7 +4607,7 @@ function ConflictProvider(t0) {
4706
4607
  conflicts
4707
4608
  });
4708
4609
  }
4709
- }).catch(_temp3).finally(() => {
4610
+ }).catch(_temp).finally(() => {
4710
4611
  hasFinishedLoadingRef.current = true;
4711
4612
  });
4712
4613
  };
@@ -4734,7 +4635,7 @@ function ConflictProvider(t0) {
4734
4635
  updatedTimestamps.set(key, now);
4735
4636
  }
4736
4637
  }
4737
- const currentKeys = new Set(state.pendingConflicts.map(_temp22));
4638
+ const currentKeys = new Set(state.pendingConflicts.map(_temp2));
4738
4639
  for (const key_0 of updatedTimestamps.keys()) {
4739
4640
  if (!currentKeys.has(key_0)) {
4740
4641
  updatedTimestamps.delete(key_0);
@@ -4914,15 +4815,15 @@ function ConflictProvider(t0) {
4914
4815
  }
4915
4816
  return t17;
4916
4817
  }
4917
- function _temp22(c) {
4818
+ function _temp2(c) {
4918
4819
  return `${c.table}:${c.recordId}`;
4919
4820
  }
4920
- function _temp3(err) {
4821
+ function _temp(err) {
4921
4822
  console.warn("[ConflictProvider] Failed to load conflicts:", err);
4922
4823
  }
4923
4824
 
4924
4825
  // src/conflicts/useConflictState.ts
4925
- import { c as _c3 } from "react/compiler-runtime";
4826
+ import { c as _c2 } from "react/compiler-runtime";
4926
4827
  import { useContext } from "react";
4927
4828
  function useConflictState() {
4928
4829
  const context = useContext(ConflictContext);
@@ -4932,7 +4833,7 @@ function useConflictState() {
4932
4833
  return context;
4933
4834
  }
4934
4835
  function usePendingConflicts() {
4935
- const $ = _c3(2);
4836
+ const $ = _c2(2);
4936
4837
  const context = useContext(ConflictContext);
4937
4838
  let t0;
4938
4839
  if ($[0] !== context?.pendingConflicts) {
@@ -4949,7 +4850,7 @@ function useHasConflicts() {
4949
4850
  return context?.hasConflicts ?? false;
4950
4851
  }
4951
4852
  function useConflictForRecord(table, recordId) {
4952
- const $ = _c3(4);
4853
+ const $ = _c2(4);
4953
4854
  const conflicts = usePendingConflicts();
4954
4855
  let t0;
4955
4856
  if ($[0] !== conflicts || $[1] !== recordId || $[2] !== table) {
@@ -4964,7 +4865,7 @@ function useConflictForRecord(table, recordId) {
4964
4865
  return t0;
4965
4866
  }
4966
4867
  function useConflictsForTable(table) {
4967
- const $ = _c3(5);
4868
+ const $ = _c2(5);
4968
4869
  const conflicts = usePendingConflicts();
4969
4870
  let t0;
4970
4871
  if ($[0] !== conflicts || $[1] !== table) {
@@ -4986,7 +4887,7 @@ function useConflictsForTable(table) {
4986
4887
  return t0;
4987
4888
  }
4988
4889
  function useConflictCountByTable() {
4989
- const $ = _c3(2);
4890
+ const $ = _c2(2);
4990
4891
  const conflicts = usePendingConflicts();
4991
4892
  let counts;
4992
4893
  if ($[0] !== conflicts) {
@@ -5003,9 +4904,9 @@ function useConflictCountByTable() {
5003
4904
  }
5004
4905
 
5005
4906
  // src/conflicts/useConflictResolution.ts
5006
- import { c as _c4 } from "react/compiler-runtime";
4907
+ import { c as _c3 } from "react/compiler-runtime";
5007
4908
  function useConflictResolution(conflict) {
5008
- const $ = _c4(28);
4909
+ const $ = _c3(28);
5009
4910
  const {
5010
4911
  resolveConflict
5011
4912
  } = useConflictState();
@@ -5079,7 +4980,7 @@ function useConflictResolution(conflict) {
5079
4980
  const syncFields = t4;
5080
4981
  let t5;
5081
4982
  if ($[13] !== conflict.conflicts) {
5082
- t5 = new Set(conflict.conflicts.map(_temp4));
4983
+ t5 = new Set(conflict.conflicts.map(_temp3));
5083
4984
  $[13] = conflict.conflicts;
5084
4985
  $[14] = t5;
5085
4986
  } else {
@@ -5141,11 +5042,11 @@ function useConflictResolution(conflict) {
5141
5042
  }
5142
5043
  return t8;
5143
5044
  }
5144
- function _temp4(c) {
5045
+ function _temp3(c) {
5145
5046
  return c.field;
5146
5047
  }
5147
5048
  function useBulkConflictResolution() {
5148
- const $ = _c4(13);
5049
+ const $ = _c3(13);
5149
5050
  const {
5150
5051
  resolveAll,
5151
5052
  resolveConflict,
@@ -5217,8 +5118,6 @@ function useBulkConflictResolution() {
5217
5118
  }
5218
5119
 
5219
5120
  export {
5220
- sanitizeStorageKey,
5221
- useDbAttachmentUpload,
5222
5121
  PowerSyncAdapter,
5223
5122
  createPowerSyncAdapter,
5224
5123
  DataLayerProvider,
@@ -5263,4 +5162,4 @@ object-assign/index.js:
5263
5162
  @license MIT
5264
5163
  *)
5265
5164
  */
5266
- //# sourceMappingURL=chunk-2T6WTCP4.js.map
5165
+ //# sourceMappingURL=chunk-3EVWXMUV.js.map