itlab-internal-services 2.3.0 → 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 (69) hide show
  1. package/dist/{modules/services/services.module-utils.js → axios.js} +1 -1
  2. package/dist/exceptions/bad-body.exception.d.ts +8 -1
  3. package/dist/exceptions/bad-body.exception.js +26 -1
  4. package/dist/exceptions/duplicate.exception.d.ts +8 -1
  5. package/dist/exceptions/duplicate.exception.js +26 -1
  6. package/dist/exceptions/index.d.ts +7 -0
  7. package/dist/exceptions/not-found.exception.d.ts +8 -1
  8. package/dist/exceptions/not-found.exception.js +26 -1
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.js +2 -1
  11. package/dist/modules/account/account.module.d.ts +12 -0
  12. package/dist/modules/account/account.module.js +34 -0
  13. package/dist/modules/{services/account-service → account}/account.service.js +3 -3
  14. package/dist/modules/account/index.d.ts +2 -0
  15. package/dist/modules/account/index.js +7 -0
  16. package/dist/modules/authentication/authentication.module.d.ts +3 -12
  17. package/dist/modules/authentication/authentication.module.js +4 -6
  18. package/dist/modules/authentication/index.d.ts +1 -1
  19. package/dist/modules/comment/comment.controller.d.ts +24 -0
  20. package/dist/modules/comment/comment.controller.js +78 -0
  21. package/dist/modules/{services/comment-service/comment-service.definitions.d.ts → comment/comment.module-options.d.ts} +2 -0
  22. package/dist/modules/{services/comment-service/comment-service.definitions.js → comment/comment.module-options.js} +2 -0
  23. package/dist/modules/comment/comment.module.d.ts +19 -0
  24. package/dist/modules/comment/comment.module.js +57 -0
  25. package/dist/modules/comment/comment.service.d.ts +42 -0
  26. package/dist/modules/comment/comment.service.js +113 -0
  27. package/dist/modules/comment/index.d.ts +3 -0
  28. package/dist/modules/comment/index.js +12 -0
  29. package/dist/modules/content/content.module.d.ts +18 -0
  30. package/dist/modules/content/content.module.js +46 -0
  31. package/dist/modules/{services/content-service → content}/content.service.d.ts +5 -6
  32. package/dist/modules/{services/content-service → content}/content.service.js +21 -17
  33. package/dist/modules/content/index.d.ts +2 -0
  34. package/dist/modules/content/index.js +7 -0
  35. package/dist/modules/index.d.ts +5 -1
  36. package/dist/modules/index.js +5 -1
  37. package/dist/modules/like/like.module.d.ts +1 -1
  38. package/dist/modules/like/like.module.js +2 -2
  39. package/dist/modules/mail/index.d.ts +3 -0
  40. package/dist/modules/mail/index.js +10 -0
  41. package/dist/modules/mail/mail.module.d.ts +12 -0
  42. package/dist/modules/mail/mail.module.js +34 -0
  43. package/dist/modules/{services/mail-service → mail}/mail.service.d.ts +1 -1
  44. package/dist/modules/{services/mail-service → mail}/mail.service.js +3 -3
  45. package/dist/modules/search/index.d.ts +3 -0
  46. package/dist/modules/search/index.js +9 -0
  47. package/dist/modules/search/search.module.d.ts +18 -0
  48. package/dist/modules/search/search.module.js +46 -0
  49. package/dist/modules/{services/search-service → search}/search.service.d.ts +6 -7
  50. package/dist/modules/{services/search-service → search}/search.service.js +21 -17
  51. package/dist/schema.transformer.d.ts +2 -0
  52. package/dist/schema.transformer.js +10 -0
  53. package/dist/virtuals.factory.d.ts +57 -0
  54. package/dist/virtuals.factory.js +117 -0
  55. package/package.json +1 -1
  56. package/dist/modules/services/comment-service/comment.service.d.ts +0 -38
  57. package/dist/modules/services/comment-service/comment.service.js +0 -101
  58. package/dist/modules/services/index.d.ts +0 -9
  59. package/dist/modules/services/index.js +0 -40
  60. package/dist/modules/services/services.module.d.ts +0 -24
  61. package/dist/modules/services/services.module.js +0 -39
  62. package/dist/virtuals.d.ts +0 -51
  63. package/dist/virtuals.js +0 -121
  64. /package/dist/{modules/services/services.module-utils.d.ts → axios.d.ts} +0 -0
  65. /package/dist/modules/{services/account-service → account}/account.service.d.ts +0 -0
  66. /package/dist/modules/{services/mail-service/mail-service.definitions.d.ts → mail/mail.models.d.ts} +0 -0
  67. /package/dist/modules/{services/mail-service/mail-service.definitions.js → mail/mail.models.js} +0 -0
  68. /package/dist/modules/{services/search-service/search-service.definitions.d.ts → search/search.models.d.ts} +0 -0
  69. /package/dist/modules/{services/search-service/search-service.definitions.js → search/search.models.js} +0 -0
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createAxios = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const internal_constants_1 = require("../authentication/internal/internal.constants");
8
+ const internal_constants_1 = require("./modules/authentication/internal/internal.constants");
9
9
  /**
10
10
  * Create an axios instance
11
11
  * @param options - the options for the axios instance
@@ -1,4 +1,4 @@
1
- import { ErrorException } from '.';
1
+ import { ErrorException, UseException } from '.';
2
2
  /**
3
3
  * Custom exception for bad request body
4
4
  * @class BadBodyException
@@ -17,3 +17,10 @@ export declare class BadBodyException extends ErrorException {
17
17
  * @returns A decorator that creates an API bad body
18
18
  */
