import type { AnnotationTerm, ConvertedMetadata, EntitySet, EntityType } from '@sap-ux/vocabularies-types'; import type { DataFieldAbstractTypes, LineItem } from '@sap-ux/vocabularies-types/vocabularies/UI'; import { UIAnnotationTerms } from '@sap-ux/vocabularies-types/vocabularies/UI'; import type { Definition, DefinitionOrBoolean } from 'typescript-json-schema'; import type { SectionTypeV2 } from '../../v2/types'; import type { PresentationVariantV4 } from '../../v4/types'; import type { FacetConfig, FacetSection, SectionType, SchemaDefinition, MessageParameters } from '@sap/ux-specification-types'; import { DefinitionName, SchemaKeyName } from '@sap/ux-specification-types'; interface PropertyInDefinition { definition?: string; property?: string; schema?: Definition; } interface EnumDefinitionParsingOptions { excludeKey?: string; resolveDefinition?: boolean; keyProperties?: SchemaKeyName[]; descriptionAsFallback?: boolean; } /** * Adds enum values to the app schema. Either as 'enum' - if multiple entries exist, * or as 'const', if it is only a single value. * * @param enumEntries - array of strings for setting up the enum definition * @param currentDefinition - currentDefinition in the schema * @param multiSelect - indication for multi selection with comma separate string approach */ export declare function addEnumToSchema(enumEntries: string[], currentDefinition: SchemaDefinition, multiSelect?: boolean): void; /** * Determines the existing UI annotations of the given list (validAnnotations). * * @param entityType - The entity type containing annotations to be processed * @param validAnnotations - List of valid UI annotation terms to be processed * @returns the list of valid annotations */ export declare function getListOfValidAnnotations(entityType: EntityType, validAnnotations: UIAnnotationTerms[]): string[]; /** * Adds an enum filled with existing UI annotations of the given list (validAnnotations). * * @param {EntityType} entityType - The entity type containing annotations to be processed * @param {UIAnnotationTerms[]} validAnnotations - List of valid UI annotation terms to be processed * @param {Definition} annoPath - the annotation path property in the app schema where the enum shall be added */ export declare function addEnumForValidAnnotations(entityType: EntityType, validAnnotations: UIAnnotationTerms[], annoPath: Definition): void; /** * Adds an enum filled with existing UI annotations for single-tab variants of a table. * * @param {EntityType} entityType - The entity type containing annotations to be processed * @param {Definition} appSchema - app specific JSON schema * @param definitionName - name of the definition in the app schema */ export declare function addEnumForSingleTabVariant(entityType: EntityType, appSchema: Definition, definitionName: string): void; /** * Adds an enum filled with existing UI annotations for multi-tab variants of a table. * * @param appSchema - app specific JSOn schema * @param definitionName - name of the definition in the app schema * @param {EntitySet} entitySet - current entity set of the page or view */ export declare function addEnumForMultiTabVariant(appSchema: Definition, definitionName: string, entitySet: EntitySet): void; /** * Adds the enum values for entitySet as part of the multiple view scenario. * * @param {ConvertedMetadata} oDataServiceAVT - combined service metadata, as returned by annotation vocabularies tools * @param appSchema - app specific JSOn schema * @param definitionName - name of the definition in the app schema */ export declare function addEnumForVariantEntitySet(oDataServiceAVT: ConvertedMetadata, appSchema: Definition, definitionName: string): void; /** * Adds an enum filled with existing UI FieldGroup annotations for annotationPath property in MultiEdit. * * @param entityType - The entity type containing annotations to be processed * @param appSchema - app specific JSOn schema * @param definitionName - name of the definition in the app schema */ export declare function addEnumFieldGroupAnnotationPath(entityType: EntityType, appSchema: Definition, definitionName: string): void; /** * Method adds definition for 'RelatedFacetKeys' as enum with description and adds references to 'RelatedFacetKeys' for custom section definitions. * * @param appSchema App specific schema that potentially gets enhanced * @param sectionDefinitions array of section definitions which should be updated with new reference to 'RelatedFacetKeys' enum. * @param facetSections Array of facet section objects which is used to generate enum values. * @param idProperties Array of property names which should be looked up in 'FacetSection' object. * Please note that method depends on order and takes first non empty value associated to passed properties. */ export declare function addDefinitionForRelatedFacetKeys(appSchema: Definition, sectionDefinitions: string[], facetSections: FacetSection[], idProperties: Array>): void; /** * Receives a facet key and returns the key as used in schema. * * @param facetKey - key of the facet, as used in annotation * @returns facetKeyInSchema - key of the facet, as used in schema */ export declare function getFacetKeyInSchema(facetKey: string): string; /** * Returns the name of a facet and definition, as key in definition. * * @param definition name of definition, as used in schema * @param facetKey - key of the facet, as used in annotation * @returns definition key of facet, as used in definition */ export declare function getFacetDefinitionKey(definition: string, facetKey: string): string; /** * Adds an existing schema definition to a new definition in the app schema. * * @param definition name of definition, as used in schema * @param facetKey - key of the facet, as used in annotation * @param {Definition} appSchema App schema in general * @param {boolean} useDefinitionAsKey If set to false, facet key will solely be used as key, else encapsulated within definition key `definition` * @returns {Definition} part of app schema that has been added and filled */ export declare function parseSchemaDefinition(definition: string, facetKey: string, appSchema: Definition, useDefinitionAsKey?: boolean): Definition; /** * Method receives custom extension base definition name and detect if it should be combined with lineItemId. * * @param appSchema - the app specific schema that shall get enhanced * @param lineItemId - line item ID, as comprise in stable ID * @param customExtensionDefinitionName - name of the custom extension definition * @returns $ref path for definition. */ export declare function getCustomExtensionDefinitionName(appSchema: Definition, lineItemId: string, customExtensionDefinitionName: string): string; /** * Functions used both by V2 and V4 to add the common definitions for a line item to the app schema. * * @param isObjectPage - indicates that the page is an object page * @param appSchema - the app specific schema that shall get enhanced * @param lineItemAnnotation - the UI.LineItem annotation, comprising all records * @param entityType - the entity type as part of the AVT ConvertedMetadata * @param lineItemId - line item ID, as comprise in stable ID * @param customColumnDefinitionName - (optional) definition name of custom column. * Passed in the V4 case, then additional properties of this type will be allowed. * @param customActionDefinitionName - (optional) definition name of custom action. * @returns the actions definition plus the annotation path to the given line item */ export declare function addCommonLineItemDefinitions(isObjectPage: boolean, appSchema: Definition, lineItemAnnotation: AnnotationTerm, entityType: EntityType, lineItemId: string, customColumnDefinitionName?: string, customActionDefinitionName?: string): { actions: Definition; footerActions: Definition; lineItemPath: string; }; export declare enum DataType { String = "String", Rating = "Rating", Progress = "Progress", DataPoint = "DataPoint", Contact = "Contact", Address = "Address", Chart = "Chart", FieldGroup = "FieldGroup", IntentBasedNavigation = "IntentBasedNavigation" } /** * Common logic to build the dataType tag from an annotation type. * * @param {string} annotation - the annotation type * @returns the dataType as string */ export declare function getDataTypeFromAnnotation(annotation: string): string; /** * Determines the dataType of the target that shall be added to a property in schema. * * @param target - the given target * @returns - the dataType as string */ export declare function determineDataTypeOfTarget(target: any): string | undefined; /** * Determines the dataType that shall be added to a property in schema for any kind of field like: * - field of a field group * - line item record * - selection field * passed as object. * * @param field - the given field * @returns - the dataType as string */ export declare function determineDataType(field: object): string | undefined; /** * Adds the dataType to the given schema field definition, if the data type cane be determined. * * @param definition - given schema definition * @param field - given field definition = annotation property, at AVT */ export declare function addDataTypeToDefinition(definition: object, field: object): void; /** * Creates a definition link for a facet and definition name. * * @param {DefinitionName} definition - name of definition, as used in schema * @param {string} facetKey - key of the facet, as used in annotation * @returns definition link of facet, as used in definition */ export declare function getFacetDefinitionLink(definition: DefinitionName | SectionTypeV2, facetKey: string): string; /** * Generates a unique facet definition link by appending an index to the facet key if necessary. * * @param definition The definition name or section type used to derive the facet definition link. * @param facetKey The base key of the facet to generate the definition link. * @param appSchema The application schema containing existing definitions where the uniqueness will be validated. * @param lineItemPath The path to the line item to check if the facet definition is associated with it. * @returns A string representing a unique facet definition link. */ export declare function getUniqueFacetDefinitionLink(definition: DefinitionName | SectionTypeV2, facetKey: string, appSchema: Definition, lineItemPath: string): string; /** * Creates and adds a reference link to a definition. * * @param {Definition} schemaPart - part of schema to add $ref to * @param {string} schemaRef - reference to be added * @param {string} schemaKey - key to be encapsulated within reference as `schemaRef` */ export declare function addDefinitionRef(schemaPart: Definition, schemaRef: string, schemaKey?: string): void; /** * Extracts annotationPath from facet or Chart/LineItem fullyQualifiedName. * * @param facet facet or Chart/LineItem * @returns {string} annotationPath */ export declare function getFacetAnnotationPath(facet: FacetConfig | PresentationVariantV4 | object): string | undefined; /** * Adds definitions for Address and Contact items in object page sections to the app schema. * * @param facet - current facet. * @param facetKey - facet key. * @param sections - schema of current sections definition. * @param appSchema - app specific schema that potentially gets enhanced. * @param sectionPrefix - prefix to distinguish Section and HeaderSection * @param subSectionPrefix - prefix to distinguish subsections within the schema * @param versionPostfix - optional postfix to distinguish schema versions */ export declare function handleAddressContact(facet: FacetConfig, facetKey: string, sections: Definition, appSchema: Definition, sectionPrefix: SectionType, subSectionPrefix?: SectionType, versionPostfix?: string): void; /** * Add schema definitions for fields of createWithParameterDialog. * * @param {object} appSchema - Application-specific schema, to be enhanced * @param {EntityType} entityType - Given entity type for which entries shall get generated * @param {string=} suffix - floorplan specific suffix (optional) */ export declare function addFieldsType(appSchema: Definition, entityType: EntityType, suffix?: string): void; /** * Method returns enum entry for passed schema definition. * * @param {Definition} appSchema App specific JSON schema * @param {SchemaDefinition} definition Target definition to resolve description. * @param {string} key Default enum key. * @param {EnumDefinitionParsingOptions} [options] Additional parsing options. * @returns {string | undefined} Enum entry of passed definition. */ export declare function getEnumEntry(appSchema: Definition, definition: SchemaDefinition, key: string, options?: EnumDefinitionParsingOptions): { const: string; description: string | undefined; custom?: boolean; }; /** * Method adds enum with key and description to schema definition. * Description can be easily used by UI to describe enum value/key. * * @param {Definition} appSchema App specific JSON schema * @param {DefinitionOrBoolean} origin Origin schema object containing key and description. * @param {PropertyInDefinition} target Target to update with enum. * @param {EnumDefinitionParsingOptions} [options] Additional parsing options. * @param {boolean} [options.resolveDefinition] Should logic use fallback to look into reference definition. */ export declare function addDescriptiveEnumDefinition(appSchema: Definition, origin: DefinitionOrBoolean, target: PropertyInDefinition, options?: EnumDefinitionParsingOptions): void; /** * Extracts the key of an action that shall be added to schema as SchemaTag.keys. * * @param action - full-blown action ID * @param isAction - indicates an action * @returns action ID stripped down to the last key part */ export declare function getActionKey(action: string, isAction: boolean): { key: string; ns: string; }; /** * Adds the schema tag key to a line item record or property in schema. * * @param lineItemRecord - the given line item record * @param properties - list of all properties in schema * @param schemaKey - key of the given property */ export declare function addKeyToDefinition(lineItemRecord: object, properties: object, schemaKey: string): void; /** * Determines the description of a data field, e.g. for the column header. * * @param dataFieldAbstract - the given record of the line item annotation * @param entityType - the entity type as part of the AVT ConvertedMetadata * @returns the description of the data field */ export declare function getDataFieldDescription(dataFieldAbstract: DataFieldAbstractTypes, entityType: EntityType): string; /** * Adds a message to the `messages` field of a schema element. * * @param {Definition} element - The schema definition to which the message should be added. * @param {MessageParameters} parameters - The message parameters including text and deletable flag. */ export declare function addMessageToSchema(element: Definition, { text, deletable }: MessageParameters): void; export {}; //# sourceMappingURL=utils.d.ts.map