/** * TemplateConfig defines configuration rules for system-based variables (e.g. $user.role). * They are currently used for providing default values in FieldConfig. */ import { UUID } from '../uuid'; import { FieldValue } from './FieldValue'; /** * Available system variables for configuration. */ export type SystemVariables = { user: { id: string; name?: string; role?: string; firstname?: string; middlename?: string; surname?: string; primaryOfficeId?: UUID; fullHonorificName?: string; administrativeAreaId?: UUID; device?: string; avatar?: string; signature?: string; }; $window: { location: { href: string; pathname: string; hostname: string; originPathname: string; }; }; }; /** * Resolves `window().location.get('href')` to `window.location.href` to allow us to 1) type check system variables 2) change the implementation later if needed */ export declare const window: () => { location: { get: (key: "href" | "pathname" | "hostname" | "originPathname") => string; }; }; /** * Recursively flatten the keys of an object. Used to limit types when configuring default values in country config. * @example * type Test = FlattenedKeyStrings<{ a: { b: string, c: { d: string } } }> * // 'a.b' | 'a.c.d' but not 'a' or 'a.c' */ type FlattenedKeyStrings = { [K in keyof T]: T[K] extends Record ? FlattenedKeyStrings : `${Prefix}${K & string}`; }[keyof T]; export type FlattenenedSystemVariables = FlattenedKeyStrings; /** * Default value for a field when configuring a form. */ export type FieldConfigDefaultValue = FieldValue | FlattenenedSystemVariables | Record; export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenenedSystemVariables; export declare function isFieldValue(value: FieldConfigDefaultValue): value is FieldValue; /** * Checks if given value is valid for a field, and known template variables are already resolved. * @todo: Extend functionality to arbitrary depth objects. Currently only checks first level since our compoosite fields are only 1 level deep. */ export declare function isFieldValueWithoutTemplates(value: FieldConfigDefaultValue): value is FieldValue; export declare function isFieldConfigDefaultValue(value: any): value is FieldConfigDefaultValue; export {}; //# sourceMappingURL=TemplateConfig.d.ts.map