///
import { Writable, Transform } from 'node:stream';
import Docker from 'dockerode';
import { Chain, Deploy } from '@fadroma/agent';
import { Error, Console } from "./oci-base.dist";
import type { DockerHandle } from "./oci-base.dist";
import * as Mock from "./oci-mock.dist";
export { Mock, Error, Console };
export declare const console: Console;
declare class OCIConnection extends Chain.Connection {
static mock(callback?: Function): OCIConnection;
/** By default, creates an instance of Dockerode
* connected to env `DOCKER_HOST`. You can also pass
* your own Dockerode instance or socket path. */
constructor(properties?: Partial);
api: DockerHandle;
doGetHeight(): Promise;
doGetBlockInfo(): Promise<{}>;
doGetBalance(): Promise;
doSend(): Promise;
doSendMany(): Promise;
doGetCodeId(containerId: string): Promise;
doGetCodeHashOfCodeId(contract: any): Promise;
doGetCodeHashOfAddress(contract: any): Promise;
/** Returns list of container images. */
doGetCodes(): Promise<{}>;
/** Returns list of containers from a given image. */
doGetContractsByCodeId(imageId: any): Promise<{
address: string;
codeId: any;
container: Docker.ContainerInfo;
}[]>;
doUpload(data: Uint8Array): Promise<{}>;
doInstantiate(imageId: string): Promise<{}>;
doExecute(): Promise<{}>;
doQuery(contract: any, message: any): Promise<{}>;
image(name: string | null, dockerfile?: string | null, inputFiles?: string[]): OCIImage;
container(id: string): OCIContainer;
}
declare class OCIImage extends Deploy.ContractTemplate {
constructor(properties?: Partial);
log: Console;
engine: OCIConnection | null;
dockerfile: string | null;
inputFiles: string[];
get [Symbol.toStringTag](): string;
protected _available: Promise | null;
get api(): Docker.Image;
container(name?: string, options?: Partial, command?: ContainerCommand, entrypoint?: ContainerCommand): OCIContainer;
/** Get info about a container. */
inspect(): Promise;
/** Check if the image exists. */
exists(): Promise;
/** Throws if inspected image does not exist locally. */
assertExists(): Promise;
/** Remove this image. */
remove(): Promise;
/** Pull the image from the registry, or build it from a local file if not available there. */
pullOrBuild(): Promise;
/** Throws if inspected image does not exist in Docker Hub. */
pull(): Promise;
build(): Promise;
/** Run a container from this image. */
run(parameters?: {
name?: string;
options?: Partial;
command?: ContainerCommand;
entrypoint?: ContainerCommand;
outputStream?: Writable;
}): Promise;
}
/** Interface to a Docker container. */
declare class OCIContainer extends Deploy.ContractInstance {
constructor(properties?: Partial);
id?: string;
engine: OCIConnection | null;
image: OCIImage;
entrypoint?: ContainerCommand;
command?: ContainerCommand;
options: Partial;
log: Console;
get [Symbol.toStringTag](): string;
get api(): Docker.Container;
get shortId(): string;
/** Get info about a container. */
inspect(): Promise;
ip(): Promise;
exists(): Promise;
/** Create a container. */
create(): Promise;
/** Remove a stopped container. */
remove(): Promise;
/** Is this container running? */
isRunning(): Promise;
/** Start the container. */
start(): Promise;
/** Immediately terminate the container. */
kill(): Promise;
/** Wait for the container to exit. */
wait(): Promise<{
error: any;
code: any;
}>;
/** Wait for the container logs to emit an expected string. */
waitLog(expected: string, logFilter?: (data: string) => boolean, thenDetach?: boolean): Promise;
/** Executes a command in the container.
* @returns [stdout, stderr] */
exec(...command: string[]): Promise<[string, string]>;
/** Save a container as an image. */
export(repository?: string, tag?: string): Promise;
}
export interface ContainerOptions {
cwd: string;
env: Record;
exposed: string[];
mapped: Record;
readonly: Record;
writable: Record;
extra: Record;
remove: boolean;
}
export type ContainerCommand = string | string[];
export interface ContainerState {
Image: string;
State: {
Running: boolean;
};
NetworkSettings: {
IPAddress: string;
};
}
/** Follow the output stream from a Dockerode container until it closes. */
export declare function follow(dockerode: DockerHandle, stream: any, callback: (data: any) => void): Promise;
/** Based on: Line Transform Stream by Nick Schwarzenberg
* https://github.com/bitfasching/node-line-transform-stream#readme
* Used under MIT license. */
export declare class LineTransformStream extends Transform {
transformCallback: Function;
stringEncoding: string;
lineBuffer: string;
constructor(transformCallback: Function, stringEncoding?: string);
_transform(data: any, encoding: string, callback: Function): void;
}
export { OCIConnection as Connection, OCIImage as Image, OCIContainer as Container, };
export declare const toLabel: ({ id, shortId, name }: {
id?: string;
shortId?: string;
name?: string;
}) => string;
//# sourceMappingURL=oci.d.ts.map