diff --git a/packages/types/src/generator.ts b/packages/types/src/generator.ts index b7bc96c9..8b75136b 100644 --- a/packages/types/src/generator.ts +++ b/packages/types/src/generator.ts @@ -6,6 +6,7 @@ export interface GitConfig { export interface GeneratorProps { [key: string]: string | boolean | undefined + useRxJS6: boolean | string | undefined usePromise: boolean | string | undefined supportsES6: boolean | string | undefined @@ -19,8 +20,40 @@ export interface GeneratorProps { npmName: string | undefined } -export interface GeneratorConfig extends GitConfig { - additionalProperties: GeneratorProps +export const FileTemplateType = { + Api: 'API', + ApiDocs: 'APIDocs', + ApiTests: 'APITests', + Model: 'Model', + ModelDocs: 'ModelDocs', + ModelTests: 'ModelTests', + SupportingFiles: 'SupportingFiles', +} as const + +export type FileTemplateType = + (typeof FileTemplateType)[keyof typeof FileTemplateType] + +export interface FileTemplate { + templateType: FileTemplateType + destinationFilename: string + folder?: string +} + +export interface FileTemplateExtensions { + /** + * Path relative to client output to write file in. + */ + destinationPath?: string + sourcePath?: string +} + +export interface ExtendedFileTemplate + extends FileTemplate, + FileTemplateExtensions {} + +export interface GeneratorConfig + extends GitConfig { + additionalProperties?: T generatorName: string | undefined templateDir?: string | undefined output: string @@ -28,17 +61,24 @@ export interface GeneratorConfig extends GitConfig { inputSpec: string | undefined removeOperationIdPrefix: boolean legacyDiscriminatorBehavior: boolean + files?: Record } -export interface TemplateConfig { +export interface TemplateConfig { generatorVersion?: string | undefined + additionalProperties?: T additionalArgs: string[] drop?: string[] + files?: Record } -export interface ExtendedGeneratorConfig - extends GeneratorConfig, - TemplateConfig {} +export interface ExtendedGeneratorConfig< + T extends GeneratorProps = GeneratorProps, +> extends GeneratorConfig, + TemplateConfig { + files?: TemplateConfig['files'] + addtionalProperties?: TemplateConfig['additionalProperties'] +} export interface OASConfig { $schema?: string @@ -49,11 +89,6 @@ export interface OASConfig { } } -export interface TemplatesConfig { - extends: string - drop?: string[] -} - export interface GenerateOptions { clients: string[] rootDir: string @@ -74,8 +109,10 @@ export interface Workspace { export interface WorkspaceProvider { workspace: T + create(outputDir: string, overwrite?: boolean): Promise addTemplatePath(path: string, ...args: any[]): Promise + setConfig(config: GeneratorConfig): Promise }