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

@dataui/crud-typeorm

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dataui/crud-typeorm - npm Package Compare versions

Comparing version 5.3.0 to 5.3.1-alpha.0

6

lib/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

66

lib/typeorm-crud.service.js

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

const primaryParams = this.getPrimaryParams(req.options);
if (!primaryParams.length && primaryParams.some((p) => crud_util_1.isNil(saved[p]))) {
if (!primaryParams.length && primaryParams.some((p) => (0, crud_util_1.isNil)(saved[p]))) {
return saved;

@@ -74,3 +74,3 @@ }

async createMany(req, dto) {
if (!crud_util_1.isObject(dto) || !crud_util_1.isArrayFull(dto.bulk)) {
if (!(0, crud_util_1.isObject)(dto) || !(0, crud_util_1.isArrayFull)(dto.bulk)) {
this.throwBadRequestException(`Empty data. Nothing to save.`);

@@ -80,4 +80,4 @@ }

.map((one) => this.prepareEntityBeforeSave(one, req.parsed))
.filter((d) => !crud_util_1.isUndefined(d));
if (!crud_util_1.hasLength(bulk)) {
.filter((d) => !(0, crud_util_1.isUndefined)(d));
if (!(0, crud_util_1.hasLength)(bulk)) {
this.throwBadRequestException(`Empty data. Nothing to save.`);

@@ -95,3 +95,3 @@ }

: { ...found, ...dto, ...req.parsed.authPersist };
const updated = await this.repo.save(class_transformer_1.plainToClass(this.entityType, toSave, req.parsed.classTransformOptions));
const updated = await this.repo.save((0, class_transformer_1.plainToClass)(this.entityType, toSave, req.parsed.classTransformOptions));
if (returnShallow) {

@@ -116,3 +116,3 @@ return updated;

req.options.query.cache = false;
const [_, found] = await o0_1.oO(this.getOneOrFail(req, returnShallow));
const [_, found] = await (0, o0_1.oO)(this.getOneOrFail(req, returnShallow));
const toSave = !allowParamsOverride

@@ -126,3 +126,3 @@ ? { ...(found || {}), ...dto, ...paramsFilters, ...req.parsed.authPersist }

};
const replaced = await this.repo.save(class_transformer_1.plainToClass(this.entityType, toSave, req.parsed.classTransformOptions));
const replaced = await this.repo.save((0, class_transformer_1.plainToClass)(this.entityType, toSave, req.parsed.classTransformOptions));
if (returnShallow) {

@@ -145,3 +145,3 @@ return replaced;

const toReturn = returnDeleted
? class_transformer_1.plainToClass(this.entityType, { ...found }, req.parsed.classTransformOptions)
? (0, class_transformer_1.plainToClass)(this.entityType, { ...found }, req.parsed.classTransformOptions)
: undefined;

@@ -155,3 +155,3 @@ const deleted = req.options.query.softDelete === true

const filters = {};
if (crud_util_1.hasLength(parsed.paramsFilter)) {
if ((0, crud_util_1.hasLength)(parsed.paramsFilter)) {
for (const filter of parsed.paramsFilter) {

@@ -175,4 +175,4 @@ filters[filter.field] = filter.value;

const joinOptions = ((_b = options.query) === null || _b === void 0 ? void 0 : _b.join) || {};
const allowedJoins = crud_util_1.objKeys(joinOptions);
if (crud_util_1.hasLength(allowedJoins)) {
const allowedJoins = (0, crud_util_1.objKeys)(joinOptions);
if ((0, crud_util_1.hasLength)(allowedJoins)) {
const eagerJoins = {};

@@ -188,3 +188,3 @@ for (let i = 0; i < allowedJoins.length; i++) {

}
if (crud_util_1.isArrayFull(parsed.join)) {
if ((0, crud_util_1.isArrayFull)(parsed.join)) {
for (let i = 0; i < parsed.join.length; i++) {

@@ -256,6 +256,6 @@ if (!eagerJoins[parsed.join[i].field]) {

prepareEntityBeforeSave(dto, parsed) {
if (!crud_util_1.isObject(dto)) {
if (!(0, crud_util_1.isObject)(dto)) {
return undefined;
}
if (crud_util_1.hasLength(parsed.paramsFilter)) {
if ((0, crud_util_1.hasLength)(parsed.paramsFilter)) {
for (const filter of parsed.paramsFilter) {

@@ -265,3 +265,3 @@ dto[filter.field] = filter.value;

}
if (!crud_util_1.hasLength(crud_util_1.objKeys(dto))) {
if (!(0, crud_util_1.hasLength)((0, crud_util_1.objKeys)(dto))) {
return undefined;

@@ -271,3 +271,3 @@ }

? Object.assign(dto, parsed.authPersist)
: class_transformer_1.plainToClass(this.entityType, { ...dto, ...parsed.authPersist }, parsed.classTransformOptions);
: (0, class_transformer_1.plainToClass)(this.entityType, { ...dto, ...parsed.authPersist }, parsed.classTransformOptions);
}

@@ -390,3 +390,3 @@ getAllowedColumns(columns, options) {

if (options.select !== false) {
const columns = crud_util_1.isArrayFull(cond.select)
const columns = (0, crud_util_1.isArrayFull)(cond.select)
? cond.select.filter((column) => allowedRelation.allowedColumns.some((allowed) => allowed === column))

@@ -396,3 +396,3 @@ : allowedRelation.allowedColumns;

...allowedRelation.primaryColumns,
...(crud_util_1.isArrayFull(options.persist) ? options.persist : []),
...((0, crud_util_1.isArrayFull)(options.persist) ? options.persist : []),
...columns,

@@ -412,6 +412,6 @@ ].map((col) => `${alias}.${col}`);

setSearchCondition(builder, search, customOperators, condition = '$and') {
if (crud_util_1.isObject(search)) {
const keys = crud_util_1.objKeys(search);
if ((0, crud_util_1.isObject)(search)) {
const keys = (0, crud_util_1.objKeys)(search);
if (keys.length) {
if (crud_util_1.isArrayFull(search.$not)) {
if ((0, crud_util_1.isArrayFull)(search.$not)) {
this.builderAddBrackets(builder, condition, new typeorm_1.Brackets((qb) => {

@@ -423,3 +423,3 @@ search.$not.forEach((item) => {

}
else if (crud_util_1.isArrayFull(search.$and)) {
else if ((0, crud_util_1.isArrayFull)(search.$and)) {
if (search.$and.length === 1) {

@@ -436,3 +436,3 @@ this.setSearchCondition(builder, search.$and[0], customOperators, condition);

}
else if (crud_util_1.isArrayFull(search.$or)) {
else if ((0, crud_util_1.isArrayFull)(search.$or)) {
if (keys.length === 1) {

@@ -455,3 +455,3 @@ if (search.$or.length === 1) {

const value = search[field];
if (!crud_util_1.isObject(value)) {
if (!(0, crud_util_1.isObject)(value)) {
this.builderSetWhere(qb, '$and', field, value, customOperators);

@@ -483,3 +483,3 @@ }

const value = search[field];
if (!crud_util_1.isObject(value)) {
if (!(0, crud_util_1.isObject)(value)) {
this.builderSetWhere(builder, condition, field, value, customOperators);

@@ -495,3 +495,3 @@ }

const value = search[field];
if (!crud_util_1.isObject(value)) {
if (!(0, crud_util_1.isObject)(value)) {
this.builderSetWhere(qb, '$and', field, value, customOperators);

@@ -546,3 +546,3 @@ }

const args = [
{ field, operator: crud_util_1.isNull(value) ? '$isnull' : operator, value },
{ field, operator: (0, crud_util_1.isNull)(value) ? '$isnull' : operator, value },
index,

@@ -556,9 +556,9 @@ builder,

setSearchFieldObjectCondition(builder, condition, field, object, customOperators) {
if (crud_util_1.isObject(object)) {
const operators = crud_util_1.objKeys(object);
if ((0, crud_util_1.isObject)(object)) {
const operators = (0, crud_util_1.objKeys)(object);
if (operators.length === 1) {
const operator = operators[0];
const value = object[operator];
if (crud_util_1.isObject(object.$or)) {
const orKeys = crud_util_1.objKeys(object.$or);
if ((0, crud_util_1.isObject)(object.$or)) {
const orKeys = (0, crud_util_1.objKeys)(object.$or);
this.setSearchFieldObjectCondition(builder, orKeys.length === 1 ? condition : '$or', field, object.$or, customOperators);

@@ -579,3 +579,3 @@ }

else {
const orKeys = crud_util_1.objKeys(object.$or);
const orKeys = (0, crud_util_1.objKeys)(object.$or);
if (orKeys.length === 1) {

@@ -763,3 +763,3 @@ this.setSearchFieldObjectCondition(qb, condition, field, object.$or, customOperators);

!cond.value.length ||
(!crud_util_1.isNil(withLength) ? withLength : false)) {
(!(0, crud_util_1.isNil)(withLength) ? withLength : false)) {
this.throwBadRequestException(`Invalid column '${cond.field}' value`);

@@ -766,0 +766,0 @@ }

{
"name": "@dataui/crud-typeorm",
"description": "NestJs CRUD for RESTful APIs - TypeORM",
"version": "5.3.0",
"version": "5.3.1-alpha.0",
"license": "MIT",

@@ -45,3 +45,3 @@ "main": "lib/index.js",

},
"gitHead": "1f5899feaecace00b8e5b19fc612eac49b3cff39"
"gitHead": "fa6f209fb223752becce404ec6088fafcd08c8a4"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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