@mixxtor/currencyx-adonisjs
Version:
AdonisJS integration for CurrencyX.js with database exchange provider and cache support
55 lines (54 loc) • 1.89 kB
TypeScript
import type { CurrencyCode, ConversionResult, ExchangeRatesResult, ConvertParams, ExchangeRatesParams } from '@mixxtor/currencyx-js';
import { BaseCurrencyExchange } from '@mixxtor/currencyx-js';
import type { DatabaseConfig } from '../types.js';
import type { CacheService } from '@adonisjs/cache/types';
import { PROVIDER_CURRENCY_MODEL } from '../symbols.js';
import type { LucidModel } from '@adonisjs/lucid/types/model';
export declare class DatabaseExchange<Model extends LucidModel = LucidModel> extends BaseCurrencyExchange {
#private;
[PROVIDER_CURRENCY_MODEL]: InstanceType<Model>;
readonly name = "database";
protected model?: Model;
private columns;
private configModel?;
private cache?;
private cacheSetupPromise?;
private config;
constructor(config: DatabaseConfig<Model>);
/**
* Imports the model from the provider, returns and caches it
* for further operations.
*/
protected getModel(): Promise<Model>;
/**
* Imports the cache service from the provider, returns and caches it
* for further operations.
*/
protected getCacheService(): Promise<CacheService>;
/**
* Convert currency using database rates
*/
convert(params: ConvertParams): Promise<ConversionResult>;
/**
* Get latest rates (required abstract method)
*/
latestRates(params?: ExchangeRatesParams & {
cache?: boolean;
}): Promise<ExchangeRatesResult>;
/**
* Clear the currency cache
*/
clearCache(): Promise<void>;
/**
* Refresh currency data from database
*/
refreshCurrencyData(): Promise<void>;
/**
* Get convert rate (required abstract method)
*/
getConvertRate(from: CurrencyCode, to: CurrencyCode): Promise<number | undefined>;
/**
* Cleanup method for graceful shutdown
*/
cleanup(): Promise<void>;
}