From b45bfaeed77119d0ebc4c736d3d54d3b4add53c0 Mon Sep 17 00:00:00 2001 From: m1212e <14091540+m1212e@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:13:44 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20implement=20optional=20pref?= =?UTF-8?q?ixes=20for=20generated=20type=20identifiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.ts | 4 ++++ src/generators/wrappers/composite.ts | 2 +- src/model.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 850c23e..e38e132 100644 --- a/src/config.ts +++ b/src/config.ts @@ -67,6 +67,10 @@ const configSchema = Type.Object( * What file extension, if any, to add to src file imports. Set to ".js" to support nodenext module resolution */ importFileExtension: Type.String({ default: "" }), + /** + * The prefix to add to exported types + */ + exportedTypePrefix: Type.String({ default: "" }), }, { additionalProperties: false }, ); diff --git a/src/generators/wrappers/composite.ts b/src/generators/wrappers/composite.ts index 8044dfb..0254bc6 100644 --- a/src/generators/wrappers/composite.ts +++ b/src/generators/wrappers/composite.ts @@ -4,5 +4,5 @@ import { getConfig } from "../../config"; export function makeComposite(inputModels: string[]) { return `${ getConfig().typeboxImportVariableName - }.Composite([${inputModels.join(",")}], ${generateTypeboxOptions()})\n`; + }.Composite([${inputModels.map((i) => `${getConfig().exportedTypePrefix}${i}`).join(",")}], ${generateTypeboxOptions()})\n`; } diff --git a/src/model.ts b/src/model.ts index e639d7f..a5d88fb 100644 --- a/src/model.ts +++ b/src/model.ts @@ -23,7 +23,7 @@ export type ProcessedModel = { function convertModelToStandalone( input: Pick, ) { - return `export const ${input.name} = ${input.stringRepresentation}\n`; + return `export const ${getConfig().exportedTypePrefix}${input.name} = ${input.stringRepresentation}\n`; } function typepoxImportStatement() {