import WarpError from "../errors/WarpError.js";
import { DeliveryObservation } from "./DeliveryObservation.js";
export const EFFECT_SINK_INVALID_OBSERVATION_BATCH = 'E_EFFECT_SINK_INVALID_OBSERVATION_BATCH';
export const EFFECT_SINK_INVALID_OBSERVATION = 'E_EFFECT_SINK_INVALID_OBSERVATION';
export function requireDeliveryObservationBatch(observations, sinkId) {
    if (!Array.isArray(observations)) {
        throw new WarpError(`Effect sink ${sinkId} must return DeliveryObservation[]`, EFFECT_SINK_INVALID_OBSERVATION_BATCH, { context: { sinkId } });
    }
    for (let index = 0; index < observations.length; index += 1) {
        const observation = observations[index];
        if (!(observation instanceof DeliveryObservation)) {
            throw new WarpError(`Effect sink ${sinkId} returned a non-DeliveryObservation at index ${String(index)}`, EFFECT_SINK_INVALID_OBSERVATION, { context: { sinkId, index } });
        }
    }
    return observations;
}
