import { AggregationOptions, DcuplGlobalQueryOptions, DcuplQuery, DcuplQueryGroup, RawItem } from '.'; import { PivotOptions } from '../pivot'; type AggregationOptionsModel = Omit; export type PropertyType = 'any' | 'Array' | 'Array' | 'Array' | 'Array' | 'boolean' | 'date' | 'float' | 'int' | 'json' | 'string'; export declare const PropertyTypesAsArray: PropertyType[]; export declare const NumberPropertyTypes: PropertyType[]; export declare const DatePropertyTypes: PropertyType[]; /** * must be singleValued or multiValued * singleValued contains only one key to an object * multiValued contains multiple key of objects * * @minLength 1 * @chance { * "pickone": [ [ "singleValued", "multiValued" ] ] * } * @ignoreThis 2 * @important */ export type ReferenceType = 'singleValued' | 'multiValued'; export type AttributeType = PropertyType | ReferenceType; export type ModelMetadata = { name: string; description?: string; [key: string]: any; }; export type FilterComparisonType = 'equal' | 'equalIgnoreCase' | 'contains' | 'containsIgnoreCase' | 'containsIgnoreCaseAndWhitespace'; export type PropertyAggregate = (PropertyNumber | PropertyString) & { aggregate: true; }; export type FilterStringArray = { key: string; comparisonType: FilterComparisonType; }; export type FilterStringSingle = { comparisonType?: FilterComparisonType; }; /** * A property is a quality or characteristic belonging an object. * @defaultSnippets {"label":"Property", "properties":["key","type"]} * */ export type PropertyBase = { /** * A key is an unique identifier overall properties in this model. * * @minLength 1 * @important */ key: string; type: PropertyType; expression?: string; derive?: { localReference: string; remoteProperty: string; separator?: string; }; origin?: string; filter?: boolean | FilterStringSingle | FilterStringArray[] | FilterNumberArray[]; aggregate?: boolean | AggregationOptionsModel; meta?: ModelMetadata; index?: boolean; quality?: AttributeQualityConfig; }; /** * @defaultSnippets { "label": "String Property", "properties": ["key", "type:string:boolean"] } */ export type PropertyBoolean = PropertyBase & { type: 'boolean'; aggregate?: boolean | AggregationOptionsModel; filter?: boolean; }; /** * @defaultSnippets { "label": "Int Property", "properties": ["key", "type:int"] } */ export type PropertyInt = PropertyBase & { type: 'int' | 'Array'; aggregate?: boolean | AggregationOptionsModel; filter?: boolean | FilterNumberArray[]; }; /** * @defaultSnippets { "label": "Float Property", "properties": ["key", "type:float"] } */ export type PropertyFloat = PropertyBase & { type: 'float' | 'Array'; aggregate?: boolean | AggregationOptionsModel; fractionDigits?: number; filter?: boolean | FilterNumberArray[]; }; export type FilterNumberArray = { key: string; }; /** * @defaultSnippets { "label": "Json Property", "properties": ["key", "type:string:json"] } */ export type PropertyJson = PropertyBase & { type: 'json' | 'Array'; filter?: boolean; }; /** * @defaultSnippets { "label": "Any Property", "properties": ["key", "type:any"] } */ export type PropertyAny = PropertyBase & { type: 'any' | 'Array'; }; /** * Example: 'yyyy-MM-dd' | 'dd.MM.yyyy' | ... */ export type PropertyDateInputFormat = string; /** * @defaultSnippets { "label": "Date Property", "properties": ["key", "type:date"] } */ export type PropertyDate = PropertyBase & { type: 'date' | 'Array'; inputFormat?: PropertyDateInputFormat; UTC?: boolean; filter?: boolean; }; /** * @defaultSnippets { "label": "String Property", "properties": ["key", "type:string:string"] } */ export type PropertyString = PropertyBase & { type: 'string' | 'Array'; filter?: boolean | FilterStringSingle | FilterStringArray[]; }; export type PropertyNumber = PropertyFloat | PropertyInt; export type Property = PropertyString | PropertyInt | PropertyFloat | PropertyDate | PropertyJson | PropertyBoolean | PropertyAny; /** * Facet calculation is disabled by default */ export type ReferenceFilterDefinition = { calculateFacets?: boolean; excludeZeros?: boolean; excludeUndefineds?: boolean; }; export type BooleanFilterDefinition = { calculateFacets?: boolean; excludeUndefineds?: boolean; }; export type ReferenceValidity = 'loose' | 'strict'; /** * @defaultSnippets { "label": "Default Reference", "properties": ["key", "type:singleValued", "model"] } */ export type ReferenceBase = { /** * A key is an unique identifier for all reference in this model. * * @minLength 1 * @important */ key: string; type: ReferenceType; /** * The Model this reference is pointing to. * * @minLength 1 * @important */ model: string; origin?: string; filter?: boolean | ReferenceFilterDefinition; aggregate?: boolean | AggregationOptionsModel; meta?: ModelMetadata; index?: boolean; validity?: ReferenceValidity; quality?: AttributeQualityConfig; }; export type AggregatedReference = ReferenceBase & { aggregate: true; }; /** * Resolves a Reference from a foreign model * * @defaultSnippets { "label": "Resolved Reference", "properties": ["key", "type:multiValued", "model", "resolve:json:{\"reference\":\"\", \"model\":\"\" }"] } */ export type ResolvedReference = ReferenceBase & { /** * Resolve a Relationship to an foreign model * * @defaultSnippets {"label":"Resolve Relationship", "properties":["reference","model"]} */ resolve: { /** * The reference on the foreign object which should be used for resolve the relation. * * @minLength 1 * @important */ reference: string; /** * The model of the foreign object reference. * * @minLength 1 * @important */ model: string; }; }; /** * Queries a Reference from a foreign model * * @defaultSnippets { "label": "Resolved Reference", "properties": ["key", "type:multiValued", "model", "resolve:json:{\"reference\":\"\", \"model\":\"\" }"] } */ export type QueryReference = ReferenceBase & { /** * Resolve a Relationship to an foreign model * * @defaultSnippets {"label":"Resolve Relationship", "properties":["reference","model"]} */ query: DcuplGlobalQueryOptions | DcuplQuery | DcuplQueryGroup | DcuplQuery[] | DcuplQueryGroup[]; }; /** * Derives a References for a specific value from an other model * * @defaultSnippets { "label": "Derived Reference", "properties": ["key", "type:singleValued", "model", "derive:json:{\"localReference\":\"\", \"remoteReference\":\"\"}"] } */ export type DerivedReference = ReferenceBase & { type: ReferenceType; /** * Derive a specific value from an other object/entity * @defaultSnippets {"label":"Derive Values", "properties": ["localReference","remoteReference"]} */ derive: { /** * The reference on the foreign object which should be used for resolve the relation. * * @minLength 1 * @important */ localReference: string; /** * The reference on the foreign object which should be derived. * * @minLength 1 * @important */ remoteReference: string; }; }; /** * Groups a Reference by a specific value from an other model * * @defaultSnippets { "label": "Grouped Reference", "properties": ["key", "type:singleValued", "model", "groupBy:json:{\"reference\":\"\" }", "includeSelfInGroup:boolean"] } */ export type GroupedRefeference = ReferenceBase & { type: ReferenceType; /** * Group by a specific reference * @defaultSnippets {"label":"Grouped Values", "properties": ["reference","includeSelfInGroup"]} */ groupBy: { /** * The reference that groups are generated from * * @minLength 1 * @important */ reference: string; includeSelfInGroup?: boolean; }; }; export type Reference = ResolvedReference | DerivedReference | GroupedRefeference | ReferenceBase | QueryReference; export type ValueMappingValue = string | '$dcupl_falsy'; export type ValueMappingValues = { from: ValueMappingValue[]; to: any; }; export type ValueMappingConfig = { attributes: string[]; values: ValueMappingValues[]; }; export type ModelAttribute = Property | Reference; export type ModelQualityConfig = { enabled?: boolean; attributes?: AttributeQualityConfig; }; export type ValidatorErrorType = 'loose' | 'strict'; export type ValidatorConfig = { value?: any; }; export type CustomValidatorConfig = { key: string; value?: any; validatorHandling?: ValidatorErrorType; }; export type AttributeValidatorConfig = { email?: ValidatorConfig; endsWith?: ValidatorConfig; enum?: ValidatorConfig; includes?: ValidatorConfig; max?: ValidatorConfig; maxLength?: ValidatorConfig; min?: ValidatorConfig; minLength?: ValidatorConfig; pattern?: ValidatorConfig; unique?: ValidatorConfig; startsWith?: ValidatorConfig; }; export type AttributeQualityConfig = { required?: boolean; nullable?: boolean; forceStrictDataType?: boolean; validators?: AttributeValidatorConfig; validatorHandling?: ValidatorErrorType; }; /** * A model describes a real world object and hols attributes. * * @defaultSnippets {"label":"Model Definition", "properties":["key:string:myModel", "properties:json:[{\"key\":\"my_property\", \"type\": \"string\"}]", "references:array"]} */ export type ModelDefinition = { /** * The key is an unique identifier overall models in the application. * * @minLength 1 */ key: ModelNames; properties?: Property[]; references?: Reference[]; data?: RawItem[]; keyProperty?: string; autoGenerateKey?: boolean; autoGenerateProperties?: boolean; supportsAutoCreation?: boolean; valueMappings?: ValueMappingConfig[]; meta?: ModelMetadata; quality?: ModelQualityConfig; }; export type DcuplViewType = 'section' | 'pivot'; export type ViewDefinitionBase = { /** * The key is an unique identifier overall models in the application. * * @minLength 1 */ key: string; /** * @minLength 1 */ model: string; /** * @minLength 1 */ type: DcuplViewType; meta?: ModelMetadata; }; /** * @defaultSnippets { "label": "Dcupl Section View", "properties": ["key", "model", "type:section", "primaryAttribute", "aggregates:array"] } */ export type ViewDefinitionSection = ViewDefinitionBase & { type: 'section'; /** * @minLength 1 */ primaryAttribute: string; aggregates: AggregationOptions[]; }; /** * @defaultSnippets { "label": "Dcupl Pivot View", "properties": ["key", "model", "type:pivot", "options:json:{\"rows\":[{\"attribute\": \"\"}], \"columns\":[{\"attribute\": \"\"}], \"values\":[{\"attribute\": \"\", \"types\": [\"sum\"]}]}"] } */ export type ViewDefinitionPivot = ViewDefinitionBase & { type: 'pivot'; options: PivotOptions; }; export type ViewDefinition = ViewDefinitionSection | ViewDefinitionPivot; /** * Container for ModelDescriptions & Views * */ export type Model = ViewDefinition | ModelDefinition | Array; export {};