itlab-internal-services 2.16.1 → 2.16.3

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 (201) hide show
  1. package/dist/classes/document/commentable-document.class.d.ts +200 -0
  2. package/dist/classes/document/commentable-document.class.js +24 -0
  3. package/dist/classes/document/content-document.class.d.ts +200 -0
  4. package/dist/classes/document/content-document.class.js +24 -0
  5. package/dist/classes/document/index.d.ts +4 -0
  6. package/dist/classes/document/index.js +11 -0
  7. package/dist/classes/document/likeable-document.class.d.ts +205 -0
  8. package/dist/classes/document/likeable-document.class.js +70 -0
  9. package/dist/classes/document/viewable-document.class.d.ts +205 -0
  10. package/dist/classes/document/viewable-document.class.js +67 -0
  11. package/dist/classes/document-updater.class.d.ts +40 -0
  12. package/dist/classes/document-updater.class.js +58 -0
  13. package/dist/classes/fetch-options/base-options.class.d.ts +18 -0
  14. package/dist/classes/fetch-options/base-options.class.js +81 -0
  15. package/dist/classes/fetch-options/comments-options.class.d.ts +6 -0
  16. package/dist/classes/fetch-options/comments-options.class.js +26 -0
  17. package/dist/classes/fetch-options/content-options.class.d.ts +7 -0
  18. package/dist/classes/fetch-options/content-options.class.js +32 -0
  19. package/dist/classes/fetch-options/drafted-options.class.d.ts +9 -0
  20. package/dist/classes/fetch-options/drafted-options.class.js +34 -0
  21. package/dist/classes/fetch-options/index.d.ts +6 -0
  22. package/dist/classes/fetch-options/index.js +15 -0
  23. package/dist/classes/fetch-options/liked-by-options.class.d.ts +8 -0
  24. package/dist/classes/fetch-options/liked-by-options.class.js +28 -0
  25. package/dist/classes/fetch-options/viewed-by-options.class.d.ts +9 -0
  26. package/dist/classes/fetch-options/viewed-by-options.class.js +28 -0
  27. package/dist/classes/index.d.ts +2 -2
  28. package/dist/classes/index.js +17 -3
  29. package/dist/classes/task-manager.class.d.ts +2 -2
  30. package/dist/classes/task-manager.class.js +4 -0
  31. package/dist/decorators/has-permission.decorator.d.ts +3 -0
  32. package/dist/decorators/has-permission.decorator.js +26 -0
  33. package/dist/decorators/index.d.ts +2 -0
  34. package/dist/decorators/index.js +2 -0
  35. package/dist/decorators/jwt.decorator.d.ts +1 -1
  36. package/dist/decorators/jwt.decorator.js +13 -11
  37. package/dist/decorators/schema-with-critical-keys.decorator.d.ts +12 -0
  38. package/dist/decorators/schema-with-critical-keys.decorator.js +16 -0
  39. package/dist/factories/index.d.ts +1 -0
  40. package/dist/factories/index.js +5 -0
  41. package/dist/factories/virtuals.factory.d.ts +80 -0
  42. package/dist/factories/virtuals.factory.js +172 -0
  43. package/dist/functions/create-schema.function.d.ts +3 -0
  44. package/dist/functions/create-schema.function.js +33 -0
  45. package/dist/functions/index.d.ts +1 -1
  46. package/dist/functions/index.js +3 -3
  47. package/dist/index.d.ts +6 -0
  48. package/dist/index.js +10 -0
  49. package/dist/likeable.interface.d.ts +42 -0
  50. package/dist/likeable.interface.js +48 -0
  51. package/dist/modules/_old/comment/comment.controller.d.ts +35 -0
  52. package/dist/modules/_old/comment/comment.controller.js +86 -0
  53. package/dist/modules/_old/comment/comment.model.d.ts +29 -0
  54. package/dist/modules/_old/comment/comment.model.js +43 -0
  55. package/dist/modules/_old/comment/comment.module-definition.d.ts +45 -0
  56. package/dist/modules/{comment → _old/comment}/comment.module-definition.js +2 -1
  57. package/dist/modules/_old/comment/comment.module.d.ts +22 -0
  58. package/dist/modules/_old/comment/comment.module.js +71 -0
  59. package/dist/modules/_old/comment/comment.service.d.ts +54 -0
  60. package/dist/modules/_old/comment/comment.service.js +133 -0
  61. package/dist/modules/_old/comment/index.d.ts +3 -0
  62. package/dist/modules/_old/comment/index.js +9 -0
  63. package/dist/modules/_old/content/content.module-definition.d.ts +5 -0
  64. package/dist/modules/_old/content/content.module-definition.js +8 -0
  65. package/dist/modules/_old/content/content.module.d.ts +31 -0
  66. package/dist/modules/_old/content/content.module.js +60 -0
  67. package/dist/modules/_old/content/content.service.d.ts +50 -0
  68. package/dist/modules/_old/content/content.service.js +145 -0
  69. package/dist/modules/_old/content/index.d.ts +2 -0
  70. package/dist/modules/_old/content/index.js +7 -0
  71. package/dist/modules/_old/database/database-module-options.interface.d.ts +41 -0
  72. package/dist/modules/_old/database/database.liveness-controller.d.ts +27 -0
  73. package/dist/modules/_old/database/database.liveness-controller.js +80 -0
  74. package/dist/modules/_old/database/database.module.d.ts +41 -0
  75. package/dist/modules/_old/database/database.module.js +97 -0
  76. package/dist/modules/_old/database/index.d.ts +6 -0
  77. package/dist/modules/_old/database/index.js +13 -0
  78. package/dist/modules/_old/database/lock-service/lock.schema.d.ts +38 -0
  79. package/dist/modules/_old/database/lock-service/lock.schema.js +51 -0
  80. package/dist/modules/_old/database/lock-service/lock.service.d.ts +53 -0
  81. package/dist/modules/_old/database/lock-service/lock.service.js +103 -0
  82. package/dist/modules/_old/database/model-service/dbs/hub-account.db.d.ts +28 -0
  83. package/dist/modules/_old/database/model-service/dbs/hub-account.db.js +44 -0
  84. package/dist/modules/_old/database/model-service/dbs/hub-books.db.d.ts +23 -0
  85. package/dist/modules/_old/database/model-service/dbs/hub-books.db.js +45 -0
  86. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.d.ts +29 -0
  87. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.js +68 -0
  88. package/dist/modules/_old/database/model-service/dbs/hub-content.db.d.ts +24 -0
  89. package/dist/modules/_old/database/model-service/dbs/hub-content.db.js +49 -0
  90. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.d.ts +23 -0
  91. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.js +45 -0
  92. package/dist/modules/_old/database/model-service/dbs/hub-events.db.d.ts +24 -0
  93. package/dist/modules/_old/database/model-service/dbs/hub-events.db.js +49 -0
  94. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.d.ts +60 -0
  95. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.js +106 -0
  96. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.d.ts +25 -0
  97. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.js +53 -0
  98. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.d.ts +23 -0
  99. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.js +45 -0
  100. package/dist/modules/_old/database/model-service/dbs/hub-team.db.d.ts +22 -0
  101. package/dist/modules/_old/database/model-service/dbs/hub-team.db.js +41 -0
  102. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.d.ts +42 -0
  103. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.js +81 -0
  104. package/dist/modules/_old/database/model-service/model.service.d.ts +8465 -0
  105. package/dist/modules/_old/database/model-service/model.service.js +136 -0
  106. package/dist/modules/_old/database/populate-service/populate.service.d.ts +73 -0
  107. package/dist/modules/_old/database/populate-service/populate.service.js +163 -0
  108. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.d.ts +32 -0
  109. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.js +73 -0
  110. package/dist/modules/_old/fetch/fetch.module.d.ts +31 -0
  111. package/dist/modules/_old/fetch/fetch.module.js +60 -0
  112. package/dist/modules/_old/fetch/fetch.service.d.ts +153 -0
  113. package/dist/modules/_old/fetch/fetch.service.js +274 -0
  114. package/dist/modules/_old/fetch/index.d.ts +2 -0
  115. package/dist/modules/_old/fetch/index.js +7 -0
  116. package/dist/modules/_old/index.d.ts +5 -0
  117. package/dist/modules/{comment → _old}/index.js +5 -2
  118. package/dist/modules/_old/like/index.d.ts +1 -0
  119. package/dist/modules/_old/like/index.js +5 -0
  120. package/dist/modules/_old/like/like.controller.d.ts +41 -0
  121. package/dist/modules/_old/like/like.controller.js +125 -0
  122. package/dist/modules/_old/like/like.module-definition.d.ts +20 -0
  123. package/dist/modules/_old/like/like.module-definition.js +8 -0
  124. package/dist/modules/_old/like/like.module.d.ts +21 -0
  125. package/dist/modules/_old/like/like.module.js +67 -0
  126. package/dist/modules/_old/like/like.service.d.ts +61 -0
  127. package/dist/modules/_old/like/like.service.js +103 -0
  128. package/dist/modules/authentication/guards/jwt-auth.guard.d.ts +1 -1
  129. package/dist/modules/authentication/guards/jwt-auth.guard.js +5 -3
  130. package/dist/modules/authentication/guards/permissions.guard.d.ts +1 -3
  131. package/dist/modules/authentication/guards/permissions.guard.js +2 -8
  132. package/dist/modules/authentication/guards/service-auth.guard.d.ts +0 -4
  133. package/dist/modules/authentication/guards/service-auth.guard.js +10 -13
  134. package/dist/modules/{comment/comment-module-options.interface.d.ts → comments/comments-module-options.interface.d.ts} +3 -2
  135. package/dist/modules/comments/comments-module-options.interface.js +2 -0
  136. package/dist/modules/{comment/comment.controller.d.ts → comments/comments.controller.d.ts} +7 -6
  137. package/dist/modules/{comment/comment.controller.js → comments/comments.controller.js} +14 -14
  138. package/dist/modules/comments/comments.module-definition.d.ts +4 -0
  139. package/dist/modules/comments/comments.module-definition.js +7 -0
  140. package/dist/modules/{comment/comment.module.d.ts → comments/comments.module.d.ts} +6 -6
  141. package/dist/modules/{comment/comment.module.js → comments/comments.module.js} +17 -16
  142. package/dist/modules/{comment/comment.service.d.ts → comments/comments.service.d.ts} +35 -9
  143. package/dist/modules/comments/comments.service.js +165 -0
  144. package/dist/modules/comments/index.d.ts +3 -0
  145. package/dist/modules/{services/providers/comments → comments}/index.js +2 -0
  146. package/dist/modules/index.d.ts +1 -1
  147. package/dist/modules/index.js +1 -1
  148. package/dist/modules/like/like-module-options.interface.d.ts +1 -0
  149. package/dist/modules/like/like.controller.d.ts +3 -2
  150. package/dist/modules/like/like.controller.js +4 -4
  151. package/dist/modules/like/like.module.js +1 -1
  152. package/dist/modules/like/like.service.d.ts +0 -16
  153. package/dist/modules/like/like.service.js +9 -28
  154. package/dist/modules/merge/merge-module-options.interface.d.ts +1 -0
  155. package/dist/modules/merge/merge.controller.d.ts +3 -2
  156. package/dist/modules/merge/merge.controller.js +4 -4
  157. package/dist/modules/merge/merge.module.js +1 -1
  158. package/dist/modules/services/providers/accounts.service.js +4 -0
  159. package/dist/modules/services/providers/index.d.ts +0 -1
  160. package/dist/modules/services/providers/index.js +0 -1
  161. package/dist/modules/services/services.module.js +0 -1
  162. package/dist/pipes/index.d.ts +1 -0
  163. package/dist/pipes/index.js +1 -0
  164. package/dist/pipes/restricted-fields.pipe.d.ts +35 -0
  165. package/dist/pipes/restricted-fields.pipe.js +83 -0
  166. package/dist/properties/content-return-type.property.d.ts +4 -0
  167. package/dist/properties/content-return-type.property.js +12 -7
  168. package/dist/properties/content.property.d.ts +7 -2
  169. package/dist/properties/content.property.js +11 -3
  170. package/dist/properties/index.d.ts +2 -4
  171. package/dist/properties/index.js +5 -5
  172. package/dist/transform/index.d.ts +2 -0
  173. package/dist/transform/index.js +2 -0
  174. package/dist/transform/mongo-id.transform.d.ts +4 -0
  175. package/dist/transform/mongo-id.transform.js +13 -0
  176. package/dist/transform/mongo-ids.transform.d.ts +4 -0
  177. package/dist/transform/mongo-ids.transform.js +16 -0
  178. package/dist/types/duplicable-model.type.d.ts +10 -0
  179. package/dist/types/duplicable-model.type.js +2 -0
  180. package/dist/types/index.d.ts +1 -0
  181. package/dist/types/index.js +1 -0
  182. package/dist/types/likeable.type.d.ts +4 -3
  183. package/dist/types/viewable.type.d.ts +4 -3
  184. package/dist/viewable.interface.d.ts +42 -0
  185. package/dist/viewable.interface.js +48 -0
  186. package/package.json +1 -1
  187. package/dist/classes/schema-builder.class.d.ts +0 -75
  188. package/dist/classes/schema-builder.class.js +0 -109
  189. package/dist/modules/comment/comment.module-definition.d.ts +0 -4
  190. package/dist/modules/comment/comment.service.js +0 -99
  191. package/dist/modules/comment/index.d.ts +0 -2
  192. package/dist/modules/services/providers/comments/comments.service-definition.d.ts +0 -1
  193. package/dist/modules/services/providers/comments/comments.service-definition.js +0 -4
  194. package/dist/modules/services/providers/comments/comments.service.d.ts +0 -60
  195. package/dist/modules/services/providers/comments/comments.service.js +0 -139
  196. package/dist/modules/services/providers/comments/index.d.ts +0 -1
  197. package/dist/properties/likeable.properties.d.ts +0 -1
  198. package/dist/properties/likeable.properties.js +0 -66
  199. package/dist/properties/viewable.properties.d.ts +0 -1
  200. package/dist/properties/viewable.properties.js +0 -66
  201. /package/dist/modules/{comment/comment-module-options.interface.js → _old/database/database-module-options.interface.js} +0 -0
