@pol-studios/db 1.0.17 → 1.0.18
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-Cm1nAvT7.d.ts → DataLayerContext-ZmLPYR_s.d.ts} +23 -5
- package/dist/{chunk-PMRV6WND.js → chunk-XOPORVJG.js} +58 -12
- package/dist/{chunk-PMRV6WND.js.map → chunk-XOPORVJG.js.map} +1 -1
- package/dist/{chunk-FHVF26YA.js → chunk-ZFM6AGWV.js} +2 -2
- package/dist/core/index.d.ts +12 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/{index-BHFInYVr.d.ts → index-BNKhgDdC.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.native.d.ts +5 -5
- package/dist/index.native.js +2 -2
- package/dist/index.web.d.ts +5 -5
- package/dist/index.web.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/{useDbCount-Cu2Q5ZdH.d.ts → useDbCount-Id14x_1P.d.ts} +1 -1
- package/dist/{useResolveFeedback-Bg3JDRs8.d.ts → useResolveFeedback-Ca2rh_Bs.d.ts} +3 -3
- package/package.json +1 -1
- /package/dist/{chunk-FHVF26YA.js.map → chunk-ZFM6AGWV.js.map} +0 -0
|
@@ -551,7 +551,11 @@ declare class AdapterRegistry {
|
|
|
551
551
|
* For tables not in config, defaults to auto-detection if available,
|
|
552
552
|
* otherwise falls back to SupabaseAdapter.
|
|
553
553
|
*
|
|
554
|
-
*
|
|
554
|
+
* Supports schema-qualified table names:
|
|
555
|
+
* - "core.Profile" looks up config["core.Profile"] first, then config["Profile"]
|
|
556
|
+
* - Auto-generates PowerSync alias as "CoreProfile" if not explicitly set
|
|
557
|
+
*
|
|
558
|
+
* @param table - The table name (may be schema-qualified like "core.Profile")
|
|
555
559
|
* @returns The appropriate adapter for the table
|
|
556
560
|
* @throws Error if adapters are not initialized
|
|
557
561
|
*/
|
|
@@ -583,23 +587,37 @@ declare class AdapterRegistry {
|
|
|
583
587
|
/**
|
|
584
588
|
* Get the strategy for a specific table
|
|
585
589
|
*
|
|
586
|
-
* @param table - The table name
|
|
590
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
587
591
|
* @returns The table strategy or undefined if not configured
|
|
588
592
|
*/
|
|
589
593
|
getTableStrategy(table: string): TableStrategy | undefined;
|
|
590
594
|
/**
|
|
591
595
|
* Check if a table uses PowerSync strategy
|
|
592
596
|
*
|
|
593
|
-
* @param table - The table name
|
|
597
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
594
598
|
* @returns True if table uses PowerSync or Hybrid strategy
|
|
595
599
|
*/
|
|
596
600
|
usesPowerSync(table: string): boolean;
|
|
597
601
|
/**
|
|
598
|
-
* Get all
|
|
602
|
+
* Get all table config keys that use PowerSync (may be schema-qualified)
|
|
603
|
+
*
|
|
604
|
+
* @returns Array of config keys using PowerSync or Hybrid strategy
|
|
605
|
+
*/
|
|
606
|
+
getPowerSyncTableKeys(): string[];
|
|
607
|
+
/**
|
|
608
|
+
* Get all tables that use PowerSync (returns aliases for PowerSync schema)
|
|
599
609
|
*
|
|
600
|
-
* @returns Array of
|
|
610
|
+
* @returns Array of PowerSync table aliases
|
|
601
611
|
*/
|
|
602
612
|
getPowerSyncTables(): string[];
|
|
613
|
+
/**
|
|
614
|
+
* Get the PowerSync alias for a table.
|
|
615
|
+
* Uses explicit alias from config if set, otherwise auto-generates.
|
|
616
|
+
*
|
|
617
|
+
* @param table - Table name (may be schema-qualified)
|
|
618
|
+
* @returns The alias to use in PowerSync schema
|
|
619
|
+
*/
|
|
620
|
+
getTableAlias(table: string): string;
|
|
603
621
|
/**
|
|
604
622
|
* Get adapter using auto-detection
|
|
605
623
|
*
|
|
@@ -1554,6 +1554,23 @@ function createAdapterAutoDetector(powerSyncDb, supabase, options) {
|
|
|
1554
1554
|
}
|
|
1555
1555
|
|
|
1556
1556
|
// src/adapters/registry.ts
|
|
1557
|
+
function generatePowerSyncAlias(tableName) {
|
|
1558
|
+
if (!tableName.includes(".")) {
|
|
1559
|
+
return tableName;
|
|
1560
|
+
}
|
|
1561
|
+
const [schema, table] = tableName.split(".");
|
|
1562
|
+
const pascalSchema = schema.charAt(0).toUpperCase() + schema.slice(1);
|
|
1563
|
+
return `${pascalSchema}${table}`;
|
|
1564
|
+
}
|
|
1565
|
+
function getPowerSyncAlias(tableName, strategy) {
|
|
1566
|
+
if (strategy && (strategy.strategy === "powersync" || strategy.strategy === "hybrid")) {
|
|
1567
|
+
const typedStrategy = strategy;
|
|
1568
|
+
if (typedStrategy.alias) {
|
|
1569
|
+
return typedStrategy.alias;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return generatePowerSyncAlias(tableName);
|
|
1573
|
+
}
|
|
1557
1574
|
var AdapterRegistry = class {
|
|
1558
1575
|
/**
|
|
1559
1576
|
* Create a new adapter registry
|
|
@@ -1670,16 +1687,23 @@ var AdapterRegistry = class {
|
|
|
1670
1687
|
* For tables not in config, defaults to auto-detection if available,
|
|
1671
1688
|
* otherwise falls back to SupabaseAdapter.
|
|
1672
1689
|
*
|
|
1673
|
-
*
|
|
1690
|
+
* Supports schema-qualified table names:
|
|
1691
|
+
* - "core.Profile" looks up config["core.Profile"] first, then config["Profile"]
|
|
1692
|
+
* - Auto-generates PowerSync alias as "CoreProfile" if not explicitly set
|
|
1693
|
+
*
|
|
1694
|
+
* @param table - The table name (may be schema-qualified like "core.Profile")
|
|
1674
1695
|
* @returns The appropriate adapter for the table
|
|
1675
1696
|
* @throws Error if adapters are not initialized
|
|
1676
1697
|
*/
|
|
1677
1698
|
getAdapter(table) {
|
|
1678
|
-
const
|
|
1699
|
+
const tableWithoutSchema = table.includes(".") ? table.split(".")[1] : table;
|
|
1700
|
+
const strategy = this.config.tables[table] ?? this.config.tables[tableWithoutSchema];
|
|
1701
|
+
const configKey = this.config.tables[table] ? table : tableWithoutSchema;
|
|
1679
1702
|
if (!strategy || strategy.strategy === "auto") {
|
|
1680
1703
|
if (this.powerSyncAdapter) {
|
|
1681
|
-
const
|
|
1682
|
-
|
|
1704
|
+
const powerSyncTableKeys = this.getPowerSyncTableKeys();
|
|
1705
|
+
const isConfigured = powerSyncTableKeys.some((key) => key === table || key === tableWithoutSchema || key.includes(".") && key.split(".")[1] === tableWithoutSchema);
|
|
1706
|
+
if (!isConfigured) {
|
|
1683
1707
|
if (this.supabaseAdapter) {
|
|
1684
1708
|
return this.supabaseAdapter;
|
|
1685
1709
|
}
|
|
@@ -1737,29 +1761,51 @@ var AdapterRegistry = class {
|
|
|
1737
1761
|
/**
|
|
1738
1762
|
* Get the strategy for a specific table
|
|
1739
1763
|
*
|
|
1740
|
-
* @param table - The table name
|
|
1764
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
1741
1765
|
* @returns The table strategy or undefined if not configured
|
|
1742
1766
|
*/
|
|
1743
1767
|
getTableStrategy(table) {
|
|
1744
|
-
|
|
1768
|
+
const tableWithoutSchema = table.includes(".") ? table.split(".")[1] : table;
|
|
1769
|
+
return this.config.tables[table] ?? this.config.tables[tableWithoutSchema];
|
|
1745
1770
|
}
|
|
1746
1771
|
/**
|
|
1747
1772
|
* Check if a table uses PowerSync strategy
|
|
1748
1773
|
*
|
|
1749
|
-
* @param table - The table name
|
|
1774
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
1750
1775
|
* @returns True if table uses PowerSync or Hybrid strategy
|
|
1751
1776
|
*/
|
|
1752
1777
|
usesPowerSync(table) {
|
|
1753
|
-
const strategy = this.
|
|
1778
|
+
const strategy = this.getTableStrategy(table);
|
|
1754
1779
|
return strategy?.strategy === "powersync" || strategy?.strategy === "hybrid";
|
|
1755
1780
|
}
|
|
1756
1781
|
/**
|
|
1757
|
-
* Get all
|
|
1782
|
+
* Get all table config keys that use PowerSync (may be schema-qualified)
|
|
1758
1783
|
*
|
|
1759
|
-
* @returns Array of
|
|
1784
|
+
* @returns Array of config keys using PowerSync or Hybrid strategy
|
|
1785
|
+
*/
|
|
1786
|
+
getPowerSyncTableKeys() {
|
|
1787
|
+
return Object.entries(this.config.tables).filter(([_, strategy]) => strategy.strategy === "powersync" || strategy.strategy === "hybrid").map(([key]) => key);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Get all tables that use PowerSync (returns aliases for PowerSync schema)
|
|
1791
|
+
*
|
|
1792
|
+
* @returns Array of PowerSync table aliases
|
|
1760
1793
|
*/
|
|
1761
1794
|
getPowerSyncTables() {
|
|
1762
|
-
return Object.entries(this.config.tables).filter(([_, strategy]) => strategy.strategy === "powersync" || strategy.strategy === "hybrid").map(([
|
|
1795
|
+
return Object.entries(this.config.tables).filter(([_, strategy]) => strategy.strategy === "powersync" || strategy.strategy === "hybrid").map(([key, strategy]) => getPowerSyncAlias(key, strategy));
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Get the PowerSync alias for a table.
|
|
1799
|
+
* Uses explicit alias from config if set, otherwise auto-generates.
|
|
1800
|
+
*
|
|
1801
|
+
* @param table - Table name (may be schema-qualified)
|
|
1802
|
+
* @returns The alias to use in PowerSync schema
|
|
1803
|
+
*/
|
|
1804
|
+
getTableAlias(table) {
|
|
1805
|
+
const strategy = this.getTableStrategy(table);
|
|
1806
|
+
const tableWithoutSchema = table.includes(".") ? table.split(".")[1] : table;
|
|
1807
|
+
const configKey = this.config.tables[table] ? table : tableWithoutSchema;
|
|
1808
|
+
return getPowerSyncAlias(configKey, strategy);
|
|
1763
1809
|
}
|
|
1764
1810
|
// ===========================================================================
|
|
1765
1811
|
// Auto-Detection Methods
|
|
@@ -3871,4 +3917,4 @@ export {
|
|
|
3871
3917
|
useApplyFeedback,
|
|
3872
3918
|
useResolveFeedback
|
|
3873
3919
|
};
|
|
3874
|
-
//# sourceMappingURL=chunk-
|
|
3920
|
+
//# sourceMappingURL=chunk-XOPORVJG.js.map
|