rosettajs_dist_lib_rosetta_database.js

"use strict";
/***************************************************
* Licensed Materials - Property of HCL.
* (c)Copyright HCL America, Inc. 2023-2024
****************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
exports.dbLookup = exports.dbColumn = exports._openFormula = exports._notes_drapi = exports._notes_vmx_utils = exports._notes_vmx = exports._notes = void 0;
exports.dAverage = dAverage;
exports.dCount = dCount;
exports.dCountA = dCountA;
exports.dGet = dGet;
exports.dMax = dMax;
exports.dMin = dMin;
exports.dProduct = dProduct;
exports.dstDev = dstDev;
exports.dstDevP = dstDevP;
exports.dSum = dSum;
exports.dVar = dVar;
exports.dVarP = dVarP;
exports.getDocField = getDocField;
exports.setDocField = setDocField;
exports.dB2Schema = dB2Schema;
exports.dbCommand = dbCommand;
exports.dbExists = dbExists;
exports.dbManager = dbManager;
exports.dbName = dbName;
exports.dbTitle = dbTitle;
exports.getProfileField = getProfileField;
exports.isDB2 = isDB2;
exports.isExpandable = isExpandable;
exports.replicaID = replicaID;
exports.serverName = serverName;
exports.setProfileField = setProfileField;
exports.viewTitle = viewTitle;
exports.webDbName = webDbName;
exports.addDatabase = addDatabase;
exports.addDatabaseRepID = addDatabaseRepID;
exports.databaseDelete = databaseDelete;
exports.databaseReplSettings = databaseReplSettings;
exports.publishDatabase = publishDatabase;
exports.renameDatabase = renameDatabase;
exports.switchView = switchView;
exports._selectDocuments = _selectDocuments;
const tslib_1 = require("tslib");
/**
 * @file Database
 * @module database
 * @category Database
 */
const openf = tslib_1.__importStar(require("../openformula/database"));
const notesf_base = tslib_1.__importStar(require("../notes/database"));
const notesf_vmx = tslib_1.__importStar(require("../notes/voltmx/database"));
const notesf_vmx_utils = tslib_1.__importStar(require("../notes/voltmx/database.utils"));
const notesf_drapi = tslib_1.__importStar(require("../notes/drapi/database"));
const API = tslib_1.__importStar(require("../rosetta/API"));
/**
 * Sets the Notes function to the current Framework.
 * Note that if a function is not defined for the current Framework, the default base framework function is used.
 */
const notesf = () => {
    switch (API.getCurrentFramework()) {
        case API._config.framework._voltmx:
            return notesf_vmx;
        case API._config.framework._drapi:
            return notesf_drapi;
        default:
            return notesf_base;
    }
};
exports._notes = notesf_base;
exports._notes_vmx = notesf_vmx;
exports._notes_vmx_utils = notesf_vmx_utils;
exports._notes_drapi = notesf_drapi;
const notesc = notesf; // notes commands are exposed in the notes functions source file; this notesc is just for visual cue
exports._openFormula = openf;
//-----------------------------
// Open Formula database
/**
 * Finds the average of values in a given field from the records (rows) in a
 * database that match a search criteria.
 * @param {Array} database Range of values that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
 * @param {string} field Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
 * @param {Array} criteria Range of values that contains the conditions you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one value below the column label in which you specify a condition for the column.
 * @returns {number} Average of the field's values from call to OpenFormula DAVERAGE function
 */
function dAverage(database, field, criteria) {
    return openf.DAVERAGE(database, field, criteria);
}
/**
 * Counts the number of records (rows) in a database that match a search criteria
 * and contain numerical values.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Count of records matching search criteria from call to OpenFormula
 *     DCOUNT function
 */
function dCount(database, field, criteria) {
    return openf.DCOUNT(database, field, criteria);
}
/**
 * Counts the number of records (rows) in a database that match a search criteria
 * and contain values (as COUNTA).
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Count of records matching search criteria from call to OpenFormula
 *     DCOUNTA function
 */
function dCountA(database, field, criteria) {
    return openf.DCOUNTA(database, field, criteria);
}
/**
 * Get the single value in the field from the single record (row) in a database
 * that matches a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Value in field matching search criteria from call to OpenFormula DGET function
 */
function dGet(database, field, criteria) {
    return openf.DGET(database, field, criteria);
}
/**
 * Finds the maximum value in a given field from the records (rows) in a database
 * that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Maximum value of the field's values matching search criteria from call
 *     to OpenFormula DMAX function
 */
function dMax(database, field, criteria) {
    return openf.DMAX(database, field, criteria);
}
/**
 * Finds the minimum value in a given field from the records (rows) in a database
 * that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Minimum value of the field's values matching search criteria from call
 *     to OpenFormula DMIN function
 */
