the-moby-effect
Version:
Moby/Docker API client built using effect-ts
300 lines • 11.2 kB
TypeScript
/**
* Docker engine.
*
* @since 1.0.0
*/
import type * as Effect from "effect/Effect";
import type * as Schema from "effect/Schema";
import type * as Scope from "effect/Scope";
import type * as Stream from "effect/Stream";
import type * as HttpClient from "effect/unstable/http/HttpClient";
import type * as Socket from "effect/unstable/socket/Socket";
import * as Layer from "effect/Layer";
import type * as IdSchemas from "./internal/schemas/id.ts";
import type * as MobyConnection from "./MobyConnection.ts";
import type * as MobyDemux from "./MobyDemux.ts";
import type * as MobySchemas from "./MobySchemas.ts";
import * as internalCircular from "./internal/endpoints/circular.ts";
import * as MobyEndpoints from "./MobyEndpoints.ts";
/**
* @since 1.0.0
* @category Errors
*/
export declare const DockerErrorTypeId: unique symbol;
/**
* @since 1.0.0
* @category Errors
*/
export type DockerErrorTypeId = typeof DockerErrorTypeId;
/**
* @since 1.0.0
* @category Errors
*/
export declare const isDockerError: (u: unknown) => u is DockerError;
/**
* @since 1.0.0
* @category Errors
*/
export type DockerError = internalCircular.DockerError;
/**
* @since 1.0.0
* @category Errors
*/
export declare const DockerError: typeof internalCircular.DockerError;
/**
* @since 1.0.0
* @category Layers
*/
export type DockerLayer = Layer.Layer<MobyEndpoints.Configs | MobyEndpoints.Containers | MobyEndpoints.Distributions | MobyEndpoints.Execs | MobyEndpoints.Images | MobyEndpoints.Networks | MobyEndpoints.Nodes | MobyEndpoints.Plugins | MobyEndpoints.Secrets | MobyEndpoints.Services | MobyEndpoints.Sessions | MobyEndpoints.Swarm | MobyEndpoints.System | MobyEndpoints.Tasks | MobyEndpoints.Volumes, never, never>;
/**
* @since 1.0.0
* @category Layers
*/
export type DockerLayerWithoutHttpClientOrWebsocketConstructor = Layer.Layer<Layer.Success<DockerLayer>, Layer.Error<DockerLayer>, Layer.Services<DockerLayer> | HttpClient.HttpClient | Socket.WebSocketConstructor>;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerWithoutHttpCLient: DockerLayerWithoutHttpClientOrWebsocketConstructor;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerNodeJS: (connectionOptions: MobyConnection.MobyConnectionOptions) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerBun: (connectionOptions: MobyConnection.MobyConnectionOptions) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerDeno: (connectionOptions: MobyConnection.MobyConnectionOptions) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerUndici: (connectionOptions: MobyConnection.MobyConnectionOptions) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerWeb: (connectionOptions: MobyConnection.HttpConnectionOptionsTagged | MobyConnection.HttpsConnectionOptionsTagged) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerFetch: (connectionOptions: MobyConnection.HttpConnectionOptionsTagged | MobyConnection.HttpsConnectionOptionsTagged) => DockerLayer;
/**
* @since 1.0.0
* @category Layers
*/
export declare const layerAgnostic: (connectionOptions: MobyConnection.HttpConnectionOptionsTagged | MobyConnection.HttpsConnectionOptionsTagged) => DockerLayerWithoutHttpClientOrWebsocketConstructor;
export {
/**
* @since 1.0.0
* @category Auth
* @see https://docs.docker.com/reference/api/engine/version/v1.51/#section/Authentication
*/
RegistryAuth, } from "./internal/endpoints/auth.ts";
/**
* Implements the `docker build` command. It doesn't have all the flags that the
* images build endpoint exposes.
*
* @since 1.0.0
* @category Docker
*/
export declare const build: <E1>({ buildargs, context, dockerfile, platform, tag, }: {
tag: string;
platform?: string | undefined;
dockerfile?: string | undefined;
context: Stream.Stream<Uint8Array, E1, never>;
buildargs?: Record<string, string | undefined> | undefined;
}) => Stream.Stream<MobySchemas.JSONMessage, DockerError, MobyEndpoints.Images>;
/**
* Implements the `docker build` command as a scoped effect. When the scope is
* closed, the built image is removed. It doesn't have all the flags that the
* images build endpoint exposes.
*
* @since 1.0.0
* @category Docker
*/
export declare const buildScoped: <E1>({ buildargs, context, dockerfile, platform, tag, }: {
tag: string;
platform?: string | undefined;
dockerfile?: string | undefined;
buildargs?: Record<string, string | undefined> | undefined;
context: Stream.Stream<Uint8Array, E1, never>;
}) => Effect.Effect<Stream.Stream<MobySchemas.JSONMessage, DockerError, never>, never, Scope.Scope | MobyEndpoints.Images>;
/**
* Implements the `docker exec` command in a blocking fashion. Incompatible with
* web.
*
* @since 1.0.0
* @category Docker
*/
export declare const exec: ({ command, containerId, }: {
command: string | Array<string>;
containerId: IdSchemas.ContainerIdentifier;
}) => Effect.Effect<[
exitCode: bigint,
output: string
], Socket.SocketError | Schema.SchemaError | DockerError, MobyEndpoints.Execs>;
/**
* Implements the `docker exec` command in a non blocking fashion. Incompatible
* with web when not detached.
*
* @since 1.0.0
* @category Docker
*/
export declare const execNonBlocking: <const T extends boolean = false>({ command, containerId, detach, }: {
detach: T;
command: string | Array<string>;
containerId: IdSchemas.ContainerIdentifier;
}) => Effect.Effect<[
[T] extends [false] ? MobyDemux.RawSocket | MobyDemux.MultiplexedSocket : void,
IdSchemas.ExecIdentifier
], Socket.SocketError | Schema.SchemaError | DockerError, MobyEndpoints.Execs>;
/**
* Implements the `docker exec` command in a blocking fashion with websockets as
* the underlying transport instead of the docker engine exec apis so that is
* can be compatible with web.
*
* @since 1.0.0
* @category Docker
*/
export declare const execWebsockets: ({ command, containerId, }: {
command: string | Array<string>;
containerId: IdSchemas.ContainerIdentifier;
}) => Effect.Effect<readonly [stdout: string, stderr: string], Socket.SocketError | Schema.SchemaError | DockerError, MobyEndpoints.Containers>;
/**
* Implements the `docker exec` command in a non blocking fashion with
* websockets as the underlying transport instead of the docker engine exec apis
* so that is can be compatible with web.
*
* @since 1.0.0
* @category Docker
*/
export declare const execWebsocketsNonBlocking: ({ command, containerId, cwd, }: {
command: string | Array<string>;
containerId: IdSchemas.ContainerIdentifier;
cwd?: string | undefined;
}) => Effect.Effect<MobyDemux.MultiplexedChannel<never, Socket.SocketError | DockerError, never>, never, MobyEndpoints.Containers>;
/**
* Implements the `docker images` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const images: (options?: Parameters<MobyEndpoints.Images["Service"]["list"]>[0]) => Effect.Effect<ReadonlyArray<MobySchemas.ImageSummary>, DockerError, MobyEndpoints.Images>;
/**
* Implements the `docker info` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const info: () => Effect.Effect<MobySchemas.SystemInfo, DockerError, MobyEndpoints.System>;
/**
* Implements the `docker ping` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const ping: () => Effect.Effect<void, DockerError, MobyEndpoints.System>;
/**
* Implements the `docker ping` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const pingHead: () => Effect.Effect<void, DockerError, MobyEndpoints.System>;
/**
* Implements the `docker ps` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const ps: (options?: Parameters<MobyEndpoints.Containers["Service"]["list"]>[0]) => Effect.Effect<ReadonlyArray<MobySchemas.ContainerSummary>, DockerError, MobyEndpoints.Containers>;
/**
* Implements the `docker pull` command. It does not have all the flags that the
* images create endpoint exposes.
*
* @since 1.0.0
* @category Docker
*/
export declare const pull: ({ image, platform, }: {
image: string;
platform?: string | undefined;
}) => Stream.Stream<MobySchemas.JSONMessage, DockerError, MobyEndpoints.Images>;
/**
* Implements the `docker pull` command as a scoped effect. When the scope is
* closed, the pulled image is removed. It doesn't have all the flag =
* internalDocker.flags that the images create endpoint exposes.
*
* @since 1.0.0
* @category Docker
*/
export declare const pullScoped: ({ image, platform, }: {
image: string;
platform?: string | undefined;
}) => Effect.Effect<Stream.Stream<MobySchemas.JSONMessage, DockerError, never>, never, MobyEndpoints.Images | Scope.Scope>;
/**
* Implements the `docker push` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const push: (name: string, options: Parameters<MobyEndpoints.Images["Service"]["push"]>[1]) => Stream.Stream<MobySchemas.JSONMessage, DockerError, MobyEndpoints.Images>;
/**
* Implements `docker run` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const run: (options: Omit<(typeof MobySchemas.ContainerCreateRequest)["~type.make.in"], "HostConfig"> & {
readonly name?: string | undefined;
readonly platform?: string | undefined;
readonly HostConfig?: (typeof MobySchemas.ContainerHostConfig)["~type.make.in"] | undefined;
}) => Effect.Effect<MobySchemas.ContainerInspectResponse, DockerError, MobyEndpoints.Containers>;
/**
* Implements `docker run` command as a scoped effect. When the scope is closed,
* both the image and the container is removed = internalDocker.removed.
*
* @since 1.0.0
* @category Docker
*/
export declare const runScoped: (options: Omit<(typeof MobySchemas.ContainerCreateRequest)["~type.make.in"], "HostConfig"> & {
readonly name?: string | undefined;
readonly platform?: string | undefined;
readonly HostConfig?: (typeof MobySchemas.ContainerHostConfig)["~type.make.in"] | undefined;
}) => Effect.Effect<MobySchemas.ContainerInspectResponse, DockerError, Scope.Scope | MobyEndpoints.Containers>;
/**
* Implements the `docker search` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const search: (options: Parameters<MobyEndpoints.Images["Service"]["search"]>[0]) => Effect.Effect<ReadonlyArray<MobySchemas.RegistrySearchResult>, DockerError, MobyEndpoints.Images>;
/**
* Implements the `docker start` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const start: (containerId: IdSchemas.ContainerIdentifier) => Effect.Effect<void, DockerError, MobyEndpoints.Containers>;
/**
* Implements the `docker stop` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const stop: (containerId: IdSchemas.ContainerIdentifier) => Effect.Effect<void, DockerError, MobyEndpoints.Containers>;
/**
* Implements the `docker version` command.
*
* @since 1.0.0
* @category Docker
*/
export declare const version: () => Effect.Effect<MobySchemas.TypesVersion, DockerError, MobyEndpoints.System>;
//# sourceMappingURL=DockerEngine.d.ts.map