itlab-internal-services 2.16.12 → 2.16.14

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 (127) hide show
  1. package/dist/classes/document/content-document.class.d.ts +2 -2
  2. package/dist/classes/fetch-options/content-options.class.d.ts +2 -2
  3. package/dist/hub-resource.enum.d.ts +0 -23
  4. package/dist/hub-resource.enum.js +1 -25
  5. package/dist/index.d.ts +0 -6
  6. package/dist/index.js +0 -10
  7. package/dist/modules/comments/comments.controller.d.ts +3 -3
  8. package/dist/modules/comments/comments.controller.js +1 -1
  9. package/dist/modules/comments/comments.service.d.ts +3 -3
  10. package/dist/modules/comments/comments.service.js +1 -1
  11. package/dist/modules/services/providers/books/books.service.d.ts +5 -5
  12. package/dist/modules/services/providers/books/books.service.js +2 -2
  13. package/dist/modules/services/providers/changelog/changelog.service.d.ts +1 -14
  14. package/dist/modules/services/providers/conflicts/conflicts.service.d.ts +5 -15
  15. package/dist/modules/services/providers/conflicts/conflicts.service.js +2 -2
  16. package/dist/modules/services/providers/content/content-return-types.d.ts +5 -5
  17. package/dist/modules/services/providers/content/content.service.d.ts +7 -6
  18. package/dist/modules/services/providers/content/content.service.js +2 -2
  19. package/dist/modules/services/providers/demo-hive/demo-hive.service.d.ts +5 -5
  20. package/dist/modules/services/providers/demo-hive/demo-hive.service.js +2 -2
  21. package/dist/modules/services/providers/events/events.service.d.ts +5 -5
  22. package/dist/modules/services/providers/events/events.service.js +2 -2
  23. package/dist/modules/services/providers/files/files.service.d.ts +9 -30
  24. package/dist/modules/services/providers/files/files.service.js +4 -4
  25. package/dist/modules/services/providers/mail/dtos/newsletter-issue-mail.dto.v1.d.ts +2 -2
  26. package/dist/modules/services/providers/newsletter/newsletter.service.d.ts +5 -5
  27. package/dist/modules/services/providers/newsletter/newsletter.service.js +2 -2
  28. package/dist/modules/services/providers/newsroom/newsroom.service.d.ts +5 -5
  29. package/dist/modules/services/providers/newsroom/newsroom.service.js +2 -2
  30. package/dist/modules/services/providers/notifications/notifications.service.d.ts +5 -18
  31. package/dist/modules/services/providers/notifications/notifications.service.js +5 -3
  32. package/dist/modules/services/providers/podcasts/podcasts.service.d.ts +5 -5
  33. package/dist/modules/services/providers/podcasts/podcasts.service.js +2 -2
  34. package/dist/modules/services/providers/quick-links/quick-links.service.d.ts +5 -17
  35. package/dist/modules/services/providers/quick-links/quick-links.service.js +2 -2
  36. package/dist/pipes/restricted-fields.pipe.js +3 -1
  37. package/package.json +23 -23
  38. package/dist/classes/document-updater.class.d.ts +0 -40
  39. package/dist/classes/document-updater.class.js +0 -58
  40. package/dist/factories/index.d.ts +0 -1
  41. package/dist/factories/index.js +0 -5
  42. package/dist/factories/virtuals.factory.d.ts +0 -80
  43. package/dist/factories/virtuals.factory.js +0 -172
  44. package/dist/functions/create-duplicate-checker.function.d.ts +0 -29
  45. package/dist/functions/create-duplicate-checker.function.js +0 -52
  46. package/dist/likeable.interface.d.ts +0 -42
  47. package/dist/likeable.interface.js +0 -48
  48. package/dist/modules/_old/comment/comment.controller.d.ts +0 -35
  49. package/dist/modules/_old/comment/comment.controller.js +0 -86
  50. package/dist/modules/_old/comment/comment.model.d.ts +0 -29
  51. package/dist/modules/_old/comment/comment.model.js +0 -43
  52. package/dist/modules/_old/comment/comment.module-definition.d.ts +0 -45
  53. package/dist/modules/_old/comment/comment.module-definition.js +0 -8
  54. package/dist/modules/_old/comment/comment.module.d.ts +0 -22
  55. package/dist/modules/_old/comment/comment.module.js +0 -71
  56. package/dist/modules/_old/comment/comment.service.d.ts +0 -54
  57. package/dist/modules/_old/comment/comment.service.js +0 -133
  58. package/dist/modules/_old/comment/index.d.ts +0 -3
  59. package/dist/modules/_old/comment/index.js +0 -9
  60. package/dist/modules/_old/content/content.module-definition.d.ts +0 -5
  61. package/dist/modules/_old/content/content.module-definition.js +0 -8
  62. package/dist/modules/_old/content/content.module.d.ts +0 -31
  63. package/dist/modules/_old/content/content.module.js +0 -60
  64. package/dist/modules/_old/content/content.service.d.ts +0 -50
  65. package/dist/modules/_old/content/content.service.js +0 -145
  66. package/dist/modules/_old/content/index.d.ts +0 -2
  67. package/dist/modules/_old/content/index.js +0 -7
  68. package/dist/modules/_old/database/database-module-options.interface.d.ts +0 -41
  69. package/dist/modules/_old/database/database-module-options.interface.js +0 -2
  70. package/dist/modules/_old/database/database.liveness-controller.d.ts +0 -27
  71. package/dist/modules/_old/database/database.liveness-controller.js +0 -80
  72. package/dist/modules/_old/database/database.module.d.ts +0 -41
  73. package/dist/modules/_old/database/database.module.js +0 -97
  74. package/dist/modules/_old/database/index.d.ts +0 -6
  75. package/dist/modules/_old/database/index.js +0 -13
  76. package/dist/modules/_old/database/lock-service/lock.schema.d.ts +0 -38
  77. package/dist/modules/_old/database/lock-service/lock.schema.js +0 -51
  78. package/dist/modules/_old/database/lock-service/lock.service.d.ts +0 -53
  79. package/dist/modules/_old/database/lock-service/lock.service.js +0 -103
  80. package/dist/modules/_old/database/model-service/dbs/hub-account.db.d.ts +0 -28
  81. package/dist/modules/_old/database/model-service/dbs/hub-account.db.js +0 -44
  82. package/dist/modules/_old/database/model-service/dbs/hub-books.db.d.ts +0 -23
  83. package/dist/modules/_old/database/model-service/dbs/hub-books.db.js +0 -45
  84. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.d.ts +0 -29
  85. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.js +0 -68
  86. package/dist/modules/_old/database/model-service/dbs/hub-content.db.d.ts +0 -24
  87. package/dist/modules/_old/database/model-service/dbs/hub-content.db.js +0 -49
  88. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
  89. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.js +0 -45
  90. package/dist/modules/_old/database/model-service/dbs/hub-events.db.d.ts +0 -24
  91. package/dist/modules/_old/database/model-service/dbs/hub-events.db.js +0 -49
  92. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
  93. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.js +0 -106
  94. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
  95. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.js +0 -53
  96. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
  97. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.js +0 -45
  98. package/dist/modules/_old/database/model-service/dbs/hub-team.db.d.ts +0 -22
  99. package/dist/modules/_old/database/model-service/dbs/hub-team.db.js +0 -41
  100. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
  101. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.js +0 -81
  102. package/dist/modules/_old/database/model-service/model.service.d.ts +0 -8465
  103. package/dist/modules/_old/database/model-service/model.service.js +0 -136
  104. package/dist/modules/_old/database/populate-service/populate.service.d.ts +0 -73
  105. package/dist/modules/_old/database/populate-service/populate.service.js +0 -163
  106. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.d.ts +0 -32
  107. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.js +0 -73
  108. package/dist/modules/_old/fetch/fetch.module.d.ts +0 -31
  109. package/dist/modules/_old/fetch/fetch.module.js +0 -60
  110. package/dist/modules/_old/fetch/fetch.service.d.ts +0 -153
  111. package/dist/modules/_old/fetch/fetch.service.js +0 -274
  112. package/dist/modules/_old/fetch/index.d.ts +0 -2
  113. package/dist/modules/_old/fetch/index.js +0 -7
  114. package/dist/modules/_old/index.d.ts +0 -5
  115. package/dist/modules/_old/index.js +0 -21
  116. package/dist/modules/_old/like/index.d.ts +0 -1
  117. package/dist/modules/_old/like/index.js +0 -5
  118. package/dist/modules/_old/like/like.controller.d.ts +0 -41
  119. package/dist/modules/_old/like/like.controller.js +0 -125
  120. package/dist/modules/_old/like/like.module-definition.d.ts +0 -20
  121. package/dist/modules/_old/like/like.module-definition.js +0 -8
  122. package/dist/modules/_old/like/like.module.d.ts +0 -21
  123. package/dist/modules/_old/like/like.module.js +0 -67
  124. package/dist/modules/_old/like/like.service.d.ts +0 -61
  125. package/dist/modules/_old/like/like.service.js +0 -103
  126. package/dist/viewable.interface.d.ts +0 -42
  127. package/dist/viewable.interface.js +0 -48
