@lenne.tech/nest-server 8.6.0 → 8.6.3

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.0",
3
+ "version": "8.6.3",
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",
@@ -32,9 +32,9 @@
32
32
  "test": "NODE_ENV=local jest",
33
33
  "test:cov": "NODE_ENV=local jest --coverage",
34
34
  "test:debug": "NODE_ENV=local node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
35
- "test:e2e": "NODE_ENV=local jest --config jest-e2e.json",
36
- "test:e2e-cov": "NODE_ENV=local jest --config jest-e2e.json --coverage",
37
- "test:ci": "NODE_ENV=local jest --config jest-e2e.json --ci",
35
+ "test:e2e": "NODE_ENV=local jest --config jest-e2e.json --forceExit --detectOpenHandles",
36
+ "test:e2e-cov": "NODE_ENV=local jest --config jest-e2e.json --coverage --forceExit --detectOpenHandles",
37
+ "test:ci": "NODE_ENV=local jest --config jest-e2e.json --ci --forceExit --detectOpenHandles",
38
38
  "test:watch": "NODE_ENV=local jest --watch",
39
39
  "prepack": "npm run prestart:prod",
40
40
  "prepare": "husky install",
@@ -134,7 +134,7 @@ export const checkRestricted = (
134
134
  return (
135
135
  typeof item === 'object' &&
136
136
  // Check if object is valid
137
- item.memberOf.length &&
137
+ item.memberOf?.length &&
138
138
  // Check if processType is specified and is valid for current process
139
139
  (config.processType && item.processType ? config.processType === item.processType : true)
140
140
  );
@@ -34,14 +34,9 @@ export abstract class CoreModel {
34
34
  mapId?: boolean;
35
35
  } = {}
36
36
  ): T {
37
- const config = {
38
- init: true,
39
- ...options,
40
- };
41
-
42
37
  const item = options.item || new this();
43
38
  delete options.item;
44
- return item.map(data, config);
39
+ return item.map(data, options);
45
40
  }
46
41
 
47
42
  /**
@@ -64,14 +59,9 @@ export abstract class CoreModel {
64
59
  mapId?: boolean;
65
60
  } = {}
66
61
  ): T {
67
- const config = {
68
- init: true,
69
- ...options,
70
- };
71
-
72
62
  const item = options.item || new this();
73
63
  delete options.item;
74
- return item.mapDeep(data, config);
64
+ return item.mapDeep(data, options);
75
65
  }
76
66
 
77
67
  /**
@@ -88,7 +88,7 @@ export abstract class ModuleService<T extends CoreModel = any> {
88
88
  if (!opts.targetModel && config.inputType) {
89
89
  opts.targetModel = config.inputType;
90
90
  }
91
- await this.prepareInput(config.input, opts);
91
+ config.input = await this.prepareInput(config.input, opts);
92
92
  }
93
93
 
94
94
  // Get DB object
@@ -1,6 +1,7 @@
1
- import { IsEmail, IsOptional } from 'class-validator';
2
1
  import { Field, InputType } from '@nestjs/graphql';
2
+ import { IsEmail, IsOptional } from 'class-validator';
3
3
  import { Restricted } from '../../../common/decorators/restricted.decorator';
4
+ import { ProcessType } from '../../../common/enums/process-type.enum';
4
5
  import { RoleEnum } from '../../../common/enums/role.enum';
5
6
  import { CoreInput } from '../../../common/inputs/core-input.input';
6
7
 
@@ -38,7 +39,7 @@ export abstract class CoreUserInput extends CoreInput {
38
39
  /**
39
40
  * Roles of the user
40
41
  */
41
- @Restricted(RoleEnum.ADMIN)
42
+ @Restricted({ roles: RoleEnum.ADMIN, processType: ProcessType.INPUT })
42
43
  @Field((type) => [String], { description: 'Roles of the user', nullable: true })
43
44
  @IsOptional()
44
45
  roles?: string[] = undefined;
package/src/index.ts CHANGED
@@ -67,6 +67,8 @@ export * from './core/common/types/string-or-object-id.type';
67
67
 
68
68
  export * from './core/modules/auth/guards/auth.guard';
69
69
  export * from './core/modules/auth/guards/roles.guard';
70
+ export * from './core/modules/auth/inputs/core-auth-sign-in.input';
71
+ export * from './core/modules/auth/inputs/core-auth-sign-up.input';
70
72
  export * from './core/modules/auth/interfaces/core-auth-user.interface';
71
73
  export * from './core/modules/auth/interfaces/jwt-payload.interface';
72
74
  export * from './core/modules/auth/services/core-auth.service';
@@ -3,7 +3,6 @@ import { JwtService } from '@nestjs/jwt';
3
3
  import * as bcrypt from 'bcrypt';
4
4
  import envConfig from '../../../config.env';
5
5
  import { prepareServiceOptions } from '../../../core/common/helpers/service.helper';
6
- import { ResolveSelector } from '../../../core/common/interfaces/resolve-selector.interface';
7
6
  import { ServiceOptions } from '../../../core/common/interfaces/service-options.interface';
8
7
  import { EmailService } from '../../../core/common/services/email.service';
9
8
  import { JwtPayload } from '../../../core/modules/auth/interfaces/jwt-payload.interface';
@@ -4,7 +4,7 @@ import { CoreAuthSignInInput } from '../../../../core/modules/auth/inputs/core-a
4
4
  /**
5
5
  * SignIn input
6
6
  */
7
- @InputType({ description: 'Description for AuthSignInInput' })
7
+ @InputType({ description: 'Sign-in input' })
8
8
  export class AuthSignInInput extends CoreAuthSignInInput {
9
9
  // Extend UserInput here
10
10
  }
@@ -4,7 +4,7 @@ import { CoreAuthSignUpInput } from '../../../../core/modules/auth/inputs/core-a
4
4
  /**
5
5
  * SignUp input
6
6
  */
7
- @InputType({ description: 'Description for AuthSignUpInput' })
7
+ @InputType({ description: 'Sign-up input' })
8
8
  export class AuthSignUpInput extends CoreAuthSignUpInput {
9
9
  // ===================================================================================================================
10
10
  // Properties