19
19
  export declare const ApiBadBody: (description?: string) => MethodDecorator & ClassDecorator;
20
+ /**
21
+ * Creates a bad body exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
22
+ *
23
+ * @param {string} description - The description for the bad body exception
24
+ * @return {UseException<typeof BadBodyException>} An array containing the Exception class and the ApiDecorator function
25
+ */
26
+ export declare function useBadBodyException(description?: string): UseException<typeof BadBodyException>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiBadBody = exports.BadBodyException = void 0;
3
+ exports.useBadBodyException = exports.ApiBadBody = exports.BadBodyException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const _1 = require(".");
@@ -30,3 +30,28 @@ exports.BadBodyException = BadBodyException;
30
30
  */
31
31
  const ApiBadBody = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
32
32
  exports.ApiBadBody = ApiBadBody;
33
+ /**
34
+ * Creates a bad body exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
35
+ *
36
+ * @param {string} description - The description for the bad body exception
37
+ * @return {UseException<typeof BadBodyException>} An array containing the Exception class and the ApiDecorator function
38
+ */
39
+ function useBadBodyException(description = error) {
40
+ /**
41
+ * Creates a bad body exception with the given description
42
+ * @class Exception
43
+ * @extends {BadBodyException}
44
+ */
45
+ class Exception extends BadBodyException {
46
+ /**
47
+ * Constructor for BadBodyException.
48
+ * @param desc - Description of the error.
49
+ */
50
+ constructor(desc = description) {
51
+ super(desc);
52
+ }
53
+ }
54
+ // Return an array containing the Exception class and the ApiDecorator function
55
+ return [Exception, () => (0, exports.ApiBadBody)(description)];
56
+ }
57
+ exports.useBadBodyException = useBadBodyException;
@@ -1,4 +1,4 @@
1
- import { ErrorException } from '.';
1
+ import { ErrorException, UseException } from '.';
2
2
  /**
3
3
  * Represents an exception for duplicate errors.
4
4
  * @class DuplicateException
@@ -17,3 +17,10 @@ export declare class DuplicateException extends ErrorException {
17
17
  * @returns A decorator that creates an API duplicate
18
18
  */
