@lenne.tech/nest-server 8.6.11 → 8.6.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.6.11",
3
+ "version": "8.6.12",
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",
@@ -543,7 +543,7 @@ export function removeIds(source: any[], ids: StringOrObjectId | StringOrObjectI
543
543
  */
544
544
  export async function setPopulates<T = Query<any, any> | Document>(
545
545
  queryOrDocument: T,
546
- populateOptions: PopulateOptions[],
546
+ populateOptions: string[] | PopulateOptions[] | (string | PopulateOptions)[],
547
547
  modelSchemaPaths?: { [key: string]: SchemaType }
548
548
  ): Promise<T> {
549
549
  // Check parameters
@@ -553,8 +553,12 @@ export async function setPopulates<T = Query<any, any> | Document>(
553
553
 
554
554
  // Filter populate options via model schema paths
555
555
  if (modelSchemaPaths) {
556
- populateOptions = populateOptions.filter((options) => {
557
- return Object.keys(modelSchemaPaths).includes(options.path);
556
+ populateOptions = populateOptions.filter((option: string | PopulateOptions) => {
557
+ let key: string = option as string;
558
+ if ((option as PopulateOptions)?.path) {
559
+ key = (option as PopulateOptions)?.path;
560
+ }
561
+ return Object.keys(modelSchemaPaths).includes(key);
558
562
  });
559
563
  }
560
564
 
@@ -35,7 +35,7 @@ export interface ServiceOptions {
35
35
  outputType?: new (...params: any[]) => any;
36
36
 
37
37
  // Alias for fieldSelection (if both are set fieldSelection is overwritten by populate)
38
- populate?: PopulateOptions | (PopulateOptions | string)[];
38
+ populate?: string | PopulateOptions | (PopulateOptions | string)[];
39
39
 
40
40
  // Process field selection
41
41
  // If {} or not set, then the field selection runs with defaults
@@ -5,4 +5,9 @@ import { ResolveSelector } from '../interfaces/resolve-selector.interface';
5
5
  /**
6
6
  * Field selection to set fields of (populated) result
7
7
  */
8
- export type FieldSelection = PopulateOptions | (PopulateOptions | string)[] | SelectionNode[] | ResolveSelector;
8
+ export type FieldSelection =
9
+ | string
10
+ | PopulateOptions
11
+ | (PopulateOptions | string)[]
12
+ | SelectionNode[]
13
+ | ResolveSelector;
@@ -34,7 +34,8 @@ export class CoreAuthModel extends CoreModel {
34
34
  */
35
35
  map(input) {
36
36
  super.map(input);
37
- // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
37
+ // There is nothing to map yet. Non-primitive variables should always be mapped.
38
+ // If something comes up, you can use `mapClasses` / `mapClassesAsync` from ModelHelper.
38
39
  return this;
39
40
  }
40
41
  }
@@ -128,7 +128,8 @@ export abstract class CoreUserModel extends CorePersistenceModel {
128
128
  */
129
129
  map(input) {
130
130
  super.map(input);
131
- // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
131
+ // There is nothing to map yet. Non-primitive variables should always be mapped.
132
+ // If something comes up, you can use `mapClasses` / `mapClassesAsync` from ModelHelper.
132
133
  return this;
133
134
  }
134
135
  }
@@ -61,7 +61,8 @@ export abstract class PersistenceModel extends CorePersistenceModel {
61
61
  */
62
62
  map(input) {
63
63
  super.map(input);
64
- // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
64
+ // There is nothing to map yet. Non-primitive variables should always be mapped.
65
+ // If something comes up, you can use `mapClasses` / `mapClassesAsync` from ModelHelper.
65
66
  return this;
66
67
  }
67
68
  }
@@ -1,4 +1,5 @@
1
1
  import { Field, ObjectType } from '@nestjs/graphql';
2
+ import { mapClasses } from '../../../core/common/helpers/model.helper';
2
3
  import { CoreAuthModel } from '../../../core/modules/auth/core-auth.model';
3
4
  import { User } from '../user/user.model';
4
5
 
@@ -35,7 +36,6 @@ export class Auth extends CoreAuthModel {
35
36
  */
36
37
  map(input) {
37
38
  super.map(input);
38
- // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
39
- return this;
39
+ return mapClasses(input, { user: User }, this);
40
40
  }
41
41
  }