itlab-internal-services 2.16.8 → 2.16.10
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.
- package/dist/classes/document/likeable-document.class.d.ts +2 -2
- package/dist/classes/document/likeable-document.class.js +6 -3
- package/dist/classes/document/viewable-document.class.d.ts +2 -2
- package/dist/classes/document/viewable-document.class.js +6 -3
- package/dist/classes/entity-map.class.d.ts +1 -1
- package/dist/classes/entity-map.class.js +2 -0
- package/dist/classes/fetch-options/base-options.class.d.ts +9 -0
- package/dist/classes/fetch-options/comments-options.class.d.ts +3 -0
- package/dist/classes/fetch-options/comments-options.class.js +1 -1
- package/dist/classes/fetch-options/content-options.class.d.ts +3 -0
- package/dist/classes/fetch-options/content-options.class.js +1 -1
- package/dist/classes/fetch-options/drafted-options.class.d.ts +5 -1
- package/dist/classes/fetch-options/drafted-options.class.js +3 -2
- package/dist/classes/fetch-options/liked-by-options.class.d.ts +4 -0
- package/dist/classes/fetch-options/liked-by-options.class.js +3 -2
- package/dist/classes/fetch-options/timestamps-options.class.d.ts +4 -1
- package/dist/classes/fetch-options/timestamps-options.class.js +1 -1
- package/dist/classes/fetch-options/viewed-by-options.class.d.ts +7 -2
- package/dist/classes/fetch-options/viewed-by-options.class.js +15 -4
- package/dist/hub-resource.enum.d.ts +10 -10
- package/dist/hub-resource.enum.js +16 -16
- package/dist/modules/comments/comments.controller.js +1 -1
- package/dist/modules/comments/comments.service.d.ts +5 -5
- package/dist/modules/comments/comments.service.js +21 -13
- package/dist/modules/like/like.service.d.ts +1 -1
- package/dist/modules/like/like.service.js +7 -7
- package/dist/modules/merge/merge-module-options.interface.d.ts +2 -2
- package/dist/modules/merge/merge.controller.d.ts +3 -3
- package/dist/modules/merge/merge.service.interface.d.ts +1 -1
- package/dist/modules/services/base-http.service.d.ts +44 -40
- package/dist/modules/services/base-http.service.js +72 -47
- package/dist/modules/services/base-urls.d.ts +22 -19
- package/dist/modules/services/base-urls.js +38 -19
- package/dist/modules/services/providers/accounts/accounts.service.d.ts +99 -0
- package/dist/modules/services/providers/accounts/accounts.service.js +154 -0
- package/dist/modules/services/providers/accounts/fetch-account-options.dto.v1.type.d.ts +29 -0
- package/dist/modules/services/providers/accounts/index.d.ts +2 -0
- package/dist/modules/services/providers/accounts/index.js +18 -0
- package/dist/modules/services/providers/books/books.service.d.ts +49 -0
- package/dist/modules/services/providers/books/books.service.js +79 -0
- package/dist/modules/services/providers/books/fetch-book-options.dto.v1.type.d.ts +27 -0
- package/dist/modules/services/providers/books/index.d.ts +2 -0
- package/dist/modules/services/providers/{notification → books}/index.js +2 -2
- package/dist/modules/services/providers/changelog/changelog.service.d.ts +62 -0
- package/dist/modules/services/providers/changelog/changelog.service.js +79 -0
- package/dist/modules/services/providers/changelog/fetch-change-options.dto.v1.type.d.ts +15 -0
- package/dist/modules/services/providers/changelog/index.d.ts +2 -0
- package/dist/modules/services/providers/changelog/index.js +18 -0
- package/dist/modules/services/providers/conflicts/conflicts.service.d.ts +59 -0
- package/dist/modules/services/providers/conflicts/conflicts.service.js +79 -0
- package/dist/modules/services/providers/conflicts/fetch-conflict-options.dto.v1.type.d.ts +18 -0
- package/dist/modules/services/providers/conflicts/index.d.ts +2 -0
- package/dist/modules/services/providers/conflicts/index.js +18 -0
- package/dist/modules/services/providers/content/content-return-types.d.ts +3 -2
- package/dist/modules/services/providers/content/content-return-types.js +8 -2
- package/dist/modules/services/providers/content/content.service.d.ts +49 -7
- package/dist/modules/services/providers/content/content.service.js +61 -19
- package/dist/modules/services/providers/content/fetch-content-options.dto.v1.type.d.ts +15 -0
- package/dist/modules/services/providers/content/index.d.ts +1 -0
- package/dist/modules/services/providers/content/index.js +1 -0
- package/dist/modules/services/providers/demo-hive/demo-hive.service.d.ts +49 -0
- package/dist/modules/services/providers/demo-hive/demo-hive.service.js +79 -0
- package/dist/modules/services/providers/demo-hive/fetch-demo-options.dto.v1.type.d.ts +16 -0
- package/dist/modules/services/providers/demo-hive/index.d.ts +2 -0
- package/dist/modules/services/providers/demo-hive/index.js +18 -0
- package/dist/modules/services/providers/events/events.service.d.ts +49 -0
- package/dist/modules/services/providers/events/events.service.js +79 -0
- package/dist/modules/services/providers/events/fetch-event-options.dto.v1.type.d.ts +27 -0
- package/dist/modules/services/providers/events/index.d.ts +2 -0
- package/dist/modules/services/providers/events/index.js +18 -0
- package/dist/modules/services/providers/files/crop-image-options.dto.v1.type.d.ts +13 -0
- package/dist/modules/services/providers/files/fetch-file-options.dto.v1.type.d.ts +21 -0
- package/dist/modules/services/providers/files/fetch-folder-options.dto.v1.type.d.ts +15 -0
- package/dist/modules/services/providers/files/files.service.d.ts +106 -0
- package/dist/modules/services/providers/files/files.service.js +146 -0
- package/dist/modules/services/providers/files/index.d.ts +4 -0
- package/dist/modules/services/providers/files/index.js +20 -0
- package/dist/modules/services/providers/hackschool/fetch-course-options.dto.v1.type.d.ts +15 -0
- package/dist/modules/services/providers/hackschool/fetch-doc-options.dto.v1.type.d.ts +17 -0
- package/dist/modules/services/providers/hackschool/fetch-thread-options.dto.v1.type.d.ts +18 -0
- package/dist/modules/services/providers/hackschool/hackschool.service.d.ts +93 -0
- package/dist/modules/services/providers/hackschool/hackschool.service.js +135 -0
- package/dist/modules/services/providers/hackschool/index.d.ts +2 -0
- package/dist/modules/services/providers/hackschool/index.js +18 -0
- package/dist/modules/services/providers/ideas.service.js +1 -1
- package/dist/modules/services/providers/index.d.ts +15 -12
- package/dist/modules/services/providers/index.js +17 -12
- package/dist/modules/services/providers/lunch-roulette.service.js +1 -1
- package/dist/modules/services/providers/mail/dtos/{auth-login-token-mail.dto.d.ts → auth-login-token-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/{auth-password-reset-mail.dto.d.ts → auth-password-reset-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/{event-cancel-mail.dto.d.ts → event-cancel-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/{event-invite-mail.dto.d.ts → event-invite-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/{idea-status-updated-mail.dto.d.ts → idea-status-updated-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/{idea-submitted-mail.dto.d.ts → idea-submitted-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/idea-submitted-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/index.d.ts +14 -14
- package/dist/modules/services/providers/mail/dtos/index.js +14 -14
- package/dist/modules/services/providers/mail/dtos/{lunch-roulette-cancel-mail.dto.d.ts → lunch-roulette-cancel-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/lunch-roulette-cancel-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{lunch-roulette-matched-mail.dto.d.ts → lunch-roulette-matched-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/lunch-roulette-matched-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{lunch-roulette-submitted-mail.dto.d.ts → lunch-roulette-submitted-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/lunch-roulette-submitted-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{lunch-roulette-unmatched-mail.dto.d.ts → lunch-roulette-unmatched-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/lunch-roulette-unmatched-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{newsletter-issue-mail.dto.d.ts → newsletter-issue-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/newsletter-issue-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{newsletter-subscribed-mail.dto.d.ts → newsletter-subscribed-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/newsletter-subscribed-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{newsletter-unsubscribed-mail.dto.d.ts → newsletter-unsubscribed-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/newsletter-unsubscribed-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/dtos/{notification-mail.dto.d.ts → notification-mail.dto.v1.d.ts} +1 -1
- package/dist/modules/services/providers/mail/dtos/notification-mail.dto.v1.js +2 -0
- package/dist/modules/services/providers/mail/mail-types.d.ts +17 -16
- package/dist/modules/services/providers/mail/mail-types.js +31 -14
- package/dist/modules/services/providers/mail/mail.service.d.ts +30 -31
- package/dist/modules/services/providers/mail/mail.service.js +49 -50
- package/dist/modules/services/providers/mail/models/mail-recipient.model.d.ts +2 -0
- package/dist/modules/services/providers/mail/models/mail-recipient.model.js +3 -0
- package/dist/modules/services/providers/newsletter/fetch-issue-options.dto.v1.type.d.ts +16 -0
- package/dist/modules/services/providers/newsletter/fetch-issue-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/newsletter/index.d.ts +2 -0
- package/dist/modules/services/providers/newsletter/index.js +18 -0
- package/dist/modules/services/providers/newsletter/newsletter.service.d.ts +49 -0
- package/dist/modules/services/providers/newsletter/newsletter.service.js +79 -0
- package/dist/modules/services/providers/newsroom/fetch-news-options.dto.v1.type.d.ts +20 -0
- package/dist/modules/services/providers/newsroom/fetch-news-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/newsroom/index.d.ts +2 -0
- package/dist/modules/services/providers/newsroom/index.js +18 -0
- package/dist/modules/services/providers/newsroom/newsroom.service.d.ts +49 -0
- package/dist/modules/services/providers/newsroom/newsroom.service.js +79 -0
- package/dist/modules/services/providers/notifications/dtos/index.d.ts +1 -0
- package/dist/modules/services/providers/{notification → notifications}/dtos/index.js +1 -1
- package/dist/modules/services/providers/{notification/dtos/schedule-notification.dto.d.ts → notifications/dtos/schedule-notification.dto.v1.d.ts} +2 -10
- package/dist/modules/services/providers/notifications/dtos/schedule-notification.dto.v1.js +2 -0
- package/dist/modules/services/providers/notifications/fetch-notification-options.dto.v1.type.d.ts +19 -0
- package/dist/modules/services/providers/notifications/fetch-notification-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/notifications/index.d.ts +3 -0
- package/dist/modules/services/providers/notifications/index.js +19 -0
- package/dist/modules/services/providers/notifications/notifications.service-definition.d.ts +1 -0
- package/dist/modules/services/providers/notifications/notifications.service-definition.js +4 -0
- package/dist/modules/services/providers/{notification/notification.service.d.ts → notifications/notifications.service.d.ts} +41 -5
- package/dist/modules/services/providers/{notification/notification.service.js → notifications/notifications.service.js} +52 -26
- package/dist/modules/services/providers/pass/dtos/{create-guild-member-pass.dto.d.ts → create-guild-member-pass.dto.v1.d.ts} +2 -2
- package/dist/modules/services/providers/pass/dtos/create-guild-member-pass.dto.v1.js +2 -0
- package/dist/modules/services/providers/pass/dtos/{create-team-member-pass.dto.d.ts → create-team-member-pass.dto.v1.d.ts} +2 -2
- package/dist/modules/services/providers/pass/dtos/create-team-member-pass.dto.v1.js +2 -0
- package/dist/modules/services/providers/pass/dtos/index.d.ts +2 -2
- package/dist/modules/services/providers/pass/dtos/index.js +2 -2
- package/dist/modules/services/providers/pass/pass-types.d.ts +3 -3
- package/dist/modules/services/providers/pass/pass.service.d.ts +14 -14
- package/dist/modules/services/providers/pass/pass.service.js +28 -28
- package/dist/modules/services/providers/podcasts/fetch-episode-options.dto.v1.type.d.ts +19 -0
- package/dist/modules/services/providers/podcasts/fetch-episode-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/podcasts/index.d.ts +2 -0
- package/dist/modules/services/providers/podcasts/index.js +18 -0
- package/dist/modules/services/providers/podcasts/podcasts.service.d.ts +49 -0
- package/dist/modules/services/providers/podcasts/podcasts.service.js +79 -0
- package/dist/modules/services/providers/quick-links/fetch-link-options.dto.v1.type.d.ts +14 -0
- package/dist/modules/services/providers/quick-links/fetch-link-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/quick-links/index.d.ts +2 -0
- package/dist/modules/services/providers/quick-links/index.js +18 -0
- package/dist/modules/services/providers/quick-links/quick-links.service.d.ts +61 -0
- package/dist/modules/services/providers/quick-links/quick-links.service.js +79 -0
- package/dist/modules/services/providers/search/dtos/{index-search-document.dto.d.ts → index-document.dto.v1.d.ts} +2 -2
- package/dist/modules/services/providers/search/dtos/index-document.dto.v1.js +2 -0
- package/dist/modules/services/providers/search/dtos/index.d.ts +1 -1
- package/dist/modules/services/providers/search/dtos/index.js +1 -1
- package/dist/modules/services/providers/search/search.service.d.ts +6 -6
- package/dist/modules/services/providers/search/search.service.js +14 -17
- package/dist/modules/services/providers/team/fetch-member-options.dto.v1.type.d.ts +11 -0
- package/dist/modules/services/providers/team/fetch-member-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/team/index.d.ts +2 -0
- package/dist/modules/services/providers/team/index.js +18 -0
- package/dist/modules/services/providers/team/team.service.d.ts +49 -0
- package/dist/modules/services/providers/team/team.service.js +79 -0
- package/dist/modules/services/providers/tech-radar/fetch-blip-options.dto.v1.type.d.ts +19 -0
- package/dist/modules/services/providers/tech-radar/fetch-blip-options.dto.v1.type.js +2 -0
- package/dist/modules/services/providers/tech-radar/fetch-edition-options.dto.v1.type copy.d.ts +15 -0
- package/dist/modules/services/providers/tech-radar/fetch-edition-options.dto.v1.type copy.js +2 -0
- package/dist/modules/services/providers/tech-radar/index.d.ts +3 -0
- package/dist/modules/services/providers/tech-radar/index.js +19 -0
- package/dist/modules/services/providers/tech-radar/tech-radar.service.d.ts +71 -0
- package/dist/modules/services/providers/tech-radar/tech-radar.service.js +107 -0
- package/dist/modules/services/services.module.js +6 -3
- package/dist/pipes/params/hub-id.pipe.js +6 -3
- package/dist/types/likeable.type.d.ts +2 -2
- package/dist/types/viewable.type.d.ts +2 -2
- package/package.json +1 -1
- package/dist/modules/services/providers/accounts.service.d.ts +0 -67
- package/dist/modules/services/providers/accounts.service.js +0 -131
- package/dist/modules/services/providers/books.service.d.ts +0 -29
- package/dist/modules/services/providers/books.service.js +0 -55
- package/dist/modules/services/providers/changelog.service.d.ts +0 -18
- package/dist/modules/services/providers/changelog.service.js +0 -43
- package/dist/modules/services/providers/demo-hive.service.d.ts +0 -29
- package/dist/modules/services/providers/demo-hive.service.js +0 -55
- package/dist/modules/services/providers/events.service.d.ts +0 -29
- package/dist/modules/services/providers/events.service.js +0 -55
- package/dist/modules/services/providers/hackschool.service.d.ts +0 -49
- package/dist/modules/services/providers/hackschool.service.js +0 -79
- package/dist/modules/services/providers/newletter.service.d.ts +0 -29
- package/dist/modules/services/providers/newletter.service.js +0 -55
- package/dist/modules/services/providers/newsroom.service.d.ts +0 -47
- package/dist/modules/services/providers/newsroom.service.js +0 -73
- package/dist/modules/services/providers/notification/dtos/index.d.ts +0 -1
- package/dist/modules/services/providers/notification/index.d.ts +0 -2
- package/dist/modules/services/providers/notification/notification.service-definition.d.ts +0 -1
- package/dist/modules/services/providers/notification/notification.service-definition.js +0 -4
- package/dist/modules/services/providers/podcasts.service.d.ts +0 -29
- package/dist/modules/services/providers/podcasts.service.js +0 -55
- package/dist/modules/services/providers/team.service.d.ts +0 -29
- package/dist/modules/services/providers/team.service.js +0 -55
- package/dist/modules/services/providers/tech-radar.service.d.ts +0 -39
- package/dist/modules/services/providers/tech-radar.service.js +0 -67
- /package/dist/modules/services/providers/{mail/dtos/auth-login-token-mail.dto.js → accounts/fetch-account-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/auth-password-reset-mail.dto.js → books/fetch-book-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/event-cancel-mail.dto.js → changelog/fetch-change-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/event-invite-mail.dto.js → conflicts/fetch-conflict-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/idea-status-updated-mail.dto.js → content/fetch-content-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/idea-submitted-mail.dto.js → demo-hive/fetch-demo-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/lunch-roulette-cancel-mail.dto.js → events/fetch-event-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/lunch-roulette-matched-mail.dto.js → files/crop-image-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/lunch-roulette-submitted-mail.dto.js → files/fetch-file-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/lunch-roulette-unmatched-mail.dto.js → files/fetch-folder-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/newsletter-issue-mail.dto.js → hackschool/fetch-course-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/newsletter-subscribed-mail.dto.js → hackschool/fetch-doc-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/{mail/dtos/newsletter-unsubscribed-mail.dto.js → hackschool/fetch-thread-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/mail/dtos/{notification-mail.dto.js → auth-login-token-mail.dto.v1.js} +0 -0
- /package/dist/modules/services/providers/{notification/dtos/schedule-notification.dto.js → mail/dtos/auth-password-reset-mail.dto.v1.js} +0 -0
- /package/dist/modules/services/providers/{pass/dtos/create-guild-member-pass.dto.js → mail/dtos/event-cancel-mail.dto.v1.js} +0 -0
- /package/dist/modules/services/providers/{pass/dtos/create-team-member-pass.dto.js → mail/dtos/event-invite-mail.dto.v1.js} +0 -0
- /package/dist/modules/services/providers/{search/dtos/index-search-document.dto.js → mail/dtos/idea-status-updated-mail.dto.v1.js} +0 -0
|
@@ -4,8 +4,8 @@ export declare function LikeableDocument<TBase extends new (...args: any[]) => D
|
|
|
4
4
|
requiredPermissions?: string[];
|
|
5
5
|
}): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
|
-
_likedBy
|
|
8
|
-
likes
|
|
7
|
+
_likedBy?: string[];
|
|
8
|
+
likes?: number;
|
|
9
9
|
likedBy?: User[];
|
|
10
10
|
hasLiked(accountId: string): boolean;
|
|
11
11
|
addLike(accountId: string): Promise<number>;
|
|
@@ -18,20 +18,23 @@ const pipes_1 = require("../../pipes");
|
|
|
18
18
|
function LikeableDocument(Base, options) {
|
|
19
19
|
class LikeableDocument extends Base {
|
|
20
20
|
hasLiked(accountId) {
|
|
21
|
-
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = this._likedBy) !== null && _a !== void 0 ? _a : []).includes(accountId);
|
|
22
23
|
}
|
|
23
24
|
async addLike(accountId) {
|
|
25
|
+
var _a;
|
|
24
26
|
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
25
27
|
return this.likes;
|
|
26
|
-
this._likedBy = Array.from(new Set([...this._likedBy, accountId]));
|
|
28
|
+
this._likedBy = Array.from(new Set([...((_a = this._likedBy) !== null && _a !== void 0 ? _a : []), accountId]));
|
|
27
29
|
this.likes = this._likedBy.length;
|
|
28
30
|
await this.save({ timestamps: false });
|
|
29
31
|
return this.likes;
|
|
30
32
|
}
|
|
31
33
|
async removeLike(accountId) {
|
|
34
|
+
var _a;
|
|
32
35
|
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
33
36
|
return this.likes;
|
|
34
|
-
this._likedBy = this._likedBy.filter((id) => id !== accountId);
|
|
37
|
+
this._likedBy = ((_a = this._likedBy) !== null && _a !== void 0 ? _a : []).filter((id) => id !== accountId);
|
|
35
38
|
this.likes = this._likedBy.length;
|
|
36
39
|
await this.save({ timestamps: false });
|
|
37
40
|
return this.likes;
|
|
@@ -4,8 +4,8 @@ export declare function ViewableDocument<TBase extends new (...args: any[]) => D
|
|
|
4
4
|
requiredPermissions?: string[];
|
|
5
5
|
}): {
|
|
6
6
|
new (...args: any[]): {
|
|
7
|
-
_viewedBy
|
|
8
|
-
views
|
|
7
|
+
_viewedBy?: string[];
|
|
8
|
+
views?: number;
|
|
9
9
|
viewedBy?: User[];
|
|
10
10
|
hasViewed(accountId: string): boolean;
|
|
11
11
|
addView(accountId: string): Promise<number>;
|
|
@@ -18,20 +18,23 @@ const pipes_1 = require("../../pipes");
|
|
|
18
18
|
function ViewableDocument(Base, options) {
|
|
19
19
|
class ViewableDocument extends Base {
|
|
20
20
|
hasViewed(accountId) {
|
|
21
|
-
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = this._viewedBy) !== null && _a !== void 0 ? _a : []).includes(accountId);
|
|
22
23
|
}
|
|
23
24
|
async addView(accountId) {
|
|
25
|
+
var _a;
|
|
24
26
|
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
25
27
|
return this.views;
|
|
26
|
-
this._viewedBy = Array.from(new Set([...this._viewedBy, accountId]));
|
|
28
|
+
this._viewedBy = Array.from(new Set([...((_a = this._viewedBy) !== null && _a !== void 0 ? _a : []), accountId]));
|
|
27
29
|
this.views = this._viewedBy.length;
|
|
28
30
|
await this.save({ timestamps: false });
|
|
29
31
|
return this.views;
|
|
30
32
|
}
|
|
31
33
|
async removeView(accountId) {
|
|
34
|
+
var _a;
|
|
32
35
|
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
33
36
|
return this.views;
|
|
34
|
-
this._viewedBy = this._viewedBy.filter((id) => id !== accountId);
|
|
37
|
+
this._viewedBy = ((_a = this._viewedBy) !== null && _a !== void 0 ? _a : []).filter((id) => id !== accountId);
|
|
35
38
|
this.views = this._viewedBy.length;
|
|
36
39
|
await this.save({ timestamps: false });
|
|
37
40
|
return this.views;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Document, FilterQuery, QueryOptions } from 'mongoose';
|
|
2
|
+
export type BaseFetchOptions = {
|
|
3
|
+
id?: string;
|
|
4
|
+
ids?: string[];
|
|
5
|
+
samples?: number;
|
|
6
|
+
sortField?: string;
|
|
7
|
+
sortDirection?: 1 | -1;
|
|
8
|
+
skip?: number;
|
|
9
|
+
limit?: number;
|
|
10
|
+
};
|
|
2
11
|
export declare class BaseOptions {
|
|
3
12
|
/**
|
|
4
13
|
* Basic
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LabComment } from 'itlab-functions';
|
|
2
2
|
import { CommentsService } from '../../modules';
|
|
3
|
+
export type CommentsFetchOptions = {
|
|
4
|
+
includeComments?: boolean;
|
|
5
|
+
};
|
|
3
6
|
export declare function CommentsOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
|
|
4
7
|
new (...args: any[]): {
|
|
5
8
|
[x: string]: any;
|
|
@@ -32,7 +32,7 @@ async function populateComments(options, items, commentsService) {
|
|
|
32
32
|
items.forEach((item) => {
|
|
33
33
|
const itemId = item._id.toString();
|
|
34
34
|
taskManager.add(async () => {
|
|
35
|
-
item.comments = await commentsService.
|
|
35
|
+
item.comments = await commentsService.fetchCachedPopulatedCommentsV1(itemId);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
return taskManager.run();
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LabContent, LabContentPopulated } from 'itlab-functions';
|
|
2
2
|
import { ContentReturnType, ContentService } from '../../modules';
|
|
3
|
+
export type ContentFetchOptions = {
|
|
4
|
+
includeContent?: ContentReturnType;
|
|
5
|
+
};
|
|
3
6
|
export declare function ContentOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
|
|
4
7
|
new (...args: any[]): {
|
|
5
8
|
[x: string]: any;
|
|
@@ -38,7 +38,7 @@ async function populateContent(options, items, contentService) {
|
|
|
38
38
|
items.forEach((item) => {
|
|
39
39
|
const itemId = item._id.toString();
|
|
40
40
|
taskManager.add(async () => {
|
|
41
|
-
item.content = await contentService.
|
|
41
|
+
item.content = await contentService.fetchCachedContentV1(itemId, options.includeContent);
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
return taskManager.run();
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Document, FilterQuery } from 'mongoose';
|
|
2
|
+
export type DraftedFetchOptions = {
|
|
3
|
+
includeDrafted?: boolean;
|
|
4
|
+
isDraft?: boolean;
|
|
5
|
+
};
|
|
2
6
|
export declare function DraftedOptions<TBase extends new (...args: any[]) => any>(Base: TBase, options: {
|
|
3
|
-
requiredPermissions
|
|
7
|
+
requiredPermissions?: string[];
|
|
4
8
|
}): {
|
|
5
9
|
new (...args: any[]): {
|
|
6
10
|
[x: string]: any;
|
|
@@ -36,9 +36,10 @@ function DraftedOptions(Base, options) {
|
|
|
36
36
|
}
|
|
37
37
|
function parseDraftedOptions(options, filterQuery, onDraftsExcluded) {
|
|
38
38
|
// Include draft status in filter if explicitly set
|
|
39
|
-
if (options.isDraft !== undefined)
|
|
39
|
+
if (options.isDraft !== undefined) {
|
|
40
40
|
filterQuery.draft = options.isDraft;
|
|
41
|
-
|
|
41
|
+
}
|
|
42
|
+
else if (options.includeDrafted === undefined) {
|
|
42
43
|
filterQuery.draft = false;
|
|
43
44
|
onDraftsExcluded === null || onDraftsExcluded === void 0 ? void 0 : onDraftsExcluded();
|
|
44
45
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AccountsService } from '../../modules';
|
|
2
2
|
import { IsLikeable } from '../../types';
|
|
3
|
+
export type LikedByFetchOptions = {
|
|
4
|
+
includeLikedBy?: boolean;
|
|
5
|
+
includeLikedByIds?: boolean;
|
|
6
|
+
};
|
|
3
7
|
export declare function LikedByOptions<TBase extends new (...args: any[]) => any>(Base: TBase): {
|
|
4
8
|
new (...args: any[]): {
|
|
5
9
|
[x: string]: any;
|
|
@@ -33,13 +33,14 @@ function LikedByOptions(Base) {
|
|
|
33
33
|
}
|
|
34
34
|
async function populateLikedBy(options, items, accountsService) {
|
|
35
35
|
if (options.includeLikedBy) {
|
|
36
|
-
const userMap = await accountsService.
|
|
36
|
+
const userMap = await accountsService.fetchUserMapV1(items.map((item) => item._likedBy));
|
|
37
37
|
items.forEach((item) => {
|
|
38
38
|
item.likedBy = userMap.getMultiple(item._likedBy);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
items.forEach((item) => {
|
|
42
|
-
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
item.likes = (_c = (_b = (_a = item._likedBy) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : item.likes) !== null && _c !== void 0 ? _c : 0;
|
|
43
44
|
if (!options.includeLikedBy)
|
|
44
45
|
item.likedBy = undefined;
|
|
45
46
|
if (!(options.includeLikedBy || options.includeLikedByIds)) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { HasTimestamps } from '../../types';
|
|
2
|
+
export type TimestampsFetchOptions = {
|
|
3
|
+
includeTimestamps?: boolean;
|
|
4
|
+
};
|
|
2
5
|
export declare function TimestampsOptions<TBase extends new (...args: any[]) => any>(Base: TBase, options: {
|
|
3
|
-
requiredPermissions
|
|
6
|
+
requiredPermissions?: string[];
|
|
4
7
|
}): {
|
|
5
8
|
new (...args: any[]): {
|
|
6
9
|
[x: string]: any;
|
|
@@ -22,7 +22,7 @@ function TimestampsOptions(Base, options) {
|
|
|
22
22
|
(0, swagger_1.ApiPropertyOptional)({}),
|
|
23
23
|
(0, transform_1.BooleanTransform)(),
|
|
24
24
|
(0, class_validator_1.IsOptional)(),
|
|
25
|
-
(0, pipes_1.Restricted)(options.requiredPermissions),
|
|
25
|
+
(0, pipes_1.Restricted)(options === null || options === void 0 ? void 0 : options.requiredPermissions),
|
|
26
26
|
__metadata("design:type", Boolean)
|
|
27
27
|
], TimestampsOptions.prototype, "includeTimestamps", void 0);
|
|
28
28
|
return TimestampsOptions;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Document } from 'mongoose';
|
|
1
2
|
import { AccountsService } from '../../modules';
|
|
2
3
|
import { IsViewable } from '../../types';
|
|
4
|
+
export type ViewedByFetchOptions = {
|
|
5
|
+
includeViewedBy?: boolean;
|
|
6
|
+
includeViewedByIds?: boolean;
|
|
7
|
+
};
|
|
3
8
|
export declare function ViewedByOptions<TBase extends new (...args: any[]) => any>(Base: TBase, options: {
|
|
4
|
-
requiredPermissions
|
|
9
|
+
requiredPermissions?: string[];
|
|
5
10
|
}): {
|
|
6
11
|
new (...args: any[]): {
|
|
7
12
|
[x: string]: any;
|
|
@@ -14,4 +19,4 @@ export declare function populateViewedBy(options: {
|
|
|
14
19
|
includeViewedBy?: boolean;
|
|
15
20
|
includeViewedByIds?: boolean;
|
|
16
21
|
viewedBy?: string;
|
|
17
|
-
}, items: IsViewable[], accountsService: AccountsService): Promise<void>;
|
|
22
|
+
}, items: (Document & IsViewable)[], accountsService: AccountsService): Promise<void>;
|
|
@@ -11,9 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ViewedByOptions = ViewedByOptions;
|
|
13
13
|
exports.populateViewedBy = populateViewedBy;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
14
15
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
16
|
const class_validator_1 = require("class-validator");
|
|
16
|
-
const rxjs_1 = require("rxjs");
|
|
17
17
|
const pipes_1 = require("../../pipes");
|
|
18
18
|
const transform_1 = require("../../transform");
|
|
19
19
|
function ViewedByOptions(Base, options) {
|
|
@@ -37,18 +37,29 @@ function ViewedByOptions(Base, options) {
|
|
|
37
37
|
}
|
|
38
38
|
async function populateViewedBy(options, items, accountsService) {
|
|
39
39
|
if (options.viewedBy) {
|
|
40
|
+
const logger = new common_1.Logger('MongooseModule');
|
|
40
41
|
items.forEach((item) => {
|
|
41
|
-
|
|
42
|
+
var _a;
|
|
43
|
+
const viewedBy = Array.from(new Set([...((_a = item._viewedBy) !== null && _a !== void 0 ? _a : []), options.viewedBy]));
|
|
44
|
+
item
|
|
45
|
+
.updateOne({ $set: { _viewedBy: viewedBy, views: viewedBy.length } }, { timestamps: false })
|
|
46
|
+
.then(() => {
|
|
47
|
+
logger.log(`Added unique accountId '${options.viewedBy}' to '_viewedBy' for document ${item._id.toString()}`);
|
|
48
|
+
})
|
|
49
|
+
.catch((error) => {
|
|
50
|
+
logger.error(`Failed to add accountId '${options.viewedBy}' to attribute '_viewedBy' for document ${item._id.toString()}: ${error.stack}`);
|
|
51
|
+
});
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
54
|
if (options.includeViewedBy) {
|
|
45
|
-
const userMap = await accountsService.
|
|
55
|
+
const userMap = await accountsService.fetchUserMapV1(items.map((item) => item._viewedBy));
|
|
46
56
|
items.forEach((item) => {
|
|
47
57
|
item.viewedBy = userMap.getMultiple(item._viewedBy);
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
60
|
items.forEach((item) => {
|
|
51
|
-
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
item.views = (_c = (_b = (_a = item._viewedBy) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : item.views) !== null && _c !== void 0 ? _c : 0;
|
|
52
63
|
if (!options.includeViewedBy)
|
|
53
64
|
item.viewedBy = undefined;
|
|
54
65
|
if (!(options.includeViewedBy || options.includeViewedByIds)) {
|
|
@@ -20,27 +20,27 @@
|
|
|
20
20
|
export declare enum HubResource {
|
|
21
21
|
NEWSROOM_NEWS = "newsroom-news",
|
|
22
22
|
EVENTS_EVENT = "events-event",
|
|
23
|
+
HACKSCHOOL_COURSE = "hackschool-course",
|
|
24
|
+
HACKSCHOOL_THREAD = "hackschool-thread",
|
|
25
|
+
HACKSCHOOL_DOC = "hackschool-doc",
|
|
23
26
|
DEMO_HIVE_DEMO = "demo-hive-demo",
|
|
24
27
|
TECH_RADAR_BLIP = "tech-radar-blip",
|
|
25
28
|
TECH_RADAR_EDITION = "tech-radar-edition",
|
|
26
|
-
|
|
29
|
+
PODCASTS_EPISODE = "podcasts-podcast",
|
|
27
30
|
BOOKS_BOOK = "books-book",
|
|
28
|
-
HACKSCHOOL_COURSE = "hackschool-course",
|
|
29
|
-
HACKSCHOOL_THREAD = "hackschool-thread",
|
|
30
|
-
HACKSCHOOL_DOC = "hackschool-doc",
|
|
31
31
|
TEAM_MEMBER = "team-member",
|
|
32
32
|
NEWSLETTER_ISSUE = "newsletter-issue",
|
|
33
|
-
|
|
33
|
+
HUB_IDEA = "hub-idea",
|
|
34
34
|
HUB_FILE = "hub-file",
|
|
35
35
|
HUB_QUICK_LINK = "hub-quick-link",
|
|
36
|
+
HUB_USER = "hub-user",
|
|
36
37
|
HUB_COMMENT = "hub-comment",
|
|
37
38
|
HUB_CONFLICT = "hub-conflict",
|
|
38
|
-
HUB_IDEA = "hub-idea",
|
|
39
39
|
HUB_CHANGELOG = "hub-changelog",
|
|
40
40
|
ANY = "any"
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* FetchableHubResource
|
|
43
|
+
* FetchableHubResource TODO: remove
|
|
44
44
|
*
|
|
45
45
|
* Defines a strict subset of `HubResource` values that support fetch operations,
|
|
46
46
|
* such as querying external APIs or syncing with third-party services.
|
|
@@ -51,13 +51,13 @@ export declare enum FetchableHubResource {
|
|
|
51
51
|
NEWSROOM_NEWS = "newsroom-news",
|
|
52
52
|
EVENTS_EVENT = "events-event",
|
|
53
53
|
DEMO_HIVE_DEMO = "demo-hive-demo",
|
|
54
|
+
HACKSCHOOL_COURSE = "hackschool-course",
|
|
55
|
+
HACKSCHOOL_THREAD = "hackschool-thread",
|
|
56
|
+
HACKSCHOOL_DOC = "hackschool-doc",
|
|
54
57
|
TECH_RADAR_BLIP = "tech-radar-blip",
|
|
55
58
|
TECH_RADAR_EDITION = "tech-radar-edition",
|
|
56
59
|
PODCASTS_PODCAST = "podcasts-podcast",
|
|
57
60
|
BOOKS_BOOK = "books-book",
|
|
58
|
-
HACKSCHOOL_COURSE = "hackschool-course",
|
|
59
|
-
HACKSCHOOL_THREAD = "hackschool-thread",
|
|
60
|
-
HACKSCHOOL_DOC = "hackschool-doc",
|
|
61
61
|
TEAM_MEMBER = "team-member",
|
|
62
62
|
NEWSLETTER_ISSUE = "newsletter-issue",
|
|
63
63
|
HUB_USER = "hub-user"
|
|
@@ -24,27 +24,27 @@ var HubResource;
|
|
|
24
24
|
(function (HubResource) {
|
|
25
25
|
HubResource["NEWSROOM_NEWS"] = "newsroom-news";
|
|
26
26
|
HubResource["EVENTS_EVENT"] = "events-event";
|
|
27
|
+
HubResource["HACKSCHOOL_COURSE"] = "hackschool-course";
|
|
28
|
+
HubResource["HACKSCHOOL_THREAD"] = "hackschool-thread";
|
|
29
|
+
HubResource["HACKSCHOOL_DOC"] = "hackschool-doc";
|
|
27
30
|
HubResource["DEMO_HIVE_DEMO"] = "demo-hive-demo";
|
|
28
31
|
HubResource["TECH_RADAR_BLIP"] = "tech-radar-blip";
|
|
29
32
|
HubResource["TECH_RADAR_EDITION"] = "tech-radar-edition";
|
|
30
|
-
HubResource["
|
|
33
|
+
HubResource["PODCASTS_EPISODE"] = "podcasts-podcast";
|
|
31
34
|
HubResource["BOOKS_BOOK"] = "books-book";
|
|
32
|
-
HubResource["HACKSCHOOL_COURSE"] = "hackschool-course";
|
|
33
|
-
HubResource["HACKSCHOOL_THREAD"] = "hackschool-thread";
|
|
34
|
-
HubResource["HACKSCHOOL_DOC"] = "hackschool-doc";
|
|
35
35
|
HubResource["TEAM_MEMBER"] = "team-member";
|
|
36
36
|
HubResource["NEWSLETTER_ISSUE"] = "newsletter-issue";
|
|
37
|
-
HubResource["
|
|
37
|
+
HubResource["HUB_IDEA"] = "hub-idea";
|
|
38
38
|
HubResource["HUB_FILE"] = "hub-file";
|
|
39
39
|
HubResource["HUB_QUICK_LINK"] = "hub-quick-link";
|
|
40
|
+
HubResource["HUB_USER"] = "hub-user";
|
|
40
41
|
HubResource["HUB_COMMENT"] = "hub-comment";
|
|
41
42
|
HubResource["HUB_CONFLICT"] = "hub-conflict";
|
|
42
|
-
HubResource["HUB_IDEA"] = "hub-idea";
|
|
43
43
|
HubResource["HUB_CHANGELOG"] = "hub-changelog";
|
|
44
44
|
HubResource["ANY"] = "any";
|
|
45
45
|
})(HubResource || (exports.HubResource = HubResource = {}));
|
|
46
46
|
/**
|
|
47
|
-
* FetchableHubResource
|
|
47
|
+
* FetchableHubResource TODO: remove
|
|
48
48
|
*
|
|
49
49
|
* Defines a strict subset of `HubResource` values that support fetch operations,
|
|
50
50
|
* such as querying external APIs or syncing with third-party services.
|
|
@@ -56,13 +56,13 @@ var FetchableHubResource;
|
|
|
56
56
|
FetchableHubResource["NEWSROOM_NEWS"] = "newsroom-news";
|
|
57
57
|
FetchableHubResource["EVENTS_EVENT"] = "events-event";
|
|
58
58
|
FetchableHubResource["DEMO_HIVE_DEMO"] = "demo-hive-demo";
|
|
59
|
+
FetchableHubResource["HACKSCHOOL_COURSE"] = "hackschool-course";
|
|
60
|
+
FetchableHubResource["HACKSCHOOL_THREAD"] = "hackschool-thread";
|
|
61
|
+
FetchableHubResource["HACKSCHOOL_DOC"] = "hackschool-doc";
|
|
59
62
|
FetchableHubResource["TECH_RADAR_BLIP"] = "tech-radar-blip";
|
|
60
63
|
FetchableHubResource["TECH_RADAR_EDITION"] = "tech-radar-edition";
|
|
61
64
|
FetchableHubResource["PODCASTS_PODCAST"] = "podcasts-podcast";
|
|
62
65
|
FetchableHubResource["BOOKS_BOOK"] = "books-book";
|
|
63
|
-
FetchableHubResource["HACKSCHOOL_COURSE"] = "hackschool-course";
|
|
64
|
-
FetchableHubResource["HACKSCHOOL_THREAD"] = "hackschool-thread";
|
|
65
|
-
FetchableHubResource["HACKSCHOOL_DOC"] = "hackschool-doc";
|
|
66
66
|
FetchableHubResource["TEAM_MEMBER"] = "team-member";
|
|
67
67
|
FetchableHubResource["NEWSLETTER_ISSUE"] = "newsletter-issue";
|
|
68
68
|
FetchableHubResource["HUB_USER"] = "hub-user";
|
|
@@ -77,22 +77,22 @@ var FetchableHubResource;
|
|
|
77
77
|
exports.HUB_RESOURCES = [
|
|
78
78
|
HubResource.NEWSROOM_NEWS,
|
|
79
79
|
HubResource.EVENTS_EVENT,
|
|
80
|
+
HubResource.HACKSCHOOL_COURSE,
|
|
81
|
+
HubResource.HACKSCHOOL_THREAD,
|
|
82
|
+
HubResource.HACKSCHOOL_DOC,
|
|
80
83
|
HubResource.DEMO_HIVE_DEMO,
|
|
81
84
|
HubResource.TECH_RADAR_BLIP,
|
|
82
85
|
HubResource.TECH_RADAR_EDITION,
|
|
83
|
-
HubResource.
|
|
86
|
+
HubResource.PODCASTS_EPISODE,
|
|
84
87
|
HubResource.BOOKS_BOOK,
|
|
85
|
-
HubResource.HACKSCHOOL_COURSE,
|
|
86
|
-
HubResource.HACKSCHOOL_THREAD,
|
|
87
|
-
HubResource.HACKSCHOOL_DOC,
|
|
88
88
|
HubResource.TEAM_MEMBER,
|
|
89
89
|
HubResource.NEWSLETTER_ISSUE,
|
|
90
|
-
HubResource.
|
|
90
|
+
HubResource.HUB_IDEA,
|
|
91
91
|
HubResource.HUB_FILE,
|
|
92
92
|
HubResource.HUB_QUICK_LINK,
|
|
93
|
+
HubResource.HUB_USER,
|
|
93
94
|
HubResource.HUB_COMMENT,
|
|
94
95
|
HubResource.HUB_CONFLICT,
|
|
95
|
-
HubResource.HUB_IDEA,
|
|
96
96
|
HubResource.HUB_CHANGELOG,
|
|
97
97
|
HubResource.ANY,
|
|
98
98
|
];
|
|
@@ -49,7 +49,7 @@ function createCommentsController(options) {
|
|
|
49
49
|
* @returns {Promise<LabComment>} The saved comment object.
|
|
50
50
|
*/
|
|
51
51
|
async postComment(resourceId, accountId, comment) {
|
|
52
|
-
return this.commentService.
|
|
52
|
+
return this.commentService.postCommentV1(resourceId, accountId, comment);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
__decorate([
|
|
@@ -26,7 +26,7 @@ export declare class CommentsService extends BaseHttpService {
|
|
|
26
26
|
* @param {Connection} connection - Mongoose database connection.
|
|
27
27
|
*/
|
|
28
28
|
constructor(authenticationOptions: AuthenticationModuleOptions, options: CommentsModuleOptions<any>, configService: ConfigService, connection?: Connection, cacheService?: CacheService);
|
|
29
|
-
private get
|
|
29
|
+
private get commentableModel();
|
|
30
30
|
private cacheKey;
|
|
31
31
|
private clearCache;
|
|
32
32
|
/**
|
|
@@ -44,14 +44,14 @@ export declare class CommentsService extends BaseHttpService {
|
|
|
44
44
|
* @throws {NotFoundException} If the resource does not exist.
|
|
45
45
|
* @throws {HttpException} If the internal service call fails.
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
postCommentV1(resourceId: string, accountId: string, richtext: LabContentRichtext): Promise<LabComment>;
|
|
48
48
|
/**
|
|
49
49
|
* Deletes all comments for a given resource.
|
|
50
50
|
* Logs success or failure. Does not throw to avoid disrupting cleanup flows.
|
|
51
51
|
*
|
|
52
52
|
* @param resourceId Unique identifier of the resource whose comments will be deleted.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
deleteCommentsV1(resourceId: string): void;
|
|
55
55
|
/**
|
|
56
56
|
* Retrieves comments from the backend.
|
|
57
57
|
* Provides default values if comments retrieval fails.
|
|
@@ -59,12 +59,12 @@ export declare class CommentsService extends BaseHttpService {
|
|
|
59
59
|
* @param resourceId Unique identifier of the resource.
|
|
60
60
|
* @returns Retrieved comments.
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
fetchPopulatedCommentsV1(resourceId: string): Promise<LabComment[]>;
|
|
63
63
|
/**
|
|
64
64
|
* Retrieves comments from the cache if available; otherwise fetches from the backend.
|
|
65
65
|
*
|
|
66
66
|
* @param resourceId Unique identifier of the resource.
|
|
67
67
|
* @returns Cached or freshly retrieved comments.
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
fetchCachedPopulatedCommentsV1(resourceId: string): Promise<LabComment[]>;
|
|
70
70
|
}
|
|
@@ -40,7 +40,7 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
40
40
|
* @param {Connection} connection - Mongoose database connection.
|
|
41
41
|
*/
|
|
42
42
|
constructor(authenticationOptions, options, configService, connection, cacheService) {
|
|
43
|
-
super('Comment', base_urls_1.BaseUrls.
|
|
43
|
+
super('Comment', base_urls_1.BaseUrls.commentsService, authenticationOptions, configService);
|
|
44
44
|
this.options = options;
|
|
45
45
|
this.connection = connection;
|
|
46
46
|
this.cacheService = cacheService;
|
|
@@ -48,7 +48,7 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
48
48
|
return `${this.options.resource}.${resourceId}.populatedComments`;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
get
|
|
51
|
+
get commentableModel() {
|
|
52
52
|
if (!this.connection) {
|
|
53
53
|
this.logger.debug("Couldn't load comment Model... Not connected to the database");
|
|
54
54
|
return undefined;
|
|
@@ -78,11 +78,11 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
78
78
|
* @throws {NotFoundException} If the resource does not exist.
|
|
79
79
|
* @throws {HttpException} If the internal service call fails.
|
|
80
80
|
*/
|
|
81
|
-
async
|
|
81
|
+
async postCommentV1(resourceId, accountId, richtext) {
|
|
82
82
|
var _a;
|
|
83
83
|
const resourceType = this.options.model.name.toLowerCase();
|
|
84
84
|
// Verify that the resource exists before posting a comment.
|
|
85
|
-
const resource = await ((_a = this.
|
|
85
|
+
const resource = await ((_a = this.commentableModel) === null || _a === void 0 ? void 0 : _a.findOne({ _id: resourceId }));
|
|
86
86
|
if (!resource) {
|
|
87
87
|
this.logger.error(`Cannot post comment: ${resourceType} ${resourceId} not found`);
|
|
88
88
|
throw new common_1.NotFoundException('Kommentar konnte nicht erstellt werden');
|
|
@@ -90,10 +90,10 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
90
90
|
// Extract ownership metadata if configured for downstream use.
|
|
91
91
|
const ownerId = this.options.ownerIdField ? resource[this.options.ownerIdField] : undefined;
|
|
92
92
|
const ownerIds = this.options.ownerIdsField ? resource[this.options.ownerIdsField] : undefined;
|
|
93
|
-
const endpoint = `internal/${this.options.resource}/${resourceId}/${accountId}`;
|
|
93
|
+
const endpoint = `v1/internal/comment/${this.options.resource}/${resourceId}/${accountId}`;
|
|
94
94
|
this.logger.log(`Account ${accountId} is posting a comment on ${resourceType} resource ${resourceId}`);
|
|
95
95
|
try {
|
|
96
|
-
const { data } = await this.
|
|
96
|
+
const { data } = await this.httpClient.post(endpoint, richtext, {
|
|
97
97
|
params: { ownerId, ownerIds },
|
|
98
98
|
});
|
|
99
99
|
this.logger.log(`Account ${accountId} successfully posted a comment on ${resourceType} resource ${resourceId}`);
|
|
@@ -112,10 +112,10 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
112
112
|
*
|
|
113
113
|
* @param resourceId Unique identifier of the resource whose comments will be deleted.
|
|
114
114
|
*/
|
|
115
|
-
|
|
116
|
-
const endpoint = `internal/${this.options.resource}/${resourceId}`;
|
|
115
|
+
deleteCommentsV1(resourceId) {
|
|
116
|
+
const endpoint = `v1/internal/comments/${this.options.resource}/${resourceId}`;
|
|
117
117
|
this.logger.log(`Deleting all comments for ${this.options.resource} ${resourceId}...`);
|
|
118
|
-
this.
|
|
118
|
+
this.httpClient
|
|
119
119
|
.delete(endpoint)
|
|
120
120
|
.then(() => {
|
|
121
121
|
this.logger.log(`All comments for ${this.options.resource} ${resourceId} deleted successfully.`);
|
|
@@ -133,8 +133,16 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
133
133
|
* @param resourceId Unique identifier of the resource.
|
|
134
134
|
* @returns Retrieved comments.
|
|
135
135
|
*/
|
|
136
|
-
async
|
|
137
|
-
return this.fetchResourceCollection(`internal
|
|
136
|
+
async fetchPopulatedCommentsV1(resourceId) {
|
|
137
|
+
return this.fetchResourceCollection(`v1/internal/comments/`, {
|
|
138
|
+
params: {
|
|
139
|
+
resource: this.options.resource,
|
|
140
|
+
resourceId: resourceId,
|
|
141
|
+
isReply: false,
|
|
142
|
+
includeReplies: true,
|
|
143
|
+
includeAuthor: true,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
138
146
|
}
|
|
139
147
|
/**
|
|
140
148
|
* Retrieves comments from the cache if available; otherwise fetches from the backend.
|
|
@@ -142,8 +150,8 @@ let CommentsService = class CommentsService extends base_http_service_1.BaseHttp
|
|
|
142
150
|
* @param resourceId Unique identifier of the resource.
|
|
143
151
|
* @returns Cached or freshly retrieved comments.
|
|
144
152
|
*/
|
|
145
|
-
async
|
|
146
|
-
const fetchPopulatedComments = () => this.
|
|
153
|
+
async fetchCachedPopulatedCommentsV1(resourceId) {
|
|
154
|
+
const fetchPopulatedComments = () => this.fetchPopulatedCommentsV1(resourceId);
|
|
147
155
|
if (this.cacheService) {
|
|
148
156
|
const cacheKey = this.cacheKey(resourceId);
|
|
149
157
|
return this.cacheService.fetchOrStore(cacheKey, fetchPopulatedComments, 60000); // 1 Minute
|
|
@@ -11,7 +11,7 @@ export declare class LikeService {
|
|
|
11
11
|
private readonly moduleOptions;
|
|
12
12
|
private readonly connection;
|
|
13
13
|
private readonly logger;
|
|
14
|
-
private readonly
|
|
14
|
+
private readonly likeableModel;
|
|
15
15
|
/**
|
|
16
16
|
* Constructs the LikeService with a configured model instance.
|
|
17
17
|
*
|
|
@@ -40,7 +40,7 @@ let LikeService = LikeService_1 = class LikeService {
|
|
|
40
40
|
this.connection = connection;
|
|
41
41
|
this.logger = new common_1.Logger(LikeService_1.name);
|
|
42
42
|
const { name, schema } = this.moduleOptions.model;
|
|
43
|
-
this.
|
|
43
|
+
this.likeableModel = this.connection.model(name, schema);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Adds a like from the specified account to a resource.
|
|
@@ -51,8 +51,8 @@ let LikeService = LikeService_1 = class LikeService {
|
|
|
51
51
|
*/
|
|
52
52
|
async addLike(resourceId, accountId) {
|
|
53
53
|
var _a;
|
|
54
|
-
this.logger.debug(`Account ${accountId} liked ${this.
|
|
55
|
-
const resource = await this.
|
|
54
|
+
this.logger.debug(`Account ${accountId} liked ${this.likeableModel.name.toLowerCase()} resource ${resourceId}`);
|
|
55
|
+
const resource = await this.likeableModel.findOne({ _id: resourceId });
|
|
56
56
|
return (_a = resource === null || resource === void 0 ? void 0 : resource.addLike(accountId)) !== null && _a !== void 0 ? _a : 0;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -64,8 +64,8 @@ let LikeService = LikeService_1 = class LikeService {
|
|
|
64
64
|
*/
|
|
65
65
|
async removeLike(resourceId, accountId) {
|
|
66
66
|
var _a;
|
|
67
|
-
this.logger.debug(`Account ${accountId} unliked ${this.
|
|
68
|
-
const resource = await this.
|
|
67
|
+
this.logger.debug(`Account ${accountId} unliked ${this.likeableModel.name.toLowerCase()} resource ${resourceId}`);
|
|
68
|
+
const resource = await this.likeableModel.findOne({ _id: resourceId });
|
|
69
69
|
return (_a = resource === null || resource === void 0 ? void 0 : resource.removeLike(accountId)) !== null && _a !== void 0 ? _a : 0;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -77,8 +77,8 @@ let LikeService = LikeService_1 = class LikeService {
|
|
|
77
77
|
*/
|
|
78
78
|
async hasLiked(resourceId, accountId) {
|
|
79
79
|
var _a;
|
|
80
|
-
this.logger.log(`Checking like status for account ${accountId} on ${this.
|
|
81
|
-
const resource = await this.
|
|
80
|
+
this.logger.log(`Checking like status for account ${accountId} on ${this.likeableModel.name.toLowerCase()} resource ${resourceId}`);
|
|
81
|
+
const resource = await this.likeableModel.findOne({ _id: resourceId });
|
|
82
82
|
return (_a = resource === null || resource === void 0 ? void 0 : resource.hasLiked(accountId)) !== null && _a !== void 0 ? _a : false;
|
|
83
83
|
}
|
|
84
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { MergeServiceClass } from './merge.service.interface';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for registering a merge module feature.
|
|
5
5
|
*/
|
|
@@ -8,7 +8,7 @@ export interface MergeModuleOptions {
|
|
|
8
8
|
* Custom service class responsible for performing merges.
|
|
9
9
|
* Must implement `MergeModuleService`.
|
|
10
10
|
*/
|
|
11
|
-
providerClass: Type<
|
|
11
|
+
providerClass: Type<MergeServiceClass>;
|
|
12
12
|
/**
|
|
13
13
|
* Optional: other modules required by the merge service.
|
|
14
14
|
*/
|