@weverson_na/prisma-generator-nestjs-dto
Version:
Advanced Prisma Generator with Smart Merge v2: Creates DTO and Entity classes with AST-based preservation, intelligent import management, and modular architecture for NestJS
38 lines (37 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateDtoFieldConfig = void 0;
const annotations_1 = require("../../annotations");
const field_classifiers_1 = require("../../field-classifiers");
class UpdateDtoFieldConfig {
constructor(templateHelpers) {
this.templateHelpers = templateHelpers;
this.relationModifiers = annotations_1.DTO_RELATION_MODIFIERS_ON_UPDATE;
this.canCreateAnnotation = annotations_1.DTO_RELATION_CAN_CRAEATE_ON_UPDATE;
this.canConnectAnnotation = annotations_1.DTO_RELATION_CAN_CONNECT_ON_UPDATE;
this.optionalAnnotation = annotations_1.DTO_UPDATE_OPTIONAL;
this.dtoNameGenerator = (name) => {
return this.templateHelpers.updateDtoName(name);
};
this.fieldFilters = {
shouldSkipField: (field) => {
return (0, field_classifiers_1.isReadOnly)(field);
},
shouldProcessOptional: (field) => {
const isDtoOptional = (0, field_classifiers_1.isAnnotatedWith)(field, annotations_1.DTO_UPDATE_OPTIONAL);
if (!isDtoOptional) {
return ((0, field_classifiers_1.isId)(field) || (0, field_classifiers_1.isUpdatedAt)(field) || (0, field_classifiers_1.isRequiredWithDefaultValue)(field));
}
return false;
},
};
this.getFieldOverrides = (field) => {
const overrides = { isRequired: false };
if (field.kind === 'object') {
overrides.isList = false;
}
return overrides;
};
}
}
exports.UpdateDtoFieldConfig = UpdateDtoFieldConfig;