import { injectable } from '@cloudbeaver/core-di' ; import { GraphQLService , CachedMapResource , ResourceKey , SqlQueryGenerator , ResourceKeyUtils , resourceKeyList , } from '@cloudbeaver/core-sdk' ; import { NavNodeInfoResource } from '../NodesManager/NavNodeInfoResource' ; export const MAX_GENERATORS_LENGTH = 15 ; @ injectable ( ) export class SqlGeneratorsResource extends CachedMapResource < string , SqlQueryGenerator [ ] > { constructor ( private readonly graphQLService , private readonly navNodeInfoResource ) { super ( ) ; this . navNodeInfoResource . outdateResource ( this ) ; this . navNodeInfoResource . deleteInResource ( this ) ; } async generateEntityQuery ( generatorId , nodePathList ) { const result = await this . graphQLService . sdk . sqlGenerateEntityQuery ( { generatorId , nodePathList , options : { } , } ) ; return result . sqlGenerateEntityQuery ; } protected async loader ( key ) { const values = new Map ( ) ; await ResourceKeyUtils . forEachAsync ( key , async ( key ) => { const { generators } = await this . graphQLService . sdk . sqlEntityQueryGenerators ( ( { nodePathList : key , } ) ) ; values . set ( key , generators ) ; } ) ; this . set ( resourceKeyList ( Array . from ( values . keys ( ) ) ) , Array . from ( values . values ( ) ) ) ; return this . data ; } }