import { PackageJson } from 'type-fest'; import { Callable, PinionContext, Location } from '@featherscloud/pinion'; import ts from 'typescript'; import { Options as PrettierOptions } from 'prettier'; export declare const version: any; export type DependencyVersions = { [key: string]: string; }; export declare const DATABASE_TYPES: readonly ["mongodb", "mysql", "postgresql", "sqlite", "mssql", "other"]; /** * The database types supported by this generator */ export type DatabaseType = (typeof DATABASE_TYPES)[number]; /** * Returns the name of the Feathers database adapter for a supported database type * * @param database The type of the database * @returns The name of the adapter */ export declare const getDatabaseAdapter: (database: DatabaseType) => "mongodb" | "knex"; export type FeathersAppInfo = { /** * The application language */ language: 'ts' | 'js'; /** * The main database */ database: DatabaseType; /** * The package manager used */ packager: 'yarn' | 'npm' | 'pnpm'; /** * A list of all chosen transports */ transports: ('rest' | 'websockets')[]; /** * The HTTP framework used */ framework: 'koa' | 'express'; /** * The main schema definition format */ schema: 'typebox' | 'json' | false; }; export interface AppPackageJson extends PackageJson { feathers?: FeathersAppInfo; } export interface FeathersBaseContext extends PinionContext { /** * Information about the Feathers application (like chosen language, database etc.) * usually taken from `package.json` */ feathers: FeathersAppInfo; /** * The package.json file */ pkg: AppPackageJson; /** * The folder where source files are put */ lib: string; /** * The folder where test files are put */ test: string; /** * The language the app is generated in */ language: 'js' | 'ts'; /** * A list dependencies that should be installed with a certain version. * Used for installing development dependencies during testing. */ dependencyVersions?: DependencyVersions; } /** * Returns dependencies with the versions from the context attached (if available) * * @param dependencies The dependencies to install * @param versions The dependency version list * @returns A list of dependencies with their versions */ export declare const addVersions: (dependencies: string[], versions: DependencyVersions, defaultVersion?: string) => string[]; /** * Loads the application package.json and populates information like the library and test directory * and Feathers app specific information. * * @returns The updated context */ export declare const initializeBaseContext: () => (ctx: C) => Promise & { pkg: import("@featherscloud/pinion").JSONData; } & { lib: string; test: string; language: "ts" | "js"; feathers: FeathersAppInfo; dependencyVersions: { '@feathersjs/cli': any; }; }>; /** * A special error that can be thrown by generators. It contains additional * information about the error that can be used to display a more helpful * error message to the user. */ export declare class FeathersGeneratorError extends Error { /** * Additional information about the error. This can include things like * the reason for the error and suggested actions to take. */ context?: Record; /** * Creates a new FeathersGeneratorError * @param message The error message * @param context Additional information about the error */ constructor(message: string, context?: Record); } /** * Checks if the current context contains a valid generated application. This is necesary for most * generators (besides the app generator). * * @param ctx The context to check against * @returns Throws an error or returns the original context */ export declare const checkPreconditions: () => (ctx: T) => Promise; /** * Returns the transpiled and prettified JavaScript for a TypeScript source code * * @param typescript The TypeScript source code * @param options TypeScript transpilation options * @returns The formatted JavaScript source code */ export declare const getJavaScript: (typescript: string, options?: ts.TranspileOptions) => string; /** * The default configuration for prettifying files */ export declare const PRETTIERRC: PrettierOptions; export declare const prettify: (target: Callable, options?: PrettierOptions) => (ctx: C) => Promise; /** * Render a source file template for the language set in the context. * * @param templates The JavaScript and TypeScript template to render * @param target The target filename without extension (will be added based on language) * @returns The updated context */ export declare const renderSource: (template: Callable, target: Callable, options?: { force: boolean; }) => (ctx: C) => Promise; export declare const install: (dependencies: Callable, dev: Callable, packager: Callable) => (ctx: C) => Promise; /** * Inject a source template as the language set in the context. * * @param template The source template to render * @param location The location to inject the code to. Must use the target language. * @param target The target file name * @param transpile Set to `false` if the code should not be transpiled to JavaScript * @returns */ export declare const injectSource: (template: Callable, location: Location, target: Callable, transpile?: boolean) => (ctx: C) => Promise; /** * Synchronously checks if a file exits * @param context The base context * @param filenames The filenames to check * @returns Wether the file exists or not */ export declare const fileExists: (...filenames: string[]) => boolean; /** * The helper used by Knex to create migration names * @returns The current date and time in the format `YYYYMMDDHHMMSS` */ export declare const yyyymmddhhmmss: (offset?: number) => string; /** * Render a template if `local` authentication strategy has been selected * @param authStrategies The list of selected authentication strategies * @param content The content to render if `local` is selected * @param alt The content to render if `local` is not selected * @returns */ export declare const localTemplate: (authStrategies: string[], content: string, alt?: string) => string; /** * Render a template if an `oauth` authentication strategy has been selected * @param authStrategies * @param content * @returns */ export declare const oauthTemplate: (authStrategies: string[], content: string) => string;