itlab-internal-services 2.2.2 → 2.3.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 (144) hide show
  1. package/dist/env.d.ts +14 -0
  2. package/dist/env.js +14 -0
  3. package/dist/exceptions/bad-body.exception.d.ts +14 -0
  4. package/dist/exceptions/bad-body.exception.js +16 -0
  5. package/dist/exceptions/duplicate.exception.d.ts +14 -0
  6. package/dist/exceptions/duplicate.exception.js +16 -0
  7. package/dist/exceptions/index.d.ts +11 -0
  8. package/dist/exceptions/index.js +11 -0
  9. package/dist/exceptions/not-found.exception.d.ts +14 -0
  10. package/dist/exceptions/not-found.exception.js +16 -0
  11. package/dist/favicon.controller.d.ts +12 -0
  12. package/dist/favicon.controller.js +13 -0
  13. package/dist/guards/perms.guard.d.ts +28 -0
  14. package/dist/guards/perms.guard.js +40 -2
  15. package/dist/guards/puplic.guard.d.ts +5 -0
  16. package/dist/guards/puplic.guard.js +5 -0
  17. package/dist/http.logger.d.ts +6 -0
  18. package/dist/http.logger.js +9 -1
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +2 -0
  21. package/dist/interceptors/errors.interceptor.d.ts +33 -1
  22. package/dist/interceptors/errors.interceptor.js +41 -3
  23. package/dist/liveness.probe.d.ts +11 -0
  24. package/dist/liveness.probe.js +11 -0
  25. package/dist/models/content.d.ts +8 -0
  26. package/dist/models/content.js +21 -0
  27. package/dist/models/filter/index.d.ts +49 -0
  28. package/dist/models/filter/index.js +88 -0
  29. package/dist/models/filter/limit.property.d.ts +4 -0
  30. package/dist/models/filter/limit.property.js +11 -0
  31. package/dist/models/filter/skip.property.d.ts +4 -0
  32. package/dist/models/filter/skip.property.js +16 -0
  33. package/dist/models/filter/sort-direction.property.d.ts +4 -0
  34. package/dist/models/filter/sort-direction.property.js +16 -0
  35. package/dist/models/filter/sort-field.property.d.ts +4 -0
  36. package/dist/models/filter/sort-field.property.js +17 -0
  37. package/dist/models/index.d.ts +4 -0
  38. package/dist/models/index.js +20 -0
  39. package/dist/models/search-result.d.ts +14 -0
  40. package/dist/models/search-result.js +32 -0
  41. package/dist/models/thumbnail/alt.property.d.ts +8 -0
  42. package/dist/models/thumbnail/alt.property.js +18 -0
  43. package/dist/models/thumbnail/background.property.d.ts +8 -0
  44. package/dist/models/thumbnail/background.property.js +27 -0
  45. package/dist/models/thumbnail/contain.property.d.ts +8 -0
  46. package/dist/models/thumbnail/contain.property.js +18 -0
  47. package/dist/models/thumbnail/index.d.ts +30 -0
  48. package/dist/models/thumbnail/index.js +68 -0
  49. package/dist/models/thumbnail/max-height.property.d.ts +8 -0
  50. package/dist/models/thumbnail/max-height.property.js +20 -0
  51. package/dist/models/thumbnail/src.property.d.ts +8 -0
  52. package/dist/models/thumbnail/src.property.js +21 -0
  53. package/dist/modules/authentication/authentication.module.d.ts +14 -0
  54. package/dist/modules/authentication/authentication.module.js +10 -0
  55. package/dist/modules/authentication/internal/internal.constants.d.ts +4 -0
  56. package/dist/modules/authentication/internal/internal.constants.js +4 -0
  57. package/dist/modules/authentication/internal/internal.decorators.d.ts +4 -0
  58. package/dist/modules/authentication/internal/internal.decorators.js +4 -0
  59. package/dist/modules/authentication/internal/internal.guard.d.ts +5 -0
  60. package/dist/modules/authentication/internal/internal.guard.js +5 -0
  61. package/dist/modules/authentication/internal/internal.strategy.d.ts +17 -0
  62. package/dist/modules/authentication/internal/internal.strategy.js +17 -0
  63. package/dist/modules/authentication/jwt/jwt.constants.d.ts +20 -0
  64. package/dist/modules/authentication/jwt/jwt.constants.js +12 -0
  65. package/dist/modules/authentication/jwt/jwt.decorators.d.ts +15 -3
  66. package/dist/modules/authentication/jwt/jwt.decorators.js +16 -7
  67. package/dist/modules/authentication/jwt/jwt.guard.d.ts +15 -0
  68. package/dist/modules/authentication/jwt/jwt.guard.js +17 -0
  69. package/dist/modules/authentication/jwt/jwt.strategy.d.ts +16 -1
  70. package/dist/modules/authentication/jwt/jwt.strategy.js +16 -1
  71. package/dist/modules/database/database.module-options.d.ts +6 -0
  72. package/dist/modules/database/database.module.d.ts +19 -0
  73. package/dist/modules/database/database.module.js +41 -0
  74. package/dist/modules/database/index.js +12 -0
  75. package/dist/modules/database/model-service/model.service.d.ts +29 -0
  76. package/dist/modules/database/model-service/model.service.js +31 -0
  77. package/dist/modules/database/model-service/schemas/hub-account.schemas.d.ts +10 -0
  78. package/dist/modules/database/model-service/schemas/hub-account.schemas.js +7 -0
  79. package/dist/modules/database/model-service/schemas/hub-hackschool.schemas.js +3 -0
  80. package/dist/modules/database/model-service/schemas/hub-tech-radar.schemas.js +2 -0
  81. package/dist/modules/database/populate-service/populate.service.d.ts +35 -0
  82. package/dist/modules/database/populate-service/populate.service.js +35 -0
  83. package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +23 -0
  84. package/dist/modules/database/service-mapper-service/service-mapper.service.js +23 -0
  85. package/dist/modules/index.d.ts +1 -0
  86. package/dist/modules/index.js +1 -0
  87. package/dist/modules/like/index.d.ts +1 -0
  88. package/dist/modules/like/index.js +8 -0
  89. package/dist/modules/like/like.controller.d.ts +38 -0
  90. package/dist/modules/like/like.controller.js +119 -0
  91. package/dist/modules/like/like.module-options.d.ts +17 -0
  92. package/dist/modules/like/like.module-options.js +17 -0
  93. package/dist/modules/like/like.module.d.ts +18 -0
  94. package/dist/modules/like/like.module.js +45 -0
  95. package/dist/modules/like/like.service.d.ts +48 -0
  96. package/dist/modules/like/like.service.js +107 -0
  97. package/dist/modules/services/account-service/account.service.d.ts +15 -0
  98. package/dist/modules/services/account-service/account.service.js +15 -0
  99. package/dist/modules/services/comment-service/comment-service.definitions.d.ts +11 -0
  100. package/dist/modules/services/comment-service/comment-service.definitions.js +8 -0
  101. package/dist/modules/services/comment-service/comment.service.d.ts +26 -0
  102. package/dist/modules/services/comment-service/comment.service.js +26 -0
  103. package/dist/modules/services/content-service/content.service.d.ts +33 -1
  104. package/dist/modules/services/content-service/content.service.js +34 -2
  105. package/dist/modules/services/index.js +18 -0
  106. package/dist/modules/services/mail-service/mail-service.definitions.d.ts +15 -0
  107. package/dist/modules/services/mail-service/mail-service.definitions.js +6 -0
  108. package/dist/modules/services/mail-service/mail.service.d.ts +31 -0
  109. package/dist/modules/services/mail-service/mail.service.js +31 -0
  110. package/dist/modules/services/search-service/search-service.definitions.d.ts +13 -0
  111. package/dist/modules/services/search-service/search-service.definitions.js +9 -0
  112. package/dist/modules/services/search-service/search.service.d.ts +25 -0
  113. package/dist/modules/services/search-service/search.service.js +25 -0
  114. package/dist/modules/services/services.module-utils.d.ts +9 -0
  115. package/dist/modules/services/services.module-utils.js +5 -0
  116. package/dist/modules/services/services.module.d.ts +17 -0
  117. package/dist/modules/services/services.module.js +9 -0
  118. package/dist/pipes/hid.pipe.d.ts +30 -0
  119. package/dist/pipes/hid.pipe.js +49 -5
  120. package/dist/pipes/id.pipe.d.ts +20 -0
  121. package/dist/pipes/id.pipe.js +40 -4
  122. package/dist/pipes/target.pipe.d.ts +23 -0
  123. package/dist/pipes/target.pipe.js +48 -6
  124. package/dist/swagger.config.d.ts +36 -2
  125. package/dist/swagger.config.js +40 -3
  126. package/dist/transform/_trim.d.ts +7 -0
  127. package/dist/transform/_trim.js +16 -0
  128. package/dist/transform/index.d.ts +6 -0
  129. package/dist/transform/index.js +17 -0
  130. package/dist/transform/transformImage.d.ts +4 -0
  131. package/dist/transform/transformImage.js +16 -0
  132. package/dist/transform/transformString.d.ts +5 -0
  133. package/dist/transform/transformString.js +16 -0
  134. package/dist/transform/transformStringArray.d.ts +6 -0
  135. package/dist/transform/transformStringArray.js +24 -0
  136. package/dist/transform/transformStringLike.d.ts +20 -0
  137. package/dist/transform/transformStringLike.js +37 -0
  138. package/dist/transform/transformStringLowerCase.d.ts +5 -0
  139. package/dist/transform/transformStringLowerCase.js +16 -0
  140. package/dist/transform/transformStringSet.d.ts +6 -0
  141. package/dist/transform/transformStringSet.js +25 -0
  142. package/dist/virtuals.d.ts +43 -0
  143. package/dist/virtuals.js +44 -0
  144. package/package.json +3 -1
