import type { IActivityHandler } from "@vertigis/workflow"; /** An interface that defines the inputs of the activity. */ interface SetSessionStorageItemActivityInputs { /** * @displayName keyName * @description A string containing the name of the key you want to create/update. * @required */ keyName: string; /** * @displayName keyValue * @description A string containing the value you want to give the key you are creating/updating. * @required */ keyValue: string; } /** An interface that defines the outputs of the activity. */ interface SetSessionStorageItemActivityOutputs { /** * @description The result of the activity. */ result: object; } /** * @displayName Set SessionStorage Item * @category EBTA Utilities * @description Add an item to browser SessionStorage object 1.1 */ export default class SetSessionStorageItemActivity implements IActivityHandler { /** Perform the execution logic of the activity. */ async execute(inputs: SetSessionStorageItemActivityInputs): Promise { const { keyName, keyValue } = inputs; let message = ""; if (typeof(keyName) !== "undefined" && keyName !== null) { if (typeof(keyValue) !== "undefined" && keyValue !== null) { sessionStorage.setItem(keyName, keyValue); message = "Wrote value to SessionStorage"; } } else { message = "Could not write value to SessionStorage" } return { result: { "message": message, "keyName": keyName, "keyValue": keyValue } }; } }