@lenne.tech/nest-server 8.6.10 → 8.6.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.
Files changed (33) hide show
  1. package/dist/core/modules/auth/core-auth.model.d.ts +1 -0
  2. package/dist/core/modules/auth/core-auth.model.js +4 -0
  3. package/dist/core/modules/auth/core-auth.model.js.map +1 -1
  4. package/dist/core/modules/user/core-user.model.d.ts +1 -0
  5. package/dist/core/modules/user/core-user.model.js +4 -0
  6. package/dist/core/modules/user/core-user.model.js.map +1 -1
  7. package/dist/core.module.js +1 -1
  8. package/dist/core.module.js.map +1 -1
  9. package/dist/server/common/models/persistence.model.d.ts +3 -3
  10. package/dist/server/common/models/persistence.model.js +8 -4
  11. package/dist/server/common/models/persistence.model.js.map +1 -1
  12. package/dist/server/modules/auth/auth.model.d.ts +1 -0
  13. package/dist/server/modules/auth/auth.model.js +4 -0
  14. package/dist/server/modules/auth/auth.model.js.map +1 -1
  15. package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
  16. package/dist/server/modules/user/inputs/user.input.js.map +1 -1
  17. package/dist/server/modules/user/user.model.d.ts +3 -3
  18. package/dist/server/modules/user/user.model.js +4 -4
  19. package/dist/server/modules/user/user.model.js.map +1 -1
  20. package/dist/test/test.helper.js +1 -1
  21. package/dist/test/test.helper.js.map +1 -1
  22. package/dist/tsconfig.build.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/src/core/modules/auth/core-auth.model.ts +10 -1
  25. package/src/core/modules/user/core-user.model.ts +9 -0
  26. package/src/core.module.ts +1 -2
  27. package/src/server/common/models/persistence.model.ts +24 -11
  28. package/src/server/modules/auth/auth.model.ts +9 -0
  29. package/src/server/modules/file/file.controller.ts +1 -1
  30. package/src/server/modules/user/inputs/user-create.input.ts +0 -4
  31. package/src/server/modules/user/inputs/user.input.ts +0 -4
  32. package/src/server/modules/user/user.model.ts +8 -8
  33. package/src/test/test.helper.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.6.10",
3
+ "version": "8.6.11",
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",
@@ -17,7 +17,7 @@ export class CoreAuthModel extends CoreModel {
17
17
  token: string = undefined;
18
18
 
19
19
  // ===================================================================================================================
20
- // Properties
20
+ // Methods
21
21
  // ===================================================================================================================
22
22
 
23
23
  /**
@@ -28,4 +28,13 @@ export class CoreAuthModel extends CoreModel {
28
28
  // Nothing more to initialize yet
29
29
  return this;
30
30
  }
31
+
32
+ /**
33
+ * Map input
34
+ */
35
+ map(input) {
36
+ super.map(input);
37
+ // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
38
+ return this;
39
+ }
31
40
  }
@@ -122,4 +122,13 @@ export abstract class CoreUserModel extends CorePersistenceModel {
122
122
  this.roles = this.roles === undefined ? [] : this.roles;
123
123
  return this;
124
124
  }
125
+
126
+ /**
127
+ * Map input
128
+ */
129
+ map(input) {
130
+ super.map(input);
131
+ // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
132
+ return this;
133
+ }
125
134
  }
