/************************************************************************* * Copyright 2020 Adobe * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute this file in * accordance with the terms of the Adobe license agreement accompanying * it. If you have received this file from a source other than Adobe, * then your use, modification, or distribution of it requires the prior * written permission of Adobe. **************************************************************************/ /** * API to request shell-specific information such as environment and shellInfo. * * ***Import:*** * * ```typescript * import shell from '@adobe/exc-app/shell'; * ``` * * ***Default export:*** * * [ShellApi](../interfaces/shell.shellapi.md#interface-shellapi) * * ***Usage:*** * * Below is an example of how to get various attributes associated to the shell: * * ```typescript * import shell from '@adobe/exc-app/shell'; * * const [env, imsEnv, info] = await Promise.all([ * shell.get('environment'), * shell.get('imsEnvironment'), * shell.get('shellInfo') * ]); * ``` * * ### Receiving updates * * You can also listen for updates on the requested data by listening to specific change events. * * These change events are emitted from the api that the data is requested from. For example, if a * shell calls `await shell.get('shellInfo');` they must listen for the change event on * `shell.on('change:shellInfo')`. If a shell calls `await shell.get('environment')` they must listen for the * change event on `shell.on('change:environment')`. Here is a more detailed example of how the promise * api and change events can be used to keep track of specific values from the config: * * ```typescript * import shell from '@adobe/exc-app/shell'; * * constructor() { * this.state = {environment: null}; * * shell.on('change:environment', (env) => { * this.setState({env}); * }); * } * * async componentDidMount() { * const env = await shell.get('environment'); * this.setState({env}); * } * ``` * @packageDocumentation * @module shell */ import { AIApplicationId } from './ai'; import EventEmitter from './src/EventEmitter'; import type { SubOrg } from './appcontext'; export interface LandingPage { /** * Specifies the Adobe brand icon to use. */ adobeBrandType: string; /** * Unique key to identify the app. */ appId: string; /** * Link to the app. */ href: string; /** * Full name */ longName: string; /** * Branding approved name of the app. */ name: string; } export interface ProfileComponent { editProfileLink: string; signOutLink: string; userAvatarUrl?: string; userName: string; userTitle?: string; } export interface ShellStatus { enabled: boolean; field: string; } export interface ExperienceLeague { communities?: string; filter: string; } export interface SolutionOrService { adobeBrandType: string; agentApplicationId?: AIApplicationId; appId: string; description: string; enabled: boolean; experienceLeague?: ExperienceLeague; functionalIconReact: string; functionalIconUrl: string; href: string; isAgentOrchestratorEnabled: boolean; learnMoreLink?: string; longName: string; name: string; settingsAppId: string; visible: boolean; } export interface SolutionOrServiceExtended extends SolutionOrService { subOrgs?: SubOrg[]; } export interface ShellInfoObject { landingpage: LandingPage; orgId: string; profileComponent: ProfileComponent; services: SolutionOrService[]; solutions: SolutionOrService[]; status: ShellStatus[]; } export interface ExtendedShellInfoObject extends ShellInfoObject { services: SolutionOrServiceExtended[]; solutions: SolutionOrServiceExtended[]; } export interface ShellInfo { cdn: string; environment: string; imsEnvironment: string; shellInfo: ShellInfoObject; } interface ShellInfoEvent { 'change:cdn': string; 'change:environment': string; 'change:imsEnvironment': string; 'change:shellInfo': ShellInfoObject; } export interface ShellApi extends EventEmitter { /** * Gets the specified type of information about the shell. * @param type The type of information to get. */ get(type: T): Promise; /** * Gets the extended shellInfo object. * * ***Example:*** * * ```typescript * shell.getExtendedShellInfo(); * ```` * @returns Extended version of shellInfo object that is available in ready * and configuration events. */ getExtendedShellInfo(): Promise; } declare const shell: ShellApi; export default shell;