import { AstNode, CodeBlock } from "@amplication/csharp-ast"; import type { Promisable } from "type-fest"; import { BuildLogger } from "../build-logger"; import { clientDirectories, DTOs, EntityActionsMap, ModuleActionsAndDtosMap, serverDirectories } from "../code-gen-types"; import { DSGResourceData } from "../dsg-resource-data"; import { FileMap } from "../files"; import { BlueprintEvents } from "./blueprint-plugin-events.types"; export interface EventParams { } export type PluginBeforeEvent = (dsgContext: DsgContext, eventParams: T) => Promisable; export type PluginAfterEvent = (dsgContext: DsgContext, eventParams: T, files: FileMap) => Promisable>; export interface PluginEventType { before?: PluginBeforeEvent; after?: PluginAfterEvent; } export interface PrintResultType { code: string; map?: any; toString(): string; } export interface ContextUtil { skipDefaultBehavior: boolean; abortGeneration: (msg: string) => void; abortMessage?: string; abort: boolean; importStaticFiles: (source: string, basePath: string) => Promise>; importStaticFilesWithReplacements: (source: string, basePath: string, placeholders: Record, stringReplacements: Record) => Promise>; replacePlaceholders: (template: string, replacements: Record) => string; replaceText: (template: string, replacements: Record) => string; } export interface DsgContext extends DSGResourceData { /** * List of generated files. */ files: FileMap; DTOs: DTOs; plugins: PluginMap; /** * Logger for user facing logs. Logs will be visible in the build log. */ logger: BuildLogger; utils: ContextUtil; clientDirectories: clientDirectories; serverDirectories: serverDirectories; userEntityName: string; userNameFieldName: string; userPasswordFieldName: string; userRolesFieldName: string; entityActionsMap: EntityActionsMap; moduleActionsAndDtoMap: ModuleActionsAndDtosMap; } export type PluginWrapper = (args: EventParams, func: () => void) => any; export type PluginMap = { [K in BlueprintEventNames]?: { before?: PluginBeforeEvent[]; after?: PluginAfterEvent[]; }; }; export declare enum BlueprintEventNames { createBlueprint = "createBlueprint", createModules = "createModules", createModule = "createModule" } export interface AmplicationPlugin { init?: (name: string, version: string) => void; register: () => BlueprintEvents; }