@progress/sitefinity-widget-designers-sdk
Version:
This package aims to create a parity for widget designer generation similar to the [autogenerated widget designers](https://www.progress.com/documentation/sitefinity-cms/next.js-autogenerated-field-types) in Sitefinity. Due to some limitations in Typescri
96 lines (95 loc) • 3.84 kB
TypeScript
/**
* Generates the metadata for the widget designer based on a decorated widget entity.
*/
export declare class EntityMetadataGenerator {
/**
* Compiles the designer metadata from the widget entity.
* The passed class should be decorated with {@link WidgetEntity}.
* @param widgetEntityClass The widget enitity class.
* @returns The generated designer metadata.
*/
static extractMetadata(widgetEntityClass: any): MetadataModel | undefined;
/**
* Extracts the entity's default values according to the widget designer metadata.
* The designer metadata (the {@link DefaultValue} decorator) takes precedence over the defaults set in the entity class definition.
* Handles special scenarios such as complex objects, booleans, numbers.
* @param {MetadataModel} metadata The designer metadata.
*/
static extractDefaultValues(metadata: MetadataModel): {
[key: string]: any;
};
/**
* Deserializes the values for widget properties. Parses JSON objects, turns boolean properties from string to true boolean, parses numbers.
* @param serializedValues The values assigned to the widget's properties that are received from the server.
* @param metadata The widget designer metadata.
*/
static parseValues(serializedValues: {
[key: string]: any;
}, metadata: MetadataModel): any;
/**
* Extracts a single property default value from the property model generated by the designer decorators.
* @param property The property model as in the designer metadata.
* @returns The default value for the property in the appropriate type as by the designer metadata.
*/
static extractPropertyDefaultValue(property: PropertyModel): any;
/**
* Parses a single property value based on the property model generated by the designer decorators.
* @param currentValue The property current value as persisted in Sitefinity.
* @param propertyMeta The property model as in the designer metadata.
* @returns The property value parsed to the appropriate type defined by the property metadata.
*/
static parsePropertyValue(currentValue: any, propertyMeta: PropertyModel): any;
private static getDefaultValuesForComplexType;
private static deserializeProperties;
private static buildMetadata;
private static createSectionIfNotExists;
private static addPropertyToSection;
private static pushIfHasSections;
private static compileProperty;
private static sortPropertiesByPosition;
private static unpackDataModel;
private static assignIfEmpty;
private static modifyPropertyMeta;
private static compileSpecialProperties;
private static generateCategory;
private static generateSection;
private static capitalize;
private static parseBooleanValue;
private static parseChoiceBooleanValue;
private static parseMultipleChoicesValue;
private static isMultipleChoice;
private static extractPropertiesMetadataFromHierarchy;
private static skipMetaKeyword;
private static mergePrototypes;
private static isChoiceKey;
}
export interface MetadataModel {
Name: string;
Caption: string;
PropertyMetadata: CategoryModel[];
PropertyMetadataFlat?: PropertyModel[];
}
export interface CategoryModel {
Name: string;
Sections: SectionModel[];
}
export interface SectionModel {
Name: string;
Title: string | null;
Properties: PropertyModel[];
CategoryName?: string;
}
export interface PropertyModel {
Name: string;
DefaultValue: any;
Title: string;
SectionName: string | null;
CategoryName: string | null;
Type: string | null;
Properties: {
[key: string]: any;
};
TypeChildProperties: PropertyModel[];
Position: number;
[key: string]: any;
}