@lenne.tech/nest-server 9.0.7 → 9.0.9
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/dist/config.env.js +9 -9
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/args/filter.args.d.ts +1 -0
- package/dist/core/common/args/filter.args.js +8 -0
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.d.ts +0 -1
- package/dist/core/common/args/pagination.args.js +1 -15
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/helpers/service.helper.js +1 -1
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/services/crud.service.d.ts +56 -0
- package/dist/core/common/services/crud.service.js +89 -4
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +30 -30
- package/src/config.env.ts +9 -9
- package/src/core/common/args/filter.args.ts +10 -0
- package/src/core/common/args/pagination.args.ts +1 -19
- package/src/core/common/helpers/service.helper.ts +1 -1
- package/src/core/common/services/crud.service.ts +235 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.9",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
"node": ">= 16.13.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@apollo/gateway": "2.
|
|
62
|
-
"@nestjs/apollo": "10.
|
|
63
|
-
"@nestjs/common": "9.
|
|
64
|
-
"@nestjs/core": "9.
|
|
65
|
-
"@nestjs/graphql": "10.
|
|
61
|
+
"@apollo/gateway": "2.1.3",
|
|
62
|
+
"@nestjs/apollo": "10.1.3",
|
|
63
|
+
"@nestjs/common": "9.1.4",
|
|
64
|
+
"@nestjs/core": "9.1.4",
|
|
65
|
+
"@nestjs/graphql": "10.1.3",
|
|
66
66
|
"@nestjs/jwt": "9.0.0",
|
|
67
67
|
"@nestjs/mongoose": "9.2.0",
|
|
68
68
|
"@nestjs/passport": "9.0.0",
|
|
69
|
-
"@nestjs/platform-express": "9.
|
|
69
|
+
"@nestjs/platform-express": "9.1.4",
|
|
70
70
|
"@nestjs/schedule": "2.1.0",
|
|
71
|
-
"apollo-server-core": "3.10.
|
|
72
|
-
"apollo-server-express": "3.10.
|
|
73
|
-
"bcrypt": "5.0
|
|
71
|
+
"apollo-server-core": "3.10.3",
|
|
72
|
+
"apollo-server-express": "3.10.3",
|
|
73
|
+
"bcrypt": "5.1.0",
|
|
74
74
|
"class-transformer": "0.5.1",
|
|
75
75
|
"class-validator": "0.13.2",
|
|
76
76
|
"ejs": "3.1.8",
|
|
@@ -79,37 +79,37 @@
|
|
|
79
79
|
"graphql-upload": "15.0.2",
|
|
80
80
|
"js-sha256": "0.9.0",
|
|
81
81
|
"json-to-graphql-query": "2.2.4",
|
|
82
|
-
"light-my-request": "5.
|
|
82
|
+
"light-my-request": "5.6.1",
|
|
83
83
|
"lodash": "4.17.21",
|
|
84
|
-
"mongodb": "4.
|
|
85
|
-
"mongoose": "6.5
|
|
84
|
+
"mongodb": "4.10.0",
|
|
85
|
+
"mongoose": "6.6.5",
|
|
86
86
|
"mongoose-gridfs": "1.3.0",
|
|
87
87
|
"multer": "1.4.5-lts.1",
|
|
88
88
|
"node-mailjet": "5.1.1",
|
|
89
|
-
"nodemailer": "6.
|
|
90
|
-
"nodemon": "2.0.
|
|
89
|
+
"nodemailer": "6.8.0",
|
|
90
|
+
"nodemon": "2.0.20",
|
|
91
91
|
"passport": "0.6.0",
|
|
92
92
|
"passport-jwt": "4.0.0",
|
|
93
93
|
"reflect-metadata": "0.1.13",
|
|
94
94
|
"rfdc": "1.3.0",
|
|
95
95
|
"rimraf": "3.0.2",
|
|
96
|
-
"rxjs": "7.5.
|
|
96
|
+
"rxjs": "7.5.7"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@nestjs/testing": "9.
|
|
99
|
+
"@nestjs/testing": "9.1.4",
|
|
100
100
|
"@types/cron": "2.0.0",
|
|
101
101
|
"@types/ejs": "3.1.1",
|
|
102
|
-
"@types/jest": "
|
|
103
|
-
"@types/lodash": "4.14.
|
|
102
|
+
"@types/jest": "29.1.2",
|
|
103
|
+
"@types/lodash": "4.14.186",
|
|
104
104
|
"@types/multer": "1.4.7",
|
|
105
|
-
"@types/node": "18.
|
|
106
|
-
"@types/nodemailer": "6.4.
|
|
107
|
-
"@types/passport": "1.0.
|
|
105
|
+
"@types/node": "18.8.3",
|
|
106
|
+
"@types/nodemailer": "6.4.6",
|
|
107
|
+
"@types/passport": "1.0.11",
|
|
108
108
|
"@types/supertest": "2.0.12",
|
|
109
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
110
|
-
"@typescript-eslint/parser": "5.
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "5.39.0",
|
|
110
|
+
"@typescript-eslint/parser": "5.39.0",
|
|
111
111
|
"coffeescript": "2.7.0",
|
|
112
|
-
"eslint": "8.
|
|
112
|
+
"eslint": "8.25.0",
|
|
113
113
|
"eslint-config-prettier": "8.5.0",
|
|
114
114
|
"find-file-up": "2.0.1",
|
|
115
115
|
"grunt": "1.5.3",
|
|
@@ -118,16 +118,16 @@
|
|
|
118
118
|
"grunt-contrib-watch": "1.1.0",
|
|
119
119
|
"grunt-sync": "0.8.2",
|
|
120
120
|
"husky": "8.0.1",
|
|
121
|
-
"jest": "
|
|
121
|
+
"jest": "29.1.2",
|
|
122
122
|
"pm2": "5.2.0",
|
|
123
123
|
"prettier": "2.7.1",
|
|
124
124
|
"pretty-quick": "3.1.3",
|
|
125
|
-
"supertest": "6.
|
|
126
|
-
"ts-jest": "
|
|
127
|
-
"ts-morph": "
|
|
125
|
+
"supertest": "6.3.0",
|
|
126
|
+
"ts-jest": "29.0.3",
|
|
127
|
+
"ts-morph": "16.0.0",
|
|
128
128
|
"ts-node": "10.9.1",
|
|
129
129
|
"tsconfig-paths": "4.1.0",
|
|
130
|
-
"typescript": "4.8.
|
|
130
|
+
"typescript": "4.8.4"
|
|
131
131
|
},
|
|
132
132
|
"jest": {
|
|
133
133
|
"collectCoverage": true,
|
package/src/config.env.ts
CHANGED
|
@@ -23,8 +23,8 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
23
23
|
email: {
|
|
24
24
|
smtp: {
|
|
25
25
|
auth: {
|
|
26
|
-
user: '
|
|
27
|
-
pass: '
|
|
26
|
+
user: 'cade72@ethereal.email',
|
|
27
|
+
pass: 'jpvTwGYeSajEqDvRKT',
|
|
28
28
|
},
|
|
29
29
|
host: 'smtp.ethereal.email',
|
|
30
30
|
port: 587,
|
|
@@ -35,7 +35,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
35
35
|
api_key_private: 'MAILJET_API_KEY_PRIVATE',
|
|
36
36
|
},
|
|
37
37
|
defaultSender: {
|
|
38
|
-
email: '
|
|
38
|
+
email: 'cade72@ethereal.email',
|
|
39
39
|
name: 'Sandra Klein',
|
|
40
40
|
},
|
|
41
41
|
verificationLink: 'http://localhost:4200/user/verification',
|
|
@@ -75,8 +75,8 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
75
75
|
email: {
|
|
76
76
|
smtp: {
|
|
77
77
|
auth: {
|
|
78
|
-
user: '
|
|
79
|
-
pass: '
|
|
78
|
+
user: 'cade72@ethereal.email',
|
|
79
|
+
pass: 'jpvTwGYeSajEqDvRKT',
|
|
80
80
|
},
|
|
81
81
|
host: 'smtp.ethereal.email',
|
|
82
82
|
port: 587,
|
|
@@ -87,7 +87,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
87
87
|
api_key_private: 'MAILJET_API_KEY_PRIVATE',
|
|
88
88
|
},
|
|
89
89
|
defaultSender: {
|
|
90
|
-
email: '
|
|
90
|
+
email: 'cade72@ethereal.email',
|
|
91
91
|
name: 'Sandra Klein',
|
|
92
92
|
},
|
|
93
93
|
verificationLink: 'http://localhost:4200/user/verification',
|
|
@@ -127,8 +127,8 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
127
127
|
email: {
|
|
128
128
|
smtp: {
|
|
129
129
|
auth: {
|
|
130
|
-
user: '
|
|
131
|
-
pass: '
|
|
130
|
+
user: 'cade72@ethereal.email',
|
|
131
|
+
pass: 'jpvTwGYeSajEqDvRKT',
|
|
132
132
|
},
|
|
133
133
|
host: 'smtp.ethereal.email',
|
|
134
134
|
port: 587,
|
|
@@ -139,7 +139,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
139
139
|
api_key_private: 'MAILJET_API_KEY_PRIVATE',
|
|
140
140
|
},
|
|
141
141
|
defaultSender: {
|
|
142
|
-
email: '
|
|
142
|
+
email: 'cade72@ethereal.email',
|
|
143
143
|
name: 'Sandra Klein',
|
|
144
144
|
},
|
|
145
145
|
verificationLink: 'http://localhost:4200/user/verification',
|
|
@@ -15,6 +15,16 @@ export class FilterArgs extends PaginationArgs {
|
|
|
15
15
|
@IsOptional()
|
|
16
16
|
filter?: FilterInput = undefined;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Get a specific number of random samples from filter results
|
|
20
|
+
*/
|
|
21
|
+
@Field((type) => Number, {
|
|
22
|
+
description:
|
|
23
|
+
'Request only a specified number of samples from the filter results; if not specified, all results are returned.',
|
|
24
|
+
nullable: true,
|
|
25
|
+
})
|
|
26
|
+
samples?: number = undefined;
|
|
27
|
+
|
|
18
28
|
// ===================================================================================================================
|
|
19
29
|
// Methods
|
|
20
30
|
// ===================================================================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IsOptional, Max } from 'class-validator';
|
|
2
1
|
import { ArgsType, Field, Int } from '@nestjs/graphql';
|
|
2
|
+
import { IsOptional } from 'class-validator';
|
|
3
3
|
import { maps } from '../helpers/model.helper';
|
|
4
4
|
import { CoreInput } from '../inputs/core-input.input';
|
|
5
5
|
import { SortInput } from '../inputs/sort.input';
|
|
@@ -12,10 +12,8 @@ export class PaginationArgs extends CoreInput {
|
|
|
12
12
|
@Field((type) => Int, {
|
|
13
13
|
description: 'Limit specifies the maximum number of elements found that are to be returned',
|
|
14
14
|
nullable: true,
|
|
15
|
-
defaultValue: 25,
|
|
16
15
|
})
|
|
17
16
|
@IsOptional()
|
|
18
|
-
@Max(100)
|
|
19
17
|
limit?: number = undefined;
|
|
20
18
|
|
|
21
19
|
/**
|
|
@@ -24,7 +22,6 @@ export class PaginationArgs extends CoreInput {
|
|
|
24
22
|
@Field((type) => Int, {
|
|
25
23
|
description: 'Alias for skip',
|
|
26
24
|
nullable: true,
|
|
27
|
-
defaultValue: 0,
|
|
28
25
|
})
|
|
29
26
|
@IsOptional()
|
|
30
27
|
offset?: number = undefined;
|
|
@@ -35,7 +32,6 @@ export class PaginationArgs extends CoreInput {
|
|
|
35
32
|
@Field((type) => Int, {
|
|
36
33
|
description: 'Skip specifies how many found elements should be skipped on return',
|
|
37
34
|
nullable: true,
|
|
38
|
-
defaultValue: undefined,
|
|
39
35
|
})
|
|
40
36
|
@IsOptional()
|
|
41
37
|
skip?: number = undefined;
|
|
@@ -56,28 +52,14 @@ export class PaginationArgs extends CoreInput {
|
|
|
56
52
|
@Field((type) => Int, {
|
|
57
53
|
description: 'Alias for limit',
|
|
58
54
|
nullable: true,
|
|
59
|
-
defaultValue: 25,
|
|
60
55
|
})
|
|
61
56
|
@IsOptional()
|
|
62
|
-
@Max(100)
|
|
63
57
|
take?: number = undefined;
|
|
64
58
|
|
|
65
59
|
// ===================================================================================================================
|
|
66
60
|
// Methods
|
|
67
61
|
// ===================================================================================================================
|
|
68
62
|
|
|
69
|
-
/**
|
|
70
|
-
* Initialize instance with default values instead of undefined
|
|
71
|
-
*/
|
|
72
|
-
init(): this {
|
|
73
|
-
super.init();
|
|
74
|
-
this.limit = this.limit === undefined ? 25 : this.limit;
|
|
75
|
-
this.offset = this.offset === undefined ? 0 : this.offset;
|
|
76
|
-
this.skip = this.skip === undefined ? 0 : this.skip;
|
|
77
|
-
this.take = this.take === undefined ? 0 : this.take;
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
63
|
/**
|
|
82
64
|
* Mapping for Subtypes
|
|
83
65
|
*/
|
|
@@ -97,7 +97,7 @@ export async function prepareInput<T = any>(
|
|
|
97
97
|
if (Array.isArray(input)) {
|
|
98
98
|
const processedArray = config.getNewArray ? ([] as T & any[]) : input;
|
|
99
99
|
for (let i = 0; i <= input.length - 1; i++) {
|
|
100
|
-
processedArray[i] = await
|
|
100
|
+
processedArray[i] = await prepareInput(input[i], currentUser, options);
|
|
101
101
|
if (processedArray[i] === undefined && config.removeUndefined) {
|
|
102
102
|
processedArray.splice(i, 1);
|
|
103
103
|
}
|
|
@@ -24,6 +24,24 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Create item without checks or restrictions
|
|
29
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
30
|
+
*/
|
|
31
|
+
async createForce(input: any, serviceOptions: ServiceOptions = {}): Promise<T> {
|
|
32
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
33
|
+
return this.create(input, serviceOptions);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create item without checks, restrictions or preparations
|
|
38
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
39
|
+
*/
|
|
40
|
+
async createRaw(input: any, serviceOptions: ServiceOptions = {}): Promise<T> {
|
|
41
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
42
|
+
return this.createForce(input, serviceOptions);
|
|
43
|
+
}
|
|
44
|
+
|
|
27
45
|
/**
|
|
28
46
|
* Get item by ID
|
|
29
47
|
*/
|
|
@@ -35,15 +53,44 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
35
53
|
return this.process(async () => dbObject, { dbObject, serviceOptions });
|
|
36
54
|
}
|
|
37
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Get item by ID without checks or restrictions
|
|
58
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
59
|
+
*/
|
|
60
|
+
async getForce(id: string, serviceOptions: ServiceOptions = {}): Promise<T> {
|
|
61
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
62
|
+
return this.get(id, serviceOptions);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get item by ID without checks, restrictions or preparations
|
|
67
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
68
|
+
*/
|
|
69
|
+
async getRaw(id: string, serviceOptions: ServiceOptions = {}): Promise<T> {
|
|
70
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
71
|
+
return this.getForce(id, serviceOptions);
|
|
72
|
+
}
|
|
73
|
+
|
|
38
74
|
/**
|
|
39
75
|
* Get items via filter
|
|
40
76
|
*/
|
|
41
77
|
async find(
|
|
42
|
-
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
78
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
43
79
|
serviceOptions?: ServiceOptions
|
|
44
80
|
): Promise<T[]> {
|
|
81
|
+
// If filter is not instance of FilterArgs a simple form with filterQuery and queryOptions is set
|
|
82
|
+
// and should not be processed as FilterArgs
|
|
83
|
+
if (!(filter instanceof FilterArgs) && serviceOptions?.inputType === FilterArgs) {
|
|
84
|
+
serviceOptions = Object.assign({ prepareInput: null }, serviceOptions, { inputType: null });
|
|
85
|
+
}
|
|
86
|
+
|
|
45
87
|
return this.process(
|
|
46
88
|
async (data) => {
|
|
89
|
+
// Return only a certain number of random samples
|
|
90
|
+
if (filter?.samples) {
|
|
91
|
+
return (await this.findAndCount(filter, serviceOptions)).items;
|
|
92
|
+
}
|
|
93
|
+
|
|
47
94
|
// Prepare filter query
|
|
48
95
|
const filterQuery = { filterQuery: data?.input?.filterQuery, queryOptions: data?.input?.queryOptions };
|
|
49
96
|
if (data?.input instanceof FilterArgs) {
|
|
@@ -59,13 +106,43 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
59
106
|
);
|
|
60
107
|
}
|
|
61
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Get items via filter without checks or restrictions
|
|
111
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
112
|
+
*/
|
|
113
|
+
async findForce(
|
|
114
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
115
|
+
serviceOptions: ServiceOptions = {}
|
|
116
|
+
): Promise<T[]> {
|
|
117
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
118
|
+
return this.find(filter, serviceOptions);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get items via filter without checks, restrictions or preparations
|
|
123
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
124
|
+
*/
|
|
125
|
+
async findRaw(
|
|
126
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
127
|
+
serviceOptions: ServiceOptions = {}
|
|
128
|
+
): Promise<T[]> {
|
|
129
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
130
|
+
return this.findForce(filter, serviceOptions);
|
|
131
|
+
}
|
|
132
|
+
|
|
62
133
|
/**
|
|
63
134
|
* Get items and total count via filter
|
|
64
135
|
*/
|
|
65
136
|
async findAndCount(
|
|
66
|
-
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
137
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
67
138
|
serviceOptions?: ServiceOptions
|
|
68
139
|
): Promise<{ items: T[]; totalCount: number }> {
|
|
140
|
+
// If filter is not instance of FilterArgs a simple form with filterQuery and queryOptions is set
|
|
141
|
+
// and should not be processed as FilterArgs
|
|
142
|
+
if (!(filter instanceof FilterArgs) && serviceOptions?.inputType === FilterArgs) {
|
|
143
|
+
serviceOptions = Object.assign({ prepareInput: null }, serviceOptions, { inputType: null });
|
|
144
|
+
}
|
|
145
|
+
|
|
69
146
|
return this.process(
|
|
70
147
|
async (data) => {
|
|
71
148
|
// Prepare filter query
|
|
@@ -77,12 +154,14 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
77
154
|
}
|
|
78
155
|
|
|
79
156
|
// Prepare aggregation (with fixed defined sequence)
|
|
80
|
-
const aggregation: PipelineStage[] = [
|
|
81
|
-
|
|
82
|
-
|
|
157
|
+
const aggregation: PipelineStage[] = [];
|
|
158
|
+
|
|
159
|
+
// Add pipeline stage 1: match
|
|
160
|
+
if (filterQuery.filterQuery) {
|
|
161
|
+
aggregation.push({
|
|
83
162
|
$match: filterQuery.filterQuery,
|
|
84
|
-
}
|
|
85
|
-
|
|
163
|
+
});
|
|
164
|
+
}
|
|
86
165
|
|
|
87
166
|
// Prepare $facet
|
|
88
167
|
const facet = {
|
|
@@ -109,6 +188,11 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
109
188
|
}
|
|
110
189
|
}
|
|
111
190
|
|
|
191
|
+
// Get a certain number of random samples
|
|
192
|
+
if (filter?.samples) {
|
|
193
|
+
facet.items.push({ $sample: { size: filter.samples } });
|
|
194
|
+
}
|
|
195
|
+
|
|
112
196
|
// Set pipeline stage 3: facet => items (with skip & limit) and totalCount
|
|
113
197
|
aggregation.push({ $facet: facet });
|
|
114
198
|
|
|
@@ -122,6 +206,30 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
122
206
|
);
|
|
123
207
|
}
|
|
124
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Get items and total count via filter without checks or restrictions
|
|
211
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
212
|
+
*/
|
|
213
|
+
async findAndCountForce(
|
|
214
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
215
|
+
serviceOptions: ServiceOptions = {}
|
|
216
|
+
): Promise<{ items: T[]; totalCount: number }> {
|
|
217
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
218
|
+
return this.findAndCount(filter, serviceOptions);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get items and total count via filter without checks, restrictions or preparations
|
|
223
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
224
|
+
*/
|
|
225
|
+
async findAndCountRaw(
|
|
226
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
227
|
+
serviceOptions: ServiceOptions = {}
|
|
228
|
+
): Promise<{ items: T[]; totalCount: number }> {
|
|
229
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
230
|
+
return this.findAndCountForce(filter, serviceOptions);
|
|
231
|
+
}
|
|
232
|
+
|
|
125
233
|
/**
|
|
126
234
|
* Find and update
|
|
127
235
|
*/
|
|
@@ -150,6 +258,30 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
150
258
|
return await Promise.all(promises);
|
|
151
259
|
}
|
|
152
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Find and update without checks or restrictions
|
|
263
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
264
|
+
*/
|
|
265
|
+
async findAndUpdateForce(
|
|
266
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
267
|
+
serviceOptions: ServiceOptions = {}
|
|
268
|
+
): Promise<T[]> {
|
|
269
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
270
|
+
return this.findAndUpdate(filter, serviceOptions);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Find and update without checks, restrictions or preparations
|
|
275
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
276
|
+
*/
|
|
277
|
+
async findAndUpdateRaw(
|
|
278
|
+
filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
|
|
279
|
+
serviceOptions: ServiceOptions = {}
|
|
280
|
+
): Promise<T[]> {
|
|
281
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
282
|
+
return this.findAndUpdateForce(filter, serviceOptions);
|
|
283
|
+
}
|
|
284
|
+
|
|
153
285
|
/**
|
|
154
286
|
* CRUD alias for get
|
|
155
287
|
*/
|
|
@@ -177,6 +309,66 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
177
309
|
}
|
|
178
310
|
}
|
|
179
311
|
|
|
312
|
+
/**
|
|
313
|
+
* CRUD alias for getForce
|
|
314
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
315
|
+
*/
|
|
316
|
+
async readForce(id: string, serviceOptions?: ServiceOptions): Promise<T>;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* CRUD alias for findForce
|
|
320
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
321
|
+
*/
|
|
322
|
+
async readForce(
|
|
323
|
+
filter: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
324
|
+
serviceOptions?: ServiceOptions
|
|
325
|
+
): Promise<T[]>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* CRUD alias for getForce or findForce
|
|
329
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
330
|
+
*/
|
|
331
|
+
async readForce(
|
|
332
|
+
input: string | FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
333
|
+
serviceOptions?: ServiceOptions
|
|
334
|
+
): Promise<T | T[]> {
|
|
335
|
+
if (typeof input === 'string') {
|
|
336
|
+
return this.getForce(input, serviceOptions);
|
|
337
|
+
} else {
|
|
338
|
+
return this.findForce(input, serviceOptions);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* CRUD alias for getRaw
|
|
344
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
345
|
+
*/
|
|
346
|
+
async readRaw(id: string, serviceOptions?: ServiceOptions): Promise<T>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* CRUD alias for findRaw
|
|
350
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
351
|
+
*/
|
|
352
|
+
async readRaw(
|
|
353
|
+
filter: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
354
|
+
serviceOptions?: ServiceOptions
|
|
355
|
+
): Promise<T[]>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* CRUD alias for getRaw or findRaw
|
|
359
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
360
|
+
*/
|
|
361
|
+
async readRaw(
|
|
362
|
+
input: string | FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
|
|
363
|
+
serviceOptions?: ServiceOptions
|
|
364
|
+
): Promise<T | T[]> {
|
|
365
|
+
if (typeof input === 'string') {
|
|
366
|
+
return this.getRaw(input, serviceOptions);
|
|
367
|
+
} else {
|
|
368
|
+
return this.findRaw(input, serviceOptions);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
180
372
|
/**
|
|
181
373
|
* Update item via ID
|
|
182
374
|
*/
|
|
@@ -194,6 +386,24 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
194
386
|
);
|
|
195
387
|
}
|
|
196
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Update item via ID without checks or restrictions
|
|
391
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
392
|
+
*/
|
|
393
|
+
async updateForce(id: string, input: any, serviceOptions?: ServiceOptions): Promise<T> {
|
|
394
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
395
|
+
return this.update(id, input, serviceOptions);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Update item via ID without checks, restrictions or preparations
|
|
400
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
401
|
+
*/
|
|
402
|
+
async updateRaw(id: string, input: any, serviceOptions?: ServiceOptions): Promise<T> {
|
|
403
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
404
|
+
return this.updateForce(id, input, serviceOptions);
|
|
405
|
+
}
|
|
406
|
+
|
|
197
407
|
/**
|
|
198
408
|
* Delete item via ID
|
|
199
409
|
*/
|
|
@@ -210,4 +420,22 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
|
|
|
210
420
|
{ dbObject, serviceOptions }
|
|
211
421
|
);
|
|
212
422
|
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Delete item via ID without checks or restrictions
|
|
426
|
+
* Warning: Disables the handling of rights and restrictions!
|
|
427
|
+
*/
|
|
428
|
+
async deleteForce(id: string, serviceOptions?: ServiceOptions): Promise<T> {
|
|
429
|
+
serviceOptions = merge(serviceOptions, { force: true });
|
|
430
|
+
return this.delete(id, serviceOptions);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Delete item via ID without checks, restrictions or preparations
|
|
435
|
+
* Warning: Disables the handling of rights and restrictions! The raw data may contain secrets (such as passwords).
|
|
436
|
+
*/
|
|
437
|
+
async deleteRaw(id: string, serviceOptions?: ServiceOptions): Promise<T> {
|
|
438
|
+
serviceOptions = merge(serviceOptions, { prepareInput: null, prepareOutput: null });
|
|
439
|
+
return this.deleteForce(id, serviceOptions);
|
|
440
|
+
}
|
|
213
441
|
}
|