import { Options } from './common-types'; import { Type } from './types'; /** * This module defines the key classes representing building blocks for Domain * Driven Design. * See https://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks */ export declare type PropertyType = string | Function | Object | Type; /** * Property definition for a model */ export declare class PropertyDefinition { readonly name: string; type: PropertyType; json?: PropertyForm; store?: PropertyForm; [attribute: string]: any; constructor(name: string, type?: PropertyType); } /** * See https://github.com/strongloop/loopback-datasource-juggler/issues/432 */ export interface PropertyForm { in?: boolean; out?: boolean; name?: string; } /** * Definition for a model */ export declare class ModelDefinition { readonly name: string; properties: { [name: string]: PropertyDefinition; }; settings: { [name: string]: any; }; [attribute: string]: any; constructor(name: string, properties?: { [name: string]: PropertyDefinition; }, settings?: { [name: string]: any; }); /** * Add a property * @param property Property definition or name (string) * @param type Property type */ addProperty(property: PropertyDefinition | string, type?: PropertyType): this; /** * Add a setting * @param name Setting name * @param value Setting value */ addSetting(name: string, value: any): this; /** * Get an array of definitions for ID properties, which are specified in * the model settings or properties with `id` attribute. For example, * ``` * { * settings: { * id: ['id'] * } * properties: { * id: { * type: 'string', * id: true * } * } * } * ``` */ idProperties(): PropertyDefinition[]; } /** * Base class for models */ export declare abstract class Model { static modelName: string; static definition: ModelDefinition; /** * Serialize into a plain JSON object */ toJSON(): Object; /** * Convert to a plain object as DTO */ toObject(options?: Options): Object; [prop: string]: any; } export interface Persistable { } /** * Base class for value objects - An object that contains attributes but has no * conceptual identity. They should be treated as immutable. */ export declare abstract class ValueObject extends Model implements Persistable { } /** * Base class for entities which have unique ids */ export declare abstract class Entity extends Model implements Persistable { /** * Get the identity value. If the identity is a composite key, returns * an object. */ getId(): any; /** * Get the identity as an object, such as `{id: 1}` or * `{schoolId: 1, studentId: 2}` */ getIdObject(): Object; /** * Build the where object for the given id */ static buildWhereForId(id: any): any; } /** * Domain events */ export declare class Event { source: any; type: string; }