"use strict";
/***************************************************
* Licensed Materials - Property of HCL.
* (c)Copyright HCL America, Inc. 2023-2024
****************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateFormulaContext = exports.isValid = exports.checkFormulaSyntax = exports.command = exports._notes_vmx = exports._notes = void 0;
const tslib_1 = require("tslib");
/**
* @file formula
* @module formula
* @category Formula
*/
const API = tslib_1.__importStar(require("../rosetta/API"));
const notesf_base = tslib_1.__importStar(require("../notes/formula"));
const notesf_vmx = tslib_1.__importStar(require("../notes/voltmx/formula"));
const notesf = () => API.isCurrentFrameworkVoltMX() ? notesf_vmx : notesf_base;
exports._notes = notesf_base;
exports._notes_vmx = notesf_vmx;
//-----------------------------
// Notes @functions Formula
/**
* Executes a Domino command.
*
* In the context of RosettaJS, the @Command is a Notes Formula function that
* does not exist in the functions of the Notes Formula language but rather an
* @Command command itself that accepts the command name to execute as its first
* argument and the accompanying command parameters as arguments 2 through n.
*
* @param {string} commandName The name of the command you want to perform. See {@link https://help.hcltechsw.com/dom_designer/12.0.2/basic/H_COMMANDS_LISTED.html|www.hcltechsw.com }
* for a list of avaliable commands.
* @param {*} commandParameters Zero, one, or more parameters, depending on the command you're calling. Separate parameters with commas.
* @returns {boolean} True if the command executes successfully or false if the command does not execute successfully.
* @example
* // Opens RECIPE.NSF to the 'Main' view, highlighting the first document whose value in the sort
* // column matches the key 'Hot Chocolate'.
* rosettajs.Formula.command("FileOpenDatabase", ["server", "RECIPE.NSF"], "Main", "Hot Chocolate" );
*/
function command(commandName, ...commandParameters) {
return notesf().Command(commandName, ...commandParameters) !== 0;
}
exports.command = command;
/**
* Checks a block of commented out formula language code for errors.
* @throws {Error} method not implemented
* @TODO this needs to be implemented
*/
function checkFormulaSyntax() {
return notesf().CheckFormulaSyntax();
}
exports.checkFormulaSyntax = checkFormulaSyntax;
/**
* At run-time, compiles and runs each element in a text expression as a formula.
* Returns the result of the last formula expression in the list or an error if an
* error is generated by any of the formula expressions in the list.
* @param {string} textExpressions Any text expressions that you want eval to evaluate.
* Surround the text expression to be evaluated with braces ({ }) or quotation marks (" ").
* If you use quotation marks, escape quotes around individual text expressions within the formula with back-slashes (\).
* If you use braces, escape the right brace. Use the plus sign (+) to concatenate text expressions.
* @returns {Promise<any>} lastExpression The value of the last expression.
* @example
* // Returns "rebar"
* let x = "re";
* rosettajs.Formula.eval('{x + "bar"}');
*/
exports.eval = (textExpressions) => {
return notesf().Eval(textExpressions);
};
/**
* Executes all validation formulas within the current form.
* @throws {Error} method not implemented
* @TODO this needs to be implemented
*/
function isValid() {
return notesf().IsValid();
}
exports.isValid = isValid;
// The @Set Notes formula is converted directly to native javascript by the Rosetta converter.
// export function set(): void | Error {
// return notesf().Set();
// }
/**
* Updates the context of a formula to a document currently being updated by the code.
* For example, if the code accesses a new form called "Response" by using rosettajs.Formula.command("Compose", "Response"),
* rosettajs.Formula.updateFormulaContext switches the context of the formula to this new form. Any subsequent functions in
* the code execute in the context of the Response document, not the current document.
*
* @returns {void | Error} A promise that resolves when the context is updated or rejects with an error.
* @example
* // This example, creates a response document to the currently selected document then populates its fname and lname fields with the values of the fname and lname fields in the current document.
* var tempfname = voltmx.rosettajs.Document.getField("fname");
* var templname = voltmx.rosettajs.Document.getField("lname");
* voltmx.rosettajs.Formula.command("Compose", "Response");
* voltmx.rosettajs.Formula.updateFormulaContext();
* await voltmx.rosettajs.Document.setField("fname", tempfname);
* await voltmx.rosettajs.Document.setField("lname", templname);
*/
function updateFormulaContext() {
return notesf().UpdateFormulaContext();
}
exports.updateFormulaContext = updateFormulaContext;
//# sourceMappingURL=formula.js.map