Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brakebein/prisma-generator-nestjs-dto

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brakebein/prisma-generator-nestjs-dto - npm Package Compare versions

Comparing version 1.17.0-beta0 to 1.17.0

1

dist/generator/index.d.ts

@@ -19,2 +19,3 @@ import { DMMF } from '@prisma/generator-helper';

noDependencies: boolean;
definiteAssignmentAssertion: boolean;
prismaClientImportPath: string;

@@ -21,0 +22,0 @@ }

3

dist/generator/index.js

@@ -21,3 +21,3 @@ "use strict";

const run = ({ output, dmmf, ...options }) => {
const { exportRelationModifierClasses, outputToNestJsResourceStructure, flatResourceStructure, fileNamingStyle = 'camel', classValidation, outputType, noDependencies, prismaClientImportPath, ...preAndSuffixes } = options;
const { exportRelationModifierClasses, outputToNestJsResourceStructure, flatResourceStructure, fileNamingStyle = 'camel', classValidation, outputType, noDependencies, definiteAssignmentAssertion, prismaClientImportPath, ...preAndSuffixes } = options;
const transformers = {

@@ -36,2 +36,3 @@ camel: case_1.camel,

noDependencies,
definiteAssignmentAssertion,
prismaClientImportPath,

@@ -38,0 +39,0 @@ ...preAndSuffixes,

@@ -21,5 +21,6 @@ import { ImportStatementParams, ParsedField } from './types';

noDependencies: boolean;
definiteAssignmentAssertion: boolean;
prismaClientImportPath: string;
}
export declare const makeHelpers: ({ connectDtoPrefix, createDtoPrefix, updateDtoPrefix, dtoSuffix, entityPrefix, entitySuffix, transformClassNameCase, transformFileNameCase, classValidation, outputType, noDependencies, prismaClientImportPath, }: MakeHelpersParam) => {
export declare const makeHelpers: ({ connectDtoPrefix, createDtoPrefix, updateDtoPrefix, dtoSuffix, entityPrefix, entitySuffix, transformClassNameCase, transformFileNameCase, classValidation, outputType, noDependencies, definiteAssignmentAssertion, prismaClientImportPath, }: MakeHelpersParam) => {
config: {

@@ -35,2 +36,3 @@ connectDtoPrefix: string;

noDependencies: boolean;
definiteAssignmentAssertion: boolean;
prismaClientImportPath: string;

@@ -37,0 +39,0 @@ };

@@ -66,3 +66,3 @@ "use strict";

exports.importStatements = importStatements;
const makeHelpers = ({ connectDtoPrefix, createDtoPrefix, updateDtoPrefix, dtoSuffix, entityPrefix, entitySuffix, transformClassNameCase = exports.echo, transformFileNameCase = exports.echo, classValidation, outputType, noDependencies, prismaClientImportPath, }) => {
const makeHelpers = ({ connectDtoPrefix, createDtoPrefix, updateDtoPrefix, dtoSuffix, entityPrefix, entitySuffix, transformClassNameCase = exports.echo, transformFileNameCase = exports.echo, classValidation, outputType, noDependencies, definiteAssignmentAssertion, prismaClientImportPath, }) => {
const className = (name, prefix = '', suffix = '') => `${prefix}${transformClassNameCase(name)}${suffix}`;

@@ -112,5 +112,5 @@ const fileName = (name, prefix = '', suffix = '', withExtension = false) => `${prefix}${transformFileNameCase(name)}${suffix}${(0, exports.when)(withExtension, '.ts')}`;

};
const fieldToDtoProp = (field, dtoType, useInputTypes = false, forceOptional = false) => `${(0, api_decorator_1.decorateApiProperty)(field)}${(0, class_validator_1.decorateClassValidators)(field)}${field.name}${(0, exports.unless)(field.isRequired && !forceOptional, '?')}: ${fieldType(field, dtoType, useInputTypes)} ${(0, exports.when)(field.isNullable, ' | null')};`;
const fieldToDtoProp = (field, dtoType, useInputTypes = false, forceOptional = false) => `${(0, api_decorator_1.decorateApiProperty)(field)}${(0, class_validator_1.decorateClassValidators)(field)}${field.name}${(0, exports.unless)(field.isRequired && !forceOptional, '?', (0, exports.when)(definiteAssignmentAssertion, '!'))}: ${fieldType(field, dtoType, useInputTypes)} ${(0, exports.when)(field.isNullable, ' | null')};`;
const fieldsToDtoProps = (fields, dtoType, useInputTypes = false, forceOptional = false) => `${(0, exports.each)(fields, (field) => fieldToDtoProp(field, dtoType, 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 fieldToEntityProp = (field) => `${(0, api_decorator_1.decorateApiProperty)(field)}${field.name}${(0, exports.unless)(field.isRequired, '?', (0, exports.when)(definiteAssignmentAssertion, '!'))}: ${fieldType(field)} ${(0, exports.when)(field.isNullable, ' | null')};`;
const fieldsToEntityProps = (fields) => `${(0, exports.each)(fields, (field) => fieldToEntityProp(field), '\n')}`;

@@ -129,2 +129,3 @@ const apiExtraModels = (names) => `@ApiExtraModels(${names.map(entityName)})`;

noDependencies,
definiteAssignmentAssertion,
prismaClientImportPath,

@@ -131,0 +132,0 @@ },

@@ -48,2 +48,12 @@ "use strict";

const noDependencies = stringToBoolean(options.generator.config.noDependencies, false);
if (classValidation && outputType !== 'class') {
throw new Error(`To use 'validation' validation decorators, 'outputType' must be 'class'.`);
}
if (classValidation && noDependencies) {
throw new Error(`To use 'validation' validation decorators, 'noDependencies' cannot be false.`);
}
const definiteAssignmentAssertion = stringToBoolean(options.generator.config.definiteAssignmentAssertion, false);
if (definiteAssignmentAssertion && outputType !== 'class') {
throw new Error(`To use 'definiteAssignmentAssertion', 'outputType' must be 'class'.`);
}
const prismaClientGenerator = options.otherGenerators.find((config) => config.name === 'client');

@@ -64,8 +74,2 @@ const prismaClientOutputPath = (_a = prismaClientGenerator === null || prismaClientGenerator === void 0 ? void 0 : prismaClientGenerator.output) === null || _a === void 0 ? void 0 : _a.value;

}
if (classValidation && outputType !== 'class') {
throw new Error(`To use 'validation' validation decorators, 'outputType' must be 'class'.`);
}
if (classValidation && noDependencies) {
throw new Error(`To use 'validation' validation decorators, 'noDependencies' cannot be false.`);
}
const results = (0, generator_1.run)({

@@ -87,2 +91,3 @@ output,

noDependencies,
definiteAssignmentAssertion,
prismaClientImportPath,

@@ -89,0 +94,0 @@ });

{
"name": "@brakebein/prisma-generator-nestjs-dto",
"description": "Generates DTO and Entity classes from Prisma Schema for NestJS",
"version": "1.17.0-beta0",
"version": "1.17.0",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": {

@@ -27,2 +27,4 @@ # Prisma Generator NestJS DTO

See [CHANGELOG](CHANGELOG.md) for all improvements and changes.
### ToDo

@@ -55,2 +57,3 @@

outputType = "class"
definiteAssignmentAssertion = "true"
prettier = "false"

@@ -78,2 +81,3 @@ }

- [`outputType`]: (default: `"class"`) - Output the DTOs as `class` or as `interface`. `interface` should only be used to generate DTOs for the frontend.
- [`definiteAssignmentAssertion`]: (default: `"false"`) - Add a definite assignment assertion operator `!` to required fields, which is required if `strict` and/or `strictPropertyInitialization` is set `true` in your tsconfig.json's `compilerOptions`.
- [`prettier`]: (default: `"false"`) - Stylize output files with prettier.

@@ -80,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc