Skip to content

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 System Management app to be installed and running in your development environment.

ts
import { getCurrentUser } from '@telia-ace/alliance-utilities';

const currentUser = await getCurrentUser();

hasPermission

user.hasPermission(appName: string, permissionName: string): boolean

Checks whether or not the user has a given permission.

ts
import { getCurrentUser } from '@telia-ace/alliance-utilities';

const user = await getCurrentUser();
const hasWriteArticlePermission = user.hasPermission('article-app', 'write-article');

isSystemAdmin

user.isSystemAdmin(): boolean

Checks whether or not the user is a system admin.

ts
import { getCurrentUser } from '@telia-ace/alliance-utilities';

const user = await getCurrentUser();
const userIsSystemAdmin = user.isSystemAdmin();

getCurrentWorkspace

Fetches the the currentWorkspace managed object.

Note: this utility requires either the Developer Tools app or the System Management app to be installed and running in your development environment.

ts
import { getCurrentWorkspace } from '@telia-ace/alliance-utilities';

const currentWorkspace = await getCurrentWorkspace();

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.

ts
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.

KeyDefaultDescription
app-nameDefaults to the name defined in the app manifest.
app-description''Description used when contextualising the app in user views.