/**
 * Convenance utilities for Docker input and output streams.
 *
 * @since 1.0.0
 */

import type * as Effect from "effect/Effect";
import type * as Sink from "effect/Sink";
import type * as Stream from "effect/Stream";

import type * as MobySchemas from "./MobySchemas.ts";

import * as internal from "./internal/convey/sinks.ts";

/**
 * Waits for the progress stream to complete and returns the result.
 *
 * @since 1.0.0
 * @category Conveyance Sinks
 */
export const waitForProgressToComplete: <E1, R1>(
    stream: Stream.Stream<MobySchemas.JSONMessage, E1, R1>
) => Effect.Effect<Array<MobySchemas.JSONMessage>, E1, R1> = internal.waitForProgressToComplete;

/**
 * Consumes the progress stream and logs it to the console.
 *
 * @since 1.0.0
 * @category Conveyance Sinks
 */
export const followProgressSink: Sink.Sink<void, MobySchemas.JSONMessage, never, never, never> =
    internal.followProgressSink;

/**
 * Tracks the progress stream in the console and returns the result.
 *
 * @since 1.0.0
 * @category Conveyance Sinks
 */
export const followProgressInConsole: <E1, R1>(
    stream: Stream.Stream<MobySchemas.JSONMessage, E1, R1>
) => Effect.Effect<Array<MobySchemas.JSONMessage>, E1, R1> = internal.followProgressInConsole;
