Utilities
The @telia-ace/alliance-utilities
package enhances app developers' experiences by offering easy-to-use utilities that encapsulate the core framework APIs.
getCurrentUser
Fetches the the currentUser
managed object and adds some high level quality of life functions on top.
Note: this utility requires either the Developer Tools app or the User Control app to be installed and running in your development environment.
import { getCurrentUser } from '@telia-ace/alliance-utilities';
const currentUser = await getCurrentUser();
hasRole
user.hasRole(role: string): boolean
Checks whether or not the user has a specific role.
import { getCurrentUser } from '@telia-ace/alliance-utilities';
const user = await getCurrentUser();
const hasAccessControlAdministratorRole = user.hasRole('access-control-administrator');
getCurrentWorkspace
Fetches the the currentWorkspace
managed object.
Note: this utility requires either the Developer Tools app or the User Control app to be installed and running in your development environment.
import { getCurrentWorkspace } from '@telia-ace/alliance-utilities';
const currentWorkspace = await getCurrentWorkspace();
getCurrentOrganization
Fetches the the currentOrganization
managed object.
Note: this utility requires either the Developer Tools app or the User Control app to be installed and running in your development environment.
import { getCurrentOrganization } from '@telia-ace/alliance-utilities';
const currentOrganization = await getCurrentOrganization();
getTranslator
getTranslator(): Promise<(key: string, variables?: Record<string, string>) => string>
Returns a promise that resolves to a function for retrieving localized texts from your app manifest in the currently selected language.
INFO
The Translator will first attempt to retrieve the text in the currently selected language. If that is not available, it will default to English. Should English also be unavailable, it will fall back to the default value defined in the app manifest.
import { getTranslator } from '@telia-ace/alliance-utilities';
const translate = await getTranslator();
const greeting = translate('greeting', { user: 'John Doe' });
Predefined texts
The Localization API predefines certain texts that all apps have in common.
Key | Default | Description |
---|---|---|
app-name | Defaults to the name defined in the app manifest. | |
app-description | '' | Description used when contextualising the app in user views. |