import type { UserProvidedQualtricsApiFetchConfig, FetchResponse, UserProvidedFetchConfig } from '@qualtrics/plugin-client/src/models'; import type { ActionTaskOptions, Context, Source, WorkflowMediaSource, AvailableFileDescriptor, UiOpAck, UiOpData } from './models/models'; import PluginClient from '@qualtrics/plugin-client'; export default class ActionsTaskClient { pluginClientInstance: PluginClient; private events; numPages: number; context: Context; currentPage: number; private constructor(); static initialize(options?: ActionTaskOptions): Promise; enableAdvance(): void; disableAdvance(): void; /** * Enables the save button so the task can be saved */ enableSaveButton(): void; /** * Disables the save button so the task cannot be saved */ disableSaveButton(): void; /** * Enables the back button */ enableBackButton(): void; /** * Disables the back button */ disableBackButton(): void; /** * Used to determine if the user is configuring a new task * @returns Returns true if the task is new. Returns false if it is a saved task. */ isNewTask(): boolean; /** * Used to determine if the user is edditing a saved task * @returns Returns false if the task is new. Returns true if it is a saved task. */ isSavedTask(): boolean; /** * Used to get an object of possible connections * @returns returns an object of available connections and their ID's */ getAvailableConnections(): any; /** * Used to get an array of Source objects of available data sources * @returns returns an array of objects of available data sources */ getAvailableDataSources(): Source[]; /** * Use to get an array of WorkflowMediaSource objects of available media sources * @returns returns an array of objects of available media sources */ getAvailableMediaSources(): WorkflowMediaSource[]; /** * Used to get an array of AvailableFileDescriptor objects of available file descriptors * @returns returns an array of available AvailableFileDescriptor objects */ getAvailableFileDescriptors(): AvailableFileDescriptor[]; /** * Used to retrieve the piped text to be used in components from the `@qualtrics/plugin-ui-react` library * @returns Returns piped text array */ getPipedText(): any[]; /** * Returns a value from the plugin's configuration. * @param key - The key of the value in the configuration, defined in the extension's manifest. * @returns A promise that resolves to the value of the key in the configuration. */ getPluginConfig(key: string): Promise; /** * Used to get the previously saved config. * @returns Returns the previously saved config, or an empty object if it is a new task */ getConfig(): unknown; /** * The save handler will be called when the save button is pressed. Currently defaults to a WebService task. It should return a * config that is formatted as follows: * ``` * { * url {string}: the url of the http request * method {string}: POST or PUT * headers {object}: the header of the http request * body {object}: The body of the http request * connection {object}: { * id {string}: the name of the connection to use (see getAvailableConnections() for a list of ID's). * paramFormat {string}: where to place the credential. Can be 'header','body', or 'query'. * paramName {string}: what to name the credential param. As in, the field name for a body param, the query name for a query param, or the header name for a header. Ex: for a bearer token this might be "Authorization". * paramTemplate {string}: what to insert the credential as. Use it similarly to a string passed to String.format. EX: "Bearer %s" would be a template for bearer tokens, "%s" inserts the token as-is. * } * ``` * @param saveHandler */ onSave(saveHandler: (...args: unknown[]) => unknown): void; /** * The save handler will be called when the save button is pressed in order to use a WebService task. It should return a * config that is formatted as follows: * ``` * { * url {string}: the url of the http request * method {string}: POST or PUT * headers {object}: the header of the http request * body {object}: The body of the http request * connection {object}: { * id {string}: the name of the connection to use (see getAvailableConnections() for a list of ID's). * paramFormat {string}: where to place the credential. Can be 'header','body', or 'query'. * paramName {string}: what to name the credential param. As in, the field name for a body param, the query name for a query param, or the header name for a header. Ex: for a bearer token this might be "Authorization". * paramTemplate {string}: what to insert the credential as. Use it similarly to a string passed to String.format. EX: "Bearer %s" would be a template for bearer tokens, "%s" inserts the token as-is. * } * ``` * @param saveHandler */ webServiceOnSave(saveHandler: (...args: unknown[]) => unknown): void; /** * The save handler will be called when the save button is pressed in order to use an XM Function task. It should return a * config that is formatted as follows: * ``` * { * arguments {object}: the arguments passed into XM Function in worker.js. Maps argument names to argument values. * exports {ExportItem[]}: [ * { * key {string}: the key of the export item * display_name{string}: the display name of the export item * } * ] * } * ``` * @param saveHandler */ xmFunctionOnSave(saveHandler: (...args: unknown[]) => unknown): void; /** * Used when wanting to make the task trigger a custom worker. * * The handler should return a config with a custom triggerAction * ``` * { * triggerAction {string}: custom worker name * ... * any other fields to pass to the custom worker * } * ``` * * @param saveHandler */ customOnSave(saveHandler: (...args: unknown[]) => unknown): void; /** * The next handler will be called when the next button is pressed. * @param callback - A callback function that will be called with the next page number. If isValid is false, the callback will be called with the current page number instead. * @param isValid - A boolean value that indicates whether the current page is valid. */ onNext(callback: (...args: unknown[]) => unknown, isValid?: boolean): void; /** * The back handler will be called when the back button is pressed. * @param callback - A callback function that will be called with the back page number. */ onBack(callback: (...args: unknown[]) => unknown): void; /** * Registers a custom handler for agent UI ops (target_element, highlight_element, etc.). * Replaces the default DOM implementation. Call `defaultUiOpHandler` to delegate back. * @param handler - receives {op, payload} and must return a UiOpAck */ onUiOp(handler: (data: UiOpData) => UiOpAck | Promise): void; /** * Retrieves localized strings from the Plugin's translation files, specifically * from the translation that matches the User's language. Valid keys are defined by top-level * properties of the `strings` object in the translation file. * * @param key * @param placeHolders * @param defaultVal * @returns the translation associated with the key */ getText(key: string, placeHolders?: Record, defaultVal?: string): string; /** * Returns the language code of the logged in user given by the host on init. * @returns the language code of the logged user given by the host on init. */ getLanguage(): string; /** * Make a request to Qualtrics Public API. Similar to fetch, but doesn't accept a connection. * * The config should be formatted as follows: * ``` * { * method {string}: the http method to use (ex: 'POST', 'GET, 'PUT', etc.) * body {object | string} (optional): the body of the request * } * ``` * @param {string} url - The relative Qualtrics API path to make a request to, such as `surveys` * @param {object} config - Configures all aspects of the request * @param {number} timeout - Defaults to 10000 (10 seconds). Specifies the number of milliseconds at which to reject the returned promise if no response has been received from the Plugin. * @returns {Promise} - response from the API */ qualtricsApiFetch(url: string, config: UserProvidedQualtricsApiFetchConfig, timeout?: number): Promise; /** * Sends a request to the provided URL. Injects user defined account for authentication * if specified in connection property. * * fetchConfig should be formatted as follows: * ``` * { * method {string}: the http method to use (ex: 'POST', 'GET, 'PUT', etc.) * headers {object} (optional): key/value pairs that correspond to headers to add to the request (ex: "Content-Type": "application/json") * body {object | string} (optional): the body of the request * params {object} (optional): key/value pairs that correspond query params to add to the request URL (ex: "filter": "random") * connection {object} (optional): { * connectionName {string}: the name of the connection to use (see context.availableConnections for a list of connections). * paramFormat {string}: where to place the credential. Can be 'header','body', or 'query'. * paramName {string}: what to name the credential param. As in, the field name for a body param, the query name for a query param, or the header name for a header. Ex: for a bearer token this might be "Authorization". * paramTemplate {string}: what to insert the credential as. Use it similarly to a string passed to String.format. EX: "Bearer %s" would be a template for bearer tokens, "%s" inserts the token as-is. * } * } * ``` * @param {string} url - The URL to make a request to * @param {object} fetchConfig - Configures all aspects of the request * @param {number} timeout - Defaults to 10000 (10 seconds). Specifies the number of milliseconds at which to reject the returned promise if no response has been received from the Plugin. * @returns {Promise} resolves to an object containing {responseBody: JSON string, httpStatusCode: string} */ fetch(url: string, fetchConfig: UserProvidedFetchConfig, timeout?: number): Promise; }