@sakuli/commons
Version:
62 lines • 1.91 kB
TypeScript
import 'reflect-metadata';
import { Type } from "../../type.interface";
declare type ReadMap<T, R = T> = (i: T) => R;
export interface PropertyDecoratorDefinition {
/**
* The path to property in a PropertyMap
* e.g. 'my-property.from.any.source'
* @see PropertyMap
*/
path: string;
/**
* The actual key of a class property
* e.g. For this class
*
* <code>
* class Test {
* @Property('some.property.path')
* myProp: string = ''
* }
* </code>
*
* the property is 'myProp'
*
*/
property: string;
reader: ReadMap<any>;
}
export declare function Property(path: string, reader?: ReadMap<any>): ({ constructor }: any, property: string) => void;
/**
* Converts value to Boolean if present
* @param path
* @constructor
*/
export declare const BooleanProperty: (path: string) => ({ constructor }: any, property: string) => void;
/**
* Converts value to Number if present
* @param path
* @constructor
*/
export declare const NumberProperty: (path: string) => ({ constructor }: any, property: string) => void;
/**
* Converts value to String if present
* @param path
* @constructor
*/
export declare const StringProperty: (path: string) => ({ constructor }: any, property: string) => void;
export interface ListPropertyOptions {
delimiter: string;
mapper: ReadMap<string, any>;
}
/**
* Assuming a string string data (all inputs are converted to string).
*
* @param path
* @param delimiter - default: ,
* @param mapper - trims each string value
* @constructor
*/
export declare const ListProperty: (path: string, { delimiter, mapper }?: Partial<ListPropertyOptions>) => ({ constructor }: any, property: string) => void;
export declare function getPropertyDecoratorDefinitions(type: Type<any>): PropertyDecoratorDefinition[];
export {};
//# sourceMappingURL=properties.decorator.d.ts.map