@@ -27,24 +27,55 @@ const hub_newsroom_schemas_1 = require("./schemas/hub-newsroom.schemas");
27
27
  const hub_podcasts_schemas_1 = require("./schemas/hub-podcasts.schemas");
28
28
  const hub_team_schemas_1 = require("./schemas/hub-team.schemas");
29
29
  const hub_tech_radar_schemas_1 = require("./schemas/hub-tech-radar.schemas");
30
+ /**
31
+ * Model service
32
+ * @class ModelService
33
+ */
30
34
  let ModelService = class ModelService {
35
+ /**
36
+ * Constructor
37
+ * @param connection - the connection
38
+ */
31
39
  constructor(connection) {
32
40
  this.connection = connection;
41
+ // General
42
+ /** Returns the account model */
33
43
  this.accountModel = () => this.useModel(hub_account_schemas_1.AccountDB, hub_account_schemas_1.AccountModel.name, hub_account_schemas_1.AccountSchema);
44
+ /** Returns the comment model */
34
45
  this.commentModel = () => this.useModel(hub_comments_schemas_1.CommentDB, hub_comments_schemas_1.CommentModel.name, hub_comments_schemas_1.CommentSchema);
46
+ /** Returns the content model */
35
47
  this.contentModel = () => this.useModel(hub_content_schemas_1.ContentDB, hub_content_schemas_1.ContentModel.name, hub_content_schemas_1.ContentSchema);
48
+ // Services
49
+ /** Returns the book model */
36
50
  this.bookModel = () => this.useModel(hub_books_schemas_1.BooksDB, hub_books_schemas_1.BookModel.name, hub_books_schemas_1.BookSchema);
51
+ /** Returns the demo model */
37
52
  this.demoModel = () => this.useModel(hub_demo_hive_schemas_1.DemoHiveDB, hub_demo_hive_schemas_1.DemoModel.name, hub_demo_hive_schemas_1.DemoSchema);
53
+ /** Returns the event model */
38
54
  this.eventModel = () => this.useModel(hub_events_schemas_1.EventsDB, hub_events_schemas_1.EventModel.name, hub_events_schemas_1.EventSchema);
55
+ /** Returns the hackschool course model */
39
56
  this.courseModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.CourseModel.name, hub_hackschool_schemas_1.CourseSchema);
57
+ /** Returns the hackschool documentation model */
40
58
  this.docModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.DocModel.name, hub_hackschool_schemas_1.DocSchema);
