@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.
- package/LICENSE +1 -1
- package/README.md +273 -150
- package/dist/decorator-factory.d.ts +297 -0
- package/{dist6/src → dist}/decorator-factory.js +197 -90
- package/dist/decorator-factory.js.map +1 -0
- package/dist/index.d.ts +22 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +120 -0
- package/dist/inspector.js +186 -0
- package/dist/inspector.js.map +1 -0
- package/dist/{src/reflect.d.ts → reflect.d.ts} +16 -15
- package/dist/{src/reflect.js → reflect.js} +7 -8
- package/dist/reflect.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -44
- package/src/decorator-factory.ts +289 -140
- package/src/index.ts +22 -2
- package/src/inspector.ts +118 -126
- package/src/reflect.ts +32 -21
- package/src/types.ts +94 -0
- package/CHANGELOG.md +0 -99
- package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-precomposed.png +0 -0
- package/api-docs/apple-touch-icon.png +0 -0
- package/api-docs/css/bootstrap.min.css +0 -9
- package/api-docs/css/code-themes/arta.css +0 -158
- package/api-docs/css/code-themes/ascetic.css +0 -50
- package/api-docs/css/code-themes/brown_paper.css +0 -104
- package/api-docs/css/code-themes/brown_papersq.png +0 -0
- package/api-docs/css/code-themes/dark.css +0 -103
- package/api-docs/css/code-themes/default.css +0 -135
- package/api-docs/css/code-themes/far.css +0 -111
- package/api-docs/css/code-themes/github.css +0 -127
- package/api-docs/css/code-themes/googlecode.css +0 -144
- package/api-docs/css/code-themes/idea.css +0 -121
- package/api-docs/css/code-themes/ir_black.css +0 -104
- package/api-docs/css/code-themes/magula.css +0 -121
- package/api-docs/css/code-themes/monokai.css +0 -114
- package/api-docs/css/code-themes/pojoaque.css +0 -104
- package/api-docs/css/code-themes/pojoaque.jpg +0 -0
- package/api-docs/css/code-themes/rainbow.css +0 -114
- package/api-docs/css/code-themes/school_book.css +0 -111
- package/api-docs/css/code-themes/school_book.png +0 -0
- package/api-docs/css/code-themes/sl-theme.css +0 -45
- package/api-docs/css/code-themes/solarized_dark.css +0 -88
- package/api-docs/css/code-themes/solarized_light.css +0 -88
- package/api-docs/css/code-themes/sunburst.css +0 -158
- package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
- package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night.css +0 -52
- package/api-docs/css/code-themes/tomorrow.css +0 -49
- package/api-docs/css/code-themes/vs.css +0 -86
- package/api-docs/css/code-themes/xcode.css +0 -154
- package/api-docs/css/code-themes/zenburn.css +0 -115
- package/api-docs/css/main.css +0 -139
- package/api-docs/favicon.ico +0 -0
- package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/index.html +0 -53
- package/api-docs/js/main.js +0 -19
- package/api-docs/js/vendor/bootstrap.min.js +0 -6
- package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
- package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
- package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
- package/dist/src/decorator-factory.d.ts +0 -252
- package/dist/src/decorator-factory.js +0 -468
- package/dist/src/decorator-factory.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -13
- package/dist/src/index.js.map +0 -1
- package/dist/src/inspector.d.ts +0 -150
- package/dist/src/inspector.js +0 -163
- package/dist/src/inspector.js.map +0 -1
- package/dist/src/reflect.js.map +0 -1
- package/dist6/index.d.ts +0 -1
- package/dist6/index.js +0 -13
- package/dist6/src/decorator-factory.d.ts +0 -252
- package/dist6/src/decorator-factory.js.map +0 -1
- package/dist6/src/index.d.ts +0 -3
- package/dist6/src/index.js +0 -13
- package/dist6/src/index.js.map +0 -1
- package/dist6/src/inspector.d.ts +0 -150
- package/dist6/src/inspector.js +0 -163
- package/dist6/src/inspector.js.map +0 -1
- package/dist6/src/reflect.d.ts +0 -38
- package/dist6/src/reflect.js +0 -143
- package/dist6/src/reflect.js.map +0 -1
- package/index.d.ts +0 -6
- package/index.js +0 -7
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/metadata
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const reflect_1 = require("./reflect");
|
|
8
|
-
const _ = require("lodash");
|
|
9
|
-
const debugModule = require("debug");
|
|
10
|
-
const debug = debugModule('loopback:metadata:decorator');
|
|
11
|
-
/**
|
|
12
|
-
* Base factory class for decorator functions
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* function classDecorator(spec: MySpec): ClassDecorator {
|
|
17
|
-
* return ClassDecoratorFactory.createDecorator('my-key', spec);
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
* or
|
|
21
|
-
* ```
|
|
22
|
-
* function classDecorator(spec: MySpec): ClassDecorator {
|
|
23
|
-
* const factory: ClassDecoratorFactory<MySpec>('my-key', spec);
|
|
24
|
-
* return factory.create();
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
* These functions above declare `@classDecorator` that can be used as follows:
|
|
28
|
-
* ```
|
|
29
|
-
* @classDecorator({x: 1})
|
|
30
|
-
* class MyController {}
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
class DecoratorFactory {
|
|
34
|
-
/**
|
|
35
|
-
* Construct a new class decorator factory
|
|
36
|
-
* @param key Metadata key
|
|
37
|
-
* @param spec Metadata object from the decorator function
|
|
38
|
-
* @param options Options for the decorator. Default to
|
|
39
|
-
* `{allowInheritance: true}` if not provided
|
|
40
|
-
*/
|
|
41
|
-
constructor(key, spec, options) {
|
|
42
|
-
this.key = key;
|
|
43
|
-
this.spec = spec;
|
|
44
|
-
this.options = options;
|
|
45
|
-
this.options = Object.assign({ allowInheritance: true, cloneInputSpec: true }, options);
|
|
46
|
-
if (this.options.cloneInputSpec) {
|
|
47
|
-
this.spec = DecoratorFactory.cloneDeep(spec);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
allowInheritance() {
|
|
51
|
-
return !!(this.options && this.options.allowInheritance);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Inherit metadata from base classes. By default, this method merges base
|
|
55
|
-
* metadata into the spec if `allowInheritance` is set to `true`. To customize
|
|
56
|
-
* the behavior, this method can be overridden by sub classes.
|
|
57
|
-
*
|
|
58
|
-
* @param inheritedMetadata Metadata from base classes for the member
|
|
59
|
-
*/
|
|
60
|
-
inherit(inheritedMetadata) {
|
|
61
|
-
if (!this.allowInheritance())
|
|
62
|
-
return this.spec;
|
|
63
|
-
if (inheritedMetadata == null)
|
|
64
|
-
return this.spec;
|
|
65
|
-
if (this.spec == undefined)
|
|
66
|
-
return inheritedMetadata;
|
|
67
|
-
if (typeof inheritedMetadata !== 'object')
|
|
68
|
-
return this.spec;
|
|
69
|
-
if (Array.isArray(inheritedMetadata) || Array.isArray(this.spec)) {
|
|
70
|
-
// For arrays, we don't merge
|
|
71
|
-
return this.spec;
|
|
72
|
-
}
|
|
73
|
-
return Object.assign(inheritedMetadata, this.spec);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the qualified name of a decoration target. For example:
|
|
77
|
-
* ```
|
|
78
|
-
* class MyClass
|
|
79
|
-
* MyClass.constructor[0] // First parameter of the constructor
|
|
80
|
-
* MyClass.myStaticProperty
|
|
81
|
-
* MyClass.myStaticMethod()
|
|
82
|
-
* MyClass.myStaticMethod[0] // First parameter of the myStaticMethod
|
|
83
|
-
* MyClass.prototype.myProperty
|
|
84
|
-
* MyClass.prototype.myMethod()
|
|
85
|
-
* MyClass.prototype.myMethod[1] // Second parameter of myMethod
|
|
86
|
-
* ```
|
|
87
|
-
* @param target Class or prototype of a class
|
|
88
|
-
* @param member Optional property/method name
|
|
89
|
-
* @param descriptorOrIndex Optional method descriptor or parameter index
|
|
90
|
-
*/
|
|
91
|
-
static getTargetName(target, member, descriptorOrIndex) {
|
|
92
|
-
let name = target instanceof Function
|
|
93
|
-
? target.name
|
|
94
|
-
: `${target.constructor.name}.prototype`;
|
|
95
|
-
if (member == null && descriptorOrIndex == null) {
|
|
96
|
-
return `class ${name}`;
|
|
97
|
-
}
|
|
98
|
-
if (member == null)
|
|
99
|
-
member = 'constructor';
|
|
100
|
-
if (typeof descriptorOrIndex === 'number') {
|
|
101
|
-
// Parameter
|
|
102
|
-
name = `${name}.${member}[${descriptorOrIndex}]`;
|
|
103
|
-
}
|
|
104
|
-
else if (descriptorOrIndex != null) {
|
|
105
|
-
name = `${name}.${member}()`;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
name = `${name}.${member}`;
|
|
109
|
-
}
|
|
110
|
-
return name;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Get the number of parameters for a given constructor or method
|
|
114
|
-
* @param target Class or the prototype
|
|
115
|
-
* @param member Method name
|
|
116
|
-
*/
|
|
117
|
-
static getNumberOfParameters(target, member) {
|
|
118
|
-
if (target instanceof Function && !member) {
|
|
119
|
-
// constructor
|
|
120
|
-
return target.length;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// target[member] is a function
|
|
124
|
-
return target[member].length;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Set a reference to the target class or prototype for a given spec if
|
|
129
|
-
* it's an object
|
|
130
|
-
* @param spec Metadata spec
|
|
131
|
-
* @param target Target of the decoration. It is a class or the prototype of
|
|
132
|
-
* a class.
|
|
133
|
-
*/
|
|
134
|
-
withTarget(spec, target) {
|
|
135
|
-
if (typeof spec === 'object' && spec != null) {
|
|
136
|
-
// Add a hidden property for the `target`
|
|
137
|
-
Object.defineProperty(spec, DecoratorFactory.TARGET, {
|
|
138
|
-
value: target,
|
|
139
|
-
enumerable: false,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
return spec;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get the optional decoration target of a given spec
|
|
146
|
-
* @param spec Metadata spec
|
|
147
|
-
*/
|
|
148
|
-
getTarget(spec) {
|
|
149
|
-
if (typeof spec === 'object' && spec != null) {
|
|
150
|
-
const specWithTarget = spec;
|
|
151
|
-
return specWithTarget[DecoratorFactory.TARGET];
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
return undefined;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* This method is called by the default implementation of the decorator
|
|
159
|
-
* function to merge the spec argument from the decoration with the inherited
|
|
160
|
-
* metadata for a class, all properties, all methods, or all method
|
|
161
|
-
* parameters that are decorated by this decorator.
|
|
162
|
-
*
|
|
163
|
-
* It MUST be overridden by subclasses to process inherited metadata.
|
|
164
|
-
*
|
|
165
|
-
* @param inheritedMetadata Metadata inherited from the base classes
|
|
166
|
-
* @param target Decoration target
|
|
167
|
-
* @param member Optional property or method
|
|
168
|
-
* @param descriptorOrIndex Optional parameter index or method descriptor
|
|
169
|
-
*/
|
|
170
|
-
mergeWithInherited(inheritedMetadata, target, member, descriptorOrIndex) {
|
|
171
|
-
throw new Error('mergeWithInherited() is not implemented');
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* This method is called by the default implementation of the decorator
|
|
175
|
-
* function to merge the spec argument from the decoration with the own
|
|
176
|
-
* metadata for a class, all properties, all methods, or all method
|
|
177
|
-
* parameters that are decorated by this decorator.
|
|
178
|
-
*
|
|
179
|
-
* It MUST be overridden by subclasses to process own metadata.
|
|
180
|
-
*
|
|
181
|
-
* @param ownMetadata Own Metadata exists locally on the target
|
|
182
|
-
* @param target Decoration target
|
|
183
|
-
* @param member Optional property or method
|
|
184
|
-
* @param descriptorOrIndex Optional parameter index or method descriptor
|
|
185
|
-
*/
|
|
186
|
-
mergeWithOwn(ownMetadata, target, member, descriptorOrIndex) {
|
|
187
|
-
throw new Error('mergeWithOwn() is not implemented');
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Create a decorator function of the given type. Each sub class MUST
|
|
191
|
-
* implement this method.
|
|
192
|
-
*/
|
|
193
|
-
create() {
|
|
194
|
-
throw new Error('create() is not implemented');
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Base implementation of the decorator function
|
|
198
|
-
* @param target Decorator target
|
|
199
|
-
* @param member Optional property or method
|
|
200
|
-
* @param descriptorOrIndex Optional method descriptor or parameter index
|
|
201
|
-
*/
|
|
202
|
-
decorate(target, member, descriptorOrIndex) {
|
|
203
|
-
const targetName = DecoratorFactory.getTargetName(target, member, descriptorOrIndex);
|
|
204
|
-
let meta = reflect_1.Reflector.getOwnMetadata(this.key, target);
|
|
205
|
-
if (meta == null && this.allowInheritance()) {
|
|
206
|
-
// Clone the base metadata so that it won't be accidentally
|
|
207
|
-
// mutated by sub classes
|
|
208
|
-
meta = DecoratorFactory.cloneDeep(reflect_1.Reflector.getMetadata(this.key, target));
|
|
209
|
-
meta = this.mergeWithInherited(meta, target, member, descriptorOrIndex);
|
|
210
|
-
if (debug.enabled) {
|
|
211
|
-
debug('%s: %j', targetName, meta);
|
|
212
|
-
}
|
|
213
|
-
reflect_1.Reflector.defineMetadata(this.key, meta, target);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
meta = this.mergeWithOwn(meta, target, member, descriptorOrIndex);
|
|
217
|
-
if (debug.enabled) {
|
|
218
|
-
debug('%s: %j', targetName, meta);
|
|
219
|
-
}
|
|
220
|
-
reflect_1.Reflector.defineMetadata(this.key, meta, target);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Create a decorator function
|
|
225
|
-
* @param key Metadata key
|
|
226
|
-
* @param spec Metadata object from the decorator function
|
|
227
|
-
* @param options Options for the decorator
|
|
228
|
-
*/
|
|
229
|
-
static _createDecorator(key, spec, options) {
|
|
230
|
-
const inst = new this(key, spec, options);
|
|
231
|
-
return inst.create();
|
|
232
|
-
}
|
|
233
|
-
static cloneDeep(val) {
|
|
234
|
-
if (typeof val !== 'object')
|
|
235
|
-
return val;
|
|
236
|
-
return _.cloneDeepWith(val, v => {
|
|
237
|
-
// Do not clone functions
|
|
238
|
-
if (typeof v === 'function')
|
|
239
|
-
return v;
|
|
240
|
-
if (v &&
|
|
241
|
-
typeof v.constructor === 'function' &&
|
|
242
|
-
v.constructor.prototype === v) {
|
|
243
|
-
// Do not clone class prototype
|
|
244
|
-
return v;
|
|
245
|
-
}
|
|
246
|
-
return undefined;
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* A constant to reference the target of a decoration
|
|
252
|
-
*/
|
|
253
|
-
DecoratorFactory.TARGET = '__decoratorTarget';
|
|
254
|
-
exports.DecoratorFactory = DecoratorFactory;
|
|
255
|
-
/**
|
|
256
|
-
* Factory for class decorators
|
|
257
|
-
*/
|
|
258
|
-
class ClassDecoratorFactory extends DecoratorFactory {
|
|
259
|
-
mergeWithInherited(inheritedMetadata, target, member, descriptorOrIndex) {
|
|
260
|
-
return this.withTarget(this.inherit(inheritedMetadata), target);
|
|
261
|
-
}
|
|
262
|
-
mergeWithOwn(ownMetadata, target, member, descriptorOrIndex) {
|
|
263
|
-
if (ownMetadata != null) {
|
|
264
|
-
throw new Error('Decorator cannot be applied more than once on ' +
|
|
265
|
-
DecoratorFactory.getTargetName(target));
|
|
266
|
-
}
|
|
267
|
-
return this.withTarget(this.spec, target);
|
|
268
|
-
}
|
|
269
|
-
create() {
|
|
270
|
-
return (target) => this.decorate(target);
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Create a class decorator function
|
|
274
|
-
* @param key Metadata key
|
|
275
|
-
* @param spec Metadata object from the decorator function
|
|
276
|
-
* @param options Options for the decorator
|
|
277
|
-
*/
|
|
278
|
-
static createDecorator(key, spec, options) {
|
|
279
|
-
return super._createDecorator(key, spec, options);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
exports.ClassDecoratorFactory = ClassDecoratorFactory;
|
|
283
|
-
/**
|
|
284
|
-
* Factory for property decorators
|
|
285
|
-
*/
|
|
286
|
-
class PropertyDecoratorFactory extends DecoratorFactory {
|
|
287
|
-
mergeWithInherited(inheritedMetadata, target, propertyName, descriptorOrIndex) {
|
|
288
|
-
inheritedMetadata = inheritedMetadata || {};
|
|
289
|
-
const propertyMeta = this.withTarget(this.inherit(inheritedMetadata[propertyName]), target);
|
|
290
|
-
inheritedMetadata[propertyName] = propertyMeta;
|
|
291
|
-
return inheritedMetadata;
|
|
292
|
-
}
|
|
293
|
-
mergeWithOwn(ownMetadata, target, propertyName, descriptorOrParameterIndex) {
|
|
294
|
-
ownMetadata = ownMetadata || {};
|
|
295
|
-
if (ownMetadata[propertyName] != null) {
|
|
296
|
-
const targetName = DecoratorFactory.getTargetName(target, propertyName);
|
|
297
|
-
throw new Error('Decorator cannot be applied more than once on ' + targetName);
|
|
298
|
-
}
|
|
299
|
-
ownMetadata[propertyName] = this.withTarget(this.spec, target);
|
|
300
|
-
return ownMetadata;
|
|
301
|
-
}
|
|
302
|
-
create() {
|
|
303
|
-
return (target, propertyName) => this.decorate(target, propertyName);
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Create a property decorator function
|
|
307
|
-
* @param key Metadata key
|
|
308
|
-
* @param spec Metadata object from the decorator function
|
|
309
|
-
* @param options Options for the decorator
|
|
310
|
-
*/
|
|
311
|
-
static createDecorator(key, spec, options) {
|
|
312
|
-
return super._createDecorator(key, spec, options);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
exports.PropertyDecoratorFactory = PropertyDecoratorFactory;
|
|
316
|
-
/**
|
|
317
|
-
* Factory for method decorators
|
|
318
|
-
*/
|
|
319
|
-
class MethodDecoratorFactory extends DecoratorFactory {
|
|
320
|
-
mergeWithInherited(inheritedMetadata, target, methodName, methodDescriptor) {
|
|
321
|
-
inheritedMetadata = inheritedMetadata || {};
|
|
322
|
-
const methodMeta = this.withTarget(this.inherit(inheritedMetadata[methodName]), target);
|
|
323
|
-
inheritedMetadata[methodName] = methodMeta;
|
|
324
|
-
return inheritedMetadata;
|
|
325
|
-
}
|
|
326
|
-
mergeWithOwn(ownMetadata, target, methodName, methodDescriptor) {
|
|
327
|
-
ownMetadata = ownMetadata || {};
|
|
328
|
-
const methodMeta = ownMetadata[methodName];
|
|
329
|
-
if (this.getTarget(methodMeta) === target) {
|
|
330
|
-
throw new Error('Decorator cannot be applied more than once on ' +
|
|
331
|
-
DecoratorFactory.getTargetName(target, methodName, methodDescriptor));
|
|
332
|
-
}
|
|
333
|
-
// Set the method metadata
|
|
334
|
-
ownMetadata[methodName] = this.withTarget(this.spec, target);
|
|
335
|
-
return ownMetadata;
|
|
336
|
-
}
|
|
337
|
-
create() {
|
|
338
|
-
return (target, methodName, descriptor) => this.decorate(target, methodName, descriptor);
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Create a method decorator function
|
|
342
|
-
* @param key Metadata key
|
|
343
|
-
* @param spec Metadata object from the decorator function
|
|
344
|
-
* @param options Options for the decorator
|
|
345
|
-
*/
|
|
346
|
-
static createDecorator(key, spec, options) {
|
|
347
|
-
return super._createDecorator(key, spec, options);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
exports.MethodDecoratorFactory = MethodDecoratorFactory;
|
|
351
|
-
/**
|
|
352
|
-
* Factory for parameter decorators
|
|
353
|
-
*/
|
|
354
|
-
class ParameterDecoratorFactory extends DecoratorFactory {
|
|
355
|
-
getOrInitMetadata(meta, target, methodName) {
|
|
356
|
-
const method = methodName ? methodName : '';
|
|
357
|
-
let methodMeta = meta[method];
|
|
358
|
-
if (methodMeta == null) {
|
|
359
|
-
// Initialize the method metadata
|
|
360
|
-
methodMeta = new Array(DecoratorFactory.getNumberOfParameters(target, methodName)).fill(undefined);
|
|
361
|
-
meta[method] = methodMeta;
|
|
362
|
-
}
|
|
363
|
-
return methodMeta;
|
|
364
|
-
}
|
|
365
|
-
mergeWithInherited(inheritedMetadata, target, methodName, parameterIndex) {
|
|
366
|
-
inheritedMetadata = inheritedMetadata || {};
|
|
367
|
-
const methodMeta = this.getOrInitMetadata(inheritedMetadata, target, methodName);
|
|
368
|
-
const index = parameterIndex;
|
|
369
|
-
methodMeta[index] = this.withTarget(this.inherit(methodMeta[index]), target);
|
|
370
|
-
return inheritedMetadata;
|
|
371
|
-
}
|
|
372
|
-
mergeWithOwn(ownMetadata, target, methodName, parameterIndex) {
|
|
373
|
-
ownMetadata = ownMetadata || {};
|
|
374
|
-
// Find the method metadata
|
|
375
|
-
const methodMeta = this.getOrInitMetadata(ownMetadata, target, methodName);
|
|
376
|
-
const index = parameterIndex;
|
|
377
|
-
if (this.getTarget(methodMeta[index]) === target) {
|
|
378
|
-
throw new Error('Decorator cannot be applied more than once on ' +
|
|
379
|
-
DecoratorFactory.getTargetName(target, methodName, parameterIndex));
|
|
380
|
-
}
|
|
381
|
-
// Set the parameter metadata
|
|
382
|
-
methodMeta[index] = this.withTarget(this.inherit(methodMeta[index]), target);
|
|
383
|
-
return ownMetadata;
|
|
384
|
-
}
|
|
385
|
-
create() {
|
|
386
|
-
return (target, methodName, parameterIndex) => this.decorate(target, methodName, parameterIndex);
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Create a parameter decorator function
|
|
390
|
-
* @param key Metadata key
|
|
391
|
-
* @param spec Metadata object from the decorator function
|
|
392
|
-
* @param options Options for the decorator
|
|
393
|
-
*/
|
|
394
|
-
static createDecorator(key, spec, options) {
|
|
395
|
-
return super._createDecorator(key, spec, options);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
exports.ParameterDecoratorFactory = ParameterDecoratorFactory;
|
|
399
|
-
/**
|
|
400
|
-
* Factory for method level parameter decorator. For example, the following
|
|
401
|
-
* code uses `@param` to declare two parameters for `greet()`.
|
|
402
|
-
* ```ts
|
|
403
|
-
* class MyController {
|
|
404
|
-
* @param('name') // Parameter 0
|
|
405
|
-
* @param('msg') // Parameter 1
|
|
406
|
-
* greet() {}
|
|
407
|
-
* }
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
class MethodParameterDecoratorFactory extends DecoratorFactory {
|
|
411
|
-
/**
|
|
412
|
-
* Find the corresponding parameter index for the decoration
|
|
413
|
-
* @param target
|
|
414
|
-
* @param methodName
|
|
415
|
-
* @param methodDescriptor
|
|
416
|
-
*/
|
|
417
|
-
getParameterIndex(target, methodName, methodDescriptor) {
|
|
418
|
-
const numOfParams = DecoratorFactory.getNumberOfParameters(target, methodName);
|
|
419
|
-
// Fetch the cached parameter index
|
|
420
|
-
let index = reflect_1.Reflector.getOwnMetadata(`${this.key}:index`, target, methodName);
|
|
421
|
-
// Default to the last parameter
|
|
422
|
-
if (index == null)
|
|
423
|
-
index = numOfParams - 1;
|
|
424
|
-
if (index < 0) {
|
|
425
|
-
// Excessive decorations than the number of parameters detected
|
|
426
|
-
const method = DecoratorFactory.getTargetName(target, methodName, methodDescriptor);
|
|
427
|
-
throw new Error(`The decorator is used more than ${numOfParams} time(s) on ${method}`);
|
|
428
|
-
}
|
|
429
|
-
return index;
|
|
430
|
-
}
|
|
431
|
-
mergeWithInherited(inheritedMetadata, target, methodName, methodDescriptor) {
|
|
432
|
-
inheritedMetadata = inheritedMetadata || {};
|
|
433
|
-
const index = this.getParameterIndex(target, methodName, methodDescriptor);
|
|
434
|
-
const inheritedParams = inheritedMetadata[methodName] || new Array(index + 1).fill(undefined);
|
|
435
|
-
if (inheritedParams.length) {
|
|
436
|
-
// First time applied to a method. This is the last parameter of the method
|
|
437
|
-
inheritedParams[index] = this.withTarget(this.inherit(inheritedParams[index]), target);
|
|
438
|
-
}
|
|
439
|
-
// Cache the index to help us position the next parameter
|
|
440
|
-
reflect_1.Reflector.defineMetadata(`${this.key}:index`, index - 1, target, methodName);
|
|
441
|
-
inheritedMetadata[methodName] = inheritedParams;
|
|
442
|
-
return inheritedMetadata;
|
|
443
|
-
}
|
|
444
|
-
mergeWithOwn(ownMetadata, target, methodName, methodDescriptor) {
|
|
445
|
-
ownMetadata = ownMetadata || {};
|
|
446
|
-
const index = this.getParameterIndex(target, methodName, methodDescriptor);
|
|
447
|
-
let params = ownMetadata[methodName] || new Array(index + 1).fill(undefined);
|
|
448
|
-
params[index] = this.withTarget(this.inherit(params[index]), target);
|
|
449
|
-
ownMetadata[methodName] = params;
|
|
450
|
-
// Cache the index to help us position the next parameter
|
|
451
|
-
reflect_1.Reflector.defineMetadata(`${this.key}:index`, index - 1, target, methodName);
|
|
452
|
-
return ownMetadata;
|
|
453
|
-
}
|
|
454
|
-
create() {
|
|
455
|
-
return (target, methodName, descriptor) => this.decorate(target, methodName, descriptor);
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Create a method decorator function
|
|
459
|
-
* @param key Metadata key
|
|
460
|
-
* @param spec Metadata object from the decorator function
|
|
461
|
-
* @param options Options for the decorator
|
|
462
|
-
*/
|
|
463
|
-
static createDecorator(key, spec, options) {
|
|
464
|
-
return super._createDecorator(key, spec, options);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
exports.MethodParameterDecoratorFactory = MethodParameterDecoratorFactory;
|
|
468
|
-
//# sourceMappingURL=decorator-factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorator-factory.js","sourceRoot":"","sources":["../../src/decorator-factory.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;;AAEhE,uCAAoC;AACpC,4BAA4B;AAC5B,qCAAqC;AACrC,MAAM,KAAK,GAAG,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAwCzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAUE;;;;;;OAMG;IACH,YACY,GAAW,EACX,IAAO,EACP,OAA0B;QAF1B,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAG;QACP,YAAO,GAAP,OAAO,CAAmB;QAEpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B,EAAC,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAC,EAC9C,OAAO,CACR,CAAC;QACF,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAES,gBAAgB;QACxB,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACO,OAAO,CAAC,iBAAuC;QACvD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAC/C,EAAE,CAAC,CAAC,iBAAiB,IAAI,IAAI,CAAC;YAAC,MA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AAQ,EACnB,KAAK,GAAG,CAAC,EACT,MAAM,EACN,UAAU,CACX,CAAC;QACF,MAAM,CAAC,WAAW,CAAC;IACrB,CAAC;IAED,MAAM;QACJ,MAAM,CAAC,CACL,MAAc,EACd,UAA2B,EAC3B,UAAwC,EACxC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAI,GAAW,EAAE,IAAO,EAAE,OAA0B;QACxE,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,GAAG,EACH,IAAI,EACJ,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAnHD,0EAmHC"}
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/metadata
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
function __export(m) {
|
|
7
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
__export(require("./reflect"));
|
|
11
|
-
__export(require("./decorator-factory"));
|
|
12
|
-
__export(require("./inspector"));
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,kCAAkC;AAClC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,+BAA0B;AAC1B,yCAAoC;AACpC,iCAA4B"}
|
package/dist/src/inspector.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { NamespacedReflect } from './reflect';
|
|
2
|
-
import { MetadataMap } from './decorator-factory';
|
|
3
|
-
/**
|
|
4
|
-
* Design time metadata for a method.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* class MyController
|
|
9
|
-
* {
|
|
10
|
-
* myMethod(x: string, y: number, z: MyClass): boolean {
|
|
11
|
-
* // ...
|
|
12
|
-
* return true;
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* The `myMethod` above has design-time metadata as follows:
|
|
18
|
-
* ```ts
|
|
19
|
-
* {
|
|
20
|
-
* type: Function,
|
|
21
|
-
* parameterTypes: [String, Number, MyClass],
|
|
22
|
-
* returnType: Boolean
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export interface DesignTimeMethodMetadata {
|
|
27
|
-
/**
|
|
28
|
-
* Type of the method itself. It is `Function`
|
|
29
|
-
*/
|
|
30
|
-
type: Function;
|
|
31
|
-
/**
|
|
32
|
-
* An array of parameter types
|
|
33
|
-
*/
|
|
34
|
-
parameterTypes: Function[];
|
|
35
|
-
/**
|
|
36
|
-
* Return type
|
|
37
|
-
*/
|
|
38
|
-
returnType: Function;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Options for inspection
|
|
42
|
-
*/
|
|
43
|
-
export interface InspectionOptions {
|
|
44
|
-
/**
|
|
45
|
-
* Only inspect own metadata of a given target. The prototype chain will not
|
|
46
|
-
* be checked. The implementation uses `Reflect.getOwnMetadata()` if the flag
|
|
47
|
-
* is set to `true`. Otherwise, it uses `Reflect.getMetadata()`.
|
|
48
|
-
*
|
|
49
|
-
* The flag is `false` by default for `MetadataInspector`.
|
|
50
|
-
*/
|
|
51
|
-
ownMetadataOnly?: boolean;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Inspector for metadata applied by decorators
|
|
55
|
-
*/
|
|
56
|
-
export declare class MetadataInspector {
|
|
57
|
-
/**
|
|
58
|
-
* Expose Reflector, which is a wrapper of `Reflect` and it uses `loopback`
|
|
59
|
-
* as the namespace prefix for all metadata keys
|
|
60
|
-
*/
|
|
61
|
-
static readonly Reflector: NamespacedReflect;
|
|
62
|
-
/**
|
|
63
|
-
* Expose the reflector for TypeScript design-time metadata
|
|
64
|
-
*/
|
|
65
|
-
static readonly DesignTimeReflector: NamespacedReflect;
|
|
66
|
-
/**
|
|
67
|
-
* Get the metadata associated with the given key for a given class
|
|
68
|
-
* @param key Metadata key
|
|
69
|
-
* @param target Class that contains the metadata
|
|
70
|
-
* @param options Options for inspection
|
|
71
|
-
*/
|
|
72
|
-
static getClassMetadata<T>(key: string, target: Function, options?: InspectionOptions): T | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* Define metadata for the given target
|
|
75
|
-
* @param key Metadata key
|
|
76
|
-
* @param value Metadata value
|
|
77
|
-
* @param target Target for the metadata
|
|
78
|
-
* @param member Optional property or method name
|
|
79
|
-
*/
|
|
80
|
-
static defineMetadata<T>(key: string, value: T, target: Object, member?: string | symbol): void;
|
|
81
|
-
/**
|
|
82
|
-
* Get the metadata associated with the given key for all methods of the
|
|
83
|
-
* target class or prototype
|
|
84
|
-
* @param key Metadata key
|
|
85
|
-
* @param target Class for static methods or prototype for instance methods
|
|
86
|
-
* @param options Options for inspection
|
|
87
|
-
*/
|
|
88
|
-
static getAllMethodMetadata<T>(key: string, target: Object, options?: InspectionOptions): MetadataMap<T> | undefined;
|
|
89
|
-
/**
|
|
90
|
-
* Get the metadata associated with the given key for a given method of the
|
|
91
|
-
* target class or prototype
|
|
92
|
-
* @param key Metadata key
|
|
93
|
-
* @param target Class for static methods or prototype for instance methods
|
|
94
|
-
* @param methodName Method name. If not present, default to '' to use
|
|
95
|
-
* the constructor
|
|
96
|
-
* @param options Options for inspection
|
|
97
|
-
*/
|
|
98
|
-
static getMethodMetadata<T>(key: string, target: Object, methodName?: string | symbol, options?: InspectionOptions): T | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Get the metadata associated with the given key for all properties of the
|
|
101
|
-
* target class or prototype
|
|
102
|
-
* @param key Metadata key
|
|
103
|
-
* @param target Class for static methods or prototype for instance methods
|
|
104
|
-
* @param options Options for inspection
|
|
105
|
-
*/
|
|
106
|
-
static getAllPropertyMetadata<T>(key: string, target: Object, options?: InspectionOptions): MetadataMap<T> | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Get the metadata associated with the given key for a given property of the
|
|
109
|
-
* target class or prototype
|
|
110
|
-
* @param key Metadata key
|
|
111
|
-
* @param target Class for static properties or prototype for instance
|
|
112
|
-
* properties
|
|
113
|
-
* @param propertyName Property name
|
|
114
|
-
* @param options Options for inspection
|
|
115
|
-
*/
|
|
116
|
-
static getPropertyMetadata<T>(key: string, target: Object, propertyName: string | symbol, options?: InspectionOptions): T | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Get the metadata associated with the given key for all parameters of a
|
|
119
|
-
* given method
|
|
120
|
-
* @param key Metadata key
|
|
121
|
-
* @param target Class for static methods or prototype for instance methods
|
|
122
|
-
* @param methodName Method name. If not present, default to '' to use
|
|
123
|
-
* the constructor
|
|
124
|
-
* @param options Options for inspection
|
|
125
|
-
*/
|
|
126
|
-
static getAllParameterMetadata<T>(key: string, target: Object, methodName?: string | symbol, options?: InspectionOptions): T[] | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Get the metadata associated with the given key for a parameter of a given
|
|
129
|
-
* method by index
|
|
130
|
-
* @param key Metadata key
|
|
131
|
-
* @param target Class for static methods or prototype for instance methods
|
|
132
|
-
* @param methodName Method name. If not present, default to '' to use
|
|
133
|
-
* the constructor
|
|
134
|
-
* @param index Index of the parameter, starting with 0
|
|
135
|
-
* @param options Options for inspection
|
|
136
|
-
*/
|
|
137
|
-
static getParameterMetadata<T>(key: string, target: Object, methodName: string | symbol, index: number, options?: InspectionOptions): T | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* Get TypeScript design time type for a property
|
|
140
|
-
* @param target Class or prototype
|
|
141
|
-
* @param propertyName Property name
|
|
142
|
-
*/
|
|
143
|
-
static getDesignTypeForProperty(target: Object, propertyName: string | symbol): Function;
|
|
144
|
-
/**
|
|
145
|
-
* Get TypeScript design time type for a method
|
|
146
|
-
* @param target Class or prototype
|
|
147
|
-
* @param methodName Method name
|
|
148
|
-
*/
|
|
149
|
-
static getDesignTypeForMethod(target: Object, methodName: string | symbol): DesignTimeMethodMetadata;
|
|
150
|
-
}
|