function dMin(database, field, criteria) {
    return openf.DMIN(database, field, criteria);
}
/**
 * Finds the product of values in a given field from the records (rows) in a
 * database that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Product of the field's values matching search criteriain field records
 *     matching search criteria from call to OpenFormula DPRODUCT function
 */
function dProduct(database, field, criteria) {
    return openf.DPRODUCT(database, field, criteria);
}
/**
 * Finds the sample standard deviation in a given field from the records (rows) in
 * a database that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Sample standard deviation of the field's values matching search criteria
 *     from call to OpenFormula DSTDEV function
 */
function dstDev(database, field, criteria) {
    return openf.DSTDEV(database, field, criteria);
}
/**
 * Finds the population standard deviation in a given field from the records (rows)
 * in a database that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Population standard deviation of the field's values matching search
 *     criteria from call to OpenFormula DSTDEVP function
 */
function dstDevP(database, field, criteria) {
    return openf.DSTDEVP(database, field, criteria);
}
/**
 * Finds the sum of values in a given field from the records (rows) in a database
 * that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Sum of the field's values matching search criteria from call to
 *     OpenFormula DSUM function
 */
function dSum(database, field, criteria) {
    return openf.DSUM(database, field, criteria);
}
/**
 * Finds the sample variance in a given field from the records (rows) in a database
 * that match a search criteria.
 * @param {Array} catabase The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Sample variance of the field's values matching search criteria from call
 *     to OpenFormula DVAR function
 */
function dVar(database, field, criteria) {
    return openf.DVAR(database, field, criteria);
}
/**
 * Finds the population variance in a given field from the records (rows) in a
 * database that match a search criteria.
 * @param {Array} database The database
 * @param {string} field The field
 * @param {Array} criteria The criteria
 * @returns {number} Population variance of the field's values matching search criteria from
 *     call to OpenFormula DVARP function
 */
function dVarP(database, field, criteria) {
    return openf.DVARP(database, field, criteria);
}
//-----------------------------
// Notes @functions database
/**
 * Returns a column of values from a view or folder in a Domino® database.
 * @param {*} cache
 * @param {*} serverDatabase
 * @param {string} viewName
 * @param {number} column
 * @returns Promise
 */
const dbColumn = (cache, serverDatabase, viewName, column = 1) => {
    const notesFunction = notesf().DbColumn;
    return typeof notesFunction === 'function' ? notesFunction(cache, serverDatabase, viewName, column) : notesf_base.DbColumn();
};
exports.dbColumn = dbColumn;
/**
 * Given a key value, looks in the specified view (or folder) and finds all
 * documents containing the key value within the view.
 * @param {*} cache
 * @param {*} serverDatabase
 * @param {string} viewName
 * @param {string} key
 * @param {*} field
 * @returns Promise
 */
const dbLookup = (cache, serverDatabase, viewName, key, field, keywords) => {
    const notesFunction = notesf().DbLookup;
    return typeof notesFunction === 'function' ? notesFunction(cache, serverDatabase, viewName, key, field, keywords) : notesf_base.DbLookup();
};
exports.dbLookup = dbLookup;
/**
 * Given the unique ID of a document, returns the contents of a specific field on
 * that document. The document must reside in the current database.
 * @param {string} documentUNID
 * @param {string} fieldName
 * @returns {*} fieldValue
 */
function getDocField(documentUNID, fieldName) {
    const notesFunction = notesf().GetDocField;
    return typeof notesFunction === 'function' ? notesFunction(documentUNID, fieldName) : notesf_base.GetDocField();
}
/**
 * Given the unique ID of a document, sets the value of a specific field on that
 * document. The document must reside in the current database.
 * @param {string} documentUNID The unique ID of a document.
 * @param {string} fieldName The name of a field in the current document.
 * @param {*} fieldValue The value to set the field.
 */
function setDocField(documentUNID, fieldName, fieldValue) {
    const notesFunction = notesf().SetDocField;
    return typeof notesFunction === 'function' ? notesFunction(documentUNID, fieldName, fieldValue) : notesf_base.SetDocField();
}
/**
 * Given the name of a database as a text string, returns a text string containing
 * the DB2® schema of that database if it is a db2nsf database or the empty string
 * if it is not a db2nsf database.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dB2Schema() {
    const notesFunction = notesf().DB2Schema;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DB2Schema();
}
/**
 * Accesses view and folder information from a Domino® database in Web applications.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dbCommand() {
    const notesFunction = notesf().DbCommand;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DbCommand();
}
/**
 * Given a server and file name, or replica ID, indicates whether the specified
 * database exists.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dbExists() {
    const notesFunction = notesf().DbExists;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DbExists();
}
/**
 * Returns a list of users, groups, and servers who currently have Manager access
 * to the database. In a window title formula, only the name of the first manager
 * listed in the ACL is displayed.
 *
 * @DbManager does not work in selection formulas or column formulas.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dbManager() {
    const notesFunction = notesf().DbManager;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DbManager();
}
/**
 * Returns the name of the current Domino® server and database.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dbName() {
    const notesFunction = notesf().DbName;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DbName();
}
/**
 * Returns the title of the current database.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function dbTitle() {
    const notesFunction = notesf().DbTitle;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.DbTitle();
}
/**
 * Retrieves a field from a profile document, and caches the field value for the
 * remainder of the session.
 * @param {Array} any arguments
 * @throws {Error} No plans to implement
 */