19
19
  export declare const ApiDuplicate: (description?: string) => MethodDecorator & ClassDecorator;
20
+ /**
21
+ * Creates a duplicate exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
22
+ *
23
+ * @param {string} description - The description for the duplicate exception
24
+ * @return {UseException<typeof DuplicateException>} An array containing the Exception class and the ApiDecorator function
25
+ */
26
+ export declare function useDuplicateException(description?: string): UseException<typeof DuplicateException>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiDuplicate = exports.DuplicateException = void 0;
3
+ exports.useDuplicateException = exports.ApiDuplicate = exports.DuplicateException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const _1 = require(".");
@@ -30,3 +30,28 @@ exports.DuplicateException = DuplicateException;
30
30
  */
31
31
  const ApiDuplicate = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
32
32
  exports.ApiDuplicate = ApiDuplicate;
33
+ /**
34
+ * Creates a duplicate exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
35
+ *
36
+ * @param {string} description - The description for the duplicate exception
37
+ * @return {UseException<typeof DuplicateException>} An array containing the Exception class and the ApiDecorator function
38
+ */
39
+ function useDuplicateException(description = error) {
40
+ /**
41
+ * Creates a duplicate exception with the given description
42
+ * @class Exception
43
+ * @extends {DuplicateException}
44
+ */
45
+ class Exception extends DuplicateException {
46
+ /**
47
+ * Constructor for DuplicateException.
48
+ * @param desc - Description of the error.
49
+ */
50
+ constructor(desc = description) {
51
+ super(desc);
52
+ }
53
+ }
54
+ // Return an array containing the Exception class and the ApiDecorator function
55
+ return [Exception, () => (0, exports.ApiDuplicate)(description)];
56
+ }
57
+ exports.useDuplicateException = useDuplicateException;
@@ -13,6 +13,13 @@ export declare class ErrorException extends HttpException {
13
13
  */
14
14
  constructor(error: string, status: number, description?: string);
15
15
  }
16
+ /**
17
+ * Type representing the use of an exception
18
+ * @typedef {Array} UseException
19
+ * @property {typeof ErrorException} 0 - The type of error exception
20
+ * @property {Function} 1 - The method and class decorator
21
+ */
22
+ export declare type UseException<T> = [T, () => MethodDecorator & ClassDecorator];
16
23
  export * from './bad-body.exception';
17
24
  export * from './duplicate.exception';
18
25
  export * from './not-found.exception';
@@ -1,4 +1,4 @@
1
- import { ErrorException } from '.';
1
+ import { ErrorException, UseException } from '.';
2
2
  /**
3
3
  * Custom exception for not found errors.
4
4
  * @class NotFoundException
@@ -17,3 +17,10 @@ export declare class NotFoundException extends ErrorException {
17
17
  * @returns A decorator that creates an API not found
18
18
  */
19
19
  export declare const ApiNotFound: (description?: string) => MethodDecorator & ClassDecorator;
20
+ /**
21
+ * Creates a not found exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
22
+ *
23
+ * @param {string} description - The description for the not found exception
24
+ * @return {UseException<typeof NotFoundException>} An array containing the Exception class and the ApiDecorator function
25
+ */
26
+ export declare function useNotFoundException(description?: string): UseException<typeof NotFoundException>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiNotFound = exports.NotFoundException = void 0;
3
+ exports.useNotFoundException = exports.ApiNotFound = exports.NotFoundException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const _1 = require(".");
@@ -30,3 +30,28 @@ exports.NotFoundException = NotFoundException;
30
30
  */
31
31
  const ApiNotFound = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
32
32
  exports.ApiNotFound = ApiNotFound;
