nodejs-data-grid
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -6,11 +6,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const { __ΩClassType } = require('@deepkit/core'); | ||
const { __ΩIGridRequestDto } = require('./GridRequestDto'); | ||
const { __ΩIGridRequestDtoFilter } = require('./GridRequestDto'); | ||
const __ΩRecord = ['K', 'T', 'l\'e#"Rb!b"Pde"!N#!']; | ||
const orm_1 = require("@deepkit/orm"); | ||
const GridRequestDto_1 = require("./GridRequestDto"); | ||
const GridResponse_1 = __importDefault(require("./GridResponse")); | ||
class AGrid { | ||
db; | ||
constructor(db) { | ||
this.db = db; | ||
this.filterableColumns = null; | ||
this.sortableColumns = null; | ||
this.searchableColumns = null; | ||
} | ||
filterableColumns = null; | ||
sortableColumns = null; | ||
searchableColumns = null; | ||
async filter(dto) { | ||
@@ -52,3 +58,3 @@ let query = this.searchQuery(this.db.query(this.entity)); | ||
let sorted = query; | ||
allSorts.forEach(sorter => { | ||
allSorts.forEach(Object.assign(sorter => { | ||
let column = sorter.column; | ||
@@ -64,3 +70,3 @@ if (this.sortableColumns != null) { | ||
sorted = sorted.orderBy(column, sorter.direction.toLowerCase()); | ||
}); | ||
}, { __type: ['sorter', '', 'P"2!"/"'] })); | ||
return sorted; | ||
@@ -75,17 +81,17 @@ } | ||
if (allFilters.length > 0) { | ||
allFilters.forEach(and => { | ||
allFilters.forEach(Object.assign(and => { | ||
const orFilter = []; | ||
and.forEach(or => { | ||
and.forEach(Object.assign(or => { | ||
const column = this.getFilterableColumn(or.column); | ||
orFilter.push({ [column]: AGrid.createExpression(or) }); | ||
}); | ||
}, { __type: ['or', '', 'P"2!"/"'] })); | ||
filter.$and.push({ $or: orFilter }); | ||
}); | ||
}, { __type: ['and', '', 'P"2!"/"'] })); | ||
} | ||
if (dto.search) { | ||
const searches = []; | ||
this.searchableColumns?.forEach(column => { | ||
this.searchableColumns?.forEach(Object.assign(column => { | ||
const name = this.getFilterableColumn(column); | ||
searches.push({ [name]: { $regex: dto.search } }); | ||
}); | ||
}, { __type: ['column', '', 'P"2!"/"'] })); | ||
filter.$and.push({ $or: searches }); | ||
@@ -157,3 +163,4 @@ } | ||
} | ||
static __type = ['T', () => orm_1.Database, 'db', 'constructor', () => __ΩClassType, 'entity', () => __ΩRecord, 'filterableColumns', function () { return null; }, () => __ΩRecord, 'sortableColumns', function () { return null; }, 'searchableColumns', function () { return null; }, () => __ΩIGridRequestDto, 'dto', () => GridResponse_1.default, 'filter', () => orm_1.Query, 'query', () => orm_1.Query, 'searchQuery', () => orm_1.Query, () => __ΩIGridRequestDto, () => orm_1.Query, 'addPaging', () => orm_1.Query, () => __ΩIGridRequestDto, () => orm_1.Query, 'addSorter', () => __ΩIGridRequestDto, () => __ΩRecord, 'addFilter', 'name', 'getFilterableColumn', () => __ΩRecord, 'filters', 'isFilterEmpty', () => __ΩIGridRequestDtoFilter, 'createExpression', 'b!PP7"2#;"0$n%3&<=P&&o\'#,J3(<>)P&&o*#,J3+<>,P&F,J3-<>.Pn/20Pe#!71`02PP"7324P"7506<PP"7724n820P"790:;PP"7;24n<20P"7=0>;Pn?20&"o@#0A;P&2B&0C;P&"oD#2E)0F;PnG22"0H;5']; | ||
} | ||
exports.default = AGrid; |
@@ -42,1 +42,4 @@ export interface IGridRequestDto { | ||
} | ||
export declare type __ΩIGridRequestDto = any[]; | ||
export declare type __ΩIGridRequestDtoFilter = any[]; | ||
export declare type __ΩIGridRequestDtoSorter = any[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Direction = exports.Operator = void 0; | ||
exports.Direction = exports.__ΩDirection = exports.Operator = exports.__ΩOperator = exports.__ΩIGridRequestDtoSorter = exports.__ΩIGridRequestDtoFilter = exports.__ΩIGridRequestDto = void 0; | ||
const __ΩIGridRequestDto = [() => __ΩIGridRequestDtoFilter, 'filter', () => __ΩIGridRequestDtoFilter, 'additionalFilter', () => __ΩIGridRequestDtoSorter, 'sorter', () => __ΩIGridRequestDtoSorter, 'additionalSorter', 'search', 'page', 'itemsPerPage', 'paging', 'Pn!FF4"8n#FF4$8n%F4&8n\'F4(8&4)8P\'4*\'4+M4,8M']; | ||
exports.__ΩIGridRequestDto = __ΩIGridRequestDto; | ||
const __ΩIGridRequestDtoFilter = ['column', () => __ΩOperator, 'operator', 'value', 'P&4!n"4#&F4$M']; | ||
exports.__ΩIGridRequestDtoFilter = __ΩIGridRequestDtoFilter; | ||
const __ΩIGridRequestDtoSorter = ['column', () => __ΩDirection, 'direction', 'P&4!n"4#M']; | ||
exports.__ΩIGridRequestDtoSorter = __ΩIGridRequestDtoSorter; | ||
const __ΩOperator = ['EQ', () => "EQ", 'NEQ', () => "NEQ", 'IN', () => "IN", 'NIN', () => "NIN", 'GT', () => "GT", 'LT', () => "LT", 'GTE', () => "GTE", 'LTE', () => "LTE", 'LIKE', () => "LIKE", 'STARTS', () => "STARTS", 'ENDS', () => "ENDS", 'NEMPTY', () => "NEMPTY", 'EMPTY', () => "EMPTY", 'BETWEEN', () => "BETWEEN", 'NBETWEEN', () => "NBETWEEN", 'PC!>"C#>$C%>&C\'>(C)>*C+>,C->.C/>0C1>2C3>4C5>6C7>8C9>:C;><C=>>B']; | ||
exports.__ΩOperator = __ΩOperator; | ||
var Operator; | ||
@@ -22,2 +30,4 @@ (function (Operator) { | ||
})(Operator = exports.Operator || (exports.Operator = {})); | ||
const __ΩDirection = ['ASC', () => "ASC", 'DESC', () => "DESC", 'PC!>"C#>$B']; | ||
exports.__ΩDirection = __ΩDirection; | ||
var Direction; | ||
@@ -24,0 +34,0 @@ (function (Direction) { |
@@ -18,1 +18,2 @@ import { IGridRequestDto, IGridRequestDtoFilter, IGridRequestDtoSorter } from './GridRequestDto'; | ||
} | ||
export declare type __ΩIPaging = any[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.__ΩIPaging = void 0; | ||
const { __ΩIGridRequestDtoFilter } = require('./GridRequestDto'); | ||
const { __ΩIGridRequestDtoSorter } = require('./GridRequestDto'); | ||
const { __ΩIGridRequestDto } = require('./GridRequestDto'); | ||
class GridResponse { | ||
items; | ||
filter; | ||
sorter; | ||
search; | ||
paging; | ||
constructor(items, total, dto) { | ||
@@ -21,3 +30,6 @@ this.items = items; | ||
} | ||
static __type = ['T', 'items', () => __ΩIGridRequestDtoFilter, 'filter', () => __ΩIGridRequestDtoSorter, 'sorter', 'search', () => __ΩIPaging, 'paging', 'total', () => __ΩIGridRequestDto, 'dto', 'constructor', 'b!e!!F3"n#FF3$8n%F3&8&3\'8n(3)Pe"!F2"\'2*n+2,"0-5']; | ||
} | ||
exports.default = GridResponse; | ||
const __ΩIPaging = ['page', 'itemsPerPage', 'total', 'nextPage', 'lastPage', 'previousPage', 'P\'4!\'4"\'4#\'4$\'4%\'4&M']; | ||
exports.__ΩIPaging = __ΩIPaging; |
@@ -12,8 +12,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const { __ΩPrimaryKey } = require('@deepkit/type'); | ||
const { __ΩAutoIncrement } = require('@deepkit/type'); | ||
const type_1 = require("@deepkit/type"); | ||
let ExampleEntity = class ExampleEntity { | ||
name; | ||
id = 0; | ||
constructor(name) { | ||
this.name = name; | ||
this.id = 0; | ||
} | ||
static __type = [() => __ΩPrimaryKey, () => __ΩAutoIncrement, 'id', function () { return 0; }, 'name', 'constructor', 'P(!n!n"K3#>$P&2%:"0&5']; | ||
}; | ||
@@ -20,0 +24,0 @@ ExampleEntity = __decorate([ |
@@ -6,24 +6,33 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const { __ΩClassType } = require('@deepkit/core'); | ||
const __ΩRecord = ['K', 'T', 'l\'e#"Rb!b"Pde"!N#!']; | ||
const AGrid_1 = __importDefault(require("../lib/AGrid")); | ||
const orm_1 = require("@deepkit/orm"); | ||
const ExampleEntity_1 = __importDefault(require("./ExampleEntity")); | ||
class ExampleGrid extends AGrid_1.default { | ||
constructor() { | ||
super(...arguments); | ||
this.entity = ExampleEntity_1.default; | ||
this.filterableColumns = { | ||
entity = ExampleEntity_1.default; | ||
filterableColumns = { | ||
id: 'id', | ||
namae: 'name', | ||
}; | ||
sortableColumns = { | ||
id: 'id', | ||
}; | ||
searchableColumns = [ | ||
'id', | ||
'namae', | ||
]; | ||
searchQuery(query) { | ||
return query.select('id', 'name'); | ||
} | ||
static __type = [() => __ΩClassType, 'entity', function () { return ExampleEntity_1.default; }, () => __ΩRecord, 'filterableColumns', function () { return { | ||
id: 'id', | ||
namae: 'name', | ||
}; | ||
this.sortableColumns = { | ||
}; }, () => __ΩRecord, 'sortableColumns', function () { return { | ||
id: 'id', | ||
}; | ||
this.searchableColumns = [ | ||
}; }, 'searchableColumns', function () { return [ | ||
'id', | ||
'namae', | ||
]; | ||
} | ||
searchQuery(query) { | ||
return query.select('id', 'name'); | ||
} | ||
]; }, () => orm_1.Query, 'query', () => orm_1.Query, 'searchQuery', () => ExampleEntity_1.default, 'n!3"<>#P&&o$#,J3%<>&P&&o\'#,J3(<>)P&F,J3*<>+PP"7,2-P"7.0/<5P706"']; | ||
} | ||
exports.default = ExampleGrid; |
{ | ||
"name": "nodejs-data-grid", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -24,4 +24,4 @@ "main": "dist/lib/index.js", | ||
"@deepkit/type-compiler": "^1.0.1-alpha.71", | ||
"rxjs": "^7.4.0", | ||
"typescript": "^4.5.2" | ||
"rxjs": "^7.5.5", | ||
"typescript": "^4.6.4" | ||
}, | ||
@@ -31,14 +31,14 @@ "devDependencies": { | ||
"@deepkit/sql": "^1.0.1-alpha.71", | ||
"@types/jest": "^27.0.3", | ||
"@types/node": "^16.11.9", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"eslint": "^8.2.0", | ||
"@types/jest": "^27.5.0", | ||
"@types/node": "^17.0.31", | ||
"@typescript-eslint/eslint-plugin": "^5.22.0", | ||
"@typescript-eslint/parser": "^5.22.0", | ||
"eslint": "^8.14.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-import-resolver-typescript": "^2.5.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"jest": "^27.3.1", | ||
"ts-jest": "^27.0.7", | ||
"ts-node": "^10.4.0" | ||
"eslint-import-resolver-typescript": "^2.7.1", | ||
"eslint-plugin-import": "^2.26.0", | ||
"jest": "^28.0.3", | ||
"ts-jest": "^28.0.1", | ||
"ts-node": "^10.7.0" | ||
} | ||
} |
@@ -1,2 +0,4 @@ | ||
import { entity, PrimaryKey, AutoIncrement, integer } from '@deepkit/type'; | ||
import { | ||
entity, PrimaryKey, AutoIncrement, integer, | ||
} from '@deepkit/type'; | ||
@@ -3,0 +5,0 @@ @entity.name('example') |
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"target": "ES2022", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"rootDir": "./", | ||
"outDir": "./dist", | ||
"typeRoots": [ | ||
"node_modules/@types" | ||
], | ||
"allowJs": true, | ||
@@ -12,0 +8,0 @@ "noImplicitAny": true, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73066
968
Updatedrxjs@^7.5.5
Updatedtypescript@^4.6.4