File tree Expand file tree Collapse file tree 4 files changed +41
-18
lines changed
Expand file tree Collapse file tree 4 files changed +41
-18
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,15 @@ export interface ImportPlugin<
3737// withOptions: WithOptions<ImportPlugin>;
3838// }
3939
40- export interface ExportPlugin extends Plugin {
40+ export interface ExportPlugin <
41+ PluginName extends string ,
42+ ConcreteSourceOptions extends object = any ,
43+ ConcreteDestOptions extends object = any
44+ > extends Plugin {
45+ __name : PluginName ;
4146 exportData : (
42- sourceOptions : any ,
43- destOptions : any
47+ sourceOptions : ConcreteSourceOptions ,
48+ destOptions : ConcreteDestOptions
4449 ) => Promise < { response : any | null ; error : any | null ; info ?: any | null } > ;
4550}
4651
@@ -87,9 +92,9 @@ export type ExportPluginFromList<
8792 ConcretePluginList extends PluginList ,
8893 PluginName extends ExtractPlugin <
8994 ConcretePluginList ,
90- ExportPlugin
95+ ExportPlugin < string >
9196 > [ "__name" ] = string
92- > = ExtractPlugin < ConcretePluginList , ExportPlugin & { __name : PluginName } > ;
97+ > = ExtractPlugin < ConcretePluginList , ExportPlugin < PluginName > > ;
9398
9499export interface DbOptions < ConcretePluginList extends PluginList > {
95100 plugins : ConcretePluginList ;
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ import {
3333import type { HTTPStrategies , HTTPClientOptions } from "@madatdata/client-http" ;
3434
3535export type DefaultSeafowlPluginList <
36- ConcretePluginList extends ( ImportPlugin < string > | ExportPlugin ) [ ] = (
36+ ConcretePluginList extends ( ImportPlugin < string > | ExportPlugin < string > ) [ ] = (
3737 | ImportPlugin < string >
38- | ExportPlugin
38+ | ExportPlugin < string >
3939 ) [ ]
4040> = ConcretePluginList [ number ] [ ] ;
4141
@@ -265,10 +265,16 @@ export class DbSeafowl<SeafowlPluginList extends PluginList>
265265 ) ;
266266 }
267267
268- async exportData (
269- _pluginName : ExtractPlugin < SeafowlPluginList , ExportPlugin > [ "__name" ] ,
268+ // TODO: atm, there are no Seafowl export plugins
269+ async exportData <
270+ PluginName extends ExtractPlugin <
271+ SeafowlPluginList ,
272+ ExportPlugin < string >
273+ > [ "__name" ]
274+ > (
275+ _pluginName : PluginName ,
270276 ..._rest : Parameters <
271- ExtractPlugin < SeafowlPluginList , ExportPlugin > [ "exportData" ]
277+ ExtractPlugin < SeafowlPluginList , ExportPlugin < PluginName > > [ "exportData" ]
272278 >
273279 ) : Promise < unknown > {
274280 await Promise . resolve ( ) ;
Original file line number Diff line number Diff line change @@ -285,10 +285,18 @@ export class DbSplitgraph<SplitgraphPluginList extends PluginList>
285285 } ;
286286 }
287287
288- async exportData (
289- pluginName : ExtractPlugin < SplitgraphPluginList , ExportPlugin > [ "__name" ] ,
288+ async exportData <
289+ PluginName extends ExtractPlugin <
290+ SplitgraphPluginList ,
291+ ExportPlugin < string >
292+ > [ "__name" ]
293+ > (
294+ pluginName : PluginName ,
290295 ...rest : Parameters <
291- ExtractPlugin < SplitgraphPluginList , ExportPlugin > [ "exportData" ]
296+ ExtractPlugin <
297+ SplitgraphPluginList ,
298+ ExportPlugin < PluginName >
299+ > [ "exportData" ]
292300 >
293301 ) {
294302 const [ sourceOpts , destOpts ] = rest ;
@@ -299,10 +307,12 @@ export class DbSplitgraph<SplitgraphPluginList extends PluginList>
299307 plugin
300308 ) : plugin is ExtractPlugin <
301309 SplitgraphPluginList ,
302- ExportPlugin & { __name : typeof pluginName } & Partial <
303- WithOptionsInterface < ExportPlugin >
304- >
305- > => "exportData" in Object . getPrototypeOf ( plugin )
310+ ExportPlugin < typeof pluginName > & {
311+ __name : typeof pluginName ;
312+ } & Partial < WithOptionsInterface < ExportPlugin < typeof pluginName > > >
313+ > =>
314+ "exportData" in Object . getPrototypeOf ( plugin ) &&
315+ plugin . __name === pluginName
306316 )
307317 . pop ( ) ;
308318
Original file line number Diff line number Diff line change @@ -53,7 +53,9 @@ const retryOptions = {
5353 exponentialOption : { maxInterval : MAX_BACKOFF_INTERVAL , multiplier : 2 } ,
5454} ;
5555export class ExportQueryPlugin
56- implements ExportPlugin , WithOptionsInterface < ExportQueryPlugin >
56+ implements
57+ ExportPlugin < "exportQuery" > ,
58+ WithOptionsInterface < ExportQueryPlugin >
5759{
5860 private readonly opts : ExportQueryPluginOptions ;
5961 public readonly graphqlEndpoint : ExportQueryPluginOptions [ "graphqlEndpoint" ] ;
You can’t perform that action at this time.
0 commit comments