diff --git a/package.json b/package.json index 95cb8c973a..4cf3a1e0cf 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "./dist/*": "./dist/*" }, - "types": "index.d.ts", "files": [ "dist", "lib", diff --git a/types/builders.d.ts b/types/builders.d.ts deleted file mode 100644 index fee9af8a82..0000000000 --- a/types/builders.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Builders { - static readonly builders: any; - static addBuilder(name: string, builder: any): void; - static addBuilders(builders: any): void; - static getBuilder(name: string): any; - static getBuilder(): any; -} diff --git a/types/components/_classes/component/component.d.ts b/types/components/_classes/component/component.d.ts deleted file mode 100644 index 4d8bf89a3a..0000000000 --- a/types/components/_classes/component/component.d.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { Element } from '../../../element'; -import { ValidateOptions } from '../../../formio'; -import { ComponentSchema, ElementInfo, ExtendedComponentSchema } from './../../schema.d'; - -export class Component extends Element { - static schema(sources: ExtendedComponentSchema): ExtendedComponentSchema; - static tableView(value: any, options: any): void; - constructor(component: any, options: Object, data: Object); - public originalComponent: any | Component; - public refs: Object; - public attached: boolean; - public rendered: boolean; - public data: Object; - public component: any; - public error: string; - public tooltip: string; - public row: any; - public pristine: boolean; - public parent: any; - public root: any; - public lastChanged: any; - public triggerRedraw: Function; - public tooltips: any[]; - public invalid: boolean; - public isBuilt: boolean; - readonly ready: any; - readonly labelInfo: any; - init(): void; - destroy(): void; - readonly shouldDisabled: any | boolean; - readonly isInputComponent: boolean; - readonly defaultSchema: ComponentSchema; - readonly hasInput: boolean; - readonly key: any; - public parentVisible: any | boolean; - public parentDisabled: any | boolean; - public visible: any | boolean; - public currentForm: any; - readonly fullMode: boolean; - readonly builderMode: boolean; - getModifiedSchema( - schema: ExtendedComponentSchema, - defaultSchema: ComponentSchema, - recursion: boolean, - ): ExtendedComponentSchema; - readonly schema: ExtendedComponentSchema; - t(text: string, params?: Object): any; - labelIsHidden(): boolean; - readonly transform: any; - getTemplate(names: any, modes: any): any; - checkTemplate(templates: any, names: any, modes: any): any; - checkTemplateMode(templatesByName: any, modes: any): any; - renderTemplate(name: any, data: any, modeOption?: any[]): any; - sanitize(dirty: string): any; - renderString(template: any, data: any): HTMLElement; - performInputMapping(input: any): any; - getBrowserLanguage(): string | null; - beforeNext(): any; - beforePage(): any; - beforeSubmit(): any; - readonly submissionTimezone: string | any; - readonly canDisable: boolean; - loadRefs(element: any, refs: any): any; - build(element: any): any; - render(children: any, topLevel?: boolean): any; - attach(element: any): any; - addShortcut(element: any, shortcut: any): void; - removeShortcut(element: any, shortcut: any): void; - detach(): void; - attachRefreshEvent(refreshData: any): void; - attachRefreshOn(): void; - refresh(value: any): void; - inContext(component: any): boolean; - readonly viewOnly: boolean | any; - createViewOnlyElement(): HTMLElement; - readonly defaultViewOnlyValue: '-'; - getValueAsString(value: any): string; - getView(value: any): string; - updateItems(...args: any[]): void; - createModal(): HTMLElement; - readonly className: string; - readonly customStyle: string; - getElement(): HTMLElement; - evalContext(additional: any): any; - setPristine(pristine: boolean): void; - removeValue(index: number): void; - iconClass(name: any, spinning: any): any; - readonly name: string; - readonly errorLabel: string; - errorMessage(type: any): any; - setContent(element: any, content: any): boolean; - redraw(): any; - rebuild(): any; - removeEventListeners(): void; - hasClass(element: any, className: string): any; - addClass(element: any, className: string): any; - removeClass(element: any, className: string): any; - hasCondition(): boolean; - conditionallyVisible(data: any): boolean; - checkCondition(row: any, data: Object): boolean; - checkConditions(data: any): any; - readonly logic: any[]; - fieldLogic(data: any): any; - applyActions(actions: any[], result: any, data: any, newComponent: any): boolean; - addInputError(message: any, dirty: boolean): void; - clearOnHide(show: boolean): void; - onChange(flags: Object, fromRoot: boolean): void; - readonly wysiwygDefault: { - theme: string; - placeholder: any | string; - modules: { - clipboard: { - matchVisual: boolean; - }; - toolbar: any[]; - }; - }; - addCKE(element: HTMLElement | any, settings: Object, onChange: (input: any) => any): any; - addQuill(element: HTMLElement | any, settings: Object, onChange: (input: any) => any): any; - addAce(element: HTMLElement | any, settings: Object, onChange: (input: any) => any): any; - readonly emptyValue: null; - hasValue(data: Object): boolean; - readonly rootValue: any; - readonly rootPristine: any; - public dataValue: any; - splice(index: number | string): void; - deleteValue(): void; - readonly defaultValue: any; - getValue(): any; - getValueAt(index: number): any; - setValue(value: any, flags: any): boolean; - setValueAt(index: number, value: any, flags: any): void; - readonly hasSetValue: boolean; - restoreValue(): void; - normalizeValue(value: any): any; - getIcon(name: any | string, content: any, styles: any, ref?: string): any | HTMLElement; - resetValue(): void; - hasChanged(before: any, after: any): boolean; - updateOnChange(flags: any, changed: boolean | any): boolean; - calculateValue(data: Object, flags: any): boolean; - public label: any | string; - getRoot(): Component; - invalidMessage(data: any, dirty: boolean, ignoreCondition?: boolean): any; - isValid(data: any, dirty: boolean): boolean; - checkValidity(data: any, dirty: any | boolean, rowData: any): boolean; - readonly validationValue: any; - isEmpty(value: any): boolean; - validateMultiple(): boolean; - readonly errors: any[]; - setCustomValidity(message: any, dirty: any): void; - shouldSkipValidation(data: any, dirty: any, rowData: any): boolean; - whenReady(): any | Promise; - readonly dataReady: any | Promise; - asString(value: any): string; - public disabled: boolean; - setDisabled(element: any, disabled: any | boolean): void; - setLoading(element: any, loading: any | boolean): void; - selectOptions(select: any, tag: any, options: any, defaultValue: any): void; - setSelectValue(select: any, value: any): void; - clear(): any; - append(element: HTMLElement): void; - prepend(element: HTMLElement): void; - removeChild(element: HTMLElement): void; - attachLogic(): void; - elementInfo(): ElementInfo; - autofocus(): void; - focus(): void; - readonly shouldDisable: boolean; - readonly info: ElementInfo; - public element: any; - public validators: (keyof ValidateOptions)[]; - public calculatedValue: any; - public options: any; - public labelElement: any; -} diff --git a/types/components/_classes/componentmodal/componentmodal.d.ts b/types/components/_classes/componentmodal/componentmodal.d.ts deleted file mode 100644 index 9c6b65ab14..0000000000 --- a/types/components/_classes/componentmodal/componentmodal.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component } from '../component/component'; - -export class ComponentModal { - constructor(component: Component | any, element: any, isOpened: boolean, currentValue: any); - public isOpened: boolean; - public component: Component | any; - public element: any; - public currentValue: any; - public dataLoaded: boolean; - static render(component: Component | any, data: any, topLevel: boolean): any; - readonly refs: any; - init(): void; - setValue(value: any): any; - setOpenModalElement(template: string): void; - readonly templateRefs: any; - loadRefs(): void; - removeEventListeners(): void; - setEventListeners(): void; - isValueChanged(): boolean; - setOpenEventListener(): void; - openModalHandler(event: Event): void; - positionOverElement(): void; - openModal(): void; - updateView(): void; - closeModal(): void; - closeModalHandler(event: Event): void; - showDialog(): void; - closeDialog(event: Event): void; - saveDialog(event: Event): void; - saveModalValueHandler(event: Event): void; -} diff --git a/types/components/_classes/field/field.d.ts b/types/components/_classes/field/field.d.ts deleted file mode 100644 index 25590c4f6a..0000000000 --- a/types/components/_classes/field/field.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Component } from '../component/component'; - -export class Field extends Component { - render(element: any): any; -} diff --git a/types/components/_classes/input/input.d.ts b/types/components/_classes/input/input.d.ts deleted file mode 100644 index a49179abab..0000000000 --- a/types/components/_classes/input/input.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component } from '../component/component'; -import { Multivalue } from '../multivalue/multivalue'; -import { Element } from './../../../element.d'; - -export class Input extends Multivalue { - constructor(component: Component | any, options: Object, data: any); - readonly inputInfo: { - id: string | number; - type: string; - changeEvent: string; - content?: any; - attr: any; - }; - readonly maskOptions: { label: any; value: any }[]; - readonly isMultipleMasksField: boolean; - getMaskByName(maskName: string): any; - setInputMask(input: any, inputMask: any): any; - getMaskOptions(): { label: any; value: any }[]; - readonly remainingWords: number; - renderElement(value: any, index: string | number): any; - setCounter(type: string, element: any | Element, count: number, max: number): void; - updateValueAt(value: any, flags: any, index: string | number): void; - getValueAt(index: string | number): any; - updateValue(value: any, flags: any, index: string | number): any; - attach(element: any): any; - attachElement(element: any | Element, index: string | number): void; - readonly widget: any; - createWidget(index: string | number): any; - addFocusBlurEvents(element: any | Element): void; -} diff --git a/types/components/_classes/multivalue/multivalue.d.ts b/types/components/_classes/multivalue/multivalue.d.ts deleted file mode 100644 index 7e700d46c3..0000000000 --- a/types/components/_classes/multivalue/multivalue.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Field } from '../field/field'; - -export class Multivalue extends Field { - public dataValue: any; - readonly defaultValue: any; - readonly addAnother: any; - useWrapper(): boolean; - renderRow(value: any, index: any): any; - attach(dom: any): any; - attachElement(element: any, index: number | string): any; - onSelectMaskHandler(event: any): void; - tryAttachMultipleMasksInput(): boolean; - updateMask(input: any, mask: any): void; - addNewValue(value: any): void; - addValue(): void; -} diff --git a/types/components/_classes/nested/nestedComponent.d.ts b/types/components/_classes/nested/nestedComponent.d.ts deleted file mode 100644 index c73ff4299d..0000000000 --- a/types/components/_classes/nested/nestedComponent.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Field } from '../field/field'; -import { Component } from './../component/component.d'; - -export class NestedComponent extends Field { - constructor(component: any | Component, options: Object, data: any); - readonly defaultSchema: any; - readonly schema: any; - public collapsed: any | boolean; - public visible: any | boolean; - public parentVisible: boolean; - public disabled: boolean; - public parentDisabled: any | boolean; - readonly ready: any; - public currentForm: any; - public data: any; - getComponents(): any[] | Component[]; - getAllComponents(): any[] | Component[]; - everyComponent(fn: Function): void; - flattenComponents(): Object; - eachComponent(fn: Function): void; - getComponent(path: string, fn: Function): Object; - getComponentById(id: string, fn: Function): Object; - createComponent(component: any | Component, options: Object, data: any, before: any): any | Object; - getContainer(): any; - readonly componentComponents: any[]; - readonly nestedKey: string; - readonly templateName: string; - init(): void; - addComponents(data: any, options: Object): void; - addComponent(component: any, data: Object, before: HTMLElement, noAdd?: any): Component; - render(children: any): any; - renderComponents(components: any): any; - attach(element: any): any; - attachComponents(element: any, components: any | Component[], container: any): any; - removeComponent(component: Component, components: Component[]): any; - removeComponentByKey(key: string, fn: Function): null; - removeComponentById(id: string, fn: Function): null; - updateValue(value: any, flags: any, source: any): any; - hasChanged(): boolean; - checkData(data: any, flags: any, source: any): boolean; - checkModal(isValid: boolean, dirty: boolean): void; - checkConditions(data: any, norecurse?: any): any; - clearOnHide(show: boolean): void; - restoreComponentsContext(): void; - beforePage(next?: any): any; - beforeSubmit(): any; - calculateValue(data: any, flags: any): any; - isLastPage(): boolean; - isValid(data: any, dirty: any): boolean; - checkValidity(data: any, dirty: any): any | boolean; - setPristine(pristine: any): void; - detach(): void; - destroy(): void; - destroyComponents(): void; - readonly errors: any[]; - getValue(): any; - resetValue(): void; - readonly dataReady: any; - setNestedValue(component: any | Component, value: any, flags: any | Object, changed: boolean): any; - setValue(value: any, flags: any | Object): boolean; -} diff --git a/types/components/_classes/widgetcomponent/widgetComponent.d.ts b/types/components/_classes/widgetcomponent/widgetComponent.d.ts deleted file mode 100644 index daffa44f94..0000000000 --- a/types/components/_classes/widgetcomponent/widgetComponent.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Input } from '../input/input'; - -export class WidgetComponent extends Input { - readonly widgetLocale: any; - readonly widgetData: any; -} diff --git a/types/components/components.d.ts b/types/components/components.d.ts deleted file mode 100644 index 9bdb2a5399..0000000000 --- a/types/components/components.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { ExtendedComponentSchema } from './schema'; -import { Component } from './_classes/component/component'; -import { ComponentModal } from './_classes/componentmodal/componentmodal'; -import { Field } from './_classes/field/field'; -import { Input } from './_classes/input/input'; -import { Multivalue } from './_classes/multivalue/multivalue'; -import { NestedComponent } from './_classes/nested/nestedComponent'; -import { WidgetComponent } from './_classes/widgetcomponent/widgetComponent'; - -type ClassWithEditForm = C & { editForm: () => { components: ExtendedComponentSchema[] } }; - -export namespace Components { - function setComponents(comps: Object): void; - function setComponent(name: string, comp: Object): void; - function addComponent(name: string, comp: Object): void; - function create(component: any, options: Object, data?: any, flag?: any): Object; - let baseEditForm: any; - let EditFormUtils: any; - namespace components { - class base extends Component {} - class componentmodal extends ComponentModal {} - class input extends Input {} - class nested extends NestedComponent {} - class multivalue extends Multivalue {} - class field extends Field {} - - const address: ClassWithEditForm; - const button: ClassWithEditForm; - const checkbox: ClassWithEditForm; - const columns: ClassWithEditForm; - const container: ClassWithEditForm; - const content: ClassWithEditForm; - const currency: ClassWithEditForm; - const datagrid: ClassWithEditForm; - const datamap: ClassWithEditForm; - const datetime: ClassWithEditForm; - const day: ClassWithEditForm; - const editgrid: ClassWithEditForm; - const email: ClassWithEditForm; - const fieldset: ClassWithEditForm; - const file: ClassWithEditForm; - const form: ClassWithEditForm; - const hidden: ClassWithEditForm; - const htmlelement: ClassWithEditForm; - const number: ClassWithEditForm; - const panel: ClassWithEditForm; - const password: ClassWithEditForm; - const phoneNumber: ClassWithEditForm; - const radio: ClassWithEditForm; - const recaptcha: ClassWithEditForm; - const resource: ClassWithEditForm; - const select: ClassWithEditForm; - const selectboxes: ClassWithEditForm; - const signature: ClassWithEditForm; - const sketchpad: ClassWithEditForm; - const survey: ClassWithEditForm; - const table: ClassWithEditForm; - const tabs: ClassWithEditForm; - const tagpad: ClassWithEditForm; - const tags: ClassWithEditForm; - const textarea: ClassWithEditForm; - const textfield: ClassWithEditForm; - const time: ClassWithEditForm; - const tree: ClassWithEditForm; - const unknown: ClassWithEditForm; - const url: ClassWithEditForm; - const well: ClassWithEditForm; - } -} diff --git a/types/components/schema.d.ts b/types/components/schema.d.ts deleted file mode 100644 index 4ebb660309..0000000000 --- a/types/components/schema.d.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { ConditionalOptions, ValidateOptions } from '../formio'; - -export interface ComponentSchema { - /** - * The type of component - */ - type?: string; - - /** - * The data key for this component (how the data is stored in the database, referenced as API key in docs). - */ - key?: string; - - /** - * The HTML label to give this component. - */ - label?: string; - - /** - * The input placeholder for this component. - */ - placeholder?: string; - - /** - * Determines if this component provides an input. - */ - input?: boolean; - - /** - * If this component should be included as a column within a submission table. - * Determines if this field will show in the data tables output. - */ - tableView?: boolean; - - /** - * If this component should allow an array of values to be captured. - */ - multiple?: boolean; - - /** - * If the data of this component should be protected (no GET api requests can see the data) - */ - protected?: boolean; - - /** - * The prefix text to put in front of the input - */ - prefix?: string; - - /** - * The suffix text to put after the input - */ - suffix?: string; - - /** - * The default value of this compoennt. - */ - defaultValue?: T; - - /** - * If the value of this field should be cleared when it is conditionally hidden. - */ - clearOnHide?: boolean; - - /** - * Validate if the value of this component should be unique within the form. - */ - unique?: boolean; - - /** - * If the value of this component should be persisted within the backend api database. - */ - persistent?: boolean; - - /** - * Determines if the component should be within the form, but not visible. - * This can be overridden with the conditionals. - */ - hidden?: boolean; - - /** - * The validation criteria for this component. - */ - validate?: ValidateOptions; - - /** - * Determines when this component should be added to the form for both processing and input. - */ - conditional?: ConditionalOptions; - - /** - * Allows customizable errors to be displayed for each component when an error occurs. This is an object with the following keys: - required - min - max - minLength - maxLength - invalid_email - invalid_date - pattern - custom - - An object (keys listed above), values are the strings you wish to display. Each string has the {{ field }} to use within the string. Example. - {"required": "{{ field }} is required. Try again."} - */ - errors?: Object; - - /** - * Allows changing the component definition in reaction to data entered in a form. For example, changing a field to required, disabled or hidden when a value is entered. - An array of instances of the Field Logic Schema - Fyi: https://github.com/formio/formio.js/wiki/Field-Logic-Schema - */ - logic?: Object[]; - - /** - * The custom CSS class to provide to this component. - */ - customClass?: string; - - /** - * If true, will show label when component is in a datagrid. - */ - dataGridLabel?: boolean; - - labelPosition?: 'top' | 'bottom' | 'left' | 'right'; - labelWidth?: number; - labelMargin?: number; - description?: string; - errorLabel?: string; - tooltip?: string; - hideLabel?: boolean; - tabindex?: string; - disabled?: boolean; - autofocus?: boolean; - dbIndex?: boolean; - customDefaultValue?: any; - calculateValue?: any; - allowCalculateOverride?: boolean; - widget?: any; // Input widgets i.e. calendar widget - - /** - * This will refresh this component when this field changes. - */ - refreshOn?: string; - - /** - * Determines if we should clear our value when a refresh occurs. - */ - clearOnRefresh?: boolean; - - /** - * This will perform the validation on either "change" or "blur" of the input element. - */ - validateOn?: 'change' | 'blur'; -} - -export type ExtendedComponentSchema = ComponentSchema & { [key: string]: any }; - -export interface ElementInfo { - type: string; - component: ExtendedComponentSchema; - changeEvent: string; - attr: any; - content: string; -} - -export interface BuilderInfo { - title: string; - group: string; - icon: string; - documentation?: string; - weight?: number; - schema?: ExtendedComponentSchema; -} diff --git a/types/displays.d.ts b/types/displays.d.ts deleted file mode 100644 index 4585dff10f..0000000000 --- a/types/displays.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Displays { - static readonly displays: any; - static addDisplay(name: string, display: any): void; - static addDisplays(name: string, display: any): void; - static getDisplay(name: string): any; - static getDisplays(name: string): any; -} diff --git a/types/element.d.ts b/types/element.d.ts deleted file mode 100644 index 3419ce9537..0000000000 --- a/types/element.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { EventEmitter } from './eventEmitter.d'; - -export class Element { - options: Object; - id: string; - eventHandlers: any[]; - i18next: any; - events: EventEmitter; - defaultMask: any; - inputMasks: any[]; - constructor(options: any); - on(event: string, cb: Function, internal: boolean, once?: boolean): any; - once(event: string, cb: Function, internal: boolean): any; - onAny(cb: Function): any; - off(event: string): void; - emit(event: string, data: Object): void; - addEventListener(obj: HTMLElement, type: string, func: Function, persistent?: boolean): any; - removeEventListener(obj: Object, type: any): any; - removeEventListeners(): void; - removeAllEvents(includeExternal: boolean): void; - destroy(): void; - appendTo(element: HTMLElement, container: HTMLElement): any; - prependTo(element: HTMLElement, container: HTMLElement): any; - removeChildFrom(element: HTMLElement, container: HTMLElement): any; - ce(type: string, attr?: Object, children?: HTMLElement | string | Array): HTMLElement; - appendChild(element: any, child: any): any; - maskPlaceholder(mask: HTMLElement): string; - setInputMask(input: HTMLElement, inputMask: string, placeholder: boolean): void; - t(text: string, params?: Object): string; - text(text: string): Text; - attr(element: HTMLElement, attr: Object): void; - hasClass(element: HTMLElement | any, className: string): boolean; - addClass(element: HTMLElement, className: string): any; - removeClass(element: HTMLElement, className: string): any; - empty(element: HTMLElement): void; - evalContext(additional: any): any; - interpolate(string: any, data: any): any; - evaluate( - func: any, - args: { component: any; form: any; instance: any; row: any; data: any } | any, - ret: any, - tokenize?: any, - ): any; - hook(...args: any[]): any; -} diff --git a/types/eventEmitter.d.ts b/types/eventEmitter.d.ts deleted file mode 100644 index 6b95e0a09f..0000000000 --- a/types/eventEmitter.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class EventEmitter /* extends EventEmitter3 */ { - constructor(conf: Object); -} diff --git a/types/form.d.ts b/types/form.d.ts deleted file mode 100644 index c7652f44b4..0000000000 --- a/types/form.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Element } from './element'; - -export class Form extends Element { - form: any; - instance: any; - ready: Promise; - constructor(...args: any[]); - create(display: 'wizard' | 'form' | 'pdf'): any; - setForm(formParam: any): any; - setDisplay(display: any): any; - empty(): void; - render(): any | Promise; - static embed(element: any): any; - sanitize(dirty: string): any; - setContent(element: any, content: any): boolean; - build(): Promise; - attach(element: any): any | Promise; -} diff --git a/types/formbuilder.d.ts b/types/formbuilder.d.ts deleted file mode 100644 index 745d31527e..0000000000 --- a/types/formbuilder.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Form } from './form'; - -export class FormBuilder extends Form { - constructor(element: any, form: any, options: any); - create(display: string): any; -} diff --git a/types/formio.d.ts b/types/formio.d.ts deleted file mode 100644 index 6368096ac7..0000000000 --- a/types/formio.d.ts +++ /dev/null @@ -1,1236 +0,0 @@ -import EventEmitter from 'eventemitter3'; -import Plugins from './Plugins'; - -export interface FormioLibrarySource { - type: string; - src: string; -} - -/** - * The Formio class options interface. - */ -export interface FormioOptions { - /** - * The base API url of the Form.io Platform. Example: https://api.form.io - */ - base?: string; - /** - * The project API url of the Form.io Project. Example: https://examples.form.io - */ - project?: string; - useSessionToken?: boolean; - formOnly?: boolean; -} -/** - * The different path types for a project. - */ -export declare enum FormioPathType { - Subdirectories = 'Subdirectories', - Subdomains = 'Subdomains' -} - -export interface ConditionalOptions { - /** If the field should show if the condition is true */ - show?: boolean; - /** The field API key that it should compare its value against to determine if the condition is triggered. */ - when?: string; - /** The value that should be checked against the comparison component */ - eq?: string; - /** The JSON Logic to determine if this component is conditionally available. - * Fyi: http://jsonlogic.com/ - */ - json?: Object; -} - -export interface ValidateOptions { - /** - * If this component is required. - */ - required?: boolean; - - /** - * For text input, this checks the minimum length of text for valid input - */ - minLength?: number; - - /** - * For text input, this checks the maximum length of text for valid input - */ - maxLength?: number; - - /** - * For text input, this checks the text agains a Regular expression pattern. - */ - pattern?: string; - - /** - * A custom javascript based validation or a JSON object for using JSON Logic - */ - custom?: any; - - /** - * If the custom validation should remain private (only the backend will see it and execute it). - */ - customPrivate?: boolean; - - /** - * Minimum value for numbers - */ - min?: number; - - /** - * Maximum value for numbers - */ - max?: number; - - minSelectedCount?: number; - maxSelectedCount?: number; - minWords?: number; - maxWords?: number; - email?: boolean; - url?: boolean; - date?: boolean; - day?: boolean; - json?: string; - mask?: boolean; - minDate?: any; - maxDate?: any; -} - -/** - * The Formio interface class. This is a minimalistic API library that allows you to work with the Form.io API's within JavaScript. - * - * ## Usage - * Creating an instance of Formio is simple, and takes only a path (URL String). The path can be different, depending on the desired output. - * The Formio instance can also access higher level operations, depending on how granular of a path you start with. - * - * ```ts - * var formio = new Formio(, [options]); - * ``` - * - * Where **endpoint** is any valid API endpoint within Form.io. These URL's can provide a number of different methods depending on the granularity of the endpoint. This allows you to use the same interface but have access to different methods depending on how granular the endpoint url is. - * **options** is defined within the {link Formio.constructor} documentation. - * - * Here is an example of how this library can be used to load a form JSON from the Form.io API's - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.loadForm().then((form) => { - * console.log(form); - * }); - * ``` - */ -export declare class Formio { - path?: string | undefined; - options: FormioOptions; - /** - * The base API url of the Form.io Platform. Example: https://api.form.io - */ - static baseUrl: string; - /** - * The project API url of the Form.io Project. Example: https://examples.form.io - */ - static projectUrl: string; - /** - * The project url to use for Authentication. - */ - static authUrl: string; - /** - * The path type for the project. - */ - static pathType?: FormioPathType; - /** - * Set to true if the project url has been established with ```Formio.setProjectUrl()``` - */ - static projectUrlSet: boolean; - /** - * The Form.io API Cache. This ensures that requests to the same API endpoint are cached. - */ - static cache: any; - /** - * The namespace used to save the Form.io Token's and variables within an application. - */ - static namespace: string; - /** - * Handles events fired within this SDK library. - */ - static events: EventEmitter; - /** - * Stores all of the libraries lazy loaded with ```Formio.requireLibrary``` method. - */ - static libraries: any; - /** - * The Library license for this application. - */ - static license: string; - /** - * A direct interface to the Form.io fetch polyfill. - */ - static fetch: any; - /** - * A direct interface to the Form.io fetch Headers polyfill. - */ - static Headers: any; - /** - * The rules definitions. - */ - static rulesEntities: any; - /** - * All of the auth tokens for this session. - */ - static tokens: any; - static config: any; - static icons: string; - /** - * The version of this library. - */ - static version: string; - static formOnly: boolean; - /** - * The base API url of the Form.io Platform. Example: https://api.form.io - */ - base: string; - /** - * The Projects Endpoint derived from the provided source. - * - * @example https://api.form.io/project - */ - projectsUrl: string; - /** - * A specific project endpoint derived from the provided source. - * - * @example https://examples.form.io - */ - projectUrl: string; - /** - * The Project ID found within the provided source. - */ - projectId: string; - /** - * A specific Role URL provided the source. - * - * @example https://examples.form.io/role/2342343234234234 - */ - roleUrl: string; - /** - * The roles endpoint derived from the provided source. - * - * @example https://examples.form.io/role - */ - rolesUrl: string; - /** - * The roleID derieved from the provided source. - */ - roleId: string; - /** - * A specific form url derived from the provided source. - * - * @example https://examples.form.io/example - */ - formUrl: string; - /** - * The forms url derived from the provided source. - * - * @example https://example.form.io/form - */ - formsUrl: string; - /** - * The Form ID derived from the provided source. - */ - formId: string; - /** - * The submissions URL derived from the provided source. - * - * @example https://examples.form.io/example/submission - */ - submissionsUrl: string; - /** - * A specific submissions URL derived from a provided source. - * - * @example https://examples.form.io/example/submission/223423423423 - */ - submissionUrl: string; - /** - * The submission ID provided a submission url. - */ - submissionId: string; - /** - * The actions url provided a form url as the source. - * - * @example https://examples.form.io/example/action - */ - actionsUrl: string; - /** - * The Action ID derived from a provided Action url. - */ - actionId: string; - /** - * A specific action api endoint. - */ - actionUrl: string; - vsUrl: string; - vId: string; - vUrl: string; - /** - * The query string derived from the provided src url. - */ - query: string; - /** - * The project type. - */ - pathType?: FormioPathType; - /** - * If this is a non-project url, such is the case for Open Source API. - */ - noProject: boolean; - /** - * @constructor - * @param {string} path - A project, form, and submission API Url. - * @param {FormioOptions} options - Available options to configure the Javascript API. - */ - constructor(path?: string | undefined, options?: FormioOptions); - /** - * Deletes a remote resource of any provided type. - * - * @param {string} type - The type of resource to delete. "submission", "form", etc. - * @param {object} options - The options passed to {@link Formio.request} - * @return {Promise} - */ - delete(type: string, opts?: any): any; - /** - * Returns the index (array of records) for any provided type. - * - * @param {string} type - The type of resource to fetch the index of. "submission", "form", etc. - * @param {object} query - A query object to pass to the request. - * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - index(type: string, query?: any, opts?: any): any; - /** - * Save a document record using "upsert". If the document does not exist, it will be created, if the _id is provided, - * it will be updated. - * - * @param {string} type - The type of resource to fetch the index of. "submission", "form", etc. - * @param {object} data - The resource data object. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - save(type: string, data?: any, opts?: any): any; - /** - * @summary Load (GET) a document record. - * - * @param {string} type - The type of resource to fetch the index of. "submission", "form", etc. - * @param {object} query - A query object to pass to the request. - * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - load(type: string, query?: any, opts?: any): any; - /** - * @summary Call {@link Formio.makeRequest} for this Formio instance. - * - * @param {string} type - The request resource type. "submission", "form", etc. - * @param {string} url - The URL to request. - * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH - * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods) - * @param {object} options - An object of options to pass to the request method. - * @param {boolean} options.ignoreCache - To ignore internal caching of the request. - * @param {object} options.headers - An object of headers to pass along to the request. - * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request. - * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken. - * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method. - * @return {Promise} - */ - makeRequest(type: string, url: string, method?: string, data?: any, opts?: any): any; - /** - * @summary Loads a project. - * - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.loadProject().then((project) => { - * console.log(project); - * }); - * ``` - * - * @param {object} query - Query parameters to pass to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadProject(query?: any, opts?: any): any; - /** - * Saves or Updates a project. - * - * ### Create a new project - * ```ts - * const formio = new Formio(); - * formio.saveProject({ - * title: 'My Project', - * path: 'myproject', - * name: 'myproject' - * }); - * ``` - * - * ### Update an existing project - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.loadProject().then((project) => { - * project.title = 'Title changed'; - * formio.saveProject(project).then(() => { - * console.log('Done saving project!'); - * }); - * }); - * ``` - * - * @param {object} data - The project JSON to create or update. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - saveProject(data?: any, opts?: any): any; - /** - * Deletes a project - * - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.deleteProject(); - * ``` - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - deleteProject(opts?: any): any; - /** - * Loads a list of all projects. - * - * ```ts - * Formio.loadProjects().then((projects) => { - * console.log(projects); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {*} - */ - static loadProjects(query?: any, opts?: any): any; - /** - * Loads a role within a project. - * - * ```ts - * const formio = new Formio('https://examples.form.io/role/234234234234'); - * formio.loadRole().then((role) => { - * console.log(role); - * }); - * ``` - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadRole(opts?: any): any; - /** - * Create a new or Update an existing role within a project. - * - * ### Create new Role example - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.saveRole({ - * title: 'Employee', - * description: 'A person who belongs to a company.' - * }).then((role) => { - * console.log(role); - * }); - * ``` - * - * ### Update existing role example - * ```ts - * const formio = new Formio('https://examples.form.io/role/234234234234234'); - * formio.loadRole().then((role) => { - * role.title = 'Manager'; - * formio.saveRole(role).then(() => { - * console.log('DONE'); - * }); - * }); - * ``` - * - * @param {object} role - The Role JSON to create or update. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - saveRole(data?: any, opts?: any): any; - /** - * Deletes a role within a project. - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - deleteRole(opts?: any): any; - /** - * Load all roles within a project. - * - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.loadRoles().then((roles) => { - * console.log(roles); - * }); - * ``` - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadRoles(opts?: any): any; - /** - * Loads a form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.loadForm().then((form) => { - * console.log(form); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadForm(query?: any, opts?: any): any; - /** - * Create or Update a specific form. - * - * ### Create form example - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.saveForm({ - * title: 'Employee', - * type: 'resource', - * path: 'employee', - * name: 'employee', - * components: [ - * { - * type: 'textfield', - * key: 'firstName', - * label: 'First Name' - * }, - * { - * type: 'textfield', - * key: 'lastName', - * label: 'Last Name' - * } - * ] - * }); - * ``` - * - * ### Update a form example - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.loadForm().then((form) => { - * form.title = 'Changed Title'; - * formio.saveForm(form).then(() => { - * console.log('DONE!!!'); - * }); - * }); - * ``` - * - * @param {object} data - The Form JSON to create or update. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - saveForm(data?: any, opts?: any): any; - /** - * Deletes a form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.deleteForm().then(() => { - * console.log('Deleted!'); - * }); - * ``` - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - deleteForm(opts?: any): any; - /** - * Loads all forms within a project. - * - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.loadForms().then((forms) => { - * console.log(forms); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadForms(query?: any, opts?: any): any; - /** - * Loads a specific submissionn. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423'); - * formio.loadSubmission().then((submission) => { - * console.log(submission); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadSubmission(query?: any, opts?: any): any; - /** - * Creates a new or Updates an existing submission. - * - * ### Create a new submission - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.saveSubmission({ - * data: { - * firstName: 'Joe', - * lastName: 'Smith' - * } - * }).then((submission) => { - * // This will now be the complete submission object saved on the server. - * console.log(submission); - * }); - * ``` - * - * ### Update an existing submission - * ```ts - * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423'); - * formio.loadSubmission().then((submission) => { - * submission.data.lastName = 'Thompson'; - * formio.saveSubmission(submission).then(() => { - * console.log('DONE'); - * }); - * }); - * ``` - * - * @param {object} data - The submission JSON object. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - saveSubmission(data?: any, opts?: any): any; - /** - * Deletes a submission. - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - deleteSubmission(opts?: any): any; - /** - * Loads all submissions within a form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.loadSubmissions({ - * params: { - * limit: 25, - * 'data.lastName__regex': 'smith' - * } - * }).then((submissions) => { - * // Should print out 25 submissions where the last name contains "smith". - * console.log(submissions); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadSubmissions(query?: any, opts?: any): any; - /** - * Loads a form action. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example/action/234234234234'); - * formio.loadAction().then((action) => { - * console.log(action); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadAction(query?: any, opts?: any): any; - /** - * Create a new or update an existing action. - * - * ### Create a new action for a form. - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.saveAction({ - * data: { - * name: 'webhook', - * title: 'Webhook Action', - * method: ['create', 'update', 'delete'], - * handler: ['after'], - * condition: {}, - * settings: { - * url: 'https://example.com', - * headers: [{}], - * block: false, - * forwardHeaders: false - * } - * } - * }).then((action) => { - * console.log(action); - * }); - * ``` - * - * ### Update an action - * ```ts - * const formio = new Formio('https://examples.form.io/example/action/234234234234'); - * formio.loadAction().then((action) => { - * action.title = 'Updated title'; - * formio.saveAction(action).then(() => { - * console.log('Done!'); - * }); - * }); - * ``` - * - * @param {object} data - The action JSON - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - saveAction(data?: any, opts?: any): any; - /** - * Delete an action - * - * ```ts - * const formio = new Formio('https://examples.form.io/example/action/234234234234'); - * formio.deleteAction().then(() => { - * console.log('Action was deleted.'); - * }); - * ``` - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - deleteAction(opts?: any): any; - /** - * Loads all actions within a form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.loadActions().then((actions) => { - * console.log(actions); - * }); - * ``` - * - * @param {object} query - Query parameters similar to {@link Formio#load}. - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - loadActions(query?: any, opts?: any): any; - /** - * Returns a list of available actions - * - * @return {Promise} - */ - availableActions(): any; - /** - * Returns the action information for a specific action, such as "save". - * - * ```ts - * const formio = new Formio('https://examples.form.io/example/actions/save'); - * formio.actionInfo().then((info) => { - * console.log(info); - * }); - * ``` - * - * @param {string} name - The name of the action you would like to get information for. i.e. "save", "webhook", etc. - * @return {Promise} - */ - actionInfo(name: string): any; - /** - * Determine if a string ID is a valid MongoID. - * - * @param {string} id - The id that should be tested if it is avalid id. - * @return {boolean} - true if it is a valid MongoId, false otherwise. - */ - isObjectId(id: string): boolean; - /** - * Get the project ID of project. - * - * ```ts - * const formio = new Formio('https://examples.form.io'); - * formio.getProjectId().then((projectId) => { - * console.log(projectId); - * }; - * ``` - * - * @return {Promise} - */ - getProjectId(): any; - /** - * Get the ID of a form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example'); - * formio.getFormId().then((formId) => { - * console.log(formId); - * }); - * ``` - * - * @return {Promise} - */ - getFormId(): any; - /** - * Instance method for {@link Formio.currentUser} - * - * @param {object} options - Options to pass to {@link Formio.request} - * @return {Promise} - */ - currentUser(options?: any): any; - /** - * Instance method for {@link Formio.accessInfo} - * - * @return {Promise} - */ - accessInfo(): any; - /** - * Sets OAuth Logout URL. - * - * @param {string} uri - Logout URL. - * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage. - * @return {string} - */ - oauthLogoutURI(uri: string, options: string | { - namespace: string; - }): string; - /** - * Returns the JWT token for this instance. - * - * @param {object} options - The following options are provided. - * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage. - * @return {string} - The JWT token for this user. - */ - getToken(options?: any): any; - /** - * Sets the JWT token for this instance. - * - * @param {string} token - The JWT token to set. - * @param {object} options - The following options are provided. - * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage. - * @return {string} - The JWT token that was set. - */ - setToken(token: any, options?: any): any; - /** - * Returns a temporary authentication token for single purpose token generation. - * - * @param {number|string} expire - The amount of seconds to wait before this temp token expires. - * @param {string} allowed - The allowed path string inn the format GET:/path - * @param {object} options - The options passed to {@link Formio#getToken} - */ - getTempToken(expire: any, allowed: string, options?: any): any; - /** - * Get a PDF download url for a submission, which will generate a new PDF of the submission. This method will first - * fetch a temporary download token, and then append this to the download url for this form. - * - * ```ts - * const formio = new Formio('https://examples.form.io/example/submission/324234234234234'); - * formio.getDownloadUrl().then((url) => { - * console.log(url); - * }); - * ``` - * - * @param {object} [form] - The form JSON to fetch a download url for. - * @return {Promise} - The download url. - */ - getDownloadUrl(form: any): any; - /** - * Returns the user permissions to a form and submission. - * - * @param user - The user or current user if undefined. For anonymous, use "null" - * @param form - The form or current form if undefined. For no form check, use "null" - * @param submission - The submisison or "index" if undefined. - * - * @return {{create: boolean, read: boolean, edit: boolean, delete: boolean}} - */ - userPermissions(user?: any, form?: any, submission?: any): Promise; - /** - * `Determine if the current user can submit a form. - * @return {*} - */ - canSubmit(): Promise; - getUrlParts(url: string): RegExpMatchArray | null; - uploadFile(storage: any, file: any, fileName: any, dir: any, progressCallback: any, url: any): any; - downloadFile(file: any): any; - deleteFile(file: any): any; - static getUrlParts(url: string, formio: any): RegExpMatchArray | null; - static serialize(obj: any, _interpolate?: any): string; - static getRequestArgs(formio: any, type: string, url: string, method?: any, data?: any, opts?: any): any; - static makeStaticRequest(url: string, method?: any, data?: any, opts?: any): any; - /** - * Make an API request and wrap that request with the Form.io Request plugin system. This is very similar to the - * {Formio.request} method with a difference being that it will pass the request through the Form.io request plugin. - * - * @param {Formio} formio - An instance of the Formio class. - * @param {string} type - The request resource type. "submission", "form", etc. - * @param {string} url - The URL to request. - * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH - * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods) - * @param {object} options - An object of options to pass to the request method. - * @param {boolean} options.ignoreCache - To ignore internal caching of the request. - * @param {object} options.headers - An object of headers to pass along to the request. - * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request. - * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken. - * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method. - * @return {Promise} - */ - static makeRequest(formio: any, type: string, url: string, method?: string, data?: any, opts?: any): any; - /** - * Execute an API request to any external system. This is a wrapper around the Web fetch method. - * - * ```ts - * Formio.request('https://examples.form.io').then((form) => { - * console.log(form); - * }); - * ``` - * - * @param {string} url - The URL to request. - * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH - * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods) - * @param {Headers} header - An object of headers to pass to the request. - * @param {object} options - An object of options to pass to the request method. - * @param {boolean} options.ignoreCache - To ignore internal caching of the request. - * @param {object} options.headers - An object of headers to pass along to the request. - * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request. - * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken. - * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method. - * @return {Promise|*} - */ - static request(url: string, method?: any, data?: any, header?: any, opts?: any): any; - static get token(): any; - static set token(token: any); - static useSessionToken(options: string | { - namespace: string; - }): void; - /** - * Sets the JWT in storage to be used within an application. - * - * @param {string} token - The JWT token to set. - * @param {object} options - Options as follows - * @param {string} options.namespace - The namespace to save the token within. i.e. "formio" - * @param {Formio} options.formio - The Formio instance. - * @return {Promise|void} - */ - static setToken(token?: any, opts?: any): any; - /** - * Returns the token set within the application for the user. - * - * @param {object} options - The options as follows. - * @param {string} options.namespace - The namespace of the token you wish to fetch. - * @param {boolean} options.decode - If you would like the token returned as decoded JSON. - * @return {*} - */ - static getToken(options?: any): any; - /** - * Sets the current user within the application cache. - * - * @param {object} user - JSON object of the user you wish to set. - * @param {object} options - Options as follows - * @param {string} options.namespace - The namespace of the tokens - */ - static setUser(user: any, opts?: any): void; - /** - * Returns the user JSON. - * - * @param {object} options - Options as follows - * @param {string} namespace - The namespace of the tokens stored within this application. - * @return {object} - The user object. - */ - static getUser(options?: any): any; - /** - * Sets the BaseURL for the application. - * - * @description Every application developed using the JavaScript SDK must set both the {@link Formio.setBaseUrl} and - * {@link Formio.setProjectUrl} methods. These two functions ensure that every URL passed into the constructor of this - * class can determine the "project" context for which the application is running. - * - * Any Open Source server applications will set both the {@link Formio.setBaseUrl} and {@link Formio.setProjectUrl} - * values will be the same value. - * - * ```ts - * Formio.setBaseUrl('https://yourwebsite.com/forms'); - * Formio.setProjectUrl('https://yourwebsite.com/forms/project'); - * - * // Now the Formio constructor will know what is the "project" and what is the form alias name. Without setBaseUrl - * // and setProjectUrl, this would throw an error. - * - * const formio = new Formio('https://yourwebsite.com/forms/project/user'); - * formio.loadForm().then((form) => { - * console.log(form); - * }); - * ``` - * - * @param {string} url - The URL of the Base API url. - */ - static setBaseUrl(url: string): void; - /** - * Returns the current base url described at {@link Formio.setBaseUrl} - * - * @return {string} - The base url of the application. - */ - static getBaseUrl(): string; - static setApiUrl(url: string): void; - static getApiUrl(): string; - static setAppUrl(url: string): void; - /** - * Sets the Project Url for the application. This is an important method that needs to be set for all applications. It - * is documented @ {@link Formio.setBaseUrl}. - * - * @param {string} url - The project api url. - */ - static setProjectUrl(url: string): void; - /** - * The Auth URL can be set to customize the authentication requests made from an application. By default, this is - * just the same value as {@link Formio.projectUrl} - * - * @param {string} url - The authentication url - */ - static setAuthUrl(url: string): void; - static getAppUrl(): string; - /** - * Returns the Project url described at {@link Formio.setProjectUrl} - * - * @return {string|string} - The Project Url. - */ - static getProjectUrl(): string; - /** - * Clears the runtime internal API cache. - * - * @description By default, the Formio class will cache all API requests in memory so that any subsequent requests - * using GET method will return the cached results as long as the API URl is the same as what was cached previously. - * This cache can be cleared using this method as follows. - * - * ```ts - * Formio.clearCache(); - * ``` - * - * Or, if you just wish to clear a single request, then the {@link Formio.request#options.ignoreCache} option can be - * provided when making an API request as follows. - * - * ```ts - * Formio.loadForm({}, { - * ignoreCache: true - * }).then((form) => { - * console.log(form); - * }); - * ``` - * - * Both of the following will ensure that a new request is made to the API server and that the results will not be - * from the cached result. - */ - static clearCache(): void; - /** - * Return the access information about a Project, such as the Role ID's for that project, and if the server is - * configured to do so, the Form and Resource access configurations that the authenticated user has access to. - * - * @description This is useful for an application to determine the UI for a specific user to identify which forms they have - * access to submit or read. - * - * @param {Formio} formio - The Formio instance. - * @return {Promise} - */ - static accessInfo(formio?: any): any; - /** - * Returns an array of roles for the project, which includes the ID's and names of those roles. - * - * @param {Formio} formio - The Formio instance. - * @return {Promise} - */ - static projectRoles(formio?: any): any; - /** - * Return the currentUser object. This will fetch the user from the server and respond with the Submission JSON - * of that user object. - * - * @param {Formio} formio - The Formio instance - * @param {object} options - The options passed to {@link Formio.getUser} - * @return {Promise|*} - */ - static currentUser(formio?: any, options?: any): any; - /** - * Performs a logout of the Form.io application. This will reset all cache, as well as make a request to the logout - * endpoint of the Form.io api platform. - * - * @param {Formio} formio - A Formio instance. - * @param {object} options - Options passed to both {@link Formio.setToken} as well as {@link Formio.setUser} - * @return {Promise} - */ - static logout(formio?: any, options?: any): any; - /** - * Returns the query passed to a page in JSON object format. - * - * @description For example, lets say you visit your application using - * the url as follows. - * - * ``` - * https://yourapplication.com/?token=23423423423&username=Joe - * ``` - * - * The following code will provide your application with the following. - * - * ```ts - * const query Formio.pageQuery(); - * console.log(query.token); // Will print 23423423423 - * console.log(query.username); // Will print Joe - * ``` - * - * @return {{}} - A JSON object representation of the query that was passed to the URL of an application. - */ - static pageQuery(): any; - /** - * Much like {@link Formio.currentUser}, but instead automatically injects the Bearer tokens into the headers to - * perform a Token swap of the OAuth token which will then return the JWT token for that user. - * - * @param {Formio} formio - The Formio instance - * @param {string} token - An OAuth Bearer token to use for a token swap between the OAuth provider and Form.io - * @return {Promise|*} - */ - static oAuthCurrentUser(formio: any, token: string): any; - static oauthLogoutURI(uri: string, options: string | { - namespace: string; - }): string; - /** - * Perform a SAML initialization. - * - * @description Typically, you would use the {@link Formio.ssoInit} method to perform this function - * since this method is an alias for the following. - * - * ```ts - * Formio.samlInit(); - * Formio.ssoInit('saml'); // This is the exact same thing as calling Formio.samlInit - * ``` - * - * This method will return false if the process is just starting. The code below is a typical block of code that is - * used to automatically trigger the SAML authentication process within your application using a Button component. - * - * ```ts - * if (Formio.pageQuery().saml) { - * const sso = Formio.samlInit(); - * if (sso) { - * sso.then((user) => { - * // The SSO user is now loaded! - * console.log(user); - * }); - * } - * } - * ``` - * - * You can then place the following code withiin the "Custom" action of a Button component on your form. - * - * ```ts - * Formio.samlInit(); - * ``` - * - * Now when you click on this button, it will start the handshake process with SAML, and once it returns, will pass - * a "saml" query parameter back to your application which will execute the code to load the current user from SAML. - * - * @param {object} options - Options to pass to the SAML initialization process. - * @param {string} options.relay - The URL that will be used as the authentication "relay" that occurs during a SAML handshake process. - * @return {boolean|Promise|void} - */ - static samlInit(options?: any): any; - /** - * Perform an Okta Authentication process using the {@link https://developer.okta.com/code/javascript/okta_auth_sdk|Okta SDK}. - * - * @description This method does require that you first include the Okta JavaScript SDK within your application as follows. - * - * First you need to include the Okta Authentication script. - * - * ```html - * - * ``` - * - * Then you can call this method as follows. - * - * ```ts - * Formio.oktaInit(); - * ``` - * - * @param {object} options - Options that are passed directly to the {@link https://github.com/okta/okta-auth-js#configuration-reference|Okta SDK constructor} - * @param {constructor} options.OktaAuth - If the OktaAuth constructor is not provided global to the application, it can be provided to this method using this property. - * @param {Formio} options.formio - The Formio instance. - * @param {Array} options.scopes - Scopes that are passed to the {@link https://github.com/okta/okta-auth-js#tokengetwithredirectoptions|getWithRedirect} method from the Okta SDK. - * @return {Promise} - */ - static oktaInit(options?: any): Promise; - /** - * A common static method to trigger any SSO processes. This method is really just an alias for other static methods. - * - * @param {('saml'|'okta')} type - The type of SSO to trigger. 'saml' is an alias for {@link Formio.samlInit}, and 'okta' is an alias for {@link Formio.oktaInit}. - * @param {object} options - Options to pass to the specific sso methods - * @return {*|Promise|boolean|void} - */ - static ssoInit(type: string, options?: any): any; - /** - * Lazy load a remote library dependency. - * - * @description This is useful for components that wish to lazy load a required library - * by adding that library to the section of the HTML webpage, and then provide a promise that will resolve - * when the library becomes available for use. - * - * @example Load Google Maps API. - * ```ts - * Formio.requireLibrary('googleMaps', 'google.maps.Map', 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap', true).then(() => { - * // Once the promise resolves, the following can now be used within your application. - * const map = new google.maps.Map(document.getElementById("map"), {...}); - * }); - * ``` - * - * @param {string} name - The internal name to give to the library you are loading. This is useful for caching the library for later use. - * @param {string} property - The name of the global property that will be added to the global namespace once the library has been loaded. This is used to check to see if the property exists before resolving the promise that the library is ready for use. - * @param {string} src - The URL of the library to lazy load. - * @param {boolean} polling - Determines if polling should be used to determine if they library is ready to use. If set to false, then it will rely on a global callback called ${name}Callback where "name" is the first property passed to this method. When this is called, that will indicate when the library is ready. In most cases, you will want to pass true to this parameter to initiate a polling method to check for the library availability in the global context. - * @return {Promise} - A promise that will resolve when the plugin is ready to be used. - */ - static requireLibrary(name: string, property: string, src: string | Array | FormioLibrarySource | Array, polling?: boolean, onload?: (ready: Promise) => void): any; - /** - * Determines if a lazy loaded library is ready to be used. - * - * @description Example: Let's assume that the example provided at {@link Formio.requireLibrary} was used elsewhere in your application. - * You could now use the following within a separate place that will also resolve once the library is ready to be used. - * - * ```js - * Formio.libraryReady('googleMaps').then(() => { - * // Once the promise resolves, the following can now be used within your application. - * const map = new google.maps.Map(document.getElementById("map"), {...}); - * }); - * ``` - * - * @param {string} name - The name of the library to check. - * @return {Promise} - A promise that will resolve when the library is ready to be used. - */ - static libraryReady(name: string): any; - /** - * Clones the response from the API so that it cannot be mutated. - * - * @param response - */ - static cloneResponse(response: any): any; - /** - * Sets the project path type. - * - * @param type - */ - static setPathType(type: FormioPathType): void; - static createForm(element: HTMLElement, form: any, options: any): any; - static builder(element: HTMLElement, form: any, options: any): any; - static use(plugin: any): void; - - /** - * Gets the project path type. - */ - static getPathType(): FormioPathType | undefined; - static plugins: import('./Plugins').Plugin[]; - static deregisterPlugin: typeof Plugins.deregisterPlugin; - static registerPlugin: typeof Plugins.registerPlugin; - static getPlugin: typeof Plugins.getPlugin; - static pluginWait: typeof Plugins.pluginWait; - static pluginGet: typeof Plugins.pluginGet; - static pluginAlter: typeof Plugins.pluginAlter; -} diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index c773e5f64b..0000000000 --- a/types/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export * from './components/components'; -export * from './components/schema'; -export * from './form'; -export * from './formbuilder'; -export * from './formio'; -export * from './templates'; -export * from './displays'; -export * from './widgets'; -export * from './utils'; -export * from './builders'; -export * from './rulesEngine/conjunctions'; -export * from './rulesEngine/operators'; -export * from './rulesEngine/quckRules'; -export * from './rulesEngine/rules'; -export * from './rulesEngine/transformers'; -export * from './rulesEngine/valueSources'; -export * from './providers'; -export * from './licenses'; diff --git a/types/licenses.d.ts b/types/licenses.d.ts deleted file mode 100644 index a9ed473be2..0000000000 --- a/types/licenses.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Licenses { - static readonly licenses: any; - static addLicense(name: string, license: any): void; - static removeLicense(name: string): void; - static getLicense(name: string): any; - static getLicenses(): any; -} diff --git a/types/providers.d.ts b/types/providers.d.ts deleted file mode 100644 index 39392df3fd..0000000000 --- a/types/providers.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class Providers { - static readonly providers: any; - static addProvider(type: string, name: string, provider:any): void; - static addProviders(type:string, providers: any): void; - static getProvider(type: string, name: string): any; - static getProviders(type: string): any; -} - diff --git a/types/rulesEngine/conjunctions.d.ts b/types/rulesEngine/conjunctions.d.ts deleted file mode 100644 index 0fa8ef07fa..0000000000 --- a/types/rulesEngine/conjunctions.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Conjunctions { - static readonly conjunctions: any; - static addConjunction(name: string, conjunction: any): void; - static addConjunctions(conjunctions: any): void; - static getConjunction(name: string): any; - static getConjunctions(): any; -} diff --git a/types/rulesEngine/operators.d.ts b/types/rulesEngine/operators.d.ts deleted file mode 100644 index 0205a1c3b0..0000000000 --- a/types/rulesEngine/operators.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Operators { - static readonly operators: any; - static addOperator(name: string, conjunction: any): void; - static addOperators(conjunctions: any): void; - static getOperator(name: string): any; - static getOperators(): any; -} diff --git a/types/rulesEngine/quckRules.d.ts b/types/rulesEngine/quckRules.d.ts deleted file mode 100644 index 4dc7a5f8d0..0000000000 --- a/types/rulesEngine/quckRules.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class QuickRules { - static readonly quickRules: any; - static addQuickRule(name: string, conjunction: any): void; - static addQuickRules(conjunctions: any): void; - static getQuickRule(name: string): any; - static getQuickRules(): any; -} diff --git a/types/rulesEngine/rules.d.ts b/types/rulesEngine/rules.d.ts deleted file mode 100644 index 567f0f6934..0000000000 --- a/types/rulesEngine/rules.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Rules { - static readonly rules: any; - static addRule(name: string, conjunction: any): void; - static addRules(conjunctions: any): void; - static getRule(name: string): any; - static getRules(): any; -} diff --git a/types/rulesEngine/transformers.d.ts b/types/rulesEngine/transformers.d.ts deleted file mode 100644 index b516fc86b9..0000000000 --- a/types/rulesEngine/transformers.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Transformers { - static readonly transformers: any; - static addTransformer(name: string, conjunction: any): void; - static addTransformers(conjunctions: any): void; - static getTransformer(name: string): any; - static getTransformers(): any; -} diff --git a/types/rulesEngine/valueSources.d.ts b/types/rulesEngine/valueSources.d.ts deleted file mode 100644 index 8f0227585c..0000000000 --- a/types/rulesEngine/valueSources.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class ValueSources { - static readonly valueSources: any; - static addValueSource(name: string, conjunction: any): void; - static addValueSources(conjunctions: any): void; - static getValueSource(name: string): any; - static getValueSources(): any; -} diff --git a/types/templates.d.ts b/types/templates.d.ts deleted file mode 100644 index 296fe6541c..0000000000 --- a/types/templates.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class Templates { - static readonly templates: any; - static addTemplate(name: string, template: any): void; - static setTemplate(name: string, template: any): void; - static current: any; - static readonly defaultTemplates: any; - static framework: any; -} diff --git a/types/utils.d.ts b/types/utils.d.ts deleted file mode 100644 index ccb348f68d..0000000000 --- a/types/utils.d.ts +++ /dev/null @@ -1,157 +0,0 @@ -import * as moment from 'moment'; - -export type AnyForJSON = { [key: string]: any } | any; - -export namespace Utils { - const ConditionOperators: any; - const componentValueTypes: { [key: string]: string }; - const Evaluator: any; - const _: any; - function getComponentSavedTypes(schema: object): Array | null; - function evaluate( - func: any, - args: { component: any; form: any; instance: any; row: any; data: any } | any, - ret: any, - tokenize?: any, - ): any; - function getRandomComponentId(): string; - function getPropertyValue(style: CSSStyleDeclaration, prop: string): number; - function getElementRect(element: any): { x: number; y: number; width: number; height: number }; - function boolValue(value: boolean | string): boolean; - function isMongoId(text: any): any; - function checkCalculated(component: { calculateValue?: any; key: any } | any, submission: any, rowData: any): void; - function checkSimpleConditional( - component: any /* unused */, - condition: { eq: any; show: any; when: any } & any, - row: any, - data: any, - instance: any - ): boolean; - function checkCustomConditional( - component: any /* unused */, - custom: string | any, - row: any, - data: any, - form: any, - variable: any, - onError: any, - instance: { evaluate?: any } | any, - ): any; - function checkJsonConditional( - component: { key: string | any } | any, - json: AnyForJSON, - row: any, - data: any, - form: any, - onError: any, - ): any; - function checkCondition( - component: { customConditional: any; conditional: { when: any; json: AnyForJSON } } | any, - row: any, - data: any, - form: any, - instance: any, - ): boolean; - function checkTrigger( - component: any, - trigger: { type: string; simple: any; json: AnyForJSON; javascript: any } | any, - row: any, - data: any, - form: any, - instance: any, - ): boolean | any; - function setActionProperty( - component: any, - action: { property: { type: string | any; value: any } | any; state: boolean | any; text: any }, - row: any, - data: any, - result: any, - instance?: { interpolate: (textValue: any, evalData: any) => any | any }, - ): any; - function interpolateTemplate(template: string): any; - function addTemplateHash(template: string): number; - function interpolate(rawTemplate: number | string, data: any): any; - function uniqueName(name: string, template: string, evalContext: Object): string; - function guid(): string; - function getDateSetting(date: any): null | Date; - function isValidDate(date: any): boolean; - function currentTimezone(): string; - function offsetDate(date: Date, timezone: string): { date: Date; abbr: string }; - function zonesLoaded(): boolean; - function shouldLoadZones(timezone: string): boolean; - function loadZones(timezone?: string): Promise; - function momentDate(value: moment.MomentInput, format: string, timezone: string): moment.Moment; - function formatDate(value: moment.MomentInput, format: string, timezone: string): string; - function formatOffset( - formatFn: (date: any, format: any) => string, - date: Date | any, - format: string | any, - timezone: string, - ): string; - function getLocaleDateFormatInfo(locale: string | string[]): { dayFirst: boolean }; - function convertFormatToFlatpickr(format: string): string; - function convertFormatToMoment(format: string): string; - function convertFormatToMask(format: string): string; - function getInputMask(mask: string | RegExp[]): RegExp[]; - function matchInputMask(value: string | RegExp, inputMask?: string | RegExp): boolean; - function getNumberSeparators(lang: string): { delimiter: string; decimalSeparator: string }; - function getNumberDecimalLimit(component: any): number; - function getCurrencyAffixes(input: { - currency: string; - decimalLimit: number; - decimalSeparator: string; - lang: string | string[]; - }): { prefix: string; suffix: string }; - function fieldData(data: Object, component: { key: string | any[]; multiple: boolean | any } | any): any; - function delay(fn: Function, delay: number, args: any[]): any; - function iterateKey(key: string): string; - function uniqueKey(map: Object, base: string): string; - function bootstrapVersion(options: { bootstrap?: any } | any): number; - function unfold(e: any): any; - const firstNonNil: any; - function withSwitch(a: any, b: any): [Function, Function]; - function observeOverload(callback: Function, options?: { limit?: number; delay?: number }): any; - function getContextComponents(context: any, excludeNested?: any, excludedTypes?: any): any; - function sanitize(string: string, options: any): any; - - // Form Utils - function isLayoutComponent(component: { columns: any; rows: any; components: any } | any): boolean; - function eachComponent(components: any[], fn: Function, includeAll?: boolean, path?: string, parent?: Object): any; - function matchComponent(component: any, query: any): boolean; - function getComponent(components: any[], key: string | Object | any, includeAll: boolean): any; - function searchComponents(components: any[], query: any): any; - function findComponent(components: any[], key: any, path: any, fn: Function): boolean; - function removeComponent(components: any[], path: any): void; - function fastCloneDeep(json: any): any; - function generateFormChange( - type: string | any, - data: { schema: any; parent: { key: any } | any; originalComponent: any }, - ): { - op: string; - key: any; - container?: any; - index?: number; - component?: any; - patches?: any; - }; - function applyFormChanges(form: any, changes: any[]): { form: any; failed: any[] }; - function flattenComponents(components: any[], includeAll?: boolean): any; - function hasCondition(component: any): boolean; - function parseFloatExt(value: any): number; - function formatAsCurrency(value: any): string; - function escapeRegExCharacters(value: string): string; - function getValue(submission: any, key: string): any; - function getStrings( - form: { components: any[] } | any, - ): { key: any; type?: any; property: string; string: string | any }; - - // Builder Utils - namespace BuilderUtils { - function uniquify(container: any[], component: any): boolean; - const additionalShortcuts: { button: ['Enter', 'Esc'] }; - function getAlphaShortcuts(): string[]; - function getAdditionalShortcuts(type: string): string[]; - function getBindedShortcuts(components: any[], input: any): any[]; - function getAvailableShortcuts(form: { components: any[] } | any, component: { type: any } | any): string[]; - } -} diff --git a/types/widgets.d.ts b/types/widgets.d.ts deleted file mode 100644 index ad62c4446b..0000000000 --- a/types/widgets.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class Widgets { - static readonly calendar: any; - static readonly input: any; -}