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.
Files changed (182) hide show
  1. package/dist/axios.d.ts +16 -0
  2. package/dist/{modules/services/services.module-utils.js → axios.js} +6 -1
  3. package/dist/env.d.ts +14 -0
  4. package/dist/env.js +14 -0
  5. package/dist/exceptions/bad-body.exception.d.ts +22 -1
  6. package/dist/exceptions/bad-body.exception.js +42 -1
  7. package/dist/exceptions/duplicate.exception.d.ts +22 -1
  8. package/dist/exceptions/duplicate.exception.js +42 -1
  9. package/dist/exceptions/index.d.ts +18 -0
  10. package/dist/exceptions/index.js +11 -0
  11. package/dist/exceptions/not-found.exception.d.ts +22 -1
  12. package/dist/exceptions/not-found.exception.js +42 -1
  13. package/dist/favicon.controller.d.ts +12 -0
  14. package/dist/favicon.controller.js +13 -0
  15. package/dist/guards/perms.guard.d.ts +28 -0
  16. package/dist/guards/perms.guard.js +40 -2
  17. package/dist/guards/puplic.guard.d.ts +5 -0
  18. package/dist/guards/puplic.guard.js +5 -0
  19. package/dist/http.logger.d.ts +6 -0
  20. package/dist/http.logger.js +9 -1
  21. package/dist/index.d.ts +4 -1
  22. package/dist/index.js +4 -1
  23. package/dist/interceptors/errors.interceptor.d.ts +33 -1
  24. package/dist/interceptors/errors.interceptor.js +41 -3
  25. package/dist/liveness.probe.d.ts +11 -0
  26. package/dist/liveness.probe.js +11 -0
  27. package/dist/models/content.d.ts +8 -0
  28. package/dist/models/content.js +21 -0
  29. package/dist/models/filter/index.d.ts +49 -0
  30. package/dist/models/filter/index.js +88 -0
  31. package/dist/models/filter/limit.property.d.ts +4 -0
  32. package/dist/models/filter/limit.property.js +11 -0
  33. package/dist/models/filter/skip.property.d.ts +4 -0
  34. package/dist/models/filter/skip.property.js +16 -0
  35. package/dist/models/filter/sort-direction.property.d.ts +4 -0
  36. package/dist/models/filter/sort-direction.property.js +16 -0
  37. package/dist/models/filter/sort-field.property.d.ts +4 -0
  38. package/dist/models/filter/sort-field.property.js +17 -0
  39. package/dist/models/index.d.ts +4 -0
  40. package/dist/models/index.js +20 -0
  41. package/dist/models/search-result.d.ts +14 -0
  42. package/dist/models/search-result.js +32 -0
  43. package/dist/models/thumbnail/alt.property.d.ts +8 -0
  44. package/dist/models/thumbnail/alt.property.js +18 -0
  45. package/dist/models/thumbnail/background.property.d.ts +8 -0
  46. package/dist/models/thumbnail/background.property.js +27 -0
  47. package/dist/models/thumbnail/contain.property.d.ts +8 -0
  48. package/dist/models/thumbnail/contain.property.js +18 -0
  49. package/dist/models/thumbnail/index.d.ts +30 -0
  50. package/dist/models/thumbnail/index.js +68 -0
  51. package/dist/models/thumbnail/max-height.property.d.ts +8 -0
  52. package/dist/models/thumbnail/max-height.property.js +20 -0
  53. package/dist/models/thumbnail/src.property.d.ts +8 -0
  54. package/dist/models/thumbnail/src.property.js +21 -0
  55. package/dist/modules/account/account.module.d.ts +12 -0
  56. package/dist/modules/account/account.module.js +34 -0
  57. package/dist/modules/account/account.service.d.ts +23 -0
  58. package/dist/modules/{services/account-service → account}/account.service.js +18 -3
  59. package/dist/modules/account/index.d.ts +2 -0
  60. package/dist/modules/account/index.js +7 -0
  61. package/dist/modules/authentication/authentication.module.d.ts +9 -4
  62. package/dist/modules/authentication/authentication.module.js +10 -2
  63. package/dist/modules/authentication/index.d.ts +1 -1
  64. package/dist/modules/authentication/internal/internal.constants.d.ts +4 -0
  65. package/dist/modules/authentication/internal/internal.constants.js +4 -0
  66. package/dist/modules/authentication/internal/internal.decorators.d.ts +4 -0
  67. package/dist/modules/authentication/internal/internal.decorators.js +4 -0
  68. package/dist/modules/authentication/internal/internal.guard.d.ts +5 -0
  69. package/dist/modules/authentication/internal/internal.guard.js +5 -0
  70. package/dist/modules/authentication/internal/internal.strategy.d.ts +17 -0
  71. package/dist/modules/authentication/internal/internal.strategy.js +17 -0
  72. package/dist/modules/authentication/jwt/jwt.constants.d.ts +20 -0
  73. package/dist/modules/authentication/jwt/jwt.constants.js +12 -0
  74. package/dist/modules/authentication/jwt/jwt.decorators.d.ts +15 -3
  75. package/dist/modules/authentication/jwt/jwt.decorators.js +16 -7
  76. package/dist/modules/authentication/jwt/jwt.guard.d.ts +15 -0
  77. package/dist/modules/authentication/jwt/jwt.guard.js +17 -0
  78. package/dist/modules/authentication/jwt/jwt.strategy.d.ts +16 -1
  79. package/dist/modules/authentication/jwt/jwt.strategy.js +16 -1
  80. package/dist/modules/comment/comment.controller.d.ts +24 -0
  81. package/dist/modules/comment/comment.controller.js +78 -0
  82. package/dist/modules/comment/comment.module-options.d.ts +18 -0
  83. package/dist/modules/{services/comment-service/comment-service.definitions.js → comment/comment.module-options.js} +10 -0
  84. package/dist/modules/comment/comment.module.d.ts +19 -0
  85. package/dist/modules/comment/comment.module.js +57 -0
  86. package/dist/modules/comment/comment.service.d.ts +42 -0
  87. package/dist/modules/comment/comment.service.js +113 -0
  88. package/dist/modules/comment/index.d.ts +3 -0
  89. package/dist/modules/comment/index.js +12 -0
  90. package/dist/modules/content/content.module.d.ts +18 -0
  91. package/dist/modules/content/content.module.js +46 -0
  92. package/dist/modules/content/content.service.d.ts +43 -0
  93. package/dist/modules/{services/content-service → content}/content.service.js +53 -17
  94. package/dist/modules/content/index.d.ts +2 -0
  95. package/dist/modules/content/index.js +7 -0
  96. package/dist/modules/database/database.module-options.d.ts +6 -0
  97. package/dist/modules/database/database.module.d.ts +19 -0
  98. package/dist/modules/database/database.module.js +41 -0
  99. package/dist/modules/database/index.js +12 -0
  100. package/dist/modules/database/model-service/model.service.d.ts +29 -0
  101. package/dist/modules/database/model-service/model.service.js +31 -0
  102. package/dist/modules/database/model-service/schemas/hub-account.schemas.d.ts +10 -0
  103. package/dist/modules/database/model-service/schemas/hub-account.schemas.js +7 -0
  104. package/dist/modules/database/model-service/schemas/hub-hackschool.schemas.js +3 -0
  105. package/dist/modules/database/model-service/schemas/hub-tech-radar.schemas.js +2 -0
  106. package/dist/modules/database/populate-service/populate.service.d.ts +35 -0
  107. package/dist/modules/database/populate-service/populate.service.js +35 -0
  108. package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +23 -0
  109. package/dist/modules/database/service-mapper-service/service-mapper.service.js +23 -0
  110. package/dist/modules/index.d.ts +6 -1
  111. package/dist/modules/index.js +6 -1
  112. package/dist/modules/like/index.d.ts +1 -0
  113. package/dist/modules/like/index.js +8 -0
  114. package/dist/modules/like/like.controller.d.ts +38 -0
  115. package/dist/modules/like/like.controller.js +119 -0
  116. package/dist/modules/like/like.module-options.d.ts +17 -0
  117. package/dist/modules/like/like.module-options.js +17 -0
  118. package/dist/modules/like/like.module.d.ts +18 -0
  119. package/dist/modules/like/like.module.js +45 -0
  120. package/dist/modules/like/like.service.d.ts +48 -0
  121. package/dist/modules/like/like.service.js +107 -0
  122. package/dist/modules/mail/index.d.ts +3 -0
  123. package/dist/modules/mail/index.js +10 -0
  124. package/dist/modules/mail/mail.models.d.ts +28 -0
  125. package/dist/modules/{services/mail-service/mail-service.definitions.js → mail/mail.models.js} +6 -0
  126. package/dist/modules/mail/mail.module.d.ts +12 -0
  127. package/dist/modules/mail/mail.module.js +34 -0
  128. package/dist/modules/mail/mail.service.d.ts +42 -0
  129. package/dist/modules/{services/mail-service → mail}/mail.service.js +34 -3
  130. package/dist/modules/search/index.d.ts +3 -0
  131. package/dist/modules/search/index.js +9 -0
  132. package/dist/modules/search/search.models.d.ts +19 -0
  133. package/dist/modules/{services/search-service/search-service.definitions.js → search/search.models.js} +9 -0
  134. package/dist/modules/search/search.module.d.ts +18 -0
  135. package/dist/modules/search/search.module.js +46 -0
  136. package/dist/modules/search/search.service.d.ts +35 -0
  137. package/dist/modules/{services/search-service → search}/search.service.js +44 -15
  138. package/dist/pipes/hid.pipe.d.ts +30 -0
  139. package/dist/pipes/hid.pipe.js +49 -5
  140. package/dist/pipes/id.pipe.d.ts +20 -0
  141. package/dist/pipes/id.pipe.js +40 -4
  142. package/dist/pipes/target.pipe.d.ts +23 -0
  143. package/dist/pipes/target.pipe.js +48 -6
  144. package/dist/schema.transformer.d.ts +2 -0
  145. package/dist/schema.transformer.js +10 -0
  146. package/dist/swagger.config.d.ts +36 -2
  147. package/dist/swagger.config.js +40 -3
  148. package/dist/transform/_trim.d.ts +7 -0
  149. package/dist/transform/_trim.js +16 -0
  150. package/dist/transform/index.d.ts +6 -0
  151. package/dist/transform/index.js +17 -0
  152. package/dist/transform/transformImage.d.ts +4 -0
  153. package/dist/transform/transformImage.js +16 -0
  154. package/dist/transform/transformString.d.ts +5 -0
  155. package/dist/transform/transformString.js +16 -0
  156. package/dist/transform/transformStringArray.d.ts +6 -0
  157. package/dist/transform/transformStringArray.js +24 -0
  158. package/dist/transform/transformStringLike.d.ts +20 -0
  159. package/dist/transform/transformStringLike.js +37 -0
  160. package/dist/transform/transformStringLowerCase.d.ts +5 -0
  161. package/dist/transform/transformStringLowerCase.js +16 -0
  162. package/dist/transform/transformStringSet.d.ts +6 -0
  163. package/dist/transform/transformStringSet.js +25 -0
  164. package/dist/virtuals.factory.d.ts +57 -0
  165. package/dist/virtuals.factory.js +117 -0
  166. package/package.json +3 -1
  167. package/dist/modules/services/account-service/account.service.d.ts +0 -8
  168. package/dist/modules/services/comment-service/comment-service.definitions.d.ts +0 -5
  169. package/dist/modules/services/comment-service/comment.service.d.ts +0 -12
  170. package/dist/modules/services/comment-service/comment.service.js +0 -75
  171. package/dist/modules/services/content-service/content.service.d.ts +0 -12
  172. package/dist/modules/services/index.d.ts +0 -9
  173. package/dist/modules/services/index.js +0 -22
  174. package/dist/modules/services/mail-service/mail-service.definitions.d.ts +0 -13
  175. package/dist/modules/services/mail-service/mail.service.d.ts +0 -11
  176. package/dist/modules/services/search-service/search-service.definitions.d.ts +0 -6
  177. package/dist/modules/services/search-service/search.service.d.ts +0 -11
  178. package/dist/modules/services/services.module-utils.d.ts +0 -7
  179. package/dist/modules/services/services.module.d.ts +0 -7
  180. package/dist/modules/services/services.module.js +0 -30
  181. package/dist/virtuals.d.ts +0 -8
  182. package/dist/virtuals.js +0 -77
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchService = exports.SearchModule = exports.SearchableDocument = void 0;
4
+ var search_models_1 = require("./search.models");
5
+ Object.defineProperty(exports, "SearchableDocument", { enumerable: true, get: function () { return search_models_1.SearchableDocument; } });
6
+ var search_module_1 = require("./search.module");
7
+ Object.defineProperty(exports, "SearchModule", { enumerable: true, get: function () { return search_module_1.SearchModule; } });
8
+ var search_service_1 = require("./search.service");
9
+ Object.defineProperty(exports, "SearchService", { enumerable: true, get: function () { return search_service_1.SearchService; } });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Represents a searchable document.
3
+ *
4
+ * @class SearchableDocument
5
+ * @property {string} label - The label of the searchable document.
6
+ * @property {string} url - The url of the searchable document.
7
+ * @property {number} timestamp - The timestamp of the searchable document.
8
+ * @property {object} data - The data of the searchable document.
9
+ */
10
+ export declare class SearchableDocument {
11
+ /** The label of the searchable document. */
12
+ label: string;
13
+ /** The url of the searchable document. */
14
+ url: string;
15
+ /** The timestamp of the searchable document. */
16
+ timestamp: number;
17
+ /** The data of the searchable document. */
18
+ data: object;
19
+ }
@@ -11,6 +11,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SearchableDocument = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
+ /**
15
+ * Represents a searchable document.
16
+ *
17
+ * @class SearchableDocument
18
+ * @property {string} label - The label of the searchable document.
19
+ * @property {string} url - The url of the searchable document.
20
+ * @property {number} timestamp - The timestamp of the searchable document.
21
+ * @property {object} data - The data of the searchable document.
22
+ */
14
23
  class SearchableDocument {
15
24
  }
