UNPKG

node-test-bed-adapter

Version:

An adapter to connect a node.js application to the Test-bed's Common Information Space or Common Simulation Space.

61 lines (60 loc) 2.8 kB
import { Readable } from 'stream'; import { DataType } from 'test-bed-schemas'; import { TestBedAdapter, RecordMetadata } from '../index.mjs'; import { ITestBedOptions } from '../models/index.mjs'; import { Logger } from '../logger/logger.mjs'; export declare const clone: <T extends any>(model: T) => T; /** * Find all files recursively in specific folder with specific extension * * @param directoryName Path relative to this file or other file which requires this files * @param ext Extension name, e.g: '.html' * @return Result files with path string in an array */ export declare const findFilesInDir: (directoryName: string, ext: string) => string[]; /** * Look for schema files that represent a value, but without a corresponding key file, i.e. * a schema file names <topic>-value.avsc should also have a <topic>-key.avsc. * * @param files Found schema files * @return missing key schema files */ export declare const findMissingKeyFiles: (files: string[]) => string[]; /** * Create a RFC4122 version 4 GUID * * @see https://stackoverflow.com/a/2117523/319711 * * @returns RFC4122 version 4 compliant GUID */ export declare const uuid4: () => string; /** * Check if the object is empty. * @param obj Any object * @see https://stackoverflow.com/a/32108184/319711 */ export declare const isEmptyObject: (obj: Object) => boolean; /** Convert a buffer to a readable stream, e.g. to send it via FormData */ export declare const bufferToStream: (buffer: Buffer) => Readable; /** * Helper function to create a callback that automatically sends a large file upload message * to the Test-bed's LargeDataUpdateTopic (system_large_data_update). This callback can be * passed to the uploadFile function of the adapter. * * @param adapter test bed adapter, needed to send the message * @param title title of the large file upload message * @param description description of the large file upload message * @param dataType data type of the message * @param callback to return the result of the large file upload (default logs errors) */ export declare const largeFileUploadCallback: (adapter: TestBedAdapter, title?: string, description?: string, dataType?: DataType, cb?: (err: Error, data?: RecordMetadata[]) => void) => (err?: Error, url?: string) => void; /** Is unique filter for array filter method */ export declare const isUnique: <T extends any>(value: T, index: number, arr: T[]) => boolean; /** Check if the schema registry is available */ export declare const isSchemaRegistryAvailable: (options: ITestBedOptions, log: Logger) => Promise<void>; export declare const resolveUrl: (from: string, to: string) => string; /** Sleep for msec time */ export declare const sleep: (msec: number) => Promise<unknown>; export interface MapOptions { concurrency?: number; }