itlab-internal-services 2.16.8 → 2.16.9
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/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 +1 -1
- 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 +5 -1
- package/dist/classes/fetch-options/viewed-by-options.class.js +1 -1
- 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/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
|
@@ -6,39 +6,40 @@ import { InternalExternalUrl } from './base-urls';
|
|
|
6
6
|
/**
|
|
7
7
|
* BaseHttpService
|
|
8
8
|
*
|
|
9
|
-
* A
|
|
9
|
+
* A structured, type-safe abstraction over Axios that standardizes outbound HTTP requests
|
|
10
|
+
* to other internal or external microservices.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
14
|
-
* -
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - Axios is both callable and constructable, leading to TypeScript conflicts when extended.
|
|
18
|
-
* - Wrapping avoids prototype traps, giving us full control over configuration and flow.
|
|
12
|
+
* ### Key Principles:
|
|
13
|
+
* - **Controlled Configuration:** Rather than subclassing Axios (which creates prototype issues),
|
|
14
|
+
* this class wraps Axios to maintain predictable behavior across environments.
|
|
15
|
+
* - **Environment-Aware Routing:** Selects internal vs. external base URLs automatically based on environment.
|
|
16
|
+
* - **Secure Communication:** Injects a Kubernetes service token into every outbound request header.
|
|
17
|
+
* - **Operational Transparency:** Implements structured logging for observability of inter-service communication.
|
|
19
18
|
*/
|
|
20
19
|
export declare abstract class BaseHttpService {
|
|
21
20
|
private readonly serviceName;
|
|
22
21
|
private readonly baseUrls;
|
|
23
22
|
private readonly authenticationOptions;
|
|
24
23
|
private readonly configService;
|
|
25
|
-
readonly
|
|
24
|
+
readonly httpClient: AxiosInstance;
|
|
26
25
|
protected readonly logger: Logger;
|
|
27
26
|
protected readonly isProduction: boolean;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
28
|
+
* Constructs a base HTTP service instance configured for a downstream microservice.
|
|
30
29
|
*
|
|
31
|
-
* @param {string} serviceName -
|
|
32
|
-
* @param {InternalExternalUrl} baseUrls -
|
|
33
|
-
* @param {AuthenticationModuleOptions} authenticationOptions -
|
|
34
|
-
* @param {ConfigService} configService - NestJS
|
|
30
|
+
* @param {string} serviceName - Name of the downstream service (used for contextualized logs).
|
|
31
|
+
* @param {InternalExternalUrl} baseUrls - Tuple `[internalUrl, externalUrl]`. In production, internal URLs are preferred for security and speed.
|
|
32
|
+
* @param {AuthenticationModuleOptions} authenticationOptions - Configuration containing Kubernetes token.
|
|
33
|
+
* @param {ConfigService} configService - NestJS configuration provider.
|
|
35
34
|
*/
|
|
36
35
|
constructor(serviceName: string, baseUrls: InternalExternalUrl, authenticationOptions: AuthenticationModuleOptions, configService: ConfigService);
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Converts an Axios error into a structured and consistent error format.
|
|
38
|
+
*
|
|
39
|
+
* This allows downstream callers to rely on predictable error shapes,
|
|
40
|
+
* regardless of how the target service responds.
|
|
40
41
|
*
|
|
41
|
-
* @param {any} error - Raw Axios error object.
|
|
42
|
+
* @param {any} error - Raw Axios error object from a failed request.
|
|
42
43
|
* @returns {{ status: number; data: string | Record<string, any>; message: string }}
|
|
43
44
|
*/
|
|
44
45
|
protected parseError(error: any): {
|
|
@@ -47,37 +48,40 @@ export declare abstract class BaseHttpService {
|
|
|
47
48
|
message: string;
|
|
48
49
|
};
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* Retrieves a single resource from the downstream service.
|
|
51
52
|
*
|
|
52
|
-
*
|
|
53
|
-
* -
|
|
54
|
-
* -
|
|
55
|
-
* - Returns `undefined` instead of throwing, enabling graceful fallbacks in callers.
|
|
53
|
+
* Why this abstraction matters:
|
|
54
|
+
* - Prevents unhandled promise rejections by returning `undefined` on failure.
|
|
55
|
+
* - Allows optional per-request configuration without mutating the shared Axios instance.
|
|
56
56
|
*
|
|
57
57
|
* @template T
|
|
58
|
-
* @param {string} endpoint -
|
|
59
|
-
* @param {AxiosRequestConfig} [config={}] - Optional
|
|
60
|
-
*
|
|
61
|
-
* or override default client behavior for this specific request.
|
|
62
|
-
* @returns {Promise<T | undefined>} A promise resolving to the resource of type `T`,
|
|
63
|
-
* or `undefined` if the request fails.
|
|
58
|
+
* @param {string} endpoint - Relative path (e.g., `"/users/42"`).
|
|
59
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request overrides (headers, params, etc.).
|
|
60
|
+
* @returns {Promise<T | undefined>} - The fetched resource, or `undefined` if the request fails.
|
|
64
61
|
*/
|
|
65
62
|
protected fetchResource<T>(endpoint: string, config?: AxiosRequestConfig): Promise<T | undefined>;
|
|
66
63
|
/**
|
|
67
|
-
*
|
|
64
|
+
* Retrieves a collection of resources from the downstream service.
|
|
68
65
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* - Logs request failures with contextual detail for easier troubleshooting.
|
|
72
|
-
* - Returns `undefined` instead of throwing, enabling graceful fallbacks in callers.
|
|
66
|
+
* Handles cases where large sets of IDs need to be split into chunks
|
|
67
|
+
* to avoid exceeding query parameter length limits.
|
|
73
68
|
*
|
|
74
69
|
* @template T
|
|
75
|
-
* @param {string} endpoint -
|
|
76
|
-
* @param {AxiosRequestConfig} [config={}] - Optional
|
|
77
|
-
*
|
|
78
|
-
* or override default client behavior for this specific request.
|
|
79
|
-
* @returns {Promise<T[]>} A promise resolving to an array of resources of type `T`,
|
|
80
|
-
* or an empty array if the request fails.
|
|
70
|
+
* @param {string} endpoint - Relative API path.
|
|
71
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request customization.
|
|
72
|
+
* @returns {Promise<T[]>} - Array of resources, or an empty array if all attempts fail.
|
|
81
73
|
*/
|
|
82
74
|
protected fetchResourceCollection<T>(endpoint: string, config?: AxiosRequestConfig): Promise<T[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Helper for fetching a batch (or full collection) of resources in a single request.
|
|
77
|
+
*
|
|
78
|
+
* Encapsulated separately to isolate retry/fallback behavior and keep
|
|
79
|
+
* the main collection method simpler.
|
|
80
|
+
*
|
|
81
|
+
* @template T
|
|
82
|
+
* @param {string} endpoint - Target API path.
|
|
83
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request customization.
|
|
84
|
+
* @returns {Promise<T[]>} - List of retrieved resources or an empty array if failed.
|
|
85
|
+
*/
|
|
86
|
+
private fetchResourceCollectionBatch;
|
|
83
87
|
}
|
|
@@ -7,29 +7,29 @@ exports.BaseHttpService = void 0;
|
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const class_validator_1 = require("class-validator");
|
|
10
|
+
const itlab_functions_1 = require("itlab-functions");
|
|
10
11
|
const service_auth_guard_1 = require("../authentication/guards/service-auth.guard");
|
|
11
12
|
/**
|
|
12
13
|
* BaseHttpService
|
|
13
14
|
*
|
|
14
|
-
* A
|
|
15
|
+
* A structured, type-safe abstraction over Axios that standardizes outbound HTTP requests
|
|
16
|
+
* to other internal or external microservices.
|
|
15
17
|
*
|
|
16
|
-
*
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* - Axios is both callable and constructable, leading to TypeScript conflicts when extended.
|
|
23
|
-
* - Wrapping avoids prototype traps, giving us full control over configuration and flow.
|
|
18
|
+
* ### Key Principles:
|
|
19
|
+
* - **Controlled Configuration:** Rather than subclassing Axios (which creates prototype issues),
|
|
20
|
+
* this class wraps Axios to maintain predictable behavior across environments.
|
|
21
|
+
* - **Environment-Aware Routing:** Selects internal vs. external base URLs automatically based on environment.
|
|
22
|
+
* - **Secure Communication:** Injects a Kubernetes service token into every outbound request header.
|
|
23
|
+
* - **Operational Transparency:** Implements structured logging for observability of inter-service communication.
|
|
24
24
|
*/
|
|
25
25
|
class BaseHttpService {
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Constructs a base HTTP service instance configured for a downstream microservice.
|
|
28
28
|
*
|
|
29
|
-
* @param {string} serviceName -
|
|
30
|
-
* @param {InternalExternalUrl} baseUrls -
|
|
31
|
-
* @param {AuthenticationModuleOptions} authenticationOptions -
|
|
32
|
-
* @param {ConfigService} configService - NestJS
|
|
29
|
+
* @param {string} serviceName - Name of the downstream service (used for contextualized logs).
|
|
30
|
+
* @param {InternalExternalUrl} baseUrls - Tuple `[internalUrl, externalUrl]`. In production, internal URLs are preferred for security and speed.
|
|
31
|
+
* @param {AuthenticationModuleOptions} authenticationOptions - Configuration containing Kubernetes token.
|
|
32
|
+
* @param {ConfigService} configService - NestJS configuration provider.
|
|
33
33
|
*/
|
|
34
34
|
constructor(serviceName, baseUrls, authenticationOptions, configService) {
|
|
35
35
|
this.serviceName = serviceName;
|
|
@@ -38,26 +38,28 @@ class BaseHttpService {
|
|
|
38
38
|
this.configService = configService;
|
|
39
39
|
this.logger = new common_1.Logger(`${this.serviceName}Service`);
|
|
40
40
|
this.isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
41
|
-
//
|
|
42
|
-
this.
|
|
41
|
+
// Initialize Axios with base URL dynamically selected per environment.
|
|
42
|
+
this.httpClient = axios_1.default.create({
|
|
43
43
|
baseURL: this.baseUrls[this.isProduction ? 0 : 1],
|
|
44
44
|
headers: {
|
|
45
|
-
//
|
|
45
|
+
// Kubernetes internal authentication for secure service-to-service calls.
|
|
46
46
|
[service_auth_guard_1.SERVICE_AUTH_HEADER_KEY]: this.authenticationOptions.k8sToken,
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
|
-
//
|
|
50
|
-
this.
|
|
49
|
+
// Add a request interceptor to log outbound traffic before each request is sent.
|
|
50
|
+
this.httpClient.interceptors.request.use((config) => {
|
|
51
51
|
var _a;
|
|
52
52
|
this.logger.log(`${(_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${config.url}`);
|
|
53
53
|
return config;
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* Converts an Axios error into a structured and consistent error format.
|
|
58
|
+
*
|
|
59
|
+
* This allows downstream callers to rely on predictable error shapes,
|
|
60
|
+
* regardless of how the target service responds.
|
|
59
61
|
*
|
|
60
|
-
* @param {any} error - Raw Axios error object.
|
|
62
|
+
* @param {any} error - Raw Axios error object from a failed request.
|
|
61
63
|
* @returns {{ status: number; data: string | Record<string, any>; message: string }}
|
|
62
64
|
*/
|
|
63
65
|
parseError(error) {
|
|
@@ -67,51 +69,74 @@ class BaseHttpService {
|
|
|
67
69
|
return { status, data, message: (0, class_validator_1.isObject)(data) ? JSON.stringify(data) : String(data) };
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* Retrieves a single resource from the downstream service.
|
|
71
73
|
*
|
|
72
|
-
*
|
|
73
|
-
* -
|
|
74
|
-
* -
|
|
75
|
-
* - Returns `undefined` instead of throwing, enabling graceful fallbacks in callers.
|
|
74
|
+
* Why this abstraction matters:
|
|
75
|
+
* - Prevents unhandled promise rejections by returning `undefined` on failure.
|
|
76
|
+
* - Allows optional per-request configuration without mutating the shared Axios instance.
|
|
76
77
|
*
|
|
77
78
|
* @template T
|
|
78
|
-
* @param {string} endpoint -
|
|
79
|
-
* @param {AxiosRequestConfig} [config={}] - Optional
|
|
80
|
-
*
|
|
81
|
-
* or override default client behavior for this specific request.
|
|
82
|
-
* @returns {Promise<T | undefined>} A promise resolving to the resource of type `T`,
|
|
83
|
-
* or `undefined` if the request fails.
|
|
79
|
+
* @param {string} endpoint - Relative path (e.g., `"/users/42"`).
|
|
80
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request overrides (headers, params, etc.).
|
|
81
|
+
* @returns {Promise<T | undefined>} - The fetched resource, or `undefined` if the request fails.
|
|
84
82
|
*/
|
|
85
83
|
async fetchResource(endpoint, config = {}) {
|
|
84
|
+
// Defensive cleanup: prevent leaking invalid `id` parameters to downstream services.
|
|
85
|
+
if (config.params) {
|
|
86
|
+
delete config.params.ids;
|
|
87
|
+
delete config.params.id;
|
|
88
|
+
}
|
|
86
89
|
try {
|
|
87
|
-
const response = await this.
|
|
90
|
+
const response = await this.httpClient.get(endpoint, config);
|
|
88
91
|
return response.data;
|
|
89
92
|
}
|
|
90
93
|
catch (error) {
|
|
91
94
|
const { message } = this.parseError(error);
|
|
92
|
-
this.logger.error(`Failed to fetch resource
|
|
95
|
+
this.logger.error(`Failed to fetch single resource from "${endpoint}": ${message}. Config: ${JSON.stringify(config)}`);
|
|
93
96
|
return undefined;
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
|
-
*
|
|
100
|
+
* Retrieves a collection of resources from the downstream service.
|
|
98
101
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* - Logs request failures with contextual detail for easier troubleshooting.
|
|
102
|
-
* - Returns `undefined` instead of throwing, enabling graceful fallbacks in callers.
|
|
102
|
+
* Handles cases where large sets of IDs need to be split into chunks
|
|
103
|
+
* to avoid exceeding query parameter length limits.
|
|
103
104
|
*
|
|
104
105
|
* @template T
|
|
105
|
-
* @param {string} endpoint -
|
|
106
|
-
* @param {AxiosRequestConfig} [config={}] - Optional
|
|
107
|
-
*
|
|
108
|
-
* or override default client behavior for this specific request.
|
|
109
|
-
* @returns {Promise<T[]>} A promise resolving to an array of resources of type `T`,
|
|
110
|
-
* or an empty array if the request fails.
|
|
106
|
+
* @param {string} endpoint - Relative API path.
|
|
107
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request customization.
|
|
108
|
+
* @returns {Promise<T[]>} - Array of resources, or an empty array if all attempts fail.
|
|
111
109
|
*/
|
|
112
110
|
async fetchResourceCollection(endpoint, config = {}) {
|
|
111
|
+
var _a;
|
|
112
|
+
const ids = (_a = config.params) === null || _a === void 0 ? void 0 : _a.ids;
|
|
113
|
+
if (!(ids && (0, class_validator_1.isArray)(ids) && ids.length > 50)) {
|
|
114
|
+
return this.fetchResourceCollectionBatch(endpoint, config);
|
|
115
|
+
}
|
|
116
|
+
// Deduplicate and chunk IDs to avoid overloading downstream query limits.
|
|
117
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
118
|
+
const idChunks = (0, itlab_functions_1.createChunks)(uniqueIds, 50);
|
|
119
|
+
// Parallelize requests for each chunk; flatten the results into one array.
|
|
120
|
+
const batchPromises = idChunks.map((chunk) => {
|
|
121
|
+
config.params.ids = chunk;
|
|
122
|
+
return this.fetchResourceCollectionBatch(endpoint, config);
|
|
123
|
+
});
|
|
124
|
+
return (await Promise.all(batchPromises)).flat();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Helper for fetching a batch (or full collection) of resources in a single request.
|
|
128
|
+
*
|
|
129
|
+
* Encapsulated separately to isolate retry/fallback behavior and keep
|
|
130
|
+
* the main collection method simpler.
|
|
131
|
+
*
|
|
132
|
+
* @template T
|
|
133
|
+
* @param {string} endpoint - Target API path.
|
|
134
|
+
* @param {AxiosRequestConfig} [config={}] - Optional request customization.
|
|
135
|
+
* @returns {Promise<T[]>} - List of retrieved resources or an empty array if failed.
|
|
136
|
+
*/
|
|
137
|
+
async fetchResourceCollectionBatch(endpoint, config = {}) {
|
|
113
138
|
try {
|
|
114
|
-
const response = await this.
|
|
139
|
+
const response = await this.httpClient.get(endpoint, config);
|
|
115
140
|
return response.data;
|
|
116
141
|
}
|
|
117
142
|
catch (error) {
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
export type InternalExternalUrl = [internalUrl: string, externalUrl: string];
|
|
2
2
|
export declare class BaseUrls {
|
|
3
|
-
static get
|
|
4
|
-
static get
|
|
5
|
-
static get
|
|
6
|
-
static get
|
|
7
|
-
static get
|
|
8
|
-
static get
|
|
9
|
-
static get
|
|
10
|
-
static get
|
|
11
|
-
static get
|
|
12
|
-
static get
|
|
13
|
-
static get
|
|
14
|
-
static get
|
|
15
|
-
static get
|
|
16
|
-
static get
|
|
17
|
-
static get
|
|
18
|
-
static get
|
|
19
|
-
static get
|
|
20
|
-
static get
|
|
21
|
-
static get
|
|
3
|
+
static get newsroomService(): InternalExternalUrl;
|
|
4
|
+
static get eventsService(): InternalExternalUrl;
|
|
5
|
+
static get hackschoolService(): InternalExternalUrl;
|
|
6
|
+
static get demoHiveService(): InternalExternalUrl;
|
|
7
|
+
static get techRadarService(): InternalExternalUrl;
|
|
8
|
+
static get podcastsService(): InternalExternalUrl;
|
|
9
|
+
static get booksService(): InternalExternalUrl;
|
|
10
|
+
static get teamService(): InternalExternalUrl;
|
|
11
|
+
static get newsletterService(): InternalExternalUrl;
|
|
12
|
+
static get ideasService(): InternalExternalUrl;
|
|
13
|
+
static get lunchRouletteService(): InternalExternalUrl;
|
|
14
|
+
static get filesService(): InternalExternalUrl;
|
|
15
|
+
static get quickLinksService(): InternalExternalUrl;
|
|
16
|
+
static get accountsService(): InternalExternalUrl;
|
|
17
|
+
static get commentsService(): InternalExternalUrl;
|
|
18
|
+
static get conflictsService(): InternalExternalUrl;
|
|
19
|
+
static get notificationsService(): InternalExternalUrl;
|
|
20
|
+
static get mailService(): InternalExternalUrl;
|
|
21
|
+
static get searchService(): InternalExternalUrl;
|
|
22
|
+
static get changelogService(): InternalExternalUrl;
|
|
23
|
+
static get passService(): InternalExternalUrl;
|
|
24
|
+
static get contentService(): InternalExternalUrl;
|
|
22
25
|
}
|
|
@@ -2,116 +2,135 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseUrls = void 0;
|
|
4
4
|
class BaseUrls {
|
|
5
|
-
static get
|
|
5
|
+
static get newsroomService() {
|
|
6
6
|
return [
|
|
7
7
|
'http://organisation-hub-newsroom-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
8
8
|
'https://services.svi-itlab.com/newsroom/',
|
|
9
9
|
];
|
|
10
10
|
}
|
|
11
|
-
static get
|
|
11
|
+
static get eventsService() {
|
|
12
12
|
return [
|
|
13
13
|
'http://organisation-hub-events-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
14
14
|
'https://services.svi-itlab.com/events/',
|
|
15
15
|
];
|
|
16
16
|
}
|
|
17
|
-
static get
|
|
17
|
+
static get hackschoolService() {
|
|
18
18
|
return [
|
|
19
19
|
'http://organisation-hub-hackschool-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
20
20
|
'https://services.svi-itlab.com/hackschool/',
|
|
21
21
|
];
|
|
22
22
|
}
|
|
23
|
-
static get
|
|
23
|
+
static get demoHiveService() {
|
|
24
24
|
return [
|
|
25
25
|
'http://organisation-hub-demo-hive-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
26
26
|
'https://services.svi-itlab.com/demo-hive/',
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
|
-
static get
|
|
29
|
+
static get techRadarService() {
|
|
30
30
|
return [
|
|
31
31
|
'http://organisation-hub-tech-radar-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
32
32
|
'https://services.svi-itlab.com/tech-radar/',
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
|
-
static get
|
|
35
|
+
static get podcastsService() {
|
|
36
36
|
return [
|
|
37
37
|
'http://organisation-hub-podcasts-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
38
38
|
'https://services.svi-itlab.com/podcasts/',
|
|
39
39
|
];
|
|
40
40
|
}
|
|
41
|
-
static get
|
|
41
|
+
static get booksService() {
|
|
42
42
|
return [
|
|
43
43
|
'http://organisation-hub-books-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
44
44
|
'https://services.svi-itlab.com/books/',
|
|
45
45
|
];
|
|
46
46
|
}
|
|
47
|
-
static get
|
|
47
|
+
static get teamService() {
|
|
48
48
|
return [
|
|
49
49
|
'http://organisation-hub-team-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
50
50
|
'https://services.svi-itlab.com/team/',
|
|
51
51
|
];
|
|
52
52
|
}
|
|
53
|
-
static get
|
|
53
|
+
static get newsletterService() {
|
|
54
54
|
return [
|
|
55
55
|
'http://organisation-hub-newsletter-backend.organisation-hub-services.svc.cluster.local:3000/',
|
|
56
56
|
'https://services.svi-itlab.com/newsletter/',
|
|
57
57
|
];
|
|
58
58
|
}
|
|
59
|
-
static get
|
|
59
|
+
static get ideasService() {
|
|
60
60
|
return [
|
|
61
61
|
'http://organisation-hub-ideas-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
62
62
|
'https://services.svi-itlab.com/ideas/',
|
|
63
63
|
];
|
|
64
64
|
}
|
|
65
|
-
static get
|
|
65
|
+
static get lunchRouletteService() {
|
|
66
66
|
return [
|
|
67
67
|
'http://project-lunch-roulette-backend.project-lunch-roulette.svc.cluster.local:3000/',
|
|
68
68
|
'https://services.svi-itlab.com/lunch-roulette/',
|
|
69
69
|
];
|
|
70
70
|
}
|
|
71
|
+
// Services
|
|
72
|
+
static get filesService() {
|
|
73
|
+
return [
|
|
74
|
+
'http://organisation-hub-files-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
75
|
+
'https://services.svi-itlab.com/files/',
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
static get quickLinksService() {
|
|
79
|
+
return [
|
|
80
|
+
'http://organisation-hub-quick-links-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
81
|
+
'https://services.svi-itlab.com/quick-links/',
|
|
82
|
+
];
|
|
83
|
+
}
|
|
71
84
|
// Utils
|
|
72
|
-
static get
|
|
85
|
+
static get accountsService() {
|
|
73
86
|
return [
|
|
74
87
|
'http://organisation-hub-accounts-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
75
88
|
'https://services.svi-itlab.com/accounts/',
|
|
76
89
|
];
|
|
77
90
|
}
|
|
78
|
-
static get
|
|
91
|
+
static get commentsService() {
|
|
79
92
|
return [
|
|
80
93
|
'http://organisation-hub-comments-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
81
94
|
'https://services.svi-itlab.com/comments/',
|
|
82
95
|
];
|
|
83
96
|
}
|
|
84
|
-
static get
|
|
97
|
+
static get conflictsService() {
|
|
98
|
+
return [
|
|
99
|
+
'http://organisation-hub-conflicts-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
100
|
+
'https://services.svi-itlab.com/conflicts/',
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
static get notificationsService() {
|
|
85
104
|
return [
|
|
86
105
|
'http://organisation-hub-notifications-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
87
106
|
'https://services.svi-itlab.com/notifications/',
|
|
88
107
|
];
|
|
89
108
|
}
|
|
90
|
-
static get
|
|
109
|
+
static get mailService() {
|
|
91
110
|
return [
|
|
92
111
|
'http://organisation-hub-email-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
93
112
|
'https://services.svi-itlab.com/email/',
|
|
94
113
|
];
|
|
95
114
|
}
|
|
96
|
-
static get
|
|
115
|
+
static get searchService() {
|
|
97
116
|
return [
|
|
98
117
|
'http://organisation-hub-search-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
99
118
|
'https://services.svi-itlab.com/search/',
|
|
100
119
|
];
|
|
101
120
|
}
|
|
102
|
-
static get
|
|
121
|
+
static get changelogService() {
|
|
103
122
|
return [
|
|
104
123
|
'http://organisation-hub-changelog-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
105
124
|
'https://services.svi-itlab.com/changelog/',
|
|
106
125
|
];
|
|
107
126
|
}
|
|
108
|
-
static get
|
|
127
|
+
static get passService() {
|
|
109
128
|
return [
|
|
110
129
|
'http://organisation-hub-pass-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
111
130
|
'https://services.svi-itlab.com/pass/',
|
|
112
131
|
];
|
|
113
132
|
}
|
|
114
|
-
static get
|
|
133
|
+
static get contentService() {
|
|
115
134
|
return [
|
|
116
135
|
'http://organisation-hub-content-service.organisation-hub-services.svc.cluster.local:3000/',
|
|
117
136
|
'https://services.svi-itlab.com/content/',
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { EntityMap } from '../../../../classes';
|
|
3
|
+
import { Account, User } from '../../../../models';
|
|
4
|
+
import { AuthenticationModuleOptions } from '../../../authentication';
|
|
5
|
+
import { BaseHttpService } from '../../base-http.service';
|
|
6
|
+
import { FetchAccountOptionsDtoV1 } from './fetch-account-options.dto.v1.type';
|
|
7
|
+
/**
|
|
8
|
+
* AccountsService
|
|
9
|
+
*
|
|
10
|
+
* Service client responsible for interacting with the Accounts microservice.
|
|
11
|
+
* Extends `BaseHttpService` to inherit:
|
|
12
|
+
* - Environment-sensitive URL resolution (internal vs. external).
|
|
13
|
+
* - Secure inter-service authentication.
|
|
14
|
+
* - Structured logging for traceability of outbound requests.
|
|
15
|
+
*
|
|
16
|
+
* Why this pattern?
|
|
17
|
+
* - Ensures all outbound calls follow a unified configuration and logging structure.
|
|
18
|
+
* - Promotes strong typing and maintainable HTTP logic.
|
|
19
|
+
* - Makes service interactions predictable and debuggable across environments.
|
|
20
|
+
*/
|
|
21
|
+
export declare class AccountsService extends BaseHttpService {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs an Accounts service client instance.
|
|
24
|
+
*
|
|
25
|
+
* @param {AuthenticationModuleOptions} authenticationOptions - Injected authentication configuration.
|
|
26
|
+
* @param {ConfigService} configService - NestJS ConfigService for environment detection.
|
|
27
|
+
*/
|
|
28
|
+
constructor(authenticationOptions: AuthenticationModuleOptions, configService: ConfigService);
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves a single account entry by its MongoDB identifier.
|
|
31
|
+
*
|
|
32
|
+
* This method gracefully handles downstream failures by logging
|
|
33
|
+
* and returning `undefined` instead of throwing.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} accountId - Unique MongoDB identifier of the account.
|
|
36
|
+
* @param {FetchAccountOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
37
|
+
* @returns {Promise<Account | undefined>} Resolves to an Account or `undefined` on failure.
|
|
38
|
+
*/
|
|
39
|
+
fetchAccountV1(accountId: string, options?: FetchAccountOptionsDtoV1): Promise<Account | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves a collection of account entries.
|
|
42
|
+
*
|
|
43
|
+
* Useful for batch lookups or paginated listings.
|
|
44
|
+
* Returns an empty array if the downstream service call fails.
|
|
45
|
+
*
|
|
46
|
+
* @param {FetchAccountOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
47
|
+
* @returns {Promise<Account[]>} Resolves to a list of accounts, or an empty array if none found.
|
|
48
|
+
*/
|
|
49
|
+
fetchAccountCollectionV1(options?: FetchAccountOptionsDtoV1): Promise<Account[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetches accounts for multiple groups of account IDs and returns a mapped result.
|
|
52
|
+
*
|
|
53
|
+
* This is particularly useful when aggregating accounts related to different entities
|
|
54
|
+
* (e.g., post authors, commenters, likedBy lists).
|
|
55
|
+
*
|
|
56
|
+
* The function ensures:
|
|
57
|
+
* - Each unique account is fetched only once.
|
|
58
|
+
* - The result is returned as an `EntityMap` for O(1) lookups.
|
|
59
|
+
*
|
|
60
|
+
* @param {string[][]} accountIdGroups - Nested arrays of account IDs.
|
|
61
|
+
* @returns {Promise<EntityMap<Account>>} Map of accountId → Account entity.
|
|
62
|
+
*/
|
|
63
|
+
fetchAccountMapV1(accountIdGroups: string[][]): Promise<EntityMap<Account>>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves a single user entry by its MongoDB identifier.
|
|
66
|
+
*
|
|
67
|
+
* This method gracefully handles downstream failures by logging
|
|
68
|
+
* and returning `undefined` instead of throwing.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} userId - Unique MongoDB identifier of the user.
|
|
71
|
+
* @param {FetchAccountOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
72
|
+
* @returns {Promise<User | undefined>} Resolves to an User or `undefined` on failure.
|
|
73
|
+
*/
|
|
74
|
+
fetchUserV1(userId: string, options?: FetchAccountOptionsDtoV1): Promise<User | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves a collection of user entries.
|
|
77
|
+
*
|
|
78
|
+
* Useful for batch lookups or paginated listings.
|
|
79
|
+
* Returns an empty array if the downstream service call fails.
|
|
80
|
+
*
|
|
81
|
+
* @param {FetchAccountOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
82
|
+
* @returns {Promise<User[]>} Resolves to a list of users, or an empty array if none found.
|
|
83
|
+
*/
|
|
84
|
+
fetchUserCollectionV1(options?: FetchAccountOptionsDtoV1): Promise<User[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Fetches users for multiple groups of user IDs and returns a mapped result.
|
|
87
|
+
*
|
|
88
|
+
* This is particularly useful when aggregating users related to different entities
|
|
89
|
+
* (e.g., post authors, commenters, likedBy lists).
|
|
90
|
+
*
|
|
91
|
+
* The function ensures:
|
|
92
|
+
* - Each unique user is fetched only once.
|
|
93
|
+
* - The result is returned as an `EntityMap` for O(1) lookups.
|
|
94
|
+
*
|
|
95
|
+
* @param {string[][]} userIdGroups - Nested arrays of user IDs.
|
|
96
|
+
* @returns {Promise<EntityMap<User>>} Map of userId → User entity.
|
|
97
|
+
*/
|
|
98
|
+
fetchUserMapV1(userIdGroups: string[][]): Promise<EntityMap<User>>;
|
|
99
|
+
}
|