16
25
  __decorate([
@@ -0,0 +1,18 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { Targets } from '../../pipes';
3
+ /**
4
+ * Search module
5
+ * @class SearchModule
6
+ */
7
+ export declare class SearchModule {
8
+ /**
9
+ * Creates a global SearchModule
10
+ * @returns {DynamicModule} SearchModule
11
+ */
12
+ static forRoot(target: Targets): DynamicModule;
13
+ /**
14
+ * Creates a local SearchModule
15
+ * @returns {DynamicModule} SearchModule
16
+ */
17
+ static register(target: Targets): DynamicModule;
18
+ }
@@ -0,0 +1,46 @@
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 SearchModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SearchModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const search_service_1 = require("./search.service");
13
+ /**
14
+ * Search module
15
+ * @class SearchModule
16
+ */
17
+ let SearchModule = SearchModule_1 = class SearchModule {
18
+ /**
19
+ * Creates a global SearchModule
20
+ * @returns {DynamicModule} SearchModule
21
+ */
22
+ static forRoot(target) {
23
+ return {
24
+ global: true,
25
+ module: SearchModule_1,
26
+ providers: [search_service_1.SearchService, { provide: 'SEARCH_TARGET', useValue: target }],
27
+ exports: [search_service_1.SearchService],
28
+ };
29
+ }
30
+ /**
31
+ * Creates a local SearchModule
32
+ * @returns {DynamicModule} SearchModule
33
+ */
34
+ static register(target) {
35
+ return {
36
+ global: true,
37
+ module: SearchModule_1,
38
+ providers: [search_service_1.SearchService, { provide: 'SEARCH_TARGET', useValue: target }],
39
+ exports: [search_service_1.SearchService],
40
+ };
41
+ }
42
+ };
43
+ SearchModule = SearchModule_1 = __decorate([
44
+ (0, common_1.Module)({})
45
+ ], SearchModule);
46
+ exports.SearchModule = SearchModule;
@@ -0,0 +1,35 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { Targets } from '../../pipes';
3
+ import { SearchableDocument } from './search.models';
4
+ /**
5
+ * Search service
6
+ * @class SearchService
7
+ */
8
+ export declare class SearchService {
9
+ private readonly configService;
10
+ private readonly target;
11
+ /** The Logger instance */
12
+ private logger;
13
+ /**
14
+ * Constructor
15
+ * @param configService - the config service
16
+ */
17
+ constructor(configService: ConfigService, target: Targets);
18
+ /** The axios instance */
19
+ private axios;
20
+ /**
21
+ * Index/Update a document in elasticsearch
22
+ *
23
+ * @param {string} targetId - the ID of the target
24
+ * @param {SearchableDocument} document - the document to be indexed/updated
25
+ * @return {void}
26
+ */
27
+ index(targetId: string, document: SearchableDocument): void;
28
+ /**
29
+ * Remove a document from elasticsearch
30
+ *
31
+ * @param {string} targetId - the ID of the target to be removed
32
+ * @return {void}
33
+ */
34
+ remove(targetId: string): void;
35
+ }
@@ -8,39 +8,68 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
11
14
  var SearchService_1;
12
15
  Object.defineProperty(exports, "__esModule", { value: true });
13
16
  exports.SearchService = void 0;
14
17
  const common_1 = require("@nestjs/common");
15
18
  const config_1 = require("@nestjs/config");
16
- const env_1 = require("../../../env");
17
- const services_module_utils_1 = require("../services.module-utils");
19
+ const axios_1 = require("../../axios");
20
+ const env_1 = require("../../env");
21
+ const pipes_1 = require("../../pipes");
22
+ /**
23
+ * Search service
24
+ * @class SearchService
25
+ */
18
26
  let SearchService = SearchService_1 = class SearchService {
19
- constructor(configService) {
27
+ /**
28
+ * Constructor
29
+ * @param configService - the config service
30
+ */
31
+ constructor(configService, target) {
20
32
  this.configService = configService;
33
+ this.target = target;
34
+ /** The Logger instance */
21
35
  this.logger = new common_1.Logger(SearchService_1.name);
22
- this.axios = (0, services_module_utils_1.createAxios)({
36
+ /** The axios instance */
37
+ this.axios = (0, axios_1.createAxios)({
23
38
  baseUrl: 'https://services.svi-itlab.com/search/internal/',
24
39
  k8sToken: this.configService.getOrThrow(env_1.ENV_K8S_TOKEN),
25
40
  });
26
41
  }
27
- index(targetId, document, target) {
28
- this.logger.log(`Indexing ${target} (${targetId})`);
42
+ /**
43
+ * Index/Update a document in elasticsearch
44
+ *
45
+ * @param {string} targetId - the ID of the target
46
+ * @param {SearchableDocument} document - the document to be indexed/updated
47
+ * @return {void}
48
+ */
49
+ index(targetId, document) {
50
+ this.logger.log(`Indexing ${this.target} (${targetId})`);
29
51
  this.axios
30
- .post(`${target}/${targetId}`, document)
31
- .then(() => this.logger.log(`Sucessfully indexed ${target} (${targetId})`))
32
- .catch(({ response }) => this.logger.error(`Couldn't index ${target} (${targetId})`, response.data));
52
+ .post(`${this.target}/${targetId}`, document)
53
+ .then(() => this.logger.log(`Sucessfully indexed ${this.target} (${targetId})`))
54
+ .catch(({ response }) => this.logger.error(`Couldn't index ${this.target} (${targetId})`, response.data));
33
55
  }
34
- remove(targetId, target) {
35
- this.logger.log(`Removing ${target} (${targetId})`);
56
+ /**
57
+ * Remove a document from elasticsearch
58
+ *
59
+ * @param {string} targetId - the ID of the target to be removed
60
+ * @return {void}
61
+ */
62
+ remove(targetId) {
63
+ this.logger.log(`Removing ${this.target} (${targetId})`);
36
64
  this.axios
37
- .delete(`${target}/${targetId}`)
38
- .then(() => this.logger.log(`Sucessfully removed ${target} (${targetId})`))
39
- .catch(({ response }) => this.logger.error(`Couldn't remove ${target} (${targetId})`, response.data));
65
+ .delete(`${this.target}/${targetId}`)
66
+ .then(() => this.logger.log(`Sucessfully removed ${this.target} (${targetId})`))
67
+ .catch(({ response }) => this.logger.error(`Couldn't remove ${this.target} (${targetId})`, response.data));
40
68
  }
41
69
  };
42
70
  SearchService = SearchService_1 = __decorate([
43
71
  (0, common_1.Injectable)(),
44
- __metadata("design:paramtypes", [config_1.ConfigService])
72
+ __param(1, (0, common_1.Inject)('SEARCH_TARGET')),
73
+ __metadata("design:paramtypes", [config_1.ConfigService, String])
45
74
  ], SearchService);
46
75
  exports.SearchService = SearchService;
@@ -1,9 +1,39 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ValidationOptions } from 'class-validator';
3
+ /**
4
+ * Custom exception for invalid HID.
5
+ */
3
6
  export declare class InvalidHidException extends HttpException {
7
+ /**
8
+ * Constructor for InvalidHidException.
9
+ * @param param - The parameter causing the exception.
10
+ */
4
11
  constructor(param: string);
5
12
  }
13
+ /**
14
+ * Used to parse a valid HID from the request parameters
15
+ * @param param - The parameter to use for the HID
16
+ * @returns The extracted HID
17
+ */
6
18
  export declare const Hid: (param: string) => ParameterDecorator;
19
+ /**
20
+ * Creates an ApiHid decorator with the given parameter
21
+ *
22
+ * @param {string} param - the parameter for the API HID
23
+ * @return A decorator that creates an API HID with the given parameter
24
+ */
7
25
  export declare const ApiHid: (param: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
26
+ /**
27
+ * Check if the given value is a valid hub ID.
28
+ *
29
+ * @param {unknown} value - the value to be checked
30
+ * @return {boolean} true if the value is a valid hub ID, false otherwise
31
+ */
8
32
  export declare function isHubID(value: unknown): boolean;
33
+ /**
34
+ * A decorator that validates whether the value is a valid HubID.
35
+ *
36
+ * @param {ValidationOptions} validationOptions - optional validation options
37
+ * @return {PropertyDecorator} a decorator function
38
+ */
9
39
  export declare function IsHubID(validationOptions?: ValidationOptions): PropertyDecorator;
@@ -5,27 +5,59 @@ const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const class_validator_1 = require("class-validator");
7
7
  const itlab_functions_1 = require("itlab-functions");
8
+ /** Description for invalid HIDs */
8
9
  const description = 'Invalid parameter';
10
+ /** Status code for invalid HIDs */
9
11
  const status = common_1.HttpStatus.BAD_REQUEST;
12
+ /**
13
+ * ParseHidPipe class to transform input value to string
14
+ */
10
15
  class ParseHidPipe {
16
+ /**
17
+ * Constructor for ParseHidPipe
18
+ * @param param - The parameter for the pipe
19
+ */
11
20
  constructor(param) {
12
21
  this.param = param;
13
22
  }
23
+ /**
24
+ * Transform method to transform the input value to string if it is a valid HID
25
+ * @param value - The input value to be transformed
26
+ * @returns The transformed string value
27
+ * @throws InvalidHidException if the input value is invalid
28
+ */
14
29
  transform(value) {
15
- const isString = typeof value === 'string' || value instanceof String;
16
- if (isString && (0, itlab_functions_1.isID)(value.toString()))
17
- return value.toString();
30
+ if (isHubID(value))
31
+ return String(value);
18
32
  throw new InvalidHidException(this.param);
19
33
  }
20
34
  }
35
+ /**
36
+ * Custom exception for invalid HID.
37
+ */
21
38
  class InvalidHidException extends common_1.HttpException {
39
+ /**
40
+ * Constructor for InvalidHidException.
41
+ * @param param - The parameter causing the exception.
42
+ */
22
43
  constructor(param) {
23
44
  super(`${description} '${param}'`, status);
24
45
  }
25
46
  }
26
47
  exports.InvalidHidException = InvalidHidException;
48
+ /**
49
+ * Used to parse a valid HID from the request parameters
50
+ * @param param - The parameter to use for the HID
51
+ * @returns The extracted HID
52
+ */
27
53
  const Hid = (param) => (0, common_1.Param)(param, new ParseHidPipe(param));
28
54
  exports.Hid = Hid;
55
+ /**
56
+ * Creates an ApiHid decorator with the given parameter
57
+ *
58
+ * @param {string} param - the parameter for the API HID
59
+ * @return A decorator that creates an API HID with the given parameter
60
+ */
29
61
  const ApiHid = (param) => (0, common_1.applyDecorators)((0, swagger_1.ApiParam)({
30
62
  name: param,
31
63
  example: 'hallo-welt',
@@ -35,15 +67,27 @@ const ApiHid = (param) => (0, common_1.applyDecorators)((0, swagger_1.ApiParam)(
35
67
  },
36
68
  }), (0, swagger_1.ApiResponse)({ description, status }));
37
69
  exports.ApiHid = ApiHid;
70
+ /**
71
+ * Check if the given value is a valid hub ID.
72
+ *
73
+ * @param {unknown} value - the value to be checked
74
+ * @return {boolean} true if the value is a valid hub ID, false otherwise
75
+ */
38
76
  function isHubID(value) {
39
- return typeof value === 'string' && (0, itlab_functions_1.isID)(value);
77
+ return (0, class_validator_1.isString)(value) && (0, itlab_functions_1.isID)(String(value));
40
78
  }
41
79
  exports.isHubID = isHubID;
80
+ /**
81
+ * A decorator that validates whether the value is a valid HubID.
82
+ *
83
+ * @param {ValidationOptions} validationOptions - optional validation options
84
+ * @return {PropertyDecorator} a decorator function
85
+ */
42
86
  function IsHubID(validationOptions) {
43
87
  return (0, class_validator_1.ValidateBy)({
44
88
  name: 'isHubID',
45
89
  validator: {
46
- validate: (value, args) => isHubID(value),
90
+ validate: (value) => isHubID(value),
47
91
  defaultMessage: (0, class_validator_1.buildMessage)((eachPrefix) => eachPrefix + '$property ist keine gültige HubID', validationOptions),
48
92
  },
49
93
  }, validationOptions);
@@ -1,6 +1,26 @@
1
1
  import { HttpException } from '@nestjs/common';
2
+ /**
3
+ * Custom exception for invalid ID
4
+ * @class InvalidIdException
5
+ * @extends {HttpException}
6
+ */
2
7
  export declare class InvalidIdException extends HttpException {
8
+ /**
9
+ * Constructor for InvalidIdException
10
+ * @param param - The invalid ID parameter
11
+ */
3
12
  constructor(param: string);
4
13
  }
14
+ /**
15
+ * Used to parse a valid ID from the request parameters
16
+ * @param param - The parameter to use for the ID
17
+ * @returns The extracted ID
18
+ */
5
19
  export declare const Id: (param: string) => ParameterDecorator;
20
+ /**
21
+ * Creates an ApiId decorator with the given parameter
22
+ *
23
+ * @param {string} param - the parameter for the API ID
24
+ * @return A decorator that creates an API ID with the given parameter
25
+ */
6
26
  export declare const ApiId: (param: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -3,27 +3,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiId = exports.Id = exports.InvalidIdException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
+ const class_validator_1 = require("class-validator");
7
+ /** Description for invalid IDs */
6
8
  const description = 'Invalid parameter';
9
+ /** Status code for invalid IDs */
7
10
  const status = common_1.HttpStatus.BAD_REQUEST;
11
+ /**
12
+ * ParseIdPipe class for transforming input value to string
13
+ * @class ParseIdPipe
14
+ * @implements {PipeTransform<unknown, string>}
15
+ */
8
16
  class ParseIdPipe {
17
+ /**
18
+ * Constructor for ParseIdPipe
19
+ * @param param - the parameter for the pipe
20
+ */
9
21
  constructor(param) {
10
22
  this.param = param;
11
23
  }
24
+ /**
25
+ * Transform function to transform input value to string if it is a valid Mongo ID
26
+ * @param value - the input value to be transformed
27
+ * @returns the transformed value as a string
28
+ * @throws InvalidIdException if the input value is not a valid Mongo ID
29
+ */
12
30
  transform(value) {
13
- const isString = typeof value === 'string' || value instanceof String;
14
- const isMongoId = /^(0x|0h)?[0-9A-F]+$/i.test(value) && value.length === 24;
15
- if (isString && isMongoId)
16
- return value.toString();
31
+ if ((0, class_validator_1.isMongoId)(value))
32
+ return String(value);
17
33
  throw new InvalidIdException(this.param);
18
34
  }
19
35
  }
36
+ /**
37
+ * Custom exception for invalid ID
38
+ * @class InvalidIdException
39
+ * @extends {HttpException}
40
+ */
20
41
  class InvalidIdException extends common_1.HttpException {
42
+ /**
43
+ * Constructor for InvalidIdException
44
+ * @param param - The invalid ID parameter
45
+ */
21
46
  constructor(param) {
22
47
  super(`${description} '${param}'`, status);
23
48
  }
24
49
  }
25
50
  exports.InvalidIdException = InvalidIdException;
51
+ /**
52
+ * Used to parse a valid ID from the request parameters
53
+ * @param param - The parameter to use for the ID
54
+ * @returns The extracted ID
55
+ */
26
56
  const Id = (param) => (0, common_1.Param)(param, new ParseIdPipe(param));
27
57
  exports.Id = Id;
58
+ /**
59
+ * Creates an ApiId decorator with the given parameter
60
+ *
61
+ * @param {string} param - the parameter for the API ID
62
+ * @return A decorator that creates an API ID with the given parameter
63
+ */
28
64
  const ApiId = (param) => (0, common_1.applyDecorators)((0, swagger_1.ApiParam)({ name: param, example: ''.padEnd(24, '0') }), (0, swagger_1.ApiResponse)({ description, status }));
29
65
  exports.ApiId = ApiId;
@@ -1,4 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
+ /**
3
+ * Enum representing various targets in the application
4
+ */
2
5
  export declare enum Targets {
3
6
  NEWSROOM = "news",
4
7
  EVENTS = "event",
@@ -14,8 +17,28 @@ export declare enum Targets {
14
17
  HUB_USER = "hub-user",
15
18
  HUB_FILE = "hub-file"
16
19
  }
20
+ /**
21
+ * Custom exception for invalid targets
22
+ * @class InvalidTargetException
23
+ * @extends {HttpException}
24
+ */
17
25
  export declare class InvalidTargetException extends HttpException {
26
+ /**
27
+ * Constructor for InvalidTargetException
28
+ * @param param - The parameter causing the exception
29
+ */
18
30
  constructor(param: string);
19
31
  }
32
+ /**
33
+ * Used to parse a valid target from the request parameters
34
+ * @param param - The parameter to use for the target
35
+ * @returns The extracted target
36
+ */
20
37
  export declare const Target: (param: string) => ParameterDecorator;
38
+ /**
39
+ * Creates an ApiTarget decorator with the given parameter
40
+ *
41
+ * @param {string} param - the parameter for the API target
42
+ * @return A decorator that creates an API target with the given parameter
43
+ */
21
44
  export declare const ApiTarget: (param: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiTarget = exports.Target = exports.InvalidTargetException = exports.Targets = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
+ /**
7
+ * Enum representing various targets in the application
8
+ */
6
9
  var Targets;
7
10
  (function (Targets) {
8
11
  Targets["NEWSROOM"] = "news";
@@ -19,30 +22,69 @@ var Targets;
19
22
  Targets["HUB_USER"] = "hub-user";
20
23
  Targets["HUB_FILE"] = "hub-file";
21
24
  })(Targets = exports.Targets || (exports.Targets = {}));
22
- function generateExamples() {
23
- const map = {};
24
- Object.entries(Targets).forEach(([value, key]) => (map[key] = { value }));
25
- return map;
26
- }
25
+ /** Description for invalid targets */
27
26
  const description = 'Invalid parameter';
27
+ /** Status code for invalid targets */
28
28
  const status = common_1.HttpStatus.BAD_REQUEST;
29
+ /**
30
+ * This class represents a custom pipe to transform Targets to string.
31
+ * @class ParseTargetPipe
32
+ * @implements {PipeTransform<Targets, string>}
33
+ */
29
34
  class ParseTargetPipe {
35
+ /**
36
+ * Creates an instance of ParseTargetPipe.
37
+ * @param param - The parameter for the pipe.
38
+ */
30
39
  constructor(param) {
31
40
  this.param = param;
32
41
  }
42
+ /**
43
+ * Transforms the given value to a string.
44
+ * @param {Targets} value - The value to be transformed.
45
+ * @returns {string} The transformed string.
46
+ * @throws InvalidTargetException if the value is not a valid target.
47
+ */
33
48
  transform(value) {
34
49
  if (Object.values(Targets).includes(value))
35
50
  return value;
36
51
  throw new InvalidTargetException(this.param);
37
52
  }
38
53
  }
54
+ /**
55
+ * Custom exception for invalid targets
56
+ * @class InvalidTargetException
57
+ * @extends {HttpException}
58
+ */
39
59
  class InvalidTargetException extends common_1.HttpException {
60
+ /**
61
+ * Constructor for InvalidTargetException
62
+ * @param param - The parameter causing the exception
63
+ */
40
64
  constructor(param) {
41
65
  super(`${description} '${param}'`, status);
42
66
  }
43
67
  }
44
68
  exports.InvalidTargetException = InvalidTargetException;
69
+ /**
70
+ * Used to parse a valid target from the request parameters
71
+ * @param param - The parameter to use for the target
72
+ * @returns The extracted target
73
+ */
45
74
  const Target = (param) => (0, common_1.Param)(param, new ParseTargetPipe(param));
46
75
  exports.Target = Target;
47
- const ApiTarget = (param) => (0, common_1.applyDecorators)((0, swagger_1.ApiParam)({ name: param, example: Targets.NEWSROOM, examples: generateExamples() }), (0, swagger_1.ApiResponse)({ description, status }));
76
+ /**
77
+ * Creates an ApiTarget decorator with the given parameter
78
+ *
79
+ * @param {string} param - the parameter for the API target
80
+ * @return A decorator that creates an API target with the given parameter
81
+ */
82
+ const ApiTarget = (param) => (0, common_1.applyDecorators)((0, swagger_1.ApiParam)({
83
+ name: param,
84
+ example: Targets.NEWSROOM,
85
+ examples: Object.entries(Targets).reduce((map, [value, key]) => {
86
+ map[key] = { value };
87
+ return map;
88
+ }, {}),
89
+ }), (0, swagger_1.ApiResponse)({ description, status }));
48
90
  exports.ApiTarget = ApiTarget;
@@ -0,0 +1,2 @@
1
+ import { ToObjectOptions } from 'mongoose';
2
+ export declare function SchemaTransformer<T, R = T>(transformer: (doc: T) => R): ToObjectOptions;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaTransformer = void 0;
4
+ function SchemaTransformer(transformer) {
5
+ return {
6
+ virtuals: true,
7
+ transform: (_, ret) => transformer(ret),
8
+ };
9
+ }
10
+ exports.SchemaTransformer = SchemaTransformer;
@@ -1,13 +1,47 @@
1
1
  import { INestApplication } from '@nestjs/common';
2
2
  import { DocumentBuilder, OpenAPIObject } from '@nestjs/swagger';
3
- export interface SwaggerOptions {
3
+ /**
4
+ * Class representing Swagger options.
5
+ *
6
+ * @class SwaggerOptions
7
+ *
8
+ * @property {string} title - Title of the Swagger documentation.
9
+ * @property {string} description - Description of the Swagger documentation.
10
+ * @property {boolean} jwt - Whether JWT authentication is enabled.
11
+ * @property {boolean} k8s - Whether Kubernetes integration is enabled.
12
+ */
13
+ export declare class SwaggerOptions {
14
+ /** Title of the Swagger documentation. */
4
15
  title: string;
16
+ /** Description of the Swagger documentation. */
5
17
  description: string;
18
+ /** Whether JWT authentication is enabled. */
6
19
  jwt?: boolean;
20
+ /** Whether Kubernetes integration is enabled. */
7
21
  k8s?: boolean;
8
22
  }
23
+ /** Type representing the Swagger configuration. */
9
24
  declare type SwaggerConfig = Omit<OpenAPIObject, 'paths'>;
25
+ /**
26
+ * Retrieves the Swagger configuration.
27
+ *
28
+ * @param {SwaggerOptions} options - optional options for Swagger
29
+ * @return {SwaggerConfig} the Swagger configuration
30
+ */
10
31
  export declare function getSwaggerConfig(options?: SwaggerOptions): SwaggerConfig;
11
- export declare function getSwaggerDocument(options?: SwaggerOptions): DocumentBuilder;
32
+ /**
33
+ * Returns a Swagger document builder with the specified options.
34
+ *
35
+ * @param {SwaggerOptions} options - optional Swagger options
36
+ * @return {DocumentBuilder} the constructed Swagger document builder
37
+ */
38
+ export declare function getSwaggerDocument(options: SwaggerOptions): DocumentBuilder;
39
+ /**
40
+ * Initializes and configures Swagger for the given Nest application.
41
+ *
42
+ * @param {INestApplication} app - The Nest application instance
43
+ * @param {SwaggerOptions} [options] - Optional Swagger configuration options
44
+ * @return {void}
45
+ */
12
46
  export declare function useSwagger(app: INestApplication, options?: SwaggerOptions): void;
13
47
  export {};