bb-inspired
Version:
Core library for BB-inspired NestJS backend
42 lines (41 loc) • 1.43 kB
TypeScript
import { HttpService } from '@nestjs/axios';
import { ExportOptions, ImportOptions, ExportResult, ImportResult, DataExportPackage, SchemaDefinition } from './data-transfer.interfaces';
export interface DataTransferOptions {
basePath?: string;
defaultFormat?: 'json' | 'csv' | 'xml';
encryption?: {
algorithm: string;
secretKey?: string;
};
compression?: {
enabled: boolean;
level?: number;
};
validation?: {
enabled: boolean;
strictMode?: boolean;
};
global?: boolean;
}
export declare class DataTransferService {
private options;
private readonly httpService?;
private readonly logger;
private readonly defaultOptions;
constructor(options?: DataTransferOptions, httpService?: HttpService);
exportData<T = any>(data: T, options?: ExportOptions): Promise<ExportResult<T>>;
importData<T = any>(source: string | Buffer | DataExportPackage<T>, options?: ImportOptions): Promise<ImportResult<T>>;
createSchemaFromSample(sample: any, additionalProperties?: boolean): SchemaDefinition;
private validateImportData;
private calculateChecksum;
private serializeData;
private deserializeData;
private parseCSVLine;
private encryptData;
private decryptData;
private saveToFile;
private readFromFile;
private sendToHttp;
private fetchFromHttp;
private getContentTypeForFormat;
}