@loopback/metadata 4.0.0-alpha.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +273 -150
  3. package/dist/decorator-factory.d.ts +297 -0
  4. package/{dist6/src → dist}/decorator-factory.js +197 -90
  5. package/dist/decorator-factory.js.map +1 -0
  6. package/dist/index.d.ts +22 -1
  7. package/dist/index.js +24 -7
  8. package/dist/index.js.map +1 -0
  9. package/dist/inspector.d.ts +120 -0
  10. package/dist/inspector.js +186 -0
  11. package/dist/inspector.js.map +1 -0
  12. package/dist/{src/reflect.d.ts → reflect.d.ts} +16 -15
  13. package/dist/{src/reflect.js → reflect.js} +7 -8
  14. package/dist/reflect.js.map +1 -0
  15. package/dist/types.d.ts +70 -0
  16. package/dist/types.js +32 -0
  17. package/dist/types.js.map +1 -0
  18. package/package.json +43 -44
  19. package/src/decorator-factory.ts +289 -140
  20. package/src/index.ts +22 -2
  21. package/src/inspector.ts +118 -126
  22. package/src/reflect.ts +32 -21
  23. package/src/types.ts +94 -0
  24. package/CHANGELOG.md +0 -99
  25. package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
  26. package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
  27. package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
  28. package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
  29. package/api-docs/apple-touch-icon-precomposed.png +0 -0
  30. package/api-docs/apple-touch-icon.png +0 -0
  31. package/api-docs/css/bootstrap.min.css +0 -9
  32. package/api-docs/css/code-themes/arta.css +0 -158
  33. package/api-docs/css/code-themes/ascetic.css +0 -50
  34. package/api-docs/css/code-themes/brown_paper.css +0 -104
  35. package/api-docs/css/code-themes/brown_papersq.png +0 -0
  36. package/api-docs/css/code-themes/dark.css +0 -103
  37. package/api-docs/css/code-themes/default.css +0 -135
  38. package/api-docs/css/code-themes/far.css +0 -111
  39. package/api-docs/css/code-themes/github.css +0 -127
  40. package/api-docs/css/code-themes/googlecode.css +0 -144
  41. package/api-docs/css/code-themes/idea.css +0 -121
  42. package/api-docs/css/code-themes/ir_black.css +0 -104
  43. package/api-docs/css/code-themes/magula.css +0 -121
  44. package/api-docs/css/code-themes/monokai.css +0 -114
  45. package/api-docs/css/code-themes/pojoaque.css +0 -104
  46. package/api-docs/css/code-themes/pojoaque.jpg +0 -0
  47. package/api-docs/css/code-themes/rainbow.css +0 -114
  48. package/api-docs/css/code-themes/school_book.css +0 -111
  49. package/api-docs/css/code-themes/school_book.png +0 -0
  50. package/api-docs/css/code-themes/sl-theme.css +0 -45
  51. package/api-docs/css/code-themes/solarized_dark.css +0 -88
  52. package/api-docs/css/code-themes/solarized_light.css +0 -88
  53. package/api-docs/css/code-themes/sunburst.css +0 -158
  54. package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
  55. package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
  56. package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
  57. package/api-docs/css/code-themes/tomorrow-night.css +0 -52
  58. package/api-docs/css/code-themes/tomorrow.css +0 -49
  59. package/api-docs/css/code-themes/vs.css +0 -86
  60. package/api-docs/css/code-themes/xcode.css +0 -154
  61. package/api-docs/css/code-themes/zenburn.css +0 -115
  62. package/api-docs/css/main.css +0 -139
  63. package/api-docs/favicon.ico +0 -0
  64. package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  65. package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  66. package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  67. package/api-docs/index.html +0 -53
  68. package/api-docs/js/main.js +0 -19
  69. package/api-docs/js/vendor/bootstrap.min.js +0 -6
  70. package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
  71. package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
  72. package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
  73. package/dist/src/decorator-factory.d.ts +0 -252
  74. package/dist/src/decorator-factory.js +0 -468
  75. package/dist/src/decorator-factory.js.map +0 -1
  76. package/dist/src/index.d.ts +0 -3
  77. package/dist/src/index.js +0 -13
  78. package/dist/src/index.js.map +0 -1
  79. package/dist/src/inspector.d.ts +0 -150
  80. package/dist/src/inspector.js +0 -163
  81. package/dist/src/inspector.js.map +0 -1
  82. package/dist/src/reflect.js.map +0 -1
  83. package/dist6/index.d.ts +0 -1
  84. package/dist6/index.js +0 -13
  85. package/dist6/src/decorator-factory.d.ts +0 -252
  86. package/dist6/src/decorator-factory.js.map +0 -1
  87. package/dist6/src/index.d.ts +0 -3
  88. package/dist6/src/index.js +0 -13
  89. package/dist6/src/index.js.map +0 -1
  90. package/dist6/src/inspector.d.ts +0 -150
  91. package/dist6/src/inspector.js +0 -163
  92. package/dist6/src/inspector.js.map +0 -1
  93. package/dist6/src/reflect.d.ts +0 -38
  94. package/dist6/src/reflect.js +0 -143
  95. package/dist6/src/reflect.js.map +0 -1
  96. package/index.d.ts +0 -6
  97. package/index.js +0 -7
