UNPKG

@transact-open-ux/core

Version:

Provides utility methods to integrate with the Transact Platform

216 lines (215 loc) 15.5 kB
import { FormErrorResponse, FormFunctionResponse, FormIneligibleResponse, FormInitResponse, FormLoadResponse, FormNewResponse, FormStartResponse, FormUpdateResponse, UserCancelResponse, UserSaveResponse, UserSubmitResponse } from "./types"; interface OpenUxConfig { endpoint: string; requestKey: string; isReceipt: boolean; } declare global { interface Window { openUxConfig: OpenUxConfig; callPhantom: (object: object) => void; } } /** * A boolean variable that indicates whether the app is being opened in receipt mode * @returns boolean true or false depending on whether the app is being opened in receipt mode. */ export declare const isReceipt: boolean; /** * Returns a string that contains an XML representation of the data * @param data The application data object to serialize to XML. * @param prettify A boolean value indicating whether to prettify the output. * @returns A string that contains an XML representation of the data. */ export declare const getDataXml: (data: object, prettify?: boolean | undefined) => string; /** * Returns true if Save Challenge is required. * User should perform a formLoad with options to resume the form. * @returns A boolean true if Save Challenge is required, otherwise false. */ export declare const isSaveChallengeRequired: () => boolean; /** * Make a call that performs a user initiated save operation. * It is recommended that the app displays a save confirmation page after this operation. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {boolean} sendEmailSavedForm Specify whether to send an "Form Saved" email message to the specified user emailAddress parameter * @param {boolean} sendEmailShareForm Specify whether to send a "Form Shared" email message to the user specified by the emailAddress parameter * @param {string} emailAddress The email address of the user to send the * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const userSave: (formData: object, sendEmailSavedForm?: boolean | undefined, sendEmailShareForm?: boolean | undefined, emailAddress?: string | undefined, milestone?: string | undefined) => Promise<UserSaveResponse>; /** * Make a call that performs a user initiated submit operation. * The app should display a submission confirmation page after this operation. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {boolean} sendEmailFormReceipt Specify whether to send an "Form Receipt" email message to the specified user emailAddress parameter * @param {string} emailAddress The email address of the user to send the * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const userSubmit: (formData: object, sendEmailFormReceipt?: boolean | undefined, emailAddress?: string | undefined, milestone?: string | undefined) => Promise<UserSubmitResponse>; /** * Make a call that performs a user initiated cancel abandonment operation. * The app should display a cancel confirmation page after this operation. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const userCancel: (formData: object, milestone?: string | undefined) => Promise<UserCancelResponse>; /** * Call the formInit command. * * This command type specifies that the form application is fully initialized and ready for user interaction. * The role of this command to provide analytics around the performance of forms and understand how long they take to open, * and what the impact is on conversion rate and form starts. * * This information will be recorded in the TM Request Log table as a millisecond value between the TM HTML document * data streamed completed time and the time the formInit event was received * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const formInit: () => Promise<FormInitResponse>; /** * Make a call to the form load operation to load the application prefill data at load time. * You can also load a saved application via a combination of parameters, see examples below. * After the data has been retrieved a form initiated operation will be called. * @param saveChallengeAnswer {string} specify the save challenge answer * @param trackingCode {string} specify the tracking code or reference number. This value should be used when presenting a user with a dialog to open another previously saved form. * @param parameters {object} specify custom parameters, For example a mobile SMS PIN token * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> <br> * *Note: the formData property will be an object instead of XML when returned via the core library.* */ export declare function formLoad(saveChallengeAnswer?: string, trackingCode?: string, parameters?: object): Promise<FormLoadResponse>; /** * The formNew command creates a new form transaction or opens an existing transaction. * This call should be followed by the formLoad command. * <br> * This command is provided to support the use case where Transact is not rendering the HTML Open UX application, * but instead it is being rendered separately by another system such as a Content Management System (CSM) or another application. * * @param requestUrl {string} specify the endpoint which will be used for this call and all subsequent Open UX calls * @param formCode {string} specify the globally unique application form code to create a new transaction for * @param formVersion {string} specify the application form version number to use, if not specified then the current form version will be used for the transaction * @param trackingCode {string} specify the tracking code or reference number. This value should be used when opening an previously saved form application. * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare function formNew(requestUrl: string, formCode?: string, formVersion?: string, trackingCode?: string): Promise<FormNewResponse>; /** * Make a call to the form start operation specifying that the user has started interacting with the form. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const formStart: (formData: object, milestone?: string | undefined) => Promise<FormStartResponse>; /** * This command type enables recording information about an unexpected JavaScript error in the application and * storing this information in the TM Error Log for operational support * @param {string} stacktrace the JavaScript stacktrace, with \n character new line delimiters * @param {string} context application state / context information to help understand the context of the error. * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const formError: (stacktrace: string, context?: string | undefined) => Promise<FormErrorResponse>; /** * Make a call to the form update operation, this performs an app initiated background save. * Reasons to call this command include: page change save, timer based save, milestone based save, add attachment, * specify attachment to be added manually and remove attachment. * * The parameters addAttachmentManually, removeAttachment and addAttachmentFile can be specified with appropriate metadata * using the associated helper methods, detailed separately in the parameter descriptions below. It is expected that only one * of these parameters (or none of them) would be provided for any one call, * the others can be either left off (if they appear after any other necessary parameters) or provided with a null or undefined value. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {boolean} userSaved Specify whether to set submission.user_saved_flag so that submission automatic abandonment will not occur * @param {boolean} sendEmailSavedForm Specify whether to send an "Form Saved" email message to the specified user emailAddress parameter * @param {string} emailAddress The email address of the user to send the * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @param {object} addAttachmentManually The add submit manually file attachment - use the method makeAddAttachmentManually to obtain this * @param {object} removeAttachment The remove file attachment metadata - use the method makeRemoveAttachment to obtain this * @param {object} addAttachmentFile The add file attachment metadata - use the method makeAddAttachmentFile to obtain this * @param fileContent The DOM File object with content as per: https://developer.mozilla.org/en-US/docs/Web/API/File * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> <br> * *Note: the formData property will be an object instead of XML when returned via the core library.* */ export declare const formUpdate: (formData: object, userSaved?: boolean | undefined, sendEmailSavedForm?: boolean | undefined, emailAddress?: string | undefined, milestone?: string | undefined, addAttachmentManually?: { path: string; attachmentKey: string; attachmentName: string; } | undefined, removeAttachment?: { attachmentKey: string; } | undefined, addAttachmentFile?: { path: string; attachmentKey: string; attachmentName: string; description: string; maxSize: number; fileTypes: string; } | undefined, fileContent?: File | undefined) => Promise<FormUpdateResponse>; /** * Make a call to execute a named Fluent Function service hosted on Transact Manager. * @param {string} serviceName The form action service definition name (required) * @param {string} serviceVersion The form action service definition version number (required) * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @param {object} params The parameters to the specified form function. This takes the form of an object, where each key is a parameter name. The object value for that key is delivered as the value for that parameter. * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const formFunction: (serviceName: string, serviceVersion: string, milestone?: string | undefined, params?: object | undefined) => Promise<FormFunctionResponse>; /** * Make a call to the form ineligible operation. * The app should display a custom page after this operation preventing the user from performing further work. * @param {object} formData An object tree of the form data, e.g. passed in via a Redux selector * @param {string} milestone A transaction milestone event to record with the transaction, maximum length should be 100 characters (optional) * @returns A Promise containing the response object. <br> * For more information visit the <a target="_blank" href="https://docs.avoka.com/sdk/">SDK documentation.</a> */ export declare const formIneligible: (formData: object, milestone?: string | undefined) => Promise<FormIneligibleResponse>; /** * Return an object suitable for passing to the addAttachmentManually parameter of the formUpdate method. * @param {string} path Should specify the XPath to the Attachment Field. * The path value would be used when returning validation errors to the client if the addAttachmentFile operation fail * @param {string} attachmentKey provides a GUID of the file attachment, this value will be used to store the new file attachment in TM * @param {string} attachmentName The name attribute for the meta data * @returns An object suitable for passing to the addAttachmentManually parameter of the formUpdate method. */ export declare const makeAddAttachmentManually: (path: string, attachmentKey: string, attachmentName: string) => { attachmentKey: string; attachmentName: string; path: string; }; /** * Return an object suitable for passing to the addAttachmentFile parameter of the formUpdate method. * @param {string} path Should specify the XPath to the Attachment Field. * The path value would be used when returning validation errors to the client if the addAttachmentFile operation fail * @param {string} attachmentKey provides a GUID of the file attachment, this value will be used to store the new file attachment in TM * @param {string} attachmentName The name attribute for the meta data * @param {string} description The description attribute for the meta data * @param {number} maxSize Specifies the max file size allowed for the attachment, this is a server side check. * @param {string} fileTypes Specifies the file types allowed * @returns an object suitable for passing to the addAttachmentFile parameter of the formUpdate method. */ export declare const makeAddAttachmentFile: (path: string, attachmentKey: string, attachmentName: string, description: string, maxSize: number, fileTypes: string) => { attachmentKey: string; attachmentName: string; description: string; fileTypes: string; maxSize: number; path: string; }; /** * Return an object suitable for passing to the removeAttachment parameter of the formUpdate method. * @param {string} attachmentKey The attachmentKey string * @returns an object suitable for passing to the removeAttachment parameter of the formUpdate method. */ export declare const makeRemoveAttachment: (attachmentKey: string) => { attachmentKey: string; }; export {};