UNPKG

@dans98/prismabox

Version:

Typebox generator for prisma schema

21 lines (17 loc) 716 B
import { getConfig } from "../../config"; export function nullableType() { return `import { ${ getConfig().typeboxImportVariableName }, type TSchema } from "${getConfig().typeboxImportDependencyName}" export const ${getConfig().nullableName} = <T extends TSchema>(schema: T) => ${ getConfig().typeboxImportVariableName }.Union([${getConfig().typeboxImportVariableName}.Null(), schema])\n`; } export function nullableImport() { return `import { ${getConfig().nullableName} } from "./${ getConfig().nullableName }${getConfig().explicitFileExtensions ? ".js" : ""}"\n`; } export function wrapWithNullable(input: string) { return `${getConfig().nullableName}(${input})`; }