identity-admin 1.26.6 → 1.26.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -126
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -95
- package/lib/container/helpers/HelperInversify.d.ts +6 -6
- package/lib/container/helpers/HelperInversify.js +10 -10
- package/lib/container/helpers/HelperTypes.d.ts +5 -5
- package/lib/container/helpers/HelperTypes.js +7 -7
- package/lib/container/index.d.ts +1 -1
- package/lib/container/index.js +14 -14
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
- package/lib/container/repositories/RepositoryInversify.js +13 -13
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
- package/lib/container/repositories/RepositoryTypes.js +6 -6
- package/lib/container/types.d.ts +8 -8
- package/lib/container/types.js +9 -9
- package/lib/controllers/ActionController.d.ts +8 -8
- package/lib/controllers/ActionController.js +91 -91
- package/lib/controllers/DashboardController.d.ts +43 -43
- package/lib/controllers/DashboardController.js +730 -730
- package/lib/controllers/ResourceController.d.ts +15 -15
- package/lib/controllers/ResourceController.js +134 -134
- package/lib/helpers/ActionsGenerator.d.ts +11 -11
- package/lib/helpers/ActionsGenerator.js +179 -179
- package/lib/helpers/FiltersHelper.d.ts +9 -9
- package/lib/helpers/FiltersHelper.js +113 -113
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +9 -9
- package/lib/helpers/LocalizedStringHelper.js +57 -57
- package/lib/helpers/Permissions/PermissionFetcher.d.ts +7 -7
- package/lib/helpers/Permissions/PermissionFetcher.js +78 -78
- package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
- package/lib/helpers/Permissions/PermissionLabel.js +42 -42
- package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionMapper.js +35 -35
- package/lib/helpers/Permissions/PermissionResource.d.ts +5 -5
- package/lib/helpers/Permissions/PermissionResource.js +31 -31
- package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
- package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
- package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
- package/lib/helpers/Permissions/types.d.ts +17 -17
- package/lib/helpers/Permissions/types.js +2 -2
- package/lib/helpers/PopulationHelper.d.ts +12 -12
- package/lib/helpers/PopulationHelper.js +50 -50
- package/lib/helpers/ReportsGenerator.d.ts +11 -11
- package/lib/helpers/ReportsGenerator.js +57 -57
- package/lib/helpers/ResourceGenerator.d.ts +9 -9
- package/lib/helpers/ResourceGenerator.js +172 -172
- package/lib/helpers/ResourceHelper.d.ts +28 -28
- package/lib/helpers/ResourceHelper.js +395 -395
- package/lib/helpers/RportsGenerator.d.ts +10 -10
- package/lib/helpers/RportsGenerator.js +21 -21
- package/lib/helpers/SchemaGenerator.d.ts +5 -5
- package/lib/helpers/SchemaGenerator.js +97 -97
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.d.ts +2 -2
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.js +49 -49
- package/lib/locales/en.json +53 -53
- package/lib/middlewares/cache/decorator.d.ts +3 -3
- package/lib/middlewares/cache/decorator.js +60 -60
- package/lib/middlewares/cache/deletionMethods.d.ts +3 -3
- package/lib/middlewares/cache/deletionMethods.js +23 -23
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +8 -8
- package/lib/models/ModelNames.js +11 -11
- package/lib/models/adminpermission/AdminPermission.d.ts +6 -6
- package/lib/models/adminpermission/AdminPermission.js +23 -23
- package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
- package/lib/models/adminpermission/IAdminPermission.js +2 -2
- package/lib/models/customPage/CustomPage.d.ts +2 -2
- package/lib/models/customPage/CustomPage.js +38 -38
- package/lib/models/customPage/ICustomPage.d.ts +17 -17
- package/lib/models/customPage/ICustomPage.js +2 -2
- package/lib/models/file/File.d.ts +2 -2
- package/lib/models/file/File.js +23 -23
- package/lib/models/file/IFile.d.ts +15 -15
- package/lib/models/file/IFile.js +2 -2
- package/lib/models/location/ILocation.d.ts +14 -14
- package/lib/models/location/ILocation.js +2 -2
- package/lib/models/location/Location.d.ts +2 -2
- package/lib/models/location/Location.js +21 -21
- package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
- package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
- package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
- package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
- package/lib/models/permission/IPermission.d.ts +14 -14
- package/lib/models/permission/IPermission.js +2 -2
- package/lib/models/permission/Permission.d.ts +2 -2
- package/lib/models/permission/Permission.js +21 -21
- package/lib/models/request-log/IRequestLog.d.ts +22 -22
- package/lib/models/request-log/IRequestLog.js +2 -2
- package/lib/models/request-log/RequestLog.d.ts +3 -3
- package/lib/models/request-log/RequestLog.js +51 -51
- package/lib/models/userActionsLog/IUserActionsLog.d.ts +26 -24
- package/lib/models/userActionsLog/IUserActionsLog.js +11 -9
- package/lib/models/userActionsLog/UserActionsLog.d.ts +3 -3
- package/lib/models/userActionsLog/UserActionsLog.js +41 -41
- package/lib/pdf/ReportTemplate.d.ts +71 -71
- package/lib/pdf/ReportTemplate.js +94 -94
- package/lib/repositories/DashboardRepository.d.ts +5 -5
- package/lib/repositories/DashboardRepository.js +12 -12
- package/lib/repositories/Repository.d.ts +68 -68
- package/lib/repositories/Repository.js +212 -212
- package/lib/repositories/RequestLogRepository.d.ts +10 -10
- package/lib/repositories/RequestLogRepository.js +54 -54
- package/lib/repositories/SaveResult.d.ts +14 -14
- package/lib/repositories/SaveResult.js +18 -18
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +104 -104
- package/lib/types/DashbordConfig.d.ts +21 -21
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +9 -9
- package/lib/types/IConfigurationFile.js +2 -2
- package/lib/types/IResourceFile.d.ts +654 -654
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/IResourceResponse.d.ts +95 -95
- package/lib/types/IResourceResponse.js +2 -2
- package/lib/types/helpers.d.ts +65 -65
- package/lib/types/helpers.js +76 -76
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +11 -11
- package/lib/utils/ResponseUtils.js +41 -41
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +18 -18
- package/lib/view/assets/icons/delete_icon.svg +3 -3
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
- package/lib/view/assets/icons/info_icon.svg +3 -3
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
- package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
- package/lib/view/assets/icons/small_info_icon.svg +3 -3
- package/lib/view/assets/illustrations/Group 16.svg +4 -4
- package/lib/view/assets/illustrations/logo.svg +5 -5
- package/lib/view/favicon/browserconfig.xml +9 -9
- package/lib/view/favicon/safari-pinned-tab.svg +182 -182
- package/lib/view/favicon/site.webmanifest +19 -19
- package/lib/view/fonts/index.css +18 -18
- package/lib/view/index.html +52 -52
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/css/main.54de06ef.css +1 -1
- package/lib/view/static/js/574.778b5963.chunk.js +1 -1
- package/lib/view/static/js/678.521704a3.chunk.js +1 -1
- package/lib/view/static/js/798.54856416.chunk.js +1 -1
- package/lib/view/static/js/main.4687f255.js +2 -2
- package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
- package/package.json +62 -62
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { Aggregate, Document, Model } from 'mongoose';
|
|
2
|
-
import SaveResult from './SaveResult';
|
|
3
|
-
export interface PaginateParams {
|
|
4
|
-
page: number;
|
|
5
|
-
perPage: number;
|
|
6
|
-
}
|
|
7
|
-
interface IQueryOptions {
|
|
8
|
-
filter?: any;
|
|
9
|
-
sort?: any;
|
|
10
|
-
select?: any;
|
|
11
|
-
limit?: number;
|
|
12
|
-
skip?: number;
|
|
13
|
-
paginateParams?: PaginateParams;
|
|
14
|
-
populate?: any;
|
|
15
|
-
}
|
|
16
|
-
export interface PageInfo {
|
|
17
|
-
currentPage: number;
|
|
18
|
-
pagesCount: number;
|
|
19
|
-
nextPage: number;
|
|
20
|
-
recordsCount: number;
|
|
21
|
-
perPage: number;
|
|
22
|
-
}
|
|
23
|
-
export interface Page<T> {
|
|
24
|
-
records: T[];
|
|
25
|
-
pageInfo: PageInfo;
|
|
26
|
-
}
|
|
27
|
-
export interface IDashboardRepository {
|
|
28
|
-
}
|
|
29
|
-
export interface IRepository<T extends Document> {
|
|
30
|
-
findById(id: any): Promise<T | null>;
|
|
31
|
-
findOne(queryOptions?: IQueryOptions): Promise<T | null>;
|
|
32
|
-
findMany(queryOptions?: IQueryOptions): Promise<T[]>;
|
|
33
|
-
count(filterOptions: any): Promise<number>;
|
|
34
|
-
save(props: any): Promise<SaveResult<T>>;
|
|
35
|
-
saveAll(props: any[]): Promise<any>;
|
|
36
|
-
findByIdAndUpdate(id: any, props: any): Promise<T | null>;
|
|
37
|
-
findOneAndUpdate(filter: any, props: any, options?: any): Promise<T | null>;
|
|
38
|
-
remove(filterOptions: any): Promise<T | null>;
|
|
39
|
-
distinct(field: string, filterOptions: any): Promise<T[] | null>;
|
|
40
|
-
paginate(queryOptions: IQueryOptions): Promise<Page<T>>;
|
|
41
|
-
update(instance: T, props: any): Promise<SaveResult<T>>;
|
|
42
|
-
saveInstance(instance: T): Promise<SaveResult<T>>;
|
|
43
|
-
}
|
|
44
|
-
export default class Repository<T extends Document> implements IRepository<T>, IDashboardRepository {
|
|
45
|
-
protected model: Model<T>;
|
|
46
|
-
private static NO_NEXT_PAGE;
|
|
47
|
-
constructor(model: Model<T>);
|
|
48
|
-
findById(id: any): Promise<T | null>;
|
|
49
|
-
findOne(queryOptions?: IQueryOptions): Promise<T | null>;
|
|
50
|
-
findMany(queryOptions: IQueryOptions): Promise<T[]>;
|
|
51
|
-
paginate(queryOptions: IQueryOptions): Promise<Page<T>>;
|
|
52
|
-
private getLimit;
|
|
53
|
-
private getSkip;
|
|
54
|
-
toLimitSkip(paginateParams: PaginateParams): [number, number];
|
|
55
|
-
protected createPageInfo(filter: any, skip: number, limit: number): Promise<PageInfo>;
|
|
56
|
-
protected createPageInfoFromAggregate(aggregate: Aggregate<any[]>, skip: number, limit: number): Promise<PageInfo>;
|
|
57
|
-
count(filter: any): Promise<number>;
|
|
58
|
-
countAggregate(aggregate: Aggregate<any[]>): Promise<number>;
|
|
59
|
-
update(instance: T, props: any): Promise<SaveResult<T>>;
|
|
60
|
-
save(props: any): Promise<SaveResult<T>>;
|
|
61
|
-
saveInstance(instance: T): Promise<SaveResult<T>>;
|
|
62
|
-
saveAll(props: any[]): Promise<any>;
|
|
63
|
-
findByIdAndUpdate(id: any, props: any): Promise<T | null>;
|
|
64
|
-
findOneAndUpdate(filter: any, props: any): Promise<T | null>;
|
|
65
|
-
remove(filter: any): Promise<T | null>;
|
|
66
|
-
distinct(field: string, filter: any): Promise<T[] | null>;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
1
|
+
import { Aggregate, Document, Model } from 'mongoose';
|
|
2
|
+
import SaveResult from './SaveResult';
|
|
3
|
+
export interface PaginateParams {
|
|
4
|
+
page: number;
|
|
5
|
+
perPage: number;
|
|
6
|
+
}
|
|
7
|
+
interface IQueryOptions {
|
|
8
|
+
filter?: any;
|
|
9
|
+
sort?: any;
|
|
10
|
+
select?: any;
|
|
11
|
+
limit?: number;
|
|
12
|
+
skip?: number;
|
|
13
|
+
paginateParams?: PaginateParams;
|
|
14
|
+
populate?: any;
|
|
15
|
+
}
|
|
16
|
+
export interface PageInfo {
|
|
17
|
+
currentPage: number;
|
|
18
|
+
pagesCount: number;
|
|
19
|
+
nextPage: number;
|
|
20
|
+
recordsCount: number;
|
|
21
|
+
perPage: number;
|
|
22
|
+
}
|
|
23
|
+
export interface Page<T> {
|
|
24
|
+
records: T[];
|
|
25
|
+
pageInfo: PageInfo;
|
|
26
|
+
}
|
|
27
|
+
export interface IDashboardRepository {
|
|
28
|
+
}
|
|
29
|
+
export interface IRepository<T extends Document> {
|
|
30
|
+
findById(id: any): Promise<T | null>;
|
|
31
|
+
findOne(queryOptions?: IQueryOptions): Promise<T | null>;
|
|
32
|
+
findMany(queryOptions?: IQueryOptions): Promise<T[]>;
|
|
33
|
+
count(filterOptions: any): Promise<number>;
|
|
34
|
+
save(props: any): Promise<SaveResult<T>>;
|
|
35
|
+
saveAll(props: any[]): Promise<any>;
|
|
36
|
+
findByIdAndUpdate(id: any, props: any): Promise<T | null>;
|
|
37
|
+
findOneAndUpdate(filter: any, props: any, options?: any): Promise<T | null>;
|
|
38
|
+
remove(filterOptions: any): Promise<T | null>;
|
|
39
|
+
distinct(field: string, filterOptions: any): Promise<T[] | null>;
|
|
40
|
+
paginate(queryOptions: IQueryOptions): Promise<Page<T>>;
|
|
41
|
+
update(instance: T, props: any): Promise<SaveResult<T>>;
|
|
42
|
+
saveInstance(instance: T): Promise<SaveResult<T>>;
|
|
43
|
+
}
|
|
44
|
+
export default class Repository<T extends Document> implements IRepository<T>, IDashboardRepository {
|
|
45
|
+
protected model: Model<T>;
|
|
46
|
+
private static NO_NEXT_PAGE;
|
|
47
|
+
constructor(model: Model<T>);
|
|
48
|
+
findById(id: any): Promise<T | null>;
|
|
49
|
+
findOne(queryOptions?: IQueryOptions): Promise<T | null>;
|
|
50
|
+
findMany(queryOptions: IQueryOptions): Promise<T[]>;
|
|
51
|
+
paginate(queryOptions: IQueryOptions): Promise<Page<T>>;
|
|
52
|
+
private getLimit;
|
|
53
|
+
private getSkip;
|
|
54
|
+
toLimitSkip(paginateParams: PaginateParams): [number, number];
|
|
55
|
+
protected createPageInfo(filter: any, skip: number, limit: number): Promise<PageInfo>;
|
|
56
|
+
protected createPageInfoFromAggregate(aggregate: Aggregate<any[]>, skip: number, limit: number): Promise<PageInfo>;
|
|
57
|
+
count(filter: any): Promise<number>;
|
|
58
|
+
countAggregate(aggregate: Aggregate<any[]>): Promise<number>;
|
|
59
|
+
update(instance: T, props: any): Promise<SaveResult<T>>;
|
|
60
|
+
save(props: any): Promise<SaveResult<T>>;
|
|
61
|
+
saveInstance(instance: T): Promise<SaveResult<T>>;
|
|
62
|
+
saveAll(props: any[]): Promise<any>;
|
|
63
|
+
findByIdAndUpdate(id: any, props: any): Promise<T | null>;
|
|
64
|
+
findOneAndUpdate(filter: any, props: any): Promise<T | null>;
|
|
65
|
+
remove(filter: any): Promise<T | null>;
|
|
66
|
+
distinct(field: string, filter: any): Promise<T[] | null>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -1,212 +1,212 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
-
};
|
|
23
|
-
var Repository_1;
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const inversify_1 = require("inversify");
|
|
26
|
-
const mongoose_1 = require("mongoose");
|
|
27
|
-
const SaveResult_1 = __importDefault(require("./SaveResult"));
|
|
28
|
-
let Repository = Repository_1 = class Repository {
|
|
29
|
-
constructor(model) {
|
|
30
|
-
this.model = model;
|
|
31
|
-
}
|
|
32
|
-
findById(id) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return yield this.model.findById(id);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
findOne(queryOptions) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const filter = (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.filter) ? queryOptions.filter : {};
|
|
40
|
-
const populate = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.populate;
|
|
41
|
-
return this.model.findOne(filter).populate(populate).exec();
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
findMany(queryOptions) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const filter = queryOptions.filter ? queryOptions.filter : {};
|
|
47
|
-
const sort = queryOptions.sort;
|
|
48
|
-
const select = queryOptions.select;
|
|
49
|
-
const limit = this.getLimit(queryOptions);
|
|
50
|
-
const skip = this.getSkip(queryOptions);
|
|
51
|
-
const populate = queryOptions.populate;
|
|
52
|
-
var query = this.model.find(filter);
|
|
53
|
-
if (select) {
|
|
54
|
-
query = query.select(select);
|
|
55
|
-
}
|
|
56
|
-
if (sort) {
|
|
57
|
-
query = query.sort(sort);
|
|
58
|
-
}
|
|
59
|
-
if (skip) {
|
|
60
|
-
query = query.skip(skip);
|
|
61
|
-
}
|
|
62
|
-
if (limit) {
|
|
63
|
-
query = query.limit(limit);
|
|
64
|
-
}
|
|
65
|
-
if (populate) {
|
|
66
|
-
query = query.populate(populate);
|
|
67
|
-
}
|
|
68
|
-
return yield query;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
paginate(queryOptions) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const filter = queryOptions.filter ? queryOptions.filter : {};
|
|
74
|
-
const limit = this.getLimit(queryOptions);
|
|
75
|
-
const skip = this.getSkip(queryOptions);
|
|
76
|
-
const pageInfoPromise = yield this.createPageInfo(filter, skip, limit);
|
|
77
|
-
const recordsPromise = yield this.findMany(queryOptions);
|
|
78
|
-
const [records, pageInfo] = yield Promise.all([recordsPromise, pageInfoPromise]);
|
|
79
|
-
return {
|
|
80
|
-
records: records,
|
|
81
|
-
pageInfo
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
getLimit(queryOptions) {
|
|
86
|
-
if (queryOptions.paginateParams) {
|
|
87
|
-
return queryOptions.paginateParams.perPage;
|
|
88
|
-
}
|
|
89
|
-
return queryOptions.limit;
|
|
90
|
-
}
|
|
91
|
-
getSkip(queryOptions) {
|
|
92
|
-
if (queryOptions.paginateParams) {
|
|
93
|
-
return queryOptions.paginateParams.perPage * (queryOptions.paginateParams.page - 1);
|
|
94
|
-
}
|
|
95
|
-
return queryOptions.skip;
|
|
96
|
-
}
|
|
97
|
-
toLimitSkip(paginateParams) {
|
|
98
|
-
return [paginateParams.perPage, paginateParams.perPage * (paginateParams.page - 1)];
|
|
99
|
-
}
|
|
100
|
-
createPageInfo(filter, skip, limit) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const count = yield this.count(filter);
|
|
103
|
-
const currentPage = (skip / limit) + 1;
|
|
104
|
-
const pagesCount = Math.ceil(count / limit);
|
|
105
|
-
const nextPage = currentPage < pagesCount ? (currentPage + 1) : Repository_1.NO_NEXT_PAGE;
|
|
106
|
-
return {
|
|
107
|
-
currentPage,
|
|
108
|
-
pagesCount,
|
|
109
|
-
nextPage,
|
|
110
|
-
perPage: limit,
|
|
111
|
-
recordsCount: count
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
createPageInfoFromAggregate(aggregate, skip, limit) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
const count = yield this.countAggregate(aggregate);
|
|
118
|
-
const currentPage = (skip / limit) + 1;
|
|
119
|
-
const pagesCount = Math.ceil(count / limit);
|
|
120
|
-
const nextPage = currentPage < pagesCount ? (currentPage + 1) : Repository_1.NO_NEXT_PAGE;
|
|
121
|
-
return {
|
|
122
|
-
currentPage,
|
|
123
|
-
pagesCount,
|
|
124
|
-
nextPage,
|
|
125
|
-
perPage: limit,
|
|
126
|
-
recordsCount: count
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
count(filter) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
return this.model.countDocuments(filter);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
countAggregate(aggregate) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const queryResult = yield aggregate.count('count');
|
|
138
|
-
if (queryResult.length == 0) {
|
|
139
|
-
return 0;
|
|
140
|
-
}
|
|
141
|
-
return queryResult[0].count;
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
update(instance, props) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const allProps = Object.assign(Object.assign({}, instance.toObject()), props);
|
|
147
|
-
return this.save(allProps);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
save(props) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const instance = new this.model(props);
|
|
153
|
-
const hasId = !!props._id;
|
|
154
|
-
instance.isNew = !hasId;
|
|
155
|
-
return this.saveInstance(instance);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
saveInstance(instance) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var document;
|
|
161
|
-
var errors = [];
|
|
162
|
-
try {
|
|
163
|
-
document = yield instance.save();
|
|
164
|
-
return new SaveResult_1.default(document, errors);
|
|
165
|
-
}
|
|
166
|
-
catch (e) {
|
|
167
|
-
if (e instanceof mongoose_1.Error.ValidationError) {
|
|
168
|
-
errors = Object.keys(e.errors).map((key) => {
|
|
169
|
-
const saveError = e.errors[key];
|
|
170
|
-
return {
|
|
171
|
-
path: saveError.path,
|
|
172
|
-
type: saveError.kind,
|
|
173
|
-
message: saveError.message
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return new SaveResult_1.default(document, errors);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
saveAll(props) {
|
|
182
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
return this.model.insertMany(props);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
findByIdAndUpdate(id, props) {
|
|
187
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
return yield this.model.findByIdAndUpdate(id, props, { new: true, returnOriginal: false, returnDocument: 'after' });
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
findOneAndUpdate(filter, props) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
return yield this.model.findOneAndUpdate(filter, props, { new: true, returnOriginal: false, returnDocument: 'after', setDefaultsOnInsert: true, upsert: true });
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
remove(filter) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
return yield this.model.findOneAndRemove(filter);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
distinct(field, filter) {
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
return yield this.model.distinct(field, filter);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
Repository.NO_NEXT_PAGE = -1;
|
|
208
|
-
Repository = Repository_1 = __decorate([
|
|
209
|
-
(0, inversify_1.injectable)(),
|
|
210
|
-
__param(0, (0, inversify_1.unmanaged)())
|
|
211
|
-
], Repository);
|
|
212
|
-
exports.default = Repository;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
var Repository_1;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const inversify_1 = require("inversify");
|
|
26
|
+
const mongoose_1 = require("mongoose");
|
|
27
|
+
const SaveResult_1 = __importDefault(require("./SaveResult"));
|
|
28
|
+
let Repository = Repository_1 = class Repository {
|
|
29
|
+
constructor(model) {
|
|
30
|
+
this.model = model;
|
|
31
|
+
}
|
|
32
|
+
findById(id) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return yield this.model.findById(id);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
findOne(queryOptions) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const filter = (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.filter) ? queryOptions.filter : {};
|
|
40
|
+
const populate = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.populate;
|
|
41
|
+
return this.model.findOne(filter).populate(populate).exec();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
findMany(queryOptions) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const filter = queryOptions.filter ? queryOptions.filter : {};
|
|
47
|
+
const sort = queryOptions.sort;
|
|
48
|
+
const select = queryOptions.select;
|
|
49
|
+
const limit = this.getLimit(queryOptions);
|
|
50
|
+
const skip = this.getSkip(queryOptions);
|
|
51
|
+
const populate = queryOptions.populate;
|
|
52
|
+
var query = this.model.find(filter);
|
|
53
|
+
if (select) {
|
|
54
|
+
query = query.select(select);
|
|
55
|
+
}
|
|
56
|
+
if (sort) {
|
|
57
|
+
query = query.sort(sort);
|
|
58
|
+
}
|
|
59
|
+
if (skip) {
|
|
60
|
+
query = query.skip(skip);
|
|
61
|
+
}
|
|
62
|
+
if (limit) {
|
|
63
|
+
query = query.limit(limit);
|
|
64
|
+
}
|
|
65
|
+
if (populate) {
|
|
66
|
+
query = query.populate(populate);
|
|
67
|
+
}
|
|
68
|
+
return yield query;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
paginate(queryOptions) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const filter = queryOptions.filter ? queryOptions.filter : {};
|
|
74
|
+
const limit = this.getLimit(queryOptions);
|
|
75
|
+
const skip = this.getSkip(queryOptions);
|
|
76
|
+
const pageInfoPromise = yield this.createPageInfo(filter, skip, limit);
|
|
77
|
+
const recordsPromise = yield this.findMany(queryOptions);
|
|
78
|
+
const [records, pageInfo] = yield Promise.all([recordsPromise, pageInfoPromise]);
|
|
79
|
+
return {
|
|
80
|
+
records: records,
|
|
81
|
+
pageInfo
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
getLimit(queryOptions) {
|
|
86
|
+
if (queryOptions.paginateParams) {
|
|
87
|
+
return queryOptions.paginateParams.perPage;
|
|
88
|
+
}
|
|
89
|
+
return queryOptions.limit;
|
|
90
|
+
}
|
|
91
|
+
getSkip(queryOptions) {
|
|
92
|
+
if (queryOptions.paginateParams) {
|
|
93
|
+
return queryOptions.paginateParams.perPage * (queryOptions.paginateParams.page - 1);
|
|
94
|
+
}
|
|
95
|
+
return queryOptions.skip;
|
|
96
|
+
}
|
|
97
|
+
toLimitSkip(paginateParams) {
|
|
98
|
+
return [paginateParams.perPage, paginateParams.perPage * (paginateParams.page - 1)];
|
|
99
|
+
}
|
|
100
|
+
createPageInfo(filter, skip, limit) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const count = yield this.count(filter);
|
|
103
|
+
const currentPage = (skip / limit) + 1;
|
|
104
|
+
const pagesCount = Math.ceil(count / limit);
|
|
105
|
+
const nextPage = currentPage < pagesCount ? (currentPage + 1) : Repository_1.NO_NEXT_PAGE;
|
|
106
|
+
return {
|
|
107
|
+
currentPage,
|
|
108
|
+
pagesCount,
|
|
109
|
+
nextPage,
|
|
110
|
+
perPage: limit,
|
|
111
|
+
recordsCount: count
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
createPageInfoFromAggregate(aggregate, skip, limit) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const count = yield this.countAggregate(aggregate);
|
|
118
|
+
const currentPage = (skip / limit) + 1;
|
|
119
|
+
const pagesCount = Math.ceil(count / limit);
|
|
120
|
+
const nextPage = currentPage < pagesCount ? (currentPage + 1) : Repository_1.NO_NEXT_PAGE;
|
|
121
|
+
return {
|
|
122
|
+
currentPage,
|
|
123
|
+
pagesCount,
|
|
124
|
+
nextPage,
|
|
125
|
+
perPage: limit,
|
|
126
|
+
recordsCount: count
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
count(filter) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
return this.model.countDocuments(filter);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
countAggregate(aggregate) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const queryResult = yield aggregate.count('count');
|
|
138
|
+
if (queryResult.length == 0) {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
return queryResult[0].count;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
update(instance, props) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const allProps = Object.assign(Object.assign({}, instance.toObject()), props);
|
|
147
|
+
return this.save(allProps);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
save(props) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const instance = new this.model(props);
|
|
153
|
+
const hasId = !!props._id;
|
|
154
|
+
instance.isNew = !hasId;
|
|
155
|
+
return this.saveInstance(instance);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
saveInstance(instance) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
var document;
|
|
161
|
+
var errors = [];
|
|
162
|
+
try {
|
|
163
|
+
document = yield instance.save();
|
|
164
|
+
return new SaveResult_1.default(document, errors);
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
if (e instanceof mongoose_1.Error.ValidationError) {
|
|
168
|
+
errors = Object.keys(e.errors).map((key) => {
|
|
169
|
+
const saveError = e.errors[key];
|
|
170
|
+
return {
|
|
171
|
+
path: saveError.path,
|
|
172
|
+
type: saveError.kind,
|
|
173
|
+
message: saveError.message
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return new SaveResult_1.default(document, errors);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
saveAll(props) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
return this.model.insertMany(props);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
findByIdAndUpdate(id, props) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
return yield this.model.findByIdAndUpdate(id, props, { new: true, returnOriginal: false, returnDocument: 'after' });
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
findOneAndUpdate(filter, props) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
return yield this.model.findOneAndUpdate(filter, props, { new: true, returnOriginal: false, returnDocument: 'after', setDefaultsOnInsert: true, upsert: true });
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
remove(filter) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
return yield this.model.findOneAndRemove(filter);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
distinct(field, filter) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
return yield this.model.distinct(field, filter);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
Repository.NO_NEXT_PAGE = -1;
|
|
208
|
+
Repository = Repository_1 = __decorate([
|
|
209
|
+
(0, inversify_1.injectable)(),
|
|
210
|
+
__param(0, (0, inversify_1.unmanaged)())
|
|
211
|
+
], Repository);
|
|
212
|
+
exports.default = Repository;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IRequestLogDocument } from '../models/request-log/IRequestLog';
|
|
2
|
-
import Repository, { IRepository } from './Repository';
|
|
3
|
-
export interface IRequestLogRepository extends IRepository<IRequestLogDocument> {
|
|
4
|
-
deleteTillLastDays(days: number): Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
export default class RequestLogRepository extends Repository<IRequestLogDocument> {
|
|
7
|
-
constructor();
|
|
8
|
-
deleteTillLastDays(days: number): Promise<void>;
|
|
9
|
-
getRequestLogsStats(): Promise<any[]>;
|
|
10
|
-
}
|
|
1
|
+
import { IRequestLogDocument } from '../models/request-log/IRequestLog';
|
|
2
|
+
import Repository, { IRepository } from './Repository';
|
|
3
|
+
export interface IRequestLogRepository extends IRepository<IRequestLogDocument> {
|
|
4
|
+
deleteTillLastDays(days: number): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export default class RequestLogRepository extends Repository<IRequestLogDocument> {
|
|
7
|
+
constructor();
|
|
8
|
+
deleteTillLastDays(days: number): Promise<void>;
|
|
9
|
+
getRequestLogsStats(): Promise<any[]>;
|
|
10
|
+
}
|