33
+ /**
34
+ * Creates a not found exception with the given description and returns an array containing the Exception class and the ApiDecorator function.
35
+ *
36
+ * @param {string} description - The description for the not found exception
37
+ * @return {UseException<typeof NotFoundException>} An array containing the Exception class and the ApiDecorator function
38
+ */
39
+ function useNotFoundException(description = error) {
40
+ /**
41
+ * Creates a not found exception with the given description
42
+ * @class Exception
43
+ * @extends {NotFoundException}
44
+ */
45
+ class Exception extends NotFoundException {
46
+ /**
47
+ * Constructor for NotFoundException.
48
+ * @param desc - Description of the error.
49
+ */
50
+ constructor(desc = description) {
51
+ super(desc);
52
+ }
53
+ }
54
+ // Return an array containing the Exception class and the ApiDecorator function
55
+ return [Exception, () => (0, exports.ApiNotFound)(description)];
56
+ }
57
+ exports.useNotFoundException = useNotFoundException;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './liveness.probe';
7
7
  export * from './models';
8
8
  export * from './modules';
9
9
  export * from './pipes';
10
+ export * from './schema.transformer';
10
11
  export * from './swagger.config';
11
12
  export * from './transform';
12
- export * from './virtuals';
13
+ export * from './virtuals.factory';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./liveness.probe"), exports);
23
23
  __exportStar(require("./models"), exports);
24
24
  __exportStar(require("./modules"), exports);
25
25
  __exportStar(require("./pipes"), exports);
26
+ __exportStar(require("./schema.transformer"), exports);
26
27
  __exportStar(require("./swagger.config"), exports);
27
28
  __exportStar(require("./transform"), exports);
28
- __exportStar(require("./virtuals"), exports);
29
+ __exportStar(require("./virtuals.factory"), exports);
@@ -0,0 +1,12 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ /**
3
+ * Account module
4
+ * @class AccountModule
5
+ */
6
+ export declare class AccountModule {
7
+ /**
8
+ * Creates a global AccountModule
9
+ * @returns {DynamicModule} AccountModule
10
+ */
11
+ static forRoot(): DynamicModule;
12
+ }
@@ -0,0 +1,34 @@
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 AccountModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AccountModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const account_service_1 = require("./account.service");
13
+ /**
14
+ * Account module
15
+ * @class AccountModule
16
+ */
17
+ let AccountModule = AccountModule_1 = class AccountModule {
18
+ /**
19
+ * Creates a global AccountModule
20
+ * @returns {DynamicModule} AccountModule
21
+ */
22
+ static forRoot() {
23
+ return {
24
+ global: true,
25
+ module: AccountModule_1,
26
+ providers: [account_service_1.AccountService],
27
+ exports: [account_service_1.AccountService],
28
+ };
29
+ }
30
+ };
31
+ AccountModule = AccountModule_1 = __decorate([
32
+ (0, common_1.Module)({})
33
+ ], AccountModule);
34
+ exports.AccountModule = AccountModule;
@@ -21,8 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.AccountService = void 0;
22
22
  const common_1 = require("@nestjs/common");
23
23
  const config_1 = require("@nestjs/config");
24
- const env_1 = require("../../../env");
25
- const services_module_utils_1 = require("../services.module-utils");
24
+ const axios_1 = require("../../axios");
25
+ const env_1 = require("../../env");
26
26
  /**
27
27
  * Account service
28
28
  * @class AccountService
@@ -35,7 +35,7 @@ let AccountService = class AccountService {
35
35
  constructor(configService) {
36
36
  this.configService = configService;
37
37
  /** The axios instance */
