/*! 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 { OcpdComponentRegister } from './ocpd-component-register'; import { Model, OcpdItemManagerHelper, SchemaPropertyInfo } from './ocpd-item-manager-helper'; import { ComponentRow, Constraint, DATA_TYPES } from './ocpd-constraints-config'; import { Component } from '@opentext/forms-common'; import { FormControlConfig } from '@opentext/forms-types'; export declare class OcpdFormSchemaManager { _ocpdComponentRegister: OcpdComponentRegister; _ocpdItemManagerHelper: OcpdItemManagerHelper; stagingSchema: { properties: {}; }; private static _instance; private activeAdditionalFormSchemas; private formSchema; private currentSchema; formSchemaLocalizations: {}; static isPropertyPathSupported: { 'check-box': { type: string; }; datetime: { date: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; dateTime: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; }; 'text-box': { string: { type: string; otFormat: { repeating: boolean; }; }; integer: { type: string; otMinimum: number; otMaximum: number; otFormat: { repeating: boolean; }; }; numeric: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; bigint: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; number: { type: string; otFormat: { repeating: boolean; }; }; decimal: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; currency: { type: string; otFormat: { dataType: string; repeating: boolean; }; }; }; 'radio-group': { type: string; otFormat: { presentationType: string; }; }; 'richtext-editor': { type: string; otFormat: { presentationType: string; }; }; 'select-box': { type: string; otFormat: { presentationType: string; repeating: boolean; }; }; 'combo-box': { type: string; otFormat: { presentationType: string; repeating: boolean; }; }; 'multi-select': { type: string; items: { type: string; }; otFormat: { repeating: boolean; presentationType: string; }; }; 'simple-list': { type: string; items: { type: string; }; otFormat: { presentationType: string; repeating: boolean; }; }; table: { type: string; items: { $ref: string; }; otFormat: { presentationType: string; }; }; 'text-area': { otFormat: { presentationType: string; repeating: boolean; }; type: string; }; 'toggle-switch': { type: string; otFormat: { presentationType: string; }; }; upload: { type: string; items: { type: string; }; otMinItems: number; otFormat: { presentationType: string; allowedExtensions: any[]; maxFileSize: number; maxFileCount: number; requireDropzone: boolean; }; }; image: {}; 'user-control': { otFormat: { dataType: string; presentationType: string; repeating: boolean; }; type: string; }; }; static workingSchemaId: string; constructor(); deleteFormSchema(): void; isFormSchemaCreated(): boolean; getFormSchema(): any; createFormSchema(id: any): void; deleteActiveAdditionalFormSchemas(): void; createActiveAdditionalFormSchemas(id: any): void; findSchemaPropertyObject(propertyPath: string, withSchemaId?: boolean): any; getActiveAdditionalFormSchemaById(schemaId: any): any; isPropertiesSectionDefined(): boolean; addPropertiesSection(): void; /** * Return information about a character. * @param {string} str the string to extract the character from * @param {number} pos the zero-based index of the character within the string * @returns {CharInfo} information about the character */ getCharInfo(str: string, pos: number): { ch: string; chUpper: string; chLower: string; isUpper: boolean; isLower: boolean; isDigit: boolean; }; /** * Checks if a word separator should be appended at the current position in a string. * @param {string} str the string to check * @param {number} pos the zero-based index of the next character within the string * @param {CharInfo} [prev] information about the previous character within the string * @returns {boolean} true if a word separator should be inserted */ appendWordSeparator(str: string, pos: number, prev: any | undefined): boolean; /** * Format a model name from a file name. * @param {string} fileName the file name of the model * @returns {string} the model name formatted from the file name */ formatNameFromFileName(fileName: string): string; static isPropertyNameInUse(propertyName: any, formSchemaModel: any): boolean; getFormSchemaPropertyObject(propertyPath: string): any; getLocalizedFormSchemaPropertyObject(locale: any, propertyName: any): any; isPropertiesDefined(propertyName: string): boolean; removeRowIdFromOptionsOrEnum(options: any, isEnum?: boolean): any; createEnumFromArrayOfObjects(enumObject: any): any[]; supportsEnumOrOptions(config: FormControlConfig): boolean; /** * Adds `otOptions` to a specific schema property * @param propertyPath property path * @param schemaProperty schema property object where otOptions will be added * @param otOptions options to be added */ addOtOptionsForProperty(propertyPath: any, schemaProperty: any, otOptions: any): void; /** * Resets `otOptions` from a specific target object. * Resets to an empty array * @param workingModel object where otOptions needs to be reset */ resetOtOptionsForProperty(workingModel: any): void; /** * Adds `enum` to a specific target object * @param propertyPath property path * @param schemaProperty schema property object where enums will be added * @param enums enum values to be added */ addEnumsForProperty(propertyPath: string, schemaProperty: any, enums: any): void; /** * Deletes `enum` from the default schema property which is used to validate default value * @param defaultSchemaProperty object where enum needs to be deleted */ deleteEnumsFromProperty(defaultSchemaProperty: any): void; /** * Deletes `otOptions` from the default schema property which is used to validate default value * @param defaultSchemaProperty object where otOptions needs to be deleted */ deleteOtOptionsFromProperty(defaultSchemaProperty: any): void; /** * Resets `enum` from a specific target object. * Resets to an empty array * @param workingModel object where enum needs to be reset */ resetEnumsForProperty(workingModel: any): void; /** * Populates options/enums into a target schema property using model and form schema based on `path` * @param modelSchemaProperty model schema property * @param formSchemaProperty form schema property * @param targetObject target property where otOptions will be added * @param values options to be added * @param {string} path type of values (either `otEnum` or `otOptions`) */ populateOptionsEnumsFromSchemas(modelSchemaProperty: any, formSchemaProperty: any, targetObject: any, values: any[], path: string): void; /** * Checks if the given schema property defines an `items` field * @param modelSchemaObject model schema object * @param formSchemaObject form schema object * @returns true if the property has `items` field in either of the two schemas */ doesPropertyHasItems(modelSchemaObject: any, formSchemaObject: any): boolean; findSchema(schemaId: any): any; findUnboundSchema(schemaId: any): any; generateCustomSchemaId(schemaId: string, config: FormControlConfig): string; addProperty(config: FormControlConfig, rootModelSchema: any, schemaItemId: any, currentLocale: any, defaultLocale: any): void; deleteLocalizationsForDeletedOTOption(workingModel: any): void; /** * Checks if an option exists in the working model otOptions * @param optionValue option value to be checked * @param workingModel working model * @returns {boolean} true if option exists */ doesOptionExistsInWorkingModel(optionValue: string, workingModel: any): boolean; /** * Delete `otOptions` for a property in all form schema localizations * This is function is mainly used when changing otOptions to enum * @param {string}propertyName propertyPath */ deleteOtOptionsFromAllLocales(propertyName: string): void; /** * Returns the otOptions from the property * @param property schema property * @returns {any[] | undefined} `otOptions` from schema */ getOtOptionsFromProperty(property: any): any[] | undefined; /** * Returns the enum from the property * @param property schema property * @returns {any[] | undefined} `enum` from schema */ getEnumsFromProperty(property: any): any[] | undefined; changeToRequiredArray(config: FormControlConfig, currentSchema: any, formSchema: any, currentSchemaProperty: any, dictionaryId: any): void; changeUserDataType(schemaProperty: any, dataType: any): void; changeExternalDataSource(propertyPath: any, currentSchema: any, dataSource: any): void; changeExternalDictionary(propertyPath: any, currentSchema: any, dictionaryId: any): void; changeConstraints(propertyPath: any, schemaProperty: any, propertyModel: any, dataType: string): void; changeConstraintErrorMessage(propertyPath: any, schemaProperty: any, errorMessage: any): void; processConstraintComponents(components: ComponentRow[]): Component[]; processComponentItem(componentItem: ComponentRow): Component; processComponentArray(dataType: string, componentsArray: any[]): any[]; isValidComponentModel(model: any, componentId: string | any[]): boolean; isMinItemsDefinedInSchema(config: FormControlConfig, schema: any, propertyName: string): boolean; isMinLengthDefinedInSchema(config: FormControlConfig, schema: any, propertyName: string): boolean; isConstDefinedInSchema(config: FormControlConfig, schema: any, propertyName: string): boolean; isMinLengthSupportedByPresentationType(currentSchemaProperty: any, dictionaryId: any): boolean; isMinLengthSupportedByDataType(currentSchemaProperty: any): boolean; isMinItemsSupportedByPresentationType(currentSchemaProperty: any): boolean; isMinItemsSupported(currentSchemaProperty: any): boolean; isMinLengthSupported(currentSchemaProperty: any, dictionaryId: any): boolean; setMinItems(currentSchemaProperty: any, property: any, minItems: number): void; setMinLength(currentSchemaProperty: any, property: any, minLength: number): void; setConstValue(property: any, constValue: any): void; setPrecision(config: FormControlConfig, currentSchemaProperty: any, precision: number): void; setScale(config: FormControlConfig, currentSchemaProperty: any, scale: number): void; setCurrencyCode(config: FormControlConfig, currentSchemaProperty: any, currencyCode: string): void; changeToRepeatingAttribute(config: FormControlConfig, currentSchemaProperty: any): void; isMaxLengthSupported(type: any, dataType: any): boolean; changeToMaxLengthAttribute(config: FormControlConfig, currentSchemaProperty: any, workingModel: any): void; static getInitialValueForProperty(config: FormControlConfig): any; resetAndBuildFormSchema(allPropertyModelsOnCanvas: Model[], formSchema: any, schemaItemId: any, currentLocale: any, defaultLocale: any): void; findModelSchemaByPropertyPath(propertyPath: string, formSchema: any, config: FormControlConfig): any; getRefFromSchemaProperty(schemaPropertyObject: any): any; rebuildFormSchema(allPropertyModelsOnCanvas: Model[], rootModelSchema: any, schemaItemId: any, currentLocale: any, defaultLocale: any): void; getConfig(allModels: Model[], parentId: any): FormControlConfig; static getFormSchemaSchemaById(schemaId: any): any; setActiveAdditionalFormSchemas(activeAdditionalFormSchemas: any): void; getActiveAdditionalFormSchemas(): any[]; clearLocalizationsForProperty(propertyPath: string): void; getAllLocalizations(): string[]; setFormSchemaLocalizations(formSchemaLocalizations: any, currentFormLocale: any, propertyName: any, value: any, propertyChanged: any): void; isEmptyObject(obj: any): boolean; deleteFormSchemaDefaultLocalizations(defaultLocale: any, formSchemaLocalizations: any): void; updateDefaultLocalePropertyInFormSchema(localeProperty: any, schemaProperty: any): void; updateDefaultLocaleInFormSchema(defaultLocale: any, formSchemaLocalizations: any): any; deleteMissingPropertyFromLocalizations(formSchemaLocalizations: any, formSchemaModel: any): any; deleteUnusedLocaleObject(localeObject: any, locale: any, formSchemaLocalizations: any): void; getFormSchemaLocalizations(): {}; setFormSchema(formSchema: any): void; resetStagingSchema(): void; notifyFormLocaleChanged(locale: any, oldLocale: any, formSchemaModel: Model): void; createPropertyModel(propertyName: string, propertyPath: string, config: FormControlConfig): Model; restoreLocalizationsWithFullPropertyPath(localizations: any, defaultLocale: any, config: FormControlConfig): void; createPropertyModelSchema(model: Model): { $id: string; properties: { default: {}; }; additionalProperties: boolean; type: string; }; /** * Delete property model for the given property name * @param propertyName - property name * @param schemaItemId - property mapping model id */ deletePropertyModel(propertyPath: string): void; static createWorkingSchema(): { $id: string; title: string; type: string; required: string[]; properties: { propertyPath: { type: string; pattern: string; }; otFormat: { type: string; items: { $ref: string; }; }; otMaxLength: { type: string; otMinimum: number; otMaximum: number; }; read_only: { type: string; }; required: { type: string; }; repeating: { type: string; }; otOptionsToggle: { type: string; }; otOptions: { type: string; items: { $ref: string; }; }; otEnum: { type: string; items: { $ref: string; }; }; default: { type: string; otFormat: {}; }; dataSource: { type: string; otMinLength: number; }; dictionaryId: { type: string; otMinLength: number; }; constraints: { type: string; items: { $ref: string; }; }; constraintsErrorMessage: { type: string; }; precision: { type: string; otMinimum: number; otMaximum: number; }; scale: { type: string; otMinimum: number; }; currencyCode: { type: string; otMinLength: number; }; }; }; createWorkingModelSkeleton(schemaItemId: any): Model; /** * Finds the maximum of two values * @param value1 first value * @param value2 second value * @returns the maximum value */ findMaximumValue(value1: any, value2: any): any; getMaxLengthFromDefault(defaultValue: any): number; calculatePropertiesMaxLength(schemaLocalisations: any, property: any, locale: any, propertyName: any, maxLengthDefaultValue: any): any; getLongestDefaultValueStringLength(propertyNames: string[]): number; /** * Get the longest string length from the `otOptions` or `enum` values for the given property names * @param propertyNames array of property names * @returns {number} the longest string length from the `otOptions` or `enum` values */ getLongestOptionsValueStringLength(propertyNames: string[]): number; /** * Get the maximum length of the otOptions/enum for a specific property * @param maxLength current max length * @param property the property to check i.e., either model schema or form schema property * @returns {number} the updated max length */ getOptionsMaxLengthForProperty(maxLength: number, property: any): number; getPropertyPath(element: HTMLElement): any; getConfigFromElement(element: HTMLElement): any; getPropertyPathsFromFocusTree(): string[]; getConfigsInCanvasThatMatchPropertyPaths(models: any, propertyPaths: any): any; getPropertyMappingModel(propertyPath: string): any; getRootPropertyMappingModel(): any; getWorkingModel(schemaItemId: any): any; getPropertyModel(schemaItemId: any, propertyPath: any): Model; getTypeFromFocusTree(): any; updateSchemaProperties(propertyPath: string, oldValue: any, newValue: any, transactionId: any, schemaItemId: any, currentFormLocale: any, defaultFormLocale: any, rowGuid: any, isUndo: any): Promise; applyPrecisionAndScale(config: FormControlConfig, localPropertyPath: string, newValue: any, propertyModel: any, transactionId: string): Promise; applyCurrencyCode(propertyModel: any, oldValue: string, newValue: string, config: FormControlConfig, isUndo: boolean, schemaItemId: string, transactionId: string): Promise; applyMaxLengthToOptionsAndEnumSchemas(isComboBox: boolean, isComboBoxOtOptionsValue: boolean, isComboBoxEnumValue: boolean, workingModel: any): void; /** * Validate and resets the default value if it is not valid * @param propertyModel property model * @param workingModel working model * @param optionValues list values */ validateAndResetDefault(propertyModel: any, workingModel: any, optionValues: any): void; /** * Checks if the default value is valid against list of options/enums * @param defaultValue default value * @param options list of options/enums * @returns {boolean} true if default value present in list of options/enums */ isDefaultValueValid(defaultValue: any, options: any[]): boolean; /** * Returns model schema object for the propertyPath * @param {string} propertyPath property path * @returns {Object | undefined} model schema object for a bound control, else undefined */ getModelSchemaObject(propertyPath: string): object | undefined; createPropertyMappingSchema(propertyMappingModel: any, schemaItemId: any): any; createPropertyMappingModel(schemaItemId: any, addWorkingModel?: boolean): Model; addPropertyToPropertyModel(config: FormControlConfig, schemaItemId: string): any; addValidationMetaDataToSchemaProperty(schemaPropertyInfo: any, config: any): any; static getFormSchemaSchemas(): any[]; clearFormSchemaLocalizations(): void; setLocalizationsFromDesign(contentLocalizations: any): void; extractAdditionalFormSchemaLocalizationsLocalizations(additionalFormSchemaLocalizations: any): any; formatFormSchemaLocalizationsForStorage(formSchemaLocalizations: any): {}; validateMaxLength(valueToTest: any, maxLength: any, repeating?: boolean): { schema: { $id: string; type: string; properties: {}; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; }; additionalSchemas: any[]; }; validatePropertyPath(valueToTest: any): { schema: { $id: string; type: string; required: string[]; properties: { valueToTest: { type: string; otMinLength: number; pattern: string; }; }; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; }; additionalSchemas: any[]; }; validateRequired(valueToTest: any, repeating?: boolean): { schema: { $id: string; type: string; required: string[]; properties: { valueToTest: { type: string; otMinLength: number; otFormat: { repeating: boolean; }; }; }; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; }; additionalSchemas: any[]; }; validateDefaultValue(config: FormControlConfig, valueToTest: any, maxLength: any, repeating: any, schemaPropertyInfo: any): { schema: { $id: string; type: string; properties: { valueToTest: any; }; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; }; additionalSchemas: any[]; }; validateIntegerRange(minimum: any, maximum: any, valueToTest: any): { schema: { $id: string; type: string; required: string[]; properties: { valueToTest: { type: string; otMinimum: any; otMaximum: any; }; }; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; }; additionalSchemas: any[]; }; validateDuplicateOptions(valueToTest: any): { schema: { $id: string; type: string; properties: { options: { type: string; items: { type: string; }; uniqueItems: boolean; }; }; additionalProperties: boolean; }; model: { data: { options: any; }; }; additionalSchemas: any[]; }; setValidationSchemaMaxLength(property: any, maxLength: number): void; showDuplicateOptionErrorMessages(validationDataAndSchema: any, schemaItemId: any, otOptionTypeIndex: any, actualPropertyPath: any): Promise<{ data: any[]; }>; getDataTypesHasOtFormat(): DATA_TYPES[]; validateByDataType(valueToTest: any, dataType: string, isRepeating: boolean, schemaItemId: string): { schema: { $id: string; type: string; properties: { valueToTest: any; }; additionalProperties: boolean; }; model: { data: { valueToTest: any; }; id: string; }; additionalSchemas: any[]; }; getSchemaForDataType(dataType: string, isRepeating: boolean): { $id: string; type: string; properties: { valueToTest: any; }; additionalProperties: boolean; }; validateSchemaProperty(itemId: any, propertyPath: string, propertyRowIndex: any): Promise<{ data: any; }>; getProblemsForConstraints(constraints: Constraint[], itemId: string): Promise<{ data: any[]; }>; validateConstantInConstraint(componentRow: ComponentRow, problems: any[], iConstraint: number, iComponent: number, schemaItemId: string): Promise; getErrorPropertyPathForComponentRow(schemaItemId: string, constraintIndex: number, componentIndex: number, componentRow: ComponentRow, repeatingIndex?: number): string; processComponentValue(propertyPath: string, itemId: string, rowId: string, newValue: any, messageId?: string): Promise<{ returnValue: any; }>; getSavedDefault(propertyPath: string, config: FormControlConfig, currentFormLocale: any, schemaPropertyInfo: SchemaPropertyInfo): string; getSavedMaxLength(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): number; getSavedDataType(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): any; /** * Returns the `OT options` from the form schema or the model schema. * @param {string} propertyName propertyName of the property * @returns {any} returns otOptions from the schema property if it exists. */ getSavedOTOptions(propertyPath: string, config: FormControlConfig, currentFormLocale: any, schemaPropertyInfo: SchemaPropertyInfo): any; getSavedConstraintErrorMessage(propertyPath: string, config: FormControlConfig, currentFormLocale: any, schemaPropertyInfo: SchemaPropertyInfo): string | undefined; getSavedEnum(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): any; getSavedConstraints(propertyPath: string, config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): any[]; private getConvertedConstraints; getSavedDataSource(config: FormControlConfig, propertyName: string, schemaPropertyInfo: SchemaPropertyInfo): any; getSavedDictionaryId(config: FormControlConfig, propertyName: string, schemaPropertyInfo: SchemaPropertyInfo): any; getSavedPrecision(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): number; getSavedScale(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): number; getSavedCurrencyCode(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): any; getSavedMasked(config: FormControlConfig, schemaPropertyInfo: SchemaPropertyInfo): boolean; isMaskedProperty(config: FormControlConfig): boolean; doesControlSupportMasking(config: FormControlConfig): boolean; deleteMetaDataForProperty(config: FormControlConfig): void; }