itlab-internal-services 2.2.2 → 2.4.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.
- package/dist/axios.d.ts +16 -0
- package/dist/{modules/services/services.module-utils.js → axios.js} +6 -1
- package/dist/env.d.ts +14 -0
- package/dist/env.js +14 -0
- package/dist/exceptions/bad-body.exception.d.ts +22 -1
- package/dist/exceptions/bad-body.exception.js +42 -1
- package/dist/exceptions/duplicate.exception.d.ts +22 -1
- package/dist/exceptions/duplicate.exception.js +42 -1
- package/dist/exceptions/index.d.ts +18 -0
- package/dist/exceptions/index.js +11 -0
- package/dist/exceptions/not-found.exception.d.ts +22 -1
- package/dist/exceptions/not-found.exception.js +42 -1
- package/dist/favicon.controller.d.ts +12 -0
- package/dist/favicon.controller.js +13 -0
- package/dist/guards/perms.guard.d.ts +28 -0
- package/dist/guards/perms.guard.js +40 -2
- package/dist/guards/puplic.guard.d.ts +5 -0
- package/dist/guards/puplic.guard.js +5 -0
- package/dist/http.logger.d.ts +6 -0
- package/dist/http.logger.js +9 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/interceptors/errors.interceptor.d.ts +33 -1
- package/dist/interceptors/errors.interceptor.js +41 -3
- package/dist/liveness.probe.d.ts +11 -0
- package/dist/liveness.probe.js +11 -0
- package/dist/models/content.d.ts +8 -0
- package/dist/models/content.js +21 -0
- package/dist/models/filter/index.d.ts +49 -0
- package/dist/models/filter/index.js +88 -0
- package/dist/models/filter/limit.property.d.ts +4 -0
- package/dist/models/filter/limit.property.js +11 -0
- package/dist/models/filter/skip.property.d.ts +4 -0
- package/dist/models/filter/skip.property.js +16 -0
- package/dist/models/filter/sort-direction.property.d.ts +4 -0
- package/dist/models/filter/sort-direction.property.js +16 -0
- package/dist/models/filter/sort-field.property.d.ts +4 -0
- package/dist/models/filter/sort-field.property.js +17 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +20 -0
- package/dist/models/search-result.d.ts +14 -0
- package/dist/models/search-result.js +32 -0
- package/dist/models/thumbnail/alt.property.d.ts +8 -0
- package/dist/models/thumbnail/alt.property.js +18 -0
- package/dist/models/thumbnail/background.property.d.ts +8 -0
- package/dist/models/thumbnail/background.property.js +27 -0
- package/dist/models/thumbnail/contain.property.d.ts +8 -0
- package/dist/models/thumbnail/contain.property.js +18 -0
- package/dist/models/thumbnail/index.d.ts +30 -0
- package/dist/models/thumbnail/index.js +68 -0
- package/dist/models/thumbnail/max-height.property.d.ts +8 -0
- package/dist/models/thumbnail/max-height.property.js +20 -0
- package/dist/models/thumbnail/src.property.d.ts +8 -0
- package/dist/models/thumbnail/src.property.js +21 -0
- package/dist/modules/account/account.module.d.ts +12 -0
- package/dist/modules/account/account.module.js +34 -0
- package/dist/modules/account/account.service.d.ts +23 -0
- package/dist/modules/{services/account-service → account}/account.service.js +18 -3
- package/dist/modules/account/index.d.ts +2 -0
- package/dist/modules/account/index.js +7 -0
- package/dist/modules/authentication/authentication.module.d.ts +9 -4
- package/dist/modules/authentication/authentication.module.js +10 -2
- package/dist/modules/authentication/index.d.ts +1 -1
- package/dist/modules/authentication/internal/internal.constants.d.ts +4 -0
- package/dist/modules/authentication/internal/internal.constants.js +4 -0
- package/dist/modules/authentication/internal/internal.decorators.d.ts +4 -0
- package/dist/modules/authentication/internal/internal.decorators.js +4 -0
- package/dist/modules/authentication/internal/internal.guard.d.ts +5 -0
- package/dist/modules/authentication/internal/internal.guard.js +5 -0
- package/dist/modules/authentication/internal/internal.strategy.d.ts +17 -0
- package/dist/modules/authentication/internal/internal.strategy.js +17 -0
- package/dist/modules/authentication/jwt/jwt.constants.d.ts +20 -0
- package/dist/modules/authentication/jwt/jwt.constants.js +12 -0
- package/dist/modules/authentication/jwt/jwt.decorators.d.ts +15 -3
- package/dist/modules/authentication/jwt/jwt.decorators.js +16 -7
- package/dist/modules/authentication/jwt/jwt.guard.d.ts +15 -0
- package/dist/modules/authentication/jwt/jwt.guard.js +17 -0
- package/dist/modules/authentication/jwt/jwt.strategy.d.ts +16 -1
- package/dist/modules/authentication/jwt/jwt.strategy.js +16 -1
- package/dist/modules/comment/comment.controller.d.ts +24 -0
- package/dist/modules/comment/comment.controller.js +78 -0
- package/dist/modules/comment/comment.module-options.d.ts +18 -0
- package/dist/modules/{services/comment-service/comment-service.definitions.js → comment/comment.module-options.js} +10 -0
- package/dist/modules/comment/comment.module.d.ts +19 -0
- package/dist/modules/comment/comment.module.js +57 -0
- package/dist/modules/comment/comment.service.d.ts +42 -0
- package/dist/modules/comment/comment.service.js +113 -0
- package/dist/modules/comment/index.d.ts +3 -0
- package/dist/modules/comment/index.js +12 -0
- package/dist/modules/content/content.module.d.ts +18 -0
- package/dist/modules/content/content.module.js +46 -0
- package/dist/modules/content/content.service.d.ts +43 -0
- package/dist/modules/{services/content-service → content}/content.service.js +53 -17
- package/dist/modules/content/index.d.ts +2 -0
- package/dist/modules/content/index.js +7 -0
- package/dist/modules/database/database.module-options.d.ts +6 -0
- package/dist/modules/database/database.module.d.ts +19 -0
- package/dist/modules/database/database.module.js +41 -0
- package/dist/modules/database/index.js +12 -0
- package/dist/modules/database/model-service/model.service.d.ts +29 -0
- package/dist/modules/database/model-service/model.service.js +31 -0
- package/dist/modules/database/model-service/schemas/hub-account.schemas.d.ts +10 -0
- package/dist/modules/database/model-service/schemas/hub-account.schemas.js +7 -0
- package/dist/modules/database/model-service/schemas/hub-hackschool.schemas.js +3 -0
- package/dist/modules/database/model-service/schemas/hub-tech-radar.schemas.js +2 -0
- package/dist/modules/database/populate-service/populate.service.d.ts +35 -0
- package/dist/modules/database/populate-service/populate.service.js +35 -0
- package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +23 -0
- package/dist/modules/database/service-mapper-service/service-mapper.service.js +23 -0
- package/dist/modules/index.d.ts +6 -1
- package/dist/modules/index.js +6 -1
- package/dist/modules/like/index.d.ts +1 -0
- package/dist/modules/like/index.js +8 -0
- package/dist/modules/like/like.controller.d.ts +38 -0
- package/dist/modules/like/like.controller.js +119 -0
- package/dist/modules/like/like.module-options.d.ts +17 -0
- package/dist/modules/like/like.module-options.js +17 -0
- package/dist/modules/like/like.module.d.ts +18 -0
- package/dist/modules/like/like.module.js +45 -0
- package/dist/modules/like/like.service.d.ts +48 -0
- package/dist/modules/like/like.service.js +107 -0
- package/dist/modules/mail/index.d.ts +3 -0
- package/dist/modules/mail/index.js +10 -0
- package/dist/modules/mail/mail.models.d.ts +28 -0
- package/dist/modules/{services/mail-service/mail-service.definitions.js → mail/mail.models.js} +6 -0
- package/dist/modules/mail/mail.module.d.ts +12 -0
- package/dist/modules/mail/mail.module.js +34 -0
- package/dist/modules/mail/mail.service.d.ts +42 -0
- package/dist/modules/{services/mail-service → mail}/mail.service.js +34 -3
- package/dist/modules/search/index.d.ts +3 -0
- package/dist/modules/search/index.js +9 -0
- package/dist/modules/search/search.models.d.ts +19 -0
- package/dist/modules/{services/search-service/search-service.definitions.js → search/search.models.js} +9 -0
- package/dist/modules/search/search.module.d.ts +18 -0
- package/dist/modules/search/search.module.js +46 -0
- package/dist/modules/search/search.service.d.ts +35 -0
- package/dist/modules/{services/search-service → search}/search.service.js +44 -15
- package/dist/pipes/hid.pipe.d.ts +30 -0
- package/dist/pipes/hid.pipe.js +49 -5
- package/dist/pipes/id.pipe.d.ts +20 -0
- package/dist/pipes/id.pipe.js +40 -4
- package/dist/pipes/target.pipe.d.ts +23 -0
- package/dist/pipes/target.pipe.js +48 -6
- package/dist/schema.transformer.d.ts +2 -0
- package/dist/schema.transformer.js +10 -0
- package/dist/swagger.config.d.ts +36 -2
- package/dist/swagger.config.js +40 -3
- package/dist/transform/_trim.d.ts +7 -0
- package/dist/transform/_trim.js +16 -0
- package/dist/transform/index.d.ts +6 -0
- package/dist/transform/index.js +17 -0
- package/dist/transform/transformImage.d.ts +4 -0
- package/dist/transform/transformImage.js +16 -0
- package/dist/transform/transformString.d.ts +5 -0
- package/dist/transform/transformString.js +16 -0
- package/dist/transform/transformStringArray.d.ts +6 -0
- package/dist/transform/transformStringArray.js +24 -0
- package/dist/transform/transformStringLike.d.ts +20 -0
- package/dist/transform/transformStringLike.js +37 -0
- package/dist/transform/transformStringLowerCase.d.ts +5 -0
- package/dist/transform/transformStringLowerCase.js +16 -0
- package/dist/transform/transformStringSet.d.ts +6 -0
- package/dist/transform/transformStringSet.js +25 -0
- package/dist/virtuals.factory.d.ts +57 -0
- package/dist/virtuals.factory.js +117 -0
- package/package.json +3 -1
- package/dist/modules/services/account-service/account.service.d.ts +0 -8
- package/dist/modules/services/comment-service/comment-service.definitions.d.ts +0 -5
- package/dist/modules/services/comment-service/comment.service.d.ts +0 -12
- package/dist/modules/services/comment-service/comment.service.js +0 -75
- package/dist/modules/services/content-service/content.service.d.ts +0 -12
- package/dist/modules/services/index.d.ts +0 -9
- package/dist/modules/services/index.js +0 -22
- package/dist/modules/services/mail-service/mail-service.definitions.d.ts +0 -13
- package/dist/modules/services/mail-service/mail.service.d.ts +0 -11
- package/dist/modules/services/search-service/search-service.definitions.d.ts +0 -6
- package/dist/modules/services/search-service/search.service.d.ts +0 -11
- package/dist/modules/services/services.module-utils.d.ts +0 -7
- package/dist/modules/services/services.module.d.ts +0 -7
- package/dist/modules/services/services.module.js +0 -30
- package/dist/virtuals.d.ts +0 -8
- package/dist/virtuals.js +0 -77
package/dist/swagger.config.js
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSwagger = exports.getSwaggerDocument = exports.getSwaggerConfig = void 0;
|
|
3
|
+
exports.useSwagger = exports.getSwaggerDocument = exports.getSwaggerConfig = exports.SwaggerOptions = void 0;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
5
|
const internal_constants_1 = require("./modules/authentication/internal/internal.constants");
|
|
6
|
+
/**
|
|
7
|
+
* Class representing Swagger options.
|
|
8
|
+
*
|
|
9
|
+
* @class SwaggerOptions
|
|
10
|
+
*
|
|
11
|
+
* @property {string} title - Title of the Swagger documentation.
|
|
12
|
+
* @property {string} description - Description of the Swagger documentation.
|
|
13
|
+
* @property {boolean} jwt - Whether JWT authentication is enabled.
|
|
14
|
+
* @property {boolean} k8s - Whether Kubernetes integration is enabled.
|
|
15
|
+
*/
|
|
16
|
+
class SwaggerOptions {
|
|
17
|
+
}
|
|
18
|
+
exports.SwaggerOptions = SwaggerOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the Swagger configuration.
|
|
21
|
+
*
|
|
22
|
+
* @param {SwaggerOptions} options - optional options for Swagger
|
|
23
|
+
* @return {SwaggerConfig} the Swagger configuration
|
|
24
|
+
*/
|
|
6
25
|
function getSwaggerConfig(options) {
|
|
7
26
|
return getSwaggerDocument(options).build();
|
|
8
27
|
}
|
|
9
28
|
exports.getSwaggerConfig = getSwaggerConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a Swagger document builder with the specified options.
|
|
31
|
+
*
|
|
32
|
+
* @param {SwaggerOptions} options - optional Swagger options
|
|
33
|
+
* @return {DocumentBuilder} the constructed Swagger document builder
|
|
34
|
+
*/
|
|
10
35
|
function getSwaggerDocument(options) {
|
|
11
36
|
let cfg = new swagger_1.DocumentBuilder();
|
|
37
|
+
// Set contact information
|
|
12
38
|
cfg = cfg.setContact('Timo Scheuermann', '', 'timo.scheuermann@sv-informatik.de');
|
|
39
|
+
// Set title and description
|
|
13
40
|
cfg = cfg.setTitle(options.title);
|
|
14
41
|
cfg = cfg.setDescription(options.description);
|
|
42
|
+
// Add server with base path
|
|
15
43
|
cfg = cfg.addServer(process.env.SWAGGER_BASE_PATH || 'http://localhost:3000');
|
|
16
|
-
|
|
44
|
+
// Add JWT bearer authentication if specified in options
|
|
45
|
+
if (options.jwt === true) {
|
|
17
46
|
cfg = cfg.addBearerAuth({
|
|
18
47
|
in: 'header',
|
|
19
48
|
type: 'http',
|
|
@@ -21,12 +50,20 @@ function getSwaggerDocument(options) {
|
|
|
21
50
|
description: 'Gesicherter Login Token',
|
|
22
51
|
});
|
|
23
52
|
}
|
|
24
|
-
|
|
53
|
+
// Add Kubernetes API key if specified in options
|
|
54
|
+
if (options.k8s === true) {
|
|
25
55
|
cfg = cfg.addApiKey({ in: 'header', type: 'apiKey', description: 'Token zur Authentifizierung interner Anrufe' }, internal_constants_1.INTERNAL_HEADER_KEY);
|
|
26
56
|
}
|
|
27
57
|
return cfg;
|
|
28
58
|
}
|
|
29
59
|
exports.getSwaggerDocument = getSwaggerDocument;
|
|
60
|
+
/**
|
|
61
|
+
* Initializes and configures Swagger for the given Nest application.
|
|
62
|
+
*
|
|
63
|
+
* @param {INestApplication} app - The Nest application instance
|
|
64
|
+
* @param {SwaggerOptions} [options] - Optional Swagger configuration options
|
|
65
|
+
* @return {void}
|
|
66
|
+
*/
|
|
30
67
|
function useSwagger(app, options) {
|
|
31
68
|
const document = swagger_1.SwaggerModule.createDocument(app, getSwaggerConfig(options));
|
|
32
69
|
swagger_1.SwaggerModule.setup('api', app, document);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trimStringLike = void 0;
|
|
4
|
+
const transformStringLike_1 = require("./transformStringLike");
|
|
5
|
+
/**
|
|
6
|
+
* Trims and normalizes the given value if it is a string or number.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to be trimmed and normalized
|
|
9
|
+
* @returns The trimmed and normalized value
|
|
10
|
+
*/
|
|
11
|
+
function trimStringLike(value) {
|
|
12
|
+
if (!(0, transformStringLike_1.isStringLike)(value))
|
|
13
|
+
return value;
|
|
14
|
+
return String(value).replace(/\s+/g, ' ').trim();
|
|
15
|
+
}
|
|
16
|
+
exports.trimStringLike = trimStringLike;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TransformImage } from './transformImage';
|
|
2
|
+
export { TransformString } from './transformString';
|
|
3
|
+
export { TransformStringArray } from './transformStringArray';
|
|
4
|
+
export { isStringLike, isStringLikeMin, TransformStringLike } from './transformStringLike';
|
|
5
|
+
export { TransformStringLowerCase } from './transformStringLowerCase';
|
|
6
|
+
export { TransformStringSet } from './transformStringSet';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformStringSet = exports.TransformStringLowerCase = exports.TransformStringLike = exports.isStringLikeMin = exports.isStringLike = exports.TransformStringArray = exports.TransformString = exports.TransformImage = void 0;
|
|
4
|
+
var transformImage_1 = require("./transformImage");
|
|
5
|
+
Object.defineProperty(exports, "TransformImage", { enumerable: true, get: function () { return transformImage_1.TransformImage; } });
|
|
6
|
+
var transformString_1 = require("./transformString");
|
|
7
|
+
Object.defineProperty(exports, "TransformString", { enumerable: true, get: function () { return transformString_1.TransformString; } });
|
|
8
|
+
var transformStringArray_1 = require("./transformStringArray");
|
|
9
|
+
Object.defineProperty(exports, "TransformStringArray", { enumerable: true, get: function () { return transformStringArray_1.TransformStringArray; } });
|
|
10
|
+
var transformStringLike_1 = require("./transformStringLike");
|
|
11
|
+
Object.defineProperty(exports, "isStringLike", { enumerable: true, get: function () { return transformStringLike_1.isStringLike; } });
|
|
12
|
+
Object.defineProperty(exports, "isStringLikeMin", { enumerable: true, get: function () { return transformStringLike_1.isStringLikeMin; } });
|
|
13
|
+
Object.defineProperty(exports, "TransformStringLike", { enumerable: true, get: function () { return transformStringLike_1.TransformStringLike; } });
|
|
14
|
+
var transformStringLowerCase_1 = require("./transformStringLowerCase");
|
|
15
|
+
Object.defineProperty(exports, "TransformStringLowerCase", { enumerable: true, get: function () { return transformStringLowerCase_1.TransformStringLowerCase; } });
|
|
16
|
+
var transformStringSet_1 = require("./transformStringSet");
|
|
17
|
+
Object.defineProperty(exports, "TransformStringSet", { enumerable: true, get: function () { return transformStringSet_1.TransformStringSet; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformImage = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const itlab_functions_1 = require("itlab-functions");
|
|
7
|
+
const _trim_1 = require("./_trim");
|
|
8
|
+
/**
|
|
9
|
+
* This function transforms the input value to a cleaned image url if it's a string
|
|
10
|
+
*/
|
|
11
|
+
function TransformImage() {
|
|
12
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
13
|
+
return (0, class_validator_1.isString)(value) ? (0, itlab_functions_1.transformImage)((0, _trim_1.trimStringLike)(value)) : value;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.TransformImage = TransformImage;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformString = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const _trim_1 = require("./_trim");
|
|
7
|
+
/**
|
|
8
|
+
* This function transforms the input value to a trimmed string if it's a string,
|
|
9
|
+
* otherwise it returns the original value.
|
|
10
|
+
*/
|
|
11
|
+
function TransformString() {
|
|
12
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
13
|
+
return (0, class_validator_1.isString)(value) ? (0, _trim_1.trimStringLike)(value) : value;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.TransformString = TransformString;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformStringArray = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const transformStringLike_1 = require("./transformStringLike");
|
|
7
|
+
const _trim_1 = require("./_trim");
|
|
8
|
+
/**
|
|
9
|
+
* This function transforms the input value to an array of trimmed strings if it's
|
|
10
|
+
* an array of strings or an array of numbers, otherwise it returns the original
|
|
11
|
+
* value.
|
|
12
|
+
*/
|
|
13
|
+
function TransformStringArray() {
|
|
14
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
15
|
+
if (!(0, class_validator_1.isArray)(value))
|
|
16
|
+
return value;
|
|
17
|
+
value = value
|
|
18
|
+
.filter((v) => (0, transformStringLike_1.isStringLike)(v)) // filter out non-string and non-number values
|
|
19
|
+
.map((v) => (0, _trim_1.trimStringLike)(v)) // trim and normalize the value
|
|
20
|
+
.filter((v) => v.length); // filter out empty values
|
|
21
|
+
return value;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.TransformStringArray = TransformStringArray;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a string or a number
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value - The value to be checked
|
|
5
|
+
* @return {boolean} true if the value is like a string, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function isStringLike(value: unknown): value is string | number;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the given value is a string or a number with a minimum length.
|
|
10
|
+
*
|
|
11
|
+
* @param {unknown} value - the value to be checked
|
|
12
|
+
* @param {number} min - the minimum length to be checked against
|
|
13
|
+
* @return {boolean} true if the value is a string or number with minimum length, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isStringLikeMin(value: unknown, min: number): value is string | number;
|
|
16
|
+
/**
|
|
17
|
+
* This function transforms the input value to a trimmed string if it's a string
|
|
18
|
+
* or a number, otherwise it returns the original value.
|
|
19
|
+
*/
|
|
20
|
+
export declare function TransformStringLike(): PropertyDecorator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformStringLike = exports.isStringLikeMin = exports.isStringLike = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const _trim_1 = require("./_trim");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the given value is a string or a number
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} value - The value to be checked
|
|
11
|
+
* @return {boolean} true if the value is like a string, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
function isStringLike(value) {
|
|
14
|
+
return (0, class_validator_1.isString)(value) || (0, class_validator_1.isNumber)(value);
|
|
15
|
+
}
|
|
16
|
+
exports.isStringLike = isStringLike;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the given value is a string or a number with a minimum length.
|
|
19
|
+
*
|
|
20
|
+
* @param {unknown} value - the value to be checked
|
|
21
|
+
* @param {number} min - the minimum length to be checked against
|
|
22
|
+
* @return {boolean} true if the value is a string or number with minimum length, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
function isStringLikeMin(value, min) {
|
|
25
|
+
return isStringLike(value) && (0, class_validator_1.minLength)((0, _trim_1.trimStringLike)(value), min);
|
|
26
|
+
}
|
|
27
|
+
exports.isStringLikeMin = isStringLikeMin;
|
|
28
|
+
/**
|
|
29
|
+
* This function transforms the input value to a trimmed string if it's a string
|
|
30
|
+
* or a number, otherwise it returns the original value.
|
|
31
|
+
*/
|
|
32
|
+
function TransformStringLike() {
|
|
33
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
34
|
+
return isStringLike(value) ? (0, _trim_1.trimStringLike)(value) : value;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.TransformStringLike = TransformStringLike;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformStringLowerCase = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const transformStringLike_1 = require("./transformStringLike");
|
|
6
|
+
const _trim_1 = require("./_trim");
|
|
7
|
+
/**
|
|
8
|
+
* This function transforms the input value to a trimmed lowercase string if it's
|
|
9
|
+
* a string, otherwise it returns the original value.
|
|
10
|
+
*/
|
|
11
|
+
function TransformStringLowerCase() {
|
|
12
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
13
|
+
return (0, transformStringLike_1.isStringLike)(value) ? (0, _trim_1.trimStringLike)(value).toLowerCase() : value;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.TransformStringLowerCase = TransformStringLowerCase;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformStringSet = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const transformStringLike_1 = require("./transformStringLike");
|
|
7
|
+
const _trim_1 = require("./_trim");
|
|
8
|
+
/**
|
|
9
|
+
* This function transforms the input value to a set of trimmed strings if it's
|
|
10
|
+
* an array of strings or an array of numbers, otherwise it returns the original
|
|
11
|
+
* value.
|
|
12
|
+
*/
|
|
13
|
+
function TransformStringSet() {
|
|
14
|
+
return (0, class_transformer_1.Transform)(({ value }) => {
|
|
15
|
+
if (!(0, class_validator_1.isArray)(value))
|
|
16
|
+
return value;
|
|
17
|
+
value = value
|
|
18
|
+
.filter((v) => (0, transformStringLike_1.isStringLike)(v)) // filter out non-string and non-number values
|
|
19
|
+
.map((v) => (0, _trim_1.trimStringLike)(v)) // trim and normalize the value
|
|
20
|
+
.filter((v) => v.length); // filter out empty values
|
|
21
|
+
value = [...new Set(value)]; // remove duplicates
|
|
22
|
+
return value;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.TransformStringSet = TransformStringSet;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
import { Targets } from './pipes';
|
|
3
|
+
/**
|
|
4
|
+
* Creates virtual fields on a schema.
|
|
5
|
+
*
|
|
6
|
+
* @class VirtualsFactory
|
|
7
|
+
*/
|
|
8
|
+
export declare class VirtualsFactory {
|
|
9
|
+
private readonly schema;
|
|
10
|
+
private readonly target;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new VirtualsFactory.
|
|
13
|
+
* @param {Schema} schema - the schema to create the virtual field on
|
|
14
|
+
* @param {Targets} target - the target for the virtual field
|
|
15
|
+
*/
|
|
16
|
+
constructor(schema: Schema, target: Targets);
|
|
17
|
+
/**
|
|
18
|
+
* Creates a virtual account field on the given schema, linking it to the 'accounts' collection.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} name - the name of the virtual field
|
|
21
|
+
* @param {string} localField - the local field to be used for the virtual linking
|
|
22
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
23
|
+
*/
|
|
24
|
+
account(name: string, localField: string): VirtualsFactory;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a virtual accounts field on the given schema, linking it to the 'accounts' collection.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name - the name of the virtual field
|
|
29
|
+
* @param {string} localField - the local field to be used for the virtual linking
|
|
30
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
31
|
+
*/
|
|
32
|
+
accounts(name: string, localField: string): VirtualsFactory;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a virtual content field on the given schema, linking it to the 'content' collection.
|
|
35
|
+
*
|
|
36
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
37
|
+
*/
|
|
38
|
+
content(): VirtualsFactory;
|
|
39
|
+
/**
|
|
40
|
+
* Creates virtual comments field on the given schema, linking it to the 'comments' collection.
|
|
41
|
+
*
|
|
42
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
43
|
+
*/
|
|
44
|
+
comments(): VirtualsFactory;
|
|
45
|
+
/**
|
|
46
|
+
* Creates virtual commentsCount field on the given schema, linking it to the 'comments' collection.
|
|
47
|
+
*
|
|
48
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
49
|
+
*/
|
|
50
|
+
commentsCount(): VirtualsFactory;
|
|
51
|
+
/**
|
|
52
|
+
* Creates multiple virtual fields on the given schema for each target.
|
|
53
|
+
*
|
|
54
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
55
|
+
*/
|
|
56
|
+
registerServiceRefs(): VirtualsFactory;
|
|
57
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VirtualsFactory = void 0;
|
|
4
|
+
const pipes_1 = require("./pipes");
|
|
5
|
+
/**
|
|
6
|
+
* Creates virtual fields on a schema.
|
|
7
|
+
*
|
|
8
|
+
* @class VirtualsFactory
|
|
9
|
+
*/
|
|
10
|
+
class VirtualsFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new VirtualsFactory.
|
|
13
|
+
* @param {Schema} schema - the schema to create the virtual field on
|
|
14
|
+
* @param {Targets} target - the target for the virtual field
|
|
15
|
+
*/
|
|
16
|
+
constructor(schema, target) {
|
|
17
|
+
this.schema = schema;
|
|
18
|
+
this.target = target;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a virtual account field on the given schema, linking it to the 'accounts' collection.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} name - the name of the virtual field
|
|
24
|
+
* @param {string} localField - the local field to be used for the virtual linking
|
|
25
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
26
|
+
*/
|
|
27
|
+
account(name, localField) {
|
|
28
|
+
this.schema.virtual(name, {
|
|
29
|
+
ref: 'accounts',
|
|
30
|
+
foreignField: '_id',
|
|
31
|
+
localField,
|
|
32
|
+
justOne: true,
|
|
33
|
+
});
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a virtual accounts field on the given schema, linking it to the 'accounts' collection.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} name - the name of the virtual field
|
|
40
|
+
* @param {string} localField - the local field to be used for the virtual linking
|
|
41
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
42
|
+
*/
|
|
43
|
+
accounts(name, localField) {
|
|
44
|
+
this.schema.virtual(name, {
|
|
45
|
+
ref: 'accounts',
|
|
46
|
+
foreignField: '_id',
|
|
47
|
+
localField,
|
|
48
|
+
justOne: false,
|
|
49
|
+
});
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a virtual content field on the given schema, linking it to the 'content' collection.
|
|
54
|
+
*
|
|
55
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
56
|
+
*/
|
|
57
|
+
content() {
|
|
58
|
+
this.schema.virtual('content', {
|
|
59
|
+
ref: 'content',
|
|
60
|
+
foreignField: 'targetId',
|
|
61
|
+
localField: '_id',
|
|
62
|
+
match: { target: this.target },
|
|
63
|
+
justOne: true,
|
|
64
|
+
});
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates virtual comments field on the given schema, linking it to the 'comments' collection.
|
|
69
|
+
*
|
|
70
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
71
|
+
*/
|
|
72
|
+
comments() {
|
|
73
|
+
this.schema.virtual('comments', {
|
|
74
|
+
ref: 'comments',
|
|
75
|
+
foreignField: 'targetId',
|
|
76
|
+
localField: '_id',
|
|
77
|
+
match: { target: this.target, _replyTo: { $exists: false } },
|
|
78
|
+
justOne: false,
|
|
79
|
+
});
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates virtual commentsCount field on the given schema, linking it to the 'comments' collection.
|
|
84
|
+
*
|
|
85
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
86
|
+
*/
|
|
87
|
+
commentsCount() {
|
|
88
|
+
this.schema.virtual('commentsCount', {
|
|
89
|
+
ref: 'comments',
|
|
90
|
+
foreignField: 'targetId',
|
|
91
|
+
localField: '_id',
|
|
92
|
+
match: { target: this.target },
|
|
93
|
+
count: true,
|
|
94
|
+
});
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates multiple virtual fields on the given schema for each target.
|
|
99
|
+
*
|
|
100
|
+
* @return {VirtualsFactory} the VirtualsFactory
|
|
101
|
+
*/
|
|
102
|
+
registerServiceRefs() {
|
|
103
|
+
// prettier-ignore
|
|
104
|
+
const targets = [pipes_1.Targets.BOOKS, pipes_1.Targets.DEMOHIVE, pipes_1.Targets.EVENTS, pipes_1.Targets.HACKSCHOOL_COURSE, pipes_1.Targets.HACKSCHOOL_DOCUMENTATION, pipes_1.Targets.HACKSCHOOL_THREAD, pipes_1.Targets.NEWSROOM, pipes_1.Targets.PODCASTS, pipes_1.Targets.TEAM_MEMBER, pipes_1.Targets.TECH_RADAR_BLIPS, pipes_1.Targets.TECH_RADAR_RADAR];
|
|
105
|
+
for (const target of targets) {
|
|
106
|
+
this.schema.virtual('ref-' + target, {
|
|
107
|
+
ref: target,
|
|
108
|
+
foreignField: '_id',
|
|
109
|
+
localField: 'targetId',
|
|
110
|
+
match: { target },
|
|
111
|
+
justOne: true,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.VirtualsFactory = VirtualsFactory;
|
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.4.0",
|
|
9
9
|
"type": "commonjs",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@types/passport-strategy": "^0.2.35",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "5.42.1",
|
|
40
40
|
"@typescript-eslint/parser": "5.42.1",
|
|
41
|
+
"class-transformer": "^0.5.1",
|
|
41
42
|
"class-validator": "^0.13.2",
|
|
42
43
|
"eslint": "8.27.0",
|
|
43
44
|
"eslint-config-prettier": "8.5.0",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"@nestjs/mongoose": "^10.0.0",
|
|
61
62
|
"@nestjs/passport": "^8.0.0 || ^9.0.0",
|
|
62
63
|
"@nestjs/swagger": "^6.0.0",
|
|
64
|
+
"class-transformer": "^0.5.1",
|
|
63
65
|
"class-validator": "^0.13.2",
|
|
64
66
|
"mongoose": "^7.3.1",
|
|
65
67
|
"passport-jwt": "^4.0.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { AccountInformation } from 'itlab-functions';
|
|
3
|
-
export declare class AccountService {
|
|
4
|
-
private readonly configService;
|
|
5
|
-
constructor(configService: ConfigService);
|
|
6
|
-
private axios;
|
|
7
|
-
get(accountId: string): Promise<AccountInformation>;
|
|
8
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { ContentRichtext } from 'itlab-functions';
|
|
3
|
-
import { Targets } from '../../../pipes';
|
|
4
|
-
import { Comment } from './comment-service.definitions';
|
|
5
|
-
export declare class CommentService {
|
|
6
|
-
private readonly configService;
|
|
7
|
-
private logger;
|
|
8
|
-
constructor(configService: ConfigService);
|
|
9
|
-
private axios;
|
|
10
|
-
post(targetId: string, authorId: string, comment: ContentRichtext, target: Targets): Promise<Comment>;
|
|
11
|
-
delete(targetId: string, target: Targets): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var CommentService_1;
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.CommentService = void 0;
|
|
23
|
-
const common_1 = require("@nestjs/common");
|
|
24
|
-
const config_1 = require("@nestjs/config");
|
|
25
|
-
const env_1 = require("../../../env");
|
|
26
|
-
const services_module_utils_1 = require("../services.module-utils");
|
|
27
|
-
let CommentService = CommentService_1 = class CommentService {
|
|
28
|
-
constructor(configService) {
|
|
29
|
-
this.configService = configService;
|
|
30
|
-
this.logger = new common_1.Logger(CommentService_1.name);
|
|
31
|
-
this.axios = (0, services_module_utils_1.createAxios)({
|
|
32
|
-
baseUrl: 'https://services.svi-itlab.com/comment/internal/',
|
|
33
|
-
k8sToken: this.configService.getOrThrow(env_1.ENV_K8S_TOKEN),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
post(targetId, authorId, comment, target) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
this.logger.log(`Posting comment for ${target} (${targetId}) by ${authorId}`);
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
this.axios
|
|
41
|
-
.post(`${target}/${targetId}/${authorId}`, comment)
|
|
42
|
-
.then(({ data }) => {
|
|
43
|
-
this.logger.log(`Comment for ${target} (${targetId}) posted`);
|
|
44
|
-
resolve(data);
|
|
45
|
-
})
|
|
46
|
-
.catch(({ response }) => {
|
|
47
|
-
this.logger.error(`Couldn't post comment for ${target} (${targetId})`, response.data);
|
|
48
|
-
reject(new common_1.HttpException(response.data, response.status));
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
delete(targetId, target) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
this.logger.log(`Deleting all comments for ${target} (${targetId})`);
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
this.axios
|
|
58
|
-
.delete(`${target}/${targetId}`)
|
|
59
|
-
.then(() => {
|
|
60
|
-
this.logger.log(`All comments for ${target} (${targetId}) deleted`);
|
|
61
|
-
resolve();
|
|
62
|
-
})
|
|
63
|
-
.catch(({ response }) => {
|
|
64
|
-
this.logger.error(`Couldn't delete all comments for ${target} (${targetId})`, response.data);
|
|
65
|
-
reject(new common_1.HttpException(response.data, response.status));
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
CommentService = CommentService_1 = __decorate([
|
|
72
|
-
(0, common_1.Injectable)(),
|
|
73
|
-
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
74
|
-
], CommentService);
|
|
75
|
-
exports.CommentService = CommentService;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { Content } from 'itlab-functions';
|
|
3
|
-
import { Targets } from '../../../pipes';
|
|
4
|
-
export declare class ContentService {
|
|
5
|
-
private readonly configService;
|
|
6
|
-
private logger;
|
|
7
|
-
constructor(configService: ConfigService);
|
|
8
|
-
private axios;
|
|
9
|
-
verify(content: Content): Promise<void>;
|
|
10
|
-
post(targetId: string, content: Content, target: Targets): Promise<string>;
|
|
11
|
-
delete(targetId: string, target: Targets): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { AccountService } from './account-service/account.service';
|
|
2
|
-
export { Comment } from './comment-service/comment-service.definitions';
|
|
3
|
-
export { CommentService } from './comment-service/comment.service';
|
|
4
|
-
export { ContentService } from './content-service/content.service';
|
|
5
|
-
export { MailDagoBERTDowntime, MailWeeklyDagoBERTSummary } from './mail-service/mail-service.definitions';
|
|
6
|
-
export { MailService } from './mail-service/mail.service';
|
|
7
|
-
export { SearchableDocument } from './search-service/search-service.definitions';
|
|
8
|
-
export { SearchService } from './search-service/search.service';
|
|
9
|
-
export { ServicesModule, ServicesModuleOptions } from './services.module';
|