import { injectable } from '@cloudbeaver/core-di' ; import { SessionResource } from '@cloudbeaver/core-root' ; import { CachedDataResource , GraphQLService , UserConnectionAuthPropertiesFragment } from '@cloudbeaver/core-sdk' ; export type UserMetaParameter = UserConnectionAuthPropertiesFragment ; export interface IUserMetaParameterOptions { id : string ; displayName : string ; description ? : string ; required : boolean ; } @ injectable ( ) export class UserMetaParametersResource extends CachedDataResource < UserMetaParameter [ ] > { constructor ( private graphQLService , sessionResource ) { super ( [ ] ) ; this . sync ( sessionResource ) ; } async add ( options ) { const { parameter } = await this . graphQLService . sdk . setUserMetaParameter ( options ) ; this . data . push ( parameter ) ; return parameter ; } async delete ( id ) { await this . graphQLService . sdk . deleteUserMetaParameter ( { id } ) ; const index = this . data . findIndex ( property => property . id === id ) ; if ( index > - 1 ) { this . data . splice ( index , 1 ) ; } } protected async loader ( ) { const { properties } = await this . graphQLService . sdk . getUserProfileProperties ( ) ; return properties ; } }