@@ -1,252 +0,0 @@
1
- /**
2
- * An object mapping keys to corresponding metadata
3
- */
4
- export interface MetadataMap<T> {
5
- [propertyOrMethodName: string]: T;
6
- }
7
- /**
8
- * Options for a decorator
9
- */
10
- export interface DecoratorOptions {
11
- /**
12
- * Controls if inherited metadata will be honored. Default to `true`.
13
- */
14
- allowInheritance?: boolean;
15
- /**
16
- * Controls if the value of `spec` argument will be cloned. Sometimes we
17
- * use shared spec for the decoration, but the decorator function might need
18
- * to mutate the object. Cloning the input spec makes it safe to use the same
19
- * spec (`template`) to decorate different members.
20
- *
21
- * Default to `true`.
22
- */
23
- cloneInputSpec?: boolean;
24
- [name: string]: any;
25
- }
26
- /**
27
- * Decorator function types
28
- */
29
- export declare type DecoratorType = ClassDecorator | PropertyDecorator | MethodDecorator | ParameterDecorator;
30
- /**
31
- * Base factory class for decorator functions
32
- *
33
- * @example
34
- * ```
35
- * function classDecorator(spec: MySpec): ClassDecorator {
36
- * return ClassDecoratorFactory.createDecorator('my-key', spec);
37
- * }
38
- * ```
39
- * or
40
- * ```
41
- * function classDecorator(spec: MySpec): ClassDecorator {
42
- * const factory: ClassDecoratorFactory<MySpec>('my-key', spec);
43
- * return factory.create();
44
- * }
45
- * ```
46
- * These functions above declare `@classDecorator` that can be used as follows:
47
- * ```
48
- * @classDecorator({x: 1})
49
- * class MyController {}
50
- * ```
51
- */
52
- export declare class DecoratorFactory<T, M extends T | MetadataMap<T> | MetadataMap<T[]>, D extends DecoratorType> {
53
- protected key: string;
54
- protected spec: T;
55
- protected options: DecoratorOptions | undefined;
56
- /**
57
- * A constant to reference the target of a decoration
58
- */
59
- static TARGET: string;
60
- /**
61
- * Construct a new class decorator factory
62
- * @param key Metadata key
63
- * @param spec Metadata object from the decorator function
64
- * @param options Options for the decorator. Default to
65
- * `{allowInheritance: true}` if not provided
66
- */
67
- constructor(key: string, spec: T, options?: DecoratorOptions | undefined);
68
- protected allowInheritance(): boolean;
69
- /**
70
- * Inherit metadata from base classes. By default, this method merges base
71
- * metadata into the spec if `allowInheritance` is set to `true`. To customize
72
- * the behavior, this method can be overridden by sub classes.
73
- *
74
- * @param inheritedMetadata Metadata from base classes for the member
75
- */
76
- protected inherit(inheritedMetadata: T | undefined | null): T;
77
- /**
78
- * Get the qualified name of a decoration target. For example:
79
- * ```
80
- * class MyClass
81
- * MyClass.constructor[0] // First parameter of the constructor
82
- * MyClass.myStaticProperty
83
- * MyClass.myStaticMethod()
84
- * MyClass.myStaticMethod[0] // First parameter of the myStaticMethod
85
- * MyClass.prototype.myProperty
86
- * MyClass.prototype.myMethod()
87
- * MyClass.prototype.myMethod[1] // Second parameter of myMethod
88
- * ```
89
- * @param target Class or prototype of a class
90
- * @param member Optional property/method name
91
- * @param descriptorOrIndex Optional method descriptor or parameter index
92
- */
93
- static getTargetName(target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): string;
94
- /**
95
- * Get the number of parameters for a given constructor or method
96
- * @param target Class or the prototype
97
- * @param member Method name
98
- */
99
- static getNumberOfParameters(target: Object, member?: string | symbol): number;
100
- /**
101
- * Set a reference to the target class or prototype for a given spec if
102
- * it's an object
103
- * @param spec Metadata spec
104
- * @param target Target of the decoration. It is a class or the prototype of
105
- * a class.
106
- */
107
- withTarget(spec: T, target: Object): T;
108
- /**
109
- * Get the optional decoration target of a given spec
110
- * @param spec Metadata spec
111
- */
112
- getTarget(spec: T): any;
113
- /**
114
- * This method is called by the default implementation of the decorator
115
- * function to merge the spec argument from the decoration with the inherited
116
- * metadata for a class, all properties, all methods, or all method
117
- * parameters that are decorated by this decorator.
118
- *
119
- * It MUST be overridden by subclasses to process inherited metadata.
120
- *
121
- * @param inheritedMetadata Metadata inherited from the base classes
122
- * @param target Decoration target
123
- * @param member Optional property or method
124
- * @param descriptorOrIndex Optional parameter index or method descriptor
125
- */
126
- protected mergeWithInherited(inheritedMetadata: M, target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): M;
127
- /**
128
- * This method is called by the default implementation of the decorator
129
- * function to merge the spec argument from the decoration with the own
130
- * metadata for a class, all properties, all methods, or all method
131
- * parameters that are decorated by this decorator.
132
- *
133
- * It MUST be overridden by subclasses to process own metadata.
134
- *
135
- * @param ownMetadata Own Metadata exists locally on the target
136
- * @param target Decoration target
137
- * @param member Optional property or method
138
- * @param descriptorOrIndex Optional parameter index or method descriptor
139
- */
140
- protected mergeWithOwn(ownMetadata: M, target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): M;
141
- /**
142
- * Create a decorator function of the given type. Each sub class MUST
143
- * implement this method.
144
- */
145
- create(): D;
146
- /**
147
- * Base implementation of the decorator function
148
- * @param target Decorator target
149
- * @param member Optional property or method
150
- * @param descriptorOrIndex Optional method descriptor or parameter index
151
- */
152
- protected decorate(target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): void;
153
- /**
154
- * Create a decorator function
155
- * @param key Metadata key
156
- * @param spec Metadata object from the decorator function
157
- * @param options Options for the decorator
158
- */
159
- protected static _createDecorator<T, M extends T | MetadataMap<T> | MetadataMap<T[]>, D extends DecoratorType>(key: string, spec: T, options?: DecoratorOptions): D;
160
- static cloneDeep<T>(val: T): T;
161
- }
162
- /**
163
- * Factory for class decorators
164
- */
165
- export declare class ClassDecoratorFactory<T> extends DecoratorFactory<T, T, ClassDecorator> {
166
- protected mergeWithInherited(inheritedMetadata: T, target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): T;
167
- protected mergeWithOwn(ownMetadata: T, target: Object, member?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): T;
168
- create(): ClassDecorator;
169
- /**
170
- * Create a class decorator function
171
- * @param key Metadata key
172
- * @param spec Metadata object from the decorator function
173
- * @param options Options for the decorator
174
- */
175
- static createDecorator<T>(key: string, spec: T, options?: DecoratorOptions): ClassDecorator;
176
- }
177
- /**
178
- * Factory for property decorators
179
- */
180
- export declare class PropertyDecoratorFactory<T> extends DecoratorFactory<T, MetadataMap<T>, PropertyDecorator> {
181
- protected mergeWithInherited(inheritedMetadata: MetadataMap<T>, target: Object, propertyName?: string | symbol, descriptorOrIndex?: TypedPropertyDescriptor<any> | number): MetadataMap<T>;
182
- protected mergeWithOwn(ownMetadata: MetadataMap<T>, target: Object, propertyName?: string | symbol, descriptorOrParameterIndex?: TypedPropertyDescriptor<any> | number): MetadataMap<T>;
183
- create(): PropertyDecorator;
184
- /**
185
- * Create a property decorator function
186
- * @param key Metadata key
187
- * @param spec Metadata object from the decorator function
188
- * @param options Options for the decorator
189
- */
190
- static createDecorator<T>(key: string, spec: T, options?: DecoratorOptions): PropertyDecorator;
191
- }
192
- /**
193
- * Factory for method decorators
194
- */
195
- export declare class MethodDecoratorFactory<T> extends DecoratorFactory<T, MetadataMap<T>, MethodDecorator> {
196
- protected mergeWithInherited(inheritedMetadata: MetadataMap<T>, target: Object, methodName?: string | symbol, methodDescriptor?: TypedPropertyDescriptor<any> | number): MetadataMap<T>;
197
- protected mergeWithOwn(ownMetadata: MetadataMap<T>, target: Object, methodName?: string | symbol, methodDescriptor?: TypedPropertyDescriptor<any> | number): MetadataMap<T>;
198
- create(): MethodDecorator;
199
- /**
200
- * Create a method decorator function
201
- * @param key Metadata key
202
- * @param spec Metadata object from the decorator function
203
- * @param options Options for the decorator
204
- */
205
- static createDecorator<T>(key: string, spec: T, options?: DecoratorOptions): MethodDecorator;
206
- }
207
- /**
208
- * Factory for parameter decorators
209
- */
210
- export declare class ParameterDecoratorFactory<T> extends DecoratorFactory<T, MetadataMap<T[]>, ParameterDecorator> {
211
- private getOrInitMetadata(meta, target, methodName?);
212
- protected mergeWithInherited(inheritedMetadata: MetadataMap<T[]>, target: Object, methodName?: string | symbol, parameterIndex?: TypedPropertyDescriptor<any> | number): MetadataMap<T[]>;
213
- protected mergeWithOwn(ownMetadata: MetadataMap<T[]>, target: Object, methodName?: string | symbol, parameterIndex?: TypedPropertyDescriptor<any> | number): MetadataMap<T[]>;
214
- create(): ParameterDecorator;
215
- /**
216
- * Create a parameter decorator function
217
- * @param key Metadata key
218
- * @param spec Metadata object from the decorator function
219
- * @param options Options for the decorator
220
- */
221
- static createDecorator<T>(key: string, spec: T, options?: DecoratorOptions): ParameterDecorator;
222
- }
223
- /**
224
- * Factory for method level parameter decorator. For example, the following
225
- * code uses `@param` to declare two parameters for `greet()`.
226
- * ```ts
227
- * class MyController {
228
- * @param('name') // Parameter 0
229
- * @param('msg') // Parameter 1
230
- * greet() {}
231
- * }
232
- * ```
233
- */
234
- export declare class MethodParameterDecoratorFactory<T> extends DecoratorFactory<T, MetadataMap<T[]>, MethodDecorator> {
235
- /**
236
- * Find the corresponding parameter index for the decoration
237
- * @param target
238
- * @param methodName
239
- * @param methodDescriptor
240
- */
241
- private getParameterIndex(target, methodName?, methodDescriptor?);
242
- protected mergeWithInherited(inheritedMetadata: MetadataMap<T[]>, target: Object, methodName?: string | symbol, methodDescriptor?: TypedPropertyDescriptor<any> | number): MetadataMap<T[]>;
243
- protected mergeWithOwn(ownMetadata: MetadataMap<T[]>, target: Object, methodName?: string | symbol, methodDescriptor?: TypedPropertyDescriptor<any> | number): MetadataMap<T[]>;
244
- create(): MethodDecorator;
245
- /**
246
- * Create a method decorator function
247
- * @param key Metadata key
248
- * @param spec Metadata object from the decorator function
249
- * @param options Options for the decorator
250
- */
251
- static createDecorator<T>(key: string, spec: T, options?: DecoratorOptions): MethodDecorator;
252
- }