Categories:
aura-mocks-profiles-response-service plugin
Description and guidelines for working with the aura-mocks-profiles-response-service plugin
Introduction
The aura-mocks-profiles-response-service plugin provides the rest of the plugins a specific utility to employ profiles and perform different behaviors, depending on the information received in requests and the configuration by type.
Find more information in the Github repository:
https://github.com/Telefonica/aura-mocks-server/tree/master/src/plugins/aura-mocks-profiles-response-service
How to use
To use it, you must:
- Import services with injected plugins.
- Use Dynamic settings plugin to fetch the profile.
- Use
profileServiceto fetch the profile settings.
import { services } from './services';
const profiles: ProfileSettings[] = services.dynamicSettings?.getSettingsForPlugin('nameOfProfile')?.profiles;
const profileSettings: ProfileSettings = services.profileService.getProfile(profile, profiles);
Methods
getData
/**
* Get data of profile.
*
* @param {string} value Message identifier
* @returns {ProfileData} Profile data
*/
public getData(value: string): ProfileData {
Example
const profileData: ProfileData = services.profileService?.getData(profile);
isProfile
/**
* Determine whether the service contains a correct profile.
*
* @param {string} value Value to test
* @param {ProfileSettings[]} profiles Profile list
* @returns {boolean} Is profile?
*/
public isProfile(value: string, profiles: ProfileSettings[]): boolean {
getProfile
/**
* Get profile from value.
*
* @param {string} value Value to test
* @param {ProfileSettings[]} profiles Profile list
* @returns {ProfileSettings|undefined} Profile settings
*/
public getProfile(value: string, profiles: ProfileSettings[]): ProfileSettings | undefined {
Example
services.profileService.getProfile(profile, profiles);
executeProfile
/**
* Executes given profile.
*
* @param {ProfileSettings} profile Settings of channel.
* @param {object[]} savedMessages Messages stored in cache.
* @param {object} message Message sent by the bridge.
* @param {ResponseMessage} response Default response.
* @param {ProfileData} profileData Profile data
* @returns {ResponseResult} Response result.
*/
public executeProfile(
profile: ProfileSettings,
savedMessages: any[],
message: any,
response: ResponseMessage,
profileData: ProfileData
): ResponseResult {
Example
services.profileService.executeProfile(profileSettings, messages, message, {} as any, profileData);
executeProfileRetries
/**
* Executes profile retries.
*
* @param {ProfileSettings} profile Settings of channel.
* @param {object[]} savedMessages Messages stored in cache.
* @param {object} message Message sent by the bridge.
* @param {ResponseMessage} response Default response.
* @param {ProfileData} profileData Profile data
* @returns {ResponseResult} Response result.
*/
private executeProfileRetries(
profile: ProfileSettings,
savedMessages: any[],
message: any,
response: ResponseMessage,
profileData: ProfileData
): ResponseResult {
Example
this.executeProfileRetries(profile, [{text: 'hola'}], 'hola', response, profileData);
executeProfileTokenExpired
/**
* Execute `tokenExpired` profile.
* Emulate the `token expired` response from 4P.
*
* @param {any} message Message sent by the bridge.
* @returns {ResponseResult} Response result.
*/
private executeProfileTokenExpired(message: any): ResponseResult {
getNamespaceAndProfile
/**
* Get namespace and profile from value.
* Example: '12345|namespace:aura-ap-next|retries:wa-1015&4p-200' => { namespace: 'aura', profile: '12345|retries:wa-1015&4p-200' }
*
* @param {string} value Value to test
* @returns {{ namespace: string, profile: string }} Namespace and profile
*/
public getNamespaceAndProfile(value: string): { namespace: string, profile: string } {
Example
const { namespace, profile } = services.profileService.getNamespaceAndProfile(id);
Last modified January 15, 2025: feat: Documentation Assistant and ATRIA for Linkin Park release #AURA-26619 [RTM] (409958c0)