@@ -79,8 +79,7 @@ export class CoreModule implements NestModule {
79
79
  const { connectionParams, extra } = context;
80
80
  if (config.graphQl.enableSubscriptionAuth) {
81
81
  // get authToken from authorization header
82
- const authToken: string =
83
- 'Authorization' in connectionParams && connectionParams?.Authorization?.split(' ')[1];
82
+ const authToken: string = connectionParams?.Authorization?.split(' ')[1];
84
83
  if (authToken) {
85
84
  // verify authToken/getJwtPayLoad
86
85
  const payload = authService.decodeJwt(authToken);
@@ -15,33 +15,37 @@ import { User } from '../../modules/user/user.model';
15
15
  isAbstract: true,
16
16
  })
17
17
  export abstract class PersistenceModel extends CorePersistenceModel {
18
+ // ===================================================================================================================
19
+ // Properties
20
+ // ===================================================================================================================
21
+
18
22
  /**
19
- * User who created the object
23
+ * ID of the user who created the object
20
24
  *
21
25
  * Not set when created by system
22
26
  */
23
- @Field((type) => User, {
24
- description: 'User who created the object',
27
+ @Field(() => User, {
28
+ description: 'ID of the user who created the object',
25
29
  nullable: true,
26
30
  })
27
31
  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User' })
28
- createdBy?: Types.ObjectId | User = undefined;
32
+ createdBy?: Types.ObjectId | string = undefined;
29
33
 
30
34
  /**
31
- * User who last updated the object
35
+ * ID of the user who updated the object
32
36
  *
33
37
  * Not set when updated by system
34
38
  */
35
- @Field((type) => User, {
36
- description: 'User who last updated the object',
39
+ @Field(() => User, {
40
+ description: 'ID of the user who updated the object',
37
41
  nullable: true,
38
42
  })
39
43
  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User' })
40
- updatedBy?: Types.ObjectId | User = undefined;
44
+ updatedBy?: Types.ObjectId | string = undefined;
41
45
 
42
- // ===========================================================================
43
- // Properties
44
- // ===========================================================================
46
+ // ===================================================================================================================
47
+ // Methods
48
+ // ===================================================================================================================
45
49
 
46
50
  /**
47
51
  * Initialize instance with default values instead of undefined
@@ -51,4 +55,13 @@ export abstract class PersistenceModel extends CorePersistenceModel {
51
55
  // Nothing more to initialize yet
52
56
  return this;
53
57
  }
58
+
59
+ /**
60
+ * Map input
61
+ */
62
+ map(input) {
63
+ super.map(input);
64
+ // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
65
+ return this;
66
+ }
54
67
  }
@@ -29,4 +29,13 @@ export class Auth extends CoreAuthModel {
29
29
  // Nothing more to initialize yet
30
30
  return this;
31
31
  }
32
+
33
+ /**
34
+ * Map input
35
+ */
36
+ map(input) {
37
+ super.map(input);
38
+ // There is nothing to map yet, if something comes up you can use `mapClass` / `mapClassAsync` from ModelHelper
39
+ return this;
40
+ }
32
41
  }
@@ -21,7 +21,7 @@ import { User } from '../user/user.model';
21
21
  import { FileService } from './file.service';
22
22
 
23
23
  /**
24
- * File controller for
24
+ * File controller
25
25
  */
26
26
  @Controller('files')
27
27
  export class FileController {
@@ -3,10 +3,6 @@ import { CoreUserCreateInput } from '../../../../core/modules/user/inputs/core-u
3
3
 
4
4
  /**
5
5
  * User input to create a new user
6
- *
7
- * HINT: All properties (in this class and all classes that extend this class) must be initialized with undefined,
8
- * otherwise the property will not be recognized via Object.keys (this is necessary for mapping) or will be initialized
9
- * with a default value that may overwrite an existing value in the DB.
10
6
  */
11
7
  @InputType({ description: 'User input to create a new user' })
12
8
  export class UserCreateInput extends CoreUserCreateInput {
@@ -3,10 +3,6 @@ import { CoreUserInput } from '../../../../core/modules/user/inputs/core-user.in
3
3
 
4
4
  /**
5
5
  * User input to update a user
6
- *
7
- * HINT: All properties (in this class and all classes that extend this class) must be initialized with undefined,
8
- * otherwise the property will not be recognized via Object.keys (this is necessary for mapping) or will be initialized
9
- * with a default value that may overwrite an existing value in the DB.
10
6
  */
11
7
  @InputType({ description: 'User input' })
12
8
  export class UserInput extends CoreUserInput {
@@ -1,6 +1,6 @@
1
1
  import { Field, ObjectType } from '@nestjs/graphql';
2
2
  import { Prop, Schema as MongooseSchema, SchemaFactory } from '@nestjs/mongoose';
3
- import { Document, Schema } from 'mongoose';
3
+ import { Document, Schema, Types } from 'mongoose';
4
4
  import { mapClasses } from '../../../core/common/helpers/model.helper';
5
5
  import { CoreUserModel } from '../../../core/modules/user/core-user.model';
6
6
  import { PersistenceModel } from '../../common/models/persistence.model';
@@ -8,7 +8,7 @@ import { PersistenceModel } from '../../common/models/persistence.model';
8
8
  export type UserDocument = User & Document;
9
9
 
10
10
  /**
11
- * User schema
11
+ * User model
12
12
  */
13
13
  @ObjectType({ description: 'User' })
14
14
  @MongooseSchema({ timestamps: true })
@@ -25,28 +25,28 @@ export class User extends CoreUserModel implements PersistenceModel {
25
25
  avatar: string = undefined;
26
26
 
27
27
  /**
28
- * Editor who created the object
28
+ * ID of the user who created the object
29
29
  *
30
30
  * Not set when created by system
31
31
  */
32
- @Field((type) => User, {
32
+ @Field(() => String, {
33
33
  description: 'ID of the user who created the object',
34
34
  nullable: true,
35
35
  })
36
36
  @Prop({ type: Schema.Types.ObjectId, ref: 'User' })
37
- createdBy: User = undefined;
37
+ createdBy: Types.ObjectId | string = undefined;
38
38
 
39
39
  /**
40
- * Editor who last updated the object
40
+ * ID of the user who updated the object
41
41
  *
42
42
  * Not set when updated by system
43
43
  */
44
- @Field((type) => User, {
44
+ @Field(() => String, {
45
45
  description: 'ID of the user who last updated the object',
46
46
  nullable: true,
47
47
  })
48
48
  @Prop({ type: Schema.Types.ObjectId, ref: 'User' })
49
- updatedBy: User = undefined;
49
+ updatedBy: Types.ObjectId | string = undefined;
50
50
 
51
51
  // ===================================================================================================================
52
52
  // Methods
@@ -169,7 +169,7 @@ export class TestHelper {
169
169
  });
170
170
  })
171
171
  .end((err, res: superagent.Response) => {
172
- (res as superagent.Response & { data: string }).data = new Buffer(data, 'binary').toString();
172
+ (res as superagent.Response & { data: string }).data = Buffer.from(data, 'binary').toString();
173
173
  err ? reject(err) : resolve(res as superagent.Response & { data: string });
174
174
  });
175
175
  });