@alterior/annotations 3.0.0-rc.5 → 3.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/dist/annotations.js +242 -322
- package/dist/annotations.js.map +1 -1
- package/dist/annotations.test.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/sealed.js +3 -3
- package/dist/sealed.js.map +1 -1
- package/dist/test.js.map +1 -1
- package/package.json +3 -3
package/dist/annotations.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="reflect-metadata" />
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Label = exports.LabelAnnotation = exports.Annotations = exports.Annotation = exports.Mutator = exports.MetadataName = exports.AnnotationTargetError = exports.METHOD_PARAMETER_ANNOTATIONS_KEY = exports.PROPERTY_ANNOTATIONS_KEY = exports.CONSTRUCTOR_PARAMETERS_ANNOTATIONS_KEY = exports.ANNOTATIONS_KEY = void 0;
|
|
5
|
-
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
6
|
/**
|
|
7
7
|
* @alterior/annotations
|
|
8
8
|
* A class library for handling Typescript metadata decorators via "annotation" classes
|
|
@@ -10,7 +10,7 @@ var tslib_1 = require("tslib");
|
|
|
10
10
|
* (C) 2017-2019 William Lahti
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
const common_1 = require("@alterior/common");
|
|
14
14
|
// These are the properties on a class where annotation metadata is deposited
|
|
15
15
|
// when annotation decorators are executed. Note that these are intended to
|
|
16
16
|
// be compatible with Angular 6's model
|
|
@@ -22,38 +22,23 @@ exports.METHOD_PARAMETER_ANNOTATIONS_KEY = '__parameter__metadata__';
|
|
|
22
22
|
* Thrown when a caller attempts to decorate an annotation target when the
|
|
23
23
|
* annotation does not support that target.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get: function () {
|
|
43
|
-
return this._supportedTypes;
|
|
44
|
-
},
|
|
45
|
-
enumerable: false,
|
|
46
|
-
configurable: true
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(AnnotationTargetError.prototype, "annotationClass", {
|
|
49
|
-
get: function () {
|
|
50
|
-
return this._annotationClass;
|
|
51
|
-
},
|
|
52
|
-
enumerable: false,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
|
-
return AnnotationTargetError;
|
|
56
|
-
}(common_1.NotSupportedError));
|
|
25
|
+
class AnnotationTargetError extends common_1.NotSupportedError {
|
|
26
|
+
constructor(annotationClass, invalidType, supportedTypes, message) {
|
|
27
|
+
super(message || `You cannot decorate a ${invalidType} with annotation ${annotationClass.name}. Valid targets: ${supportedTypes.join(', ')}`);
|
|
28
|
+
this._invalidType = invalidType;
|
|
29
|
+
this._annotationClass = annotationClass;
|
|
30
|
+
this._supportedTypes = supportedTypes;
|
|
31
|
+
}
|
|
32
|
+
get invalidType() {
|
|
33
|
+
return this._invalidType;
|
|
34
|
+
}
|
|
35
|
+
get supportedTypes() {
|
|
36
|
+
return this._supportedTypes;
|
|
37
|
+
}
|
|
38
|
+
get annotationClass() {
|
|
39
|
+
return this._annotationClass;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
57
42
|
exports.AnnotationTargetError = AnnotationTargetError;
|
|
58
43
|
/**
|
|
59
44
|
* Create a decorator suitable for use along with an Annotation class.
|
|
@@ -64,10 +49,10 @@ exports.AnnotationTargetError = AnnotationTargetError;
|
|
|
64
49
|
*/
|
|
65
50
|
function makeDecorator(ctor, options) {
|
|
66
51
|
if (!ctor)
|
|
67
|
-
throw new Error(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
throw new Error(`Cannot create decorator: Passed class reference was undefined/null: This can happen due to circular dependencies.`);
|
|
53
|
+
let factory = null;
|
|
54
|
+
let validTargets = null;
|
|
55
|
+
let allowMultiple = false;
|
|
71
56
|
if (options) {
|
|
72
57
|
if (options.factory)
|
|
73
58
|
factory = options.factory;
|
|
@@ -77,58 +62,44 @@ function makeDecorator(ctor, options) {
|
|
|
77
62
|
allowMultiple = options.allowMultiple;
|
|
78
63
|
}
|
|
79
64
|
if (!factory)
|
|
80
|
-
factory =
|
|
81
|
-
var args = [];
|
|
82
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
83
|
-
args[_i - 1] = arguments[_i];
|
|
84
|
-
}
|
|
85
|
-
return new (ctor.bind.apply(ctor, (0, tslib_1.__spreadArray)([void 0], (0, tslib_1.__read)(args), false)))();
|
|
86
|
-
};
|
|
65
|
+
factory = (target, ...args) => new ctor(...args);
|
|
87
66
|
if (!validTargets)
|
|
88
67
|
validTargets = ['class', 'method', 'property', 'parameter'];
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
92
|
-
decoratorArgs[_i] = arguments[_i];
|
|
93
|
-
}
|
|
94
|
-
return function (target) {
|
|
68
|
+
return (...decoratorArgs) => {
|
|
69
|
+
return (target, ...args) => {
|
|
95
70
|
// Note that checking the length is not enough, because for properties
|
|
96
71
|
// two arguments are passed, but the property descriptor is `undefined`.
|
|
97
72
|
// So we make sure that we have a valid property descriptor (args[1])
|
|
98
|
-
var args = [];
|
|
99
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
100
|
-
args[_i - 1] = arguments[_i];
|
|
101
|
-
}
|
|
102
73
|
if (args.length === 2 && args[1] !== undefined) {
|
|
103
74
|
if (typeof args[1] === 'number') {
|
|
104
75
|
// Parameter decorator on a method or a constructor (methodName will be undefined)
|
|
105
|
-
|
|
106
|
-
|
|
76
|
+
let methodName = args[0];
|
|
77
|
+
let index = args[1];
|
|
107
78
|
if (!validTargets.includes('parameter'))
|
|
108
79
|
throw new AnnotationTargetError(ctor, 'parameter', validTargets);
|
|
109
80
|
if (!allowMultiple) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (existingParamAnnots.find(
|
|
113
|
-
throw new Error(
|
|
81
|
+
let existingParamDecs = Annotations.getParameterAnnotations(target, methodName, true);
|
|
82
|
+
let existingParamAnnots = existingParamDecs[index] || [];
|
|
83
|
+
if (existingParamAnnots.find(x => x.$metadataName === ctor['$metadataName']))
|
|
84
|
+
throw new Error(`Annotation ${ctor.name} can only be applied to an element once.`);
|
|
114
85
|
}
|
|
115
86
|
if (methodName) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
87
|
+
let annotation = factory({
|
|
88
|
+
type: 'parameter',
|
|
89
|
+
target,
|
|
90
|
+
propertyKey: methodName,
|
|
91
|
+
index
|
|
92
|
+
}, ...decoratorArgs);
|
|
122
93
|
if (!annotation)
|
|
123
94
|
return;
|
|
124
95
|
annotation.applyToParameter(target, methodName, index);
|
|
125
96
|
}
|
|
126
97
|
else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
98
|
+
let annotation = factory({
|
|
99
|
+
type: 'parameter',
|
|
100
|
+
target,
|
|
101
|
+
index
|
|
102
|
+
}, ...decoratorArgs);
|
|
132
103
|
if (!annotation)
|
|
133
104
|
return;
|
|
134
105
|
annotation.applyToConstructorParameter(target, index);
|
|
@@ -136,21 +107,21 @@ function makeDecorator(ctor, options) {
|
|
|
136
107
|
}
|
|
137
108
|
else {
|
|
138
109
|
// Method decorator
|
|
139
|
-
|
|
140
|
-
|
|
110
|
+
let methodName = args[0];
|
|
111
|
+
let descriptor = args[1];
|
|
141
112
|
if (!validTargets.includes('method'))
|
|
142
113
|
throw new AnnotationTargetError(ctor, 'method', validTargets);
|
|
143
114
|
if (!allowMultiple) {
|
|
144
|
-
|
|
145
|
-
if (existingAnnots.find(
|
|
146
|
-
throw new Error(
|
|
115
|
+
let existingAnnots = Annotations.getMethodAnnotations(target, methodName, true);
|
|
116
|
+
if (existingAnnots.find(x => x.$metadataName === ctor['$metadataName']))
|
|
117
|
+
throw new Error(`Annotation ${ctor.name} can only be applied to an element once.`);
|
|
147
118
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
119
|
+
let annotation = factory({
|
|
120
|
+
type: 'method',
|
|
121
|
+
target,
|
|
122
|
+
propertyKey: methodName,
|
|
123
|
+
propertyDescriptor: descriptor
|
|
124
|
+
}, ...decoratorArgs);
|
|
154
125
|
if (!annotation)
|
|
155
126
|
return;
|
|
156
127
|
annotation.applyToMethod(target, methodName);
|
|
@@ -158,19 +129,19 @@ function makeDecorator(ctor, options) {
|
|
|
158
129
|
}
|
|
159
130
|
else if (args.length >= 1) {
|
|
160
131
|
// Property decorator
|
|
161
|
-
|
|
132
|
+
let propertyKey = args[0];
|
|
162
133
|
if (!validTargets.includes('property'))
|
|
163
134
|
throw new AnnotationTargetError(ctor, 'property', validTargets);
|
|
164
135
|
if (!allowMultiple) {
|
|
165
|
-
|
|
166
|
-
if (existingAnnots.find(
|
|
167
|
-
throw new Error(
|
|
136
|
+
let existingAnnots = Annotations.getPropertyAnnotations(target, propertyKey, true);
|
|
137
|
+
if (existingAnnots.find(x => x.$metadataName === ctor['$metadataName']))
|
|
138
|
+
throw new Error(`Annotation ${ctor.name} can only be applied to an element once.`);
|
|
168
139
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
140
|
+
let annotation = factory({
|
|
141
|
+
type: 'property',
|
|
142
|
+
target,
|
|
143
|
+
propertyKey
|
|
144
|
+
}, ...decoratorArgs);
|
|
174
145
|
if (!annotation)
|
|
175
146
|
return;
|
|
176
147
|
annotation.applyToProperty(target, propertyKey);
|
|
@@ -180,27 +151,27 @@ function makeDecorator(ctor, options) {
|
|
|
180
151
|
if (!validTargets.includes('class'))
|
|
181
152
|
throw new AnnotationTargetError(ctor, 'class', validTargets);
|
|
182
153
|
if (!allowMultiple) {
|
|
183
|
-
|
|
184
|
-
if (existingAnnots.find(
|
|
185
|
-
throw new Error(
|
|
154
|
+
let existingAnnots = Annotations.getClassAnnotations(target);
|
|
155
|
+
if (existingAnnots.find(x => x.$metadataName === ctor['$metadataName']))
|
|
156
|
+
throw new Error(`Annotation ${ctor.name} can only be applied to an element once.`);
|
|
186
157
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
158
|
+
let annotation = factory({
|
|
159
|
+
type: 'class',
|
|
160
|
+
target
|
|
161
|
+
}, ...decoratorArgs);
|
|
191
162
|
if (!annotation)
|
|
192
163
|
return;
|
|
193
164
|
annotation.applyToClass(target);
|
|
194
165
|
}
|
|
195
166
|
else {
|
|
196
167
|
// Invalid, or future decorator types we don't support yet.
|
|
197
|
-
throw new Error(
|
|
168
|
+
throw new Error(`Encountered unknown decorator invocation with ${args.length + 1} parameters.`);
|
|
198
169
|
}
|
|
199
170
|
};
|
|
200
171
|
};
|
|
201
172
|
}
|
|
202
173
|
function MetadataName(name) {
|
|
203
|
-
return
|
|
174
|
+
return target => Object.defineProperty(target, '$metadataName', { value: name });
|
|
204
175
|
}
|
|
205
176
|
exports.MetadataName = MetadataName;
|
|
206
177
|
/**
|
|
@@ -210,24 +181,18 @@ exports.MetadataName = MetadataName;
|
|
|
210
181
|
*
|
|
211
182
|
* Create a mutator with Mutator.create().
|
|
212
183
|
*/
|
|
213
|
-
|
|
214
|
-
function Mutator() {
|
|
215
|
-
}
|
|
184
|
+
class Mutator {
|
|
216
185
|
/**
|
|
217
186
|
* Low-level method to ceate a new mutation decorator (mutator) based on the given function.
|
|
218
187
|
* Use `Mutator.define()` instead.
|
|
219
188
|
*/
|
|
220
|
-
|
|
189
|
+
static create(mutator, options) {
|
|
221
190
|
return Annotation.decorator(Object.assign({}, options || {}, {
|
|
222
|
-
factory:
|
|
223
|
-
|
|
224
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
225
|
-
args[_i - 1] = arguments[_i];
|
|
226
|
-
}
|
|
227
|
-
mutator.apply(void 0, (0, tslib_1.__spreadArray)([target], (0, tslib_1.__read)(args), false));
|
|
191
|
+
factory: (target, ...args) => {
|
|
192
|
+
mutator(target, ...args);
|
|
228
193
|
}
|
|
229
194
|
}));
|
|
230
|
-
}
|
|
195
|
+
}
|
|
231
196
|
/**
|
|
232
197
|
* Define a new mutation decorator (mutator).
|
|
233
198
|
* This should be called and returned from a
|
|
@@ -265,11 +230,10 @@ export function RunTwice() {
|
|
|
265
230
|
)
|
|
266
231
|
* ```
|
|
267
232
|
*/
|
|
268
|
-
|
|
233
|
+
static define(definition) {
|
|
269
234
|
return this.create(definition.invoke, definition.options)();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
}());
|
|
235
|
+
}
|
|
236
|
+
}
|
|
273
237
|
exports.Mutator = Mutator;
|
|
274
238
|
/**
|
|
275
239
|
* Represents a metadata annotation which can be applied to classes,
|
|
@@ -318,23 +282,23 @@ class ABC {
|
|
|
318
282
|
```
|
|
319
283
|
*
|
|
320
284
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
285
|
+
class Annotation {
|
|
286
|
+
constructor(props) {
|
|
323
287
|
this.$metadataName = this.constructor['$metadataName'];
|
|
324
288
|
if (!this.$metadataName || !this.$metadataName.includes(':')) {
|
|
325
|
-
throw new Error(
|
|
326
|
-
+
|
|
289
|
+
throw new Error(`You must specify a metadata name for this annotation in the form of `
|
|
290
|
+
+ ` 'mynamespace:myproperty'. You specified: '${this.$metadataName || '<none>'}'`);
|
|
327
291
|
}
|
|
328
292
|
Object.assign(this, props || {});
|
|
329
293
|
}
|
|
330
|
-
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
|
|
294
|
+
toString() {
|
|
295
|
+
return `@${this.constructor.name}`;
|
|
296
|
+
}
|
|
297
|
+
static getMetadataName() {
|
|
334
298
|
if (!this['$metadataName'])
|
|
335
|
-
throw new Error(
|
|
299
|
+
throw new Error(`Annotation subclass ${this.name} must have @MetadataName()`);
|
|
336
300
|
return this['$metadataName'];
|
|
337
|
-
}
|
|
301
|
+
}
|
|
338
302
|
/**
|
|
339
303
|
* Construct a decorator suitable for attaching annotations of the called type
|
|
340
304
|
* onto classes, constructor parameters, methods, properties, and parameters.
|
|
@@ -345,61 +309,61 @@ var Annotation = /** @class */ (function () {
|
|
|
345
309
|
* @param options Allows for specifying options which will modify the behavior of the decorator.
|
|
346
310
|
* See the DecoratorOptions documentation for more information.
|
|
347
311
|
*/
|
|
348
|
-
|
|
312
|
+
static decorator(options) {
|
|
349
313
|
if (this === Annotation) {
|
|
350
314
|
if (!options || !options.factory) {
|
|
351
|
-
throw new Error(
|
|
315
|
+
throw new Error(`When calling Annotation.decorator() to create a mutator, you must specify a factory (or use Mutator.decorator())`);
|
|
352
316
|
}
|
|
353
317
|
}
|
|
354
318
|
return makeDecorator(this, options);
|
|
355
|
-
}
|
|
319
|
+
}
|
|
356
320
|
/**
|
|
357
321
|
* Clone this annotation instance into a new one. This is not a deep copy.
|
|
358
322
|
*/
|
|
359
|
-
|
|
323
|
+
clone() {
|
|
360
324
|
return Annotations.clone(this);
|
|
361
|
-
}
|
|
325
|
+
}
|
|
362
326
|
/**
|
|
363
327
|
* Apply this annotation to a given target.
|
|
364
328
|
* @param target
|
|
365
329
|
*/
|
|
366
|
-
|
|
330
|
+
applyToClass(target) {
|
|
367
331
|
return Annotations.applyToClass(this, target);
|
|
368
|
-
}
|
|
332
|
+
}
|
|
369
333
|
/**
|
|
370
334
|
* Apply this annotation instance to the given property.
|
|
371
335
|
* @param target
|
|
372
336
|
* @param name
|
|
373
337
|
*/
|
|
374
|
-
|
|
338
|
+
applyToProperty(target, name) {
|
|
375
339
|
return Annotations.applyToProperty(this, target, name);
|
|
376
|
-
}
|
|
340
|
+
}
|
|
377
341
|
/**
|
|
378
342
|
* Apply this annotation instance to the given method.
|
|
379
343
|
* @param target
|
|
380
344
|
* @param name
|
|
381
345
|
*/
|
|
382
|
-
|
|
346
|
+
applyToMethod(target, name) {
|
|
383
347
|
return Annotations.applyToMethod(this, target, name);
|
|
384
|
-
}
|
|
348
|
+
}
|
|
385
349
|
/**
|
|
386
350
|
* Apply this annotation instance to the given method parameter.
|
|
387
351
|
* @param target
|
|
388
352
|
* @param name
|
|
389
353
|
* @param index
|
|
390
354
|
*/
|
|
391
|
-
|
|
355
|
+
applyToParameter(target, name, index) {
|
|
392
356
|
return Annotations.applyToParameter(this, target, name, index);
|
|
393
|
-
}
|
|
357
|
+
}
|
|
394
358
|
/**
|
|
395
359
|
* Apply this annotation instance to the given constructor parameter.
|
|
396
360
|
* @param target
|
|
397
361
|
* @param name
|
|
398
362
|
* @param index
|
|
399
363
|
*/
|
|
400
|
-
|
|
364
|
+
applyToConstructorParameter(target, index) {
|
|
401
365
|
return Annotations.applyToConstructorParameter(this, target, index);
|
|
402
|
-
}
|
|
366
|
+
}
|
|
403
367
|
/**
|
|
404
368
|
* Filter the given list of annotations for the ones which match this annotation class
|
|
405
369
|
* based on matching $metadataName.
|
|
@@ -407,10 +371,9 @@ var Annotation = /** @class */ (function () {
|
|
|
407
371
|
* @param this
|
|
408
372
|
* @param annotations
|
|
409
373
|
*/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
};
|
|
374
|
+
static filter(annotations) {
|
|
375
|
+
return annotations.filter(x => x.$metadataName === this.getMetadataName());
|
|
376
|
+
}
|
|
414
377
|
/**
|
|
415
378
|
* Get all instances of this annotation class attached to the given class.
|
|
416
379
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -418,11 +381,10 @@ var Annotation = /** @class */ (function () {
|
|
|
418
381
|
* @param this
|
|
419
382
|
* @param type The class to check
|
|
420
383
|
*/
|
|
421
|
-
|
|
422
|
-
var _this = this;
|
|
384
|
+
static getAllForClass(type) {
|
|
423
385
|
return Annotations.getClassAnnotations(type)
|
|
424
|
-
.filter(
|
|
425
|
-
}
|
|
386
|
+
.filter(x => x.$metadataName === this.getMetadataName());
|
|
387
|
+
}
|
|
426
388
|
/**
|
|
427
389
|
* Get a single instance of this annotation class attached to the given class.
|
|
428
390
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -431,9 +393,9 @@ var Annotation = /** @class */ (function () {
|
|
|
431
393
|
* @param this
|
|
432
394
|
* @param type
|
|
433
395
|
*/
|
|
434
|
-
|
|
396
|
+
static getForClass(type) {
|
|
435
397
|
return this.getAllForClass(type)[0];
|
|
436
|
-
}
|
|
398
|
+
}
|
|
437
399
|
/**
|
|
438
400
|
* Get all instances of this annotation class attached to the given method.
|
|
439
401
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -443,11 +405,10 @@ var Annotation = /** @class */ (function () {
|
|
|
443
405
|
* @param type The class where the method is defined
|
|
444
406
|
* @param methodName The name of the method to check
|
|
445
407
|
*/
|
|
446
|
-
|
|
447
|
-
var _this = this;
|
|
408
|
+
static getAllForMethod(type, methodName) {
|
|
448
409
|
return Annotations.getMethodAnnotations(type, methodName)
|
|
449
|
-
.filter(
|
|
450
|
-
}
|
|
410
|
+
.filter(x => x.$metadataName === this.getMetadataName());
|
|
411
|
+
}
|
|
451
412
|
/**
|
|
452
413
|
* Get one instance of this annotation class attached to the given method.
|
|
453
414
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -457,9 +418,9 @@ var Annotation = /** @class */ (function () {
|
|
|
457
418
|
* @param type The class where the method is defined
|
|
458
419
|
* @param methodName The name of the method to check
|
|
459
420
|
*/
|
|
460
|
-
|
|
421
|
+
static getForMethod(type, methodName) {
|
|
461
422
|
return this.getAllForMethod(type, methodName)[0];
|
|
462
|
-
}
|
|
423
|
+
}
|
|
463
424
|
/**
|
|
464
425
|
* Get all instances of this annotation class attached to the given property.
|
|
465
426
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -469,11 +430,10 @@ var Annotation = /** @class */ (function () {
|
|
|
469
430
|
* @param type The class where the property is defined
|
|
470
431
|
* @param propertyName The name of the property to check
|
|
471
432
|
*/
|
|
472
|
-
|
|
473
|
-
var _this = this;
|
|
433
|
+
static getAllForProperty(type, propertyName) {
|
|
474
434
|
return Annotations.getPropertyAnnotations(type, propertyName)
|
|
475
|
-
.filter(
|
|
476
|
-
}
|
|
435
|
+
.filter(x => x.$metadataName === this.getMetadataName());
|
|
436
|
+
}
|
|
477
437
|
/**
|
|
478
438
|
* Get one instance of this annotation class attached to the given property.
|
|
479
439
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -483,9 +443,9 @@ var Annotation = /** @class */ (function () {
|
|
|
483
443
|
* @param type The class where the property is defined
|
|
484
444
|
* @param propertyName The name of the property to check
|
|
485
445
|
*/
|
|
486
|
-
|
|
446
|
+
static getForProperty(type, propertyName) {
|
|
487
447
|
return this.getAllForProperty(type, propertyName)[0];
|
|
488
|
-
}
|
|
448
|
+
}
|
|
489
449
|
/**
|
|
490
450
|
* Get all instances of this annotation class attached to the parameters of the given method.
|
|
491
451
|
* If called on a subclass of Annotation, it returns only annotations that match
|
|
@@ -495,11 +455,10 @@ var Annotation = /** @class */ (function () {
|
|
|
495
455
|
* @param type The class where the method is defined
|
|
496
456
|
* @param methodName The name of the method where parameter annotations should be checked for
|
|
497
457
|
*/
|
|
498
|
-
|
|
499
|
-
var _this = this;
|
|
458
|
+
static getAllForParameters(type, methodName) {
|
|
500
459
|
return Annotations.getParameterAnnotations(type, methodName)
|
|
501
|
-
.map(
|
|
502
|
-
}
|
|
460
|
+
.map(set => (set || []).filter(x => this === Annotation ? true : (x.$metadataName === this.getMetadataName())));
|
|
461
|
+
}
|
|
503
462
|
/**
|
|
504
463
|
* Get all instances of this annotation class attached to the parameters of the constructor
|
|
505
464
|
* for the given class.
|
|
@@ -509,168 +468,159 @@ var Annotation = /** @class */ (function () {
|
|
|
509
468
|
* @param this
|
|
510
469
|
* @param type The class where constructor parameter annotations should be checked for
|
|
511
470
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
for (var i = 0, max = annotations.length; i < max; ++i)
|
|
471
|
+
static getAllForConstructorParameters(type) {
|
|
472
|
+
let finalSet = new Array(type.length).fill(undefined);
|
|
473
|
+
let annotations = Annotations.getConstructorParameterAnnotations(type)
|
|
474
|
+
.map(set => (set || []).filter(x => this === Annotation ? true : (x.$metadataName === this.getMetadataName())));
|
|
475
|
+
for (let i = 0, max = annotations.length; i < max; ++i)
|
|
518
476
|
finalSet[i] = annotations[i];
|
|
519
477
|
return finalSet;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
}());
|
|
478
|
+
}
|
|
479
|
+
}
|
|
523
480
|
exports.Annotation = Annotation;
|
|
524
481
|
/**
|
|
525
482
|
* A helper class for managing annotations
|
|
526
483
|
*/
|
|
527
|
-
|
|
528
|
-
function Annotations() {
|
|
529
|
-
}
|
|
484
|
+
class Annotations {
|
|
530
485
|
/**
|
|
531
486
|
* Copy the annotations defined for one class onto another.
|
|
532
487
|
* @param from The class to copy annotations from
|
|
533
488
|
* @param to The class to copy annotations to
|
|
534
489
|
*/
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
annotations.forEach(
|
|
538
|
-
}
|
|
490
|
+
static copyClassAnnotations(from, to) {
|
|
491
|
+
let annotations = Annotations.getClassAnnotations(from);
|
|
492
|
+
annotations.forEach(x => Annotations.applyToClass(x, to));
|
|
493
|
+
}
|
|
539
494
|
/**
|
|
540
495
|
* Apply this annotation to a given target.
|
|
541
496
|
* @param target
|
|
542
497
|
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
498
|
+
static applyToClass(annotation, target) {
|
|
499
|
+
let list = this.getOrCreateListForClass(target);
|
|
500
|
+
let clone = this.clone(annotation);
|
|
546
501
|
list.push(clone);
|
|
547
502
|
if (Reflect.getOwnMetadata) {
|
|
548
|
-
|
|
549
|
-
reflectedAnnotations.push({ toString
|
|
503
|
+
let reflectedAnnotations = Reflect.getOwnMetadata('annotations', target) || [];
|
|
504
|
+
reflectedAnnotations.push({ toString() { return `${clone.$metadataName}`; }, annotation: clone });
|
|
550
505
|
Reflect.defineMetadata('annotations', reflectedAnnotations, target);
|
|
551
506
|
}
|
|
552
507
|
return clone;
|
|
553
|
-
}
|
|
508
|
+
}
|
|
554
509
|
/**
|
|
555
510
|
* Apply this annotation instance to the given property.
|
|
556
511
|
* @param target
|
|
557
512
|
* @param name
|
|
558
513
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
514
|
+
static applyToProperty(annotation, target, name) {
|
|
515
|
+
let list = this.getOrCreateListForProperty(target, name);
|
|
516
|
+
let clone = this.clone(annotation);
|
|
562
517
|
list.push(clone);
|
|
563
518
|
if (Reflect.getOwnMetadata) {
|
|
564
|
-
|
|
565
|
-
reflectedAnnotations.push({ toString
|
|
519
|
+
let reflectedAnnotations = Reflect.getOwnMetadata('propMetadata', target, name) || [];
|
|
520
|
+
reflectedAnnotations.push({ toString() { return `${clone.$metadataName}`; }, annotation: clone });
|
|
566
521
|
Reflect.defineMetadata('propMetadata', reflectedAnnotations, target, name);
|
|
567
522
|
}
|
|
568
523
|
return clone;
|
|
569
|
-
}
|
|
524
|
+
}
|
|
570
525
|
/**
|
|
571
526
|
* Apply this annotation instance to the given method.
|
|
572
527
|
* @param target
|
|
573
528
|
* @param name
|
|
574
529
|
*/
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
530
|
+
static applyToMethod(annotation, target, name) {
|
|
531
|
+
let list = this.getOrCreateListForMethod(target, name);
|
|
532
|
+
let clone = Annotations.clone(annotation);
|
|
578
533
|
list.push(clone);
|
|
579
534
|
if (Reflect.getOwnMetadata && target.constructor) {
|
|
580
|
-
|
|
535
|
+
const meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
|
|
581
536
|
meta[name] = (meta.hasOwnProperty(name) && meta[name]) || [];
|
|
582
|
-
meta[name].unshift({ toString
|
|
537
|
+
meta[name].unshift({ toString() { return `${clone.$metadataName}`; }, annotation: clone });
|
|
583
538
|
Reflect.defineMetadata('propMetadata', meta, target.constructor);
|
|
584
539
|
}
|
|
585
540
|
return clone;
|
|
586
|
-
}
|
|
541
|
+
}
|
|
587
542
|
/**
|
|
588
543
|
* Apply this annotation instance to the given method parameter.
|
|
589
544
|
* @param target
|
|
590
545
|
* @param name
|
|
591
546
|
* @param index
|
|
592
547
|
*/
|
|
593
|
-
|
|
594
|
-
|
|
548
|
+
static applyToParameter(annotation, target, name, index) {
|
|
549
|
+
let list = this.getOrCreateListForMethodParameters(target, name);
|
|
595
550
|
while (list.length < index)
|
|
596
551
|
list.push(null);
|
|
597
|
-
|
|
598
|
-
|
|
552
|
+
let paramList = list[index] || [];
|
|
553
|
+
let clone = this.clone(annotation);
|
|
599
554
|
paramList.push(clone);
|
|
600
555
|
list[index] = paramList;
|
|
601
556
|
return clone;
|
|
602
|
-
}
|
|
557
|
+
}
|
|
603
558
|
/**
|
|
604
559
|
* Apply this annotation instance to the given constructor parameter.
|
|
605
560
|
* @param target
|
|
606
561
|
* @param name
|
|
607
562
|
* @param index
|
|
608
563
|
*/
|
|
609
|
-
|
|
610
|
-
|
|
564
|
+
static applyToConstructorParameter(annotation, target, index) {
|
|
565
|
+
let list = this.getOrCreateListForConstructorParameters(target);
|
|
611
566
|
while (list.length < index)
|
|
612
567
|
list.push(null);
|
|
613
|
-
|
|
614
|
-
|
|
568
|
+
let paramList = list[index] || [];
|
|
569
|
+
let clone = this.clone(annotation);
|
|
615
570
|
paramList.push(clone);
|
|
616
571
|
list[index] = paramList;
|
|
617
572
|
if (Reflect.getOwnMetadata) {
|
|
618
|
-
|
|
573
|
+
let parameterList = Reflect.getOwnMetadata('parameters', target) || [];
|
|
619
574
|
while (parameterList.length < index)
|
|
620
575
|
parameterList.push(null);
|
|
621
|
-
|
|
576
|
+
let parameterAnnotes = parameterList[index] || [];
|
|
622
577
|
parameterAnnotes.push(clone);
|
|
623
578
|
parameterList[index] = parameterAnnotes;
|
|
624
579
|
Reflect.defineMetadata('parameters', parameterList, target);
|
|
625
580
|
}
|
|
626
581
|
return clone;
|
|
627
|
-
}
|
|
582
|
+
}
|
|
628
583
|
/**
|
|
629
584
|
* Clone the given Annotation instance into a new instance. This is not
|
|
630
585
|
* a deep copy.
|
|
631
586
|
*
|
|
632
587
|
* @param annotation
|
|
633
588
|
*/
|
|
634
|
-
|
|
589
|
+
static clone(annotation) {
|
|
635
590
|
if (!annotation)
|
|
636
591
|
return annotation;
|
|
637
592
|
return Object.assign(Object.create(Object.getPrototypeOf(annotation)), annotation);
|
|
638
|
-
}
|
|
593
|
+
}
|
|
639
594
|
/**
|
|
640
595
|
* Get all annotations (including from Angular and other compatible
|
|
641
596
|
* frameworks).
|
|
642
597
|
*
|
|
643
598
|
* @param target The target to fetch annotations for
|
|
644
599
|
*/
|
|
645
|
-
|
|
646
|
-
var _this = this;
|
|
600
|
+
static getClassAnnotations(target) {
|
|
647
601
|
return (this.getListForClass(target) || [])
|
|
648
|
-
.map(
|
|
649
|
-
}
|
|
602
|
+
.map(x => this.clone(x));
|
|
603
|
+
}
|
|
650
604
|
/**
|
|
651
605
|
* Get all annotations (including from Angular and other compatible
|
|
652
606
|
* frameworks).
|
|
653
607
|
*
|
|
654
608
|
* @param target The target to fetch annotations for
|
|
655
609
|
*/
|
|
656
|
-
|
|
657
|
-
var _this = this;
|
|
658
|
-
if (isStatic === void 0) { isStatic = false; }
|
|
610
|
+
static getMethodAnnotations(target, methodName, isStatic = false) {
|
|
659
611
|
return (this.getListForMethod(isStatic ? target : target.prototype, methodName) || [])
|
|
660
|
-
.map(
|
|
661
|
-
}
|
|
612
|
+
.map(x => this.clone(x));
|
|
613
|
+
}
|
|
662
614
|
/**
|
|
663
615
|
* Get all annotations (including from Angular and other compatible
|
|
664
616
|
* frameworks).
|
|
665
617
|
*
|
|
666
618
|
* @param target The target to fetch annotations for
|
|
667
619
|
*/
|
|
668
|
-
|
|
669
|
-
var _this = this;
|
|
670
|
-
if (isStatic === void 0) { isStatic = false; }
|
|
620
|
+
static getPropertyAnnotations(target, methodName, isStatic = false) {
|
|
671
621
|
return (this.getListForProperty(isStatic ? target : target.prototype, methodName) || [])
|
|
672
|
-
.map(
|
|
673
|
-
}
|
|
622
|
+
.map(x => this.clone(x));
|
|
623
|
+
}
|
|
674
624
|
/**
|
|
675
625
|
* Get the annotations defined on the parameters of the given method of the given
|
|
676
626
|
* class.
|
|
@@ -680,12 +630,10 @@ var Annotations = /** @class */ (function () {
|
|
|
680
630
|
* @param isStatic Whether `type` itself (isStatic = true), or `type.prototype` (isStatic = false) should be the target.
|
|
681
631
|
* Note that passing true may indicate that the passed `type` is already the prototype of a class.
|
|
682
632
|
*/
|
|
683
|
-
|
|
684
|
-
var _this = this;
|
|
685
|
-
if (isStatic === void 0) { isStatic = false; }
|
|
633
|
+
static getParameterAnnotations(type, methodName, isStatic = false) {
|
|
686
634
|
return (this.getListForMethodParameters(isStatic ? type : type.prototype, methodName) || [])
|
|
687
|
-
.map(
|
|
688
|
-
}
|
|
635
|
+
.map(set => set ? set.map(anno => this.clone(anno)) : []);
|
|
636
|
+
}
|
|
689
637
|
/**
|
|
690
638
|
* Get the annotations defined on the parameters of the given method of the given
|
|
691
639
|
* class.
|
|
@@ -693,165 +641,137 @@ var Annotations = /** @class */ (function () {
|
|
|
693
641
|
* @param type
|
|
694
642
|
* @param methodName
|
|
695
643
|
*/
|
|
696
|
-
|
|
697
|
-
var _this = this;
|
|
644
|
+
static getConstructorParameterAnnotations(type) {
|
|
698
645
|
return (this.getListForConstructorParameters(type) || [])
|
|
699
|
-
.map(
|
|
700
|
-
}
|
|
646
|
+
.map(set => set ? set.map(anno => this.clone(anno)) : []);
|
|
647
|
+
}
|
|
701
648
|
/**
|
|
702
649
|
* Get a list of annotations for the given class.
|
|
703
650
|
* @param target
|
|
704
651
|
*/
|
|
705
|
-
|
|
652
|
+
static getListForClass(target) {
|
|
706
653
|
if (!target)
|
|
707
654
|
return [];
|
|
708
|
-
|
|
709
|
-
|
|
655
|
+
let combinedSet = [];
|
|
656
|
+
let superclass = Object.getPrototypeOf(target);
|
|
710
657
|
if (superclass && superclass !== Function)
|
|
711
658
|
combinedSet = combinedSet.concat(this.getListForClass(superclass));
|
|
712
659
|
if (target.hasOwnProperty(exports.ANNOTATIONS_KEY))
|
|
713
660
|
combinedSet = combinedSet.concat(target[exports.ANNOTATIONS_KEY] || []);
|
|
714
661
|
return combinedSet;
|
|
715
|
-
}
|
|
662
|
+
}
|
|
716
663
|
/**
|
|
717
664
|
* Get a list of own annotations for the given class, or create that list.
|
|
718
665
|
* @param target
|
|
719
666
|
*/
|
|
720
|
-
|
|
667
|
+
static getOrCreateListForClass(target) {
|
|
721
668
|
if (!target.hasOwnProperty(exports.ANNOTATIONS_KEY))
|
|
722
669
|
Object.defineProperty(target, exports.ANNOTATIONS_KEY, { enumerable: false, value: [] });
|
|
723
670
|
return target[exports.ANNOTATIONS_KEY];
|
|
724
|
-
}
|
|
671
|
+
}
|
|
725
672
|
/**
|
|
726
673
|
* Gets a map of the annotations defined on all properties of the given class/function. To get the annotations of instance fields,
|
|
727
674
|
* make sure to use `Class.prototype`, otherwise static annotations are returned.
|
|
728
675
|
*/
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
var combinedSet = mapToPopulate || {};
|
|
676
|
+
static getMapForClassProperties(target, mapToPopulate) {
|
|
677
|
+
let combinedSet = mapToPopulate || {};
|
|
732
678
|
if (!target || target === Function)
|
|
733
679
|
return combinedSet;
|
|
734
680
|
this.getMapForClassProperties(Object.getPrototypeOf(target), combinedSet);
|
|
735
681
|
if (target.hasOwnProperty(exports.PROPERTY_ANNOTATIONS_KEY)) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
var key = _c.value;
|
|
740
|
-
combinedSet[key] = (combinedSet[key] || []).concat(ownMap[key]);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
744
|
-
finally {
|
|
745
|
-
try {
|
|
746
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
747
|
-
}
|
|
748
|
-
finally { if (e_1) throw e_1.error; }
|
|
749
|
-
}
|
|
682
|
+
let ownMap = target[exports.PROPERTY_ANNOTATIONS_KEY] || {};
|
|
683
|
+
for (let key of Object.keys(ownMap))
|
|
684
|
+
combinedSet[key] = (combinedSet[key] || []).concat(ownMap[key]);
|
|
750
685
|
}
|
|
751
686
|
return combinedSet;
|
|
752
|
-
}
|
|
753
|
-
|
|
687
|
+
}
|
|
688
|
+
static getOrCreateMapForClassProperties(target) {
|
|
754
689
|
if (!target.hasOwnProperty(exports.PROPERTY_ANNOTATIONS_KEY))
|
|
755
690
|
Object.defineProperty(target, exports.PROPERTY_ANNOTATIONS_KEY, { enumerable: false, value: [] });
|
|
756
691
|
return target[exports.PROPERTY_ANNOTATIONS_KEY];
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
|
|
692
|
+
}
|
|
693
|
+
static getListForProperty(target, propertyKey) {
|
|
694
|
+
let map = this.getMapForClassProperties(target);
|
|
760
695
|
if (!map)
|
|
761
696
|
return null;
|
|
762
697
|
return map[propertyKey];
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
698
|
+
}
|
|
699
|
+
static getOrCreateListForProperty(target, propertyKey) {
|
|
700
|
+
let map = this.getOrCreateMapForClassProperties(target);
|
|
766
701
|
if (!map[propertyKey])
|
|
767
702
|
map[propertyKey] = [];
|
|
768
703
|
return map[propertyKey];
|
|
769
|
-
}
|
|
770
|
-
|
|
704
|
+
}
|
|
705
|
+
static getOrCreateListForMethod(target, methodName) {
|
|
771
706
|
return this.getOrCreateListForProperty(target, methodName);
|
|
772
|
-
}
|
|
773
|
-
|
|
707
|
+
}
|
|
708
|
+
static getListForMethod(target, methodName) {
|
|
774
709
|
return this.getListForProperty(target, methodName);
|
|
775
|
-
}
|
|
710
|
+
}
|
|
776
711
|
/**
|
|
777
712
|
* Get a map of the annotations defined on all parameters of all methods of the given class/function.
|
|
778
713
|
* To get instance methods, make sure to pass `Class.prototype`, otherwise the results are for static fields.
|
|
779
714
|
*/
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
var combinedMap = mapToPopulate || {};
|
|
715
|
+
static getMapForMethodParameters(target, mapToPopulate) {
|
|
716
|
+
let combinedMap = mapToPopulate || {};
|
|
783
717
|
if (!target || target === Function)
|
|
784
718
|
return combinedMap;
|
|
785
719
|
// superclass/prototype
|
|
786
720
|
this.getMapForMethodParameters(Object.getPrototypeOf(target), combinedMap);
|
|
787
721
|
if (target.hasOwnProperty(exports.METHOD_PARAMETER_ANNOTATIONS_KEY)) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
for (var i = 0, max = parameters.length; i < max; ++i) {
|
|
795
|
-
combinedMethodMap[i] = (combinedMethodMap[i] || []).concat(parameters[i] || []);
|
|
796
|
-
}
|
|
797
|
-
combinedMap[methodName] = combinedMethodMap;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
801
|
-
finally {
|
|
802
|
-
try {
|
|
803
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
722
|
+
let ownMap = target[exports.METHOD_PARAMETER_ANNOTATIONS_KEY] || {};
|
|
723
|
+
for (let methodName of Object.keys(ownMap)) {
|
|
724
|
+
let parameters = ownMap[methodName];
|
|
725
|
+
let combinedMethodMap = combinedMap[methodName] || [];
|
|
726
|
+
for (let i = 0, max = parameters.length; i < max; ++i) {
|
|
727
|
+
combinedMethodMap[i] = (combinedMethodMap[i] || []).concat(parameters[i] || []);
|
|
804
728
|
}
|
|
805
|
-
|
|
729
|
+
combinedMap[methodName] = combinedMethodMap;
|
|
806
730
|
}
|
|
807
731
|
}
|
|
808
732
|
return combinedMap;
|
|
809
|
-
}
|
|
810
|
-
|
|
733
|
+
}
|
|
734
|
+
static getOrCreateMapForMethodParameters(target) {
|
|
811
735
|
if (!target.hasOwnProperty(exports.METHOD_PARAMETER_ANNOTATIONS_KEY))
|
|
812
736
|
Object.defineProperty(target, exports.METHOD_PARAMETER_ANNOTATIONS_KEY, { enumerable: false, value: [] });
|
|
813
737
|
return target[exports.METHOD_PARAMETER_ANNOTATIONS_KEY];
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
738
|
+
}
|
|
739
|
+
static getListForMethodParameters(target, methodName) {
|
|
740
|
+
let map = this.getMapForMethodParameters(target);
|
|
817
741
|
if (!map)
|
|
818
742
|
return null;
|
|
819
743
|
return map[methodName];
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
744
|
+
}
|
|
745
|
+
static getOrCreateListForMethodParameters(target, methodName) {
|
|
746
|
+
let map = this.getOrCreateMapForMethodParameters(target);
|
|
823
747
|
if (!map[methodName])
|
|
824
748
|
map[methodName] = [];
|
|
825
749
|
return map[methodName];
|
|
826
|
-
}
|
|
827
|
-
|
|
750
|
+
}
|
|
751
|
+
static getOrCreateListForConstructorParameters(target) {
|
|
828
752
|
if (!target[exports.CONSTRUCTOR_PARAMETERS_ANNOTATIONS_KEY])
|
|
829
753
|
Object.defineProperty(target, exports.CONSTRUCTOR_PARAMETERS_ANNOTATIONS_KEY, { enumerable: false, value: [] });
|
|
830
754
|
return target[exports.CONSTRUCTOR_PARAMETERS_ANNOTATIONS_KEY];
|
|
831
|
-
}
|
|
832
|
-
|
|
755
|
+
}
|
|
756
|
+
static getListForConstructorParameters(target) {
|
|
833
757
|
return target[exports.CONSTRUCTOR_PARAMETERS_ANNOTATIONS_KEY];
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
}());
|
|
758
|
+
}
|
|
759
|
+
}
|
|
837
760
|
exports.Annotations = Annotations;
|
|
838
761
|
/**
|
|
839
762
|
* An annotation for attaching a label to a programmatic element.
|
|
840
763
|
* Can be queried with LabelAnnotation.getForClass() for example.
|
|
841
764
|
*/
|
|
842
|
-
|
|
843
|
-
(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
], LabelAnnotation);
|
|
853
|
-
return LabelAnnotation;
|
|
854
|
-
}(Annotation));
|
|
765
|
+
let LabelAnnotation = class LabelAnnotation extends Annotation {
|
|
766
|
+
constructor(text) {
|
|
767
|
+
super();
|
|
768
|
+
this.text = text;
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
LabelAnnotation = (0, tslib_1.__decorate)([
|
|
772
|
+
MetadataName('alterior:Label'),
|
|
773
|
+
(0, tslib_1.__metadata)("design:paramtypes", [String])
|
|
774
|
+
], LabelAnnotation);
|
|
855
775
|
exports.LabelAnnotation = LabelAnnotation;
|
|
856
776
|
exports.Label = LabelAnnotation.decorator();
|
|
857
777
|
//# sourceMappingURL=annotations.js.map
|