///
import { Platform } from '@prisma/get-platform';
import { GeneratorConfig } from '@prisma/generator-helper';
import { RustLog, RustError } from './log';
import { ChildProcessWithoutNullStreams } from 'child_process';
export interface DatasourceOverwrite {
name: string;
url: string;
}
export interface EngineConfig {
cwd?: string;
datamodelPath: string;
debug?: boolean;
prismaPath?: string;
fetcher?: (query: string) => Promise<{
data?: any;
error?: any;
}>;
generator?: GeneratorConfig;
datasources?: DatasourceOverwrite[];
showColors?: boolean;
logQueries?: boolean;
logLevel?: 'info' | 'warn';
env?: Record;
flags?: string[];
}
export declare type Deferred = {
resolve: () => void;
reject: (err: Error) => void;
};
export declare class NodeEngine {
private logEmitter;
private showColors;
private logQueries;
private logLevel?;
private env?;
private flags;
port?: number;
debug: boolean;
child?: ChildProcessWithoutNullStreams;
/**
* exiting is used to tell the .on('exit') hook, if the exit came from our script.
* As soon as the Prisma binary returns a correct return code (like 1 or 0), we don't need this anymore
*/
exiting: boolean;
managementApiEnabled: boolean;
datamodelJson?: string;
cwd: string;
datamodelPath: string;
prismaPath?: string;
url: string;
ready: boolean;
stderrLogs: string;
stdoutLogs: string;
currentRequestPromise?: any;
cwdPromise: Promise;
platformPromise: Promise;
platform?: Platform | string;
generator?: GeneratorConfig;
incorrectlyPinnedPlatform?: string;
datasources?: DatasourceOverwrite[];
lastErrorLog?: RustLog;
lastError?: RustError;
startPromise?: Promise;
engineStartDeferred?: Deferred;
constructor({ cwd, datamodelPath, prismaPath, generator, datasources, showColors, logLevel, logQueries, env, flags, ...args }: EngineConfig);
private resolveCwd;
on(event: 'query' | 'info' | 'warn', listener: (log: RustLog) => any): void;
getPlatform(): Promise;
private getQueryEnginePath;
private handlePanic;
private resolvePrismaPath;
private getPrismaPath;
printDatasources(): string;
/**
* Starts the engine, returns the url that it runs on
*/
start(): Promise;
private internalStart;
fail: (e: any, why: any) => Promise;
/**
* If Prisma runs, stop it
*/
stop(): Promise;
/**
* Use the port 0 trick to get a new port
*/
protected getFreePort(): Promise;
/**
* Make sure that our internal port is not conflicting with the prisma.yml's port
* @param str config
*/
protected trimPort(str: string): string;
request(queries: string[]): Promise;
private graphQLToJSError;
}