import { ILandingPageInfoResponse } from './dto/landing-page-info'; import { IHasFields, ModuleClass, OnInit } from './interfaces'; import { FullcubeApi, IApiOptions } from './services/fullcube-api'; import { I18n, II18nOptions } from './services/i18n'; export declare type ITransactionType = 'error' | 'performance' | 'request'; export interface IElasticApmSpan { end(): void; } export interface IElasticApmTransaction { end(): void; startSpan(name: string, type?: string, options?: any): IElasticApmSpan; } export interface IElasticApm { setCustomContext(context: any): void; startTransaction(name: string, type?: ITransactionType, options?: any): IElasticApmTransaction; addLabels(labels: { [name: string]: string; }): void; captureError(err: Error): void; } export interface IElasticInitApmOptions { serviceName: string; serverUrl: string; serviceVersion?: string; environment?: 'development' | 'production'; logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error'; breakdownMetrics?: boolean; instrument?: boolean; active?: boolean; flushInterval?: number; distributedTracing?: boolean; centralConfig?: boolean; } export declare type IElasticInitApm = { init: (options: IElasticInitApmOptions) => IElasticApm; }; export interface IDomOptions { disabledClasses: string[]; errorClasses: string[]; feedbackSuffix: string; idPrefix: string; } export interface IAction { name: string; options?: () => any; module?: string; ignoreError?: boolean; } export interface IModule { name: string; options?: any; } export interface IAssets { path: string; } export interface IOptions { modules: IModule[]; actions: IAction[]; api: IApiOptions; assets: IAssets; dom: IDomOptions; i18n: II18nOptions; } /** * Main class responsible for whole integration process. Performs methods shared by different modules. */ export declare class Campaign { i18n: I18n; fcApi: FullcubeApi; /** * Landing page configuration retrieved from API. */ landingPageConfig: ILandingPageInfoResponse; options: IOptions; results: any; /** * Loaded module. */ modules: { [moduleName: string]: ModuleClass; }; /** * URL object of current location.href. */ url: URL; apm: IElasticApm; form: HTMLFormElement; submit: HTMLButtonElement; error: HTMLElement; constructor(i18n: I18n, fcApi: FullcubeApi); /** * Main method launching whole campaign process. */ bootstrap(options?: Partial): Promise; bootstrapInit(options?: Partial): Promise; /** * Binds form HTMLElements as properties for later use. Checks if all required keys exist. */ detectBasicElements(): void; /** * Binds form HTMLElements as properties for later use depending on modules loaded. */ detectModuleElements(): void; /** * Listen to input events. */ listen(): void; /** * Handle form submit */ onSubmit(e: MouseEvent): Promise; onSubmitError(error: Error): false; setupLogs(): void; /** * Run form validation. */ formValidate(): boolean; /** * Validate bootstrap options. */ validateOptions(): void; /** * Utility method to retrieve element by id with a prefix. * @param name name of field, gets prefixed with fc- by default */ getElement(name: string): HTMLElement | null; /** * Retrieves param from HTMLElement form field or url. * @param name */ getParam(name: string): string | null; getParamFromIframe(name: string): string | null; /** * Makes sure all HTMLElement in given map exist. Otherwise throws error. */ htmlElementsExists(map: { [key: string]: HTMLElement | null; }): void; /** * Redirect to the nextPage copying parameters and adding values from existing fields. */ redirect(options: { path: string; }): void; /** * Checks if module has fields. * @param mod */ hasFields(mod: ModuleClass): mod is ModuleClass & IHasFields; /** * Checks if module has onInit. * @param mod */ hasOnInit(mod: ModuleClass): mod is ModuleClass & OnInit; /** * Handle error of script. */ handleBootstrapError(err: Error): void; } export declare const fcCampaign: Campaign;