UNPKG

@appsemble/lang-sdk

Version:

Language SDK for Appsemble

76 lines (75 loc) 2.01 kB
import { type IntlMessageFormat } from 'intl-messageformat'; import { type AppMemberInfo, type Remapper } from './types/index.js'; export interface IntlMessage { id?: string; defaultMessage?: string; } /** * Get a message format instance based on a message id and default message. * * @param msg The message to get the message format instance for. * @returns A message format instance. */ export type MessageGetter = (msg: IntlMessage) => IntlMessageFormat; export type AppConfigEntryValue = boolean | number | string | undefined; export type AppConfigEntryGetter = (name: string) => AppConfigEntryValue; export interface RemapperContext { /** * The id of the app whose context the remapper is run in. */ appId: number; /** * The current URL. */ url: string; /** * The base URL of the app. */ appUrl: string; /** * @see MessageGetter */ getMessage: MessageGetter; /** * @see VariableGetter */ getVariable: AppConfigEntryGetter; /** * The history stack containing the states before an action was called. */ history?: unknown[]; /** * The current locale of the app. */ locale: string; /** * Custom data that is available in the page. */ pageData?: unknown; /** * The OpenID compatible userinfo object for the current app member. */ appMemberInfo: AppMemberInfo; /** * A custom context passed to the remap function. */ context: Record<string, any>; } interface InternalContext extends RemapperContext { root?: unknown; array?: { index: number; length: number; item: unknown; prevItem: unknown; nextItem: unknown; }; stepRef?: { current: Record<string, any>; }; tabRef?: { current: Record<string, any>; }; } export declare function remap(remapper: Remapper, input: unknown, context: InternalContext | RemapperContext): unknown; export {};