### Class: classdecoratorfactory = new ClassDecoratorFactory()

Factory for class decorators

#### create() : ClassDecorator

#### createDecorator(key: MetadataKey<T, ClassDecorator>, spec: T, options: DecoratorOptions) : anonymous

Create a class decorator function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, ClassDecorator>` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator

### Class: decoratorfactory = new DecoratorFactory()

Base factory class for decorator functions

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
TARGET | `string` | "__decoratorTarget" | static exported | A constant to reference the target of a decoration

#### constructor(key: string, spec: T, options: DecoratorOptions) : DecoratorFactory

Construct a new class decorator factory

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator. Default to `{allowInheritance: true}` if not provided

#### create() : D

Create a decorator function of the given type. Each sub class MUST implement this method.

#### getTarget(spec: T) : any

Get the optional decoration target of a given spec

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `T` |  |  | Metadata spec

#### withTarget(spec: T, target: Object) : T

Set a reference to the target class or prototype for a given spec if it's an object

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
spec | `T` |  |  | Metadata spec
target | `Object` |  |  | Target of the decoration. It is a class or the prototype of a class.

#### cloneDeep(val: Readonly<V>) : V

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
val | `Readonly<V>` |  |  | Base factory class for decorator functions

#### getNumberOfParameters(target: Object, member: undefined | string) : number

Get the number of parameters for a given constructor or method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  | Class or the prototype
member | `undefined | string` |  | optional | Method name

#### getTargetName(target: Object, member: string | symbol, descriptorOrIndex: TypedPropertyDescriptor<any> | number) : string

Get the qualified name of a decoration target. For example:

    class MyClass
    MyClass.constructor[0] // First parameter of the constructor
    MyClass.myStaticProperty
    MyClass.myStaticMethod()
    MyClass.myStaticMethod[0] // First parameter of the myStaticMethod
    MyClass.prototype.myProperty
    MyClass.prototype.myMethod()
    MyClass.prototype.myMethod[1] // Second parameter of myMethod

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  | Class or prototype of a class
member | `string | symbol` |  | optional | Optional property/method name
descriptorOrIndex | `TypedPropertyDescriptor<any> | number` |  | optional | Optional method descriptor or parameter index

### Class: methoddecoratorfactory = new MethodDecoratorFactory()

Factory for method decorators

#### create() : MethodDecorator

#### createDecorator(key: MetadataKey<T, MethodDecorator>, spec: T, options: DecoratorOptions) : anonymous

Create a method decorator function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, MethodDecorator>` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator

### Class: methodparameterdecoratorfactory = new MethodParameterDecoratorFactory()

Factory for method level parameter decorator.

#### create() : MethodDecorator

#### createDecorator(key: MetadataKey<T, MethodDecorator>, spec: T, options: DecoratorOptions) : anonymous

Create a method decorator function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, MethodDecorator>` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator

### Class: parameterdecoratorfactory = new ParameterDecoratorFactory()

Factory for parameter decorators

#### create() : ParameterDecorator

#### createDecorator(key: MetadataKey<T, ParameterDecorator>, spec: T, options: DecoratorOptions) : anonymous

Create a parameter decorator function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, ParameterDecorator>` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator

### Class: propertydecoratorfactory = new PropertyDecoratorFactory()

Factory for property decorators

#### create() : PropertyDecorator

#### createDecorator(key: MetadataKey<T, PropertyDecorator>, spec: T, options: DecoratorOptions) : anonymous

Create a property decorator function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, PropertyDecorator>` |  |  | Metadata key
spec | `T` |  |  | Metadata object from the decorator function
options | `DecoratorOptions` |  | optional | Options for the decorator

### Interface: DecoratorOptions

Options for a decorator

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
allowInheritance | `undefined | false | true` |  | exported optional | Controls if inherited metadata will be honored. Default to `true`.
cloneInputSpec | `undefined | false | true` |  | exported optional | Controls if the value of `spec` argument will be cloned. Sometimes we use shared spec for the decoration, but the decorator function might need to mutate the object. Cloning the input spec makes it safe to use the same spec (`template`) to decorate different members. Default to `true`.

### Class: metadatainspector = new MetadataInspector()

Inspector for metadata applied by decorators

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
DesignTimeReflector | `NamespacedReflect` | TSReflector | static exported | Expose the reflector for TypeScript design-time metadata
Reflector | `NamespacedReflect` | Reflector | static exported | Expose Reflector, which is a wrapper of `Reflect` and it uses `loopback` as the namespace prefix for all metadata keys

#### defineMetadata(key: MetadataKey<T, DecoratorType>, value: T, target: Object, member: undefined | string) : void

Define metadata for the given target

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, DecoratorType>` |  |  | Metadata key
value | `T` |  |  | Metadata value
target | `Object` |  |  | Target for the metadata
member | `undefined | string` |  | optional | Optional property or method name

#### getAllMethodMetadata(key: MetadataKey<T, MethodDecorator>, target: Object, options: InspectionOptions) : MetadataMap<T> | undefined

Get the metadata associated with the given key for all methods of the target class or prototype

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, MethodDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static methods or prototype for instance methods
options | `InspectionOptions` |  | optional | Options for inspection

#### getAllParameterMetadata(key: MetadataKey<T, ParameterDecorator>, target: Object, methodName: undefined | string, options: InspectionOptions) : T[] | undefined

Get the metadata associated with the given key for all parameters of a given method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, ParameterDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static methods or prototype for instance methods
methodName | `undefined | string` |  | optional | Method name. If not present, default to '' to use the constructor
options | `InspectionOptions` |  | optional | Options for inspection