59
+ /** Returns the hackschool thread model */
41
60
  this.threadModel = () => this.useModel(hub_hackschool_schemas_1.HackschoolDB, hub_hackschool_schemas_1.ThreadModel.name, hub_hackschool_schemas_1.ThreadSchema);
61
+ /** Returns the news model */
42
62
  this.newsModel = () => this.useModel(hub_newsroom_schemas_1.NewsroomDB, hub_newsroom_schemas_1.NewsModel.name, hub_newsroom_schemas_1.NewsSchema);
63
+ /** Returns the podcast model */
43
64
  this.podcastModel = () => this.useModel(hub_podcasts_schemas_1.PodcastsDB, hub_podcasts_schemas_1.PodcastModel.name, hub_podcasts_schemas_1.PodcastSchema);
65
+ /** Returns the member model */
44
66
  this.memberModel = () => this.useModel(hub_team_schemas_1.TeamDB, hub_team_schemas_1.MemberModel.name, hub_team_schemas_1.MemberSchema);
67
+ /** Returns the tech radar blip model */
45
68
  this.blipModel = () => this.useModel(hub_tech_radar_schemas_1.TechRadarDB, hub_tech_radar_schemas_1.BlipModel.name, hub_tech_radar_schemas_1.BlipSchema);
69
+ /** Returns the tech radar radar model */
46
70
  this.radarModel = () => this.useModel(hub_tech_radar_schemas_1.TechRadarDB, hub_tech_radar_schemas_1.RadarModel.name, hub_tech_radar_schemas_1.RadarSchema);
