import { DynamicModule } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { LabHtmlContent, LabJsonContent, LabTextContent } from 'itlab-functions'; import { HubResource } from '../../../../hub-resource.enum'; import { AuthenticationModuleOptions } from '../../../authentication'; import { CacheService } from '../../../cache'; import { BaseHttpService } from '../../base-http.service'; import { ServicesModuleOptions } from '../../services-module-options.interface'; import { ContentReturnType, ContentReturnTypeMap } from './content-return-types'; import { FetchContentOptionsDtoV1 } from './fetch-content-options.dto.v1.type'; /** * Parameter decorator to inject the feature-specific ContentService. */ export declare function InjectFeatureContentService(): ParameterDecorator; type ContentSchema = { id: string; _resource: string; _resourceId: string; json: LabJsonContent; html: LabHtmlContent; text: LabTextContent; }; /** * Service responsible for all operations with the Organisation Hub Content Service. * * This includes: * - Validating content structure before submission. * - Submitting content to the backend. * - Removing content from the backend. * - Retrieving content in multiple formats. * * Optionally supports caching via `CacheService` for read operations. */ export declare class ContentService extends BaseHttpService { readonly options: ServicesModuleOptions; private readonly cacheService?; /** * Creates a ContentService client for a specific resource. * * @param authenticationOptions Authentication options injected from the Auth module. * @param options Options specifying the resource type this service operates on. * @param configService NestJS configuration service for environment variables and URLs. * @param cacheService Optional caching service for retrieving content efficiently. */ constructor(authenticationOptions: AuthenticationModuleOptions, options: ServicesModuleOptions, configService: ConfigService, cacheService?: CacheService); /** * Factory method to create a dynamic module for a specific Hub resource. * * @param resource The HubResource type this module will provide content services for. * @returns A DynamicModule with a provider for the specified ContentService instance. */ static forResource(resource: HubResource): DynamicModule; private cacheKey; private clearCache; /** * Retrieves a single content entry by its MongoDB identifier. * * This method gracefully handles downstream failures by logging * and returning `undefined` instead of throwing. * * @param {string} contentId - Unique MongoDB identifier of the content. * @param {FetchContentOptionsDtoV1} [options] - Optional query parameters for filtering or projection. * @returns {Promise} Resolves to an Content or `undefined` on failure. */ fetchContentSchemaV1(contentId: string, options?: FetchContentOptionsDtoV1): Promise; /** * Retrieves a collection of content entries. * * Useful for batch lookups or paginated listings. * Returns an empty array if the downstream service call fails. * * @param {FetchContentOptionsDtoV1} [options] - Optional filter options for narrowing results. * @returns {Promise} Resolves to a list of contents, or an empty array if none found. */ fetchContentSchemaCollectionV1(options?: FetchContentOptionsDtoV1): Promise; /** * Retrieves a single content entry by its resource and resourceId identifiers. * * This method gracefully handles downstream failures by logging * and returning `undefined` instead of throwing. * * @param {string} resource - Resource Type of the content. * @param {string} resourceId - Unique MongoDB identifier of Resource of the content. * @param {FetchContentOptionsDtoV1} [options] - Optional query parameters for filtering or projection. * @returns {Promise} Resolves to an Content or `undefined` on failure. */ fetchContentSchemaOfResourceV1(resource: string, resourceId: string, options?: FetchContentOptionsDtoV1): Promise; /** * Validates the given content object using the backend service. * Logs the process and throws an HTTP exception if validation fails. * * @param content Content object to validate. * @returns Resolves if validation is successful. * @throws HttpException if the backend returns an error. */ validateContentV1(content: LabJsonContent): Promise; /** * Submits content for a given resource. * * @param resourceId Unique identifier of the resource. * @param content Content object to submit. * @throws HttpException if the backend returns an error. */ submitContentV1(resourceId: string, content: LabJsonContent): Promise; /** * Directly submits content without extra validation. * Backend will handle validation internally. * * @param resourceId Unique identifier of the resource. * @param content Content object to submit. * @throws HttpException if the backend returns an error. */ validateAndSubmitContentV1(resourceId: string, content: LabJsonContent): Promise; /** * Removes content associated with a given resource. * Logs errors but does not throw; always resolves to allow safe cleanup. * * @param resourceId Unique identifier of the resource. */ deleteContentV1(resourceId: string): void; /** * Retrieves content in a specified format from the backend. * Provides default values if content retrieval fails. * * @param resourceId Unique identifier of the resource. * @param returnType Format of content to retrieve ('json', 'text', 'html', 'populated'). * @returns Retrieved content in the requested format. */ fetchContentV1(resourceId: string, returnType: ReturnType): Promise; /** * Retrieves content from the cache if available; otherwise fetches from the backend. * * @param resourceId Unique identifier of the resource. * @param returnType Format of content to retrieve. * @returns Cached or freshly retrieved content. */ fetchCachedContentV1(resourceId: string, returnType: ReturnType): Promise; } export {};