UNPKG

@t1mmen/srtd

Version:

Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀

39 lines (38 loc) • 1.5 kB
import type { RenderContext, TemplateResult } from '../ui/types.js'; /** * Base envelope for all JSON command output. * All command-specific outputs extend this interface. */ export interface BaseJsonOutput<TCommand extends RenderContext['command'] = RenderContext['command']> { success: boolean; command: TCommand; timestamp: string; error?: string; } /** * Create the base JSON output envelope. * Used by all commands for consistent structure. */ export declare function createBaseJsonOutput<TCommand extends RenderContext['command']>(command: TCommand, success: boolean, error?: string): BaseJsonOutput<TCommand>; /** * Write a JSON object to stdout with pretty formatting and trailing newline. * Centralized helper to ensure consistent JSON output across all commands. */ export declare function writeJson(output: unknown): void; /** * Format a fatal error response for batch commands (build/apply). * Used in catch blocks when the entire operation fails before processing templates. */ export declare function formatFatalError(command: 'build' | 'apply', error: string): JsonOutput; export interface JsonOutputSummary { total: number; success: number; error: number; unchanged: number; skipped: number; } export interface JsonOutput extends BaseJsonOutput<'build' | 'apply'> { results: TemplateResult[]; summary: JsonOutputSummary; } export declare function formatJsonOutput(results: TemplateResult[], command: 'build' | 'apply'): JsonOutput;