import XMLElement, { JSONElement } from './Element'; import Registry from './Registry'; import Translator from './Translator'; export type Plugin = (registry: Registry) => void; export interface JSONData { [key: string]: any; } export type FieldName = string; export type XName = string; export type Type = string; export type Version = string; export type VersionType = string; export type FieldImporter = (xml: XMLElement, context: TranslationContext) => T | undefined; export type FieldExporter = (xml: XMLElement, data: T, context: TranslationContext) => void; export type LanguageResolver = (availableLanguages: string[], acceptLanguages: string[], currentLanguage?: string) => string; export interface FieldDefinition { order?: number; importOrder?: number; exportOrder?: number; importer: FieldImporter; exporter: FieldExporter; } export interface Importer { namespace: string; element: string; fields: Map; fieldOrders: Map; } export interface Exporter { namespace: string; element: string; fields: Map; fieldOrders: Map; optionalNamespaces: Map; } export interface ChildTranslator { name: FieldName; translator: Translator; multiple: boolean; selector?: string; } export interface DefinitionUpdateOptions { namespace: string; element: string; type?: string; version?: string; importerOrdering: Map; importers: Map; exporterOrdering: Map; exporters: Map; contexts: Map; optionalNamespaces: Map; typeOrder?: number; } export interface DefinitionOptions
{ namespace: string; element: string; typeField?: string; languageField?: string; type?: string; defaultType?: string; version?: string; defaultVersion?: string; versionField?: string; fields?: { [K in keyof DT]: FieldDefinition>; }; path?: string; aliases?: Array; childrenExportOrder?: { [key: string]: number; }; optionalNamespaces?: { [prefix: string]: string; }; typeOrder?: number; } export interface LinkPath { path: string; multiple?: boolean; selector?: string; contextField?: FieldName; impliedType?: boolean; } export interface LinkOptions { namespace: string; element: string; path: string | string[]; multiple?: boolean; selector?: string; } export interface PathContext { impliedType?: Type; typeField: FieldName; typeValues: Map; versionField: FieldName; } export interface TranslationContext { acceptLanguages?: string[]; resolveLanguage?: LanguageResolver; lang?: string; namespace?: string; data?: JSONData; element?: XMLElement; translator?: Translator; importer?: Importer; exporter?: Exporter; registry?: Registry; path?: string; pathSelector?: string; sanitizers?: { [key: string]: (input: JSONElement | string) => JSONElement | string | undefined; }; } export interface LanguageValue { lang: string; value: T; } export type LanguageSet = Array>; export declare function escapeXML(text: string): string; export declare function unescapeXML(text: string): string; export declare function escapeXMLText(text: string): string; export declare function basicLanguageResolver(available: string[], accept?: string[], current?: string): string;