@pol-studios/db 1.0.59 → 1.0.62

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.
@@ -3,7 +3,7 @@ import {
3
3
  createSupabaseAdapter,
4
4
  getPowerSyncAlias,
5
5
  stripSchemaPrefix
6
- } from "./chunk-VADZSRHY.js";
6
+ } from "./chunk-FWCHS5NN.js";
7
7
  import {
8
8
  DataLayerContext,
9
9
  DataLayerCoreContext,
@@ -1418,20 +1418,13 @@ var defaultSyncControl = {
1418
1418
  setScope: async () => {
1419
1419
  console.warn("Scope control not available: PowerSync not initialized");
1420
1420
  },
1421
- pauseAutoRetry: () => {
1422
- console.warn("Pause auto-retry not available: PowerSync not initialized");
1423
- },
1424
- resumeAutoRetry: () => {
1425
- console.warn("Resume auto-retry not available: PowerSync not initialized");
1426
- },
1427
- isAutoRetryPaused: false,
1428
1421
  addPendingMutation: () => {
1429
1422
  },
1430
1423
  removePendingMutation: () => {
1431
1424
  }
1432
1425
  };
1433
1426
  function DataLayerProvider(t0) {
1434
- const $ = _c(68);
1427
+ const $ = _c(70);
1435
1428
  const {
1436
1429
  config,
1437
1430
  children,
@@ -1562,26 +1555,44 @@ function DataLayerProvider(t0) {
1562
1555
  }
1563
1556
  const getPowerSyncTables = t9;
1564
1557
  let t10;
1565
- if ($[24] !== adapters.powerSync || $[25] !== adapters.supabase || $[26] !== adapters.syncTracking || $[27] !== config.tables) {
1558
+ if ($[24] !== adapters.powerSync || $[25] !== adapters.supabase || $[26] !== adapters.syncTracking || $[27] !== config.tables || $[28] !== hasSynced || $[29] !== isOnline) {
1566
1559
  t10 = (table_2, t112) => {
1567
- t112 === void 0 ? "read" : t112;
1560
+ const _operation = t112 === void 0 ? "read" : t112;
1568
1561
  const tableWithoutSchema_1 = table_2.includes(".") ? stripSchemaPrefix(table_2) : table_2;
1569
1562
  const strategy_3 = config.tables[table_2] ?? config.tables[tableWithoutSchema_1];
1570
1563
  if (strategy_3?.strategy === "supabase") {
1571
1564
  return adapters.supabase;
1572
1565
  }
1573
- const isPowerSyncTable = !strategy_3 || strategy_3.strategy === "powersync" || strategy_3.strategy === "hybrid" || strategy_3.strategy === "auto";
1574
- if (isPowerSyncTable && adapters.powerSync) {
1566
+ if (strategy_3?.strategy === "cached") {
1567
+ return adapters.supabase;
1568
+ }
1569
+ if (strategy_3?.strategy === "powersync") {
1570
+ if (_operation === "read" && isOnline && !hasSynced) {
1571
+ return adapters.supabase;
1572
+ }
1573
+ if (adapters.powerSync) {
1574
+ return adapters.syncTracking ?? adapters.powerSync;
1575
+ }
1576
+ return adapters.supabase;
1577
+ }
1578
+ const isAutoTable = !strategy_3 || strategy_3.strategy === "auto" || strategy_3.strategy === "hybrid";
1579
+ if (isAutoTable) {
1575
1580
  const powerSyncTableKeys = Object.keys(config.tables).filter((key_0) => {
1576
1581
  const s = config.tables[key_0];
1577
1582
  return s.strategy === "powersync" || s.strategy === "hybrid" || s.strategy === "auto";
1578
1583
  });
1579
1584
  const isConfigured = powerSyncTableKeys.some((key_1) => key_1 === table_2 || key_1 === tableWithoutSchema_1 || key_1.includes(".") && key_1.split(".")[1] === tableWithoutSchema_1);
1580
- if (isConfigured) {
1581
- return adapters.syncTracking ?? adapters.powerSync;
1585
+ if (!isConfigured) {
1586
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1587
+ console.warn(`[DataLayerProvider] Table "${table_2}" is not configured for PowerSync. Using Supabase fallback.`);
1588
+ }
1589
+ return adapters.supabase;
1582
1590
  }
1583
- if (typeof __DEV__ !== "undefined" && __DEV__) {
1584
- console.warn(`[DataLayerProvider] Table "${table_2}" is not configured for PowerSync. Using Supabase fallback.`);
1591
+ if (isOnline && !hasSynced) {
1592
+ return adapters.supabase;
1593
+ }
1594
+ if (adapters.powerSync) {
1595
+ return adapters.syncTracking ?? adapters.powerSync;
1585
1596
  }
1586
1597
  }
1587
1598
  if (!adapters.supabase) {
@@ -1593,13 +1604,15 @@ function DataLayerProvider(t0) {
1593
1604
  $[25] = adapters.supabase;
1594
1605
  $[26] = adapters.syncTracking;
1595
1606
  $[27] = config.tables;
1596
- $[28] = t10;
1607
+ $[28] = hasSynced;
1608
+ $[29] = isOnline;
1609
+ $[30] = t10;
1597
1610
  } else {
1598
- t10 = $[28];
1611
+ t10 = $[30];
1599
1612
  }
1600
1613
  const getAdapter = t10;
1601
1614
  let t11;
1602
- if ($[29] !== adapters.powerSync || $[30] !== config.tables || $[31] !== getPowerSyncTables) {
1615
+ if ($[31] !== adapters.powerSync || $[32] !== config.tables || $[33] !== getPowerSyncTables) {
1603
1616
  t11 = () => ({
1604
1617
  isInitialized: true,
1605
1618
  hasPowerSync: adapters.powerSync !== null,
@@ -1607,15 +1620,15 @@ function DataLayerProvider(t0) {
1607
1620
  configuredTableCount: Object.keys(config.tables).length,
1608
1621
  powerSyncTables: getPowerSyncTables()
1609
1622
  });
1610
- $[29] = adapters.powerSync;
1611
- $[30] = config.tables;
1612
- $[31] = getPowerSyncTables;
1613
- $[32] = t11;
1623
+ $[31] = adapters.powerSync;
1624
+ $[32] = config.tables;
1625
+ $[33] = getPowerSyncTables;
1626
+ $[34] = t11;
1614
1627
  } else {
1615
- t11 = $[32];
1628
+ t11 = $[34];
1616
1629
  }
1617
1630
  let t12;
1618
- if ($[33] !== config || $[34] !== getAdapter || $[35] !== getPowerSyncTables || $[36] !== getTableAlias || $[37] !== getTableStrategy || $[38] !== t11 || $[39] !== usesPowerSync) {
1631
+ if ($[35] !== config || $[36] !== getAdapter || $[37] !== getPowerSyncTables || $[38] !== getTableAlias || $[39] !== getTableStrategy || $[40] !== t11 || $[41] !== usesPowerSync) {
1619
1632
  t12 = {
1620
1633
  getAdapter,
1621
1634
  getTableStrategy,
@@ -1626,20 +1639,20 @@ function DataLayerProvider(t0) {
1626
1639
  config,
1627
1640
  isInitialized: true
1628
1641
  };
1629
- $[33] = config;
1630
- $[34] = getAdapter;
1631
- $[35] = getPowerSyncTables;
1632
- $[36] = getTableAlias;
1633
- $[37] = getTableStrategy;
1634
- $[38] = t11;
1635
- $[39] = usesPowerSync;
1636
- $[40] = t12;
1642
+ $[35] = config;
1643
+ $[36] = getAdapter;
1644
+ $[37] = getPowerSyncTables;
1645
+ $[38] = getTableAlias;
1646
+ $[39] = getTableStrategy;
1647
+ $[40] = t11;
1648
+ $[41] = usesPowerSync;
1649
+ $[42] = t12;
1637
1650
  } else {
1638
- t12 = $[40];
1651
+ t12 = $[42];
1639
1652
  }
1640
1653
  const registry = t12;
1641
1654
  let t13;
1642
- if ($[41] !== config.schema || $[42] !== getAdapter || $[43] !== powerSyncInstance || $[44] !== queryClient || $[45] !== registry || $[46] !== supabaseClient || $[47] !== syncControl) {
1655
+ if ($[43] !== config.schema || $[44] !== getAdapter || $[45] !== powerSyncInstance || $[46] !== queryClient || $[47] !== registry || $[48] !== supabaseClient || $[49] !== syncControl) {
1643
1656
  t13 = {
1644
1657
  registry,
1645
1658
  getAdapter,
@@ -1649,22 +1662,22 @@ function DataLayerProvider(t0) {
1649
1662
  schema: config.schema,
1650
1663
  syncControl
1651
1664
  };
1652
- $[41] = config.schema;
1653
- $[42] = getAdapter;
1654
- $[43] = powerSyncInstance;
1655
- $[44] = queryClient;
1656
- $[45] = registry;
1657
- $[46] = supabaseClient;
1658
- $[47] = syncControl;
1659
- $[48] = t13;
1665
+ $[43] = config.schema;
1666
+ $[44] = getAdapter;
1667
+ $[45] = powerSyncInstance;
1668
+ $[46] = queryClient;
1669
+ $[47] = registry;
1670
+ $[48] = supabaseClient;
1671
+ $[49] = syncControl;
1672
+ $[50] = t13;
1660
1673
  } else {
1661
- t13 = $[48];
1674
+ t13 = $[50];
1662
1675
  }
1663
1676
  const coreContextValue = t13;
1664
1677
  const t14 = powerSyncInstance ? "powersync" : "supabase";
1665
1678
  const t15 = powerSyncInstance ? "available" /* AVAILABLE */ : "unavailable" /* UNAVAILABLE */;
1666
1679
  let t16;
1667
- if ($[49] !== hasSynced || $[50] !== isOnline || $[51] !== t14 || $[52] !== t15) {
1680
+ if ($[51] !== hasSynced || $[52] !== isOnline || $[53] !== t14 || $[54] !== t15) {
1668
1681
  t16 = {
1669
1682
  isInitialized: true,
1670
1683
  currentBackend: t14,
@@ -1674,66 +1687,66 @@ function DataLayerProvider(t0) {
1674
1687
  error: null,
1675
1688
  hasSynced
1676
1689
  };
1677
- $[49] = hasSynced;
1678
- $[50] = isOnline;
1679
- $[51] = t14;
1680
- $[52] = t15;
1681
- $[53] = t16;
1690
+ $[51] = hasSynced;
1691
+ $[52] = isOnline;
1692
+ $[53] = t14;
1693
+ $[54] = t15;
1694
+ $[55] = t16;
1682
1695
  } else {
1683
- t16 = $[53];
1696
+ t16 = $[55];
1684
1697
  }
1685
1698
  const status = t16;
1686
1699
  let t17;
1687
- if ($[54] !== status) {
1700
+ if ($[56] !== status) {
1688
1701
  t17 = {
1689
1702
  status,
1690
1703
  syncStatus: defaultSyncStatus
1691
1704
  };
1692
- $[54] = status;
1693
- $[55] = t17;
1705
+ $[56] = status;
1706
+ $[57] = t17;
1694
1707
  } else {
1695
- t17 = $[55];
1708
+ t17 = $[57];
1696
1709
  }
1697
1710
  const statusContextValue = t17;
1698
1711
  let t18;
1699
- if ($[56] !== coreContextValue || $[57] !== statusContextValue) {
1712
+ if ($[58] !== coreContextValue || $[59] !== statusContextValue) {
1700
1713
  t18 = {
1701
1714
  ...coreContextValue,
1702
1715
  ...statusContextValue
1703
1716
  };
1704
- $[56] = coreContextValue;
1705
- $[57] = statusContextValue;
1706
- $[58] = t18;
1717
+ $[58] = coreContextValue;
1718
+ $[59] = statusContextValue;
1719
+ $[60] = t18;
1707
1720
  } else {
1708
- t18 = $[58];
1721
+ t18 = $[60];
1709
1722
  }
1710
1723
  const contextValue = t18;
1711
1724
  let t19;
1712
- if ($[59] !== children || $[60] !== statusContextValue) {
1725
+ if ($[61] !== children || $[62] !== statusContextValue) {
1713
1726
  t19 = /* @__PURE__ */ jsx(DataLayerStatusContext.Provider, { value: statusContextValue, children });
1714
- $[59] = children;
1715
- $[60] = statusContextValue;
1716
- $[61] = t19;
1727
+ $[61] = children;
1728
+ $[62] = statusContextValue;
1729
+ $[63] = t19;
1717
1730
  } else {
1718
- t19 = $[61];
1731
+ t19 = $[63];
1719
1732
  }
1720
1733
  let t20;
1721
- if ($[62] !== coreContextValue || $[63] !== t19) {
1734
+ if ($[64] !== coreContextValue || $[65] !== t19) {
1722
1735
  t20 = /* @__PURE__ */ jsx(DataLayerCoreContext.Provider, { value: coreContextValue, children: t19 });
1723
- $[62] = coreContextValue;
1724
- $[63] = t19;
1725
- $[64] = t20;
1736
+ $[64] = coreContextValue;
1737
+ $[65] = t19;
1738
+ $[66] = t20;
1726
1739
  } else {
1727
- t20 = $[64];
1740
+ t20 = $[66];
1728
1741
  }
1729
1742
  let t21;
1730
- if ($[65] !== contextValue || $[66] !== t20) {
1743
+ if ($[67] !== contextValue || $[68] !== t20) {
1731
1744
  t21 = /* @__PURE__ */ jsx(DataLayerNestingContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DataLayerContext.Provider, { value: contextValue, children: t20 }) });
1732
- $[65] = contextValue;
1733
- $[66] = t20;
1734
- $[67] = t21;
1745
+ $[67] = contextValue;
1746
+ $[68] = t20;
1747
+ $[69] = t21;
1735
1748
  } else {
1736
- t21 = $[67];
1749
+ t21 = $[69];
1737
1750
  }
1738
1751
  return t21;
1739
1752
  }
@@ -5012,4 +5025,4 @@ object-assign/index.js:
5012
5025
  @license MIT
5013
5026
  *)
5014
5027
  */
5015
- //# sourceMappingURL=chunk-K46TGKB2.js.map
5028
+ //# sourceMappingURL=chunk-EKIZNM2L.js.map