import { Readable } from 'stream'; import { BaseConnection, Close } from './baseConnection.types.js'; import { Ifs } from './ifs/types.js'; interface ProgramDefinitionOptions { programName: string; paramsSchema: PgmParamType[]; libraryName?: string; ccsid?: number; } interface PgmParamType1 { name: string; size: number; type?: string; decimals?: number; } interface PgmParamType2 { name: string; precision: number; typeName?: string; scale?: number; } interface PgmParamStructType { [key: string]: PgmParamType[]; } type PgmParamType = PgmParamType1 | PgmParamType2 | PgmParamStructType; interface JustNameMessageQ { name: string; } interface JustPathMessageQ { path: string; } type MessageQOptions = JustNameMessageQ | JustPathMessageQ; interface MessageQReadOptions { wait?: number; } interface DataQReadOptions { key: string; wait?: number; writeKeyLength?: number; } interface MessageFileHandlerOptions { path: string; } interface MessageFileReadOptions { messageId: string[7]; } interface MessageQ { sendInformational: (messageText: string) => Promise; read: (params?: MessageQReadOptions) => Promise | Promise; } interface DataQOptions { name: string; } interface KeyedDataQ { write: (key: string, data: string) => void; read: (params: DataQReadOptions | string) => Promise; } interface AS400Message { getText: () => Promise; } interface MessageFileHandler { read: (params: MessageFileReadOptions) => Promise; } type TransactionFun = (transaction: BaseConnection) => Promise; interface Connection extends BaseConnection { pgm: (programName: string, paramsSchema: PgmParamType[], libraryName?: string) => any; defineProgram: (options: ProgramDefinitionOptions) => any; getTablesAsStream: (params: any) => Readable; getColumns: (params: any) => any; getPrimaryKeys: (params: any) => any; transaction: (fn: TransactionFun) => Promise; openMessageQ: (params: MessageQOptions) => Promise; createKeyedDataQ: (params: DataQOptions) => KeyedDataQ; openMessageFile: (params: MessageFileHandlerOptions) => Promise; ifs: () => Ifs; close: Close; } export type { AS400Message, Connection, DataQOptions, DataQReadOptions, JustNameMessageQ, JustPathMessageQ, KeyedDataQ, MessageFileHandler, MessageFileHandlerOptions, MessageFileReadOptions, MessageQ, MessageQOptions, MessageQReadOptions, PgmParamStructType, PgmParamType, PgmParamType1, PgmParamType2, ProgramDefinitionOptions, TransactionFun };