/*! Copyright © 2024 Open Text Corporation, All Rights Reserved. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import { ComponentType, OT_EXPRESSION_KEYS, SystemValue } from '@opentext/forms-common'; /** Union type of all valid expression key values from OT_EXPRESSION_KEYS */ type ExpressionKey = (typeof OT_EXPRESSION_KEYS)[keyof typeof OT_EXPRESSION_KEYS]; /** * Supported data types for conditions and functions */ declare enum DATA_TYPES { STRING = "string", NUMBER = "number", INTEGER = "integer", DECIMAL = "decimal", BIGINT = "bigint", NUMERIC = "numeric", CURRENCY = "currency", BOOLEAN = "boolean", DATE = "date", DATETIME = "dateTime", ARRAY = "array", INHERIT = "inherit" } interface Constraint { name: string; components: ComponentRow[]; 'ot2mc-row-id': string; } interface ComponentRow { component: any; dataType: string; default: string; 'ot2mc-row-id': string; allowUserInput: boolean; isRepeating: boolean; } interface ConstraintComponent { text: string; value: string; type: ComponentType; outputDataType: string; applicableDataTypes: string[]; allowUserInput: boolean; supportedComponentTypes?: ComponentType[]; forceIncludeKeys?: ExpressionKey[]; forceExcludeKeys?: ExpressionKey[]; tooltip: string; arrayItemDataType?: string[]; class?: string; configId?: string; } interface ConstraintComponentModel { id: string; schemaId: string; data: ConstraintComponent; } /** * Configuration for a constraint component */ interface ConstraintConfig { id: string; /** * Type of the component (comparison, function, system value, etc.) */ type: ComponentType; /** * Data types applicable for this component */ applicableDataTypes: string[]; /** * The output/return type this component produces */ outputDataType: string; /** * Whether user input is allowed for this component */ allowUserInput: boolean; /** * Component types that are specifically compatible with this component */ supportedComponentTypes?: ComponentType[]; /** * Specific keys to always include for this component. */ forceIncludeKeys?: ExpressionKey[]; /** * Specific keys to always exclude for this component. */ forceExcludeKeys?: ExpressionKey[]; /** * If the config supports array types, this specifies the data type of the items within the array */ arrayItemDataType?: string[]; } interface ConstraintsConfigType { conditions: Record; functions: Record; systemValues: Record; } declare const COLLECTION_KEYS: ("all_of" | "any_of" | "one_of" | "none_of")[]; /** * Generates a unique ID for a condition configuration. * Format: exp-{type-prefix}-{uuid} */ declare function generateComponentId(type: ComponentType): string; /** * Returns the prefix for a given component type * @param type The constraint component type * @returns The prefix string */ declare function getPrefixForComponentId(type: ComponentType): string; /** * Get entire constraint configs */ declare function getAllConstraintConfigs(): Record; /** * Returns condition configs applicable for a specific data type * @param dataType The data type to filter conditions by * @returns {Record} Condition configs applicable for the specified data type */ declare function getConditionConfigsForDataType(dataType: string): Record; /** * Returns function configs applicable for a specific data type * @param dataType The data type to filter functions by * @returns {Record} Function configs applicable for the specified data type */ declare function getFunctionConfigsForDataType(dataType: string): Record; /** * Returns system value configs applicable for a specific data type * @param dataType The data type to filter system values by * @returns {Record} System value configs applicable for the specified data type */ declare function getSystemValueConfigsForDataType(dataType: string): Record; /** * Returns the ID associated with a given component key */ declare function getIdForConstraintKey(componentKey: string): string | undefined; /** * Returns all supported data types * @returns {string[]} Array of supported data types */ declare function getAllSupportedDataTypes(): string[]; /** * Converts a snake_case string to camelCase. * Used to map expression key values (snake_case) to locale JSON keys (camelCase). */ declare function snakeToCamelCase(key: string): string; /** * Retrieves the tooltip for a given constraint key from the locale tooltips map. * @param componentKey The key of the constraint component (condition, function, or system value) * @param tooltips Locale tooltips map (camelCase keys) from the constraintsEditor locale data * @returns The localized tooltip string if found, otherwise undefined */ declare function getTooltipForConstraintKey(componentKey: string, tooltips?: Record): string | undefined; /** * Helper function to get default value based on data type * @param dataType The data type to get the default value for * @returns The default value corresponding to the specified data type */ declare function getDefaultValueByDataType(dataType: string): any; export { DATA_TYPES, SystemValue, OT_EXPRESSION_KEYS, COLLECTION_KEYS, ExpressionKey, snakeToCamelCase, ConstraintsConfigType, ConstraintConfig, Constraint, ComponentRow, ConstraintComponent, ConstraintComponentModel, generateComponentId, getIdForConstraintKey, getPrefixForComponentId, getAllConstraintConfigs, getConditionConfigsForDataType, getFunctionConfigsForDataType, getSystemValueConfigsForDataType, getAllSupportedDataTypes, getTooltipForConstraintKey, getDefaultValueByDataType };