@lenne.tech/nest-server 10.0.5 → 10.0.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/dist/core/common/helpers/input.helper.d.ts +2 -1
- package/dist/core/common/helpers/input.helper.js +26 -7
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/services/model-doc.service.d.ts +1 -1
- package/dist/core/common/services/model-doc.service.js +5 -0
- package/dist/core/common/services/model-doc.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/helpers/filter.helper.ts +1 -1
- package/src/core/common/helpers/input.helper.ts +34 -11
- package/src/core/common/services/model-doc.service.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.7",
|
|
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",
|
|
@@ -163,7 +163,7 @@ export function generateFilterQuery<T = any>(
|
|
|
163
163
|
// Check if value is a string ID and automatic ObjectID filtering is activated
|
|
164
164
|
} else if (config.automaticObjectIdFiltering && checkStringIds(value)) {
|
|
165
165
|
if (field === 'id') {
|
|
166
|
-
// Replace field name id
|
|
166
|
+
// Replace field name id with _id and convert value to ObjectId
|
|
167
167
|
field = '_id';
|
|
168
168
|
value = getObjectIds(value);
|
|
169
169
|
} else {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as inspector from 'inspector';
|
|
2
|
+
import * as util from 'util';
|
|
1
3
|
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
|
|
2
4
|
import { plainToInstance } from 'class-transformer';
|
|
3
5
|
import { validate } from 'class-validator';
|
|
@@ -323,9 +325,8 @@ export function checkAndGetDate(input: any): Date {
|
|
|
323
325
|
* Clone object
|
|
324
326
|
* @param object Any object
|
|
325
327
|
* @param options Finetuning of rfdc cloning
|
|
326
|
-
* @param options.
|
|
327
|
-
*
|
|
328
|
-
* cloned object (not onto it's prototype, directly onto the object).
|
|
328
|
+
* @param options.checkResult Whether to compare object and cloned object via JSON.stringify and try alternative cloning
|
|
329
|
+
* methods if they are not equal
|
|
329
330
|
* @param options.circles Keeping track of circular references will slow down performance with an additional 25% overhead.
|
|
330
331
|
* Even if an object doesn't have any circular references, the tracking overhead is the cost.
|
|
331
332
|
* By default if an object with a circular reference is passed to rfdc, it will throw
|
|
@@ -333,26 +334,48 @@ export function checkAndGetDate(input: any): Date {
|
|
|
333
334
|
* circular references in the object. If performance is important, try removing the circular
|
|
334
335
|
* reference from the object (set to undefined) and then add it back manually after cloning
|
|
335
336
|
* instead of using this option.
|
|
337
|
+
* @param options.debug Whether to shoe console.debug messages
|
|
338
|
+
* @param options.proto Copy prototype properties as well as own properties into the new object.
|
|
339
|
+
* It's marginally faster to allow enumerable properties on the prototype to be copied into the
|
|
340
|
+
* cloned object (not onto it's prototype, directly onto the object).
|
|
336
341
|
*/
|
|
337
|
-
export function clone(object: any, options?: {
|
|
342
|
+
export function clone(object: any, options?: { checkResult?: boolean; circles?: boolean; proto?: boolean }) {
|
|
338
343
|
const config = {
|
|
339
|
-
|
|
344
|
+
checkResult: true,
|
|
340
345
|
circles: true,
|
|
346
|
+
debug: inspector.url() !== undefined,
|
|
347
|
+
proto: false,
|
|
341
348
|
...options,
|
|
342
349
|
};
|
|
350
|
+
|
|
343
351
|
try {
|
|
344
|
-
|
|
352
|
+
const cloned = rfdc(config)(object);
|
|
353
|
+
if (config.checkResult && !util.isDeepStrictEqual(object, cloned)) {
|
|
354
|
+
throw new Error('Cloned object differs from original object');
|
|
355
|
+
}
|
|
356
|
+
return cloned;
|
|
345
357
|
} catch (e) {
|
|
346
|
-
console.debug(e, config, object, 'automatic try to use rfdc with circles');
|
|
347
358
|
if (!config.circles) {
|
|
359
|
+
if (config.debug) {
|
|
360
|
+
console.debug(e, config, object, 'automatic try to use rfdc with circles');
|
|
361
|
+
}
|
|
348
362
|
try {
|
|
349
|
-
|
|
363
|
+
const clonedWithCircles = rfdc({ ...config, ...{ circles: true } })(object);
|
|
364
|
+
if (config.checkResult && !util.isDeepStrictEqual(object, clonedWithCircles)) {
|
|
365
|
+
throw new Error('Cloned object differs from original object');
|
|
366
|
+
}
|
|
367
|
+
return clonedWithCircles;
|
|
350
368
|
} catch (e) {
|
|
351
|
-
|
|
352
|
-
|
|
369
|
+
if (config.debug) {
|
|
370
|
+
console.debug(e, 'rfcd with circles did not work => automatic use of _.clone!');
|
|
371
|
+
}
|
|
372
|
+
return _.cloneDeep(object);
|
|
353
373
|
}
|
|
354
374
|
} else {
|
|
355
|
-
|
|
375
|
+
if (config.debug) {
|
|
376
|
+
console.debug(e, config, object, 'automatic try to use _.clone instead rfdc');
|
|
377
|
+
}
|
|
378
|
+
return _.cloneDeep(object);
|
|
356
379
|
}
|
|
357
380
|
}
|
|
358
381
|
}
|
|
@@ -116,7 +116,7 @@ export class ModelDocService implements OnApplicationBootstrap {
|
|
|
116
116
|
* @param yUmlText
|
|
117
117
|
* @protected
|
|
118
118
|
*/
|
|
119
|
-
protected yUmlToSvg(yUmlText:
|
|
119
|
+
protected yUmlToSvg(yUmlText: string) {
|
|
120
120
|
|
|
121
121
|
// Create diagrams
|
|
122
122
|
// see https://github.com/jaime-olivares/yuml-diagram
|
|
@@ -125,6 +125,13 @@ export class ModelDocService implements OnApplicationBootstrap {
|
|
|
125
125
|
const svgLightBg = yuml.processYumlDocument(yUmlText, false);
|
|
126
126
|
const svgDarkBg = yuml.processYumlDocument(yUmlText, true);
|
|
127
127
|
|
|
128
|
+
// Save yuml document
|
|
129
|
+
fs.writeFile('model-doc.yuml', yUmlText, (err) => {
|
|
130
|
+
if (err) {
|
|
131
|
+
console.error(err);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
128
135
|
// Save diagrams
|
|
129
136
|
fs.writeFile('model-doc-light.svg', svgLightBg, (err) => {
|
|
130
137
|
if (err) {
|