47
71
  }
72
+ /**
73
+ * Returns a model for the given database, name and schema
74
+ * @param database - the database of the model
75
+ * @param name - the name of the model
76
+ * @param schema - the schema of the model
77
+ * @returns {Model<T>} the model
78
+ */
48
79
  useModel(database, name, schema) {
49
80
  return this.connection.useDb(database).model(name, schema);
50
81
  }
@@ -23,9 +23,19 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import { Document } from 'mongoose';
26
+ /**
27
+ * Account avatar model
28
+ * @class AvatarModel
29
+ * @property {string} extension - The extension of the avatar
30
+ * @property {string} mimetype - The mimetype of the avatar
31
+ * @property {number} size - The size of the avatar
32
+ */
26
33
  declare class AvatarModel {
34
+ /** The extension of the avatar */
27
35
  extension: string;
36
+ /** The mimetype of the avatar */
28
37
  mimetype: string;
38
+ /** The size of the avatar */
29
39
  size: number;
30
40
  }
31
41
  declare class AccountModel extends Document {
@@ -12,6 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AccountDB = exports.AccountSchema = exports.AccountModel = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
+ /**
16
+ * Account avatar model
17
+ * @class AvatarModel
18
+ * @property {string} extension - The extension of the avatar
19
+ * @property {string} mimetype - The mimetype of the avatar
20
+ * @property {number} size - The size of the avatar
21
+ */
15
22
  class AvatarModel {
16
23
  }
17
24
  const transform = {
@@ -35,6 +35,7 @@ CourseModel = __decorate([
35
35
  exports.CourseModel = CourseModel;
36
36
  const CourseSchema = mongoose_1.SchemaFactory.createForClass(CourseModel);
37
37
  exports.CourseSchema = CourseSchema;
38
+ // ================================================================================
38
39
  const transformDoc = {
39
40
  virtuals: true,
40
41
  transform: (_, { title, _hid }) => {
@@ -58,6 +59,7 @@ DocModel = __decorate([
58
59
  exports.DocModel = DocModel;
59
60
  const DocSchema = mongoose_1.SchemaFactory.createForClass(DocModel);
60
61
  exports.DocSchema = DocSchema;
62
+ // ================================================================================
61
63
  const transformThread = {
62
64
  virtuals: true,
63
65
  transform: (_, { title, _hid }) => {
@@ -81,5 +83,6 @@ ThreadModel = __decorate([
81
83
  exports.ThreadModel = ThreadModel;
82
84
  const ThreadSchema = mongoose_1.SchemaFactory.createForClass(ThreadModel);
83
85
  exports.ThreadSchema = ThreadSchema;
86
+ // ================================================================================
84
87
  const HackschoolDB = 'hub-hackschool';
85
88
  exports.HackschoolDB = HackschoolDB;
@@ -35,6 +35,7 @@ BlipModel = __decorate([
35
35
  exports.BlipModel = BlipModel;
36
36
  const BlipSchema = mongoose_1.SchemaFactory.createForClass(BlipModel);
37
37
  exports.BlipSchema = BlipSchema;
38
+ // ================================================================================
38
39
  const toTitle = Intl.DateTimeFormat('de-DE', { month: 'long', year: 'numeric' }).format;
39
40
  const transformRadar = {
40
41
  virtuals: true,
@@ -65,5 +66,6 @@ RadarModel = __decorate([
65
66
  exports.RadarModel = RadarModel;
66
67
  const RadarSchema = mongoose_1.SchemaFactory.createForClass(RadarModel);
67
68
  exports.RadarSchema = RadarSchema;
69
+ // ================================================================================
68
70
  const TechRadarDB = 'hub-tech-radar';
69
71
  exports.TechRadarDB = TechRadarDB;
@@ -1,12 +1,47 @@
1
1
  import { PopulateOptions } from 'mongoose';
2
2
  import { ModelService } from '../model-service/model.service';
3
+ /**
4
+ * Populate service
5
+ * @class PopulateService
6
+ */
3
7
  export declare class PopulateService {
4
8
  private readonly modelService;
9
+ /**
10
+ * Constructor
11
+ * @param modelService - the model service
12
+ */
5
13
  constructor(modelService: ModelService);
14
+ /**
15
+ * Populates an account
16
+ * @param {string} path - the path to populate
17
+ * @returns {PopulateOptions} the populate options
18
+ */
6
19
  account: (path: string) => PopulateOptions;
20
+ /**
21
+ * Populates an array of accounts
22
+ * @param path - the path to populate
23
+ * @returns {PopulateOptions} the populate options
24
+ */
7
25
  accounts: (path: string) => PopulateOptions;
26
+ /**
27
+ * Populates the comments field of a document with its comments but without replies
28
+ * @returns {PopulateOptions} the populate options
29
+ */
8
30
  comments: () => PopulateOptions;
31
+ /**
32
+ * Populates the commentsCount field of a document with the number of comments
33
+ * @returns {PopulateOptions} the populate options
34
+ */
9
35
  commentsCount: () => PopulateOptions;
36
+ /**
37
+ * Populates the comments field of a document with its comments and replies
38
+ * @returns {PopulateOptions} the populate options
39
+ */
10
40
  commentsAndReplies: () => PopulateOptions;
41
+ /**
42
+ * Populates the content field of a document
43
+ * @param {string} contentAs - the format of the content
44
+ * @returns {PopulateOptions} the populate options
45
+ */
11
46
  content: (contentAs?: 'json' | 'text' | 'html') => PopulateOptions;
12
47
  }
@@ -12,29 +12,59 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PopulateService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const model_service_1 = require("../model-service/model.service");
15
+ /**
16
+ * Populate service
17
+ * @class PopulateService
18
+ */
15
19
  let PopulateService = class PopulateService {
20
+ /**
21
+ * Constructor
22
+ * @param modelService - the model service
23
+ */
16
24
  constructor(modelService) {
17
25
  this.modelService = modelService;
26
+ /**
27
+ * Populates an account
28
+ * @param {string} path - the path to populate
29
+ * @returns {PopulateOptions} the populate options
30
+ */
18
31
  this.account = (path) => ({
19
32
  path,
20
33
  justOne: true,
21
34
  model: this.modelService.accountModel(),
22
35
  });
36
+ /**
37
+ * Populates an array of accounts
38
+ * @param path - the path to populate
39
+ * @returns {PopulateOptions} the populate options
40
+ */
23
41
  this.accounts = (path) => ({
24
42
  path,
25
43
  justOne: false,
26
44
  model: this.modelService.accountModel(),
27
45
  });
46
+ /**
47
+ * Populates the comments field of a document with its comments but without replies
48
+ * @returns {PopulateOptions} the populate options
49
+ */
28
50
  this.comments = () => ({
29
51
  path: 'comments',
30
52
  justOne: false,
31
53
  model: this.modelService.commentModel(),
32
54
  options: { populate: [this.account('author')] },
33
55
  });
56
+ /**
57
+ * Populates the commentsCount field of a document with the number of comments
58
+ * @returns {PopulateOptions} the populate options
59
+ */
34
60
  this.commentsCount = () => ({
35
61
  path: 'commentsCount',
36
62
  model: this.modelService.commentModel(),
37
63
  });
64
+ /**
65
+ * Populates the comments field of a document with its comments and replies
66
+ * @returns {PopulateOptions} the populate options
67
+ */
38
68
  this.commentsAndReplies = () => ({
39
69
  path: 'comments',
40
70
  justOne: false,
@@ -46,6 +76,11 @@ let PopulateService = class PopulateService {
46
76
  ],
47
77
  },
48
78
  });
79
+ /**
80
+ * Populates the content field of a document
81
+ * @param {string} contentAs - the format of the content
82
+ * @returns {PopulateOptions} the populate options
83
+ */
49
84
  this.content = (contentAs = 'html') => ({
50
85
  path: 'content',
51
86
  justOne: true,
@@ -1,10 +1,33 @@
1
1
  import { PopulateOptions } from 'mongoose';
2
2
  import { ModelService } from '../model-service/model.service';
3
+ /**
4
+ * Service mapper service
5
+ * @class ServiceMapperService
6
+ */
3
7
  export declare class ServiceMapperService {
4
8
  private readonly modelService;
9
+ /**
10
+ * Constructor
11
+ * @param modelService - the model service
12
+ */
5
13
  constructor(modelService: ModelService);
14
+ /** Map of Targets and their corresponding Model */
6
15
  private targets;
16
+ /**
17
+ * Transforms a target into a PopulateOptions
18
+ * @param {string} target - the target
19
+ * @param {Model<any>} model - the model
20
+ */
7
21
  private transformTarget;
22
+ /**
23
+ * Maps all targets to their corresponding PopulateOptions
24
+ * @returns {PopulateOptions[]} the populate options for all targets
25
+ */
8
26
  all: () => PopulateOptions[];
27
+ /**
28
+ * Maps filtered targets to their corresponding PopulateOptions
29
+ * @param {string[]} targets - the targets
30
+ * @returns {PopulateOptions[]} the populate options for filtered targets
31
+ */
9
32
  filtered: (targets?: string[]) => PopulateOptions[];
10
33
  }
@@ -12,9 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ServiceMapperService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const model_service_1 = require("../model-service/model.service");
15
+ /**
16
+ * Service mapper service
17
+ * @class ServiceMapperService
18
+ */
15
19
  let ServiceMapperService = class ServiceMapperService {
20
+ /**
21
+ * Constructor
22
+ * @param modelService - the model service
23
+ */
16
24
  constructor(modelService) {
17
25
  this.modelService = modelService;
26
+ /** Map of Targets and their corresponding Model */
18
27
  this.targets = {
19
28
  book: this.modelService.bookModel(),
20
29
  demo: this.modelService.demoModel(),
@@ -28,11 +37,25 @@ let ServiceMapperService = class ServiceMapperService {
28
37
  'tech-radar-blip': this.modelService.blipModel(),
29
38
  'tech-radar-radar': this.modelService.radarModel(),
30
39
  };
40
+ /**
41
+ * Transforms a target into a PopulateOptions
42
+ * @param {string} target - the target
43
+ * @param {Model<any>} model - the model
44
+ */
31
45
  this.transformTarget = (target, model) => ({
32
46
  path: `ref-${target}`,
33
47
  model,
34
48
  });
49
+ /**
50
+ * Maps all targets to their corresponding PopulateOptions
51
+ * @returns {PopulateOptions[]} the populate options for all targets
52
+ */
35
53
  this.all = () => Object.entries(this.targets).map(([target, model]) => this.transformTarget(target, model));
54
+ /**
55
+ * Maps filtered targets to their corresponding PopulateOptions
56
+ * @param {string[]} targets - the targets
57
+ * @returns {PopulateOptions[]} the populate options for filtered targets
58
+ */
36
59
  this.filtered = (targets) => {
37
60
  if (!targets || !targets.length)
38
61
  return this.all();
@@ -1,3 +1,4 @@
1
1
  export * from './authentication';
2
2
  export * from './database';
3
+ export * from './like';
3
4
  export * from './services';
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./authentication"), exports);
18
18
  __exportStar(require("./database"), exports);
19
+ __exportStar(require("./like"), exports);
19
20
  __exportStar(require("./services"), exports);
@@ -0,0 +1 @@
1
+ export { LikeModule } from './like.module';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LikeModule = void 0;
4
+ /*
5
+ * Like Module
6
+ */
7
+ var like_module_1 = require("./like.module");
8
+ Object.defineProperty(exports, "LikeModule", { enumerable: true, get: function () { return like_module_1.LikeModule; } });
@@ -0,0 +1,38 @@
1
+ import { LikeService } from './like.service';
2
+ /**
3
+ * @class LikeController
4
+ * @description This class handles operations related to adding, removing, and checking likes for specific targets.
5
+ * @author Timo Scheuermann
6
+ */
7
+ export declare class LikeController {
8
+ private readonly likeService;
9
+ /**
10
+ * @constructor Constructor for the LikeController class
11
+ * @param {LikeService} likeService - The injected service for likes
12
+ */
13
+ constructor(likeService: LikeService);
14
+ /**
15
+ * Add a like to the specified target by the given account.
16
+ *
17
+ * @param {string} targetId - The ID of the target to add the like to
18
+ * @param {string} accountId - The ID of the account adding the like
19
+ * @return {Promise<number>} The number of likes after the addition
20
+ */
21
+ addLike(targetId: string, accountId: string): Promise<number>;
22
+ /**
23
+ * Remove a like from the specified target by the given account.
24
+ *
25
+ * @param {string} targetId - the ID of the target to remove the like from
26
+ * @param {string} accountId - the ID of the account removing the like
27
+ * @return {Promise<number>} the number of likes after removal
28
+ */
29
+ removeLike(targetId: string, accountId: string): Promise<number>;
30
+ /**
31
+ * Check if the specified account has liked the target entity.
32
+ *
33
+ * @param {string} targetId - the ID of the target entity to check
34
+ * @param {string} accountId - the ID of the account whose like to check
35
+ * @return {Promise<boolean>} a boolean indicating whether the account has liked the target entity
36
+ */
37
+ hasLiked(targetId: string, accountId: string): Promise<boolean>;
38
+ }
@@ -0,0 +1,119 @@
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.LikeController = void 0;
25
+ const common_1 = require("@nestjs/common");
26
+ const swagger_1 = require("@nestjs/swagger");
27
+ const pipes_1 = require("../../pipes");
28
+ const authentication_1 = require("../authentication");
29
+ const like_service_1 = require("./like.service");
30
+ /**
31
+ * @class LikeController
32
+ * @description This class handles operations related to adding, removing, and checking likes for specific targets.
33
+ * @author Timo Scheuermann
34
+ */
35
+ let LikeController = class LikeController {
36
+ /**
37
+ * @constructor Constructor for the LikeController class
38
+ * @param {LikeService} likeService - The injected service for likes
39
+ */
40
+ constructor(likeService) {
41
+ this.likeService = likeService;
42
+ }
43
+ /**
44
+ * Add a like to the specified target by the given account.
45
+ *
46
+ * @param {string} targetId - The ID of the target to add the like to
47
+ * @param {string} accountId - The ID of the account adding the like
48
+ * @return {Promise<number>} The number of likes after the addition
49
+ */
50
+ addLike(targetId, accountId) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ return this.likeService.addLike(targetId, accountId);
53
+ });
54
+ }
55
+ /**
56
+ * Remove a like from the specified target by the given account.
57
+ *
58
+ * @param {string} targetId - the ID of the target to remove the like from
59
+ * @param {string} accountId - the ID of the account removing the like
60
+ * @return {Promise<number>} the number of likes after removal
61
+ */
62
+ removeLike(targetId, accountId) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ return this.likeService.removeLike(targetId, accountId);
65
+ });
66
+ }
67
+ /**
68
+ * Check if the specified account has liked the target entity.
69
+ *
70
+ * @param {string} targetId - the ID of the target entity to check
71
+ * @param {string} accountId - the ID of the account whose like to check
72
+ * @return {Promise<boolean>} a boolean indicating whether the account has liked the target entity
73
+ */
74
+ hasLiked(targetId, accountId) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ return this.likeService.hasLiked(targetId, accountId);
77
+ });
78
+ }
79
+ };
80
+ __decorate([
81
+ (0, swagger_1.ApiOperation)({ description: 'Fügt den Aufrufer zu den Likes des Targets hinzu' }),
82
+ (0, swagger_1.ApiResponse)({ type: Number, description: 'Die neue Anzahl der Likes', status: 200 }),
83
+ (0, pipes_1.ApiId)('targetId'),
84
+ (0, common_1.Put)(':targetId'),
85
+ __param(0, (0, pipes_1.Id)('targetId')),
86
+ __param(1, (0, authentication_1.Account)('id')),
87
+ __metadata("design:type", Function),
88
+ __metadata("design:paramtypes", [String, String]),
89
+ __metadata("design:returntype", Promise)
90
+ ], LikeController.prototype, "addLike", null);
91
+ __decorate([
92
+ (0, swagger_1.ApiOperation)({ description: 'Entfernt den Aufrufer von den Likes des Targets' }),
93
+ (0, swagger_1.ApiResponse)({ type: Number, description: 'Die neue Anzahl der Likes', status: 200 }),
94
+ (0, pipes_1.ApiId)('targetId'),
95
+ (0, common_1.Delete)(':targetId'),
96
+ __param(0, (0, pipes_1.Id)('targetId')),
97
+ __param(1, (0, authentication_1.Account)('id')),
98
+ __metadata("design:type", Function),
99
+ __metadata("design:paramtypes", [String, String]),
100
+ __metadata("design:returntype", Promise)
101
+ ], LikeController.prototype, "removeLike", null);
102
+ __decorate([
103
+ (0, swagger_1.ApiOperation)({ description: 'Gibt an, ob der Aufrufer das Target geliked hat' }),
104
+ (0, swagger_1.ApiResponse)({ type: Boolean, description: 'Gibt an, ob der Aufrufer das Target geliked hat', status: 200 }),
105
+ (0, pipes_1.ApiId)('targetId'),
106
+ (0, common_1.Get)(':targetId'),
107
+ __param(0, (0, pipes_1.Id)('targetId')),
108
+ __param(1, (0, authentication_1.Account)('id')),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [String, String]),
111
+ __metadata("design:returntype", Promise)
112
+ ], LikeController.prototype, "hasLiked", null);
113
+ LikeController = __decorate([
114
+ (0, authentication_1.Jwt)(),
115
+ (0, swagger_1.ApiTags)('Like'),
116
+ (0, common_1.Controller)('like'),
117
+ __metadata("design:paramtypes", [like_service_1.LikeService])
118
+ ], LikeController);
119
+ exports.LikeController = LikeController;
@@ -0,0 +1,17 @@
1
+ import { Document } from 'mongoose';
2
+ /**
3
+ * Represents a likeable document.
4
+ *
5
+ * @class LikeableDocument
6
+ * @extends {Document}
7
+ * @author Timo Scheuermann
8
+ *
9
+ * @property {string[]} _likedBy - Array of user IDs who have liked the document
10
+ * @property {boolean} draft - Indicates if the document is a draft
11
+ */
12
+ export declare class LikeableDocument extends Document {
13
+ /** Array of user IDs who have liked the document. */
14
+ _likedBy: string[];
15
+ /** Indicates if the document is a draft. */
16
+ draft?: boolean;
17
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LikeableDocument = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ /**
6
+ * Represents a likeable document.
7
+ *
8
+ * @class LikeableDocument
9
+ * @extends {Document}
10
+ * @author Timo Scheuermann
11
+ *
12
+ * @property {string[]} _likedBy - Array of user IDs who have liked the document
13
+ * @property {boolean} draft - Indicates if the document is a draft
14
+ */
15
+ class LikeableDocument extends mongoose_1.Document {
16
+ }
17
+ exports.LikeableDocument = LikeableDocument;
@@ -0,0 +1,18 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { Schema } from 'mongoose';
3
+ import { LikeableDocument } from './like.module-options';
4
+ /**
5
+ * @class LikeModule
6
+ * @description This module handles all operations related to likes.
7
+ * @author Timo Scheuermann
8
+ */
9
+ export declare class LikeModule {
10
+ /**
11
+ * Generate a LikeModule based on the given schema.
12
+ *
13
+ * @param {Schema<LikeableDocument>} schema - the schema for the LikeModule
14
+ * @param {string | string[]} prefix - the prefix for the LikeController (Defaults to "like")
15
+ * @return {DynamicModule} the LikeModule generated for the given schema
16
+ */
17
+ static forFeature(schema: Schema<LikeableDocument>, prefix?: string | string[]): DynamicModule;
18
+ }
@@ -0,0 +1,45 @@
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.LikeModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const mongoose_1 = require("@nestjs/mongoose");
12
+ const like_controller_1 = require("./like.controller");
13
+ const like_service_1 = require("./like.service");
14
+ /**
15
+ * @class LikeModule
16
+ * @description This module handles all operations related to likes.
17
+ * @author Timo Scheuermann
18
+ */
19
+ class LikeModule {
20
+ /**
21
+ * Generate a LikeModule based on the given schema.
22
+ *
23
+ * @param {Schema<LikeableDocument>} schema - the schema for the LikeModule
24
+ * @param {string | string[]} prefix - the prefix for the LikeController (Defaults to "like")
25
+ * @return {DynamicModule} the LikeModule generated for the given schema
26
+ */
27
+ static forFeature(schema, prefix = 'like') {
28
+ let LikeController = class LikeController extends like_controller_1.LikeController {
29
+ };
30
+ LikeController = __decorate([
31
+ (0, common_1.Controller)(prefix)
32
+ ], LikeController);
33
+ let LikeModuleTemplate = class LikeModuleTemplate {
34
+ };
35
+ LikeModuleTemplate = __decorate([
36
+ (0, common_1.Module)({
37
+ imports: [mongoose_1.MongooseModule.forFeature([{ name: 'LIKE_SCHEMA', schema }])],
38
+ controllers: [LikeController],
39
+ providers: [like_service_1.LikeService],
40
+ })
41
+ ], LikeModuleTemplate);
42
+ return { module: LikeModuleTemplate };
43
+ }
44
+ }
45
+ exports.LikeModule = LikeModule;