UNPKG

fluig-types

Version:
280 lines (276 loc) 11.7 kB
/** @format */ /** * Constraint type, used when creating a new constraint. * Requires: /webdesk/vcXMLRPC.js */ declare enum ConstraintType { /** * Must contain */ MUST = 1, /* * Should contain (OR) */ SHOULD = 2, /** * Must not contain */ MUST_NOT = 3, } /** * Constraint type, used by APIs. * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) */ declare class SearchConstraint { _field: string; _initialValue: string | '___NULL___VALUE___'; _finalValue: string | '___NULL___VALUE___'; _type: ConstraintType; _likeSearch: boolean; constructor(field: string, initialValue?: string, finalValue?: string, type?: ConstraintType, likeSearch?: boolean); } /** * Callback used on various `DatasetFactory` methods. * Requires: /webdesk/vcXMLRPC.js * @template T - The value types of the dataset. */ interface Callback<T> { success: (data: T) => void; error: (jqXHR: JQuery.jqXHR, textStatus: string, errorThrown: string) => void; } /** * Dataset object value. * Requires: /webdesk/vcXMLRPC.js */ type DatasetValue = string | boolean | number | null | undefined | Record<string, unknown>; /** * Result of a query to the Dataset using WCM * * Available only on pages that use the `/webdesk/vcXMLRPC.js` file. * @template T - The value types of the dataset. */ interface DatasetCallbackResult<T extends Record<string, DatasetValue>> { /** * Column names */ columns: string[]; /** * Values of the query. * On each object, the keys are the column names. */ values: { [K in keyof T]: T[K] }[]; } /** * Dataset object. * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * @template T - The value types of the dataset. */ interface Dataset<T extends Record<string, DatasetValue>> { /** * Column names */ columns: (keyof T)[]; /** * Values of the query. * On each object, the keys are the column names. */ values: { [K in keyof T]: T[K] }[]; } interface Dataset<T extends Record<string, DatasetValue>> { /** * Add a new column to the dataset * * @param {string} name The name of the column * @returns {void} */ addColumn(name: string): void; /** * Add a new row to the dataset * * @param {Record<string, any>[]} row The row to be added * @returns {void} */ addRow(row: Record<string, any>[]): void; /** * Returns the name of a column in the Dataset. * * @param {number} colNum - The index of the column (0-based). * @returns {java.lang.String} The name of the column. */ getColumnName(colNum: number): java.lang.String; /** * Returns an array with the column names in the Dataset. * * @returns {string[]} An array of column names. */ getColumnsName(): java.lang.String[]; /** * Returns the number of columns of the Dataset. * * @returns {number} The number of columns. */ getColumnsCount(): number; /** * Returns the values of the Dataset in the form of a list containing maps, * where each Dataset record corresponds to a map with the column name as the key. * * @returns {java.util.ArrayList<java.util.HashMap<string, object>>} An array of maps containing the dataset records. */ getMap(): java.util.ArrayList<java.util.HashMap<java.lang.String, java.lang.Object>>; /** * Returns the number of rows available in the Dataset. * * @returns {number} The number of rows in the dataset. */ getRowsCount(): number; /** * Returns a subset of the Dataset data, in the form of a new Dataset. * * @param {string} field - The field name to filter by. * @param {any} value - The value to filter the dataset by. * @returns {DefaultDataset} A new dataset containing the subset of data. */ getSubDataset(field: string, value: any): Dataset<T>; /** * Returns the value stored in the Dataset, in the row and column passed by the parameters. * * @param {number} row - The row index (0-based). * @param {number} col - The column index (0-based). * @returns {java.lang.Object} The value stored in the specified row and column. */ getValue(row: number, col: number): java.lang.Object; /** * Returns the value stored in the Dataset, in the row and field passed by the parameters. * * @param {number} row - The row index (0-based). * @param {string} colName - The column name. * @returns {java.lang.Object} The value stored in the specified row and column name. */ getValue(row: number, colName: string): java.lang.Object; /** * Returns all the values of a Dataset, in the form of a two-dimensional array. * * @returns {java.lang.Object[][]} A two-dimensional array of all dataset values. */ getValues(): java.lang.Object[][]; /** * WARN: Needs validation! * * Returns an object with all the values of the fields of a given sequence. * * @param {number} sequence - Sequence number. * @returns {Record<string, any>[]} The values of the row. */ getValuesBySequence(sequence: number): Record<string, any>[]; // /** * WARN: Needs validation! * * Get all the values of a dataset object of a specific fieldname. * * @param {number} * @returns {Record<string, any>[]} All the values of a specific fieldname. */ getValuesByField(fieldname: string): Record<string, any>[]; /** * Returns a ResultSet containing the Dataset data. * * @returns {javax.sql.ResultSet} A ResultSet object containing the dataset data. */ toResultSet(): javax.sql.ResultSet; } /** * Dataset factory object. * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) */ declare namespace DatasetFactory { /** * Creates a search constraint for filtering data queries. * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {string} field - The name of the field to apply the constraint on. * @param {string | null} initialValue - The initial value for the constraint (can be `null` if not required). * @param {string | null} finalValue - The final value for the constraint (can be `null` if not required). * @param {ConstraintType} type - The type of constraint to apply. * @param {boolean} [likeSearch] - Whether to perform a "LIKE" search (optional, defaults to `false`). * @returns {SearchConstraint} The constructed search constraint object. */ function createConstraint(field: string, initialValue: string | null, finalValue: string | null, type: ConstraintType, likeSearch?: boolean): SearchConstraint; /** * Obtain a string array of all available datasets * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {Callback<string[]>} callback - The callback to handle the dataset object containing the queried data. * @returns {void} */ function getAvailableDatasets(callback: Callback<string[]>): void; /** * Obtain a string array of all available datasets * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @returns {java.util.List<java.lang.String>} The available datasets. */ function getAvailableDatasets(): java.util.List<java.lang.String>; /** * Obtain data from a dataset * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {string} name - The name of the dataset to query. * @param {string[] | null} [fields] - The fields to retrieve from the dataset (optional, defaults to all fields). * @param {SearchConstraint[] | null} [constraints] - The constraints to apply to the query (optional, defaults to no constraints). * @param {(`${string};asc` | `${string};desc` | string)[] | null} [order] - The order to apply to the query (optional, defaults to no order). * @param {Callback<DatasetCallbackResult<Record<string, DatasetValue>>>} callback - The callback to handle the dataset object containing the queried data. * @returns {void} */ function getDataset<T extends Record<string, DatasetValue>>(name: string, fields: string[] | null, constraints: SearchConstraint[] | null, order: (`${string};asc` | `${string};desc` | string)[] | null, callback: Callback<DatasetCallbackResult<T>>): void; /** * Obtain data from a dataset * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {string} name - The name of the dataset to query. * @param {string[] | null} [fields] - The fields to retrieve from the dataset (optional, defaults to all fields). * @param {SearchConstraint[] | null} [constraints] - The constraints to apply to the query (optional, defaults to no constraints). * @param {(`${string};asc` | `${string};desc` | string)[] | null} [order] - The order to apply to the query (optional, defaults to no order). * @returns {Dataset<Record<string, DatasetValue>>} The dataset object containing the queried data. */ function getDataset<T extends Record<string, DatasetValue>>(name: string, fields?: string[] | null, constraints?: SearchConstraint[] | null, order?: (`${string};asc` | `${string};desc` | string)[] | null): Dataset<T>; /** * Obtain just the values from a dataset * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {string | number} name - The name of the dataset to query. * @param {Record<string, DatasetValue>} [filter] - The filter to apply to the query (optional, defaults to no filter). * @param {Callback<Record<string, DatasetValue>>} callback - The callback to handle the dataset object containing the queried data. * @returns {Record<string, DatasetValue>[]} The dataset values. */ function getDatasetValues<T extends Record<string, DatasetValue>>(name: string | number, filter: { [K in keyof T]?: T[K] } | null, callback: Callback<T[]>): void; /** * Obtain just the values from a dataset * Requires: /webdesk/vcXMLRPC.js (If not used on the backend) * * @param {string | number} name - The name of the dataset to query. * @param {Record<string, DatasetValue>} [filter] - The filter to apply to the query (optional, defaults to no filter). * @returns {Record<string, DatasetValue>[]} The dataset values. */ function getDatasetValues<T extends Record<string, DatasetValue>>(name: string | number, filter?: { [K in keyof T]?: T[K] } | null): T[]; /** * Obtain just the values from a dataset * In `getDatasetValues` function, `NOT` all field values are returned for safety reasons. * To obtain all the data, use the `DatasetFactory`. * * @param {java.lang.String} name - The name of the dataset to query. * @param {java.util.HashMap<java.lang.String, java.lang.Object> | null} [filter] - The filter to apply to the query (optional, defaults to no filter). * @returns {java.util.HashMap<keyof T, string>} The dataset values. */ function getDatasetValues<T extends Record<string, DatasetValue>>(name: java.lang.String, filter?: java.util.HashMap<java.lang.String, java.lang.Object> | null): java.util.HashMap<keyof T, DatasetValue>; } declare namespace DatasetBuilder { /** * Creates a new dataset object. * PSA: Avaiable only on the backend (Datasets, form and workflow events and etc.). * * @param {string} * @returns {Dataset<Record<string, DatasetValue>>} The dataset object. */ function newDataset<T extends Record<string, DatasetValue>>(): Dataset<T>; }