import { ConfigService } from '@nestjs/config'; import { LabComment, LabJsonContentRichtext } from 'itlab-functions'; import { Connection } from 'mongoose'; import { AuthenticationModuleOptions } from '../authentication'; import { CacheService } from '../cache'; import { BaseHttpService } from '../services/base-http.service'; import { CommentsModuleOptions } from './comments-module-options.interface'; /** * CommentsService manages persistence and business logic * for adding, comments on resource entities. * * Why: Encapsulates MongoDB operations and ensures consistent handling * of comment-related behavior across all resources that support comments. */ export declare class CommentsService extends BaseHttpService { private readonly options; private readonly connection?; private readonly cacheService?; /** * Constructs the CommentsService with a configured model instance. * * Why: Using the provided Mongoose connection and model options ensures * that comments are tied to the correct resource collection dynamically. * * @param {CommentsModuleOptions} options - Config for the commentable resource model. * @param {Connection} connection - Mongoose database connection. */ constructor(authenticationOptions: AuthenticationModuleOptions, options: CommentsModuleOptions, configService: ConfigService, connection?: Connection, cacheService?: CacheService); private get commentableModel(); private cacheKey; private clearCache; /** * Posts a comment to a given resource, optionally attaching ownership metadata. * * Why: * - Ensures that the resource exists before attempting to save a comment. * - Optionally extracts `ownerId` or `ownerIds` for downstream authorization or notifications. * - Wraps the internal HTTP call in a promise with proper error handling and logging. * * @param {string} resourceId - MongoDB ObjectId of the resource being commented on. * @param {string} accountId - Authenticated user ID posting the comment. * @param {LabJsonContentRichtext} richtext - Comment content in rich-text format. * @returns {Promise} Resolves with the saved comment or throws an HTTP exception. * @throws {NotFoundException} If the resource does not exist. * @throws {HttpException} If the internal service call fails. */ postCommentV1(resourceId: string, accountId: string, richtext: LabJsonContentRichtext): Promise; /** * Deletes all comments for a given resource. * Logs success or failure. Does not throw to avoid disrupting cleanup flows. * * @param resourceId Unique identifier of the resource whose comments will be deleted. */ deleteCommentsV1(resourceId: string): void; /** * Retrieves comments from the backend. * Provides default values if comments retrieval fails. * * @param resourceId Unique identifier of the resource. * @returns Retrieved comments. */ fetchPopulatedCommentsV1(resourceId: string): Promise; /** * Retrieves comments from the cache if available; otherwise fetches from the backend. * * @param resourceId Unique identifier of the resource. * @returns Cached or freshly retrieved comments. */ fetchCachedPopulatedCommentsV1(resourceId: string): Promise; }