/*! Tripetto Studio Services 4.0.1 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */ declare module "@tripetto/studio" { import { IDefinition, ISnapshot, Instance, L10n, TAny, TL10n, TStyles } from "@tripetto/runner"; interface IAttachments { readonly get: (file: string) => Promise; readonly put: (file: File, onProgress: (percentage: number) => void) => Promise; readonly delete: (file: string) => Promise; } export default class Services { /** Initialize a services instance. */ static init(props: { /** Specifies the token. */ readonly token: string; /** Specifies an optional signature of the owner of the form (this allows to only load forms that are attached to a certain account or domain). */ readonly signature?: string; /** Specifies the url of the server. */ readonly url?: string; /** Specifies the url of the filestore service. */ readonly filestoreUrl?: string; }): Services; /** Creates an internal services instance. */ static internal(props?: { readonly token?: string; readonly filestoreUrl?: string }): Services; /** Retrieves a Studio form instance. */ static get( props: { [key: string]: TAny; } & { /** Specifies the token. */ readonly token: string; /** Specifies an optional signature of the owner of the form (this allows to only load forms that are attached to a certain account or domain). */ readonly signature?: string; /** Specifies the element for the form. */ readonly element?: string | HTMLElement | null; /** Specifies the url of the server. */ readonly url?: string; /** Specifies the url of the filestore service. */ readonly filestoreUrl?: string; /** Specifies to store sessions in the local store to preserve persistency when navigating between multiple pages that host the runner. */ readonly persistent?: boolean; /** Specifies if the form can be paused and resumed. */ readonly pausable?: boolean; /** Specifies a tracking function that is invoked when the user performs an action. */ readonly trackers?: ( type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete", definition: { readonly fingerprint: string; readonly name: string; }, block?: { readonly id: string; readonly name: string; } ) => void; /** Specifies a function that is invoked when the form is submitted. */ readonly onSubmit?: ( instance: Instance, id: string, language: string, locale: string, namespace?: string ) => Promise | void; } ): { readonly element?: HTMLElement | null; readonly definition?: Promise; readonly snapshot?: Promise | undefined>; readonly styles?: Promise; readonly l10n?: Promise; readonly license?: Promise; readonly locale?: (locale: "auto" | string) => Promise; readonly translations?: ( language: "auto" | string, context: string ) => Promise; readonly attachments?: IAttachments; readonly persistent?: boolean; readonly onSubmit?: ( instance: Instance, language: string, locale: string, runner?: string ) => Promise | boolean | void; readonly onPause?: { recipe: "email"; onPause: ( emailAddress: string, snapshot: ISnapshot, language: string, locale: string, runner: string ) => Promise; }; readonly onReload?: () => Promise; readonly onAction?: ( type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete", definition: { readonly fingerprint: string; readonly name: string; }, block?: { readonly id: string; readonly name: string; } ) => void; }; /** Initializes a form runner. */ static form< Runner extends { readonly run: (props: Props) => Promise; }, Props extends {}, Controller extends {}, Snapshot = unknown >( props: Props & { /** Specifies the runner to use. */ readonly runner: Runner; /** Specifies the token. */ readonly token: string; /** Specifies an optional signature of the owner of the form (this allows to only load forms that are attached to a certain account or domain). */ readonly signature?: string; /** Specifies the element for the form. */ readonly element?: string; /** Specifies the url of the server. */ readonly url?: string; /** Specifies the url of the filestore service. */ readonly filestoreUrl?: string; /** Specifies to store sessions in the local store to preserve persistency when navigating between multiple pages that host the runner. */ readonly persistent?: boolean; /** Specifies if the form can be paused and resumed. */ readonly pausable?: boolean; /** Specifies a tracking function that is invoked when the user performs an action. */ readonly trackers?: ( type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete", definition: { readonly fingerprint: string; readonly name: string; }, block?: { readonly id: string; readonly name: string; } ) => void; /** Specifies a function that is invoked when the form is submitted. */ readonly onSubmit?: ( instance: Instance, id: string, language: string, locale: string, namespace?: string ) => Promise | void; } ): Promise; static get definition(): Promise; static get style(): Promise; static get onAttachment(): IAttachments; static onFinish(instance: Instance, language?: string, locale?: string): void; /** Creates a new services instance. */ constructor(props: { readonly token?: string; readonly signature?: string; readonly url?: string; readonly filestoreUrl?: string }); /** Fetches the definition from the server. */ get definition(): Promise; /** Fetches the snapshot from the server. */ get snapshot(): Promise | undefined>; /** Fetches the styles from the server. */ get styles(): Promise; /** Fetches the l10n data from the server. */ get l10n(): Promise; /** Fetches the license from the server. */ get license(): Promise; /** Retrieves the attachments handler. */ get attachments(): IAttachments; /** Retrieves locale data from the server. */ get locale(): (locale: "auto" | string) => Promise; /** Retrieves translations from the server. */ get translations(): (language: "auto" | string, context: string) => Promise; /** Saves submitted responses to the server. */ get onSubmit(): (instance: Instance, language: string, locale: string, runner?: string) => Promise; /** Saves the snapshot to the server. */ get onPause(): { recipe: "email"; onPause: ( emailAddress: string, snapshot: ISnapshot, language: string, locale: string, runner: string ) => Promise; }; /** Reloads the definition from the server. */ get onReload(): () => Promise; } export {}; }