import { Editor } from 'mem-fs-editor'; import * as prettier from 'prettier'; import Enquirer from 'enquirer'; import { EventEmitter } from 'events'; import { Overrides } from 'recast/parsers/_babel_options'; import { Transform, TransformCallback } from 'stream'; import File from 'vinyl'; declare function getProjectRootSync(): string; declare function getConfigSrcPath(): string; declare const customTemplatesBlitzConfig: (isTypeScript: boolean, customTemplatesPath?: string, codemod?: boolean) => Promise; declare const customTsParser: { parse(source: string, options?: Overrides): any; }; interface GeneratorOptions { context?: string; destinationRoot?: string; templateDir?: string; dryRun?: boolean; useTs?: boolean; } interface SourceRootType { type: "template" | "absolute"; path: string; } /** * The base generator class. * Every generator must extend this class. */ declare abstract class Generator extends EventEmitter { protected readonly options: T; private readonly store; protected readonly fs: Editor; protected readonly enquirer: Enquirer; private performedActions; private useTs; private prettier; prettierDisabled: boolean; unsafe_disableConflictChecker: boolean; returnResults: boolean; /** * When `type: 'absolute'`, it's an absolute path * When `type: 'template'`, is the path type `templates/`. * * @example {type: 'absolue', path: './src/app'} => `./src/app` * @example {type: 'template', path: 'app'} => `templates/app` */ abstract sourceRoot: SourceRootType; constructor(options: T); templateValuesBuilder: IBuilder; getTemplateValues(): Promise; fieldTemplateRegExp: RegExp; abstract getTargetDirectory(): string; filesToIgnore(): string[]; replaceConditionals(input: string, templateValues: any, prettierOptions?: prettier.Options): string; replaceTemplateValues(input: string, templateValues: any): string; process(input: Buffer, pathEnding: string, templateValues: any, prettierOptions: prettier.Options | undefined): string | Buffer; preFileWrite(filePath: string): Promise; postFileWrite(filePath: string, templateValues: CommonTemplateValues): Promise; write(): Promise; preCommit(): Promise; postWrite(): Promise; preventFileFromLogging(_path: string): boolean; sourcePath(...paths: string[]): string; destinationPath(...paths: string[]): string; run(): Promise; } type CodegenField = { component: string; inputType: string; zodType: string; prismaType: string; default?: string; }; interface IBuilder { getTemplateValues(Options: T): Promise; } declare function createFieldTemplateValues(valueName: string | undefined, typeName: string | undefined, parent?: boolean, isOptional?: boolean): Promise<{ [x: string]: any; }>; interface ResourceGeneratorOptions extends GeneratorOptions { ModelName: string; ModelNames: string; modelName: string; modelNames: string; rawParentModelName?: string; parentModel?: string; parentModels?: string; ParentModel?: string; ParentModels?: string; extraArgs?: string[]; } interface CommonTemplateValues { prismaFolder?: string; parentModelId: string; parentModelParam: string; parentModel?: string; parentModels?: string; ParentModel?: string; ParentModels?: string; parentModelIdZodType?: string; modelId: string; modelIdZodType?: string; modelIdParam: string; modelName: string; modelNames: string; ModelName: string; ModelNames: string; modelNamesPath: string; fieldTemplateValues?: { [x: string]: any; }; } declare abstract class Builder implements IBuilder { constructor(fs?: Editor); abstract getTemplateValues(Options: T): Promise; fs: Editor | undefined; defaultFieldConfig: CodegenField; getId(input?: string): string; getParam(input?: string): string; getModelNamesPath(context: string | undefined, modelNames: string): string; getZodType(type?: string): Promise; getComponentForType(type?: string): Promise; getInputType(type?: string): Promise; getFieldTemplateValues(args: string[]): Promise<{ [x: string]: any; }[]>; } declare class AppValuesBuilder extends Builder { getTemplateValues(options: AppGeneratorOptions): Promise; } interface AppTemplateValues { name: string; safeNameSlug: string; username: string | undefined; } type TemplateConfig = { path: string; skipForms?: boolean; skipDatabase?: boolean; }; interface AppGeneratorOptions extends GeneratorOptions { template: TemplateConfig; appName: string; useTs: boolean; yarn: boolean; pnpm?: boolean; version: string; skipInstall: boolean; skipGit: boolean; form: "finalform" | "hookform" | "formik"; onPostInstall?: () => Promise; } declare class AppGenerator extends Generator { sourceRoot: SourceRootType; prettierDisabled: boolean; packageInstallSuccess: boolean; filesToIgnore(): string[]; templateValuesBuilder: AppValuesBuilder; getTargetDirectory(): string; preCommit(): Promise; postWrite(): Promise; preventFileFromLogging(path: string): boolean; commitChanges(): void; private updateForms; private get pkgManager(); } interface ValidationsGeneratorOptions extends ResourceGeneratorOptions { } declare class ValidationsGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: ValidationsGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; preFileWrite(filePath: string): Promise; getTargetDirectory(): string; } interface ModelGeneratorOptions extends GeneratorOptions { modelName: string; extraArgs: string[]; } declare class ModelGenerator extends Generator { sourceRoot: SourceRootType; constructor(options: ModelGeneratorOptions); static subdirectory: string; unsafe_disableConflictChecker: boolean; prisma: boolean; getTargetDirectory(): string; prismaMigratePrompt(): Promise; write(): Promise; postWrite(): Promise; } interface MutationsGeneratorOptions extends ResourceGeneratorOptions { } declare class MutationsGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: MutationsGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; preFileWrite(filePath: string): Promise; getTargetDirectory(): string; } interface MutationGeneratorOptions extends GeneratorOptions { name: string; Name: string; } declare class MutationGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: MutationGeneratorOptions); static subdirectory: string; getTemplateValues(): Promise<{ name: string; Name: string; }>; getTargetDirectory(): string; } interface PageGeneratorOptions extends ResourceGeneratorOptions { } declare class PageGenerator extends Generator { sourceRoot: SourceRootType; constructor(options: PageGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; getModelNamesPath(): string; getTargetDirectory(): string; preFileWrite(): Promise; postWrite(): Promise; } interface QueriesGeneratorOptions extends ResourceGeneratorOptions { } declare class QueriesGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: QueriesGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; preFileWrite(filePath: string): Promise; getTargetDirectory(): string; } interface QueryGeneratorOptions extends GeneratorOptions { name: string; Name: string; } declare class QueryGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: QueryGeneratorOptions); static subdirectory: string; getTemplateValues(): Promise<{ name: string; Name: string; }>; getTargetDirectory(): string; } interface FormGeneratorOptions extends ResourceGeneratorOptions { } declare class FormGenerator extends Generator { sourceRoot: SourceRootType; isAppDir: boolean; constructor(options: FormGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; preFileWrite(): Promise; postFileWrite(filePath: string, templateValues: CommonTemplateValues): Promise; getTargetDirectory(): string; } interface RouteGeneratorOptions extends ResourceGeneratorOptions { } declare class RouteGenerator extends Generator { sourceRoot: SourceRootType; constructor(options: RouteGeneratorOptions); static subdirectory: string; templateValuesBuilder: FieldValuesBuilder; getModelNamesPath(): string; getTargetDirectory(): string; } declare const NullBuilder: IBuilder; declare class FieldValuesBuilder extends Builder { private getEditor; getTemplateValues(options: ResourceGeneratorOptions): Promise; } declare function modelName(input?: string): any; declare function modelNames(input?: string): any; declare function ModelName(input?: string): any; declare function ModelNames(input?: string): any; type PromptActions = "create" | "overwrite" | "skip" | "identical"; interface ConflictCheckerOptions { dryRun?: boolean; } declare class ConflictChecker extends Transform { private readonly options?; private _destroyed; constructor(options?: ConflictCheckerOptions | undefined); _transform(file: File, _encoding: string, cb: TransformCallback): void; destroy(err?: Error): this; handlePush(file: File, status: PromptActions): void; private checkDiff; private printDiff; private fileStatusString; } interface Fallbackable { value: T; isFallback?: boolean; } declare const getLatestVersion: (dependency: string, templateVersion?: string) => Promise>; type PackageInformation = any; type NpmDepResponse = { versions: Record; }; declare const fetchAllVersions: (dependency: string) => Promise; declare const fetchDistTags: (dependency: string) => Promise>; declare const fetchLatestDistVersion: (dependency: string) => Promise; declare const getBlitzDependencyVersion: () => Promise<{ value: any; }>; declare function addSpaceBeforeCapitals(input: string): string; declare function capitalize(input: string): string; declare function uncapitalize(input: string): string; declare const singlePascal: (initial: any, ...args: any[]) => any; declare const singleCamel: (initial: any, ...args: any[]) => any; declare const pluralPascal: (initial: any, ...args: any[]) => any; declare const pluralCamel: (initial: any, ...args: any[]) => any; export { AppGenerator, AppGeneratorOptions, AppTemplateValues, AppValuesBuilder, Builder, CommonTemplateValues, ConflictChecker, FieldValuesBuilder, FormGenerator, FormGeneratorOptions, Generator, GeneratorOptions, IBuilder, ModelGenerator, ModelGeneratorOptions, ModelName, ModelNames, MutationGenerator, MutationGeneratorOptions, MutationsGenerator, MutationsGeneratorOptions, NpmDepResponse, NullBuilder, PageGenerator, PageGeneratorOptions, QueriesGenerator, QueriesGeneratorOptions, QueryGenerator, QueryGeneratorOptions, ResourceGeneratorOptions, RouteGenerator, RouteGeneratorOptions, SourceRootType, ValidationsGenerator, ValidationsGeneratorOptions, addSpaceBeforeCapitals, capitalize, createFieldTemplateValues, customTemplatesBlitzConfig, customTsParser, fetchAllVersions, fetchDistTags, fetchLatestDistVersion, getBlitzDependencyVersion, getConfigSrcPath, getLatestVersion, getProjectRootSync, modelName, modelNames, pluralCamel, pluralPascal, singleCamel, singlePascal, uncapitalize };