import { CaaSMapper } from '.'; import { FetchResponse, ProjectProperties } from '..'; import { NavigationData, QueryBuilderQuery, FetchNavigationParams, FetchElementParams, FetchByFilterParams, FSXARemoteApiConfig, FSXAApi, MappedCaasItem, SortParams, RemoteProjectConfiguration, NormalizedProjectPropertyResponse } from '../types'; import { LogLevel } from './Logger'; type buildNavigationServiceURLParams = { locale?: string; initialPath?: string; all?: boolean; }; type buildCaaSUrlParams = { filters?: QueryBuilderQuery[]; locale?: string; page?: number; pagesize?: number; sort?: SortParams[]; additionalParams?: Record<'keys' | string, any>; remoteProject?: string; id?: string; }; /** * This class represents the `remote` variant of the FSXA API. */ export declare class FSXARemoteApi implements FSXAApi { mode: 'remote'; private _apikey; private _caasURL; private _navigationServiceURL; private _tenantID; private _projectID; private _remotes; private _contentMode; private _maxReferenceDepth?; private _customMapper?; private _queryBuilder; private _logger; private _navigationItemFilter?; private _caasItemFilter?; private _logLevel; private _enableEventStream; private _includeRevisionInMediaUrls; /** * The constructor of this class initializes the configuration for the api. * * @param config {@link FSXARemoteApiConfig FSXARemoteApiConfig} * @param config.apikey * @param config.caasURL * @param config.navigationServiceURL * @param config.tenantID * @param config.projectID * @param config.remotes optional {@link RemoteProjectConfiguration RemoteProjectConfiguration} * @param config.contentMode 'release' | 'preview' * @param config.maxReferenceDepth optional number to define the maximum depth of resolved objects * @param config.customMapper optional {@link CustomMapper CustomMapper} * @param config.filterOptions optional {@link RemoteApiFilterOptions RemoteApiFilterOptions} (EXPERIMENTAL) * @param config.logLevel the used {@link LogLevel LogLevel} for the API `(default LogLevel.ERROR)` - optional * @param config.includeRevisionInMediaUrls whether to append `rev` query param to media URLs `(default: true in preview, false in release)` */ constructor({ apikey, caasURL, navigationServiceURL, tenantID, projectID, remotes, contentMode, maxReferenceDepth, customMapper, filterOptions, logLevel, includeRevisionInMediaUrls, }: FSXARemoteApiConfig); /** * Can be used in CaaS requests. * @returns an object with the configured apikey as value for the authorization key. */ get authorizationHeader(): { authorization: string; }; private verifyRemoteProjectExists; private getRemoteConfigById; /** * This methods builds an URL for the CaaS. * Based upon the optional {@link buildCaaSUrlParams buildCaaSUrlParams} object the returning url can link to any desired document. * @param id a specific CaaS document id * @param locale the locale of CaaS document (id of the document must be set) * @param remoteProject name of the remote project * @param additionalParams additional URL parameters * @param filters filters for CaaS documents - for more details read the [CaaS Platform documentation](https://docs.e-spirit.com/module/caas-platform/CaaS_Platform_Documentation_EN.html#use-of-filters) * @param page number of the page you want to access * @param pagesize number of the resulting CaaS documents * @returns a string that contains the CaaS URL with the configured parameters as query parameters */ buildCaaSUrl({ id, locale, remoteProject: remoteProjectId, additionalParams, filters, page, pagesize, sort, }?: buildCaaSUrlParams): string; /** * This fuction builds the URL for the NavigationService. * Based upon the optional {@link buildNavigationServiceURLParams buildNavigationServiceURLParams} object the returning url can link * to a seo route or a locale specific subtree of the navigation. * For more details how the Navigation Service works, * read the [Navigation Service documentation](https://navigationservice.e-spirit.cloud/docs/user/en/documentation.html). * @param locale value must be ISO conform, both 'en' and 'en_US' are valid." * @param initialPath can be provided when you want to access a subtree of the navigation * @returns {string} the Navigation Service url for either a subtree of or a complete navigation */ buildNavigationServiceUrl({ locale, initialPath, all, }?: buildNavigationServiceURLParams): string; /** * This method fetches the navigation from the configured navigation service. * The {@link FetchNavigationParams FetchNavigationParams} object defines options for the navigation. * Check {@link buildNavigationServiceUrl buildNavigationServiceUrl} to know which URL will be used. * @param locale value must be ISO conform, both 'en' and 'en_US' are valid." * @param initialPath optional value can be provided when you want to access a subtree of the navigation * @param fetchOptions optional object to pass additional request options (Check {@link RequestInit RequestInit}) * @param filterContext an optional value with additional context used for filtering * @returns {Promise} a Promise with the Navigation Service data or null */ fetchNavigation({ locale, initialPath, fetchOptions, filterContext, }: FetchNavigationParams): Promise; private getFilteredNavigation; /** * This method fetches an element from the configured CaaS. * The {@link FetchElementParams FetchElementParams} object defines options to specify your request. * Check {@link buildCaaSUrl buildCaaSUrl} to know which URL will be used. * @typeParam T optional type parameter you can provide to get a typed CaaS object as result. * @param id the CaaS id of the element you want to fetch * @param locale value must be ISO conform, both 'en' and 'en_US' are valid * @param additionalParams optional additional URL parameters * @param remoteProject optional name of the remote project * @param fetchOptions optional object to pass additional request options (Check {@link RequestInit RequestInit}) * @returns {Promise} a Promise with the mapped result */ fetchElement({ id, locale, additionalParams, remoteProject, fetchOptions, filterContext, normalized, }: FetchElementParams): Promise; /** * This method fetches a filtered page from the configured CaaS. * The {@link FetchElementParams FetchElementParams} object defines options to specify your request. * Check {@link buildCaaSUrl buildCaaSUrl} to know which URL will be used. * Example call: * * ```typescript const englishMedia = await fetchByFilter({ filters: [ { field: 'fsType', value: 'Media', operator: ComparisonQueryOperatorEnum.EQUALS, }, ], "en_GB", }) * ``` * @param filters array of {@link QueryBuilderQuery QueryBuilderQuery} to filter you request * @param locale value must be ISO conform, both 'en' and 'en_US' are valid * @param page optional the number of the page you will get results from `(default = 1)` (must be greater than 0) * @param pagesize optional the number of document entries you will get back `(default = 30)` (must be greater than 0) * @param sort optional the parameter to sort the results by `(default = [])`. * @param additionalParams optional additional URL parameters * @param remoteProject optional name of the remote project * @param fetchOptions optional object to pass additional request options (Check {@link RequestInit RequestInit}) * @returns the mapped and filtered response from the CaaS request, * if `additionalParams.keys` are set, the result will be unmapped, * if `data._embedded['rh:doc']` is undefined, the returning result will be the unmapped `data` object */ fetchByFilter({ filters, locale, page, pagesize, additionalParams, remoteProject: remoteProjectId, fetchOptions, filterContext, sort, normalized, }: FetchByFilterParams, mapper?: CaaSMapper): Promise; private filterMapResponse; /** * This method fetches the project properties from the configured CaaS. * It uses {@link fetchByFilter fetchByFilter} to get them. * @param locale value must be ISO conform, both 'en' and 'en_US' are valid * @param additionalParams optional additional URL parameters * @param resolve optional array of fsTypes that will be resolved `(default = 'GCAPage')` * @param filterContext * @param normalized * @returns the resolved project properties */ fetchProjectProperties({ locale, additionalParams, resolve, filterContext, normalized, }: { locale: string; additionalParams?: Record; resolve?: string[]; filterContext?: unknown; normalized?: boolean; }): Promise; private fetchProjectPropertiesNormalized; /** * This method fetches a one-time secure token from the configured CaaS. * This token is used to establish the WebSocket connection. * @returns the secure token */ fetchSecureToken(): Promise; private buildStringifiedQueryParams; /** * @returns the configured apikey */ get apikey(): string; /** * This method sets the string value of the apikey. * @param value the mandatory string value of the apikey */ set apikey(value: string); /** * @returns the configured CaaS base url */ get caasURL(): string; /** * This method sets the base url of the CaaS. * @param value the mandatory base url of the CaaS e.g. `https://customername-dev-caas-api.e-spirit.cloud` */ set caasURL(value: string); /** * @returns the configured FirstSpirit project id */ get projectID(): string; /** * This method sets the FirstSpirit project id * @param value the mandatory FirstSpirit project id */ set projectID(value: string); /** * @returns the configured tenant id */ get tenantID(): string; /** * This method sets the tenant id * @param value the mandatory tenant id (schema: `customername-stage`) */ set tenantID(value: string); /** * @returns the configured NavigationService url */ get navigationServiceURL(): string; /** * This method sets the url of the NavigationService. * @param value the mandatory url of the NavigationService e.g. `https://customername-stage-navigationservice.e-spirit.cloud/navigation` */ set navigationServiceURL(value: string); /** * @returns the configured remote project configuration */ get remotes(): RemoteProjectConfiguration; /** * This method sets the remote project configuration * @param value the mandatory remote project configuration * example: * ```typescript { "media": { "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "locale": "en_GB" } } ``` */ set remotes(value: RemoteProjectConfiguration); /** * @returns the configured content mode * `preview` links to the unreleased content * `release` links to the published content */ get contentMode(): 'preview' | 'release'; /** * This method sets the content mode * @param value the mandatory value of the content mode (allowed: `preview`, `release`) */ set contentMode(value: 'preview' | 'release'); /** * @returns whether revision query parameter `rev` is appended to media URLs */ get includeRevisionInMediaUrls(): boolean; /** * Sets whether revision query parameter `rev` is appended to media URLs */ set includeRevisionInMediaUrls(value: boolean); /** * @returns the configured log level */ get logLevel(): LogLevel; /** * Getter/Setter to enable the CaaS event stream * @returns true, if a event stream should pipe events from CaaS change events websocket */ enableEventStream(enable?: boolean): boolean; } export {};