Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// set serialize
const serialize = isObjectFull(this.options.serialize) ? this.options.serialize : {};
this.options.serialize = { ...CrudConfigService.config.serialize, ...serialize };
this.options.serialize.get = isFalse(this.options.serialize.get)
? false
: this.options.serialize.get || this.modelType;
this.options.serialize.getMany = isFalse(this.options.serialize.getMany)
? false
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
this.options.serialize.create = isFalse(this.options.serialize.create)
? false
: this.options.serialize.create || this.modelType;
this.options.serialize.update = isFalse(this.options.serialize.update)
? false
: this.options.serialize.update || this.modelType;
this.options.serialize.replace = isFalse(this.options.serialize.replace)
? false
: this.options.serialize.replace || this.modelType;
this.options.serialize.delete =
isFalse(this.options.serialize.delete) ||
!this.options.routes.deleteOneBase.returnDeleted
? false
: this.options.serialize.delete || this.modelType;
R.setCrudOptions(this.options, this.target);
}
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
this.options.serialize.create = isFalse(this.options.serialize.create)
? false
: this.options.serialize.create || this.modelType;
this.options.serialize.update = isFalse(this.options.serialize.update)
? false
: this.options.serialize.update || this.modelType;
this.options.serialize.replace = isFalse(this.options.serialize.replace)
? false
: this.options.serialize.replace || this.modelType;
this.options.serialize.delete =
isFalse(this.options.serialize.delete) ||
!this.options.routes.deleteOneBase.returnDeleted
? false
: this.options.serialize.delete || this.modelType;
R.setCrudOptions(this.options, this.target);
}
primary: true,
};
}
// set dto
if (!isObjectFull(this.options.dto)) {
this.options.dto = {};
}
// set serialize
const serialize = isObjectFull(this.options.serialize) ? this.options.serialize : {};
this.options.serialize = { ...CrudConfigService.config.serialize, ...serialize };
this.options.serialize.get = isFalse(this.options.serialize.get)
? false
: this.options.serialize.get || this.modelType;
this.options.serialize.getMany = isFalse(this.options.serialize.getMany)
? false
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
this.options.serialize.create = isFalse(this.options.serialize.create)
? false
: this.options.serialize.create || this.modelType;
this.options.serialize.update = isFalse(this.options.serialize.update)
? false
: this.options.serialize.update || this.modelType;
this.options.serialize.replace = isFalse(this.options.serialize.replace)
? false
: this.options.serialize.replace || this.modelType;
this.options.serialize.delete =
static createBulkDto(options: MergedCrudOptions): any {
/* istanbul ignore else */
if (validator && transformer && !isFalse(options.validation)) {
const { IsArray, ArrayNotEmpty, ValidateNested } = validator;
const { Type } = transformer;
const hasDto = !isNil(options.dto.create);
const groups = !hasDto ? [CrudValidationGroups.CREATE] : undefined;
const always = hasDto ? true : undefined;
const Model = hasDto ? options.dto.create : options.model.type;
// tslint:disable-next-line:max-classes-per-file
class BulkDtoImpl implements CreateManyDto {
@ApiProperty({ type: Model, isArray: true })
@IsArray({ groups, always })
@ArrayNotEmpty({ groups, always })
@ValidateNested({ each: true, groups, always })
@Type(() => Model)
bulk: T[];
}
static getValidationPipe(
options: CrudOptions,
group?: CrudValidationGroups,
): ValidationPipe {
return validator && !isFalse(options.validation)
? new ValidationPipe({
...(options.validation || {}),
groups: group ? [group] : undefined,
})
: /* istanbul ignore next */ undefined;
}
? false
: this.options.serialize.get || this.modelType;
this.options.serialize.getMany = isFalse(this.options.serialize.getMany)
? false
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
this.options.serialize.create = isFalse(this.options.serialize.create)
? false
: this.options.serialize.create || this.modelType;
this.options.serialize.update = isFalse(this.options.serialize.update)
? false
: this.options.serialize.update || this.modelType;
this.options.serialize.replace = isFalse(this.options.serialize.replace)
? false
: this.options.serialize.replace || this.modelType;
this.options.serialize.delete =
isFalse(this.options.serialize.delete) ||
!this.options.routes.deleteOneBase.returnDeleted
? false
: this.options.serialize.delete || this.modelType;
R.setCrudOptions(this.options, this.target);
}
protected transform(dto: any, data: any) {
if (!isObject(data) || isFalse(dto)) {
return data;
}
if (!isFunction(dto)) {
return data.constructor !== Object ? classToPlain(data) : data;
}
return data instanceof dto
? classToPlain(data)
: classToPlain(classToPlainFromExist(data, new dto()));
}