itlab-internal-services 2.9.2 → 2.10.0
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.
|
@@ -9,7 +9,7 @@ const jwt_guard_1 = require("./jwt.guard");
|
|
|
9
9
|
* Creates an ApiJwt decorator
|
|
10
10
|
* @returns A decorator that creates an API JWT
|
|
11
11
|
*/
|
|
12
|
-
const Jwt = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: jwt_constants_1.JWT_DESCRIPTION
|
|
12
|
+
const Jwt = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: jwt_constants_1.JWT_DESCRIPTION }));
|
|
13
13
|
exports.Jwt = Jwt;
|
|
14
14
|
/**
|
|
15
15
|
* Used to parse a authorized account from the request header
|
|
@@ -26,61 +26,49 @@
|
|
|
26
26
|
import { PopulateOptions } from 'mongoose';
|
|
27
27
|
import { ModelService } from '../model-service/model.service';
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @class PopulateService
|
|
29
|
+
* PopulateService handles population options for various fields.
|
|
31
30
|
*/
|
|
32
31
|
export declare class PopulateService {
|
|
33
32
|
private readonly modelService;
|
|
34
|
-
/**
|
|
35
|
-
* Constructor
|
|
36
|
-
* @param modelService - the model service
|
|
37
|
-
*/
|
|
38
33
|
constructor(modelService: ModelService);
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @returns {PopulateOptions} the populate options
|
|
35
|
+
* Returns populate options for a single account field.
|
|
36
|
+
* @param path - The field path to populate
|
|
43
37
|
*/
|
|
44
|
-
account
|
|
38
|
+
account(path: string): PopulateOptions;
|
|
45
39
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
40
|
+
* Returns populate options for multiple accounts in an array field.
|
|
41
|
+
* @param path - The field path to populate
|
|
48
42
|
*/
|
|
49
|
-
|
|
43
|
+
accounts(path: string): PopulateOptions;
|
|
50
44
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @returns {PopulateOptions} the populate options
|
|
45
|
+
* Populate options for 'author' field.
|
|
53
46
|
*/
|
|
54
|
-
|
|
47
|
+
author(): PopulateOptions;
|
|
55
48
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param path - the path to populate
|
|
58
|
-
* @returns {PopulateOptions} the populate options
|
|
49
|
+
* Populate options for 'contact' field.
|
|
59
50
|
*/
|
|
60
|
-
|
|
51
|
+
contact(): PopulateOptions;
|
|
61
52
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @returns {PopulateOptions} the populate options
|
|
53
|
+
* Populate options for '_viewedBy' field (array of accounts).
|
|
64
54
|
*/
|
|
65
|
-
viewedBy
|
|
55
|
+
viewedBy(): PopulateOptions;
|
|
66
56
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @returns {PopulateOptions} the populate options
|
|
57
|
+
* Populate options for '_likedBy' field (array of accounts).
|
|
69
58
|
*/
|
|
70
|
-
likedBy
|
|
59
|
+
likedBy(): PopulateOptions;
|
|
71
60
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
61
|
+
* Populate options for 'comments' field, including optional author population.
|
|
62
|
+
* @param {boolean} includeAuthor - Whether to include author information
|
|
74
63
|
*/
|
|
75
|
-
comments
|
|
64
|
+
comments(includeAuthor?: boolean): PopulateOptions;
|
|
76
65
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @returns {PopulateOptions} the populate options
|
|
66
|
+
* Populate options for 'commentsCount' field.
|
|
79
67
|
*/
|
|
80
|
-
commentsCount
|
|
68
|
+
commentsCount(): PopulateOptions;
|
|
81
69
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
70
|
+
* Populate options for 'comments' field with nested 'replies', including optional author population.
|
|
71
|
+
* @param includeAuthor - Whether to populate author information in replies
|
|
84
72
|
*/
|
|
85
|
-
commentsAndReplies: () => PopulateOptions;
|
|
73
|
+
commentsAndReplies: (includeAuthor?: boolean) => PopulateOptions;
|
|
86
74
|
}
|
|
@@ -13,89 +13,97 @@ exports.PopulateService = void 0;
|
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const model_service_1 = require("../model-service/model.service");
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @class PopulateService
|
|
16
|
+
* PopulateService handles population options for various fields.
|
|
18
17
|
*/
|
|
19
18
|
let PopulateService = class PopulateService {
|
|
20
|
-
/**
|
|
21
|
-
* Constructor
|
|
22
|
-
* @param modelService - the model service
|
|
23
|
-
*/
|
|
24
19
|
constructor(modelService) {
|
|
25
20
|
this.modelService = modelService;
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @returns {PopulateOptions} the populate options
|
|
22
|
+
* Populate options for 'comments' field with nested 'replies', including optional author population.
|
|
23
|
+
* @param includeAuthor - Whether to populate author information in replies
|
|
30
24
|
*/
|
|
31
|
-
this.
|
|
25
|
+
this.commentsAndReplies = (includeAuthor = false) => {
|
|
26
|
+
const commentModel = this.modelService.commentModel();
|
|
27
|
+
const repliesPopulate = {
|
|
28
|
+
path: 'replies',
|
|
29
|
+
model: commentModel,
|
|
30
|
+
populate: includeAuthor ? this.author() : undefined,
|
|
31
|
+
};
|
|
32
|
+
const populateOptions = includeAuthor ? [this.author(), repliesPopulate] : [repliesPopulate];
|
|
33
|
+
return {
|
|
34
|
+
path: 'comments',
|
|
35
|
+
justOne: false,
|
|
36
|
+
model: commentModel,
|
|
37
|
+
options: { populate: populateOptions },
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns populate options for a single account field.
|
|
43
|
+
* @param path - The field path to populate
|
|
44
|
+
*/
|
|
45
|
+
account(path) {
|
|
46
|
+
return {
|
|
32
47
|
path,
|
|
33
48
|
justOne: true,
|
|
34
49
|
model: this.modelService.accountModel(),
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @returns {PopulateOptions} the populate options
|
|
44
|
-
*/
|
|
45
|
-
this.contact = () => this.account('contact');
|
|
46
|
-
/**
|
|
47
|
-
* Populates an array of accounts
|
|
48
|
-
* @param path - the path to populate
|
|
49
|
-
* @returns {PopulateOptions} the populate options
|
|
50
|
-
*/
|
|
51
|
-
this.accounts = (path) => ({
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns populate options for multiple accounts in an array field.
|
|
54
|
+
* @param path - The field path to populate
|
|
55
|
+
*/
|
|
56
|
+
accounts(path) {
|
|
57
|
+
return {
|
|
52
58
|
path,
|
|
53
59
|
justOne: false,
|
|
54
60
|
model: this.modelService.accountModel(),
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Populate options for 'author' field.
|
|
65
|
+
*/
|
|
66
|
+
author() {
|
|
67
|
+
return this.account('author');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Populate options for 'contact' field.
|
|
71
|
+
*/
|
|
72
|
+
contact() {
|
|
73
|
+
return this.account('contact');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Populate options for '_viewedBy' field (array of accounts).
|
|
77
|
+
*/
|
|
78
|
+
viewedBy() {
|
|
79
|
+
return this.accounts('viewedBy');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Populate options for '_likedBy' field (array of accounts).
|
|
83
|
+
*/
|
|
84
|
+
likedBy() {
|
|
85
|
+
return this.accounts('likedBy');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Populate options for 'comments' field, including optional author population.
|
|
89
|
+
* @param {boolean} includeAuthor - Whether to include author information
|
|
90
|
+
*/
|
|
91
|
+
comments(includeAuthor = false) {
|
|
92
|
+
return {
|
|
71
93
|
path: 'comments',
|
|
72
94
|
justOne: false,
|
|
73
95
|
model: this.modelService.commentModel(),
|
|
74
|
-
options: { populate:
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
options: { populate: includeAuthor ? this.author() : undefined },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Populate options for 'commentsCount' field.
|
|
101
|
+
*/
|
|
102
|
+
commentsCount() {
|
|
103
|
+
return {
|
|
81
104
|
path: 'commentsCount',
|
|
82
105
|
model: this.modelService.commentModel(),
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Populates the comments field of a document with its comments and replies
|
|
86
|
-
* @returns {PopulateOptions} the populate options
|
|
87
|
-
*/
|
|
88
|
-
this.commentsAndReplies = () => ({
|
|
89
|
-
path: 'comments',
|
|
90
|
-
justOne: false,
|
|
91
|
-
model: this.modelService.commentModel(),
|
|
92
|
-
options: {
|
|
93
|
-
populate: [
|
|
94
|
-
this.account('author'),
|
|
95
|
-
{ path: 'replies', model: this.modelService.commentModel(), populate: this.account('author') },
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
});
|
|
106
|
+
};
|
|
99
107
|
}
|
|
100
108
|
};
|
|
101
109
|
exports.PopulateService = PopulateService;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"email": "timo.scheuermann@sv-informatik.de",
|
|
6
6
|
"url": "https://timos.design"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.10.0",
|
|
9
9
|
"type": "commonjs",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
@@ -13,27 +13,28 @@
|
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
17
|
+
"format": "prettier \"src/**/*.ts\" --write",
|
|
18
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
19
|
+
"prepack": "npm run build",
|
|
20
|
+
"release": "npm run release:major",
|
|
18
21
|
"release:major": "npm version major && git push origin master --follow-tags",
|
|
19
22
|
"release:minor": "npm version minor && git push origin master --follow-tags",
|
|
20
|
-
"release:patch": "npm version patch && git push origin master --follow-tags"
|
|
21
|
-
"release": "npm run release:major",
|
|
22
|
-
"prepack": "npm run build"
|
|
23
|
+
"release:patch": "npm version patch && git push origin master --follow-tags"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"axios": "^1.7.7",
|
|
26
|
-
"itlab-functions": "^0.7.
|
|
27
|
+
"itlab-functions": "^0.7.7",
|
|
27
28
|
"passport-custom": "^1.1.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@nestjs/common": "^10.
|
|
31
|
-
"@nestjs/config": "^3.
|
|
32
|
-
"@nestjs/core": "^10.
|
|
33
|
-
"@nestjs/mongoose": "^10.0
|
|
34
|
-
"@nestjs/passport": "^10.0.
|
|
35
|
-
"@nestjs/platform-express": "^10.
|
|
36
|
-
"@nestjs/swagger": "^
|
|
31
|
+
"@nestjs/common": "^10.0.0",
|
|
32
|
+
"@nestjs/config": "^3.3.0",
|
|
33
|
+
"@nestjs/core": "^10.0.0",
|
|
34
|
+
"@nestjs/mongoose": "^10.1.0",
|
|
35
|
+
"@nestjs/passport": "^10.0.0",
|
|
36
|
+
"@nestjs/platform-express": "^10.0.0",
|
|
37
|
+
"@nestjs/swagger": "^8.0.5",
|
|
37
38
|
"@types/passport-strategy": "^0.2.38",
|
|
38
39
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
39
40
|
"@typescript-eslint/parser": "5.62.0",
|
|
@@ -42,12 +43,11 @@
|
|
|
42
43
|
"eslint": "8.42.0",
|
|
43
44
|
"eslint-config-prettier": "9.1.0",
|
|
44
45
|
"eslint-plugin-import": "2.29.1",
|
|
45
|
-
"mongoose": "^8.
|
|
46
|
+
"mongoose": "^8.8.1",
|
|
46
47
|
"passport": "^0.7.0",
|
|
47
48
|
"passport-jwt": "^4.0.1",
|
|
48
49
|
"prettier": "^3.3.3",
|
|
49
50
|
"reflect-metadata": "^0.2.2",
|
|
50
|
-
"rimraf": "^6.0.1",
|
|
51
51
|
"rxjs": "^7.8.1",
|
|
52
52
|
"typescript": "5.3.3"
|
|
53
53
|
},
|