import { CudOperation, TransactionPackage, DBClientInputSessionTarget, DbClientOutputClosePackage, DbClientOutputReloadPackage, DbClientOutputSignalPackage, DbSelector, DbSession, DbSessions, DbToken, IfOptionValue, PreTransactionPackage } from "./dbDefinitions"; import { DataboxClass } from "../../api/databox/Databox"; import DataboxContainer from "../../api/databox/container/databoxContainer"; import { StaticDataboxClass } from "../../api/databox/StaticDatabox"; import StaticDataboxContainer from "../../api/databox/container/staticDataboxContainer"; export default class DataboxUtils { /** * Creates a the PreTransactionPackage. */ static buildPreTransactionPackage(operations?: CudOperation[], code?: number | string, metadata?: any): PreTransactionPackage; static buildTransactionPackage(preTransactionPackage: PreTransactionPackage, timestamp?: number): TransactionPackage; /** * Generates the start transactionId. */ static generateStartTransactionId(): string; static buildInsert(selector: DbSelector, value: any, ifOption?: IfOptionValue, potentialUpdate?: boolean): CudOperation; static buildUpdate(selector: DbSelector, value: any, ifOption?: IfOptionValue, potentialInsert?: boolean): CudOperation; static buildDelete(selector: DbSelector, ifOption?: IfOptionValue): CudOperation; static buildClientReloadPackage(): DbClientOutputReloadPackage; static buildClientClosePackage(code?: number | string, metadata?: any): DbClientOutputClosePackage; static buildClientSignalPackage(signal: string, data?: any): DbClientOutputSignalPackage; /** * A method that will load the instances from Databox classes * and will return the correct container for it. * @param databoxes */ static getDbContainer(databoxes: StaticDataboxClass[] | DataboxClass[]): StaticDataboxContainer | DataboxContainer; /** * Creates a new Databox token. * @param rawOptions */ static createDbToken(rawOptions: any): DbToken; /** * Create db session data. */ static createDbSessionData(): DbSessions; /** * This function is used to figure out the session that the client wants to use. * It can throw an error if the target is unknown. * @param dbSessionData * @param target */ static getSession(dbSessionData: DbSessions, target?: DBClientInputSessionTarget): DbSession; /** * Returns if the session target is the reload session. * @param target */ static isReloadTarget(target?: DBClientInputSessionTarget): boolean; /** * This function will copy the selected session in the other session. * @param dbSessionData * @param target */ static copySession(dbSessionData: DbSessions, target?: DBClientInputSessionTarget): void; /** * This function will reset the selected session. * @param dbSessionData * @param target */ static resetSession(dbSessionData: DbSessions, target?: DBClientInputSessionTarget): void; /** * Generates a unique channel input id. * @param inputChIds */ static generateInputChId(inputChIds: Set): string; /** * Checker for checking the max input channel limit, * it will throw an error to deny access. * @param current * @param max */ static maxInputChannelsCheck(current: number, max: number): void; /** * Checker for checking the max member limit, * it will throw an error to deny access. * @param current * @param max */ static maxMembersCheck(current: number, max: number): void; }