@@ -0,0 +1,136 @@
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.OldModelService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const mongoose_1 = require("@nestjs/mongoose");
18
+ const mongoose_2 = require("mongoose");
19
+ const hub_account_db_1 = require("./dbs/hub-account.db");
20
+ const hub_books_db_1 = require("./dbs/hub-books.db");
21
+ const hub_comments_db_1 = require("./dbs/hub-comments.db");
22
+ const hub_content_db_1 = require("./dbs/hub-content.db");
23
+ const hub_demo_hive_db_1 = require("./dbs/hub-demo-hive.db");
24
+ const hub_events_db_1 = require("./dbs/hub-events.db");
25
+ const hub_hackschool_db_1 = require("./dbs/hub-hackschool.db");
26
+ const hub_newsroom_db_1 = require("./dbs/hub-newsroom.db");
27
+ const hub_podcasts_db_1 = require("./dbs/hub-podcasts.db");
28
+ const hub_team_db_1 = require("./dbs/hub-team.db");
29
+ const hub_tech_radar_db_1 = require("./dbs/hub-tech-radar.db");
30
+ /**
31
+ * ModelService provides access to all registered Mongoose models in the system.
32
+ * It encapsulates database context and ensures models are instantiated per database.
33
+ */
34
+ let OldModelService = class OldModelService {
35
+ /**
36
+ * Initializes the service with a shared Mongoose connection.
37
+ * @param connection - The active Mongoose connection
38
+ */
39
+ constructor(connection) {
40
+ this.connection = connection;
41
+ }
42
+ /**
43
+ * Creates a namespaced Mongoose model from a specific database.
44
+ *
45
+ * @param database - The name of the database to bind to
46
+ * @param modelName - The name of the model
47
+ * @param schema - The schema definition for the model
48
+ * @returns {Model<InferSchemaType<T>>} A typed Mongoose model instance
49
+ */
50
+ createModelFromDatabase(database, modelName, schema) {
51
+ return this.connection.useDb(database).model(modelName, schema);
52
+ }
53
+ // ──────────────────────────── General Models ─────────────────────────────
54
+ /** Returns the model used for Account entities */
55
+ get accountModel() {
56
+ return this.createModelFromDatabase(hub_account_db_1.AccountDB.name, hub_account_db_1.AccountDB.account.model.name, hub_account_db_1.AccountDB.account.schema);
57
+ }
58
+ /** Returns the model used for Comment entities */
59
+ get commentModel() {
60
+ return this.createModelFromDatabase(hub_comments_db_1.CommentsDB.name, hub_comments_db_1.CommentsDB.comment.model.name, hub_comments_db_1.CommentsDB.comment.schema);
61
+ }
62
+ /** Returns the model used for shared Content entities */
63
+ get contentModel() {
64
+ return this.createModelFromDatabase(hub_content_db_1.ContentDB.name, hub_content_db_1.ContentDB.content.model.name, hub_content_db_1.ContentDB.content.schema);
65
+ }
66
+ // ──────────────────────────── Service Models ─────────────────────────────
67
+ /** Returns the model used for Book resources */
68
+ get bookModel() {
69
+ return this.createModelFromDatabase(hub_books_db_1.BooksDB.name, hub_books_db_1.BooksDB.book.model.name, hub_books_db_1.BooksDB.book.schema);
70
+ }
71
+ /** Returns the model used for DemoHive Demos */
72
+ get demoModel() {
73
+ return this.createModelFromDatabase(hub_demo_hive_db_1.DemoHiveDB.name, hub_demo_hive_db_1.DemoHiveDB.demo.model.name, hub_demo_hive_db_1.DemoHiveDB.demo.schema);
74
+ }
75
+ /** Returns the model used for Event resources */
76
+ get eventModel() {
77
+ return this.createModelFromDatabase(hub_events_db_1.EventsDB.name, hub_events_db_1.EventsDB.event.model.name, hub_events_db_1.EventsDB.event.schema);
78
+ }
79
+ /** Returns the model used for Hackschool Courses */
80
+ get hackschoolCourseModel() {
81
+ return this.createModelFromDatabase(hub_hackschool_db_1.HackschoolDB.name, hub_hackschool_db_1.HackschoolDB.course.model.name, hub_hackschool_db_1.HackschoolDB.course.schema);
82
+ }
83
+ /** Returns the model used for Hackschool Docs */
84
+ get hackschoolDocModel() {
85
+ return this.createModelFromDatabase(hub_hackschool_db_1.HackschoolDB.name, hub_hackschool_db_1.HackschoolDB.doc.model.name, hub_hackschool_db_1.HackschoolDB.doc.schema);
86
+ }
87
+ /** Returns the model used for Hackschool Threads */
88
+ get hackschoolThreadModel() {
89
+ return this.createModelFromDatabase(hub_hackschool_db_1.HackschoolDB.name, hub_hackschool_db_1.HackschoolDB.thread.model.name, hub_hackschool_db_1.HackschoolDB.thread.schema);
90
+ }
91
+ /** Returns the model used for Newsroom News */
92
+ get newsModel() {
93
+ return this.createModelFromDatabase(hub_newsroom_db_1.NewsroomDB.name, hub_newsroom_db_1.NewsroomDB.news.model.name, hub_newsroom_db_1.NewsroomDB.news.schema);
94
+ }
95
+ /** Returns the model used for Podcast resources */
96
+ get podcastModel() {
97
+ return this.createModelFromDatabase(hub_podcasts_db_1.PodcastsDB.name, hub_podcasts_db_1.PodcastsDB.podcast.model.name, hub_podcasts_db_1.PodcastsDB.podcast.schema);
98
+ }
99
+ /** Returns the model used for Team Members */
100
+ get teamMemberModel() {
101
+ return this.createModelFromDatabase(hub_team_db_1.TeamDB.name, hub_team_db_1.TeamDB.member.model.name, hub_team_db_1.TeamDB.member.schema);
102
+ }
103
+ /** Returns the model used for TechRadar Blips */
104
+ get techRadarBlipModel() {
105
+ return this.createModelFromDatabase(hub_tech_radar_db_1.TechRadarDB.name, hub_tech_radar_db_1.TechRadarDB.blip.model.name, hub_tech_radar_db_1.TechRadarDB.blip.schema);
106
+ }
107
+ /** Returns the model used for TechRadar Editions */
108
+ get techRadarEditionModel() {
109
+ return this.createModelFromDatabase(hub_tech_radar_db_1.TechRadarDB.name, hub_tech_radar_db_1.TechRadarDB.edition.model.name, hub_tech_radar_db_1.TechRadarDB.edition.schema);
110
+ }
111
+ // ──────────────────────────── Query Helpers ─────────────────────────────
112
+ /**
113
+ * Fetches a single Account document by its unique ID.
114
+ *
115
+ * @param accountId - The MongoDB ID of the account
116
+ * @returns {Promise<Account>} A single account or null
117
+ */
118
+ async findAccountById(accountId) {
119
+ return this.accountModel.findOne({ _id: accountId });
120
+ }
121
+ /**
122
+ * Fetches multiple Account documents by an array of IDs.
123
+ *
124
+ * @param accountIds - List of account IDs to fetch
125
+ * @returns {Promise<Account[]>} Array of account documents
126
+ */
127
+ async findAccountsByIds(accountIds) {
128
+ return this.accountModel.find({ _id: { $in: accountIds } });
129
+ }
130
+ };
131
+ exports.OldModelService = OldModelService;
132
+ exports.OldModelService = OldModelService = __decorate([
133
+ (0, common_1.Injectable)(),
134
+ __param(0, (0, mongoose_1.InjectConnection)()),
135
+ __metadata("design:paramtypes", [mongoose_2.Connection])
136
+ ], OldModelService);
@@ -0,0 +1,73 @@
1
+ import { PopulateOptions } from 'mongoose';
2
+ import { OldModelService } from '../model-service/model.service';
3
+ /**
4
+ * PopulateService
5
+ *
6
+ * Provides centralized, reusable Mongoose population configurations.
7
+ * Ensures consistent population logic for common document fields,
8
+ * improving maintainability and preventing scattered populate definitions.
9
+ */
10
+ export declare class OldPopulateService {
11
+ private readonly modelService;
12
+ constructor(modelService: OldModelService);
13
+ /**
14
+ * Builds a populate option for a single Account reference.
15
+ *
16
+ * @param {string} fieldPath - The field containing a reference to one Account.
17
+ * @returns {PopulateOptions} - Mongoose populate options for a single reference.
18
+ */
19
+ populateSingleAccount(fieldPath: string): PopulateOptions;
20
+ /**
21
+ * Builds a populate option for an array of Account references.
22
+ *
23
+ * @param {string} fieldPath - The field containing multiple Account references.
24
+ * @returns {PopulateOptions} - Mongoose populate options for multiple references.
25
+ */
26
+ populateMultipleAccounts(fieldPath: string): PopulateOptions;
27
+ /** Populates the `account` field with a single Account */
28
+ get account(): PopulateOptions;
29
+ /** Populates the `author` field with a single Account */
30
+ get author(): PopulateOptions;
31
+ /** Populates the `submitter` field with a single Account */
32
+ get submitter(): PopulateOptions;
33
+ /** Populates the `contact` field with a single Account */
34
+ get contact(): PopulateOptions;
35
+ /** Populates the `accounts` field (array of Account references) */
36
+ get accounts(): PopulateOptions;
37
+ /** Populates the `authors` field (array of Account references) */
38
+ get authors(): PopulateOptions;
39
+ /** Populates the `submitters` field (array of Account references) */
40
+ get submitters(): PopulateOptions;
41
+ /** Populates the `contacts` field (array of Account references) */
42
+ get contacts(): PopulateOptions;
43
+ /** Populates the `viewedBy` field (accounts who viewed the document) */
44
+ get viewedBy(): PopulateOptions;
45
+ /** Populates the `likedBy` field (accounts who liked the document) */
46
+ get likedBy(): PopulateOptions;
47
+ /**
48
+ * Populates the `comments` field with Comment documents (shallow).
49
+ */
50
+ get comments(): PopulateOptions;
51
+ /**
52
+ * Populates `comments`, including each comment's `author`.
53
+ * Useful for rendering user information with comments.
54
+ */
55
+ get commentsWithAuthors(): PopulateOptions;
56
+ /**
57
+ * Populates `comments` and their nested `replies`.
58
+ * Does not include author data.
59
+ */
60
+ get commentsWithReplies(): PopulateOptions;
61
+ /**
62
+ * Fully nested comment population:
63
+ * - `comments`
64
+ * - each comment's `author`
65
+ * - nested `replies` and each reply's `author`
66
+ */
67
+ get commentsWithRepliesAndAuthors(): PopulateOptions;
68
+ /**
69
+ * Populates the `commentsCount` field if linked to a separate model.
70
+ * Assumes the count is stored in a model (denormalized or virtual).
71
+ */
72
+ get commentsCount(): PopulateOptions;
73
+ }
@@ -0,0 +1,163 @@
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.OldPopulateService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const model_service_1 = require("../model-service/model.service");
15
+ /**
16
+ * PopulateService
17
+ *
18
+ * Provides centralized, reusable Mongoose population configurations.
19
+ * Ensures consistent population logic for common document fields,
20
+ * improving maintainability and preventing scattered populate definitions.
21
+ */
22
+ let OldPopulateService = class OldPopulateService {
23
+ constructor(modelService) {
24
+ this.modelService = modelService;
25
+ }
26
+ // ———————————————————————— Core Helpers ————————————————————————
27
+ /**
28
+ * Builds a populate option for a single Account reference.
29
+ *
30
+ * @param {string} fieldPath - The field containing a reference to one Account.
31
+ * @returns {PopulateOptions} - Mongoose populate options for a single reference.
32
+ */
33
+ populateSingleAccount(fieldPath) {
34
+ return {
35
+ path: fieldPath,
36
+ justOne: true,
37
+ model: this.modelService.accountModel,
38
+ };
39
+ }
40
+ /**
41
+ * Builds a populate option for an array of Account references.
42
+ *
43
+ * @param {string} fieldPath - The field containing multiple Account references.
44
+ * @returns {PopulateOptions} - Mongoose populate options for multiple references.
45
+ */
46
+ populateMultipleAccounts(fieldPath) {
47
+ return {
48
+ path: fieldPath,
49
+ justOne: false,
50
+ model: this.modelService.accountModel,
51
+ };
52
+ }
53
+ // ———————————————————————— Common Single Account References ————————————————————————
54
+ /** Populates the `account` field with a single Account */
55
+ get account() {
56
+ return this.populateSingleAccount('account');
57
+ }
58
+ /** Populates the `author` field with a single Account */
59
+ get author() {
60
+ return this.populateSingleAccount('author');
61
+ }
62
+ /** Populates the `submitter` field with a single Account */
63
+ get submitter() {
64
+ return this.populateSingleAccount('submitter');
65
+ }
66
+ /** Populates the `contact` field with a single Account */
67
+ get contact() {
68
+ return this.populateSingleAccount('contact');
69
+ }
70
+ // ———————————————————————— Common Multi-Account References ————————————————————————
71
+ /** Populates the `accounts` field (array of Account references) */
72
+ get accounts() {
73
+ return this.populateMultipleAccounts('accounts');
74
+ }
75
+ /** Populates the `authors` field (array of Account references) */
76
+ get authors() {
77
+ return this.populateMultipleAccounts('authors');
78
+ }
79
+ /** Populates the `submitters` field (array of Account references) */
80
+ get submitters() {
81
+ return this.populateMultipleAccounts('submitters');
82
+ }
83
+ /** Populates the `contacts` field (array of Account references) */
84
+ get contacts() {
85
+ return this.populateMultipleAccounts('contacts');
86
+ }
87
+ /** Populates the `viewedBy` field (accounts who viewed the document) */
88
+ get viewedBy() {
89
+ return this.populateMultipleAccounts('viewedBy');
90
+ }
91
+ /** Populates the `likedBy` field (accounts who liked the document) */
92
+ get likedBy() {
93
+ return this.populateMultipleAccounts('likedBy');
94
+ }
95
+ // ———————————————————————— Comment-related Populations ————————————————————————
96
+ /**
97
+ * Populates the `comments` field with Comment documents (shallow).
98
+ */
99
+ get comments() {
100
+ return {
101
+ path: 'comments',
102
+ justOne: false,
103
+ model: this.modelService.commentModel,
104
+ };
105
+ }
106
+ /**
107
+ * Populates `comments`, including each comment's `author`.
108
+ * Useful for rendering user information with comments.
109
+ */
110
+ get commentsWithAuthors() {
111
+ return {
112
+ path: 'comments',
113
+ justOne: false,
114
+ model: this.modelService.commentModel,
115
+ options: {
116
+ populate: this.author,
117
+ },
118
+ };
119
+ }
120
+ /**
121
+ * Populates `comments` and their nested `replies`.
122
+ * Does not include author data.
123
+ */
124
+ get commentsWithReplies() {
125
+ return {
126
+ path: 'comments',
127
+ justOne: false,
128
+ model: this.modelService.commentModel,
129
+ options: {
130
+ populate: { path: 'replies', model: this.modelService.commentModel },
131
+ },
132
+ };
133
+ }
134
+ /**
135
+ * Fully nested comment population:
136
+ * - `comments`
137
+ * - each comment's `author`
138
+ * - nested `replies` and each reply's `author`
139
+ */
140
+ get commentsWithRepliesAndAuthors() {
141
+ return {
142
+ path: 'comments',
143
+ justOne: false,
144
+ model: this.modelService.commentModel,
145
+ options: {
146
+ populate: [this.author, { path: 'replies', model: this.modelService.commentModel, populate: this.author }],
147
+ },
148
+ };
149
+ }
150
+ // ———————————————————————— Miscellaneous ————————————————————————
151
+ /**
152
+ * Populates the `commentsCount` field if linked to a separate model.
153
+ * Assumes the count is stored in a model (denormalized or virtual).
154
+ */
155
+ get commentsCount() {
156
+ return { path: 'commentsCount', model: this.modelService.commentModel };
157
+ }
158
+ };
159
+ exports.OldPopulateService = OldPopulateService;
160
+ exports.OldPopulateService = OldPopulateService = __decorate([
161
+ (0, common_1.Injectable)(),
162
+ __metadata("design:paramtypes", [model_service_1.OldModelService])
163
+ ], OldPopulateService);
@@ -0,0 +1,32 @@
1
+ import { Model, PopulateOptions } from 'mongoose';
2
+ import { HubResource } from '../../../../hub-resource.enum';
3
+ import { OldModelService } from '../model-service/model.service';
4
+ /**
5
+ * ServiceMapperService provides a centralized mapping between HubResource identifiers
6
+ * and their corresponding Mongoose models. This enables consistent retrieval
7
+ * of model references and automatic generation of populate options for related resources.
8
+ */
9
+ export declare class OldServiceMapperService {
10
+ private readonly modelService;
11
+ /**
12
+ * Initializes the service with dependencies injected.
13
+ * @param modelService - Provides access to all Mongoose models used in the application
14
+ */
15
+ constructor(modelService: OldModelService);
16
+ /**
17
+ * Maps HubResource keys to their corresponding Mongoose Model instances.
18
+ * This object acts as a lookup to resolve resource identifiers to models,
19
+ * enabling dynamic population and query building.
20
+ */
21
+ resourceModels: Partial<Record<HubResource, Model<any>>>;
22
+ /**
23
+ * Generates an array of Mongoose PopulateOptions corresponding to
24
+ * the provided list of HubResources. This facilitates automated
25
+ * population of referenced documents by their resource type.
26
+ *
27
+ * @param {HubResource[]} resources - Array of resource identifiers to generate populate options for
28
+ * Defaults to all HUB_RESOURCES if not specified.
29
+ * @returns {PopulateOptions[]} Array of populate options for use in Mongoose queries
30
+ */
31
+ generatePopulateOptions(resources?: HubResource[]): PopulateOptions[];
32
+ }
@@ -0,0 +1,73 @@
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.OldServiceMapperService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const hub_resource_enum_1 = require("../../../../hub-resource.enum");
15
+ const model_service_1 = require("../model-service/model.service");
16
+ /**
17
+ * ServiceMapperService provides a centralized mapping between HubResource identifiers
18
+ * and their corresponding Mongoose models. This enables consistent retrieval
19
+ * of model references and automatic generation of populate options for related resources.
20
+ */
21
+ let OldServiceMapperService = class OldServiceMapperService {
22
+ /**
23
+ * Initializes the service with dependencies injected.
24
+ * @param modelService - Provides access to all Mongoose models used in the application
25
+ */
26
+ constructor(modelService) {
27
+ this.modelService = modelService;
28
+ /**
29
+ * Maps HubResource keys to their corresponding Mongoose Model instances.
30
+ * This object acts as a lookup to resolve resource identifiers to models,
31
+ * enabling dynamic population and query building.
32
+ */
33
+ this.resourceModels = {
34
+ 'newsroom-news': this.modelService.newsModel,
35
+ 'events-event': this.modelService.eventModel,
36
+ 'demo-hive-demo': this.modelService.demoModel,
37
+ 'tech-radar-blip': this.modelService.techRadarBlipModel,
38
+ 'tech-radar-edition': this.modelService.techRadarEditionModel,
39
+ 'podcasts-podcast': this.modelService.podcastModel,
40
+ 'books-book': this.modelService.bookModel,
41
+ 'hackschool-course': this.modelService.hackschoolCourseModel,
42
+ 'hackschool-thread': this.modelService.hackschoolThreadModel,
43
+ 'hackschool-doc': this.modelService.hackschoolDocModel,
44
+ 'team-member': this.modelService.teamMemberModel,
45
+ // 'newsletter-issue': this.modelService.newsletterModel,
46
+ };
47
+ }
48
+ /**
49
+ * Generates an array of Mongoose PopulateOptions corresponding to
50
+ * the provided list of HubResources. This facilitates automated
51
+ * population of referenced documents by their resource type.
52
+ *
53
+ * @param {HubResource[]} resources - Array of resource identifiers to generate populate options for
54
+ * Defaults to all HUB_RESOURCES if not specified.
55
+ * @returns {PopulateOptions[]} Array of populate options for use in Mongoose queries
56
+ */
57
+ generatePopulateOptions(resources = hub_resource_enum_1.HUB_RESOURCES) {
58
+ const populateOptions = [];
59
+ // Iterate over each resource and build corresponding populate config if model exists
60
+ for (const resource of resources) {
61
+ const model = this.resourceModels[resource];
62
+ if (!model)
63
+ continue;
64
+ populateOptions.push({ path: `ref-${resource}`, model, strictPopulate: false });
65
+ }
66
+ return populateOptions;
67
+ }
68
+ };
69
+ exports.OldServiceMapperService = OldServiceMapperService;
70
+ exports.OldServiceMapperService = OldServiceMapperService = __decorate([
71
+ (0, common_1.Injectable)(),
72
+ __metadata("design:paramtypes", [model_service_1.OldModelService])
73
+ ], OldServiceMapperService);
@@ -0,0 +1,31 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ /**
3
+ * FetchModule
4
+ *
5
+ * Central module for fetching resources.
6
+ *
7
+ * - Use `FetchModule.forRoot()` to make the module globally available across the application.
8
+ * - Use `FetchModule.register()` for feature-scoped usage in specific modules.
9
+ */
10
+ export declare class OldFetchModule {
11
+ /**
12
+ * Internal utility to generate the module configuration.
13
+ *
14
+ * @param {boolean} isGlobal - Whether the module should be globally scoped.
15
+ * @returns {DynamicModule} - Configured dynamic module.
16
+ */
17
+ private static createModule;
18
+ /**
19
+ * Registers the module globally, making FetcbService accessible application-wide.
20
+ *
21
+ * @returns {DynamicModule} - Global dynamic module instance.
22
+ */
23
+ static forRoot(): DynamicModule;
24
+ /**
25
+ * Registers the module locally (non-global), restricting FetcbService
26
+ * to the importing module's scope.
27
+ *
28
+ * @returns {DynamicModule} - Local dynamic module instance.
29
+ */
30
+ static register(): DynamicModule;
31
+ }
@@ -0,0 +1,60 @@
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 OldFetchModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.OldFetchModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const fetch_service_1 = require("./fetch.service");
13
+ /**
14
+ * FetchModule
15
+ *
16
+ * Central module for fetching resources.
17
+ *
18
+ * - Use `FetchModule.forRoot()` to make the module globally available across the application.
19
+ * - Use `FetchModule.register()` for feature-scoped usage in specific modules.
20
+ */
21
+ let OldFetchModule = OldFetchModule_1 = class OldFetchModule {
22
+ /**
23
+ * Internal utility to generate the module configuration.
24
+ *
25
+ * @param {boolean} isGlobal - Whether the module should be globally scoped.
26
+ * @returns {DynamicModule} - Configured dynamic module.
27
+ */
28
+ static createModule(isGlobal) {
29
+ return {
30
+ global: isGlobal,
31
+ module: OldFetchModule_1,
32
+ providers: [fetch_service_1.OldFetchService],
33
+ exports: [fetch_service_1.OldFetchService],
34
+ };
35
+ }
36
+ /**
37
+ * Registers the module globally, making FetcbService accessible application-wide.
38
+ *
39
+ * @returns {DynamicModule} - Global dynamic module instance.
40
+ */
41
+ static forRoot() {
42
+ return this.createModule(true);
43
+ }
44
+ /**
45
+ * Registers the module locally (non-global), restricting FetcbService
46
+ * to the importing module's scope.
47
+ *
48
+ * @returns {DynamicModule} - Local dynamic module instance.
49
+ */
50
+ static register() {
51
+ return this.createModule(false);
52
+ }
53
+ };
54
+ exports.OldFetchModule = OldFetchModule;
55
+ exports.OldFetchModule = OldFetchModule = OldFetchModule_1 = __decorate([
56
+ (0, common_1.Module)({
57
+ providers: [fetch_service_1.OldFetchService],
58
+ exports: [fetch_service_1.OldFetchService],
59
+ })
60
+ ], OldFetchModule);