import { z } from 'zod';
import { StreamResponseError } from "./util.js";
// --- Response schemas matching Pulse format ---
const DeleteStreamResponseSchema = z.discriminatedUnion('success', [
    z.object({
        success: z.literal(false),
        message: z.string().optional(),
    }),
    z.object({
        success: z.literal(true),
    }),
]);
const DeleteNamespaceResponseSchema = z.discriminatedUnion('success', [
    z.object({
        success: z.literal(false),
        message: z.string().optional(),
    }),
    z.object({
        success: z.literal(true),
        deleted: z.number(),
    }),
]);
// --- Functions ---
/**
 * Delete a single stream by ID.
 *
 * @param client - The API client configured for Pulse
 * @param id - The stream ID to delete
 *
 * @example
 * await streamDelete(client, 'strm_abc123');
 */
export async function streamDelete(client, id) {
    const resp = await client.delete(`/${encodeURIComponent(id)}`, DeleteStreamResponseSchema);
    if (resp.success) {
        return;
    }
    throw new StreamResponseError({ message: resp.message });
}
/**
 * Delete all streams in a namespace (soft delete).
 *
 * @param client - The API client configured for Pulse
 * @param name - The namespace name to delete
 * @returns The number of streams that were deleted
 *
 * @example
 * const result = await streamDeleteNamespace(client, 'old-logs');
 * console.log(`Deleted ${result.deleted} streams`);
 */
export async function streamDeleteNamespace(client, name) {
    const resp = await client.delete(`/namespace/${encodeURIComponent(name)}`, DeleteNamespaceResponseSchema);
    if (resp.success) {
        return { deleted: resp.deleted };
    }
    throw new StreamResponseError({ message: resp.message });
}
//# sourceMappingURL=delete.js.map