Skip to content

Commit

Permalink
✨ feat: implement optional prefixes for generated type identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
m1212e committed Nov 12, 2024
1 parent 5ebbea1 commit b45bfae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
);
Expand Down
2 changes: 1 addition & 1 deletion src/generators/wrappers/composite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type ProcessedModel = {
function convertModelToStandalone(
input: Pick<ProcessedModel, "name" | "stringRepresentation">,
) {
return `export const ${input.name} = ${input.stringRepresentation}\n`;
return `export const ${getConfig().exportedTypePrefix}${input.name} = ${input.stringRepresentation}\n`;
}

function typepoxImportStatement() {
Expand Down

0 comments on commit b45bfae

Please sign in to comment.