@@ -9,7 +9,7 @@ import { FractionsQueryStrategy } from "./FractionsQueryStrategy.js";
99import { HyperboardsQueryStrategy } from "./HyperboardsQueryStrategy.js" ;
1010import { MarketplaceOrdersQueryStrategy } from "./MarketplaceOrdersQueryStrategy.js" ;
1111import { MetadataQueryStrategy } from "./MetadataQueryStrategy.js" ;
12- import { QueryStrategy , SupportedDatabases } from "./QueryStrategy.js" ;
12+ import { QueryStrategy , SupportedDatabase } from "./QueryStrategy.js" ;
1313import { SalesQueryStrategy } from "./SalesQueryStrategy.js" ;
1414import { SignatureRequestsQueryStrategy } from "./SignatureRequestsQueryStrategy.js" ;
1515import { SupportedSchemasQueryStrategy } from "./SupportedSchemasQueryStrategy.js" ;
@@ -29,7 +29,7 @@ type QueryArgs = BaseQueryArgsType<
2929 * Type for strategy constructors to ensure they match the QueryStrategy interface
3030 */
3131type QueryStrategyConstructor <
32- DB extends SupportedDatabases = SupportedDatabases ,
32+ DB extends SupportedDatabase = SupportedDatabase ,
3333 T extends keyof DB & string = keyof DB & string ,
3434 Args extends QueryArgs = QueryArgs ,
3535> = new ( ) => QueryStrategy < DB , T , Args > ;
@@ -38,8 +38,8 @@ type QueryStrategyConstructor<
3838 * Type for the strategy registry mapping table names to their constructors
3939 */
4040type StrategyRegistry = {
41- [ K in keyof SupportedDatabases & string ] : QueryStrategyConstructor <
42- SupportedDatabases ,
41+ [ K in keyof SupportedDatabase & string ] : QueryStrategyConstructor <
42+ SupportedDatabase ,
4343 K
4444 > ;
4545} ;
@@ -48,10 +48,7 @@ type StrategyRegistry = {
4848 * Type for the strategy cache mapping table names to their instances
4949 */
5050type StrategyCache = {
51- [ K in keyof SupportedDatabases & string ] ?: QueryStrategy <
52- SupportedDatabases ,
53- K
54- > ;
51+ [ K in keyof SupportedDatabase & string ] ?: QueryStrategy < SupportedDatabase , K > ;
5552} ;
5653
5754/**
@@ -91,13 +88,13 @@ export class QueryStrategyFactory {
9188 * Cache of strategy instances
9289 * @private
9390 */
94- private static strategies : StrategyCache = new Proxy < StrategyCache > (
91+ private static strategies = new Proxy < StrategyCache > (
9592 { } ,
9693 {
97- get < K extends keyof SupportedDatabases & string > (
94+ get < K extends keyof SupportedDatabase & string > (
9895 target : StrategyCache ,
9996 prop : K | string | symbol ,
100- ) : QueryStrategy < SupportedDatabases , K > | undefined {
97+ ) : QueryStrategy < SupportedDatabase , K > | undefined {
10198 if ( typeof prop !== "string" ) {
10299 return undefined ;
103100 }
@@ -106,7 +103,7 @@ export class QueryStrategyFactory {
106103
107104 // Check if we already have a cached instance
108105 if ( key in target && target [ key ] ) {
109- return target [ key ] as QueryStrategy < SupportedDatabases , K > ;
106+ return target [ key ] as QueryStrategy < SupportedDatabase , K > ;
110107 }
111108
112109 // Get the constructor from the registry
@@ -121,10 +118,10 @@ export class QueryStrategyFactory {
121118
122119 // Create and cache a new instance
123120 const strategy = new Constructor ( ) as QueryStrategy <
124- SupportedDatabases ,
121+ SupportedDatabase ,
125122 K
126123 > ;
127- ( target as Record < K , QueryStrategy < SupportedDatabases , K > > ) [ key ] =
124+ ( target as Record < K , QueryStrategy < SupportedDatabase , K > > ) [ key ] =
128125 strategy ;
129126 return strategy ;
130127 } ,
@@ -140,18 +137,17 @@ export class QueryStrategyFactory {
140137 * @throws Error if no strategy is registered for the table
141138 */
142139 static getStrategy <
143- DB extends SupportedDatabases ,
140+ DB extends SupportedDatabase ,
144141 T extends keyof DB & string ,
145142 Args extends QueryArgs = QueryArgs ,
146143 > ( tableName : T ) : QueryStrategy < DB , T , Args > {
147- const strategy = ( this . strategies as Record < T , QueryStrategy < DB , T , Args > > ) [
148- tableName
149- ] ;
144+ const strategy =
145+ this . strategies [ tableName as keyof SupportedDatabase & string ] ;
150146 if ( ! strategy ) {
151147 throw new Error (
152148 `Failed to get strategy for table "${ tableName } ". This might be a type mismatch or the strategy is not properly registered.` ,
153149 ) ;
154150 }
155- return strategy ;
151+ return strategy as QueryStrategy < DB , T , Args > ;
156152 }
157153}
0 commit comments