@@ -1,172 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VirtualsFactory = void 0;
4
- const class_validator_1 = require("class-validator");
5
- const hub_resource_enum_1 = require("../hub-resource.enum");
6
- /**
7
- * TODO: Remove
8
- * VirtualsFactory
9
- *
10
- * Provides a fluent, composable API for defining reusable Mongoose virtuals on schemas.
11
- * Helps keep schema definitions clean and DRY by centralizing the logic for frequently-used
12
- * virtual references (accounts, comments, likes, etc.), derived values, and hub-based resources.
13
- */
14
- class VirtualsFactory {
15
- /**
16
- * @param {Schema} schema - the schema to create the virtual field on
17
- * @param {HubResource} resource - the resource used for the virtual field
18
- */
19
- constructor(schema, resource) {
20
- this.schema = schema;
21
- this.resource = resource;
22
- }
23
- // ———————————————————————— Core Helper Methods ————————————————————————
24
- /**
25
- * Registers a generic virtual with custom Mongoose options.
26
- *
27
- * @param {string} name - The virtual field name.
28
- * @param {VirtualTypeOptions} [options] - The Mongoose virtual options.
29
- * @returns {VirtualsFactory} - The VirtualsFactory instance for chaining.
30
- */
31
- virtual(name, options) {
32
- this.schema.virtual(name, options);
33
- return this;
34
- }
35
- /**
36
- * Registers a virtual referencing a single Account by ID.
37
- *
38
- * @param {string} name - Virtual field name.
39
- * @param {string} localField - Field containing the Account ID.
40
- */
41
- virtualSingleAccount(name, localField) {
42
- this.schema.virtual(name, {
43
- ref: 'accounts',
44
- foreignField: '_id',
45
- localField,
46
- justOne: true,
47
- });
48
- return this;
49
- }
50
- /**
51
- * Registers a virtual referencing multiple Accounts by ID array.
52
- *
53
- * @param {string} name - Virtual field name.
54
- * @param {string} localField - Field containing array of Account IDs.
55
- */
56
- virtualMultipleAccounts(name, localField) {
57
- this.schema.virtual(name, {
58
- ref: 'accounts',
59
- foreignField: '_id',
60
- localField,
61
- justOne: false,
62
- });
63
- return this;
64
- }
65
- // ———————————————————————— Account-Related Virtuals ————————————————————————
66
- /** Links `accountId` → `account` (single Account) */
67
- get account() {
68
- return this.virtualSingleAccount('account', 'accountId');
69
- }
70
- /** Links `accountIds` → `accounts` (multiple Accounts) */
71
- get accounts() {
72
- return this.virtualMultipleAccounts('accounts', 'accountIds');
73
- }
74
- /** Links `authorId` → `author` (single Account) */
75
- get author() {
76
- return this.virtualSingleAccount('author', 'authorId');
77
- }
78
- /** Links `authorIds` → `authors` (multiple Accounts) */
79
- get authors() {
80
- return this.virtualMultipleAccounts('authors', 'authorIds');
81
- }
82
- /** Links `submitterId` → `submitter` (single Account) */
83
- get submitter() {
84
- return this.virtualSingleAccount('submitter', 'submitterId');
85
- }
86
- /** Links `submitterIds` → `submitters` (multiple Accounts) */
87
- get submitters() {
88
- return this.virtualMultipleAccounts('submitters', 'submitterIds');
89
- }
90
- /** Links `contactId` → `contact` (single Account) */
91
- get contact() {
92
- return this.virtualSingleAccount('contact', 'contactId');
93
- }
94
- /** Links `contactIds` → `contacts` (multiple Accounts) */
95
- get contacts() {
96
- return this.virtualMultipleAccounts('contacts', 'contactIds');
97
- }
98
- /** Links `_viewedBy` → `viewedBy` and creates derived `views` counter */
99
- get views() {
100
- this.virtualMultipleAccounts('viewedBy', '_viewedBy');
101
- this.schema.virtual('views').get(function () {
102
- return (0, class_validator_1.isArray)(this._viewedBy) ? this._viewedBy.length : 0;
103
- });
104
- return this;
105
- }
106
- /** Links `_likedBy` → `likedBy` and creates derived `likes` counter */
107
- get likes() {
108
- this.virtualMultipleAccounts('likedBy', '_likedBy');
109
- this.schema.virtual('likes').get(function () {
110
- return (0, class_validator_1.isArray)(this._likedBy) ? this._likedBy.length : 0;
111
- });
112
- return this;
113
- }
114
- // ———————————————————————— Comment-Related Virtuals ————————————————————————
115
- /**
116
- * Creates `comments` virtual for top-level comments on the resource.
117
- * Filters out replies.
118
- */
119
- get comments() {
120
- this.schema.virtual('comments', {
121
- ref: 'comments',
122
- foreignField: '_resourceId',
123
- localField: '_id',
124
- match: {
125
- _resource: this.resource,
126
- _replyTo: { $exists: false },
127
- },
128
- justOne: false,
129
- });
130
- return this;
131
- }
132
- /**
133
- * Creates `commentsCount` virtual for counting all related comments on this resource.
134
- */
135
- get commentsCount() {
136
- this.schema.virtual('commentsCount', {
137
- ref: 'comments',
138
- foreignField: '_resourceId',
139
- localField: '_id',
140
- match: { _resource: this.resource },
141
- count: true,
142
- });
143
- return this;
144
- }
145
- // ———————————————————————— Content and Utility Virtuals ————————————————————————
146
- /**
147
- * Creates an empty virtual field for general content use.
148
- * Placeholder to support virtual getter/setter extension in custom implementations.
149
- */
150
- get content() {
151
- this.schema.virtual('content');
152
- return this;
153
- }
154
- // ———————————————————————— Hub Resource Virtuals ————————————————————————
155
- /**
156
- * Registers `ref-[resource]` virtuals for each known Hub resource.
157
- * Used for polymorphic document relationships in the platform.
158
- */
159
- get hubResources() {
160
- for (const resource of hub_resource_enum_1.HUB_RESOURCES) {
161
- this.schema.virtual(`ref-${resource}`, {
162
- ref: resource,
163
- foreignField: '_id',
164
- localField: '_resourceId',
165
- match: { _resource: resource },
166
- justOne: true,
167
- });
168
- }
169
- return this;
170
- }
171
- }
172
- exports.VirtualsFactory = VirtualsFactory;
@@ -1,29 +0,0 @@
1
- import { HttpException } from '@nestjs/common';
2
- import { Document, Model } from 'mongoose';
3
- /**
4
- * @fileoverview
5
- * Provides a utility to create a duplicate checker function for a Mongoose model.
6
- * The generated function verifies whether a given data transfer object (DTO) would
7
- * result in a duplicate record based on critical identifying fields.
8
- *
9
- * If a duplicate is detected that does not match the current resource (if provided),
10
- * a specified HTTP exception is thrown to prevent creation or update.
11
- */
12
- /**
13
- * Generates a function that performs a duplicate check in a MongoDB collection
14
- * using critical fields from a DTO and an optional existing document.
15
- *
16
- * This function ensures data integrity by preventing records with the same
17
- * critical identifiers from being saved multiple times.
18
- *
19
- * @template TDto - DTO type, expected to share key fields with the document.
20
- * @template TDocument - Mongoose document type.
21
- *
22
- * @param {Model<TDocument>} model - Mongoose model to search for potential duplicates.
23
- * @param {(keyof TDto & keyof TDocument)[]} criticalKeys - Keys used to identify duplicates.
24
- * @param {new () => HttpException} DuplicateError - Error type to throw if a duplicate is found.
25
- *
26
- * @returns {(dto: TDto, existingResource?: TDocument) => Promise<void>}
27
- * A function that checks for duplicates and throws an error if a different record matches.
28
- */
29
- export declare function createDuplicateChecker<TDto extends Partial<TDocument>, TDocument extends Document>(model: Model<TDocument>, criticalKeys: (keyof TDto & keyof TDocument)[], DuplicateError: new () => HttpException): (dto: TDto, existingResource?: TDocument) => Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDuplicateChecker = createDuplicateChecker;
4
- /**
5
- * @fileoverview
6
- * Provides a utility to create a duplicate checker function for a Mongoose model.
7
- * The generated function verifies whether a given data transfer object (DTO) would
8
- * result in a duplicate record based on critical identifying fields.
9
- *
10
- * If a duplicate is detected that does not match the current resource (if provided),
11
- * a specified HTTP exception is thrown to prevent creation or update.
12
- */
13
- /**
14
- * Generates a function that performs a duplicate check in a MongoDB collection
15
- * using critical fields from a DTO and an optional existing document.
16
- *
17
- * This function ensures data integrity by preventing records with the same
18
- * critical identifiers from being saved multiple times.
19
- *
20
- * @template TDto - DTO type, expected to share key fields with the document.
21
- * @template TDocument - Mongoose document type.
22
- *
23
- * @param {Model<TDocument>} model - Mongoose model to search for potential duplicates.
24
- * @param {(keyof TDto & keyof TDocument)[]} criticalKeys - Keys used to identify duplicates.
25
- * @param {new () => HttpException} DuplicateError - Error type to throw if a duplicate is found.
26
- *
27
- * @returns {(dto: TDto, existingResource?: TDocument) => Promise<void>}
28
- * A function that checks for duplicates and throws an error if a different record matches.
29
- */
30
- function createDuplicateChecker(model, criticalKeys, DuplicateError) {
31
- return async (dto, existingResource) => {
32
- const filterQuery = {};
33
- // Populate filterQuery with key-value pairs from the DTO or the existing document.
34
- // Priority is given to the DTO values since those represent the intended update/create.
35
- for (const criticalKey of criticalKeys) {
36
- if (dto && criticalKey in dto) {
37
- filterQuery[criticalKey] = dto[criticalKey];
38
- }
39
- else if (existingResource && criticalKey in existingResource) {
40
- filterQuery[criticalKey] = existingResource[criticalKey];
41
- }
42
- }
43
- // Attempt to find an existing document with matching critical fields.
44
- const potentialDuplicate = await model.findOne(filterQuery);
45
- // Convert existing resource ID to lowercase string for safe comparison.
46
- const currentResourceId = existingResource ? String(existingResource._id).toLowerCase() : undefined;
47
- // If a duplicate exists and it's not the same as the current resource, throw the error.
48
- if (potentialDuplicate && String(potentialDuplicate._id).toLowerCase() !== currentResourceId) {
49
- throw new DuplicateError();
50
- }
51
- };
52
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * TODO: REMOVE
3
- * Interface for entities that can be liked by users. Used to track engagement metrics
4
- * such as user interest or approval. Fields include a reference to user IDs and a count of total likes.
5
- *
6
- * Intended to be implemented or extended by Mongoose documents representing likeable resources.
7
- */
8
- export interface Likeable {
9
- /**
10
- * List of account IDs who have liked this entity.
11
- */
12
- _likedBy: string[];
13
- /**
14
- * Count of total likes.
15
- */
16
- likes: number;
17
- }
18
- /**
19
- * Mongoose property decorator for defining the `_likedBy` field.
20
- * This field is required and initialized with an empty array to ensure consistency.
21
- *
22
- * Useful for tracking which accounts have liked a particular document.
23
- *
24
- * @returns {PropertyDecorator} - Mongoose property configuration for `_likedBy`.
25
- */
26
- export declare function PropertyLikedBy(): PropertyDecorator;
27
- /**
28
- * Swagger property decorator for documenting the `_likedBy` field in API specs.
29
- * Describes the field as an array of `Account` and documents its usage.
30
- *
31
- * This improves visibility in auto-generated API docs for consumers of likeable entities.
32
- *
33
- * @returns {PropertyDecorator} - Swagger metadata for the `_likedBy` field.
34
- */
35
- export declare function ApiLikedBy(): PropertyDecorator;
36
- /**
37
- * Swagger property decorator for documenting the `likes` field in API responses.
38
- * Represents the total number of likes and helps clarify it is derived/cached.
39
- *
40
- * @returns {PropertyDecorator} - Swagger metadata for the `likes` field.
41
- */
42
- export declare function ApiLikes(): PropertyDecorator;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PropertyLikedBy = PropertyLikedBy;
4
- exports.ApiLikedBy = ApiLikedBy;
5
- exports.ApiLikes = ApiLikes;
6
- const mongoose_1 = require("@nestjs/mongoose");
7
- const swagger_1 = require("@nestjs/swagger");
8
- const models_1 = require("./models");
9
- /**
10
- * Mongoose property decorator for defining the `_likedBy` field.
11
- * This field is required and initialized with an empty array to ensure consistency.
12
- *
13
- * Useful for tracking which accounts have liked a particular document.
14
- *
15
- * @returns {PropertyDecorator} - Mongoose property configuration for `_likedBy`.
16
- */
17
- function PropertyLikedBy() {
18
- return (0, mongoose_1.Prop)({ required: true, default: () => [] });
19
- }
20
- /**
21
- * Swagger property decorator for documenting the `_likedBy` field in API specs.
22
- * Describes the field as an array of `Account` and documents its usage.
23
- *
24
- * This improves visibility in auto-generated API docs for consumers of likeable entities.
25
- *
26
- * @returns {PropertyDecorator} - Swagger metadata for the `_likedBy` field.
27
- */
28
- function ApiLikedBy() {
29
- return (0, swagger_1.ApiProperty)({
30
- name: 'likedBy',
31
- type: [models_1.Account],
32
- default: [],
33
- description: 'The accounts who have liked the entity.',
34
- });
35
- }
36
- /**
37
- * Swagger property decorator for documenting the `likes` field in API responses.
38
- * Represents the total number of likes and helps clarify it is derived/cached.
39
- *
40
- * @returns {PropertyDecorator} - Swagger metadata for the `likes` field.
41
- */
42
- function ApiLikes() {
43
- return (0, swagger_1.ApiProperty)({
44
- type: Number,
45
- default: 0,
46
- description: 'The number of likes this entity has received.',
47
- });
48
- }
@@ -1,35 +0,0 @@
1
- import { LabContentRichtext } from 'itlab-functions';
2
- import { Comment } from './comment.model';
3
- import { CommentService } from './comment.service';
4
- /**
5
- * @class CommentController
6
- * @description
7
- * Handles HTTP endpoints for adding comments to a resource.
8
- * Requires authenticated users and validates the resource ID using a MongoDB ObjectId format.
9
- * Delegates comment logic to CommentService.
10
- *
11
- * Routes are mounted dynamically and scoped by module configuration (via CommentModule).
12
- *
13
- * Example route: POST /comment/posts/:resourceId
14
- */
15
- export declare class CommentController {
16
- private readonly commentService;
17
- /**
18
- * Injects CommentService for handling comment logic.
19
- *
20
- * @param {CommentService} commentService - Service that handles comment creation and deletion logic
21
- */
22
- constructor(commentService: CommentService);
23
- /**
24
- * Adds a comment to a specific resource.
25
- *
26
- * This endpoint is authenticated. It verifies the resource exists (if a model is provided),
27
- * and forwards the comment to the internal comments service with optional owner metadata.
28
- *
29
- * @param {string} resourceId - MongoDB ObjectId of the resource to comment on
30
- * @param {string} accountId - Authenticated user ID from the JWT
31
- * @param {LabContentRichtext} comment - The comment content (rich text format)
32
- * @returns {Promise<Comment>} - The saved comment returned by the comment service
33
- */
34
- postComment(resourceId: string, accountId: string, comment: LabContentRichtext): Promise<Comment>;
35
- }
@@ -1,86 +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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CommentController = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const swagger_1 = require("@nestjs/swagger");
18
- const decorators_1 = require("../../../decorators");
19
- const exceptions_1 = require("../../../exceptions");
20
- const pipes_1 = require("../../../pipes");
21
- const authentication_1 = require("../../authentication");
22
- const comment_model_1 = require("./comment.model");
23
- const comment_service_1 = require("./comment.service");
24
- /**
25
- * @class CommentController
26
- * @description
27
- * Handles HTTP endpoints for adding comments to a resource.
28
- * Requires authenticated users and validates the resource ID using a MongoDB ObjectId format.
29
- * Delegates comment logic to CommentService.
30
- *
31
- * Routes are mounted dynamically and scoped by module configuration (via CommentModule).
32
- *
33
- * Example route: POST /comment/posts/:resourceId
34
- */
35
- let CommentController = class CommentController {
36
- /**
37
- * Injects CommentService for handling comment logic.
38
- *
39
- * @param {CommentService} commentService - Service that handles comment creation and deletion logic
40
- */
41
- constructor(commentService) {
42
- this.commentService = commentService;
43
- }
44
- /**
45
- * Adds a comment to a specific resource.
46
- *
47
- * This endpoint is authenticated. It verifies the resource exists (if a model is provided),
48
- * and forwards the comment to the internal comments service with optional owner metadata.
49
- *
50
- * @param {string} resourceId - MongoDB ObjectId of the resource to comment on
51
- * @param {string} accountId - Authenticated user ID from the JWT
52
- * @param {LabContentRichtext} comment - The comment content (rich text format)
53
- * @returns {Promise<Comment>} - The saved comment returned by the comment service
54
- */
55
- async postComment(resourceId, accountId, comment) {
56
- return this.commentService.postComment(resourceId, accountId, comment);
57
- }
58
- };
59
- exports.CommentController = CommentController;
60
- __decorate([
61
- (0, swagger_1.ApiOperation)({
62
- summary: 'Kommentar speichern',
63
- description: 'Speichert ein Kommentar zur angegebenen Ressource.',
64
- }),
65
- (0, swagger_1.ApiOkResponse)({
66
- description: 'Der erfolgreich gespeicherte Kommentar',
67
- type: comment_model_1.Comment,
68
- }),
69
- (0, exceptions_1.ApiBadBodyResponse)('Validierung des Kommentars fehlgeschlagen'),
70
- (0, swagger_1.ApiBody)({
71
- description: 'Der Kommentar-Inhalt im Richtext-Format',
72
- }),
73
- (0, pipes_1.ApiMongoIdParam)('resourceId'),
74
- (0, common_1.Post)(':resourceId'),
75
- __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
76
- __param(1, (0, decorators_1.AuthenticatedAccount)('id')),
77
- __param(2, (0, common_1.Body)()),
78
- __metadata("design:type", Function),
79
- __metadata("design:paramtypes", [String, String, Object]),
80
- __metadata("design:returntype", Promise)
81
- ], CommentController.prototype, "postComment", null);
82
- exports.CommentController = CommentController = __decorate([
83
- (0, authentication_1.RequireJwtAuth)(),
84
- (0, common_1.Controller)(),
85
- __metadata("design:paramtypes", [comment_service_1.CommentService])
86
- ], CommentController);
@@ -1,29 +0,0 @@
1
- /**
2
- * Represents a single user-generated comment entry in the system.
3
- *
4
- * Encapsulates information about the author, creation time, and comment content,
5
- * including support for rich text (HTML-formatted) body.
6
- */
7
- export declare class Comment {
8
- /**
9
- * Identifier of the user who authored the comment.
10
- * Used to associate the comment with a specific account.
11
- *
12
- * @example "000000000000000000000000"
13
- */
14
- authorId: string;
15
- /**
16
- * UNIX timestamp of when the comment was created.
17
- * Used for ordering and displaying relative or absolute creation time.
18
- *
19
- * @example 1625074800
20
- */
21
- timestamp: number;
22
- /**
23
- * The content of the comment, formatted as rich HTML.
24
- * Enables structured presentation (e.g., paragraphs, links).
25
- *
26
- * @example "<p>Hello World</p>"
27
- */
28
- richtext: string;
29
- }
@@ -1,43 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Comment = void 0;
13
- const swagger_1 = require("@nestjs/swagger");
14
- /**
15
- * Represents a single user-generated comment entry in the system.
16
- *
17
- * Encapsulates information about the author, creation time, and comment content,
18
- * including support for rich text (HTML-formatted) body.
19
- */
20
- class Comment {
21
- }
22
- exports.Comment = Comment;
23
- __decorate([
24
- (0, swagger_1.ApiProperty)({
25
- description: 'ID of the comment author',
26
- example: '000000000000000000000000',
27
- }),
28
- __metadata("design:type", String)
29
- ], Comment.prototype, "authorId", void 0);
30
- __decorate([
31
- (0, swagger_1.ApiProperty)({
32
- description: 'Timestamp when the comment was created (UNIX format)',
33
- example: 1625074800,
34
- }),
35
- __metadata("design:type", Number)
36
- ], Comment.prototype, "timestamp", void 0);
37
- __decorate([
38
- (0, swagger_1.ApiProperty)({
39
- description: 'HTML-formatted comment content',
40
- example: '<p>Hello World</p>',
41
- }),
42
- __metadata("design:type", String)
43
- ], Comment.prototype, "richtext", void 0);
@@ -1,45 +0,0 @@
1
- import { ModelDefinition } from '@nestjs/mongoose';
2
- import { Document } from 'mongoose';
3
- import { HubResource } from '../../../hub-resource.enum';
4
- /**
5
- * Options for configuring a dynamically scoped CommentModule.
6
- *
7
- * This structure allows customization of routes, Swagger tags, and field-level ownership logic
8
- * for different resource types (e.g., posts, articles, media).
9
- *
10
- * @template T - The type of the resource document.
11
- */
12
- export type CommentModuleOptions<T extends Document = any> = {
13
- /**
14
- * The enum value identifying the resource type this comment module relates to.
15
- * Used internally for routing and tagging.
16
- */
17
- resource: HubResource;
18
- /**
19
- * Optional array of path segments used to define the controller route and Swagger tag suffix.
20
- * Enables modular comment endpoints for different resource domains.
21
- *
22
- * Example: ['posts', 'featured'] → route: /comment/posts/featured
23
- */
24
- routeScope?: string[];
25
- /**
26
- * Optional Mongoose model definition for the resource to which comments are attached.
27
- * If not provided, the module will skip controller registration.
28
- */
29
- model?: ModelDefinition;
30
- /**
31
- * Field name on the resource document representing a single owner's ID.
32
- * Enables access control and filtering of comments by ownership.
33
- */
34
- ownerIdField?: keyof Omit<T, keyof Document>;
35
- /**
36
- * Field name on the resource document representing multiple owner IDs.
37
- * Useful for shared or collaborative resource ownership models.
38
- */
39
- ownerIdsField?: keyof Omit<T, keyof Document>;
40
- };
41
- /**
42
- * Token used to inject CommentModule options into services or controllers if needed.
43
- * Symbol is used to avoid accidental naming collisions across modules.
44
- */
45
- export declare const COMMENT_MODULE_OPTIONS_TOKEN: unique symbol;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMMENT_MODULE_OPTIONS_TOKEN = void 0;
4
- /**
5
- * Token used to inject CommentModule options into services or controllers if needed.
6
- * Symbol is used to avoid accidental naming collisions across modules.
7
- */
8
- exports.COMMENT_MODULE_OPTIONS_TOKEN = Symbol('COMMENT_MODULE_OPTIONS_TOKEN');
@@ -1,22 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { Document } from 'mongoose';
3
- import { CommentModuleOptions } from './comment.module-definition';
4
- /**
5
- * @class CommentModule
6
- * @description
7
- * A dynamic NestJS module that registers a comment controller and service scoped
8
- * to a specific resource type, route, and ownership model.
9
- */
10
- export declare class CommentModule {
11
- /**
12
- * Registers a dynamically scoped comment controller based on the provided options.
13
- *
14
- * - Generates a custom route path and Swagger tag based on `routeScope`.
15
- * - If no model is provided, no controller will be registered (service-only mode).
16
- *
17
- * @template T - The resource document type the comment module is tied to.
18
- * @param options - Configuration values for routing, model binding, and ownership strategy.
19
- * @returns A fully configured NestJS DynamicModule.
20
- */
21
- static register<T extends Document = any>(options: CommentModuleOptions<T>): DynamicModule;
22
- }