function getProfileField() {
    const notesFunction = notesf().GetProfileField;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.GetProfileField();
}
/**
 * Given a server and filename or server and replica ID, indicates if the specified
 * database is backed by DB2® or not.
 * @returns {boolean}
 * @throws {Error} No plans to implement
 */
function isDB2() {
    const notesFunction = notesf().IsDB2;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.IsDB2();
}
/**
 * In column formulas, returns a specified string if a row in a view can be
 * expanded.
 * @returns {string}
 * @throws {Error} No plans to implement
 */
function isExpandable() {
    const notesFunction = notesf().IsExpandable;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.IsExpandable();
}
/**
 * Returns the replica ID of the current database.
 * @returns {string}
 * @throws {Error} No plans to implement
 */
function replicaID() {
    const notesFunction = notesf().ReplicaID;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.ReplicaID();
}
/**
 * Returns the name of the server containing the current database. When the
 * database is local, returns the user name.
 * @returns {string}
 * @throws {Error} No plans to implement
 */
function serverName() {
    const notesFunction = notesf().ServerName;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.ServerName();
}
/**
 * Sets the value of a field in a profile document or creates a profile document.
 * @returns {*}
 * @throws {Error} No plans to implement
 */
function setProfileField() {
    const notesFunction = notesf().SetProfileField;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.SetProfileField();
}
/**
 * Returns the current view's name. If there are aliases and synonyms, they are
 * returned in a text list.
 * @returns {string|string[]}
 * @throws {Error} No plans to implement
 */
function viewTitle() {
    const notesFunction = notesf().ViewTitle;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.ViewTitle();
}
/**
 * Returns the name of the current database encoded for URL inclusion.
 * @returns {string}
 * @throws {Error} No plans to implement
 */
function webDbName() {
    const notesFunction = notesf().WebDbName;
    return typeof notesFunction === 'function' ? notesFunction() : notesf_base.WebDbName();
}
/**
 * Adds the specified database icon to the user's workspace, without opening the
 * database.
 * @throws {Error} no plans to implement
 */
function addDatabase() {
    const notesCommand = notesc().AddDatabase;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.AddDatabase();
}
/**
 * Adds an icon to the desktop for the database specified by its replica ID.
 * @throws {Error} no plans to implement
 */
function addDatabaseRepID() {
    const notesCommand = notesc().AddDatabaseRepID;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.AddDatabaseRepID();
}
/**
 * Permanently deletes the current database file from the hard disk where it is
 * stored.
 * @throws {Error} no plans to implement
 */
function databaseDelete() {
    const notesCommand = notesc().DatabaseDelete;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.DatabaseDelete();
}
/**
 * Displays the Replication Settings dialog box for the current database.
 * @throws {Error} no plans to implement
 */
function databaseReplSettings() {
    const notesCommand = notesc().DatabaseReplSettings;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.DatabaseReplSettings();
}
/**
 * Displays the Publish Database dialog box, where the user selects a library in
 * which to publish the selected database.
 * @throws {Error} no plans to implement
 */
function publishDatabase() {
    const notesCommand = notesc().PublishDatabase;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.PublishDatabase();
}
/**
 * For a particular database on the user's workspace, RenameDatabase locates a
 * replica of that database (based on its replica ID) on the specified server, and
 * replaces the database icon with that of the replica. The only change the user
 * sees is that the server name has changed on the database icon.
 * @throws {Error} no plans to implement
 */
function renameDatabase() {
    const notesCommand = notesc().RenameDatabase;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.RenameDatabase();
}
/**
 * Switches to the specified view or folder within the current database or, if a
 * view or folder is not specified, displays the View menu so the user can select
 * a view.
 * @throws {Error} no plans to implement
 */
function switchView() {
    const notesCommand = notesc().SwitchView;
    return typeof notesCommand === 'function' ? notesCommand() : notesf_base.SwitchView();
}
/**
 * Returns a Promise that can be resolved to an array of selected documents.
 * @param {String} formula selection formula
 * @returns Promise that will resolve to the selected documents.
 * @throws {Error} No plans to implement
 */
function _selectDocuments(formula, formName) {
    const notesCommand = notesc().SelectDocuments;
    return typeof notesCommand === 'function' ? notesCommand(formula, formName) : notesf_base.SelectDocuments();
}
//# sourceMappingURL=database.js.map