@lenne.tech/nest-server 10.8.9 → 10.8.11
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/core/common/args/filter.args.js +2 -2
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.js +5 -5
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/helpers/config.helper.d.ts +1 -1
- package/dist/core/common/helpers/config.helper.js +8 -8
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.d.ts +11 -11
- package/dist/core/common/helpers/db.helper.js +100 -100
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/file.helper.d.ts +1 -1
- package/dist/core/common/helpers/file.helper.js +10 -10
- package/dist/core/common/helpers/file.helper.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.d.ts +12 -12
- package/dist/core/common/helpers/filter.helper.js +19 -19
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.d.ts +8 -8
- package/dist/core/common/helpers/graphql.helper.js +75 -75
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.d.ts +7 -7
- package/dist/core/common/helpers/input.helper.js +60 -60
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/model.helper.d.ts +8 -8
- package/dist/core/common/helpers/model.helper.js +38 -38
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.d.ts +2 -2
- package/dist/core/common/helpers/table.helper.d.ts +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +6 -6
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js +6 -6
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +10 -10
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +4 -4
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +8 -8
- package/dist/core/common/models/core-persistence.model.js +8 -8
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/common/plugins/mongoose-id.plugin.d.ts +1 -1
- package/dist/core/common/plugins/mongoose-id.plugin.js +2 -2
- package/dist/core/common/plugins/mongoose-id.plugin.js.map +1 -1
- package/dist/core/common/scalars/any.scalar.js +8 -8
- package/dist/core/common/scalars/any.scalar.js.map +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
- package/dist/core/common/scalars/date.scalar.js +1 -1
- package/dist/core/common/scalars/date.scalar.js.map +1 -1
- package/dist/core/common/scalars/json.scalar.js +8 -8
- package/dist/core/common/scalars/json.scalar.js.map +1 -1
- package/dist/core/common/services/config.service.d.ts +26 -26
- package/dist/core/common/services/crud.service.d.ts +32 -32
- package/dist/core/common/services/mailjet.service.js +1 -1
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/core/common/services/module.service.d.ts +1 -1
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/types/falsy.type.d.ts +1 -1
- package/dist/core/common/types/id.type.d.ts +4 -4
- package/dist/core/common/types/require-only-one.type.d.ts +2 -2
- package/dist/core/common/types/required-at-least-one.type.d.ts +2 -2
- package/dist/core/common/types/string-or-object-id.type.d.ts +1 -1
- package/dist/core/modules/auth/core-auth.controller.js +6 -6
- package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js +2 -2
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.module.d.ts +4 -4
- package/dist/core/modules/auth/core-auth.module.js +2 -2
- package/dist/core/modules/auth/core-auth.module.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +6 -6
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.d.ts +2 -2
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js +2 -2
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js +2 -2
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth.service.d.ts +2 -2
- package/dist/core/modules/file/core-file-info.model.js +8 -8
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.js +2 -2
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.resolver.js +6 -6
- package/dist/core/modules/file/core-file.resolver.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +6 -6
- package/dist/core/modules/health-check/core-health-check-result.model.js +9 -9
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.controller.js +2 -2
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.resolver.js +2 -2
- package/dist/core/modules/health-check/core-health-check.resolver.js.map +1 -1
- package/dist/core/modules/user/core-user.model.js +11 -11
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.d.ts +2 -2
- package/dist/core/modules/user/inputs/core-user-create.input.js +3 -3
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +10 -10
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/server/common/models/persistence.model.d.ts +2 -2
- package/dist/server/common/models/persistence.model.js +6 -6
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/modules/auth/auth.controller.js +1 -1
- package/dist/server/modules/auth/auth.controller.js.map +1 -1
- package/dist/server/modules/auth/auth.model.js +3 -3
- package/dist/server/modules/auth/auth.model.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.js +3 -3
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js +2 -2
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js +4 -4
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
- package/dist/server/modules/file/file-info.model.js +2 -2
- package/dist/server/modules/file/file-info.model.js.map +1 -1
- package/dist/server/modules/file/file.controller.js +5 -5
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/file/file.resolver.js +5 -5
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +2 -2
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/inputs/user-create.input.js +2 -2
- package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
- package/dist/server/modules/user/inputs/user.input.js +2 -2
- package/dist/server/modules/user/inputs/user.input.js.map +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js +4 -4
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/server/modules/user/user.model.js +8 -8
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/modules/user/user.resolver.d.ts +1 -1
- package/dist/server/modules/user/user.resolver.js +11 -11
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.d.ts +1 -1
- package/dist/server/server.controller.js +2 -2
- package/dist/server/server.controller.js.map +1 -1
- package/dist/test/test.helper.d.ts +14 -14
- package/dist/test/test.helper.js +13 -3
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/src/core/common/args/filter.args.ts +2 -2
- package/src/core/common/args/pagination.args.ts +5 -5
- package/src/core/common/decorators/graphql-service-options.decorator.ts +1 -1
- package/src/core/common/decorators/graphql-user.decorator.ts +1 -1
- package/src/core/common/decorators/rest-user.decorator.ts +1 -1
- package/src/core/common/helpers/config.helper.ts +22 -21
- package/src/core/common/helpers/db.helper.ts +164 -164
- package/src/core/common/helpers/file.helper.ts +18 -18
- package/src/core/common/helpers/filter.helper.ts +35 -35
- package/src/core/common/helpers/graphql.helper.ts +100 -100
- package/src/core/common/helpers/input.helper.ts +89 -89
- package/src/core/common/helpers/model.helper.ts +70 -70
- package/src/core/common/helpers/service.helper.ts +3 -3
- package/src/core/common/helpers/table.helper.ts +1 -1
- package/src/core/common/inputs/combined-filter.input.ts +5 -5
- package/src/core/common/inputs/filter.input.ts +5 -5
- package/src/core/common/inputs/single-filter.input.ts +9 -9
- package/src/core/common/inputs/sort.input.ts +3 -3
- package/src/core/common/interfaces/server-options.interface.ts +9 -9
- package/src/core/common/models/core-persistence.model.ts +8 -8
- package/src/core/common/plugins/mongoose-id.plugin.js +2 -2
- package/src/core/common/scalars/any.scalar.ts +8 -8
- package/src/core/common/scalars/date-timestamp.scalar.ts +1 -1
- package/src/core/common/scalars/date.scalar.ts +1 -1
- package/src/core/common/scalars/json.scalar.ts +8 -8
- package/src/core/common/services/config.service.ts +7 -7
- package/src/core/common/services/crud.service.ts +19 -19
- package/src/core/common/services/mailjet.service.ts +1 -1
- package/src/core/common/services/module.service.ts +4 -4
- package/src/core/common/types/falsy.type.ts +1 -1
- package/src/core/common/types/id.type.ts +1 -1
- package/src/core/common/types/require-only-one.type.ts +3 -3
- package/src/core/common/types/required-at-least-one.type.ts +3 -3
- package/src/core/common/types/string-or-object-id.type.ts +1 -1
- package/src/core/modules/auth/core-auth.controller.ts +6 -6
- package/src/core/modules/auth/core-auth.model.ts +1 -1
- package/src/core/modules/auth/core-auth.module.ts +4 -4
- package/src/core/modules/auth/core-auth.resolver.ts +6 -6
- package/src/core/modules/auth/guards/auth.guard.ts +3 -3
- package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +1 -1
- package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +1 -1
- package/src/core/modules/auth/services/core-auth.service.ts +1 -1
- package/src/core/modules/auth/tokens.decorator.ts +2 -2
- package/src/core/modules/file/core-file-info.model.ts +7 -7
- package/src/core/modules/file/core-file.controller.ts +2 -2
- package/src/core/modules/file/core-file.resolver.ts +6 -6
- package/src/core/modules/file/core-file.service.ts +6 -6
- package/src/core/modules/health-check/core-health-check-result.model.ts +8 -8
- package/src/core/modules/health-check/core-health-check.controller.ts +2 -2
- package/src/core/modules/health-check/core-health-check.resolver.ts +2 -2
- package/src/core/modules/user/core-user.model.ts +11 -11
- package/src/core/modules/user/core-user.service.ts +2 -2
- package/src/core/modules/user/inputs/core-user-create.input.ts +2 -2
- package/src/core/modules/user/inputs/core-user.input.ts +9 -9
- package/src/index.ts +9 -9
- package/src/server/common/models/persistence.model.ts +8 -8
- package/src/server/modules/auth/auth.controller.ts +1 -1
- package/src/server/modules/auth/auth.model.ts +2 -2
- package/src/server/modules/auth/auth.resolver.ts +3 -3
- package/src/server/modules/auth/inputs/auth-sign-in.input.ts +1 -1
- package/src/server/modules/auth/inputs/auth-sign-up.input.ts +3 -3
- package/src/server/modules/file/file-info.model.ts +2 -2
- package/src/server/modules/file/file.controller.ts +5 -5
- package/src/server/modules/file/file.module.ts +1 -1
- package/src/server/modules/file/file.resolver.ts +5 -5
- package/src/server/modules/user/avatar.controller.ts +2 -2
- package/src/server/modules/user/inputs/user-create.input.ts +1 -1
- package/src/server/modules/user/inputs/user.input.ts +1 -1
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +3 -3
- package/src/server/modules/user/user.model.ts +8 -8
- package/src/server/modules/user/user.resolver.ts +11 -11
- package/src/server/modules/user/user.service.ts +1 -1
- package/src/server/server.controller.ts +2 -2
- package/src/test/test.helper.ts +31 -17
|
@@ -50,52 +50,6 @@ export class ModelHelper {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* Remove all properties from source which are not in target
|
|
55
|
-
*/
|
|
56
|
-
export function prepareMap<T = Record<string, any>>(
|
|
57
|
-
source: Partial<T> | Record<string, any>,
|
|
58
|
-
target: T,
|
|
59
|
-
options: {
|
|
60
|
-
circles?: boolean;
|
|
61
|
-
cloneDeep?: boolean;
|
|
62
|
-
funcAllowed?: boolean;
|
|
63
|
-
mapId?: boolean;
|
|
64
|
-
proto?: boolean;
|
|
65
|
-
} = {},
|
|
66
|
-
): Partial<T> | Record<string, any> {
|
|
67
|
-
// Set config
|
|
68
|
-
const config = {
|
|
69
|
-
circles: true,
|
|
70
|
-
cloneDeep: true,
|
|
71
|
-
funcAllowed: false,
|
|
72
|
-
mapId: false,
|
|
73
|
-
proto: false,
|
|
74
|
-
...options,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Initializations
|
|
78
|
-
const result = {};
|
|
79
|
-
|
|
80
|
-
// Update properties
|
|
81
|
-
for (const key of Object.keys(target)) {
|
|
82
|
-
if (
|
|
83
|
-
(!['_id', 'id'].includes(key) || config.mapId)
|
|
84
|
-
&& source[key] !== undefined
|
|
85
|
-
&& (config.funcAllowed || typeof (source[key] !== 'function'))
|
|
86
|
-
) {
|
|
87
|
-
result[key]
|
|
88
|
-
= source[key] !== 'function' && config.cloneDeep
|
|
89
|
-
? clone(source[key], { circles: config.circles, proto: config.proto })
|
|
90
|
-
: source[key];
|
|
91
|
-
} else if (key === 'id' && !config.mapId) {
|
|
92
|
-
result['id'] = source[key];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
53
|
/**
|
|
100
54
|
* Simple map function
|
|
101
55
|
*/
|
|
@@ -135,30 +89,6 @@ export function map<T = Record<string, any>>(
|
|
|
135
89
|
return target;
|
|
136
90
|
}
|
|
137
91
|
|
|
138
|
-
/**
|
|
139
|
-
* Create Object or Objects of specified type with specified data
|
|
140
|
-
*/
|
|
141
|
-
export function maps<T = Record<string, any>>(
|
|
142
|
-
data: Partial<T> | Partial<T>[] | Record<string, any> | Record<string, any>[],
|
|
143
|
-
targetClass: new (...args: any[]) => T,
|
|
144
|
-
cloneDeep = true,
|
|
145
|
-
): T[] {
|
|
146
|
-
// Check data
|
|
147
|
-
if (!data || typeof data !== 'object') {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Check array
|
|
152
|
-
if (!Array.isArray(data)) {
|
|
153
|
-
data = [data];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Map
|
|
157
|
-
return (data as any[]).map((item) => {
|
|
158
|
-
return (targetClass as any).map(item, { cloneDeep });
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
92
|
/**
|
|
163
93
|
* It takes an object, a mapping of properties to classes, and returns a new object with the properties mapped to instances
|
|
164
94
|
* of the classes
|
|
@@ -366,3 +296,73 @@ export function mapInputClassesAsync<T = Record<string, any>>(
|
|
|
366
296
|
};
|
|
367
297
|
return mapClassesAsync(input, mapping, target, config);
|
|
368
298
|
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Create Object or Objects of specified type with specified data
|
|
302
|
+
*/
|
|
303
|
+
export function maps<T = Record<string, any>>(
|
|
304
|
+
data: Partial<T> | Partial<T>[] | Record<string, any> | Record<string, any>[],
|
|
305
|
+
targetClass: new (...args: any[]) => T,
|
|
306
|
+
cloneDeep = true,
|
|
307
|
+
): T[] {
|
|
308
|
+
// Check data
|
|
309
|
+
if (!data || typeof data !== 'object') {
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Check array
|
|
314
|
+
if (!Array.isArray(data)) {
|
|
315
|
+
data = [data];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Map
|
|
319
|
+
return (data as any[]).map((item) => {
|
|
320
|
+
return (targetClass as any).map(item, { cloneDeep });
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Remove all properties from source which are not in target
|
|
326
|
+
*/
|
|
327
|
+
export function prepareMap<T = Record<string, any>>(
|
|
328
|
+
source: Partial<T> | Record<string, any>,
|
|
329
|
+
target: T,
|
|
330
|
+
options: {
|
|
331
|
+
circles?: boolean;
|
|
332
|
+
cloneDeep?: boolean;
|
|
333
|
+
funcAllowed?: boolean;
|
|
334
|
+
mapId?: boolean;
|
|
335
|
+
proto?: boolean;
|
|
336
|
+
} = {},
|
|
337
|
+
): Partial<T> | Record<string, any> {
|
|
338
|
+
// Set config
|
|
339
|
+
const config = {
|
|
340
|
+
circles: true,
|
|
341
|
+
cloneDeep: true,
|
|
342
|
+
funcAllowed: false,
|
|
343
|
+
mapId: false,
|
|
344
|
+
proto: false,
|
|
345
|
+
...options,
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// Initializations
|
|
349
|
+
const result = {};
|
|
350
|
+
|
|
351
|
+
// Update properties
|
|
352
|
+
for (const key of Object.keys(target)) {
|
|
353
|
+
if (
|
|
354
|
+
(!['_id', 'id'].includes(key) || config.mapId)
|
|
355
|
+
&& source[key] !== undefined
|
|
356
|
+
&& (config.funcAllowed || typeof (source[key] !== 'function'))
|
|
357
|
+
) {
|
|
358
|
+
result[key]
|
|
359
|
+
= source[key] !== 'function' && config.cloneDeep
|
|
360
|
+
? clone(source[key], { circles: config.circles, proto: config.proto })
|
|
361
|
+
: source[key];
|
|
362
|
+
} else if (key === 'id' && !config.mapId) {
|
|
363
|
+
result['id'] = source[key];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
@@ -54,7 +54,7 @@ export default class ServiceHelper {
|
|
|
54
54
|
removeUndefined?: boolean;
|
|
55
55
|
targetModel?: new (...args: any[]) => T;
|
|
56
56
|
} = {},
|
|
57
|
-
): Promise<T | T[]
|
|
57
|
+
): Promise<any | T | T[]> {
|
|
58
58
|
return prepareOutput(output, options);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -100,7 +100,7 @@ export async function prepareInput<T = any>(
|
|
|
100
100
|
|
|
101
101
|
// Process array
|
|
102
102
|
if (Array.isArray(input)) {
|
|
103
|
-
const processedArray = config.getNewArray ? ([] as
|
|
103
|
+
const processedArray = config.getNewArray ? ([] as any[] & T) : input;
|
|
104
104
|
for (let i = 0; i <= input.length - 1; i++) {
|
|
105
105
|
processedArray[i] = await prepareInput(input[i], currentUser, options);
|
|
106
106
|
if (processedArray[i] === undefined && config.removeUndefined) {
|
|
@@ -193,7 +193,7 @@ export async function prepareOutput<T = { [key: string]: any; map: (...args: any
|
|
|
193
193
|
removeUndefined?: boolean;
|
|
194
194
|
targetModel?: new (...args: any[]) => T;
|
|
195
195
|
} = {},
|
|
196
|
-
): Promise<T | T[]
|
|
196
|
+
): Promise<any | T | T[]> {
|
|
197
197
|
// Configuration
|
|
198
198
|
const config = {
|
|
199
199
|
circles: false,
|
|
@@ -7,27 +7,27 @@ import { maps } from '../helpers/model.helper';
|
|
|
7
7
|
import { CoreInput } from './core-input.input';
|
|
8
8
|
import { FilterInput } from './filter.input';
|
|
9
9
|
|
|
10
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
11
10
|
@InputType({
|
|
12
11
|
description: 'Combination of multiple filters via logical operator',
|
|
13
12
|
})
|
|
13
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
14
14
|
export class CombinedFilterInput extends CoreInput {
|
|
15
15
|
/**
|
|
16
16
|
* Logical Operator to combine filters
|
|
17
17
|
*/
|
|
18
|
-
@
|
|
19
|
-
@Field(type => LogicalOperatorEnum, {
|
|
18
|
+
@Field(() => LogicalOperatorEnum, {
|
|
20
19
|
description: 'Logical Operator to combine filters',
|
|
21
20
|
})
|
|
21
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
22
22
|
logicalOperator: LogicalOperatorEnum = undefined;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Filters to combine via logical operator
|
|
26
26
|
*/
|
|
27
|
-
@
|
|
28
|
-
@Field(type => [FilterInput], {
|
|
27
|
+
@Field(() => [FilterInput], {
|
|
29
28
|
description: 'Filters to combine via logical operator',
|
|
30
29
|
})
|
|
30
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
31
31
|
filters: FilterInput[] = undefined;
|
|
32
32
|
|
|
33
33
|
// ===================================================================================================================
|
|
@@ -9,29 +9,29 @@ import { SingleFilterInput } from './single-filter.input';
|
|
|
9
9
|
/**
|
|
10
10
|
* Input for filtering. The `singleFilter` will be ignored if the `combinedFilter` is set.
|
|
11
11
|
*/
|
|
12
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
13
12
|
@InputType({
|
|
14
13
|
description: 'Input for filtering. The `singleFilter` will be ignored if the `combinedFilter` is set.',
|
|
15
14
|
})
|
|
15
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
16
16
|
export class FilterInput extends CoreInput {
|
|
17
17
|
/**
|
|
18
18
|
* Combination of multiple filters via logical operator
|
|
19
19
|
*/
|
|
20
|
-
@
|
|
21
|
-
@Field(type => CombinedFilterInput, {
|
|
20
|
+
@Field(() => CombinedFilterInput, {
|
|
22
21
|
description: 'Combination of multiple filters via logical operator',
|
|
23
22
|
nullable: true,
|
|
24
23
|
})
|
|
24
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
25
25
|
combinedFilter?: CombinedFilterInput = undefined;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Filter for a single property
|
|
29
29
|
*/
|
|
30
|
-
@
|
|
31
|
-
@Field(type => SingleFilterInput, {
|
|
30
|
+
@Field(() => SingleFilterInput, {
|
|
32
31
|
description: 'Filter for a single property',
|
|
33
32
|
nullable: true,
|
|
34
33
|
})
|
|
34
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
35
35
|
singleFilter?: SingleFilterInput = undefined;
|
|
36
36
|
|
|
37
37
|
// ===================================================================================================================
|
|
@@ -9,69 +9,69 @@ import { CoreInput } from './core-input.input';
|
|
|
9
9
|
/**
|
|
10
10
|
* Input for a configuration of a filter
|
|
11
11
|
*/
|
|
12
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
13
12
|
@InputType({ description: 'Input for a configuration of a filter' })
|
|
13
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
14
14
|
export class SingleFilterInput extends CoreInput {
|
|
15
15
|
/**
|
|
16
16
|
* Convert value to ObjectId
|
|
17
17
|
*/
|
|
18
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
19
18
|
@Field({
|
|
20
19
|
description: 'Convert value to ObjectId',
|
|
21
20
|
nullable: true,
|
|
22
21
|
})
|
|
22
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
23
23
|
convertToObjectId?: boolean = undefined;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Name of the property to be used for the filter
|
|
27
27
|
*/
|
|
28
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
29
28
|
@Field({ description: 'Name of the property to be used for the filter' })
|
|
29
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
30
30
|
field: string = undefined;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Process value as reference
|
|
34
34
|
*/
|
|
35
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
36
35
|
@Field({
|
|
37
36
|
description: 'Process value as reference',
|
|
38
37
|
nullable: true,
|
|
39
38
|
})
|
|
39
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
40
40
|
isReference?: boolean = undefined;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* [Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)
|
|
44
44
|
*/
|
|
45
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
46
45
|
@Field({
|
|
47
46
|
description: '[Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)',
|
|
48
47
|
nullable: true,
|
|
49
48
|
})
|
|
49
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
50
50
|
not?: boolean = undefined;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* [Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)
|
|
54
54
|
*/
|
|
55
|
-
@
|
|
56
|
-
@Field(type => ComparisonOperatorEnum, {
|
|
55
|
+
@Field(() => ComparisonOperatorEnum, {
|
|
57
56
|
description: '[Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)',
|
|
58
57
|
})
|
|
58
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
59
59
|
operator: ComparisonOperatorEnum = undefined;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* [Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for
|
|
63
63
|
* [REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator
|
|
64
64
|
*/
|
|
65
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
66
65
|
@Field({
|
|
67
66
|
description:
|
|
68
67
|
'[Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for '
|
|
69
68
|
+ '[REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator',
|
|
70
69
|
nullable: true,
|
|
71
70
|
})
|
|
71
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
72
72
|
options?: string = undefined;
|
|
73
73
|
|
|
74
|
+
@Field(() => JSON, { description: 'Value of the property' })
|
|
74
75
|
@Restricted(RoleEnum.S_EVERYONE)
|
|
75
|
-
@Field(type => JSON, { description: 'Value of the property' })
|
|
76
76
|
value: any = undefined;
|
|
77
77
|
}
|
|
@@ -8,20 +8,20 @@ import { CoreInput } from './core-input.input';
|
|
|
8
8
|
/**
|
|
9
9
|
* Sorting the returned elements
|
|
10
10
|
*/
|
|
11
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
12
11
|
@InputType({ description: 'Sorting the returned elements' })
|
|
12
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
13
13
|
export class SortInput extends CoreInput {
|
|
14
14
|
/**
|
|
15
15
|
* Field that is to be used for sorting
|
|
16
16
|
*/
|
|
17
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
18
17
|
@Field({ description: 'Field that is to be used for sorting' })
|
|
18
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
19
19
|
field: string = undefined;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* SortInput order of the field
|
|
23
23
|
*/
|
|
24
|
+
@Field(() => SortOrderEnum, { description: 'SortInput order of the field' })
|
|
24
25
|
@Restricted(RoleEnum.S_EVERYONE)
|
|
25
|
-
@Field(type => SortOrderEnum, { description: 'SortInput order of the field' })
|
|
26
26
|
order: SortOrderEnum = undefined;
|
|
27
27
|
}
|
|
@@ -324,20 +324,21 @@ export interface IServerOptions {
|
|
|
324
324
|
* Hint: The secrets of the different environments should be different, otherwise a JWT can be used in different
|
|
325
325
|
* environments, which can lead to security vulnerabilities.
|
|
326
326
|
*/
|
|
327
|
-
jwt?:
|
|
327
|
+
jwt?: IJwt & JwtModuleOptions &
|
|
328
|
+
{
|
|
328
329
|
/**
|
|
329
330
|
* Configuration for refresh Token (JWT)
|
|
330
331
|
* Hint: The secret of the JWT and the Refresh Token should be different, otherwise a new RefreshToken can also be
|
|
331
332
|
* requested with the JWT, which can lead to a security vulnerability.
|
|
332
333
|
*/
|
|
333
|
-
refresh?: {
|
|
334
|
+
refresh?: IJwt & {
|
|
334
335
|
/**
|
|
335
336
|
* Whether renewal of the refresh token is permitted
|
|
336
337
|
* If falsy (default): during refresh only a new token, the refresh token retains its original term
|
|
337
338
|
* If true: during refresh not only a new token but also a new refresh token is created
|
|
338
339
|
*/
|
|
339
340
|
renewal?: boolean;
|
|
340
|
-
}
|
|
341
|
+
};
|
|
341
342
|
|
|
342
343
|
/**
|
|
343
344
|
* Time period in milliseconds
|
|
@@ -345,8 +346,7 @@ export interface IServerOptions {
|
|
|
345
346
|
* default: 0 (every token includes a new token ID, all parallel token refresh requests must be prevented by the client or processed accordingly)
|
|
346
347
|
*/
|
|
347
348
|
sameTokenIdPeriod?: number;
|
|
348
|
-
}
|
|
349
|
-
JwtModuleOptions;
|
|
349
|
+
};
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
352
|
* Load local configuration
|
|
@@ -412,6 +412,7 @@ export interface IServerOptions {
|
|
|
412
412
|
* See @lenne.tech/nest-server/src/core/common/interceptors/check-response.interceptor.ts
|
|
413
413
|
*/
|
|
414
414
|
checkResponseInterceptor?:
|
|
415
|
+
| boolean
|
|
415
416
|
| {
|
|
416
417
|
/**
|
|
417
418
|
* Check the object itself for restrictions
|
|
@@ -457,8 +458,7 @@ export interface IServerOptions {
|
|
|
457
458
|
* default = false (for output objects)
|
|
458
459
|
*/
|
|
459
460
|
throwError?: boolean;
|
|
460
|
-
}
|
|
461
|
-
| boolean;
|
|
461
|
+
};
|
|
462
462
|
|
|
463
463
|
/**
|
|
464
464
|
* Process securityCheck() methode of Object before response
|
|
@@ -466,6 +466,7 @@ export interface IServerOptions {
|
|
|
466
466
|
* default = true
|
|
467
467
|
*/
|
|
468
468
|
checkSecurityInterceptor?:
|
|
469
|
+
| boolean
|
|
469
470
|
| {
|
|
470
471
|
/**
|
|
471
472
|
* Whether to log if a process is slow
|
|
@@ -479,8 +480,7 @@ export interface IServerOptions {
|
|
|
479
480
|
* default = true
|
|
480
481
|
*/
|
|
481
482
|
noteCheckedObjects?: boolean;
|
|
482
|
-
}
|
|
483
|
-
| boolean;
|
|
483
|
+
};
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
486
|
* Map incoming plain objects to meta-type and validate
|
|
@@ -20,11 +20,11 @@ import { CoreModel } from './core-model.model';
|
|
|
20
20
|
* with undefined if possible. If necessary and useful, the init method can then be used deliberately:
|
|
21
21
|
* const corePersistenceModel = item ? CorePersistenceModel.map(item).init() : CorePersistenceModel.init();
|
|
22
22
|
*/
|
|
23
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
23
|
@ObjectType({
|
|
25
24
|
description: 'Persistence model which will be saved in DB',
|
|
26
25
|
isAbstract: true,
|
|
27
26
|
})
|
|
27
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
28
28
|
@Schema({ timestamps: true })
|
|
29
29
|
export abstract class CorePersistenceModel extends CoreModel {
|
|
30
30
|
// ===========================================================================
|
|
@@ -43,30 +43,30 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
43
43
|
/**
|
|
44
44
|
* ID of the persistence object as string
|
|
45
45
|
*/
|
|
46
|
-
@
|
|
47
|
-
@Field(
|
|
46
|
+
@ApiProperty({ type: String })
|
|
47
|
+
@Field(() => ID, {
|
|
48
48
|
description: 'ID of the persistence object',
|
|
49
49
|
nullable: true,
|
|
50
50
|
})
|
|
51
|
-
@
|
|
51
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
52
52
|
id: string = undefined;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Created date, is set automatically by mongoose
|
|
56
56
|
*/
|
|
57
|
-
@
|
|
57
|
+
@ApiProperty({ example: 1740037703939, format: 'int64', type: Date })
|
|
58
58
|
@Field({ description: 'Created date', nullable: true })
|
|
59
59
|
@Prop({ onCreate: () => new Date() })
|
|
60
|
-
@
|
|
60
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
61
61
|
createdAt: Date = undefined;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Updated date is set automatically by mongoose
|
|
65
65
|
*/
|
|
66
|
-
@
|
|
66
|
+
@ApiProperty({ example: 1740037703939, format: 'int64', type: String })
|
|
67
67
|
@Field({ description: 'Updated date', nullable: true })
|
|
68
68
|
@Prop({ onUpdate: () => new Date() })
|
|
69
|
-
@
|
|
69
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
70
70
|
updatedAt: Date = undefined;
|
|
71
71
|
|
|
72
72
|
// ===========================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function mongooseIdPlugin(schema
|
|
2
|
-
schema.post(['find', 'findOne', 'save', 'deleteOne'],
|
|
1
|
+
export function mongooseIdPlugin(schema) {
|
|
2
|
+
schema.post(['find', 'findOne', 'save', 'deleteOne'], (docs) => {
|
|
3
3
|
if (!Array.isArray(docs)) {
|
|
4
4
|
docs = [docs];
|
|
5
5
|
}
|
|
@@ -4,7 +4,7 @@ import { Kind, ValueNode } from 'graphql';
|
|
|
4
4
|
/**
|
|
5
5
|
* Any scalar (is equivalent to the JSON scalar)
|
|
6
6
|
*/
|
|
7
|
-
@Scalar('Any',
|
|
7
|
+
@Scalar('Any', () => Any)
|
|
8
8
|
export class Any implements CustomScalar<string, any> {
|
|
9
9
|
/**
|
|
10
10
|
* Description of the scalar
|
|
@@ -30,13 +30,17 @@ export class Any implements CustomScalar<string, any> {
|
|
|
30
30
|
*/
|
|
31
31
|
parseLiteral(ast: ValueNode, variables?: Record<string, any>) {
|
|
32
32
|
switch (ast.kind) {
|
|
33
|
-
case Kind.STRING:
|
|
34
|
-
case Kind.ENUM:
|
|
35
33
|
case Kind.BOOLEAN:
|
|
34
|
+
case Kind.ENUM:
|
|
35
|
+
case Kind.STRING:
|
|
36
36
|
return ast.value;
|
|
37
|
-
case Kind.INT:
|
|
38
37
|
case Kind.FLOAT:
|
|
38
|
+
case Kind.INT:
|
|
39
39
|
return parseFloat(ast.value);
|
|
40
|
+
case Kind.LIST:
|
|
41
|
+
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
42
|
+
case Kind.NULL:
|
|
43
|
+
return null;
|
|
40
44
|
case Kind.OBJECT: {
|
|
41
45
|
const value = Object.create(null);
|
|
42
46
|
ast.fields.forEach((field) => {
|
|
@@ -44,10 +48,6 @@ export class Any implements CustomScalar<string, any> {
|
|
|
44
48
|
});
|
|
45
49
|
return value;
|
|
46
50
|
}
|
|
47
|
-
case Kind.LIST:
|
|
48
|
-
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
49
|
-
case Kind.NULL:
|
|
50
|
-
return null;
|
|
51
51
|
case Kind.VARIABLE: {
|
|
52
52
|
const name = ast.name.value;
|
|
53
53
|
return variables ? variables[name] : undefined;
|
|
@@ -5,7 +5,7 @@ import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
|
|
|
5
5
|
/**
|
|
6
6
|
* Date-Timestamp-Scalar to convert timestamp to date and vice versa
|
|
7
7
|
*/
|
|
8
|
-
@Scalar('Date',
|
|
8
|
+
@Scalar('Date', () => Date)
|
|
9
9
|
export class DateTimestampScalar implements CustomScalar<number, Date> {
|
|
10
10
|
description = 'Date (by Timestamp) custom scalar type';
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
|
|
|
5
5
|
/**
|
|
6
6
|
* Date scalar to convert string into date
|
|
7
7
|
*/
|
|
8
|
-
@Scalar('Date',
|
|
8
|
+
@Scalar('Date', () => Date)
|
|
9
9
|
export class DateScalar implements CustomScalar<string, Date> {
|
|
10
10
|
description = 'Date custom scalar type';
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@ import { Kind, ValueNode } from 'graphql';
|
|
|
4
4
|
/**
|
|
5
5
|
* JSON scalar (is equivalent to the Any scalar)
|
|
6
6
|
*/
|
|
7
|
-
@Scalar('JSON',
|
|
7
|
+
@Scalar('JSON', () => JSON)
|
|
8
8
|
export class JSON implements CustomScalar<string, any> {
|
|
9
9
|
/**
|
|
10
10
|
* Description of the scalar
|
|
@@ -31,13 +31,17 @@ export class JSON implements CustomScalar<string, any> {
|
|
|
31
31
|
*/
|
|
32
32
|
parseLiteral(ast: ValueNode, variables?: Record<string, any>) {
|
|
33
33
|
switch (ast.kind) {
|
|
34
|
-
case Kind.STRING:
|
|
35
|
-
case Kind.ENUM:
|
|
36
34
|
case Kind.BOOLEAN:
|
|
35
|
+
case Kind.ENUM:
|
|
36
|
+
case Kind.STRING:
|
|
37
37
|
return ast.value;
|
|
38
|
-
case Kind.INT:
|
|
39
38
|
case Kind.FLOAT:
|
|
39
|
+
case Kind.INT:
|
|
40
40
|
return parseFloat(ast.value);
|
|
41
|
+
case Kind.LIST:
|
|
42
|
+
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
43
|
+
case Kind.NULL:
|
|
44
|
+
return null;
|
|
41
45
|
case Kind.OBJECT: {
|
|
42
46
|
const value = Object.create(null);
|
|
43
47
|
ast.fields.forEach((field) => {
|
|
@@ -45,10 +49,6 @@ export class JSON implements CustomScalar<string, any> {
|
|
|
45
49
|
});
|
|
46
50
|
return value;
|
|
47
51
|
}
|
|
48
|
-
case Kind.LIST:
|
|
49
|
-
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
50
|
-
case Kind.NULL:
|
|
51
|
-
return null;
|
|
52
52
|
case Kind.VARIABLE: {
|
|
53
53
|
const name = ast.name.value;
|
|
54
54
|
return variables ? variables[name] : undefined;
|
|
@@ -39,13 +39,13 @@ export class ConfigService {
|
|
|
39
39
|
/**
|
|
40
40
|
* BehaviorSubject for config
|
|
41
41
|
*/
|
|
42
|
-
protected static _configSubject$: BehaviorSubject<{ [key: string]: any }
|
|
42
|
+
protected static _configSubject$: BehaviorSubject<Partial<IServerOptions> & { [key: string]: any }>
|
|
43
43
|
= new BehaviorSubject(undefined);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* BehaviorSubject for frozen config
|
|
47
47
|
*/
|
|
48
|
-
protected static _frozenConfigSubject$: BehaviorSubject<{ [key: string]: any }
|
|
48
|
+
protected static _frozenConfigSubject$: BehaviorSubject<Partial<IServerOptions> & { [key: string]: any }>
|
|
49
49
|
= new BehaviorSubject(undefined);
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -61,7 +61,7 @@ export class ConfigService {
|
|
|
61
61
|
* Create config service or return singleton instance if exists
|
|
62
62
|
*/
|
|
63
63
|
constructor(
|
|
64
|
-
configObject?: { [key: string]: any }
|
|
64
|
+
configObject?: Partial<IServerOptions> & { [key: string]: any },
|
|
65
65
|
options?: { reInit?: boolean; warn?: boolean },
|
|
66
66
|
) {
|
|
67
67
|
const config = {
|
|
@@ -236,7 +236,7 @@ export class ConfigService {
|
|
|
236
236
|
/**
|
|
237
237
|
* Merge config and set in ConfigService
|
|
238
238
|
*/
|
|
239
|
-
mergeConfig(configData: { [key: string]: any }
|
|
239
|
+
mergeConfig(configData: Partial<IServerOptions> & { [key: string]: any }, options?: { warn?: boolean }) {
|
|
240
240
|
return ConfigService.mergeConfig(configData, options);
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -244,7 +244,7 @@ export class ConfigService {
|
|
|
244
244
|
* Merge config and set in ConfigService
|
|
245
245
|
*/
|
|
246
246
|
static mergeConfig(
|
|
247
|
-
configData: { [key: string]: any }
|
|
247
|
+
configData: Partial<IServerOptions> & { [key: string]: any },
|
|
248
248
|
options?: { init?: boolean; warn?: boolean },
|
|
249
249
|
) {
|
|
250
250
|
const config = {
|
|
@@ -318,7 +318,7 @@ export class ConfigService {
|
|
|
318
318
|
* Set config in ConfigService
|
|
319
319
|
*/
|
|
320
320
|
setConfig(
|
|
321
|
-
configData: { [key: string]: any }
|
|
321
|
+
configData: Partial<IServerOptions> & { [key: string]: any },
|
|
322
322
|
options?: { reInit?: boolean; warn?: boolean },
|
|
323
323
|
) {
|
|
324
324
|
return ConfigService.setConfig(configData, options);
|
|
@@ -328,7 +328,7 @@ export class ConfigService {
|
|
|
328
328
|
* Set config in ConfigService
|
|
329
329
|
*/
|
|
330
330
|
static setConfig(
|
|
331
|
-
configObject: { [key: string]: any }
|
|
331
|
+
configObject: Partial<IServerOptions> & { [key: string]: any },
|
|
332
332
|
options?: { init?: boolean; reInit?: boolean; warn?: boolean },
|
|
333
333
|
) {
|
|
334
334
|
const config = {
|