38
- this.axios = (0, services_module_utils_1.createAxios)({
38
+ this.axios = (0, axios_1.createAxios)({
39
39
  baseUrl: 'https://services.svi-itlab.com/account/internal/',
40
40
  k8sToken: this.configService.getOrThrow(env_1.ENV_K8S_TOKEN),
41
41
  });
@@ -0,0 +1,2 @@
1
+ export { AccountModule } from './account.module';
2
+ export { AccountService } from './account.service';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountService = exports.AccountModule = void 0;
4
+ var account_module_1 = require("./account.module");
5
+ Object.defineProperty(exports, "AccountModule", { enumerable: true, get: function () { return account_module_1.AccountModule; } });
6
+ var account_service_1 = require("./account.service");
7
+ Object.defineProperty(exports, "AccountService", { enumerable: true, get: function () { return account_service_1.AccountService; } });
@@ -1,21 +1,12 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- export interface AuthenticationModuleOptions {
3
- /**
4
- * If "true", registers `AuthenticationModule` as a global module.
5
- * See: https://docs.nestjs.com/modules#global-modules
6
- */
7
- isGlobal?: boolean;
8
- }
9
2
  /**
10
3
  * Authentication module
11
4
  * @class AuthenticationModule
12
5
  */
13
6
  export declare class AuthenticationModule {
14
7
  /**
15
- * Create a new module with the provided options.
16
- *
17
- * @param {AuthenticationModuleOptions} options - optional options for the authentication module
18
- * @return {DynamicModule} the newly created dynamic module
8
+ * Creates a new global AuthenticationModule
9
+ * @return {DynamicModule} AuthenticationModule
19
10
  */
20
- static forRoot(options?: AuthenticationModuleOptions): DynamicModule;
11
+ static forRoot(): DynamicModule;
21
12
  }
@@ -17,14 +17,12 @@ const jwt_strategy_1 = require("./jwt/jwt.strategy");
17
17
  */
18
18
  let AuthenticationModule = AuthenticationModule_1 = class AuthenticationModule {
19
19
  /**
20
- * Create a new module with the provided options.
21
- *
22
- * @param {AuthenticationModuleOptions} options - optional options for the authentication module
23
- * @return {DynamicModule} the newly created dynamic module
20
+ * Creates a new global AuthenticationModule
21
+ * @return {DynamicModule} AuthenticationModule
24
22
  */
25
- static forRoot(options) {
23
+ static forRoot() {
26
24
  return {
27
- global: options ? options.isGlobal : false,
25
+ global: true,
28
26
  module: AuthenticationModule_1,
29
27
  providers: [internal_strategy_1.InternalStrategy, jwt_strategy_1.JwtStrategy],
30
28
  };
@@ -1,3 +1,3 @@
1
- export { AuthenticationModule, AuthenticationModuleOptions } from './authentication.module';
1
+ export { AuthenticationModule } from './authentication.module';
2
2
  export * from './internal';
3
3
  export * from './jwt';
@@ -0,0 +1,24 @@
1
+ import { ContentRichtext } from 'itlab-functions';
2
+ import { Comment } from './comment.module-options';
3
+ import { CommentService } from './comment.service';
4
+ /**
5
+ * @class CommentController
6
+ * @description This class handles operations related to adding, removing, and checking likes for specific targets.
7
+ * @author Timo Scheuermann
8
+ */
9
+ export declare class CommentController {
10
+ private readonly commentService;
11
+ /**
12
+ * @constructor Constructor for the CommentController class
13
+ * @param {CommentService} commentService - The injected service for comments
14
+ */
15
+ constructor(commentService: CommentService);
16
+ /**
17
+ * Add a comment to the specified target by the given account.
18
+ *
19
+ * @param {string} targetId - The ID of the target to add the comment to
20
+ * @param {string} accountId - The ID of the account adding the comment
21
+ * @param {ContentRichtext} comment - The comment to add
22
+ */
23
+ postComment(targetId: string, accountId: string, comment: ContentRichtext): Promise<Comment>;
24
+ }
@@ -0,0 +1,78 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.CommentController = void 0;
25
+ const common_1 = require("@nestjs/common");
26
+ const swagger_1 = require("@nestjs/swagger");
27
+ const exceptions_1 = require("../../exceptions");
28
+ const pipes_1 = require("../../pipes");
29
+ const authentication_1 = require("../authentication");
30
+ const comment_module_options_1 = require("./comment.module-options");
31
+ const comment_service_1 = require("./comment.service");
32
+ /**
33
+ * @class CommentController
34
+ * @description This class handles operations related to adding, removing, and checking likes for specific targets.
35
+ * @author Timo Scheuermann
36
+ */
37
+ let CommentController = class CommentController {
38
+ /**
39
+ * @constructor Constructor for the CommentController class
40
+ * @param {CommentService} commentService - The injected service for comments
41
+ */
42
+ constructor(commentService) {
43
+ this.commentService = commentService;
44
+ }
45
+ /**
46
+ * Add a comment to the specified target by the given account.
47
+ *
48
+ * @param {string} targetId - The ID of the target to add the comment to
49
+ * @param {string} accountId - The ID of the account adding the comment
50
+ * @param {ContentRichtext} comment - The comment to add
51
+ */
52
+ postComment(targetId, accountId, comment) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return this.commentService.postComment(targetId, accountId, comment);
55
+ });
56
+ }
57
+ };
58
+ __decorate([
59
+ (0, swagger_1.ApiOperation)({ description: 'Speichert ein Kommentar zum angegeben Target' }),
60
+ (0, swagger_1.ApiResponse)({ description: 'Der gespeicherte Kommentar', status: common_1.HttpStatus.OK, type: comment_module_options_1.Comment }),
61
+ (0, swagger_1.ApiBody)({ description: 'Der zu speichernde Kommentar' }),
62
+ (0, exceptions_1.ApiBadBody)('Validierung des Kommentars fehlgeschlagen'),
63
+ (0, pipes_1.ApiId)('targetId'),
64
+ (0, common_1.Post)(':targetId/comment'),
65
+ __param(0, (0, pipes_1.Id)('targetId')),
66
+ __param(1, (0, authentication_1.Account)('id')),
67
+ __param(2, (0, common_1.Body)()),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [String, String, Object]),
70
+ __metadata("design:returntype", Promise)
71
+ ], CommentController.prototype, "postComment", null);
72
+ CommentController = __decorate([
73
+ (0, authentication_1.Jwt)(),
74
+ (0, swagger_1.ApiTags)('Comment'),
75
+ (0, common_1.Controller)(''),
76
+ __metadata("design:paramtypes", [comment_service_1.CommentService])
77
+ ], CommentController);
78
+ exports.CommentController = CommentController;
@@ -2,6 +2,8 @@
2
2
  * Represents a Comment.
3
3
  *
4
4
  * @class Comment
5
+ * @typedef {Comment} Comment
6
+ *
5
7
  * @property {string} authorId - The id of the author
6
8
  * @property {number} timestamp - The timestamp of the comment
7
9
  * @property {string} richtext - The comment text
@@ -15,6 +15,8 @@ const swagger_1 = require("@nestjs/swagger");
15
15
  * Represents a Comment.
16
16
  *
17
17
  * @class Comment
18
+ * @typedef {Comment} Comment
19
+ *
18
20
  * @property {string} authorId - The id of the author
19
21
  * @property {number} timestamp - The timestamp of the comment
20
22
  * @property {string} richtext - The comment text
@@ -0,0 +1,19 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { Schema } from 'mongoose';
3
+ import { Targets } from '../../pipes';
4
+ /**
5
+ * @class CommentModule
6
+ * @description This module handles all operations related to comments.
7
+ * @author Timo Scheuermann
8
+ */
9
+ export declare class CommentModule {
10
+ /**
11
+ * Generate a CommentModule based on the given schema.
12
+ *
13
+ * @param {Schema} schema - the schema for the CommentModule
14
+ * @param {string | string[]} prefix - the prefix for the CommentController (Defaults to "comment")
15
+ * @return {DynamicModule} the CommentModule generated for the given schema
16
+ */
17
+ static forFeature(schema: Schema, target: Targets, prefix?: string): DynamicModule;
18
+ static register(target: Targets): DynamicModule;
19
+ }
@@ -0,0 +1,57 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CommentModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const mongoose_1 = require("@nestjs/mongoose");
12
+ const comment_controller_1 = require("./comment.controller");
13
+ const comment_service_1 = require("./comment.service");
14
+ /**
15
+ * @class CommentModule
16
+ * @description This module handles all operations related to comments.
17
+ * @author Timo Scheuermann
18
+ */
19
+ class CommentModule {
20
+ /**
21
+ * Generate a CommentModule based on the given schema.
22
+ *
23
+ * @param {Schema} schema - the schema for the CommentModule
24
+ * @param {string | string[]} prefix - the prefix for the CommentController (Defaults to "comment")
25
+ * @return {DynamicModule} the CommentModule generated for the given schema
26
+ */
27
+ static forFeature(schema, target, prefix) {
28
+ let CommentController = class CommentController extends comment_controller_1.CommentController {
29
+ };
30
+ CommentController = __decorate([
31
+ (0, common_1.Controller)(prefix)
32
+ ], CommentController);
33
+ let CommentModuleTemplate = class CommentModuleTemplate {
34
+ };
35
+ CommentModuleTemplate = __decorate([
36
+ (0, common_1.Module)({
37
+ imports: [mongoose_1.MongooseModule.forFeature([{ name: 'COMMENT_SCHEMA', schema }])],
38
+ controllers: [CommentController],
39
+ providers: [comment_service_1.CommentService, { provide: 'COMMENT_TARGET', useValue: target }],
40
+ exports: [comment_service_1.CommentService],
41
+ })
42
+ ], CommentModuleTemplate);
43
+ return { module: CommentModuleTemplate };
44
+ }
45
+ static register(target) {
46
+ let CommentModuleTemplate = class CommentModuleTemplate {
47
+ };
48
+ CommentModuleTemplate = __decorate([
49
+ (0, common_1.Module)({
50
+ providers: [comment_service_1.CommentService, { provide: 'COMMENT_TARGET', useValue: target }],
51
+ exports: [comment_service_1.CommentService],
52
+ })
53
+ ], CommentModuleTemplate);
54
+ return { module: CommentModuleTemplate };
55
+ }
56
+ }
57
+ exports.CommentModule = CommentModule;
@@ -0,0 +1,42 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { ContentRichtext } from 'itlab-functions';
3
+ import { Model } from 'mongoose';
4
+ import { Targets } from '../../pipes';
5
+ import { Comment } from './comment.module-options';
6
+ /**
7
+ * @class CommentService
8
+ * @description The CommentService class is responsible for handling comments for a specified target. It provides methods to add and delete comments of a target.
9
+ * @author Timo Scheuermann
10
+ */
11
+ export declare class CommentService {
12
+ private readonly commentModel;
13
+ private readonly target;
14
+ private readonly configService;
15
+ /** The CommentService logger */
16
+ private readonly logger;
17
+ /**
18
+ * @constructor Constructor for the CommentService class
19
+ * @param commentModel - The injected model for the COMMENT_SCHEMA
20
+ * @param target - The target for which comments are being posted
21
+ * @param configService - The injected config service
22
+ */
23
+ constructor(commentModel: Model<{}> | null, target: Targets, configService: ConfigService);
24
+ /** The axios instance */
25
+ private axios;
26
+ /**
27
+ * Post a comment to a specific target.
28
+ *
29
+ * @param {string} targetId - the ID of the target for the comment
30
+ * @param {string} accountId - the ID of the account posting the comment
31
+ * @param {ContentRichtext} comment - the content of the comment
32
+ * @return {Promise<Comment>} a promise that resolves with the posted comment
33
+ */
34
+ postComment(targetId: string, accountId: string, comment: ContentRichtext): Promise<Comment>;
35
+ /**
36
+ * Deletes all comments of the specified target.
37
+ *
38
+ * @param {string} targetId - the ID of the target to be deleted
39
+ * @return {void}
40
+ */
41
+ delete(targetId: string): void;
42
+ }