import { EnvironmentTypes, FormTypes, FreshdeskTypes } from '@oneblink/types'; import OneBlinkAppsError from './services/errors/oneBlinkAppsError'; export * from './services/integration-elements'; /** * Get an array of OneBlink Forms. * * #### Example * * ```js * const formsAppId = 1 * const forms = await formService.getForms(formAppId) * ``` * * @param formsAppId * @param abortSignal * @returns */ declare function getForms(formsAppId: number, abortSignal?: AbortSignal): Promise; /** * Get a OneBlink Form by id or slug. * * #### Example * * ```js * const form = await formService.getForm({ * formId: 1, * formAppId: 1, // `formsAppId` is optional * formsAppEnvironmentId: undefined, * formSlug: undefined, * toCompleteTask: false, * }) * * // OR * * const form = await formService.getForm({ * formSlug: 'audit', * formAppId: 1, * formsAppEnvironmentId: undefined, * formId: undefined, * toCompleteTask: false, * }) * * // OR * * const form = await formService.getForm({ * formSlug: 'audit', * formsAppEnvironmentId: 1, * formAppId: undefined, * formId: undefined, * toCompleteTask: false, * }) * ``` * * @param options * @returns */ declare function getForm({ formsAppId, formsAppEnvironmentId, abortSignal, formSlug, toCompleteTask, formId, }: { formSlug: string | undefined; formId: number | undefined; formsAppId: number | undefined; formsAppEnvironmentId: number | undefined; toCompleteTask?: boolean; abortSignal?: AbortSignal; }): Promise; type FormElementLookupResult = FormTypes.FormElementLookup & { url: string | null; records: FormTypes.FormElementLookupStaticDataRecord[] | null; runLookupOnClear: boolean; }; /** * Get an array of OneBlink Form Element Lookups. * * #### Example * * ```js * const organisationId = '1234567890ABCDEFG' * const formsAppEnvironmentId = 1 * const formElementLookups = await formService.getFormElementLookups( * organisationId, * formsAppEnvironmentId, * ) * ``` * * @param organisationId * @param formsAppEnvironmentId * @param abortSignal * @returns */ declare function getFormElementLookups(organisationId: string, formsAppEnvironmentId: number, abortSignal?: AbortSignal): Promise; /** * Get a OneBlink Form Element Lookup. * * #### Example * * ```js * const organisationId = '1234567890ABCDEFG' * const formsAppEnvironmentId = 1 * const formElementLookupId = 1 * const formElementLookup = await formService.getFormElementLookupById( * organisationId, * formsAppEnvironmentId, * formElementLookupId, * ) * if (formElementLookup) { * // Use lookup * } * ``` * * @param organisationId * @param formsAppEnvironmentId * @param formElementLookupId * @param abortSignal * @returns */ declare function getFormElementLookupById(organisationId: string, formsAppEnvironmentId: number, formElementLookupId: number, abortSignal?: AbortSignal): Promise; /** * Get a list of options sets for an organisation. * * @param organisationId The identifier for the organisation to fetch options * sets for * @param abortSignal A signal to abort any asynchronous processing * @returns An array of options sets */ declare function getFormElementOptionsSets(organisationId: string, abortSignal: AbortSignal): Promise>; type FormElementOptionsSetResult = { type: 'OPTIONS'; options: unknown; } | { type: 'SEARCH'; url: string; searchQuerystringParameter: string; } | { type: 'ERROR'; error: OneBlinkAppsError; }; /** * Get the options for an options set. * * @param formElementOptionsSet The form element options set to generate options * from * @param options The environment and form to pull options from * @param abortSignal A signal to abort any asynchronous processing * @returns A result object containing potential options or a predictable error */ declare function getFormElementOptionsSetOptions(formElementOptionsSet: FormTypes.FormElementOptionSet, { formsAppEnvironmentId, formId, }: { formsAppEnvironmentId: number; formId: number; }, abortSignal: AbortSignal): Promise; /** * @param form The form definition the form element is in. Used to generate * conditional logic for the * @param element The form element to have options appended to * @param data The untrusted options that need to be parsed. * @returns A new form element. The element passed in is not mutated. */ declare function parseFormElementOptions(form: FormTypes.Form, element: FormTypes.FormElementWithOptions, options: unknown): FormTypes.FormElementWithOptions; /** * Load the options for Form Elements that are using a OneBlink List. Useful to * cache all the dynamic options when first opening an application. * * @param forms * @param abortSignal * @returns */ declare function loadFormElementDynamicOptions(forms: FormTypes.Form[], abortSignal: AbortSignal): Promise; /** * Get the Freshdesk Fields associated with a form * * @param formId The identifier for the form to fetch freshdesk fields for * @param abortSignal A signal to abort any asynchronous processing * @returns An array of Freshdesk Fields */ declare function getFreshdeskFields(formId: number, abortSignal: AbortSignal): Promise; /** * Parse Freshdesk Field options associated with a form element as form element * options. * * @param freshdeskFields An array of Freshdesk Fields * @param element The element to array of Freshdesk Fields * @returns An object containing valid options or a predictable error */ declare function parseFreshdeskFieldOptions(freshdeskFields: FreshdeskTypes.FreshdeskField[], element: FormTypes.FormElementWithOptions): { type: 'OPTIONS'; options: FormTypes.ChoiceElementOption[]; } | { type: 'ERROR'; error: OneBlinkAppsError; }; /** * Get configuration for a OneBlink Form. * * #### Example * * ```js * const formId = 1 * const configuration = await formService.getFormConfiguration(formId) * ``` * * @param formId * @param abortSignal * @returns */ declare function getFormConfiguration(formId: number, abortSignal?: AbortSignal): Promise; export { FormElementOptionsSetResult, getForms, getForm, FormElementLookupResult, getFormElementLookups, getFormElementLookupById, getFormElementOptionsSets, getFormElementOptionsSetOptions, parseFormElementOptions, getFreshdeskFields, parseFreshdeskFieldOptions, loadFormElementDynamicOptions, getFormConfiguration, };