@kwaeri/mysql-migration-generator
Version:
The @kwaeri/mysql-migration-generator component module of the @kwaeri/node-kit platform.
124 lines (123 loc) • 4.36 kB
text/typescript
/**
* SPDX-PackageName: kwaeri/mysql-migration-generator
* SPDX-PackageVersion: 0.6.0
* SPDX-FileCopyrightText: © 2014 - 2022 Richard Winters <kirvedx@gmail.com> and contributors
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR MIT
*/
import { NodeKitOptions } from '@kwaeri/standards-types';
import { ServiceProviderSubscriptions, ServiceProviderHelpText, ServiceEventBits, ServicePromiseBits } from '@kwaeri/service';
import { GeneratorServiceProvider } from '@kwaeri/generator';
import { MysqlMigrator } from '@kwaeri/mysql-migrator';
import { Configuration } from '@kwaeri/configuration';
export type MigrationType = {
[key: string]: string;
};
export declare const MIGRATION_TYPES: MigrationType;
export type GeneratorOptions = {
name?: string;
fileSafeName?: string;
ext?: string;
path?: string;
type?: string;
table?: string;
};
export type MigrationGeneratorOptions = NodeKitOptions & GeneratorOptions;
/**
* MigrationGenerator
*
* Extends the { Filesystem } class, which implements the { BaseFilesystem }
* Interface.
*
* The { MigrationGenerator } facilitates generating of migration files..
*/
export declare class MysqlMigrationGenerator extends GeneratorServiceProvider {
/**
* @var { migrator }
*/
migrator: MysqlMigrator;
/**
* @var { configuration }
*/
configuration?: Configuration;
/**
* @var { any }
*/
conf?: any;
/**
* @var { Configuration }
*/
migrationConfiguration?: Configuration;
/**
* @var { any }
*/
migrationConf?: any;
/**
* Class Constructor
*
* @param { (data: ServiceEventBits) => void } handler Method for handling ServiceEvents
* @param { NodeKitOptions } configuration A {@link NodeKitOptions} object.
*
* @returns { void }
*/
constructor(handler?: (data: ServiceEventBits) => void, configuration?: NodeKitOptions);
getServiceProviderSubscriptions(options?: any): ServiceProviderSubscriptions;
getServiceProviderSubscriptionHelpText<T extends ServiceProviderHelpText>(options?: any): T;
/**
* Method to resettle the { MySQLMigrationGeneratorOptions }. Essentially we
* merge NodeKitOptions with FilesystemDescriptor by combining provided
* command options with either a stored configuration or sane default.
*
* @param { NodeKitOptions } options
*
* @returns { MySQLMigrationGeneratorOptions } The options object, with the configuration partially populated with user-provided information
*/
assembleOptions<T extends NodeKitOptions>(options: NodeKitOptions): Promise<T>;
/**
* Returns a configuraion from disk or a default fall back
*
* @returns Promise<T>
*/
private getConfiguration;
/**
* A method which asynchronously executes the necessary steps for creating
* a migration within a project file structure
*
* @param { MigrationGeneratorOptions } options An object which specifies parameters for this method
*
* @return { Promise<any> }
*/
renderService<T>(options: NodeKitOptions): Promise<T>;
/**
* A method which asynchronously executes the necessary steps for creating
* a endpoints for a Kwaeri API Application.
*
* @param { MigrationGeneratorOptions } options An object which specifies parameters for this method
*
* @return { Promise<FilesystemPromise> }
*/
runCreateMigrationRoutine<T extends ServicePromiseBits>(options: MigrationGeneratorOptions): Promise<T>;
/**
* Generates a migrations configuration for node-kit usage
*
* @param { MigrationGeneratorOptions } options The project options
*
* @return { string }
*/
getMySQLMigrationsCfgFileContents(options: MigrationGeneratorOptions): string;
/**
* Generates a migration's file contents in es6
*
* @param { MigrationGeneratorOptions } options The migration options
*
* @return { string }
*/
getMySQLMigrationFileContentsES6(options: MigrationGeneratorOptions): string;
/**
* Generates a migration's file contents
*
* @param { MigrationGeneratorOptions } options The migration options
*
* @return { string }
*/
getMySQLMigrationFileContents(options: MigrationGeneratorOptions): string;
}