@t1mmen/srtd
Version:
Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀
47 lines (46 loc) • 1.58 kB
TypeScript
/**
* Interpolation utility for migration filename templates
* Supports $timestamp, $migrationName, and $prefix variables
*/
/**
* Interpolation options for migration filename templates
*/
export interface InterpolationOptions {
/** The template string with $timestamp, $migrationName, $prefix variables */
template: string;
/** The timestamp for the migration (e.g., '20240101123456') */
timestamp: string;
/** The migration name (template name or 'bundle') */
migrationName: string;
/** Optional prefix (e.g., 'srtd'). When present, adds trailing dash. */
prefix?: string;
}
/**
* Interpolate a migration filename template with the provided values.
*
* Supported variables:
* - $timestamp: The migration timestamp
* - $migrationName: The template name (or 'bundle' for bundled migrations)
* - $prefix: The migration prefix with trailing dash (empty if no prefix)
*
* @example
* // Default pattern (backward compatible)
* interpolateMigrationFilename({
* template: '$timestamp_$prefix$migrationName.sql',
* timestamp: '20240101123456',
* migrationName: 'create_users',
* prefix: 'srtd'
* });
* // Returns: '20240101123456_srtd-create_users.sql'
*
* @example
* // Directory-based pattern (Issue #41)
* interpolateMigrationFilename({
* template: '$migrationName/migrate.sql',
* timestamp: '20240101123456',
* migrationName: 'create_users',
* prefix: 'srtd'
* });
* // Returns: 'create_users/migrate.sql'
*/
export declare function interpolateMigrationFilename(options: InterpolationOptions): string;