typings/lib2/messagev2/messagePayload/updateApplicationContextCommandMessage.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateApplicationContextCommandMessage = exports.ContextSource = void 0;
const internal_1 = require("../internal");
/**
 * Represents the context source that initiates the application context update
 */
var ContextSource;
(function (ContextSource) {
    ContextSource["chatWindow"] = "chatWindow";
    ContextSource["UIWidget"] = "UIWidget";
    ContextSource["skill"] = "skill";
})(ContextSource = exports.ContextSource || (exports.ContextSource = {}));
/**
 * Represents an update context command message.
 * This message is used in co-pilot where the application context can be sent from the client to the skill to
 * invoke or resume a flow, or it is sent from the skill to the client to trigger application navigation.
 *
 * @extends CommandMessage
 */
class UpdateApplicationContextCommandMessage extends internal_1.CommandMessage {
    /**
     * Creates an instance of the UpdateContextCommandMessage class.
     * @param {string} applicationName The command type.
     */
    constructor(applicationName) {
        super(internal_1.CommandType.updateApplicationContext);
        this.type = 'updateApplicationContextCommand';
        this.source = ContextSource.skill;
        this.applicationName = applicationName;
    }
    /**
     * Gets the context source
     * @returns {ContextSource} The context source
     */
    getSource() {
        return this.source;
    }
    /**
     * Sets the context source
     * @param {ContextSource} The context source
     * @returns {this} The updated instance of the UpdateContextCommandMessage.
     */
    setSource(source) {
        this.source = source;
        return this;
    }
    /**
     * Gets the application name
     * @returns {string} The name of the application
     */
    getApplicationName() {
        return this.applicationName;
    }
    /**
     * Sets the application name
     * @param {string} The name of the application
     * @returns {this} The updated instance of the UpdateContextCommandMessage.
     */
    setApplicationName(applicationName) {
        this.applicationName = applicationName;
        return this;
    }
    /**
     * Gets the page name
     * @returns {string} The name of the page
     */
    getPageName() {
        return this.pageName;
    }
    /**
     * Sets the page name
     * @param {string} The name of the page
     * @returns {this} The updated instance of the UpdateContextCommandMessage.
     */
    setPageName(pageName) {
        this.pageName = pageName;
        return this;
    }
    /**
     * Gets the field name
     * @returns {string} The name of the field
     */
    getFieldName() {
        return this.fieldName;
    }
    /**
     * Sets the field name
     * @param {string} The name of the field
     * @returns {this} The updated instance of the UpdateContextCommandMessage.
     */
    setFieldName(fieldName) {
        this.fieldName = fieldName;
        return this;
    }
    /**
     * Gets the parameters of the message.
     * @returns {Map<string, any>} The parameters of the message.
     */
    getParameters() {
        return this.parameters;
    }
    /**
     * Gets the value of a parameter.
     * @param {string} parameterName The name of the parameter.
     * @returns {any} The parameter value.
     */
    getParameterValue(parameterName) {
        return this.parameters ? this.parameters[parameterName] : undefined;
    }
    /**
     * Sets the parameters of the message.
     * @param {Map<string, any>} parameters The parameters to set.
     * @returns {this} The current instance of the UpdateContextCommandMessage class.
     */
    setParameters(parameters) {
        this.parameters = parameters;
        return this;
    }
    /**
     * Add a parameter to the message.
     * @param {string} name The name of the parameter.
     * @param {any} value The value of the parameter.
     * @returns {this} The current instance of the UpdateContextCommandMessage class.
     */
    addParameter(name, value) {
        if (!this.parameters) {
            this.parameters = new Map();
        }
        this.parameters[name] = value;
        return this;
    }
    /**
     * Returns the flow reset flag
     * @returns {boolean} flow reset flag
     */
    getReset() {
        return this.reset;
    }
    /**
     * Set the flow reset flag
     * @param {boolean} reset The reset flag
     * @returns {this} The current instance of the UpdateContextCommandMessage class.
     */
    setReset(reset) {
        this.reset = reset;
        return this;
    }
}
exports.UpdateApplicationContextCommandMessage = UpdateApplicationContextCommandMessage;