#### getAllPropertyMetadata(key: MetadataKey<T, PropertyDecorator>, target: Object, options: InspectionOptions) : MetadataMap<T> | undefined

Get the metadata associated with the given key for all properties of the target class or prototype

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, PropertyDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static methods or prototype for instance methods
options | `InspectionOptions` |  | optional | Options for inspection

#### getClassMetadata(key: MetadataKey<T, ClassDecorator>, target: Function, options: InspectionOptions) : T | undefined

Get the metadata associated with the given key for a given class

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, ClassDecorator>` |  |  | Metadata key
target | `Function` |  |  | Class that contains the metadata
options | `InspectionOptions` |  | optional | Options for inspection

#### getDesignTypeForMethod(target: Object, methodName: string) : DesignTimeMethodMetadata

Get TypeScript design time type for a method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  | Class or prototype
methodName | `string` |  |  | Method name

#### getDesignTypeForProperty(target: Object, propertyName: string) : Function

Get TypeScript design time type for a property

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  | Class or prototype
propertyName | `string` |  |  | Property name

#### getMethodMetadata(key: MetadataKey<T, MethodDecorator>, target: Object, methodName: undefined | string, options: InspectionOptions) : T | undefined

Get the metadata associated with the given key for a given method of the target class or prototype

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, MethodDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static methods or prototype for instance methods
methodName | `undefined | string` |  | optional | Method name. If not present, default to '' to use the constructor
options | `InspectionOptions` |  | optional | Options for inspection

#### getParameterMetadata(key: MetadataKey<T, ParameterDecorator>, target: Object, methodName: string, index: number, options: InspectionOptions) : T | undefined

Get the metadata associated with the given key for a parameter of a given method by index

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, ParameterDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static methods or prototype for instance methods
methodName | `string` |  |  | Method name. If not present, default to '' to use the constructor
index | `number` |  |  | Index of the parameter, starting with 0
options | `InspectionOptions` |  | optional | Options for inspection

#### getPropertyMetadata(key: MetadataKey<T, PropertyDecorator>, target: Object, propertyName: string, options: InspectionOptions) : T | undefined

Get the metadata associated with the given key for a given property of the target class or prototype

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `MetadataKey<T, PropertyDecorator>` |  |  | Metadata key
target | `Object` |  |  | Class for static properties or prototype for instance properties
propertyName | `string` |  |  | Property name
options | `InspectionOptions` |  | optional | Options for inspection

### Interface: InspectionOptions

Options for inspection

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
ownMetadataOnly | `undefined | false | true` |  | exported optional | Only inspect own metadata of a given target. The prototype chain will not be checked. The implementation uses `Reflect.getOwnMetadata()` if the flag is set to `true`. Otherwise, it uses `Reflect.getMetadata()`. The flag is `false` by default for `MetadataInspector`.

### Class: namespacedreflect = new NamespacedReflect()

#### constructor(namespace: undefined | string) : NamespacedReflect

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
namespace | `undefined | string` |  | optional | Namespace to bind this reflect context

#### decorate(decorators: (anonymous | anonymous)[], target: Object, targetKey: string | symbol, descriptor: PropertyDescriptor) : PropertyDescriptor | Function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
decorators | `(anonymous | anonymous)[]` |  |  |
target | `Object` |  |  |
targetKey | `string | symbol` |  | optional |
descriptor | `PropertyDescriptor` |  | optional |

#### decorate(decorators: ClassDecorator[], target: Object) : PropertyDescriptor | Function

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
decorators | `ClassDecorator[]` |  |  |
target | `Object` |  |  |

#### defineMetadata(metadataKey: string, metadataValue: any, target: Object, propertyKey: undefined | string) : void

define metadata for a target class or it's property/method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
metadataValue | `any` |  |  |
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### deleteMetadata(metadataKey: string, target: Object, propertyKey: undefined | string) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### getMetadata(metadataKey: string, target: Object, propertyKey: undefined | string) : any

lookup metadata from a target object and its prototype chain

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### getMetadataKeys(target: Object, propertyKey: undefined | string) : string[]

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### getOwnMetadata(metadataKey: string, target: Object, propertyKey: undefined | string) : any

get own metadata for a target object or it's property/method

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### getOwnMetadataKeys(target: Object, propertyKey: undefined | string) : string[]

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### hasMetadata(metadataKey: string, target: Object, propertyKey: undefined | string) : boolean

Check if the target has corresponding metadata

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  | Key
target | `Object` |  |  | Target
propertyKey | `undefined | string` |  | optional | Optional property key

#### hasOwnMetadata(metadataKey: string, target: Object, propertyKey: undefined | string) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
target | `Object` |  |  |
propertyKey | `undefined | string` |  | optional |

#### metadata(metadataKey: string, metadataValue: any) : anonymous

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
metadataKey | `string` |  |  |
metadataValue | `any` |  |  |

### const Reflector = new NamespacedReflect('loopback')

### Class: metadataaccessor = new MetadataAccessor()

A strongly-typed metadata accessor via reflection

#### toString() : string

#### create(key: string) : MetadataAccessor<T, D>

Create a strongly-typed metadata accessor

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | The metadata key

### Interface: DesignTimeMethodMetadata

Design time metadata for a method.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
parameterTypes | `Function[]` |  | exported | An array of parameter types
returnType | `Function` |  | exported | Return type
type | `Function` |  | exported | Type of the method itself. It is `Function`

### Interface: MetadataMap

An object mapping keys to corresponding metadata