@brakebein/prisma-generator-nestjs-dto
Advanced tools
Comparing version 1.8.1 to 1.9.0
import { ParsedField } from './types'; | ||
export declare const PrismaScalarToFormat: Record<string, { | ||
type: string; | ||
format: string; | ||
}>; | ||
export declare function isAnnotatedWithDoc(field: ParsedField): boolean; | ||
export declare function getDefaultValue(field: ParsedField): any; | ||
export declare function decorateApiProperty(field: ParsedField, includeDefault?: boolean): string; | ||
export declare function parseApiProperty(field: ParsedField, include?: { | ||
default?: boolean; | ||
doc?: boolean; | ||
enum?: boolean; | ||
type?: boolean; | ||
}): boolean; | ||
export declare function decorateApiProperty(field: ParsedField): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorateApiProperty = exports.getDefaultValue = exports.isAnnotatedWithDoc = exports.PrismaScalarToFormat = void 0; | ||
exports.decorateApiProperty = exports.parseApiProperty = exports.getDefaultValue = exports.isAnnotatedWithDoc = void 0; | ||
const ApiProps = [ | ||
@@ -14,4 +14,5 @@ 'description', | ||
'maxItems', | ||
'example', | ||
]; | ||
exports.PrismaScalarToFormat = { | ||
const PrismaScalarToFormat = { | ||
Int: { type: 'integer', format: 'int32' }, | ||
@@ -58,25 +59,42 @@ BigInt: { type: 'integer', format: 'int64' }, | ||
} | ||
function decorateApiProperty(field, includeDefault = true) { | ||
function parseApiProperty(field, include = {}) { | ||
const incl = Object.assign({ | ||
default: true, | ||
doc: true, | ||
enum: true, | ||
type: true, | ||
}, include); | ||
const properties = []; | ||
for (const prop of ApiProps) { | ||
const property = extractAnnotation(field, prop); | ||
if (property) { | ||
properties.push(property); | ||
if (incl.doc) { | ||
for (const prop of ApiProps) { | ||
const property = extractAnnotation(field, prop); | ||
if (property) { | ||
properties.push(property); | ||
} | ||
} | ||
} | ||
const scalarFormat = exports.PrismaScalarToFormat[field.type]; | ||
if (scalarFormat) { | ||
const scalarFormat = PrismaScalarToFormat[field.type]; | ||
if (incl.type && scalarFormat) { | ||
properties.push({ name: 'type', value: scalarFormat.type }, { name: 'format', value: scalarFormat.format }); | ||
} | ||
if (field.kind === 'enum') { | ||
if (incl.enum && field.kind === 'enum') { | ||
properties.push({ name: 'enum', value: field.type }); | ||
} | ||
const defaultValue = getDefaultValue(field); | ||
if (includeDefault && defaultValue !== undefined) { | ||
if (incl.default && defaultValue !== undefined) { | ||
properties.push({ name: 'default', value: `${defaultValue}` }); | ||
} | ||
if (properties.length) { | ||
field.apiProperty = properties; | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.parseApiProperty = parseApiProperty; | ||
function decorateApiProperty(field) { | ||
var _a; | ||
let decorator = ''; | ||
if (properties.length) { | ||
if ((_a = field.apiProperty) === null || _a === void 0 ? void 0 : _a.length) { | ||
decorator += '@ApiProperty({\n'; | ||
properties.forEach((prop) => { | ||
field.apiProperty.forEach((prop) => { | ||
decorator += ` ${prop.name}: ${prop.name === 'enum' ? prop.value : encapsulateString(prop.value)},\n`; | ||
@@ -83,0 +101,0 @@ }); |
@@ -7,4 +7,5 @@ import type { TemplateHelpers } from '../template-helpers'; | ||
templateHelpers: TemplateHelpers; | ||
noDependencies: boolean; | ||
} | ||
export declare const computeCreateDtoParams: ({ model, allModels, templateHelpers, }: ComputeCreateDtoParamsParam) => CreateDtoParams; | ||
export declare const computeCreateDtoParams: ({ model, allModels, templateHelpers, noDependencies, }: ComputeCreateDtoParamsParam) => CreateDtoParams; | ||
export {}; |
@@ -8,7 +8,4 @@ "use strict"; | ||
const api_decorator_1 = require("../api-decorator"); | ||
const computeCreateDtoParams = ({ model, allModels, templateHelpers, }) => { | ||
let hasEnum = false; | ||
let hasDoc = false; | ||
let hasDefault = false; | ||
let hasSpecialType = false; | ||
const computeCreateDtoParams = ({ model, allModels, templateHelpers, noDependencies, }) => { | ||
let hasApiProperty = false; | ||
const imports = []; | ||
@@ -46,3 +43,4 @@ const apiExtraModels = []; | ||
(0, helpers_1.concatIntoArray)(relationInputType.generatedClasses, extraClasses); | ||
(0, helpers_1.concatIntoArray)(relationInputType.apiExtraModels, apiExtraModels); | ||
if (!noDependencies) | ||
(0, helpers_1.concatIntoArray)(relationInputType.apiExtraModels, apiExtraModels); | ||
} | ||
@@ -63,21 +61,17 @@ if (relationScalarFieldNames.includes(name)) | ||
} | ||
if (api_decorator_1.PrismaScalarToFormat[field.type]) | ||
hasSpecialType = true; | ||
if (field.kind === 'enum') | ||
hasEnum = true; | ||
if ((0, api_decorator_1.isAnnotatedWithDoc)(field)) | ||
hasDoc = true; | ||
if ((0, api_decorator_1.getDefaultValue)(field) !== undefined) | ||
hasDefault = true; | ||
if (!noDependencies) | ||
hasApiProperty = (0, api_decorator_1.parseApiProperty)(field); | ||
if (noDependencies) { | ||
if (field.type === 'Json') | ||
field.type = 'Object'; | ||
else if (field.type === 'Decimal') | ||
field.type = 'Float'; | ||
} | ||
return [...result, (0, helpers_1.mapDMMFToParsedField)(field, overrides)]; | ||
}, []); | ||
if (apiExtraModels.length || | ||
hasEnum || | ||
hasDoc || | ||
hasDefault || | ||
hasSpecialType) { | ||
if (apiExtraModels.length || hasApiProperty) { | ||
const destruct = []; | ||
if (apiExtraModels.length) | ||
destruct.push('ApiExtraModels'); | ||
if (hasEnum || hasDoc || hasDefault || hasSpecialType) | ||
if (hasApiProperty) | ||
destruct.push('ApiProperty'); | ||
@@ -84,0 +78,0 @@ imports.unshift({ from: '@nestjs/swagger', destruct }); |
@@ -7,4 +7,5 @@ import type { Model, EntityParams } from '../types'; | ||
templateHelpers: TemplateHelpers; | ||
noDependencies: boolean; | ||
} | ||
export declare const computeEntityParams: ({ model, allModels, templateHelpers, }: ComputeEntityParamsParam) => EntityParams; | ||
export declare const computeEntityParams: ({ model, allModels, templateHelpers, noDependencies, }: ComputeEntityParamsParam) => EntityParams; | ||
export {}; |
@@ -13,6 +13,4 @@ "use strict"; | ||
const api_decorator_1 = require("../api-decorator"); | ||
const computeEntityParams = ({ model, allModels, templateHelpers, }) => { | ||
let hasEnum = false; | ||
let hasDoc = false; | ||
let hasSpecialType = false; | ||
const computeEntityParams = ({ model, allModels, templateHelpers, noDependencies, }) => { | ||
let hasApiProperty = false; | ||
const imports = []; | ||
@@ -65,15 +63,17 @@ const apiExtraModels = []; | ||
} | ||
if (api_decorator_1.PrismaScalarToFormat[field.type]) | ||
hasSpecialType = true; | ||
if (field.kind === 'enum') | ||
hasEnum = true; | ||
if ((0, api_decorator_1.isAnnotatedWithDoc)(field)) | ||
hasDoc = true; | ||
if (!noDependencies) | ||
hasApiProperty = (0, api_decorator_1.parseApiProperty)(field, { default: false }); | ||
if (noDependencies) { | ||
if (field.type === 'Json') | ||
field.type = 'Object'; | ||
else if (field.type === 'Decimal') | ||
field.type = 'Float'; | ||
} | ||
return [...result, (0, helpers_1.mapDMMFToParsedField)(field, overrides)]; | ||
}, []); | ||
if (apiExtraModels.length || hasEnum || hasDoc || hasSpecialType) { | ||
if (apiExtraModels.length || hasApiProperty) { | ||
const destruct = []; | ||
if (apiExtraModels.length) | ||
destruct.push('ApiExtraModels'); | ||
if (hasEnum || hasDoc || hasSpecialType) | ||
if (hasApiProperty) | ||
destruct.push('ApiProperty'); | ||
@@ -80,0 +80,0 @@ imports.unshift({ from: '@nestjs/swagger', destruct }); |
@@ -7,4 +7,5 @@ import type { TemplateHelpers } from '../template-helpers'; | ||
templateHelpers: TemplateHelpers; | ||
noDependencies: boolean; | ||
} | ||
export declare const computePlainDtoParams: ({ model, allModels, templateHelpers, }: ComputePlainDtoParamsParam) => PlainDtoParams; | ||
export declare const computePlainDtoParams: ({ model, allModels, templateHelpers, noDependencies, }: ComputePlainDtoParamsParam) => PlainDtoParams; | ||
export {}; |
@@ -8,6 +8,4 @@ "use strict"; | ||
const api_decorator_1 = require("../api-decorator"); | ||
const computePlainDtoParams = ({ model, allModels, templateHelpers, }) => { | ||
let hasEnum = false; | ||
let hasDoc = false; | ||
let hasSpecialType = false; | ||
const computePlainDtoParams = ({ model, allModels, templateHelpers, noDependencies, }) => { | ||
let hasApiProperty = false; | ||
const imports = []; | ||
@@ -29,15 +27,17 @@ const apiExtraModels = []; | ||
return result; | ||
if (api_decorator_1.PrismaScalarToFormat[field.type]) | ||
hasSpecialType = true; | ||
if (field.kind === 'enum') | ||
hasEnum = true; | ||
if ((0, api_decorator_1.isAnnotatedWithDoc)(field)) | ||
hasDoc = true; | ||
if (!noDependencies) | ||
hasApiProperty = (0, api_decorator_1.parseApiProperty)(field, { default: false }); | ||
if (noDependencies) { | ||
if (field.type === 'Json') | ||
field.type = 'Object'; | ||
else if (field.type === 'Decimal') | ||
field.type = 'Float'; | ||
} | ||
return [...result, (0, helpers_1.mapDMMFToParsedField)(field, overrides)]; | ||
}, []); | ||
if (apiExtraModels.length || hasEnum || hasDoc || hasSpecialType) { | ||
if (apiExtraModels.length || hasApiProperty) { | ||
const destruct = []; | ||
if (apiExtraModels.length) | ||
destruct.push('ApiExtraModels'); | ||
if (hasEnum || hasDoc || hasSpecialType) | ||
if (hasApiProperty) | ||
destruct.push('ApiProperty'); | ||
@@ -44,0 +44,0 @@ imports.unshift({ from: '@nestjs/swagger', destruct }); |
@@ -7,4 +7,5 @@ import type { TemplateHelpers } from '../template-helpers'; | ||
templateHelpers: TemplateHelpers; | ||
noDependencies: boolean; | ||
} | ||
export declare const computeUpdateDtoParams: ({ model, allModels, templateHelpers, }: ComputeUpdateDtoParamsParam) => UpdateDtoParams; | ||
export declare const computeUpdateDtoParams: ({ model, allModels, templateHelpers, noDependencies, }: ComputeUpdateDtoParamsParam) => UpdateDtoParams; | ||
export {}; |
@@ -8,7 +8,4 @@ "use strict"; | ||
const api_decorator_1 = require("../api-decorator"); | ||
const computeUpdateDtoParams = ({ model, allModels, templateHelpers, }) => { | ||
let hasEnum = false; | ||
let hasDoc = false; | ||
let hasDefault = false; | ||
let hasSpecialType = false; | ||
const computeUpdateDtoParams = ({ model, allModels, templateHelpers, noDependencies, }) => { | ||
let hasApiProperty = false; | ||
const imports = []; | ||
@@ -41,3 +38,4 @@ const extraClasses = []; | ||
(0, helpers_1.concatIntoArray)(relationInputType.generatedClasses, extraClasses); | ||
(0, helpers_1.concatIntoArray)(relationInputType.apiExtraModels, apiExtraModels); | ||
if (!noDependencies) | ||
(0, helpers_1.concatIntoArray)(relationInputType.apiExtraModels, apiExtraModels); | ||
} | ||
@@ -55,21 +53,17 @@ if (relationScalarFieldNames.includes(name)) | ||
} | ||
if (api_decorator_1.PrismaScalarToFormat[field.type]) | ||
hasSpecialType = true; | ||
if (field.kind === 'enum') | ||
hasEnum = true; | ||
if ((0, api_decorator_1.isAnnotatedWithDoc)(field)) | ||
hasDoc = true; | ||
if ((0, api_decorator_1.getDefaultValue)(field) !== undefined) | ||
hasDefault = true; | ||
if (!noDependencies) | ||
hasApiProperty = (0, api_decorator_1.parseApiProperty)(field); | ||
if (noDependencies) { | ||
if (field.type === 'Json') | ||
field.type = 'Object'; | ||
else if (field.type === 'Decimal') | ||
field.type = 'Float'; | ||
} | ||
return [...result, (0, helpers_1.mapDMMFToParsedField)(field, overrides)]; | ||
}, []); | ||
if (apiExtraModels.length || | ||
hasEnum || | ||
hasDoc || | ||
hasDefault || | ||
hasSpecialType) { | ||
if (apiExtraModels.length || hasApiProperty) { | ||
const destruct = []; | ||
if (apiExtraModels.length) | ||
destruct.push('ApiExtraModels'); | ||
if (hasEnum || hasDoc || hasDefault || hasSpecialType) | ||
if (hasApiProperty) | ||
destruct.push('ApiProperty'); | ||
@@ -76,0 +70,0 @@ imports.unshift({ from: '@nestjs/swagger', destruct }); |
@@ -7,4 +7,5 @@ import { TemplateHelpers } from '../template-helpers'; | ||
templateHelpers: TemplateHelpers; | ||
noDependencies: boolean; | ||
} | ||
export declare const computeModelParams: ({ model, allModels, templateHelpers, }: ComputeModelParamsParam) => ModelParams; | ||
export declare const computeModelParams: ({ model, allModels, templateHelpers, noDependencies, }: ComputeModelParamsParam) => ModelParams; | ||
export {}; |
@@ -9,3 +9,3 @@ "use strict"; | ||
const compute_plain_dto_params_1 = require("./compute-plain-dto-params"); | ||
const computeModelParams = ({ model, allModels, templateHelpers, }) => ({ | ||
const computeModelParams = ({ model, allModels, templateHelpers, noDependencies, }) => ({ | ||
connect: (0, compute_connect_dto_params_1.computeConnectDtoParams)({ model }), | ||
@@ -16,2 +16,3 @@ create: (0, compute_create_dto_params_1.computeCreateDtoParams)({ | ||
templateHelpers, | ||
noDependencies, | ||
}), | ||
@@ -22,6 +23,17 @@ update: (0, compute_update_dto_params_1.computeUpdateDtoParams)({ | ||
templateHelpers, | ||
noDependencies, | ||
}), | ||
entity: (0, compute_entity_params_1.computeEntityParams)({ model, allModels, templateHelpers }), | ||
plain: (0, compute_plain_dto_params_1.computePlainDtoParams)({ model, allModels, templateHelpers }), | ||
entity: (0, compute_entity_params_1.computeEntityParams)({ | ||
model, | ||
allModels, | ||
templateHelpers, | ||
noDependencies, | ||
}), | ||
plain: (0, compute_plain_dto_params_1.computePlainDtoParams)({ | ||
model, | ||
allModels, | ||
templateHelpers, | ||
noDependencies, | ||
}), | ||
}); | ||
exports.computeModelParams = computeModelParams; |
@@ -7,3 +7,3 @@ "use strict"; | ||
export class ${t.connectDtoName(model.name)} { | ||
${t.fieldsToDtoProps(fields, true, false, true)} | ||
${t.fieldsToDtoProps(fields, true, false)} | ||
} | ||
@@ -10,0 +10,0 @@ `; |
@@ -8,2 +8,3 @@ import type { DMMF } from '@prisma/generator-helper'; | ||
outputToNestJsResourceStructure: boolean; | ||
flatResourceStructure: boolean; | ||
connectDtoPrefix: string; | ||
@@ -16,4 +17,5 @@ createDtoPrefix: string; | ||
fileNamingStyle: NamingStyle; | ||
noDependencies: boolean; | ||
} | ||
export declare const run: ({ output, dmmf, ...options }: RunParam) => WriteableFileSpecs[]; | ||
export {}; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const run = ({ output, dmmf, ...options }) => { | ||
const { exportRelationModifierClasses, outputToNestJsResourceStructure, fileNamingStyle = 'camel', ...preAndSuffixes } = options; | ||
const { exportRelationModifierClasses, outputToNestJsResourceStructure, flatResourceStructure, fileNamingStyle = 'camel', noDependencies, ...preAndSuffixes } = options; | ||
const transformers = { | ||
@@ -41,6 +41,10 @@ camel: case_1.camel, | ||
dto: outputToNestJsResourceStructure | ||
? node_path_1.default.join(output, transformFileNameCase(model.name), 'dto') | ||
? flatResourceStructure | ||
? node_path_1.default.join(output, transformFileNameCase(model.name)) | ||
: node_path_1.default.join(output, transformFileNameCase(model.name), 'dto') | ||
: output, | ||
entity: outputToNestJsResourceStructure | ||
? node_path_1.default.join(output, transformFileNameCase(model.name), 'entities') | ||
? flatResourceStructure | ||
? node_path_1.default.join(output, transformFileNameCase(model.name)) | ||
: node_path_1.default.join(output, transformFileNameCase(model.name), 'entities') | ||
: output, | ||
@@ -55,2 +59,3 @@ }, | ||
templateHelpers, | ||
noDependencies, | ||
}); | ||
@@ -57,0 +62,0 @@ const connectDto = { |
@@ -41,4 +41,4 @@ import { ImportStatementParams, ParsedField } from './types'; | ||
echo: (input: string) => string; | ||
fieldsToDtoProps: (fields: ParsedField[], useInputTypes?: boolean, forceOptional?: boolean, omitAnnotation?: boolean) => string; | ||
fieldToDtoProp: (field: ParsedField, useInputTypes?: boolean, forceOptional?: boolean, omitAnnotation?: boolean) => string; | ||
fieldsToDtoProps: (fields: ParsedField[], useInputTypes?: boolean, forceOptional?: boolean) => string; | ||
fieldToDtoProp: (field: ParsedField, useInputTypes?: boolean, forceOptional?: boolean) => string; | ||
fieldToEntityProp: (field: ParsedField) => string; | ||
@@ -45,0 +45,0 @@ fieldsToEntityProps: (fields: ParsedField[]) => string; |
@@ -15,2 +15,3 @@ "use strict"; | ||
Bytes: 'Buffer', | ||
Object: '{ [key: string]: any }', | ||
}; | ||
@@ -81,5 +82,5 @@ const knownPrismaScalarTypes = Object.keys(PrismaScalarToTypeScript); | ||
: entityName(field.type)}${(0, exports.when)(field.isList, '[]')}`; | ||
const fieldToDtoProp = (field, useInputTypes = false, forceOptional = false, omitAnnotation = false) => `${(0, exports.unless)(omitAnnotation, (0, api_decorator_1.decorateApiProperty)(field))}${field.name}${(0, exports.unless)(field.isRequired && !forceOptional, '?')}: ${fieldType(field, useInputTypes)};`; | ||
const fieldsToDtoProps = (fields, useInputTypes = false, forceOptional = false, omitAnnotation = false) => `${(0, exports.each)(fields, (field) => fieldToDtoProp(field, useInputTypes, forceOptional, omitAnnotation), '\n')}`; | ||
const fieldToEntityProp = (field) => `${(0, api_decorator_1.decorateApiProperty)(field, false)}${field.name}${(0, exports.unless)(field.isRequired, '?')}: ${fieldType(field)} ${(0, exports.when)(field.isNullable, ' | null')};`; | ||
const fieldToDtoProp = (field, useInputTypes = false, forceOptional = false) => `${(0, api_decorator_1.decorateApiProperty)(field)}${field.name}${(0, exports.unless)(field.isRequired && !forceOptional, '?')}: ${fieldType(field, useInputTypes)};`; | ||
const fieldsToDtoProps = (fields, useInputTypes = false, forceOptional = false) => `${(0, exports.each)(fields, (field) => fieldToDtoProp(field, useInputTypes, forceOptional), '\n')}`; | ||
const fieldToEntityProp = (field) => `${(0, api_decorator_1.decorateApiProperty)(field)}${field.name}${(0, exports.unless)(field.isRequired, '?')}: ${fieldType(field)} ${(0, exports.when)(field.isNullable, ' | null')};`; | ||
const fieldsToEntityProps = (fields) => `${(0, exports.each)(fields, (field) => fieldToEntityProp(field), '\n')}`; | ||
@@ -86,0 +87,0 @@ const apiExtraModels = (names) => `@ApiExtraModels(${names.map(entityName)})`; |
@@ -18,2 +18,3 @@ import { DMMF } from '@prisma/generator-helper'; | ||
default?: any; | ||
apiProperty?: IApiProperty[]; | ||
} | ||
@@ -64,1 +65,5 @@ export interface ExtraModel { | ||
export declare type NamingStyle = 'snake' | 'camel' | 'pascal' | 'kebab'; | ||
export interface IApiProperty { | ||
name: string; | ||
value: string; | ||
} |
@@ -28,2 +28,3 @@ "use strict"; | ||
const outputToNestJsResourceStructure = (0, exports.stringToBoolean)(options.generator.config.outputToNestJsResourceStructure, false); | ||
const flatResourceStructure = (0, exports.stringToBoolean)(options.generator.config.flatResourceStructure, false); | ||
const reExport = (0, exports.stringToBoolean)(options.generator.config.reExport, false); | ||
@@ -37,2 +38,3 @@ const supportedFileNamingStyles = ['kebab', 'camel', 'pascal', 'snake']; | ||
} | ||
const noDependencies = (0, exports.stringToBoolean)(options.generator.config.noDependencies, false); | ||
const results = (0, generator_1.run)({ | ||
@@ -43,2 +45,3 @@ output, | ||
outputToNestJsResourceStructure, | ||
flatResourceStructure, | ||
connectDtoPrefix, | ||
@@ -51,2 +54,3 @@ createDtoPrefix, | ||
fileNamingStyle, | ||
noDependencies, | ||
}); | ||
@@ -53,0 +57,0 @@ const indexCollections = {}; |
{ | ||
"name": "@brakebein/prisma-generator-nestjs-dto", | ||
"description": "Generates DTO and Entity classes from Prisma Schema for NestJS", | ||
"version": "1.8.1", | ||
"version": "1.9.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -19,3 +19,5 @@ # Prisma Generator NestJS DTO | ||
This is a fork of [@vegardit/prisma-generator-nestjs-dto](https://github.com/vegardit/prisma-generator-nestjs-dto) and adds support to enhance fields with additional schema information, e.g., description to generate a `@ApiProperty()` decorator. See [Schema Object annotations](#schema-object-annotations). | ||
This is a fork of [@vegardit/prisma-generator-nestjs-dto](https://github.com/vegardit/prisma-generator-nestjs-dto) and adds support to enhance fields with additional schema information, e.g., description to generate a `@ApiProperty()` decorator. | ||
See [Schema Object annotations](#schema-object-annotations). | ||
Additional flags `flatResourceStructure` and `noDependencies` control the output format. | ||
@@ -37,2 +39,3 @@ ### ToDo | ||
outputToNestJsResourceStructure = "false" | ||
flatResourceStructure = "false" | ||
exportRelationModifierClasses = "true" | ||
@@ -46,2 +49,3 @@ reExport = "false" | ||
fileNamingStyle = "camel" | ||
noDependencies = "false" | ||
} | ||
@@ -56,2 +60,3 @@ ``` | ||
- [`outputToNestJsResourceStructure`]: (default: `"false"`) - writes `dto`s and `entities` to subfolders aligned with [NestJS CRUD generator](https://docs.nestjs.com/recipes/crud-generator). Resource module name is derived from lower-cased model name in `schema.prisma` | ||
- [`flatResourceStructure`]: (default: `"false"`) - If `outputToNestJsResourceStructure` is `true`, subfolders `dto`s and `entities` are created within the resource folder. Setting this to `true` will flatten the hierarchy. | ||
- [`exportRelationModifierClasses`]: (default: `"true"`) - Should extra classes generated for relationship field operations on DTOs be exported? | ||
@@ -64,3 +69,4 @@ - [`reExport`]: (default: `false`) - Should an index.ts be created for every folder? | ||
- [`entitySuffix`]: (default: `""`) - phrase to suffix every `Entity` class with | ||
- [`fileNamingStyle`]: (default: `"camel"`) - how to name generated files. Valid choices are `"camel"`, `"pascal"`, `"kebab"` and `"snake"`. | ||
- [`fileNamingStyle`]: (default: `"camel"`) - How to name generated files. Valid choices are `"camel"`, `"pascal"`, `"kebab"` and `"snake"`. | ||
- [`noDependencies`]: (default: `"false"`) - Any imports and decorators that are specific to NestJS and Prisma are omitted, such that there are no references to external dependencies. This is useful if you want to generate appropriate DTOs for the frontend. | ||
@@ -112,2 +118,3 @@ ## Annotations | ||
* `maxItems` | ||
* `example` | ||
@@ -158,12 +165,12 @@ Additionally, special data types are inferred and annotated as well: | ||
model Question { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
/// @DtoReadOnly | ||
createdAt DateTime @default(now()) | ||
/// @DtoRelationRequired | ||
createdBy User? @relation("CreatedQuestions", fields: [createdById], references: [id]) | ||
createdById String? @db.Uuid | ||
updatedAt DateTime @updatedAt | ||
/// @DtoRelationRequired | ||
updatedBy User? @relation("UpdatedQuestions", fields: [updatedById], references: [id]) | ||
updatedById String? @db.Uuid | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
/// @DtoReadOnly | ||
createdAt DateTime @default(now()) | ||
/// @DtoRelationRequired | ||
createdBy User? @relation("CreatedQuestions", fields: [createdById], references: [id]) | ||
createdById String? @db.Uuid | ||
updatedAt DateTime @updatedAt | ||
/// @DtoRelationRequired | ||
updatedBy User? @relation("UpdatedQuestions", fields: [updatedById], references: [id]) | ||
updatedById String? @db.Uuid | ||
@@ -170,0 +177,0 @@ /// @DtoRelationRequired |
94019
1386
353